[PATCH v4 2/2] ntdll: fix LdrGetDllPath with LOAD_WITH_ALTERED_SEARCH_PATH
Nick Fox
nick at foxsec.net
Thu Oct 14 15:09:32 CDT 2021
Windows adds the executable directory to the path when LdrGetDllPath
is called with LOAD_WITH_ALTERED_SEARCH_PATH and a relative module name,
but only when the module name does not include directories.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=26350
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51821
Signed-off-by: Nick Fox <nick at foxsec.net>
---
v4: add additional test case and fix todo_wine usage
---
dlls/kernel32/tests/path.c | 2 --
dlls/ntdll/loader.c | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index b2a6d5acbda..63f5ab21fa5 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -2659,7 +2659,6 @@ static void test_LdrGetDllPath(void)
ok( !ret, "LdrGetDllPath failed %x\n", ret );
ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
build_search_path( buffer, ARRAY_SIZE(buffer), NULL, TRUE );
- todo_wine
ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
pRtlReleasePath( path );
@@ -2671,7 +2670,6 @@ static void test_LdrGetDllPath(void)
ok( !ret, "LdrGetDllPath failed %x\n", ret );
ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
build_search_path( buffer, ARRAY_SIZE(buffer), NULL, TRUE );
- todo_wine
ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
pRtlReleasePath( path );
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 797d72aedb6..ca128308032 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -4208,7 +4208,7 @@ NTSTATUS WINAPI LdrGetDllPath( PCWSTR module, ULONG flags, PWSTR *path, PWSTR *u
else
{
const WCHAR *dlldir = dll_directory.Length ? dll_directory.Buffer : NULL;
- if (!(flags & LOAD_WITH_ALTERED_SEARCH_PATH))
+ if (!(flags & LOAD_WITH_ALTERED_SEARCH_PATH) || !wcschr( module, L'\\' ))
module = NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer;
status = get_dll_load_path( module, dlldir, dll_safe_mode, path );
}
--
2.33.0
More information about the wine-devel
mailing list