From f2623cca38b0038200dc327f90a198108edb0de1 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 9 May 2023 12:43:53 +0200 Subject: [PATCH] ntdll: Implement RtlIsEcCode(). --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/signal_x86_64.c | 12 ++++++++++++ include/winternl.h | 3 +++ 3 files changed, 16 insertions(+) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index b7659ac8c49..4ae544cdbb4 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -836,6 +836,7 @@ @ stdcall RtlIsCriticalSectionLocked(ptr) @ stdcall RtlIsCriticalSectionLockedByThread(ptr) @ stdcall RtlIsDosDeviceName_U(wstr) +@ stdcall -arch=x86_64 -norelay RtlIsEcCode(ptr) @ stub RtlIsGenericTableEmpty # @ stub RtlIsGenericTableEmptyAvl @ stdcall RtlIsNameLegalDOS8Dot3(ptr ptr ptr) diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index 84f6935c5ce..d514ece8787 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -680,6 +680,18 @@ void WINAPI KiUserCallbackDispatcher( ULONG id, void *args, ULONG len ) } +/************************************************************************** + * RtlIsEcCode (NTDLL.@) + */ +BOOLEAN WINAPI RtlIsEcCode( const void *ptr ) +{ + const UINT64 *map = (const UINT64 *)NtCurrentTeb()->Peb->EcCodeBitMap; + ULONG_PTR page = (ULONG_PTR)ptr / page_size; + if (!map) return FALSE; + return (map[page / 64] >> (page & 63)) & 1; +} + + static ULONG64 get_int_reg( CONTEXT *context, int reg ) { return *(&context->Rax + reg); diff --git a/include/winternl.h b/include/winternl.h index 5ee05097915..4061843c4c7 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -4615,6 +4615,9 @@ NTSYSAPI BOOLEAN WINAPI RtlIsActivationContextActive(HANDLE); NTSYSAPI BOOL WINAPI RtlIsCriticalSectionLocked(RTL_CRITICAL_SECTION *); NTSYSAPI BOOL WINAPI RtlIsCriticalSectionLockedByThread(RTL_CRITICAL_SECTION *); NTSYSAPI ULONG WINAPI RtlIsDosDeviceName_U(PCWSTR); +#ifdef __x86_64__ +NTSYSAPI BOOLEAN WINAPI RtlIsEcCode(const void*); +#endif NTSYSAPI BOOLEAN WINAPI RtlIsNameLegalDOS8Dot3(const UNICODE_STRING*,POEM_STRING,PBOOLEAN); NTSYSAPI NTSTATUS WINAPI RtlIsNormalizedString(ULONG,const WCHAR*,INT,BOOLEAN*); NTSYSAPI BOOLEAN WINAPI RtlIsProcessorFeaturePresent(UINT); -- 2.11.4.GIT