ReactOS  0.4.15-dev-3331-g8ebe441
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 53 of file perfdata.c.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 29 of file perfdata.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 26 of file perfdata.c.

Typedef Documentation

◆ PSIDTOUSERNAME

◆ SIDTOUSERNAME

Function Documentation

◆ CachedGetUserFromSid()

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

Definition at line 127 of file perfdata.c.

131 {
134  ULONG cbSid, cwcUserName;
135 
136  cwcUserName = *pcwcUserName;
137 
138  /* Walk through the list */
141  pCur = pCur->Flink)
142  {
144  if (EqualSid((PSID)&pEntry->Data, pSid))
145  {
146  wcsncpy(pUserName, pEntry->pszName, cwcUserName);
148  return;
149  }
150  }
151 
152  /* We didn't find the SID in the list, get the name conventional */
153  SidToUserName(pSid, pUserName, cwcUserName);
155 
156  /* Allocate a new entry */
157  cwcUserName = *pcwcUserName + 1;
159  pEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(SIDTOUSERNAME) + cbSid + cwcUserName * sizeof(WCHAR));
160 
161  /* Copy the Sid and name to our entry */
162  CopySid(cbSid, (PSID)&pEntry->Data, pSid);
163  pEntry->pszName = (LPWSTR)(pEntry->Data + cbSid);
164  wcsncpy(pEntry->pszName, pUserName, cwcUserName);
165 
166  /* Insert the new entry */
167  pEntry->List.Flink = &SidToUserNameHead;
169  SidToUserNameHead.Blink->Flink = &pEntry->List;
170  SidToUserNameHead.Blink = &pEntry->List;
171 
172  return;
173 }
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:708
static LPWSTR PULONG pcwcUserName
static LIST_ENTRY SidToUserNameHead
Definition: perfdata.c:62
_In_ LPCSTR _Out_writes_bytes_to_opt_ cbSid PSID _Inout_ LPDWORD cbSid
Definition: winbase.h:2721
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static LPWSTR pUserName
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:798
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
SINGLE_LIST_ENTRY * pCur
static void SidToUserName(PSID Sid, LPWSTR szBuffer, DWORD BufferSize)
Definition: perfdata.c:115
static PSID pSid
Definition: security.c:74
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BOOL WINAPI CopySid(DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid)
Definition: security.c:591
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

Referenced by PerfDataRefresh().

◆ PerfDataDeallocCommandLineCache()

void PerfDataDeallocCommandLineCache ( )

Definition at line 650 of file perfdata.c.

651 {
653  PCMD_LINE_CACHE cache_old;
654 
655  while (cache && cache->pnext != NULL)
656  {
657  cache_old = cache;
658  cache = cache->pnext;
659 
660  HeapFree(GetProcessHeap(), 0, cache_old);
661  }
662 }
Definition: cache.c:48
#define GetProcessHeap()
Definition: compat.h:595
static IOleCache * cache
Definition: ole2.c:75
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
PCMD_LINE_CACHE global_cache
Definition: perfdata.c:51

Referenced by TaskManagerWndProc().

◆ PerfDataGet()

BOOL PerfDataGet ( ULONG  Index,
PPERFDATA lppData 
)

Definition at line 1124 of file perfdata.c.

1125 {
1126  BOOL bSuccessful = FALSE;
1127 
1129  if (Index < ProcessCount)
1130  {
1131  *lppData = pPerfData + Index;
1132  bSuccessful = TRUE;
1133  }
1135  return bSuccessful;
1136 }
#define TRUE
Definition: types.h:120
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ PerfDataGetBasePriority()

ULONG PerfDataGetBasePriority ( ULONG  Index)

Definition at line 838 of file perfdata.c.

839 {
840  ULONG BasePriority;
841 
843 
844  if (Index < ProcessCount)
845  BasePriority = pPerfData[Index].BasePriority;
846  else
847  BasePriority = 0;
848 
850 
851  return BasePriority;
852 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
ULONG BasePriority
Definition: perfdata.h:47
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetCommandLine()

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

Definition at line 540 of file perfdata.c.

541 {
542  static const LPWSTR ellipsis = L"...";
543 
545  UNICODE_STRING CommandLineStr = {0};
546 
547  PVOID ProcessParams = NULL;
550 
552  BOOL result;
553 
554  PCMD_LINE_CACHE new_entry;
555  LPWSTR new_string;
556 
558 
559  /* [A] Search for a string already in cache? If so, use it */
560  while (cache && cache->pnext != NULL)
561  {
562  if (cache->idx == Index && cache->str != NULL)
563  {
564  /* Found it. Use it, and add some ellipsis at the very end to make it cute */
565  wcsncpy(lpCommandLine, cache->str, CMD_LINE_MIN(nMaxCount, cache->len));
566  wcscpy(lpCommandLine + CMD_LINE_MIN(nMaxCount, cache->len) - wcslen(ellipsis), ellipsis);
567  return TRUE;
568  }
569 
570  cache = cache->pnext;
571  }
572 
573  /* [B] We don't; let's allocate and load a value from the process mem... and cache it */
575 
576  /* Default blank command line in case things don't work out */
577  wcsncpy(lpCommandLine, L"", nMaxCount);
578 
579  /* Ask for a handle to the target process so that we can read its memory and query stuff */
581  if (!hProcess)
582  goto cleanup;
583 
584  /* First off, get the ProcessEnvironmentBlock location in that process' address space */
586  if (!NT_SUCCESS(Status))
587  goto cleanup;
588 
589  /* Then get the PEB.ProcessParameters member pointer */
591  (PVOID)((ULONG_PTR)pbi.PebBaseAddress + FIELD_OFFSET(PEB, ProcessParameters)),
592  &ProcessParams,
593  sizeof(ProcessParams),
594  NULL);
595  if (!result)
596  goto cleanup;
597 
598  /* Then copy the PEB->ProcessParameters.CommandLine member
599  to get the pointer to the string buffer and its size */
601  (PVOID)((ULONG_PTR)ProcessParams + FIELD_OFFSET(RTL_USER_PROCESS_PARAMETERS, CommandLine)),
602  &CommandLineStr,
603  sizeof(CommandLineStr),
604  NULL);
605  if (!result)
606  goto cleanup;
607 
608  /* Allocate the next cache entry and its accompanying string in one go */
609  new_entry = HeapAlloc(GetProcessHeap(),
611  sizeof(CMD_LINE_CACHE) + CommandLineStr.Length + sizeof(UNICODE_NULL));
612  if (!new_entry)
613  goto cleanup;
614 
615  new_string = (LPWSTR)((ULONG_PTR)new_entry + sizeof(CMD_LINE_CACHE));
616 
617  /* Bingo, the command line should be stored there,
618  copy the string from the other process */
620  CommandLineStr.Buffer,
621  new_string,
622  CommandLineStr.Length,
623  NULL);
624  if (!result)
625  {
626  /* Weird, after successfully reading the mem of that process
627  various times it fails now, forget it and bail out */
628  HeapFree(GetProcessHeap(), 0, new_entry);
629  goto cleanup;
630  }
631 
632  /* Add our pointer to the cache... */
633  new_entry->idx = Index;
634  new_entry->str = new_string;
635  new_entry->len = CommandLineStr.Length;
636 
637  if (!global_cache)
638  global_cache = new_entry;
639  else
640  cache->pnext = new_entry;
641 
642  /* ... and print the buffer for the first time */
643  wcsncpy(lpCommandLine, new_string, CMD_LINE_MIN(nMaxCount, CommandLineStr.Length));
644 
645 cleanup:
647  return TRUE;
648 }
#define CMD_LINE_MIN(a, b)
Definition: perfdata.c:53
Definition: cache.c:48
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2709
#define CloseHandle
Definition: compat.h:598
GLuint64EXT * result
Definition: glext.h:11304
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:166
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:617
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
_Inout_ PERBANDINFO * pbi
Definition: winddi.h:3917
Status
Definition: gdiplustypes.h:24
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
ULONG PerfDataGetProcessId(ULONG Index)
Definition: perfdata.c:506
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
struct _CMD_LINE_CACHE CMD_LINE_CACHE
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define PROCESS_VM_READ
Definition: pstypes.h:161
unsigned int ULONG
Definition: retypes.h:1
char * cleanup(char *str)
Definition: wpickclick.c:99
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_In_ int nMaxCount
Definition: winuser.h:4853
#define HeapFree(x, y, z)
Definition: compat.h:594
PCMD_LINE_CACHE global_cache
Definition: perfdata.c:51
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
LPWSTR str
Definition: perfdata.h:61

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetCommitChargeLimitK()

ULONG PerfDataGetCommitChargeLimitK ( void  )

Definition at line 954 of file perfdata.c.

