ReactOS 0.4.16-dev-1537-g4e425b5
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
68 /*
69 * Set up global info storage
70 */
72 0, sizeof(*SystemProcessorTimeInfo) * SystemBasicInfo.NumberOfProcessors);
73
75}
76
78{
81
82 if (pPerfData != NULL)
84
86
87 if (SystemUserSid != NULL)
88 {
91 }
92
93 /* Free user names cache list */
95 while (pCur != &SidToUserNameHead)
96 {
98 pCur = pCur->Flink;
100 }
101
104 }
105}
106
108{
109 static WCHAR szDomainNameUnused[255];
110 DWORD DomainNameLen = _countof(szDomainNameUnused);
111 SID_NAME_USE Use;
112
113 if (Sid != NULL)
114 LookupAccountSidW(NULL, Sid, szBuffer, &BufferSize, szDomainNameUnused, &DomainNameLen, &Use);
115}
116
117VOID
118WINAPI
120 PSID pSid,
123{
126 ULONG cbSid, cwcUserName;
127
128 cwcUserName = *pcwcUserName;
129
130 /* Walk through the list */
133 pCur = pCur->Flink)
134 {
136 if (EqualSid((PSID)&pEntry->Data, pSid))
137 {
138 wcsncpy(pUserName, pEntry->pszName, cwcUserName);
140 return;
141 }
142 }
143
144 /* We didn't find the SID in the list, get the name conventional */
145 SidToUserName(pSid, pUserName, cwcUserName);
147
148 /* Allocate a new entry */
149 cwcUserName = *pcwcUserName + 1;
151 pEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(SIDTOUSERNAME) + cbSid + cwcUserName * sizeof(WCHAR));
152
153 /* Copy the Sid and name to our entry */
154 CopySid(cbSid, (PSID)&pEntry->Data, pSid);
155 pEntry->pszName = (LPWSTR)(pEntry->Data + cbSid);
156 wcsncpy(pEntry->pszName, pUserName, cwcUserName);
157
158 /* Insert the new entry */
161 SidToUserNameHead.Blink->Flink = &pEntry->List;
163}
164
166{
167 ULONG ulSize;
172 PPERFDATA pPDOld;
173 ULONG Idx, Idx2;
175 HANDLE hProcessToken;
178 SYSTEM_FILECACHE_INFORMATION SysCacheInfo;
179 SYSTEM_HANDLE_INFORMATION SysHandleInfoData;
181 double CurrentKernelTime;
182 PSECURITY_DESCRIPTOR ProcessSD;
183 PSID ProcessUser;
184 ULONG Buffer[64]; /* must be 4 bytes aligned! */
185 ULONG cwcUserName;
186 BOOL bIsWow64;
187
188 /* Get new system time */
189 status = NtQuerySystemInformation(SystemTimeOfDayInformation, &SysTimeInfo, sizeof(SysTimeInfo), NULL);
190 if (!NT_SUCCESS(status))
191 return;
192
193 /* Get new CPU's idle time */
194 status = NtQuerySystemInformation(SystemPerformanceInformation, &SysPerfInfo, sizeof(SysPerfInfo), NULL);
195 if (!NT_SUCCESS(status))
196 return;
197
198 /* Get system cache information */
199 status = NtQuerySystemInformation(SystemFileCacheInformation, &SysCacheInfo, sizeof(SysCacheInfo), NULL);
200 if (!NT_SUCCESS(status))
201 return;
202
203 /* Get processor time information */
206
207 if (!NT_SUCCESS(status))
208 {
209 if (SysProcessorTimeInfo != NULL)
210 HeapFree(GetProcessHeap(), 0, SysProcessorTimeInfo);
211 return;
212 }
213
214 /* Get handle information
215 * Number of handles is enough, no need for data array.
216 */
217 status = NtQuerySystemInformation(SystemHandleInformation, &SysHandleInfoData, sizeof(SysHandleInfoData), NULL);
218 /* On unexpected error, reuse previous value.
219 * STATUS_SUCCESS (0-1 handle) should never happen.
220 */
222 SysHandleInfoData.NumberOfHandles = SystemNumberOfHandles;
223
224 /* Get process information
225 * We don't know how much data there is so just keep
226 * increasing the buffer size until the call succeeds
227 */
228 BufferSize = 0;
229 do
230 {
231 BufferSize += 0x10000;
233
235
238 }
239
241
243
244 /*
245 * Save system performance info
246 */
248
249 /*
250 * Save system cache info
251 */
252 memcpy(&SystemCacheInfo, &SysCacheInfo, sizeof(SYSTEM_FILECACHE_INFORMATION));
253
254 /*
255 * Save system processor time info
256 */
257 memcpy(SystemProcessorTimeInfo, SysProcessorTimeInfo,
259
260 if (SysProcessorTimeInfo) {
261 HeapFree(GetProcessHeap(), 0, SysProcessorTimeInfo);
262 }
263
264 /*
265 * Save system handle info
266 */
267 SystemNumberOfHandles = SysHandleInfoData.NumberOfHandles;
268
269 for (CurrentKernelTime=0, Idx=0; Idx<(ULONG)SystemBasicInfo.NumberOfProcessors; Idx++) {
270 CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime);
271 CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].DpcTime);
272 CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].InterruptTime);
273 }
274
275 /* If it's a first call - skip idle time calcs */
276 if (liOldIdleTime.QuadPart != 0) {
277 /* CurrentValue = NewValue - OldValue */
279 dbKernelTime = CurrentKernelTime - OldKernelTime;
281
282 /* CurrentCpuIdle = IdleTime / SystemTime */
285
286 /* CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors */
287 dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
288 dbKernelTime = 100.0 - dbKernelTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
289 }
290
291 /* Store new CPU's idle and system time */
292 liOldIdleTime = SysPerfInfo.IdleProcessTime;
293 liOldSystemTime = SysTimeInfo.CurrentTime;
294 OldKernelTime = CurrentKernelTime;
295
296 /* Determine the process count
297 * We loop through the data we got from NtQuerySystemInformation
298 * and count how many structures there are (until RelativeOffset is 0)
299 */
301 ProcessCount = 0;
303 while (pSPI) {
304 ProcessCount++;
305 if (pSPI->NextEntryOffset == 0)
306 break;
307 pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->NextEntryOffset);
308 }
309
310 /* Now alloc a new PERFDATA array and fill in the data */
312
314 for (Idx=0; Idx<ProcessCount; Idx++) {
315 /* Get the old perf data for this process (if any) */
316 /* so that we can establish delta values */
317 pPDOld = NULL;
318 if (pPerfDataOld) {
319 for (Idx2=0; Idx2<ProcessCountOld; Idx2++) {
320 if (pPerfDataOld[Idx2].ProcessId == pSPI->UniqueProcessId) {
321 pPDOld = &pPerfDataOld[Idx2];
322 break;
323 }
324 }
325 }
326
327 if (pSPI->ImageName.Buffer) {
328 /* Don't assume a UNICODE_STRING Buffer is zero terminated: */
329 int len = pSPI->ImageName.Length / 2;
330 /* Check against max size and allow for terminating zero (already zeroed): */
331 if(len >= MAX_PATH)len=MAX_PATH - 1;
333 } else {
336 }
337
339
340 if (pPDOld) {
341 double CurTime = Li2Double(pSPI->KernelTime) + Li2Double(pSPI->UserTime);
342 double OldTime = Li2Double(pPDOld->KernelTime) + Li2Double(pPDOld->UserTime);
343 double CpuTime = (CurTime - OldTime) / dbSystemTime;
344 CpuTime = CpuTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
345 pPerfData[Idx].CPUUsage = (ULONG)CpuTime;
346 }
350 if (pPDOld)
352 else
355 if (pPDOld)
357 else
363 pPerfData[Idx].HandleCount = pSPI->HandleCount;
365 pPerfData[Idx].SessionId = pSPI->SessionId;
367 pPerfData[Idx].USERObjectCount = 0;
368 pPerfData[Idx].GDIObjectCount = 0;
369 ProcessUser = SystemUserSid;
370 ProcessSD = NULL;
371
372 if (pSPI->UniqueProcessId != NULL) {
374 if (hProcess) {
375 /* don't query the information of the system process. It's possible but
376 returns Administrators as the owner of the process instead of SYSTEM */
377 if (pSPI->UniqueProcessId != (HANDLE)0x4)
378 {
379 if (OpenProcessToken(hProcess, TOKEN_QUERY, &hProcessToken))
380 {
381 DWORD RetLen = 0;
382 BOOL Ret;
383
384 Ret = GetTokenInformation(hProcessToken, TokenUser, (LPVOID)Buffer, sizeof(Buffer), &RetLen);
385 CloseHandle(hProcessToken);
386
387 if (Ret)
388 ProcessUser = ((PTOKEN_USER)Buffer)->User.Sid;
389 else
390 goto ReadProcOwner;
391 }
392 else
393 {
394ReadProcOwner:
396 }
397
398 pPerfData[Idx].USERObjectCount = GetGuiResources(hProcess, GR_USEROBJECTS);
399 pPerfData[Idx].GDIObjectCount = GetGuiResources(hProcess, GR_GDIOBJECTS);
400 }
401
402 if (IsWow64Process(hProcess, &bIsWow64) && bIsWow64)
403 {
404 wcscat(pPerfData[Idx].ImageName, L" *32");
405 }
406
407 GetProcessIoCounters(hProcess, &pPerfData[Idx].IOCounters);
409 } else {
410 goto ClearInfo;
411 }
412 } else {
413ClearInfo:
414 /* clear information we were unable to fetch */
415 ZeroMemory(&pPerfData[Idx].IOCounters, sizeof(IO_COUNTERS));
416 }
417
418 cwcUserName = _countof(pPerfData[0].UserName);
419 CachedGetUserFromSid(ProcessUser, pPerfData[Idx].UserName, &cwcUserName);
420
421 if (ProcessSD != NULL)
422 {
423 LocalFree((HLOCAL)ProcessSD);
424 }
425
428 pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->NextEntryOffset);
429 }
431 if (pPerfDataOld) {
433 }
436}
437
439{
440 ULONG idx;
441
443
444 for (idx = 0; idx < ProcessCount; idx++)
445 {
447 {
448 break;
449 }
450 }
451
453
454 if (idx == ProcessCount)
455 {
456 return -1;
457 }
458 return idx;
459}
460
462{
467 return Result;
468}
469
471{
474 Result = (ULONG)min(max(dbIdleTime, 0.), 100.);
476 return Result;
477}
478
480{
483 Result = (ULONG)min(max(dbKernelTime, 0.), 100.);
485 return Result;
486}
487
489{
490 BOOL bSuccessful;
491
493
494 if (Index < ProcessCount) {
495 wcsncpy(lpImageName, pPerfData[Index].ImageName, nMaxCount);
496 bSuccessful = TRUE;
497 } else {
498 bSuccessful = FALSE;
499 }
501 return bSuccessful;
502}
503
505{
507
509
510 if (Index < ProcessCount)
512 else
513 ProcessId = 0;
514
516
517 return ProcessId;
518}
519
521{
522 BOOL bSuccessful;
523
525
526 if (Index < ProcessCount) {
527 wcsncpy(lpUserName, pPerfData[Index].UserName, nMaxCount);
528 bSuccessful = TRUE;
529 } else {
530 bSuccessful = FALSE;
531 }
532
534
535 return bSuccessful;
536}
537
539{
540 static const LPWSTR ellipsis = L"...";
541
543 UNICODE_STRING CommandLineStr = {0};
544
545 PVOID ProcessParams = NULL;
548
550 BOOL result;
551
552 PCMD_LINE_CACHE new_entry;
553 LPWSTR new_string;
554
556
557 /* [A] Search for a string already in cache? If so, use it */
558 while (cache && cache->pnext != NULL)
559 {
560 if (cache->idx == Index && cache->str != NULL)
561 {
562 /* Found it. Use it, and add some ellipsis at the very end to make it cute */
563 wcsncpy(lpCommandLine, cache->str, CMD_LINE_MIN(nMaxCount, cache->len));
564 wcscpy(lpCommandLine + CMD_LINE_MIN(nMaxCount, cache->len) - wcslen(ellipsis), ellipsis);
565 return TRUE;
566 }
567
568 cache = cache->pnext;
569 }
570
571 /* [B] We don't; let's allocate and load a value from the process mem... and cache it */
573
574 /* Default blank command line in case things don't work out */
575 wcsncpy(lpCommandLine, L"", nMaxCount);
576
577 /* Ask for a handle to the target process so that we can read its memory and query stuff */
579 if (!hProcess)
580 goto cleanup;
581
582 /* First off, get the ProcessEnvironmentBlock location in that process' address space */
584 if (!NT_SUCCESS(Status))
585 goto cleanup;
586
587 /* Then get the PEB.ProcessParameters member pointer */
589 (PVOID)((ULONG_PTR)pbi.PebBaseAddress + FIELD_OFFSET(PEB, ProcessParameters)),
590 &ProcessParams,
591 sizeof(ProcessParams),
592 NULL);
593 if (!result)
594 goto cleanup;
595
596 /* Then copy the PEB->ProcessParameters.CommandLine member
597 to get the pointer to the string buffer and its size */
599 (PVOID)((ULONG_PTR)ProcessParams + FIELD_OFFSET(RTL_USER_PROCESS_PARAMETERS, CommandLine)),
600 &CommandLineStr,
601 sizeof(CommandLineStr),
602 NULL);
603 if (!result)
604 goto cleanup;
605
606 /* Allocate the next cache entry and its accompanying string in one go */
607 new_entry = HeapAlloc(GetProcessHeap(),
609 sizeof(CMD_LINE_CACHE) + CommandLineStr.Length + sizeof(UNICODE_NULL));
610 if (!new_entry)
611 goto cleanup;
612
613 new_string = (LPWSTR)((ULONG_PTR)new_entry + sizeof(CMD_LINE_CACHE));
614
615 /* Bingo, the command line should be stored there,
616 copy the string from the other process */
618 CommandLineStr.Buffer,
619 new_string,
620 CommandLineStr.Length,
621 NULL);
622 if (!result)
623 {
624 /* Weird, after successfully reading the mem of that process
625 various times it fails now, forget it and bail out */
626 HeapFree(GetProcessHeap(), 0, new_entry);
627 goto cleanup;
628 }
629
630 /* Add our pointer to the cache... */
631 new_entry->idx = Index;
632 new_entry->str = new_string;
633 new_entry->len = CommandLineStr.Length;
634
635 if (!global_cache)
636 global_cache = new_entry;
637 else
638 cache->pnext = new_entry;
639
640 /* ... and print the buffer for the first time */
641 wcsncpy(lpCommandLine, new_string, CMD_LINE_MIN(nMaxCount, CommandLineStr.Length));
642
643cleanup:
645 return TRUE;
646}
647
649{
650 PCMD_LINE_CACHE cache, pnext;
651
652 for (cache = global_cache; cache; cache = pnext)
653 {
654 pnext = cache->pnext;
656 }
657
659}
660
662{
664
666
667 if (Index < ProcessCount)
669 else
670 SessionId = 0;
671
673
674 return SessionId;
675}
676
678{
679 ULONG CpuUsage;
680
682
683 if (Index < ProcessCount)
684 CpuUsage = pPerfData[Index].CPUUsage;
685 else
686 CpuUsage = 0;
687
689
690 return CpuUsage;
691}
692
694{
695 LARGE_INTEGER CpuTime = {{0,0}};
696
698
699 if (Index < ProcessCount)
700 CpuTime = pPerfData[Index].CPUTime;
701
703
704 return CpuTime;
705}
706
708{
709 ULONG WorkingSetSizeBytes;
710
712
713 if (Index < ProcessCount)
714 WorkingSetSizeBytes = pPerfData[Index].WorkingSetSizeBytes;
715 else
716 WorkingSetSizeBytes = 0;
717
719
720 return WorkingSetSizeBytes;
721}
722
724{
725 ULONG PeakWorkingSetSizeBytes;
726
728
729 if (Index < ProcessCount)
730 PeakWorkingSetSizeBytes = pPerfData[Index].PeakWorkingSetSizeBytes;
731 else
732 PeakWorkingSetSizeBytes = 0;
733
735
736 return PeakWorkingSetSizeBytes;
737}
738
740{
741 ULONG WorkingSetSizeDelta;
742
744
745 if (Index < ProcessCount)
746 WorkingSetSizeDelta = pPerfData[Index].WorkingSetSizeDelta;
747 else
748 WorkingSetSizeDelta = 0;
749
751
752 return WorkingSetSizeDelta;
753}
754
756{
757 ULONG PageFaultCount;
758
760
761 if (Index < ProcessCount)
762 PageFaultCount = pPerfData[Index].PageFaultCount;
763 else
764 PageFaultCount = 0;
765
767
768 return PageFaultCount;
769}
770
772{
773 ULONG PageFaultCountDelta;
774
776
777 if (Index < ProcessCount)
778 PageFaultCountDelta = pPerfData[Index].PageFaultCountDelta;
779 else
780 PageFaultCountDelta = 0;
781
783
784 return PageFaultCountDelta;
785}
786
788{
789 ULONG VirtualMemorySizeBytes;
790
792
793 if (Index < ProcessCount)
794 VirtualMemorySizeBytes = pPerfData[Index].VirtualMemorySizeBytes;
795 else
796 VirtualMemorySizeBytes = 0;
797
799
800 return VirtualMemorySizeBytes;
801}
802
804{
805 ULONG PagedPoolUsage;
806
808
809 if (Index < ProcessCount)
810 PagedPoolUsage = pPerfData[Index].PagedPoolUsagePages;
811 else
812 PagedPoolUsage = 0;
813
815
816 return PagedPoolUsage;
817}
818
820{
821 ULONG NonPagedPoolUsage;
822
824
825 if (Index < ProcessCount)
826 NonPagedPoolUsage = pPerfData[Index].NonPagedPoolUsagePages;
827 else
828 NonPagedPoolUsage = 0;
829
831
832 return NonPagedPoolUsage;
833}
834
836{
837 ULONG BasePriority;
838
840
841 if (Index < ProcessCount)
842 BasePriority = pPerfData[Index].BasePriority;
843 else
844 BasePriority = 0;
845
847
848 return BasePriority;
849}
850
852{
853 ULONG HandleCount;
854
856
857 if (Index < ProcessCount)
858 HandleCount = pPerfData[Index].HandleCount;
859 else
860 HandleCount = 0;
861
863
864 return HandleCount;
865}
866
868{
869 ULONG ThreadCount;
870
872
873 if (Index < ProcessCount)
874 ThreadCount = pPerfData[Index].ThreadCount;
875 else
876 ThreadCount = 0;
877
879
880 return ThreadCount;
881}
882
884{
885 ULONG USERObjectCount;
886
888
889 if (Index < ProcessCount)
890 USERObjectCount = pPerfData[Index].USERObjectCount;
891 else
892 USERObjectCount = 0;
893
895
896 return USERObjectCount;
897}
898
900{
901 ULONG GDIObjectCount;
902
904
905 if (Index < ProcessCount)
906 GDIObjectCount = pPerfData[Index].GDIObjectCount;
907 else
908 GDIObjectCount = 0;
909
911
912 return GDIObjectCount;
913}
914
916{
917 BOOL bSuccessful;
918
920
921 if (Index < ProcessCount)
922 {
923 memcpy(pIoCounters, &pPerfData[Index].IOCounters, sizeof(IO_COUNTERS));
924 bSuccessful = TRUE;
925 }
926 else
927 bSuccessful = FALSE;
928
930
931 return bSuccessful;
932}
933
935{
936 ULONG Total;
937 ULONG PageSize;
938
940
942 PageSize = SystemBasicInfo.PageSize;
943
945
946 Total = Total * (PageSize / 1024);
947
948 return Total;
949}
950
952{
953 ULONG Limit;
954 ULONG PageSize;
955
957
959 PageSize = SystemBasicInfo.PageSize;
960
962
963 Limit = Limit * (PageSize / 1024);
964
965 return Limit;
966}
967
969{
970 ULONG Peak;
971 ULONG PageSize;
972
974
976 PageSize = SystemBasicInfo.PageSize;
977
979
980 Peak = Peak * (PageSize / 1024);
981
982 return Peak;
983}
984
986{
987 ULONG Total;
988 ULONG Paged;
989 ULONG NonPaged;
990 ULONG PageSize;
991
993
996 PageSize = SystemBasicInfo.PageSize;
997
999
1000 Paged = Paged * (PageSize / 1024);
1001 NonPaged = NonPaged * (PageSize / 1024);
1002
1003 Total = Paged + NonPaged;
1004
1005 return Total;
1006}
1007
1009{
1010 ULONG Paged;
1011 ULONG PageSize;
1012
1014
1016 PageSize = SystemBasicInfo.PageSize;
1017
1019
1020 Paged = Paged * (PageSize / 1024);
1021
1022 return Paged;
1023}
1024
1026{
1027 ULONG NonPaged;
1028 ULONG PageSize;
1029
1031
1033 PageSize = SystemBasicInfo.PageSize;
1034
1036
1037 NonPaged = NonPaged * (PageSize / 1024);
1038
1039 return NonPaged;
1040}
1041
1043{
1044 ULONG Total;
1045 ULONG PageSize;
1046
1048
1050 PageSize = SystemBasicInfo.PageSize;
1051
1053
1054 Total = Total * (PageSize / 1024);
1055
1056 return Total;
1057}
1058
1060{
1061 ULONG Available;
1062 ULONG PageSize;
1063
1065
1066 Available = SystemPerfInfo.AvailablePages;
1067 PageSize = SystemBasicInfo.PageSize;
1068
1070
1071 Available = Available * (PageSize / 1024);
1072
1073 return Available;
1074}
1075
1077{
1078 ULONG SystemCache;
1079 ULONG PageSize;
1080
1082
1083 PageSize = SystemBasicInfo.PageSize;
1085
1087
1088 return SystemCache / 1024;
1089}
1090
1092{
1093 ULONG HandleCount;
1094
1096
1097 HandleCount = SystemNumberOfHandles;
1098
1100
1101 return HandleCount;
1102}
1103
1105{
1106 ULONG ThreadCount = 0;
1107 ULONG i;
1108
1110
1111 for (i=0; i<ProcessCount; i++)
1112 {
1113 ThreadCount += pPerfData[i].ThreadCount;
1114 }
1115
1117
1118 return ThreadCount;
1119}
1120
1122{
1123 BOOL bSuccessful = FALSE;
1124
1126 if (Index < ProcessCount)
1127 {
1128 *lppData = pPerfData + Index;
1129 bSuccessful = TRUE;
1130 }
1132 return bSuccessful;
1133}
1134
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 L(x)
Definition: resources.c:13
#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:91
#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
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:803
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:30
ULONG PerfDataGetWorkingSetSizeBytes(ULONG Index)
Definition: perfdata.c:707
ULONG SystemNumberOfHandles
Definition: perfdata.c:32
ULONG PerfDataGetWorkingSetSizeDelta(ULONG Index)
Definition: perfdata.c:739
PPERFDATA pPerfData
Definition: perfdata.c:20
ULONG PerfDataGetPageFaultCountDelta(ULONG Index)
Definition: perfdata.c:771
ULONG PerfDataGetProcessIndex(ULONG pid)
Definition: perfdata.c:438
struct _SIDTOUSERNAME SIDTOUSERNAME
ULONG PerfDataGetKernelMemoryNonPagedK(void)
Definition: perfdata.c:1025
ULONG PerfDataGetPageFaultCount(ULONG Index)
Definition: perfdata.c:755
ULONG PerfDataGetSystemHandleCount(void)
Definition: perfdata.c:1091
ULONG PerfDataGetSessionId(ULONG Index)
Definition: perfdata.c:661
double dbIdleTime
Definition: perfdata.c:23
ULONG PerfDataGetPhysicalMemoryTotalK(void)
Definition: perfdata.c:1042
PPERFDATA pPerfDataOld
Definition: perfdata.c:19
ULONG PerfDataGetTotalThreadCount(void)
Definition: perfdata.c:1104
void PerfDataDeallocCommandLineCache()
Definition: perfdata.c:648
ULONG PerfDataGetCommitChargePeakK(void)
Definition: perfdata.c:968
ULONG PerfDataGetProcessorSystemUsage(void)
Definition: perfdata.c:479
PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SystemProcessorTimeInfo
Definition: perfdata.c:33
LARGE_INTEGER PerfDataGetCPUTime(ULONG Index)
Definition: perfdata.c:693
ULONG PerfDataGetHandleCount(ULONG Index)
Definition: perfdata.c:851
ULONG PerfDataGetProcessId(ULONG Index)
Definition: perfdata.c:504
ULONG PerfDataGetProcessorUsage(void)
Definition: perfdata.c:470
ULONG PerfDataGetCPUUsage(ULONG Index)
Definition: perfdata.c:677
ULONG PerfDataGetKernelMemoryPagedK(void)
Definition: perfdata.c:1008
BOOL PerfDataGetCommandLine(ULONG Index, LPWSTR lpCommandLine, ULONG nMaxCount)
Definition: perfdata.c:538
PCMD_LINE_CACHE global_cache
Definition: perfdata.c:36
PSID SystemUserSid
Definition: perfdata.c:34
ULONG PerfDataGetKernelMemoryTotalK(void)
Definition: perfdata.c:985
ULONG ProcessCountOld
Definition: perfdata.c:21
ULONG PerfDataGetCommitChargeLimitK(void)
Definition: perfdata.c:951
double dbKernelTime
Definition: perfdata.c:24
ULONG PerfDataGetThreadCount(ULONG Index)
Definition: perfdata.c:867
ULONG PerfDataGetBasePriority(ULONG Index)
Definition: perfdata.c:835
BOOL PerfDataGetUserName(ULONG Index, LPWSTR lpUserName, ULONG nMaxCount)
Definition: perfdata.c:520
BOOL PerfDataInitialize(void)
Definition: perfdata.c:49
void PerfDataRefresh(void)
Definition: perfdata.c:165
double dbSystemTime
Definition: perfdata.c:25
static void SidToUserName(PSID Sid, LPWSTR szBuffer, DWORD BufferSize)
Definition: perfdata.c:107
struct _SIDTOUSERNAME * PSIDTOUSERNAME
ULONG PerfDataGetUSERObjectCount(ULONG Index)
Definition: perfdata.c:883
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:1059
ULONG PerfDataGetNonPagedPoolUsagePages(ULONG Index)
Definition: perfdata.c:819
ULONG PerfDataGetCommitChargeTotalK(void)
Definition: perfdata.c:934
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:18
ULONG ProcessCount
Definition: perfdata.c:22
void PerfDataUninitialize(void)
Definition: perfdata.c:77
LARGE_INTEGER liOldSystemTime
Definition: perfdata.c:28
ULONG PerfDataGetVirtualMemorySizeBytes(ULONG Index)
Definition: perfdata.c:787
VOID WINAPI CachedGetUserFromSid(PSID pSid, LPWSTR pUserName, PULONG pcwcUserName)
Definition: perfdata.c:119
BOOL PerfDataGetImageName(ULONG Index, LPWSTR lpImageName, ULONG nMaxCount)
Definition: perfdata.c:488
ULONG PerfDataGetPeakWorkingSetSizeBytes(ULONG Index)
Definition: perfdata.c:723
ULONG PerfDataGetGDIObjectCount(ULONG Index)
Definition: perfdata.c:899
BOOL PerfDataGetIOCounters(ULONG Index, PIO_COUNTERS pIoCounters)
Definition: perfdata.c:915
static LIST_ENTRY SidToUserNameHead
Definition: perfdata.c:47
SYSTEM_FILECACHE_INFORMATION SystemCacheInfo
Definition: perfdata.c:31
ULONG PerfDataGetProcessCount(void)
Definition: perfdata.c:461
BOOL PerfDataGet(ULONG Index, PPERFDATA *lppData)
Definition: perfdata.c:1121
#define CMD_LINE_MIN(a, b)
Definition: perfdata.c:38
ULONG PerfDataGetPhysicalMemorySystemCacheK(void)
Definition: perfdata.c:1076
#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:1302
LARGE_INTEGER IdleProcessTime
Definition: memtest.h:11
LARGE_INTEGER UserTime
Definition: extypes.h:1075
UNICODE_STRING ImageName
Definition: extypes.h:1077
LARGE_INTEGER KernelTime
Definition: extypes.h:1076
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:4979
_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