[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
NTAPI
ExGetCurrentProcessorCounts(
PULONG ThreadKernelTime,
PULONG TotalCpuTime,
PULONG IdleTime,
PULONG KernelAndUserTime,
PULONG ProcessorNumber);
VOID

View file

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