Commit 520b7c6d authored by Yuxuan Shui's avatar Yuxuan Shui Committed by Alexandre Julliard

shell32: PathResolve(file, NULL, ...) should not look in the current directory.

Unless it's explicitly specified.
parent c6fa51a9
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment