blob: dbbfab9ddb9e2f26932444d58d3f27410444ff4e [file] [log] [blame]
--- a/psutil/_psutil_common.c
+++ b/psutil/_psutil_common.c
@@ -272,6 +272,8 @@
}
+#ifndef __MINGW32__
+
static int
psutil_loadlibs() {
// --- Mandatory
@@ -351,6 +353,7 @@
return 0;
}
+#endif /* !__MINGW32__ */
static int
psutil_set_winver() {
@@ -381,8 +384,10 @@
int
psutil_load_globals() {
+#ifndef __MINGW32__
if (psutil_loadlibs() != 0)
return 1;
+#endif
if (psutil_set_winver() != 0)
return 1;
GetSystemInfo(&PSUTIL_SYSTEM_INFO);
--- a/psutil/_psutil_windows.c
+++ b/psutil/_psutil_windows.c
@@ -19,6 +19,8 @@
#include <Python.h>
#include <windows.h>
+#include <winternl.h>
+#include <wtsapi32.h>
#include <Psapi.h> // memory_info(), memory_maps()
#include <signal.h>
#include <tlhelp32.h> // threads(), PROCESSENTRY32
@@ -1215,6 +1217,7 @@
if (py_retlist == NULL)
return NULL;
+#ifndef __MINGW32__
if (WTSEnumerateSessionsW == NULL ||
WTSQuerySessionInformationW == NULL ||
WTSFreeMemory == NULL) {
@@ -1223,6 +1226,7 @@
// https://docs.microsoft.com/en-us/windows/win32/termserv/run-time-linking-to-wtsapi32-dll
return py_retlist;
}
+#endif /* !__MINGW32__ */
if (WTSEnumerateSessionsW(hServer, 0, 1, &sessions, &count) == 0) {
if (ERROR_CALL_NOT_IMPLEMENTED == GetLastError()) {
--- 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_phys()
#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/setup.py
+++ b/setup.py
@@ -176,7 +176,7 @@
define_macros=macros,
libraries=[
"psapi", "kernel32", "advapi32", "shell32", "netapi32",
- "ws2_32", "PowrProf", "pdh",
+ "ws2_32", "powrprof", "pdh", "iphlpapi", "ntdll", "wtsapi32",
],
# extra_compile_args=["/W 4"],
# extra_link_args=["/DEBUG"]