| The Gaudi Framework v28r2-patches (bc4ad17a)

- 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 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 {
63 return m_isValid;
64 }
65 PsApiFunctions() {
66 m_isValid = true;
67 HINSTANCE mh = ::LoadLibrary("PSAPI.DLL");
68 if ( 0 == mh ) {
69 m_isValid = false;
70 }
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:28
System::EntryPoint
unsigned long(* EntryPoint)(const unsigned long iid, void **ppvObject)
Definition of the "generic" DLL entry point function.
Definition: System.h:35