[SHELL32] Add support for more registry verb flags and CMF flags (#5785)

- Adds support for registry controlled menu separators and the documented
  values to turn off verbs.
- Adds support for CMF_OPTIMIZEFORINVOKE, CMF_NODEFAULT, CMF_DONOTPICKDEFAULT,
  CMF_EXPLORE and CMF_DISABLEDVERBS.

Bugs fixed:

- A verb with "Extended" set in the registry could cause the menu to invoke
  the incorrect command! This happened because skipping InsertMenuItemW
  caused InvokeCommand to use the wrong index with m_StaticEntries.
- Uses IS_INTRESOURCE instead of HIWORD to check if something is a string
  (only matters on 64-bit).
- TryToBrowse leaking a PIDL when calling ILCombine.

Notes:

- This PR introduces the RosGetProcessEffectiveVersion() helper function
  discussed in chat.
- Relaxed FAILED_UNEXPECTEDLY to FAILED in two places because IContextMenu
  cannot assume that it has a site that leads to IShellBrowser.
This commit is contained in:
Whindmar Saksit 2023-11-13 16:21:13 +01:00 committed by GitHub
parent 23f31cf7b4
commit 7fb91d98f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 267 additions and 120 deletions

View file

@ -1596,16 +1596,21 @@ interface IDropTargetHelper : IUnknown
]
interface IContextMenu : IUnknown
{
cpp_quote("#define CMF_NORMAL 0x00000000")
cpp_quote("#define CMF_DEFAULTONLY 0x00000001")
cpp_quote("#define CMF_VERBSONLY 0x00000002")
cpp_quote("#define CMF_EXPLORE 0x00000004")
cpp_quote("#define CMF_NOVERBS 0x00000008")
cpp_quote("#define CMF_CANRENAME 0x00000010")
cpp_quote("#define CMF_NODEFAULT 0x00000020")
cpp_quote("#define CMF_INCLUDESTATIC 0x00000040")
cpp_quote("#define CMF_EXTENDEDVERBS 0x00000100")
cpp_quote("#define CMF_RESERVED 0xffff0000")
cpp_quote("#define CMF_NORMAL 0x00000000")
cpp_quote("#define CMF_DEFAULTONLY 0x00000001")
cpp_quote("#define CMF_VERBSONLY 0x00000002")
cpp_quote("#define CMF_EXPLORE 0x00000004")
cpp_quote("#define CMF_NOVERBS 0x00000008")
cpp_quote("#define CMF_CANRENAME 0x00000010")
cpp_quote("#define CMF_NODEFAULT 0x00000020")
cpp_quote("#define CMF_INCLUDESTATIC 0x00000040")
cpp_quote("#define CMF_EXTENDEDVERBS 0x00000100")
cpp_quote("#define CMF_DISABLEDVERBS 0x00000200")
cpp_quote("#define CMF_ASYNCVERBSTATE 0x00000400")
cpp_quote("#define CMF_OPTIMIZEFORINVOKE 0x00000800")
cpp_quote("#define CMF_SYNCCASCADEMENU 0x00001000")
cpp_quote("#define CMF_DONOTPICKDEFAULT 0x00002000")
cpp_quote("#define CMF_RESERVED 0xffff0000")
cpp_quote("#define GCS_VERBA 0x00000000")
cpp_quote("#define GCS_HELPTEXTA 0x00000001")

View file

@ -34,5 +34,16 @@ DWORD RosGetProcessCompatVersion(VOID)
return g_CompatVersion < REACTOS_COMPATVERSION_UNINITIALIZED ? g_CompatVersion : 0;
}
static
inline
UINT RosGetProcessEffectiveVersion(VOID)
{
PPEB peb = NtCurrentPeb();
UINT shimVer = RosGetProcessCompatVersion();
if (shimVer)
return shimVer;
else
return (peb->OSMajorVersion << 8) | (peb->OSMinorVersion);
}
#endif // COMPAT_UNDOC_H

View file

@ -410,6 +410,18 @@ HRESULT inline ShellObjectCreatorInit(T1 initArg1, T2 initArg2, T3 initArg3, T4
return hResult;
}
template<class P, class R> static HRESULT SHILClone(P pidl, R *ppOut)
{
R r = *ppOut = (R)ILClone((PIDLIST_RELATIVE)pidl);
return r ? S_OK : E_OUTOFMEMORY;
}
template<class B, class R> static HRESULT SHILCombine(B base, PCUIDLIST_RELATIVE sub, R *ppOut)
{
R r = *ppOut = (R)ILCombine((PCIDLIST_ABSOLUTE)base, sub);
return r ? S_OK : E_OUTOFMEMORY;
}
HRESULT inline SHSetStrRet(LPSTRRET pStrRet, LPCSTR pstrValue)
{
pStrRet->uType = STRRET_CSTR;