* Sync to Wine 1.5.4.

svn path=/trunk/; revision=56597
This commit is contained in:
Amine Khaldi 2012-05-17 15:16:51 +00:00
parent 4fb6e36502
commit fc60692086
44 changed files with 2742 additions and 2438 deletions

View file

@ -1,6 +1,4 @@
set_rc_compiler()
spec2def(ole32.dll ole32.spec ADD_IMPORTLIB)
generate_idl_iids(dcom.idl)
add_idl_headers(ole32idl dcom.idl irot.idl)
@ -13,11 +11,11 @@ add_definitions(
-D_OLE32_
-DENTRY_PREFIX=OLE32_
-DPROXY_CLSID=CLSID_PSFactoryBuffer
-DREGISTER_PROXY_DLL
-DWINE_REGISTER_DLL
-DCOM_NO_WINDOWS_H)
include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
add_rpc_files(client irot.idl)
add_rpcproxy_files(
@ -50,13 +48,12 @@ list(APPEND SOURCE
memlockbytes.c
moniker.c
ole2.c
ole2stubs.c
ole2impl.c
ole2stubs.c
ole32_main.c
oleobj.c
oleproxy.c
pointermoniker.c
regsvr.c
rpc.c
stg_prop.c
stg_stream.c
@ -75,16 +72,8 @@ list(APPEND SOURCE
${CMAKE_CURRENT_BINARY_DIR}/ole32.def)
add_library(ole32 SHARED ${SOURCE})
set_module_type(ole32 win32dll)
target_link_libraries(ole32
wine
uuid
${PSEH_LIB})
target_link_libraries(ole32 wine uuid ${PSEH_LIB})
add_importlibs(ole32 advapi32 user32 gdi32 rpcrt4 msvcrt kernel32 ntdll)
add_dependencies(ole32 ole32idl)
add_cd_file(TARGET ole32 DESTINATION reactos/system32 FOR all)

View file

@ -37,22 +37,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
/* AntiMoniker data structure */
typedef struct AntiMonikerImpl{
const IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
/* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
* two monikers are equal. That's whay IROTData interface is implemented by monikers.
*/
const IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
LONG ref; /* reference counter for this object */
IMoniker IMoniker_iface;
IROTData IROTData_iface;
LONG ref;
IUnknown *pMarshal; /* custom marshaler */
} AntiMonikerImpl;
static inline IMoniker *impl_from_IROTData( IROTData *iface )
static inline AntiMonikerImpl *impl_from_IMoniker(IMoniker *iface)
{
return (IMoniker *)((char*)iface - FIELD_OFFSET(AntiMonikerImpl, lpvtbl2));
return CONTAINING_RECORD(iface, AntiMonikerImpl, IMoniker_iface);
}
static inline AntiMonikerImpl *impl_from_IROTData(IROTData *iface)
{
return CONTAINING_RECORD(iface, AntiMonikerImpl, IROTData_iface);
}
@ -62,7 +60,7 @@ static inline IMoniker *impl_from_IROTData( IROTData *iface )
static HRESULT WINAPI
AntiMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
{
AntiMonikerImpl *This = (AntiMonikerImpl *)iface;
AntiMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
@ -80,7 +78,7 @@ AntiMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
IsEqualIID(&IID_IMoniker, riid))
*ppvObject = iface;
else if (IsEqualIID(&IID_IROTData, riid))
*ppvObject = &This->lpvtbl2;
*ppvObject = &This->IROTData_iface;
else if (IsEqualIID(&IID_IMarshal, riid))
{
HRESULT hr = S_OK;
@ -107,7 +105,7 @@ AntiMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
static ULONG WINAPI
AntiMonikerImpl_AddRef(IMoniker* iface)
{
AntiMonikerImpl *This = (AntiMonikerImpl *)iface;
AntiMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p)\n",This);
@ -120,7 +118,7 @@ AntiMonikerImpl_AddRef(IMoniker* iface)
static ULONG WINAPI
AntiMonikerImpl_Release(IMoniker* iface)
{
AntiMonikerImpl *This = (AntiMonikerImpl *)iface;
AntiMonikerImpl *This = impl_from_IMoniker(iface);
ULONG ref;
TRACE("(%p)\n",This);
@ -496,11 +494,11 @@ AntiMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
static HRESULT WINAPI
AntiMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
{
IMoniker *This = impl_from_IROTData(iface);
AntiMonikerImpl *This = impl_from_IROTData(iface);
TRACE("(%p,%p,%p)\n",iface,riid,ppvObject);
return AntiMonikerImpl_QueryInterface(This, riid, ppvObject);
return AntiMonikerImpl_QueryInterface(&This->IMoniker_iface, riid, ppvObject);
}
/***********************************************************************
@ -508,11 +506,11 @@ AntiMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObje
*/
static ULONG WINAPI AntiMonikerROTDataImpl_AddRef(IROTData *iface)
{
IMoniker *This = impl_from_IROTData(iface);
AntiMonikerImpl *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
return AntiMonikerImpl_AddRef(This);
return AntiMonikerImpl_AddRef(&This->IMoniker_iface);
}
/***********************************************************************
@ -520,11 +518,11 @@ static ULONG WINAPI AntiMonikerROTDataImpl_AddRef(IROTData *iface)
*/
static ULONG WINAPI AntiMonikerROTDataImpl_Release(IROTData* iface)
{
IMoniker *This = impl_from_IROTData(iface);
AntiMonikerImpl *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
return AntiMonikerImpl_Release(This);
return AntiMonikerImpl_Release(&This->IMoniker_iface);
}
/******************************************************************************
@ -597,8 +595,8 @@ static HRESULT AntiMonikerImpl_Construct(AntiMonikerImpl* This)
TRACE("(%p)\n",This);
/* Initialize the virtual function table. */
This->lpvtbl1 = &VT_AntiMonikerImpl;
This->lpvtbl2 = &VT_ROTDataImpl;
This->IMoniker_iface.lpVtbl = &VT_AntiMonikerImpl;
This->IROTData_iface.lpVtbl = &VT_ROTDataImpl;
This->ref = 0;
This->pMarshal = NULL;
@ -608,7 +606,7 @@ static HRESULT AntiMonikerImpl_Construct(AntiMonikerImpl* This)
/******************************************************************************
* CreateAntiMoniker [OLE32.@]
******************************************************************************/
HRESULT WINAPI CreateAntiMoniker(LPMONIKER * ppmk)
HRESULT WINAPI CreateAntiMoniker(IMoniker **ppmk)
{
AntiMonikerImpl* newAntiMoniker;
HRESULT hr;
@ -627,7 +625,8 @@ HRESULT WINAPI CreateAntiMoniker(LPMONIKER * ppmk)
return hr;
}
return AntiMonikerImpl_QueryInterface((IMoniker*)newAntiMoniker,&IID_IMoniker,(void**)ppmk);
return AntiMonikerImpl_QueryInterface(&newAntiMoniker->IMoniker_iface, &IID_IMoniker,
(void**)ppmk);
}
static HRESULT WINAPI AntiMonikerCF_QueryInterface(LPCLASSFACTORY iface,

View file

@ -49,7 +49,7 @@ typedef struct BindCtxObject{
/* BindCtx data structure */
typedef struct BindCtxImpl{
const IBindCtxVtbl *lpVtbl; /* VTable relative to the IBindCtx interface.*/
IBindCtx IBindCtx_iface;
LONG ref; /* reference counter for this object */
@ -66,13 +66,18 @@ static HRESULT WINAPI BindCtxImpl_ReleaseBoundObjects(IBindCtx*);
static HRESULT BindCtxImpl_GetObjectIndex(BindCtxImpl*, IUnknown*, LPOLESTR, DWORD *);
static HRESULT BindCtxImpl_ExpandTable(BindCtxImpl *);
static inline BindCtxImpl *impl_from_IBindCtx(IBindCtx *iface)
{
return CONTAINING_RECORD(iface, BindCtxImpl, IBindCtx_iface);
}
/*******************************************************************************
* BindCtx_QueryInterface
*******************************************************************************/
static HRESULT WINAPI
BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject)
{
BindCtxImpl *This = (BindCtxImpl *)iface;
BindCtxImpl *This = impl_from_IBindCtx(iface);
TRACE("(%p %s %p)\n",This, debugstr_guid(riid), ppvObject);
@ -100,7 +105,7 @@ BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject)
******************************************************************************/
static ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface)
{
BindCtxImpl *This = (BindCtxImpl *)iface;
BindCtxImpl *This = impl_from_IBindCtx(iface);
TRACE("(%p)\n",This);
@ -128,7 +133,7 @@ static HRESULT BindCtxImpl_Destroy(BindCtxImpl* This)
******************************************************************************/
static ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface)
{
BindCtxImpl *This = (BindCtxImpl *)iface;
BindCtxImpl *This = impl_from_IBindCtx(iface);
ULONG ref;
TRACE("(%p)\n",This);
@ -137,7 +142,7 @@ static ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface)
if (ref == 0)
{
/* release all registered objects */
BindCtxImpl_ReleaseBoundObjects((IBindCtx*)This);
BindCtxImpl_ReleaseBoundObjects(&This->IBindCtx_iface);
BindCtxImpl_Destroy(This);
}
@ -151,7 +156,7 @@ static ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface)
static HRESULT WINAPI
BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk)
{
BindCtxImpl *This = (BindCtxImpl *)iface;
BindCtxImpl *This = impl_from_IBindCtx(iface);
DWORD lastIndex=This->bindCtxTableLastIndex;
TRACE("(%p,%p)\n",This,punk);
@ -185,7 +190,7 @@ BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk)
{
DWORD index,j;
BindCtxImpl *This = (BindCtxImpl *)iface;
BindCtxImpl *This = impl_from_IBindCtx(iface);
TRACE("(%p,%p)\n",This,punk);
@ -217,7 +222,7 @@ BindCtxImpl_ReleaseBoundObjects(IBindCtx* iface)
{
DWORD i;
BindCtxImpl *This = (BindCtxImpl *)iface;
BindCtxImpl *This = impl_from_IBindCtx(iface);
TRACE("(%p)\n",This);
@ -239,7 +244,7 @@ BindCtxImpl_ReleaseBoundObjects(IBindCtx* iface)
static HRESULT WINAPI
BindCtxImpl_SetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts)
{
BindCtxImpl *This = (BindCtxImpl *)iface;
BindCtxImpl *This = impl_from_IBindCtx(iface);
TRACE("(%p,%p)\n",This,pbindopts);
@ -261,7 +266,7 @@ BindCtxImpl_SetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts)
static HRESULT WINAPI
BindCtxImpl_GetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts)
{
BindCtxImpl *This = (BindCtxImpl *)iface;
BindCtxImpl *This = impl_from_IBindCtx(iface);
ULONG cbStruct;
TRACE("(%p,%p)\n",This,pbindopts);
@ -285,7 +290,7 @@ BindCtxImpl_GetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts)
static HRESULT WINAPI
BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot)
{
BindCtxImpl *This = (BindCtxImpl *)iface;
BindCtxImpl *This = impl_from_IBindCtx(iface);
TRACE("(%p,%p)\n",This,pprot);
@ -302,7 +307,7 @@ static HRESULT WINAPI
BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk)
{
DWORD index=0;
BindCtxImpl *This = (BindCtxImpl *)iface;
BindCtxImpl *This = impl_from_IBindCtx(iface);
TRACE("(%p,%s,%p)\n",This,debugstr_w(pszkey),punk);
@ -357,7 +362,7 @@ static HRESULT WINAPI
BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown** punk)
{
DWORD index;
BindCtxImpl *This = (BindCtxImpl *)iface;
BindCtxImpl *This = impl_from_IBindCtx(iface);
TRACE("(%p,%s,%p)\n",This,debugstr_w(pszkey),punk);
@ -384,7 +389,7 @@ BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR ppenum)
{
DWORD index,j;
BindCtxImpl *This = (BindCtxImpl *)iface;
BindCtxImpl *This = impl_from_IBindCtx(iface);
TRACE("(%p,%s)\n",This,debugstr_w(ppenum));
@ -513,7 +518,7 @@ static HRESULT BindCtxImpl_Construct(BindCtxImpl* This)
TRACE("(%p)\n",This);
/* Initialize the virtual function table.*/
This->lpVtbl = &VT_BindCtxImpl;
This->IBindCtx_iface.lpVtbl = &VT_BindCtxImpl;
This->ref = 0;
/* Initialize the BIND_OPTS2 structure */
@ -577,7 +582,7 @@ HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC * ppbc)
return hr;
}
return BindCtxImpl_QueryInterface((IBindCtx*)newBindCtx,&IID_IBindCtx,(void**)ppbc);
return BindCtxImpl_QueryInterface(&newBindCtx->IBindCtx_iface,&IID_IBindCtx,(void**)ppbc);
}
/******************************************************************************

View file

@ -43,16 +43,21 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
/* ClassMoniker data structure */
typedef struct ClassMoniker
{
const IMonikerVtbl* lpVtbl; /* VTable relative to the IMoniker interface.*/
const IROTDataVtbl* lpVtblRotData; /* VTable relative to the IROTData interface.*/
LONG ref; /* reference counter for this object */
IMoniker IMoniker_iface;
IROTData IROTData_iface;
LONG ref;
CLSID clsid; /* clsid identified by this moniker */
IUnknown *pMarshal; /* custom marshaler */
} ClassMoniker;
static inline IMoniker *impl_from_IROTData( IROTData *iface )
static inline ClassMoniker *impl_from_IMoniker(IMoniker *iface)
{
return (IMoniker *)((char*)iface - FIELD_OFFSET(ClassMoniker, lpVtblRotData));
return CONTAINING_RECORD(iface, ClassMoniker, IMoniker_iface);
}
static inline ClassMoniker *impl_from_IROTData(IROTData *iface)
{
return CONTAINING_RECORD(iface, ClassMoniker, IROTData_iface);
}
/*******************************************************************************
@ -60,7 +65,7 @@ static inline IMoniker *impl_from_IROTData( IROTData *iface )
*******************************************************************************/
static HRESULT WINAPI ClassMoniker_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
{
ClassMoniker *This = (ClassMoniker *)iface;
ClassMoniker *This = impl_from_IMoniker(iface);
TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
@ -80,7 +85,7 @@ static HRESULT WINAPI ClassMoniker_QueryInterface(IMoniker* iface,REFIID riid,vo
*ppvObject = iface;
}
else if (IsEqualIID(&IID_IROTData, riid))
*ppvObject = &This->lpVtblRotData;
*ppvObject = &This->IROTData_iface;
else if (IsEqualIID(&IID_IMarshal, riid))
{
HRESULT hr = S_OK;
@ -106,7 +111,7 @@ static HRESULT WINAPI ClassMoniker_QueryInterface(IMoniker* iface,REFIID riid,vo
******************************************************************************/
static ULONG WINAPI ClassMoniker_AddRef(IMoniker* iface)
{
ClassMoniker *This = (ClassMoniker *)iface;
ClassMoniker *This = impl_from_IMoniker(iface);
TRACE("(%p)\n",This);
@ -132,7 +137,7 @@ static HRESULT ClassMoniker_Destroy(ClassMoniker* This)
******************************************************************************/
static ULONG WINAPI ClassMoniker_Release(IMoniker* iface)
{
ClassMoniker *This = (ClassMoniker *)iface;
ClassMoniker *This = impl_from_IMoniker(iface);
ULONG ref;
TRACE("(%p)\n",This);
@ -179,7 +184,7 @@ static HRESULT WINAPI ClassMoniker_IsDirty(IMoniker* iface)
******************************************************************************/
static HRESULT WINAPI ClassMoniker_Load(IMoniker* iface,IStream* pStm)
{
ClassMoniker *This = (ClassMoniker *)iface;
ClassMoniker *This = impl_from_IMoniker(iface);
HRESULT hr;
DWORD zero;
@ -197,11 +202,9 @@ static HRESULT WINAPI ClassMoniker_Load(IMoniker* iface,IStream* pStm)
/******************************************************************************
* ClassMoniker_Save
******************************************************************************/
static HRESULT WINAPI ClassMoniker_Save(IMoniker* iface,
IStream* pStm,/* pointer to the stream where the object is to be saved */
BOOL fClearDirty)/* Specifies whether to clear the dirty flag */
static HRESULT WINAPI ClassMoniker_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
{
ClassMoniker *This = (ClassMoniker *)iface;
ClassMoniker *This = impl_from_IMoniker(iface);
HRESULT hr;
DWORD zero = 0;
@ -235,7 +238,7 @@ static HRESULT WINAPI ClassMoniker_BindToObject(IMoniker* iface,
REFIID riid,
VOID** ppvResult)
{
ClassMoniker *This = (ClassMoniker *)iface;
ClassMoniker *This = impl_from_IMoniker(iface);
BIND_OPTS2 bindopts;
IClassActivator *pActivator;
HRESULT hr;
@ -425,7 +428,7 @@ static HRESULT WINAPI ClassMoniker_IsEqual(IMoniker* iface,IMoniker* pmkOtherMon
******************************************************************************/
static HRESULT WINAPI ClassMoniker_Hash(IMoniker* iface,DWORD* pdwHash)
{
ClassMoniker *This = (ClassMoniker *)iface;
ClassMoniker *This = impl_from_IMoniker(iface);
TRACE("(%p)\n", pdwHash);
@ -532,7 +535,7 @@ static HRESULT WINAPI ClassMoniker_GetDisplayName(IMoniker* iface,
IMoniker* pmkToLeft,
LPOLESTR *ppszDisplayName)
{
ClassMoniker *This = (ClassMoniker *)iface;
ClassMoniker *This = impl_from_IMoniker(iface);
static const WCHAR wszClsidPrefix[] = {'c','l','s','i','d',':',0};
TRACE("(%p, %p, %p)\n", pbc, pmkToLeft, ppszDisplayName);
@ -593,11 +596,11 @@ static HRESULT WINAPI ClassMoniker_IsSystemMoniker(IMoniker* iface,DWORD* pwdMks
static HRESULT WINAPI ClassMonikerROTData_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
{
IMoniker *This = impl_from_IROTData(iface);
ClassMoniker *This = impl_from_IROTData(iface);
TRACE("(%p,%p,%p)\n",iface,riid,ppvObject);
return ClassMoniker_QueryInterface(This, riid, ppvObject);
return ClassMoniker_QueryInterface(&This->IMoniker_iface, riid, ppvObject);
}
/***********************************************************************
@ -605,11 +608,11 @@ static HRESULT WINAPI ClassMonikerROTData_QueryInterface(IROTData *iface,REFIID
*/
static ULONG WINAPI ClassMonikerROTData_AddRef(IROTData *iface)
{
IMoniker *This = impl_from_IROTData(iface);
ClassMoniker *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
return ClassMoniker_AddRef(This);
return ClassMoniker_AddRef(&This->IMoniker_iface);
}
/***********************************************************************
@ -617,11 +620,11 @@ static ULONG WINAPI ClassMonikerROTData_AddRef(IROTData *iface)
*/
static ULONG WINAPI ClassMonikerROTData_Release(IROTData* iface)
{
IMoniker *This = impl_from_IROTData(iface);
ClassMoniker *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
return ClassMoniker_Release(This);
return ClassMoniker_Release(&This->IMoniker_iface);
}
/******************************************************************************
@ -632,7 +635,7 @@ static HRESULT WINAPI ClassMonikerROTData_GetComparisonData(IROTData* iface,
ULONG cbMax,
ULONG* pcbData)
{
ClassMoniker *This = (ClassMoniker *)impl_from_IROTData(iface);
ClassMoniker *This = impl_from_IROTData(iface);
TRACE("(%p, %u, %p)\n", pbData, cbMax, pcbData);
@ -696,8 +699,8 @@ static HRESULT ClassMoniker_Construct(ClassMoniker* This, REFCLSID rclsid)
TRACE("(%p,%s)\n",This,debugstr_guid(rclsid));
/* Initialize the virtual function table. */
This->lpVtbl = &ClassMonikerVtbl;
This->lpVtblRotData = &ROTDataVtbl;
This->IMoniker_iface.lpVtbl = &ClassMonikerVtbl;
This->IROTData_iface.lpVtbl = &ROTDataVtbl;
This->ref = 0;
This->clsid = *rclsid;
This->pMarshal = NULL;
@ -728,11 +731,12 @@ HRESULT WINAPI CreateClassMoniker(REFCLSID rclsid, IMoniker **ppmk)
return hr;
}
return ClassMoniker_QueryInterface((IMoniker *)newClassMoniker, &IID_IMoniker, (void**)ppmk);
return ClassMoniker_QueryInterface(&newClassMoniker->IMoniker_iface, &IID_IMoniker,
(void**)ppmk);
}
HRESULT ClassMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
LPDWORD pchEaten, LPMONIKER *ppmk)
HRESULT ClassMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName, LPDWORD pchEaten,
IMoniker **ppmk)
{
HRESULT hr;
LPCWSTR s = strchrW(szDisplayName, ':');

View file

@ -138,7 +138,7 @@ static inline DWORD_PTR td_get_offs(ole_priv_data *data, DWORD idx)
*/
typedef struct snapshot
{
const IDataObjectVtbl* lpVtbl;
IDataObject IDataObject_iface;
LONG ref;
DWORD seq_no; /* Clipboard sequence number corresponding to this snapshot */
@ -161,7 +161,7 @@ typedef struct ole_clipbrd
static inline snapshot *impl_from_IDataObject(IDataObject *iface)
{
return (snapshot*)((char*)iface - FIELD_OFFSET(snapshot, lpVtbl));
return CONTAINING_RECORD(iface, snapshot, IDataObject_iface);
}
typedef struct PresentationDataHeader
@ -226,7 +226,7 @@ static inline char *dump_fmtetc(FORMATETC *fmt)
typedef struct enum_fmtetc
{
const IEnumFORMATETCVtbl *lpVtbl;
IEnumFORMATETC IEnumFORMATETC_iface;
LONG ref;
UINT pos; /* current enumerator position */
@ -235,7 +235,7 @@ typedef struct enum_fmtetc
static inline enum_fmtetc *impl_from_IEnumFORMATETC(IEnumFORMATETC *iface)
{
return (enum_fmtetc*)((char*)iface - FIELD_OFFSET(enum_fmtetc, lpVtbl));
return CONTAINING_RECORD(iface, enum_fmtetc, IEnumFORMATETC_iface);
}
/************************************************************************
@ -440,12 +440,12 @@ static HRESULT enum_fmtetc_construct(ole_priv_data *data, UINT pos, IEnumFORMATE
if (!ef) return E_OUTOFMEMORY;
ef->ref = 1;
ef->lpVtbl = &efvt;
ef->IEnumFORMATETC_iface.lpVtbl = &efvt;
ef->data = data;
ef->pos = pos;
TRACE("(%p)->()\n", ef);
*obj = (IEnumFORMATETC *)ef;
*obj = &ef->IEnumFORMATETC_iface;
return S_OK;
}
@ -478,6 +478,92 @@ static HRESULT dup_global_mem( HGLOBAL src, DWORD flags, HGLOBAL *dst )
return S_OK;
}
/***********************************************************************
* dup_metafilepict
*
* Helper function to duplicate a handle to a METAFILEPICT, and the
* contained HMETAFILE.
*/
static HRESULT dup_metafilepict(HGLOBAL src, HGLOBAL *pdest)
{
HRESULT hr;
HGLOBAL dest;
METAFILEPICT *dest_ptr;
*pdest = NULL;
/* Copy the METAFILEPICT structure. */
hr = dup_global_mem(src, GMEM_DDESHARE|GMEM_MOVEABLE, &dest);
if (FAILED(hr)) return hr;
dest_ptr = GlobalLock(dest);
if (!dest_ptr) return E_FAIL;
/* Give the new METAFILEPICT a separate HMETAFILE. */
dest_ptr->hMF = CopyMetaFileW(dest_ptr->hMF, NULL);
if (dest_ptr->hMF)
{
GlobalUnlock(dest);
*pdest = dest;
return S_OK;
}
else
{
GlobalUnlock(dest);
GlobalFree(dest);
return E_FAIL;
}
}
/***********************************************************************
* free_metafilepict
*
* Helper function to GlobalFree a handle to a METAFILEPICT, and also
* free the contained HMETAFILE.
*/
static void free_metafilepict(HGLOBAL src)
{
METAFILEPICT *src_ptr;
src_ptr = GlobalLock(src);
if (src_ptr)
{
DeleteMetaFile(src_ptr->hMF);
GlobalUnlock(src);
}
GlobalFree(src);
}
/***********************************************************************
* dup_bitmap
*
* Helper function to duplicate an HBITMAP.
*/
static HRESULT dup_bitmap(HBITMAP src, HBITMAP *pdest)
{
HDC src_dc;
HGDIOBJ orig_src_bitmap;
BITMAP bm;
HBITMAP dest;
src_dc = CreateCompatibleDC(NULL);
orig_src_bitmap = SelectObject(src_dc, src);
GetObjectW(src, sizeof bm, &bm);
dest = CreateCompatibleBitmap(src_dc, bm.bmWidth, bm.bmHeight);
if (dest)
{
HDC dest_dc = CreateCompatibleDC(NULL);
HGDIOBJ orig_dest_bitmap = SelectObject(dest_dc, dest);
BitBlt(dest_dc, 0, 0, bm.bmWidth, bm.bmHeight, src_dc, 0, 0, SRCCOPY);
SelectObject(dest_dc, orig_dest_bitmap);
DeleteDC(dest_dc);
}
SelectObject(src_dc, orig_src_bitmap);
DeleteDC(src_dc);
*pdest = dest;
return dest ? S_OK : E_FAIL;
}
/************************************************************
* render_embed_source_hack
*
@ -744,6 +830,9 @@ static HRESULT get_data_from_global(IDataObject *data, FORMATETC *fmt, HGLOBAL *
return hr;
}
/***************************************************************************
* get_data_from_enhmetafile
*/
static HRESULT get_data_from_enhmetafile(IDataObject *data, FORMATETC *fmt, HGLOBAL *mem)
{
HENHMETAFILE copy;
@ -768,6 +857,62 @@ static HRESULT get_data_from_enhmetafile(IDataObject *data, FORMATETC *fmt, HGLO
return hr;
}
/***************************************************************************
* get_data_from_metafilepict
*/
static HRESULT get_data_from_metafilepict(IDataObject *data, FORMATETC *fmt, HGLOBAL *mem)
{
HGLOBAL copy;
HRESULT hr;
FORMATETC mem_fmt;
STGMEDIUM med;
*mem = NULL;
mem_fmt = *fmt;
mem_fmt.tymed = TYMED_MFPICT;
hr = IDataObject_GetData(data, &mem_fmt, &med);
if(FAILED(hr)) return hr;
hr = dup_metafilepict(med.u.hMetaFilePict, &copy);
if(SUCCEEDED(hr)) *mem = copy;
ReleaseStgMedium(&med);
return hr;
}
/***************************************************************************
* get_data_from_bitmap
*
* Returns bitmap in an HBITMAP.
*/
static HRESULT get_data_from_bitmap(IDataObject *data, FORMATETC *fmt, HBITMAP *hbm)
{
HBITMAP copy;
HRESULT hr;
FORMATETC mem_fmt;
STGMEDIUM med;
*hbm = NULL;
mem_fmt = *fmt;
mem_fmt.tymed = TYMED_GDI;
hr = IDataObject_GetData(data, &mem_fmt, &med);
if(FAILED(hr)) return hr;
hr = dup_bitmap(med.u.hBitmap, &copy);
if(SUCCEEDED(hr)) *hbm = copy;
ReleaseStgMedium(&med);
return hr;
}
/***********************************************************************
* render_format
*
@ -776,7 +921,7 @@ static HRESULT get_data_from_enhmetafile(IDataObject *data, FORMATETC *fmt, HGLO
*/
static HRESULT render_format(IDataObject *data, LPFORMATETC fmt)
{
HGLOBAL clip_data = NULL;
HANDLE clip_data = NULL; /* HGLOBAL unless otherwise specified */
HRESULT hr;
/* Embed source hack */
@ -801,6 +946,16 @@ static HRESULT render_format(IDataObject *data, LPFORMATETC fmt)
{
hr = get_data_from_enhmetafile(data, fmt, &clip_data);
}
else if(fmt->tymed & TYMED_MFPICT)
{
/* Returns global handle to METAFILEPICT, containing a copied HMETAFILE */
hr = get_data_from_metafilepict(data, fmt, &clip_data);
}
else if(fmt->tymed & TYMED_GDI)
{
/* Returns HBITMAP not HGLOBAL */
hr = get_data_from_bitmap(data, fmt, (HBITMAP *)&clip_data);
}
else
{
FIXME("Unhandled tymed %x\n", fmt->tymed);
@ -812,7 +967,12 @@ static HRESULT render_format(IDataObject *data, LPFORMATETC fmt)
if ( !SetClipboardData(fmt->cfFormat, clip_data) )
{
WARN("() : Failed to set rendered clipboard data into clipboard!\n");
GlobalFree(clip_data);
if(fmt->tymed & TYMED_MFPICT)
free_metafilepict(clip_data);
else if(fmt->tymed & TYMED_GDI)
DeleteObject(clip_data);
else
GlobalFree(clip_data);
hr = CLIPBRD_E_CANT_SET;
}
}
@ -1501,7 +1661,7 @@ static snapshot *snapshot_construct(DWORD seq_no)
This = HeapAlloc( GetProcessHeap(), 0, sizeof(*This) );
if (!This) return NULL;
This->lpVtbl = &snapshot_vtable;
This->IDataObject_iface.lpVtbl = &snapshot_vtable;
This->ref = 0;
This->seq_no = seq_no;
This->data = NULL;
@ -2016,7 +2176,7 @@ HRESULT WINAPI OleGetClipboard(IDataObject **obj)
if(!clipbrd->latest_snapshot) return E_OUTOFMEMORY;
}
*obj = (IDataObject*)&clipbrd->latest_snapshot->lpVtbl;
*obj = &clipbrd->latest_snapshot->IDataObject_iface;
IDataObject_AddRef(*obj);
return S_OK;

View file

@ -36,18 +36,28 @@
WINE_DEFAULT_DEBUG_CHANNEL(ole);
static const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl;
static const ICatInformationVtbl COMCAT_ICatInformation_Vtbl;
typedef struct
{
const ICatRegisterVtbl *lpVtbl;
const ICatInformationVtbl *infVtbl;
ICatRegister ICatRegister_iface;
ICatInformation ICatInformation_iface;
} ComCatMgrImpl;
/* static ComCatMgr instance */
static ComCatMgrImpl COMCAT_ComCatMgr =
{
{ &COMCAT_ICatRegister_Vtbl },
{ &COMCAT_ICatInformation_Vtbl }
};
struct class_categories {
LPCWSTR impl_strings;
LPCWSTR req_strings;
};
static LPENUMCATEGORYINFO COMCAT_IEnumCATEGORYINFO_Construct(LCID lcid);
static IEnumCATEGORYINFO *COMCAT_IEnumCATEGORYINFO_Construct(LCID lcid);
static LPENUMGUID COMCAT_CLSID_IEnumGUID_Construct(struct class_categories *class_categories);
static LPENUMGUID COMCAT_CATID_IEnumGUID_Construct(REFCLSID rclsid, LPCWSTR impl_req);
@ -63,12 +73,6 @@ static const WCHAR req_keyname[] = {
static const WCHAR clsid_keyname[] = { 'C','L','S','I','D',0 };
static inline ComCatMgrImpl *impl_from_ICatInformation( ICatInformation *iface )
{
return (ComCatMgrImpl *)((char*)iface - FIELD_OFFSET(ComCatMgrImpl, infVtbl));
}
/**********************************************************************
* COMCAT_RegisterClassCategories
*/
@ -279,20 +283,19 @@ static HRESULT WINAPI COMCAT_ICatRegister_QueryInterface(
REFIID riid,
LPVOID *ppvObj)
{
ComCatMgrImpl *This = (ComCatMgrImpl *)iface;
TRACE("%s\n",debugstr_guid(riid));
if (ppvObj == NULL) return E_POINTER;
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ICatRegister)) {
*ppvObj = iface;
IUnknown_AddRef(iface);
ICatRegister_AddRef(iface);
return S_OK;
}
if (IsEqualGUID(riid, &IID_ICatInformation)) {
*ppvObj = &This->infVtbl;
IUnknown_AddRef(iface);
*ppvObj = &COMCAT_ComCatMgr.ICatInformation_iface;
ICatRegister_AddRef(iface);
return S_OK;
}
@ -462,8 +465,7 @@ static HRESULT WINAPI COMCAT_ICatInformation_QueryInterface(
REFIID riid,
LPVOID *ppvObj)
{
ComCatMgrImpl *This = impl_from_ICatInformation( iface );
return IUnknown_QueryInterface((LPUNKNOWN)This, riid, ppvObj);
return ICatRegister_QueryInterface(&COMCAT_ComCatMgr.ICatRegister_iface, riid, ppvObj);
}
/**********************************************************************
@ -471,8 +473,7 @@ static HRESULT WINAPI COMCAT_ICatInformation_QueryInterface(
*/
static ULONG WINAPI COMCAT_ICatInformation_AddRef(LPCATINFORMATION iface)
{
ComCatMgrImpl *This = impl_from_ICatInformation( iface );
return IUnknown_AddRef((LPUNKNOWN)This);
return ICatRegister_AddRef(&COMCAT_ComCatMgr.ICatRegister_iface);
}
/**********************************************************************
@ -480,8 +481,7 @@ static ULONG WINAPI COMCAT_ICatInformation_AddRef(LPCATINFORMATION iface)
*/
static ULONG WINAPI COMCAT_ICatInformation_Release(LPCATINFORMATION iface)
{
ComCatMgrImpl *This = impl_from_ICatInformation( iface );
return IUnknown_Release((LPUNKNOWN)This);
return ICatRegister_Release(&COMCAT_ComCatMgr.ICatRegister_iface);
}
/**********************************************************************
@ -490,7 +490,7 @@ static ULONG WINAPI COMCAT_ICatInformation_Release(LPCATINFORMATION iface)
static HRESULT WINAPI COMCAT_ICatInformation_EnumCategories(
LPCATINFORMATION iface,
LCID lcid,
LPENUMCATEGORYINFO *ppenumCatInfo)
IEnumCATEGORYINFO **ppenumCatInfo)
{
TRACE("\n");
@ -596,7 +596,7 @@ static HRESULT WINAPI COMCAT_ICatInformation_IsClassOfCategories(
struct class_categories *categories;
HKEY key;
if (WINE_TRACE_ON(ole)) {
if (TRACE_ON(ole)) {
ULONG count;
TRACE("CLSID: %s Implemented %u\n",debugstr_guid(rclsid),cImplemented);
for (count = 0; count < cImplemented; ++count)
@ -635,7 +635,7 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumImplCategoriesOfClass(
REFCLSID rclsid,
LPENUMCATID *ppenumCATID)
{
static const WCHAR postfix[24] = { '\\', 'I', 'm', 'p', 'l', 'e', 'm', 'e',
static const WCHAR postfix[] = { '\\', 'I', 'm', 'p', 'l', 'e', 'm', 'e',
'n', 't', 'e', 'd', ' ', 'C', 'a', 't',
'e', 'g', 'o', 'r', 'i', 'e', 's', 0 };
@ -657,7 +657,7 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumReqCategoriesOfClass(
REFCLSID rclsid,
LPENUMCATID *ppenumCATID)
{
static const WCHAR postfix[21] = { '\\', 'R', 'e', 'q', 'u', 'i', 'r', 'e',
static const WCHAR postfix[] = { '\\', 'R', 'e', 'q', 'u', 'i', 'r', 'e',
'd', ' ', 'C', 'a', 't', 'e', 'g', 'o',
'r', 'i', 'e', 's', 0 };
@ -704,15 +704,6 @@ static const ICatInformationVtbl COMCAT_ICatInformation_Vtbl =
COMCAT_ICatInformation_EnumReqCategoriesOfClass
};
/**********************************************************************
* static ComCatMgr instance
*/
static ComCatMgrImpl COMCAT_ComCatMgr =
{
&COMCAT_ICatRegister_Vtbl,
&COMCAT_ICatInformation_Vtbl
};
/**********************************************************************
* COMCAT_IClassFactory_QueryInterface (also IUnknown)
*/
@ -769,7 +760,7 @@ static HRESULT WINAPI COMCAT_IClassFactory_CreateInstance(
/* Don't support aggregation (Windows doesn't) */
if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
res = IUnknown_QueryInterface((LPUNKNOWN)&COMCAT_ComCatMgr, riid, ppvObj);
res = ICatRegister_QueryInterface(&COMCAT_ComCatMgr.ICatRegister_iface, riid, ppvObj);
if (SUCCEEDED(res)) {
return res;
}
@ -815,16 +806,21 @@ HRESULT ComCatCF_Create(REFIID riid, LPVOID *ppv)
*/
typedef struct
{
const IEnumCATEGORYINFOVtbl *lpVtbl;
IEnumCATEGORYINFO IEnumCATEGORYINFO_iface;
LONG ref;
LCID lcid;
HKEY key;
DWORD next_index;
} IEnumCATEGORYINFOImpl;
static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_AddRef(LPENUMCATEGORYINFO iface)
static inline IEnumCATEGORYINFOImpl *impl_from_IEnumCATEGORYINFO(IEnumCATEGORYINFO *iface)
{
IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface;
return CONTAINING_RECORD(iface, IEnumCATEGORYINFOImpl, IEnumCATEGORYINFO_iface);
}
static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_AddRef(IEnumCATEGORYINFO *iface)
{
IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
TRACE("\n");
@ -832,7 +828,7 @@ static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_AddRef(LPENUMCATEGORYINFO iface)
}
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_QueryInterface(
LPENUMCATEGORYINFO iface,
IEnumCATEGORYINFO *iface,
REFIID riid,
LPVOID *ppvObj)
{
@ -851,9 +847,9 @@ static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_QueryInterface(
return E_NOINTERFACE;
}
static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_Release(LPENUMCATEGORYINFO iface)
static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_Release(IEnumCATEGORYINFO *iface)
{
IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface;
IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
ULONG ref;
TRACE("\n");
@ -868,12 +864,12 @@ static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_Release(LPENUMCATEGORYINFO iface)
}
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Next(
LPENUMCATEGORYINFO iface,
IEnumCATEGORYINFO *iface,
ULONG celt,
CATEGORYINFO *rgelt,
ULONG *pceltFetched)
{
IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface;
IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
ULONG fetched = 0;
TRACE("\n");
@ -913,10 +909,10 @@ static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Next(
}
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Skip(
LPENUMCATEGORYINFO iface,
IEnumCATEGORYINFO *iface,
ULONG celt)
{
IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface;
IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
TRACE("\n");
@ -925,9 +921,9 @@ static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Skip(
return S_OK;
}
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Reset(LPENUMCATEGORYINFO iface)
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Reset(IEnumCATEGORYINFO *iface)
{
IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface;
IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
TRACE("\n");
@ -936,10 +932,10 @@ static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Reset(LPENUMCATEGORYINFO iface)
}
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Clone(
LPENUMCATEGORYINFO iface,
IEnumCATEGORYINFO *iface,
IEnumCATEGORYINFO **ppenum)
{
IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface;
IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
static const WCHAR keyname[] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n',
't', ' ', 'C', 'a', 't', 'e', 'g', 'o',
'r', 'i', 'e', 's', 0 };
@ -952,14 +948,14 @@ static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Clone(
new_this = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumCATEGORYINFOImpl));
if (new_this == NULL) return E_OUTOFMEMORY;
new_this->lpVtbl = This->lpVtbl;
new_this->IEnumCATEGORYINFO_iface = This->IEnumCATEGORYINFO_iface;
new_this->ref = 1;
new_this->lcid = This->lcid;
/* FIXME: could we more efficiently use DuplicateHandle? */
RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &new_this->key);
new_this->next_index = This->next_index;
*ppenum = (LPENUMCATEGORYINFO)new_this;
*ppenum = &new_this->IEnumCATEGORYINFO_iface;
return S_OK;
}
@ -974,7 +970,7 @@ static const IEnumCATEGORYINFOVtbl COMCAT_IEnumCATEGORYINFO_Vtbl =
COMCAT_IEnumCATEGORYINFO_Clone
};
static LPENUMCATEGORYINFO COMCAT_IEnumCATEGORYINFO_Construct(LCID lcid)
static IEnumCATEGORYINFO *COMCAT_IEnumCATEGORYINFO_Construct(LCID lcid)
{
IEnumCATEGORYINFOImpl *This;
@ -984,11 +980,11 @@ static LPENUMCATEGORYINFO COMCAT_IEnumCATEGORYINFO_Construct(LCID lcid)
't', ' ', 'C', 'a', 't', 'e', 'g', 'o',
'r', 'i', 'e', 's', 0 };
This->lpVtbl = &COMCAT_IEnumCATEGORYINFO_Vtbl;
This->IEnumCATEGORYINFO_iface.lpVtbl = &COMCAT_IEnumCATEGORYINFO_Vtbl;
This->lcid = lcid;
RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &This->key);
}
return (LPENUMCATEGORYINFO)This;
return &This->IEnumCATEGORYINFO_iface;
}
/**********************************************************************
@ -1337,7 +1333,7 @@ static LPENUMGUID COMCAT_CATID_IEnumGUID_Construct(
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CATID_IEnumGUIDImpl));
if (This) {
WCHAR prefix[6] = { 'C', 'L', 'S', 'I', 'D', '\\' };
WCHAR prefix[] = { 'C', 'L', 'S', 'I', 'D', '\\' };
This->lpVtbl = &COMCAT_CATID_IEnumGUID_Vtbl;
memcpy(This->keyname, prefix, sizeof(prefix));

View file

@ -59,7 +59,9 @@
#include "ctxtcall.h"
#include "dde.h"
#include "initguid.h"
#include "compobj_private.h"
#include "moniker.h"
#include "wine/unicode.h"
#include "wine/debug.h"
@ -68,6 +70,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
#define ARRAYSIZE(array) (sizeof(array)/sizeof((array)[0]))
#ifdef _MSC_VER
DEFINE_GUID(CLSID_PSFactoryBuffer, 0x00000320, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
#endif
/****************************************************************************
* This section defines variables internal to the COM module.
*/
@ -306,6 +312,7 @@ static void COMPOBJ_DllList_Free(void)
HeapFree(GetProcessHeap(), 0, entry);
}
LeaveCriticalSection(&csOpenDllList);
DeleteCriticalSection(&csOpenDllList);
}
/******************************************************************************
@ -456,6 +463,116 @@ static void COM_RevokeAllClasses(const struct apartment *apt)
LeaveCriticalSection( &csRegisteredClassList );
}
/******************************************************************************
* Implementation of the manual reset event object. (CLSID_ManualResetEvent)
*/
typedef struct ManualResetEvent {
ISynchronize ISynchronize_iface;
LONG ref;
HANDLE event;
} MREImpl;
static inline MREImpl *impl_from_ISynchronize(ISynchronize *iface)
{
return CONTAINING_RECORD(iface, MREImpl, ISynchronize_iface);
}
static HRESULT WINAPI ISynchronize_fnQueryInterface(ISynchronize *iface, REFIID riid, void **ppv)
{
MREImpl *This = impl_from_ISynchronize(iface);
TRACE("%p (%s, %p)\n", This, debugstr_guid(riid), ppv);
*ppv = NULL;
if(IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_ISynchronize))
*ppv = This;
else
ERR("Unknown interface %s requested.\n", debugstr_guid(riid));
if(*ppv)
{
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
return E_NOINTERFACE;
}
static ULONG WINAPI ISynchronize_fnAddRef(ISynchronize *iface)
{
MREImpl *This = impl_from_ISynchronize(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("%p - ref %d\n", This, ref);
return ref;
}
static ULONG WINAPI ISynchronize_fnRelease(ISynchronize *iface)
{
MREImpl *This = impl_from_ISynchronize(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("%p - ref %d\n", This, ref);
if(!ref)
{
CloseHandle(This->event);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
static HRESULT WINAPI ISynchronize_fnWait(ISynchronize *iface, DWORD dwFlags, DWORD dwMilliseconds)
{
MREImpl *This = impl_from_ISynchronize(iface);
UINT index;
TRACE("%p (%08x, %08x)\n", This, dwFlags, dwMilliseconds);
return CoWaitForMultipleHandles(dwFlags, dwMilliseconds, 1, &This->event, &index);
}
static HRESULT WINAPI ISynchronize_fnSignal(ISynchronize *iface)
{
MREImpl *This = impl_from_ISynchronize(iface);
TRACE("%p\n", This);
SetEvent(This->event);
return S_OK;
}
static HRESULT WINAPI ISynchronize_fnReset(ISynchronize *iface)
{
MREImpl *This = impl_from_ISynchronize(iface);
TRACE("%p\n", This);
ResetEvent(This->event);
return S_OK;
}
static ISynchronizeVtbl vt_ISynchronize = {
ISynchronize_fnQueryInterface,
ISynchronize_fnAddRef,
ISynchronize_fnRelease,
ISynchronize_fnWait,
ISynchronize_fnSignal,
ISynchronize_fnReset
};
static HRESULT ManualResetEvent_Construct(IUnknown *punkouter, REFIID iid, void **ppv)
{
MREImpl *This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MREImpl));
HRESULT hr;
if(punkouter)
FIXME("Aggregation not implemented.\n");
This->ref = 1;
This->ISynchronize_iface.lpVtbl = &vt_ISynchronize;
This->event = CreateEventW(NULL, TRUE, FALSE, NULL);
hr = ISynchronize_QueryInterface(&This->ISynchronize_iface, iid, ppv);
ISynchronize_Release(&This->ISynchronize_iface);
return hr;
}
/***********************************************************************
* CoRevokeClassObject [OLE32.@]
*
@ -1488,6 +1605,15 @@ HRESULT WINAPI CoCreateGuid(GUID *pguid)
return HRESULT_FROM_WIN32( status );
}
static inline BOOL is_valid_hex(WCHAR c)
{
if (!(((c >= '0') && (c <= '9')) ||
((c >= 'a') && (c <= 'f')) ||
((c >= 'A') && (c <= 'F'))))
return FALSE;
return TRUE;
}
/******************************************************************************
* CLSIDFromString [OLE32.@]
* IIDFromString [OLE32.@]
@ -1511,24 +1637,10 @@ static HRESULT __CLSIDFromString(LPCWSTR s, LPCLSID id)
int i;
BYTE table[256];
if (!s) {
if (!s || s[0]!='{') {
memset( id, 0, sizeof (CLSID) );
return S_OK;
}
/* validate the CLSID string */
if (strlenW(s) != 38)
if(!s) return S_OK;
return CO_E_CLASSSTRING;
if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
return CO_E_CLASSSTRING;
for (i=1; i<37; i++) {
if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
if (!(((s[i] >= '0') && (s[i] <= '9')) ||
((s[i] >= 'a') && (s[i] <= 'f')) ||
((s[i] >= 'A') && (s[i] <= 'F'))))
return CO_E_CLASSSTRING;
}
TRACE("%s -> %p\n", debugstr_w(s), id);
@ -1546,22 +1658,40 @@ static HRESULT __CLSIDFromString(LPCWSTR s, LPCLSID id)
/* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
id->Data1 = (table[s[1]] << 28 | table[s[2]] << 24 | table[s[3]] << 20 | table[s[4]] << 16 |
table[s[5]] << 12 | table[s[6]] << 8 | table[s[7]] << 4 | table[s[8]]);
id->Data2 = table[s[10]] << 12 | table[s[11]] << 8 | table[s[12]] << 4 | table[s[13]];
id->Data3 = table[s[15]] << 12 | table[s[16]] << 8 | table[s[17]] << 4 | table[s[18]];
id->Data1 = 0;
for (i = 1; i < 9; i++) {
if (!is_valid_hex(s[i])) return CO_E_CLASSSTRING;
id->Data1 = (id->Data1 << 4) | table[s[i]];
}
if (s[9]!='-') return CO_E_CLASSSTRING;
/* these are just sequential bytes */
id->Data4[0] = table[s[20]] << 4 | table[s[21]];
id->Data4[1] = table[s[22]] << 4 | table[s[23]];
id->Data4[2] = table[s[25]] << 4 | table[s[26]];
id->Data4[3] = table[s[27]] << 4 | table[s[28]];
id->Data4[4] = table[s[29]] << 4 | table[s[30]];
id->Data4[5] = table[s[31]] << 4 | table[s[32]];
id->Data4[6] = table[s[33]] << 4 | table[s[34]];
id->Data4[7] = table[s[35]] << 4 | table[s[36]];
id->Data2 = 0;
for (i = 10; i < 14; i++) {
if (!is_valid_hex(s[i])) return CO_E_CLASSSTRING;
id->Data2 = (id->Data2 << 4) | table[s[i]];
}
if (s[14]!='-') return CO_E_CLASSSTRING;
return S_OK;
id->Data3 = 0;
for (i = 15; i < 19; i++) {
if (!is_valid_hex(s[i])) return CO_E_CLASSSTRING;
id->Data3 = (id->Data3 << 4) | table[s[i]];
}
if (s[19]!='-') return CO_E_CLASSSTRING;
for (i = 20; i < 37; i+=2) {
if (i == 24) {
if (s[i]!='-') return CO_E_CLASSSTRING;
i++;
}
if (!is_valid_hex(s[i]) || !is_valid_hex(s[i+1])) return CO_E_CLASSSTRING;
id->Data4[(i-20)/2] = table[s[i]] << 4 | table[s[i+1]];
}
if (s[37] == '}' && s[38] == '\0')
return S_OK;
return CO_E_CLASSSTRING;
}
/*****************************************************************************/
@ -1575,7 +1705,10 @@ HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id )
ret = __CLSIDFromString(idstr, id);
if(ret != S_OK) { /* It appears a ProgID is also valid */
ret = CLSIDFromProgID(idstr, id);
CLSID tmp_id;
ret = CLSIDFromProgID(idstr, &tmp_id);
if(SUCCEEDED(ret))
*id = tmp_id;
}
return ret;
}
@ -2492,6 +2625,9 @@ HRESULT WINAPI CoCreateInstance(
return S_OK;
}
if (IsEqualCLSID(rclsid, &CLSID_ManualResetEvent))
return ManualResetEvent_Construct(pUnkOuter, iid, ppv);
/*
* Get a class factory to construct the object we want.
*/
@ -3518,7 +3654,7 @@ HRESULT WINAPI CoRevertToSelf(void)
static BOOL COM_PeekMessage(struct apartment *apt, MSG *msg)
{
/* first try to retrieve messages for incoming COM calls to the apartment window */
return PeekMessageW(msg, apt->win, WM_USER, WM_APP - 1, PM_REMOVE|PM_NOYIELD) ||
return PeekMessageW(msg, apt->win, 0, 0, PM_REMOVE|PM_NOYIELD) ||
/* next retrieve other messages necessary for the app to remain responsive */
PeekMessageW(msg, NULL, WM_DDE_FIRST, WM_DDE_LAST, PM_REMOVE|PM_NOYIELD) ||
PeekMessageW(msg, NULL, 0, 0, PM_QS_PAINT|PM_QS_SENDMESSAGE|PM_REMOVE|PM_NOYIELD);
@ -3580,7 +3716,7 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
res = MsgWaitForMultipleObjectsEx(cHandles, pHandles,
(dwTimeout == INFINITE) ? INFINITE : start_time + dwTimeout - now,
QS_ALLINPUT, wait_flags);
QS_SENDMESSAGE | QS_ALLPOSTMESSAGE | QS_PAINT, wait_flags);
if (res == WAIT_OBJECT_0 + cHandles) /* messages available */
{
@ -3614,11 +3750,7 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
}
}
/* note: using "if" here instead of "while" might seem less
* efficient, but only if we are optimising for quick delivery
* of pending messages, rather than quick completion of the
* COM call */
if (COM_PeekMessage(apt, &msg))
while (COM_PeekMessage(apt, &msg))
{
TRACE("received message whilst waiting for RPC: 0x%04x\n", msg.message);
TranslateMessage(&msg);
@ -3629,6 +3761,7 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
PostQuitMessage(msg.wParam);
/* no longer need to process messages */
message_loop = FALSE;
break;
}
}
continue;
@ -3644,23 +3777,19 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
(dwFlags & COWAIT_ALERTABLE) ? TRUE : FALSE);
}
if (res < WAIT_OBJECT_0 + cHandles)
{
/* handle signaled, store index */
*lpdwindex = (res - WAIT_OBJECT_0);
break;
}
else if (res == WAIT_TIMEOUT)
switch (res)
{
case WAIT_TIMEOUT:
hr = RPC_S_CALLPENDING;
break;
}
else
{
ERR("Unexpected wait termination: %d, %d\n", res, GetLastError());
hr = E_UNEXPECTED;
case WAIT_FAILED:
hr = HRESULT_FROM_WIN32( GetLastError() );
break;
default:
*lpdwindex = res;
break;
}
break;
}
TRACE("-- 0x%08x\n", hr);
return hr;
@ -3740,26 +3869,26 @@ HRESULT WINAPI CoRegisterChannelHook(REFGUID guidExtension, IChannelHook *pChann
typedef struct Context
{
const IComThreadingInfoVtbl *lpVtbl;
const IContextCallbackVtbl *lpCallbackVtbl;
const IObjContextVtbl *lpContextVtbl;
IComThreadingInfo IComThreadingInfo_iface;
IContextCallback IContextCallback_iface;
IObjContext IObjContext_iface;
LONG refs;
APTTYPE apttype;
} Context;
static inline Context *impl_from_IComThreadingInfo( IComThreadingInfo *iface )
{
return (Context *)((char*)iface - FIELD_OFFSET(Context, lpVtbl));
return CONTAINING_RECORD(iface, Context, IComThreadingInfo_iface);
}
static inline Context *impl_from_IContextCallback( IContextCallback *iface )
{
return (Context *)((char*)iface - FIELD_OFFSET(Context, lpCallbackVtbl));
return CONTAINING_RECORD(iface, Context, IContextCallback_iface);
}
static inline Context *impl_from_IObjContext( IObjContext *iface )
{
return (Context *)((char*)iface - FIELD_OFFSET(Context, lpContextVtbl));
return CONTAINING_RECORD(iface, Context, IObjContext_iface);
}
static HRESULT Context_QueryInterface(Context *iface, REFIID riid, LPVOID *ppv)
@ -3769,15 +3898,15 @@ static HRESULT Context_QueryInterface(Context *iface, REFIID riid, LPVOID *ppv)
if (IsEqualIID(riid, &IID_IComThreadingInfo) ||
IsEqualIID(riid, &IID_IUnknown))
{
*ppv = &iface->lpVtbl;
*ppv = &iface->IComThreadingInfo_iface;
}
else if (IsEqualIID(riid, &IID_IContextCallback))
{
*ppv = &iface->lpCallbackVtbl;
*ppv = &iface->IContextCallback_iface;
}
else if (IsEqualIID(riid, &IID_IObjContext))
{
*ppv = &iface->lpContextVtbl;
*ppv = &iface->IObjContext_iface;
}
if (*ppv)
@ -4054,9 +4183,9 @@ HRESULT WINAPI CoGetObjectContext(REFIID riid, void **ppv)
if (!context)
return E_OUTOFMEMORY;
context->lpVtbl = &Context_Threading_Vtbl;
context->lpCallbackVtbl = &Context_Callback_Vtbl;
context->lpContextVtbl = &Context_Object_Vtbl;
context->IComThreadingInfo_iface.lpVtbl = &Context_Threading_Vtbl;
context->IContextCallback_iface.lpVtbl = &Context_Callback_Vtbl;
context->IObjContext_iface.lpVtbl = &Context_Object_Vtbl;
context->refs = 1;
if (apt->multi_threaded)
context->apttype = APTTYPE_MTA;
@ -4065,8 +4194,8 @@ HRESULT WINAPI CoGetObjectContext(REFIID riid, void **ppv)
else
context->apttype = APTTYPE_STA;
hr = IUnknown_QueryInterface((IUnknown *)&context->lpVtbl, riid, ppv);
IUnknown_Release((IUnknown *)&context->lpVtbl);
hr = IUnknown_QueryInterface((IUnknown *)&context->IComThreadingInfo_iface, riid, ppv);
IUnknown_Release((IUnknown *)&context->IComThreadingInfo_iface);
return hr;
}
@ -4159,6 +4288,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
COMPOBJ_UninitProcess();
RPC_UnregisterAllChannelHooks();
COMPOBJ_DllList_Free();
DeleteCriticalSection(&csRegisteredClassList);
DeleteCriticalSection(&csApartment);
break;
case DLL_THREAD_DETACH:
@ -4168,4 +4299,18 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
return TRUE;
}
/* NOTE: DllRegisterServer and DllUnregisterServer are in regsvr.c */
/***********************************************************************
* DllRegisterServer (OLE32.@)
*/
HRESULT WINAPI DllRegisterServer(void)
{
return OLE32_DllRegisterServer();
}
/***********************************************************************
* DllUnregisterServer (OLE32.@)
*/
HRESULT WINAPI DllUnregisterServer(void)
{
return OLE32_DllUnregisterServer();
}

