From 2689c394dda377cdda8099164e561bfed4b07962 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Wed, 15 Feb 2017 16:50:04 +0100
Subject: ntdll: Improve speed of LdrGetDllHandle when searching for the
 basename of modules that are not loaded.

FIXME: Can we do a similar optimization when the activation context is present?
---
 dlls/ntdll/loader.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 1168bad03ae..97cde883545 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -2506,6 +2506,11 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname,
             RtlFreeHeap( GetProcessHeap(), 0, dllname );
             return status;
         }
+        else if (!handle)
+        {
+            /* Do not resolve full name if basename cannot be found */
+            return STATUS_DLL_NOT_FOUND;
+        }
     }
 
     if (RtlDetermineDosPathNameType_U( libname ) == RELATIVE_PATH)
-- 
2.11.0