[SHELL32] Improve ShellExecCmdLine in path resolving (#2397)

Fix and improve private function shell32!ShellExecCmdLine to improve Run Dialog behavior. CORE-14409
This commit is contained in:
Katayama Hirofumi MZ
2020-03-01 19:32:33 +09:00
committed by GitHub
parent 340d9360c3
commit fc11cf78ca
2 changed files with 55 additions and 12 deletions

View File

@@ -133,12 +133,31 @@ HRESULT WINAPI ShellExecCmdLine(
else
{
pchParams = SplitParams(lpCommand, szFile, _countof(szFile));
if (SearchPathW(NULL, szFile, NULL, _countof(szFile2), szFile2, NULL) ||
SearchPathW(NULL, szFile, wszExe, _countof(szFile2), szFile2, NULL) ||
SearchPathW(NULL, szFile, wszCom, _countof(szFile2), szFile2, NULL) ||
SearchPathW(pwszStartDir, szFile, NULL, _countof(szFile2), szFile2, NULL) ||
SearchPathW(pwszStartDir, szFile, wszExe, _countof(szFile2), szFile2, NULL) ||
SearchPathW(pwszStartDir, szFile, wszCom, _countof(szFile2), szFile2, NULL))
if (szFile[0] != UNICODE_NULL && szFile[1] == L':' &&
szFile[2] == UNICODE_NULL)
{
PathAddBackslashW(szFile);
}
WCHAR szCurDir[MAX_PATH];
GetCurrentDirectoryW(_countof(szCurDir), szCurDir);
if (pwszStartDir)
{
SetCurrentDirectoryW(pwszStartDir);
}
if (PathIsRelativeW(szFile) &&
GetFullPathNameW(szFile, _countof(szFile2), szFile2, NULL) &&
PathFileExistsW(szFile2))
{
StringCchCopyW(szFile, _countof(szFile), szFile2);
}
else if (SearchPathW(NULL, szFile, NULL, _countof(szFile2), szFile2, NULL) ||
SearchPathW(NULL, szFile, wszExe, _countof(szFile2), szFile2, NULL) ||
SearchPathW(NULL, szFile, wszCom, _countof(szFile2), szFile2, NULL) ||
SearchPathW(pwszStartDir, szFile, NULL, _countof(szFile2), szFile2, NULL) ||
SearchPathW(pwszStartDir, szFile, wszExe, _countof(szFile2), szFile2, NULL) ||
SearchPathW(pwszStartDir, szFile, wszCom, _countof(szFile2), szFile2, NULL))
{
StringCchCopyW(szFile, _countof(szFile), szFile2);
}
@@ -153,6 +172,11 @@ HRESULT WINAPI ShellExecCmdLine(
pchParams = NULL;
}
if (pwszStartDir)
{
SetCurrentDirectoryW(szCurDir);
}
if (!(dwSeclFlags & SECL_ALLOW_NONEXE))
{
if (!GetBinaryTypeW(szFile, &dwType))