Alexandre Julliard : ntdll: Check the main image for Unix path only the first time around.

Alexandre Julliard julliard at winehq.org
Thu Mar 25 16:49:21 CDT 2021


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Mar 25 11:24:35 2021 +0100

ntdll: Check the main image for Unix path only the first time around.

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

---

 dlls/ntdll/unix/env.c          | 6 +++---
 dlls/ntdll/unix/loader.c       | 8 ++++----
 dlls/ntdll/unix/unix_private.h | 4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c
index e4932473fcc..07b9f0fc384 100644
--- a/dlls/ntdll/unix/env.c
+++ b/dlls/ntdll/unix/env.c
@@ -1871,7 +1871,7 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params(void)
     add_registry_environment( &env, &env_pos, &env_size );
     env[env_pos++] = 0;
 
-    status = load_main_exe( main_wargv[0], curdir, &image, &module, &image_info );
+    status = load_main_exe( main_wargv[0], main_argv[0], curdir, &image, &module, &image_info );
     if (!status && image_info.Machine != current_machine)  /* need to restart for Wow64 */
     {
         NtUnmapViewOfSection( GetCurrentProcess(), module );
@@ -1888,7 +1888,7 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params(void)
 
         free( image );
         prepend_main_wargv( args, 3 );
-        if ((status = load_main_exe( startW, curdir, &image, &module, &image_info )))
+        if ((status = load_main_exe( startW, NULL, curdir, &image, &module, &image_info )))
         {
             MESSAGE( "wine: failed to start %s\n", debugstr_w(main_wargv[2]) );
             NtTerminateProcess( GetCurrentProcess(), status );
@@ -2042,7 +2042,7 @@ void init_startup_info(void)
     free( info );
     NtCurrentTeb()->Peb->ProcessParameters = params;
 
-    status = load_main_exe( params->ImagePathName.Buffer, params->CommandLine.Buffer,
+    status = load_main_exe( params->ImagePathName.Buffer, NULL, params->CommandLine.Buffer,
                             &image, &module, &image_info );
     if (status)
     {
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index a8b06d690a6..24cc546c300 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -1500,8 +1500,8 @@ static NTSTATUS open_main_image( WCHAR *image, void **module, SECTION_IMAGE_INFO
 /***********************************************************************
  *           load_main_exe
  */
-NTSTATUS load_main_exe( const WCHAR *name, const WCHAR *curdir, WCHAR **image, void **module,
-                        SECTION_IMAGE_INFORMATION *image_info )
+NTSTATUS load_main_exe( const WCHAR *name, const char *unix_name, const WCHAR *curdir,
+                        WCHAR **image, void **module, SECTION_IMAGE_INFORMATION *image_info )
 {
     UNICODE_STRING nt_name;
     NTSTATUS status;
@@ -1510,9 +1510,9 @@ NTSTATUS load_main_exe( const WCHAR *name, const WCHAR *curdir, WCHAR **image, v
     const WCHAR *p;
 
     /* special case for Unix file name */
-    if (main_argv[0][0] == '/' && !stat( main_argv[0], &st ))
+    if (unix_name && unix_name[0] == '/' && !stat( unix_name, &st ))
     {
-        if ((status = unix_to_nt_file_name( main_argv[0], image ))) goto failed;
+        if ((status = unix_to_nt_file_name( unix_name, image ))) goto failed;
         status = open_main_image( *image, module, image_info );
         if (status != STATUS_DLL_NOT_FOUND) return status;
         free( *image );
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index 8e491a3f2a4..a486a2ff0f4 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -143,8 +143,8 @@ extern char **build_envp( const WCHAR *envW ) 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, const WCHAR *filename,
                               void **addr_ptr, SIZE_T *size_ptr ) DECLSPEC_HIDDEN;
-extern NTSTATUS load_main_exe( const WCHAR *name, const WCHAR *curdir, WCHAR **image, void **module,
-                               SECTION_IMAGE_INFORMATION *image_info ) DECLSPEC_HIDDEN;
+extern NTSTATUS load_main_exe( const WCHAR *name, const char *unix_name, const WCHAR *curdir, WCHAR **image,
+                               void **module, SECTION_IMAGE_INFORMATION *image_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