[NTOS:EX] Fix swapped values in ExGetCurrentProcessorCounts() (#4565)

The function should return the kernel time for the idle thread in the
first argument, and kernel time + user time for the current thread in
the second argument.

Also retrieve the processor number from the cached PRCB instead of
calling KeGetCurrentProcessorNumber() which retrieves the PRCB again
since the processor could switch in-between those calls.

NdisGetCurrentProcessorCounts() function follows the same prototype
which is the correct one.
This commit is contained in:
Eugen Podrug 2023-01-24 05:42:03 +01:00 committed by Stanislav Motylkov
parent bc85db7d8c
commit 8e01dee251
2 changed files with 7 additions and 7 deletions

View file

@ -45,8 +45,8 @@
VOID VOID
NTAPI NTAPI
ExGetCurrentProcessorCounts( ExGetCurrentProcessorCounts(
PULONG ThreadKernelTime, PULONG IdleTime,
PULONG TotalCpuTime, PULONG KernelAndUserTime,
PULONG ProcessorNumber); PULONG ProcessorNumber);
VOID VOID

View file

@ -342,17 +342,17 @@ ExGetCurrentProcessorCpuUsage(PULONG CpuUsage)
*/ */
VOID VOID
NTAPI NTAPI
ExGetCurrentProcessorCounts(PULONG ThreadKernelTime, ExGetCurrentProcessorCounts(PULONG IdleTime,
PULONG TotalCpuTime, PULONG KernelAndUserTime,
PULONG ProcessorNumber) PULONG ProcessorNumber)
{ {
PKPRCB Prcb; PKPRCB Prcb;
Prcb = KeGetCurrentPrcb(); Prcb = KeGetCurrentPrcb();
*ThreadKernelTime = Prcb->KernelTime + Prcb->UserTime; *IdleTime = Prcb->IdleThread->KernelTime;
*TotalCpuTime = Prcb->CurrentThread->KernelTime; *KernelAndUserTime = Prcb->KernelTime + Prcb->UserTime;
*ProcessorNumber = KeGetCurrentProcessorNumber(); *ProcessorNumber = (ULONG)Prcb->Number;
} }
/* /*