diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2019-02-20 05:26:02 -0800 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2019-02-20 05:26:02 -0800 |
commit | d141020000688bb48064cb00dd0246776b89d093 (patch) | |
tree | 156b8f426d87de60f560c3328703028a9909c304 | |
parent | afc95f9473a851dfde3782ab65bf867b8c9cbc0d (diff) | |
download | psutil-d141020000688bb48064cb00dd0246776b89d093.tar.gz |
port NtWow64QueryInformationProcess64
-rw-r--r-- | psutil/arch/windows/global.c | 3 | ||||
-rw-r--r-- | psutil/arch/windows/global.h | 4 | ||||
-rw-r--r-- | psutil/arch/windows/process_info.c | 15 |
3 files changed, 11 insertions, 11 deletions
diff --git a/psutil/arch/windows/global.c b/psutil/arch/windows/global.c index f76d41d5..c45c2d7d 100644 --- a/psutil/arch/windows/global.c +++ b/psutil/arch/windows/global.c @@ -106,5 +106,8 @@ psutil_load_globals() { psutil_GetActiveProcessorCount = ps_GetProcAddress( "kernel32", "GetActiveProcessorCount"); + psutil_NtWow64QueryInformationProcess64 = psutil_GetProcAddressFromLib( + "ntdll.dll", "NtWow64QueryInformationProcess64"); + return 0; } diff --git a/psutil/arch/windows/global.h b/psutil/arch/windows/global.h index b4d7f7d7..6e608097 100644 --- a/psutil/arch/windows/global.h +++ b/psutil/arch/windows/global.h @@ -65,4 +65,8 @@ _GetTickCount64 \ _NtQueryObject \ psutil_NtQueryObject; +// XXX: just an alias; probably unnecessary +_NtQueryInformationProcess \ + psutil_NtWow64QueryInformationProcess64; + int psutil_load_globals(); diff --git a/psutil/arch/windows/process_info.c b/psutil/arch/windows/process_info.c index 5b5e8239..279b8de2 100644 --- a/psutil/arch/windows/process_info.c +++ b/psutil/arch/windows/process_info.c @@ -519,7 +519,6 @@ psutil_get_process_data(long pid, http://www.drdobbs.com/embracing-64-bit-windows/184401966 */ #ifndef _WIN64 - static _NtQueryInformationProcess NtWow64QueryInformationProcess64 = NULL; static _NtWow64ReadVirtualMemory64 NtWow64ReadVirtualMemory64 = NULL; #endif HANDLE hProcess = NULL; @@ -602,15 +601,9 @@ psutil_get_process_data(long pid, PEB64 peb64; RTL_USER_PROCESS_PARAMETERS64 procParameters64; - if (NtWow64QueryInformationProcess64 == NULL) { - NtWow64QueryInformationProcess64 = \ - psutil_GetProcAddressFromLib( - "ntdll.dll", "NtWow64QueryInformationProcess64"); - if (NtWow64QueryInformationProcess64 == NULL) { - // Too complicated. Give up. - AccessDenied("can't query 64-bit process in 32-bit-WoW mode"); - goto error; - } + if (psutil_NtWow64QueryInformationProcess64 == NULL) { + AccessDenied("can't query 64-bit process in 32-bit-WoW mode"); + goto error; } if (NtWow64ReadVirtualMemory64 == NULL) { NtWow64ReadVirtualMemory64 = \ @@ -623,7 +616,7 @@ psutil_get_process_data(long pid, } } - if (!NT_SUCCESS(NtWow64QueryInformationProcess64( + if (!NT_SUCCESS(psutil_NtWow64QueryInformationProcess64( hProcess, ProcessBasicInformation, &pbi64, |