ReactOS 0.4.16-dev-1279-gc894716
perfdata.c File Reference
#include "precomp.h"
#include <aclapi.h>
#include <ndk/psfuncs.h>
#include <ndk/exfuncs.h>
Include dependency graph for perfdata.c:

Go to the source code of this file.

Classes

struct  _SIDTOUSERNAME
 

Macros

#define WIN32_LEAN_AND_MEAN
 
#define NTOS_MODE_USER
 
#define CMD_LINE_MIN(a, b)   (a < b ? a - sizeof(WCHAR) : b)
 

Typedefs

typedef struct _SIDTOUSERNAME SIDTOUSERNAME
 
typedef struct _SIDTOUSERNAMEPSIDTOUSERNAME
 

Functions

BOOL PerfDataInitialize (void)
 
void PerfDataUninitialize (void)
 
static void SidToUserName (PSID Sid, LPWSTR szBuffer, DWORD BufferSize)
 
VOID WINAPI CachedGetUserFromSid (PSID pSid, LPWSTR pUserName, PULONG pcwcUserName)
 
void PerfDataRefresh (void)
 
ULONG PerfDataGetProcessIndex (ULONG pid)
 
ULONG PerfDataGetProcessCount (void)
 
ULONG PerfDataGetProcessorUsage (void)
 
ULONG PerfDataGetProcessorSystemUsage (void)
 
BOOL PerfDataGetImageName (ULONG Index, LPWSTR lpImageName, ULONG nMaxCount)
 
ULONG PerfDataGetProcessId (ULONG Index)
 
BOOL PerfDataGetUserName (ULONG Index, LPWSTR lpUserName, ULONG nMaxCount)
 
BOOL PerfDataGetCommandLine (ULONG Index, LPWSTR lpCommandLine, ULONG nMaxCount)
 
void PerfDataDeallocCommandLineCache ()
 
ULONG PerfDataGetSessionId (ULONG Index)
 
ULONG PerfDataGetCPUUsage (ULONG Index)
 
LARGE_INTEGER PerfDataGetCPUTime (ULONG Index)
 
ULONG PerfDataGetWorkingSetSizeBytes (ULONG Index)
 
ULONG PerfDataGetPeakWorkingSetSizeBytes (ULONG Index)
 
ULONG PerfDataGetWorkingSetSizeDelta (ULONG Index)
 
ULONG PerfDataGetPageFaultCount (ULONG Index)
 
ULONG PerfDataGetPageFaultCountDelta (ULONG Index)
 
ULONG PerfDataGetVirtualMemorySizeBytes (ULONG Index)
 
ULONG PerfDataGetPagedPoolUsagePages (ULONG Index)
 
ULONG PerfDataGetNonPagedPoolUsagePages (ULONG Index)
 
ULONG PerfDataGetBasePriority (ULONG Index)
 
ULONG PerfDataGetHandleCount (ULONG Index)
 
ULONG PerfDataGetThreadCount (ULONG Index)
 
ULONG PerfDataGetUSERObjectCount (ULONG Index)
 
ULONG PerfDataGetGDIObjectCount (ULONG Index)
 
BOOL PerfDataGetIOCounters (ULONG Index, PIO_COUNTERS pIoCounters)
 
ULONG PerfDataGetCommitChargeTotalK (void)
 
ULONG PerfDataGetCommitChargeLimitK (void)
 
ULONG PerfDataGetCommitChargePeakK (void)
 
ULONG PerfDataGetKernelMemoryTotalK (void)
 
ULONG PerfDataGetKernelMemoryPagedK (void)
 
ULONG PerfDataGetKernelMemoryNonPagedK (void)
 
ULONG PerfDataGetPhysicalMemoryTotalK (void)
 
ULONG PerfDataGetPhysicalMemoryAvailableK (void)
 
ULONG PerfDataGetPhysicalMemorySystemCacheK (void)
 
ULONG PerfDataGetSystemHandleCount (void)
 
ULONG PerfDataGetTotalThreadCount (void)
 
BOOL PerfDataGet (ULONG Index, PPERFDATA *lppData)
 

Variables

CRITICAL_SECTION PerfDataCriticalSection
 
