From: Yuxuan Shui yshui@codeweavers.com
Unless it's explicitly specified. --- dlls/shell32/shellpath.c | 4 ++-- dlls/shell32/tests/shellpath.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index 015d7cdd4e2..e7d4e181682 100644 --- a/dlls/shell32/shellpath.c +++ b/dlls/shell32/shellpath.c @@ -695,7 +695,7 @@ static BOOL PathResolveA(char *path, const char **dirs, DWORD flags) { if (PathFindOnPathExA(path, dirs, dwWhich)) return TRUE; - if (PathFileExistsDefExtA(path, dwWhich)) + if (!is_file_spec && PathFileExistsDefExtA(path, dwWhich)) return TRUE; if (!is_file_spec) GetFullPathNameA(path, MAX_PATH, path, NULL); SetLastError(ERROR_FILE_NOT_FOUND); @@ -724,7 +724,7 @@ static BOOL PathResolveW(WCHAR *path, const WCHAR **dirs, DWORD flags) { if (PathFindOnPathExW(path, dirs, dwWhich)) return TRUE; - if (PathFileExistsDefExtW(path, dwWhich)) + if (!is_file_spec && PathFileExistsDefExtW(path, dwWhich)) return TRUE; if (!is_file_spec) GetFullPathNameW(path, MAX_PATH, path, NULL); SetLastError(ERROR_FILE_NOT_FOUND); diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c index 29b47ac8706..c493f6882ee 100644 --- a/dlls/shell32/tests/shellpath.c +++ b/dlls/shell32/tests/shellpath.c @@ -2942,7 +2942,8 @@ if (0) { /* crashes on native */ static void test_PathResolve(void) { WCHAR testfile[MAX_PATH], testfile_lnk[MAX_PATH], regedit_in_testdir[MAX_PATH], regedit_cmd[MAX_PATH]; - WCHAR tempdir[MAX_PATH], path[MAX_PATH]; + WCHAR tempdir[MAX_PATH], path[MAX_PATH], curdir[MAX_PATH]; + WCHAR argv0_dir[MAX_PATH] = {0}, argv0_base[MAX_PATH] = {0}, *argv0_basep = NULL; const WCHAR *dirs[2] = { tempdir, NULL }; HANDLE file, file2; BOOL ret; @@ -3013,6 +3014,15 @@ static void test_PathResolve(void) return; }
+ ret = GetModuleFileNameW(NULL, argv0_dir, sizeof(argv0_dir)); + ok(ret != 0 && ret < sizeof(argv0_dir), "GetModuleFileName failed\n"); + if (ret != 0 && ret < sizeof(argv0_dir)) + { + argv0_basep = wcsrchr(argv0_dir, '\'); + *argv0_basep = 0; + argv0_basep++; + } + GetTempPathW(MAX_PATH, tempdir);
lstrcpyW(testfile, tempdir); @@ -3038,6 +3048,28 @@ 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; + lstrcpyW(argv0_base, argv0_basep); + GetCurrentDirectoryW(MAX_PATH, curdir); + SetCurrentDirectoryW(argv0_dir); + ret = pPathResolve(argv0_base, NULL, PRF_VERIFYEXISTS | PRF_TRYPROGRAMEXTENSIONS); + ok(!ret, "resolving argv0 succeeded unexpectedly, result: %s\n", wine_dbgstr_w(argv0_base)); + + lstrcpyW(argv0_base, argv0_basep); + if ((ext = wcsrchr(argv0_base, '.'))) + { + *ext = 0; + 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)); + } + SetCurrentDirectoryW(curdir); + } + else + win_skip("couldn't get module filename\n"); + for (i = 0; i < ARRAY_SIZE(tests); i++) { winetest_push_context("test %d", i);