diff --git a/rosapps/sysutils/ctm/ctm.c b/rosapps/sysutils/ctm/ctm.c index b9395f5cd50..482688cab0a 100644 --- a/rosapps/sysutils/ctm/ctm.c +++ b/rosapps/sysutils/ctm/ctm.c @@ -31,8 +31,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows //headers -//#include +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows //headers +#include + #include #include #include @@ -40,8 +41,9 @@ #include #include -#include +#define NTOS_MODE_USER #include + #include #include "ctm.h" @@ -372,8 +374,8 @@ void PerfDataRefresh() return; #endif // Get processor information - SysProcessorTimeInfo = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)malloc(sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberProcessors); - status = NtQuerySystemInformation(SystemProcessorPerformanceInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberProcessors, &ulSize); + SysProcessorTimeInfo = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)malloc(sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberOfProcessors); + status = NtQuerySystemInformation(SystemProcessorPerformanceInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberOfProcessors, &ulSize); // Get process information @@ -382,7 +384,7 @@ void PerfDataRefresh() #ifdef TIMES liCurrentKernelTime.QuadPart = 0; liCurrentIdleTime.QuadPart = 0; - for (Idx=0; IdxKernelTime) + Li2Double(pSPI->UserTime); double OldTime = Li2Double(pPDOld->KernelTime) + Li2Double(pPDOld->UserTime); 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; #else