1 /***********************************************************************\ 2 * psapi.d * 3 * * 4 * Windows API header module * 5 * * 6 * Translated from MinGW Windows headers * 7 * * 8 * Placed into public domain * 9 \***********************************************************************/ 10 /* Comment from MinGW 11 * Process status API (PSAPI) 12 * http://windowssdk.msdn.microsoft.com/library/ms684884.aspx 13 */ 14 15 module win32.psapi; 16 version(Windows): 17 18 private import win32.w32api; 19 private import win32.winbase; 20 private import win32.windef; 21 22 struct MODULEINFO { 23 LPVOID lpBaseOfDll; 24 DWORD SizeOfImage; 25 LPVOID EntryPoint; 26 } 27 alias MODULEINFO* LPMODULEINFO; 28 29 struct PSAPI_WS_WATCH_INFORMATION { 30 LPVOID FaultingPc; 31 LPVOID FaultingVa; 32 } 33 alias PSAPI_WS_WATCH_INFORMATION* PPSAPI_WS_WATCH_INFORMATION; 34 35 struct PSAPI_WS_WATCH_INFORMATION_EX { 36 PSAPI_WS_WATCH_INFORMATION BasicInfo; 37 ULONG_PTR FaultingThreadId; 38 ULONG_PTR Flags; 39 } 40 alias PSAPI_WS_WATCH_INFORMATION_EX* PPSAPI_WS_WATCH_INFORMATION_EX; 41 42 struct PROCESS_MEMORY_COUNTERS { 43 DWORD cb; 44 DWORD PageFaultCount; 45 DWORD PeakWorkingSetSize; 46 DWORD WorkingSetSize; 47 DWORD QuotaPeakPagedPoolUsage; 48 DWORD QuotaPagedPoolUsage; 49 DWORD QuotaPeakNonPagedPoolUsage; 50 DWORD QuotaNonPagedPoolUsage; 51 DWORD PagefileUsage; 52 DWORD PeakPagefileUsage; 53 } 54 alias PROCESS_MEMORY_COUNTERS* PPROCESS_MEMORY_COUNTERS; 55 56 struct PERFORMANCE_INFORMATION { 57 DWORD cb; 58 SIZE_T CommitTotal; 59 SIZE_T CommitLimit; 60 SIZE_T CommitPeak; 61 SIZE_T PhysicalTotal; 62 SIZE_T PhysicalAvailable; 63 SIZE_T SystemCache; 64 SIZE_T KernelTotal; 65 SIZE_T KernelPaged; 66 SIZE_T KernelNonpaged; 67 SIZE_T PageSize; 68 DWORD HandleCount; 69 DWORD ProcessCount; 70 DWORD ThreadCount; 71 } 72 alias PERFORMANCE_INFORMATION* PPERFORMANCE_INFORMATION; 73 74 struct ENUM_PAGE_FILE_INFORMATION { 75 DWORD cb; 76 DWORD Reserved; 77 SIZE_T TotalSize; 78 SIZE_T TotalInUse; 79 SIZE_T PeakUsage; 80 } 81 alias ENUM_PAGE_FILE_INFORMATION* PENUM_PAGE_FILE_INFORMATION; 82 83 /* application-defined callback function used with the EnumPageFiles() 84 * http://windowssdk.msdn.microsoft.com/library/ms682627.aspx */ 85 version (Unicode) { 86 alias BOOL function(LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCWSTR) 87 PENUM_PAGE_FILE_CALLBACK; 88 } else { 89 alias BOOL function(LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCSTR) 90 PENUM_PAGE_FILE_CALLBACK; 91 } 92 93 // Grouped by application, not in alphabetical order. 94 extern (Windows) { 95 /* Process Information 96 * http://windowssdk.msdn.microsoft.com/library/ms684870.aspx */ 97 BOOL EnumProcesses(DWORD*, DWORD, DWORD*); /* NT/2000/XP/Server2003/Vista/Longhorn */ 98 DWORD GetProcessImageFileNameA(HANDLE, LPSTR, DWORD); /* XP/Server2003/Vista/Longhorn */ 99 DWORD GetProcessImageFileNameW(HANDLE, LPWSTR, DWORD); /* XP/Server2003/Vista/Longhorn */ 100 101 /* Module Information 102 * http://windowssdk.msdn.microsoft.com/library/ms684232.aspx */ 103 BOOL EnumProcessModules(HANDLE, HMODULE*, DWORD, LPDWORD); 104 BOOL EnumProcessModulesEx(HANDLE, HMODULE*, DWORD, LPDWORD, DWORD); /* Vista/Longhorn */ 105 DWORD GetModuleBaseNameA(HANDLE, HMODULE, LPSTR, DWORD); 106 DWORD GetModuleBaseNameW(HANDLE, HMODULE, LPWSTR, DWORD); 107 DWORD GetModuleFileNameExA(HANDLE, HMODULE, LPSTR, DWORD); 108 DWORD GetModuleFileNameExW(HANDLE, HMODULE, LPWSTR, DWORD); 109 BOOL GetModuleInformation(HANDLE, HMODULE, LPMODULEINFO, DWORD); 110 111 /* Device Driver Information 112 * http://windowssdk.msdn.microsoft.com/library/ms682578.aspx */ 113 BOOL EnumDeviceDrivers(LPVOID*, DWORD, LPDWORD); 114 DWORD GetDeviceDriverBaseNameA(LPVOID, LPSTR, DWORD); 115 DWORD GetDeviceDriverBaseNameW(LPVOID, LPWSTR, DWORD); 116 DWORD GetDeviceDriverFileNameA(LPVOID, LPSTR, DWORD); 117 DWORD GetDeviceDriverFileNameW(LPVOID, LPWSTR, DWORD); 118 119 /* Process Memory Usage Information 120 * http://windowssdk.msdn.microsoft.com/library/ms684879.aspx */ 121 BOOL GetProcessMemoryInfo(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD); 122 123 /* Working Set Information 124 * http://windowssdk.msdn.microsoft.com/library/ms687398.aspx */ 125 BOOL EmptyWorkingSet(HANDLE); 126 BOOL GetWsChanges(HANDLE, PPSAPI_WS_WATCH_INFORMATION, DWORD); 127 BOOL GetWsChangesEx(HANDLE, PPSAPI_WS_WATCH_INFORMATION_EX, DWORD); /* Vista/Longhorn */ 128 BOOL InitializeProcessForWsWatch(HANDLE); 129 BOOL QueryWorkingSet(HANDLE, PVOID, DWORD); 130 BOOL QueryWorkingSetEx(HANDLE, PVOID, DWORD); 131 132 /* Memory-Mapped File Information 133 * http://windowssdk.msdn.microsoft.com/library/ms684212.aspx */ 134 DWORD GetMappedFileNameW(HANDLE, LPVOID, LPWSTR, DWORD); 135 DWORD GetMappedFileNameA(HANDLE, LPVOID, LPSTR, DWORD); 136 137 /* Resources Information */ 138 BOOL GetPerformanceInfo(PPERFORMANCE_INFORMATION, DWORD); /* XP/Server2003/Vista/Longhorn */ 139 BOOL EnumPageFilesW(PENUM_PAGE_FILE_CALLBACK, LPVOID); /* 2000/XP/Server2003/Vista/Longhorn */ 140 BOOL EnumPageFilesA(PENUM_PAGE_FILE_CALLBACK, LPVOID); /* 2000/XP/Server2003/Vista/Longhorn */ 141 } 142 143 version (Unicode) { 144 alias GetModuleBaseNameW GetModuleBaseName; 145 alias GetModuleFileNameExW GetModuleFileNameEx; 146 alias GetMappedFileNameW GetMappedFileName; 147 alias GetDeviceDriverBaseNameW GetDeviceDriverBaseName; 148 alias GetDeviceDriverFileNameW GetDeviceDriverFileName; 149 alias EnumPageFilesW EnumPageFiles; 150 alias GetProcessImageFileNameW GetProcessImageFileName; 151 } else { 152 alias GetModuleBaseNameA GetModuleBaseName; 153 alias GetModuleFileNameExA GetModuleFileNameEx; 154 alias GetMappedFileNameA GetMappedFileName; 155 alias GetDeviceDriverBaseNameA GetDeviceDriverBaseName; 156 alias GetDeviceDriverFileNameA GetDeviceDriverFileName; 157 alias EnumPageFilesA EnumPageFiles; 158 alias GetProcessImageFileNameA GetProcessImageFileName; 159 }