[PATCH v2 4/4] ntdll: Avoid taking loader lock in LdrGetDllHandle().
Paul Gofman
pgofman at codeweavers.com
Fri Nov 6 06:56:27 CST 2020
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
dlls/kernel32/tests/loader.c | 5 ++---
dlls/ntdll/loader.c | 3 ---
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 5d8991bf0f0..8b4be58036d 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -4036,9 +4036,6 @@ static void test_loader_lock_scope(void)
test_loader_lock_event = CreateEventA(NULL, FALSE, FALSE, NULL);
test_loader_lock_test_done_event = CreateEventA(NULL, FALSE, FALSE, NULL);
- hmodule = GetModuleHandleA("ntdll.dll");
- ok(!!hmodule, "Got NULL hmodule.\n");
-
hthread = CreateThread(NULL, 0, test_loader_lock_thread, NULL, 0, NULL);
ok(!!hthread, "Thread creation failed.\n");
@@ -4052,6 +4049,8 @@ static void test_loader_lock_scope(void)
RtlInitAnsiString(&name, "LdrLockLoaderLock");
address = (void *)0xdeadbeef;
/* Locks up on loader lock before Win7. */
+ hmodule = GetModuleHandleA("ntdll.dll");
+ ok(!!hmodule, "Got NULL hmodule.\n");
status = pLdrGetProcedureAddress(hmodule, &name, 0, &address);
ok(!status && address == pLdrLockLoaderLock, "Got unexpected status %#x, address %p.\n", status, address);
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 065bd62cac0..6dd73a8c001 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -3012,8 +3012,6 @@ NTSTATUS WINAPI LdrGetDllHandle( LPCWSTR load_path, ULONG flags, const UNICODE_S
SECTION_IMAGE_INFORMATION image_info;
struct file_id id;
- RtlEnterCriticalSection( &loader_section );
-
if (!load_path) load_path = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
if (!(status = find_dll_file( load_path, name->Buffer, dllW,
@@ -3024,7 +3022,6 @@ NTSTATUS WINAPI LdrGetDllHandle( LPCWSTR load_path, ULONG flags, const UNICODE_S
}
RtlFreeUnicodeString( &nt_name );
- RtlLeaveCriticalSection( &loader_section );
TRACE( "%s -> %p (load path %s)\n", debugstr_us(name), status ? NULL : *base, debugstr_w(load_path) );
return status;
}
--
2.28.0
More information about the wine-devel
mailing list