ntdll: Only check the is_wow64 flag on 32-bit platforms.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-05-17 10:12:01 +02:00
parent a8ff0c12f4
commit e40eab977a
5 changed files with 34 additions and 19 deletions

View File

@ -999,6 +999,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class
pbi.BasePriority = reply->priority; pbi.BasePriority = reply->priority;
pbi.UniqueProcessId = reply->pid; pbi.UniqueProcessId = reply->pid;
pbi.InheritedFromUniqueProcessId = reply->ppid; pbi.InheritedFromUniqueProcessId = reply->ppid;
#ifndef _WIN64
if (is_wow64) if (is_wow64)
{ {
if (reply->machine != native_machine) if (reply->machine != native_machine)
@ -1006,6 +1007,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class
else else
pbi.PebBaseAddress = NULL; pbi.PebBaseAddress = NULL;
} }
#endif
} }
} }
SERVER_END_REQ; SERVER_END_REQ;
@ -1260,20 +1262,17 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class
if (size != len) ret = STATUS_INFO_LENGTH_MISMATCH; if (size != len) ret = STATUS_INFO_LENGTH_MISMATCH;
else if (!info) ret = STATUS_ACCESS_VIOLATION; else if (!info) ret = STATUS_ACCESS_VIOLATION;
else if (!handle) ret = STATUS_INVALID_HANDLE; else if (!handle) ret = STATUS_INVALID_HANDLE;
else if (handle == GetCurrentProcess()) *(ULONG_PTR *)info = !!NtCurrentTeb()->WowTebOffset;
else else
{ {
ULONG_PTR val = 0; ULONG_PTR val = 0;
if (handle == GetCurrentProcess()) val = is_wow64;
else if (is_win64 || is_wow64)
{
SERVER_START_REQ( get_process_info ) SERVER_START_REQ( get_process_info )
{ {
req->handle = wine_server_obj_handle( handle ); req->handle = wine_server_obj_handle( handle );
if (!(ret = wine_server_call( req ))) val = (reply->machine != native_machine); if (!(ret = wine_server_call( req ))) val = (reply->machine != native_machine);
} }
SERVER_END_REQ; SERVER_END_REQ;
}
*(ULONG_PTR *)info = val; *(ULONG_PTR *)info = val;
} }
break; break;

View File

@ -104,8 +104,10 @@ static const char *server_dir;
unsigned int supported_machines_count = 0; unsigned int supported_machines_count = 0;
USHORT supported_machines[8] = { 0 }; USHORT supported_machines[8] = { 0 };
USHORT native_machine = 0; USHORT native_machine = 0;
BOOL is_wow64 = FALSE;
BOOL process_exiting = FALSE; BOOL process_exiting = FALSE;
#ifndef _WIN64
BOOL is_wow64 = FALSE;
#endif
timeout_t server_start_time = 0; /* time of server startup */ timeout_t server_start_time = 0; /* time of server startup */

View File

