| The Gaudi Framework v32r1 (f65d50dc)

Win32PsApi.h
Go to the documentation of this file.
1 //====================================================================
2 // Win32PsApi.h
3 //--------------------------------------------------------------------
4 //
5 // Package : System (The LHCb System service)
6 //
7 // Description: Definition of Systems internals for WIN32
8 // This file is NOT meant to be used outside this
9 // sub-package!
10 //
11 // Author : M.Frank
12 // Created : 13/11/00
13 // Changes :
14 //====================================================================
15 #ifndef GAUDI_SYSTEM_WIN32PSAPI_H
16 #define GAUDI_SYSTEM_WIN32PSAPI_H
17 #ifdef _WIN32
18 typedef struct _MODULEINFO {
19 LPVOID lpBaseOfDll;
20 DWORD SizeOfImage;
21 LPVOID EntryPoint;
22 } MODULEINFO, *LPMODULEINFO;
23 typedef struct _PSAPI_WS_WATCH_INFORMATION {
24 LPVOID FaultingPc;
25 LPVOID FaultingVa;
26 } PSAPI_WS_WATCH_INFORMATION, *PPSAPI_WS_WATCH_INFORMATION;
27 typedef struct _PROCESS_MEMORY_COUNTERS {
28 DWORD cb;
29 DWORD PageFaultCount;
30 DWORD PeakWorkingSetSize;
31 DWORD WorkingSetSize;
32 DWORD QuotaPeakPagedPoolUsage;
33 DWORD QuotaPagedPoolUsage;
34 DWORD QuotaPeakNonPagedPoolUsage;
35 DWORD QuotaNonPagedPoolUsage;
36 DWORD PagefileUsage;
37 DWORD PeakPagefileUsage;
38 } PROCESS_MEMORY_COUNTERS;
39 typedef PROCESS_MEMORY_COUNTERS* PPROCESS_MEMORY_COUNTERS;
40
41 class PsApiFunctions {
42 public:
43 bool m_isValid;
44 BOOL( WINAPI* EnumProcesses )( DWORD* lpidProcess, DWORD cb, DWORD* cbNeeded );
45 BOOL( WINAPI* EnumProcessModules )( HANDLE hProcess, HINSTANCE* lphModule, DWORD cb, LPDWORD lpcbNeeded );
46 DWORD( WINAPI* GetModuleBaseNameA )( HANDLE hProcess, HINSTANCE hModule, LPSTR lpBaseName, DWORD nSize );
47 DWORD( WINAPI* GetModuleFileNameExA )( HANDLE hProcess, HINSTANCE hModule, LPSTR lpFilename, DWORD nSize );
48 BOOL( WINAPI* GetModuleInformation )( HANDLE hProcess, HMODULE hModule, LPMODULEINFO lpmodinfo, DWORD cb );
49 BOOL( WINAPI* EmptyWorkingSet )( HANDLE hProcess );
50 BOOL( WINAPI* QueryWorkingSet )( HANDLE hProcess, PVOID pv, DWORD cb );
51 BOOL( WINAPI* InitializeProcessForWsWatch )( HANDLE hProcess );
52 BOOL( WINAPI* GetWsChanges )( HANDLE hProcess, PPSAPI_WS_WATCH_INFORMATION lpWatchInfo, DWORD cb );
53 DWORD( WINAPI* GetMappedFileNameA )( HANDLE hProcess, LPVOID lpv, LPSTR lpFilename, DWORD nSize );
54 BOOL( WINAPI* EnumDeviceDrivers )( LPVOID* lpImageBase, DWORD cb, LPDWORD lpcbNeeded );
55 DWORD( WINAPI* GetDeviceDriverBaseNameA )( LPVOID ImageBase, LPSTR lpBaseName, DWORD nSize );
56 DWORD( WINAPI* GetDeviceDriverFileNameA )( LPVOID ImageBase, LPSTR lpFilename, DWORD nSize );
57 BOOL( WINAPI* GetProcessMemoryInfo )( HANDLE Process, PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb );
58 void load( HINSTANCE handle, const char* name, void** pFunction ) {
59 *pFunction = (void*)::GetProcAddress( handle, name );
60 if ( 0 == *pFunction ) m_isValid = false;
61 }
62 bool isValid() const { return m_isValid; }
63 PsApiFunctions() {
64 m_isValid = true;
65 HINSTANCE mh = ::LoadLibrary( "PSAPI.DLL" );
66 if ( 0 == mh ) {
67 m_isValid = false;
68 } else {
69 load( mh, "EnumProcesses", (void**)&EnumProcesses );
70 load( mh, "EnumProcessModules", (void**)&EnumProcessModules );
71 load( mh, "GetModuleBaseNameA", (void**)&GetModuleBaseNameA );
72 load( mh, "GetModuleFileNameExA", (void**)&GetModuleFileNameExA );
73 load( mh, "GetModuleInformation", (void**)&GetModuleInformation );
74 load( mh, "EmptyWorkingSet", (void**)&EmptyWorkingSet );
75 load( mh, "QueryWorkingSet", (void**)&QueryWorkingSet );
76 load( mh, "InitializeProcessForWsWatch", (void**)&InitializeProcessForWsWatch );
77 load( mh, "GetWsChanges", (void**)&GetWsChanges );
78 load( mh, "GetMappedFileNameA", (void**)&GetMappedFileNameA );
79 load( mh, "EnumDeviceDrivers", (void**)&EnumDeviceDrivers );
80 load( mh, "GetDeviceDriverBaseNameA", (void**)&GetDeviceDriverBaseNameA );
81 load( mh, "GetDeviceDriverFileNameA", (void**)&GetDeviceDriverFileNameA );
82 load( mh, "GetProcessMemoryInfo", (void**)&GetProcessMemoryInfo );
83 }
84 }
85 };
86 #endif
87
88 #endif // GAUDI_SYSTEM_WIN32PSAPI_H
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
System::EntryPoint
unsigned long(* EntryPoint)(const unsigned long iid, void **ppvObject)
Definition of the "generic" DLL entry point function.
Definition: System.h:35