Alexandre Julliard : ntdll: Check the loadorder for .so dlls on the Unix side.

Alexandre Julliard julliard at winehq.org
Fri Mar 26 16:03:30 CDT 2021


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Mar 26 16:15:01 2021 +0100

ntdll: Check the loadorder for .so dlls on the Unix side.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/loader.c      | 24 +++++-------------------
 dlls/ntdll/unix/loader.c |  1 +
 2 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 1e89edf3bec..7dada146044 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -2349,10 +2349,11 @@ static NTSTATUS load_so_dll( LPCWSTR load_path, const UNICODE_STRING *nt_name,
     UNICODE_STRING win_name = *nt_name;
 
     TRACE( "trying %s as so lib\n", debugstr_us(&win_name) );
-    if (unix_funcs->load_so_dll( &win_name, &module ))
+    if ((status = unix_funcs->load_so_dll( &win_name, &module )))
     {
         WARN( "failed to load .so lib %s\n", debugstr_us(nt_name) );
-        return STATUS_INVALID_IMAGE_FORMAT;
+        if (status == STATUS_INVALID_IMAGE_FORMAT) status = STATUS_INVALID_IMAGE_NOT_MZ;
+        return status;
     }
 
     if ((wm = get_modref( module )))  /* already loaded */
@@ -2690,7 +2691,6 @@ done:
 static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WCHAR *default_ext,
                           DWORD flags, WINE_MODREF** pwm )
 {
-    enum loadorder loadorder;
     UNICODE_STRING nt_name;
     struct file_id id;
     HANDLE mapping = 0;
@@ -2715,27 +2715,13 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC
 
     if (nts && nts != STATUS_DLL_NOT_FOUND && nts != STATUS_INVALID_IMAGE_NOT_MZ) goto done;
 
-    loadorder = unix_funcs->get_load_order( &nt_name );
-
     prev = NtCurrentTeb()->Tib.ArbitraryUserPointer;
     NtCurrentTeb()->Tib.ArbitraryUserPointer = nt_name.Buffer + 4;
 
     switch (nts)
     {
     case STATUS_INVALID_IMAGE_NOT_MZ:  /* not in PE format, maybe it's a .so file */
-        switch (loadorder)
-        {
-        case LO_NATIVE:
-        case LO_NATIVE_BUILTIN:
-        case LO_BUILTIN:
-        case LO_BUILTIN_NATIVE:
-        case LO_DEFAULT:
-            if (!load_so_dll( load_path, &nt_name, flags, pwm )) nts = STATUS_SUCCESS;
-            break;
-        default:
-            nts = STATUS_DLL_NOT_FOUND;
-            break;
-        }
+        nts = load_so_dll( load_path, &nt_name, flags, pwm );
         break;
 
     case STATUS_SUCCESS:  /* valid PE file */
@@ -2743,7 +2729,7 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC
         break;
 
     case STATUS_DLL_NOT_FOUND:  /* no file found, try builtin */
-        switch (loadorder)
+        switch (unix_funcs->get_load_order( &nt_name ))
         {
         case LO_NATIVE_BUILTIN:
         case LO_BUILTIN:
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index d9db518ee76..438ff474a92 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -1153,6 +1153,7 @@ static NTSTATUS CDECL load_so_dll( UNICODE_STRING *nt_name, void **module )
     NTSTATUS status;
     DWORD len;
 
+    if (get_load_order( nt_name ) == LO_DISABLED) return STATUS_DLL_NOT_FOUND;
     if (nt_to_unix_file_name( nt_name, &unix_name, NULL, FILE_OPEN )) return STATUS_DLL_NOT_FOUND;
 
     /* remove .so extension from Windows name */




More information about the wine-cvs mailing list