Module: wine Branch: master Commit: e588e218f0c8a3160ca81b010b401ccf44ea7d51 URL: https://gitlab.winehq.org/wine/wine/-/commit/e588e218f0c8a3160ca81b010b401cc...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Mar 28 11:58:30 2023 +0200
ntdll: Only fall back to start.exe when using a different loader.
---
dlls/ntdll/unix/env.c | 9 ++++++++- dlls/ntdll/unix/loader.c | 2 +- dlls/ntdll/unix/unix_private.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 1e951877ab7..3c178350f2b 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -1932,8 +1932,15 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params( void **module ) status = load_main_exe( NULL, main_argv[1], curdir, &image, module ); if (!status) { + char *loader; + if (main_image_info.ImageCharacteristics & IMAGE_FILE_DLL) status = STATUS_INVALID_IMAGE_FORMAT; - if (main_image_info.Machine != current_machine) status = STATUS_INVALID_IMAGE_FORMAT; + /* if we have to use a different loader, fall back to start.exe */ + if ((loader = get_alternate_wineloader( main_image_info.Machine ))) + { + free( loader ); + status = STATUS_INVALID_IMAGE_FORMAT; + } }
if (status) /* try launching it through start.exe */ diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 0d719979046..16c044d502e 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -656,7 +656,7 @@ static void init_paths( char *argv[] ) /*********************************************************************** * get_alternate_wineloader */ -static char *get_alternate_wineloader( WORD machine ) +char *get_alternate_wineloader( WORD machine ) { char *ret = NULL;
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 57b8f01641c..b803b1cef46 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -175,6 +175,7 @@ extern void init_startup_info(void) DECLSPEC_HIDDEN; extern void *create_startup_info( const UNICODE_STRING *nt_image, const RTL_USER_PROCESS_PARAMETERS *params, DWORD *info_size ) DECLSPEC_HIDDEN; extern char **build_envp( const WCHAR *envW ) DECLSPEC_HIDDEN; +extern char *get_alternate_wineloader( WORD machine ) DECLSPEC_HIDDEN; extern NTSTATUS exec_wineloader( char **argv, int socketfd, const pe_image_info_t *pe_info ) DECLSPEC_HIDDEN; extern NTSTATUS load_builtin( const pe_image_info_t *image_info, WCHAR *filename, void **addr_ptr, SIZE_T *size_ptr, ULONG_PTR zero_bits ) DECLSPEC_HIDDEN;