Module: wine Branch: master Commit: 85d029e3b01f6dd35a86cc07796af982d66e4a03 URL: https://gitlab.winehq.org/wine/wine/-/commit/85d029e3b01f6dd35a86cc07796af98...
Author: Yuxuan Shui yshui@codeweavers.com Date: Mon Mar 18 18:32:00 2024 +0000
shell32: Rely solely on SHELL_FindExecutable for ShellExecute.
This does two things:
1. ShellExecute no longer searches in the directory where the current executable is in. 2. We always CreateProcess with a fully qualified path, so we CreateProcess won't do its own path resolution.
Serendipitously this also fixes some existing todos in tests.
---
dlls/shell32/shlexec.c | 24 +----------------------- dlls/shell32/tests/shlexec.c | 8 +++----- 2 files changed, 4 insertions(+), 28 deletions(-)
diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c index 9aa7963b71c..f09b6d4daf3 100644 --- a/dlls/shell32/shlexec.c +++ b/dlls/shell32/shlexec.c @@ -1823,30 +1823,8 @@ static BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) wcmd = malloc(len * sizeof(WCHAR)); wcmdLen = len; } - lstrcpyW(wcmd, wszApplicationName); - if (sei_tmp.lpDirectory) - { - LPCWSTR searchPath[] = { - sei_tmp.lpDirectory, - NULL - }; - PathFindOnPathW(wcmd, searchPath); - } - retval = SHELL_quote_and_execute( wcmd, wszParameters, L"", - wszApplicationName, NULL, &sei_tmp, - sei, execfunc ); - if (retval > 32) { - free(wszApplicationName); - if (wszParameters != parametersBuffer) - free(wszParameters); - if (wszDir != dirBuffer) - free(wszDir); - if (wcmd != wcmdBuffer) - free(wcmd); - return TRUE; - }
- /* Else, try to find the executable */ + /* try to find the executable */ wcmd[0] = '\0'; retval = SHELL_FindExecutable(sei_tmp.lpDirectory, lpFile, sei_tmp.lpVerb, wcmd, wcmdLen, wszKeyname, &env, sei_tmp.lpIDList, sei_tmp.lpParameters); if (retval > 32) /* Found */ diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c index 2f95ff2e15d..0f537d829f4 100644 --- a/dlls/shell32/tests/shlexec.c +++ b/dlls/shell32/tests/shlexec.c @@ -2331,9 +2331,7 @@ static void test_exes(void) if (CopyFileA(argv0, filename, FALSE)) { rc=shell_execute(NULL, filename, params, NULL); - todo_wine { - okShell(rc==SE_ERR_NOASSOC, "returned %Iu\n", rc); - } + okShell(rc==SE_ERR_NOASSOC, "returned %Iu\n", rc); } } else @@ -2359,7 +2357,7 @@ static void test_exes(void) GetCurrentDirectoryA(MAX_PATH, curdir); SetCurrentDirectoryA(tmpdir); rc = shell_execute(NULL, basename, params, NULL); - todo_wine okShell(rc == SE_ERR_FNF, "returned %Iu\n", rc); + okShell(rc == SE_ERR_FNF, "returned %Iu\n", rc); SetCurrentDirectoryA(curdir);
if (!skip_shlexec_tests) @@ -2956,7 +2954,7 @@ static void test_directory(void) NULL, "test2.exe", params, NULL, NULL); okShell(rc > 32, "returned %Iu\n", rc); okChildInt("argcA", 4); - todo_wine okChildString("argvA0", path); + okChildString("argvA0", path); okChildString("argvA3", "Exec"); okChildPath("longPath", path); SetCurrentDirectoryA(curdir);