Alexandre Julliard : ntdll: Take loadorder into account also for a main exe in .so format.

Alexandre Julliard julliard at winehq.org
Mon Apr 12 16:11:24 CDT 2021


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Apr 12 09:20:55 2021 +0200

ntdll: Take loadorder into account also for a main exe in .so format.

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

---

 dlls/ntdll/unix/loader.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index cbafa0d8882..28d2be0b770 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -1420,7 +1420,8 @@ found:
 /***********************************************************************
  *           open_main_image
  */
-static NTSTATUS open_main_image( WCHAR *image, void **module, SECTION_IMAGE_INFORMATION *info )
+static NTSTATUS open_main_image( WCHAR *image, void **module, SECTION_IMAGE_INFORMATION *info,
+                                 enum loadorder loadorder )
 {
     static const WCHAR soW[] = {'.','s','o',0};
     UNICODE_STRING nt_name;
@@ -1432,6 +1433,8 @@ static NTSTATUS open_main_image( WCHAR *image, void **module, SECTION_IMAGE_INFO
     HANDLE mapping;
     WCHAR *p;
 
+    if (loadorder == LO_DISABLED) NtTerminateProcess( GetCurrentProcess(), STATUS_DLL_NOT_FOUND );
+
     init_unicode_string( &nt_name, image );
     InitializeObjectAttributes( &attr, &nt_name, OBJ_CASE_INSENSITIVE, 0, NULL );
     if (nt_to_unix_file_name( &nt_name, &unix_name, NULL, FILE_OPEN )) return STATUS_DLL_NOT_FOUND;
@@ -1445,7 +1448,7 @@ static NTSTATUS open_main_image( WCHAR *image, void **module, SECTION_IMAGE_INFO
         if (!status) NtQuerySection( mapping, SectionImageInformation, info, sizeof(*info), NULL );
         NtClose( mapping );
     }
-    else if (status == STATUS_INVALID_IMAGE_NOT_MZ)
+    else if (status == STATUS_INVALID_IMAGE_NOT_MZ && loadorder != LO_NATIVE)
     {
         /* remove .so extension from Windows name */
         p = image + wcslen(image);
@@ -1468,6 +1471,7 @@ static NTSTATUS open_main_image( WCHAR *image, void **module, SECTION_IMAGE_INFO
 NTSTATUS load_main_exe( const WCHAR *dos_name, const char *unix_name, const WCHAR *curdir,
                         WCHAR **image, void **module )
 {
+    enum loadorder loadorder = LO_INVALID;
     UNICODE_STRING nt_name;
     WCHAR *tmp = NULL;
     BOOL contains_path;
@@ -1480,7 +1484,8 @@ NTSTATUS load_main_exe( const WCHAR *dos_name, const char *unix_name, const WCHA
     if (unix_name && unix_name[0] == '/' && !stat( unix_name, &st ))
     {
         if ((status = unix_to_nt_file_name( unix_name, image ))) goto failed;
-        status = open_main_image( *image, module, &main_image_info );
+        loadorder = get_load_order( &nt_name );
+        status = open_main_image( *image, module, &main_image_info, loadorder );
         if (status != STATUS_DLL_NOT_FOUND) return status;
         free( *image );
     }
@@ -1497,12 +1502,14 @@ NTSTATUS load_main_exe( const WCHAR *dos_name, const char *unix_name, const WCHA
     if ((status = get_full_path( dos_name, curdir, image ))) goto failed;
     free( tmp );
 
-    status = open_main_image( *image, module, &main_image_info );
+    init_unicode_string( &nt_name, *image );
+    if (loadorder == LO_INVALID) loadorder = get_load_order( &nt_name );
+
+    status = open_main_image( *image, module, &main_image_info, loadorder );
     if (status != STATUS_DLL_NOT_FOUND) return status;
 
     /* if path is in system dir, we can load the builtin even if the file itself doesn't exist */
-    init_unicode_string( &nt_name, *image );
-    if (is_builtin_path( &nt_name, &machine ))
+    if (loadorder != LO_NATIVE && is_builtin_path( &nt_name, &machine ))
     {
         status = find_builtin_dll( &nt_name, module, &size, &main_image_info, machine, FALSE );
         if (status != STATUS_DLL_NOT_FOUND) return status;




More information about the wine-cvs mailing list