Module: wine Branch: master Commit: 4a026f4230d2888fd57f26bcc5efe5d98c0091e4 URL: https://gitlab.winehq.org/wine/wine/-/commit/4a026f4230d2888fd57f26bcc5efe5d...
Author: Alexandre Julliard julliard@winehq.org Date: Fri Mar 8 09:57:10 2024 +0100
ntdll: Support the __os_arm64x_helper functions in the loader.
---
dlls/ntdll/loader.c | 28 +++++++++++++++++++++------- dlls/ntdll/ntdll_misc.h | 9 +++++++++ include/winnt.h | 9 +++++++++ 3 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 765fb5b1617..b389a16d2a7 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -240,18 +240,23 @@ static void module_push_unload_trace( const WINE_MODREF *wm )
#ifdef __arm64ec__
+static void update_hybrid_pointer( void *module, const IMAGE_SECTION_HEADER *sec, UINT rva, void *ptr ) +{ + if (!rva) return; + + if (rva < sec->VirtualAddress || rva >= sec->VirtualAddress + sec->Misc.VirtualSize) + ERR( "rva %x outside of section %s (%lx-%lx)\n", rva, + sec->Name, sec->VirtualAddress, sec->VirtualAddress + sec->Misc.VirtualSize ); + else + *(void **)get_rva( module, rva ) = ptr; +} + static void update_hybrid_metadata( void *module, IMAGE_NT_HEADERS *nt, const IMAGE_ARM64EC_METADATA *metadata ) { DWORD i, protect_old; const IMAGE_SECTION_HEADER *sec = IMAGE_FIRST_SECTION( nt );
- if (metadata->Version != 1) - { - ERR( "unknown version %lu\n", metadata->Version ); - return; - } - /* assume that all pointers are in the same section */
for (i = 0; i < nt->FileHeader.NumberOfSections; i++, sec++) @@ -264,13 +269,22 @@ static void update_hybrid_metadata( void *module, IMAGE_NT_HEADERS *nt,
NtProtectVirtualMemory( NtCurrentProcess(), &base, &size, PAGE_READWRITE, &protect_old );
-#define SET_FUNC(func,val) *(void **)get_rva( module, metadata->func ) = val +#define SET_FUNC(func,val) update_hybrid_pointer( module, sec, metadata->func, val ) SET_FUNC( __os_arm64x_dispatch_call, __os_arm64x_check_call ); SET_FUNC( __os_arm64x_dispatch_call_no_redirect, __os_arm64x_dispatch_call_no_redirect ); SET_FUNC( __os_arm64x_dispatch_fptr, __os_arm64x_dispatch_fptr ); SET_FUNC( __os_arm64x_dispatch_icall, __os_arm64x_check_icall ); SET_FUNC( __os_arm64x_dispatch_icall_cfg, __os_arm64x_check_icall_cfg ); SET_FUNC( __os_arm64x_dispatch_ret, __os_arm64x_dispatch_ret ); + SET_FUNC( __os_arm64x_helper0, __os_arm64x_helper0 ); + SET_FUNC( __os_arm64x_helper1, __os_arm64x_helper1 ); + SET_FUNC( __os_arm64x_helper2, __os_arm64x_helper2 ); + SET_FUNC( __os_arm64x_helper3, __os_arm64x_helper3 ); + SET_FUNC( __os_arm64x_helper4, __os_arm64x_helper4 ); + SET_FUNC( __os_arm64x_helper5, __os_arm64x_helper5 ); + SET_FUNC( __os_arm64x_helper6, __os_arm64x_helper6 ); + SET_FUNC( __os_arm64x_helper7, __os_arm64x_helper7 ); + SET_FUNC( __os_arm64x_helper8, __os_arm64x_helper8 ); SET_FUNC( GetX64InformationFunctionPointer, __os_arm64x_get_x64_information ); SET_FUNC( SetX64InformationFunctionPointer, __os_arm64x_set_x64_information ); #undef SET_FUNC diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 171ded98c67..cc467d44966 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -170,6 +170,15 @@ extern void *__os_arm64x_dispatch_fptr; extern void *__os_arm64x_dispatch_ret; extern void *__os_arm64x_get_x64_information; extern void *__os_arm64x_set_x64_information; +extern void *__os_arm64x_helper0; +extern void *__os_arm64x_helper1; +extern void *__os_arm64x_helper2; +extern void *__os_arm64x_helper3; +extern void *__os_arm64x_helper4; +extern void *__os_arm64x_helper5; +extern void *__os_arm64x_helper6; +extern void *__os_arm64x_helper7; +extern void *__os_arm64x_helper8;
#endif
diff --git a/include/winnt.h b/include/winnt.h index 7adbc1d3761..e7c322fd127 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -4044,6 +4044,15 @@ typedef struct _IMAGE_ARM64EC_METADATA ULONG ExtraRFETableSize; ULONG __os_arm64x_dispatch_fptr; ULONG AuxiliaryIATCopy; + ULONG __os_arm64x_helper0; + ULONG __os_arm64x_helper1; + ULONG __os_arm64x_helper2; + ULONG __os_arm64x_helper3; + ULONG __os_arm64x_helper4; + ULONG __os_arm64x_helper5; + ULONG __os_arm64x_helper6; + ULONG __os_arm64x_helper7; + ULONG __os_arm64x_helper8; } IMAGE_ARM64EC_METADATA;
typedef struct _IMAGE_ARM64EC_REDIRECTION_ENTRY