PPERFDATA pPerfDataOld = NULL
 
PPERFDATA pPerfData = NULL
 
ULONG ProcessCountOld = 0
 
ULONG ProcessCount = 0
 
double dbIdleTime
 
double dbKernelTime
 
double dbSystemTime
 
LARGE_INTEGER liOldIdleTime = {{0,0}}
 
double OldKernelTime = 0
 
LARGE_INTEGER liOldSystemTime = {{0,0}}
 
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo
 
SYSTEM_BASIC_INFORMATION SystemBasicInfo
 
SYSTEM_FILECACHE_INFORMATION SystemCacheInfo
 
ULONG SystemNumberOfHandles
 
PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SystemProcessorTimeInfo = NULL
 
PSID SystemUserSid = NULL
 
PCMD_LINE_CACHE global_cache = NULL
 
static LIST_ENTRY SidToUserNameHead = {&SidToUserNameHead, &SidToUserNameHead}
 

Macro Definition Documentation

◆ CMD_LINE_MIN

#define CMD_LINE_MIN (   a,
  b 
)    (a < b ? a - sizeof(WCHAR) : b)

Definition at line 38 of file perfdata.c.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 14 of file perfdata.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 11 of file perfdata.c.

Typedef Documentation

◆ PSIDTOUSERNAME

◆ SIDTOUSERNAME

Function Documentation

◆ CachedGetUserFromSid()

VOID WINAPI CachedGetUserFromSid ( PSID  pSid,
LPWSTR  pUserName,
PULONG  pcwcUserName 
)

Definition at line 119 of file perfdata.c.

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}
static LPWSTR PULONG pcwcUserName
static LPWSTR pUserName
wcsncpy
BOOL WINAPI CopySid(DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid)
Definition: security.c:712
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:919
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:829
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
SINGLE_LIST_ENTRY * pCur
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static PSID pSid
Definition: security.c:74
static void SidToUserName(PSID Sid, LPWSTR szBuffer, DWORD BufferSize)
Definition: perfdata.c:107
static LIST_ENTRY SidToUserNameHead
Definition: perfdata.c:47
Definition: typedefs.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
_In_ LPCSTR _Out_writes_bytes_to_opt_ cbSid PSID _Inout_ LPDWORD cbSid
Definition: winbase.h:2784
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by PerfDataRefresh().

◆ PerfDataDeallocCommandLineCache()

void PerfDataDeallocCommandLineCache ( )

Definition at line 648 of file perfdata.c.

649{
650 PCMD_LINE_CACHE cache, pnext;
651
652 for (cache = global_cache; cache; cache = pnext)
653 {
654 pnext = cache->pnext;
656 }
657
659}
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:735
PCMD_LINE_CACHE global_cache
Definition: perfdata.c:36
Definition: cache.c:49

Referenced by TaskManagerWndProc().

◆ PerfDataGet()

BOOL PerfDataGet ( ULONG  Index,
PPERFDATA lppData 
)

Definition at line 1121 of file perfdata.c.

1122{
1123 BOOL bSuccessful = FALSE;
1124
1126 if (Index < ProcessCount)
1127 {
1128 *lppData = pPerfData + Index;
1129 bSuccessful = TRUE;
1130 }
1132 return bSuccessful;
1133}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
PPERFDATA pPerfData
Definition: perfdata.c:20
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:18
ULONG ProcessCount
Definition: perfdata.c:22
_In_ WDFCOLLECTION _In_ ULONG Index
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

◆ PerfDataGetBasePriority()

ULONG PerfDataGetBasePriority ( ULONG  Index)

Definition at line 835 of file perfdata.c.

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}
ULONG BasePriority
Definition: perfdata.h:29

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetCommandLine()

BOOL PerfDataGetCommandLine ( ULONG  Index,
LPWSTR  lpCommandLine,
ULONG  nMaxCount 
)

