[PATCH 0/1] MR328: wow64: Respect the large address aware flag.
From: Brendan Shanks <bshanks(a)codeweavers.com> --- dlls/wow64/process.c | 2 +- dlls/wow64/syscall.c | 14 +++++++++++++- dlls/wow64/wow64_private.h | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dlls/wow64/process.c b/dlls/wow64/process.c index 0c6726b9c6e..849312cc691 100644 --- a/dlls/wow64/process.c +++ b/dlls/wow64/process.c @@ -1118,7 +1118,7 @@ NTSTATUS WINAPI wow64_NtSetInformationProcess( UINT *args ) PROCESS_STACK_ALLOCATION_INFORMATION info; info.ReserveSize = stack->ReserveSize; - info.ZeroBits = stack->ZeroBits ? stack->ZeroBits : 0x7fffffff; + info.ZeroBits = stack->ZeroBits ? stack->ZeroBits : (ULONG_PTR)user_space_limit; if (!(status = NtSetInformationProcess( handle, class, &info, sizeof(info) ))) stack->StackBase = PtrToUlong( info.StackBase ); return status; diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 7cab0894738..835c8b88105 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -36,6 +36,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wow); USHORT native_machine = 0; USHORT current_machine = 0; ULONG_PTR args_alignment = 0; +void *user_space_limit = (void *)0x7fffffff; typedef NTSTATUS (WINAPI *syscall_thunk)( UINT *args ); @@ -98,7 +99,18 @@ void *dummy = RtlUnwind; BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, void *reserved ) { - if (reason == DLL_PROCESS_ATTACH) LdrDisableThreadCalloutsForDll( inst ); + if (reason == DLL_PROCESS_ATTACH) + { + NTSTATUS status; + SYSTEM_BASIC_INFORMATION info; + + LdrDisableThreadCalloutsForDll( inst ); + + if (!(status = NtQuerySystemInformation( SystemEmulationBasicInformation, &info, sizeof(info), NULL ))) + user_space_limit = info.HighestUserAddress; + else + ERR( "could not retrieve address space limit: %lx\n", status ); + } return TRUE; } diff --git a/dlls/wow64/wow64_private.h b/dlls/wow64/wow64_private.h index b26148023db..c6e38964413 100644 --- a/dlls/wow64/wow64_private.h +++ b/dlls/wow64/wow64_private.h @@ -39,6 +39,7 @@ extern BOOL get_file_redirect( OBJECT_ATTRIBUTES *attr ) DECLSPEC_HIDDEN; extern USHORT native_machine DECLSPEC_HIDDEN; extern USHORT current_machine DECLSPEC_HIDDEN; extern ULONG_PTR args_alignment DECLSPEC_HIDDEN; +extern void *user_space_limit DECLSPEC_HIDDEN; extern SYSTEM_DLL_INIT_BLOCK *pLdrSystemDllInitBlock DECLSPEC_HIDDEN; struct object_attr64 @@ -83,7 +84,7 @@ static inline ULONG64 get_ulong64( UINT **args ) static inline ULONG_PTR get_zero_bits( ULONG_PTR zero_bits ) { - return zero_bits ? zero_bits : 0x7fffffff; + return zero_bits ? zero_bits : (ULONG_PTR)user_space_limit; } static inline void **addr_32to64( void **addr, ULONG *addr32 ) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/328
participants (2)
-
Brendan Shanks -
Brendan Shanks (@bshanks)