Alexandre Julliard : ntdll: Fail to load non-existent dlls, except during prefix bootstrap.

Alexandre Julliard julliard at winehq.org
Wed Mar 31 15:55:13 CDT 2021


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Mar 31 10:19:10 2021 +0200

ntdll: Fail to load non-existent dlls, except during prefix bootstrap.

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

---

 dlls/kernel32/tests/module.c | 6 +++---
 dlls/ntdll/loader.c          | 7 ++++++-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/dlls/kernel32/tests/module.c b/dlls/kernel32/tests/module.c
index 96577989431..0066f7de5a8 100644
--- a/dlls/kernel32/tests/module.c
+++ b/dlls/kernel32/tests/module.c
@@ -1093,7 +1093,7 @@ static void test_SetDefaultDllDirectories(void)
     ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_USER_DIRS );
     ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
     mod = LoadLibraryA( "authz.dll" );
-    todo_wine ok( !mod, "loading authz succeeded\n" );
+    ok( !mod, "loading authz succeeded\n" );
     FreeLibrary( mod );
     ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_SYSTEM32 );
     ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
@@ -1101,12 +1101,12 @@ static void test_SetDefaultDllDirectories(void)
     ok( mod != NULL, "loading authz failed\n" );
     FreeLibrary( mod );
     mod = LoadLibraryExA( "authz.dll", 0, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
-    todo_wine ok( !mod, "loading authz succeeded\n" );
+    ok( !mod, "loading authz succeeded\n" );
     FreeLibrary( mod );
     ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
     ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
     mod = LoadLibraryA( "authz.dll" );
-    todo_wine ok( !mod, "loading authz succeeded\n" );
+    ok( !mod, "loading authz succeeded\n" );
     FreeLibrary( mod );
     ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DEFAULT_DIRS );
     ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index e8b53778284..964a3e0eaa4 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -73,6 +73,7 @@ BOOL is_wow64 = FALSE;
 /* system search path */
 static const WCHAR system_path[] = L"C:\\windows\\system32;C:\\windows\\system;C:\\windows";
 
+static BOOL is_prefix_bootstrap;  /* are we bootstrapping the prefix? */
 static BOOL imports_fixup_done = FALSE;  /* set once the imports have been fixed up, before attaching them */
 static BOOL process_detaching = FALSE;  /* set on process detach to avoid deadlocks with thread detach */
 static int free_lib_count;   /* recursion depth of LdrUnloadDll calls */
@@ -1918,10 +1919,14 @@ static NTSTATUS build_module( LPCWSTR load_path, const UNICODE_STRING *nt_name,
 static void build_ntdll_module(void)
 {
     MEMORY_BASIC_INFORMATION meminfo;
+    FILE_BASIC_INFORMATION basic_info;
     UNICODE_STRING nt_name;
+    OBJECT_ATTRIBUTES attr;
     WINE_MODREF *wm;
 
     RtlInitUnicodeString( &nt_name, L"\\??\\C:\\windows\\system32\\ntdll.dll" );
+    InitializeObjectAttributes( &attr, &nt_name, OBJ_CASE_INSENSITIVE, 0, NULL );
+    is_prefix_bootstrap = NtQueryAttributesFile( &attr, &basic_info) != STATUS_SUCCESS;
     NtQueryVirtualMemory( GetCurrentProcess(), build_ntdll_module, MemoryBasicInformation,
                           &meminfo, sizeof(meminfo), NULL );
     wm = alloc_module( meminfo.AllocationBase, &nt_name, TRUE );
@@ -2647,7 +2652,7 @@ static NTSTATUS search_dll_file( LPCWSTR paths, LPCWSTR search, UNICODE_STRING *
 
     if (found_image)
         status = STATUS_IMAGE_MACHINE_TYPE_MISMATCH;
-    else if (!wcspbrk( search, L":/\\" ))
+    else if (is_prefix_bootstrap && !wcspbrk( search, L":/\\" ))
         status = find_builtin_without_file( search, nt_name, pwm, mapping, image_info, id );
 
 done:




More information about the wine-cvs mailing list