Definition at line 538 of file perfdata.c.

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}
LONG NTSTATUS
Definition: precomp.h:26
wcscpy
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define CloseHandle
Definition: compat.h:739
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static void cleanup(void)
Definition: main.c:1335
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2712
Status
Definition: gdiplustypes.h:25
GLuint64EXT * result
Definition: glext.h:11304
#define PROCESS_VM_READ
Definition: pstypes.h:162
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:167
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#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
ULONG PerfDataGetProcessId(ULONG Index)
Definition: perfdata.c:504
#define CMD_LINE_MIN(a, b)
Definition: perfdata.c:38
struct _CMD_LINE_CACHE CMD_LINE_CACHE
LPWSTR str
Definition: perfdata.h:43
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Inout_ PERBANDINFO * pbi
Definition: winddi.h:3917
_In_ int nMaxCount
Definition: winuser.h:4953

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetCommitChargeLimitK()

ULONG PerfDataGetCommitChargeLimitK ( void  )

Definition at line 951 of file perfdata.c.

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}
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:30
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo
Definition: perfdata.c:29
_In_ LONG _In_ LONG Limit
Definition: kefuncs.h:304

Referenced by Graph_DrawMemUsageGraph(), and PerformancePageRefreshThread().

◆ PerfDataGetCommitChargePeakK()

ULONG PerfDataGetCommitChargePeakK ( void  )

Definition at line 968 of file perfdata.c.

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}

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetCommitChargeTotalK()

ULONG PerfDataGetCommitChargeTotalK ( void  )

Definition at line 934 of file perfdata.c.

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}

Referenced by Graph_DrawMemUsageGraph(), and PerformancePageRefreshThread().

◆ PerfDataGetCPUTime()

LARGE_INTEGER PerfDataGetCPUTime ( ULONG  Index)

Definition at line 693 of file perfdata.c.

694{
695 LARGE_INTEGER CpuTime = {{0,0}};
696
698
699 if (Index < ProcessCount)
700 CpuTime = pPerfData[Index].CPUTime;
701
703
704 return CpuTime;
705}
LARGE_INTEGER CPUTime
Definition: perfdata.h:20

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetCPUUsage()

ULONG PerfDataGetCPUUsage ( ULONG  Index)

Definition at line 677 of file perfdata.c.

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}
ULONG CPUUsage
Definition: perfdata.h:19

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetGDIObjectCount()

ULONG PerfDataGetGDIObjectCount ( ULONG  Index)

Definition at line 899 of file perfdata.c.

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}
ULONG GDIObjectCount
Definition: perfdata.h:33

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetHandleCount()

ULONG PerfDataGetHandleCount ( ULONG  Index)

Definition at line 851 of file perfdata.c.

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}
ULONG HandleCount
Definition: perfdata.h:30

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetImageName()

BOOL PerfDataGetImageName ( ULONG  Index,
LPWSTR  lpImageName,
ULONG  nMaxCount 
)

Definition at line 488 of file perfdata.c.

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}
static const char * ImageName
Definition: image.c:34

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetIOCounters()

BOOL PerfDataGetIOCounters ( ULONG  Index,
PIO_COUNTERS  pIoCounters 
)

Definition at line 915 of file perfdata.c.

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}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetKernelMemoryNonPagedK()

ULONG PerfDataGetKernelMemoryNonPagedK ( void  )

Definition at line 1025 of file perfdata.c.

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}

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetKernelMemoryPagedK()

ULONG PerfDataGetKernelMemoryPagedK ( void  )

Definition at line 1008 of file perfdata.c.

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}

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetKernelMemoryTotalK()

ULONG PerfDataGetKernelMemoryTotalK ( void  )

Definition at line 985 of file perfdata.c.

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}

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetNonPagedPoolUsagePages()

ULONG PerfDataGetNonPagedPoolUsagePages ( ULONG  Index)

Definition at line 819 of file perfdata.c.

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}
ULONG NonPagedPoolUsagePages
Definition: perfdata.h:28

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetPagedPoolUsagePages()

ULONG PerfDataGetPagedPoolUsagePages ( ULONG  Index)

Definition at line 803 of file perfdata.c.

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}
ULONG PagedPoolUsagePages
Definition: perfdata.h:27

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetPageFaultCount()

ULONG PerfDataGetPageFaultCount ( ULONG  Index)

Definition at line 755 of file perfdata.c.

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}
ULONG PageFaultCount
Definition: perfdata.h:24

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetPageFaultCountDelta()

