Commit f3d90fd5 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Add a helper function to check for old-style Wow64 mode.

parent da7411fd
......@@ -2997,7 +2997,7 @@ void init_files(void)
HANDLE key;
#ifndef _WIN64
if (is_wow64) init_redirects();
if (is_old_wow64()) init_redirects();
#endif
/* a couple of directories that we don't want to return in directory searches */
ignore_file( config_dir );
......
......@@ -1152,15 +1152,13 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class
pbi.BasePriority = reply->priority;
pbi.UniqueProcessId = reply->pid;
pbi.InheritedFromUniqueProcessId = reply->ppid;
#ifndef _WIN64
if (is_wow64)
if (is_old_wow64())
{
if (reply->machine != native_machine)
pbi.PebBaseAddress = (PEB *)((char *)pbi.PebBaseAddress + 0x1000);
else
pbi.PebBaseAddress = NULL;
}
#endif
}
}
SERVER_END_REQ;
......
......@@ -96,9 +96,6 @@ unsigned int supported_machines_count = 0;
USHORT supported_machines[8] = { 0 };
USHORT native_machine = 0;
BOOL process_exiting = FALSE;
#ifndef _WIN64
BOOL is_wow64 = FALSE;
#endif
timeout_t server_start_time = 0; /* time of server startup */
......@@ -576,10 +573,8 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result, BOO
if (reserve == call->create_thread.reserve && commit == call->create_thread.commit &&
(ULONG_PTR)func == call->create_thread.func && (ULONG_PTR)arg == call->create_thread.arg)
{
#ifndef _WIN64
/* FIXME: hack for debugging 32-bit process without a 64-bit ntdll */
if (is_wow64 && func == (void *)0x7ffe1000) func = pDbgUiRemoteBreakin;
#endif
if (is_old_wow64() && func == (void *)0x7ffe1000) func = pDbgUiRemoteBreakin;
attr->TotalLength = sizeof(buffer);
attr->Attributes[0].Attribute = PS_ATTRIBUTE_CLIENT_ID;
attr->Attributes[0].Size = sizeof(id);
......@@ -1579,7 +1574,6 @@ size_t server_init_process(void)
if (arch && !strcmp( arch, "win32" ))
fatal_error( "WINEARCH set to win32 but '%s' is a 64-bit installation.\n", config_dir );
#ifndef _WIN64
is_wow64 = TRUE;
NtCurrentTeb()->GdiBatchCount = PtrToUlong( (char *)NtCurrentTeb() - teb_offset );
NtCurrentTeb()->WowTebOffset = -teb_offset;
wow_peb = (PEB64 *)((char *)peb - page_size);
......
......@@ -869,7 +869,7 @@ NTSTATUS signal_set_full_context( CONTEXT *context )
*/
void *get_native_context( CONTEXT *context )
{
return is_wow64 ? NULL : context;
return is_old_wow64() ? NULL : context;
}
......@@ -878,7 +878,7 @@ void *get_native_context( CONTEXT *context )
*/
void *get_wow_context( CONTEXT *context )
{
return is_wow64 ? context : NULL;
return is_old_wow64() ? context : NULL;
}
......@@ -1731,7 +1731,7 @@ static BOOL handle_interrupt( unsigned int interrupt, ucontext_t *sigcontext, vo
NtRaiseException( rec, context, FALSE );
return TRUE;
case 0x2d:
if (!is_wow64)
if (!is_old_wow64())
{
/* On Wow64, the upper DWORD of Rax contains garbage, and the debug
* service is usually not recognized when called from usermode. */
......@@ -1748,7 +1748,7 @@ static BOOL handle_interrupt( unsigned int interrupt, ucontext_t *sigcontext, vo
context->Eip += 3;
rec->ExceptionCode = EXCEPTION_BREAKPOINT;
rec->ExceptionAddress = (void *)context->Eip;
rec->NumberParameters = is_wow64 ? 1 : 3;
rec->NumberParameters = is_old_wow64() ? 1 : 3;
rec->ExceptionInformation[0] = context->Eax;
rec->ExceptionInformation[1] = context->Ecx;
rec->ExceptionInformation[2] = context->Edx;
......@@ -1974,7 +1974,7 @@ static void trap_handler( int signal, siginfo_t *siginfo, void *sigcontext )
/* fall through */
default:
rec.ExceptionCode = EXCEPTION_BREAKPOINT;
rec.NumberParameters = is_wow64 ? 1 : 3;
rec.NumberParameters = is_old_wow64() ? 1 : 3;
rec.ExceptionInformation[0] = 0;
rec.ExceptionInformation[1] = 0; /* FIXME */
rec.ExceptionInformation[2] = 0; /* FIXME */
......@@ -2018,7 +2018,7 @@ static void fpe_handler( int signal, siginfo_t *siginfo, void *sigcontext )
rec.ExceptionCode = STATUS_FLOAT_MULTIPLE_TRAPS;
rec.ExceptionInformation[rec.NumberParameters++] = 0;
if (is_wow64) rec.ExceptionInformation[rec.NumberParameters++] = ((XSAVE_FORMAT *)xcontext.c.ExtendedRegisters)->MxCsr;
if (is_old_wow64()) rec.ExceptionInformation[rec.NumberParameters++] = ((XSAVE_FORMAT *)xcontext.c.ExtendedRegisters)->MxCsr;
break;
default:
WINE_ERR( "Got unexpected trap %d\n", TRAP_sig(ucontext) );
......
......@@ -2572,10 +2572,8 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
{
SYSTEM_CPU_INFORMATION cpu = cpu_info;
#ifndef _WIN64
if (is_wow64 && cpu.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
if (is_old_wow64() && cpu.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
cpu.ProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64;
#endif
memcpy(info, &cpu, len);
}
else ret = STATUS_INFO_LENGTH_MISMATCH;
......
......@@ -1290,7 +1290,7 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_3;
#ifndef _WIN64
if (!is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
if (!is_old_wow64() && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
#endif
if (process != NtCurrentProcess())
......@@ -1950,14 +1950,13 @@ static void set_native_thread_name( HANDLE handle, const UNICODE_STRING *name )
#endif
}
#ifndef _WIN64
static BOOL is_process_wow64( const CLIENT_ID *id )
{
HANDLE handle;
ULONG_PTR info;
BOOL ret = FALSE;
if (id->UniqueProcess == ULongToHandle(GetCurrentProcessId())) return is_wow64;
if (id->UniqueProcess == ULongToHandle(GetCurrentProcessId())) return is_old_wow64();
if (!NtOpenProcess( &handle, PROCESS_QUERY_LIMITED_INFORMATION, NULL, id ))
{
if (!NtQueryInformationProcess( handle, ProcessWow64Information, &info, sizeof(info), NULL ))
......@@ -1966,7 +1965,6 @@ static BOOL is_process_wow64( const CLIENT_ID *id )
}
return ret;
}
#endif
/******************************************************************************
* NtQueryInformationThread (NTDLL.@)
......@@ -2002,15 +2000,13 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
SERVER_END_REQ;
if (status == STATUS_SUCCESS)
{
#ifndef _WIN64
if (is_wow64)
if (is_old_wow64())
{
if (is_process_wow64( &info.ClientId ))
info.TebBaseAddress = (char *)info.TebBaseAddress + teb_offset;
else
info.TebBaseAddress = NULL;
}
#endif
if (data) memcpy( data, &info, min( length, sizeof(info) ));
if (ret_len) *ret_len = min( length, sizeof(info) );
}
......
......@@ -138,9 +138,6 @@ extern timeout_t server_start_time DECLSPEC_HIDDEN;
extern sigset_t server_block_set DECLSPEC_HIDDEN;
extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
extern SYSTEM_CPU_INFORMATION cpu_info DECLSPEC_HIDDEN;
#ifndef _WIN64
extern BOOL is_wow64 DECLSPEC_HIDDEN;
#endif
#ifdef __i386__
extern struct ldt_copy __wine_ldt_copy DECLSPEC_HIDDEN;
#endif
......@@ -446,6 +443,12 @@ static inline WOW_TEB *get_wow_teb( TEB *teb )
return teb->WowTebOffset ? (WOW_TEB *)((char *)teb + teb->WowTebOffset) : NULL;
}
/* check for old-style Wow64 (using a 32-bit ntdll.so) */
static inline BOOL is_old_wow64(void)
{
return !is_win64 && wow_peb;
}
enum loadorder
{
LO_INVALID,
......
......@@ -3848,7 +3848,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z
if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_3;
if (zero_bits > 32 && zero_bits < granularity_mask) return STATUS_INVALID_PARAMETER_3;
#ifndef _WIN64
if (!is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
if (!is_old_wow64() && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
#endif
if (process != NtCurrentProcess())
......@@ -4648,7 +4648,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
return STATUS_INVALID_PARAMETER_4;
#ifndef _WIN64
if (!is_wow64)
if (!is_old_wow64())
{
if (zero_bits >= 32) return STATUS_INVALID_PARAMETER_4;
if (alloc_type & AT_ROUND_TO_PAGE)
......@@ -5330,7 +5330,7 @@ NTSTATUS WINAPI NtWow64GetNativeSystemInformation( SYSTEM_INFORMATION_CLASS clas
case SystemNativeBasicInformation:
return NtQuerySystemInformation( SystemBasicInformation, info, len, retlen );
default:
if (is_wow64) return STATUS_INVALID_INFO_CLASS;
if (is_old_wow64()) return STATUS_INVALID_INFO_CLASS;
return NtQuerySystemInformation( class, info, len, retlen );
}
}
......
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