[SHELL32] Pass correct lParam to DFM_INVOKECOMMAND (#6765)

This commit is contained in:
Whindmar Saksit 2024-08-22 21:04:48 +02:00 committed by GitHub
parent ea5728b5f3
commit 3b73d62eaa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -157,6 +157,7 @@ class CDefaultContextMenu :
WCHAR m_DefVerbs[MAX_PATH];
HRESULT _DoCallback(UINT uMsg, WPARAM wParam, LPVOID lParam);
HRESULT _DoInvokeCommandCallback(LPCMINVOKECOMMANDINFOEX lpcmi, WPARAM CmdId);
void AddStaticEntry(const HKEY hkeyClass, const WCHAR *szVerb, UINT uFlags);
void AddStaticEntriesForKey(HKEY hKey, UINT uFlags);
void TryPickDefault(HMENU hMenu, UINT idCmdFirst, UINT DfltOffset, UINT uFlags);
@ -1053,7 +1054,7 @@ HRESULT
CDefaultContextMenu::DoProperties(
LPCMINVOKECOMMANDINFOEX lpcmi)
{
HRESULT hr = _DoCallback(DFM_INVOKECOMMAND, DFM_CMD_PROPERTIES, NULL);
HRESULT hr = _DoInvokeCommandCallback(lpcmi, DFM_CMD_PROPERTIES);
// We are asked to run the default property sheet
if (hr == S_FALSE)
@ -1458,6 +1459,29 @@ CDefaultContextMenu::InvokeRegVerb(
return S_OK;
}
HRESULT
CDefaultContextMenu::_DoInvokeCommandCallback(
LPCMINVOKECOMMANDINFOEX lpcmi, WPARAM CmdId)
{
BOOL Unicode = IsUnicode(*lpcmi);
WCHAR lParamBuf[MAX_PATH];
LPARAM lParam = 0;
if (Unicode && lpcmi->lpParametersW)
lParam = (LPARAM)lpcmi->lpParametersW;
else if (lpcmi->lpParameters)
lParam = SHAnsiToUnicode(lpcmi->lpParameters, lParamBuf, _countof(lParamBuf)) ? (LPARAM)lParamBuf : 0;
HRESULT hr;
#if 0 // TODO: Try DFM_INVOKECOMMANDEX first.
DFMICS dfmics = { sizeof(DFMICS), lpcmi->fMask, lParam, m_iIdSCMFirst?, m_iIdDfltLast?, (LPCMINVOKECOMMANDINFO)lpcmi, m_site };
hr = _DoCallback(DFM_INVOKECOMMANDEX, CmdId, &dfmics);
if (hr == E_NOTIMPL)
#endif
hr = _DoCallback(DFM_INVOKECOMMAND, CmdId, (void*)lParam);
return hr;
}
HRESULT
WINAPI
CDefaultContextMenu::InvokeCommand(
@ -1498,7 +1522,7 @@ CDefaultContextMenu::InvokeCommand(
if (m_iIdCBFirst != m_iIdCBLast && CmdId >= m_iIdCBFirst && CmdId < m_iIdCBLast)
{
Result = _DoCallback(DFM_INVOKECOMMAND, CmdId - m_iIdCBFirst, NULL);
Result = _DoInvokeCommandCallback(&LocalInvokeInfo, CmdId - m_iIdCBFirst);
return Result;
}