ULONG PerfDataGetPageFaultCountDelta ( ULONG  Index)

Definition at line 771 of file perfdata.c.

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}
ULONG PageFaultCountDelta
Definition: perfdata.h:25

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetPeakWorkingSetSizeBytes()

ULONG PerfDataGetPeakWorkingSetSizeBytes ( ULONG  Index)

Definition at line 723 of file perfdata.c.

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}
ULONG PeakWorkingSetSizeBytes
Definition: perfdata.h:22

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetPhysicalMemoryAvailableK()

ULONG PerfDataGetPhysicalMemoryAvailableK ( void  )

Definition at line 1059 of file perfdata.c.

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}

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetPhysicalMemorySystemCacheK()

ULONG PerfDataGetPhysicalMemorySystemCacheK ( void  )

Definition at line 1076 of file perfdata.c.

1077{
1078 ULONG SystemCache;
1079 ULONG PageSize;
1080
1082
1083 PageSize = SystemBasicInfo.PageSize;
1085
1087
1088 return SystemCache / 1024;
1089}
SYSTEM_FILECACHE_INFORMATION SystemCacheInfo
Definition: perfdata.c:31
SIZE_T CurrentSizeIncludingTransitionInPages
Definition: extypes.h:1133

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetPhysicalMemoryTotalK()

ULONG PerfDataGetPhysicalMemoryTotalK ( void  )

Definition at line 1042 of file perfdata.c.

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}

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetProcessCount()

ULONG PerfDataGetProcessCount ( void  )

Definition at line 461 of file perfdata.c.

462{
467 return Result;
468}
_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

Referenced by PerformancePageRefreshThread(), and UpdateProcesses().

◆ PerfDataGetProcessId()

ULONG PerfDataGetProcessId ( ULONG  Index)

Definition at line 504 of file perfdata.c.

505{
507
509
510 if (Index < ProcessCount)
512 else
513 ProcessId = 0;
514
516
517 return ProcessId;
518}
#define PtrToUlong(u)
Definition: config.h:107

Referenced by AddProcess(), PerfDataGetCommandLine(), and PerfDataGetText().

◆ PerfDataGetProcessIndex()

ULONG PerfDataGetProcessIndex ( ULONG  pid)

Definition at line 438 of file perfdata.c.

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}
unsigned int idx
Definition: utils.c:41
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837

Referenced by ProcessPageCompareFunc(), and ProcessPageOnNotify().

◆ PerfDataGetProcessorSystemUsage()

ULONG PerfDataGetProcessorSystemUsage ( void  )

Definition at line 479 of file perfdata.c.

480{
483 Result = (ULONG)min(max(dbKernelTime, 0.), 100.);
485 return Result;
486}
#define min(a, b)
Definition: monoChain.cc:55
double dbKernelTime
Definition: perfdata.c:24
#define max(a, b)
Definition: svc.c:63

Referenced by Graph_DrawCpuUsageGraph(), and PerformancePageRefreshThread().

◆ PerfDataGetProcessorUsage()

ULONG PerfDataGetProcessorUsage ( void  )

◆ PerfDataGetSessionId()

ULONG PerfDataGetSessionId ( ULONG  Index)

Definition at line 661 of file perfdata.c.

662{
664
666
667 if (Index < ProcessCount)
669 else
670 SessionId = 0;
671
673
674 return SessionId;
675}
ULONG SessionId
Definition: dllmain.c:28
ULONG SessionId
Definition: perfdata.h:18

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetSystemHandleCount()

ULONG PerfDataGetSystemHandleCount ( void  )

Definition at line 1091 of file perfdata.c.

1092{
1093 ULONG HandleCount;
1094
1096
1097 HandleCount = SystemNumberOfHandles;
1098
1100
1101 return HandleCount;
1102}
ULONG SystemNumberOfHandles
Definition: perfdata.c:32

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetThreadCount()

ULONG PerfDataGetThreadCount ( ULONG  Index)

Definition at line 867 of file perfdata.c.

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}
ULONG ThreadCount
Definition: perfdata.h:31

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetTotalThreadCount()

ULONG PerfDataGetTotalThreadCount ( void  )

Definition at line 1104 of file perfdata.c.

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}
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

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetUserName()

