Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/ntdll/loader.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 927de8e25f5..99d5c08b002 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -3396,11 +3396,23 @@ NTSTATUS WINAPI LdrGetDllHandleEx( ULONG flags, LPCWSTR load_path, ULONG *dll_ch if (flags & ~supported_flags) FIXME( "Unsupported flags %#x.\n", flags ); if (dll_characteristics) FIXME( "dll_characteristics unsupported.\n" );
- lock_loader_exclusive(); + lock_loader_shared();
+retry: status = find_dll_file( load_path, name->Buffer, L".dll", &nt_name, &wm, &mapping, &image_info, &id );
- if (wm) *base = wm->ldr.DllBase; + if (wm) + { + lock_module_info(); + if (!is_thread_exclusive() && !wm->ldr.LoadCount) + { + unlock_module_info(); + wait_for_exclusive_lock_release(); + goto retry; + } + unlock_module_info(); + *base = wm->ldr.DllBase; + } else { if (status == STATUS_SUCCESS) NtClose( mapping ); @@ -3411,9 +3423,9 @@ NTSTATUS WINAPI LdrGetDllHandleEx( ULONG flags, LPCWSTR load_path, ULONG *dll_ch if (!status) { if (flags & LDR_GET_DLL_HANDLE_EX_FLAG_PIN) - LdrAddRefDll( LDR_ADDREF_DLL_PIN, *base ); + status = LdrAddRefDll( LDR_ADDREF_DLL_PIN, *base ); else if (!(flags & LDR_GET_DLL_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT)) - LdrAddRefDll( 0, *base ); + status = LdrAddRefDll( 0, *base ); }
unlock_loader();