ReactOS 0.4.16-dev-1260-g901af6a
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 = _countof(szDomainNameUnused);
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
159{
160 ULONG ulSize;
165 PPERFDATA pPDOld;
166 ULONG Idx, Idx2;
168 HANDLE hProcessToken;
171 SYSTEM_FILECACHE_INFORMATION SysCacheInfo;
172 SYSTEM_HANDLE_INFORMATION SysHandleInfoData;
174 double CurrentKernelTime;
175 PSECURITY_DESCRIPTOR ProcessSD;
176 PSID ProcessUser;
177 ULONG Buffer[64]; /* must be 4 bytes aligned! */
178 ULONG cwcUserName;
179 BOOL bIsWow64;
180
181 /* Get new system time */
182 status = NtQuerySystemInformation(SystemTimeOfDayInformation, &SysTimeInfo, sizeof(SysTimeInfo), NULL);
183 if (!NT_SUCCESS(status))
184 return;
185
186 /* Get new CPU's idle time */
187 status = NtQuerySystemInformation(SystemPerformanceInformation, &SysPerfInfo, sizeof(SysPerfInfo), NULL);
188 if (!NT_SUCCESS(status))
189 return;
190
191 /* Get system cache information */
192 status = NtQuerySystemInformation(SystemFileCacheInformation, &SysCacheInfo, sizeof(SysCacheInfo), NULL);
193 if (!NT_SUCCESS(status))
194 return;
195
196 /* Get processor time information */
199
200 if (!NT_SUCCESS(status))
201 {
202 if (SysProcessorTimeInfo != NULL)
203 HeapFree(GetProcessHeap(), 0, SysProcessorTimeInfo);
204 return;
205 }
206
207 /* Get handle information
208 * Number of handles is enough, no need for data array.
209 */
210 status = NtQuerySystemInformation(SystemHandleInformation, &SysHandleInfoData, sizeof(SysHandleInfoData), NULL);
211 /* On unexpected error, reuse previous value.
212 * STATUS_SUCCESS (0-1 handle) should never happen.
213 */
215 SysHandleInfoData.NumberOfHandles = SystemNumberOfHandles;
216
217 /* Get process information
218 * We don't know how much data there is so just keep
219 * increasing the buffer size until the call succeeds
220 */
221 BufferSize = 0;
222 do
223 {
224 BufferSize += 0x10000;
226
228
231 }
232
234
236
237 /*
238 * Save system performance info
239 */
241
242 /*
243 * Save system cache info
244 */
245 memcpy(&SystemCacheInfo, &SysCacheInfo, sizeof(SYSTEM_FILECACHE_INFORMATION));
246
247 /*
248 * Save system processor time info
249 */
252 }
253 SystemProcessorTimeInfo = SysProcessorTimeInfo;
254
255 /*
256 * Save system handle info
257 */
258 SystemNumberOfHandles = SysHandleInfoData.NumberOfHandles;
259
260 for (CurrentKernelTime=0, Idx=0; Idx<(ULONG)SystemBasicInfo.NumberOfProcessors; Idx++) {
261 CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime);
262 CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].DpcTime);
263 CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].InterruptTime);
264 }
265
266 /* If it's a first call - skip idle time calcs */
267 if (liOldIdleTime.QuadPart != 0) {
268 /* CurrentValue = NewValue - OldValue */
270 dbKernelTime = CurrentKernelTime - OldKernelTime;
272
273 /* CurrentCpuIdle = IdleTime / SystemTime */
276
277 /* CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors */
278 dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
279 dbKernelTime = 100.0 - dbKernelTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
280 }
281
282 /* Store new CPU's idle and system time */
283 liOldIdleTime = SysPerfInfo.IdleProcessTime;
284 liOldSystemTime = SysTimeInfo.CurrentTime;
285 OldKernelTime = CurrentKernelTime;
286
287 /* Determine the process count
288 * We loop through the data we got from NtQuerySystemInformation
289 * and count how many structures there are (until RelativeOffset is 0)
290 */
292 ProcessCount = 0;
294 while (pSPI) {
295 ProcessCount++;
296 if (pSPI->NextEntryOffset == 0)
297 break;
298 pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->NextEntryOffset);
299 }
300
301 /* Now alloc a new PERFDATA array and fill in the data */
303
305 for (Idx=0; Idx<ProcessCount; Idx++) {
306 /* Get the old perf data for this process (if any) */
307 /* so that we can establish delta values */
308 pPDOld = NULL;
309 if (pPerfDataOld) {
310 for (Idx2=0; Idx2<ProcessCountOld; Idx2++) {
311 if (pPerfDataOld[Idx2].ProcessId == pSPI->UniqueProcessId) {
312 pPDOld = &pPerfDataOld[Idx2];
313 break;
314 }
315 }
316 }
317
318 if (pSPI->ImageName.Buffer) {
319 /* Don't assume a UNICODE_STRING Buffer is zero terminated: */
320 int len = pSPI->ImageName.Length / 2;
321 /* Check against max size and allow for terminating zero (already zeroed): */
322 if(len >= MAX_PATH)len=MAX_PATH - 1;
324 } else {
327 }
328
330
331 if (pPDOld) {
332 double CurTime = Li2Double(pSPI->KernelTime) + Li2Double(pSPI->UserTime);
333 double OldTime = Li2Double(pPDOld->KernelTime) + Li2Double(pPDOld->UserTime);
334 double CpuTime = (CurTime - OldTime) / dbSystemTime;
335 CpuTime = CpuTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
336 pPerfData[Idx].CPUUsage = (ULONG)CpuTime;
337 }
341 if (pPDOld)
343 else
346 if (pPDOld)
348 else
354 pPerfData[Idx].HandleCount = pSPI->HandleCount;
356 pPerfData[Idx].SessionId = pSPI->SessionId;
358 pPerfData[Idx].USERObjectCount = 0;
359 pPerfData[Idx].GDIObjectCount = 0;
360 ProcessUser = SystemUserSid;
361 ProcessSD = NULL;
362
363 if (pSPI->UniqueProcessId != NULL) {
365 if (hProcess) {
366 /* don't query the information of the system process. It's possible but
367 returns Administrators as the owner of the process instead of SYSTEM */
368 if (pSPI->UniqueProcessId != (HANDLE)0x4)
369 {
370 if (OpenProcessToken(hProcess, TOKEN_QUERY, &hProcessToken))
371 {
372 DWORD RetLen = 0;
373 BOOL Ret;
374
375 Ret = GetTokenInformation(hProcessToken, TokenUser, (LPVOID)Buffer, sizeof(Buffer), &RetLen);
376 CloseHandle(hProcessToken);
377
378 if (Ret)
379 ProcessUser = ((PTOKEN_USER)Buffer)->User.Sid;
380 else
381 goto ReadProcOwner;
382 }
383 else
384 {
385ReadProcOwner:
387 }
388
389 pPerfData[Idx].USERObjectCount = GetGuiResources(hProcess, GR_USEROBJECTS);
390 pPerfData[Idx].GDIObjectCount = GetGuiResources(hProcess, GR_GDIOBJECTS);
391 }
392
393 if (IsWow64Process(hProcess, &bIsWow64) && bIsWow64)
394 {
395 wcscat(pPerfData[Idx].ImageName, L" *32");
396 }
397
398 GetProcessIoCounters(hProcess, &pPerfData[Idx].IOCounters);
400 } else {
401 goto ClearInfo;
402 }
403 } else {
404ClearInfo:
405 /* clear information we were unable to fetch */
406 ZeroMemory(&pPerfData[Idx].IOCounters, sizeof(IO_COUNTERS));
407 }
408
409 cwcUserName = _countof(pPerfData[0].UserName);
410 CachedGetUserFromSid(ProcessUser, pPerfData[Idx].UserName, &cwcUserName);
411
412 if (ProcessSD != NULL)
413 {
414 LocalFree((HLOCAL)ProcessSD);
415 }
416
419 pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->NextEntryOffset);
420 }
422 if (pPerfDataOld) {
424 }
427}
428
430{
431 ULONG idx;
432
434
435 for (idx = 0; idx < ProcessCount; idx++)
436 {
438 {
439 break;
440 }
441 }
442
444
445 if (idx == ProcessCount)
446 {
447 return -1;
448 }
449 return idx;
450}
451
453{
458 return Result;
459}
460
462{
465 Result = (ULONG)min(max(dbIdleTime, 0.), 100.);
467 return Result;
468}
469
471{
474 Result = (ULONG)min(max(dbKernelTime, 0.), 100.);
476 return Result;
477}
478
480{
481 BOOL bSuccessful;
482
484
485 if (Index < ProcessCount) {
486 wcsncpy(lpImageName, pPerfData[Index].ImageName, nMaxCount);
487 bSuccessful = TRUE;
488 } else {
489 bSuccessful = FALSE;
490 }
492 return bSuccessful;
493}
494
496{
498
500
501 if (Index < ProcessCount)
503 else
504 ProcessId = 0;
505
507
508 return ProcessId;
509}
510
512{
513 BOOL bSuccessful;
514
516
517 if (Index < ProcessCount) {
518 wcsncpy(lpUserName, pPerfData[Index].UserName, nMaxCount);
519 bSuccessful = TRUE;
520 } else {
521 bSuccessful = FALSE;
522 }
523
525
526 return bSuccessful;
527}
528
530{
531 static const LPWSTR ellipsis = L"...";
532
534 UNICODE_STRING CommandLineStr = {0};
535
536 PVOID ProcessParams = NULL;
539
541 BOOL result;
542
543 PCMD_LINE_CACHE new_entry;
544 LPWSTR new_string;
545
547
548 /* [A] Search for a string already in cache? If so, use it */
549 while (cache && cache->pnext != NULL)
550 {
551 if (cache->idx == Index && cache->str != NULL)
552 {
553 /* Found it. Use it, and add some ellipsis at the very end to make it cute */
554 wcsncpy(lpCommandLine, cache->str, CMD_LINE_MIN(nMaxCount, cache->len));
555 wcscpy(lpCommandLine + CMD_LINE_MIN(nMaxCount, cache->len) - wcslen(ellipsis), ellipsis);
556 return TRUE;
557 }
558
559 cache = cache->pnext;
560 }
561
562 /* [B] We don't; let's allocate and load a value from the process mem... and cache it */
564
565 /* Default blank command line in case things don't work out */
566 wcsncpy(lpCommandLine, L"", nMaxCount);
567
568 /* Ask for a handle to the target process so that we can read its memory and query stuff */
570 if (!hProcess)
571 goto cleanup;
572
573 /* First off, get the ProcessEnvironmentBlock location in that process' address space */
575 if (!NT_SUCCESS(Status))
576 goto cleanup;
577
578 /* Then get the PEB.ProcessParameters member pointer */
580 (PVOID)((ULONG_PTR)pbi.PebBaseAddress + FIELD_OFFSET(PEB, ProcessParameters)),
581 &ProcessParams,
582 sizeof(ProcessParams),
583 NULL);
584 if (!result)
585 goto cleanup;
586
587 /* Then copy the PEB->ProcessParameters.CommandLine member
588 to get the pointer to the string buffer and its size */
590 (PVOID)((ULONG_PTR)ProcessParams + FIELD_OFFSET(RTL_USER_PROCESS_PARAMETERS, CommandLine)),
591 &CommandLineStr,
592 sizeof(CommandLineStr),
593 NULL);
594 if (!result)
595 goto cleanup;
596
597 /* Allocate the next cache entry and its accompanying string in one go */
598 new_entry = HeapAlloc(GetProcessHeap(),
600 sizeof(CMD_LINE_CACHE) + CommandLineStr.Length + sizeof(UNICODE_NULL));
601 if (!new_entry)
602 goto cleanup;
603
604 new_string = (LPWSTR)((ULONG_PTR)new_entry + sizeof(CMD_LINE_CACHE));
605
606 /* Bingo, the command line should be stored there,
607 copy the string from the other process */
609 CommandLineStr.Buffer,
610 new_string,
611 CommandLineStr.Length,
612 NULL);
613 if (!result)
614 {
615 /* Weird, after successfully reading the mem of that process
616 various times it fails now, forget it and bail out */
617 HeapFree(GetProcessHeap(), 0, new_entry);
618 goto cleanup;
619 }
620
621 /* Add our pointer to the cache... */
622 new_entry->idx = Index;
623 new_entry->str = new_string;
624 new_entry->len = CommandLineStr.Length;
625
626 if (!global_cache)
627 global_cache = new_entry;
628 else
629 cache->pnext = new_entry;
630
631 /* ... and print the buffer for the first time */
632 wcsncpy(lpCommandLine, new_string, CMD_LINE_MIN(nMaxCount, CommandLineStr.Length));
633
634cleanup:
636 return TRUE;
637}
638
640{
641 PCMD_LINE_CACHE cache, pnext;
642
643 for (cache = global_cache; cache; cache = pnext)
644 {
645 pnext = cache->pnext;
647 }
648
650}
651
653{
655
657
658 if (Index < ProcessCount)
660 else
661 SessionId = 0;
662
664
665 return SessionId;
666}
667
669{
670 ULONG CpuUsage;
671
673
674 if (Index < ProcessCount)
675 CpuUsage = pPerfData[Index].CPUUsage;
676 else
677 CpuUsage = 0;
678
680
681 return CpuUsage;
682}
683
685{
686 LARGE_INTEGER CpuTime = {{0,0}};
687
689
690 if (Index < ProcessCount)
691 CpuTime = pPerfData[Index].CPUTime;
692
694
695 return CpuTime;
696}
697
699{
700 ULONG WorkingSetSizeBytes;
701
703
704 if (Index < ProcessCount)
705 WorkingSetSizeBytes = pPerfData[Index].WorkingSetSizeBytes;
706 else
707 WorkingSetSizeBytes = 0;
708
710
711 return WorkingSetSizeBytes;
712}
713
715{
716 ULONG PeakWorkingSetSizeBytes;
717
719
720 if (Index < ProcessCount)
721 PeakWorkingSetSizeBytes = pPerfData[Index].PeakWorkingSetSizeBytes;
722 else
723 PeakWorkingSetSizeBytes = 0;
724
726
727 return PeakWorkingSetSizeBytes;
728}
729
731{
732 ULONG WorkingSetSizeDelta;
733
735
736 if (Index < ProcessCount)
737 WorkingSetSizeDelta = pPerfData[Index].WorkingSetSizeDelta;
738 else
739 WorkingSetSizeDelta = 0;
740
742
743 return WorkingSetSizeDelta;
744}
745
747{
748 ULONG PageFaultCount;
749
751
752 if (Index < ProcessCount)
753 PageFaultCount = pPerfData[Index].PageFaultCount;
754 else
755 PageFaultCount = 0;
756
758
759 return PageFaultCount;
760}
761
763{
764 ULONG PageFaultCountDelta;
765
767
768 if (Index < ProcessCount)
769 PageFaultCountDelta = pPerfData[Index].PageFaultCountDelta;
770 else
771 PageFaultCountDelta = 0;
772
774
775 return PageFaultCountDelta;
776}
777
779{
780 ULONG VirtualMemorySizeBytes;
781
783
784 if (Index < ProcessCount)
785 VirtualMemorySizeBytes = pPerfData[Index].VirtualMemorySizeBytes;
786 else
787 VirtualMemorySizeBytes = 0;
788
790
791 return VirtualMemorySizeBytes;
792}
793
795{
796 ULONG PagedPoolUsage;
797
799
800 if (Index < ProcessCount)
801 PagedPoolUsage = pPerfData[Index].PagedPoolUsagePages;
802 else
803 PagedPoolUsage = 0;
804
806
807 return PagedPoolUsage;
808}
809
811{
812 ULONG NonPagedPoolUsage;
813
815
816 if (Index < ProcessCount)
817 NonPagedPoolUsage = pPerfData[Index].NonPagedPoolUsagePages;
818 else
819 NonPagedPoolUsage = 0;
820
822
823 return NonPagedPoolUsage;
824}
825
827{
828 ULONG BasePriority;
829
831
832 if (Index < ProcessCount)
833 BasePriority = pPerfData[Index].BasePriority;
834 else
835 BasePriority = 0;
836
838
839 return BasePriority;
840}
841
843{
844 ULONG HandleCount;
845
847
848 if (Index < ProcessCount)
849 HandleCount = pPerfData[Index].HandleCount;
850 else
851 HandleCount = 0;
852
854
855 return HandleCount;
856}
857
859{
860 ULONG ThreadCount;
861
863
864 if (Index < ProcessCount)
865 ThreadCount = pPerfData[Index].ThreadCount;
866 else
867 ThreadCount = 0;
868
870
871 return ThreadCount;
872}
873
875{
876 ULONG USERObjectCount;
877
879
880 if (Index < ProcessCount)
881 USERObjectCount = pPerfData[Index].USERObjectCount;
882 else
883 USERObjectCount = 0;
884
886
887 return USERObjectCount;
888}
889
891{
892 ULONG GDIObjectCount;
893
895
896 if (Index < ProcessCount)
897 GDIObjectCount = pPerfData[Index].GDIObjectCount;
898 else
899 GDIObjectCount = 0;
900
902
903 return GDIObjectCount;
904}
905
907{
908 BOOL bSuccessful;
909
911
912 if (Index < ProcessCount)
913 {
914 memcpy(pIoCounters, &pPerfData[Index].IOCounters, sizeof(IO_COUNTERS));
915 bSuccessful = TRUE;
916 }
917 else
918 bSuccessful = FALSE;
919
921
922 return bSuccessful;
923}
924
926{
927 ULONG Total;
928 ULONG PageSize;
929
931
933 PageSize = SystemBasicInfo.PageSize;
934
936
937 Total = Total * (PageSize / 1024);
938
939 return Total;
940}
941
943{
944 ULONG Limit;
945 ULONG PageSize;
946
948
950 PageSize = SystemBasicInfo.PageSize;
951
953
954 Limit = Limit * (PageSize / 1024);
955
956 return Limit;
957}
958
960{
961 ULONG Peak;
962 ULONG PageSize;
963
965
967 PageSize = SystemBasicInfo.PageSize;
968
970
971 Peak = Peak * (PageSize / 1024);
972
973 return Peak;
974}
975
977{
978 ULONG Total;
979 ULONG Paged;
980 ULONG NonPaged;
981 ULONG PageSize;
982
984
987 PageSize = SystemBasicInfo.PageSize;
988
990
991 Paged = Paged * (PageSize / 1024);
992 NonPaged = NonPaged * (PageSize / 1024);
993
994 Total = Paged + NonPaged;
995
996 return Total;
997}
998
1000{
1001 ULONG Paged;
1002 ULONG PageSize;
1003
1005
1007 PageSize = SystemBasicInfo.PageSize;
1008
1010
1011 Paged = Paged * (PageSize / 1024);
1012
1013 return Paged;
1014}
1015
1017{
1018 ULONG NonPaged;
1019 ULONG PageSize;
1020
1022
1024 PageSize = SystemBasicInfo.PageSize;
1025
1027
1028 NonPaged = NonPaged * (PageSize / 1024);
1029
1030 return NonPaged;
1031}
1032
1034{
1035 ULONG Total;
1036 ULONG PageSize;
1037
1039
1041 PageSize = SystemBasicInfo.PageSize;
1042
1044
1045 Total = Total * (PageSize / 1024);
1046
1047 return Total;
1048}
1049
1051{
1052 ULONG Available;
1053 ULONG PageSize;
1054
1056
1057 Available = SystemPerfInfo.AvailablePages;
1058 PageSize = SystemBasicInfo.PageSize;
1059
1061
1062 Available = Available * (PageSize / 1024);
1063
1064 return Available;
1065}
1066
1068{
1069 ULONG SystemCache;
1070 ULONG PageSize;
1071
1073
1074 PageSize = SystemBasicInfo.PageSize;
1076
1078
1079 return SystemCache / 1024;
1080}
1081
1083{
1084 ULONG HandleCount;
1085
1087
1088 HandleCount = SystemNumberOfHandles;
1089
1091
1092 return HandleCount;
1093}
1094
1096{
1097 ULONG ThreadCount = 0;
1098 ULONG i;
1099
1101
1102 for (i=0; i<ProcessCount; i++)
1103 {
1104 ThreadCount += pPerfData[i].ThreadCount;
1105 }
1106
1108
1109 return ThreadCount;
1110}
1111
1113{
1114 BOOL bSuccessful = FALSE;
1115
1117 if (Index < ProcessCount)
1118 {
1119 *lppData = pPerfData + Index;
1120 bSuccessful = TRUE;
1121 }
1123 return bSuccessful;
1124}
1125
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
wcsncpy
wcscat
wcscpy
#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:33
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:411
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
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:674
BOOL WINAPI CopySid(DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid)
Definition: security.c:712
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:919
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:829
#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 IsWow64Process
Definition: compat.h:760
#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:1867
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
#define PtrToUlong(u)
Definition: config.h:107
HINSTANCE hInst
Definition: dxdiag.c:13
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2712
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
GLuint64EXT * result
Definition: glext.h:11304
GLenum GLsizei len
Definition: glext.h:6722
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:162
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:167
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:89
#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:1157
#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:794
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:30
ULONG PerfDataGetWorkingSetSizeBytes(ULONG Index)
Definition: perfdata.c:698
ULONG SystemNumberOfHandles
Definition: perfdata.c:32
ULONG PerfDataGetWorkingSetSizeDelta(ULONG Index)
Definition: perfdata.c:730
PPERFDATA pPerfData
Definition: perfdata.c:20
ULONG PerfDataGetPageFaultCountDelta(ULONG Index)
Definition: perfdata.c:762
ULONG PerfDataGetProcessIndex(ULONG pid)
Definition: perfdata.c:429
struct _SIDTOUSERNAME SIDTOUSERNAME
ULONG PerfDataGetKernelMemoryNonPagedK(void)
Definition: perfdata.c:1016
ULONG PerfDataGetPageFaultCount(ULONG Index)
Definition: perfdata.c:746
ULONG PerfDataGetSystemHandleCount(void)
Definition: perfdata.c:1082
ULONG PerfDataGetSessionId(ULONG Index)
Definition: perfdata.c:652
double dbIdleTime
Definition: perfdata.c:23
ULONG PerfDataGetPhysicalMemoryTotalK(void)
Definition: perfdata.c:1033
PPERFDATA pPerfDataOld
Definition: perfdata.c:19
ULONG PerfDataGetTotalThreadCount(void)
Definition: perfdata.c:1095
void PerfDataDeallocCommandLineCache()
Definition: perfdata.c:639
ULONG PerfDataGetCommitChargePeakK(void)
Definition: perfdata.c:959
ULONG PerfDataGetProcessorSystemUsage(void)
Definition: perfdata.c:470
PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SystemProcessorTimeInfo
Definition: perfdata.c:33
LARGE_INTEGER PerfDataGetCPUTime(ULONG Index)
Definition: perfdata.c:684
ULONG PerfDataGetHandleCount(ULONG Index)
Definition: perfdata.c:842
ULONG PerfDataGetProcessId(ULONG Index)
Definition: perfdata.c:495
ULONG PerfDataGetProcessorUsage(void)
Definition: perfdata.c:461
ULONG PerfDataGetCPUUsage(ULONG Index)
Definition: perfdata.c:668
ULONG PerfDataGetKernelMemoryPagedK(void)
Definition: perfdata.c:999
BOOL PerfDataGetCommandLine(ULONG Index, LPWSTR lpCommandLine, ULONG nMaxCount)
Definition: perfdata.c:529
PCMD_LINE_CACHE global_cache
Definition: perfdata.c:36
PSID SystemUserSid
Definition: perfdata.c:34
ULONG PerfDataGetKernelMemoryTotalK(void)
Definition: perfdata.c:976
ULONG ProcessCountOld
Definition: perfdata.c:21
ULONG PerfDataGetCommitChargeLimitK(void)
Definition: perfdata.c:942
double dbKernelTime
Definition: perfdata.c:24
ULONG PerfDataGetThreadCount(ULONG Index)
Definition: perfdata.c:858
ULONG PerfDataGetBasePriority(ULONG Index)
Definition: perfdata.c:826
BOOL PerfDataGetUserName(ULONG Index, LPWSTR lpUserName, ULONG nMaxCount)
Definition: perfdata.c:511
BOOL PerfDataInitialize(void)
Definition: perfdata.c:49
void PerfDataRefresh(void)
Definition: perfdata.c:158
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:874
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:1050
ULONG PerfDataGetNonPagedPoolUsagePages(ULONG Index)
Definition: perfdata.c:810
ULONG PerfDataGetCommitChargeTotalK(void)
Definition: perfdata.c:925
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:778
VOID WINAPI CachedGetUserFromSid(PSID pSid, LPWSTR pUserName, PULONG pcwcUserName)
Definition: perfdata.c:112
BOOL PerfDataGetImageName(ULONG Index, LPWSTR lpImageName, ULONG nMaxCount)
Definition: perfdata.c:479
ULONG PerfDataGetPeakWorkingSetSizeBytes(ULONG Index)
Definition: perfdata.c:714
ULONG PerfDataGetGDIObjectCount(ULONG Index)
Definition: perfdata.c:890
BOOL PerfDataGetIOCounters(ULONG Index, PIO_COUNTERS pIoCounters)
Definition: perfdata.c:906
static LIST_ENTRY SidToUserNameHead
Definition: perfdata.c:47
SYSTEM_FILECACHE_INFORMATION SystemCacheInfo
Definition: perfdata.c:31
ULONG PerfDataGetProcessCount(void)
Definition: perfdata.c:452
BOOL PerfDataGet(ULONG Index, PPERFDATA *lppData)
Definition: perfdata.c:1112
#define CMD_LINE_MIN(a, b)
Definition: perfdata.c:38
ULONG PerfDataGetPhysicalMemorySystemCacheK(void)
Definition: perfdata.c:1067
#define Li2Double(x)
Definition: perfdata.h:11
struct _PERFDATA PERFDATA
struct _PERFDATA * PPERFDATA
struct _CMD_LINE_CACHE CMD_LINE_CACHE
PVOID pBuffer
static SID_IDENTIFIER_AUTHORITY NtSidAuthority
Definition: samrpc.c:14
#define _countof(array)
Definition: sndvol32.h:70
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
LPWSTR str
Definition: perfdata.h:43
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:25
WCHAR UserName[MAX_PATH]
Definition: perfdata.h:17
LARGE_INTEGER UserTime
Definition: perfdata.h:36
LARGE_INTEGER CPUTime
Definition: perfdata.h:20
ULONG WorkingSetSizeDelta
Definition: perfdata.h:23
ULONG CPUUsage
Definition: perfdata.h:19
LARGE_INTEGER KernelTime
Definition: perfdata.h:37
ULONG NonPagedPoolUsagePages
Definition: perfdata.h:28
ULONG VirtualMemorySizeBytes
Definition: perfdata.h:26
ULONG PagedPoolUsagePages
Definition: perfdata.h:27
ULONG USERObjectCount
Definition: perfdata.h:32
ULONG ThreadCount
Definition: perfdata.h:31
ULONG SessionId
Definition: perfdata.h:18
ULONG PageFaultCount
Definition: perfdata.h:24
ULONG HandleCount
Definition: perfdata.h:30
HANDLE ProcessId
Definition: perfdata.h:16
ULONG WorkingSetSizeBytes
Definition: perfdata.h:21
ULONG PeakWorkingSetSizeBytes
Definition: perfdata.h:22
ULONG BasePriority
Definition: perfdata.h:29
ULONG GDIObjectCount
Definition: perfdata.h:33
LPWSTR pszName
Definition: perfdata.c:43
LIST_ENTRY List
Definition: perfdata.c:42
SIZE_T CurrentSizeIncludingTransitionInPages
Definition: extypes.h:1133
LARGE_INTEGER IdleProcessTime
Definition: memtest.h:11
LARGE_INTEGER UserTime
Definition: extypes.h:906
UNICODE_STRING ImageName
Definition: extypes.h:908
LARGE_INTEGER KernelTime
Definition: extypes.h:907
LARGE_INTEGER CurrentTime
Definition: extypes.h:864
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:1753
_In_ LPCSTR _Out_writes_bytes_to_opt_ cbSid PSID _Inout_ LPDWORD cbSid
Definition: winbase.h:2784
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
_In_ int nMaxCount
Definition: winuser.h:4953
_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:304
struct _TOKEN_USER * PTOKEN_USER
#define TOKEN_QUERY
Definition: setypes.h:940
#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:978
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned char BYTE
Definition: xxhash.c:193