19#ifndef __ROS_SHELL_UTILS_H
20#define __ROS_SHELL_UTILS_H
47 szMsgStart = szMsg +
sprintf(szMsg,
"%s:%d: ", fname,
line);
59#define DbgPrint(fmt, ...) \
60 Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
63# define IID_PPV_ARG(Itype, ppType) IID_##Itype, reinterpret_cast<void**>((static_cast<Itype**>(ppType)))
64# define IID_NULL_PPV_ARG(Itype, ppType) IID_##Itype, NULL, reinterpret_cast<void**>((static_cast<Itype**>(ppType)))
66# define IID_PPV_ARG(Itype, ppType) IID_##Itype, (void**)(ppType)
67# define IID_NULL_PPV_ARG(Itype, ppType) IID_##Itype, NULL, (void**)(ppType)
88#define FAILED_UNEXPECTEDLY(hr) _ROS_FAILED_HELPER((hr), #hr, __FILE__, __LINE__)
90#define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
112 enum { user32_IDS_ERROR = 2 };
120template<
class H>
static UINT
129class CComCreatorCentralInstance
163IUnknown *CComCreatorCentralInstance<T>::s_pInstance =
NULL;
165#define DECLARE_CENTRAL_INSTANCE_NOT_AGGREGATABLE(x) \
167 typedef CComCreatorCentralInstance< ATL::CComObject<x> > _CreatorClass;
171class CComDebugObject :
public Base
174 CComDebugObject(
void * =
NULL)
176#if DEBUG_CCOMOBJECT_CREATION
182 virtual ~CComDebugObject()
184 this->FinalRelease();
185 _pAtlModule->Unlock();
190 int rc = this->InternalAddRef();
191#if DEBUG_CCOMOBJECT_REFCOUNTING
199 int rc = this->InternalRelease();
201#if DEBUG_CCOMOBJECT_REFCOUNTING
207#if DEBUG_CCOMOBJECT_DESTRUCTION
217 return this->_InternalQueryInterface(iid,
ppvObject);
220 static HRESULT WINAPI CreateInstance(CComDebugObject<Base> **pp)
222 CComDebugObject<Base> *newInstance;
231 ATLTRY(newInstance =
new CComDebugObject<Base>());
232 if (newInstance !=
NULL)
234 newInstance->SetVoid(
NULL);
235 newInstance->InternalFinalConstructAddRef();
236 hResult = newInstance->_AtlInitialConstruct();
238 hResult = newInstance->FinalConstruct();
240 hResult = newInstance->_AtlFinalConstruct();
241 newInstance->InternalFinalConstructRelease();
253#ifdef DEBUG_CCOMOBJECT
254# define _CComObject CComDebugObject
256# define _CComObject CComObject
265 T *raw = cptr.Detach();
266 int nrc =
r = raw->Release();
269 while (nrc > 0 && forceRelease)
271 nrc = raw->Release();
276#define ReleaseCComPtrExpectZero(...) ReleaseCComPtrExpectZeroHelper(__FILE__, __LINE__, __VA_ARGS__)
278template<
class T,
class R>
290 hResult =
obj->QueryInterface(
riid,
reinterpret_cast<void **
>(
ppv));
297HRESULT inline ShellObjectCreator(CComPtr<T> &objref)
299 _CComObject<T> *pobj;
300 HRESULT hResult = _CComObject<T>::CreateInstance(&pobj);
310 _CComObject<T> *pobj;
313 hResult = _CComObject<T>::CreateInstance(&pobj);
329 _CComObject<T> *pobj;
332 hResult = _CComObject<T>::CreateInstance(&pobj);
338 hResult = pobj->Initialize();
348template<
class T,
class T1>
351 _CComObject<T> *pobj;
354 hResult = _CComObject<T>::CreateInstance(&pobj);
360 hResult = pobj->Initialize(initArg1);
370template<
class T,
class T1,
class T2>
373 _CComObject<T> *pobj;
376 hResult = _CComObject<T>::CreateInstance(&pobj);
382 hResult = pobj->Initialize(initArg1, initArg2);
392template<
class T,
class T1,
class T2,
class T3>
393HRESULT inline ShellObjectCreatorInit(T1 initArg1, T2 initArg2, T3 initArg3,
REFIID riid,
void **
ppv)
395 _CComObject<T> *pobj;
398 hResult = _CComObject<T>::CreateInstance(&pobj);
404 hResult = pobj->Initialize(initArg1, initArg2, initArg3);
414template<
class T,
class T1,
class T2,
class T3,
class T4>
415HRESULT inline ShellObjectCreatorInit(T1 initArg1, T2 initArg2, T3 initArg3, T4 initArg4,
REFIID riid,
void **
ppv)
417 _CComObject<T> *pobj;
420 hResult = _CComObject<T>::CreateInstance(&pobj);
426 hResult = pobj->Initialize(initArg1, initArg2, initArg3, initArg4);
436template<
class T,
class T1,
class T2,
class T3,
class T4,
class T5>
437HRESULT inline ShellObjectCreatorInit(T1 initArg1, T2 initArg2, T3 initArg3, T4 initArg4, T5 initArg5,
REFIID riid,
void **
ppv)
439 _CComObject<T> *pobj;
442 hResult = _CComObject<T>::CreateInstance(&pobj);
448 hResult = pobj->Initialize(initArg1, initArg2, initArg3, initArg4, initArg5);
470static inline bool StrIsNullOrEmpty(
LPCSTR str) {
return !
str || !*
str; }
500 return SHSetStrRet(pStrRet,
Buffer);
554 int cb = pcidl->mkid.cb;
560 DbgPrint(
" - WARNING: cb is not a multiple of 4\n");
561 for (
i = 0; (
i + 4) <=
cb;
i += 4)
563 DbgPrint(
" - abID[%08x]: %02x %02x %02x %02x\n",
575 DbgPrint(
" - abID[%08x]: %02x %02x %02x --\n",
583 DbgPrint(
" - abID[%08x]: %02x %02x -- --\n",
590 DbgPrint(
" - abID[%08x]: %02x -- -- --\n",
618#define S_LESSTHAN 0xffff
620#define S_GREATERTHAN S_FALSE
621#define MAKE_COMPARE_HRESULT(x) ((x)>0 ? S_GREATERTHAN : ((x)<0 ? S_LESSTHAN : S_EQUAL))
623#define SEE_CMIC_COMMON_BASICFLAGS (SEE_MASK_NOASYNC | SEE_MASK_ASYNCOK | SEE_MASK_UNICODE | \
624 SEE_MASK_NO_CONSOLE | SEE_MASK_FLAG_NO_UI | SEE_MASK_FLAG_SEPVDM | \
625 SEE_MASK_FLAG_LOG_USAGE | SEE_MASK_NOZONECHECKS)
626#define SEE_CMIC_COMMON_FLAGS (SEE_CMIC_COMMON_BASICFLAGS | SEE_MASK_HOTKEY | SEE_MASK_ICON | \
627 SEE_MASK_HASLINKNAME | SEE_MASK_HASTITLE)
647#if defined(CMIC_MASK_UNICODE) && defined(SEE_MASK_UNICODE)
648static inline bool IsUnicode(
const CMINVOKECOMMANDINFOEX &ici)
651 return (ici.fMask & CMIC_MASK_UNICODE) && ici.cbSize >= minsize;
654static inline bool IsUnicode(
const CMINVOKECOMMANDINFO &ici)
656 return IsUnicode(*(CMINVOKECOMMANDINFOEX*)&ici);
664struct CDataObjectHIDA
675 m_hr = CreateCIDA(pDataObject, &m_cida, m_medium);
680 DestroyCIDA(m_cida, m_medium);
683 static void DestroyCIDA(
CIDA *pcida, STGMEDIUM &medium)
693 medium.pUnkForRelease =
NULL;
694 if (g_cfHIDA ==
NULL)
697 FORMATETC
fmt = { g_cfHIDA,
NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
707 medium.tymed = TYMED_NULL;
716 operator bool()
const
718 return m_cida !=
nullptr;
721 operator const CIDA* ()
const
726 const CIDA* operator->()
const
735 FORMATETC
fmt = { clipformat,
NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
736 STGMEDIUM medium = { TYMED_NULL };
745 if (
size <= dwBufferSize)
769 STGMEDIUM medium = { TYMED_HGLOBAL };
782 FORMATETC etc = { clipformat,
NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
796 if (g_cfShellIdListOffsets ==
NULL)
809 if (g_cfShellIdListOffsets ==
NULL)
820struct SHELL_GetSettingImpl
826#define SHELL_GetSetting(ssf, field) ( SHELL_GetSettingImpl(ssf)->field )
828#define SHELL_GetSetting(pss, ssf, field) ( SHGetSetSettings((pss), (ssf), FALSE), (pss)->field )
char * strcpy(char *DstString, const char *SrcString)
static HRESULT WINAPI CreateInstance(void *pv, REFIID riid, LPVOID *ppv)
static HRESULT WINAPI DataObject_GetData(LPDATAOBJECT iface, LPFORMATETC pformatetcIn, STGMEDIUM *pmedium)
static HRESULT WINAPI DataObject_SetData(LPDATAOBJECT iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
HRESULT SHILClone(_In_opt_ LPCITEMIDLIST pidl, _Outptr_ LPITEMIDLIST *ppidl)
GLuint GLuint GLsizei count
GLdouble GLdouble GLdouble r
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
void WINAPI SHIM_OBJ_NAME() OutputDebugStringA(LPCSTR lpOutputString)
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
HRESULT SetData([in, unique] FORMATETC *pformatetc, [in, unique] STGMEDIUM *pmedium, [in] BOOL fRelease)
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
nsresult QueryInterface(nsIIDRef riid, void **result)
#define InterlockedCompareExchangePointer
#define sprintf(buf, format,...)
static const WCHAR label[]
static DWORD DWORD void LPSTR DWORD cch
static HMODULE MODULEINFO DWORD cb
static HRESULT QueryInterface(REFIID, void **)
static const DWORD padding[]
static ULONG WINAPI AddRef(IStream *iface)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
#define DECLSPEC_SELECTANY
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
ULONG Win32DbgPrint(const char *filename, int line, const char *lpFormat,...)
#define DbgPrint(fmt,...)
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const *pida, SIZE_T i)
HRESULT HResultFromWin32(DWORD hr)
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
static UINT SHELL_ErrorBoxHelper(HWND hwndOwner, UINT Error)
static BOOL ILIsSingle(LPCITEMIDLIST pidl)
BOOL _ROS_FAILED_HELPER(HRESULT hr, const char *expr, const char *filename, int line)
static const WCHAR CFSTR_SHELLIDLISTOFFSETW[]
static const WCHAR CFSTR_SHELLIDLISTW[]
const ITEMIDLIST_ABSOLUTE UNALIGNED * PCUIDLIST_ABSOLUTE
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
#define FIELD_OFFSET(t, f)
DWORD WINAPI GetLastError(void)
#define FORMAT_MESSAGE_IGNORE_INSERTS
#define FORMAT_MESSAGE_FROM_SYSTEM
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
#define STG_E_INVALIDHANDLE
#define CLASS_E_NOAGGREGATION
#define HRESULT_FROM_WIN32(x)
#define ERROR_INTERNAL_ERROR
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
BOOL WINAPI IsWindowVisible(_In_ HWND)