From: Nick Subject: [PATCH v3 2/2] ntdll: fix LdrGetDllPath with LOAD_WITH_ALTERED_SEARCH_PATH Message-Id: Date: Mon, 11 Oct 2021 01:39:04 +0000 Empty Message From fb030f2a2889f3ce706f7ee734dd25f672be63f4 Mon Sep 17 00:00:00 2001 From: Nick Fox Date: Sun, 10 Oct 2021 21:34:56 -0400 Subject: [PATCH v3 2/2] ntdll: fix LdrGetDllPath with LOAD_WITH_ALTERED_SEARCH_PATH 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 --- v3: mark tests as passed in same patch that fixes them --- dlls/kernel32/tests/path.c | 4 ++-- dlls/ntdll/loader.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index 98fbd1880e8..8515d99f3ca 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -2659,7 +2659,7 @@ 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( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer)); + ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer)); pRtlReleasePath( path ); lstrcpyW( buffer, L"temp" ); @@ -2670,7 +2670,7 @@ 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( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer)); + ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer)); pRtlReleasePath( path ); lstrcpyW( buffer, L"temp" ); diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 797d72aedb6..01a5767f150 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, '\\' )) module = NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer; status = get_dll_load_path( module, dlldir, dll_safe_mode, path ); } -- 2.33.0