[SHELL32] ShellExecute: Re-work Part 2 (#6882)

Follow-up to #6871. Reduce indentation level.
JIRA issue: CORE-17482
In ShellExecuteExW, early check the structure
size and return on failure before
SHCoInitializeAnyApartment call.
This commit is contained in:
Katayama Hirofumi MZ 2024-05-14 23:00:54 +09:00 committed by GitHub
parent a0776922f4
commit 3e97f76a33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2431,44 +2431,43 @@ ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
DWORD dwError;
ULONG fOldMask;
hrCoInit = SHCoInitializeAnyApartment();
if (sei->cbSize != sizeof(SHELLEXECUTEINFOW))
{
dwError = ERROR_ACCESS_DENIED;
sei->hInstApp = (HINSTANCE)ERROR_ACCESS_DENIED;
sei->hInstApp = (HINSTANCE)UlongToHandle(SE_ERR_ACCESSDENIED);
SetLastError(ERROR_ACCESS_DENIED);
return FALSE;
}
else
hrCoInit = SHCoInitializeAnyApartment();
if (SHRegGetBoolUSValueW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
L"MaximizeApps", FALSE, FALSE))
{
if (SHRegGetBoolUSValueW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
L"MaximizeApps", FALSE, FALSE))
switch (sei->nShow)
{
switch (sei->nShow)
{
case SW_SHOW:
case SW_SHOWDEFAULT:
case SW_SHOWNORMAL:
case SW_RESTORE:
sei->nShow = SW_SHOWMAXIMIZED;
break;
default:
break;
}
case SW_SHOW:
case SW_SHOWDEFAULT:
case SW_SHOWNORMAL:
case SW_RESTORE:
sei->nShow = SW_SHOWMAXIMIZED;
break;
default:
break;
}
fOldMask = sei->fMask;
if (!(fOldMask & SEE_MASK_NOASYNC) && SHELL_InRunDllProcess())
sei->fMask |= SEE_MASK_WAITFORINPUTIDLE | SEE_MASK_NOASYNC;
dwError = ShellExecute_Normal(sei);
if (dwError && dwError != ERROR_DLL_NOT_FOUND && dwError != ERROR_CANCELLED)
ShellExecute_ShowError(sei, NULL, dwError);
sei->fMask = fOldMask;
}
fOldMask = sei->fMask;
if (!(fOldMask & SEE_MASK_NOASYNC) && SHELL_InRunDllProcess())
sei->fMask |= SEE_MASK_WAITFORINPUTIDLE | SEE_MASK_NOASYNC;
dwError = ShellExecute_Normal(sei);
if (dwError && dwError != ERROR_DLL_NOT_FOUND && dwError != ERROR_CANCELLED)
ShellExecute_ShowError(sei, NULL, dwError);
sei->fMask = fOldMask;
if (SUCCEEDED(hrCoInit))
CoUninitialize();