Build taskmgr with NDK

svn path=/trunk/; revision=16192
This commit is contained in:
Alex Ionescu 2005-06-20 22:15:59 +00:00
parent 725169d745
commit d8de94af8a
5 changed files with 43 additions and 43 deletions

View file

@ -871,7 +871,7 @@ typedef struct _SYSTEM_CACHE_INFORMATION
ULONG CurrentSizeIncludingTransitionInPages; ULONG CurrentSizeIncludingTransitionInPages;
ULONG PeakSizeIncludingTransitionInPages; ULONG PeakSizeIncludingTransitionInPages;
ULONG Unused[2]; ULONG Unused[2];
} SYSTEM_CACHE_INFORMATION; } SYSTEM_CACHE_INFORMATION, *PSYSTEM_CACHE_INFORMATION;
/* Class 22 */ /* Class 22 */
typedef struct _SYSTEM_POOLTAG typedef struct _SYSTEM_POOLTAG

View file

@ -91,13 +91,13 @@ void PerfDataRefresh(void)
return; return;
/* Get system cache information */ /* Get system cache information */
status = NtQuerySystemInformation(SystemCacheInformation, &SysCacheInfo, sizeof(SysCacheInfo), NULL); status = NtQuerySystemInformation(SystemFileCacheInformation, &SysCacheInfo, sizeof(SysCacheInfo), NULL);
if (status != NO_ERROR) if (status != NO_ERROR)
return; return;
/* Get processor time information */ /* Get processor time information */
SysProcessorTimeInfo = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)HeapAlloc(GetProcessHeap(), 0, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberProcessors); SysProcessorTimeInfo = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)HeapAlloc(GetProcessHeap(), 0, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberOfProcessors);
status = NtQuerySystemInformation(SystemProcessorPerformanceInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberProcessors, &ulSize); status = NtQuerySystemInformation(SystemProcessorPerformanceInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberOfProcessors, &ulSize);
if (status != NO_ERROR) if (status != NO_ERROR)
return; return;
@ -163,7 +163,7 @@ void PerfDataRefresh(void)
memcpy(&SystemHandleInfo, SysHandleInfoData, sizeof(SYSTEM_HANDLE_INFORMATION)); memcpy(&SystemHandleInfo, SysHandleInfoData, sizeof(SYSTEM_HANDLE_INFORMATION));
HeapFree(GetProcessHeap(), 0, SysHandleInfoData); HeapFree(GetProcessHeap(), 0, SysHandleInfoData);
for (CurrentKernelTime=0, Idx=0; Idx<SystemBasicInfo.NumberProcessors; Idx++) { for (CurrentKernelTime=0, Idx=0; Idx<SystemBasicInfo.NumberOfProcessors; Idx++) {
CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime); CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime);
CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].DpcTime); CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].DpcTime);
CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].InterruptTime); CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].InterruptTime);
@ -172,7 +172,7 @@ void PerfDataRefresh(void)
/* If it's a first call - skip idle time calcs */ /* If it's a first call - skip idle time calcs */
if (liOldIdleTime.QuadPart != 0) { if (liOldIdleTime.QuadPart != 0) {
/* CurrentValue = NewValue - OldValue */ /* CurrentValue = NewValue - OldValue */
dbIdleTime = Li2Double(SysPerfInfo.IdleTime) - Li2Double(liOldIdleTime); dbIdleTime = Li2Double(SysPerfInfo.IdleProcessTime) - Li2Double(liOldIdleTime);
dbKernelTime = CurrentKernelTime - OldKernelTime; dbKernelTime = CurrentKernelTime - OldKernelTime;
dbSystemTime = Li2Double(SysTimeInfo.CurrentTime) - Li2Double(liOldSystemTime); dbSystemTime = Li2Double(SysTimeInfo.CurrentTime) - Li2Double(liOldSystemTime);
@ -181,12 +181,12 @@ void PerfDataRefresh(void)
dbKernelTime = dbKernelTime / dbSystemTime; dbKernelTime = dbKernelTime / dbSystemTime;
/* CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors */ /* CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors */
dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.NumberProcessors; /* + 0.5; */ dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
dbKernelTime = 100.0 - dbKernelTime * 100.0 / (double)SystemBasicInfo.NumberProcessors; /* + 0.5; */ dbKernelTime = 100.0 - dbKernelTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
} }
/* Store new CPU's idle and system time */ /* Store new CPU's idle and system time */
liOldIdleTime = SysPerfInfo.IdleTime; liOldIdleTime = SysPerfInfo.IdleProcessTime;
liOldSystemTime = SysTimeInfo.CurrentTime; liOldSystemTime = SysTimeInfo.CurrentTime;
OldKernelTime = CurrentKernelTime; OldKernelTime = CurrentKernelTime;
@ -237,7 +237,7 @@ void PerfDataRefresh(void)
double CurTime = Li2Double(pSPI->KernelTime) + Li2Double(pSPI->UserTime); double CurTime = Li2Double(pSPI->KernelTime) + Li2Double(pSPI->UserTime);
double OldTime = Li2Double(pPDOld->KernelTime) + Li2Double(pPDOld->UserTime); double OldTime = Li2Double(pPDOld->KernelTime) + Li2Double(pPDOld->UserTime);
double CpuTime = (CurTime - OldTime) / dbSystemTime; double CpuTime = (CurTime - OldTime) / dbSystemTime;
CpuTime = CpuTime * 100.0 / (double)SystemBasicInfo.NumberProcessors; /* + 0.5; */ CpuTime = CpuTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; /* + 0.5; */
pPerfData[Idx].CPUUsage = (ULONG)CpuTime; pPerfData[Idx].CPUUsage = (ULONG)CpuTime;
} }
pPerfData[Idx].CPUTime.QuadPart = pSPI->UserTime.QuadPart + pSPI->KernelTime.QuadPart; pPerfData[Idx].CPUTime.QuadPart = pSPI->UserTime.QuadPart + pSPI->KernelTime.QuadPart;
@ -253,7 +253,7 @@ void PerfDataRefresh(void)
else else
pPerfData[Idx].PageFaultCountDelta = 0; pPerfData[Idx].PageFaultCountDelta = 0;
pPerfData[Idx].VirtualMemorySizeBytes = pSPI->VirtualSize; pPerfData[Idx].VirtualMemorySizeBytes = pSPI->VirtualSize;
pPerfData[Idx].PagedPoolUsagePages = pSPI->QuotaPagedPoolUsage; pPerfData[Idx].PagedPoolUsagePages = pSPI->QuotaPeakPagedPoolUsage;
pPerfData[Idx].NonPagedPoolUsagePages = pSPI->QuotaPeakNonPagedPoolUsage; pPerfData[Idx].NonPagedPoolUsagePages = pSPI->QuotaPeakNonPagedPoolUsage;
pPerfData[Idx].BasePriority = pSPI->BasePriority; pPerfData[Idx].BasePriority = pSPI->BasePriority;
pPerfData[Idx].HandleCount = pSPI->HandleCount; pPerfData[Idx].HandleCount = pSPI->HandleCount;
@ -416,9 +416,9 @@ ULONG PerfDataGetCPUUsage(ULONG Index)
return CpuUsage; return CpuUsage;
} }
TIME PerfDataGetCPUTime(ULONG Index) LARGE_INTEGER PerfDataGetCPUTime(ULONG Index)
{ {
TIME CpuTime = {{0,0}}; LARGE_INTEGER CpuTime = {{0,0}};
EnterCriticalSection(&PerfDataCriticalSection); EnterCriticalSection(&PerfDataCriticalSection);
@ -528,34 +528,34 @@ ULONG PerfDataGetVirtualMemorySizeBytes(ULONG Index)
ULONG PerfDataGetPagedPoolUsagePages(ULONG Index) ULONG PerfDataGetPagedPoolUsagePages(ULONG Index)
{ {
ULONG PagedPoolUsagePages; ULONG PagedPoolUsage;
EnterCriticalSection(&PerfDataCriticalSection); EnterCriticalSection(&PerfDataCriticalSection);
if (Index < ProcessCount) if (Index < ProcessCount)
PagedPoolUsagePages = pPerfData[Index].PagedPoolUsagePages; PagedPoolUsage = pPerfData[Index].PagedPoolUsagePages;
else else
PagedPoolUsagePages = 0; PagedPoolUsage = 0;
LeaveCriticalSection(&PerfDataCriticalSection); LeaveCriticalSection(&PerfDataCriticalSection);
return PagedPoolUsagePages; return PagedPoolUsage;
} }
ULONG PerfDataGetNonPagedPoolUsagePages(ULONG Index) ULONG PerfDataGetNonPagedPoolUsagePages(ULONG Index)
{ {
ULONG NonPagedPoolUsagePages; ULONG NonPagedPoolUsage;
EnterCriticalSection(&PerfDataCriticalSection); EnterCriticalSection(&PerfDataCriticalSection);
if (Index < ProcessCount) if (Index < ProcessCount)
NonPagedPoolUsagePages = pPerfData[Index].NonPagedPoolUsagePages; NonPagedPoolUsage = pPerfData[Index].NonPagedPoolUsagePages;
else else
NonPagedPoolUsagePages = 0; NonPagedPoolUsage = 0;
LeaveCriticalSection(&PerfDataCriticalSection); LeaveCriticalSection(&PerfDataCriticalSection);
return NonPagedPoolUsagePages; return NonPagedPoolUsage;
} }
ULONG PerfDataGetBasePriority(ULONG Index) ULONG PerfDataGetBasePriority(ULONG Index)
@ -664,8 +664,8 @@ ULONG PerfDataGetCommitChargeTotalK(void)
EnterCriticalSection(&PerfDataCriticalSection); EnterCriticalSection(&PerfDataCriticalSection);
Total = SystemPerfInfo.TotalCommittedPages; Total = SystemPerfInfo.CommittedPages;
PageSize = SystemBasicInfo.PhysicalPageSize; PageSize = SystemBasicInfo.PageSize;
LeaveCriticalSection(&PerfDataCriticalSection); LeaveCriticalSection(&PerfDataCriticalSection);
@ -681,8 +681,8 @@ ULONG PerfDataGetCommitChargeLimitK(void)
EnterCriticalSection(&PerfDataCriticalSection); EnterCriticalSection(&PerfDataCriticalSection);
Limit = SystemPerfInfo.TotalCommitLimit; Limit = SystemPerfInfo.CommitLimit;
PageSize = SystemBasicInfo.PhysicalPageSize; PageSize = SystemBasicInfo.PageSize;
LeaveCriticalSection(&PerfDataCriticalSection); LeaveCriticalSection(&PerfDataCriticalSection);
@ -699,7 +699,7 @@ ULONG PerfDataGetCommitChargePeakK(void)
EnterCriticalSection(&PerfDataCriticalSection); EnterCriticalSection(&PerfDataCriticalSection);
Peak = SystemPerfInfo.PeakCommitment; Peak = SystemPerfInfo.PeakCommitment;
PageSize = SystemBasicInfo.PhysicalPageSize; PageSize = SystemBasicInfo.PageSize;
LeaveCriticalSection(&PerfDataCriticalSection); LeaveCriticalSection(&PerfDataCriticalSection);
@ -717,9 +717,9 @@ ULONG PerfDataGetKernelMemoryTotalK(void)
EnterCriticalSection(&PerfDataCriticalSection); EnterCriticalSection(&PerfDataCriticalSection);
Paged = SystemPerfInfo.PagedPoolUsage; Paged = SystemPerfInfo.PagedPoolPages;
NonPaged = SystemPerfInfo.NonPagedPoolUsage; NonPaged = SystemPerfInfo.NonPagedPoolPages;
PageSize = SystemBasicInfo.PhysicalPageSize; PageSize = SystemBasicInfo.PageSize;
LeaveCriticalSection(&PerfDataCriticalSection); LeaveCriticalSection(&PerfDataCriticalSection);
@ -738,8 +738,8 @@ ULONG PerfDataGetKernelMemoryPagedK(void)
EnterCriticalSection(&PerfDataCriticalSection); EnterCriticalSection(&PerfDataCriticalSection);
Paged = SystemPerfInfo.PagedPoolUsage; Paged = SystemPerfInfo.PagedPoolPages;
PageSize = SystemBasicInfo.PhysicalPageSize; PageSize = SystemBasicInfo.PageSize;
LeaveCriticalSection(&PerfDataCriticalSection); LeaveCriticalSection(&PerfDataCriticalSection);
@ -755,8 +755,8 @@ ULONG PerfDataGetKernelMemoryNonPagedK(void)
EnterCriticalSection(&PerfDataCriticalSection); EnterCriticalSection(&PerfDataCriticalSection);
NonPaged = SystemPerfInfo.NonPagedPoolUsage; NonPaged = SystemPerfInfo.NonPagedPoolPages;
PageSize = SystemBasicInfo.PhysicalPageSize; PageSize = SystemBasicInfo.PageSize;
LeaveCriticalSection(&PerfDataCriticalSection); LeaveCriticalSection(&PerfDataCriticalSection);
@ -773,7 +773,7 @@ ULONG PerfDataGetPhysicalMemoryTotalK(void)
EnterCriticalSection(&PerfDataCriticalSection); EnterCriticalSection(&PerfDataCriticalSection);
Total = SystemBasicInfo.NumberOfPhysicalPages; Total = SystemBasicInfo.NumberOfPhysicalPages;
PageSize = SystemBasicInfo.PhysicalPageSize; PageSize = SystemBasicInfo.PageSize;
LeaveCriticalSection(&PerfDataCriticalSection); LeaveCriticalSection(&PerfDataCriticalSection);
@ -790,7 +790,7 @@ ULONG PerfDataGetPhysicalMemoryAvailableK(void)
EnterCriticalSection(&PerfDataCriticalSection); EnterCriticalSection(&PerfDataCriticalSection);
Available = SystemPerfInfo.AvailablePages; Available = SystemPerfInfo.AvailablePages;
PageSize = SystemBasicInfo.PhysicalPageSize; PageSize = SystemBasicInfo.PageSize;
LeaveCriticalSection(&PerfDataCriticalSection); LeaveCriticalSection(&PerfDataCriticalSection);
@ -807,7 +807,7 @@ ULONG PerfDataGetPhysicalMemorySystemCacheK(void)
EnterCriticalSection(&PerfDataCriticalSection); EnterCriticalSection(&PerfDataCriticalSection);
SystemCache = SystemCacheInfo.CurrentSize; SystemCache = SystemCacheInfo.CurrentSize;
PageSize = SystemBasicInfo.PhysicalPageSize; PageSize = SystemBasicInfo.PageSize;
LeaveCriticalSection(&PerfDataCriticalSection); LeaveCriticalSection(&PerfDataCriticalSection);

View file

@ -36,7 +36,7 @@ typedef struct _PERFDATA
WCHAR UserName[MAX_PATH]; WCHAR UserName[MAX_PATH];
ULONG SessionId; ULONG SessionId;
ULONG CPUUsage; ULONG CPUUsage;
TIME CPUTime; LARGE_INTEGER CPUTime;
ULONG WorkingSetSizeBytes; ULONG WorkingSetSizeBytes;
ULONG PeakWorkingSetSizeBytes; ULONG PeakWorkingSetSizeBytes;
ULONG WorkingSetSizeDelta; ULONG WorkingSetSizeDelta;
@ -52,8 +52,8 @@ typedef struct _PERFDATA
ULONG GDIObjectCount; ULONG GDIObjectCount;
IO_COUNTERS IOCounters; IO_COUNTERS IOCounters;
TIME UserTime; LARGE_INTEGER UserTime;
TIME KernelTime; LARGE_INTEGER KernelTime;
} PERFDATA, *PPERFDATA; } PERFDATA, *PPERFDATA;
BOOL PerfDataInitialize(void); BOOL PerfDataInitialize(void);
@ -69,7 +69,7 @@ ULONG PerfDataGetProcessId(ULONG Index);
BOOL PerfDataGetUserName(ULONG Index, LPTSTR lpUserName, int nMaxCount); BOOL PerfDataGetUserName(ULONG Index, LPTSTR lpUserName, int nMaxCount);
ULONG PerfDataGetSessionId(ULONG Index); ULONG PerfDataGetSessionId(ULONG Index);
ULONG PerfDataGetCPUUsage(ULONG Index); ULONG PerfDataGetCPUUsage(ULONG Index);
TIME PerfDataGetCPUTime(ULONG Index); LARGE_INTEGER PerfDataGetCPUTime(ULONG Index);
ULONG PerfDataGetWorkingSetSizeBytes(ULONG Index); ULONG PerfDataGetWorkingSetSizeBytes(ULONG Index);
ULONG PerfDataGetPeakWorkingSetSizeBytes(ULONG Index); ULONG PerfDataGetPeakWorkingSetSizeBytes(ULONG Index);
ULONG PerfDataGetWorkingSetSizeDelta(ULONG Index); ULONG PerfDataGetWorkingSetSizeDelta(ULONG Index);

View file

@ -1,6 +1,6 @@
#define NTOS_MODE_USER
#include <ntos.h>
#include <windows.h> #include <windows.h>
#define NTOS_MODE_USER
#include <ndk/ntndk.h>
#include <commctrl.h> #include <commctrl.h>
#include <shellapi.h> #include <shellapi.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -158,7 +158,7 @@ void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
ULONG Index; ULONG Index;
ULONG ColumnIndex; ULONG ColumnIndex;
IO_COUNTERS iocounters; IO_COUNTERS iocounters;
TIME time; LARGE_INTEGER time;
idctrl = (int) wParam; idctrl = (int) wParam;
pnmh = (LPNMHDR) lParam; pnmh = (LPNMHDR) lParam;