1 /** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the mingw-w64 runtime package. 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 */ 6 #ifndef _PSAPI_H_ 7 #define _PSAPI_H_ 8 9 #include <_mingw_unicode.h> 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 #define GetModuleBaseName __MINGW_NAME_AW(GetModuleBaseName) 16 #define GetModuleFileNameEx __MINGW_NAME_AW(GetModuleFileNameEx) 17 #define GetMappedFileName __MINGW_NAME_AW(GetMappedFileName) 18 #define GetDeviceDriverBaseName __MINGW_NAME_AW(GetDeviceDriverBaseName) 19 #define GetDeviceDriverFileName __MINGW_NAME_AW(GetDeviceDriverFileName) 20 #define PENUM_PAGE_FILE_CALLBACK __MINGW_NAME_AW(PENUM_PAGE_FILE_CALLBACK) 21 #define EnumPageFiles __MINGW_NAME_AW(EnumPageFiles) 22 #define GetProcessImageFileName __MINGW_NAME_AW(GetProcessImageFileName) 23 24 #ifndef LIST_MODULES_DEFAULT 25 #define LIST_MODULES_DEFAULT 0x0 26 #endif 27 #ifndef LIST_MODULES_32BIT 28 #define LIST_MODULES_32BIT 0x01 29 #endif 30 #ifndef LIST_MODULES_64BIT 31 #define LIST_MODULES_64BIT 0x02 32 #endif 33 #ifndef LIST_MODULES_ALL 34 #define LIST_MODULES_ALL (LIST_MODULES_32BIT|LIST_MODULES_64BIT) 35 #endif 36 37 WINBOOL WINAPI EnumProcesses(DWORD *lpidProcess,DWORD cb,DWORD *cbNeeded); 38 WINBOOL WINAPI EnumProcessModules(HANDLE hProcess,HMODULE *lphModule,DWORD cb,LPDWORD lpcbNeeded); 39 DWORD WINAPI GetModuleBaseNameA(HANDLE hProcess,HMODULE hModule,LPSTR lpBaseName,DWORD nSize); 40 DWORD WINAPI GetModuleBaseNameW(HANDLE hProcess,HMODULE hModule,LPWSTR lpBaseName,DWORD nSize); 41 DWORD WINAPI GetModuleFileNameExA(HANDLE hProcess,HMODULE hModule,LPSTR lpFilename,DWORD nSize); 42 DWORD WINAPI GetModuleFileNameExW(HANDLE hProcess,HMODULE hModule,LPWSTR lpFilename,DWORD nSize); 43 44 typedef struct _MODULEINFO { 45 LPVOID lpBaseOfDll; 46 DWORD SizeOfImage; 47 LPVOID EntryPoint; 48 } MODULEINFO,*LPMODULEINFO; 49 50 WINBOOL WINAPI GetModuleInformation(HANDLE hProcess,HMODULE hModule,LPMODULEINFO lpmodinfo,DWORD cb); 51 WINBOOL WINAPI EmptyWorkingSet(HANDLE hProcess); 52 WINBOOL WINAPI QueryWorkingSet(HANDLE hProcess,PVOID pv,DWORD cb); 53 WINBOOL WINAPI QueryWorkingSetEx(HANDLE hProcess,PVOID pv,DWORD cb); 54 WINBOOL WINAPI InitializeProcessForWsWatch(HANDLE hProcess); 55 56 typedef struct _PSAPI_WS_WATCH_INFORMATION { 57 LPVOID FaultingPc; 58 LPVOID FaultingVa; 59 } PSAPI_WS_WATCH_INFORMATION,*PPSAPI_WS_WATCH_INFORMATION; 60 61 WINBOOL WINAPI GetWsChanges(HANDLE hProcess,PPSAPI_WS_WATCH_INFORMATION lpWatchInfo,DWORD cb); 62 DWORD WINAPI GetMappedFileNameW(HANDLE hProcess,LPVOID lpv,LPWSTR lpFilename,DWORD nSize); 63 DWORD WINAPI GetMappedFileNameA(HANDLE hProcess,LPVOID lpv,LPSTR lpFilename,DWORD nSize); 64 WINBOOL WINAPI EnumDeviceDrivers(LPVOID *lpImageBase,DWORD cb,LPDWORD lpcbNeeded); 65 DWORD WINAPI GetDeviceDriverBaseNameA(LPVOID ImageBase,LPSTR lpBaseName,DWORD nSize); 66 DWORD WINAPI GetDeviceDriverBaseNameW(LPVOID ImageBase,LPWSTR lpBaseName,DWORD nSize); 67 DWORD WINAPI GetDeviceDriverFileNameA(LPVOID ImageBase,LPSTR lpFilename,DWORD nSize); 68 DWORD WINAPI GetDeviceDriverFileNameW(LPVOID ImageBase,LPWSTR lpFilename,DWORD nSize); 69 70 typedef struct _PROCESS_MEMORY_COUNTERS { 71 DWORD cb; 72 DWORD PageFaultCount; 73 SIZE_T PeakWorkingSetSize; 74 SIZE_T WorkingSetSize; 75 SIZE_T QuotaPeakPagedPoolUsage; 76 SIZE_T QuotaPagedPoolUsage; 77 SIZE_T QuotaPeakNonPagedPoolUsage; 78 SIZE_T QuotaNonPagedPoolUsage; 79 SIZE_T PagefileUsage; 80 SIZE_T PeakPagefileUsage; 81 } PROCESS_MEMORY_COUNTERS; 82 typedef PROCESS_MEMORY_COUNTERS *PPROCESS_MEMORY_COUNTERS; 83 84 typedef struct _PROCESS_MEMORY_COUNTERS_EX { 85 DWORD cb; 86 DWORD PageFaultCount; 87 SIZE_T PeakWorkingSetSize; 88 SIZE_T WorkingSetSize; 89 SIZE_T QuotaPeakPagedPoolUsage; 90 SIZE_T QuotaPagedPoolUsage; 91 SIZE_T QuotaPeakNonPagedPoolUsage; 92 SIZE_T QuotaNonPagedPoolUsage; 93 SIZE_T PagefileUsage; 94 SIZE_T PeakPagefileUsage; 95 SIZE_T PrivateUsage; 96 } PROCESS_MEMORY_COUNTERS_EX; 97 typedef PROCESS_MEMORY_COUNTERS_EX *PPROCESS_MEMORY_COUNTERS_EX; 98 99 WINBOOL WINAPI GetProcessMemoryInfo(HANDLE Process,PPROCESS_MEMORY_COUNTERS ppsmemCounters,DWORD cb); 100 101 typedef struct _PERFORMANCE_INFORMATION { 102 DWORD cb; 103 SIZE_T CommitTotal; 104 SIZE_T CommitLimit; 105 SIZE_T CommitPeak; 106 SIZE_T PhysicalTotal; 107 SIZE_T PhysicalAvailable; 108 SIZE_T SystemCache; 109 SIZE_T KernelTotal; 110 SIZE_T KernelPaged; 111 SIZE_T KernelNonpaged; 112 SIZE_T PageSize; 113 DWORD HandleCount; 114 DWORD ProcessCount; 115 DWORD ThreadCount; 116 } PERFORMANCE_INFORMATION,*PPERFORMANCE_INFORMATION,PERFORMACE_INFORMATION,*PPERFORMACE_INFORMATION; 117 118 WINBOOL WINAPI GetPerformanceInfo (PPERFORMACE_INFORMATION pPerformanceInformation,DWORD cb); 119 120 typedef struct _ENUM_PAGE_FILE_INFORMATION { 121 DWORD cb; 122 DWORD Reserved; 123 SIZE_T TotalSize; 124 SIZE_T TotalInUse; 125 SIZE_T PeakUsage; 126 } ENUM_PAGE_FILE_INFORMATION,*PENUM_PAGE_FILE_INFORMATION; 127 128 typedef WINBOOL (*PENUM_PAGE_FILE_CALLBACKW) (LPVOID pContext,PENUM_PAGE_FILE_INFORMATION pPageFileInfo,LPCWSTR lpFilename); 129 typedef WINBOOL (*PENUM_PAGE_FILE_CALLBACKA) (LPVOID pContext,PENUM_PAGE_FILE_INFORMATION pPageFileInfo,LPCSTR lpFilename); 130 131 WINBOOL WINAPI EnumPageFilesW (PENUM_PAGE_FILE_CALLBACKW pCallBackRoutine,LPVOID pContext); 132 WINBOOL WINAPI EnumPageFilesA (PENUM_PAGE_FILE_CALLBACKA pCallBackRoutine,LPVOID pContext); 133 DWORD WINAPI GetProcessImageFileNameA(HANDLE hProcess,LPSTR lpImageFileName,DWORD nSize); 134 DWORD WINAPI GetProcessImageFileNameW(HANDLE hProcess,LPWSTR lpImageFileName,DWORD nSize); 135 136 typedef struct _PSAPI_WS_WATCH_INFORMATION_EX { 137 PSAPI_WS_WATCH_INFORMATION BasicInfo; 138 ULONG_PTR FaultingThreadId; 139 ULONG_PTR Flags; 140 } PSAPI_WS_WATCH_INFORMATION_EX, *PPSAPI_WS_WATCH_INFORMATION_EX; 141 142 WINBOOL WINAPI GetWsChangesEx( 143 HANDLE hProcess, 144 PPSAPI_WS_WATCH_INFORMATION_EX lpWatchInfoEx, 145 DWORD cb 146 ); 147 148 WINBOOL WINAPI EnumProcessModulesEx( 149 HANDLE hProcess, 150 HMODULE *lphModule, 151 DWORD cb, 152 LPDWORD lpcbNeeded, 153 DWORD dwFilterFlag 154 ); 155 156 typedef union _PSAPI_WORKING_SET_BLOCK { 157 ULONG_PTR Flags; 158 __C89_NAMELESS struct { 159 ULONG_PTR Protection :5; 160 ULONG_PTR ShareCount :3; 161 ULONG_PTR Shared :1; 162 ULONG_PTR Reserved :3; 163 #ifdef _WIN64 164 ULONG_PTR VirtualPage :52; 165 #else 166 ULONG_PTR VirtualPage :20; 167 #endif 168 } ; 169 } PSAPI_WORKING_SET_BLOCK, *PPSAPI_WORKING_SET_BLOCK; 170 171 typedef struct _PSAPI_WORKING_SET_INFORMATION { 172 ULONG_PTR NumberOfEntries; 173 PSAPI_WORKING_SET_BLOCK WorkingSetInfo[1]; 174 } PSAPI_WORKING_SET_INFORMATION, *PPSAPI_WORKING_SET_INFORMATION; 175 176 typedef union _PSAPI_WORKING_SET_EX_BLOCK { 177 ULONG_PTR Flags; 178 __C89_NAMELESS struct { 179 ULONG_PTR Valid :1; 180 ULONG_PTR ShareCount :3; 181 ULONG_PTR Win32Protection :11; 182 ULONG_PTR Shared :1; 183 ULONG_PTR Node :6; 184 ULONG_PTR Locked :1; 185 ULONG_PTR LargePage :1; 186 } DUMMYSTRUCTNAME; 187 } PSAPI_WORKING_SET_EX_BLOCK, *PPSAPI_WORKING_SET_EX_BLOCK; 188 189 typedef struct _PSAPI_WORKING_SET_EX_INFORMATION { 190 PVOID VirtualAddress; 191 PSAPI_WORKING_SET_EX_BLOCK VirtualAttributes; 192 } PSAPI_WORKING_SET_EX_INFORMATION, *PPSAPI_WORKING_SET_EX_INFORMATION; 193 194 #ifdef __cplusplus 195 } 196 #endif 197 #endif 198