--- a/psutil/_psutil_common.c +++ b/psutil/_psutil_common.c @@ -288,6 +288,8 @@ } +#ifndef __MINGW32__ + static int psutil_loadlibs() { // --- Mandatory @@ -367,6 +369,7 @@ return 0; } +#endif /* !__MINGW32__ */ static int psutil_set_winver() { @@ -439,8 +442,10 @@ PSUTIL_DEBUG = 1; #ifdef PSUTIL_WINDOWS +#ifndef __MINGW32__ if (psutil_loadlibs() != 0) return 1; +#endif if (psutil_set_winver() != 0) return 1; GetSystemInfo(&PSUTIL_SYSTEM_INFO); --- a/psutil/arch/windows/ntextapi.h +++ b/psutil/arch/windows/ntextapi.h @@ -56,6 +56,8 @@ MaximumThreadState } KTHREAD_STATE, *PKTHREAD_STATE; +#ifndef __MINGW32__ + typedef enum _KWAIT_REASON { Executive, FreePage, @@ -146,6 +148,8 @@ WTSInit, // WinStation in initialization } WTS_CONNECTSTATE_CLASS; +#endif /* !_MINGW32__ */ + // ================================================================ // Structs. // ================================================================ @@ -362,6 +366,9 @@ } RTL_USER_PROCESS_PARAMETERS_, *PRTL_USER_PROCESS_PARAMETERS_; // users() + +#ifndef __MINGW32__ + typedef struct _WTS_SESSION_INFOW { DWORD SessionId; // session id LPWSTR pWinStationName; // name of WinStation this session is @@ -399,6 +406,8 @@ #define PWTSINFO PWTSINFOW +#endif /* !__MINGW32__ */ + // cpu_count_cores() #if (_WIN32_WINNT < 0x0601) // Windows < 7 (Vista and XP) typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { @@ -550,6 +559,8 @@ // Type defs for modules loaded at runtime. // ================================================================ +#ifndef __MINGW32__ + BOOL (WINAPI *_GetLogicalProcessorInformationEx) ( LOGICAL_PROCESSOR_RELATIONSHIP relationship, PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Buffer, @@ -704,4 +715,15 @@ #define RtlNtStatusToDosErrorNoTeb _RtlNtStatusToDosErrorNoTeb + +#else /* __MINGW32__ */ + +ULONG WINAPI RtlNtStatusToDosErrorNoTeb(NTSTATUS status); +NTSTATUS WINAPI RtlGetVersion(PRTL_OSVERSIONINFOW lpVersionInformation); +NTSTATUS WINAPI NtQueryVirtualMemory(HANDLE ProcessHandle, PVOID BaseAddress, int MemoryInformationClass, PVOID MemoryInformation, SIZE_T MemoryInformationLength, PSIZE_T ReturnLength); +NTSTATUS WINAPI NtResumeProcess(HANDLE hProcess); +NTSTATUS WINAPI NtSuspendProcess(HANDLE hProcess); + +#endif /* !__MINGW32__ */ + #endif // __NTEXTAPI_H__ --- a/psutil/arch/windows/sys.c +++ b/psutil/arch/windows/sys.c @@ -15,6 +15,7 @@ #include #include +#include #include "ntextapi.h" #include "../../_psutil_common.h" --- a/setup.py +++ b/setup.py @@ -240,6 +240,9 @@ "ws2_32", "PowrProf", "pdh", + "iphlpapi", + "ntdll", + "wtsapi32", ], # extra_compile_args=["/W 4"], # extra_link_args=["/DEBUG"],