Module: wine Branch: master Commit: ab6c14942ffd347b53a251e2cb73f40acc2d1e43 URL: https://gitlab.winehq.org/wine/wine/-/commit/ab6c14942ffd347b53a251e2cb73f40...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Jul 8 11:59:55 2024 +0200
ntdll: Always set the dll name pointer in the 32-bit TEB.
---
dlls/ntdll/loader.c | 19 ++++--------------- dlls/ntdll/unix/virtual.c | 7 +++++++ dlls/wow64/virtual.c | 6 ++++++ 3 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 5c59d102dd9..e7b724471e7 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -3248,7 +3248,7 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, DWORD fl HANDLE mapping = 0; SECTION_IMAGE_INFORMATION image_info; NTSTATUS nts = STATUS_DLL_NOT_FOUND; - ULONG64 prev; + void *prev;
TRACE( "looking for %s in %s\n", debugstr_w(libname), debugstr_w(load_path) );
@@ -3274,16 +3274,8 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, DWORD fl
if (nts && nts != STATUS_INVALID_IMAGE_NOT_MZ) goto done;
- if (NtCurrentTeb64()) - { - prev = NtCurrentTeb64()->Tib.ArbitraryUserPointer; - NtCurrentTeb64()->Tib.ArbitraryUserPointer = (ULONG_PTR)(nt_name.Buffer + 4); - } - else - { - prev = (ULONG_PTR)NtCurrentTeb()->Tib.ArbitraryUserPointer; - NtCurrentTeb()->Tib.ArbitraryUserPointer = nt_name.Buffer + 4; - } + prev = NtCurrentTeb()->Tib.ArbitraryUserPointer; + NtCurrentTeb()->Tib.ArbitraryUserPointer = nt_name.Buffer + 4;
switch (nts) { @@ -3296,10 +3288,7 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, DWORD fl break; }
- if (NtCurrentTeb64()) - NtCurrentTeb64()->Tib.ArbitraryUserPointer = prev; - else - NtCurrentTeb()->Tib.ArbitraryUserPointer = (void *)(ULONG_PTR)prev; + NtCurrentTeb()->Tib.ArbitraryUserPointer = prev;
done: if (nts == STATUS_SUCCESS) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index dce03c2c3b5..0d88315164a 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -3163,7 +3163,13 @@ static unsigned int virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG_P if (image_info) { SECTION_IMAGE_INFORMATION info; + ULONG64 prev = 0;
+ if (NtCurrentTeb64()) + { + prev = NtCurrentTeb64()->Tib.ArbitraryUserPointer; + NtCurrentTeb64()->Tib.ArbitraryUserPointer = PtrToUlong(NtCurrentTeb()->Tib.ArbitraryUserPointer); + } filename = (WCHAR *)(image_info + 1); /* check if we can replace that mapping with the builtin */ res = load_builtin( image_info, filename, machine, &info, @@ -3173,6 +3179,7 @@ static unsigned int virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG_P alloc_type, machine, image_info, filename, FALSE ); if (shared_file) NtClose( shared_file ); free( image_info ); + if (NtCurrentTeb64()) NtCurrentTeb64()->Tib.ArbitraryUserPointer = prev; return res; }
diff --git a/dlls/wow64/virtual.c b/dlls/wow64/virtual.c index 7df14c9b23b..e9972168f3e 100644 --- a/dlls/wow64/virtual.c +++ b/dlls/wow64/virtual.c @@ -426,7 +426,9 @@ NTSTATUS WINAPI wow64_NtMapViewOfSection( UINT *args ) void *addr; SIZE_T size; NTSTATUS status; + void *prev = NtCurrentTeb()->Tib.ArbitraryUserPointer;
+ NtCurrentTeb()->Tib.ArbitraryUserPointer = ULongToPtr( NtCurrentTeb32()->Tib.ArbitraryUserPointer ); status = NtMapViewOfSection( handle, process, addr_32to64( &addr, addr32 ), get_zero_bits( zero_bits ), commit, offset, size_32to64( &size, size32 ), inherit, alloc, protect ); if (NT_SUCCESS(status)) @@ -443,6 +445,7 @@ NTSTATUS WINAPI wow64_NtMapViewOfSection( UINT *args ) put_addr( addr32, addr ); put_size( size32, size ); } + NtCurrentTeb()->Tib.ArbitraryUserPointer = prev; return status; }
@@ -467,9 +470,11 @@ NTSTATUS WINAPI wow64_NtMapViewOfSectionEx( UINT *args ) MEM_EXTENDED_PARAMETER *params64; BOOL is_current = RtlIsCurrentProcess( process ); BOOL set_limit = (!*addr32 && is_current); + void *prev = NtCurrentTeb()->Tib.ArbitraryUserPointer;
if ((status = mem_extended_parameters_32to64( ¶ms64, params32, &count, set_limit ))) return status;
+ NtCurrentTeb()->Tib.ArbitraryUserPointer = ULongToPtr( NtCurrentTeb32()->Tib.ArbitraryUserPointer ); status = NtMapViewOfSectionEx( handle, process, addr_32to64( &addr, addr32 ), offset, size_32to64( &size, size32 ), alloc, protect, params64, count ); if (NT_SUCCESS(status)) @@ -486,6 +491,7 @@ NTSTATUS WINAPI wow64_NtMapViewOfSectionEx( UINT *args ) put_addr( addr32, addr ); put_size( size32, size ); } + NtCurrentTeb()->Tib.ArbitraryUserPointer = prev; return status; }