955 {
956  ULONG Limit;
957  ULONG PageSize;
958 
960 
962  PageSize = SystemBasicInfo.PageSize;
963 
965 
966  Limit = Limit * (PageSize / 1024);
967 
968  return Limit;
969 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo
Definition: perfdata.c:44
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
_In_ LONG _In_ LONG Limit
Definition: kefuncs.h:315

Referenced by Graph_DrawMemUsageGraph(), and PerformancePageRefreshThread().

◆ PerfDataGetCommitChargePeakK()

ULONG PerfDataGetCommitChargePeakK ( void  )

Definition at line 971 of file perfdata.c.

972 {
973  ULONG Peak;
974  ULONG PageSize;
975 
977 
979  PageSize = SystemBasicInfo.PageSize;
980 
982 
983  Peak = Peak * (PageSize / 1024);
984 
985  return Peak;
986 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo
Definition: perfdata.c:44
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetCommitChargeTotalK()

ULONG PerfDataGetCommitChargeTotalK ( void  )

Definition at line 937 of file perfdata.c.

938 {
939  ULONG Total;
940  ULONG PageSize;
941 
943 
945  PageSize = SystemBasicInfo.PageSize;
946 
948 
949  Total = Total * (PageSize / 1024);
950 
951  return Total;
952 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo
Definition: perfdata.c:44
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by Graph_DrawMemUsageGraph(), and PerformancePageRefreshThread().

◆ PerfDataGetCPUTime()

LARGE_INTEGER PerfDataGetCPUTime ( ULONG  Index)

Definition at line 696 of file perfdata.c.

697 {
698  LARGE_INTEGER CpuTime = {{0,0}};
699 
701 
702  if (Index < ProcessCount)
703  CpuTime = pPerfData[Index].CPUTime;
704 
706 
707  return CpuTime;
708 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
LARGE_INTEGER CPUTime
Definition: perfdata.h:38
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetCPUUsage()

ULONG PerfDataGetCPUUsage ( ULONG  Index)

Definition at line 680 of file perfdata.c.

681 {
682  ULONG CpuUsage;
683 
685 
686  if (Index < ProcessCount)
687  CpuUsage = pPerfData[Index].CPUUsage;
688  else
689  CpuUsage = 0;
690 
692 
693  return CpuUsage;
694 }
ULONG CPUUsage
Definition: perfdata.h:37
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetGDIObjectCount()

ULONG PerfDataGetGDIObjectCount ( ULONG  Index)

Definition at line 902 of file perfdata.c.

903 {
904  ULONG GDIObjectCount;
905 
907 
908  if (Index < ProcessCount)
909  GDIObjectCount = pPerfData[Index].GDIObjectCount;
910  else
911  GDIObjectCount = 0;
912 
914 
915  return GDIObjectCount;
916 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
ULONG GDIObjectCount
Definition: perfdata.h:51
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetHandleCount()

ULONG PerfDataGetHandleCount ( ULONG  Index)

Definition at line 854 of file perfdata.c.

855 {
856  ULONG HandleCount;
857 
859 
860  if (Index < ProcessCount)
861  HandleCount = pPerfData[Index].HandleCount;
862  else
863  HandleCount = 0;
864 
866 
867  return HandleCount;
868 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
ULONG HandleCount
Definition: perfdata.h:48
_In_ WDFCOLLECTION _In_ ULONG Index
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetImageName()

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

Definition at line 490 of file perfdata.c.

491 {
492  BOOL bSuccessful;
493 
495 
496  if (Index < ProcessCount) {
497  wcsncpy(lpImageName, pPerfData[Index].ImageName, nMaxCount);
498  bSuccessful = TRUE;
499  } else {
500  bSuccessful = FALSE;
501  }
503  return bSuccessful;
504 }
#define TRUE
Definition: types.h:120
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
static const char * ImageName
Definition: image.c:34
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
_In_ int nMaxCount
Definition: winuser.h:4853

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetIOCounters()

BOOL PerfDataGetIOCounters ( ULONG  Index,
PIO_COUNTERS  pIoCounters 
)

Definition at line 918 of file perfdata.c.

919 {
920  BOOL bSuccessful;
921 
923 
924  if (Index < ProcessCount)
925  {
926  memcpy(pIoCounters, &pPerfData[Index].IOCounters, sizeof(IO_COUNTERS));
927  bSuccessful = TRUE;
928  }
929  else
930  bSuccessful = FALSE;
931 
933 
934  return bSuccessful;
935 }
#define TRUE
Definition: types.h:120
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetKernelMemoryNonPagedK()

ULONG PerfDataGetKernelMemoryNonPagedK ( void  )

Definition at line 1028 of file perfdata.c.

1029 {
1030  ULONG NonPaged;
1031  ULONG PageSize;
1032 
1034 
1035  NonPaged = SystemPerfInfo.NonPagedPoolPages;
1036  PageSize = SystemBasicInfo.PageSize;
1037 
1039 
1040  NonPaged = NonPaged * (PageSize / 1024);
1041 
1042  return NonPaged;
1043 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo
Definition: perfdata.c:44
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetKernelMemoryPagedK()

ULONG PerfDataGetKernelMemoryPagedK ( void  )

Definition at line 1011 of file perfdata.c.

1012 {
1013  ULONG Paged;
1014  ULONG PageSize;
1015 
1017 
1019  PageSize = SystemBasicInfo.PageSize;
1020 
1022 
1023  Paged = Paged * (PageSize / 1024);
1024 
1025  return Paged;
1026 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo
Definition: perfdata.c:44
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetKernelMemoryTotalK()

ULONG PerfDataGetKernelMemoryTotalK ( void  )

Definition at line 988 of file perfdata.c.

989 {
990  ULONG Total;
991  ULONG Paged;
992  ULONG NonPaged;
993  ULONG PageSize;
994 
996 
999  PageSize = SystemBasicInfo.PageSize;
1000 
1002 
1003  Paged = Paged * (PageSize / 1024);
1004  NonPaged = NonPaged * (PageSize / 1024);
1005 
1006  Total = Paged + NonPaged;
1007 
1008  return Total;
1009 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo
Definition: perfdata.c:44
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetNonPagedPoolUsagePages()

ULONG PerfDataGetNonPagedPoolUsagePages ( ULONG  Index)

Definition at line 822 of file perfdata.c.

823 {
824  ULONG NonPagedPoolUsage;
825 
827 
828  if (Index < ProcessCount)
829  NonPagedPoolUsage = pPerfData[Index].NonPagedPoolUsagePages;
830  else
831  NonPagedPoolUsage = 0;
832 
834 
835  return NonPagedPoolUsage;
836 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
ULONG NonPagedPoolUsagePages
Definition: perfdata.h:46
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetPagedPoolUsagePages()

ULONG PerfDataGetPagedPoolUsagePages ( ULONG  Index)

Definition at line 806 of file perfdata.c.

807 {
808  ULONG PagedPoolUsage;
809 
811 
812  if (Index < ProcessCount)
813  PagedPoolUsage = pPerfData[Index].PagedPoolUsagePages;
814  else
815  PagedPoolUsage = 0;
816 
818 
819  return PagedPoolUsage;
820 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG PagedPoolUsagePages
Definition: perfdata.h:45

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetPageFaultCount()

ULONG PerfDataGetPageFaultCount ( ULONG  Index)

Definition at line 758 of file perfdata.c.

759 {
760  ULONG PageFaultCount;
761 
763 
764  if (Index < ProcessCount)
765  PageFaultCount = pPerfData[Index].PageFaultCount;
766  else
767  PageFaultCount = 0;
768 
770 
771  return PageFaultCount;
772 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
ULONG PageFaultCount
Definition: perfdata.h:42
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetPageFaultCountDelta()

ULONG PerfDataGetPageFaultCountDelta ( ULONG  Index)

Definition at line 774 of file perfdata.c.

775 {
776  ULONG PageFaultCountDelta;
777 
779 
780  if (Index < ProcessCount)
781  PageFaultCountDelta = pPerfData[Index].PageFaultCountDelta;
782  else
783  PageFaultCountDelta = 0;
784 
786 
787  return PageFaultCountDelta;
788 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
ULONG PageFaultCountDelta
Definition: perfdata.h:43
_In_ WDFCOLLECTION _In_ ULONG Index
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetPeakWorkingSetSizeBytes()

ULONG PerfDataGetPeakWorkingSetSizeBytes ( ULONG  Index)

Definition at line 726 of file perfdata.c.

727 {
728  ULONG PeakWorkingSetSizeBytes;
729 
731 
732  if (Index < ProcessCount)
733  PeakWorkingSetSizeBytes = pPerfData[Index].PeakWorkingSetSizeBytes;
734  else
735  PeakWorkingSetSizeBytes = 0;
736 
738 
739  return PeakWorkingSetSizeBytes;
740 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
ULONG PeakWorkingSetSizeBytes
Definition: perfdata.h:40
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetPhysicalMemoryAvailableK()

ULONG PerfDataGetPhysicalMemoryAvailableK ( void  )

Definition at line 1062 of file perfdata.c.

1063 {
1064  ULONG Available;
1065  ULONG PageSize;
1066 
1068 
1069  Available = SystemPerfInfo.AvailablePages;
1070  PageSize = SystemBasicInfo.PageSize;
1071 
1073 
1074  Available = Available * (PageSize / 1024);
1075 
1076  return Available;
1077 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo
Definition: perfdata.c:44
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetPhysicalMemorySystemCacheK()

ULONG PerfDataGetPhysicalMemorySystemCacheK ( void  )

Definition at line 1079 of file perfdata.c.

1080 {
1081  ULONG SystemCache;
1082  ULONG PageSize;
1083 
1085 
1086  PageSize = SystemBasicInfo.PageSize;
1087  SystemCache = SystemCacheInfo.CurrentSizeIncludingTransitionInPages * PageSize;
1088 
1090 
1091  return SystemCache / 1024;
1092 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
SIZE_T CurrentSizeIncludingTransitionInPages
Definition: extypes.h:1119
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
SYSTEM_FILECACHE_INFORMATION SystemCacheInfo
Definition: perfdata.c:46
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetPhysicalMemoryTotalK()

ULONG PerfDataGetPhysicalMemoryTotalK ( void  )

Definition at line 1045 of file perfdata.c.

1046 {
1047  ULONG Total;
1048  ULONG PageSize;
1049 
1051 
1053  PageSize = SystemBasicInfo.PageSize;
1054 
1056 
1057  Total = Total * (PageSize / 1024);
1058 
1059  return Total;
1060 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetProcessCount()

ULONG PerfDataGetProcessCount ( void  )

Definition at line 463 of file perfdata.c.

464 {
465  ULONG Result;
469  return Result;
470 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
_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:426
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerformancePageRefreshThread(), and UpdateProcesses().

◆ PerfDataGetProcessId()

ULONG PerfDataGetProcessId ( ULONG  Index)

Definition at line 506 of file perfdata.c.

507 {
509 
511 
512  if (Index < ProcessCount)
514  else
515  ProcessId = 0;
516 
518 
519  return ProcessId;
520 }
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2709
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
#define PtrToUlong(u)
Definition: config.h:107
_In_ WDFCOLLECTION _In_ ULONG Index
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

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

◆ PerfDataGetProcessIndex()

ULONG PerfDataGetProcessIndex ( ULONG  pid)

Definition at line 440 of file perfdata.c.

441 {
442  ULONG idx;
443 
445 
446  for (idx = 0; idx < ProcessCount; idx++)
447  {
449  {
450  break;
451  }
452  }
453 
455 
456  if (idx == ProcessCount)
457  {
458  return -1;
459  }
460  return idx;
461 }
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2709
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
unsigned int idx
Definition: utils.c:41
PPERFDATA pPerfData
Definition: perfdata.c:35
#define PtrToUlong(u)
Definition: config.h:107
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by ProcessPageCompareFunc(), and ProcessPageOnNotify().

◆ PerfDataGetProcessorSystemUsage()

ULONG PerfDataGetProcessorSystemUsage ( void  )

Definition at line 481 of file perfdata.c.

482 {
483  ULONG Result;
487  return Result;
488 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
double dbKernelTime
Definition: perfdata.c:39
_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:426
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by Graph_DrawCpuUsageGraph(), and PerformancePageRefreshThread().

◆ PerfDataGetProcessorUsage()

ULONG PerfDataGetProcessorUsage ( void  )

Definition at line 472 of file perfdata.c.

473 {
474  ULONG Result;
478  return Result;
479 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
_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:426
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
double dbIdleTime
Definition: perfdata.c:38

Referenced by Graph_DrawCpuUsageGraph(), PerformancePageRefreshThread(), TrayIcon_GetProcessorUsageIcon(), TrayIcon_ShellAddTrayIcon(), and TrayIcon_ShellUpdateTrayIcon().

◆ PerfDataGetSessionId()

ULONG PerfDataGetSessionId ( ULONG  Index)

Definition at line 664 of file perfdata.c.

665 {
667 
669 
670  if (Index < ProcessCount)
672  else
673  SessionId = 0;
674 
676 
677  return SessionId;
678 }
ULONG SessionId
Definition: dllmain.c:28
ULONG SessionId
Definition: perfdata.h:36
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetSystemHandleCount()

ULONG PerfDataGetSystemHandleCount ( void  )

Definition at line 1094 of file perfdata.c.

1095 {
1096  ULONG HandleCount;
1097 
1099 
1100  HandleCount = SystemNumberOfHandles;
1101 
1103 
1104  return HandleCount;
1105 }
ULONG SystemNumberOfHandles
Definition: perfdata.c:47
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetThreadCount()

ULONG PerfDataGetThreadCount ( ULONG  Index)

Definition at line 870 of file perfdata.c.

871 {
872  ULONG ThreadCount;
873 
875 
876  if (Index < ProcessCount)
877  ThreadCount = pPerfData[Index].ThreadCount;
878  else
879  ThreadCount = 0;
880 
882 
883  return ThreadCount;
884 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
ULONG ThreadCount
Definition: perfdata.h:49
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetTotalThreadCount()

ULONG PerfDataGetTotalThreadCount ( void  )

Definition at line 1107 of file perfdata.c.

1108 {
1109  ULONG ThreadCount = 0;
1110  ULONG i;
1111 
1113 
1114  for (i=0; i<ProcessCount; i++)
1115  {
1116  ThreadCount += pPerfData[i].ThreadCount;
1117  }
1118 
1120 
1121  return ThreadCount;
1122 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
ULONG ThreadCount
Definition: perfdata.h:49
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
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerformancePageRefreshThread().

◆ PerfDataGetUserName()

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

Definition at line 522 of file perfdata.c.

523 {
524  BOOL bSuccessful;
525 
527 
528  if (Index < ProcessCount) {
529  wcsncpy(lpUserName, pPerfData[Index].UserName, nMaxCount);
530  bSuccessful = TRUE;
531  } else {
532  bSuccessful = FALSE;
533  }
534 
536 
537  return bSuccessful;
538 }
#define TRUE
Definition: types.h:120
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
_In_ int nMaxCount
Definition: winuser.h:4853

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetUSERObjectCount()

ULONG PerfDataGetUSERObjectCount ( ULONG  Index)

Definition at line 886 of file perfdata.c.

887 {
888  ULONG USERObjectCount;
889 
891 
892  if (Index < ProcessCount)
893  USERObjectCount = pPerfData[Index].USERObjectCount;
894  else
895  USERObjectCount = 0;
896 
898 
899  return USERObjectCount;
900 }
ULONG USERObjectCount
Definition: perfdata.h:50
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetVirtualMemorySizeBytes()

ULONG PerfDataGetVirtualMemorySizeBytes ( ULONG  Index)

Definition at line 790 of file perfdata.c.

791 {
792  ULONG VirtualMemorySizeBytes;
793 
795 
796  if (Index < ProcessCount)
797  VirtualMemorySizeBytes = pPerfData[Index].VirtualMemorySizeBytes;
798  else
799  VirtualMemorySizeBytes = 0;
800 
802 
803  return VirtualMemorySizeBytes;
804 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG VirtualMemorySizeBytes
Definition: perfdata.h:44

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetWorkingSetSizeBytes()

ULONG PerfDataGetWorkingSetSizeBytes ( ULONG  Index)

Definition at line 710 of file perfdata.c.

711 {
712  ULONG WorkingSetSizeBytes;
713 
715 
716  if (Index < ProcessCount)
717  WorkingSetSizeBytes = pPerfData[Index].WorkingSetSizeBytes;
718  else
719  WorkingSetSizeBytes = 0;
720 
722 
723  return WorkingSetSizeBytes;
724 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
_In_ WDFCOLLECTION _In_ ULONG Index
ULONG WorkingSetSizeBytes
Definition: perfdata.h:39
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataGetWorkingSetSizeDelta()

ULONG PerfDataGetWorkingSetSizeDelta ( ULONG  Index)

Definition at line 742 of file perfdata.c.

743 {
744  ULONG WorkingSetSizeDelta;
745 
747 
748  if (Index < ProcessCount)
749  WorkingSetSizeDelta = pPerfData[Index].WorkingSetSizeDelta;
750  else
751  WorkingSetSizeDelta = 0;
752 
754 
755  return WorkingSetSizeDelta;
756 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONG ProcessCount
Definition: perfdata.c:37
PPERFDATA pPerfData
Definition: perfdata.c:35
ULONG WorkingSetSizeDelta
Definition: perfdata.h:41
_In_ WDFCOLLECTION _In_ ULONG Index
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PerfDataGetText(), and ProcessPageCompareFunc().

◆ PerfDataInitialize()

BOOL PerfDataInitialize ( void  )

Definition at line 64 of file perfdata.c.

65 {
68 
70 
71  /*
72  * Get number of processors in the system
73  */
75  if (!NT_SUCCESS(status))
76  return FALSE;
77 
78  /*
79  * Create the SYSTEM Sid
80  */
82  return TRUE;
83 }
#define SECURITY_LOCAL_SYSTEM_RID
Definition: setypes.h:561
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
PSID SystemUserSid
Definition: perfdata.c:49
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
static SID_IDENTIFIER_AUTHORITY NtSidAuthority
Definition: samrpc.c:14
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:541
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
#define NULL
Definition: types.h:112
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
static SERVICE_STATUS status
Definition: service.c:31
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:553
Definition: ps.c:97

Referenced by wWinMain().

◆ PerfDataRefresh()

void PerfDataRefresh ( void  )

Definition at line 175 of file perfdata.c.

176 {
177  ULONG ulSize;
179  LPBYTE pBuffer;
182  PPERFDATA pPDOld;
183  ULONG Idx, Idx2;
185  HANDLE hProcessToken;
186  SYSTEM_PERFORMANCE_INFORMATION SysPerfInfo;
187  SYSTEM_TIMEOFDAY_INFORMATION SysTimeInfo;
188  SYSTEM_FILECACHE_INFORMATION SysCacheInfo;
189  SYSTEM_HANDLE_INFORMATION SysHandleInfoData;
190  PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SysProcessorTimeInfo;
191  double CurrentKernelTime;
192  PSECURITY_DESCRIPTOR ProcessSD;
193  PSID ProcessUser;
194  ULONG Buffer[64]; /* must be 4 bytes aligned! */
195  ULONG cwcUserName;
196 
197  /* Get new system time */
198  status = NtQuerySystemInformation(SystemTimeOfDayInformation, &SysTimeInfo, sizeof(SysTimeInfo), NULL);
199  if (!NT_SUCCESS(status))
200  return;
201 
202  /* Get new CPU's idle time */
203  status = NtQuerySystemInformation(SystemPerformanceInformation, &SysPerfInfo, sizeof(SysPerfInfo), NULL);
204  if (!NT_SUCCESS(status))
205  return;
206 
207  /* Get system cache information */
208  status = NtQuerySystemInformation(SystemFileCacheInformation, &SysCacheInfo, sizeof(SysCacheInfo), NULL);
209  if (!NT_SUCCESS(status))
210  return;
211 
212  /* Get processor time information */
215 
216  if (!NT_SUCCESS(status))
217  {
218  if (SysProcessorTimeInfo != NULL)
219  HeapFree(GetProcessHeap(), 0, SysProcessorTimeInfo);
220  return;
221  }
222 
223  /* Get handle information
224  * Number of handles is enough, no need for data array.
225  */
226  status = NtQuerySystemInformation(SystemHandleInformation, &SysHandleInfoData, sizeof(SysHandleInfoData), NULL);
227  /* On unexpected error, reuse previous value.
228  * STATUS_SUCCESS (0-1 handle) should never happen.
229  */
231  SysHandleInfoData.NumberOfHandles = SystemNumberOfHandles;
232 
233  /* Get process information
234  * We don't know how much data there is so just keep
235  * increasing the buffer size until the call succeeds
236  */
237  BufferSize = 0;
238  do
239  {
240  BufferSize += 0x10000;
242 
244 
247  }
248 
249  } while (status == STATUS_INFO_LENGTH_MISMATCH);
250 
252 
253  /*
254  * Save system performance info
255  */
256  memcpy(&SystemPerfInfo, &SysPerfInfo, sizeof(SYSTEM_PERFORMANCE_INFORMATION));
257 
258  /*
259  * Save system cache info
260  */
261  memcpy(&SystemCacheInfo, &SysCacheInfo, sizeof(SYSTEM_FILECACHE_INFORMATION));
262 
263  /*
264  * Save system processor time info
265  */
268  }
269  SystemProcessorTimeInfo = SysProcessorTimeInfo;
270 
271  /*
272  * Save system handle info
273  */
274  SystemNumberOfHandles = SysHandleInfoData.NumberOfHandles;
275 
276  for (CurrentKernelTime=0, Idx=0; Idx<(ULONG)SystemBasicInfo.NumberOfProcessors; Idx++) {
277  CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime);
278  CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].DpcTime);
279  CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].InterruptTime);
280  }
281 
282  /* If it's a first call - skip idle time calcs */
283  if (liOldIdleTime.QuadPart != 0) {
284  /* CurrentValue = NewValue - OldValue */
286  dbKernelTime = CurrentKernelTime - OldKernelTime;
288 
289  /* CurrentCpuIdle = IdleTime / SystemTime */
292 
293  /* CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors */
294  dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
295  dbKernelTime = 100.0 - dbKernelTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
296  }
297 
298  /* Store new CPU's idle and system time */
299  liOldIdleTime = SysPerfInfo.IdleProcessTime;
300  liOldSystemTime = SysTimeInfo.CurrentTime;
301  OldKernelTime = CurrentKernelTime;
302 
303  /* Determine the process count
304  * We loop through the data we got from NtQuerySystemInformation
305  * and count how many structures there are (until RelativeOffset is 0)
306  */
308  ProcessCount = 0;
310  while (pSPI) {
311  ProcessCount++;
312  if (pSPI->NextEntryOffset == 0)
313  break;
314  pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->NextEntryOffset);
315  }
316 
317  /* Now alloc a new PERFDATA array and fill in the data */
319 
321  for (Idx=0; Idx<ProcessCount; Idx++) {
322  /* Get the old perf data for this process (if any) */
323  /* so that we can establish delta values */
324  pPDOld = NULL;
325  if (pPerfDataOld) {
326  for (Idx2=0; Idx2<ProcessCountOld; Idx2++) {
327  if (pPerfDataOld[Idx2].ProcessId == pSPI->UniqueProcessId) {
328  pPDOld = &pPerfDataOld[Idx2];
329  break;
330  }
331  }
332  }
333 
334  if (pSPI->ImageName.Buffer) {
335  /* Don't assume a UNICODE_STRING Buffer is zero terminated: */
336  int len = pSPI->ImageName.Length / 2;
337  /* Check against max size and allow for terminating zero (already zeroed): */
338  if(len >= MAX_PATH)len=MAX_PATH - 1;
340  } else {
342  sizeof(pPerfData[Idx].ImageName) / sizeof(pPerfData[Idx].ImageName[0]));
343  }
344 
345  pPerfData[Idx].ProcessId = pSPI->UniqueProcessId;
346 
347  if (pPDOld) {
348  double CurTime = Li2Double(pSPI->KernelTime) + Li2Double(pSPI->UserTime);
349  double OldTime = Li2Double(pPDOld->KernelTime) + Li2Double(pPDOld->UserTime);
350  double CpuTime = (CurTime - OldTime) / dbSystemTime;
351  CpuTime = CpuTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
352  pPerfData[Idx].CPUUsage = (ULONG)CpuTime;
353  }
357  if (pPDOld)
359  else
362  if (pPDOld)
364  else
369  pPerfData[Idx].BasePriority = pSPI->BasePriority;
370  pPerfData[Idx].HandleCount = pSPI->HandleCount;
372  pPerfData[Idx].SessionId = pSPI->SessionId;
373  pPerfData[Idx].UserName[0] = UNICODE_NULL;
374  pPerfData[Idx].USERObjectCount = 0;
375  pPerfData[Idx].GDIObjectCount = 0;
376  ProcessUser = SystemUserSid;
377  ProcessSD = NULL;
378 
379  if (pSPI->UniqueProcessId != NULL) {
381  if (hProcess) {
382  /* don't query the information of the system process. It's possible but
383  returns Administrators as the owner of the process instead of SYSTEM */
384  if (pSPI->UniqueProcessId != (HANDLE)0x4)
385  {
386  if (OpenProcessToken(hProcess, TOKEN_QUERY, &hProcessToken))
387  {
388  DWORD RetLen = 0;
389  BOOL Ret;
390 
391  Ret = GetTokenInformation(hProcessToken, TokenUser, (LPVOID)Buffer, sizeof(Buffer), &RetLen);
392  CloseHandle(hProcessToken);
393 
394  if (Ret)
395  ProcessUser = ((PTOKEN_USER)Buffer)->User.Sid;
396  else
397  goto ReadProcOwner;
398  }
399  else
400  {
401 ReadProcOwner:
403  }
404 
405  pPerfData[Idx].USERObjectCount = GetGuiResources(hProcess, GR_USEROBJECTS);
406  pPerfData[Idx].GDIObjectCount = GetGuiResources(hProcess, GR_GDIOBJECTS);
407  }
408 
409  GetProcessIoCounters(hProcess, &pPerfData[Idx].IOCounters);
411  } else {
412  goto ClearInfo;
413  }
414  } else {
415 ClearInfo:
416  /* clear information we were unable to fetch */
417  ZeroMemory(&pPerfData[Idx].IOCounters, sizeof(IO_COUNTERS));
418  }
419 
420  cwcUserName = sizeof(pPerfData[0].UserName) / sizeof(pPerfData[0].UserName[0]);
421  CachedGetUserFromSid(ProcessUser, pPerfData[Idx].UserName, &cwcUserName);
422 
423  if (ProcessSD != NULL)
424  {
425  LocalFree((HLOCAL)ProcessSD);
426  }
427 
430  pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->NextEntryOffset);
431  }
433  if (pPerfDataOld) {
435  }
438 }
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2709
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SystemProcessorTimeInfo
Definition: perfdata.c:48
struct _PERFDATA * PPERFDATA
#define CloseHandle
Definition: compat.h:598
PSID SystemUserSid
Definition: perfdata.c:49
WCHAR UserName[MAX_PATH]
Definition: perfdata.h:35
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:166
ULONG SystemNumberOfHandles
Definition: perfdata.c:47
ULONG ProcessCountOld
Definition: perfdata.c:36
LONG NTSTATUS
Definition: precomp.h:26
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
ULONG SessionId
Definition: perfdata.h:36
#define ZeroMemory
Definition: winbase.h:1664
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
EXTINLINE DWORD WINAPI GetGuiResources(HANDLE hProcess, DWORD uiFlags)
Definition: ntwrapper.h:64
ULONG USERObjectCount
Definition: perfdata.h:50
ULONG CPUUsage
Definition: perfdata.h:37
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
ULONG ProcessCount
Definition: perfdata.c:37
LARGE_INTEGER CurrentTime
Definition: extypes.h:850
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
ULONG NonPagedPoolUsagePages
Definition: perfdata.h:46
double dbKernelTime
Definition: perfdata.c:39
LARGE_INTEGER IdleProcessTime
Definition: memtest.h:11
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
PPERFDATA pPerfData
Definition: perfdata.c:35
PVOID pBuffer
double OldKernelTime
Definition: perfdata.c:42
Definition: bufpool.h:45
#define SystemPerformanceInformation
Definition: memtest.h:87
ULONG WorkingSetSizeDelta
Definition: perfdata.h:41
BOOL WINAPI GetProcessIoCounters(IN HANDLE hProcess, OUT PIO_COUNTERS lpIoCounters)
Definition: proc.c:1862
#define PtrToUlong(u)
Definition: config.h:107
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo
Definition: perfdata.c:44
ULONG HandleCount
Definition: perfdata.h:48
double dbSystemTime
Definition: perfdata.c:40
#define GetProcessHeap()
Definition: compat.h:595
LARGE_INTEGER liOldIdleTime
Definition: perfdata.c:41
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define TOKEN_QUERY
Definition: setypes.h:893
ULONG PageFaultCountDelta
Definition: perfdata.h:43
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
#define MAX_PATH
Definition: compat.h:34
VOID WINAPI CachedGetUserFromSid(PSID pSid, LPWSTR pUserName, PULONG pcwcUserName)
Definition: perfdata.c:127
ULONG BasePriority
Definition: perfdata.h:47
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION * PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
#define READ_CONTROL
Definition: nt_native.h:58
UNICODE_STRING ImageName
Definition: extypes.h:894
ULONG WorkingSetSizeBytes
Definition: perfdata.h:39
static const char * ImageName
Definition: image.c:34
LARGE_INTEGER liOldSystemTime
Definition: perfdata.c:43
#define IDS_IDLE_PROCESS
Definition: resource.h:3
struct _PERFDATA PERFDATA
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
LARGE_INTEGER CPUTime
Definition: perfdata.h:38
SYSTEM_FILECACHE_INFORMATION SystemCacheInfo
Definition: perfdata.c:46
ULONG ThreadCount
Definition: perfdata.h:49
struct _SYSTEM_PROCESS_INFORMATION * PSYSTEM_PROCESS_INFORMATION
HANDLE ProcessId
Definition: perfdata.h:34
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
HINSTANCE hInst
Definition: dxdiag.c:13
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
LARGE_INTEGER KernelTime
Definition: extypes.h:893
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
ULONG PeakWorkingSetSizeBytes
Definition: perfdata.h:40
#define OWNER_SECURITY_INFORMATION
Definition: setypes.h:123
ULONG PageFaultCount
Definition: perfdata.h:42
#define NULL
Definition: types.h:112
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
PPERFDATA pPerfDataOld
Definition: perfdata.c:34
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define Li2Double(x)
Definition: perfdata.h:29
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
unsigned int ULONG
Definition: retypes.h:1
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
ULONG GDIObjectCount
Definition: perfdata.h:51
struct _TOKEN_USER * PTOKEN_USER
LARGE_INTEGER UserTime
Definition: extypes.h:892
_Check_return_ long __cdecl labs(_In_ long x)
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
LARGE_INTEGER KernelTime
Definition: perfdata.h:55
ULONG VirtualMemorySizeBytes
Definition: perfdata.h:44
static SERVICE_STATUS status
Definition: service.c:31
LARGE_INTEGER UserTime
Definition: perfdata.h:54
#define HeapFree(x, y, z)
Definition: compat.h:594
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
LONGLONG QuadPart
Definition: typedefs.h:114
double dbIdleTime
Definition: perfdata.c:38
ULONG PagedPoolUsagePages
Definition: perfdata.h:45
Definition: ps.c:97

Referenced by OnCreate(), and TaskManagerWndProc().

◆ PerfDataUninitialize()

void PerfDataUninitialize ( void  )

Definition at line 85 of file perfdata.c.

86 {
89 
90  if (pPerfData != NULL)
92 
94 
95  if (SystemUserSid != NULL)
96  {
99  }
100 
101  /* Free user names cache list */
103  while (pCur != &SidToUserNameHead)
104  {
106  pCur = pCur->Flink;
108  }
109 
112  }
113 }
PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SystemProcessorTimeInfo
Definition: perfdata.c:48
PSID SystemUserSid
Definition: perfdata.c:49
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:577
PPERFDATA pPerfData
Definition: perfdata.c:35
static LIST_ENTRY SidToUserNameHead
Definition: perfdata.c:62
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define GetProcessHeap()
Definition: compat.h:595
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
SINGLE_LIST_ENTRY * pCur
#define NULL
Definition: types.h:112
CRITICAL_SECTION PerfDataCriticalSection
Definition: perfdata.c:33
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by wWinMain().

◆ SidToUserName()

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

Definition at line 115 of file perfdata.c.

116 {
117  static WCHAR szDomainNameUnused[255];
118  DWORD DomainNameLen = sizeof(szDomainNameUnused) / sizeof(szDomainNameUnused[0]);
119  SID_NAME_USE Use;
120 
121  if (Sid != NULL)
122  LookupAccountSidW(NULL, Sid, szBuffer, &BufferSize, szDomainNameUnused, &DomainNameLen, &Use);
123 }
enum _SID_NAME_USE SID_NAME_USE
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1103
BOOL WINAPI LookupAccountSidW(LPCWSTR pSystemName, PSID pSid, LPWSTR pAccountName, LPDWORD pdwAccountName, LPWSTR pDomainName, LPDWORD pdwDomainName, PSID_NAME_USE peUse)
Definition: misc.c:537
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NULL
Definition: types.h:112
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by CachedGetUserFromSid().

Variable Documentation

◆ dbIdleTime

double dbIdleTime

Definition at line 38 of file perfdata.c.

Referenced by PerfDataGetProcessorUsage(), and PerfDataRefresh().

◆ dbKernelTime

double dbKernelTime

Definition at line 39 of file perfdata.c.

Referenced by PerfDataGetProcessorSystemUsage(), and PerfDataRefresh().

◆ dbSystemTime

double dbSystemTime

Definition at line 40 of file perfdata.c.

Referenced by PerfDataRefresh().

◆ global_cache

PCMD_LINE_CACHE global_cache = NULL

Definition at line 51 of file perfdata.c.

Referenced by PerfDataDeallocCommandLineCache(), and PerfDataGetCommandLine().

◆ liOldIdleTime

LARGE_INTEGER liOldIdleTime = {{0,0}}

Definition at line 41 of file perfdata.c.

Referenced by PerfDataRefresh().

◆ liOldSystemTime

LARGE_INTEGER liOldSystemTime = {{0,0}}

Definition at line 43 of file perfdata.c.

Referenced by PerfDataRefresh().

◆ OldKernelTime

double OldKernelTime = 0

Definition at line 42 of file perfdata.c.

Referenced by PerfDataRefresh().

◆ PerfDataCriticalSection

◆ pPerfData

◆ pPerfDataOld

PPERFDATA pPerfDataOld = NULL

Definition at line 34 of file perfdata.c.

Referenced by PerfDataRefresh().

◆ ProcessCount

◆ ProcessCountOld

ULONG ProcessCountOld = 0

Definition at line 36 of file perfdata.c.

Referenced by PerfDataRefresh().

◆ SidToUserNameHead

LIST_ENTRY SidToUserNameHead = {&SidToUserNameHead, &SidToUserNameHead}
static

Definition at line 62 of file perfdata.c.

Referenced by CachedGetUserFromSid(), and PerfDataUninitialize().

◆ SystemBasicInfo

◆ SystemCacheInfo

Definition at line 46 of file perfdata.c.

Referenced by PerfDataGetPhysicalMemorySystemCacheK(), and PerfDataRefresh().

◆ SystemNumberOfHandles

ULONG SystemNumberOfHandles

Definition at line 47 of file perfdata.c.

Referenced by PerfDataGetSystemHandleCount(), and PerfDataRefresh().

◆ SystemPerfInfo

◆ SystemProcessorTimeInfo

Definition at line 48 of file perfdata.c.

Referenced by PerfDataRefresh(), and PerfDataUninitialize().

◆ SystemUserSid

PSID SystemUserSid = NULL

Definition at line 49 of file perfdata.c.

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