Alexandre Julliard : ntdll: The loader is named wine64 only on platforms that support WoW64.

Alexandre Julliard julliard at winehq.org
Fri Jul 3 14:36:17 CDT 2020


Module: wine
Branch: master
Commit: b64208df0d8e94259783081084c5a731e0839542
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b64208df0d8e94259783081084c5a731e0839542

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Jul  3 19:42:45 2020 +0200

ntdll: The loader is named wine64 only on platforms that support WoW64.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49438
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/loader.c       | 14 ++++++++------
 dlls/ntdll/unix/process.c      | 10 ++--------
 dlls/ntdll/unix/unix_private.h |  3 +--
 3 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index a8af46e2df..e2074f9734 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -426,13 +426,13 @@ static void preloader_exec( char **argv )
     execv( argv[1], argv + 1 );
 }
 
-static NTSTATUS loader_exec( const char *loader, char **argv, int is_child_64bit )
+static NTSTATUS loader_exec( const char *loader, char **argv, client_cpu_t cpu )
 {
     char *p, *path;
 
     if (build_dir)
     {
-        argv[1] = build_path( build_dir, is_child_64bit ? "loader/wine64" : "loader/wine" );
+        argv[1] = build_path( build_dir, (cpu == CPU_x86_64) ? "loader/wine64" : "loader/wine" );
         preloader_exec( argv );
         return STATUS_INVALID_IMAGE_FORMAT;
     }
@@ -465,9 +465,11 @@ static NTSTATUS loader_exec( const char *loader, char **argv, int is_child_64bit
  *
  * argv[0] and argv[1] must be reserved for the preloader and loader respectively.
  */
-NTSTATUS exec_wineloader( char **argv, int socketfd, int is_child_64bit,
-                          ULONGLONG res_start, ULONGLONG res_end )
+NTSTATUS exec_wineloader( char **argv, int socketfd, const pe_image_info_t *pe_info )
 {
+    int is_child_64bit = (pe_info->cpu == CPU_x86_64 || pe_info->cpu == CPU_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];
@@ -507,7 +509,7 @@ NTSTATUS exec_wineloader( char **argv, int socketfd, int is_child_64bit,
     putenv( preloader_reserve );
     putenv( socket_env );
 
-    return loader_exec( loader, argv, is_child_64bit );
+    return loader_exec( loader, argv, pe_info->cpu );
 }
 
 
@@ -1805,7 +1807,7 @@ void __wine_main( int argc, char *argv[], char *envp[] )
         {
             char **new_argv = malloc( (argc + 2) * sizeof(*argv) );
             memcpy( new_argv + 1, argv, (argc + 1) * sizeof(*argv) );
-            loader_exec( argv0, new_argv, is_win64 );
+            loader_exec( argv0, new_argv, client_cpu );
             fatal_error( "could not exec the wine loader\n" );
         }
     }
diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c
index 6c29055821..b86c67e6af 100644
--- a/dlls/ntdll/unix/process.c
+++ b/dlls/ntdll/unix/process.c
@@ -523,7 +523,6 @@ static void set_stdio_fd( int stdin_fd, int stdout_fd )
 static NTSTATUS spawn_process( const RTL_USER_PROCESS_PARAMETERS *params, int socketfd,
                                int unixdir, char *winedebug, const pe_image_info_t *pe_info )
 {
-    const int is_child_64bit = (pe_info->cpu == CPU_x86_64 || pe_info->cpu == CPU_ARM64);
     NTSTATUS status = STATUS_SUCCESS;
     int stdin_fd = -1, stdout_fd = -1;
     pid_t pid;
@@ -556,8 +555,7 @@ static NTSTATUS spawn_process( const RTL_USER_PROCESS_PARAMETERS *params, int so
             }
             argv = build_argv( &params->CommandLine, 2 );
 
-            exec_wineloader( argv, socketfd, is_child_64bit,
-                             pe_info->base, pe_info->base + pe_info->map_size );
+            exec_wineloader( argv, socketfd, pe_info );
             _exit(1);
         }
 
@@ -586,7 +584,6 @@ static NTSTATUS spawn_process( const RTL_USER_PROCESS_PARAMETERS *params, int so
 NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status )
 {
     pe_image_info_t pe_info;
-    BOOL is_child_64bit;
     int unixdir, socketfd[2];
     char **argv;
     HANDLE handle;
@@ -601,7 +598,6 @@ NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTST
     case STATUS_INVALID_IMAGE_NOT_MZ:
         if (getenv( "WINEPRELOADRESERVE" )) return status;
         if ((status = get_pe_file_info( path, &handle, &pe_info ))) return status;
-        is_child_64bit = (pe_info.cpu == CPU_x86_64 || pe_info.cpu == CPU_ARM64);
         break;
     case STATUS_INVALID_IMAGE_WIN_16:
     case STATUS_INVALID_IMAGE_NE_FORMAT:
@@ -609,7 +605,6 @@ NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTST
         /* we'll start winevdm */
         memset( &pe_info, 0, sizeof(pe_info) );
         pe_info.cpu = CPU_x86;
-        is_child_64bit = FALSE;
         break;
     default:
         return status;
@@ -642,8 +637,7 @@ NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTST
         fchdir( unixdir );
         do
         {
-            status = exec_wineloader( argv, socketfd[0], is_child_64bit,
-                                      pe_info.base, pe_info.base + pe_info.map_size );
+            status = exec_wineloader( argv, socketfd[0], &pe_info );
         }
 #ifdef __APPLE__
         while (errno == ENOTSUP && terminate_main_thread());
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index 919988db13..e14da3ff7e 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -157,8 +157,7 @@ extern void init_environment( int argc, char *argv[], char *envp[] ) DECLSPEC_HI
 extern DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen ) DECLSPEC_HIDDEN;
 extern int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict ) DECLSPEC_HIDDEN;
 extern char **build_envp( const WCHAR *envW ) DECLSPEC_HIDDEN;
-extern NTSTATUS exec_wineloader( char **argv, int socketfd, int is_child_64bit,
-                                 ULONGLONG res_start, ULONGLONG res_end ) DECLSPEC_HIDDEN;
+extern NTSTATUS exec_wineloader( char **argv, int socketfd, const pe_image_info_t *pe_info ) DECLSPEC_HIDDEN;
 extern void start_server( BOOL debug ) DECLSPEC_HIDDEN;
 extern ULONG_PTR get_image_address(void) DECLSPEC_HIDDEN;
 




More information about the wine-cvs mailing list