--- a/psutil/arch/windows/init.c +++ b/psutil/arch/windows/init.c @@ -183,6 +183,8 @@ // ==================================================================== +#ifndef __MINGW32__ + static int psutil_loadlibs() { // --- Mandatory @@ -278,6 +280,7 @@ return 0; } +#endif /* !__MINGW32__ */ static int psutil_set_winver() { @@ -309,8 +312,10 @@ // Called on module import. int psutil_setup_windows(void) { +#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 @@ -57,6 +57,8 @@ MaximumThreadState } KTHREAD_STATE, *PKTHREAD_STATE; +#ifndef __MINGW32__ + typedef enum _KWAIT_REASON { Executive, FreePage, @@ -147,6 +149,8 @@ WTSInit, // WinStation in initialization } WTS_CONNECTSTATE_CLASS; +#endif /* !_MINGW32__ */ + // ================================================================ // Structs. // ================================================================ @@ -363,6 +367,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 @@ -400,6 +407,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 { @@ -551,6 +560,8 @@ // Type defs for modules loaded at runtime. // ================================================================ +#ifndef __MINGW32__ + BOOL (WINAPI *_GetLogicalProcessorInformationEx) ( LOGICAL_PROCESSOR_RELATIONSHIP relationship, PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Buffer, @@ -711,5 +722,16 @@ #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__ // clang-format on --- a/psutil/arch/windows/sys.c +++ b/psutil/arch/windows/sys.c @@ -17,6 +17,7 @@ #include #include +#include #include "ntextapi.h" #include "../../arch/all/init.h" --- a/setup.py +++ b/setup.py @@ -319,6 +319,10 @@ "psapi", "shell32", "ws2_32", + "iphlpapi", + "ntdll", + "wtsapi32", + "mincore", ], # extra_compile_args=["/W 4"], # extra_link_args=["/DEBUG"],