ReactOS 0.4.15-dev-6694-g4ba8af9
perfdata.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Task Manager
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Performance Counters.
5 * COPYRIGHT: Copyright 1999-2001 Brian Palmer <brianp@reactos.org>
6 * Copyright 2014 Ismael Ferreras Morezuelas <swyterzone+ros@gmail.com>
7 */
8
9#include "precomp.h"
10
11#define WIN32_LEAN_AND_MEAN
12#include <aclapi.h>
13
14#define NTOS_MODE_USER
15#include <ndk/psfuncs.h>
16#include <ndk/exfuncs.h>
17
19PPERFDATA pPerfDataOld = NULL; /* Older perf data (saved to establish delta values) */
20PPERFDATA pPerfData = NULL; /* Most recent copy of perf data */
27double OldKernelTime = 0;
35
37
38#define CMD_LINE_MIN(a, b) (a < b ? a - sizeof(WCHAR) : b)
39
40typedef struct _SIDTOUSERNAME
41{
46
48
50{
53
55
56 /*
57 * Get number of processors in the system
58 */
60 if (!NT_SUCCESS(status))
61 return FALSE;
62
63 /*
64 * Create the SYSTEM Sid
65 */
67 return TRUE;
68}
69
71{
74
75 if (pPerfData != NULL)
77
79
80 if (SystemUserSid != NULL)
81 {
84 }
85
86 /* Free user names cache list */
88 while (pCur != &SidToUserNameHead)
89 {
91 pCur = pCur->Flink;
93 }
94
97 }
98}
99
101{
102 static WCHAR szDomainNameUnused[255];
103 DWORD DomainNameLen = sizeof(szDomainNameUnused) / sizeof(szDomainNameUnused[0]);
104 SID_NAME_USE Use;
105
106 if (Sid != NULL)
107 LookupAccountSidW(NULL, Sid, szBuffer, &BufferSize, szDomainNameUnused, &DomainNameLen, &Use);
108}
109
110VOID
111WINAPI
113 PSID pSid,
116{
119 ULONG cbSid, cwcUserName;
120
121 cwcUserName = *pcwcUserName;
122
123 /* Walk through the list */
126 pCur = pCur->Flink)
127 {
129 if (EqualSid((PSID)&pEntry->Data, pSid))
130 {
131 wcsncpy(pUserName, pEntry->pszName, cwcUserName);
133 return;
134 }
135 }
136
137 /* We didn't find the SID in the list, get the name conventional */
138 SidToUserName(pSid, pUserName, cwcUserName);
140
141 /* Allocate a new entry */
142 cwcUserName = *pcwcUserName + 1;
144 pEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(SIDTOUSERNAME) + cbSid + cwcUserName * sizeof(WCHAR));
145
146 /* Copy the Sid and name to our entry */
147 CopySid(cbSid, (PSID)&pEntry->Data, pSid);
148 pEntry->pszName = (LPWSTR)(pEntry->Data + cbSid);
149 wcsncpy(pEntry->pszName, pUserName, cwcUserName);
150
151 /* Insert the new entry */
154 SidToUserNameHead.Blink->Flink = &pEntry->List;
156
157 return;
158}
159
161{
162 ULONG ulSize;
167 PPERFDATA pPDOld;
168 ULONG Idx, Idx2;
170 HANDLE hProcessToken;
173 SYSTEM_FILECACHE_INFORMATION SysCacheInfo;
174 SYSTEM_HANDLE_INFORMATION SysHandleInfoData;
176 double CurrentKernelTime;
177 PSECURITY_DESCRIPTOR ProcessSD;
178 PSID ProcessUser;
179 ULONG Buffer[64]; /* must be 4 bytes aligned! */
180 ULONG cwcUserName;
181
182 /* Get new system time */
183 status = NtQuerySystemInformation(SystemTimeOfDayInformation, &SysTimeInfo, sizeof(SysTimeInfo), NULL);
184 if (!NT_SUCCESS(status))
185 return;
186
187 /* Get new CPU's idle time */
188 status = NtQuerySystemInformation(SystemPerformanceInformation, &SysPerfInfo, sizeof(SysPerfInfo), NULL);
189 if (!NT_SUCCESS(status))
190 return;
191
192 /* Get system cache information */
193 status = NtQuerySystemInformation(SystemFileCacheInformation, &SysCacheInfo, sizeof(SysCacheInfo), NULL);
194 if (!NT_SUCCESS(status))
195 return;
196
197 /* Get processor time information */
200
201 if (!NT_SUCCESS(status))
202 {
203 if (SysProcessorTimeInfo != NULL)
204 HeapFree(GetProcessHeap(), 0, SysProcessorTimeInfo);
205 return;
206 }
207
208 /* Get handle information
209 * Number of handles is enough, no need for data array.
210 */
211 status = NtQuerySystemInformation(SystemHandleInformation, &SysHandleInfoData, sizeof(SysHandleInfoData), NULL);
212 /* On unexpected error, reuse previous value.
213 * STATUS_SUCCESS (0-1 handle) should never happen.
214 */
216 SysHandleInfoData.NumberOfHandles = SystemNumberOfHandles;
217
218 /* Get process information
219 * We don't know how much data there is so just keep
220 * increasing the buffer size until the call succeeds
221 */
222 BufferSize = 0;
223 do
224 {
225 BufferSize += 0x10000;
227
229
232 }
233
235
237
238 /*
239 * Save system performance info
240 */
242
243 /*
244 * Save system cache info
245 */
246 memcpy(&SystemCacheInfo, &SysCacheInfo, sizeof(SYSTEM_FILECACHE_INFORMATION));
247
248 /*
249 * Save system processor time info
250 */
253 }
254 SystemProcessorTimeInfo = SysProcessorTimeInfo;
255
256 /*
257 * Save system handle info
258 */
259 SystemNumberOfHandles = SysHandleInfoData.NumberOfHandles;
260
261 for (CurrentKernelTime=0, Idx=0; Idx<(ULONG)SystemBasicInfo.NumberOfProcessors; Idx++) {
262 CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime);
263 CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].DpcTime);
264 CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].InterruptTime);
265 }
266
267 /* If it's a first call - skip idle time calcs */
268 if (liOldIdleTime.QuadPart != 0) {
269 /* CurrentValue = NewValue - OldValue */
271 dbKernelTime = CurrentKernelTime - OldKernelTime;
273
274 /* CurrentCpuIdle = IdleTime / SystemTime */
277
278 /* CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors */
279 dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
280 dbKernelTime = 100.0 - dbKernelTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
281 }
282
283 /* Store new CPU's idle and system time */
284 liOldIdleTime = SysPerfInfo.IdleProcessTime;
285 liOldSystemTime = SysTimeInfo.CurrentTime;
286 OldKernelTime = CurrentKernelTime;
287
288 /* Determine the process count
289 * We loop through the data we got from NtQuerySystemInformation
290 * and count how many structures there are (until RelativeOffset is 0)
291 */
293 ProcessCount = 0;
295 while (pSPI) {
296 ProcessCount++;
297 if (pSPI->NextEntryOffset == 0)
298 break;
299 pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->NextEntryOffset);
300 }
301
302 /* Now alloc a new PERFDATA array and fill in the data */
304
306 for (Idx=0; Idx<ProcessCount; Idx++) {
307 /* Get the old perf data for this process (if any) */
308 /* so that we can establish delta values */
309 pPDOld = NULL;
310 if (pPerfDataOld) {
311 for (Idx2=0; Idx2<ProcessCountOld; Idx2++) {
312 if (pPerfDataOld[Idx2].ProcessId == pSPI->UniqueProcessId) {
313 pPDOld = &pPerfDataOld[Idx2];
314 break;
315 }
316 }
317 }
318
319 if (pSPI->ImageName.Buffer) {
320 /* Don't assume a UNICODE_STRING Buffer is zero terminated: */
321 int len = pSPI->ImageName.Length / 2;
322 /* Check against max size and allow for terminating zero (already zeroed): */
323 if(len >= MAX_PATH)len=MAX_PATH - 1;
325 } else {
327 sizeof(pPerfData[Idx].ImageName) / sizeof(pPerfData[Idx].ImageName[0]));
328 }
329
331
332 if (pPDOld) {
333 double CurTime = Li2Double(pSPI->KernelTime) + Li2Double(pSPI->UserTime);
334 double OldTime = Li2Double(pPDOld->KernelTime) + Li2Double(pPDOld->UserTime);
335 double CpuTime = (CurTime - OldTime) / dbSystemTime;
336 CpuTime = CpuTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
337 pPerfData[Idx].CPUUsage = (ULONG)CpuTime;
338 }
342 if (pPDOld)
344 else
347 if (pPDOld)
349 else
355 pPerfData[Idx].HandleCount = pSPI->HandleCount;
357 pPerfData[Idx].SessionId = pSPI->SessionId;
359 pPerfData[Idx].USERObjectCount = 0;
360 pPerfData[Idx].GDIObjectCount = 0;
361 ProcessUser = SystemUserSid;
362 ProcessSD = NULL;
363
364 if (pSPI->UniqueProcessId != NULL) {
366 if (hProcess) {
367 /* don't query the information of the system process. It's possible but
368 returns Administrators as the owner of the process instead of SYSTEM */
369 if (pSPI->UniqueProcessId != (HANDLE)0x4)
370 {
371 if (OpenProcessToken(hProcess, TOKEN_QUERY, &hProcessToken))
372 {
373 DWORD RetLen = 0;
374 BOOL Ret;
375
376 Ret = GetTokenInformation(hProcessToken, TokenUser, (LPVOID)Buffer, sizeof(Buffer), &RetLen);
377 CloseHandle(hProcessToken);
378
379 if (Ret)
380 ProcessUser = ((PTOKEN_USER)Buffer)->User.Sid;
381 else
382 goto ReadProcOwner;
383 }
384 else
385 {
386ReadProcOwner:
388 }
389
390 pPerfData[Idx].USERObjectCount = GetGuiResources(hProcess, GR_USEROBJECTS);
391 pPerfData[Idx].GDIObjectCount = GetGuiResources(hProcess, GR_GDIOBJECTS);
392 }
393
394 GetProcessIoCounters(hProcess, &pPerfData[Idx].IOCounters);
396 } else {
397 goto ClearInfo;
398 }
399 } else {
400ClearInfo:
401 /* clear information we were unable to fetch */
402 ZeroMemory(&pPerfData[Idx].IOCounters, sizeof(IO_COUNTERS));
403 }
404
405 cwcUserName = sizeof(pPerfData[0].UserName) / sizeof(pPerfData[0].UserName[0]);
406 CachedGetUserFromSid(ProcessUser, pPerfData[Idx].UserName, &cwcUserName);
407
408 if (ProcessSD != NULL)
409 {
410 LocalFree((HLOCAL)ProcessSD);
411 }
412
415 pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->NextEntryOffset);
416 }
418 if (pPerfDataOld) {
420 }
423}
424
426{
427 ULONG idx;
428
430
431 for (idx = 0; idx < ProcessCount; idx++)
432 {
434 {
435 break;
436 }
437 }
438
440
441 if (idx == ProcessCount)
442 {
443 return -1;
444 }
445 return idx;
446}
447
449{
454 return Result;
455}
456
458{
461 Result = (ULONG)min(max(dbIdleTime, 0.), 100.);
463 return Result;
464}
465
467{
470 Result = (ULONG)min(max(dbKernelTime, 0.), 100.);
472 return Result;
473}
474
476{
477 BOOL bSuccessful;
478
480
481 if (Index < ProcessCount) {
482 wcsncpy(lpImageName, pPerfData[Index].ImageName, nMaxCount);
483 bSuccessful = TRUE;
484 } else {
485 bSuccessful = FALSE;
486 }
488 return bSuccessful;
489}
490
492{
494
496
497 if (Index < ProcessCount)
499 else
500 ProcessId = 0;
501
503
504 return ProcessId;
505}
506
508{
509 BOOL bSuccessful;
510
512
513 if (Index < ProcessCount) {
514 wcsncpy(lpUserName, pPerfData[Index].UserName, nMaxCount);
515 bSuccessful = TRUE;
516 } else {
517 bSuccessful = FALSE;
518 }
519
521
522 return bSuccessful;
523}
524
526{
527 static const LPWSTR ellipsis = L"...";
528
530 UNICODE_STRING CommandLineStr = {0};
531
532 PVOID ProcessParams = NULL;
535
537 BOOL result;
538
539 PCMD_LINE_CACHE new_entry;
540 LPWSTR new_string;
541
543
544 /* [A] Search for a string already in cache? If so, use it */
545 while (cache && cache->pnext != NULL)
546 {
547 if (cache->idx == Index && cache->str != NULL)
548 {
549 /* Found it. Use it, and add some ellipsis at the very end to make it cute */
550 wcsncpy(lpCommandLine, cache->str, CMD_LINE_MIN(nMaxCount, cache->len));
551 wcscpy(lpCommandLine + CMD_LINE_MIN(nMaxCount, cache->len) - wcslen(ellipsis), ellipsis);
552 return TRUE;
553 }
554
555 cache = cache->pnext;
556 }
557
558 /* [B] We don't; let's allocate and load a value from the process mem... and cache it */
560
561 /* Default blank command line in case things don't work out */
562 wcsncpy(lpCommandLine, L"", nMaxCount);
563
564 /* Ask for a handle to the target process so that we can read its memory and query stuff */
566 if (!hProcess)
567 goto cleanup;
568
569 /* First off, get the ProcessEnvironmentBlock location in that process' address space */
571 if (!NT_SUCCESS(Status))
572 goto cleanup;
573
574 /* Then get the PEB.ProcessParameters member pointer */
576 (PVOID)((ULONG_PTR)pbi.PebBaseAddress + FIELD_OFFSET(PEB, ProcessParameters)),
577 &ProcessParams,
578 sizeof(ProcessParams),
579 NULL);
580 if (!result)
581 goto cleanup;
582
583 /* Then copy the PEB->ProcessParameters.CommandLine member
584 to get the pointer to the string buffer and its size */
586 (PVOID)((ULONG_PTR)ProcessParams + FIELD_OFFSET(RTL_USER_PROCESS_PARAMETERS, CommandLine)),
587 &CommandLineStr,
588 sizeof(CommandLineStr),
589 NULL);
590 if (!result)
591 goto cleanup;
592
593 /* Allocate the next cache entry and its accompanying string in one go */
594 new_entry = HeapAlloc(GetProcessHeap(),
596 sizeof(CMD_LINE_CACHE) + CommandLineStr.Length + sizeof(UNICODE_NULL));
597 if (!new_entry)
598 goto cleanup;
599
600 new_string = (LPWSTR)((ULONG_PTR)new_entry + sizeof(CMD_LINE_CACHE));
601
602 /* Bingo, the command line should be stored there,
603 copy the string from the other process */
605 CommandLineStr.Buffer,
606 new_string,
607 CommandLineStr.Length,
608 NULL);
609 if (!result)
610 {
611 /* Weird, after successfully reading the mem of that process
612 various times it fails now, forget it and bail out */
613 HeapFree(GetProcessHeap(), 0, new_entry);
614 goto cleanup;
615 }
616
617 /* Add our pointer to the cache... */
618 new_entry->idx = Index;
619 new_entry->str = new_string;
620 new_entry->len = CommandLineStr.Length;
621
622 if (!global_cache)
623 global_cache = new_entry;
624 else
625 cache->pnext = new_entry;
626
627 /* ... and print the buffer for the first time */
628 wcsncpy(lpCommandLine, new_string, CMD_LINE_MIN(nMaxCount, CommandLineStr.Length));
629
630cleanup:
632 return TRUE;
633}
634
636{
637 PCMD_LINE_CACHE cache, pnext;
638
639 for (cache = global_cache; cache; cache = pnext)
640 {
641 pnext = cache->pnext;
643 }
644
646}
647
649{
651
653
654 if (Index < ProcessCount)
656 else
657 SessionId = 0;
658
660
661 return SessionId;
662}
663
665{
666 ULONG CpuUsage;
667
669
670 if (Index < ProcessCount)
671 CpuUsage = pPerfData[Index].CPUUsage;
672 else
673 CpuUsage = 0;
674
676
677 return CpuUsage;
678}
679
681{
682 LARGE_INTEGER CpuTime = {{0,0}};
683
685
686 if (Index < ProcessCount)
687 CpuTime = pPerfData[Index].CPUTime;
688
690
691 return CpuTime;
692}
693
695{
696 ULONG WorkingSetSizeBytes;
697
699
700 if (Index < ProcessCount)
701 WorkingSetSizeBytes = pPerfData[Index].WorkingSetSizeBytes;
702 else
703 WorkingSetSizeBytes = 0;
704
706
707 return WorkingSetSizeBytes;
708}
709
711{
712 ULONG PeakWorkingSetSizeBytes;
713
715
716 if (Index < ProcessCount)
717 PeakWorkingSetSizeBytes = pPerfData[Index].PeakWorkingSetSizeBytes;
718 else
719 PeakWorkingSetSizeBytes = 0;
720
722
723 return PeakWorkingSetSizeBytes;
724}
725
727{
728 ULONG WorkingSetSizeDelta;
729
731
732 if (Index < ProcessCount)
733 WorkingSetSizeDelta = pPerfData[Index].WorkingSetSizeDelta;
734 else
735 WorkingSetSizeDelta = 0;
736
738
739 return WorkingSetSizeDelta;
740}
741
743{
744 ULONG PageFaultCount;
745
747
748 if (Index < ProcessCount)
749 PageFaultCount = pPerfData[Index].PageFaultCount;
750 else
751 PageFaultCount = 0;
752
754
755 return PageFaultCount;
756}
757
759{
760 ULONG PageFaultCountDelta;
761
763
764 if (Index < ProcessCount)
765 PageFaultCountDelta = pPerfData[Index].PageFaultCountDelta;
766 else
767 PageFaultCountDelta = 0;
768
770
771 return PageFaultCountDelta;
772}
773
775{
776 ULONG VirtualMemorySizeBytes;
777
779
780 if (Index < ProcessCount)
781 VirtualMemorySizeBytes = pPerfData[Index].VirtualMemorySizeBytes;
782 else
783 VirtualMemorySizeBytes = 0;
784
786
787 return VirtualMemorySizeBytes;
788}
789
791{
792 ULONG PagedPoolUsage;
793
795
796 if (Index < ProcessCount)
797 PagedPoolUsage = pPerfData[Index].PagedPoolUsagePages;
798 else
799 PagedPoolUsage = 0;
800
802
803 return PagedPoolUsage;
804}
805
807{
808 ULONG NonPagedPoolUsage;
809
811
812 if (Index < ProcessCount)
813 NonPagedPoolUsage = pPerfData[Index].NonPagedPoolUsagePages;
814 else
815 NonPagedPoolUsage = 0;
816
818
819 return NonPagedPoolUsage;
820}
821
823{
824 ULONG BasePriority;
825
827
828 if (Index < ProcessCount)
829 BasePriority = pPerfData[Index].BasePriority;
830 else
831 BasePriority = 0;
832
834
835 return BasePriority;
836}
837
839{
840 ULONG HandleCount;
841
843
844 if (Index < ProcessCount)
845 HandleCount = pPerfData[Index].HandleCount;
846 else
847 HandleCount = 0;
848
850
851 return HandleCount;
852}
853
855{
856 ULONG ThreadCount;
857
859
860 if (Index < ProcessCount)
861 ThreadCount = pPerfData[Index].ThreadCount;
862 else
863 ThreadCount = 0;
864
866
867 return ThreadCount;
868}
869
871{
872 ULONG USERObjectCount;
873
875
876 if (Index < ProcessCount)
877 USERObjectCount = pPerfData[Index].USERObjectCount;
878 else
879 USERObjectCount = 0;
880
882
883 return USERObjectCount;
884}
885
887{
888 ULONG GDIObjectCount;
889
891
892 if (Index < ProcessCount)
893 GDIObjectCount = pPerfData[Index].GDIObjectCount;
894 else
895 GDIObjectCount = 0;
896
898
899 return GDIObjectCount;
900}
901
903{
904 BOOL bSuccessful;
905
907
908 if (Index < ProcessCount)
909 {
910 memcpy(pIoCounters, &pPerfData[Index].IOCounters, sizeof(IO_COUNTERS));
911 bSuccessful = TRUE;
912 }
913 else
914 bSuccessful = FALSE;
915
917
918 return bSuccessful;
919}
920
922{
923 ULONG Total;
924 ULONG PageSize;
925
927
929 PageSize = SystemBasicInfo.PageSize;
930
932
933 Total = Total * (PageSize / 1024);
934
935 return Total;
936}
937
939{
940 ULONG Limit;
941 ULONG PageSize;
942
944
946 PageSize = SystemBasicInfo.PageSize;
947
949
950 Limit = Limit * (PageSize / 1024);
951
952 return Limit;
953}
954
956{
957 ULONG Peak;
958 ULONG PageSize;
959
961
963 PageSize = SystemBasicInfo.PageSize;
964
966
967 Peak = Peak * (PageSize / 1024);
968
969 return Peak;
970}
971
973{
974 ULONG Total;
975 ULONG Paged;
976 ULONG NonPaged;
977 ULONG PageSize;
978
980
983 PageSize = SystemBasicInfo.PageSize;
984
986
987 Paged = Paged * (PageSize / 1024);
988 NonPaged = NonPaged * (PageSize / 1024);
989
990 Total = Paged + NonPaged;
991
992 return Total;
993}
994
996{
997 ULONG Paged;
998 ULONG PageSize;
999
1001
1003 PageSize = SystemBasicInfo.PageSize;
1004
1006
1007 Paged = Paged * (PageSize / 1024);
1008
1009 return Paged;
1010}
1011
1013{
1014 ULONG NonPaged;
1015 ULONG PageSize;
1016
1018
1020 PageSize = SystemBasicInfo.PageSize;
1021
1023
1024 NonPaged = NonPaged * (PageSize / 1024);
1025
1026 return NonPaged;
1027}
1028
1030{
1031 ULONG Total;
1032 ULONG PageSize;
1033
1035
1037 PageSize = SystemBasicInfo.PageSize;
1038
1040
1041 Total = Total * (PageSize / 1024);
1042
1043 return Total;
1044}
1045
1047{
1048 ULONG Available;
1049 ULONG PageSize;
1050
1052
1053 Available = SystemPerfInfo.AvailablePages;
1054 PageSize = SystemBasicInfo.PageSize;
1055
1057
1058 Available = Available * (PageSize / 1024);
1059
1060 return Available;
1061}
1062
1064{
1065 ULONG SystemCache;
1066 ULONG PageSize;
1067
1069
1070 PageSize = SystemBasicInfo.PageSize;
1072
1074
1075 return SystemCache / 1024;
1076}
1077
1079{
1080 ULONG HandleCount;
1081
1083
1084 HandleCount = SystemNumberOfHandles;
1085
1087
1088 return HandleCount;
1089}
1090
1092{
1093 ULONG ThreadCount = 0;
1094 ULONG i;
1095
1097
1098 for (i=0; i<ProcessCount; i++)
1099 {
1100 ThreadCount += pPerfData[i].ThreadCount;
1101 }
1102
1104
1105 return ThreadCount;
1106}
1107
1109{
1110 BOOL bSuccessful = FALSE;
1111
1113 if (Index < ProcessCount)
1114 {
1115 *lppData = pPerfData + Index;
1116 bSuccessful = TRUE;
1117 }
1119 return bSuccessful;
1120}
1121
static LPWSTR PULONG pcwcUserName
static LPWSTR pUserName
@ SE_KERNEL_OBJECT
Definition: accctrl.h:165
LONG NTSTATUS
Definition: precomp.h:26
#define IDS_IDLE_PROCESS
Definition: resource.h:10
Definition: bufpool.h:45
#define BufferSize
Definition: mmc.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned int idx
Definition: utils.c:41
DWORD WINAPI GetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, PSID *ppsidOwner, PSID *ppsidGroup, PACL *ppDacl, PACL *ppSacl, PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
Definition: misc.c:1244
BOOL WINAPI LookupAccountSidW(LPCWSTR pSystemName, PSID pSid, LPWSTR pAccountName, LPDWORD pdwAccountName, LPWSTR pDomainName, LPDWORD pdwDomainName, PSID_NAME_USE peUse)
Definition: misc.c:537
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:676
BOOL WINAPI CopySid(DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid)
Definition: security.c:714
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:921
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:700
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:831
#define CloseHandle
Definition: compat.h:739
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static void cleanup(void)
Definition: main.c:1335
ULONG SessionId
Definition: dllmain.c:28
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
BOOL WINAPI GetProcessIoCounters(IN HANDLE hProcess, OUT PIO_COUNTERS lpIoCounters)
Definition: proc.c:1861
#define PtrToUlong(u)
Definition: config.h:107
HINSTANCE hInst
Definition: dxdiag.c:13
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2711
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
@ SystemTimeOfDayInformation
Definition: ntddk_ex.h:14
@ SystemBasicInformation
Definition: ntddk_ex.h:11
@ SystemFileCacheInformation
Definition: ntddk_ex.h:32
@ SystemHandleInformation
Definition: ntddk_ex.h:27
@ SystemProcessInformation
Definition: ntddk_ex.h:16
@ SystemProcessorPerformanceInformation
Definition: ntddk_ex.h:19
SINGLE_LIST_ENTRY * pCur
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
Status
Definition: gdiplustypes.h:25
GLenum GLsizei len
Definition: glext.h:6722
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
_Check_return_ long __cdecl labs(_In_ long x)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define PROCESS_VM_READ
Definition: pstypes.h:161
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:166
enum _SID_NAME_USE SID_NAME_USE
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define SystemPerformanceInformation
Definition: memtest.h:87
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PSID pSid
Definition: security.c:74
static const char * ImageName
Definition: image.c:34
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
#define min(a, b)
Definition: monoChain.cc:55
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION * PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
struct _SYSTEM_PROCESS_INFORMATION * PSYSTEM_PROCESS_INFORMATION
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1133
#define READ_CONTROL
Definition: nt_native.h:58
#define UNICODE_NULL
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
#define L(x)
Definition: ntvdm.h:50
EXTINLINE DWORD WINAPI GetGuiResources(HANDLE hProcess, DWORD uiFlags)
Definition: ntwrapper.h:64
long LONG
Definition: pedump.c:60
ULONG PerfDataGetPagedPoolUsagePages(ULONG Index)
Definition: perfdata.c:790
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:30
ULONG PerfDataGetWorkingSetSizeBytes(ULONG Index)
Definition: perfdata.c:694
ULONG SystemNumberOfHandles
Definition: perfdata.c:32
ULONG PerfDataGetWorkingSetSizeDelta(ULONG Index)
Definition: perfdata.c:726
PPERFDATA pPerfData
Definition: perfdata.c:20
ULONG PerfDataGetPageFaultCountDelta(ULONG Index)
Definition: perfdata.c:758
ULONG PerfDataGetProcessIndex(ULONG pid)
Definition: perfdata.c:425
struct _SIDTOUSERNAME SIDTOUSERNAME
ULONG PerfDataGetKernelMemoryNonPagedK(void)
Definition: perfdata.c:1012
ULONG PerfDataGetPageFaultCount(ULONG Index)
Definition: perfdata.c:742
ULONG PerfDataGetSystemHandleCount(void)
Definition: perfdata.c:1078
ULONG PerfDataGetSessionId(ULONG Index)
Definition: perfdata.c:648
double dbIdleTime
Definition: perfdata.c:23
ULONG PerfDataGetPhysicalMemoryTotalK(void)
Definition: perfdata.c:1029
PPERFDATA pPerfDataOld
Definition: perfdata.c:19
ULONG PerfDataGetTotalThreadCount(void)
Definition: perfdata.c:1091
void PerfDataDeallocCommandLineCache()
Definition: perfdata.c:635
ULONG PerfDataGetCommitChargePeakK(void)
Definition: perfdata.c:955
ULONG PerfDataGetProcessorSystemUsage(void)
Definition: perfdata.c:466
PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SystemProcessorTimeInfo
Definition: perfdata.c:33
LARGE_INTEGER PerfDataGetCPUTime(ULONG Index)
Definition: perfdata.c:680
ULONG PerfDataGetHandleCount(ULONG Index)
Definition: perfdata.c:838
ULONG PerfDataGetProcessId(ULONG Index)
Definition: perfdata.c:491
ULONG PerfDataGetProcessorUsage(void)
Definition: perfdata.c:457
ULONG PerfDataGetCPUUsage(ULONG Index)
Definition: perfdata.c:664
ULONG PerfDataGetKernelMemoryPagedK(void)
Definition: perfdata.c:995
BOOL PerfDataGetCommandLine(ULONG Index, LPWSTR lpCommandLine, ULONG nMaxCount)
Definition: perfdata.c:525
PCMD_LINE_CACHE global_cache
Definition: perfdata.c:36
PSID SystemUserSid
Definition: perfdata.c:34
ULONG PerfDataGetKernelMemoryTotalK(void)
Definition: perfdata.c:972
ULONG ProcessCountOld
Definition: perfdata.c:21
ULONG PerfDataGetCommitChargeLimitK(void)
Definition: perfdata.c:938
double dbKernelTime
Definition: perfdata.c:24
ULONG PerfDataGetThreadCount(ULONG Index)
Definition: perfdata.c:854
ULONG PerfDataGetBasePriority(ULONG Index)
Definition: perfdata.c:822
BOOL PerfDataGetUserName(ULONG Index, LPWSTR lpUserName, ULONG nMaxCount)
Definition: perfdata.c:507
BOOL PerfDataInitialize(void)
Definition: perfdata.c:49
void PerfDataRefresh(void)
Definition: perfdata.c:160
double dbSystemTime
Definition: perfdata.c:25
static void SidToUserName(PSID Sid, LPWSTR szBuffer, DWORD BufferSize)
Definition: perfdata.c:100
struct _SIDTOUSERNAME * PSIDTOUSERNAME
ULONG PerfDataGetUSERObjectCount(ULONG Index)
Definition: perfdata.c:870
LARGE_INTEGER liOldIdleTime
Definition: perfdata.c:26
double OldKernelTime
Definition: perfdata.c:27
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo
Definition: perfdata.c:29
ULONG PerfDataGetPhysicalMemoryAvailableK(void)
Definition: perfdata.c:1046
ULONG PerfDataGetNonPagedPoolUsagePages(ULONG Index)
Definition: perfdata.c:806
ULONG PerfDataGetCommitChargeTotalK(void)
Definition: perfdata.c:921
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:18
ULONG ProcessCount
Definition: perfdata.c:22
void PerfDataUninitialize(void)
Definition: perfdata.c:70
LARGE_INTEGER liOldSystemTime
Definition: perfdata.c:28
ULONG PerfDataGetVirtualMemorySizeBytes(ULONG Index)
Definition: perfdata.c:774
VOID WINAPI CachedGetUserFromSid(PSID pSid, LPWSTR pUserName, PULONG pcwcUserName)
Definition: perfdata.c:112
BOOL PerfDataGetImageName(ULONG Index, LPWSTR lpImageName, ULONG nMaxCount)
Definition: perfdata.c:475
ULONG PerfDataGetPeakWorkingSetSizeBytes(ULONG Index)
Definition: perfdata.c:710
ULONG PerfDataGetGDIObjectCount(ULONG Index)
Definition: perfdata.c:886
BOOL PerfDataGetIOCounters(ULONG Index, PIO_COUNTERS pIoCounters)
Definition: perfdata.c:902
static LIST_ENTRY SidToUserNameHead
Definition: perfdata.c:47
SYSTEM_FILECACHE_INFORMATION SystemCacheInfo
Definition: perfdata.c:31
ULONG PerfDataGetProcessCount(void)
Definition: perfdata.c:448
BOOL PerfDataGet(ULONG Index, PPERFDATA *lppData)
Definition: perfdata.c:1108
#define CMD_LINE_MIN(a, b)
Definition: perfdata.c:38
ULONG PerfDataGetPhysicalMemorySystemCacheK(void)
Definition: perfdata.c:1063
#define Li2Double(x)
Definition: perfdata.h:15
struct _PERFDATA PERFDATA
struct _PERFDATA * PPERFDATA
struct _CMD_LINE_CACHE CMD_LINE_CACHE
PVOID pBuffer
static SID_IDENTIFIER_AUTHORITY NtSidAuthority
Definition: samrpc.c:14
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
LPWSTR str
Definition: perfdata.h:47
Definition: typedefs.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
ULONG PageFaultCountDelta
Definition: perfdata.h:29
WCHAR UserName[MAX_PATH]
Definition: perfdata.h:21
LARGE_INTEGER UserTime
Definition: perfdata.h:40
LARGE_INTEGER CPUTime
Definition: perfdata.h:24
ULONG WorkingSetSizeDelta
Definition: perfdata.h:27
ULONG CPUUsage
Definition: perfdata.h:23
LARGE_INTEGER KernelTime
Definition: perfdata.h:41
ULONG NonPagedPoolUsagePages
Definition: perfdata.h:32
ULONG VirtualMemorySizeBytes
Definition: perfdata.h:30
ULONG PagedPoolUsagePages
Definition: perfdata.h:31
ULONG USERObjectCount
Definition: perfdata.h:36
ULONG ThreadCount
Definition: perfdata.h:35
ULONG SessionId
Definition: perfdata.h:22
ULONG PageFaultCount
Definition: perfdata.h:28
ULONG HandleCount
Definition: perfdata.h:34
HANDLE ProcessId
Definition: perfdata.h:20
ULONG WorkingSetSizeBytes
Definition: perfdata.h:25
ULONG PeakWorkingSetSizeBytes
Definition: perfdata.h:26
ULONG BasePriority
Definition: perfdata.h:33
ULONG GDIObjectCount
Definition: perfdata.h:37
LPWSTR pszName
Definition: perfdata.c:43
LIST_ENTRY List
Definition: perfdata.c:42
SIZE_T CurrentSizeIncludingTransitionInPages
Definition: extypes.h:1127
LARGE_INTEGER IdleProcessTime
Definition: memtest.h:11
LARGE_INTEGER UserTime
Definition: extypes.h:900
UNICODE_STRING ImageName
Definition: extypes.h:902
LARGE_INTEGER KernelTime
Definition: extypes.h:901
LARGE_INTEGER CurrentTime
Definition: extypes.h:858
Definition: cache.c:49
Definition: ps.c:97
#define max(a, b)
Definition: svc.c:63
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define ZeroMemory
Definition: winbase.h:1700
_In_ LPCSTR _Out_writes_bytes_to_opt_ cbSid PSID _Inout_ LPDWORD cbSid
Definition: winbase.h:2733
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
_Inout_ PERBANDINFO * pbi
Definition: winddi.h:3917
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837
#define WINAPI
Definition: msvc.h:6
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
_In_ int nMaxCount
Definition: winuser.h:4867
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
_In_ LONG _In_ LONG Limit
Definition: kefuncs.h:318
struct _TOKEN_USER * PTOKEN_USER
#define TOKEN_QUERY
Definition: setypes.h:928
#define SECURITY_LOCAL_SYSTEM_RID
Definition: setypes.h:574
#define OWNER_SECURITY_INFORMATION
Definition: setypes.h:123
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554
@ TokenUser
Definition: setypes.h:966
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned char BYTE
Definition: xxhash.c:193