From: Yuxuan Shui <yshui(a)codeweavers.com> Previously looking for file that does exist in current directory will fail because of the early `!PathFileExists(path)` check, even when the current directory is specified in `dirs`. --- dlls/shell32/shellpath.c | 4 ++-- dlls/shell32/tests/shellpath.c | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index e7d4e181682..9b527b35ac4 100644 --- a/dlls/shell32/shellpath.c +++ b/dlls/shell32/shellpath.c @@ -691,7 +691,7 @@ static BOOL PathResolveA(char *path, const char **dirs, DWORD flags) TRACE("(%s,%p,0x%08lx)\n", debugstr_a(path), dirs, flags); - if (flags & PRF_VERIFYEXISTS && !PathFileExistsA(path)) + if (flags & PRF_VERIFYEXISTS) { if (PathFindOnPathExA(path, dirs, dwWhich)) return TRUE; @@ -720,7 +720,7 @@ static BOOL PathResolveW(WCHAR *path, const WCHAR **dirs, DWORD flags) TRACE("(%s,%p,0x%08lx)\n", debugstr_w(path), dirs, flags); - if (flags & PRF_VERIFYEXISTS && !PathFileExistsW(path)) + if (flags & PRF_VERIFYEXISTS) { if (PathFindOnPathExW(path, dirs, dwWhich)) return TRUE; diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c index c493f6882ee..5ed25136003 100644 --- a/dlls/shell32/tests/shellpath.c +++ b/dlls/shell32/tests/shellpath.c @@ -3048,10 +3048,14 @@ static void test_PathResolve(void) ok(!lstrcmpiW(path, L"C:\\windows\\regedit.exe") || !lstrcmpiW(path, L"C:\\windows\\system32\\regedit.exe"), "unexpected path %s\n", wine_dbgstr_w(path)); - /* show that PathResolve doesn't check current directory */ if (argv0_basep) { WCHAR *ext; + const WCHAR *search_path[] = { + argv0_dir, + NULL + }; + /* show that PathResolve doesn't check current directory */ lstrcpyW(argv0_base, argv0_basep); GetCurrentDirectoryW(MAX_PATH, curdir); SetCurrentDirectoryW(argv0_dir); @@ -3065,6 +3069,16 @@ static void test_PathResolve(void) ret = pPathResolve(argv0_base, NULL, PRF_VERIFYEXISTS | PRF_TRYPROGRAMEXTENSIONS); ok(!ret, "resolving argv0 without extension succeeded unexpectedly, result: %s\n", wine_dbgstr_w(argv0_base)); } + + /* show that PathResolve will check specified search path, even if it's the current directory */ + lstrcpyW(argv0_base, argv0_basep); + if ((ext = wcsrchr(argv0_base, '.'))) + { + *ext = 0; + ret = pPathResolve(argv0_base, search_path, PRF_VERIFYEXISTS | PRF_TRYPROGRAMEXTENSIONS); + ok(ret, "resolving argv0 without extension with search path succeeded unexpectedly, result: %s\n", wine_dbgstr_w(argv0_base)); + } + SetCurrentDirectoryW(curdir); } else -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5342