https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8e01dee25155b8edc256f7d2239f8fb22496a543

commit 8e01dee25155b8edc256f7d2239f8fb22496a543
Author:     Eugen Podrug <[email protected]>
AuthorDate: Tue Jan 24 05:42:03 2023 +0100
Commit:     Stanislav Motylkov <[email protected]>
CommitDate: Sun Jul 2 16:10:36 2023 +0300

    [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.
---
 drivers/network/ndis/include/ndissys.h |  4 ++--
 ntoskrnl/ex/sysinfo.c                  | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/network/ndis/include/ndissys.h 
b/drivers/network/ndis/include/ndissys.h
index b80a6a0bbfa..7d5dbb0740a 100644
--- a/drivers/network/ndis/include/ndissys.h
+++ b/drivers/network/ndis/include/ndissys.h
@@ -45,8 +45,8 @@
 VOID
 NTAPI
 ExGetCurrentProcessorCounts(
-   PULONG ThreadKernelTime,
-   PULONG TotalCpuTime,
+   PULONG IdleTime,
+   PULONG KernelAndUserTime,
    PULONG ProcessorNumber);
 
 VOID
diff --git a/ntoskrnl/ex/sysinfo.c b/ntoskrnl/ex/sysinfo.c
index ecf6380dd8b..d6692bc83f6 100644
--- a/ntoskrnl/ex/sysinfo.c
+++ b/ntoskrnl/ex/sysinfo.c
@@ -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;
 }
 
 /*

Reply via email to