@ -233,7 +233,9 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
NTSTATUS status; NTSTATUS status;
if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_3; if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_3;
if (!is_win64 && !is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3; #ifndef _WIN64
if (!is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
#endif
if (process != NtCurrentProcess()) if (process != NtCurrentProcess())
{ {
@ -950,6 +952,7 @@ BOOL get_thread_times(int unix_pid, int unix_tid, LARGE_INTEGER *kernel_time, LA
#endif #endif
} }
#ifndef _WIN64
static BOOL is_process_wow64( const CLIENT_ID *id ) static BOOL is_process_wow64( const CLIENT_ID *id )
{ {
HANDLE handle; HANDLE handle;
@ -965,6 +968,7 @@ static BOOL is_process_wow64( const CLIENT_ID *id )
} }
return ret; return ret;
} }
#endif
/****************************************************************************** /******************************************************************************
* NtQueryInformationThread (NTDLL.@) * NtQueryInformationThread (NTDLL.@)
@ -1000,6 +1004,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
SERVER_END_REQ; SERVER_END_REQ;
if (status == STATUS_SUCCESS) if (status == STATUS_SUCCESS)
{ {
#ifndef _WIN64
if (is_wow64) if (is_wow64)
{ {
if (is_process_wow64( &info.ClientId )) if (is_process_wow64( &info.ClientId ))
@ -1007,6 +1012,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
else else
info.TebBaseAddress = NULL; info.TebBaseAddress = NULL;
} }
#endif
if (data) memcpy( data, &info, min( length, sizeof(info) )); if (data) memcpy( data, &info, min( length, sizeof(info) ));
if (ret_len) *ret_len = min( length, sizeof(info) ); if (ret_len) *ret_len = min( length, sizeof(info) );
} }

View File

@ -125,13 +125,15 @@ extern WCHAR **main_wargv DECLSPEC_HIDDEN;
extern const WCHAR system_dir[] DECLSPEC_HIDDEN; extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
extern unsigned int supported_machines_count DECLSPEC_HIDDEN; extern unsigned int supported_machines_count DECLSPEC_HIDDEN;
extern USHORT supported_machines[8] DECLSPEC_HIDDEN; extern USHORT supported_machines[8] DECLSPEC_HIDDEN;
extern BOOL is_wow64 DECLSPEC_HIDDEN;
extern BOOL process_exiting DECLSPEC_HIDDEN; extern BOOL process_exiting DECLSPEC_HIDDEN;
extern HANDLE keyed_event DECLSPEC_HIDDEN; extern HANDLE keyed_event DECLSPEC_HIDDEN;
extern timeout_t server_start_time DECLSPEC_HIDDEN; extern timeout_t server_start_time DECLSPEC_HIDDEN;
extern sigset_t server_block_set DECLSPEC_HIDDEN; extern sigset_t server_block_set DECLSPEC_HIDDEN;
extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN; extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
extern SYSTEM_CPU_INFORMATION cpu_info DECLSPEC_HIDDEN; extern SYSTEM_CPU_INFORMATION cpu_info DECLSPEC_HIDDEN;
#ifndef _WIN64
extern BOOL is_wow64 DECLSPEC_HIDDEN;
#endif
#ifdef __i386__ #ifdef __i386__
extern struct ldt_copy __wine_ldt_copy DECLSPEC_HIDDEN; extern struct ldt_copy __wine_ldt_copy DECLSPEC_HIDDEN;
#endif #endif

View File

@ -722,7 +722,9 @@ static void free_ranges_insert_view( struct file_view *view )
(range->end == view_base && next->base >= view_end)) (range->end == view_base && next->base >= view_end))
{ {
/* on Win64, assert that it's correctly aligned so we're not going to be in trouble later */ /* on Win64, assert that it's correctly aligned so we're not going to be in trouble later */
assert( (!is_win64 && !is_wow64) || view->base == view_base ); #ifdef _WIN64
assert( view->base == view_base );
#endif
WARN( "range %p - %p is already mapped\n", view_base, view_end ); WARN( "range %p - %p is already mapped\n", view_base, view_end );
return; return;
} }
@ -2962,7 +2964,7 @@ NTSTATUS virtual_alloc_teb( TEB **ret_teb )
NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&ptr, 0, &block_size, NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&ptr, 0, &block_size,
MEM_COMMIT, PAGE_READWRITE ); MEM_COMMIT, PAGE_READWRITE );
} }
*ret_teb = teb = init_teb( ptr, NtCurrentTeb()->Peb, is_wow64 ); *ret_teb = teb = init_teb( ptr, NtCurrentTeb()->Peb, !!NtCurrentTeb()->WowTebOffset );
server_leave_uninterrupted_section( &virtual_mutex, &sigset ); server_leave_uninterrupted_section( &virtual_mutex, &sigset );
if ((status = signal_alloc_thread( teb ))) if ((status = signal_alloc_thread( teb )))
@ -3674,7 +3676,9 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z
if (!size) return STATUS_INVALID_PARAMETER; if (!size) return STATUS_INVALID_PARAMETER;
if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_3; if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_3;
if (!is_win64 && !is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3; #ifndef _WIN64
if (!is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
#endif
if (process != NtCurrentProcess()) if (process != NtCurrentProcess())
{ {
@ -4344,8 +4348,6 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
/* Check parameters */ /* Check parameters */
if (zero_bits > 21 && zero_bits < 32) if (zero_bits > 21 && zero_bits < 32)
return STATUS_INVALID_PARAMETER_4; return STATUS_INVALID_PARAMETER_4;
if (!is_win64 && !is_wow64 && zero_bits >= 32)
return STATUS_INVALID_PARAMETER_4;
/* If both addr_ptr and zero_bits are passed, they have match */ /* If both addr_ptr and zero_bits are passed, they have match */
if (*addr_ptr && zero_bits && zero_bits < 32 && if (*addr_ptr && zero_bits && zero_bits < 32 &&
@ -4356,11 +4358,15 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
return STATUS_INVALID_PARAMETER_4; return STATUS_INVALID_PARAMETER_4;
#ifndef _WIN64 #ifndef _WIN64
if (!is_wow64 && (alloc_type & AT_ROUND_TO_PAGE)) if (!is_wow64)
{
if (zero_bits >= 32) return STATUS_INVALID_PARAMETER_4;
if (alloc_type & AT_ROUND_TO_PAGE)
{ {
*addr_ptr = ROUND_ADDR( *addr_ptr, page_mask ); *addr_ptr = ROUND_ADDR( *addr_ptr, page_mask );
mask = page_mask; mask = page_mask;
} }
}
#endif #endif
if ((offset.u.LowPart & mask) || (*addr_ptr && ((UINT_PTR)*addr_ptr & mask))) if ((offset.u.LowPart & mask) || (*addr_ptr && ((UINT_PTR)*addr_ptr & mask)))