diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index e4c062cea98..e78df4d73d2 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -439,20 +439,17 @@ static NTSTATUS loader_exec( const char *loader, char **argv, WORD machine ) NTSTATUS exec_wineloader( char **argv, int socketfd, const pe_image_info_t *pe_info ) { WORD machine = pe_info->machine; - int is_child_64bit = (machine == IMAGE_FILE_MACHINE_AMD64 || machine == IMAGE_FILE_MACHINE_ARM64); ULONGLONG res_start = pe_info->base; ULONGLONG res_end = pe_info->base + pe_info->map_size; const char *loader = argv0; const char *loader_env = getenv( "WINELOADER" ); char preloader_reserve[64], socket_env[64]; + BOOL is_child_64bit; if (pe_info->image_flags & IMAGE_FLAGS_WineFakeDll) res_start = res_end = 0; + if (pe_info->image_flags & IMAGE_FLAGS_ComPlusNativeReady) machine = native_machine; - if (!is_child_64bit && (is_win64 || is_wow64) && (pe_info->image_flags & IMAGE_FLAGS_ComPlusNativeReady)) - { - is_child_64bit = TRUE; - machine = IMAGE_FILE_MACHINE_AMD64; - } + is_child_64bit = is_machine_64bit( machine ); if (!is_win64 ^ !is_child_64bit) { @@ -1469,7 +1466,7 @@ const WCHAR *get_machine_wow64_dir( WORD machine ) static const WCHAR sysx8664[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\','s','y','s','x','8','6','6','4','\\',0}; static const WCHAR sysarm64[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\','s','y','s','a','r','m','6','4','\\',0}; - if (machine == supported_machines[0]) machine = IMAGE_FILE_MACHINE_TARGET_HOST; + if (machine == native_machine) machine = IMAGE_FILE_MACHINE_TARGET_HOST; switch (machine) { diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index 3f71d70e60f..ce2033bc0dc 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -1240,9 +1240,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class SERVER_START_REQ( get_process_info ) { req->handle = wine_server_obj_handle( handle ); - if (!(ret = wine_server_call( req ))) - val = (reply->machine != IMAGE_FILE_MACHINE_AMD64 && - reply->machine != IMAGE_FILE_MACHINE_ARM64); + if (!(ret = wine_server_call( req ))) val = (reply->machine != native_machine); } SERVER_END_REQ; } diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c index b13e2997962..ff632b7c6c0 100644 --- a/dlls/ntdll/unix/server.c +++ b/dlls/ntdll/unix/server.c @@ -103,6 +103,7 @@ static const char *server_dir; unsigned int supported_machines_count = 0; USHORT supported_machines[8] = { 0 }; +USHORT native_machine = 0; BOOL is_wow64 = FALSE; BOOL process_exiting = FALSE; @@ -1579,10 +1580,9 @@ size_t server_init_process(void) fatal_error( "'%s' is a 64-bit installation, it cannot be used with a 32-bit wineserver.\n", config_dir ); - switch (supported_machines[0]) + native_machine = supported_machines[0]; + if (is_machine_64bit( native_machine )) { - case IMAGE_FILE_MACHINE_AMD64: - case IMAGE_FILE_MACHINE_ARM64: if (arch && !strcmp( arch, "win32" )) fatal_error( "WINEARCH set to win32 but '%s' is a 64-bit installation.\n", config_dir ); if (!is_win64) @@ -1590,13 +1590,13 @@ size_t server_init_process(void) is_wow64 = TRUE; init_teb64( NtCurrentTeb() ); } - break; - default: + } + else + { if (is_win64) fatal_error( "'%s' is a 32-bit installation, it cannot support 64-bit applications.\n", config_dir ); if (arch && !strcmp( arch, "win64" )) fatal_error( "WINEARCH set to win64 but '%s' is a 32-bit installation.\n", config_dir ); - break; } for (i = 0; i < supported_machines_count; i++) diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index a5bade02b8a..c47695c408c 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -36,9 +36,15 @@ static const WORD current_machine = IMAGE_FILE_MACHINE_ARMNT; #elif defined(__aarch64__) static const WORD current_machine = IMAGE_FILE_MACHINE_ARM64; #endif +extern WORD native_machine DECLSPEC_HIDDEN; static const BOOL is_win64 = (sizeof(void *) > sizeof(int)); +static inline BOOL is_machine_64bit( WORD machine ) +{ + return (machine == IMAGE_FILE_MACHINE_AMD64 || machine == IMAGE_FILE_MACHINE_ARM64); +} + struct debug_info { unsigned int str_pos; /* current position in strings buffer */ diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index f3e6b612b93..c3baa5f09c7 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -4469,7 +4469,7 @@ void virtual_fill_image_information( const pe_image_info_t *pe_info, SECTION_IMA info->ImageFileSize = pe_info->file_size; info->CheckSum = pe_info->checksum; #ifndef _WIN64 /* don't return 64-bit values to 32-bit processes */ - if (pe_info->machine == IMAGE_FILE_MACHINE_AMD64 || pe_info->machine == IMAGE_FILE_MACHINE_ARM64) + if (is_machine_64bit( pe_info->machine )) { info->TransferAddress = (void *)0x81231234; /* sic */ info->MaximumStackSize = 0x100000;