ntdll: Add a global variable for the WoW PEB.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2022-02-21 11:41:44 +01:00
parent 0d09268558
commit a31f3374e6
3 changed files with 26 additions and 23 deletions

View File

@ -60,6 +60,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(environ); WINE_DEFAULT_DEBUG_CHANNEL(environ);
PEB *peb = NULL; PEB *peb = NULL;
WOW_PEB *wow_peb = NULL;
USHORT *uctable = NULL, *lctable = NULL; USHORT *uctable = NULL, *lctable = NULL;
SIZE_T startup_info_size = 0; SIZE_T startup_info_size = 0;
BOOL is_prefix_bootstrap = FALSE; 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()->WowTebOffset = teb_offset;
NtCurrentTeb()->Tib.ExceptionList = (void *)((char *)NtCurrentTeb() + teb_offset); NtCurrentTeb()->Tib.ExceptionList = (void *)((char *)NtCurrentTeb() + teb_offset);
wow_peb = (PEB32 *)((char *)peb + page_size);
set_thread_id( NtCurrentTeb(), GetCurrentProcessId(), GetCurrentThreadId() ); set_thread_id( NtCurrentTeb(), GetCurrentProcessId(), GetCurrentThreadId() );
} }
#endif #endif
load_global_options( &params->ImagePathName ); load_global_options( &params->ImagePathName );
if (NtCurrentTeb()->WowTebOffset) if (wow_peb)
{ {
void *wow64_params = build_wow64_parameters( params ); void *wow64_params = build_wow64_parameters( params );
#ifdef _WIN64
PEB32 *wow64_peb = (PEB32 *)((char *)peb + page_size); wow_peb->ImageBaseAddress = PtrToUlong( peb->ImageBaseAddress );
#else wow_peb->ProcessParameters = PtrToUlong( wow64_params );
PEB64 *wow64_peb = (PEB64 *)((char *)peb - page_size); wow_peb->NumberOfProcessors = peb->NumberOfProcessors;
#endif wow_peb->NtGlobalFlag = peb->NtGlobalFlag;
wow64_peb->ImageBaseAddress = PtrToUlong( peb->ImageBaseAddress ); wow_peb->CriticalSectionTimeout.QuadPart = peb->CriticalSectionTimeout.QuadPart;
wow64_peb->ProcessParameters = PtrToUlong( wow64_params ); wow_peb->HeapSegmentReserve = peb->HeapSegmentReserve;
wow64_peb->NumberOfProcessors = peb->NumberOfProcessors; wow_peb->HeapSegmentCommit = peb->HeapSegmentCommit;
wow64_peb->NtGlobalFlag = peb->NtGlobalFlag; wow_peb->HeapDeCommitTotalFreeThreshold = peb->HeapDeCommitTotalFreeThreshold;
wow64_peb->CriticalSectionTimeout.QuadPart = peb->CriticalSectionTimeout.QuadPart; wow_peb->HeapDeCommitFreeBlockThreshold = peb->HeapDeCommitFreeBlockThreshold;
wow64_peb->HeapSegmentReserve = peb->HeapSegmentReserve; wow_peb->OSMajorVersion = peb->OSMajorVersion;
wow64_peb->HeapSegmentCommit = peb->HeapSegmentCommit; wow_peb->OSMinorVersion = peb->OSMinorVersion;
wow64_peb->HeapDeCommitTotalFreeThreshold = peb->HeapDeCommitTotalFreeThreshold; wow_peb->OSBuildNumber = peb->OSBuildNumber;
wow64_peb->HeapDeCommitFreeBlockThreshold = peb->HeapDeCommitFreeBlockThreshold; wow_peb->OSPlatformId = peb->OSPlatformId;
wow64_peb->OSMajorVersion = peb->OSMajorVersion; wow_peb->ImageSubSystem = peb->ImageSubSystem;
wow64_peb->OSMinorVersion = peb->OSMinorVersion; wow_peb->ImageSubSystemMajorVersion = peb->ImageSubSystemMajorVersion;
wow64_peb->OSBuildNumber = peb->OSBuildNumber; wow_peb->ImageSubSystemMinorVersion = peb->ImageSubSystemMinorVersion;
wow64_peb->OSPlatformId = peb->OSPlatformId; wow_peb->SessionId = peb->SessionId;
wow64_peb->ImageSubSystem = peb->ImageSubSystem;
wow64_peb->ImageSubSystemMajorVersion = peb->ImageSubSystemMajorVersion;
wow64_peb->ImageSubSystemMinorVersion = peb->ImageSubSystemMinorVersion;
wow64_peb->SessionId = peb->SessionId;
} }
} }

View File

@ -1518,6 +1518,7 @@ size_t server_init_process(void)
is_wow64 = TRUE; is_wow64 = TRUE;
NtCurrentTeb()->GdiBatchCount = PtrToUlong( (char *)NtCurrentTeb() - teb_offset ); NtCurrentTeb()->GdiBatchCount = PtrToUlong( (char *)NtCurrentTeb() - teb_offset );
NtCurrentTeb()->WowTebOffset = -teb_offset; NtCurrentTeb()->WowTebOffset = -teb_offset;
wow_peb = (PEB64 *)((char *)peb - page_size);
#endif #endif
} }
else else

View File

@ -393,12 +393,16 @@ static inline client_ptr_t iosb_client_ptr( IO_STATUS_BLOCK *io )
#ifdef _WIN64 #ifdef _WIN64
typedef TEB32 WOW_TEB; typedef TEB32 WOW_TEB;
typedef PEB32 WOW_PEB;
static inline TEB64 *NtCurrentTeb64(void) { return NULL; } static inline TEB64 *NtCurrentTeb64(void) { return NULL; }
#else #else
typedef TEB64 WOW_TEB; typedef TEB64 WOW_TEB;
typedef PEB64 WOW_PEB;
static inline TEB64 *NtCurrentTeb64(void) { return (TEB64 *)NtCurrentTeb()->GdiBatchCount; } static inline TEB64 *NtCurrentTeb64(void) { return (TEB64 *)NtCurrentTeb()->GdiBatchCount; }
#endif #endif
extern WOW_PEB *wow_peb DECLSPEC_HIDDEN;
static inline WOW_TEB *get_wow_teb( TEB *teb ) static inline WOW_TEB *get_wow_teb( TEB *teb )
{ {
return teb->WowTebOffset ? (WOW_TEB *)((char *)teb + teb->WowTebOffset) : NULL; return teb->WowTebOffset ? (WOW_TEB *)((char *)teb + teb->WowTebOffset) : NULL;