From: Yuxuan Shui yshui@codeweavers.com
Setting dwWhich to 0xff forces extensions to be appended, even when the file name already includes an extension. This causes PathResolve to fail in some cases where the file does exist. --- dlls/shell32/shellpath.c | 4 ++-- dlls/shell32/tests/shellpath.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index 9b527b35ac4..5d7f9d48ebd 100644 --- a/dlls/shell32/shellpath.c +++ b/dlls/shell32/shellpath.c @@ -687,7 +687,7 @@ BOOL WINAPI PathFileExistsDefExtW(LPWSTR,DWORD); static BOOL PathResolveA(char *path, const char **dirs, DWORD flags) { BOOL is_file_spec = PathIsFileSpecA(path); - DWORD dwWhich = flags & PRF_DONTFINDLNK ? 0xf : 0xff; + DWORD dwWhich = flags & PRF_DONTFINDLNK ? 0xf : 0xbf;
TRACE("(%s,%p,0x%08lx)\n", debugstr_a(path), dirs, flags);
@@ -716,7 +716,7 @@ static BOOL PathResolveA(char *path, const char **dirs, DWORD flags) static BOOL PathResolveW(WCHAR *path, const WCHAR **dirs, DWORD flags) { BOOL is_file_spec = PathIsFileSpecW(path); - DWORD dwWhich = flags & PRF_DONTFINDLNK ? 0xf : 0xff; + DWORD dwWhich = flags & PRF_DONTFINDLNK ? 0xf : 0xbf;
TRACE("(%s,%p,0x%08lx)\n", debugstr_w(path), dirs, flags);
diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c index 5ed25136003..5778dcc2fc8 100644 --- a/dlls/shell32/tests/shellpath.c +++ b/dlls/shell32/tests/shellpath.c @@ -2962,6 +2962,7 @@ static void test_PathResolve(void)
/* PRF_VERIFYEXISTS */ { L"shellpath", PRF_VERIFYEXISTS, TRUE, testfile_lnk }, + { L"shellpath.lnk", PRF_VERIFYEXISTS, TRUE, testfile_lnk }, { L"C:\shellpath", PRF_VERIFYEXISTS, FALSE, L"C:\shellpath" }, /* common extensions are tried even if PRF_TRYPROGRAMEXTENSIONS isn't passed */ /* directories in dirs parameter are always searched first even if PRF_FIRSTDIRDEF isn't passed */ @@ -3071,6 +3072,10 @@ static void test_PathResolve(void) }
/* show that PathResolve will check specified search path, even if it's the current directory */ + lstrcpyW(argv0_base, argv0_basep); + ret = pPathResolve(argv0_base, search_path, PRF_VERIFYEXISTS | PRF_TRYPROGRAMEXTENSIONS); + ok(ret, "resolving argv0 with search path failed unexpectedly, result: %s\n", wine_dbgstr_w(argv0_base)); + lstrcpyW(argv0_base, argv0_basep); if ((ext = wcsrchr(argv0_base, '.'))) {