25 #ifndef GAUDI_SYSTEM_WIN32PSAPI_H
26 #define GAUDI_SYSTEM_WIN32PSAPI_H
28 typedef struct _MODULEINFO {
32 } MODULEINFO, *LPMODULEINFO;
33 typedef struct _PSAPI_WS_WATCH_INFORMATION {
36 } PSAPI_WS_WATCH_INFORMATION, *PPSAPI_WS_WATCH_INFORMATION;
37 typedef struct _PROCESS_MEMORY_COUNTERS {
40 DWORD PeakWorkingSetSize;
42 DWORD QuotaPeakPagedPoolUsage;
43 DWORD QuotaPagedPoolUsage;
44 DWORD QuotaPeakNonPagedPoolUsage;
45 DWORD QuotaNonPagedPoolUsage;
47 DWORD PeakPagefileUsage;
48 } PROCESS_MEMORY_COUNTERS;
49 typedef PROCESS_MEMORY_COUNTERS* PPROCESS_MEMORY_COUNTERS;
51 class PsApiFunctions {
54 BOOL( WINAPI* EnumProcesses )( DWORD* lpidProcess, DWORD cb, DWORD* cbNeeded );
55 BOOL( WINAPI* EnumProcessModules )( HANDLE hProcess, HINSTANCE* lphModule, DWORD cb, LPDWORD lpcbNeeded );
56 DWORD( WINAPI* GetModuleBaseNameA )( HANDLE hProcess, HINSTANCE hModule, LPSTR lpBaseName, DWORD nSize );
57 DWORD( WINAPI* GetModuleFileNameExA )( HANDLE hProcess, HINSTANCE hModule, LPSTR lpFilename, DWORD nSize );
58 BOOL( WINAPI* GetModuleInformation )( HANDLE hProcess, HMODULE hModule, LPMODULEINFO lpmodinfo, DWORD cb );
59 BOOL( WINAPI* EmptyWorkingSet )( HANDLE hProcess );
60 BOOL( WINAPI* QueryWorkingSet )( HANDLE hProcess, PVOID pv, DWORD cb );
61 BOOL( WINAPI* InitializeProcessForWsWatch )( HANDLE hProcess );
62 BOOL( WINAPI* GetWsChanges )( HANDLE hProcess, PPSAPI_WS_WATCH_INFORMATION lpWatchInfo, DWORD cb );
63 DWORD( WINAPI* GetMappedFileNameA )( HANDLE hProcess, LPVOID lpv, LPSTR lpFilename, DWORD nSize );
64 BOOL( WINAPI* EnumDeviceDrivers )( LPVOID* lpImageBase, DWORD cb, LPDWORD lpcbNeeded );
65 DWORD( WINAPI* GetDeviceDriverBaseNameA )( LPVOID ImageBase, LPSTR lpBaseName, DWORD nSize );
66 DWORD( WINAPI* GetDeviceDriverFileNameA )( LPVOID ImageBase, LPSTR lpFilename, DWORD nSize );
67 BOOL( WINAPI* GetProcessMemoryInfo )( HANDLE Process, PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb );
68 void load( HINSTANCE handle,
const char*
name,
void** pFunction ) {
69 *pFunction = (
void*)::GetProcAddress( handle,
name );
70 if ( 0 == *pFunction ) m_isValid =
false;
72 bool isValid()
const {
return m_isValid; }
75 HINSTANCE mh = ::LoadLibrary(
"PSAPI.DLL" );
79 load( mh,
"EnumProcesses", (
void**)&EnumProcesses );
80 load( mh,
"EnumProcessModules", (
void**)&EnumProcessModules );
81 load( mh,
"GetModuleBaseNameA", (
void**)&GetModuleBaseNameA );
82 load( mh,
"GetModuleFileNameExA", (
void**)&GetModuleFileNameExA );
83 load( mh,
"GetModuleInformation", (
void**)&GetModuleInformation );
84 load( mh,
"EmptyWorkingSet", (
void**)&EmptyWorkingSet );
85 load( mh,
"QueryWorkingSet", (
void**)&QueryWorkingSet );
86 load( mh,
"InitializeProcessForWsWatch", (
void**)&InitializeProcessForWsWatch );
87 load( mh,
"GetWsChanges", (
void**)&GetWsChanges );
88 load( mh,
"GetMappedFileNameA", (
void**)&GetMappedFileNameA );
89 load( mh,
"EnumDeviceDrivers", (
void**)&EnumDeviceDrivers );
90 load( mh,
"GetDeviceDriverBaseNameA", (
void**)&GetDeviceDriverBaseNameA );
91 load( mh,
"GetDeviceDriverFileNameA", (
void**)&GetDeviceDriverFileNameA );
92 load( mh,
"GetProcessMemoryInfo", (
void**)&GetProcessMemoryInfo );
98 #endif // GAUDI_SYSTEM_WIN32PSAPI_H