BOOL PerfDataGetUserName ( ULONG  Index,
LPWSTR  lpUserName,
ULONG  nMaxCount 
)

Definition at line 520 of file perfdata.c.

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}

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetUSERObjectCount()

ULONG PerfDataGetUSERObjectCount ( ULONG  Index)

Definition at line 883 of file perfdata.c.

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}
ULONG USERObjectCount
Definition: perfdata.h:32

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetVirtualMemorySizeBytes()

ULONG PerfDataGetVirtualMemorySizeBytes ( ULONG  Index)

Definition at line 787 of file perfdata.c.

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}
ULONG VirtualMemorySizeBytes
Definition: perfdata.h:26

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetWorkingSetSizeBytes()

ULONG PerfDataGetWorkingSetSizeBytes ( ULONG  Index)

Definition at line 707 of file perfdata.c.

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}
ULONG WorkingSetSizeBytes
Definition: perfdata.h:21

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetWorkingSetSizeDelta()

ULONG PerfDataGetWorkingSetSizeDelta ( ULONG  Index)

Definition at line 739 of file perfdata.c.

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}
ULONG WorkingSetSizeDelta
Definition: perfdata.h:23

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataInitialize()

BOOL PerfDataInitialize ( void  )

Definition at line 49 of file perfdata.c.

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}
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
@ SystemBasicInformation
Definition: ntddk_ex.h:11
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION * PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SystemProcessorTimeInfo
Definition: perfdata.c:33
PSID SystemUserSid
Definition: perfdata.c:34
static SID_IDENTIFIER_AUTHORITY NtSidAuthority
Definition: samrpc.c:14
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
Definition: ps.c:97
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define SECURITY_LOCAL_SYSTEM_RID
Definition: setypes.h:574
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554

Referenced by wWinMain().

◆ PerfDataRefresh()

void PerfDataRefresh ( void  )

Definition at line 165 of file perfdata.c.

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}
@ SE_KERNEL_OBJECT
Definition: accctrl.h:165
#define IDS_IDLE_PROCESS
Definition: resource.h:10
Definition: bufpool.h:45
wcscat
#define BufferSize
Definition: mmc.h:75
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 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
#define IsWow64Process
Definition: compat.h:760
#define MAX_PATH
Definition: compat.h:34
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
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
@ SystemTimeOfDayInformation
Definition: ntddk_ex.h:14
@ SystemFileCacheInformation
Definition: ntddk_ex.h:32
@ SystemHandleInformation
Definition: ntddk_ex.h:27
@ SystemProcessInformation
Definition: ntddk_ex.h:16
@ SystemProcessorPerformanceInformation
Definition: ntddk_ex.h:19
GLenum GLsizei len
Definition: glext.h:6722
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
_Check_return_ long __cdecl labs(_In_ long x)
#define SystemPerformanceInformation
Definition: memtest.h:87
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:89
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
struct _SYSTEM_PROCESS_INFORMATION * PSYSTEM_PROCESS_INFORMATION
#define READ_CONTROL
Definition: nt_native.h:58
EXTINLINE DWORD WINAPI GetGuiResources(HANDLE hProcess, DWORD uiFlags)
Definition: ntwrapper.h:64
long LONG
Definition: pedump.c:60
PPERFDATA pPerfDataOld
Definition: perfdata.c:19
ULONG ProcessCountOld
Definition: perfdata.c:21
double dbSystemTime
Definition: perfdata.c:25
LARGE_INTEGER liOldIdleTime
Definition: perfdata.c:26
double OldKernelTime
Definition: perfdata.c:27
LARGE_INTEGER liOldSystemTime
Definition: perfdata.c:28
VOID WINAPI CachedGetUserFromSid(PSID pSid, LPWSTR pUserName, PULONG pcwcUserName)
Definition: perfdata.c:119
#define Li2Double(x)
Definition: perfdata.h:11
struct _PERFDATA PERFDATA
struct _PERFDATA * PPERFDATA
PVOID pBuffer
#define _countof(array)
Definition: sndvol32.h:70
WCHAR UserName[MAX_PATH]
Definition: perfdata.h:17
LARGE_INTEGER UserTime
Definition: perfdata.h:36
LARGE_INTEGER KernelTime
Definition: perfdata.h:37
HANDLE ProcessId
Definition: perfdata.h:16
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
unsigned char * LPBYTE
Definition: typedefs.h:53
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
#define ZeroMemory
Definition: winbase.h:1753
struct _TOKEN_USER * PTOKEN_USER
#define TOKEN_QUERY
Definition: setypes.h:940
#define OWNER_SECURITY_INFORMATION
Definition: setypes.h:123
@ TokenUser
Definition: setypes.h:978

