From 53aeae58ad8d9bbf4ed4cf733fe98686d264602e Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Mon, 20 Feb 2017 15:56:33 +0100 Subject: [PATCH] Added patch to improve performance of LdrGetDllHandle when DLL is not loaded. --- ...eed-of-LdrGetDllHandle-when-searchin.patch | 30 +++++++++++++++++++ patches/ntdll-LdrGetDllHandle/definition | 1 + patches/patchinstall.sh | 16 ++++++++++ 3 files changed, 47 insertions(+) create mode 100644 patches/ntdll-LdrGetDllHandle/0001-ntdll-Improve-speed-of-LdrGetDllHandle-when-searchin.patch create mode 100644 patches/ntdll-LdrGetDllHandle/definition diff --git a/patches/ntdll-LdrGetDllHandle/0001-ntdll-Improve-speed-of-LdrGetDllHandle-when-searchin.patch b/patches/ntdll-LdrGetDllHandle/0001-ntdll-Improve-speed-of-LdrGetDllHandle-when-searchin.patch new file mode 100644 index 00000000..b8487119 --- /dev/null +++ b/patches/ntdll-LdrGetDllHandle/0001-ntdll-Improve-speed-of-LdrGetDllHandle-when-searchin.patch @@ -0,0 +1,30 @@ +From 2689c394dda377cdda8099164e561bfed4b07962 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +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 + diff --git a/patches/ntdll-LdrGetDllHandle/definition b/patches/ntdll-LdrGetDllHandle/definition new file mode 100644 index 00000000..09539ed5 --- /dev/null +++ b/patches/ntdll-LdrGetDllHandle/definition @@ -0,0 +1 @@ +Fixes: Improve performance of LdrGetDllHandle when DLL is not loaded diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index f909c7df..6bed212e 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -234,6 +234,7 @@ patch_enable_all () enable_ntdll_Hide_Wine_Exports="$1" enable_ntdll_Junction_Points="$1" enable_ntdll_LdrEnumerateLoadedModules="$1" + enable_ntdll_LdrGetDllHandle="$1" enable_ntdll_Loader_Machine_Type="$1" enable_ntdll_NtAccessCheck="$1" enable_ntdll_NtAllocateUuids="$1" @@ -915,6 +916,9 @@ patch_enable () ntdll-LdrEnumerateLoadedModules) enable_ntdll_LdrEnumerateLoadedModules="$2" ;; + ntdll-LdrGetDllHandle) + enable_ntdll_LdrGetDllHandle="$2" + ;; ntdll-Loader_Machine_Type) enable_ntdll_Loader_Machine_Type="$2" ;; @@ -5445,6 +5449,18 @@ if test "$enable_ntdll_LdrEnumerateLoadedModules" -eq 1; then ) >> "$patchlist" fi +# Patchset ntdll-LdrGetDllHandle +# | +# | Modified files: +# | * dlls/ntdll/loader.c +# | +if test "$enable_ntdll_LdrGetDllHandle" -eq 1; then + patch_apply ntdll-LdrGetDllHandle/0001-ntdll-Improve-speed-of-LdrGetDllHandle-when-searchin.patch + ( + printf '%s\n' '+ { "Michael Müller", "ntdll: Improve speed of LdrGetDllHandle when searching for the basename of modules that are not loaded.", 1 },'; + ) >> "$patchlist" +fi + # Patchset ntdll-NtAccessCheck # | # | Modified files: