| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 {
43 public:
44 bool m_isValid;
45 BOOL( WINAPI* EnumProcesses )( DWORD* lpidProcess, DWORD cb, DWORD* cbNeeded );
46 BOOL( WINAPI* EnumProcessModules )( HANDLE hProcess, HINSTANCE* lphModule, DWORD cb, LPDWORD lpcbNeeded );
47 DWORD( WINAPI* GetModuleBaseNameA )( HANDLE hProcess, HINSTANCE hModule, LPSTR lpBaseName, DWORD nSize );
48 DWORD( WINAPI* GetModuleFileNameExA )( HANDLE hProcess, HINSTANCE hModule, LPSTR lpFilename, DWORD nSize );
49 BOOL( WINAPI* GetModuleInformation )( HANDLE hProcess, HMODULE hModule, LPMODULEINFO lpmodinfo, DWORD cb );
50 BOOL( WINAPI* EmptyWorkingSet )( HANDLE hProcess );
51 BOOL( WINAPI* QueryWorkingSet )( HANDLE hProcess, PVOID pv, DWORD cb );
52 BOOL( WINAPI* InitializeProcessForWsWatch )( HANDLE hProcess );
53 BOOL( WINAPI* GetWsChanges )( HANDLE hProcess, PPSAPI_WS_WATCH_INFORMATION lpWatchInfo, DWORD cb );
54 DWORD( WINAPI* GetMappedFileNameA )( HANDLE hProcess, LPVOID lpv, LPSTR lpFilename, DWORD nSize );
55 BOOL( WINAPI* EnumDeviceDrivers )( LPVOID* lpImageBase, DWORD cb, LPDWORD lpcbNeeded );
56 DWORD( WINAPI* GetDeviceDriverBaseNameA )( LPVOID ImageBase, LPSTR lpBaseName, DWORD nSize );
57 DWORD( WINAPI* GetDeviceDriverFileNameA )( LPVOID ImageBase, LPSTR lpFilename, DWORD nSize );
58 BOOL( WINAPI* GetProcessMemoryInfo )( HANDLE Process, PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb );
59 void load( HINSTANCE handle, const char* name, void** pFunction )
60 {
61 *pFunction = (void*)::GetProcAddress( handle, name );
62 if ( 0 == *pFunction ) m_isValid = false;
63 }
64 bool isValid() const { return m_isValid; }
65 PsApiFunctions()
66 {
67 m_isValid = true;
68 HINSTANCE mh = ::LoadLibrary( "PSAPI.DLL" );
69 if ( 0 == mh ) {
70 m_isValid = false;
71 } else {
72 load( mh, "EnumProcesses", (void**)&EnumProcesses );
73 load( mh, "EnumProcessModules", (void**)&EnumProcessModules );
74 load( mh, "GetModuleBaseNameA", (void**)&GetModuleBaseNameA );
75 load( mh, "GetModuleFileNameExA", (void**)&GetModuleFileNameExA );
76 load( mh, "GetModuleInformation", (void**)&GetModuleInformation );
77 load( mh, "EmptyWorkingSet", (void**)&EmptyWorkingSet );
78 load( mh, "QueryWorkingSet", (void**)&QueryWorkingSet );
79 load( mh, "InitializeProcessForWsWatch", (void**)&InitializeProcessForWsWatch );
80 load( mh, "GetWsChanges", (void**)&GetWsChanges );
81 load( mh, "GetMappedFileNameA", (void**)&GetMappedFileNameA );
82 load( mh, "EnumDeviceDrivers", (void**)&EnumDeviceDrivers );
83 load( mh, "GetDeviceDriverBaseNameA", (void**)&GetDeviceDriverBaseNameA );
84 load( mh, "GetDeviceDriverFileNameA", (void**)&GetDeviceDriverFileNameA );
85 load( mh, "GetProcessMemoryInfo", (void**)&GetProcessMemoryInfo );
86 }
87 }
88 };
89 #endif
90
91 #endif // GAUDI_SYSTEM_WIN32PSAPI_H
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
System::EntryPoint
unsigned long(* EntryPoint)(const unsigned long iid, void **ppvObject)
Definition of the "generic" DLL entry point function.
Definition: System.h:36