explorer.exe: Create the top-level message window along with the desktop window.
[wine] / programs / taskmgr / perfdata.h
1 /*
2  *  ReactOS Task Manager
3  *
4  *  perfdata.h
5  *
6  *  Copyright (C) 1999 - 2001  Brian Palmer  <brianp@reactos.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22         
23 #ifndef __PERFDATA_H
24 #define __PERFDATA_H
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30
31 #if 0
32 typedef struct _TIME {
33         DWORD LowPart;
34         LONG HighPart;
35 } TIME, *PTIME;
36 #endif
37
38 typedef ULARGE_INTEGER  TIME, *PTIME;
39
40 /* typedef WCHAR                        UNICODE_STRING; */
41 typedef struct _UNICODE_STRING {
42     USHORT      Length;
43     USHORT      MaximumLength;
44     PWSTR       Buffer;
45 } UNICODE_STRING, *PUNICODE_STRING;
46
47 typedef struct _PERFDATA
48 {
49         WCHAR                           ImageName[MAX_PATH];
50         ULONG                           ProcessId;
51         WCHAR                           UserName[MAX_PATH];
52         ULONG                           SessionId;
53         ULONG                           CPUUsage;
54         TIME                            CPUTime;
55         ULONG                           WorkingSetSizeBytes;
56         ULONG                           PeakWorkingSetSizeBytes;
57         ULONG                           WorkingSetSizeDelta;
58         ULONG                           PageFaultCount;
59         ULONG                           PageFaultCountDelta;
60         ULONG                           VirtualMemorySizeBytes;
61         ULONG                           PagedPoolUsagePages;
62         ULONG                           NonPagedPoolUsagePages;
63         ULONG                           BasePriority;
64         ULONG                           HandleCount;
65         ULONG                           ThreadCount;
66         ULONG                           USERObjectCount;
67         ULONG                           GDIObjectCount;
68         IO_COUNTERS                     IOCounters;
69
70         TIME                            UserTime;
71         TIME                            KernelTime;
72 } PERFDATA, *PPERFDATA;
73
74 typedef struct _CLIENT_ID
75 {
76     HANDLE UniqueProcess;
77     HANDLE UniqueThread;
78 } CLIENT_ID, *PCLIENT_ID;
79
80 typedef enum _KWAIT_REASON
81 {
82    Executive,
83    FreePage,
84    PageIn,
85    PoolAllocation,
86    DelayExecution,
87    Suspended,
88    UserRequest,
89    WrExecutive,
90    WrFreePage,
91    WrPageIn,
92    WrDelayExecution,
93    WrSuspended,
94    WrUserRequest,
95    WrQueue,
96    WrLpcReceive,
97    WrLpcReply,
98    WrVirtualMemory,
99    WrPageOut,
100    WrRendezvous,
101    Spare2,
102    Spare3,
103    Spare4,
104    Spare5,
105    Spare6,
106    WrKernel,
107    MaximumWaitReason,
108 } KWAIT_REASON;
109
110 /* SystemProcessThreadInfo (5) */
111 typedef struct _SYSTEM_THREAD_INFORMATION
112 {
113         TIME            KernelTime;
114         TIME            UserTime;
115         TIME            CreateTime;
116         ULONG           TickCount;
117         ULONG           StartEIP;
118         CLIENT_ID       ClientId;
119         ULONG           DynamicPriority;
120         ULONG           BasePriority;
121         ULONG           nSwitches;
122         DWORD           State;
123         KWAIT_REASON    WaitReason;
124         
125 } SYSTEM_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION;
126
127 typedef struct SYSTEM_PROCESS_INFORMATION
128 {
129         ULONG                           RelativeOffset;
130         ULONG                           ThreadCount;
131         ULONG                           Unused1 [6];
132         TIME                            CreateTime;
133         TIME                            UserTime;
134         TIME                            KernelTime;
135         UNICODE_STRING          Name;
136         ULONG                           BasePriority;
137         ULONG                           ProcessId;
138         ULONG                           ParentProcessId;
139         ULONG                           HandleCount;
140         ULONG                           SessionId;
141         ULONG                           Unused2;
142         ULONG                           PeakVirtualSizeBytes;
143         ULONG                           TotalVirtualSizeBytes;
144         ULONG                           PageFaultCount;
145         ULONG                           PeakWorkingSetSizeBytes;
146         ULONG                           TotalWorkingSetSizeBytes;
147         ULONG                           PeakPagedPoolUsagePages;
148         ULONG                           TotalPagedPoolUsagePages;
149         ULONG                           PeakNonPagedPoolUsagePages;
150         ULONG                           TotalNonPagedPoolUsagePages;
151         ULONG                           TotalPageFileUsageBytes;
152         ULONG                           PeakPageFileUsageBytes;
153         ULONG                           TotalPrivateBytes;
154         SYSTEM_THREAD_INFORMATION       ThreadSysInfo [1];
155         
156 } SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION;
157
158 typedef struct
159 {
160         DWORD   dwUnknown1;
161         ULONG   uKeMaximumIncrement;
162         ULONG   uPageSize;
163         ULONG   uMmNumberOfPhysicalPages;
164         ULONG   uMmLowestPhysicalPage;
165         ULONG   uMmHighestPhysicalPage;
166         ULONG   uAllocationGranularity;
167         PVOID   pLowestUserAddress;
168         PVOID   pMmHighestUserAddress;
169         ULONG   uKeActiveProcessors;
170         BYTE    bKeNumberProcessors;
171         BYTE    bUnknown2;
172         WORD    wUnknown3;
173 } SYSTEM_BASIC_INFORMATION;
174
175 /* SystemPerformanceInfo (2) */
176 typedef struct _SYSTEM_PERFORMANCE_INFORMATION
177 {
178         LARGE_INTEGER   /*TotalProcessorTime*/liIdleTime;
179         LARGE_INTEGER   IoReadTransferCount;
180         LARGE_INTEGER   IoWriteTransferCount;
181         LARGE_INTEGER   IoOtherTransferCount;
182         ULONG           IoReadOperationCount;
183         ULONG           IoWriteOperationCount;
184         ULONG           IoOtherOperationCount;
185         ULONG           MmAvailablePages;
186         ULONG           MmTotalCommittedPages;
187         ULONG           MmTotalCommitLimit;
188         ULONG           MmPeakLimit;
189         ULONG           PageFaults;
190         ULONG           WriteCopies;
191         ULONG           TransitionFaults;
192         ULONG           Unknown1;
193         ULONG           DemandZeroFaults;
194         ULONG           PagesInput;
195         ULONG           PagesRead;
196         ULONG           Unknown2;
197         ULONG           Unknown3;
198         ULONG           PagesOutput;
199         ULONG           PageWrites;
200         ULONG           Unknown4;
201         ULONG           Unknown5;
202         ULONG           PoolPagedBytes;
203         ULONG           PoolNonPagedBytes;
204         ULONG           Unknown6;
205         ULONG           Unknown7;
206         ULONG           Unknown8;
207         ULONG           Unknown9;
208         ULONG           MmTotalSystemFreePtes;
209         ULONG           MmSystemCodepage;
210         ULONG           MmTotalSystemDriverPages;
211         ULONG           MmTotalSystemCodePages;
212         ULONG           Unknown10;
213         ULONG           Unknown11;
214         ULONG           Unknown12;
215         ULONG           MmSystemCachePage;
216         ULONG           MmPagedPoolPage;
217         ULONG           MmSystemDriverPage;
218         ULONG           CcFastReadNoWait;
219         ULONG           CcFastReadWait;
220         ULONG           CcFastReadResourceMiss;
221         ULONG           CcFastReadNotPossible;
222         ULONG           CcFastMdlReadNoWait;
223         ULONG           CcFastMdlReadWait;
224         ULONG           CcFastMdlReadResourceMiss;
225         ULONG           CcFastMdlReadNotPossible;
226         ULONG           CcMapDataNoWait;
227         ULONG           CcMapDataWait;
228         ULONG           CcMapDataNoWaitMiss;
229         ULONG           CcMapDataWaitMiss;
230         ULONG           CcPinMappedDataCount;
231         ULONG           CcPinReadNoWait;
232         ULONG           CcPinReadWait;
233         ULONG           CcPinReadNoWaitMiss;
234         ULONG           CcPinReadWaitMiss;
235         ULONG           CcCopyReadNoWait;
236         ULONG           CcCopyReadWait;
237         ULONG           CcCopyReadNoWaitMiss;
238         ULONG           CcCopyReadWaitMiss;
239         ULONG           CcMdlReadNoWait;
240         ULONG           CcMdlReadWait;
241         ULONG           CcMdlReadNoWaitMiss;
242         ULONG           CcMdlReadWaitMiss;
243         ULONG           CcReadaheadIos;
244         ULONG           CcLazyWriteIos;
245         ULONG           CcLazyWritePages;
246         ULONG           CcDataFlushes;
247         ULONG           CcDataPages;
248         ULONG           ContextSwitches;
249         ULONG           Unknown13;
250         ULONG           Unknown14;
251         ULONG           SystemCalls;
252
253 } SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION;
254
255 typedef struct
256 {
257         LARGE_INTEGER   liKeBootTime;
258         LARGE_INTEGER   liKeSystemTime;
259         LARGE_INTEGER   liExpTimeZoneBias;
260         ULONG                   uCurrentTimeZoneId;
261         DWORD                   dwReserved;
262 } SYSTEM_TIME_INFORMATION;
263
264 /* SystemCacheInformation (21) */
265 typedef struct _SYSTEM_CACHE_INFORMATION
266 {
267         ULONG   CurrentSize;
268         ULONG   PeakSize;
269         ULONG   PageFaultCount;
270         ULONG   MinimumWorkingSet;
271         ULONG   MaximumWorkingSet;
272         ULONG   Unused[4];
273
274 } SYSTEM_CACHE_INFORMATION;
275
276 /* SystemPageFileInformation (18) */
277 typedef
278 struct _SYSTEM_PAGEFILE_INFORMATION
279 {
280         ULONG           RelativeOffset;
281         ULONG           CurrentSizePages;
282         ULONG           TotalUsedPages;
283         ULONG           PeakUsedPages;
284         UNICODE_STRING  PagefileFileName;
285         
286 } SYSTEM_PAGEFILE_INFORMATION, *PSYSTEM_PAGEFILE_INFORMATION;
287
288 /* SystemHandleInformation (16) */
289 /* (see ontypes.h) */
290 typedef
291 struct _SYSTEM_HANDLE_ENTRY
292 {
293         ULONG   OwnerPid;
294         BYTE    ObjectType;
295         BYTE    HandleFlags;
296         USHORT  HandleValue;
297         PVOID   ObjectPointer;
298         ULONG   AccessMask;
299         
300 } SYSTEM_HANDLE_ENTRY, *PSYSTEM_HANDLE_ENTRY;
301
302 typedef
303 struct _SYSTEM_HANDLE_INFORMATION
304 {
305         ULONG                   Count;
306         SYSTEM_HANDLE_ENTRY     Handle [1];
307         
308 } SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION;
309
310 /* SystemProcessorPerformanceInformation (8) */
311 typedef
312 struct _SYSTEM_PROCESSORTIME_INFO
313 {
314         LARGE_INTEGER   IdleTime;
315         LARGE_INTEGER   KernelTime;
316         LARGE_INTEGER   UserTime;
317         LARGE_INTEGER   DpcTime;
318         LARGE_INTEGER   InterruptTime;
319         ULONG                   InterruptCount;
320         ULONG                   Unused;
321         
322 } SYSTEM_PROCESSORTIME_INFO, *PSYSTEM_PROCESSORTIME_INFO;
323
324 #define SystemBasicInformation                  0
325 #define SystemPerformanceInformation    2
326 #define SystemTimeInformation                   3
327 #define SystemProcessInformation                5
328 #define SystemProcessorTimeInformation  8
329 #define SystemHandleInformation                 16
330 #define SystemPageFileInformation               18
331 #define SystemCacheInformation                  21
332
333 #define Li2Double(x) ((double)((x).QuadPart))
334
335 #define GR_GDIOBJECTS     0       /* Count of GDI objects */
336 #define GR_USEROBJECTS    1       /* Count of USER objects */
337
338 typedef LONG (WINAPI *PROCNTQSI)(UINT,PVOID,ULONG,PULONG); 
339 typedef DWORD (WINAPI *PROCGGR)(HANDLE,DWORD);
340 typedef BOOL (WINAPI *PROCGPIC)(HANDLE,PIO_COUNTERS);
341
342 BOOL    PerfDataInitialize(void);
343 void    PerfDataUninitialize(void);
344 void    PerfDataRefresh(void);
345
346 ULONG   PerfDataGetProcessCount(void);
347 ULONG   PerfDataGetProcessorUsage(void);
348 ULONG   PerfDataGetProcessorSystemUsage(void);
349
350 BOOL    PerfDataGetImageName(ULONG Index, LPTSTR lpImageName, int nMaxCount);
351 ULONG   PerfDataGetProcessId(ULONG Index);
352 BOOL    PerfDataGetUserName(ULONG Index, LPTSTR lpUserName, int nMaxCount);
353 ULONG   PerfDataGetSessionId(ULONG Index);
354 ULONG   PerfDataGetCPUUsage(ULONG Index);
355 TIME    PerfDataGetCPUTime(ULONG Index);
356 ULONG   PerfDataGetWorkingSetSizeBytes(ULONG Index);
357 ULONG   PerfDataGetPeakWorkingSetSizeBytes(ULONG Index);
358 ULONG   PerfDataGetWorkingSetSizeDelta(ULONG Index);
359 ULONG   PerfDataGetPageFaultCount(ULONG Index);
360 ULONG   PerfDataGetPageFaultCountDelta(ULONG Index);
361 ULONG   PerfDataGetVirtualMemorySizeBytes(ULONG Index);
362 ULONG   PerfDataGetPagedPoolUsagePages(ULONG Index);
363 ULONG   PerfDataGetNonPagedPoolUsagePages(ULONG Index);
364 ULONG   PerfDataGetBasePriority(ULONG Index);
365 ULONG   PerfDataGetHandleCount(ULONG Index);
366 ULONG   PerfDataGetThreadCount(ULONG Index);
367 ULONG   PerfDataGetUSERObjectCount(ULONG Index);
368 ULONG   PerfDataGetGDIObjectCount(ULONG Index);
369 BOOL    PerfDataGetIOCounters(ULONG Index, PIO_COUNTERS pIoCounters);
370
371 ULONG   PerfDataGetCommitChargeTotalK(void);
372 ULONG   PerfDataGetCommitChargeLimitK(void);
373 ULONG   PerfDataGetCommitChargePeakK(void);
374
375 ULONG   PerfDataGetKernelMemoryTotalK(void);
376 ULONG   PerfDataGetKernelMemoryPagedK(void);
377 ULONG   PerfDataGetKernelMemoryNonPagedK(void);
378
379 ULONG   PerfDataGetPhysicalMemoryTotalK(void);
380 ULONG   PerfDataGetPhysicalMemoryAvailableK(void);
381 ULONG   PerfDataGetPhysicalMemorySystemCacheK(void);
382
383 ULONG   PerfDataGetSystemHandleCount(void);
384
385 ULONG   PerfDataGetTotalThreadCount(void);
386
387
388 #ifdef __cplusplus
389 };
390 #endif
391
392 #endif /* __PERFDATA_H */