From cc9446f87486865f91a71d0a456711633bcb1397 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 19 Mar 2021 22:01:42 +0100 Subject: [PATCH] server: Don't change the reported machine for COM+ images. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50826 Signed-off-by: Alexandre Julliard --- dlls/ntdll/unix/loader.c | 12 +++++++++--- dlls/ntdll/unix/process.c | 15 +++++++++------ server/mapping.c | 4 ---- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 87a81343737..9e43358a26d 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -452,14 +452,20 @@ 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 ) { - int is_child_64bit = (pe_info->machine == IMAGE_FILE_MACHINE_AMD64 || - pe_info->machine == IMAGE_FILE_MACHINE_ARM64); + 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]; + if (!is_child_64bit && (is_win64 || is_wow64) && (pe_info->image_flags & IMAGE_FLAGS_ComPlusNativeReady)) + { + is_child_64bit = TRUE; + machine = IMAGE_FILE_MACHINE_AMD64; + } + if (!is_win64 ^ !is_child_64bit) { /* remap WINELOADER to the alternate 32/64-bit version if necessary */ @@ -495,7 +501,7 @@ NTSTATUS exec_wineloader( char **argv, int socketfd, const pe_image_info_t *pe_i putenv( preloader_reserve ); putenv( socket_env ); - return loader_exec( loader, argv, pe_info->machine ); + return loader_exec( loader, argv, machine ); } diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index d6dc893fba5..f1804009782 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -80,11 +80,14 @@ static const char * const cpu_names[] = { "x86", "x86_64", "PowerPC", "ARM", "AR static UINT process_error_mode; -static client_cpu_t get_machine_cpu( WORD machine ) +static client_cpu_t get_machine_cpu( pe_image_info_t *pe_info ) { - switch (machine) + switch (pe_info->machine) { - case IMAGE_FILE_MACHINE_I386: return CPU_x86; + case IMAGE_FILE_MACHINE_I386: + if ((is_win64 || is_wow64) && (pe_info->image_flags & IMAGE_FLAGS_ComPlusNativeReady)) + return CPU_x86_64; + return CPU_x86; case IMAGE_FILE_MACHINE_AMD64: return CPU_x86_64; case IMAGE_FILE_MACHINE_ARMNT: return CPU_ARM; case IMAGE_FILE_MACHINE_ARM64: return CPU_ARM64; @@ -679,7 +682,7 @@ void DECLSPEC_NORETURN exec_process( NTSTATUS status ) SERVER_START_REQ( exec_process ) { req->socket_fd = socketfd[1]; - req->cpu = get_machine_cpu( pe_info.machine ); + req->cpu = get_machine_cpu( &pe_info ); status = wine_server_call( req ); } SERVER_END_REQ; @@ -963,7 +966,7 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_ req->create_flags = params->DebugFlags; /* hack: creation flags stored in DebugFlags for now */ req->socket_fd = socketfd[1]; req->access = process_access; - req->cpu = get_machine_cpu( pe_info.machine ); + req->cpu = get_machine_cpu( &pe_info ); req->info_size = startup_info_size; req->handles_size = handles_size; wine_server_add_data( req, objattr, attr_len ); @@ -990,7 +993,7 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_ break; case STATUS_INVALID_IMAGE_FORMAT: ERR( "%s not supported on this installation (%s binary)\n", - debugstr_us(&path), cpu_names[get_machine_cpu(pe_info.machine)] ); + debugstr_us(&path), cpu_names[get_machine_cpu(&pe_info)] ); break; } goto done; diff --git a/server/mapping.c b/server/mapping.c index 3a162eae76b..13a0948a8ab 100644 --- a/server/mapping.c +++ b/server/mapping.c @@ -788,11 +788,7 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s if (nt.opt.hdr32.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { if (!(clr.Flags & COMIMAGE_FLAGS_32BITREQUIRED)) - { mapping->image.image_flags |= IMAGE_FLAGS_ComPlusNativeReady; - if (cpu_mask & CPU_FLAG(CPU_x86_64)) mapping->image.machine = IMAGE_FILE_MACHINE_AMD64; - else if (cpu_mask & CPU_FLAG(CPU_ARM64)) mapping->image.machine = IMAGE_FILE_MACHINE_ARM64; - } if (clr.Flags & COMIMAGE_FLAGS_32BITPREFERRED) mapping->image.image_flags |= IMAGE_FLAGS_ComPlusPrefer32bit; }