- don't redefine public structures in taskmgr - minor taskmgr changes and make better use of PCH - fixed definition of SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION and depending code Modified: trunk/reactos/include/ntos/zwtypes.h Modified: trunk/reactos/lib/kernel32/misc/time.c Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c Modified: trunk/reactos/subsys/system/taskmgr/De.rc Modified: trunk/reactos/subsys/system/taskmgr/Dk.rc Modified: trunk/reactos/subsys/system/taskmgr/En.rc Modified: trunk/reactos/subsys/system/taskmgr/Es.rc Modified: trunk/reactos/subsys/system/taskmgr/Sv.rc Modified: trunk/reactos/subsys/system/taskmgr/about.c Modified: trunk/reactos/subsys/system/taskmgr/affinity.c Modified: trunk/reactos/subsys/system/taskmgr/applpage.c Modified: trunk/reactos/subsys/system/taskmgr/column.c Modified: trunk/reactos/subsys/system/taskmgr/dbgchnl.c Modified: trunk/reactos/subsys/system/taskmgr/debug.c Modified: trunk/reactos/subsys/system/taskmgr/endproc.c Modified: trunk/reactos/subsys/system/taskmgr/font.c Modified: trunk/reactos/subsys/system/taskmgr/graph.c Modified: trunk/reactos/subsys/system/taskmgr/graphctl.c Modified: trunk/reactos/subsys/system/taskmgr/makefile Modified: trunk/reactos/subsys/system/taskmgr/optnmenu.c Modified: trunk/reactos/subsys/system/taskmgr/perfdata.c Modified: trunk/reactos/subsys/system/taskmgr/perfdata.h Modified: trunk/reactos/subsys/system/taskmgr/perfpage.c Modified: trunk/reactos/subsys/system/taskmgr/precomp.h Modified: trunk/reactos/subsys/system/taskmgr/priority.c Modified: trunk/reactos/subsys/system/taskmgr/proclist.c Modified: trunk/reactos/subsys/system/taskmgr/procpage.c Modified: trunk/reactos/subsys/system/taskmgr/resource.h Modified: trunk/reactos/subsys/system/taskmgr/run.c Modified: trunk/reactos/subsys/system/taskmgr/taskmgr.c Modified: trunk/reactos/subsys/system/taskmgr/trayicon.c _____
Modified: trunk/reactos/include/ntos/zwtypes.h --- trunk/reactos/include/ntos/zwtypes.h 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/include/ntos/zwtypes.h 2005-04-07 13:25:34 UTC (rev 14536) @@ -1401,17 +1401,17 @@
// SystemProcessorPerformanceInformation (8) // (one per processor in the system) typedef -struct _SYSTEM_PROCESSORTIME_INFO +struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION { - TIME TotalProcessorRunTime; - TIME TotalProcessorTime; - TIME TotalProcessorUserTime; - TIME TotalDPCTime; - TIME TotalInterruptTime; - ULONG TotalInterrupts; - ULONG Unused; + LARGE_INTEGER IdleTime; + LARGE_INTEGER KernelTime; + LARGE_INTEGER UserTime; + LARGE_INTEGER DpcTime; + LARGE_INTEGER InterruptTime; + ULONG InterruptCount; + ULONG Reserved;
-} SYSTEM_PROCESSORTIME_INFO, *PSYSTEM_PROCESSORTIME_INFO; +} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
// SystemFlagsInformation (9) typedef _____
Modified: trunk/reactos/lib/kernel32/misc/time.c --- trunk/reactos/lib/kernel32/misc/time.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/lib/kernel32/misc/time.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -500,12 +500,12 @@
LPFILETIME lpUserTime ) { - SYSTEM_PROCESSORTIME_INFO SysProcTime; + SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SysProcPerfInfo; NTSTATUS Status;
Status = ZwQuerySystemInformation(SystemProcessorPerformanceInformation, - &SysProcTime, - sizeof(SysProcTime), + &SysProcPerfInfo, + sizeof(SysProcPerfInfo), NULL);
if (!NT_SUCCESS(Status)) @@ -517,14 +517,14 @@ Good only for one processor system. */
- lpIdleTime->dwLowDateTime = SysProcTime.TotalProcessorRunTime.LowPart; - lpIdleTime->dwHighDateTime = SysProcTime.TotalProcessorRunTime.HighPart; + lpIdleTime->dwLowDateTime = SysProcPerfInfo.IdleTime.LowPart; + lpIdleTime->dwHighDateTime = SysProcPerfInfo.IdleTime.HighPart;
- lpKernelTime->dwLowDateTime = SysProcTime.TotalProcessorTime.LowPart; - lpKernelTime->dwHighDateTime = SysProcTime.TotalProcessorTime.HighPart; + lpKernelTime->dwLowDateTime = SysProcPerfInfo.KernelTime.LowPart; + lpKernelTime->dwHighDateTime = SysProcPerfInfo.KernelTime.HighPart;
- lpUserTime->dwLowDateTime = SysProcTime.TotalProcessorUserTime.LowPart; - lpUserTime->dwHighDateTime = SysProcTime.TotalProcessorUserTime.HighPart; + lpUserTime->dwLowDateTime = SysProcPerfInfo.UserTime.LowPart; + lpUserTime->dwHighDateTime = SysProcPerfInfo.UserTime.HighPart;
return TRUE; } _____
Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c --- trunk/reactos/ntoskrnl/ex/sysinfo.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/ntoskrnl/ex/sysinfo.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -725,18 +725,18 @@
/* Class 8 - Processor Performance Information */ QSI_DEF(SystemProcessorPerformanceInformation) { - PSYSTEM_PROCESSORTIME_INFO Spi - = (PSYSTEM_PROCESSORTIME_INFO) Buffer; + PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION Spi + = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) Buffer;
ULONG i; LARGE_INTEGER CurrentTime; PKPRCB Prcb;
- *ReqSize = KeNumberProcessors * sizeof (SYSTEM_PROCESSORTIME_INFO); + *ReqSize = KeNumberProcessors * sizeof (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION); /* - * Check user buffer's size + * Check user buffer's size */ - if (Size < KeNumberProcessors * sizeof(SYSTEM_PROCESSORTIME_INFO)) + if (Size < KeNumberProcessors * sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)) { return (STATUS_INFO_LENGTH_MISMATCH); } @@ -745,16 +745,16 @@ Prcb = ((PKPCR)KPCR_BASE)->Prcb; for (i = 0; i < KeNumberProcessors; i++) { - Spi->TotalProcessorRunTime.QuadPart = (Prcb->IdleThread->KernelTime + Prcb->IdleThread->UserTime) * 100000LL; // IdleTime - Spi->TotalProcessorTime.QuadPart = Prcb->KernelTime * 100000LL; // KernelTime - Spi->TotalProcessorUserTime.QuadPart = Prcb->UserTime * 100000LL; - Spi->TotalDPCTime.QuadPart = Prcb->DpcTime * 100000LL; - Spi->TotalInterruptTime.QuadPart = Prcb->InterruptTime * 100000LL; - Spi->TotalInterrupts = Prcb->InterruptCount; // Interrupt Count + Spi->IdleTime.QuadPart = (Prcb->IdleThread->KernelTime + Prcb->IdleThread->UserTime) * 100000LL; // IdleTime + Spi->KernelTime.QuadPart = Prcb->KernelTime * 100000LL; // KernelTime + Spi->UserTime.QuadPart = Prcb->UserTime * 100000LL; + Spi->DpcTime.QuadPart = Prcb->DpcTime * 100000LL; + Spi->InterruptTime.QuadPart = Prcb->InterruptTime * 100000LL; + Spi->InterruptCount = Prcb->InterruptCount; // Interrupt Count Spi++; Prcb = (PKPRCB)((ULONG_PTR)Prcb + PAGE_SIZE); } - + return (STATUS_SUCCESS); }
_____
Modified: trunk/reactos/subsys/system/taskmgr/De.rc --- trunk/reactos/subsys/system/taskmgr/De.rc 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/De.rc 2005-04-07 13:25:34 UTC (rev 14536) @@ -583,6 +583,7 @@
BEGIN IDS_APP_TITLE "Task-Manager" IDC_TASKMGR "Task-Manager" + IDS_IDLE_PROCESS "Leerlaufprozess" END
STRINGTABLE DISCARDABLE _____
Modified: trunk/reactos/subsys/system/taskmgr/Dk.rc --- trunk/reactos/subsys/system/taskmgr/Dk.rc 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/Dk.rc 2005-04-07 13:25:34 UTC (rev 14536) @@ -538,6 +538,7 @@
BEGIN IDS_APP_TITLE "Opgavestyring" IDC_TASKMGR "Opgavestyring" + IDS_IDLE_PROCESS "System Idle Process" END
STRINGTABLE DISCARDABLE _____
Modified: trunk/reactos/subsys/system/taskmgr/En.rc --- trunk/reactos/subsys/system/taskmgr/En.rc 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/En.rc 2005-04-07 13:25:34 UTC (rev 14536) @@ -538,6 +538,7 @@
BEGIN IDS_APP_TITLE "Task Manager" IDC_TASKMGR "Task Manager" + IDS_IDLE_PROCESS "System Idle Process" END
STRINGTABLE DISCARDABLE _____
Modified: trunk/reactos/subsys/system/taskmgr/Es.rc --- trunk/reactos/subsys/system/taskmgr/Es.rc 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/Es.rc 2005-04-07 13:25:34 UTC (rev 14536) @@ -611,6 +611,7 @@
BEGIN IDS_APP_TITLE "Administrador de Tareas" IDC_TASKMGR "Administrador de Tareas" + IDS_IDLE_PROCESS "System Idle Process" END
STRINGTABLE DISCARDABLE _____
Modified: trunk/reactos/subsys/system/taskmgr/Sv.rc --- trunk/reactos/subsys/system/taskmgr/Sv.rc 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/Sv.rc 2005-04-07 13:25:34 UTC (rev 14536) @@ -555,6 +555,7 @@
BEGIN IDS_APP_TITLE "Aktivitetshanteraren" IDC_TASKMGR "Aktivitetshanteraren" + IDS_IDLE_PROCESS "System Idle Process" END
STRINGTABLE DISCARDABLE _____
Modified: trunk/reactos/subsys/system/taskmgr/about.c --- trunk/reactos/subsys/system/taskmgr/about.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/about.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -21,14 +21,6 @@
*/
#include "precomp.h" -#include <commctrl.h> -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> -#include <stdio.h> - -#include "about.h"
INT_PTR CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
_____
Modified: trunk/reactos/subsys/system/taskmgr/affinity.c --- trunk/reactos/subsys/system/taskmgr/affinity.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/affinity.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -22,17 +22,6 @@
*/
#include "precomp.h" -#include <commctrl.h> -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> -#include <winnt.h> -#include <stdio.h> - -#include "procpage.h" -#include "affinity.h" -#include "perfdata.h"
HANDLE hProcessAffinityHandle; TCHAR szTemp[256]; _____
Modified: trunk/reactos/subsys/system/taskmgr/applpage.c --- trunk/reactos/subsys/system/taskmgr/applpage.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/applpage.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -22,16 +22,7 @@
*/
#include "precomp.h" -#include <commctrl.h> -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> -#include <stdio.h>
-#include "applpage.h" -#include "procpage.h" - typedef struct { HWND hWnd; @@ -370,7 +361,7 @@ /* It is not already in the list so add it */ else { - pAPLI = (LPAPPLICATION_PAGE_LIST_ITEM)malloc(sizeof(APPLICATION_PAGE_LIST_ITEM)) ; + pAPLI = (LPAPPLICATION_PAGE_LIST_ITEM)HeapAlloc(GetProcessHeap(), 0, sizeof(APPLICATION_PAGE_LIST_ITEM));
pAPLI->hWnd = hWnd; pAPLI->hIcon = hIcon; @@ -409,7 +400,7 @@ ImageList_Remove(hImageListSmall, item.iItem);
ListView_DeleteItem(hApplicationPageListCtrl, item.iItem); - free(pAPLI); + HeapFree(GetProcessHeap(), 0, pAPLI); bItemRemoved = TRUE; } } @@ -704,7 +695,7 @@ HWND* hWndArray; int nWndCount;
- hWndArray = (HWND*)malloc(sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl)); + hWndArray = (HWND*)HeapAlloc(GetProcessHeap(), 0, sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl)); nWndCount = 0;
for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) { @@ -724,7 +715,7 @@ } } TileWindows(NULL, MDITILE_HORIZONTAL, NULL, nWndCount, hWndArray); - free(hWndArray); + HeapFree(GetProcessHeap(), 0, hWndArray); }
void ApplicationPage_OnWindowsTileVertically(void) @@ -735,7 +726,7 @@ HWND* hWndArray; int nWndCount;
- hWndArray = (HWND*)malloc(sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl)); + hWndArray = (HWND*)HeapAlloc(GetProcessHeap(), 0, sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl)); nWndCount = 0;
for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) { @@ -755,7 +746,7 @@ }
TileWindows(NULL, MDITILE_VERTICAL, NULL, nWndCount, hWndArray); - free(hWndArray); + HeapFree(GetProcessHeap(), 0, hWndArray); }
void ApplicationPage_OnWindowsMinimize(void) @@ -808,7 +799,7 @@ HWND* hWndArray; int nWndCount;
- hWndArray = (HWND*)malloc(sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl)); + hWndArray = (HWND*)HeapAlloc(GetProcessHeap(), 0, sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl)); nWndCount = 0;
for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) { @@ -826,7 +817,7 @@ } } CascadeWindows(NULL, 0, NULL, nWndCount, hWndArray); - free(hWndArray); + HeapFree(GetProcessHeap(), 0, hWndArray); }
void ApplicationPage_OnWindowsBringToFront(void) _____
Modified: trunk/reactos/subsys/system/taskmgr/column.c --- trunk/reactos/subsys/system/taskmgr/column.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/column.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -22,15 +22,6 @@
*/
#include "precomp.h" -#include <commctrl.h> -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> -#include <stdio.h> - -#include "column.h" -#include "procpage.h"
UINT ColumnDataHints[25]; TCHAR szTemp[256]; _____
Modified: trunk/reactos/subsys/system/taskmgr/dbgchnl.c --- trunk/reactos/subsys/system/taskmgr/dbgchnl.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/dbgchnl.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -21,20 +21,6 @@
*/
#include "precomp.h" -#include <commctrl.h> -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> -#include <stdio.h> -#include <winnt.h> - -#include "procpage.h" -#include "perfdata.h" -#include "column.h" -#include "proclist.h" -#include "dbgchnl.h" -#include <ctype.h>
/* TODO: * - the dialog box could be non modal _____
Modified: trunk/reactos/subsys/system/taskmgr/debug.c --- trunk/reactos/subsys/system/taskmgr/debug.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/debug.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -22,17 +22,6 @@
*/
#include "precomp.h" -#include <commctrl.h> -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> -#include <stdio.h> -#include <winnt.h> - -#include "debug.h" -#include "procpage.h" -#include "perfdata.h"
void ProcessPage_OnDebug(void) { _____
Modified: trunk/reactos/subsys/system/taskmgr/endproc.c --- trunk/reactos/subsys/system/taskmgr/endproc.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/endproc.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -22,17 +22,6 @@
*/
#include "precomp.h" -#include <commctrl.h> -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> -#include <stdio.h> -#include <winnt.h> - -#include "endproc.h" -#include "procpage.h" -#include "perfdata.h"
TCHAR szTemp[256]; TCHAR szTempA[256]; _____
Modified: trunk/reactos/subsys/system/taskmgr/font.c --- trunk/reactos/subsys/system/taskmgr/font.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/font.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -21,14 +21,6 @@
*/
#include "precomp.h" -#include <commctrl.h> -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> -#include <stdio.h> - -#include "font.h"
void Font_DrawText(HDC hDC, LPCTSTR lpszText, int x, int y) { _____
Modified: trunk/reactos/subsys/system/taskmgr/graph.c --- trunk/reactos/subsys/system/taskmgr/graph.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/graph.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -21,19 +21,7 @@
*/
#include "precomp.h" -#include <commctrl.h> -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> -#include <stdio.h> -#include <winnt.h> - -#include "graph.h" -#include "font.h" -#include "perfdata.h"
- LONG OldGraphWndProc;
void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd); _____
Modified: trunk/reactos/subsys/system/taskmgr/graphctl.c --- trunk/reactos/subsys/system/taskmgr/graphctl.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/graphctl.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -21,16 +21,7 @@
*/
#include "precomp.h" -#include <commctrl.h> -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> -#include <stdio.h>
-#include <math.h> -#include "graphctl.h" - LONG OldGraphCtrlWndProc;
static void GraphCtrl_Init(TGraphCtrl* this) _____
Modified: trunk/reactos/subsys/system/taskmgr/makefile --- trunk/reactos/subsys/system/taskmgr/makefile 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/makefile 2005-04-07 13:25:34 UTC (rev 14536) @@ -16,7 +16,7 @@
TARGET_PCH = precomp.h
-TARGET_CFLAGS = -Werror -Wall -DDBG -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API +TARGET_CFLAGS = -Werror -Wall -DDBG -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API TARGET_SDKLIBS = ntdll.a kernel32.a user32.a gdi32.a comctl32.a
_____
Modified: trunk/reactos/subsys/system/taskmgr/optnmenu.c --- trunk/reactos/subsys/system/taskmgr/optnmenu.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/optnmenu.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -27,15 +27,6 @@
*/
#include "precomp.h" -#include <commctrl.h> -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> -#include <stdio.h> - -#include "optnmenu.h" -#include "procpage.h"
void TaskManager_OnOptionsAlwaysOnTop(void) { _____
Modified: trunk/reactos/subsys/system/taskmgr/perfdata.c --- trunk/reactos/subsys/system/taskmgr/perfdata.c 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/perfdata.c 2005-04-07 13:25:34 UTC (rev 14536) @@ -21,19 +21,8 @@
*/
#include "precomp.h" -#include <commctrl.h> -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> -#include <stdio.h> -#include <winnt.h> -#include "perfdata.h"
-PROCNTQSI NtQuerySystemInformation = NULL; -PROCGGR pGetGuiResources = NULL; -PROCGPIC pGetProcessIoCounters = NULL; -CRITICAL_SECTION PerfDataCriticalSection; +CRITICAL_SECTION PerfDataCriticalSection; PPERFDATA pPerfDataOld = NULL; /* Older perf data (saved to establish delta values) */ PPERFDATA pPerfData = NULL; /* Most recent copy of perf data */ ULONG ProcessCountOld = 0; @@ -48,21 +37,14 @@ SYSTEM_BASIC_INFORMATION SystemBasicInfo; SYSTEM_CACHE_INFORMATION SystemCacheInfo; SYSTEM_HANDLE_INFORMATION SystemHandleInfo; -PSYSTEM_PROCESSORTIME_INFO SystemProcessorTimeInfo = NULL; +PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SystemProcessorTimeInfo = NULL;
BOOL PerfDataInitialize(void) { - LONG status; - - NtQuerySystemInformation = (PROCNTQSI)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "NtQuerySystemInformation"); - pGetGuiResources = (PROCGGR)GetProcAddress(GetModuleHandle(_T("user32.dll")), "GetGuiResources"); - pGetProcessIoCounters = (PROCGPIC)GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "GetProcessIoCounters"); + NTSTATUS status;
InitializeCriticalSection(&PerfDataCriticalSection);
- if (!NtQuerySystemInformation) - return FALSE; - /* * Get number of processors in the system */ @@ -75,15 +57,13 @@
void PerfDataUninitialize(void) { - NtQuerySystemInformation = NULL; - DeleteCriticalSection(&PerfDataCriticalSection); }
void PerfDataRefresh(void) { ULONG ulSize; - LONG status; + NTSTATUS status; LPBYTE pBuffer; ULONG BufferSize; PSYSTEM_PROCESS_INFORMATION pSPI; @@ -94,18 +74,14 @@ TCHAR szTemp[MAX_PATH]; DWORD dwSize; SYSTEM_PERFORMANCE_INFORMATION SysPerfInfo; - SYSTEM_TIME_INFORMATION SysTimeInfo; + SYSTEM_TIMEOFDAY_INFORMATION SysTimeInfo; SYSTEM_CACHE_INFORMATION SysCacheInfo; LPBYTE SysHandleInfoData; - PSYSTEM_PROCESSORTIME_INFO SysProcessorTimeInfo; + PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SysProcessorTimeInfo; double CurrentKernelTime;
- - if (!NtQuerySystemInformation) - return; - /* Get new system time */ - status = NtQuerySystemInformation(SystemTimeInformation, &SysTimeInfo, sizeof(SysTimeInfo), 0); + status = NtQuerySystemInformation(SystemTimeOfDayInformation, &SysTimeInfo, sizeof(SysTimeInfo), 0); if (status != NO_ERROR) return;
@@ -120,8 +96,8 @@ return;
/* Get processor time information */ - SysProcessorTimeInfo = (PSYSTEM_PROCESSORTIME_INFO)malloc(sizeof(SYSTEM_PROCESSORTIME_INFO) * SystemBasicInfo.bKeNumberProcessors); - status = NtQuerySystemInformation(SystemProcessorTimeInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSORTIME_INFO) * SystemBasicInfo.bKeNumberProcessors, &ulSize); + SysProcessorTimeInfo = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)HeapAlloc(GetProcessHeap(), 0, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberProcessors); + status = NtQuerySystemInformation(SystemProcessorPerformanceInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberProcessors, &ulSize); if (status != NO_ERROR) return;
@@ -133,12 +109,12 @@ do { BufferSize += 0x10000; - SysHandleInfoData = (LPBYTE)malloc(BufferSize); + SysHandleInfoData = (LPBYTE)HeapAlloc(GetProcessHeap(), 0, BufferSize);
status = NtQuerySystemInformation(SystemHandleInformation, SysHandleInfoData, BufferSize, &ulSize);
if (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/) { - free(SysHandleInfoData); + HeapFree(GetProcessHeap(), 0, SysHandleInfoData); }
} while (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/); @@ -151,12 +127,12 @@ do { BufferSize += 0x10000; - pBuffer = (LPBYTE)malloc(BufferSize); + pBuffer = (LPBYTE)HeapAlloc(GetProcessHeap(), 0, BufferSize);
status = NtQuerySystemInformation(SystemProcessInformation, pBuffer, BufferSize, &ulSize);
if (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/) { - free(pBuffer); + HeapFree(GetProcessHeap(), 0, pBuffer); }
} while (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/); @@ -177,7 +153,7 @@ * Save system processor time info */ if (SystemProcessorTimeInfo) { - free(SystemProcessorTimeInfo); + HeapFree(GetProcessHeap(), 0, SystemProcessorTimeInfo); } SystemProcessorTimeInfo = SysProcessorTimeInfo;
@@ -185,9 +161,9 @@ * Save system handle info */ memcpy(&SystemHandleInfo, SysHandleInfoData, sizeof(SYSTEM_HANDLE_INFORMATION)); - free(SysHandleInfoData); + HeapFree(GetProcessHeap(), 0, SysHandleInfoData);
- for (CurrentKernelTime=0, Idx=0; Idx<SystemBasicInfo.bKeNumberProcessors; Idx++) { + for (CurrentKernelTime=0, Idx=0; Idx<SystemBasicInfo.NumberProcessors; Idx++) { CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime); CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].DpcTime); CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].InterruptTime); @@ -196,22 +172,22 @@ /* If it's a first call - skip idle time calcs */ if (liOldIdleTime.QuadPart != 0) { /* CurrentValue = NewValue - OldValue */ - dbIdleTime = Li2Double(SysPerfInfo.liIdleTime) - Li2Double(liOldIdleTime); + dbIdleTime = Li2Double(SysPerfInfo.IdleTime) - Li2Double(liOldIdleTime); dbKernelTime = CurrentKernelTime - OldKernelTime; - dbSystemTime = Li2Double(SysTimeInfo.liKeSystemTime) - Li2Double(liOldSystemTime); + dbSystemTime = Li2Double(SysTimeInfo.CurrentTime) - Li2Double(liOldSystemTime);
/* CurrentCpuIdle = IdleTime / SystemTime */ dbIdleTime = dbIdleTime / dbSystemTime; dbKernelTime = dbKernelTime / dbSystemTime;
/* CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors */ - dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.bKeNumberProcessors; /* + 0.5; */ - dbKernelTime = 100.0 - dbKernelTime * 100.0 / (double)SystemBasicInfo.bKeNumberProcessors; /* + 0.5; */ + dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.NumberProcessors; /* + 0.5; */ + dbKernelTime = 100.0 - dbKernelTime * 100.0 / (double)SystemBasicInfo.NumberProcessors; /* + 0.5; */ }
/* Store new CPU's idle and system time */ - liOldIdleTime = SysPerfInfo.liIdleTime; - liOldSystemTime = SysTimeInfo.liKeSystemTime; + liOldIdleTime = SysPerfInfo.IdleTime; + liOldSystemTime = SysTimeInfo.CurrentTime; OldKernelTime = CurrentKernelTime;
/* Determine the process count @@ -223,24 +199,24 @@ pSPI = (PSYSTEM_PROCESS_INFORMATION)pBuffer; while (pSPI) { ProcessCount++; - if (pSPI->RelativeOffset == 0) + if (pSPI->NextEntryOffset == 0) break; - pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->RelativeOffset); + pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->NextEntryOffset); }
/* Now alloc a new PERFDATA array and fill in the data */ if (pPerfDataOld) { - free(pPerfDataOld); + HeapFree(GetProcessHeap(), 0, pPerfDataOld); } pPerfDataOld = pPerfData; - pPerfData = (PPERFDATA)malloc(sizeof(PERFDATA) * ProcessCount); + pPerfData = (PPERFDATA)HeapAlloc(GetProcessHeap(), 0, sizeof(PERFDATA) * ProcessCount); pSPI = (PSYSTEM_PROCESS_INFORMATION)pBuffer; for (Idx=0; Idx<ProcessCount; Idx++) { /* Get the old perf data for this process (if any) */ /* so that we can establish delta values */ pPDOld = NULL; for (Idx2=0; Idx2<ProcessCountOld; Idx2++) { - if (pPerfDataOld[Idx2].ProcessId == pSPI->ProcessId) { + if (pPerfDataOld[Idx2].ProcessId == pSPI->UniqueProcessId) { pPDOld = &pPerfDataOld[Idx2]; break; } @@ -249,25 +225,26 @@ /* Clear out process perf data structure */ memset(&pPerfData[Idx], 0, sizeof(PERFDATA));
- if (pSPI->Name.Buffer) - wcscpy(pPerfData[Idx].ImageName, pSPI->Name.Buffer); + if (pSPI->ImageName.Buffer) + wcscpy(pPerfData[Idx].ImageName, pSPI->ImageName.Buffer); else - wcscpy(pPerfData[Idx].ImageName, L"System Idle Process"); + LoadStringW(hInst, IDS_IDLE_PROCESS, pPerfData[Idx].ImageName, + sizeof(pPerfData[Idx].ImageName) / sizeof(pPerfData[Idx].ImageName[0]));
- pPerfData[Idx].ProcessId = pSPI->ProcessId; + pPerfData[Idx].ProcessId = pSPI->UniqueProcessId;
if (pPDOld) { double CurTime = Li2Double(pSPI->KernelTime) + Li2Double(pSPI->UserTime); double OldTime = Li2Double(pPDOld->KernelTime) + Li2Double(pPDOld->UserTime); double CpuTime = (CurTime - OldTime) / dbSystemTime; - CpuTime = CpuTime * 100.0 / (double)SystemBasicInfo.bKeNumberProcessors; /* + 0.5; */ + CpuTime = CpuTime * 100.0 / (double)SystemBasicInfo.NumberProcessors; /* + 0.5; */ pPerfData[Idx].CPUUsage = (ULONG)CpuTime; } pPerfData[Idx].CPUTime.QuadPart = pSPI->UserTime.QuadPart + pSPI->KernelTime.QuadPart; - pPerfData[Idx].WorkingSetSizeBytes = pSPI->TotalWorkingSetSizeBytes; - pPerfData[Idx].PeakWorkingSetSizeBytes = pSPI->PeakWorkingSetSizeBytes; + pPerfData[Idx].WorkingSetSizeBytes = pSPI->WorkingSetSize; + pPerfData[Idx].PeakWorkingSetSizeBytes = pSPI->PeakWorkingSetSize; if (pPDOld) - pPerfData[Idx].WorkingSetSizeDelta = labs((LONG)pSPI->TotalWorkingSetSizeBytes - (LONG)pPDOld->WorkingSetSizeBytes); + pPerfData[Idx].WorkingSetSizeDelta = labs((LONG)pSPI->WorkingSetSize - (LONG)pPDOld->WorkingSetSizeBytes); else pPerfData[Idx].WorkingSetSizeDelta = 0; pPerfData[Idx].PageFaultCount = pSPI->PageFaultCount; @@ -275,15 +252,15 @@ pPerfData[Idx].PageFaultCountDelta = labs((LONG)pSPI->PageFaultCount - (LONG)pPDOld->PageFaultCount); else pPerfData[Idx].PageFaultCountDelta = 0; - pPerfData[Idx].VirtualMemorySizeBytes = pSPI->TotalVirtualSizeBytes; - pPerfData[Idx].PagedPoolUsagePages = pSPI->TotalPagedPoolUsagePages; - pPerfData[Idx].NonPagedPoolUsagePages = pSPI->TotalNonPagedPoolUsagePages; + pPerfData[Idx].VirtualMemorySizeBytes = pSPI->VirtualSize; + pPerfData[Idx].PagedPoolUsagePages = pSPI->QuotaPagedPoolUsage; + pPerfData[Idx].NonPagedPoolUsagePages = pSPI->QuotaPeakNonPagedPoolUsage; pPerfData[Idx].BasePriority = pSPI->BasePriority; pPerfData[Idx].HandleCount = pSPI->HandleCount; - pPerfData[Idx].ThreadCount = pSPI->ThreadCount; + pPerfData[Idx].ThreadCount = pSPI->NumberOfThreads; pPerfData[Idx].SessionId = pSPI->SessionId;
- hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pSPI->ProcessId); + hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, (DWORD)pSPI->UniqueProcessId); if (hProcess) { if (OpenProcessToken(hProcess, TOKEN_QUERY|TOKEN_DUPLICATE|TOKEN_IMPERSONATE, &hProcessToken)) { ImpersonateLoggedOnUser(hProcessToken); @@ -306,19 +283,16 @@ RevertToSelf(); CloseHandle(hProcessToken); } - if (pGetGuiResources) { - pPerfData[Idx].USERObjectCount = pGetGuiResources(hProcess, GR_USEROBJECTS); - pPerfData[Idx].GDIObjectCount = pGetGuiResources(hProcess, GR_GDIOBJECTS); - } - if (pGetProcessIoCounters) - pGetProcessIoCounters(hProcess, &pPerfData[Idx].IOCounters); + pPerfData[Idx].USERObjectCount = GetGuiResources(hProcess, GR_USEROBJECTS); + pPerfData[Idx].GDIObjectCount = GetGuiResources(hProcess, GR_GDIOBJECTS); + GetProcessIoCounters(hProcess, &pPerfData[Idx].IOCounters); CloseHandle(hProcess); } pPerfData[Idx].UserTime.QuadPart = pSPI->UserTime.QuadPart; pPerfData[Idx].KernelTime.QuadPart = pSPI->KernelTime.QuadPart; - pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->RelativeOffset); + pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->NextEntryOffset); } - free(pBuffer); + HeapFree(GetProcessHeap(), 0, pBuffer); LeaveCriticalSection(&PerfDataCriticalSection); }
@@ -365,7 +339,7 @@ EnterCriticalSection(&PerfDataCriticalSection);
if (Index < ProcessCount) - ProcessId = pPerfData[Index].ProcessId; + ProcessId = (ULONG)pPerfData[Index].ProcessId; else ProcessId = 0;
@@ -677,8 +651,8 @@
EnterCriticalSection(&PerfDataCriticalSection);
- Total = SystemPerfInfo.MmTotalCommitedPages; - PageSize = SystemBasicInfo.uPageSize; + Total = SystemPerfInfo.TotalCommittedPages; + PageSize = SystemBasicInfo.PhysicalPageSize;
LeaveCriticalSection(&PerfDataCriticalSection);
@@ -694,8 +668,8 @@
EnterCriticalSection(&PerfDataCriticalSection);
- Limit = SystemPerfInfo.MmTotalCommitLimit; - PageSize = SystemBasicInfo.uPageSize; + Limit = SystemPerfInfo.TotalCommitLimit; + PageSize = SystemBasicInfo.PhysicalPageSize;
LeaveCriticalSection(&PerfDataCriticalSection);
@@ -711,8 +685,8 @@
EnterCriticalSection(&PerfDataCriticalSection);
- Peak = SystemPerfInfo.MmPeakLimit; - PageSize = SystemBasicInfo.uPageSize; + Peak = SystemPerfInfo.PeakCommitment; + PageSize = SystemBasicInfo.PhysicalPageSize;
LeaveCriticalSection(&PerfDataCriticalSection);
@@ -730,9 +704,9 @@
EnterCriticalSection(&PerfDataCriticalSection);
- Paged = SystemPerfInfo.PoolPagedBytes; - NonPaged = SystemPerfInfo.PoolNonPagedBytes; - PageSize = SystemBasicInfo.uPageSize; + Paged = SystemPerfInfo.PagedPoolUsage; + NonPaged = SystemPerfInfo.NonPagedPoolUsage; + PageSize = SystemBasicInfo.PhysicalPageSize;
LeaveCriticalSection(&PerfDataCriticalSection);
@@ -751,8 +725,8 @@
EnterCriticalSection(&PerfDataCriticalSection);
- Paged = SystemPerfInfo.PoolPagedBytes; - PageSize = SystemBasicInfo.uPageSize; + Paged = SystemPerfInfo.PagedPoolUsage; + PageSize = SystemBasicInfo.PhysicalPageSize;
LeaveCriticalSection(&PerfDataCriticalSection);
@@ -768,8 +742,8 @@
EnterCriticalSection(&PerfDataCriticalSection);
- NonPaged = SystemPerfInfo.PoolNonPagedBytes; - PageSize = SystemBasicInfo.uPageSize; + NonPaged = SystemPerfInfo.NonPagedPoolUsage; + PageSize = SystemBasicInfo.PhysicalPageSize;
LeaveCriticalSection(&PerfDataCriticalSection);
@@ -785,8 +759,8 @@
EnterCriticalSection(&PerfDataCriticalSection);
- Total = SystemBasicInfo.uMmNumberOfPhysicalPages; - PageSize = SystemBasicInfo.uPageSize; + Total = SystemBasicInfo.NumberOfPhysicalPages; + PageSize = SystemBasicInfo.PhysicalPageSize;
LeaveCriticalSection(&PerfDataCriticalSection);
@@ -802,8 +776,8 @@
EnterCriticalSection(&PerfDataCriticalSection);
- Available = SystemPerfInfo.MmAvailablePages; - PageSize = SystemBasicInfo.uPageSize; + Available = SystemPerfInfo.AvailablePages; + PageSize = SystemBasicInfo.PhysicalPageSize;
LeaveCriticalSection(&PerfDataCriticalSection);
@@ -820,7 +794,7 @@ EnterCriticalSection(&PerfDataCriticalSection);
SystemCache = SystemCacheInfo.CurrentSize; - PageSize = SystemBasicInfo.uPageSize; + PageSize = SystemBasicInfo.PhysicalPageSize;
LeaveCriticalSection(&PerfDataCriticalSection);
@@ -836,7 +810,7 @@
EnterCriticalSection(&PerfDataCriticalSection);
- HandleCount = SystemHandleInfo.Count; + HandleCount = SystemHandleInfo.NumberOfHandles;
LeaveCriticalSection(&PerfDataCriticalSection);
_____
Modified: trunk/reactos/subsys/system/taskmgr/perfdata.h --- trunk/reactos/subsys/system/taskmgr/perfdata.h 2005-04-07 13:11:46 UTC (rev 14535) +++ trunk/reactos/subsys/system/taskmgr/perfdata.h 2005-04-07 13:25:34 UTC (rev 14536) @@ -27,27 +27,12 @@
extern "C" { #endif
+#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + (double)((x).LowPart))
-#if 0 -typedef struct _TIME { - DWORD LowPart; - LONG HighPart; -} TIME, *PTIME; -#endif - -typedef ULARGE_INTEGER TIME, *PTIME; - -/* typedef WCHAR UNICODE_STRING; */ -typedef struct _UNICODE_STRING { - USHORT Length; - USHORT MaximumLength; - PWSTR Buffer; -} UNICODE_STRING, *PUNICODE_STRING; - typedef struct _PERFDATA { WCHAR ImageName[MAX_PATH]; - ULONG ProcessId; + HANDLE ProcessId; WCHAR UserName[MAX_PATH]; ULONG SessionId; ULONG CPUUsage; @@ -71,277 +56,6 @@ TIME KernelTime; } PERFDATA, *PPERFDATA;
-typedef struct _CLIENT_ID -{ - HANDLE UniqueProcess; - HANDLE UniqueThread; -} CLIENT_ID, *PCLIENT_ID; - -typedef enum _KWAIT_REASON -{ - Executive, - FreePage, - PageIn, - PoolAllocation, - DelayExecution, - Suspended, - UserRequest, - WrExecutive, - WrFreePage, - WrPageIn, - WrDelayExecution, - WrSuspended, - WrUserRequest, - WrQueue, - WrLpcReceive, - WrLpcReply, - WrVirtualMemory, - WrPageOut, - WrRendezvous, - Spare2, - Spare3, - Spare4, - Spare5, - Spare6, - WrKernel, - MaximumWaitReason, -} KWAIT_REASON; - -/* SystemProcessThreadInfo (5) */ -typedef struct _SYSTEM_THREAD_INFORMATION -{ - TIME KernelTime; - TIME UserTime; - TIME CreateTime; - ULONG TickCount; - ULONG StartEIP; - CLIENT_ID ClientId; - ULONG DynamicPriority; - ULONG BasePriority; - ULONG nSwitches; - DWORD State; - KWAIT_REASON WaitReason; - [truncated at 1000 lines; 442 more skipped]