The OpenD Programming Language

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