I haven't seen any software that uses this, but some older software out there might use it, so it's good idea to export it.
-- v5: ntoskrnl.exe: add KeNumberProcessors export.
From: Etaash Mathamsetty etaash.mathamsetty@gmail.com
fix various issues with original implementation
use winxp+ behavior
add tests --- dlls/ntoskrnl.exe/ntoskrnl.c | 3 +++ dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +- dlls/ntoskrnl.exe/tests/driver.c | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 9320e02dca9..ae508a1a432 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -2595,6 +2595,8 @@ KAFFINITY WINAPI KeQueryActiveProcessors( void ) return affinity_mask; }
+volatile CCHAR KeNumberProcessors = 0; + ULONG WINAPI KeQueryActiveProcessorCountEx(USHORT group_number) { TRACE("group_number %u.\n", group_number); @@ -4544,6 +4546,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) NtBuildNumber = NtCurrentTeb()->Peb->OSBuildNumber; ntoskrnl_heap = HeapCreate( HEAP_CREATE_ENABLE_EXECUTE, 0, 0 ); dpc_call_tls_index = TlsAlloc(); + KeNumberProcessors = (CCHAR)min( 64UL, KeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS) ); LdrRegisterDllNotification( 0, ldr_notify_callback, NULL, &ldr_notify_cookie ); break; case DLL_PROCESS_DETACH: diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index 8f8edcac7a0..322ed5329de 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -593,7 +593,7 @@ @ stdcall KeLeaveCriticalRegion() @ stub KeLoaderBlock @ stdcall -arch=x86_64 KeLowerIrql(long) -@ stub KeNumberProcessors +@ extern KeNumberProcessors @ stub KeProfileInterrupt @ stub KeProfileInterruptWithSource @ stub KePulseEvent diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index d293889c823..a0a8741f744 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -2003,6 +2003,7 @@ static void test_affinity(void) void (WINAPI *pKeRevertToUserAffinityThreadEx)(KAFFINITY affinity); ULONG (WINAPI *pKeQueryActiveProcessorCountEx)(USHORT); KAFFINITY (WINAPI *pKeQueryActiveProcessors)(void); + CCHAR *pKeNumberProcessors; KAFFINITY mask, mask_all_cpus; ULONG cpu_count, count;
@@ -2022,6 +2023,9 @@ static void test_affinity(void) pKeRevertToUserAffinityThreadEx = get_proc_address("KeRevertToUserAffinityThreadEx"); ok(!!pKeRevertToUserAffinityThreadEx, "KeRevertToUserAffinityThreadEx is not available.\n");
+ pKeNumberProcessors = get_proc_address("KeNumberProcessors"); + ok(!!pKeNumberProcessors, "KeNumberProcessors is not available.\n"); + count = pKeQueryActiveProcessorCountEx(1); ok(!count, "Got unexpected count %lu.\n", count);
@@ -2031,6 +2035,11 @@ static void test_affinity(void) count = pKeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS); ok(count == cpu_count, "Got unexpected count %lu.\n", count);
+ if(count >= 64) + ok(*pKeNumberProcessors == 64, "Got unexpected count %lu.\n", count); + else + ok(*pKeNumberProcessors == cpu_count, "Got unexpected count %lu.\n", count); + if (cpu_count >= 8 * sizeof(KAFFINITY)) mask_all_cpus = ~(KAFFINITY)0; else
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=125380
Your paranoid android.
=== debian11 (32 bit report) ===
dinput: joystick8.c:3556: Test failed: joyGetPosEx returned 165 joystick8.c:3563: Test failed: joyGetDevCapsW returned 165 joystick8.c:3564: Test failed: got wMid 0 joystick8.c:3565: Test failed: got wPid 0 joystick8.c:3569: Test failed: got wXmax 0 joystick8.c:3571: Test failed: got wYmax 0 joystick8.c:3573: Test failed: got wZmax 0 joystick8.c:3574: Test failed: got wNumButtons 0 joystick8.c:3575: Test failed: got wPeriodMin 0 joystick8.c:3576: Test failed: got wPeriodMax 0 joystick8.c:3578: Test failed: got wRmax 0 joystick8.c:3580: Test failed: got wUmax 0 joystick8.c:3582: Test failed: got wVmax 0 joystick8.c:3583: Test failed: got wCaps 0 joystick8.c:3584: Test failed: got wMaxAxes 0 joystick8.c:3585: Test failed: got wNumAxes 0 joystick8.c:3586: Test failed: got wMaxButtons 0 joystick8.c:3594: Test failed: joyGetDevCapsW returned 165 joystick8.c:3615: Test failed: joyGetPosEx returned 165 joystick8.c:3618: Test failed: got dwXpos 0xcdcdcdcd joystick8.c:3619: Test failed: got dwYpos 0xcdcdcdcd joystick8.c:3620: Test failed: got dwZpos 0xcdcdcdcd joystick8.c:3621: Test failed: got dwRpos 0xcdcdcdcd joystick8.c:3622: Test failed: got dwUpos 0xcdcdcdcd joystick8.c:3623: Test failed: got dwVpos 0xcdcdcdcd joystick8.c:3624: Test failed: got dwButtons 0xcdcdcdcd joystick8.c:3625: Test failed: got dwButtonNumber 0xcdcdcdcd joystick8.c:3626: Test failed: got dwPOV 0xcdcdcdcd joystick8.c:3640: Test failed: joyGetPos returned 165 joystick8.c:3641: Test failed: got wXpos 0xcdcdcdcd joystick8.c:3642: Test failed: got wYpos 0xcdcdcdcd joystick8.c:3643: Test failed: got wZpos 0xcdcdcdcd joystick8.c:3644: Test failed: got wButtons 0xcdcdcdcd joystick8.c:3676: Test failed: joyGetPosEx returned 165 joystick8.c:3679: Test failed: got dwXpos 0xcdcdcdcd joystick8.c:3680: Test failed: got dwYpos 0xcdcdcdcd joystick8.c:3681: Test failed: got dwZpos 0xcdcdcdcd joystick8.c:3682: Test failed: got dwRpos 0xcdcdcdcd joystick8.c:3683: Test failed: got dwUpos 0xcdcdcdcd joystick8.c:3684: Test failed: got dwVpos 0xcdcdcdcd joystick8.c:3685: Test failed: got dwButtons 0xcdcdcdcd joystick8.c:3686: Test failed: got dwButtonNumber 0xcdcdcdcd joystick8.c:3687: Test failed: got dwPOV 0xcdcdcdcd joystick8.c:3698: Test failed: joyGetPosEx returned 165 joystick8.c:3701: Test failed: got dwXpos 0xcdcdcdcd joystick8.c:3702: Test failed: got dwYpos 0xcdcdcdcd joystick8.c:3703: Test failed: got dwZpos 0xcdcdcdcd joystick8.c:3704: Test failed: got dwRpos 0xcdcdcdcd joystick8.c:3705: Test failed: got dwUpos 0xcdcdcdcd joystick8.c:3706: Test failed: got dwVpos 0xcdcdcdcd joystick8.c:3707: Test failed: got dwButtons 0xcdcdcdcd joystick8.c:3708: Test failed: got dwButtonNumber 0xcdcdcdcd joystick8.c:3709: Test failed: got dwPOV 0xcdcdcdcd
mmdevapi: render.c:1116: Test marked flaky: Position 54144 too far after playing 100ms
=== debian11 (32 bit de report) ===
ntoskrnl.exe: ntoskrnl.c:1707: Test succeeded inside todo block: got error 997 driver_pnp.c:737: Test failed: expected IRP_MN_REMOVE_DEVICE
I haven't seen any software that uses this, but some older software out there might use it, so it's good idea to export it.
In general we don't do this, i.e. we only add new functions when an application needs them. Otherwise it's just a waste of time, and adds more code to maintain.
This merge request was closed by Etaash Mathamsetty.