ReactOS 0.4.15-dev-7961-gdcf9eb0
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
180 /* Get new system time */
181 status = NtQuerySystemInformation(SystemTimeOfDayInformation, &SysTimeInfo, sizeof(SysTimeInfo), NULL);
182 if (!NT_SUCCESS(status))
183 return;
184
185 /* Get new CPU's idle time */
186 status = NtQuerySystemInformation(SystemPerformanceInformation, &SysPerfInfo, sizeof(SysPerfInfo), NULL);
187 if (!NT_SUCCESS(status))
188 return;
189
190 /* Get system cache information */
191 status = NtQuerySystemInformation(SystemFileCacheInformation, &SysCacheInfo, sizeof(SysCacheInfo), NULL);
192 if (!NT_SUCCESS(status))
193 return;
194
195 /* Get processor time information */
198
199 if (!NT_SUCCESS(status))
200 {
201 if (SysProcessorTimeInfo != NULL)
202 HeapFree(GetProcessHeap(), 0, SysProcessorTimeInfo);
203 return;
204 }
205
206 /* Get handle information
207 * Number of handles is enough, no need for data array.
208 */
209 status = NtQuerySystemInformation(SystemHandleInformation, &SysHandleInfoData, sizeof(SysHandleInfoData), NULL);
210 /* On unexpected error, reuse previous value.
211 * STATUS_SUCCESS (0-1 handle) should never happen.
212 */
214 SysHandleInfoData.NumberOfHandles = SystemNumberOfHandles;
215
216 /* Get process information
217 * We don't know how much data there is so just keep
218 * increasing the buffer size until the call succeeds
219 */
220 BufferSize = 0;
221 do
222 {
223 BufferSize += 0x10000;
225
227
230 }
231
233
235
236 /*
237 * Save system performance info
238 */
240
241 /*
242 * Save system cache info
243 */
244 memcpy(&SystemCacheInfo, &SysCacheInfo, sizeof(SYSTEM_FILECACHE_INFORMATION));
245
246 /*
247 * Save system processor time info
248 */
251 }
252 SystemProcessorTimeInfo = SysProcessorTimeInfo;
253
254 /*
255 * Save system handle info
256 */
257 SystemNumberOfHandles = SysHandleInfoData.NumberOfHandles;
258
259 for (CurrentKernelTime=0, Idx=0; Idx<(ULONG)SystemBasicInfo.NumberOfProcessors; Idx++) {
260 CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime);
261 CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].DpcTime);
262 CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].InterruptTime);
263 }
264
265 /* If it's a first call - skip idle time calcs */
266 if (liOldIdleTime.QuadPart != 0) {
267 /* CurrentValue = NewValue - OldValue */
269 dbKernelTime = CurrentKernelTime - OldKernelTime;
271
272 /* CurrentCpuIdle = IdleTime / SystemTime */
275
276 /* CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors */
277 dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
278 dbKernelTime = 100.0 - dbKernelTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
279 }
280
281 /* Store new CPU's idle and system time */
282 liOldIdleTime = SysPerfInfo.IdleProcessTime;
283 liOldSystemTime = SysTimeInfo.CurrentTime;
284 OldKernelTime = CurrentKernelTime;
285
286 /* Determine the process count
287 * We loop through the data we got from NtQuerySystemInformation
288 * and count how many structures there are (until RelativeOffset is 0)
289 */
291 ProcessCount = 0;
293 while (pSPI) {
294 ProcessCount++;
295 if (pSPI->NextEntryOffset == 0)
296 break;
297 pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->NextEntryOffset);
298 }
299
300 /* Now alloc a new PERFDATA array and fill in the data */
302
304 for (Idx=0; Idx<ProcessCount; Idx++) {
305 /* Get the old perf data for this process (if any) */
306 /* so that we can establish delta values */
307 pPDOld = NULL;
308 if (pPerfDataOld) {
309 for (Idx2=0; Idx2<ProcessCountOld; Idx2++) {
310 if (pPerfDataOld[Idx2].ProcessId == pSPI->UniqueProcessId) {
311 pPDOld = &pPerfDataOld[Idx2];
312 break;
313 }
314 }
315 }
316
317 if (pSPI->ImageName.Buffer) {
318 /* Don't assume a UNICODE_STRING Buffer is zero terminated: */
319 int len = pSPI->ImageName.Length / 2;
320 /* Check against max size and allow for terminating zero (already zeroed): */
321 if(len >= MAX_PATH)len=MAX_PATH - 1;
323 } else {
326 }
327
329
330 if (pPDOld) {
331 double CurTime = Li2Double(pSPI->KernelTime) + Li2Double(pSPI->UserTime);
332 double OldTime = Li2Double(pPDOld->KernelTime) + Li2Double(pPDOld->UserTime);
333 double CpuTime = (CurTime - OldTime) / dbSystemTime;
334 CpuTime = CpuTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
335 pPerfData[Idx].CPUUsage = (ULONG)CpuTime;
336 }
340 if (pPDOld)
342 else
345 if (pPDOld)
347 else
353 pPerfData[Idx].HandleCount = pSPI->HandleCount;
355 pPerfData[Idx].SessionId = pSPI->SessionId;
357 pPerfData[Idx].USERObjectCount = 0;
358 pPerfData[Idx].GDIObjectCount = 0;
359 ProcessUser = SystemUserSid;
360 ProcessSD = NULL;
361
362 if (pSPI->UniqueProcessId != NULL) {
364 if (hProcess) {
365 /* don't query the information of the system process. It's possible but
366 returns Administrators as the owner of the process instead of SYSTEM */
367 if (pSPI->UniqueProcessId != (HANDLE)0x4)
368 {
369 if (OpenProcessToken(hProcess, TOKEN_QUERY, &hProcessToken))
370 {
371 DWORD RetLen = 0;
372 BOOL Ret;
373
374 Ret = GetTokenInformation(hProcessToken, TokenUser, (LPVOID)Buffer, sizeof(Buffer), &RetLen);
375 CloseHandle(hProcessToken);
376
377 if (Ret)
378 ProcessUser = ((PTOKEN_USER)Buffer)->User.Sid;
379 else
380 goto ReadProcOwner;
381 }
382 else
383 {
384ReadProcOwner:
386 }
387
388 pPerfData[Idx].USERObjectCount = GetGuiResources(hProcess, GR_USEROBJECTS);
389 pPerfData[Idx].GDIObjectCount = GetGuiResources(hProcess, GR_GDIOBJECTS);
390 }
391
392 GetProcessIoCounters(hProcess, &pPerfData[Idx].IOCounters);
394 } else {
395 goto ClearInfo;
396 }
397 } else {
398ClearInfo:
399 /* clear information we were unable to fetch */
400 ZeroMemory(&pPerfData[Idx].IOCounters, sizeof(IO_COUNTERS));
401 }
402
403 cwcUserName = _countof(pPerfData[0].UserName);
404 CachedGetUserFromSid(ProcessUser, pPerfData[Idx].UserName, &cwcUserName);
405
406 if (ProcessSD != NULL)
407 {
408 LocalFree((HLOCAL)ProcessSD);
409 }
410
413 pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->NextEntryOffset);
414 }
416 if (pPerfDataOld) {
418 }
421}
422
424{
425 ULONG idx;
426
428
429 for (idx = 0; idx < ProcessCount; idx++)
430 {
432 {
433 break;
434 }
435 }
436
438
439 if (idx == ProcessCount)
440 {
441 return -1;
442 }
443 return idx;
444}
445
447{
452 return Result;
453}
454
456{
459 Result = (ULONG)min(max(dbIdleTime, 0.), 100.);
461 return Result;
462}
463
465{
468 Result = (ULONG)min(max(dbKernelTime, 0.), 100.);
470 return Result;
471}
472
474{
475 BOOL bSuccessful;
476
478
479 if (Index < ProcessCount) {
480 wcsncpy(lpImageName, pPerfData[Index].ImageName, nMaxCount);
481 bSuccessful = TRUE;
482 } else {
483 bSuccessful = FALSE;
484 }
486 return bSuccessful;
487}
488
490{
492
494
495 if (Index < ProcessCount)
497 else
498 ProcessId = 0;
499
501
502 return ProcessId;
503}
504
506{
507 BOOL bSuccessful;
508
510
511 if (Index < ProcessCount) {
512 wcsncpy(lpUserName, pPerfData[Index].UserName, nMaxCount);
513 bSuccessful = TRUE;
514 } else {
515 bSuccessful = FALSE;
516 }
517
519
520 return bSuccessful;
521}
522
524{
525 static const LPWSTR ellipsis = L"...";
526
528 UNICODE_STRING CommandLineStr = {0};
529
530 PVOID ProcessParams = NULL;
533
535 BOOL result;
536
537 PCMD_LINE_CACHE new_entry;
538 LPWSTR new_string;
539
541
542 /* [A] Search for a string already in cache? If so, use it */
543 while (cache && cache->pnext != NULL)
544 {
545 if (cache->idx == Index && cache->str != NULL)
546 {
547 /* Found it. Use it, and add some ellipsis at the very end to make it cute */
548 wcsncpy(lpCommandLine, cache->str, CMD_LINE_MIN(nMaxCount, cache->len));
549 wcscpy(lpCommandLine + CMD_LINE_MIN(nMaxCount, cache->len) - wcslen(ellipsis), ellipsis);
550 return TRUE;
551 }
552
553 cache = cache->pnext;
554 }
555
556 /* [B] We don't; let's allocate and load a value from the process mem... and cache it */
558
559 /* Default blank command line in case things don't work out */
560 wcsncpy(lpCommandLine, L"", nMaxCount);
561
562 /* Ask for a handle to the target process so that we can read its memory and query stuff */
564 if (!hProcess)
565 goto cleanup;
566
567 /* First off, get the ProcessEnvironmentBlock location in that process' address space */
569 if (!NT_SUCCESS(Status))
570 goto cleanup;
571
572 /* Then get the PEB.ProcessParameters member pointer */
574 (PVOID)((ULONG_PTR)pbi.PebBaseAddress + FIELD_OFFSET(PEB, ProcessParameters)),
575 &ProcessParams,
576 sizeof(ProcessParams),
577 NULL);
578 if (!result)
579 goto cleanup;
580
581 /* Then copy the PEB->ProcessParameters.CommandLine member
582 to get the pointer to the string buffer and its size */
584 (PVOID)((ULONG_PTR)ProcessParams + FIELD_OFFSET(RTL_USER_PROCESS_PARAMETERS, CommandLine)),
585 &CommandLineStr,
586 sizeof(CommandLineStr),
587 NULL);
588 if (!result)
589 goto cleanup;
590
591 /* Allocate the next cache entry and its accompanying string in one go */
592 new_entry = HeapAlloc(GetProcessHeap(),
594 sizeof(CMD_LINE_CACHE) + CommandLineStr.Length + sizeof(UNICODE_NULL));
595 if (!new_entry)
596 goto cleanup;
597
598 new_string = (LPWSTR)((ULONG_PTR)new_entry + sizeof(CMD_LINE_CACHE));
599
600 /* Bingo, the command line should be stored there,
601 copy the string from the other process */
603 CommandLineStr.Buffer,
604 new_string,
605 CommandLineStr.Length,
606 NULL);
607 if (!result)
608 {
609 /* Weird, after successfully reading the mem of that process
610 various times it fails now, forget it and bail out */
611 HeapFree(GetProcessHeap(), 0, new_entry);
612 goto cleanup;
613 }
614
615 /* Add our pointer to the cache... */
616 new_entry->idx = Index;
617 new_entry->str = new_string;
618 new_entry->len = CommandLineStr.Length;
619
620 if (!global_cache)
621 global_cache = new_entry;
622 else
623 cache->pnext = new_entry;
624
625 /* ... and print the buffer for the first time */
626 wcsncpy(lpCommandLine, new_string, CMD_LINE_MIN(nMaxCount, CommandLineStr.Length));
627
628cleanup:
630 return TRUE;
631}
632
634{
635 PCMD_LINE_CACHE cache, pnext;
636
637 for (cache = global_cache; cache; cache = pnext)
638 {
639 pnext = cache->pnext;
641 }
642
644}
645
647{
649
651
652 if (Index < ProcessCount)
654 else
655 SessionId = 0;
656
658
659 return SessionId;
660}
661
663{
664 ULONG CpuUsage;
665
667
668 if (Index < ProcessCount)
669 CpuUsage = pPerfData[Index].CPUUsage;
670 else
671 CpuUsage = 0;
672
674
675 return CpuUsage;
676}
677
679{
680 LARGE_INTEGER CpuTime = {{0,0}};
681
683
684 if (Index < ProcessCount)
685 CpuTime = pPerfData[Index].CPUTime;
686
688
689 return CpuTime;
690}
691
693{
694 ULONG WorkingSetSizeBytes;
695
697
698 if (Index < ProcessCount)
699 WorkingSetSizeBytes = pPerfData[Index].WorkingSetSizeBytes;
700 else
701 WorkingSetSizeBytes = 0;
702
704
705 return WorkingSetSizeBytes;
706}
707
709{
710 ULONG PeakWorkingSetSizeBytes;
711
713
714 if (Index < ProcessCount)
715 PeakWorkingSetSizeBytes = pPerfData[Index].PeakWorkingSetSizeBytes;
716 else
717 PeakWorkingSetSizeBytes = 0;
718
720
721 return PeakWorkingSetSizeBytes;
722}
723
725{
726 ULONG WorkingSetSizeDelta;
727
729
730 if (Index < ProcessCount)
731 WorkingSetSizeDelta = pPerfData[Index].WorkingSetSizeDelta;
732 else
733 WorkingSetSizeDelta = 0;
734
736
737 return WorkingSetSizeDelta;
738}
739
741{
742 ULONG PageFaultCount;
743
745
746 if (Index < ProcessCount)
747 PageFaultCount = pPerfData[Index].PageFaultCount;
748 else
749 PageFaultCount = 0;
750
752
753 return PageFaultCount;
754}
755
757{
758 ULONG PageFaultCountDelta;
759
761
762 if (Index < ProcessCount)
763 PageFaultCountDelta = pPerfData[Index].PageFaultCountDelta;
764 else
765 PageFaultCountDelta = 0;
766
768
769 return PageFaultCountDelta;
770}
771
773{
774 ULONG VirtualMemorySizeBytes;
775
777
778 if (Index < ProcessCount)
779 VirtualMemorySizeBytes = pPerfData[Index].VirtualMemorySizeBytes;
780 else
781 VirtualMemorySizeBytes = 0;
782
784
785 return VirtualMemorySizeBytes;
786}
787
789{
790 ULONG PagedPoolUsage;
791
793
794 if (Index < ProcessCount)
795 PagedPoolUsage = pPerfData[Index].PagedPoolUsagePages;
796 else
797 PagedPoolUsage = 0;
798
800
801 return PagedPoolUsage;
802}
803
805{
806 ULONG NonPagedPoolUsage;
807
809
810 if (Index < ProcessCount)
811 NonPagedPoolUsage = pPerfData[Index].NonPagedPoolUsagePages;
812 else
813 NonPagedPoolUsage = 0;
814
816
817 return NonPagedPoolUsage;
818}
819
821{
822 ULONG BasePriority;
823
825
826 if (Index < ProcessCount)
827 BasePriority = pPerfData[Index].BasePriority;
828 else
829 BasePriority = 0;
830
832
833 return BasePriority;
834}
835
837{
838 ULONG HandleCount;
839
841
842 if (Index < ProcessCount)
843 HandleCount = pPerfData[Index].HandleCount;
844 else
845 HandleCount = 0;
846
848
849 return HandleCount;
850}
851
853{
854 ULONG ThreadCount;
855
857
858 if (Index < ProcessCount)
859 ThreadCount = pPerfData[Index].ThreadCount;
860 else
861 ThreadCount = 0;
862
864
865 return ThreadCount;
866}
867
869{
870 ULONG USERObjectCount;
871
873
874 if (Index < ProcessCount)
875 USERObjectCount = pPerfData[Index].USERObjectCount;
876 else
877 USERObjectCount = 0;
878
880
881 return USERObjectCount;
882}
883
885{
886 ULONG GDIObjectCount;
887
889
890 if (Index < ProcessCount)
891 GDIObjectCount = pPerfData[Index].GDIObjectCount;
892 else
893 GDIObjectCount = 0;
894
896
897 return GDIObjectCount;
898}
899
901{
902 BOOL bSuccessful;
903
905
906 if (Index < ProcessCount)
907 {
908 memcpy(pIoCounters, &pPerfData[Index].IOCounters, sizeof(IO_COUNTERS));
909 bSuccessful = TRUE;
910 }
911 else
912 bSuccessful = FALSE;
913
915
916 return bSuccessful;
917}
918
920{
921 ULONG Total;
922 ULONG PageSize;
923
925
927 PageSize = SystemBasicInfo.PageSize;
928
930
931 Total = Total * (PageSize / 1024);
932
933 return Total;
934}
935
937{
938 ULONG Limit;
939 ULONG PageSize;
940
942
944 PageSize = SystemBasicInfo.PageSize;
945
947
948 Limit = Limit * (PageSize / 1024);
949
950 return Limit;
951}
952
954{
955 ULONG Peak;
956 ULONG PageSize;
957
959
961 PageSize = SystemBasicInfo.PageSize;
962
964
965 Peak = Peak * (PageSize / 1024);
966
967 return Peak;
968}
969
971{
972 ULONG Total;
973 ULONG Paged;
974 ULONG NonPaged;
975 ULONG PageSize;
976
978
981 PageSize = SystemBasicInfo.PageSize;
982
984
985 Paged = Paged * (PageSize / 1024);
986 NonPaged = NonPaged * (PageSize / 1024);
987
988 Total = Paged + NonPaged;
989
990 return Total;
991}
992
994{
995 ULONG Paged;
996 ULONG PageSize;
997
999
1001 PageSize = SystemBasicInfo.PageSize;
1002
1004
1005 Paged = Paged * (PageSize / 1024);
1006
1007 return Paged;
1008}
1009
1011{
1012 ULONG NonPaged;
1013 ULONG PageSize;
1014
1016
1018 PageSize = SystemBasicInfo.PageSize;
1019
1021
1022 NonPaged = NonPaged * (PageSize / 1024);
1023
1024 return NonPaged;
1025}
1026
1028{
1029 ULONG Total;
1030 ULONG PageSize;
1031
1033
1035 PageSize = SystemBasicInfo.PageSize;
1036
1038
1039 Total = Total * (PageSize / 1024);
1040
1041 return Total;
1042}
1043
1045{
1046 ULONG Available;
1047 ULONG PageSize;
1048
1050
1051 Available = SystemPerfInfo.AvailablePages;
1052 PageSize = SystemBasicInfo.PageSize;
1053
1055
1056 Available = Available * (PageSize / 1024);
1057
1058 return Available;
1059}
1060
1062{
1063 ULONG SystemCache;
1064 ULONG PageSize;
1065
1067
1068 PageSize = SystemBasicInfo.PageSize;
1070
1072
1073 return SystemCache / 1024;
1074}
1075
1077{
1078 ULONG HandleCount;
1079
1081
1082 HandleCount = SystemNumberOfHandles;
1083
1085
1086 return HandleCount;
1087}
1088
1090{
1091 ULONG ThreadCount = 0;
1092 ULONG i;
1093
1095
1096 for (i=0; i<ProcessCount; i++)
1097 {
1098 ThreadCount += pPerfData[i].ThreadCount;
1099 }
1100
1102
1103 return ThreadCount;
1104}
1105
1107{
1108 BOOL bSuccessful = FALSE;
1109
1111 if (Index < ProcessCount)
1112 {
1113 *lppData = pPerfData + Index;
1114 bSuccessful = TRUE;
1115 }
1117 return bSuccessful;
1118}
1119
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: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 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:788
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:30
ULONG PerfDataGetWorkingSetSizeBytes(ULONG Index)
Definition: perfdata.c:692
ULONG SystemNumberOfHandles
Definition: perfdata.c:32
ULONG PerfDataGetWorkingSetSizeDelta(ULONG Index)
Definition: perfdata.c:724
PPERFDATA pPerfData
Definition: perfdata.c:20
ULONG PerfDataGetPageFaultCountDelta(ULONG Index)
Definition: perfdata.c:756
ULONG PerfDataGetProcessIndex(ULONG pid)
Definition: perfdata.c:423
struct _SIDTOUSERNAME SIDTOUSERNAME
ULONG PerfDataGetKernelMemoryNonPagedK(void)
Definition: perfdata.c:1010
ULONG PerfDataGetPageFaultCount(ULONG Index)
Definition: perfdata.c:740
ULONG PerfDataGetSystemHandleCount(void)
Definition: perfdata.c:1076
ULONG PerfDataGetSessionId(ULONG Index)
Definition: perfdata.c:646
double dbIdleTime
Definition: perfdata.c:23
ULONG PerfDataGetPhysicalMemoryTotalK(void)
Definition: perfdata.c:1027
PPERFDATA pPerfDataOld
Definition: perfdata.c:19
ULONG PerfDataGetTotalThreadCount(void)
Definition: perfdata.c:1089
void PerfDataDeallocCommandLineCache()
Definition: perfdata.c:633
ULONG PerfDataGetCommitChargePeakK(void)
Definition: perfdata.c:953
ULONG PerfDataGetProcessorSystemUsage(void)
Definition: perfdata.c:464
PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SystemProcessorTimeInfo
Definition: perfdata.c:33
LARGE_INTEGER PerfDataGetCPUTime(ULONG Index)
Definition: perfdata.c:678
ULONG PerfDataGetHandleCount(ULONG Index)
Definition: perfdata.c:836
ULONG PerfDataGetProcessId(ULONG Index)
Definition: perfdata.c:489
ULONG PerfDataGetProcessorUsage(void)
Definition: perfdata.c:455
ULONG PerfDataGetCPUUsage(ULONG Index)
Definition: perfdata.c:662
ULONG PerfDataGetKernelMemoryPagedK(void)
Definition: perfdata.c:993
BOOL PerfDataGetCommandLine(ULONG Index, LPWSTR lpCommandLine, ULONG nMaxCount)
Definition: perfdata.c:523
PCMD_LINE_CACHE global_cache
Definition: perfdata.c:36
PSID SystemUserSid
Definition: perfdata.c:34
ULONG PerfDataGetKernelMemoryTotalK(void)
Definition: perfdata.c:970
ULONG ProcessCountOld
Definition: perfdata.c:21
ULONG PerfDataGetCommitChargeLimitK(void)
Definition: perfdata.c:936
double dbKernelTime
Definition: perfdata.c:24
ULONG PerfDataGetThreadCount(ULONG Index)
Definition: perfdata.c:852
ULONG PerfDataGetBasePriority(ULONG Index)
Definition: perfdata.c:820
BOOL PerfDataGetUserName(ULONG Index, LPWSTR lpUserName, ULONG nMaxCount)
Definition: perfdata.c:505
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:868
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:1044
ULONG PerfDataGetNonPagedPoolUsagePages(ULONG Index)
Definition: perfdata.c:804
ULONG PerfDataGetCommitChargeTotalK(void)
Definition: perfdata.c:919
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:772
VOID WINAPI CachedGetUserFromSid(PSID pSid, LPWSTR pUserName, PULONG pcwcUserName)
Definition: perfdata.c:112
BOOL PerfDataGetImageName(ULONG Index, LPWSTR lpImageName, ULONG nMaxCount)
Definition: perfdata.c:473
ULONG PerfDataGetPeakWorkingSetSizeBytes(ULONG Index)
Definition: perfdata.c:708
ULONG PerfDataGetGDIObjectCount(ULONG Index)
Definition: perfdata.c:884
BOOL PerfDataGetIOCounters(ULONG Index, PIO_COUNTERS pIoCounters)
Definition: perfdata.c:900
static LIST_ENTRY SidToUserNameHead
Definition: perfdata.c:47
SYSTEM_FILECACHE_INFORMATION SystemCacheInfo
Definition: perfdata.c:31
ULONG PerfDataGetProcessCount(void)
Definition: perfdata.c:446
BOOL PerfDataGet(ULONG Index, PPERFDATA *lppData)
Definition: perfdata.c:1106
#define CMD_LINE_MIN(a, b)
Definition: perfdata.c:38
ULONG PerfDataGetPhysicalMemorySystemCacheK(void)
Definition: perfdata.c:1061
#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
_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)
#define _countof(array)
Definition: sndvol32.h:68
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: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:1712
_In_ LPCSTR _Out_writes_bytes_to_opt_ cbSid PSID _Inout_ LPDWORD cbSid
Definition: winbase.h:2743
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:4877
_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: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