Commit 3e3af62b authored by Alexandre Julliard's avatar Alexandre Julliard

wow64: Create the WOW64INFO structure.

parent a8f11bb8
...@@ -97,6 +97,7 @@ SYSTEM_DLL_INIT_BLOCK *pLdrSystemDllInitBlock = NULL; ...@@ -97,6 +97,7 @@ SYSTEM_DLL_INIT_BLOCK *pLdrSystemDllInitBlock = NULL;
/* wow64win syscall table */ /* wow64win syscall table */
static const SYSTEM_SERVICE_TABLE *psdwhwin32; static const SYSTEM_SERVICE_TABLE *psdwhwin32;
static HMODULE win32u_module; static HMODULE win32u_module;
static WOW64INFO *wow64info;
/* cpu backend dll functions */ /* cpu backend dll functions */
static void * (WINAPI *pBTCpuGetBopCode)(void); static void * (WINAPI *pBTCpuGetBopCode)(void);
...@@ -783,6 +784,7 @@ static const WCHAR *get_cpu_dll_name(void) ...@@ -783,6 +784,7 @@ static const WCHAR *get_cpu_dll_name(void)
*/ */
static DWORD WINAPI process_init( RTL_RUN_ONCE *once, void *param, void **context ) static DWORD WINAPI process_init( RTL_RUN_ONCE *once, void *param, void **context )
{ {
TEB32 *teb32 = (TEB32 *)((char *)NtCurrentTeb() + NtCurrentTeb()->WowTebOffset);
HMODULE module; HMODULE module;
UNICODE_STRING str = RTL_CONSTANT_STRING( L"ntdll.dll" ); UNICODE_STRING str = RTL_CONSTANT_STRING( L"ntdll.dll" );
SYSTEM_BASIC_INFORMATION info; SYSTEM_BASIC_INFORMATION info;
...@@ -793,6 +795,11 @@ static DWORD WINAPI process_init( RTL_RUN_ONCE *once, void *param, void **contex ...@@ -793,6 +795,11 @@ static DWORD WINAPI process_init( RTL_RUN_ONCE *once, void *param, void **contex
NtQuerySystemInformation( SystemEmulationBasicInformation, &info, sizeof(info), NULL ); NtQuerySystemInformation( SystemEmulationBasicInformation, &info, sizeof(info), NULL );
highest_user_address = (ULONG_PTR)info.HighestUserAddress; highest_user_address = (ULONG_PTR)info.HighestUserAddress;
default_zero_bits = (ULONG_PTR)info.HighestUserAddress | 0x7fffffff; default_zero_bits = (ULONG_PTR)info.HighestUserAddress | 0x7fffffff;
wow64info = (WOW64INFO *)((PEB32 *)ULongToPtr( teb32->Peb ) + 1);
wow64info->NativeSystemPageSize = 0x1000;
wow64info->NativeMachineType = native_machine;
wow64info->EmulatedMachineType = current_machine;
NtCurrentTeb()->TlsSlots[WOW64_TLS_WOW64INFO] = wow64info;
#define GET_PTR(name) p ## name = RtlFindExportedRoutineByName( module, #name ) #define GET_PTR(name) p ## name = RtlFindExportedRoutineByName( module, #name )
...@@ -836,6 +843,7 @@ static void thread_init(void) ...@@ -836,6 +843,7 @@ static void thread_init(void)
void *cpu_area_ctx; void *cpu_area_ctx;
RtlWow64GetCurrentCpuArea( NULL, &cpu_area_ctx, NULL ); RtlWow64GetCurrentCpuArea( NULL, &cpu_area_ctx, NULL );
NtCurrentTeb()->TlsSlots[WOW64_TLS_WOW64INFO] = wow64info;
if (pBTCpuThreadInit) pBTCpuThreadInit(); if (pBTCpuThreadInit) pBTCpuThreadInit();
/* update initial context to jump to 32-bit LdrInitializeThunk (cf. 32-bit call_init_thunk) */ /* update initial context to jump to 32-bit LdrInitializeThunk (cf. 32-bit call_init_thunk) */
......
...@@ -290,6 +290,7 @@ NTSTATUS WINAPI BTCpuProcessInit(void) ...@@ -290,6 +290,7 @@ NTSTATUS WINAPI BTCpuProcessInit(void)
HMODULE module; HMODULE module;
UNICODE_STRING str; UNICODE_STRING str;
void **p__wine_unix_call_dispatcher; void **p__wine_unix_call_dispatcher;
WOW64INFO *wow64info = NtCurrentTeb()->TlsSlots[WOW64_TLS_WOW64INFO];
if ((ULONG_PTR)syscall_32to64 >> 32) if ((ULONG_PTR)syscall_32to64 >> 32)
{ {
...@@ -297,6 +298,8 @@ NTSTATUS WINAPI BTCpuProcessInit(void) ...@@ -297,6 +298,8 @@ NTSTATUS WINAPI BTCpuProcessInit(void)
return STATUS_INVALID_ADDRESS; return STATUS_INVALID_ADDRESS;
} }
wow64info->CpuFlags |= WOW64_CPUFLAGS_MSFT64;
RtlInitUnicodeString( &str, L"ntdll.dll" ); RtlInitUnicodeString( &str, L"ntdll.dll" );
LdrGetDllHandle( NULL, 0, &str, &module ); LdrGetDllHandle( NULL, 0, &str, &module );
p__wine_unix_call_dispatcher = RtlFindExportedRoutineByName( module, "__wine_unix_call_dispatcher" ); p__wine_unix_call_dispatcher = RtlFindExportedRoutineByName( module, "__wine_unix_call_dispatcher" );
......
...@@ -1085,6 +1085,7 @@ typedef struct _TEB64 ...@@ -1085,6 +1085,7 @@ typedef struct _TEB64
#define WOW64_TLS_USERCALLBACKDATA 5 #define WOW64_TLS_USERCALLBACKDATA 5
#define WOW64_TLS_APCLIST 7 #define WOW64_TLS_APCLIST 7
#define WOW64_TLS_FILESYSREDIR 8 #define WOW64_TLS_FILESYSREDIR 8
#define WOW64_TLS_WOW64INFO 10
#define WOW64_TLS_MAX_NUMBER 19 #define WOW64_TLS_MAX_NUMBER 19
...@@ -3855,6 +3856,19 @@ typedef struct _WOW64_CPU_AREA_INFO ...@@ -3855,6 +3856,19 @@ typedef struct _WOW64_CPU_AREA_INFO
USHORT Machine; USHORT Machine;
} WOW64_CPU_AREA_INFO, *PWOW64_CPU_AREA_INFO; } WOW64_CPU_AREA_INFO, *PWOW64_CPU_AREA_INFO;
typedef struct _WOW64INFO
{
ULONG NativeSystemPageSize;
ULONG CpuFlags;
ULONG Wow64ExecuteFlags;
ULONG unknown[5];
USHORT NativeMachineType;
USHORT EmulatedMachineType;
} WOW64INFO;
#define WOW64_CPUFLAGS_MSFT64 0x01
#define WOW64_CPUFLAGS_SOFTWARE 0x02
/* wow64.dll functions */ /* wow64.dll functions */
void * WINAPI Wow64AllocateTemp(SIZE_T); void * WINAPI Wow64AllocateTemp(SIZE_T);
void WINAPI Wow64ApcRoutine(ULONG_PTR,ULONG_PTR,ULONG_PTR,CONTEXT*); void WINAPI Wow64ApcRoutine(ULONG_PTR,ULONG_PTR,ULONG_PTR,CONTEXT*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment