mirror of
https://github.com/reactos/reactos.git
synced 2024-06-21 05:21:31 +00:00
[0.4.11][SHELL32] Squashed port of several RunDlg and ShellExecuteW() fixes
This is a big backport, that brings us closer to releases/0.4.14/0.4.14-release-10-g1b0b852 The main motivation is to fix the two regressions: CORE-17351 'RunDlg fails calling URL without http' and CORE-16898 'RunCommand "iexplore" fails to open Wine IE' Both regressed by 0.4.10-dev-419-gbfcbda227f
By porting back the following commits: 0.4.15-dev-2883-g33c7c91b36
CORE-17351 CORE-16898 (#3797) Improve performance of Start-Run Dialog Box Options 0.4.14-dev-1016-g4e721f780e
CORE-12266 (#1854) [SHELL32] This fixes the ERROR_DDE_FAIL in the 'www.google.de' testcase 0.4.13-dev-790-g0f16d44b66
CORE-6412 + CORE-12927 but in return we have to fix all the callers of ShellExecuteW() that relied on this ancient hack-code, and we do this by picking 0.4.13-dev-930-gcb77f1701f
CORE-16299 [SHELL32][STOBJECT] ShellExecuteW() params part2 0.4.13-dev-860-g944aba1fcc
CORE-16299 [SHELL32] ShellExecuteW() params part1 (#1833) 0.4.12-dev-94-g932a812c66
CORE-15434 [SHELL32] shlexec.cpp UNICODE_NULL Add backslash if path was like C: (#1152) 0.4.12-dev-49-gfad9f6677a
CORE-15434 [SHELL32] dialogs.cpp (#1117) Addendum 0.4.12-dev-48-gc64d31e9b8
CORE-15434 [BROWSEUI] Add backslash for directory (#1121) C: C:\
This commit is contained in:
parent
d26a5e5be8
commit
990abadd40
|
@ -159,7 +159,12 @@ HRESULT STDMETHODCALLTYPE Hotplug_Shutdown(_In_ CSysTray * pSysTray)
|
|||
|
||||
static void _RunHotplug(CSysTray * pSysTray)
|
||||
{
|
||||
ShellExecuteW(pSysTray->GetHWnd(), L"open", L"rundll32.exe shell32.dll,Control_RunDLL hotplug.dll", NULL, NULL, SW_SHOWNORMAL);
|
||||
ShellExecuteW(pSysTray->GetHWnd(),
|
||||
L"open",
|
||||
L"rundll32.exe",
|
||||
L"shell32.dll,Control_RunDLL hotplug.dll",
|
||||
NULL,
|
||||
SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
static void _ShowContextMenu(CSysTray * pSysTray)
|
||||
|
|
|
@ -216,7 +216,12 @@ HRESULT Volume_OnDeviceChange(_In_ CSysTray * pSysTray, WPARAM wParam, LPARAM lP
|
|||
|
||||
static void _RunVolume(BOOL bTray)
|
||||
{
|
||||
ShellExecuteW(NULL, NULL, bTray ? L"sndvol32.exe /t" : L"sndvol32.exe", NULL, NULL, SW_SHOWNORMAL);
|
||||
ShellExecuteW(NULL,
|
||||
NULL,
|
||||
L"sndvol32.exe",
|
||||
bTray ? L"/t" : NULL,
|
||||
NULL,
|
||||
SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
static void _RunMMCpl()
|
||||
|
|
|
@ -382,6 +382,9 @@ SHExplorerParseCmdLine(ExplorerCommandLineParseResults * pInfo)
|
|||
{
|
||||
// Or just a plain old string.
|
||||
|
||||
if (PathIsDirectoryW(strField))
|
||||
PathAddBackslash(strField);
|
||||
|
||||
WCHAR szPath[MAX_PATH];
|
||||
DWORD result = GetFullPathNameW(strField, _countof(szPath), szPath, NULL);
|
||||
|
||||
|
|
|
@ -553,6 +553,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
|||
INT ic;
|
||||
WCHAR *psz, *pszExpanded, *parent = NULL;
|
||||
DWORD cchExpand;
|
||||
SHELLEXECUTEINFOW sei;
|
||||
NMRUNFILEDLGW nmrfd;
|
||||
|
||||
ic = GetWindowTextLengthW(htxt);
|
||||
|
@ -562,6 +563,9 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
ZeroMemory(&sei, sizeof(sei));
|
||||
sei.cbSize = sizeof(sei);
|
||||
|
||||
/*
|
||||
* Allocate a new MRU entry, we need to add two characters
|
||||
* for the terminating "\\1" part, then the NULL character.
|
||||
|
@ -574,11 +578,14 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
|||
}
|
||||
|
||||
GetWindowTextW(htxt, psz, ic + 1);
|
||||
sei.hwnd = hwnd;
|
||||
sei.nShow = SW_SHOWNORMAL;
|
||||
sei.lpFile = psz;
|
||||
StrTrimW(psz, L" \t");
|
||||
|
||||
if (wcschr(psz, L'%') != NULL)
|
||||
{
|
||||
cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0) + 1;
|
||||
cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0);
|
||||
pszExpanded = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, cchExpand * sizeof(WCHAR));
|
||||
if (!pszExpanded)
|
||||
{
|
||||
|
@ -602,11 +609,20 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
|||
*/
|
||||
LPCWSTR pszStartDir;
|
||||
if (prfdp->lpstrDirectory)
|
||||
{
|
||||
sei.lpDirectory = prfdp->lpstrDirectory;
|
||||
pszStartDir = prfdp->lpstrDirectory;
|
||||
}
|
||||
else if (prfdp->uFlags & RFF_CALCDIRECTORY)
|
||||
{
|
||||
sei.lpDirectory = parent = RunDlg_GetParentDir(sei.lpFile);
|
||||
pszStartDir = parent = RunDlg_GetParentDir(pszExpanded);
|
||||
}
|
||||
else
|
||||
{
|
||||
sei.lpDirectory = NULL;
|
||||
pszStartDir = NULL;
|
||||
}
|
||||
|
||||
/* Hide the dialog for now on, we will show it up in case of retry */
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
|
@ -636,10 +652,21 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
|||
break;
|
||||
|
||||
case RF_OK:
|
||||
/* We use SECL_NO_UI because we don't want to see
|
||||
* errors here, but we will try again below and
|
||||
* there we will output our errors. */
|
||||
if (SUCCEEDED(ShellExecCmdLine(hwnd, pszExpanded, pszStartDir, SW_SHOWNORMAL, NULL,
|
||||
SECL_ALLOW_NONEXE)))
|
||||
SECL_ALLOW_NONEXE | SECL_NO_UI)))
|
||||
{
|
||||
/* Call again GetWindowText in case the contents of the edit box has changed? */
|
||||
/* Call GetWindowText again in case the contents of the edit box have changed. */
|
||||
GetWindowTextW(htxt, psz, ic + 1);
|
||||
FillList(htxt, psz, ic + 2 + 1, FALSE);
|
||||
EndDialog(hwnd, IDOK);
|
||||
break;
|
||||
}
|
||||
else if (SUCCEEDED(ShellExecuteExW(&sei)))
|
||||
{
|
||||
/* Call GetWindowText again in case the contents of the edit box have changed. */
|
||||
GetWindowTextW(htxt, psz, ic + 1);
|
||||
FillList(htxt, psz, ic + 2 + 1, FALSE);
|
||||
EndDialog(hwnd, IDOK);
|
||||
|
|
|
@ -845,8 +845,11 @@ HRESULT WINAPI CDesktopFolder::CallBack(IShellFolder *psf, HWND hwndOwner, IData
|
|||
{
|
||||
if (uMsg == DFM_INVOKECOMMAND && wParam == 0)
|
||||
{
|
||||
if (32 >= (UINT_PTR)ShellExecuteW(hwndOwner, L"open", L"rundll32.exe shell32.dll,Control_RunDLL desk.cpl", NULL, NULL, SW_SHOWNORMAL))
|
||||
if (32 >= (UINT_PTR)ShellExecuteW(hwndOwner, L"open", L"rundll32.exe",
|
||||
L"shell32.dll,Control_RunDLL desk.cpl", NULL, SW_SHOWNORMAL))
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
else if (uMsg == DFM_MERGECONTEXTMENU)
|
||||
|
|
|
@ -1087,7 +1087,12 @@ HRESULT WINAPI CDrivesFolder::CallBack(IShellFolder *psf, HWND hwndOwner, IDataO
|
|||
if (uMsg == DFM_INVOKECOMMAND && wParam == 1) // #1
|
||||
{
|
||||
// "System" properties
|
||||
ShellExecuteW(hwndOwner, NULL, L"rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl", NULL, NULL, SW_SHOWNORMAL);
|
||||
ShellExecuteW(hwndOwner,
|
||||
NULL,
|
||||
L"rundll32.exe",
|
||||
L"shell32.dll,Control_RunDLL sysdm.cpl",
|
||||
NULL,
|
||||
SW_SHOWNORMAL);
|
||||
}
|
||||
else if (uMsg == DFM_MERGECONTEXTMENU)
|
||||
{
|
||||
|
|
|
@ -41,21 +41,40 @@ HRESULT CALLBACK RegFolderContextMenuCallback(IShellFolder *psf,
|
|||
|
||||
if (_ILIsMyComputer(apidl[0]))
|
||||
{
|
||||
if (32 >= (UINT_PTR)ShellExecuteW(hwnd, L"open", L"rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl", NULL, NULL, SW_SHOWNORMAL))
|
||||
if (32 >= (UINT_PTR)ShellExecuteW(hwnd,
|
||||
L"open",
|
||||
L"rundll32.exe",
|
||||
L"shell32.dll,Control_RunDLL sysdm.cpl",
|
||||
NULL,
|
||||
SW_SHOWNORMAL))
|
||||
{
|
||||
hr = E_FAIL;
|
||||
}
|
||||
}
|
||||
else if (_ILIsDesktop(apidl[0]))
|
||||
{
|
||||
if (32 >= (UINT_PTR)ShellExecuteW(hwnd, L"open", L"rundll32.exe shell32.dll,Control_RunDLL desk.cpl", NULL, NULL, SW_SHOWNORMAL))
|
||||
if (32 >= (UINT_PTR)ShellExecuteW(hwnd,
|
||||
L"open",
|
||||
L"rundll32.exe",
|
||||
L"shell32.dll,Control_RunDLL desk.cpl",
|
||||
NULL,
|
||||
SW_SHOWNORMAL))
|
||||
{
|
||||
hr = E_FAIL;
|
||||
}
|
||||
}
|
||||
else if (_ILIsNetHood(apidl[0]))
|
||||
{
|
||||
// FIXME path!
|
||||
if (32 >= (UINT_PTR)ShellExecuteW(NULL, L"open", L"explorer.exe",
|
||||
L"::{7007ACC7-3202-11D1-AAD2-00805FC1270E}",
|
||||
NULL, SW_SHOWDEFAULT))
|
||||
if (32 >= (UINT_PTR)ShellExecuteW(NULL,
|
||||
L"open",
|
||||
L"explorer.exe",
|
||||
L"::{7007ACC7-3202-11D1-AAD2-00805FC1270E}",
|
||||
NULL,
|
||||
SW_SHOWDEFAULT))
|
||||
{
|
||||
hr = E_FAIL;
|
||||
}
|
||||
}
|
||||
else if (_ILIsBitBucket(apidl[0]))
|
||||
{
|
||||
|
|
|
@ -1042,6 +1042,22 @@ static unsigned dde_connect(const WCHAR* key, const WCHAR* start, WCHAR* ddeexec
|
|||
TRACE("Couldn't launch\n");
|
||||
goto error;
|
||||
}
|
||||
/* if ddeexec is NULL, then we just need to exit here */
|
||||
if (ddeexec == NULL)
|
||||
{
|
||||
TRACE("Exiting because ddeexec is NULL. ret=42.\n");
|
||||
/* See https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutew */
|
||||
/* for reason why we use 42 here and also "Shell32_apitest ShellExecuteW" regression test */
|
||||
return 42;
|
||||
}
|
||||
/* if ddeexec is 'empty string', then we just need to exit here */
|
||||
if (wcscmp(ddeexec, L"") == 0)
|
||||
{
|
||||
TRACE("Exiting because ddeexec is 'empty string'. ret=42.\n");
|
||||
/* See https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutew */
|
||||
/* for reason why we use 42 here and also "Shell32_apitest ShellExecuteW" regression test */
|
||||
return 42;
|
||||
}
|
||||
hConv = DdeConnect(ddeInst, hszApp, hszTopic, NULL);
|
||||
if (!hConv)
|
||||
{
|
||||
|
@ -1993,34 +2009,6 @@ static BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* If the executable name is not quoted, we have to use this search loop here,
|
||||
that in CreateProcess() is not sufficient because it does not handle shell links. */
|
||||
WCHAR buffer[MAX_PATH], xlpFile[MAX_PATH];
|
||||
LPWSTR space, s;
|
||||
|
||||
LPWSTR beg = wszApplicationName/*sei_tmp.lpFile*/;
|
||||
for(s = beg; (space = const_cast<LPWSTR>(strchrW(s, L' '))); s = space + 1)
|
||||
{
|
||||
int idx = space - sei_tmp.lpFile;
|
||||
memcpy(buffer, sei_tmp.lpFile, idx * sizeof(WCHAR));
|
||||
buffer[idx] = '\0';
|
||||
|
||||
/*FIXME This finds directory paths if the targeted file name contains spaces. */
|
||||
if (SearchPathW(*sei_tmp.lpDirectory ? sei_tmp.lpDirectory : NULL, buffer, wszExe, sizeof(xlpFile) / sizeof(xlpFile[0]), xlpFile, NULL))
|
||||
{
|
||||
/* separate out command from parameter string */
|
||||
LPCWSTR p = space + 1;
|
||||
|
||||
while(isspaceW(*p))
|
||||
++p;
|
||||
|
||||
strcpyW(wszParameters, p);
|
||||
*space = L'\0';
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lpFile = sei_tmp.lpFile;
|
||||
}
|
||||
}
|
||||
|
@ -2422,6 +2410,11 @@ HRESULT WINAPI ShellExecCmdLine(
|
|||
else
|
||||
{
|
||||
pchParams = SplitParams(lpCommand, szFile, _countof(szFile));
|
||||
if (szFile[0] != UNICODE_NULL && szFile[1] == L':' &&
|
||||
szFile[2] == UNICODE_NULL)
|
||||
{
|
||||
PathAddBackslashW(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) ||
|
||||
|
|
Loading…
Reference in a new issue