diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-03 16:24:09 -0800 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-03 16:24:09 -0800 |
commit | b16778a759124796845d9c3ca2ada147074fda4c (patch) | |
tree | 3b8550e0d58d95ce67d28a81cef7549794dddd74 | |
parent | eb4ffe954252ce080118a9a1322b133f456163c7 (diff) | |
download | psutil-b16778a759124796845d9c3ca2ada147074fda4c.tar.gz |
fix compiler warnings; move some defss into process_info.h
-rw-r--r-- | psutil/arch/windows/process_info.c | 17 | ||||
-rw-r--r-- | psutil/arch/windows/process_info.h | 7 |
2 files changed, 11 insertions, 13 deletions
diff --git a/psutil/arch/windows/process_info.c b/psutil/arch/windows/process_info.c index 46b59149..d33008bb 100644 --- a/psutil/arch/windows/process_info.c +++ b/psutil/arch/windows/process_info.c @@ -11,18 +11,11 @@ #include <windows.h> #include "globals.h" +#include "process_info.h" #include "process_utils.h" #include "../../_psutil_common.h" -#define PSUTIL_FIRST_PROCESS(Processes) ( \ - (PSYSTEM_PROCESS_INFORMATION)(Processes)) -#define PSUTIL_NEXT_PROCESS(Process) ( \ - ((PSYSTEM_PROCESS_INFORMATION)(Process))->NextEntryOffset ? \ - (PSYSTEM_PROCESS_INFORMATION)((PCHAR)(Process) + \ - ((PSYSTEM_PROCESS_INFORMATION)(Process))->NextEntryOffset) : NULL) - - // ==================================================================== // Helper structures to access the memory correctly. // Some of these might also be defined in the winternl.h header file @@ -189,14 +182,13 @@ psutil_get_process_data(long pid, http://stackoverflow.com/a/14012919 http://www.drdobbs.com/embracing-64-bit-windows/184401966 */ - _NtQueryInformationProcess NtQueryInformationProcess = NULL; + SIZE_T size = 0; #ifndef _WIN64 static _NtQueryInformationProcess NtWow64QueryInformationProcess64 = NULL; static _NtWow64ReadVirtualMemory64 NtWow64ReadVirtualMemory64 = NULL; #endif HANDLE hProcess = NULL; LPCVOID src; - SIZE_T size; WCHAR *buffer = NULL; #ifdef _WIN64 LPVOID ppeb32 = NULL; @@ -482,7 +474,7 @@ error: */ static int psutil_cmdline_query_proc(long pid, WCHAR **pdata, SIZE_T *psize) { - HANDLE hProcess; + HANDLE hProcess = NULL; ULONG bufLen = 0; NTSTATUS status; char * buffer = NULL; @@ -509,9 +501,8 @@ psutil_cmdline_query_proc(long pid, WCHAR **pdata, SIZE_T *psize) { 0, &bufLen); - // 0xC0000225 == STATUS_NOT_FOUND, see: // https://github.com/giampaolo/psutil/issues/1501 - if (status == 0xC0000225) { + if (status == STATUS_NOT_FOUND) { AccessDenied("NtQueryInformationProcess(ProcessBasicInformation) -> " "STATUS_NOT_FOUND translated into PermissionError"); goto error; diff --git a/psutil/arch/windows/process_info.h b/psutil/arch/windows/process_info.h index 20535669..5fe342b3 100644 --- a/psutil/arch/windows/process_info.h +++ b/psutil/arch/windows/process_info.h @@ -6,6 +6,13 @@ #include <Python.h> +#define PSUTIL_FIRST_PROCESS(Processes) ( \ + (PSYSTEM_PROCESS_INFORMATION)(Processes)) +#define PSUTIL_NEXT_PROCESS(Process) ( \ + ((PSYSTEM_PROCESS_INFORMATION)(Process))->NextEntryOffset ? \ + (PSYSTEM_PROCESS_INFORMATION)((PCHAR)(Process) + \ + ((PSYSTEM_PROCESS_INFORMATION)(Process))->NextEntryOffset) : NULL) + int psutil_get_proc_info(DWORD pid, PSYSTEM_PROCESS_INFORMATION *retProcess, PVOID *retBuffer); PyObject* psutil_get_cmdline(long pid, int use_peb); |