View file

@ -42,7 +42,6 @@ struct apartment;
typedef struct apartment APARTMENT;
DEFINE_OLEGUID( CLSID_DfMarshal, 0x0000030b, 0, 0 );
DEFINE_OLEGUID( CLSID_PSFactoryBuffer, 0x00000320, 0, 0 );
/* signal to stub manager that this is a rem unknown object */
#define MSHLFLAGSP_REMUNKNOWN 0x80000000
@ -120,27 +119,6 @@ struct ifproxy
IRpcChannelBuffer *chan; /* channel to object (CS parent->cs) */
};
/* imported object / proxy manager */
struct proxy_manager
{
const IMultiQIVtbl *lpVtbl;
const IMarshalVtbl *lpVtblMarshal;
const IClientSecurityVtbl *lpVtblCliSec;
struct apartment *parent; /* owning apartment (RO) */
struct list entry; /* entry in apartment (CS parent->cs) */
OXID oxid; /* object exported ID (RO) */
OXID_INFO oxid_info; /* string binding, ipid of rem unknown and other information (RO) */
OID oid; /* object ID (RO) */
struct list interfaces; /* imported interfaces (CS cs) */
LONG refs; /* proxy reference count (LOCK) */
CRITICAL_SECTION cs; /* thread safety for this object and children */
ULONG sorflags; /* STDOBJREF flags (RO) */
IRemUnknown *remunk; /* proxy to IRemUnknown used for lifecycle management (CS cs) */
HANDLE remoting_mutex; /* mutex used for synchronizing access to IRemUnknown */
MSHCTX dest_context; /* context used for activating optimisations (LOCK) */
void *dest_context_data; /* reserved context value (LOCK) */
};
struct apartment
{
struct list entry;
@ -160,7 +138,7 @@ struct apartment
DWORD host_apt_tid; /* thread ID of apartment hosting objects of differing threading model (CS cs) */
HWND host_apt_hwnd; /* handle to apartment window of host apartment (CS cs) */
/* FIXME: OID's should be given out by RPCSS */
/* FIXME: OIDs should be given out by RPCSS */
OID oidc; /* object ID counter, starts at 1, zero is invalid OID (CS cs) */
/* STA-only fields */
@ -192,77 +170,77 @@ struct oletls
/* Global Interface Table Functions */
extern void* StdGlobalInterfaceTable_Construct(void);
extern HRESULT StdGlobalInterfaceTable_GetFactory(LPVOID *ppv);
extern void* StdGlobalInterfaceTableInstance;
extern void* StdGlobalInterfaceTable_Construct(void) DECLSPEC_HIDDEN;
extern HRESULT StdGlobalInterfaceTable_GetFactory(LPVOID *ppv) DECLSPEC_HIDDEN;
extern void* StdGlobalInterfaceTableInstance DECLSPEC_HIDDEN;
HRESULT COM_OpenKeyForCLSID(REFCLSID clsid, LPCWSTR keyname, REGSAM access, HKEY *key);
HRESULT COM_OpenKeyForAppIdFromCLSID(REFCLSID clsid, REGSAM access, HKEY *subkey);
HRESULT MARSHAL_GetStandardMarshalCF(LPVOID *ppv);
HRESULT FTMarshalCF_Create(REFIID riid, LPVOID *ppv);
HRESULT COM_OpenKeyForCLSID(REFCLSID clsid, LPCWSTR keyname, REGSAM access, HKEY *key) DECLSPEC_HIDDEN;
HRESULT COM_OpenKeyForAppIdFromCLSID(REFCLSID clsid, REGSAM access, HKEY *subkey) DECLSPEC_HIDDEN;
HRESULT MARSHAL_GetStandardMarshalCF(LPVOID *ppv) DECLSPEC_HIDDEN;
HRESULT FTMarshalCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
/* Stub Manager */
ULONG stub_manager_int_release(struct stub_manager *This);
struct stub_manager *new_stub_manager(APARTMENT *apt, IUnknown *object);
ULONG stub_manager_ext_addref(struct stub_manager *m, ULONG refs, BOOL tableweak);
ULONG stub_manager_ext_release(struct stub_manager *m, ULONG refs, BOOL tableweak, BOOL last_unlock_releases);
struct ifstub *stub_manager_new_ifstub(struct stub_manager *m, IRpcStubBuffer *sb, IUnknown *iptr, REFIID iid, MSHLFLAGS flags);
struct ifstub *stub_manager_find_ifstub(struct stub_manager *m, REFIID iid, MSHLFLAGS flags);
struct stub_manager *get_stub_manager(APARTMENT *apt, OID oid);
struct stub_manager *get_stub_manager_from_object(APARTMENT *apt, void *object);
BOOL stub_manager_notify_unmarshal(struct stub_manager *m, const IPID *ipid);
BOOL stub_manager_is_table_marshaled(struct stub_manager *m, const IPID *ipid);
void stub_manager_release_marshal_data(struct stub_manager *m, ULONG refs, const IPID *ipid, BOOL tableweak);
HRESULT ipid_get_dispatch_params(const IPID *ipid, APARTMENT **stub_apt, IRpcStubBuffer **stub, IRpcChannelBuffer **chan, IID *iid, IUnknown **iface);
HRESULT start_apartment_remote_unknown(void);
ULONG stub_manager_int_release(struct stub_manager *This) DECLSPEC_HIDDEN;
struct stub_manager *new_stub_manager(APARTMENT *apt, IUnknown *object) DECLSPEC_HIDDEN;
ULONG stub_manager_ext_addref(struct stub_manager *m, ULONG refs, BOOL tableweak) DECLSPEC_HIDDEN;
ULONG stub_manager_ext_release(struct stub_manager *m, ULONG refs, BOOL tableweak, BOOL last_unlock_releases) DECLSPEC_HIDDEN;
struct ifstub *stub_manager_new_ifstub(struct stub_manager *m, IRpcStubBuffer *sb, IUnknown *iptr, REFIID iid, MSHLFLAGS flags) DECLSPEC_HIDDEN;
struct ifstub *stub_manager_find_ifstub(struct stub_manager *m, REFIID iid, MSHLFLAGS flags) DECLSPEC_HIDDEN;
struct stub_manager *get_stub_manager(APARTMENT *apt, OID oid) DECLSPEC_HIDDEN;
struct stub_manager *get_stub_manager_from_object(APARTMENT *apt, void *object) DECLSPEC_HIDDEN;
BOOL stub_manager_notify_unmarshal(struct stub_manager *m, const IPID *ipid) DECLSPEC_HIDDEN;
BOOL stub_manager_is_table_marshaled(struct stub_manager *m, const IPID *ipid) DECLSPEC_HIDDEN;
void stub_manager_release_marshal_data(struct stub_manager *m, ULONG refs, const IPID *ipid, BOOL tableweak) DECLSPEC_HIDDEN;
HRESULT ipid_get_dispatch_params(const IPID *ipid, APARTMENT **stub_apt, IRpcStubBuffer **stub, IRpcChannelBuffer **chan, IID *iid, IUnknown **iface) DECLSPEC_HIDDEN;
HRESULT start_apartment_remote_unknown(void) DECLSPEC_HIDDEN;
HRESULT marshal_object(APARTMENT *apt, STDOBJREF *stdobjref, REFIID riid, IUnknown *obj, MSHLFLAGS mshlflags);
HRESULT marshal_object(APARTMENT *apt, STDOBJREF *stdobjref, REFIID riid, IUnknown *obj, MSHLFLAGS mshlflags) DECLSPEC_HIDDEN;
/* RPC Backend */
struct dispatch_params;
void RPC_StartRemoting(struct apartment *apt);
void RPC_StartRemoting(struct apartment *apt) DECLSPEC_HIDDEN;
HRESULT RPC_CreateClientChannel(const OXID *oxid, const IPID *ipid,
const OXID_INFO *oxid_info,
DWORD dest_context, void *dest_context_data,
IRpcChannelBuffer **chan);
HRESULT RPC_CreateServerChannel(IRpcChannelBuffer **chan);
void RPC_ExecuteCall(struct dispatch_params *params);
HRESULT RPC_RegisterInterface(REFIID riid);
void RPC_UnregisterInterface(REFIID riid);
HRESULT RPC_StartLocalServer(REFCLSID clsid, IStream *stream, BOOL multi_use, void **registration);
void RPC_StopLocalServer(void *registration);
HRESULT RPC_GetLocalClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv);
HRESULT RPC_RegisterChannelHook(REFGUID rguid, IChannelHook *hook);
void RPC_UnregisterAllChannelHooks(void);
HRESULT RPC_ResolveOxid(OXID oxid, OXID_INFO *oxid_info);
IRpcChannelBuffer **chan) DECLSPEC_HIDDEN;
HRESULT RPC_CreateServerChannel(IRpcChannelBuffer **chan) DECLSPEC_HIDDEN;
void RPC_ExecuteCall(struct dispatch_params *params) DECLSPEC_HIDDEN;
HRESULT RPC_RegisterInterface(REFIID riid) DECLSPEC_HIDDEN;
void RPC_UnregisterInterface(REFIID riid) DECLSPEC_HIDDEN;
HRESULT RPC_StartLocalServer(REFCLSID clsid, IStream *stream, BOOL multi_use, void **registration) DECLSPEC_HIDDEN;
void RPC_StopLocalServer(void *registration) DECLSPEC_HIDDEN;
HRESULT RPC_GetLocalClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) DECLSPEC_HIDDEN;
HRESULT RPC_RegisterChannelHook(REFGUID rguid, IChannelHook *hook) DECLSPEC_HIDDEN;
void RPC_UnregisterAllChannelHooks(void) DECLSPEC_HIDDEN;
HRESULT RPC_ResolveOxid(OXID oxid, OXID_INFO *oxid_info) DECLSPEC_HIDDEN;
/* This function initialize the Running Object Table */
HRESULT WINAPI RunningObjectTableImpl_Initialize(void);
HRESULT WINAPI RunningObjectTableImpl_Initialize(void) DECLSPEC_HIDDEN;
/* This function uninitialize the Running Object Table */
HRESULT WINAPI RunningObjectTableImpl_UnInitialize(void);
HRESULT WINAPI RunningObjectTableImpl_UnInitialize(void) DECLSPEC_HIDDEN;
/* Drag and drop */
void OLEDD_UnInitialize(void);
void OLEDD_UnInitialize(void) DECLSPEC_HIDDEN;
/* Apartment Functions */
APARTMENT *apartment_findfromoxid(OXID oxid, BOOL ref);
APARTMENT *apartment_findfromtid(DWORD tid);
DWORD apartment_release(struct apartment *apt);
HRESULT apartment_disconnectproxies(struct apartment *apt);
void apartment_disconnectobject(struct apartment *apt, void *object);
APARTMENT *apartment_findfromoxid(OXID oxid, BOOL ref) DECLSPEC_HIDDEN;
APARTMENT *apartment_findfromtid(DWORD tid) DECLSPEC_HIDDEN;
DWORD apartment_release(struct apartment *apt) DECLSPEC_HIDDEN;
HRESULT apartment_disconnectproxies(struct apartment *apt) DECLSPEC_HIDDEN;
void apartment_disconnectobject(struct apartment *apt, void *object) DECLSPEC_HIDDEN;
static inline HRESULT apartment_getoxid(const struct apartment *apt, OXID *oxid)
{
*oxid = apt->oxid;
return S_OK;
}
HRESULT apartment_createwindowifneeded(struct apartment *apt);
HWND apartment_getwindow(const struct apartment *apt);
void apartment_joinmta(void);
HRESULT apartment_createwindowifneeded(struct apartment *apt) DECLSPEC_HIDDEN;
HWND apartment_getwindow(const struct apartment *apt) DECLSPEC_HIDDEN;
void apartment_joinmta(void) DECLSPEC_HIDDEN;
/* DCOM messages used by the apartment window (not compatible with native) */
@ -297,8 +275,6 @@ static inline GUID COM_CurrentCausalityId(void)
return info->causality_id;
}
#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
/* helpers for debugging */
# define DEBUG_SET_CRITSEC_NAME(cs, name) (cs)->DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": " name)
# define DEBUG_CLEAR_CRITSEC_NAME(cs) (cs)->DebugInfo->Spare[0] = 0
@ -313,23 +289,23 @@ extern HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID
extern HRESULT WINAPI OLE32_DllRegisterServer(void) DECLSPEC_HIDDEN;
extern HRESULT WINAPI OLE32_DllUnregisterServer(void) DECLSPEC_HIDDEN;
extern HRESULT Handler_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv);
extern HRESULT HandlerCF_Create(REFCLSID rclsid, REFIID riid, LPVOID *ppv);
extern HRESULT Handler_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
extern HRESULT HandlerCF_Create(REFCLSID rclsid, REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
/* Exported non-interface Data Advise Holder functions */
HRESULT DataAdviseHolder_OnConnect(IDataAdviseHolder *iface, IDataObject *pDelegate);
void DataAdviseHolder_OnDisconnect(IDataAdviseHolder *iface);
HRESULT DataAdviseHolder_OnConnect(IDataAdviseHolder *iface, IDataObject *pDelegate) DECLSPEC_HIDDEN;
void DataAdviseHolder_OnDisconnect(IDataAdviseHolder *iface) DECLSPEC_HIDDEN;
extern UINT ownerlink_clipboard_format;
extern UINT filename_clipboard_format;
extern UINT filenameW_clipboard_format;
extern UINT dataobject_clipboard_format;
extern UINT embedded_object_clipboard_format;
extern UINT embed_source_clipboard_format;
extern UINT custom_link_source_clipboard_format;
extern UINT link_source_clipboard_format;
extern UINT object_descriptor_clipboard_format;
extern UINT link_source_descriptor_clipboard_format;
extern UINT ole_private_data_clipboard_format;
extern UINT ownerlink_clipboard_format DECLSPEC_HIDDEN;
extern UINT filename_clipboard_format DECLSPEC_HIDDEN;
extern UINT filenameW_clipboard_format DECLSPEC_HIDDEN;
extern UINT dataobject_clipboard_format DECLSPEC_HIDDEN;
extern UINT embedded_object_clipboard_format DECLSPEC_HIDDEN;
extern UINT embed_source_clipboard_format DECLSPEC_HIDDEN;
extern UINT custom_link_source_clipboard_format DECLSPEC_HIDDEN;
extern UINT link_source_clipboard_format DECLSPEC_HIDDEN;
extern UINT object_descriptor_clipboard_format DECLSPEC_HIDDEN;
extern UINT link_source_descriptor_clipboard_format DECLSPEC_HIDDEN;
extern UINT ole_private_data_clipboard_format DECLSPEC_HIDDEN;
#endif /* __WINE_OLE_COMPOBJ_H */

View file

@ -41,51 +41,42 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
/* CompositeMoniker data structure */
typedef struct CompositeMonikerImpl{
const IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
/* The ROT (RunningObjectTable implementation) uses the IROTData
* interface to test whether two monikers are equal. That's why IROTData
* interface is implemented by monikers.
*/
const IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
const IMarshalVtbl* lpvtblMarshal; /* VTable relative to the IMarshal interface.*/
LONG ref; /* reference counter for this object */
IMoniker IMoniker_iface;
IROTData IROTData_iface;
IMarshal IMarshal_iface;
LONG ref;
IMoniker** tabMoniker; /* dynamic table containing all components (monikers) of this composite moniker */
ULONG tabSize; /* size of tabMoniker */
ULONG tabLastIndex; /* first free index in tabMoniker */
ULONG tabLastIndex; /* first free index in tabMoniker */
} CompositeMonikerImpl;
static inline CompositeMonikerImpl *impl_from_IMoniker(IMoniker *iface)
{
return CONTAINING_RECORD(iface, CompositeMonikerImpl, IMoniker_iface);
}
static inline CompositeMonikerImpl *impl_from_IROTData(IROTData *iface)
{
return CONTAINING_RECORD(iface, CompositeMonikerImpl, IROTData_iface);
}
static inline CompositeMonikerImpl *impl_from_IMarshal(IMarshal *iface)
{
return CONTAINING_RECORD(iface, CompositeMonikerImpl, IMarshal_iface);
}
/* EnumMoniker data structure */
typedef struct EnumMonikerImpl{
const IEnumMonikerVtbl *lpVtbl; /* VTable relative to the IEnumMoniker interface.*/
LONG ref; /* reference counter for this object */
IEnumMoniker IEnumMoniker_iface;
LONG ref;
IMoniker** tabMoniker; /* dynamic table containing the enumerated monikers */
ULONG tabSize; /* size of tabMoniker */
ULONG currentPos; /* index pointer on the current moniker */
} EnumMonikerImpl;
static inline IMoniker *impl_from_IROTData( IROTData *iface )
static inline EnumMonikerImpl *impl_from_IEnumMoniker(IEnumMoniker *iface)
{
return (IMoniker *)((char*)iface - FIELD_OFFSET(CompositeMonikerImpl, lpvtbl2));
}
static inline IMoniker *impl_from_IMarshal( IMarshal *iface )
{
return (IMoniker *)((char*)iface - FIELD_OFFSET(CompositeMonikerImpl, lpvtblMarshal));
return CONTAINING_RECORD(iface, EnumMonikerImpl, IEnumMoniker_iface);
}
static HRESULT EnumMonikerImpl_CreateEnumMoniker(IMoniker** tabMoniker,ULONG tabSize,ULONG currentPos,BOOL leftToRigth,IEnumMoniker ** ppmk);
@ -96,7 +87,7 @@ static HRESULT EnumMonikerImpl_CreateEnumMoniker(IMoniker** tabMoniker,ULONG tab
static HRESULT WINAPI
CompositeMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
{
CompositeMonikerImpl *This = (CompositeMonikerImpl *)iface;
CompositeMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
@ -115,9 +106,9 @@ CompositeMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject
)
*ppvObject = iface;
else if (IsEqualIID(&IID_IROTData, riid))
*ppvObject = &This->lpvtbl2;
*ppvObject = &This->IROTData_iface;
else if (IsEqualIID(&IID_IMarshal, riid))
*ppvObject = &This->lpvtblMarshal;
*ppvObject = &This->IMarshal_iface;
/* Check that we obtained an interface.*/
if ((*ppvObject)==0)
@ -135,7 +126,7 @@ CompositeMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject
static ULONG WINAPI
CompositeMonikerImpl_AddRef(IMoniker* iface)
{
CompositeMonikerImpl *This = (CompositeMonikerImpl *)iface;
CompositeMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p)\n",This);
@ -158,7 +149,7 @@ static void CompositeMonikerImpl_ReleaseMonikersInTable(CompositeMonikerImpl *Th
static ULONG WINAPI
CompositeMonikerImpl_Release(IMoniker* iface)
{
CompositeMonikerImpl *This = (CompositeMonikerImpl *)iface;
CompositeMonikerImpl *This = impl_from_IMoniker(iface);
ULONG ref;
TRACE("(%p)\n",This);
@ -214,12 +205,11 @@ CompositeMonikerImpl_IsDirty(IMoniker* iface)
static HRESULT WINAPI
CompositeMonikerImpl_Load(IMoniker* iface,IStream* pStm)
{
CompositeMonikerImpl *This = impl_from_IMoniker(iface);
HRESULT res;
DWORD moniker_count;
DWORD i;
CompositeMonikerImpl *This = (CompositeMonikerImpl *)iface;
TRACE("(%p,%p)\n",iface,pStm);
/* this function call OleLoadFromStream function for each moniker within this object */
@ -262,7 +252,7 @@ CompositeMonikerImpl_Load(IMoniker* iface,IStream* pStm)
static HRESULT WINAPI
CompositeMonikerImpl_Save(IMoniker* iface,IStream* pStm,BOOL fClearDirty)
{
CompositeMonikerImpl *This = (CompositeMonikerImpl *)iface;
CompositeMonikerImpl *This = impl_from_IMoniker(iface);
HRESULT res;
IEnumMoniker *enumMk;
IMoniker *pmk;
@ -532,7 +522,7 @@ CompositeMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
static HRESULT WINAPI
CompositeMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
{
CompositeMonikerImpl *This = (CompositeMonikerImpl *)iface;
CompositeMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p,%d,%p)\n",iface,fForward,ppenumMoniker);
@ -841,7 +831,7 @@ CompositeMonikerImpl_CommonPrefixWith(IMoniker* iface, IMoniker* pmkOther,
IMoniker_IsSystemMoniker(pmkOther,&mkSys);
if((mkSys==MKSYS_GENERICCOMPOSITE)){
if(mkSys==MKSYS_GENERICCOMPOSITE){
IMoniker_Enum(iface,TRUE,&enumMoniker1);
IMoniker_Enum(pmkOther,TRUE,&enumMoniker2);
@ -1196,12 +1186,11 @@ static HRESULT WINAPI
CompositeMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,
VOID** ppvObject)
{
IMoniker *This = impl_from_IROTData(iface);
CompositeMonikerImpl *This = impl_from_IROTData(iface);
TRACE("(%p,%p,%p)\n",iface,riid,ppvObject);
return CompositeMonikerImpl_QueryInterface(This, riid, ppvObject);
return CompositeMonikerImpl_QueryInterface(&This->IMoniker_iface, riid, ppvObject);
}
/***********************************************************************
@ -1210,11 +1199,11 @@ CompositeMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,
static ULONG WINAPI
CompositeMonikerROTDataImpl_AddRef(IROTData *iface)
{
IMoniker *This = impl_from_IROTData(iface);
CompositeMonikerImpl *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
return IMoniker_AddRef(This);
return IMoniker_AddRef(&This->IMoniker_iface);
}
/***********************************************************************
@ -1222,11 +1211,11 @@ CompositeMonikerROTDataImpl_AddRef(IROTData *iface)
*/
static ULONG WINAPI CompositeMonikerROTDataImpl_Release(IROTData* iface)
{
IMoniker *This = impl_from_IROTData(iface);
CompositeMonikerImpl *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
return IMoniker_Release(This);
return IMoniker_Release(&This->IMoniker_iface);
}
/******************************************************************************
@ -1236,7 +1225,7 @@ static HRESULT WINAPI
CompositeMonikerROTDataImpl_GetComparisonData(IROTData* iface,
BYTE* pbData, ULONG cbMax, ULONG* pcbData)
{
IMoniker *This = impl_from_IROTData(iface);
CompositeMonikerImpl *This = impl_from_IROTData(iface);
IEnumMoniker *pEnumMk;
IMoniker *pmk;
HRESULT hr;
@ -1245,7 +1234,7 @@ CompositeMonikerROTDataImpl_GetComparisonData(IROTData* iface,
*pcbData = sizeof(CLSID);
hr = IMoniker_Enum(This, TRUE, &pEnumMk);
hr = IMoniker_Enum(&This->IMoniker_iface, TRUE, &pEnumMk);
if (FAILED(hr)) return hr;
while(IEnumMoniker_Next(pEnumMk, 1, &pmk, NULL) == S_OK)
@ -1323,48 +1312,48 @@ CompositeMonikerROTDataImpl_GetComparisonData(IROTData* iface,
static HRESULT WINAPI CompositeMonikerMarshalImpl_QueryInterface(IMarshal *iface, REFIID riid, LPVOID *ppv)
{
IMoniker *This = impl_from_IMarshal(iface);
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
TRACE("(%p,%s,%p)\n",iface,debugstr_guid(riid),ppv);
return CompositeMonikerImpl_QueryInterface(This, riid, ppv);
return CompositeMonikerImpl_QueryInterface(&This->IMoniker_iface, riid, ppv);
}
static ULONG WINAPI CompositeMonikerMarshalImpl_AddRef(IMarshal *iface)
{
IMoniker *This = impl_from_IMarshal(iface);
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
TRACE("(%p)\n",iface);
return CompositeMonikerImpl_AddRef(This);
return CompositeMonikerImpl_AddRef(&This->IMoniker_iface);
}
static ULONG WINAPI CompositeMonikerMarshalImpl_Release(IMarshal *iface)
{
IMoniker *This = impl_from_IMarshal(iface);
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
TRACE("(%p)\n",iface);
return CompositeMonikerImpl_Release(This);
return CompositeMonikerImpl_Release(&This->IMoniker_iface);
}
static HRESULT WINAPI CompositeMonikerMarshalImpl_GetUnmarshalClass(
LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext,
IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags, CLSID* pCid)
{
IMoniker *This = impl_from_IMarshal(iface);
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
TRACE("(%s, %p, %x, %p, %x, %p)\n", debugstr_guid(riid), pv,
dwDestContext, pvDestContext, mshlflags, pCid);
return IMoniker_GetClassID(This, pCid);
return IMoniker_GetClassID(&This->IMoniker_iface, pCid);
}
static HRESULT WINAPI CompositeMonikerMarshalImpl_GetMarshalSizeMax(
LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext,
IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags, DWORD* pSize)
{
IMoniker *This = impl_from_IMarshal(iface);
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
IEnumMoniker *pEnumMk;
IMoniker *pmk;
HRESULT hr;
@ -1375,10 +1364,10 @@ static HRESULT WINAPI CompositeMonikerMarshalImpl_GetMarshalSizeMax(
*pSize = 0x10; /* to match native */
hr = IMoniker_Enum(This, TRUE, &pEnumMk);
hr = IMoniker_Enum(&This->IMoniker_iface, TRUE, &pEnumMk);
if (FAILED(hr)) return hr;
hr = IMoniker_GetSizeMax(This, &size);
hr = IMoniker_GetSizeMax(&This->IMoniker_iface, &size);
while (IEnumMoniker_Next(pEnumMk, 1, &pmk, NULL) == S_OK)
{
@ -1402,11 +1391,11 @@ static HRESULT WINAPI CompositeMonikerMarshalImpl_GetMarshalSizeMax(
return S_OK;
}
static HRESULT WINAPI CompositeMonikerMarshalImpl_MarshalInterface(LPMARSHAL iface, IStream *pStm,
static HRESULT WINAPI CompositeMonikerMarshalImpl_MarshalInterface(IMarshal *iface, IStream *pStm,
REFIID riid, void* pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags)
{
IMoniker *This = impl_from_IMarshal(iface);
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
IEnumMoniker *pEnumMk;
IMoniker *pmk;
HRESULT hr;
@ -1415,7 +1404,7 @@ static HRESULT WINAPI CompositeMonikerMarshalImpl_MarshalInterface(LPMARSHAL ifa
TRACE("(%p, %s, %p, %x, %p, %x)\n", pStm, debugstr_guid(riid), pv,
dwDestContext, pvDestContext, mshlflags);
hr = IMoniker_Enum(This, TRUE, &pEnumMk);
hr = IMoniker_Enum(&This->IMoniker_iface, TRUE, &pEnumMk);
if (FAILED(hr)) return hr;
while (IEnumMoniker_Next(pEnumMk, 1, &pmk, NULL) == S_OK)
@ -1440,9 +1429,10 @@ static HRESULT WINAPI CompositeMonikerMarshalImpl_MarshalInterface(LPMARSHAL ifa
return S_OK;
}
static HRESULT WINAPI CompositeMonikerMarshalImpl_UnmarshalInterface(LPMARSHAL iface, IStream *pStm, REFIID riid, void **ppv)
static HRESULT WINAPI CompositeMonikerMarshalImpl_UnmarshalInterface(IMarshal *iface, IStream *pStm,
REFIID riid, void **ppv)
{
CompositeMonikerImpl *This = (CompositeMonikerImpl *)impl_from_IMarshal(iface);
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
HRESULT hr;
TRACE("(%p, %s, %p)\n", pStm, debugstr_guid(riid), ppv);
@ -1474,10 +1464,10 @@ static HRESULT WINAPI CompositeMonikerMarshalImpl_UnmarshalInterface(LPMARSHAL i
}
This->tabLastIndex++;
return IMoniker_QueryInterface((IMoniker *)&This->lpvtbl1, riid, ppv);
return IMoniker_QueryInterface(&This->IMoniker_iface, riid, ppv);
}
static HRESULT WINAPI CompositeMonikerMarshalImpl_ReleaseMarshalData(LPMARSHAL iface, IStream *pStm)
static HRESULT WINAPI CompositeMonikerMarshalImpl_ReleaseMarshalData(IMarshal *iface, IStream *pStm)
{
TRACE("(%p)\n", pStm);
/* can't release a state-based marshal as nothing on server side to
@ -1485,7 +1475,8 @@ static HRESULT WINAPI CompositeMonikerMarshalImpl_ReleaseMarshalData(LPMARSHAL i
return S_OK;
}
static HRESULT WINAPI CompositeMonikerMarshalImpl_DisconnectObject(LPMARSHAL iface, DWORD dwReserved)
static HRESULT WINAPI CompositeMonikerMarshalImpl_DisconnectObject(IMarshal *iface,
DWORD dwReserved)
{
TRACE("(0x%x)\n", dwReserved);
/* can't disconnect a state-based marshal as nothing on server side to
@ -1499,7 +1490,7 @@ static HRESULT WINAPI CompositeMonikerMarshalImpl_DisconnectObject(LPMARSHAL ifa
static HRESULT WINAPI
EnumMonikerImpl_QueryInterface(IEnumMoniker* iface,REFIID riid,void** ppvObject)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
@ -1530,7 +1521,7 @@ EnumMonikerImpl_QueryInterface(IEnumMoniker* iface,REFIID riid,void** ppvObject)
static ULONG WINAPI
EnumMonikerImpl_AddRef(IEnumMoniker* iface)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
TRACE("(%p)\n",This);
@ -1544,7 +1535,7 @@ EnumMonikerImpl_AddRef(IEnumMoniker* iface)
static ULONG WINAPI
EnumMonikerImpl_Release(IEnumMoniker* iface)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
ULONG i;
ULONG ref;
TRACE("(%p)\n",This);
@ -1570,7 +1561,7 @@ static HRESULT WINAPI
EnumMonikerImpl_Next(IEnumMoniker* iface,ULONG celt, IMoniker** rgelt,
ULONG* pceltFethed)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
ULONG i;
/* retrieve the requested number of moniker from the current position */
@ -1595,7 +1586,7 @@ EnumMonikerImpl_Next(IEnumMoniker* iface,ULONG celt, IMoniker** rgelt,
static HRESULT WINAPI
EnumMonikerImpl_Skip(IEnumMoniker* iface,ULONG celt)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
if ((This->currentPos+celt) >= This->tabSize)
return S_FALSE;
@ -1611,8 +1602,7 @@ EnumMonikerImpl_Skip(IEnumMoniker* iface,ULONG celt)
static HRESULT WINAPI
EnumMonikerImpl_Reset(IEnumMoniker* iface)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
This->currentPos=0;
@ -1625,7 +1615,7 @@ EnumMonikerImpl_Reset(IEnumMoniker* iface)
static HRESULT WINAPI
EnumMonikerImpl_Clone(IEnumMoniker* iface,IEnumMoniker** ppenum)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
return EnumMonikerImpl_CreateEnumMoniker(This->tabMoniker,This->tabSize,This->currentPos,TRUE,ppenum);
}
@ -1662,7 +1652,7 @@ EnumMonikerImpl_CreateEnumMoniker(IMoniker** tabMoniker, ULONG tabSize,
return STG_E_INSUFFICIENTMEMORY;
/* Initialize the virtual function table. */
newEnumMoniker->lpVtbl = &VT_EnumMonikerImpl;
newEnumMoniker->IEnumMoniker_iface.lpVtbl = &VT_EnumMonikerImpl;
newEnumMoniker->ref = 1;
newEnumMoniker->tabSize=tabSize;
@ -1688,7 +1678,7 @@ EnumMonikerImpl_CreateEnumMoniker(IMoniker** tabMoniker, ULONG tabSize,
IMoniker_AddRef(tabMoniker[i]);
}
*ppmk=(IEnumMoniker*)newEnumMoniker;
*ppmk=&newEnumMoniker->IEnumMoniker_iface;
return S_OK;
}
@ -1751,8 +1741,7 @@ static const IMarshalVtbl VT_MarshalImpl =
* Composite-Moniker_Construct (local function)
*******************************************************************************/
static HRESULT
CompositeMonikerImpl_Construct(IMoniker** ppMoniker,
LPMONIKER pmkFirst, LPMONIKER pmkRest)
CompositeMonikerImpl_Construct(IMoniker **ppMoniker, IMoniker *pmkFirst, IMoniker *pmkRest)
{
DWORD mkSys;
IEnumMoniker *enumMoniker;
@ -1768,9 +1757,9 @@ CompositeMonikerImpl_Construct(IMoniker** ppMoniker,
TRACE("(%p,%p,%p)\n",This,pmkFirst,pmkRest);
/* Initialize the virtual function table. */
This->lpvtbl1 = &VT_CompositeMonikerImpl;
This->lpvtbl2 = &VT_ROTDataImpl;
This->lpvtblMarshal= &VT_MarshalImpl;
This->IMoniker_iface.lpVtbl = &VT_CompositeMonikerImpl;
This->IROTData_iface.lpVtbl = &VT_ROTDataImpl;
This->IMarshal_iface.lpVtbl = &VT_MarshalImpl;
This->ref = 1;
This->tabSize=BLOCK_TAB_SIZE;
@ -1784,7 +1773,7 @@ CompositeMonikerImpl_Construct(IMoniker** ppMoniker,
if (!pmkFirst && !pmkRest)
{
*ppMoniker = (IMoniker *)This;
*ppMoniker = &This->IMoniker_iface;
return S_OK;
}
@ -1922,10 +1911,10 @@ CompositeMonikerImpl_Construct(IMoniker** ppMoniker,
{
*ppMoniker = This->tabMoniker[0];
IMoniker_AddRef(*ppMoniker);
IMoniker_Release((IMoniker *)This);
IMoniker_Release(&This->IMoniker_iface);
}
else
*ppMoniker = (IMoniker *)This;
*ppMoniker = &This->IMoniker_iface;
return S_OK;
}
@ -1934,8 +1923,7 @@ CompositeMonikerImpl_Construct(IMoniker** ppMoniker,
* CreateGenericComposite [OLE32.@]
******************************************************************************/
HRESULT WINAPI
CreateGenericComposite(LPMONIKER pmkFirst, LPMONIKER pmkRest,
LPMONIKER* ppmkComposite)
CreateGenericComposite(IMoniker *pmkFirst, IMoniker *pmkRest, IMoniker **ppmkComposite)
{
IMoniker* moniker = 0;
HRESULT hr = S_OK;

File diff suppressed because it is too large Load diff

View file

@ -21,6 +21,14 @@
import "unknwn.idl";
#ifdef __WIDL__
[
threading(both),
uuid(00000320-0000-0000-c000-000000000046)
]
coclass PSFactoryBuffer { interface IFactoryBuffer; }
#endif
[
uuid(99fcfe60-5260-101b-bbcb-00aa0021347a),
pointer_default(unique)

View file

@ -83,12 +83,12 @@ enum object_state
*/
struct DefaultHandler
{
const IOleObjectVtbl* lpVtbl;
const IUnknownVtbl* lpvtblIUnknown;
const IDataObjectVtbl* lpvtblIDataObject;
const IRunnableObjectVtbl* lpvtblIRunnableObject;
const IAdviseSinkVtbl *lpvtblIAdviseSink;
const IPersistStorageVtbl *lpvtblIPersistStorage;
IOleObject IOleObject_iface;
IUnknown IUnknown_iface;
IDataObject IDataObject_iface;
IRunnableObject IRunnableObject_iface;
IAdviseSink IAdviseSink_iface;
IPersistStorage IPersistStorage_iface;
/* Reference count of this object */
LONG ref;
@ -148,39 +148,39 @@ typedef struct DefaultHandler DefaultHandler;
static inline DefaultHandler *impl_from_IOleObject( IOleObject *iface )
{
return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpVtbl));
return CONTAINING_RECORD(iface, DefaultHandler, IOleObject_iface);
}
static inline DefaultHandler *impl_from_NDIUnknown( IUnknown *iface )
static inline DefaultHandler *impl_from_IUnknown( IUnknown *iface )
{
return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpvtblIUnknown));
return CONTAINING_RECORD(iface, DefaultHandler, IUnknown_iface);
}
static inline DefaultHandler *impl_from_IDataObject( IDataObject *iface )
{
return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpvtblIDataObject));
return CONTAINING_RECORD(iface, DefaultHandler, IDataObject_iface);
}
static inline DefaultHandler *impl_from_IRunnableObject( IRunnableObject *iface )
{
return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpvtblIRunnableObject));
return CONTAINING_RECORD(iface, DefaultHandler, IRunnableObject_iface);
}
static inline DefaultHandler *impl_from_IAdviseSink( IAdviseSink *iface )
{
return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpvtblIAdviseSink));
return CONTAINING_RECORD(iface, DefaultHandler, IAdviseSink_iface);
}
static inline DefaultHandler *impl_from_IPersistStorage( IPersistStorage *iface )
{
return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpvtblIPersistStorage));
return CONTAINING_RECORD(iface, DefaultHandler, IPersistStorage_iface);
}
static void DefaultHandler_Destroy(DefaultHandler* This);
static inline BOOL object_is_running(DefaultHandler *This)
{
return IRunnableObject_IsRunning((IRunnableObject*)&This->lpvtblIRunnableObject);
return IRunnableObject_IsRunning(&This->IRunnableObject_iface);
}
/*********************************************************
@ -201,7 +201,7 @@ static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
REFIID riid,
void** ppvObject)
{
DefaultHandler *This = impl_from_NDIUnknown(iface);
DefaultHandler *This = impl_from_IUnknown(iface);
if (!ppvObject)
return E_INVALIDARG;
@ -211,14 +211,14 @@ static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
if (IsEqualIID(&IID_IUnknown, riid))
*ppvObject = iface;
else if (IsEqualIID(&IID_IOleObject, riid))
*ppvObject = &This->lpVtbl;
*ppvObject = &This->IOleObject_iface;
else if (IsEqualIID(&IID_IDataObject, riid))
*ppvObject = &This->lpvtblIDataObject;
*ppvObject = &This->IDataObject_iface;
else if (IsEqualIID(&IID_IRunnableObject, riid))
*ppvObject = &This->lpvtblIRunnableObject;
*ppvObject = &This->IRunnableObject_iface;
else if (IsEqualIID(&IID_IPersist, riid) ||
IsEqualIID(&IID_IPersistStorage, riid))
*ppvObject = &This->lpvtblIPersistStorage;
*ppvObject = &This->IPersistStorage_iface;
else if (IsEqualIID(&IID_IViewObject, riid) ||
IsEqualIID(&IID_IViewObject2, riid) ||
IsEqualIID(&IID_IOleCache, riid) ||
@ -230,9 +230,7 @@ static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
}
else if (This->inproc_server && This->pOleDelegate)
{
HRESULT hr = IUnknown_QueryInterface(This->pOleDelegate, riid, ppvObject);
if (SUCCEEDED(hr))
return hr;
return IUnknown_QueryInterface(This->pOleDelegate, riid, ppvObject);
}
/* Check that we obtained an interface. */
@ -262,7 +260,7 @@ static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
IUnknown* iface)
{
DefaultHandler *This = impl_from_NDIUnknown(iface);
DefaultHandler *This = impl_from_IUnknown(iface);
return InterlockedIncrement(&This->ref);
}
@ -277,7 +275,7 @@ static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
IUnknown* iface)
{
DefaultHandler *This = impl_from_NDIUnknown(iface);
DefaultHandler *This = impl_from_IUnknown(iface);
ULONG ref;
ref = InterlockedDecrement(&This->ref);
@ -619,7 +617,7 @@ static HRESULT WINAPI DefaultHandler_DoVerb(
LPCRECT lprcPosRect)
{
DefaultHandler *This = impl_from_IOleObject(iface);
IRunnableObject *pRunnableObj = (IRunnableObject *)&This->lpvtblIRunnableObject;
IRunnableObject *pRunnableObj = &This->IRunnableObject_iface;
HRESULT hr;
TRACE("(%d, %p, %p, %d, %p, %s)\n", iVerb, lpmsg, pActiveSite, lindex, hwndParent, wine_dbgstr_rect(lprcPosRect));
@ -1330,9 +1328,7 @@ static HRESULT WINAPI DefaultHandler_Run(
This->object_state = object_state_running;
hr = IOleObject_Advise(This->pOleDelegate,
(IAdviseSink *)&This->lpvtblIAdviseSink,
&This->dwAdvConn);
hr = IOleObject_Advise(This->pOleDelegate, &This->IAdviseSink_iface, &This->dwAdvConn);
if (SUCCEEDED(hr) && This->clientSite)
hr = IOleObject_SetClientSite(This->pOleDelegate, This->clientSite);
@ -1442,7 +1438,7 @@ static ULONG WINAPI DefaultHandler_IAdviseSink_AddRef(
{
DefaultHandler *This = impl_from_IAdviseSink(iface);
return IUnknown_AddRef((IUnknown *)&This->lpvtblIUnknown);
return IUnknown_AddRef(&This->IUnknown_iface);
}
static ULONG WINAPI DefaultHandler_IAdviseSink_Release(
@ -1450,7 +1446,7 @@ static ULONG WINAPI DefaultHandler_IAdviseSink_Release(
{
DefaultHandler *This = impl_from_IAdviseSink(iface);
return IUnknown_Release((IUnknown *)&This->lpvtblIUnknown);
return IUnknown_Release(&This->IUnknown_iface);
}
static void WINAPI DefaultHandler_IAdviseSink_OnDataChange(
@ -1921,12 +1917,12 @@ static DefaultHandler* DefaultHandler_Construct(
if (!This)
return This;
This->lpVtbl = &DefaultHandler_IOleObject_VTable;
This->lpvtblIUnknown = &DefaultHandler_NDIUnknown_VTable;
This->lpvtblIDataObject = &DefaultHandler_IDataObject_VTable;
This->lpvtblIRunnableObject = &DefaultHandler_IRunnableObject_VTable;
This->lpvtblIAdviseSink = &DefaultHandler_IAdviseSink_VTable;
This->lpvtblIPersistStorage = &DefaultHandler_IPersistStorage_VTable;
This->IOleObject_iface.lpVtbl = &DefaultHandler_IOleObject_VTable;
This->IUnknown_iface.lpVtbl = &DefaultHandler_NDIUnknown_VTable;
This->IDataObject_iface.lpVtbl = &DefaultHandler_IDataObject_VTable;
This->IRunnableObject_iface.lpVtbl = &DefaultHandler_IRunnableObject_VTable;
This->IAdviseSink_iface.lpVtbl = &DefaultHandler_IAdviseSink_VTable;
This->IPersistStorage_iface.lpVtbl = &DefaultHandler_IPersistStorage_VTable;
This->inproc_server = (flags & EMBDHLP_INPROC_SERVER) ? TRUE : FALSE;
@ -1943,7 +1939,7 @@ static DefaultHandler* DefaultHandler_Construct(
* lifetime.
*/
if (!pUnkOuter)
pUnkOuter = (IUnknown*)&This->lpvtblIUnknown;
pUnkOuter = &This->IUnknown_iface;
This->outerUnknown = pUnkOuter;
@ -2119,13 +2115,13 @@ HRESULT WINAPI OleCreateEmbeddingHelper(
/*
* Make sure it supports the interface required by the caller.
*/
hr = IUnknown_QueryInterface((IUnknown*)&newHandler->lpvtblIUnknown, riid, ppvObj);
hr = IUnknown_QueryInterface(&newHandler->IUnknown_iface, riid, ppvObj);
/*
* Release the reference obtained in the constructor. If
* the QueryInterface was unsuccessful, it will free the class.
*/
IUnknown_Release((IUnknown*)&newHandler->lpvtblIUnknown);
IUnknown_Release(&newHandler->IUnknown_iface);
return hr;
}
@ -2144,11 +2140,16 @@ HRESULT WINAPI OleCreateDefaultHandler(REFCLSID clsid, LPUNKNOWN pUnkOuter,
typedef struct HandlerCF
{
const IClassFactoryVtbl *lpVtbl;
IClassFactory IClassFactory_iface;
LONG refs;
CLSID clsid;
} HandlerCF;
static inline HandlerCF *impl_from_IClassFactory(IClassFactory *iface)
{
return CONTAINING_RECORD(iface, HandlerCF, IClassFactory_iface);
}
static HRESULT WINAPI
HandlerCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid, LPVOID *ppv)
{
@ -2165,13 +2166,13 @@ HandlerCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid, LPVOID *ppv)
static ULONG WINAPI HandlerCF_AddRef(LPCLASSFACTORY iface)
{
HandlerCF *This = (HandlerCF *)iface;
HandlerCF *This = impl_from_IClassFactory(iface);
return InterlockedIncrement(&This->refs);
}
static ULONG WINAPI HandlerCF_Release(LPCLASSFACTORY iface)
{
HandlerCF *This = (HandlerCF *)iface;
HandlerCF *This = impl_from_IClassFactory(iface);
ULONG refs = InterlockedDecrement(&This->refs);
if (!refs)
HeapFree(GetProcessHeap(), 0, This);
@ -2182,7 +2183,7 @@ static HRESULT WINAPI
HandlerCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pUnk,
REFIID riid, LPVOID *ppv)
{
HandlerCF *This = (HandlerCF *)iface;
HandlerCF *This = impl_from_IClassFactory(iface);
return OleCreateDefaultHandler(&This->clsid, pUnk, riid, ppv);
}
@ -2205,11 +2206,11 @@ HRESULT HandlerCF_Create(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
HRESULT hr;
HandlerCF *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
if (!This) return E_OUTOFMEMORY;
This->lpVtbl = &HandlerClassFactoryVtbl;
This->IClassFactory_iface.lpVtbl = &HandlerClassFactoryVtbl;
This->refs = 0;
This->clsid = *rclsid;
hr = IUnknown_QueryInterface((IUnknown *)&This->lpVtbl, riid, ppv);
hr = IUnknown_QueryInterface((IUnknown *)&This->IClassFactory_iface, riid, ppv);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);

View file

@ -52,15 +52,15 @@ typedef BOOL (*enumeratefunc)(const void *k, const void *v, void *extra,
* extra is passed to c (and d, if it's provided).
* Assumes c is not NULL.
*/
struct dictionary *dictionary_create(comparefunc c, destroyfunc d, void *extra);
struct dictionary *dictionary_create(comparefunc c, destroyfunc d, void *extra) DECLSPEC_HIDDEN;
/* Assumes d is not NULL. */
void dictionary_destroy(struct dictionary *d);
void dictionary_destroy(struct dictionary *d) DECLSPEC_HIDDEN;
/* Returns how many entries have been stored in the dictionary. If two values
* with the same key are inserted, only one is counted.
*/
UINT dictionary_num_entries(struct dictionary *d);
UINT dictionary_num_entries(struct dictionary *d) DECLSPEC_HIDDEN;
/* Sets an element with key k and value v to the dictionary. If a value
* already exists with key k, its value is replaced, and the destroyfunc (if
@ -70,7 +70,7 @@ UINT dictionary_num_entries(struct dictionary *d);
* values for either the key or the value.
* Assumes d is not NULL.
*/
void dictionary_insert(struct dictionary *d, const void *k, const void *v);
void dictionary_insert(struct dictionary *d, const void *k, const void *v) DECLSPEC_HIDDEN;
/* If a value with key k has been inserted into the dictionary, *v is set
* to its associated value. Returns FALSE if the key is not found, and TRUE
@ -79,15 +79,15 @@ void dictionary_insert(struct dictionary *d, const void *k, const void *v);
* value; see dictionary_insert.)
* Assumes d and v are not NULL.
*/
BOOL dictionary_find(struct dictionary *d, const void *k, void **v);
BOOL dictionary_find(struct dictionary *d, const void *k, void **v) DECLSPEC_HIDDEN;
/* Removes the element with key k from the dictionary. Calls the destroyfunc
* for the dictionary with the element if found (so you may destroy it if it's
* dynamically allocated.)
* Assumes d is not NULL.
*/
void dictionary_remove(struct dictionary *d, const void *k);
void dictionary_remove(struct dictionary *d, const void *k) DECLSPEC_HIDDEN;
void dictionary_enumerate(struct dictionary *d, enumeratefunc e, void *closure);
void dictionary_enumerate(struct dictionary *d, enumeratefunc e, void *closure) DECLSPEC_HIDDEN;
#endif /* ndef __DICTIONARY_H__ */

View file

@ -21,14 +21,14 @@
typedef struct tagEnumSTATPROPSETSTG_impl enumx_impl;
extern HRESULT WINAPI enumx_QueryInterface(enumx_impl *, REFIID, void**);
extern ULONG WINAPI enumx_AddRef(enumx_impl *);
extern ULONG WINAPI enumx_Release(enumx_impl *);
extern HRESULT WINAPI enumx_Next(enumx_impl *, ULONG, void *, ULONG *);
extern HRESULT WINAPI enumx_Skip(enumx_impl *, ULONG);
extern HRESULT WINAPI enumx_Reset(enumx_impl *);
extern HRESULT WINAPI enumx_Clone(enumx_impl *, enumx_impl **);
extern enumx_impl *enumx_allocate(REFIID, const void *, ULONG);
extern void *enumx_add_element(enumx_impl *, const void *);
extern HRESULT WINAPI enumx_QueryInterface(enumx_impl *, REFIID, void**) DECLSPEC_HIDDEN;
extern ULONG WINAPI enumx_AddRef(enumx_impl *) DECLSPEC_HIDDEN;
extern ULONG WINAPI enumx_Release(enumx_impl *) DECLSPEC_HIDDEN;
extern HRESULT WINAPI enumx_Next(enumx_impl *, ULONG, void *, ULONG *) DECLSPEC_HIDDEN;
extern HRESULT WINAPI enumx_Skip(enumx_impl *, ULONG) DECLSPEC_HIDDEN;
extern HRESULT WINAPI enumx_Reset(enumx_impl *) DECLSPEC_HIDDEN;
extern HRESULT WINAPI enumx_Clone(enumx_impl *, enumx_impl **) DECLSPEC_HIDDEN;
extern enumx_impl *enumx_allocate(REFIID, const void *, ULONG) DECLSPEC_HIDDEN;
extern void *enumx_add_element(enumx_impl *, const void *) DECLSPEC_HIDDEN;
#endif

View file

@ -47,7 +47,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(storage);
typedef struct FileLockBytesImpl
{
const ILockBytesVtbl *lpVtbl;
ILockBytes ILockBytes_iface;
LONG ref;
ULARGE_INTEGER filesize;
HANDLE hfile;
@ -57,6 +57,11 @@ typedef struct FileLockBytesImpl
static const ILockBytesVtbl FileLockBytesImpl_Vtbl;
static inline FileLockBytesImpl *impl_from_ILockBytes(ILockBytes *iface)
{
return CONTAINING_RECORD(iface, FileLockBytesImpl, ILockBytes_iface);
}
/***********************************************************
* Prototypes for private methods
*/
@ -100,7 +105,7 @@ HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsN
if (!This)
return E_OUTOFMEMORY;
This->lpVtbl = &FileLockBytesImpl_Vtbl;
This->ILockBytes_iface.lpVtbl = &FileLockBytesImpl_Vtbl;
This->ref = 1;
This->hfile = hFile;
This->filesize.u.LowPart = GetFileSize(This->hfile,
@ -126,7 +131,7 @@ HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsN
TRACE("file len %u\n", This->filesize.u.LowPart);
*pLockBytes = (ILockBytes*)This;
*pLockBytes = &This->ILockBytes_iface;
return S_OK;
}
@ -151,13 +156,13 @@ static HRESULT WINAPI FileLockBytesImpl_QueryInterface(ILockBytes *iface, REFIID
static ULONG WINAPI FileLockBytesImpl_AddRef(ILockBytes *iface)
{
FileLockBytesImpl* This = (FileLockBytesImpl*)iface;
FileLockBytesImpl* This = impl_from_ILockBytes(iface);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI FileLockBytesImpl_Release(ILockBytes *iface)
{
FileLockBytesImpl* This = (FileLockBytesImpl*)iface;
FileLockBytesImpl* This = impl_from_ILockBytes(iface);
ULONG ref;
ref = InterlockedDecrement(&This->ref);
@ -187,7 +192,7 @@ static HRESULT WINAPI FileLockBytesImpl_ReadAt(
ULONG cb, /* [in] */
ULONG* pcbRead) /* [out] */
{
FileLockBytesImpl* This = (FileLockBytesImpl*)iface;
FileLockBytesImpl* This = impl_from_ILockBytes(iface);
ULONG bytes_left = cb;
LPBYTE readPtr = pv;
BOOL ret;
@ -242,7 +247,7 @@ static HRESULT WINAPI FileLockBytesImpl_WriteAt(
ULONG cb, /* [in] */
ULONG* pcbWritten) /* [out] */
{
FileLockBytesImpl* This = (FileLockBytesImpl*)iface;
FileLockBytesImpl* This = impl_from_ILockBytes(iface);
ULONG size_needed = ulOffset.u.LowPart + cb;
ULONG bytes_left = cb;
const BYTE *writePtr = pv;
@ -307,7 +312,7 @@ static HRESULT WINAPI FileLockBytesImpl_Flush(ILockBytes* iface)
*/
static HRESULT WINAPI FileLockBytesImpl_SetSize(ILockBytes* iface, ULARGE_INTEGER newSize)
{
FileLockBytesImpl* This = (FileLockBytesImpl*)iface;
FileLockBytesImpl* This = impl_from_ILockBytes(iface);
HRESULT hr = S_OK;
LARGE_INTEGER newpos;
@ -343,7 +348,7 @@ static HRESULT WINAPI FileLockBytesImpl_UnlockRegion(ILockBytes* iface,
static HRESULT WINAPI FileLockBytesImpl_Stat(ILockBytes* iface,
STATSTG *pstatstg, DWORD grfStatFlag)
{
FileLockBytesImpl* This = (FileLockBytesImpl*)iface;
FileLockBytesImpl* This = impl_from_ILockBytes(iface);
if (!(STATFLAG_NONAME & grfStatFlag) && This->pwcsName)
{

View file

@ -42,24 +42,21 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
/* filemoniker data structure */
typedef struct FileMonikerImpl{
const IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
/* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
* two monikers are equal. That's whay IROTData interface is implemented by monikers.
*/
const IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
LONG ref; /* reference counter for this object */
IMoniker IMoniker_iface;
IROTData IROTData_iface;
LONG ref;
LPOLESTR filePathName; /* path string identified by this filemoniker */
IUnknown *pMarshal; /* custom marshaler */
} FileMonikerImpl;
static inline IMoniker *impl_from_IROTData( IROTData *iface )
static inline FileMonikerImpl *impl_from_IMoniker(IMoniker *iface)
{
return (IMoniker *)((char*)iface - FIELD_OFFSET(FileMonikerImpl, lpvtbl2));
return CONTAINING_RECORD(iface, FileMonikerImpl, IMoniker_iface);
}
static inline FileMonikerImpl *impl_from_IROTData(IROTData *iface)
{
return CONTAINING_RECORD(iface, FileMonikerImpl, IROTData_iface);
}
/* Local function used by filemoniker implementation */
@ -72,7 +69,7 @@ static HRESULT FileMonikerImpl_Destroy(FileMonikerImpl* iface);
static HRESULT WINAPI
FileMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
{
FileMonikerImpl *This = (FileMonikerImpl *)iface;
FileMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
@ -92,7 +89,7 @@ FileMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
*ppvObject = iface;
else if (IsEqualIID(&IID_IROTData, riid))
*ppvObject = &This->lpvtbl2;
*ppvObject = &This->IROTData_iface;
else if (IsEqualIID(&IID_IMarshal, riid))
{
HRESULT hr = S_OK;
@ -119,7 +116,7 @@ FileMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
static ULONG WINAPI
FileMonikerImpl_AddRef(IMoniker* iface)
{
FileMonikerImpl *This = (FileMonikerImpl *)iface;
FileMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p)\n",iface);
@ -132,7 +129,7 @@ FileMonikerImpl_AddRef(IMoniker* iface)
static ULONG WINAPI
FileMonikerImpl_Release(IMoniker* iface)
{
FileMonikerImpl *This = (FileMonikerImpl *)iface;
FileMonikerImpl *This = impl_from_IMoniker(iface);
ULONG ref;
TRACE("(%p)\n",iface);
@ -186,6 +183,7 @@ FileMonikerImpl_IsDirty(IMoniker* iface)
static HRESULT WINAPI
FileMonikerImpl_Load(IMoniker* iface, IStream* pStm)
{
FileMonikerImpl *This = impl_from_IMoniker(iface);
HRESULT res;
CHAR* filePathA = NULL;
WCHAR* filePathW = NULL;
@ -194,7 +192,6 @@ FileMonikerImpl_Load(IMoniker* iface, IStream* pStm)
DWORD dwbuffer, bytesA, bytesW, len;
int i;
FileMonikerImpl *This = (FileMonikerImpl *)iface;
TRACE("(%p,%p)\n",iface,pStm);
@ -347,8 +344,7 @@ FileMonikerImpl_Load(IMoniker* iface, IStream* pStm)
static HRESULT WINAPI
FileMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
{
FileMonikerImpl *This = (FileMonikerImpl *)iface;
FileMonikerImpl *This = impl_from_IMoniker(iface);
HRESULT res;
LPOLESTR filePathW=This->filePathName;
CHAR* filePathA;
@ -447,7 +443,7 @@ FileMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
static HRESULT WINAPI
FileMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
{
FileMonikerImpl *This = (FileMonikerImpl *)iface;
FileMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p,%p)\n",iface,pcbSize);
@ -484,6 +480,7 @@ static HRESULT WINAPI
FileMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
REFIID riid, VOID** ppvResult)
{
FileMonikerImpl *This = impl_from_IMoniker(iface);
HRESULT res=E_FAIL;
CLSID clsID;
IUnknown* pObj=0;
@ -492,8 +489,6 @@ FileMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft
IClassFactory *pcf=0;
IClassActivator *pca=0;
FileMonikerImpl *This = (FileMonikerImpl *)iface;
*ppvResult=0;
TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvResult);
@ -784,7 +779,7 @@ FileMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker
static HRESULT WINAPI
FileMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
{
FileMonikerImpl *This = (FileMonikerImpl *)iface;
FileMonikerImpl *This = impl_from_IMoniker(iface);
CLSID clsid;
LPOLESTR filePath;
IBindCtx* bind;
@ -820,8 +815,7 @@ FileMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
static HRESULT WINAPI
FileMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
{
FileMonikerImpl *This = (FileMonikerImpl *)iface;
FileMonikerImpl *This = impl_from_IMoniker(iface);
int h = 0,i,skip,len;
int off = 0;
LPOLESTR val;
@ -886,7 +880,7 @@ static HRESULT WINAPI
FileMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc,
IMoniker* pmkToLeft, FILETIME* pFileTime)
{
FileMonikerImpl *This = (FileMonikerImpl *)iface;
FileMonikerImpl *This = impl_from_IMoniker(iface);
IRunningObjectTable* rot;
HRESULT res;
WIN32_FILE_ATTRIBUTE_DATA info;
@ -1195,8 +1189,7 @@ static HRESULT WINAPI
FileMonikerImpl_GetDisplayName(IMoniker* iface, IBindCtx* pbc,
IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName)
{
FileMonikerImpl *This = (FileMonikerImpl *)iface;
FileMonikerImpl *This = impl_from_IMoniker(iface);
int len=lstrlenW(This->filePathName);
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
@ -1252,11 +1245,11 @@ static HRESULT WINAPI
FileMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
{
IMoniker *This = impl_from_IROTData(iface);
FileMonikerImpl *This = impl_from_IROTData(iface);
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
return FileMonikerImpl_QueryInterface(This, riid, ppvObject);
return FileMonikerImpl_QueryInterface(&This->IMoniker_iface, riid, ppvObject);
}
/***********************************************************************
@ -1265,11 +1258,11 @@ FileMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObje
static ULONG WINAPI
FileMonikerROTDataImpl_AddRef(IROTData *iface)
{
IMoniker *This = impl_from_IROTData(iface);
FileMonikerImpl *This = impl_from_IROTData(iface);
TRACE("(%p)\n",This);
return IMoniker_AddRef(This);
return IMoniker_AddRef(&This->IMoniker_iface);
}
/***********************************************************************
@ -1278,11 +1271,11 @@ FileMonikerROTDataImpl_AddRef(IROTData *iface)
static ULONG WINAPI
FileMonikerROTDataImpl_Release(IROTData* iface)
{
IMoniker *This = impl_from_IROTData(iface);
FileMonikerImpl *This = impl_from_IROTData(iface);
TRACE("(%p)\n",This);
return FileMonikerImpl_Release(This);
return FileMonikerImpl_Release(&This->IMoniker_iface);
}
/******************************************************************************
@ -1292,9 +1285,8 @@ static HRESULT WINAPI
FileMonikerROTDataImpl_GetComparisonData(IROTData* iface, BYTE* pbData,
ULONG cbMax, ULONG* pcbData)
{
IMoniker *This = impl_from_IROTData(iface);
FileMonikerImpl *This1 = (FileMonikerImpl *)This;
int len = (strlenW(This1->filePathName)+1);
FileMonikerImpl *This = impl_from_IROTData(iface);
int len = strlenW(This->filePathName)+1;
int i;
LPWSTR pszFileName;
@ -1307,7 +1299,7 @@ FileMonikerROTDataImpl_GetComparisonData(IROTData* iface, BYTE* pbData,
memcpy(pbData, &CLSID_FileMoniker, sizeof(CLSID));
pszFileName = (LPWSTR)(pbData+sizeof(CLSID));
for (i = 0; i < len; i++)
pszFileName[i] = toupperW(This1->filePathName[i]);
pszFileName[i] = toupperW(This->filePathName[i]);
return S_OK;
}
@ -1367,8 +1359,8 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
TRACE("(%p,%s)\n",This,debugstr_w(lpszPathName));
/* Initialize the virtual function table. */
This->lpvtbl1 = &VT_FileMonikerImpl;
This->lpvtbl2 = &VT_ROTDataImpl;
This->IMoniker_iface.lpVtbl = &VT_FileMonikerImpl;
This->IROTData_iface.lpVtbl = &VT_ROTDataImpl;
This->ref = 0;
This->pMarshal = NULL;
@ -1427,7 +1419,7 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
/******************************************************************************
* CreateFileMoniker (OLE32.@)
******************************************************************************/
HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, LPMONIKER * ppmk)
HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, IMoniker **ppmk)
{
FileMonikerImpl* newFileMoniker;
HRESULT hr;
@ -1450,7 +1442,7 @@ HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, LPMONIKER * ppmk)
hr = FileMonikerImpl_Construct(newFileMoniker,lpszPathName);
if (SUCCEEDED(hr))
hr = IMoniker_QueryInterface((IMoniker*)newFileMoniker,&IID_IMoniker,(void**)ppmk);
hr = IMoniker_QueryInterface(&newFileMoniker->IMoniker_iface,&IID_IMoniker,(void**)ppmk);
else
HeapFree(GetProcessHeap(),0,newFileMoniker);
@ -1466,7 +1458,7 @@ static inline WCHAR *memrpbrkW(const WCHAR *ptr, size_t n, const WCHAR *accept)
}
HRESULT FileMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
LPDWORD pchEaten, LPMONIKER *ppmk)
LPDWORD pchEaten, IMoniker **ppmk)
{
LPCWSTR end;
static const WCHAR wszSeparators[] = {':','\\','/','!',0};
@ -1600,7 +1592,7 @@ static HRESULT WINAPI FileMonikerCF_CreateInstance(LPCLASSFACTORY iface,
hr = FileMonikerImpl_Construct(newFileMoniker, wszEmpty);
if (SUCCEEDED(hr))
hr = IMoniker_QueryInterface((IMoniker*)newFileMoniker, riid, ppv);
hr = IMoniker_QueryInterface(&newFileMoniker->IMoniker_iface, riid, ppv);
if (FAILED(hr))
HeapFree(GetProcessHeap(),0,newFileMoniker);

View file

@ -39,19 +39,21 @@
WINE_DEFAULT_DEBUG_CHANNEL(ole);
typedef struct _FTMarshalImpl {
const IUnknownVtbl *lpVtbl;
IUnknown IUnknown_iface;
LONG ref;
const IMarshalVtbl *lpvtblFTM;
IMarshal IMarshal_iface;
IUnknown *pUnkOuter;
} FTMarshalImpl;
#define _IFTMUnknown_(This) ((IUnknown*)&(This)->lpVtbl)
#define _IFTMarshal_(This) (&(This)->lpvtblFTM)
static inline FTMarshalImpl *impl_from_IUnknown(IUnknown *iface)
{
return CONTAINING_RECORD(iface, FTMarshalImpl, IUnknown_iface);
}
static inline FTMarshalImpl *impl_from_IMarshal( IMarshal *iface )
{
return (FTMarshalImpl *)((char*)iface - FIELD_OFFSET(FTMarshalImpl, lpvtblFTM));
return CONTAINING_RECORD(iface, FTMarshalImpl, IMarshal_iface);
}
/* inner IUnknown to handle aggregation */
@ -59,15 +61,15 @@ static HRESULT WINAPI
IiFTMUnknown_fnQueryInterface (IUnknown * iface, REFIID riid, LPVOID * ppv)
{
FTMarshalImpl *This = (FTMarshalImpl *)iface;
FTMarshalImpl *This = impl_from_IUnknown(iface);
TRACE ("\n");
*ppv = NULL;
if (IsEqualIID (&IID_IUnknown, riid))
*ppv = _IFTMUnknown_ (This);
*ppv = &This->IUnknown_iface;
else if (IsEqualIID (&IID_IMarshal, riid))
*ppv = _IFTMarshal_ (This);
*ppv = &This->IMarshal_iface;
else {
FIXME ("No interface for %s.\n", debugstr_guid (riid));
return E_NOINTERFACE;
@ -79,7 +81,7 @@ IiFTMUnknown_fnQueryInterface (IUnknown * iface, REFIID riid, LPVOID * ppv)
static ULONG WINAPI IiFTMUnknown_fnAddRef (IUnknown * iface)
{
FTMarshalImpl *This = (FTMarshalImpl *)iface;
FTMarshalImpl *This = impl_from_IUnknown(iface);
TRACE ("\n");
return InterlockedIncrement (&This->ref);
@ -88,7 +90,7 @@ static ULONG WINAPI IiFTMUnknown_fnAddRef (IUnknown * iface)
static ULONG WINAPI IiFTMUnknown_fnRelease (IUnknown * iface)
{
FTMarshalImpl *This = (FTMarshalImpl *)iface;
FTMarshalImpl *This = impl_from_IUnknown(iface);
TRACE ("\n");
if (InterlockedDecrement (&This->ref))
@ -340,12 +342,12 @@ HRESULT WINAPI CoCreateFreeThreadedMarshaler (LPUNKNOWN punkOuter, LPUNKNOWN * p
if (!ftm)
return E_OUTOFMEMORY;
ftm->lpVtbl = &iunkvt;
ftm->lpvtblFTM = &ftmvtbl;
ftm->IUnknown_iface.lpVtbl = &iunkvt;
ftm->IMarshal_iface.lpVtbl = &ftmvtbl;
ftm->ref = 1;
ftm->pUnkOuter = punkOuter ? punkOuter : _IFTMUnknown_(ftm);
ftm->pUnkOuter = punkOuter ? punkOuter : &ftm->IUnknown_iface;
*ppunkMarshal = _IFTMUnknown_ (ftm);
*ppunkMarshal = &ftm->IUnknown_iface;
return S_OK;
}

View file

@ -64,7 +64,7 @@ typedef struct StdGITEntry
/* Class data */
typedef struct StdGlobalInterfaceTableImpl
{
const IGlobalInterfaceTableVtbl *lpVtbl;
IGlobalInterfaceTable IGlobalInterfaceTable_iface;
ULONG ref;
struct list list;
@ -84,13 +84,18 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
static CRITICAL_SECTION git_section = { &critsect_debug, -1, 0, 0, 0, 0 };
/** This destroys it again. It should revoke all the held interfaces first **/
static void StdGlobalInterfaceTable_Destroy(void* self)
static inline StdGlobalInterfaceTableImpl *impl_from_IGlobalInterfaceTable(IGlobalInterfaceTable *iface)
{
TRACE("(%p)\n", self);
return CONTAINING_RECORD(iface, StdGlobalInterfaceTableImpl, IGlobalInterfaceTable_iface);
}
/** This destroys it again. It should revoke all the held interfaces first **/
static void StdGlobalInterfaceTable_Destroy(void* This)
{
TRACE("(%p)\n", This);
FIXME("Revoke held interfaces here\n");
HeapFree(GetProcessHeap(), 0, self);
HeapFree(GetProcessHeap(), 0, This);
StdGlobalInterfaceTableInstance = NULL;
}
@ -98,19 +103,18 @@ static void StdGlobalInterfaceTable_Destroy(void* self)
* A helper function to traverse the list and find the entry that matches the cookie.
* Returns NULL if not found. Must be called inside git_section critical section.
*/
static StdGITEntry*
StdGlobalInterfaceTable_FindEntry(IGlobalInterfaceTable* iface, DWORD cookie)
static StdGITEntry* StdGlobalInterfaceTable_FindEntry(StdGlobalInterfaceTableImpl* This,
DWORD cookie)
{
StdGlobalInterfaceTableImpl* const self = (StdGlobalInterfaceTableImpl*) iface;
StdGITEntry* e;
TRACE("iface=%p, cookie=0x%x\n", iface, cookie);
TRACE("This=%p, cookie=0x%x\n", This, cookie);
LIST_FOR_EACH_ENTRY(e, &self->list, StdGITEntry, entry) {
LIST_FOR_EACH_ENTRY(e, &This->list, StdGITEntry, entry) {
if (e->cookie == cookie)
return e;
}
TRACE("Entry not found\n");
return NULL;
}
@ -143,25 +147,25 @@ StdGlobalInterfaceTable_QueryInterface(IGlobalInterfaceTable* iface,
static ULONG WINAPI
StdGlobalInterfaceTable_AddRef(IGlobalInterfaceTable* iface)
{
StdGlobalInterfaceTableImpl* const self = (StdGlobalInterfaceTableImpl*) iface;
StdGlobalInterfaceTableImpl* const This = impl_from_IGlobalInterfaceTable(iface);
/* InterlockedIncrement(&self->ref); */
return self->ref;
/* InterlockedIncrement(&This->ref); */
return This->ref;
}
static ULONG WINAPI
StdGlobalInterfaceTable_Release(IGlobalInterfaceTable* iface)
{
StdGlobalInterfaceTableImpl* const self = (StdGlobalInterfaceTableImpl*) iface;
StdGlobalInterfaceTableImpl* const This = impl_from_IGlobalInterfaceTable(iface);
/* InterlockedDecrement(&self->ref); */
if (self->ref == 0) {
/* InterlockedDecrement(&This->ref); */
if (This->ref == 0) {
/* Hey ho, it's time to go, so long again 'till next weeks show! */
StdGlobalInterfaceTable_Destroy(self);
StdGlobalInterfaceTable_Destroy(This);
return 0;
}
return self->ref;
return This->ref;
}
/***
@ -173,7 +177,7 @@ StdGlobalInterfaceTable_RegisterInterfaceInGlobal(
IGlobalInterfaceTable* iface, IUnknown* pUnk,
REFIID riid, DWORD* pdwCookie)
{
StdGlobalInterfaceTableImpl* const self = (StdGlobalInterfaceTableImpl*) iface;
StdGlobalInterfaceTableImpl* const This = impl_from_IGlobalInterfaceTable(iface);
IStream* stream = NULL;
HRESULT hres;
StdGITEntry* entry;
@ -205,11 +209,11 @@ StdGlobalInterfaceTable_RegisterInterfaceInGlobal(
entry->iid = *riid;
entry->stream = stream;
entry->cookie = self->nextCookie;
self->nextCookie++; /* inc the cookie count */
entry->cookie = This->nextCookie;
This->nextCookie++; /* inc the cookie count */
/* insert the new entry at the end of the list */
list_add_tail(&self->list, &entry->entry);
list_add_tail(&This->list, &entry->entry);
/* and return the cookie */
*pdwCookie = entry->cookie;
@ -224,6 +228,7 @@ static HRESULT WINAPI
StdGlobalInterfaceTable_RevokeInterfaceFromGlobal(
IGlobalInterfaceTable* iface, DWORD dwCookie)
{
StdGlobalInterfaceTableImpl* This = impl_from_IGlobalInterfaceTable(iface);
StdGITEntry* entry;
HRESULT hr;
@ -231,7 +236,7 @@ StdGlobalInterfaceTable_RevokeInterfaceFromGlobal(
EnterCriticalSection(&git_section);
entry = StdGlobalInterfaceTable_FindEntry(iface, dwCookie);
entry = StdGlobalInterfaceTable_FindEntry(This, dwCookie);
if (entry == NULL) {
TRACE("Entry not found\n");
LeaveCriticalSection(&git_section);
@ -260,6 +265,7 @@ StdGlobalInterfaceTable_GetInterfaceFromGlobal(
IGlobalInterfaceTable* iface, DWORD dwCookie,
REFIID riid, void **ppv)
{
StdGlobalInterfaceTableImpl* This = impl_from_IGlobalInterfaceTable(iface);
StdGITEntry* entry;
HRESULT hres;
IStream *stream;
@ -268,7 +274,7 @@ StdGlobalInterfaceTable_GetInterfaceFromGlobal(
EnterCriticalSection(&git_section);
entry = StdGlobalInterfaceTable_FindEntry(iface, dwCookie);
entry = StdGlobalInterfaceTable_FindEntry(This, dwCookie);
if (entry == NULL) {
WARN("Entry for cookie 0x%x not found\n", dwCookie);
LeaveCriticalSection(&git_section);
@ -380,7 +386,7 @@ void* StdGlobalInterfaceTable_Construct(void)
newGIT = HeapAlloc(GetProcessHeap(), 0, sizeof(StdGlobalInterfaceTableImpl));
if (newGIT == 0) return newGIT;
newGIT->lpVtbl = &StdGlobalInterfaceTableImpl_Vtbl;
newGIT->IGlobalInterfaceTable_iface.lpVtbl = &StdGlobalInterfaceTableImpl_Vtbl;
newGIT->ref = 1; /* Initialise the reference count */
list_init(&newGIT->list);
newGIT->nextCookie = 0xf100; /* that's where windows starts, so that's where we start */

View file

@ -51,102 +51,41 @@ WINE_DEFAULT_DEBUG_CHANNEL(storage);
* This class implements the IStream interface and represents a stream
* supported by an HGLOBAL pointer.
*/
struct HGLOBALStreamImpl
typedef struct
{
const IStreamVtbl *lpVtbl; /* Needs to be the first item in the struct
* since we want to cast this in an IStream pointer */
IStream IStream_iface;
LONG ref;
/*
* Reference count
*/
LONG ref;
/*
* Support for the stream
*/
/* support for the stream */
HGLOBAL supportHandle;
/*
* This flag is TRUE if the HGLOBAL is destroyed when the stream
* is finally released.
*/
BOOL deleteOnRelease;
/* if TRUE the HGLOBAL is destroyed when the stream is finally released */
BOOL deleteOnRelease;
/*
* Helper variable that contains the size of the stream
*/
ULARGE_INTEGER streamSize;
/* size of the stream */
ULARGE_INTEGER streamSize;
/*
* This is the current position of the cursor in the stream
*/
ULARGE_INTEGER currentPosition;
};
/* current position of the cursor */
ULARGE_INTEGER currentPosition;
} HGLOBALStreamImpl;
typedef struct HGLOBALStreamImpl HGLOBALStreamImpl;
/***
* This is the destructor of the HGLOBALStreamImpl class.
*
* This method will clean-up all the resources used-up by the given HGLOBALStreamImpl
* class. The pointer passed-in to this function will be freed and will not
* be valid anymore.
*/
static void HGLOBALStreamImpl_Destroy(HGLOBALStreamImpl* This)
static inline HGLOBALStreamImpl *impl_from_IStream(IStream *iface)
{
TRACE("(%p)\n", This);
/*
* Release the HGlobal if the constructor asked for that.
*/
if (This->deleteOnRelease)
{
GlobalFree(This->supportHandle);
This->supportHandle=0;
}
/*
* Finally, free the memory used-up by the class.
*/
HeapFree(GetProcessHeap(), 0, This);
return CONTAINING_RECORD(iface, HGLOBALStreamImpl, IStream_iface);
}
/***
* This implements the IUnknown method AddRef for this
* class
*/
static ULONG WINAPI HGLOBALStreamImpl_AddRef(
IStream* iface)
{
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
return InterlockedIncrement(&This->ref);
}
/***
* This implements the IUnknown method QueryInterface for this
* class
*/
static HRESULT WINAPI HGLOBALStreamImpl_QueryInterface(
IStream* iface,
REFIID riid, /* [in] */
void** ppvObject) /* [iid_is][out] */
{
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
HGLOBALStreamImpl* This = impl_from_IStream(iface);
/*
* Perform a sanity check on the parameters.
*/
if (ppvObject==0)
return E_INVALIDARG;
/*
* Initialize the return parameter.
*/
*ppvObject = 0;
/*
* Compare the riid with the interface IDs implemented by this object.
*/
if (IsEqualIID(&IID_IUnknown, riid) ||
IsEqualIID(&IID_ISequentialStream, riid) ||
IsEqualIID(&IID_IStream, riid))
@ -154,42 +93,38 @@ static HRESULT WINAPI HGLOBALStreamImpl_QueryInterface(
*ppvObject = This;
}
/*
* Check that we obtained an interface.
*/
if ((*ppvObject)==0)
return E_NOINTERFACE;
/*
* Query Interface always increases the reference count by one when it is
* successful
*/
HGLOBALStreamImpl_AddRef(iface);
IStream_AddRef(iface);
return S_OK;
}
/***
* This implements the IUnknown method Release for this
* class
*/
static ULONG WINAPI HGLOBALStreamImpl_AddRef(IStream* iface)
{
HGLOBALStreamImpl* This = impl_from_IStream(iface);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI HGLOBALStreamImpl_Release(
IStream* iface)
{
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
ULONG newRef;
HGLOBALStreamImpl* This= impl_from_IStream(iface);
ULONG ref = InterlockedDecrement(&This->ref);
newRef = InterlockedDecrement(&This->ref);
/*
* If the reference count goes down to 0, perform suicide.
*/
if (newRef==0)
if (!ref)
{
HGLOBALStreamImpl_Destroy(This);
if (This->deleteOnRelease)
{
GlobalFree(This->supportHandle);
This->supportHandle = NULL;
}
HeapFree(GetProcessHeap(), 0, This);
}
return newRef;
return ref;
}
/***
@ -207,7 +142,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_Read(
ULONG cb, /* [in] */
ULONG* pcbRead) /* [out] */
{
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
HGLOBALStreamImpl* This = impl_from_IStream(iface);
void* supportBuffer;
ULONG bytesReadBuffer;
@ -217,7 +152,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_Read(
pv, cb, pcbRead);
/*
* If the caller is not interested in the nubmer of bytes read,
* If the caller is not interested in the number of bytes read,
* we use another buffer to avoid "if" statements in the code.
*/
if (pcbRead==0)
@ -281,7 +216,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_Write(
ULONG cb, /* [in] */
ULONG* pcbWritten) /* [out] */
{
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
HGLOBALStreamImpl* This = impl_from_IStream(iface);
void* supportBuffer;
ULARGE_INTEGER newSize;
@ -363,7 +298,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_Seek(
DWORD dwOrigin, /* [in] */
ULARGE_INTEGER* plibNewPosition) /* [out] */
{
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
HGLOBALStreamImpl* This = impl_from_IStream(iface);
ULARGE_INTEGER newPosition = This->currentPosition;
HRESULT hr = S_OK;
@ -428,7 +363,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_SetSize(
IStream* iface,
ULARGE_INTEGER libNewSize) /* [in] */
{
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
HGLOBALStreamImpl* This = impl_from_IStream(iface);
HGLOBAL supportHandle;
TRACE("(%p, %d)\n", iface, libNewSize.u.LowPart);
@ -593,7 +528,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_Stat(
STATSTG* pstatstg, /* [out] */
DWORD grfStatFlag) /* [in] */
{
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
HGLOBALStreamImpl* This = impl_from_IStream(iface);
memset(pstatstg, 0, sizeof(STATSTG));
@ -608,23 +543,21 @@ static HRESULT WINAPI HGLOBALStreamImpl_Clone(
IStream* iface,
IStream** ppstm) /* [out] */
{
HGLOBALStreamImpl* This = impl_from_IStream(iface);
ULARGE_INTEGER dummy;
LARGE_INTEGER offset;
HRESULT hr;
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
TRACE(" Cloning %p (deleteOnRelease=%d seek position=%ld)\n",iface,This->deleteOnRelease,(long)This->currentPosition.QuadPart);
hr=CreateStreamOnHGlobal(This->supportHandle, FALSE, ppstm);
hr = CreateStreamOnHGlobal(This->supportHandle, FALSE, ppstm);
if(FAILED(hr))
return hr;
offset.QuadPart=(LONGLONG)This->currentPosition.QuadPart;
HGLOBALStreamImpl_Seek(*ppstm,offset,STREAM_SEEK_SET,&dummy);
offset.QuadPart = (LONGLONG)This->currentPosition.QuadPart;
IStream_Seek(*ppstm, offset, STREAM_SEEK_SET, &dummy);
return S_OK;
}
/*
* Virtual function table for the HGLOBALStreamImpl class.
*/
static const IStreamVtbl HGLOBALStreamImpl_Vtbl =
static const IStreamVtbl HGLOBALStreamImplVtbl =
{
HGLOBALStreamImpl_QueryInterface,
HGLOBALStreamImpl_AddRef,
@ -642,66 +575,6 @@ static const IStreamVtbl HGLOBALStreamImpl_Vtbl =
HGLOBALStreamImpl_Clone
};
/******************************************************************************
** HGLOBALStreamImpl implementation
*/
/***
* This is the constructor for the HGLOBALStreamImpl class.
*
* Params:
* hGlobal - Handle that will support the stream. can be NULL.
* fDeleteOnRelease - Flag set to TRUE if the HGLOBAL will be released
* when the IStream object is destroyed.
*/
static HGLOBALStreamImpl* HGLOBALStreamImpl_Construct(
HGLOBAL hGlobal,
BOOL fDeleteOnRelease)
{
HGLOBALStreamImpl* newStream;
newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALStreamImpl));
if (newStream!=0)
{
/*
* Set-up the virtual function table and reference count.
*/
newStream->lpVtbl = &HGLOBALStreamImpl_Vtbl;
newStream->ref = 0;
/*
* Initialize the support.
*/
newStream->supportHandle = hGlobal;
newStream->deleteOnRelease = fDeleteOnRelease;
/*
* This method will allocate a handle if one is not supplied.
*/
if (!newStream->supportHandle)
{
newStream->supportHandle = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD |
GMEM_SHARE, 0);
}
/*
* Start the stream at the beginning.
*/
newStream->currentPosition.u.HighPart = 0;
newStream->currentPosition.u.LowPart = 0;
/*
* Initialize the size of the stream to the size of the handle.
*/
newStream->streamSize.u.HighPart = 0;
newStream->streamSize.u.LowPart = GlobalSize(newStream->supportHandle);
}
return newStream;
}
/***********************************************************************
* CreateStreamOnHGlobal [OLE32.@]
*/
@ -710,22 +583,36 @@ HRESULT WINAPI CreateStreamOnHGlobal(
BOOL fDeleteOnRelease,
LPSTREAM* ppstm)
{
HGLOBALStreamImpl* newStream;
HGLOBALStreamImpl* This;
if (!ppstm)
return E_INVALIDARG;
newStream = HGLOBALStreamImpl_Construct(hGlobal,
fDeleteOnRelease);
This = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALStreamImpl));
if (!This) return E_OUTOFMEMORY;
if (newStream!=NULL)
{
return IUnknown_QueryInterface((IUnknown*)newStream,
&IID_IStream,
(void**)ppstm);
}
This->IStream_iface.lpVtbl = &HGLOBALStreamImplVtbl;
This->ref = 1;
return E_OUTOFMEMORY;
/* initialize the support */
This->supportHandle = hGlobal;
This->deleteOnRelease = fDeleteOnRelease;
/* allocate a handle if one is not supplied */
if (!This->supportHandle)
This->supportHandle = GlobalAlloc(GMEM_MOVEABLE|GMEM_NODISCARD|GMEM_SHARE, 0);
/* start at the beginning */
This->currentPosition.u.HighPart = 0;
This->currentPosition.u.LowPart = 0;
/* initialize the size of the stream to the size of the handle */
This->streamSize.u.HighPart = 0;
This->streamSize.u.LowPart = GlobalSize(This->supportHandle);
*ppstm = &This->IStream_iface;
return S_OK;
}
/***********************************************************************
@ -743,7 +630,7 @@ HRESULT WINAPI GetHGlobalFromStream(IStream* pstm, HGLOBAL* phglobal)
/*
* Verify that the stream object was created with CreateStreamOnHGlobal.
*/
if (pStream->lpVtbl == &HGLOBALStreamImpl_Vtbl)
if (pStream->IStream_iface.lpVtbl == &HGLOBALStreamImplVtbl)
*phglobal = pStream->supportHandle;
else
{

View file

@ -50,7 +50,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(olemalloc);
static const IMallocVtbl VT_IMalloc32;
typedef struct {
const IMallocVtbl *lpVtbl;
IMalloc IMalloc_iface;
DWORD dummy; /* nothing, we are static */
IMallocSpy * pSpy; /* the spy when active */
DWORD SpyedAllocationsLeft; /* number of spyed allocations left */
@ -60,7 +60,7 @@ typedef struct {
} _Malloc32;
/* this is the static object instance */
static _Malloc32 Malloc32 = {&VT_IMalloc32, 0, NULL, 0, 0, NULL, 0};
static _Malloc32 Malloc32 = {{&VT_IMalloc32}, 0, NULL, 0, 0, NULL, 0};
/* with a spy active all calls from pre to post methods are threadsave */
static CRITICAL_SECTION IMalloc32_SpyCS;
@ -374,7 +374,7 @@ static const IMallocVtbl VT_IMalloc32 =
*/
HRESULT WINAPI CoGetMalloc(DWORD dwMemContext, LPMALLOC *lpMalloc)
{
*lpMalloc = (LPMALLOC)&Malloc32;
*lpMalloc = &Malloc32.IMalloc_iface;
return S_OK;
}
@ -392,7 +392,7 @@ HRESULT WINAPI CoGetMalloc(DWORD dwMemContext, LPMALLOC *lpMalloc)
*/
LPVOID WINAPI CoTaskMemAlloc(ULONG size)
{
return IMalloc_Alloc((LPMALLOC)&Malloc32,size);
return IMalloc_Alloc(&Malloc32.IMalloc_iface,size);
}
/***********************************************************************
@ -408,7 +408,7 @@ LPVOID WINAPI CoTaskMemAlloc(ULONG size)
*/
VOID WINAPI CoTaskMemFree(LPVOID ptr)
{
IMalloc_Free((LPMALLOC)&Malloc32, ptr);
IMalloc_Free(&Malloc32.IMalloc_iface, ptr);
}
/***********************************************************************
@ -426,7 +426,7 @@ VOID WINAPI CoTaskMemFree(LPVOID ptr)
*/
LPVOID WINAPI CoTaskMemRealloc(LPVOID pvOld, ULONG size)
{
return IMalloc_Realloc((LPMALLOC)&Malloc32, pvOld, size);
return IMalloc_Realloc(&Malloc32.IMalloc_iface, pvOld, size);
}
/***********************************************************************

View file

@ -40,26 +40,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
/* ItemMoniker data structure */
typedef struct ItemMonikerImpl{
const IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
/* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
* two monikers are equal. That's whay IROTData interface is implemented by monikers.
*/
const IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
LONG ref; /* reference counter for this object */
IMoniker IMoniker_iface; /* VTable relative to the IMoniker interface.*/
IROTData IROTData_iface; /* VTable relative to the IROTData interface.*/
LONG ref;
LPOLESTR itemName; /* item name identified by this ItemMoniker */
LPOLESTR itemDelimiter; /* Delimiter string */
IUnknown *pMarshal; /* custom marshaler */
} ItemMonikerImpl;
static inline IMoniker *impl_from_IROTData( IROTData *iface )
static inline ItemMonikerImpl *impl_from_IMoniker(IMoniker *iface)
{
return (IMoniker *)((char*)iface - FIELD_OFFSET(ItemMonikerImpl, lpvtbl2));
return CONTAINING_RECORD(iface, ItemMonikerImpl, IMoniker_iface);
}
static inline ItemMonikerImpl *impl_from_IROTData(IROTData *iface)
{
return CONTAINING_RECORD(iface, ItemMonikerImpl, IROTData_iface);
}
static HRESULT ItemMonikerImpl_Destroy(ItemMonikerImpl* iface);
@ -69,27 +65,21 @@ static HRESULT ItemMonikerImpl_Destroy(ItemMonikerImpl* iface);
*******************************************************************************/
static HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
{
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
ItemMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
/* Perform a sanity check on the parameters.*/
if ( (This==0) || (ppvObject==0) )
return E_INVALIDARG;
/* Initialize the return parameter */
*ppvObject = 0;
/* Compare the riid with the interface IDs implemented by this object.*/
if (IsEqualIID(&IID_IUnknown, riid) ||
IsEqualIID(&IID_IPersist, riid) ||
IsEqualIID(&IID_IPersistStream, riid) ||
IsEqualIID(&IID_IMoniker, riid)
)
*ppvObject = iface;
if (!ppvObject)
return E_INVALIDARG;
/* Compare the riid with the interface IDs implemented by this object.*/
if (IsEqualIID(&IID_IUnknown, riid) ||
IsEqualIID(&IID_IPersist, riid) ||
IsEqualIID(&IID_IPersistStream, riid) ||
IsEqualIID(&IID_IMoniker, riid))
*ppvObject = iface;
else if (IsEqualIID(&IID_IROTData, riid))
*ppvObject = &This->lpvtbl2;
*ppvObject = &This->IROTData_iface;
else if (IsEqualIID(&IID_IMarshal, riid))
{
HRESULT hr = S_OK;
@ -99,15 +89,14 @@ static HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid
return hr;
return IUnknown_QueryInterface(This->pMarshal, riid, ppvObject);
}
/* Check that we obtained an interface.*/
if ((*ppvObject)==0)
else
{
*ppvObject = NULL;
return E_NOINTERFACE;
}
/* Query Interface always increases the reference count by one when it is successful */
IMoniker_AddRef(iface);
return S_OK;
IMoniker_AddRef(iface);
return S_OK;
}
/******************************************************************************
@ -115,7 +104,7 @@ static HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid
******************************************************************************/
static ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface)
{
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
ItemMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p)\n",This);
@ -127,7 +116,7 @@ static ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface)
******************************************************************************/
static ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface)
{
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
ItemMonikerImpl *This = impl_from_IMoniker(iface);
ULONG ref;
TRACE("(%p)\n",This);
@ -174,8 +163,7 @@ static HRESULT WINAPI ItemMonikerImpl_IsDirty(IMoniker* iface)
******************************************************************************/
static HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface,IStream* pStm)
{
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
ItemMonikerImpl *This = impl_from_IMoniker(iface);
HRESULT res;
DWORD delimiterLength,nameLength,lenW;
CHAR *itemNameA,*itemDelimiterA;
@ -241,11 +229,9 @@ static HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface,IStream* pStm)
/******************************************************************************
* ItemMoniker_Save
******************************************************************************/
static HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface,
IStream* pStm,/* pointer to the stream where the object is to be saved */
BOOL fClearDirty)/* Specifies whether to clear the dirty flag */
static HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
{
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
ItemMonikerImpl *This = impl_from_IMoniker(iface);
HRESULT res;
CHAR *itemNameA,*itemDelimiterA;
@ -277,10 +263,9 @@ static HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface,
/******************************************************************************
* ItemMoniker_GetSizeMax
******************************************************************************/
static HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface,
ULARGE_INTEGER* pcbSize)/* Pointer to size of stream needed to save object */
static HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
{
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
ItemMonikerImpl *This = impl_from_IMoniker(iface);
DWORD delimiterLength=lstrlenW(This->itemDelimiter)+1;
DWORD nameLength=lstrlenW(This->itemName)+1;
@ -310,8 +295,7 @@ static HRESULT WINAPI ItemMonikerImpl_BindToObject(IMoniker* iface,
REFIID riid,
VOID** ppvResult)
{
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
ItemMonikerImpl *This = impl_from_IMoniker(iface);
HRESULT res;
IID refid=IID_IOleItemContainer;
IOleItemContainer *poic=0;
@ -347,8 +331,7 @@ static HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker* iface,
REFIID riid,
VOID** ppvResult)
{
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
ItemMonikerImpl *This = impl_from_IMoniker(iface);
HRESULT res;
IOleItemContainer *poic=0;
@ -519,7 +502,7 @@ static HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOther
******************************************************************************/
static HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
{
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
ItemMonikerImpl *This = impl_from_IMoniker(iface);
DWORD h = 0;
int i,len;
int off = 0;
@ -547,10 +530,10 @@ static HRESULT WINAPI ItemMonikerImpl_IsRunning(IMoniker* iface,
IMoniker* pmkToLeft,
IMoniker* pmkNewlyRunning)
{
ItemMonikerImpl *This = impl_from_IMoniker(iface);
IRunningObjectTable* rot;
HRESULT res;
IOleItemContainer *poic=0;
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning);
@ -695,7 +678,7 @@ static HRESULT WINAPI ItemMonikerImpl_GetDisplayName(IMoniker* iface,
IMoniker* pmkToLeft,
LPOLESTR *ppszDisplayName)
{
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
ItemMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
@ -729,11 +712,11 @@ static HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(IMoniker* iface,
ULONG* pchEaten,
IMoniker** ppmkOut)
{
ItemMonikerImpl *This = impl_from_IMoniker(iface);
IOleItemContainer* poic=0;
IParseDisplayName* ppdn=0;
LPOLESTR displayName;
HRESULT res;
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
TRACE("%s\n", debugstr_w(pszDisplayName));
@ -781,14 +764,15 @@ static HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwd
/*******************************************************************************
* ItemMonikerIROTData_QueryInterface
*******************************************************************************/
static HRESULT WINAPI ItemMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
static HRESULT WINAPI ItemMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,
void **ppvObject)
{
IMoniker *This = impl_from_IROTData(iface);
ItemMonikerImpl *This = impl_from_IROTData(iface);
TRACE("(%p,%p,%p)\n",iface,riid,ppvObject);
return ItemMonikerImpl_QueryInterface(This, riid, ppvObject);
return ItemMonikerImpl_QueryInterface(&This->IMoniker_iface, riid, ppvObject);
}
/***********************************************************************
@ -796,11 +780,11 @@ static HRESULT WINAPI ItemMonikerROTDataImpl_QueryInterface(IROTData *iface,REFI
*/
static ULONG WINAPI ItemMonikerROTDataImpl_AddRef(IROTData *iface)
{
IMoniker *This = impl_from_IROTData(iface);
ItemMonikerImpl *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
return ItemMonikerImpl_AddRef(This);
return ItemMonikerImpl_AddRef(&This->IMoniker_iface);
}
/***********************************************************************
@ -808,11 +792,11 @@ static ULONG WINAPI ItemMonikerROTDataImpl_AddRef(IROTData *iface)
*/
static ULONG WINAPI ItemMonikerROTDataImpl_Release(IROTData* iface)
{
IMoniker *This = impl_from_IROTData(iface);
ItemMonikerImpl *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
return ItemMonikerImpl_Release(This);
return ItemMonikerImpl_Release(&This->IMoniker_iface);
}
/******************************************************************************
@ -823,9 +807,8 @@ static HRESULT WINAPI ItemMonikerROTDataImpl_GetComparisonData(IROTData* iface,
ULONG cbMax,
ULONG* pcbData)
{
IMoniker *This = impl_from_IROTData(iface);
ItemMonikerImpl *This1 = (ItemMonikerImpl *)This;
int len = (strlenW(This1->itemName)+1);
ItemMonikerImpl *This = impl_from_IROTData(iface);
int len = (strlenW(This->itemName)+1);
int i;
LPWSTR pszItemName;
LPWSTR pszItemDelimiter;
@ -840,11 +823,11 @@ static HRESULT WINAPI ItemMonikerROTDataImpl_GetComparisonData(IROTData* iface,
memcpy(pbData, &CLSID_ItemMoniker, sizeof(CLSID));
/* write delimiter */
pszItemDelimiter = (LPWSTR)(pbData+sizeof(CLSID));
*pszItemDelimiter = *This1->itemDelimiter;
*pszItemDelimiter = *This->itemDelimiter;
/* write name */
pszItemName = pszItemDelimiter + 1;
for (i = 0; i < len; i++)
pszItemName[i] = toupperW(This1->itemName[i]);
pszItemName[i] = toupperW(This->itemName[i]);
return S_OK;
}
@ -902,8 +885,8 @@ static HRESULT ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDe
TRACE("(%p,%s,%s)\n",This,debugstr_w(lpszDelim),debugstr_w(lpszItem));
/* Initialize the virtual function table. */
This->lpvtbl1 = &VT_ItemMonikerImpl;
This->lpvtbl2 = &VT_ROTDataImpl;
This->IMoniker_iface.lpVtbl = &VT_ItemMonikerImpl;
This->IROTData_iface.lpVtbl = &VT_ROTDataImpl;
This->ref = 0;
This->pMarshal = NULL;
@ -945,7 +928,7 @@ static HRESULT ItemMonikerImpl_Destroy(ItemMonikerImpl* This)
/******************************************************************************
* CreateItemMoniker [OLE32.@]
******************************************************************************/
HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim,LPCOLESTR lpszItem, LPMONIKER * ppmk)
HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim, LPCOLESTR lpszItem, IMoniker **ppmk)
{
ItemMonikerImpl* newItemMoniker;
HRESULT hr;
@ -965,7 +948,8 @@ HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim,LPCOLESTR lpszItem, LPMONI
return hr;
}
return ItemMonikerImpl_QueryInterface((IMoniker*)newItemMoniker,&IID_IMoniker,(void**)ppmk);
return ItemMonikerImpl_QueryInterface(&newItemMoniker->IMoniker_iface,&IID_IMoniker,
(void**)ppmk);
}
static HRESULT WINAPI ItemMonikerCF_QueryInterface(LPCLASSFACTORY iface,
@ -1012,7 +996,7 @@ static HRESULT WINAPI ItemMonikerCF_CreateInstance(LPCLASSFACTORY iface,
hr = ItemMonikerImpl_Construct(newItemMoniker, wszEmpty, wszEmpty);
if (SUCCEEDED(hr))
hr = ItemMonikerImpl_QueryInterface((IMoniker*)newItemMoniker, riid, ppv);
hr = ItemMonikerImpl_QueryInterface(&newItemMoniker->IMoniker_iface, riid, ppv);
if (FAILED(hr))
HeapFree(GetProcessHeap(),0,newItemMoniker);

View file

@ -52,6 +52,37 @@ extern const CLSID CLSID_DfMarshal;
* when the proxy disconnects or is destroyed */
#define SORFP_NOLIFETIMEMGMT SORF_OXRES2
/* imported object / proxy manager */
struct proxy_manager
{
const IMultiQIVtbl *lpVtbl;
const IMarshalVtbl *lpVtblMarshal;
const IClientSecurityVtbl *lpVtblCliSec;
struct apartment *parent; /* owning apartment (RO) */
struct list entry; /* entry in apartment (CS parent->cs) */
OXID oxid; /* object exported ID (RO) */
OXID_INFO oxid_info; /* string binding, ipid of rem unknown and other information (RO) */
OID oid; /* object ID (RO) */
struct list interfaces; /* imported interfaces (CS cs) */
LONG refs; /* proxy reference count (LOCK) */
CRITICAL_SECTION cs; /* thread safety for this object and children */
ULONG sorflags; /* STDOBJREF flags (RO) */
IRemUnknown *remunk; /* proxy to IRemUnknown used for lifecycle management (CS cs) */
HANDLE remoting_mutex; /* mutex used for synchronizing access to IRemUnknown */
MSHCTX dest_context; /* context used for activating optimisations (LOCK) */
void *dest_context_data; /* reserved context value (LOCK) */
};
static inline struct proxy_manager *impl_from_IMarshal( IMarshal *iface )
{
return (struct proxy_manager *)((char*)iface - FIELD_OFFSET(struct proxy_manager, lpVtblMarshal));
}
static inline struct proxy_manager *impl_from_IClientSecurity( IClientSecurity *iface )
{
return (struct proxy_manager *)((char*)iface - FIELD_OFFSET(struct proxy_manager, lpVtblCliSec));
}
static HRESULT unmarshal_object(const STDOBJREF *stdobjref, APARTMENT *apt,
MSHCTX dest_context, void *dest_context_data,
REFIID riid, const OXID_INFO *oxid_info,
@ -352,19 +383,19 @@ static HRESULT WINAPI StdMarshalImpl_DisconnectObject(LPMARSHAL iface, DWORD dwR
static HRESULT WINAPI Proxy_QueryInterface(IMarshal *iface, REFIID riid, void **ppvObject)
{
ICOM_THIS_MULTI(struct proxy_manager, lpVtblMarshal, iface);
struct proxy_manager *This = impl_from_IMarshal( iface );
return IMultiQI_QueryInterface((IMultiQI *)&This->lpVtbl, riid, ppvObject);
}
static ULONG WINAPI Proxy_AddRef(IMarshal *iface)
{
ICOM_THIS_MULTI(struct proxy_manager, lpVtblMarshal, iface);
struct proxy_manager *This = impl_from_IMarshal( iface );
return IMultiQI_AddRef((IMultiQI *)&This->lpVtbl);
}
static ULONG WINAPI Proxy_Release(IMarshal *iface)
{
ICOM_THIS_MULTI(struct proxy_manager, lpVtblMarshal, iface);
struct proxy_manager *This = impl_from_IMarshal( iface );
return IMultiQI_Release((IMultiQI *)&This->lpVtbl);
}
@ -372,7 +403,7 @@ static HRESULT WINAPI Proxy_MarshalInterface(
LPMARSHAL iface, IStream *pStm, REFIID riid, void* pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags)
{
ICOM_THIS_MULTI(struct proxy_manager, lpVtblMarshal, iface);
struct proxy_manager *This = impl_from_IMarshal( iface );
HRESULT hr;
struct ifproxy *ifproxy;
@ -497,19 +528,19 @@ static const IMarshalVtbl ProxyMarshal_Vtbl =
static HRESULT WINAPI ProxyCliSec_QueryInterface(IClientSecurity *iface, REFIID riid, void **ppvObject)
{
ICOM_THIS_MULTI(struct proxy_manager, lpVtblCliSec, iface);
struct proxy_manager *This = impl_from_IClientSecurity( iface );
return IMultiQI_QueryInterface((IMultiQI *)&This->lpVtbl, riid, ppvObject);
}
static ULONG WINAPI ProxyCliSec_AddRef(IClientSecurity *iface)
{
ICOM_THIS_MULTI(struct proxy_manager, lpVtblCliSec, iface);
struct proxy_manager *This = impl_from_IClientSecurity( iface );
return IMultiQI_AddRef((IMultiQI *)&This->lpVtbl);
}
static ULONG WINAPI ProxyCliSec_Release(IClientSecurity *iface)
{
ICOM_THIS_MULTI(struct proxy_manager, lpVtblCliSec, iface);
struct proxy_manager *This = impl_from_IClientSecurity( iface );
return IMultiQI_Release((IMultiQI *)&This->lpVtbl);
}

View file

@ -165,7 +165,7 @@ HRESULT WINAPI GetHGlobalFromILockBytes(ILockBytes* plkbyt, HGLOBAL* phglobal)
ERR("Cannot ILockBytes_Stat, %x\n",hres);
return hres;
}
FIXME("cbSize is %d\n",stbuf.cbSize.u.LowPart);
TRACE("cbSize is %s\n", wine_dbgstr_longlong(stbuf.cbSize.QuadPart));
*phglobal = GlobalAlloc( GMEM_MOVEABLE|GMEM_SHARE, stbuf.cbSize.u.LowPart);
if (!*phglobal)
return E_INVALIDARG;

View file

@ -71,7 +71,7 @@ struct rot_entry
/* define the RunningObjectTableImpl structure */
typedef struct RunningObjectTableImpl
{
const IRunningObjectTableVtbl *lpVtbl;
IRunningObjectTable IRunningObjectTable_iface;
LONG ref;
struct list rot; /* list of ROT entries */
@ -84,13 +84,22 @@ static IrotHandle irot_handle;
/* define the EnumMonikerImpl structure */
typedef struct EnumMonikerImpl
{
const IEnumMonikerVtbl *lpVtbl;
IEnumMoniker IEnumMoniker_iface;
LONG ref;
InterfaceList *moniker_list;
ULONG pos;
} EnumMonikerImpl;
static inline RunningObjectTableImpl *impl_from_IRunningObjectTable(IRunningObjectTable *iface)
{
return CONTAINING_RECORD(iface, RunningObjectTableImpl, IRunningObjectTable_iface);
}
static inline EnumMonikerImpl *impl_from_IEnumMoniker(IEnumMoniker *iface)
{
return CONTAINING_RECORD(iface, EnumMonikerImpl, IEnumMoniker_iface);
}
/* IEnumMoniker Local functions*/
static HRESULT EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList *moniker_list,
@ -159,7 +168,7 @@ static HRESULT create_stream_on_mip_ro(const InterfaceData *mip, IStream **strea
return CreateStreamOnHGlobal(hglobal, TRUE, stream);
}
static inline void rot_entry_delete(struct rot_entry *rot_entry)
static void rot_entry_delete(struct rot_entry *rot_entry)
{
if (rot_entry->cookie)
{
@ -294,7 +303,7 @@ static HRESULT WINAPI
RunningObjectTableImpl_QueryInterface(IRunningObjectTable* iface,
REFIID riid,void** ppvObject)
{
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
RunningObjectTableImpl *This = impl_from_IRunningObjectTable(iface);
TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
@ -323,7 +332,7 @@ RunningObjectTableImpl_QueryInterface(IRunningObjectTable* iface,
static ULONG WINAPI
RunningObjectTableImpl_AddRef(IRunningObjectTable* iface)
{
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
RunningObjectTableImpl *This = impl_from_IRunningObjectTable(iface);
TRACE("(%p)\n",This);
@ -373,7 +382,7 @@ RunningObjectTableImpl_Destroy(void)
static ULONG WINAPI
RunningObjectTableImpl_Release(IRunningObjectTable* iface)
{
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
RunningObjectTableImpl *This = impl_from_IRunningObjectTable(iface);
ULONG ref;
TRACE("(%p)\n",This);
@ -411,7 +420,7 @@ static HRESULT WINAPI
RunningObjectTableImpl_Register(IRunningObjectTable* iface, DWORD grfFlags,
IUnknown *punkObject, IMoniker *pmkObjectName, DWORD *pdwRegister)
{
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
RunningObjectTableImpl *This = impl_from_IRunningObjectTable(iface);
struct rot_entry *rot_entry;
HRESULT hr = S_OK;
IStream *pStream = NULL;
@ -582,7 +591,7 @@ RunningObjectTableImpl_Register(IRunningObjectTable* iface, DWORD grfFlags,
static HRESULT WINAPI
RunningObjectTableImpl_Revoke( IRunningObjectTable* iface, DWORD dwRegister)
{
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
RunningObjectTableImpl *This = impl_from_IRunningObjectTable(iface);
struct rot_entry *rot_entry;
TRACE("(%p,%d)\n",This,dwRegister);
@ -613,7 +622,7 @@ RunningObjectTableImpl_Revoke( IRunningObjectTable* iface, DWORD dwRegister)
static HRESULT WINAPI
RunningObjectTableImpl_IsRunning( IRunningObjectTable* iface, IMoniker *pmkObjectName)
{
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
RunningObjectTableImpl *This = impl_from_IRunningObjectTable(iface);
MonikerComparisonData *moniker_data;
HRESULT hr;
const struct rot_entry *rot_entry;
@ -679,7 +688,7 @@ static HRESULT WINAPI
RunningObjectTableImpl_GetObject( IRunningObjectTable* iface,
IMoniker *pmkObjectName, IUnknown **ppunkObject)
{
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
RunningObjectTableImpl *This = impl_from_IRunningObjectTable(iface);
MonikerComparisonData *moniker_data;
InterfaceData *object = NULL;
IrotCookie cookie;
@ -773,7 +782,7 @@ static HRESULT WINAPI
RunningObjectTableImpl_NoteChangeTime(IRunningObjectTable* iface,
DWORD dwRegister, FILETIME *pfiletime)
{
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
RunningObjectTableImpl *This = impl_from_IRunningObjectTable(iface);
struct rot_entry *rot_entry;
HRESULT hr = E_INVALIDARG;
@ -828,7 +837,7 @@ RunningObjectTableImpl_GetTimeOfLastChange(IRunningObjectTable* iface,
IMoniker *pmkObjectName, FILETIME *pfiletime)
{
HRESULT hr = MK_E_UNAVAILABLE;
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
RunningObjectTableImpl *This = impl_from_IRunningObjectTable(iface);
MonikerComparisonData *moniker_data;
const struct rot_entry *rot_entry;
@ -898,7 +907,7 @@ static HRESULT WINAPI
RunningObjectTableImpl_EnumRunning(IRunningObjectTable* iface,
IEnumMoniker **ppenumMoniker)
{
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
RunningObjectTableImpl *This = impl_from_IRunningObjectTable(iface);
InterfaceList *interface_list = NULL;
HRESULT hr;
@ -961,7 +970,7 @@ HRESULT WINAPI RunningObjectTableImpl_Initialize(void)
return E_OUTOFMEMORY;
/* initialize the virtual table function */
runningObjectTableInstance->lpVtbl = &VT_RunningObjectTableImpl;
runningObjectTableInstance->IRunningObjectTable_iface.lpVtbl = &VT_RunningObjectTableImpl;
/* the initial reference is set to "1" so that it isn't destroyed after its
* first use until the process is destroyed, as the running object table is
@ -985,7 +994,7 @@ HRESULT WINAPI RunningObjectTableImpl_UnInitialize(void)
if (runningObjectTableInstance==NULL)
return E_POINTER;
RunningObjectTableImpl_Release((IRunningObjectTable*)runningObjectTableInstance);
RunningObjectTableImpl_Release(&runningObjectTableInstance->IRunningObjectTable_iface);
RunningObjectTableImpl_Destroy();
@ -1019,7 +1028,8 @@ GetRunningObjectTable(DWORD reserved, LPRUNNINGOBJECTTABLE *pprot)
if(runningObjectTableInstance==NULL)
return CO_E_NOTINITIALIZED;
res = IRunningObjectTable_QueryInterface((IRunningObjectTable*)runningObjectTableInstance,&riid,(void**)pprot);
res = IRunningObjectTable_QueryInterface(&runningObjectTableInstance->IRunningObjectTable_iface,
&riid,(void**)pprot);
return res;
}
@ -1277,7 +1287,7 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
*/
static HRESULT WINAPI EnumMonikerImpl_QueryInterface(IEnumMoniker* iface,REFIID riid,void** ppvObject)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
@ -1306,7 +1316,7 @@ static HRESULT WINAPI EnumMonikerImpl_QueryInterface(IEnumMoniker* iface,REFIID
*/
static ULONG WINAPI EnumMonikerImpl_AddRef(IEnumMoniker* iface)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
TRACE("(%p)\n",This);
@ -1318,7 +1328,7 @@ static ULONG WINAPI EnumMonikerImpl_AddRef(IEnumMoniker* iface)
*/
static ULONG WINAPI EnumMonikerImpl_Release(IEnumMoniker* iface)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
ULONG ref;
TRACE("(%p)\n",This);
@ -1346,7 +1356,7 @@ static ULONG WINAPI EnumMonikerImpl_Release(IEnumMoniker* iface)
static HRESULT WINAPI EnumMonikerImpl_Next(IEnumMoniker* iface, ULONG celt, IMoniker** rgelt, ULONG * pceltFetched)
{
ULONG i;
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
HRESULT hr = S_OK;
TRACE("(%p) TabCurrentPos %d Tablastindx %d\n", This, This->pos, This->moniker_list->size);
@ -1380,7 +1390,7 @@ static HRESULT WINAPI EnumMonikerImpl_Next(IEnumMoniker* iface, ULONG celt, IM
*/
static HRESULT WINAPI EnumMonikerImpl_Skip(IEnumMoniker* iface, ULONG celt)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
TRACE("(%p)\n",This);
@ -1397,7 +1407,7 @@ static HRESULT WINAPI EnumMonikerImpl_Skip(IEnumMoniker* iface, ULONG celt)
*/
static HRESULT WINAPI EnumMonikerImpl_Reset(IEnumMoniker* iface)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
This->pos = 0; /* set back to start of list */
@ -1411,7 +1421,7 @@ static HRESULT WINAPI EnumMonikerImpl_Reset(IEnumMoniker* iface)
*/
static HRESULT WINAPI EnumMonikerImpl_Clone(IEnumMoniker* iface, IEnumMoniker ** ppenum)
{
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
InterfaceList *moniker_list;
ULONG i;
@ -1475,14 +1485,14 @@ static HRESULT EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList *moniker_list,
TRACE("(%p)\n", This);
/* initialize the virtual table function */
This->lpVtbl = &VT_EnumMonikerImpl;
This->IEnumMoniker_iface.lpVtbl = &VT_EnumMonikerImpl;
/* the initial reference is set to "1" */
This->ref = 1; /* set the ref count to one */
This->pos = current_pos; /* Set the list start posn */
This->moniker_list = moniker_list;
*ppenumMoniker = (IEnumMoniker*)This;
*ppenumMoniker = &This->IEnumMoniker_iface;
return S_OK;
}
@ -1493,27 +1503,32 @@ static HRESULT EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList *moniker_list,
typedef struct MonikerMarshal
{
const IUnknownVtbl *lpVtbl;
const IMarshalVtbl *lpVtblMarshal;
IUnknown IUnknown_iface;
IMarshal IMarshal_iface;
LONG ref;
IMoniker *moniker;
} MonikerMarshal;
static inline MonikerMarshal *impl_from_IUnknown(IUnknown *iface)
{
return CONTAINING_RECORD(iface, MonikerMarshal, IUnknown_iface);
}
static inline MonikerMarshal *impl_from_IMarshal( IMarshal *iface )
{
return (MonikerMarshal *)((char*)iface - FIELD_OFFSET(MonikerMarshal, lpVtblMarshal));
return CONTAINING_RECORD(iface, MonikerMarshal, IMarshal_iface);
}
static HRESULT WINAPI MonikerMarshalInner_QueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppv)
{
MonikerMarshal *This = (MonikerMarshal *)iface;
MonikerMarshal *This = impl_from_IUnknown(iface);
TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
*ppv = NULL;
if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IMarshal, riid))
{
*ppv = &This->lpVtblMarshal;
IUnknown_AddRef((IUnknown *)&This->lpVtblMarshal);
*ppv = &This->IMarshal_iface;
IUnknown_AddRef((IUnknown *)&This->IMarshal_iface);
return S_OK;
}
FIXME("No interface for %s\n", debugstr_guid(riid));
@ -1522,13 +1537,13 @@ static HRESULT WINAPI MonikerMarshalInner_QueryInterface(IUnknown *iface, REFIID
static ULONG WINAPI MonikerMarshalInner_AddRef(IUnknown *iface)
{
MonikerMarshal *This = (MonikerMarshal *)iface;
MonikerMarshal *This = impl_from_IUnknown(iface);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI MonikerMarshalInner_Release(IUnknown *iface)
{
MonikerMarshal *This = (MonikerMarshal *)iface;
MonikerMarshal *This = impl_from_IUnknown(iface);
ULONG ref = InterlockedDecrement(&This->ref);
if (!ref) HeapFree(GetProcessHeap(), 0, This);
@ -1648,12 +1663,12 @@ HRESULT MonikerMarshal_Create(IMoniker *inner, IUnknown **outer)
MonikerMarshal *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
if (!This) return E_OUTOFMEMORY;
This->lpVtbl = &VT_MonikerMarshalInner;
This->lpVtblMarshal = &VT_MonikerMarshal;
This->IUnknown_iface.lpVtbl = &VT_MonikerMarshalInner;
This->IMarshal_iface.lpVtbl = &VT_MonikerMarshal;
This->ref = 1;
This->moniker = inner;
*outer = (IUnknown *)&This->lpVtbl;
*outer = &This->IUnknown_iface;
return S_OK;
}

View file

@ -30,23 +30,23 @@ DEFINE_OLEGUID( CLSID_CompositeMoniker, 0x309, 0, 0 );
DEFINE_OLEGUID( CLSID_ClassMoniker, 0x31a, 0, 0 );
DEFINE_OLEGUID( CLSID_PointerMoniker, 0x306, 0, 0 );
HRESULT FileMonikerCF_Create(REFIID riid, LPVOID *ppv);
HRESULT ItemMonikerCF_Create(REFIID riid, LPVOID *ppv);
HRESULT AntiMonikerCF_Create(REFIID riid, LPVOID *ppv);
HRESULT CompositeMonikerCF_Create(REFIID riid, LPVOID *ppv);
HRESULT ClassMonikerCF_Create(REFIID riid, LPVOID *ppv);
HRESULT PointerMonikerCF_Create(REFIID riid, LPVOID *ppv);
HRESULT ComCatCF_Create(REFIID riid, LPVOID *ppv);
HRESULT FileMonikerCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
HRESULT ItemMonikerCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
HRESULT AntiMonikerCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
HRESULT CompositeMonikerCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
HRESULT ClassMonikerCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
HRESULT PointerMonikerCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
HRESULT ComCatCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
/* This function decomposes a String path to a String Table containing all the elements ("\" or "subDirectory" or "Directory" or "FileName") of the path */
int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable);
int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable) DECLSPEC_HIDDEN;
HRESULT FileMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
LPDWORD pchEaten, LPMONIKER *ppmk);
LPDWORD pchEaten, LPMONIKER *ppmk) DECLSPEC_HIDDEN;
HRESULT ClassMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
LPDWORD pchEaten, LPMONIKER *ppmk);
LPDWORD pchEaten, LPMONIKER *ppmk) DECLSPEC_HIDDEN;
HRESULT MonikerMarshal_Create(IMoniker *inner, IUnknown **outer);
HRESULT MonikerMarshal_Create(IMoniker *inner, IUnknown **outer) DECLSPEC_HIDDEN;
#endif /* __WINE_MONIKER_H__ */

View file

@ -382,10 +382,12 @@ static HRESULT create_stream_from_map(HANDLE map, IStream **stream)
* IDropTarget::QueryInterface(). Windows doesn't expose this because it
* doesn't call CoMarshallInterface() in RegisterDragDrop().
* The wrapper is only used internally, and only exists for the life of
* the marshal. */
* the marshal. We don't want to hold a ref on the app provided target
* as some apps destroy this prior to CoUninitialize without calling
* RevokeDragDrop. The only (long-term) ref is held by the window prop. */
typedef struct {
IDropTarget IDropTarget_iface;
IDropTarget* inner;
HWND hwnd;
LONG refs;
} DropTargetWrapper;
@ -420,22 +422,34 @@ static ULONG WINAPI DropTargetWrapper_Release(IDropTarget* iface)
{
DropTargetWrapper* This = impl_from_IDropTarget(iface);
ULONG refs = InterlockedDecrement(&This->refs);
if (!refs)
{
IDropTarget_Release(This->inner);
HeapFree(GetProcessHeap(), 0, This);
}
if (!refs) HeapFree(GetProcessHeap(), 0, This);
return refs;
}
static inline HRESULT get_target_from_wrapper( IDropTarget *wrapper, IDropTarget **target )
{
DropTargetWrapper* This = impl_from_IDropTarget( wrapper );
*target = GetPropW( This->hwnd, prop_oledroptarget );
if (!*target) return DRAGDROP_E_NOTREGISTERED;
IDropTarget_AddRef( *target );
return S_OK;
}
static HRESULT WINAPI DropTargetWrapper_DragEnter(IDropTarget* iface,
IDataObject* pDataObj,
DWORD grfKeyState,
POINTL pt,
DWORD* pdwEffect)
{
DropTargetWrapper* This = impl_from_IDropTarget(iface);
return IDropTarget_DragEnter(This->inner, pDataObj, grfKeyState, pt, pdwEffect);
IDropTarget *target;
HRESULT r = get_target_from_wrapper( iface, &target );
if (SUCCEEDED( r ))
{
r = IDropTarget_DragEnter( target, pDataObj, grfKeyState, pt, pdwEffect );
IDropTarget_Release( target );
}
return r;
}
static HRESULT WINAPI DropTargetWrapper_DragOver(IDropTarget* iface,
@ -443,14 +457,28 @@ static HRESULT WINAPI DropTargetWrapper_DragOver(IDropTarget* iface,
POINTL pt,
DWORD* pdwEffect)
{
DropTargetWrapper* This = impl_from_IDropTarget(iface);
return IDropTarget_DragOver(This->inner, grfKeyState, pt, pdwEffect);
IDropTarget *target;
HRESULT r = get_target_from_wrapper( iface, &target );
if (SUCCEEDED( r ))
{
r = IDropTarget_DragOver( target, grfKeyState, pt, pdwEffect );
IDropTarget_Release( target );
}
return r;
}
static HRESULT WINAPI DropTargetWrapper_DragLeave(IDropTarget* iface)
{
DropTargetWrapper* This = impl_from_IDropTarget(iface);
return IDropTarget_DragLeave(This->inner);
IDropTarget *target;
HRESULT r = get_target_from_wrapper( iface, &target );
if (SUCCEEDED( r ))
{
r = IDropTarget_DragLeave( target );
IDropTarget_Release( target );
}
return r;
}
static HRESULT WINAPI DropTargetWrapper_Drop(IDropTarget* iface,
@ -459,8 +487,15 @@ static HRESULT WINAPI DropTargetWrapper_Drop(IDropTarget* iface,
POINTL pt,
DWORD* pdwEffect)
{
DropTargetWrapper* This = impl_from_IDropTarget(iface);
return IDropTarget_Drop(This->inner, pDataObj, grfKeyState, pt, pdwEffect);
IDropTarget *target;
HRESULT r = get_target_from_wrapper( iface, &target );
if (SUCCEEDED( r ))
{
r = IDropTarget_Drop( target, pDataObj, grfKeyState, pt, pdwEffect );
IDropTarget_Release( target );
}
return r;
}
static const IDropTargetVtbl DropTargetWrapperVTbl =
@ -474,15 +509,14 @@ static const IDropTargetVtbl DropTargetWrapperVTbl =
DropTargetWrapper_Drop
};
static IDropTarget* WrapDropTarget(IDropTarget* inner)
static IDropTarget* WrapDropTarget( HWND hwnd )
{
DropTargetWrapper* This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
if (This)
{
IDropTarget_AddRef(inner);
This->IDropTarget_iface.lpVtbl = &DropTargetWrapperVTbl;
This->inner = inner;
This->hwnd = hwnd;
This->refs = 1;
}
return &This->IDropTarget_iface;
@ -562,7 +596,7 @@ HRESULT WINAPI RegisterDragDrop(HWND hwnd, LPDROPTARGET pDropTarget)
if(FAILED(hr)) return hr;
/* IDropTarget::QueryInterface() shouldn't be called, some (broken) apps depend on this. */
wrapper = WrapDropTarget(pDropTarget);
wrapper = WrapDropTarget( hwnd );
if(!wrapper)
{
IStream_Release(stream);
@ -739,7 +773,7 @@ HRESULT WINAPI DoDragDrop (
HWND hwndTrackWindow;
MSG msg;
TRACE("(%p, %p, %d, %p)\n", pDataObject, pDropSource, dwOKEffect, pdwEffect);
TRACE("(%p, %p, %08x, %p)\n", pDataObject, pDropSource, dwOKEffect, pdwEffect);
if (!pDataObject || !pDropSource || !pdwEffect)
return E_INVALIDARG;

View file

@ -90,7 +90,8 @@ HRESULT WINAPI OleCreateStaticFromData(LPDATAOBJECT pSrcDataObj, REFIID iid,
DWORD renderopt, LPFORMATETC pFormatEtc, LPOLECLIENTSITE pClientSite,
LPSTORAGE pStg, LPVOID* ppvObj)
{
FIXME("(not shown), stub!\n");
FIXME("(srcdata=%p, refiid=%s, renderopt=%x, formatetc=%p, client=%p, storage=%p, ppv=%p), stub!\n",
pSrcDataObj,debugstr_guid(iid),renderopt,pFormatEtc,pClientSite,pStg,ppvObj );
return E_NOTIMPL;
}

View file

@ -0,0 +1,409 @@
HKCR
{
NoRemove Interface
{
'{00000131-0000-0000-C000-000000000046}' = s 'IRemUnknown'
{
NumMethods = s 6
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000142-0000-0000-C000-000000000046}' = s 'IRemUnknown2'
{
NumMethods = s 7
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
}
NoRemove CLSID
{
'{00000320-0000-0000-C000-000000000046}' = s 'PSFactoryBuffer'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
}
NoRemove Interface
{
'{00000100-0000-0000-C000-000000000046}' = s 'IEnumUnknown'
{
NumMethods = s 7
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000022-0000-0000-C000-000000000046}' = s 'ISurrogate'
{
NumMethods = s 5
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000000E-0000-0000-C000-000000000046}' = s 'IBindCtx'
{
NumMethods = s 13
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000102-0000-0000-C000-000000000046}' = s 'IEnumMoniker'
{
NumMethods = s 7
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000126-0000-0000-C000-000000000046}' = s 'IRunnableObject'
{
NumMethods = s 8
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000010-0000-0000-C000-000000000046}' = s 'IRunningObjectTable'
{
NumMethods = s 10
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000010C-0000-0000-C000-000000000046}' = s 'IPersist'
{
NumMethods = s 4
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000109-0000-0000-C000-000000000046}' = s 'IPersistStream'
{
NumMethods = s 8
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000000F-0000-0000-C000-000000000046}' = s 'IMoniker'
{
NumMethods = s 23
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{F29F6BC0-5021-11CE-AA15-00006901293F}' = s 'IROTData'
{
NumMethods = s 4
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000101-0000-0000-C000-000000000046}' = s 'IEnumString'
{
NumMethods = s 7
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000140-0000-0000-C000-000000000046}' = s 'IClassActivator'
{
NumMethods = s 4
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0C733A30-2A1C-11CE-ADE5-00AA0044773D}' = s 'ISequentialStream'
{
NumMethods = s 5
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000000C-0000-0000-C000-000000000046}' = s 'IStream'
{
NumMethods = s 14
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000000D-0000-0000-C000-000000000046}' = s 'IEnumSTATSTG'
{
NumMethods = s 7
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000000B-0000-0000-C000-000000000046}' = s 'IStorage'
{
NumMethods = s 18
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000010B-0000-0000-C000-000000000046}' = s 'IPersistFile'
{
NumMethods = s 9
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000010A-0000-0000-C000-000000000046}' = s 'IPersistStorage'
{
NumMethods = s 10
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000012-0000-0000-C000-000000000046}' = s 'IRootStorage'
{
NumMethods = s 4
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000000A-0000-0000-C000-000000000046}' = s 'ILockBytes'
{
NumMethods = s 10
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{99CAF010-415E-11CF-8814-00AA00B569F5}' = s 'IFillLockBytes'
{
NumMethods = s 7
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{A9D758A0-4617-11CF-95FC-00AA00680DB4}' = s 'IProgressNotify'
{
NumMethods = s 4
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{30F3D47A-6447-11D1-8E3C-00C04FB9386D}' = s 'IBlockingLock'
{
NumMethods = s 5
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{BC0BF6AE-8878-11D1-83E9-00C04FC2C6D4}' = s 'ITimeAndNoticeControl'
{
NumMethods = s 4
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{8D19C834-8879-11D1-83E9-00C04FC2C6D4}' = s 'IOplockStorage'
{
NumMethods = s 5
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000103-0000-0000-C000-000000000046}' = s 'IEnumFORMATETC'
{
NumMethods = s 7
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000105-0000-0000-C000-000000000046}' = s 'IEnumSTATDATA'
{
NumMethods = s 7
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000010F-0000-0000-C000-000000000046}' = s 'IAdviseSink'
{
NumMethods = s 8
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000125-0000-0000-C000-000000000046}' = s 'IAdviseSink2'
{
NumMethods = s 9
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000010E-0000-0000-C000-000000000046}' = s 'IDataObject'
{
NumMethods = s 12
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0E6D4D92-6738-11CF-9608-00AA00680DB4}' = s 'IDirectWriterLock'
{
NumMethods = s 6
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000030-0000-0000-C000-000000000046}' = s 'ISynchronize'
{
NumMethods = s 6
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000026-0000-0000-C000-000000000046}' = s 'IUrlMon'
{
NumMethods = s 4
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{72380D55-8D2B-43A3-8513-2B6EF31434E9}' = s 'IProcessInitControl'
{
NumMethods = s 4
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{969DC708-5C76-11D1-8D86-0000F804B057}' = s 'IThumbnailExtractor'
{
NumMethods = s 5
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
}
NoRemove CLSID
{
'{00000300-0000-0000-C000-000000000046}' = s 'StdOleLink'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{00000303-0000-0000-C000-000000000046}' = s 'FileMoniker'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
ProgId = s 'file'
}
'{00000304-0000-0000-C000-000000000046}' = s 'ItemMoniker'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{00000305-0000-0000-C000-000000000046}' = s 'AntiMoniker'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{00000306-0000-0000-C000-000000000046}' = s 'PointerMoniker'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{00000308-0000-0000-C000-000000000046}' = s 'PackagerMoniker'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{00000309-0000-0000-C000-000000000046}' = s 'CompositeMoniker'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{0000030B-0000-0000-C000-000000000046}' = s 'DfMarshal'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{00000315-0000-0000-C000-000000000046}' = s 'Picture (Metafile)'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
ProgId = s 'StaticMetafile'
}
'{00000316-0000-0000-C000-000000000046}' = s 'Picture (Device Independent Bitmap)'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
ProgId = s 'StaticDib'
}
'{0000031A-0000-0000-C000-000000000046}' = s 'ClassMoniker'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
ProgId = s 'CLSID'
}
'{00000320-0000-0000-C000-000000000046}' = s 'PSFactoryBuffer'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{00000323-0000-0000-C000-000000000046}' = s 'StdGlobalInterfaceTable'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' }
}
'{0002E005-0000-0000-C000-000000000046}' = s 'Component Categories Manager'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
}
'file' = s 'FileMoniker'
{
CLSID = s '{00000303-0000-0000-C000-000000000046}'
}
'StaticMetafile' = s 'Picture (Metafile)'
{
CLSID = s '{00000315-0000-0000-C000-000000000046}'
}
'StaticDib' = s 'Picture (Device Independent Bitmap)'
{
CLSID = s '{00000316-0000-0000-C000-000000000046}'
}
'CLSID' = s 'ClassMoniker'
{
CLSID = s '{0000031A-0000-0000-C000-000000000046}'
}
NoRemove Interface
{
'{00000114-0000-0000-C000-000000000046}' = s 'IOleWindow'
{
NumMethods = s 5
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000113-0000-0000-C000-000000000046}' = s 'IOleInPlaceObject'
{
NumMethods = s 9
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000115-0000-0000-C000-000000000046}' = s 'IOleInPlaceUIWindow'
{
NumMethods = s 9
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000116-0000-0000-C000-000000000046}' = s 'IOleInPlaceFrame'
{
NumMethods = s 15
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000117-0000-0000-C000-000000000046}' = s 'IOleInPlaceActiveObject'
{
NumMethods = s 10
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000119-0000-0000-C000-000000000046}' = s 'IOleInPlaceSite'
{
NumMethods = s 15
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000011A-0000-0000-C000-000000000046}' = s 'IParseDisplayName'
{
NumMethods = s 4
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000011B-0000-0000-C000-000000000046}' = s 'IOleContainer'
{
NumMethods = s 6
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000011C-0000-0000-C000-000000000046}' = s 'IOleItemContainer'
{
NumMethods = s 9
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000011D-0000-0000-C000-000000000046}' = s 'IOleLink'
{
NumMethods = s 14
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000118-0000-0000-C000-000000000046}' = s 'IOleClientSite'
{
NumMethods = s 9
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000011E-0000-0000-C000-000000000046}' = s 'IOleCache'
{
NumMethods = s 8
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000128-0000-0000-C000-000000000046}' = s 'IOleCache2'
{
NumMethods = s 10
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000129-0000-0000-C000-000000000046}' = s 'IOleCacheControl'
{
NumMethods = s 5
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000104-0000-0000-C000-000000000046}' = s 'IEnumOLEVERB'
{
NumMethods = s 7
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000112-0000-0000-C000-000000000046}' = s 'IOleObject'
{
NumMethods = s 24
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000012A-0000-0000-C000-000000000046}' = s 'IContinue'
{
NumMethods = s 4
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{0000010D-0000-0000-C000-000000000046}' = s 'IViewObject'
{
NumMethods = s 9
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000127-0000-0000-C000-000000000046}' = s 'IViewObject2'
{
NumMethods = s 10
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
'{00000122-0000-0000-C000-000000000046}' = s 'IDropTarget'
{
NumMethods = s 7
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
}
NoRemove CLSID
{
'{00000320-0000-0000-C000-000000000046}' = s 'PSFactoryBuffer'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
}
NoRemove Interface
{
'{00000000-0000-0000-C000-000000000046}' = s 'IUnknown'
'{00000001-0000-0000-C000-000000000046}' = s 'IClassFactory'
{
NumMethods = s 5
ProxyStubClsid32 = s '{00000320-0000-0000-C000-000000000046}'
}
}
NoRemove CLSID
{
'{00000320-0000-0000-C000-000000000046}' = s 'PSFactoryBuffer'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
}
}

View file

@ -98,7 +98,7 @@
@ stdcall CreatePointerMoniker(ptr ptr)
@ stdcall CreateStreamOnHGlobal(ptr long ptr)
@ stdcall DllDebugObjectRPCHook(long ptr)
@ stdcall DllGetClassObject (ptr ptr ptr)
@ stdcall -private DllGetClassObject (ptr ptr ptr)
@ stub DllGetClassObjectWOW
@ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer()

View file

@ -104,10 +104,10 @@ HGLOBAL WINAPI OleMetafilePictFromIconAndLabel(HICON hIcon, LPOLESTR lpszLabel,
SetWindowOrgEx(hdc, 0, 0, NULL);
SetWindowExtEx(hdc, width, label_offset + text_size.cy, NULL);
/* draw the icon centred */
/* draw the icon centered */
DrawIcon(hdc, (width-icon_width) / 2, 0, hIcon);
if(lpszLabel)
/* draw the label centred too, if provided */
/* draw the label centered too, if provided */
TextOutW(hdc, (width-text_size.cx) / 2, label_offset, lpszLabel, lstrlenW(lpszLabel));
if (lpszSourceFile)

View file

@ -23,3 +23,105 @@
cpp_quote("#if 0 /* ole32_objidl.idl hack */")
#include "objidl.idl"
cpp_quote("#endif /* ole32_objidl.idl hack */")
#ifndef __WIDL__
#define threading(model)
#define progid(str)
#endif
[
threading(both),
uuid(00000300-0000-0000-c000-000000000046)
]
coclass StdOleLink { interface IMarshal; }
[
threading(both),
progid("file"),
uuid(00000303-0000-0000-c000-000000000046)
]
coclass FileMoniker { interface IMoniker; }
[
threading(both),
uuid(00000304-0000-0000-c000-000000000046)
]
coclass ItemMoniker { interface IMoniker; }
[
threading(both),
uuid(00000305-0000-0000-c000-000000000046)
]
coclass AntiMoniker { interface IMoniker; }
[
threading(both),
uuid(00000306-0000-0000-c000-000000000046)
]
coclass PointerMoniker { interface IMoniker; }
[
threading(both),
uuid(00000308-0000-0000-c000-000000000046)
]
coclass PackagerMoniker { interface IMoniker; }
[
threading(both),
uuid(00000309-0000-0000-c000-000000000046)
]
coclass CompositeMoniker { interface IMoniker; }
[
threading(both),
uuid(0000030b-0000-0000-c000-000000000046)
]
coclass DfMarshal { interface IMarshal; }
#ifdef __WIDL__
[
helpstring("Picture (Metafile)"),
threading(both),
progid("StaticMetafile"),
uuid(00000315-0000-0000-c000-000000000046)
]
coclass Picture_Metafile { interface IPicture; }
[
helpstring("Picture (Device Independent Bitmap)"),
threading(both),
progid("StaticDib"),
uuid(00000316-0000-0000-c000-000000000046)
]
coclass Picture_Dib { interface IPicture; }
#endif
[
threading(both),
progid("CLSID"),
uuid(0000031a-0000-0000-c000-000000000046)
]
coclass ClassMoniker { interface IMoniker; }
#ifdef __WIDL__
[
threading(both),
uuid(00000320-0000-0000-c000-000000000046)
]
coclass PSFactoryBuffer { interface IFactoryBuffer; }
#endif
[
threading(apartment),
uuid(00000323-0000-0000-c000-000000000046)
]
coclass StdGlobalInterfaceTable { interface IGlobalInterfaceTable; }
#ifdef __WIDL__
[
helpstring("Component Categories Manager"),
threading(both),
uuid(0002e005-0000-0000-c000-000000000046)
]
coclass StdComponentCategoriesMgr { interface ICatRegister; interface ICatInformation; }
#endif

View file

@ -17,3 +17,11 @@
*/
#include "oleidl.idl"
#ifdef __WIDL__
[
threading(both),
uuid(00000320-0000-0000-c000-000000000046)
]
coclass PSFactoryBuffer { interface IFactoryBuffer; }
#endif

View file

@ -23,3 +23,11 @@
cpp_quote("#if 0 /* oleaut32_unknwn.idl hack */")
#include "unknwn.idl"
cpp_quote("#endif /* oleaut32_unknwn.idl hack */")
#ifdef __WIDL__
[
threading(both),
uuid(00000320-0000-0000-c000-000000000046)
]
coclass PSFactoryBuffer { interface IFactoryBuffer; }
#endif

View file

@ -47,3 +47,5 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
/* @makedep: drag_link.cur */
4 CURSOR drag_link.cur
1 WINE_REGISTRY ole32.rgs

File diff suppressed because it is too large Load diff

View file

@ -40,17 +40,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
/* PointerMoniker data structure */
typedef struct PointerMonikerImpl{
const IMonikerVtbl* lpvtbl; /* VTable relative to the IMoniker interface.*/
IMoniker IMoniker_iface;
LONG ref; /* reference counter for this object */
IUnknown *pObject; /* custom marshaler */
} PointerMonikerImpl;
static inline PointerMonikerImpl *impl_from_IMoniker(IMoniker *iface)
{
return CONTAINING_RECORD(iface, PointerMonikerImpl, IMoniker_iface);
}
static HRESULT WINAPI
PointerMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
{
PointerMonikerImpl *This = (PointerMonikerImpl *)iface;
PointerMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
@ -84,7 +89,7 @@ PointerMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
static ULONG WINAPI
PointerMonikerImpl_AddRef(IMoniker* iface)
{
PointerMonikerImpl *This = (PointerMonikerImpl *)iface;
PointerMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p)\n",This);
@ -97,7 +102,7 @@ PointerMonikerImpl_AddRef(IMoniker* iface)
static ULONG WINAPI
PointerMonikerImpl_Release(IMoniker* iface)
{
PointerMonikerImpl *This = (PointerMonikerImpl *)iface;
PointerMonikerImpl *This = impl_from_IMoniker(iface);
ULONG ref;
TRACE("(%p)\n",This);
@ -194,7 +199,7 @@ static HRESULT WINAPI
PointerMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
REFIID riid, VOID** ppvResult)
{
PointerMonikerImpl *This = (PointerMonikerImpl *)iface;
PointerMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult);
@ -211,7 +216,7 @@ static HRESULT WINAPI
PointerMonikerImpl_BindToStorage(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
REFIID riid, VOID** ppvResult)
{
PointerMonikerImpl *This = (PointerMonikerImpl *)iface;
PointerMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult);
@ -336,7 +341,7 @@ PointerMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoni
static HRESULT WINAPI
PointerMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
{
PointerMonikerImpl *This = (PointerMonikerImpl *)iface;
PointerMonikerImpl *This = impl_from_IMoniker(iface);
DWORD mkSys;
TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
@ -348,7 +353,7 @@ PointerMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
if (mkSys==MKSYS_POINTERMONIKER)
{
PointerMonikerImpl *pOtherMoniker = (PointerMonikerImpl *)pmkOtherMoniker;
PointerMonikerImpl *pOtherMoniker = impl_from_IMoniker(pmkOtherMoniker);
return This->pObject == pOtherMoniker->pObject ? S_OK : S_FALSE;
}
else
@ -360,12 +365,12 @@ PointerMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
******************************************************************************/
static HRESULT WINAPI PointerMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
{
PointerMonikerImpl *This = (PointerMonikerImpl *)iface;
PointerMonikerImpl *This = impl_from_IMoniker(iface);
if (pdwHash==NULL)
return E_POINTER;
*pdwHash = (DWORD)This->pObject;
*pdwHash = PtrToUlong(This->pObject);
return S_OK;
}
@ -467,7 +472,7 @@ PointerMonikerImpl_ParseDisplayName(IMoniker* iface, IBindCtx* pbc,
IMoniker* pmkToLeft, LPOLESTR pszDisplayName,
ULONG* pchEaten, IMoniker** ppmkOut)
{
PointerMonikerImpl *This = (PointerMonikerImpl *)iface;
PointerMonikerImpl *This = impl_from_IMoniker(iface);
HRESULT hr;
IParseDisplayName *pPDN;
@ -543,8 +548,8 @@ static void PointerMonikerImpl_Construct(PointerMonikerImpl* This, IUnknown *pun
TRACE("(%p)\n",This);
/* Initialize the virtual function table. */
This->lpvtbl = &VT_PointerMonikerImpl;
This->ref = 1;
This->IMoniker_iface.lpVtbl = &VT_PointerMonikerImpl;
This->ref = 1;
if (punk)
IUnknown_AddRef(punk);
This->pObject = punk;
@ -580,7 +585,7 @@ HRESULT WINAPI CreatePointerMoniker(LPUNKNOWN punk, LPMONIKER *ppmk)
}
PointerMonikerImpl_Construct(This, punk);
*ppmk = (IMoniker *)&This->lpvtbl;
*ppmk = &This->IMoniker_iface;
return S_OK;
}

View file

@ -1,574 +0,0 @@
/*
* self-registerable dll functions for ole32.dll
*
* Copyright (C) 2003 John K. Hohm
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winreg.h"
#include "winerror.h"
#include "objbase.h"
#include "ole2.h"
#include "olectl.h"
#include "comcat.h"
#include "initguid.h"
#include "compobj_private.h"
#include "moniker.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
/*
* Near the bottom of this file are the exported DllRegisterServer and
* DllUnregisterServer, which make all this worthwhile.
*/
/***********************************************************************
* interface for self-registering
*/
struct regsvr_interface
{
IID const *iid; /* NULL for end of list */
LPCSTR name; /* can be NULL to omit */
IID const *base_iid; /* can be NULL to omit */
int num_methods; /* can be <0 to omit */
CLSID const *ps_clsid; /* can be NULL to omit */
CLSID const *ps_clsid32; /* can be NULL to omit */
};
static HRESULT register_interfaces(struct regsvr_interface const *list);
static HRESULT unregister_interfaces(struct regsvr_interface const *list);
struct regsvr_coclass
{
CLSID const *clsid; /* NULL for end of list */
LPCSTR name; /* can be NULL to omit */
LPCSTR ips; /* can be NULL to omit */
LPCSTR ips32; /* can be NULL to omit */
LPCSTR ips32_tmodel; /* can be NULL to omit */
LPCSTR progid; /* can be NULL to omit */
};
static HRESULT register_coclasses(struct regsvr_coclass const *list);
static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
/***********************************************************************
* static string constants
*/
static WCHAR const interface_keyname[10] = {
'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
static WCHAR const base_ifa_keyname[14] = {
'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
'e', 0 };
static WCHAR const num_methods_keyname[11] = {
'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
static WCHAR const ps_clsid_keyname[15] = {
'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
'i', 'd', 0 };
static WCHAR const ps_clsid32_keyname[17] = {
'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
'i', 'd', '3', '2', 0 };
static WCHAR const clsid_keyname[6] = {
'C', 'L', 'S', 'I', 'D', 0 };
static WCHAR const ips_keyname[13] = {
'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
0 };
static WCHAR const ips32_keyname[15] = {
'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
'3', '2', 0 };
static WCHAR const progid_keyname[7] = {
'P', 'r', 'o', 'g', 'I', 'D', 0 };
static char const tmodel_valuename[] = "ThreadingModel";
/***********************************************************************
* static helper functions
*/
static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
WCHAR const *value);
static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
char const *value);
static LONG register_progid(WCHAR const *clsid, char const *progid,
char const *name);
/***********************************************************************
* register_interfaces
*/
static HRESULT register_interfaces(struct regsvr_interface const *list)
{
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
HKEY iid_key;
StringFromGUID2(list->iid, buf, 39);
res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_interface_key;
if (list->name) {
res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
(CONST BYTE*)(list->name),
strlen(list->name) + 1);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->base_iid) {
res = register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (0 <= list->num_methods) {
static WCHAR const fmt[3] = { '%', 'd', 0 };
HKEY key;
res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
sprintfW(buf, fmt, list->num_methods);
res = RegSetValueExW(key, NULL, 0, REG_SZ,
(CONST BYTE*)buf,
(lstrlenW(buf) + 1) * sizeof(WCHAR));
RegCloseKey(key);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid) {
res = register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid32) {
res = register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
error_close_iid_key:
RegCloseKey(iid_key);
}
error_close_interface_key:
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* unregister_interfaces
*/
static HRESULT unregister_interfaces(struct regsvr_interface const *list)
{
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
KEY_READ | KEY_WRITE, &interface_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
StringFromGUID2(list->iid, buf, 39);
res = RegDeleteTreeW(interface_key, buf);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
}
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* register_coclasses
*/
static HRESULT register_coclasses(struct regsvr_coclass const *list)
{
LONG res = ERROR_SUCCESS;
HKEY coclass_key;
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->clsid; ++list) {
WCHAR buf[39];
HKEY clsid_key;
StringFromGUID2(list->clsid, buf, 39);
res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->name) {
res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
(CONST BYTE*)(list->name),
strlen(list->name) + 1);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->ips) {
res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->ips32) {
HKEY ips32_key;
res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&ips32_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
(CONST BYTE*)list->ips32,
lstrlenA(list->ips32) + 1);
if (res == ERROR_SUCCESS && list->ips32_tmodel)
res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
(CONST BYTE*)list->ips32_tmodel,
strlen(list->ips32_tmodel) + 1);
RegCloseKey(ips32_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->progid) {
res = register_key_defvalueA(clsid_key, progid_keyname,
list->progid);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = register_progid(buf, list->progid, list->name);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
error_close_clsid_key:
RegCloseKey(clsid_key);
}
error_close_coclass_key:
RegCloseKey(coclass_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* unregister_coclasses
*/
static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
{
LONG res = ERROR_SUCCESS;
HKEY coclass_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
KEY_READ | KEY_WRITE, &coclass_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->clsid; ++list) {
WCHAR buf[39];
StringFromGUID2(list->clsid, buf, 39);
res = RegDeleteTreeW(coclass_key, buf);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->progid) {
res = RegDeleteTreeA(HKEY_CLASSES_ROOT, list->progid);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
}
}
error_close_coclass_key:
RegCloseKey(coclass_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* regsvr_key_guid
*/
static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
{
WCHAR buf[39];
StringFromGUID2(guid, buf, 39);
return register_key_defvalueW(base, name, buf);
}
/***********************************************************************
* regsvr_key_defvalueW
*/
static LONG register_key_defvalueW(
HKEY base,
WCHAR const *name,
WCHAR const *value)
{
LONG res;
HKEY key;
res = RegCreateKeyExW(base, name, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) return res;
res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
(lstrlenW(value) + 1) * sizeof(WCHAR));
RegCloseKey(key);
return res;
}
/***********************************************************************
* regsvr_key_defvalueA
*/
static LONG register_key_defvalueA(
HKEY base,
WCHAR const *name,
char const *value)
{
LONG res;
HKEY key;
res = RegCreateKeyExW(base, name, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) return res;
res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
lstrlenA(value) + 1);
RegCloseKey(key);
return res;
}
/***********************************************************************
* regsvr_progid
*/
static LONG register_progid(
WCHAR const *clsid,
char const *progid,
char const *name)
{
LONG res;
HKEY progid_key;
res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
NULL, 0, KEY_READ | KEY_WRITE, NULL,
&progid_key, NULL);
if (res != ERROR_SUCCESS) return res;
if (name) {
res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
(CONST BYTE*)name, strlen(name) + 1);
if (res != ERROR_SUCCESS) goto error_close_progid_key;
}
if (clsid) {
res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
if (res != ERROR_SUCCESS) goto error_close_progid_key;
}
error_close_progid_key:
RegCloseKey(progid_key);
return res;
}
/***********************************************************************
* coclass list
*/
static GUID const CLSID_StdOleLink = {
0x00000300, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
static GUID const CLSID_PackagerMoniker = {
0x00000308, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
extern GUID const CLSID_Picture_Metafile;
extern GUID const CLSID_Picture_Dib;
static struct regsvr_coclass const coclass_list[] = {
{ &CLSID_StdOleLink,
"StdOleLink",
NULL,
"ole32.dll",
NULL
},
{ &CLSID_FileMoniker,
"FileMoniker",
NULL,
"ole32.dll",
"Both",
"file"
},
{ &CLSID_ItemMoniker,
"ItemMoniker",
NULL,
"ole32.dll",
"Both"
},
{ &CLSID_AntiMoniker,
"AntiMoniker",
NULL,
"ole32.dll",
"Both"
},
{ &CLSID_PointerMoniker,
"PointerMoniker",
NULL,
"ole32.dll",
"Both"
},
{ &CLSID_PackagerMoniker,
"PackagerMoniker",
NULL,
"ole32.dll",
"Both"
},
{ &CLSID_CompositeMoniker,
"CompositeMoniker",
NULL,
"ole32.dll",
"Both"
},
{ &CLSID_DfMarshal,
"DfMarshal",
NULL,
"ole32.dll",
"Both"
},
{ &CLSID_Picture_Metafile,
"Picture (Metafile)",
NULL,
"ole32.dll",
NULL,
"StaticMetafile"
},
{ &CLSID_Picture_Dib,
"Picture (Device Independent Bitmap)",
NULL,
"ole32.dll",
NULL,
"StaticDib"
},
{ &CLSID_ClassMoniker,
"ClassMoniker",
NULL,
"ole32.dll",
"Both",
"CLSID"
},
{ &CLSID_PSFactoryBuffer,
"PSFactoryBuffer",
NULL,
"ole32.dll",
"Both"
},
{ &CLSID_StdGlobalInterfaceTable,
"StdGlobalInterfaceTable",
NULL,
"ole32.dll",
"Apartment"
},
{ &CLSID_StdComponentCategoriesMgr,
"Component Categories Manager",
NULL,
"ole32.dll",
"Both"
},
{ NULL } /* list terminator */
};
/***********************************************************************
* interface list
*/
#define INTERFACE_ENTRY(interface, base) { &IID_##interface, #interface, base, sizeof(interface##Vtbl)/sizeof(void*), NULL, NULL }
static const struct regsvr_interface interface_list[] = {
INTERFACE_ENTRY( IUnknown, NULL ),
INTERFACE_ENTRY( IMalloc, NULL ),
INTERFACE_ENTRY( IMarshal, NULL ),
INTERFACE_ENTRY( IMoniker, &IID_IPersistStream ),
INTERFACE_ENTRY( IMessageFilter, NULL ),
INTERFACE_ENTRY( IStdMarshalInfo, NULL ),
INTERFACE_ENTRY( IExternalConnection, NULL ),
INTERFACE_ENTRY( IMallocSpy, NULL ),
INTERFACE_ENTRY( IMultiQI, NULL ),
INTERFACE_ENTRY( IPersistStream, &IID_IPersist ),
INTERFACE_ENTRY( IPersistStorage, &IID_IPersist ),
INTERFACE_ENTRY( IPersistFile, &IID_IPersist ),
INTERFACE_ENTRY( IDataAdviseHolder, NULL ),
INTERFACE_ENTRY( IOleAdviseHolder, NULL ),
INTERFACE_ENTRY( IOleInPlaceObject, &IID_IOleWindow ),
INTERFACE_ENTRY( IOleInPlaceUIWindow, &IID_IOleWindow ),
INTERFACE_ENTRY( IOleInPlaceActiveObject, &IID_IOleWindow ),
INTERFACE_ENTRY( IOleInPlaceSite, &IID_IOleWindow ),
INTERFACE_ENTRY( IOleContainer, &IID_IParseDisplayName ),
INTERFACE_ENTRY( IOleItemContainer, &IID_IOleContainer ),
INTERFACE_ENTRY( IDropSource, NULL ),
INTERFACE_ENTRY( IAdviseSink2, &IID_IAdviseSink ),
INTERFACE_ENTRY( IViewObject2, &IID_IViewObject ),
INTERFACE_ENTRY( IOleCache2, &IID_IOleCache ),
INTERFACE_ENTRY( IClientSecurity, NULL ),
INTERFACE_ENTRY( IServerSecurity, NULL ),
{ NULL } /* list terminator */
};
/***********************************************************************
* DllRegisterServer (OLE32.@)
*/
HRESULT WINAPI DllRegisterServer(void)
{
HRESULT hr;
TRACE("\n");
hr = OLE32_DllRegisterServer();
if (SUCCEEDED(hr))
hr = register_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = register_interfaces(interface_list);
return hr;
}
/***********************************************************************
* DllUnregisterServer (OLE32.@)
*/
HRESULT WINAPI DllUnregisterServer(void)
{
HRESULT hr;
TRACE("\n");
hr = unregister_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = unregister_interfaces(interface_list);
if (SUCCEEDED(hr))
hr = OLE32_DllUnregisterServer();
return hr;
}

View file

@ -453,6 +453,8 @@ void RPC_UnregisterAllChannelHooks(void)
LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &channel_hooks, struct channel_hook_entry, entry)
HeapFree(GetProcessHeap(), 0, cursor);
LeaveCriticalSection(&csChannelHook);
DeleteCriticalSection(&csChannelHook);
DeleteCriticalSection(&csRegIf);
}
/* RPC Channel Buffer Functions */
@ -539,7 +541,10 @@ static HRESULT WINAPI ServerRpcChannelBuffer_GetBuffer(LPRPCCHANNELBUFFER iface,
if (msg->Buffer)
status = RPC_S_OK;
else
status = ERROR_OUTOFMEMORY;
{
HeapFree(GetProcessHeap(), 0, channel_hook_data);
return E_OUTOFMEMORY;
}
}
else
status = I_RpcGetBuffer(msg);
@ -1637,7 +1642,7 @@ void RPC_StartRemoting(struct apartment *apt)
}
static HRESULT create_server(REFCLSID rclsid)
static HRESULT create_server(REFCLSID rclsid, HANDLE *process)
{
static const WCHAR wszLocalServer32[] = { 'L','o','c','a','l','S','e','r','v','e','r','3','2',0 };
static const WCHAR embedding[] = { ' ', '-','E','m','b','e','d','d','i','n','g',0 };
@ -1676,7 +1681,7 @@ static HRESULT create_server(REFCLSID rclsid)
WARN("failed to run local server %s\n", debugstr_w(command));
return HRESULT_FROM_WIN32(GetLastError());
}
CloseHandle(pinfo.hProcess);
*process = pinfo.hProcess;
CloseHandle(pinfo.hThread);
return S_OK;
@ -1813,9 +1818,10 @@ HRESULT RPC_GetLocalClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
if (hPipe == INVALID_HANDLE_VALUE) {
DWORD index;
DWORD start_ticks;
HANDLE process = 0;
if (tries == 1) {
if ( (hres = create_local_service(rclsid)) &&
(hres = create_server(rclsid)) )
(hres = create_server(rclsid, &process)) )
return hres;
} else {
WARN("Connecting to %s, no response yet, retrying: le is %u\n", debugstr_w(pipefn), GetLastError());
@ -1823,8 +1829,16 @@ HRESULT RPC_GetLocalClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
/* wait for one second, even if messages arrive */
start_ticks = GetTickCount();
do {
CoWaitForMultipleHandles(0, 1000, 0, NULL, &index);
if (SUCCEEDED(CoWaitForMultipleHandles(0, 1000, (process != 0),
&process, &index)) && process && !index)
{
WARN( "server for %s failed to start\n", debugstr_guid(rclsid) );
CloseHandle( hPipe );
CloseHandle( process );
return E_NOINTERFACE;
}
} while (GetTickCount() - start_ticks < 1000);
if (process) CloseHandle( process );
continue;
}
bufferlen = 0;
@ -1870,7 +1884,6 @@ struct local_server_params
static DWORD WINAPI local_server_thread(LPVOID param)
{
struct local_server_params * lsp = param;
HANDLE hPipe;
WCHAR pipefn[100];
HRESULT hres;
IStream *pStm = lsp->stream;
@ -1882,28 +1895,27 @@ static DWORD WINAPI local_server_thread(LPVOID param)
ULONG res;
BOOL multi_use = lsp->multi_use;
OVERLAPPED ovl;
HANDLE pipe_event;
HANDLE pipe_event, hPipe, new_pipe;
DWORD bytes;
TRACE("Starting threader for %s.\n",debugstr_guid(&lsp->clsid));
memset(&ovl, 0, sizeof(ovl));
get_localserver_pipe_name(pipefn, &lsp->clsid);
ovl.hEvent = pipe_event = CreateEventW(NULL, FALSE, FALSE, NULL);
hPipe = CreateNamedPipeW( pipefn, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE|PIPE_WAIT, PIPE_UNLIMITED_INSTANCES,
4096, 4096, 500 /* 0.5 second timeout */, NULL );
SetEvent(lsp->ready_event);
if (hPipe == INVALID_HANDLE_VALUE)
{
FIXME("pipe creation failed for %s, le is %u\n", debugstr_w(pipefn), GetLastError());
CloseHandle(pipe_event);
return 1;
}
ovl.hEvent = pipe_event = CreateEventW(NULL, FALSE, FALSE, NULL);
SetEvent(lsp->ready_event);
while (1) {
if (!ConnectNamedPipe(hPipe, &ovl))
{
@ -1914,12 +1926,16 @@ static DWORD WINAPI local_server_thread(LPVOID param)
DWORD ret;
ret = WaitForMultipleObjects(2, handles, FALSE, INFINITE);
if (ret != WAIT_OBJECT_0)
{
CloseHandle(hPipe);
break;
}
}
/* client already connected isn't an error */
else if (error != ERROR_PIPE_CONNECTED)
{
ERR("ConnectNamedPipe failed with error %d\n", GetLastError());
CloseHandle(hPipe);
break;
}
}
@ -1927,7 +1943,12 @@ static DWORD WINAPI local_server_thread(LPVOID param)
TRACE("marshalling IClassFactory to client\n");
hres = IStream_Stat(pStm,&ststg,STATFLAG_NONAME);
if (hres) return hres;
if (hres)
{
CloseHandle(hPipe);
CloseHandle(pipe_event);
return hres;
}
seekto.u.LowPart = 0;
seekto.u.HighPart = 0;
@ -1957,16 +1978,26 @@ static DWORD WINAPI local_server_thread(LPVOID param)
FlushFileBuffers(hPipe);
DisconnectNamedPipe(hPipe);
TRACE("done marshalling IClassFactory\n");
if (!multi_use)
{
TRACE("single use object, shutting down pipe %s\n", debugstr_w(pipefn));
CloseHandle(hPipe);
break;
}
new_pipe = CreateNamedPipeW( pipefn, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE|PIPE_WAIT, PIPE_UNLIMITED_INSTANCES,
4096, 4096, 500 /* 0.5 second timeout */, NULL );
CloseHandle(hPipe);
if (new_pipe == INVALID_HANDLE_VALUE)
{
FIXME("pipe creation failed for %s, le is %u\n", debugstr_w(pipefn), GetLastError());
CloseHandle(pipe_event);
return 1;
}
hPipe = new_pipe;
}
CloseHandle(hPipe);
CloseHandle(pipe_event);
return 0;
}

View file

@ -152,7 +152,7 @@ static HRESULT create_EnumSTATPROPSTG(PropertyStorage_impl *, IEnumSTATPROPSTG**
*/
struct tagPropertyStorage_impl
{
const IPropertyStorageVtbl *vtbl;
IPropertyStorage IPropertyStorage_iface;
LONG ref;
CRITICAL_SECTION cs;
IStream *stm;
@ -171,6 +171,11 @@ struct tagPropertyStorage_impl
struct dictionary *propid_to_prop;
};
static inline PropertyStorage_impl *impl_from_IPropertyStorage(IPropertyStorage *iface)
{
return CONTAINING_RECORD(iface, PropertyStorage_impl, IPropertyStorage_iface);
}
/************************************************************************
* IPropertyStorage_fnQueryInterface (IPropertyStorage)
*/
@ -179,7 +184,7 @@ static HRESULT WINAPI IPropertyStorage_fnQueryInterface(
REFIID riid,
void** ppvObject)
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObject);
@ -205,7 +210,7 @@ static HRESULT WINAPI IPropertyStorage_fnQueryInterface(
static ULONG WINAPI IPropertyStorage_fnAddRef(
IPropertyStorage *iface)
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
return InterlockedIncrement(&This->ref);
}
@ -215,7 +220,7 @@ static ULONG WINAPI IPropertyStorage_fnAddRef(
static ULONG WINAPI IPropertyStorage_fnRelease(
IPropertyStorage *iface)
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
ULONG ref;
ref = InterlockedDecrement(&This->ref);
@ -293,7 +298,7 @@ static HRESULT WINAPI IPropertyStorage_fnReadMultiple(
const PROPSPEC rgpspec[],
PROPVARIANT rgpropvar[])
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
HRESULT hr = S_OK;
ULONG i;
@ -551,7 +556,7 @@ static HRESULT WINAPI IPropertyStorage_fnWriteMultiple(
const PROPVARIANT rgpropvar[],
PROPID propidNameFirst)
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
HRESULT hr = S_OK;
ULONG i;
@ -650,7 +655,7 @@ static HRESULT WINAPI IPropertyStorage_fnDeleteMultiple(
ULONG cpspec,
const PROPSPEC rgpspec[])
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
ULONG i;
HRESULT hr;
@ -696,7 +701,7 @@ static HRESULT WINAPI IPropertyStorage_fnReadPropertyNames(
const PROPID rgpropid[],
LPOLESTR rglpwstrName[])
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
ULONG i;
HRESULT hr = S_FALSE;
@ -715,8 +720,8 @@ static HRESULT WINAPI IPropertyStorage_fnReadPropertyNames(
hr = S_OK;
rglpwstrName[i] = CoTaskMemAlloc((len + 1) * sizeof(WCHAR));
if (rglpwstrName)
memcpy(rglpwstrName, name, (len + 1) * sizeof(WCHAR));
if (rglpwstrName[i])
memcpy(rglpwstrName[i], name, (len + 1) * sizeof(WCHAR));
else
hr = STG_E_INSUFFICIENTMEMORY;
}
@ -736,7 +741,7 @@ static HRESULT WINAPI IPropertyStorage_fnWritePropertyNames(
const PROPID rgpropid[],
const LPOLESTR rglpwstrName[])
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
ULONG i;
HRESULT hr;
@ -769,7 +774,7 @@ static HRESULT WINAPI IPropertyStorage_fnDeletePropertyNames(
ULONG cpropid,
const PROPID rgpropid[])
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
ULONG i;
HRESULT hr;
@ -805,7 +810,7 @@ static HRESULT WINAPI IPropertyStorage_fnCommit(
IPropertyStorage* iface,
DWORD grfCommitFlags)
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
HRESULT hr;
TRACE("(%p, 0x%08x)\n", iface, grfCommitFlags);
@ -828,7 +833,7 @@ static HRESULT WINAPI IPropertyStorage_fnRevert(
IPropertyStorage* iface)
{
HRESULT hr;
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
TRACE("%p\n", iface);
@ -853,7 +858,7 @@ static HRESULT WINAPI IPropertyStorage_fnEnum(
IPropertyStorage* iface,
IEnumSTATPROPSTG** ppenum)
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
return create_EnumSTATPROPSTG(This, ppenum);
}
@ -877,7 +882,7 @@ static HRESULT WINAPI IPropertyStorage_fnSetClass(
IPropertyStorage* iface,
REFCLSID clsid)
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
TRACE("%p, %s\n", iface, debugstr_guid(clsid));
@ -899,7 +904,7 @@ static HRESULT WINAPI IPropertyStorage_fnStat(
IPropertyStorage* iface,
STATPROPSETSTG* statpsstg)
{
PropertyStorage_impl *This = (PropertyStorage_impl *)iface;
PropertyStorage_impl *This = impl_from_IPropertyStorage(iface);
STATSTG stat;
HRESULT hr;
@ -1106,6 +1111,22 @@ static HRESULT PropertyStorage_ReadProperty(PropertyStorage_impl *This,
}
break;
}
case VT_BLOB:
{
DWORD count;
StorageUtl_ReadDWord(data, 0, &count);
prop->u.blob.cbSize = count;
prop->u.blob.pBlobData = CoTaskMemAlloc(count);
if (prop->u.blob.pBlobData)
{
memcpy(prop->u.blob.pBlobData, data + sizeof(DWORD), count);
TRACE("Read blob value of size %d\n", count);
}
else
hr = STG_E_INSUFFICIENTMEMORY;
break;
}
case VT_LPWSTR:
{
DWORD count;
@ -1314,13 +1335,6 @@ static HRESULT PropertyStorage_ReadFromStream(PropertyStorage_impl *This)
hr = PropertyStorage_ReadFmtIdOffsetFromStream(This->stm, &fmtOffset);
if (FAILED(hr))
goto end;
if (!IsEqualGUID(&fmtOffset.fmtid, &FMTID_DocSummaryInformation) &&
!IsEqualGUID(&fmtOffset.fmtid, &FMTID_SummaryInformation))
{
WARN("not reading unknown fmtid %s\n", debugstr_guid(&fmtOffset.fmtid));
hr = S_FALSE;
goto end;
}
if (fmtOffset.dwOffset > stat.cbSize.u.LowPart)
{
WARN("invalid offset %d (stream length is %d)\n", fmtOffset.dwOffset,
@ -1363,7 +1377,7 @@ static HRESULT PropertyStorage_ReadFromStream(PropertyStorage_impl *This)
i * sizeof(PROPERTYIDOFFSET));
if (idOffset->dwOffset < sizeof(PROPERTYSECTIONHEADER) ||
idOffset->dwOffset >= sectionHdr.cbSection - sizeof(DWORD))
idOffset->dwOffset > sectionHdr.cbSection - sizeof(DWORD))
hr = STG_E_INVALIDPOINTER;
else
{
@ -1748,6 +1762,15 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This,
bytesWritten = count + sizeof cf_hdr;
break;
}
case VT_CLSID:
{
CLSID temp;
StorageUtl_WriteGUID((BYTE *)&temp, 0, var->u.puuid);
hr = IStream_Write(This->stm, &temp, sizeof(temp), &count);
bytesWritten = count;
break;
}
default:
FIXME("unsupported type: %d\n", var->vt);
return STG_E_INVALIDPARAMETER;
@ -1986,7 +2009,7 @@ static HRESULT PropertyStorage_BaseConstruct(IStream *stm,
if (!*pps)
return E_OUTOFMEMORY;
(*pps)->vtbl = &IPropertyStorage_Vtbl;
(*pps)->IPropertyStorage_iface.lpVtbl = &IPropertyStorage_Vtbl;
(*pps)->ref = 1;
InitializeCriticalSection(&(*pps)->cs);
(*pps)->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": PropertyStorage_impl.cs");
@ -2020,7 +2043,7 @@ static HRESULT PropertyStorage_ConstructFromStream(IStream *stm,
hr = PropertyStorage_ReadFromStream(ps);
if (SUCCEEDED(hr))
{
*pps = (IPropertyStorage *)ps;
*pps = &ps->IPropertyStorage_iface;
TRACE("PropertyStorage %p constructed\n", ps);
hr = S_OK;
}
@ -2054,7 +2077,7 @@ static HRESULT PropertyStorage_ConstructEmpty(IStream *stm,
ps->codePage = CP_UNICODE;
ps->locale = LOCALE_SYSTEM_DEFAULT;
TRACE("Code page is %d, locale is %d\n", ps->codePage, ps->locale);
*pps = (IPropertyStorage *)ps;
*pps = &ps->IPropertyStorage_iface;
TRACE("PropertyStorage %p constructed\n", ps);
hr = S_OK;
}

View file

@ -87,6 +87,9 @@ struct StorageInternalImpl
};
typedef struct StorageInternalImpl StorageInternalImpl;
static const IStorageVtbl TransactedSnapshotImpl_Vtbl;
static const IStorageVtbl Storage32InternalImpl_Vtbl;
/* Method definitions for the Storage32InternalImpl class. */
static StorageInternalImpl* StorageInternalImpl_Construct(StorageBaseImpl* parentStorage,
DWORD openFlags, DirRef storageDirEntry);
@ -296,8 +299,7 @@ extern const IPropertySetStorageVtbl IPropertySetStorage_Vtbl;
*/
struct IEnumSTATSTGImpl
{
const IEnumSTATSTGVtbl *lpVtbl; /* Needs to be the first item in the struct
* since we want to cast this in an IEnumSTATSTG pointer */
IEnumSTATSTG IEnumSTATSTG_iface;
LONG ref; /* Reference count */
StorageBaseImpl* parentStorage; /* Reference to the parent storage */
@ -306,6 +308,11 @@ struct IEnumSTATSTGImpl
WCHAR name[DIRENTRY_NAME_MAX_LEN]; /* The most recent name visited */
};
static inline IEnumSTATSTGImpl *impl_from_IEnumSTATSTG(IEnumSTATSTG *iface)
{
return CONTAINING_RECORD(iface, IEnumSTATSTGImpl, IEnumSTATSTG_iface);
}
static IEnumSTATSTGImpl* IEnumSTATSTGImpl_Construct(StorageBaseImpl* This, DirRef storageDirEntry);
static void IEnumSTATSTGImpl_Destroy(IEnumSTATSTGImpl* This);
@ -711,7 +718,7 @@ static HRESULT WINAPI StorageBaseImpl_EnumElements(
if (newEnum!=0)
{
*ppenum = (IEnumSTATSTG*)newEnum;
*ppenum = &newEnum->IEnumSTATSTG_iface;
IEnumSTATSTG_AddRef(*ppenum);
@ -1295,7 +1302,7 @@ static HRESULT StorageImpl_CreateDirEntry(
* memset the empty entry in order to initialize the unused newly
* created entries
*/
memset(&emptyData, 0, RAW_DIRENTRY_SIZE);
memset(emptyData, 0, RAW_DIRENTRY_SIZE);
/*
* initialize them
@ -1340,7 +1347,7 @@ static HRESULT StorageImpl_DestroyDirEntry(
BYTE emptyData[RAW_DIRENTRY_SIZE];
StorageImpl *storage = (StorageImpl*)base;
memset(&emptyData, 0, RAW_DIRENTRY_SIZE);
memset(emptyData, 0, RAW_DIRENTRY_SIZE);
hr = StorageImpl_WriteRawDirEntry(storage, index, emptyData);
@ -1596,163 +1603,88 @@ static HRESULT findTreeParent(StorageBaseImpl *storage, DirRef storageEntry,
}
/*************************************************************************
* CopyTo (IStorage)
*/
static HRESULT WINAPI StorageBaseImpl_CopyTo(
IStorage* iface,
DWORD ciidExclude, /* [in] */
const IID* rgiidExclude, /* [size_is][unique][in] */
SNB snbExclude, /* [unique][in] */
IStorage* pstgDest) /* [unique][in] */
static HRESULT StorageBaseImpl_CopyStorageEntryTo(StorageBaseImpl *This,
DirRef srcEntry, BOOL skip_storage, BOOL skip_stream,
SNB snbExclude, IStorage *pstgDest);
static HRESULT StorageBaseImpl_CopyChildEntryTo(StorageBaseImpl *This,
DirRef srcEntry, BOOL skip_storage, BOOL skip_stream,
SNB snbExclude, IStorage *pstgDest)
{
StorageBaseImpl* const This=(StorageBaseImpl*)iface;
DirEntry data;
HRESULT hr;
BOOL skip = FALSE;
IStorage *pstgTmp;
IStream *pstrChild, *pstrTmp;
STATSTG strStat;
IEnumSTATSTG *elements = 0;
STATSTG curElement, strStat;
HRESULT hr;
IStorage *pstgTmp, *pstgChild;
IStream *pstrTmp, *pstrChild;
DirRef srcEntryRef;
DirEntry srcEntry;
BOOL skip = FALSE, skip_storage = FALSE, skip_stream = FALSE;
int i;
if (srcEntry == DIRENTRY_NULL)
return S_OK;
TRACE("(%p, %d, %p, %p, %p)\n",
iface, ciidExclude, rgiidExclude,
snbExclude, pstgDest);
hr = StorageBaseImpl_ReadDirEntry( This, srcEntry, &data );
if ( pstgDest == 0 )
return STG_E_INVALIDPOINTER;
/*
* Enumerate the elements
*/
hr = IStorage_EnumElements( iface, 0, 0, 0, &elements );
if ( hr != S_OK )
if (FAILED(hr))
return hr;
/*
* set the class ID
*/
IStorage_Stat( iface, &curElement, STATFLAG_NONAME);
IStorage_SetClass( pstgDest, &curElement.clsid );
for(i = 0; i < ciidExclude; ++i)
if ( snbExclude )
{
if(IsEqualGUID(&IID_IStorage, &rgiidExclude[i]))
skip_storage = TRUE;
else if(IsEqualGUID(&IID_IStream, &rgiidExclude[i]))
skip_stream = TRUE;
else
WARN("Unknown excluded GUID: %s\n", debugstr_guid(&rgiidExclude[i]));
WCHAR **snb = snbExclude;
while ( *snb != NULL && !skip )
{
if ( lstrcmpW(data.name, *snb) == 0 )
skip = TRUE;
++snb;
}
}
do
if (!skip)
{
/*
* Obtain the next element
*/
hr = IEnumSTATSTG_Next( elements, 1, &curElement, NULL );
if ( hr == S_FALSE )
if (data.stgType == STGTY_STORAGE && !skip_storage)
{
hr = S_OK; /* done, every element has been copied */
break;
}
if ( snbExclude )
{
WCHAR **snb = snbExclude;
skip = FALSE;
while ( *snb != NULL && !skip )
{
if ( lstrcmpW(curElement.pwcsName, *snb) == 0 )
skip = TRUE;
++snb;
}
}
if ( skip )
goto cleanup;
if (curElement.type == STGTY_STORAGE)
{
if(skip_storage)
goto cleanup;
/*
* open child source storage
*/
hr = IStorage_OpenStorage( iface, curElement.pwcsName, NULL,
STGM_READ|STGM_SHARE_EXCLUSIVE,
NULL, 0, &pstgChild );
if (hr != S_OK)
goto cleanup;
/*
* create a new storage in destination storage
*/
hr = IStorage_CreateStorage( pstgDest, curElement.pwcsName,
hr = IStorage_CreateStorage( pstgDest, data.name,
STGM_FAILIFTHERE|STGM_WRITE|STGM_SHARE_EXCLUSIVE,
0, 0,
0, 0,
&pstgTmp );
/*
* if it already exist, don't create a new one use this one
*/
if (hr == STG_E_FILEALREADYEXISTS)
{
hr = IStorage_OpenStorage( pstgDest, curElement.pwcsName, NULL,
hr = IStorage_OpenStorage( pstgDest, data.name, NULL,
STGM_WRITE|STGM_SHARE_EXCLUSIVE,
NULL, 0, &pstgTmp );
}
if (hr == S_OK)
if (SUCCEEDED(hr))
{
/*
* do the copy recursively
*/
hr = IStorage_CopyTo( pstgChild, ciidExclude, rgiidExclude,
NULL, pstgTmp );
hr = StorageBaseImpl_CopyStorageEntryTo( This, srcEntry, skip_storage,
skip_stream, NULL, pstgTmp );
IStorage_Release( pstgTmp );
IStorage_Release(pstgTmp);
}
IStorage_Release( pstgChild );
}
else if (curElement.type == STGTY_STREAM)
else if (data.stgType == STGTY_STREAM && !skip_stream)
{
if(skip_stream)
goto cleanup;
/*
* create a new stream in destination storage. If the stream already
* exist, it will be deleted and a new one will be created.
*/
hr = IStorage_CreateStream( pstgDest, curElement.pwcsName,
hr = IStorage_CreateStream( pstgDest, data.name,
STGM_CREATE|STGM_WRITE|STGM_SHARE_EXCLUSIVE,
0, 0, &pstrTmp );
if (hr != S_OK)
goto cleanup;
/*
* open child stream storage. This operation must succeed even if the
* stream is already open, so we use internal functions to do it.
*/
srcEntryRef = findElement( This, This->storageDirEntry, curElement.pwcsName,
&srcEntry);
if (!srcEntryRef)
{
ERR("source stream not found\n");
hr = STG_E_DOCFILECORRUPT;
}
if (hr == S_OK)
{
pstrChild = (IStream*)StgStreamImpl_Construct(This, STGM_READ|STGM_SHARE_EXCLUSIVE, srcEntryRef);
pstrChild = (IStream*)StgStreamImpl_Construct(This, STGM_READ|STGM_SHARE_EXCLUSIVE, srcEntry);
if (pstrChild)
IStream_AddRef(pstrChild);
else
@ -1782,23 +1714,128 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo(
IStream_Release( pstrTmp );
}
else
{
WARN("unknown element type: %d\n", curElement.type);
}
}
cleanup:
CoTaskMemFree(curElement.pwcsName);
} while (hr == S_OK);
/* copy siblings */
if (SUCCEEDED(hr))
hr = StorageBaseImpl_CopyChildEntryTo( This, data.leftChild, skip_storage,
skip_stream, snbExclude, pstgDest );
/*
* Clean-up
*/
IEnumSTATSTG_Release(elements);
if (SUCCEEDED(hr))
hr = StorageBaseImpl_CopyChildEntryTo( This, data.rightChild, skip_storage,
skip_stream, snbExclude, pstgDest );
return hr;
}
static HRESULT StorageBaseImpl_CopyStorageEntryTo(StorageBaseImpl *This,
DirRef srcEntry, BOOL skip_storage, BOOL skip_stream,
SNB snbExclude, IStorage *pstgDest)
{
DirEntry data;
HRESULT hr;
hr = StorageBaseImpl_ReadDirEntry( This, srcEntry, &data );
if (SUCCEEDED(hr))
hr = IStorage_SetClass( pstgDest, &data.clsid );
if (SUCCEEDED(hr))
hr = StorageBaseImpl_CopyChildEntryTo( This, data.dirRootEntry, skip_storage,
skip_stream, snbExclude, pstgDest );
return hr;
}
/*************************************************************************
* CopyTo (IStorage)
*/
static HRESULT WINAPI StorageBaseImpl_CopyTo(
IStorage* iface,
DWORD ciidExclude, /* [in] */
const IID* rgiidExclude, /* [size_is][unique][in] */
SNB snbExclude, /* [unique][in] */
IStorage* pstgDest) /* [unique][in] */
{
StorageBaseImpl* const This=(StorageBaseImpl*)iface;
BOOL skip_storage = FALSE, skip_stream = FALSE;
int i;
TRACE("(%p, %d, %p, %p, %p)\n",
iface, ciidExclude, rgiidExclude,
snbExclude, pstgDest);
if ( pstgDest == 0 )
return STG_E_INVALIDPOINTER;
for(i = 0; i < ciidExclude; ++i)
{
if(IsEqualGUID(&IID_IStorage, &rgiidExclude[i]))
skip_storage = TRUE;
else if(IsEqualGUID(&IID_IStream, &rgiidExclude[i]))
skip_stream = TRUE;
else
WARN("Unknown excluded GUID: %s\n", debugstr_guid(&rgiidExclude[i]));
}
if (!skip_storage)
{
/* Give up early if it looks like this would be infinitely recursive.
* Oddly enough, this includes some cases that aren't really recursive, like
* copying to a transacted child. */
IStorage *pstgDestAncestor = pstgDest;
IStorage *pstgDestAncestorChild = NULL;
/* Go up the chain from the destination until we find the source storage. */
while (pstgDestAncestor != iface) {
pstgDestAncestorChild = pstgDest;
if (pstgDestAncestor->lpVtbl == &TransactedSnapshotImpl_Vtbl)
{
TransactedSnapshotImpl *impl = (TransactedSnapshotImpl*) pstgDestAncestor;
pstgDestAncestor = (IStorage*)impl->transactedParent;
}
else if (pstgDestAncestor->lpVtbl == &Storage32InternalImpl_Vtbl)
{
StorageInternalImpl *impl = (StorageInternalImpl*) pstgDestAncestor;
pstgDestAncestor = (IStorage*)impl->parentStorage;
}
else
break;
}
if (pstgDestAncestor == iface)
{
BOOL fail = TRUE;
if (pstgDestAncestorChild && snbExclude)
{
StorageBaseImpl *ancestorChildBase = (StorageBaseImpl*)pstgDestAncestorChild;
DirEntry data;
WCHAR **snb = snbExclude;
StorageBaseImpl_ReadDirEntry(ancestorChildBase, ancestorChildBase->storageDirEntry, &data);
while ( *snb != NULL && fail )
{
if ( lstrcmpW(data.name, *snb) == 0 )
fail = FALSE;
++snb;
}
}
if (fail)
return STG_E_ACCESSDENIED;
}
}
return StorageBaseImpl_CopyStorageEntryTo( This, This->storageDirEntry,
skip_storage, skip_stream, snbExclude, pstgDest );
}
/*************************************************************************
* MoveElementTo (IStorage)
*/
@ -2489,7 +2526,7 @@ static HRESULT StorageImpl_StreamSetSize(StorageBaseImpl *base, DirRef index,
}
else if (bigblock && newsize.QuadPart < LIMIT_TO_USE_SMALL_BLOCK)
{
smallblock = Storage32Impl_BigBlocksToSmallBlocks(This, pbigblock);
smallblock = Storage32Impl_BigBlocksToSmallBlocks(This, pbigblock, newsize);
if (!smallblock)
return E_FAIL;
}
@ -2703,6 +2740,10 @@ static HRESULT StorageImpl_Construct(
ULARGE_INTEGER size;
BYTE bigBlockBuffer[MAX_BIG_BLOCK_SIZE];
/* Discard any existing data. */
size.QuadPart = 0;
ILockBytes_SetSize(This->lockBytes, size);
/*
* Initialize all header variables:
* - The big block depot consists of one block and it is at block 0
@ -2760,6 +2801,7 @@ static HRESULT StorageImpl_Construct(
* There is no block depot cached yet.
*/
This->indexBlockDepotCached = 0xFFFFFFFF;
This->indexExtBlockDepotCached = 0xFFFFFFFF;
/*
* Start searching for free blocks with block 0.
@ -2768,6 +2810,40 @@ static HRESULT StorageImpl_Construct(
This->firstFreeSmallBlock = 0;
/* Read the extended big block depot locations. */
if (This->extBigBlockDepotCount != 0)
{
ULONG current_block = This->extBigBlockDepotStart;
ULONG cache_size = This->extBigBlockDepotCount * 2;
int i;
This->extBigBlockDepotLocations = HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG) * cache_size);
if (!This->extBigBlockDepotLocations)
{
hr = E_OUTOFMEMORY;
goto end;
}
This->extBigBlockDepotLocationsSize = cache_size;
for (i=0; i<This->extBigBlockDepotCount; i++)
{
if (current_block == BLOCK_END_OF_CHAIN)
{
WARN("File has too few extended big block depot blocks.\n");
hr = STG_E_DOCFILECORRUPT;
goto end;
}
This->extBigBlockDepotLocations[i] = current_block;
current_block = Storage32Impl_GetNextExtendedBlock(This, current_block);
}
}
else
{
This->extBigBlockDepotLocations = NULL;
This->extBigBlockDepotLocationsSize = 0;
}
/*
* Create the block chain abstractions.
*/
@ -2884,6 +2960,8 @@ static void StorageImpl_Destroy(StorageBaseImpl* iface)
StorageImpl_Invalidate(iface);
HeapFree(GetProcessHeap(), 0, This->extBigBlockDepotLocations);
BlockChainStream_Destroy(This->smallBlockRootChain);
BlockChainStream_Destroy(This->rootBlockChain);
BlockChainStream_Destroy(This->smallBlockDepotChain);
@ -3097,22 +3175,33 @@ static ULONG Storage32Impl_GetExtDepotBlock(StorageImpl* This, ULONG depotIndex)
ULONG extBlockCount = numExtBlocks / depotBlocksPerExtBlock;
ULONG extBlockOffset = numExtBlocks % depotBlocksPerExtBlock;
ULONG blockIndex = BLOCK_UNUSED;
ULONG extBlockIndex = This->extBigBlockDepotStart;
ULONG extBlockIndex;
BYTE depotBuffer[MAX_BIG_BLOCK_SIZE];
int index, num_blocks;
assert(depotIndex >= COUNT_BBDEPOTINHEADER);
if (This->extBigBlockDepotStart == BLOCK_END_OF_CHAIN)
if (extBlockCount >= This->extBigBlockDepotCount)
return BLOCK_UNUSED;
while (extBlockCount > 0)
if (This->indexExtBlockDepotCached != extBlockCount)
{
extBlockIndex = Storage32Impl_GetNextExtendedBlock(This, extBlockIndex);
extBlockCount--;
extBlockIndex = This->extBigBlockDepotLocations[extBlockCount];
StorageImpl_ReadBigBlock(This, extBlockIndex, depotBuffer);
num_blocks = This->bigBlockSize / 4;
for (index = 0; index < num_blocks; index++)
{
StorageUtl_ReadDWord(depotBuffer, index*sizeof(ULONG), &blockIndex);
This->extBlockDepotCached[index] = blockIndex;
}
This->indexExtBlockDepotCached = extBlockCount;
}
if (extBlockIndex != BLOCK_UNUSED)
StorageImpl_ReadDWordFromBigBlock(This, extBlockIndex,
extBlockOffset * sizeof(ULONG), &blockIndex);
blockIndex = This->extBlockDepotCached[extBlockOffset];
return blockIndex;
}
@ -3130,15 +3219,13 @@ static void Storage32Impl_SetExtDepotBlock(StorageImpl* This, ULONG depotIndex,
ULONG numExtBlocks = depotIndex - COUNT_BBDEPOTINHEADER;
ULONG extBlockCount = numExtBlocks / depotBlocksPerExtBlock;
ULONG extBlockOffset = numExtBlocks % depotBlocksPerExtBlock;
ULONG extBlockIndex = This->extBigBlockDepotStart;
ULONG extBlockIndex;
assert(depotIndex >= COUNT_BBDEPOTINHEADER);
while (extBlockCount > 0)
{
extBlockIndex = Storage32Impl_GetNextExtendedBlock(This, extBlockIndex);
extBlockCount--;
}
assert(extBlockCount < This->extBigBlockDepotCount);
extBlockIndex = This->extBigBlockDepotLocations[extBlockCount];
if (extBlockIndex != BLOCK_UNUSED)
{
@ -3146,6 +3233,11 @@ static void Storage32Impl_SetExtDepotBlock(StorageImpl* This, ULONG depotIndex,
extBlockOffset * sizeof(ULONG),
blockIndex);
}
if (This->indexExtBlockDepotCached == extBlockCount)
{
This->extBlockDepotCached[extBlockOffset] = blockIndex;
}
}
/******************************************************************************
@ -3175,14 +3267,10 @@ static ULONG Storage32Impl_AddExtBlockDepot(StorageImpl* This)
}
else
{
unsigned int i;
/*
* Follow the chain to the last one.
* Find the last existing extended block.
*/
for (i = 0; i < (numExtBlocks - 1); i++)
{
nextExtBlock = Storage32Impl_GetNextExtendedBlock(This, nextExtBlock);
}
nextExtBlock = This->extBigBlockDepotLocations[This->extBigBlockDepotCount-1];
/*
* Add the new extended block to the chain.
@ -3197,6 +3285,20 @@ static ULONG Storage32Impl_AddExtBlockDepot(StorageImpl* This)
memset(depotBuffer, BLOCK_UNUSED, This->bigBlockSize);
StorageImpl_WriteBigBlock(This, index, depotBuffer);
/* Add the block to our cache. */
if (This->extBigBlockDepotLocationsSize == numExtBlocks)
{
ULONG new_cache_size = (This->extBigBlockDepotLocationsSize+1)*2;
ULONG *new_cache = HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG) * new_cache_size);
memcpy(new_cache, This->extBigBlockDepotLocations, sizeof(ULONG) * This->extBigBlockDepotLocationsSize);
HeapFree(GetProcessHeap(), 0, This->extBigBlockDepotLocations);
This->extBigBlockDepotLocations = new_cache;
This->extBigBlockDepotLocationsSize = new_cache_size;
}
This->extBigBlockDepotLocations[numExtBlocks] = index;
return index;
}
@ -4071,12 +4173,13 @@ BlockChainStream* Storage32Impl_SmallBlocksToBigBlocks(
*/
SmallBlockChainStream* Storage32Impl_BigBlocksToSmallBlocks(
StorageImpl* This,
BlockChainStream** ppbbChain)
BlockChainStream** ppbbChain,
ULARGE_INTEGER newSize)
{
ULARGE_INTEGER size, offset, cbTotalRead;
ULONG cbRead, cbWritten, sbHeadOfChain = BLOCK_END_OF_CHAIN;
DirRef streamEntryRef;
HRESULT resWrite = S_OK, resRead;
HRESULT resWrite = S_OK, resRead = S_OK;
DirEntry streamEntry;
BYTE* buffer;
SmallBlockChainStream* sbTempChain;
@ -4089,14 +4192,15 @@ SmallBlockChainStream* Storage32Impl_BigBlocksToSmallBlocks(
if(!sbTempChain)
return NULL;
SmallBlockChainStream_SetSize(sbTempChain, newSize);
size = BlockChainStream_GetSize(*ppbbChain);
SmallBlockChainStream_SetSize(sbTempChain, size);
size.QuadPart = min(size.QuadPart, newSize.QuadPart);
offset.u.HighPart = 0;
offset.u.LowPart = 0;
cbTotalRead.QuadPart = 0;
buffer = HeapAlloc(GetProcessHeap(), 0, This->bigBlockSize);
do
while(cbTotalRead.QuadPart < size.QuadPart)
{
resRead = BlockChainStream_ReadAt(*ppbbChain, offset,
min(This->bigBlockSize, size.u.LowPart - offset.u.LowPart),
@ -4122,7 +4226,7 @@ SmallBlockChainStream* Storage32Impl_BigBlocksToSmallBlocks(
resRead = STG_E_READFAULT;
break;
}
}while(cbTotalRead.QuadPart < size.QuadPart);
}
HeapFree(GetProcessHeap(), 0, buffer);
size.u.HighPart = 0;
@ -4995,7 +5099,7 @@ static HRESULT TransactedSnapshotImpl_Construct(StorageBaseImpl *parentStorage,
(*result)->base.openFlags = parentStorage->openFlags;
/* Create a new temporary storage to act as the scratch file. */
hr = StgCreateDocfile(NULL, STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_CREATE,
hr = StgCreateDocfile(NULL, STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_DELETEONRELEASE,
0, (IStorage**)&(*result)->scratch);
if (SUCCEEDED(hr))
@ -5229,7 +5333,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface(
REFIID riid,
void** ppvObject)
{
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface;
IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
if (ppvObject==0)
return E_INVALIDARG;
@ -5240,7 +5344,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface(
IsEqualGUID(&IID_IEnumSTATSTG, riid))
{
*ppvObject = This;
IEnumSTATSTG_AddRef((IEnumSTATSTG*)This);
IEnumSTATSTG_AddRef(&This->IEnumSTATSTG_iface);
return S_OK;
}
@ -5250,14 +5354,14 @@ static HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface(
static ULONG WINAPI IEnumSTATSTGImpl_AddRef(
IEnumSTATSTG* iface)
{
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface;
IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI IEnumSTATSTGImpl_Release(
IEnumSTATSTG* iface)
{
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface;
IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
ULONG newRef;
@ -5322,7 +5426,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Next(
STATSTG* rgelt,
ULONG* pceltFetched)
{
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface;
IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
DirEntry currentEntry;
STATSTG* currentReturnStruct = rgelt;
@ -5389,9 +5493,9 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Skip(
IEnumSTATSTG* iface,
ULONG celt)
{
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface;
IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
ULONG objectFetched = 0;
ULONG objectFetched = 0;
DirRef currentSearchNode;
HRESULT hr=S_OK;
@ -5417,7 +5521,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Skip(
static HRESULT WINAPI IEnumSTATSTGImpl_Reset(
IEnumSTATSTG* iface)
{
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface;
IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
if (This->parentStorage->reverted)
return STG_E_REVERTED;
@ -5431,7 +5535,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Clone(
IEnumSTATSTG* iface,
IEnumSTATSTG** ppenum)
{
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface;
IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
IEnumSTATSTGImpl* newClone;
@ -5454,7 +5558,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Clone(
*/
memcpy(newClone->name, This->name, sizeof(newClone->name));
*ppenum = (IEnumSTATSTG*)newClone;
*ppenum = &newClone->IEnumSTATSTG_iface;
/*
* Don't forget to nail down a reference to the clone before
@ -5496,7 +5600,7 @@ static IEnumSTATSTGImpl* IEnumSTATSTGImpl_Construct(
/*
* Set-up the virtual function table and reference count.
*/
newEnumeration->lpVtbl = &IEnumSTATSTGImpl_Vtbl;
newEnumeration->IEnumSTATSTG_iface.lpVtbl = &IEnumSTATSTGImpl_Vtbl;
newEnumeration->ref = 0;
/*
@ -5511,7 +5615,7 @@ static IEnumSTATSTGImpl* IEnumSTATSTGImpl_Construct(
/*
* Make sure the current node of the iterator is the first one.
*/
IEnumSTATSTGImpl_Reset((IEnumSTATSTG*)newEnumeration);
IEnumSTATSTGImpl_Reset(&newEnumeration->IEnumSTATSTG_iface);
}
return newEnumeration;
@ -7369,6 +7473,9 @@ HRESULT WINAPI StgCreateStorageEx(const WCHAR* pwcsName, DWORD grfMode, DWORD st
if (stgfmt == STGFMT_STORAGE || stgfmt == STGFMT_DOCFILE)
{
STGOPTIONS defaultOptions = {1, 0, 512};
if (!pStgOptions) pStgOptions = &defaultOptions;
return create_storagefile(pwcsName, grfMode, grfAttrs, pStgOptions, riid, ppObjectOpen);
}
@ -7739,15 +7846,16 @@ HRESULT WINAPI StgSetTimes(OLECHAR const *str, FILETIME const *pctime,
*/
HRESULT WINAPI StgIsStorageILockBytes(ILockBytes *plkbyt)
{
BYTE sig[8];
BYTE sig[sizeof(STORAGE_magic)];
ULARGE_INTEGER offset;
ULONG read = 0;
offset.u.HighPart = 0;
offset.u.LowPart = 0;
ILockBytes_ReadAt(plkbyt, offset, sig, sizeof(sig), NULL);
ILockBytes_ReadAt(plkbyt, offset, sig, sizeof(sig), &read);
if (memcmp(sig, STORAGE_magic, sizeof(STORAGE_magic)) == 0)
if (read == sizeof(sig) && memcmp(sig, STORAGE_magic, sizeof(sig)) == 0)
return S_OK;
return S_FALSE;

View file

@ -154,14 +154,14 @@ struct DirEntry
ULARGE_INTEGER size;
};
HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsName, ILockBytes **pLockBytes);
HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsName, ILockBytes **pLockBytes) DECLSPEC_HIDDEN;
/*************************************************************************
* Ole Convert support
*/
void OLECONVERT_CreateOleStream(LPSTORAGE pStorage);
HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName);
void OLECONVERT_CreateOleStream(LPSTORAGE pStorage) DECLSPEC_HIDDEN;
HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName) DECLSPEC_HIDDEN;
/****************************************************************************
@ -325,8 +325,8 @@ static inline HRESULT StorageBaseImpl_StreamLink(StorageBaseImpl *This,
* StorageBaseImpl stream list handlers
*/
void StorageBaseImpl_AddStream(StorageBaseImpl * stg, StgStreamImpl * strm);
void StorageBaseImpl_RemoveStream(StorageBaseImpl * stg, StgStreamImpl * strm);
void StorageBaseImpl_AddStream(StorageBaseImpl * stg, StgStreamImpl * strm) DECLSPEC_HIDDEN;
void StorageBaseImpl_RemoveStream(StorageBaseImpl * stg, StgStreamImpl * strm) DECLSPEC_HIDDEN;
/* Number of BlockChainStream objects to cache in a StorageImpl */
#define BLOCKCHAIN_CACHE_SIZE 4
@ -353,9 +353,14 @@ struct StorageImpl
ULONG smallBlockLimit;
ULONG smallBlockDepotStart;
ULONG extBigBlockDepotStart;
ULONG *extBigBlockDepotLocations;
ULONG extBigBlockDepotLocationsSize;
ULONG extBigBlockDepotCount;
ULONG bigBlockDepotStart[COUNT_BBDEPOTINHEADER];
ULONG extBlockDepotCached[MAX_BIG_BLOCK_SIZE / 4];
ULONG indexExtBlockDepotCached;
ULONG blockDepotCached[MAX_BIG_BLOCK_SIZE / 4];
ULONG indexBlockDepotCached;
ULONG prevFreeBlock;
@ -380,34 +385,35 @@ struct StorageImpl
HRESULT StorageImpl_ReadRawDirEntry(
StorageImpl *This,
ULONG index,
BYTE *buffer);
BYTE *buffer) DECLSPEC_HIDDEN;
void UpdateRawDirEntry(
BYTE *buffer,
const DirEntry *newData);
const DirEntry *newData) DECLSPEC_HIDDEN;
HRESULT StorageImpl_WriteRawDirEntry(
StorageImpl *This,
ULONG index,
const BYTE *buffer);
const BYTE *buffer) DECLSPEC_HIDDEN;
HRESULT StorageImpl_ReadDirEntry(
StorageImpl* This,
DirRef index,
DirEntry* buffer);
DirEntry* buffer) DECLSPEC_HIDDEN;
HRESULT StorageImpl_WriteDirEntry(
StorageImpl* This,
DirRef index,
const DirEntry* buffer);
const DirEntry* buffer) DECLSPEC_HIDDEN;
BlockChainStream* Storage32Impl_SmallBlocksToBigBlocks(
StorageImpl* This,
SmallBlockChainStream** ppsbChain);
SmallBlockChainStream** ppsbChain) DECLSPEC_HIDDEN;
SmallBlockChainStream* Storage32Impl_BigBlocksToSmallBlocks(
StorageImpl* This,
BlockChainStream** ppbbChain);
BlockChainStream** ppbbChain,
ULARGE_INTEGER newSize) DECLSPEC_HIDDEN;
/****************************************************************************
* StgStreamImpl definitions.
@ -458,7 +464,7 @@ struct StgStreamImpl
StgStreamImpl* StgStreamImpl_Construct(
StorageBaseImpl* parentStorage,
DWORD grfMode,
DirRef dirEntry);
DirRef dirEntry) DECLSPEC_HIDDEN;
/******************************************************************************
@ -485,18 +491,18 @@ StgStreamImpl* StgStreamImpl_Construct(
* are abstractions used to read values from file buffers without having to
* worry about bit order
*/
void StorageUtl_ReadWord(const BYTE* buffer, ULONG offset, WORD* value);
void StorageUtl_WriteWord(BYTE* buffer, ULONG offset, WORD value);
void StorageUtl_ReadDWord(const BYTE* buffer, ULONG offset, DWORD* value);
void StorageUtl_WriteDWord(BYTE* buffer, ULONG offset, DWORD value);
void StorageUtl_ReadWord(const BYTE* buffer, ULONG offset, WORD* value) DECLSPEC_HIDDEN;
void StorageUtl_WriteWord(BYTE* buffer, ULONG offset, WORD value) DECLSPEC_HIDDEN;
void StorageUtl_ReadDWord(const BYTE* buffer, ULONG offset, DWORD* value) DECLSPEC_HIDDEN;
void StorageUtl_WriteDWord(BYTE* buffer, ULONG offset, DWORD value) DECLSPEC_HIDDEN;
void StorageUtl_ReadULargeInteger(const BYTE* buffer, ULONG offset,
ULARGE_INTEGER* value);
ULARGE_INTEGER* value) DECLSPEC_HIDDEN;
void StorageUtl_WriteULargeInteger(BYTE* buffer, ULONG offset,
const ULARGE_INTEGER *value);
void StorageUtl_ReadGUID(const BYTE* buffer, ULONG offset, GUID* value);
void StorageUtl_WriteGUID(BYTE* buffer, ULONG offset, const GUID* value);
const ULARGE_INTEGER *value) DECLSPEC_HIDDEN;
void StorageUtl_ReadGUID(const BYTE* buffer, ULONG offset, GUID* value) DECLSPEC_HIDDEN;
void StorageUtl_WriteGUID(BYTE* buffer, ULONG offset, const GUID* value) DECLSPEC_HIDDEN;
void StorageUtl_CopyDirEntryToSTATSTG(StorageBaseImpl *storage,STATSTG* destination,
const DirEntry* source, int statFlags);
const DirEntry* source, int statFlags) DECLSPEC_HIDDEN;
/****************************************************************************
* BlockChainStream definitions.
@ -541,31 +547,31 @@ struct BlockChainStream
BlockChainStream* BlockChainStream_Construct(
StorageImpl* parentStorage,
ULONG* headOfStreamPlaceHolder,
DirRef dirEntry);
DirRef dirEntry) DECLSPEC_HIDDEN;
void BlockChainStream_Destroy(
BlockChainStream* This);
BlockChainStream* This) DECLSPEC_HIDDEN;
HRESULT BlockChainStream_ReadAt(
BlockChainStream* This,
ULARGE_INTEGER offset,
ULONG size,
void* buffer,
ULONG* bytesRead);
ULONG* bytesRead) DECLSPEC_HIDDEN;
HRESULT BlockChainStream_WriteAt(
BlockChainStream* This,
ULARGE_INTEGER offset,
ULONG size,
const void* buffer,
ULONG* bytesWritten);
ULONG* bytesWritten) DECLSPEC_HIDDEN;
BOOL BlockChainStream_SetSize(
BlockChainStream* This,
ULARGE_INTEGER newSize);
ULARGE_INTEGER newSize) DECLSPEC_HIDDEN;
HRESULT BlockChainStream_Flush(
BlockChainStream* This);
BlockChainStream* This) DECLSPEC_HIDDEN;
/****************************************************************************
* SmallBlockChainStream definitions.
@ -586,28 +592,28 @@ struct SmallBlockChainStream
SmallBlockChainStream* SmallBlockChainStream_Construct(
StorageImpl* parentStorage,
ULONG* headOfStreamPlaceHolder,
DirRef dirEntry);
DirRef dirEntry) DECLSPEC_HIDDEN;
void SmallBlockChainStream_Destroy(
SmallBlockChainStream* This);
SmallBlockChainStream* This) DECLSPEC_HIDDEN;
HRESULT SmallBlockChainStream_ReadAt(
SmallBlockChainStream* This,
ULARGE_INTEGER offset,
ULONG size,
void* buffer,
ULONG* bytesRead);
ULONG* bytesRead) DECLSPEC_HIDDEN;
HRESULT SmallBlockChainStream_WriteAt(
SmallBlockChainStream* This,
ULARGE_INTEGER offset,
ULONG size,
const void* buffer,
ULONG* bytesWritten);
ULONG* bytesWritten) DECLSPEC_HIDDEN;
BOOL SmallBlockChainStream_SetSize(
SmallBlockChainStream* This,
ULARGE_INTEGER newSize);
ULARGE_INTEGER newSize) DECLSPEC_HIDDEN;
#endif /* __STORAGE32_H__ */

View file

@ -578,12 +578,17 @@ BOOL stub_manager_is_table_marshaled(struct stub_manager *m, const IPID *ipid)
typedef struct rem_unknown
{
const IRemUnknownVtbl *lpVtbl;
IRemUnknown IRemUnknown_iface;
LONG refs;
} RemUnknown;
static const IRemUnknownVtbl RemUnknown_Vtbl;
static inline RemUnknown *impl_from_IRemUnknown(IRemUnknown *iface)
{
return CONTAINING_RECORD(iface, RemUnknown, IRemUnknown_iface);
}
/* construct an IRemUnknown object with one outstanding reference */
static HRESULT RemUnknown_Construct(IRemUnknown **ppRemUnknown)
@ -592,10 +597,10 @@ static HRESULT RemUnknown_Construct(IRemUnknown **ppRemUnknown)
if (!This) return E_OUTOFMEMORY;
This->lpVtbl = &RemUnknown_Vtbl;
This->IRemUnknown_iface.lpVtbl = &RemUnknown_Vtbl;
This->refs = 1;
*ppRemUnknown = (IRemUnknown *)This;
*ppRemUnknown = &This->IRemUnknown_iface;
return S_OK;
}
@ -620,7 +625,7 @@ static HRESULT WINAPI RemUnknown_QueryInterface(IRemUnknown *iface, REFIID riid,
static ULONG WINAPI RemUnknown_AddRef(IRemUnknown *iface)
{
ULONG refs;
RemUnknown *This = (RemUnknown *)iface;
RemUnknown *This = impl_from_IRemUnknown(iface);
refs = InterlockedIncrement(&This->refs);
@ -631,7 +636,7 @@ static ULONG WINAPI RemUnknown_AddRef(IRemUnknown *iface)
static ULONG WINAPI RemUnknown_Release(IRemUnknown *iface)
{
ULONG refs;
RemUnknown *This = (RemUnknown *)iface;
RemUnknown *This = impl_from_IRemUnknown(iface);
refs = InterlockedDecrement(&This->refs);
if (!refs)

View file

@ -429,7 +429,7 @@ unsigned char * __RPC_USER HGLOBAL_UserMarshal(ULONG *pFlags, unsigned char *pBu
{
*(ULONG *)pBuffer = WDT_REMOTE_CALL;
pBuffer += sizeof(ULONG);
*(ULONG *)pBuffer = (ULONG)*phGlobal;
*(ULONG *)pBuffer = HandleToULong(*phGlobal);
pBuffer += sizeof(ULONG);
if (*phGlobal)
{
@ -437,7 +437,7 @@ unsigned char * __RPC_USER HGLOBAL_UserMarshal(ULONG *pFlags, unsigned char *pBu
SIZE_T size = GlobalSize(*phGlobal);
*(ULONG *)pBuffer = (ULONG)size;
pBuffer += sizeof(ULONG);
*(ULONG *)pBuffer = (ULONG)*phGlobal;
*(ULONG *)pBuffer = HandleToULong(*phGlobal);
pBuffer += sizeof(ULONG);
*(ULONG *)pBuffer = (ULONG)size;
pBuffer += sizeof(ULONG);

View file

@ -123,7 +123,7 @@ reactos/dll/win32/ntprint # Synced to Wine-1.3.37
reactos/dll/win32/objsel # Synced to Wine-1.3.37
reactos/dll/win32/odbc32 # Out of sync. Depends on port of Linux ODBC.
reactos/dll/win32/odbccp32 # Synced to Wine-1.3.37
reactos/dll/win32/ole32 # Autosync
reactos/dll/win32/ole32 # Synced to Wine-1.5.4
reactos/dll/win32/oleacc # Autosync
reactos/dll/win32/oleaut32 # Autosync
reactos/dll/win32/olecli32 # Synced to Wine-1.3.37