[NTOS:KE][NTDLL][NTDLL_VISTA] Implement NtGetCurrentProcessorNumberEx

This commit is contained in:
Timo Kreuzer
2026-07-01 21:45:34 +00:00
parent aab0eac949
commit dbb4d36927
9 changed files with 84 additions and 4 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ set_subsystem(ntdll console)
target_link_libraries(ntdll ntdll_vista_static etwtrace csrlib rtl rtl_um rtl_vista ntdllsys libcntpr setjmp uuid ${PSEH_LIB})
if(DLL_EXPORT_VERSION GREATER_EQUAL 0x600)
target_link_libraries(ntdll cryptlib)
target_link_libraries(ntdll cryptlib ntdllsys_nt6)
endif()
if (STACK_PROTECTOR)
+4 -2
View File
@@ -71,7 +71,7 @@
@ stdcall -stub -version=0x600+ EtwEventActivityIdControl(long ptr)
@ stdcall -stub -version=0x600+ EtwEventEnabled(int64 ptr)
@ stdcall -stub -version=0x600+ EtwEventProviderEnabled(long long long)
@ stdcall -stub -version=0x600+ EtwEventRegister(ptr ptr ptr ptr)
@ stdcall -stub -version=0x600+ EtwEventRegister(ptr ptr ptr ptr)
@ stdcall -stub -version=0x600+ EtwEventSetInformation(int64 long ptr long)
@ stdcall -stub -version=0x600+ EtwEventUnregister(int64)
@ stdcall -stub -version=0x600+ EtwEventWrite(int64 ptr long ptr)
@@ -227,7 +227,7 @@
@ stdcall -stub -version=0x600+ NtAlpcAcceptConnectPort(long long long long long long long long long)
@ stdcall -stub -version=0x600+ NtAlpcCancelMessage(long long long)
@ stdcall -stub -version=0x600+ NtAlpcConnectPort(long long long long long long long long long long long)
@ stdcall -stub -version=0x600+ NtAlpcCreatePort(long long long)
@ stdcall -stub -version=0x600+ NtAlpcCreatePort(long long long)
@ stdcall -stub -version=0x600+ NtAlpcCreatePortSection(long long long long ptr ptr)
@ stdcall -stub -version=0x600+ NtAlpcCreateResourceReserve(long long long ptr)
@ stdcall -stub -version=0x600+ NtAlpcCreateSectionView(long long long)
@@ -339,6 +339,7 @@
@ stdcall NtFsControlFile(long long long long long long long long long long)
@ stdcall NtGetContextThread(long ptr)
@ stdcall NtGetCurrentProcessorNumber() ; 5.2 and higher
@ stdcall -version=0xA00+ NtGetCurrentProcessorNumberEx(ptr)
@ stdcall NtGetDevicePowerState(ptr ptr)
@ stdcall -stub -version=0x600+ NtGetMUIRegistryInfo(long ptr ptr)
@ stdcall -stub -version=0x600+ NtGetNextProcess(long long long long ptr)
@@ -1505,6 +1506,7 @@
@ stdcall ZwFsControlFile(long long long long long long long long long long)
@ stdcall ZwGetContextThread(long ptr)
@ stdcall ZwGetCurrentProcessorNumber()
@ stdcall -version=0xA00+ ZwGetCurrentProcessorNumberEx(ptr)
@ stdcall ZwGetDevicePowerState(ptr ptr)
@ stdcall -stub -version=0x600+ ZwGetMUIRegistryInfo(long ptr ptr)
@ stdcall -stub -version=0x600+ ZwGetNextProcess(ptr long long long ptr)
+1 -1
View File
@@ -19,7 +19,7 @@ target_link_libraries(ntdll_vista_static)
add_dependencies(ntdll_vista_static psdk)
add_library(ntdll_vista MODULE DllMain.c ${CMAKE_CURRENT_BINARY_DIR}/ntdll_vista.def ntdll_vista.rc)
set_module_type(ntdll_vista win32dll ENTRYPOINT DllMain 12)
target_link_libraries(ntdll_vista ntdll_vista_static smlib rtl_vista ${PSEH_LIB})
target_link_libraries(ntdll_vista ntdll_vista_static smlib rtl_vista ntdllsys_nt6 ${PSEH_LIB})
if(ARCH STREQUAL "arm")
target_link_libraries(ntdll_vista chkstk)
endif()
+2
View File
@@ -1,6 +1,8 @@
@ stdcall LdrRegisterDllNotification(long ptr ptr ptr)
@ stdcall LdrUnregisterDllNotification(ptr)
@ stdcall NtGetCurrentProcessorNumberEx(ptr)
@ stdcall RtlGetProductInfo(long long long long ptr)
@ stdcall RtlInitializeConditionVariable(ptr)
@ stdcall RtlWakeConditionVariable(ptr)
+6
View File
@@ -63,3 +63,9 @@ add_asm_files(ntdllsys_asm ntdll.S)
add_library(ntdllsys ${ntdllsys_asm})
set_target_properties(ntdllsys PROPERTIES LINKER_LANGUAGE "C")
add_dependencies(ntdllsys asm)
# NT6 syscalls for ntdll_vista
add_asm_files(ntdllsys_nt6_asm ntdll_nt6.S)
add_library(ntdllsys_nt6 ${ntdllsys_nt6_asm})
set_target_properties(ntdllsys_nt6 PROPERTIES LINKER_LANGUAGE "C")
add_dependencies(ntdllsys_nt6 asm)
+6
View File
@@ -1,3 +1,4 @@
#ifndef SYSFUNCS_NT6_ONLY
SVC_(AcceptConnectPort, 6)
SVC_(AccessCheck, 8)
SVC_(AccessCheckAndAuditAlarm, 11)
@@ -294,3 +295,8 @@
SVC_(QueryPortInformationProcess, 0)
SVC_(GetCurrentProcessorNumber, 0)
SVC_(WaitForMultipleObjects32, 5)
#endif // SYSFUNCS_NT6_ONLY
#ifndef SYSFUNCS_NT5_ONLY
SVC_(GetCurrentProcessorNumberEx, 1)
#endif
+28
View File
@@ -42,3 +42,31 @@ KeQueryActiveProcessors(VOID)
{
return KeActiveProcessors;
}
/**
* Retrieves the number of the current processor.
*
* \param ProcessorNumber Pointer to a PROCESSOR_NUMBER structure that receives the processor number.
*
* \return NTSTATUS The status of the operation.
*/
NTSTATUS
NTAPI
NtGetCurrentProcessorNumberEx(
_Out_ PPROCESSOR_NUMBER ProcessorNumber)
{
_SEH2_TRY
{
ProbeForWrite(ProcessorNumber, sizeof(PROCESSOR_NUMBER), __alignof(PROCESSOR_NUMBER));
ProcessorNumber->Group = 0; // TODO: Support processor groups
ProcessorNumber->Number = (UCHAR)KeGetCurrentProcessorNumber();
ProcessorNumber->Reserved = 0;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
return _SEH2_GetExceptionCode();
}
_SEH2_END;
return STATUS_SUCCESS;
}
+3
View File
@@ -1,6 +1,9 @@
#include <syscalls.inc>
/* This file only has the NT5 syscalls */
#define SYSFUNCS_NT5_ONLY
#ifdef _M_ARM
TEXTAREA
+33
View File
@@ -0,0 +1,33 @@
#include <syscalls.inc>
/* Skip NT5 syscalls, so we get the right IDs for the NT6 ones */
#define SYSFUNCS_NT5_ONLY
#define SVC_(name, argcount) SyscallId = SyscallId + 1
#include <sysfuncs.h>
#undef SVC_
#undef SYSFUNCS_NT5_ONLY
/* Now do the NT6 ones proper */
#define SYSFUNCS_NT6_ONLY
#ifdef _M_ARM
TEXTAREA
#define SVC_(name, argcount) STUB_U name
#include <sysfuncs.h>
END
#else
.code
#define SVC_(name, argcount) STUB_U name, argcount
#include <sysfuncs.h>
END
#endif