Module: wine Branch: master Commit: a31f3374e65c02f97829eb9ed712a35f484c4461 URL: https://source.winehq.org/git/wine.git/?a=commit;h=a31f3374e65c02f97829eb9ed...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Feb 21 11:41:44 2022 +0100
ntdll: Add a global variable for the WoW PEB.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/unix/env.c | 44 ++++++++++++++++++++---------------------- dlls/ntdll/unix/server.c | 1 + dlls/ntdll/unix/unix_private.h | 4 ++++ 3 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index c7e0674e083..3f9f7f1b3b7 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -60,6 +60,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(environ);
PEB *peb = NULL; +WOW_PEB *wow_peb = NULL; USHORT *uctable = NULL, *lctable = NULL; SIZE_T startup_info_size = 0; BOOL is_prefix_bootstrap = FALSE; @@ -2129,37 +2130,34 @@ static void init_peb( RTL_USER_PROCESS_PARAMETERS *params, void *module ) { NtCurrentTeb()->WowTebOffset = teb_offset; NtCurrentTeb()->Tib.ExceptionList = (void *)((char *)NtCurrentTeb() + teb_offset); + wow_peb = (PEB32 *)((char *)peb + page_size); set_thread_id( NtCurrentTeb(), GetCurrentProcessId(), GetCurrentThreadId() ); } #endif
load_global_options( ¶ms->ImagePathName );
- if (NtCurrentTeb()->WowTebOffset) + if (wow_peb) { void *wow64_params = build_wow64_parameters( params ); -#ifdef _WIN64 - PEB32 *wow64_peb = (PEB32 *)((char *)peb + page_size); -#else - PEB64 *wow64_peb = (PEB64 *)((char *)peb - page_size); -#endif - wow64_peb->ImageBaseAddress = PtrToUlong( peb->ImageBaseAddress ); - wow64_peb->ProcessParameters = PtrToUlong( wow64_params ); - wow64_peb->NumberOfProcessors = peb->NumberOfProcessors; - wow64_peb->NtGlobalFlag = peb->NtGlobalFlag; - wow64_peb->CriticalSectionTimeout.QuadPart = peb->CriticalSectionTimeout.QuadPart; - wow64_peb->HeapSegmentReserve = peb->HeapSegmentReserve; - wow64_peb->HeapSegmentCommit = peb->HeapSegmentCommit; - wow64_peb->HeapDeCommitTotalFreeThreshold = peb->HeapDeCommitTotalFreeThreshold; - wow64_peb->HeapDeCommitFreeBlockThreshold = peb->HeapDeCommitFreeBlockThreshold; - wow64_peb->OSMajorVersion = peb->OSMajorVersion; - wow64_peb->OSMinorVersion = peb->OSMinorVersion; - wow64_peb->OSBuildNumber = peb->OSBuildNumber; - wow64_peb->OSPlatformId = peb->OSPlatformId; - wow64_peb->ImageSubSystem = peb->ImageSubSystem; - wow64_peb->ImageSubSystemMajorVersion = peb->ImageSubSystemMajorVersion; - wow64_peb->ImageSubSystemMinorVersion = peb->ImageSubSystemMinorVersion; - wow64_peb->SessionId = peb->SessionId; + + wow_peb->ImageBaseAddress = PtrToUlong( peb->ImageBaseAddress ); + wow_peb->ProcessParameters = PtrToUlong( wow64_params ); + wow_peb->NumberOfProcessors = peb->NumberOfProcessors; + wow_peb->NtGlobalFlag = peb->NtGlobalFlag; + wow_peb->CriticalSectionTimeout.QuadPart = peb->CriticalSectionTimeout.QuadPart; + wow_peb->HeapSegmentReserve = peb->HeapSegmentReserve; + wow_peb->HeapSegmentCommit = peb->HeapSegmentCommit; + wow_peb->HeapDeCommitTotalFreeThreshold = peb->HeapDeCommitTotalFreeThreshold; + wow_peb->HeapDeCommitFreeBlockThreshold = peb->HeapDeCommitFreeBlockThreshold; + wow_peb->OSMajorVersion = peb->OSMajorVersion; + wow_peb->OSMinorVersion = peb->OSMinorVersion; + wow_peb->OSBuildNumber = peb->OSBuildNumber; + wow_peb->OSPlatformId = peb->OSPlatformId; + wow_peb->ImageSubSystem = peb->ImageSubSystem; + wow_peb->ImageSubSystemMajorVersion = peb->ImageSubSystemMajorVersion; + wow_peb->ImageSubSystemMinorVersion = peb->ImageSubSystemMinorVersion; + wow_peb->SessionId = peb->SessionId; } }
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c index 9d0594d3374..ab9d99c4f47 100644 --- a/dlls/ntdll/unix/server.c +++ b/dlls/ntdll/unix/server.c @@ -1518,6 +1518,7 @@ size_t server_init_process(void) is_wow64 = TRUE; NtCurrentTeb()->GdiBatchCount = PtrToUlong( (char *)NtCurrentTeb() - teb_offset ); NtCurrentTeb()->WowTebOffset = -teb_offset; + wow_peb = (PEB64 *)((char *)peb - page_size); #endif } else diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 75f03706401..b1595c792c0 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -393,12 +393,16 @@ static inline client_ptr_t iosb_client_ptr( IO_STATUS_BLOCK *io )
#ifdef _WIN64 typedef TEB32 WOW_TEB; +typedef PEB32 WOW_PEB; static inline TEB64 *NtCurrentTeb64(void) { return NULL; } #else typedef TEB64 WOW_TEB; +typedef PEB64 WOW_PEB; static inline TEB64 *NtCurrentTeb64(void) { return (TEB64 *)NtCurrentTeb()->GdiBatchCount; } #endif
+extern WOW_PEB *wow_peb DECLSPEC_HIDDEN; + static inline WOW_TEB *get_wow_teb( TEB *teb ) { return teb->WowTebOffset ? (WOW_TEB *)((char *)teb + teb->WowTebOffset) : NULL;