Referenced by OnCreate(), and TaskManagerWndProc().

◆ PerfDataUninitialize()

void PerfDataUninitialize ( void  )

Definition at line 77 of file perfdata.c.

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}
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by wWinMain().

◆ SidToUserName()

static void SidToUserName ( PSID  Sid,
LPWSTR  szBuffer,
DWORD  BufferSize 
)
static

Definition at line 107 of file perfdata.c.

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}
BOOL WINAPI LookupAccountSidW(LPCWSTR pSystemName, PSID pSid, LPWSTR pAccountName, LPDWORD pdwAccountName, LPWSTR pDomainName, LPDWORD pdwDomainName, PSID_NAME_USE peUse)
Definition: misc.c:537
enum _SID_NAME_USE SID_NAME_USE
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1157

Referenced by CachedGetUserFromSid().

Variable Documentation

◆ dbIdleTime

double dbIdleTime

Definition at line 23 of file perfdata.c.

Referenced by PerfDataGetProcessorUsage(), and PerfDataRefresh().

◆ dbKernelTime

double dbKernelTime

Definition at line 24 of file perfdata.c.

Referenced by PerfDataGetProcessorSystemUsage(), and PerfDataRefresh().

◆ dbSystemTime

double dbSystemTime

Definition at line 25 of file perfdata.c.

Referenced by PerfDataRefresh().

◆ global_cache

PCMD_LINE_CACHE global_cache = NULL

Definition at line 36 of file perfdata.c.

Referenced by PerfDataDeallocCommandLineCache(), and PerfDataGetCommandLine().

◆ liOldIdleTime

LARGE_INTEGER liOldIdleTime = {{0,0}}

Definition at line 26 of file perfdata.c.

Referenced by PerfDataRefresh().

◆ liOldSystemTime

LARGE_INTEGER liOldSystemTime = {{0,0}}

Definition at line 28 of file perfdata.c.

Referenced by PerfDataRefresh().

◆ OldKernelTime

double OldKernelTime = 0

Definition at line 27 of file perfdata.c.

Referenced by PerfDataRefresh().

◆ PerfDataCriticalSection

◆ pPerfData

◆ pPerfDataOld

PPERFDATA pPerfDataOld = NULL

Definition at line 19 of file perfdata.c.

Referenced by PerfDataRefresh().

◆ ProcessCount

◆ ProcessCountOld

ULONG ProcessCountOld = 0

Definition at line 21 of file perfdata.c.

Referenced by PerfDataRefresh().

◆ SidToUserNameHead

LIST_ENTRY SidToUserNameHead = {&SidToUserNameHead, &SidToUserNameHead}
static

Definition at line 47 of file perfdata.c.

Referenced by CachedGetUserFromSid(), and PerfDataUninitialize().

◆ SystemBasicInfo

◆ SystemCacheInfo

Definition at line 31 of file perfdata.c.

Referenced by PerfDataGetPhysicalMemorySystemCacheK(), and PerfDataRefresh().

◆ SystemNumberOfHandles

ULONG SystemNumberOfHandles

Definition at line 32 of file perfdata.c.

Referenced by PerfDataGetSystemHandleCount(), and PerfDataRefresh().

◆ SystemPerfInfo

◆ SystemProcessorTimeInfo

Definition at line 33 of file perfdata.c.

Referenced by PerfDataInitialize(), PerfDataRefresh(), and PerfDataUninitialize().

◆ SystemUserSid

PSID SystemUserSid = NULL

Definition at line 34 of file perfdata.c.

Referenced by PerfDataInitialize(), PerfDataRefresh(), and PerfDataUninitialize().