From 3df7653ebecb77324ac8d563c2700956e9f467fa Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Tue, 7 Jun 2016 10:47:21 +0000 Subject: [PATCH] [OLE32] Sync with Wine Staging 1.9.11. CORE-11368 svn path=/trunk/; revision=71579 --- reactos/dll/win32/ole32/compobj.c | 139 +++++----- reactos/dll/win32/ole32/compositemoniker.c | 88 +++--- reactos/dll/win32/ole32/datacache.c | 2 +- reactos/dll/win32/ole32/filemoniker.c | 58 ++-- reactos/dll/win32/ole32/ifs.c | 12 +- reactos/dll/win32/ole32/marshal.c | 4 +- reactos/dll/win32/ole32/ole2.c | 303 +++++++++------------ reactos/dll/win32/ole32/ole2stubs.c | 9 - reactos/dll/win32/ole32/ole32_ros.diff | 82 ++++-- reactos/dll/win32/ole32/ole32res.rc | 10 +- reactos/dll/win32/ole32/olestd.h | 5 + reactos/dll/win32/ole32/stg_prop.c | 102 ++++++- reactos/media/doc/README.WINE | 2 +- 13 files changed, 456 insertions(+), 360 deletions(-) diff --git a/reactos/dll/win32/ole32/compobj.c b/reactos/dll/win32/ole32/compobj.c index 9b3c68dc764..769794076bc 100644 --- a/reactos/dll/win32/ole32/compobj.c +++ b/reactos/dll/win32/ole32/compobj.c @@ -3181,14 +3181,14 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance( return hres; } -static void init_multi_qi(DWORD count, MULTI_QI *mqi) +static void init_multi_qi(DWORD count, MULTI_QI *mqi, HRESULT hr) { ULONG i; for (i = 0; i < count; i++) { mqi[i].pItf = NULL; - mqi[i].hr = E_NOINTERFACE; + mqi[i].hr = hr; } } @@ -3244,7 +3244,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstanceEx( if (pServerInfo) FIXME("() non-NULL pServerInfo not supported!\n"); - init_multi_qi(cmq, pResults); + init_multi_qi(cmq, pResults, E_NOINTERFACE); hres = CoGetTreatAsClass(rclsid, &clsid); if(FAILED(hres)) @@ -3328,7 +3328,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetInstanceFromFile( if (server_info) FIXME("() non-NULL server_info not supported\n"); - init_multi_qi(count, results); + init_multi_qi(count, results, E_NOINTERFACE); /* optionally get CLSID from a file */ if (!rclsid) @@ -3350,20 +3350,30 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetInstanceFromFile( (void**)&unk); if (hr != S_OK) - return hr; + { + init_multi_qi(count, results, hr); + return hr; + } /* init from file */ hr = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&pf); if (FAILED(hr)) - ERR("failed to get IPersistFile\n"); - - if (pf) { - IPersistFile_Load(pf, filename, grfmode); - IPersistFile_Release(pf); + init_multi_qi(count, results, hr); + IUnknown_Release(unk); + return hr; } - return return_multi_qi(unk, count, results, FALSE); + hr = IPersistFile_Load(pf, filename, grfmode); + IPersistFile_Release(pf); + if (SUCCEEDED(hr)) + return return_multi_qi(unk, count, results, FALSE); + else + { + init_multi_qi(count, results, hr); + IUnknown_Release(unk); + return hr; + } } /*********************************************************************** @@ -3390,7 +3400,7 @@ HRESULT WINAPI CoGetInstanceFromIStorage( if (server_info) FIXME("() non-NULL server_info not supported\n"); - init_multi_qi(count, results); + init_multi_qi(count, results, E_NOINTERFACE); /* optionally get CLSID from a file */ if (!rclsid) @@ -3828,6 +3838,20 @@ DWORD WINAPI CoGetCurrentProcess(void) return GetCurrentProcessId(); } +/*********************************************************************** + * CoGetCurrentLogicalThreadId [OLE32.@] + */ +HRESULT WINAPI CoGetCurrentLogicalThreadId(GUID *id) +{ + TRACE("(%p)\n", id); + + if (!id) + return E_INVALIDARG; + + *id = COM_CurrentCausalityId(); + return S_OK; +} + /****************************************************************************** * CoRegisterMessageFilter [OLE32.@] * @@ -4595,7 +4619,6 @@ typedef struct Context IContextCallback IContextCallback_iface; IObjContext IObjContext_iface; LONG refs; - APTTYPE apttype; } Context; static inline Context *impl_from_IComThreadingInfo( IComThreadingInfo *iface ) @@ -4648,10 +4671,15 @@ static ULONG Context_AddRef(Context *This) static ULONG Context_Release(Context *This) { - ULONG refs = InterlockedDecrement(&This->refs); - if (!refs) + /* Context instance is initially created with CoGetContextToken() with refcount set to 0, + releasing context while refcount is at 0 destroys it. */ + if (!This->refs) + { HeapFree(GetProcessHeap(), 0, This); - return refs; + return 0; + } + + return InterlockedDecrement(&This->refs); } static HRESULT WINAPI Context_CTI_QueryInterface(IComThreadingInfo *iface, REFIID riid, LPVOID *ppv) @@ -4674,21 +4702,26 @@ static ULONG WINAPI Context_CTI_Release(IComThreadingInfo *iface) static HRESULT WINAPI Context_CTI_GetCurrentApartmentType(IComThreadingInfo *iface, APTTYPE *apttype) { - Context *This = impl_from_IComThreadingInfo(iface); + APTTYPEQUALIFIER qualifier; TRACE("(%p)\n", apttype); - *apttype = This->apttype; - return S_OK; + return CoGetApartmentType(apttype, &qualifier); } static HRESULT WINAPI Context_CTI_GetCurrentThreadType(IComThreadingInfo *iface, THDTYPE *thdtype) { - Context *This = impl_from_IComThreadingInfo(iface); + APTTYPEQUALIFIER qualifier; + APTTYPE apttype; + HRESULT hr; + + hr = CoGetApartmentType(&apttype, &qualifier); + if (FAILED(hr)) + return hr; TRACE("(%p)\n", thdtype); - switch (This->apttype) + switch (apttype) { case APTTYPE_STA: case APTTYPE_MAINSTA: @@ -4703,8 +4736,8 @@ static HRESULT WINAPI Context_CTI_GetCurrentThreadType(IComThreadingInfo *iface, static HRESULT WINAPI Context_CTI_GetCurrentLogicalThreadId(IComThreadingInfo *iface, GUID *logical_thread_id) { - FIXME("(%p): stub\n", logical_thread_id); - return E_NOTIMPL; + TRACE("(%p)\n", logical_thread_id); + return CoGetCurrentLogicalThreadId(logical_thread_id); } static HRESULT WINAPI Context_CTI_SetCurrentLogicalThreadId(IComThreadingInfo *iface, REFGUID logical_thread_id) @@ -4884,45 +4917,19 @@ static const IObjContextVtbl Context_Object_Vtbl = */ HRESULT WINAPI CoGetObjectContext(REFIID riid, void **ppv) { - APARTMENT *apt = COM_CurrentApt(); - Context *context; + IObjContext *context; HRESULT hr; TRACE("(%s, %p)\n", debugstr_guid(riid), ppv); *ppv = NULL; - if (!apt) - { - if (!(apt = apartment_find_multi_threaded())) - { - ERR("apartment not initialised\n"); - return CO_E_NOTINITIALIZED; - } - apartment_release(apt); - } + hr = CoGetContextToken((ULONG_PTR*)&context); + if (FAILED(hr)) + return hr; - context = HeapAlloc(GetProcessHeap(), 0, sizeof(*context)); - if (!context) - return E_OUTOFMEMORY; - - 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; - else if (apt->main) - context->apttype = APTTYPE_MAINSTA; - else - context->apttype = APTTYPE_STA; - - hr = IComThreadingInfo_QueryInterface(&context->IComThreadingInfo_iface, riid, ppv); - IComThreadingInfo_Release(&context->IComThreadingInfo_iface); - - return hr; + return IObjContext_QueryInterface(context, riid, ppv); } - /*********************************************************************** * CoGetContextToken [OLE32.@] */ @@ -4951,16 +4958,24 @@ HRESULT WINAPI CoGetContextToken( ULONG_PTR *token ) if (!info->context_token) { - HRESULT hr; - IObjContext *ctx; + Context *context; - hr = CoGetObjectContext(&IID_IObjContext, (void **)&ctx); - if (FAILED(hr)) return hr; - info->context_token = ctx; + context = HeapAlloc(GetProcessHeap(), 0, sizeof(*context)); + if (!context) + return E_OUTOFMEMORY; + + context->IComThreadingInfo_iface.lpVtbl = &Context_Threading_Vtbl; + context->IContextCallback_iface.lpVtbl = &Context_Callback_Vtbl; + context->IObjContext_iface.lpVtbl = &Context_Object_Vtbl; + /* Context token does not take a reference, it's always zero until + interface is explicitely requested with CoGetObjectContext(). */ + context->refs = 0; + + info->context_token = &context->IObjContext_iface; } *token = (ULONG_PTR)info->context_token; - TRACE("apt->context_token=%p\n", info->context_token); + TRACE("context_token=%p\n", info->context_token); return S_OK; } @@ -5013,7 +5028,7 @@ HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier) { struct oletls *info = COM_CurrentInfo(); - FIXME("(%p %p): semi-stub\n", type, qualifier); + FIXME("(%p, %p): semi-stub\n", type, qualifier); if (!type || !qualifier) return E_INVALIDARG; @@ -5032,7 +5047,7 @@ HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier) *qualifier = APTTYPEQUALIFIER_NONE; - return info->apt ? ERROR_SUCCESS : CO_E_NOTINITIALIZED; + return info->apt ? S_OK : CO_E_NOTINITIALIZED; } /*********************************************************************** diff --git a/reactos/dll/win32/ole32/compositemoniker.c b/reactos/dll/win32/ole32/compositemoniker.c index 1476744f8fe..300df072ddd 100644 --- a/reactos/dll/win32/ole32/compositemoniker.c +++ b/reactos/dll/win32/ole32/compositemoniker.c @@ -64,7 +64,7 @@ static inline EnumMonikerImpl *impl_from_IEnumMoniker(IEnumMoniker *iface) return CONTAINING_RECORD(iface, EnumMonikerImpl, IEnumMoniker_iface); } -static HRESULT EnumMonikerImpl_CreateEnumMoniker(IMoniker** tabMoniker,ULONG tabSize,ULONG currentPos,BOOL leftToRigth,IEnumMoniker ** ppmk); +static HRESULT EnumMonikerImpl_CreateEnumMoniker(IMoniker** tabMoniker,ULONG tabSize,ULONG currentPos,BOOL leftToRight,IEnumMoniker ** ppmk); /******************************************************************************* * CompositeMoniker_QueryInterface @@ -320,7 +320,7 @@ CompositeMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc, { HRESULT res; IRunningObjectTable *prot; - IMoniker *tempMk,*antiMk,*mostRigthMk; + IMoniker *tempMk,*antiMk,*rightMostMk; IEnumMoniker *enumMoniker; TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult); @@ -349,17 +349,17 @@ CompositeMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc, /* component of the composite, passing the rest of the composite as the pmkToLeft parameter for that call */ IMoniker_Enum(iface,FALSE,&enumMoniker); - IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); + IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL); IEnumMoniker_Release(enumMoniker); res=CreateAntiMoniker(&antiMk); res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk); IMoniker_Release(antiMk); - res=IMoniker_BindToObject(mostRigthMk,pbc,tempMk,riid,ppvResult); + res=IMoniker_BindToObject(rightMostMk,pbc,tempMk,riid,ppvResult); IMoniker_Release(tempMk); - IMoniker_Release(mostRigthMk); + IMoniker_Release(rightMostMk); } return res; @@ -373,7 +373,7 @@ CompositeMonikerImpl_BindToStorage(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult) { HRESULT res; - IMoniker *tempMk,*antiMk,*mostRigthMk,*leftMk; + IMoniker *tempMk,*antiMk,*rightMostMk,*leftMk; IEnumMoniker *enumMoniker; TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult); @@ -392,7 +392,7 @@ CompositeMonikerImpl_BindToStorage(IMoniker* iface, IBindCtx* pbc, leftMk = iface; IMoniker_Enum(iface, FALSE, &enumMoniker); - IEnumMoniker_Next(enumMoniker, 1, &mostRigthMk, NULL); + IEnumMoniker_Next(enumMoniker, 1, &rightMostMk, NULL); IEnumMoniker_Release(enumMoniker); res = CreateAntiMoniker(&antiMk); @@ -401,11 +401,11 @@ CompositeMonikerImpl_BindToStorage(IMoniker* iface, IBindCtx* pbc, if (FAILED(res)) return res; IMoniker_Release(antiMk); - res = IMoniker_BindToStorage(mostRigthMk, pbc, tempMk, riid, ppvResult); + res = IMoniker_BindToStorage(rightMostMk, pbc, tempMk, riid, ppvResult); IMoniker_Release(tempMk); - IMoniker_Release(mostRigthMk); + IMoniker_Release(rightMostMk); if (pmkToLeft) IMoniker_Release(leftMk); @@ -420,7 +420,7 @@ static HRESULT WINAPI CompositeMonikerImpl_Reduce(IMoniker* iface, IBindCtx* pbc, DWORD dwReduceHowFar, IMoniker** ppmkToLeft, IMoniker** ppmkReduced) { - IMoniker *tempMk,*antiMk,*mostRigthMk,*leftReducedComposedMk,*mostRigthReducedMk; + IMoniker *tempMk,*antiMk,*rightMostMk,*leftReducedComposedMk,*rightMostReducedMk; IEnumMoniker *enumMoniker; TRACE("(%p,%p,%d,%p,%p)\n",iface,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced); @@ -433,14 +433,14 @@ CompositeMonikerImpl_Reduce(IMoniker* iface, IBindCtx* pbc, DWORD dwReduceHowFar if (ppmkToLeft==NULL){ IMoniker_Enum(iface,FALSE,&enumMoniker); - IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); + IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL); IEnumMoniker_Release(enumMoniker); CreateAntiMoniker(&antiMk); IMoniker_ComposeWith(iface,antiMk,0,&tempMk); IMoniker_Release(antiMk); - return IMoniker_Reduce(mostRigthMk,pbc,dwReduceHowFar,&tempMk, ppmkReduced); + return IMoniker_Reduce(rightMostMk,pbc,dwReduceHowFar,&tempMk, ppmkReduced); } else if (*ppmkToLeft==NULL) @@ -450,7 +450,7 @@ CompositeMonikerImpl_Reduce(IMoniker* iface, IBindCtx* pbc, DWORD dwReduceHowFar /* separate the composite moniker in to left and right moniker */ IMoniker_Enum(iface,FALSE,&enumMoniker); - IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); + IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL); IEnumMoniker_Release(enumMoniker); CreateAntiMoniker(&antiMk); @@ -459,11 +459,11 @@ CompositeMonikerImpl_Reduce(IMoniker* iface, IBindCtx* pbc, DWORD dwReduceHowFar /* If any of the components reduces itself, the method returns S_OK and passes back a composite */ /* of the reduced components */ - if (IMoniker_Reduce(mostRigthMk,pbc,dwReduceHowFar,NULL,&mostRigthReducedMk) && - IMoniker_Reduce(mostRigthMk,pbc,dwReduceHowFar,&tempMk,&leftReducedComposedMk) + if (IMoniker_Reduce(rightMostMk,pbc,dwReduceHowFar,NULL,&rightMostReducedMk) && + IMoniker_Reduce(rightMostMk,pbc,dwReduceHowFar,&tempMk,&leftReducedComposedMk) ) - return CreateGenericComposite(leftReducedComposedMk,mostRigthReducedMk,ppmkReduced); + return CreateGenericComposite(leftReducedComposedMk,rightMostReducedMk,ppmkReduced); else{ /* If no reduction occurred, the method passes back the same moniker and returns MK_S_REDUCED_TO_SELF.*/ @@ -613,7 +613,7 @@ CompositeMonikerImpl_IsRunning(IMoniker* iface, IBindCtx* pbc, { IRunningObjectTable* rot; HRESULT res; - IMoniker *tempMk,*antiMk,*mostRigthMk; + IMoniker *tempMk,*antiMk,*rightMostMk; IEnumMoniker *enumMoniker; TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning); @@ -665,17 +665,17 @@ CompositeMonikerImpl_IsRunning(IMoniker* iface, IBindCtx* pbc, else{ IMoniker_Enum(iface,FALSE,&enumMoniker); - IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); + IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL); IEnumMoniker_Release(enumMoniker); res=CreateAntiMoniker(&antiMk); res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk); IMoniker_Release(antiMk); - res=IMoniker_IsRunning(mostRigthMk,pbc,tempMk,pmkNewlyRunning); + res=IMoniker_IsRunning(rightMostMk,pbc,tempMk,pmkNewlyRunning); IMoniker_Release(tempMk); - IMoniker_Release(mostRigthMk); + IMoniker_Release(rightMostMk); return res; } @@ -690,7 +690,7 @@ CompositeMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, FILETIME* pCompositeTime) { HRESULT res; - IMoniker *tempMk,*antiMk,*mostRigthMk,*leftMk; + IMoniker *tempMk,*antiMk,*rightMostMk,*leftMk; IEnumMoniker *enumMoniker; TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pCompositeTime); @@ -727,17 +727,17 @@ CompositeMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, leftMk = iface; IMoniker_Enum(iface, FALSE, &enumMoniker); - IEnumMoniker_Next(enumMoniker, 1, &mostRigthMk, NULL); + IEnumMoniker_Next(enumMoniker, 1, &rightMostMk, NULL); IEnumMoniker_Release(enumMoniker); res = CreateAntiMoniker(&antiMk); res = IMoniker_ComposeWith(leftMk, antiMk, 0, &tempMk); IMoniker_Release(antiMk); - res = IMoniker_GetTimeOfLastChange(mostRigthMk, pbc, tempMk, pCompositeTime); + res = IMoniker_GetTimeOfLastChange(rightMostMk, pbc, tempMk, pCompositeTime); IMoniker_Release(tempMk); - IMoniker_Release(mostRigthMk); + IMoniker_Release(rightMostMk); if (pmkToLeft) IMoniker_Release(leftMk); @@ -752,7 +752,7 @@ static HRESULT WINAPI CompositeMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk) { HRESULT res; - IMoniker *tempMk,*antiMk,*mostRigthMk,*tempInvMk,*mostRigthInvMk; + IMoniker *tempMk,*antiMk,*rightMostMk,*tempInvMk,*rightMostInvMk; IEnumMoniker *enumMoniker; TRACE("(%p,%p)\n",iface,ppmk); @@ -781,18 +781,18 @@ CompositeMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk) else{ IMoniker_Enum(iface,FALSE,&enumMoniker); - IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); + IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL); IEnumMoniker_Release(enumMoniker); - IMoniker_Inverse(mostRigthMk,&mostRigthInvMk); + IMoniker_Inverse(rightMostMk,&rightMostInvMk); CompositeMonikerImpl_Inverse(tempMk,&tempInvMk); - res=CreateGenericComposite(mostRigthInvMk,tempInvMk,ppmk); + res=CreateGenericComposite(rightMostInvMk,tempInvMk,ppmk); IMoniker_Release(tempMk); - IMoniker_Release(mostRigthMk); + IMoniker_Release(rightMostMk); IMoniker_Release(tempInvMk); - IMoniker_Release(mostRigthInvMk); + IMoniker_Release(rightMostInvMk); return res; } @@ -1140,13 +1140,13 @@ CompositeMonikerImpl_ParseDisplayName(IMoniker* iface, IBindCtx* pbc, IMoniker** ppmkOut) { IEnumMoniker *enumMoniker; - IMoniker *tempMk,*mostRigthMk,*antiMk; + IMoniker *tempMk,*rightMostMk,*antiMk; /* This method recursively calls IMoniker::ParseDisplayName on the rightmost component of the composite,*/ /* passing everything else as the pmkToLeft parameter for that call. */ /* get the most right moniker */ IMoniker_Enum(iface,FALSE,&enumMoniker); - IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); + IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL); IEnumMoniker_Release(enumMoniker); /* get the left moniker */ @@ -1154,7 +1154,7 @@ CompositeMonikerImpl_ParseDisplayName(IMoniker* iface, IBindCtx* pbc, IMoniker_ComposeWith(iface,antiMk,0,&tempMk); IMoniker_Release(antiMk); - return IMoniker_ParseDisplayName(mostRigthMk,pbc,tempMk,pszDisplayName,pchEaten,ppmkOut); + return IMoniker_ParseDisplayName(rightMostMk,pbc,tempMk,pszDisplayName,pchEaten,ppmkOut); } /****************************************************************************** @@ -1742,6 +1742,7 @@ CompositeMonikerImpl_Construct(IMoniker **ppMoniker, IMoniker *pmkFirst, IMonike IMoniker *tempMk; HRESULT res; CompositeMonikerImpl *This; + int i; This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); @@ -1787,12 +1788,14 @@ CompositeMonikerImpl_Construct(IMoniker **ppMoniker, IMoniker *pmkFirst, IMonike if (++This->tabLastIndex==This->tabSize){ - LPVOID tab_moniker = This->tabMoniker; + IMoniker **tab_moniker = This->tabMoniker; This->tabSize+=BLOCK_TAB_SIZE; - This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker)); + This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(This->tabMoniker[0])); if (This->tabMoniker==NULL){ + for (i = 0; i < This->tabLastIndex; i++) + IMoniker_Release(tab_moniker[i]); HeapFree(GetProcessHeap(), 0, tab_moniker); HeapFree(GetProcessHeap(), 0, This); return E_OUTOFMEMORY; @@ -1835,18 +1838,25 @@ CompositeMonikerImpl_Construct(IMoniker **ppMoniker, IMoniker *pmkFirst, IMonike IMoniker_Release(This->tabMoniker[This->tabLastIndex-1]); This->tabMoniker[This->tabLastIndex-1]=tempMk; - } else + } else{ + for (i = 0; i < This->tabLastIndex; i++) + IMoniker_Release(This->tabMoniker[i]); + HeapFree(GetProcessHeap(), 0, This->tabMoniker); + HeapFree(GetProcessHeap(), 0, This); return res; + } /* resize tabMoniker if needed */ if (This->tabLastIndex==This->tabSize){ - LPVOID tab_moniker = This->tabMoniker; + IMoniker **tab_moniker = This->tabMoniker; This->tabSize+=BLOCK_TAB_SIZE; This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker)); if (This->tabMoniker==NULL){ + for (i = 0; i < This->tabLastIndex; i++) + IMoniker_Release(tab_moniker[i]); HeapFree(GetProcessHeap(), 0, tab_moniker); HeapFree(GetProcessHeap(), 0, This); return E_OUTOFMEMORY; @@ -1883,13 +1893,15 @@ CompositeMonikerImpl_Construct(IMoniker **ppMoniker, IMoniker *pmkFirst, IMonike } if (This->tabLastIndex==This->tabSize){ - LPVOID tab_moniker = This->tabMoniker; + IMoniker **tab_moniker = This->tabMoniker; This->tabSize+=BLOCK_TAB_SIZE; This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(This->tabMoniker[0])); if (This->tabMoniker==NULL){ + for (i = 0; i < This->tabLastIndex; i++) + IMoniker_Release(tab_moniker[i]); HeapFree(GetProcessHeap(), 0, tab_moniker); HeapFree(GetProcessHeap(), 0, This); return E_OUTOFMEMORY; diff --git a/reactos/dll/win32/ole32/datacache.c b/reactos/dll/win32/ole32/datacache.c index 2da1b6fed2b..f9b2ed219c9 100644 --- a/reactos/dll/win32/ole32/datacache.c +++ b/reactos/dll/win32/ole32/datacache.c @@ -2450,7 +2450,7 @@ HRESULT WINAPI CreateDataCache( * IUnknown pointer can be returned to the outside. */ if ( pUnkOuter && !IsEqualIID(&IID_IUnknown, riid) ) - return CLASS_E_NOAGGREGATION; + return E_INVALIDARG; /* * Try to construct a new instance of the class. diff --git a/reactos/dll/win32/ole32/filemoniker.c b/reactos/dll/win32/ole32/filemoniker.c index aa77662439a..6e46bc94459 100644 --- a/reactos/dll/win32/ole32/filemoniker.c +++ b/reactos/dll/win32/ole32/filemoniker.c @@ -678,40 +678,40 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight, lastIdx2=FileMonikerImpl_DecomposePath(str2,&strDec2)-1; if ((lastIdx1==-1 && lastIdx2>-1)||(lastIdx1==1 && lstrcmpW(strDec1[0],twoPoint)==0)) - return MK_E_SYNTAX; + res = MK_E_SYNTAX; + else{ + if(lstrcmpW(strDec1[lastIdx1],bkSlash)==0) + lastIdx1--; - if(lstrcmpW(strDec1[lastIdx1],bkSlash)==0) - lastIdx1--; + /* for each "..\" in the left of str2 remove the right element from str1 */ + for(i=0; ( (lastIdx1>=0) && (strDec2[i]!=NULL) && (lstrcmpW(strDec2[i],twoPoint)==0) ); i+=2){ - /* for etch "..\" in the left of str2 remove the right element from str1 */ - for(i=0; ( (lastIdx1>=0) && (strDec2[i]!=NULL) && (lstrcmpW(strDec2[i],twoPoint)==0) ) ;i+=2){ + lastIdx1-=2; + } - lastIdx1-=2; + /* the length of the composed path string is increased by the sum of the two paths' lengths */ + newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1)); + + if (newStr){ + /* new path is the concatenation of the rest of str1 and str2 */ + for(*newStr=0,j=0;j<=lastIdx1;j++) + strcatW(newStr,strDec1[j]); + + if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0) + strcatW(newStr,bkSlash); + + for(j=i;j<=lastIdx2;j++) + strcatW(newStr,strDec2[j]); + + /* create a new moniker with the new string */ + res=CreateFileMoniker(newStr,ppmkComposite); + + /* free string memory used by this function */ + HeapFree(GetProcessHeap(),0,newStr); + } + else res = E_OUTOFMEMORY; } - /* the length of the composed path string is raised by the sum of the two paths lengths */ - newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1)); - - if (newStr) - { - /* new path is the concatenation of the rest of str1 and str2 */ - for(*newStr=0,j=0;j<=lastIdx1;j++) - strcatW(newStr,strDec1[j]); - - if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0) - strcatW(newStr,bkSlash); - - for(j=i;j<=lastIdx2;j++) - strcatW(newStr,strDec2[j]); - - /* create a new moniker with the new string */ - res=CreateFileMoniker(newStr,ppmkComposite); - - /* free all strings space memory used by this function */ - HeapFree(GetProcessHeap(),0,newStr); - } - else res = E_OUTOFMEMORY; - free_stringtable(strDec1); free_stringtable(strDec2); diff --git a/reactos/dll/win32/ole32/ifs.c b/reactos/dll/win32/ole32/ifs.c index 43f01f7f522..0d5bae98ff1 100644 --- a/reactos/dll/win32/ole32/ifs.c +++ b/reactos/dll/win32/ole32/ifs.c @@ -448,13 +448,15 @@ HRESULT WINAPI CoRegisterMallocSpy(LPMALLOCSPY pMallocSpy) IMallocSpy* pSpy; HRESULT hres = E_INVALIDARG; - TRACE("\n"); + TRACE("%p\n", pMallocSpy); - if(Malloc32.pSpy) return CO_E_OBJISREG; + if(!pMallocSpy) return E_INVALIDARG; EnterCriticalSection(&IMalloc32_SpyCS); - if (SUCCEEDED(IMallocSpy_QueryInterface(pMallocSpy, &IID_IMallocSpy, (void**)&pSpy))) { + if (Malloc32.pSpy) + hres = CO_E_OBJISREG; + else if (SUCCEEDED(IMallocSpy_QueryInterface(pMallocSpy, &IID_IMallocSpy, (void**)&pSpy))) { Malloc32.pSpy = pSpy; hres = S_OK; } @@ -488,7 +490,9 @@ HRESULT WINAPI CoRevokeMallocSpy(void) EnterCriticalSection(&IMalloc32_SpyCS); - if (Malloc32.SpyedAllocationsLeft) { + if (!Malloc32.pSpy) + hres = CO_E_OBJNOTREG; + else if (Malloc32.SpyedAllocationsLeft) { TRACE("SpyReleasePending with %u allocations left\n", Malloc32.SpyedAllocationsLeft); Malloc32.SpyReleasePending = TRUE; hres = E_ACCESSDENIED; diff --git a/reactos/dll/win32/ole32/marshal.c b/reactos/dll/win32/ole32/marshal.c index fee74ef765e..9c3d2eba899 100644 --- a/reactos/dll/win32/ole32/marshal.c +++ b/reactos/dll/win32/ole32/marshal.c @@ -750,7 +750,7 @@ static HRESULT proxy_manager_construct( EnterCriticalSection(&apt->cs); /* FIXME: we are dependent on the ordering in here to make sure a proxy's - * IRemUnknown proxy doesn't get destroyed before the regual proxy does + * IRemUnknown proxy doesn't get destroyed before the regular proxy does * because we need the IRemUnknown proxy during the destruction of the * regular proxy. Ideally, we should maintain a separate list for the * IRemUnknown proxies that need late destruction */ @@ -1760,7 +1760,7 @@ HRESULT WINAPI CoMarshalInterface(IStream *pStream, REFIID riid, IUnknown *pUnk, } } - TRACE("Calling IMarshal::MarshalInterace\n"); + TRACE("Calling IMarshal::MarshalInterface\n"); /* call helper object to do the actual marshaling */ hr = IMarshal_MarshalInterface(pMarshal, pStream, riid, pUnk, dwDestContext, pvDestContext, mshlFlags); diff --git a/reactos/dll/win32/ole32/ole2.c b/reactos/dll/win32/ole32/ole2.c index a736162443d..13b28f3e416 100644 --- a/reactos/dll/win32/ole32/ole2.c +++ b/reactos/dll/win32/ole32/ole2.c @@ -25,6 +25,8 @@ #include "precomp.h" +#include "olestd.h" + WINE_DEFAULT_DEBUG_CHANNEL(ole); WINE_DECLARE_DEBUG_CHANNEL(accel); @@ -43,7 +45,6 @@ typedef struct tagTrackerWindowInfo BOOL escPressed; HWND curTargetHWND; /* window the mouse is hovering over */ - HWND curDragTargetHWND; /* might be an ancestor of curTargetHWND */ IDropTarget* curDragTarget; POINTL curMousePos; /* current position of the mouse in screen coordinates */ DWORD dwKeyState; /* current state of the shift and ctrl keys and the mouse buttons */ @@ -745,7 +746,6 @@ HRESULT WINAPI DoDragDrop ( trackerInfo.pdwEffect = pdwEffect; trackerInfo.trackingDone = FALSE; trackerInfo.escPressed = FALSE; - trackerInfo.curDragTargetHWND = 0; trackerInfo.curTargetHWND = 0; trackerInfo.curDragTarget = 0; @@ -2158,6 +2158,96 @@ static LRESULT WINAPI OLEDD_DragTrackerWindowProc( return DefWindowProcW (hwnd, uMsg, wParam, lParam); } +static void drag_enter( TrackerWindowInfo *info, HWND new_target ) +{ + HRESULT hr; + + info->curTargetHWND = new_target; + + while (new_target && !is_droptarget( new_target )) + new_target = GetParent( new_target ); + + info->curDragTarget = get_droptarget_pointer( new_target ); + + if (info->curDragTarget) + { + *info->pdwEffect = info->dwOKEffect; + hr = IDropTarget_DragEnter( info->curDragTarget, info->dataObject, + info->dwKeyState, info->curMousePos, + info->pdwEffect ); + *info->pdwEffect &= info->dwOKEffect; + + /* failed DragEnter() means invalid target */ + if (hr != S_OK) + { + IDropTarget_Release( info->curDragTarget ); + info->curDragTarget = NULL; + info->curTargetHWND = NULL; + } + } +} + +static void drag_end( TrackerWindowInfo *info ) +{ + HRESULT hr; + + info->trackingDone = TRUE; + ReleaseCapture(); + + if (info->curDragTarget) + { + if (info->returnValue == DRAGDROP_S_DROP && + *info->pdwEffect != DROPEFFECT_NONE) + { + *info->pdwEffect = info->dwOKEffect; + hr = IDropTarget_Drop( info->curDragTarget, info->dataObject, info->dwKeyState, + info->curMousePos, info->pdwEffect ); + *info->pdwEffect &= info->dwOKEffect; + + if (FAILED( hr )) + info->returnValue = hr; + } + else + { + IDropTarget_DragLeave( info->curDragTarget ); + *info->pdwEffect = DROPEFFECT_NONE; + } + IDropTarget_Release( info->curDragTarget ); + info->curDragTarget = NULL; + } + else + *info->pdwEffect = DROPEFFECT_NONE; +} + +static HRESULT give_feedback( TrackerWindowInfo *info ) +{ + HRESULT hr; + int res; + HCURSOR cur; + + if (info->curDragTarget == NULL) + *info->pdwEffect = DROPEFFECT_NONE; + + hr = IDropSource_GiveFeedback( info->dropSource, *info->pdwEffect ); + + if (hr == DRAGDROP_S_USEDEFAULTCURSORS) + { + if (*info->pdwEffect & DROPEFFECT_MOVE) + res = CURSOR_MOVE; + else if (*info->pdwEffect & DROPEFFECT_COPY) + res = CURSOR_COPY; + else if (*info->pdwEffect & DROPEFFECT_LINK) + res = CURSOR_LINK; + else + res = CURSOR_NODROP; + + cur = LoadCursorW( hProxyDll, MAKEINTRESOURCEW( res ) ); + SetCursor( cur ); + } + + return hr; +} + /*** * OLEDD_TrackStateChange() * @@ -2171,7 +2261,6 @@ static LRESULT WINAPI OLEDD_DragTrackerWindowProc( static void OLEDD_TrackStateChange(TrackerWindowInfo* trackerInfo) { HWND hwndNewTarget = 0; - HRESULT hr = S_OK; POINT pt; /* @@ -2185,186 +2274,40 @@ static void OLEDD_TrackStateChange(TrackerWindowInfo* trackerInfo) trackerInfo->escPressed, trackerInfo->dwKeyState); - /* - * Every time, we re-initialize the effects passed to the - * IDropTarget to the effects allowed by the source. - */ - *trackerInfo->pdwEffect = trackerInfo->dwOKEffect; - - /* - * If we are hovering over the same target as before, send the - * DragOver notification - */ - if ( (trackerInfo->curDragTarget != 0) && - (trackerInfo->curTargetHWND == hwndNewTarget) ) + if (trackerInfo->curTargetHWND != hwndNewTarget && + (trackerInfo->returnValue == S_OK || + trackerInfo->returnValue == DRAGDROP_S_DROP)) { - IDropTarget_DragOver(trackerInfo->curDragTarget, - trackerInfo->dwKeyState, - trackerInfo->curMousePos, - trackerInfo->pdwEffect); - *trackerInfo->pdwEffect &= trackerInfo->dwOKEffect; + if (trackerInfo->curDragTarget) + { + IDropTarget_DragLeave(trackerInfo->curDragTarget); + IDropTarget_Release(trackerInfo->curDragTarget); + trackerInfo->curDragTarget = NULL; + trackerInfo->curTargetHWND = NULL; + } + + if (hwndNewTarget) + drag_enter( trackerInfo, hwndNewTarget ); + + give_feedback( trackerInfo ); + + } + + if (trackerInfo->returnValue == S_OK) + { + if (trackerInfo->curDragTarget) + { + *trackerInfo->pdwEffect = trackerInfo->dwOKEffect; + IDropTarget_DragOver(trackerInfo->curDragTarget, + trackerInfo->dwKeyState, + trackerInfo->curMousePos, + trackerInfo->pdwEffect); + *trackerInfo->pdwEffect &= trackerInfo->dwOKEffect; + } + give_feedback( trackerInfo ); } else - { - /* - * If we changed window, we have to notify our old target and check for - * the new one. - */ - if (trackerInfo->curDragTarget) - IDropTarget_DragLeave(trackerInfo->curDragTarget); - - /* - * Make sure we're hovering over a window. - */ - if (hwndNewTarget) - { - /* - * Find-out if there is a drag target under the mouse - */ - HWND next_target_wnd = hwndNewTarget; - - trackerInfo->curTargetHWND = hwndNewTarget; - - while (next_target_wnd && !is_droptarget(next_target_wnd)) - next_target_wnd = GetParent(next_target_wnd); - - if (next_target_wnd) hwndNewTarget = next_target_wnd; - - trackerInfo->curDragTargetHWND = hwndNewTarget; - if(trackerInfo->curDragTarget) IDropTarget_Release(trackerInfo->curDragTarget); - trackerInfo->curDragTarget = get_droptarget_pointer(hwndNewTarget); - - /* - * If there is, notify it that we just dragged-in - */ - if (trackerInfo->curDragTarget) - { - hr = IDropTarget_DragEnter(trackerInfo->curDragTarget, - trackerInfo->dataObject, - trackerInfo->dwKeyState, - trackerInfo->curMousePos, - trackerInfo->pdwEffect); - *trackerInfo->pdwEffect &= trackerInfo->dwOKEffect; - - /* failed DragEnter() means invalid target */ - if (hr != S_OK) - { - trackerInfo->curDragTargetHWND = 0; - trackerInfo->curTargetHWND = 0; - IDropTarget_Release(trackerInfo->curDragTarget); - trackerInfo->curDragTarget = 0; - } - } - } - else - { - /* - * The mouse is not over a window so we don't track anything. - */ - trackerInfo->curDragTargetHWND = 0; - trackerInfo->curTargetHWND = 0; - if(trackerInfo->curDragTarget) IDropTarget_Release(trackerInfo->curDragTarget); - trackerInfo->curDragTarget = 0; - } - } - - /* - * Now that we have done that, we have to tell the source to give - * us feedback on the work being done by the target. If we don't - * have a target, simulate no effect. - */ - if (trackerInfo->curDragTarget==0) - { - *trackerInfo->pdwEffect = DROPEFFECT_NONE; - } - - hr = IDropSource_GiveFeedback(trackerInfo->dropSource, - *trackerInfo->pdwEffect); - - /* - * When we ask for feedback from the drop source, sometimes it will - * do all the necessary work and sometimes it will not handle it - * when that's the case, we must display the standard drag and drop - * cursors. - */ - if (hr == DRAGDROP_S_USEDEFAULTCURSORS) - { - HCURSOR hCur; - - if (*trackerInfo->pdwEffect & DROPEFFECT_MOVE) - { - hCur = LoadCursorW(hProxyDll, MAKEINTRESOURCEW(2)); - } - else if (*trackerInfo->pdwEffect & DROPEFFECT_COPY) - { - hCur = LoadCursorW(hProxyDll, MAKEINTRESOURCEW(3)); - } - else if (*trackerInfo->pdwEffect & DROPEFFECT_LINK) - { - hCur = LoadCursorW(hProxyDll, MAKEINTRESOURCEW(4)); - } - else - { - hCur = LoadCursorW(hProxyDll, MAKEINTRESOURCEW(1)); - } - - SetCursor(hCur); - } - - /* - * All the return valued will stop the operation except the S_OK - * return value. - */ - if (trackerInfo->returnValue!=S_OK) - { - /* - * Make sure the message loop in DoDragDrop stops - */ - trackerInfo->trackingDone = TRUE; - - /* - * Release the mouse in case the drop target decides to show a popup - * or a menu or something. - */ - ReleaseCapture(); - - /* - * If we end-up over a target, drop the object in the target or - * inform the target that the operation was cancelled. - */ - if (trackerInfo->curDragTarget) - { - switch (trackerInfo->returnValue) - { - /* - * If the source wants us to complete the operation, we tell - * the drop target that we just dropped the object in it. - */ - case DRAGDROP_S_DROP: - if (*trackerInfo->pdwEffect != DROPEFFECT_NONE) - { - hr = IDropTarget_Drop(trackerInfo->curDragTarget, trackerInfo->dataObject, - trackerInfo->dwKeyState, trackerInfo->curMousePos, trackerInfo->pdwEffect); - if (FAILED(hr)) - trackerInfo->returnValue = hr; - } - else - IDropTarget_DragLeave(trackerInfo->curDragTarget); - break; - - /* - * If the source told us that we should cancel, fool the drop - * target by telling it that the mouse left its window. - * Also set the drop effect to "NONE" in case the application - * ignores the result of DoDragDrop. - */ - case DRAGDROP_S_CANCEL: - IDropTarget_DragLeave(trackerInfo->curDragTarget); - *trackerInfo->pdwEffect = DROPEFFECT_NONE; - break; - } - } - } + drag_end( trackerInfo ); } /*** diff --git a/reactos/dll/win32/ole32/ole2stubs.c b/reactos/dll/win32/ole32/ole2stubs.c index 2d5cbed89fb..4a716be5aac 100644 --- a/reactos/dll/win32/ole32/ole2stubs.c +++ b/reactos/dll/win32/ole32/ole2stubs.c @@ -74,12 +74,3 @@ HRESULT WINAPI CoGetCallerTID(LPDWORD lpdwTID) FIXME("stub!\n"); return E_NOTIMPL; } - -/*********************************************************************** - * CoGetCurrentLogicalThreadId [OLE32.@] - */ -HRESULT WINAPI CoGetCurrentLogicalThreadId(GUID *pguid) -{ - FIXME(": stub\n"); - return E_NOTIMPL; -} diff --git a/reactos/dll/win32/ole32/ole32_ros.diff b/reactos/dll/win32/ole32/ole32_ros.diff index 339308746bf..5e6e8a5bb73 100644 --- a/reactos/dll/win32/ole32/ole32_ros.diff +++ b/reactos/dll/win32/ole32/ole32_ros.diff @@ -1,7 +1,30 @@ -diff -prudN e:\wine\dlls\ole32/compobj.c dll\win32\ole32/compobj.c ---- e:\wine\dlls\ole32/compobj.c 2015-02-21 17:13:09.561542200 +0100 -+++ dll\win32\ole32/compobj.c 2015-02-28 13:26:29.259662000 +0100 -@@ -331,8 +304,12 @@ static NTSTATUS create_key( HKEY *retkey +diff -pudN e:\wine\dlls\ole32/comcat.c e:\reactos\dll\win32\ole32/comcat.c +--- e:\wine\dlls\ole32/comcat.c 2016-05-31 18:02:11 +0100 ++++ e:\reactos\dll\win32\ole32/comcat.c 2016-03-04 10:20:45 +0100 +@@ -229,7 +229,11 @@ static HRESULT COMCAT_IsClassOfCategorie + if (res != ERROR_SUCCESS) return S_FALSE; + for (string = impl_strings; *string; string += CHARS_IN_GUID) { + HKEY catkey; ++#ifdef __REACTOS__ + res = open_classes_key(subkey, string, READ_CONTROL, &catkey); ++#else ++ res = open_classes_key(subkey, string, 0, &catkey); ++#endif + if (res != ERROR_SUCCESS) { + RegCloseKey(subkey); + return S_FALSE; +diff -pudN e:\wine\dlls\ole32/compobj.c e:\reactos\dll\win32\ole32/compobj.c +--- e:\wine\dlls\ole32/compobj.c 2016-05-31 18:02:11 +0100 ++++ e:\reactos\dll\win32\ole32/compobj.c 2016-06-07 11:34:16 +0100 +@@ -43,6 +43,7 @@ + + WINE_DEFAULT_DEBUG_CHANNEL(ole); + ++#undef ARRAYSIZE + #define ARRAYSIZE(array) (sizeof(array)/sizeof((array)[0])) + + /**************************************************************************** +@@ -303,9 +304,13 @@ static NTSTATUS create_key( HKEY *retkey return status; } @@ -9,52 +32,63 @@ diff -prudN e:\wine\dlls\ole32/compobj.c dll\win32\ole32/compobj.c +static const WCHAR classes_rootW[] = L"\\REGISTRY\\Machine\\Software\\Classes"; +#else static const WCHAR classes_rootW[] = - {'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e','\\','C','l','a','s','s','e','s',0}; + {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e', + '\\','S','o','f','t','w','a','r','e','\\','C','l','a','s','s','e','s',0}; +#endif static HKEY classes_root_hkey; -diff -prudN e:\wine\dlls\ole32/stg_prop.c dll\win32\ole32/stg_prop.c ---- e:\wine\dlls\ole32/stg_prop.c 2015-02-21 17:13:09.569542200 +0100 -+++ dll\win32\ole32/stg_prop.c 2014-04-08 19:21:32.097336500 +0100 -@@ -1035,12 +1018,12 @@ static HRESULT PropertyStorage_ReadDicti +diff -pudN e:\wine\dlls\ole32/stg_prop.c e:\reactos\dll\win32\ole32/stg_prop.c +--- e:\wine\dlls\ole32/stg_prop.c 2016-05-31 18:02:11 +0100 ++++ e:\reactos\dll\win32\ole32/stg_prop.c 2016-06-07 11:34:17 +0100 +@@ -41,6 +41,10 @@ + + WINE_DEFAULT_DEBUG_CHANNEL(storage); + ++#ifdef _MSC_VER ++#define __ASM_STDCALL_FUNC(name,args,code) ++#endif ++ + static inline StorageImpl *impl_from_IPropertySetStorage( IPropertySetStorage *iface ) + { + return CONTAINING_RECORD(iface, StorageImpl, base.IPropertySetStorage_iface); +@@ -1013,7 +1017,13 @@ static HRESULT PropertyStorage_ReadDicti + return hr; } - #ifdef __i386__ --#define __thiscall __stdcall +-static void* WINAPI Allocate_CoTaskMemAlloc(void *this, ULONG size) ++#ifdef __i386__ +#define __thiscall_wrapper __stdcall - #else --#define __thiscall __cdecl ++#else +#define __thiscall_wrapper __cdecl - #endif - --static __thiscall void* Allocate_CoTaskMemAlloc(void *userdata, ULONG size) -+static void* __thiscall_wrapper Allocate_CoTaskMemAlloc(void *userdata, ULONG size) ++#endif ++ ++static void* __thiscall_wrapper Allocate_CoTaskMemAlloc(void *this, ULONG size) { return CoTaskMemAlloc(size); } -@@ -1049,7 +1032,7 @@ static __thiscall void* Allocate_CoTaskM +@@ -1022,7 +1032,7 @@ static void* WINAPI Allocate_CoTaskMemAl * end of the buffer. */ static HRESULT PropertyStorage_ReadProperty(PROPVARIANT *prop, const BYTE *data, -- UINT codepage, void* (__thiscall *allocate)(void *userdata, ULONG size), void *allocate_data) -+ UINT codepage, void* (__thiscall_wrapper *allocate)(void *userdata, ULONG size), void *allocate_data) +- UINT codepage, void* (WINAPI *allocate)(void *this, ULONG size), void *allocate_data) ++ UINT codepage, void* (__thiscall_wrapper *allocate)(void *this, ULONG size), void *allocate_data) { HRESULT hr = S_OK; -@@ -2738,13 +2721,13 @@ end: +@@ -2711,13 +2721,13 @@ end: "jmp *(4*(" #num "))(%eax)" ) DEFINE_STDCALL_WRAPPER(0,Allocate_PMemoryAllocator,8) --extern void* __thiscall Allocate_PMemoryAllocator(void *this, ULONG cbSize); +-extern void* WINAPI Allocate_PMemoryAllocator(void *this, ULONG cbSize); +extern void* __stdcall Allocate_PMemoryAllocator(void *this, ULONG cbSize); #else --static void* __thiscall Allocate_PMemoryAllocator(void *this, ULONG cbSize) +-static void* WINAPI Allocate_PMemoryAllocator(void *this, ULONG cbSize) +static void* __cdecl Allocate_PMemoryAllocator(void *this, ULONG cbSize) { -- void* (__thiscall *fn)(void*,ULONG) = **(void***)this; +- void* (WINAPI *fn)(void*,ULONG) = **(void***)this; + void* (__cdecl *fn)(void*,ULONG) = **(void***)this; return fn(this, cbSize); } diff --git a/reactos/dll/win32/ole32/ole32res.rc b/reactos/dll/win32/ole32/ole32res.rc index 14dda0ab579..71b368236dc 100644 --- a/reactos/dll/win32/ole32/ole32res.rc +++ b/reactos/dll/win32/ole32/ole32res.rc @@ -23,6 +23,8 @@ //#include "winuser.h" //#include "winnls.h" +#include "olestd.h" + #define WINE_FILENAME_STR "ole32.dll" #define WINE_EXTRAVALUES VALUE "OLESelfRegister","" @@ -37,15 +39,15 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL /* @makedep: nodrop.cur */ -1 CURSOR nodrop.cur +CURSOR_NODROP CURSOR nodrop.cur /* @makedep: drag_move.cur */ -2 CURSOR drag_move.cur +CURSOR_MOVE CURSOR drag_move.cur /* @makedep: drag_copy.cur */ -3 CURSOR drag_copy.cur +CURSOR_COPY CURSOR drag_copy.cur /* @makedep: drag_link.cur */ -4 CURSOR drag_link.cur +CURSOR_LINK CURSOR drag_link.cur 1 WINE_REGISTRY "ole32.rgs" diff --git a/reactos/dll/win32/ole32/olestd.h b/reactos/dll/win32/ole32/olestd.h index fbc4442eb20..33063c7cd82 100644 --- a/reactos/dll/win32/ole32/olestd.h +++ b/reactos/dll/win32/ole32/olestd.h @@ -49,4 +49,9 @@ #define OleStdCopyMetafilePict(hpictin, phpictout) \ (*(phpictout) = OleDuplicateData(hpictin,CF_METAFILEPICT,GHND|GMEM_SHARE)) +#define CURSOR_NODROP 1 +#define CURSOR_MOVE 2 +#define CURSOR_COPY 3 +#define CURSOR_LINK 4 + #endif /* __WINE_OLESTD_H_ */ diff --git a/reactos/dll/win32/ole32/stg_prop.c b/reactos/dll/win32/ole32/stg_prop.c index 067a7d3e3e5..3b76712e5d6 100644 --- a/reactos/dll/win32/ole32/stg_prop.c +++ b/reactos/dll/win32/ole32/stg_prop.c @@ -2053,12 +2053,12 @@ static HRESULT PropertyStorage_BaseConstruct(IStream *stm, hr = PropertyStorage_CreateDictionaries(*pps); if (FAILED(hr)) { - IStream_Release(stm); (*pps)->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&(*pps)->cs); HeapFree(GetProcessHeap(), 0, *pps); *pps = NULL; } + else IStream_AddRef( stm ); return hr; } @@ -2080,11 +2080,7 @@ static HRESULT PropertyStorage_ConstructFromStream(IStream *stm, TRACE("PropertyStorage %p constructed\n", ps); hr = S_OK; } - else - { - PropertyStorage_DestroyDictionaries(ps); - HeapFree(GetProcessHeap(), 0, ps); - } + else IPropertyStorage_Release( &ps->IPropertyStorage_iface ); } return hr; } @@ -2212,6 +2208,8 @@ static HRESULT WINAPI IPropertySetStorage_fnCreate( r = PropertyStorage_ConstructEmpty(stm, rfmtid, grfFlags, grfMode, ppprstg); + IStream_Release( stm ); + end: TRACE("returning 0x%08x\n", r); return r; @@ -2257,6 +2255,8 @@ static HRESULT WINAPI IPropertySetStorage_fnOpen( r = PropertyStorage_ConstructFromStream(stm, rfmtid, grfMode, ppprstg); + IStream_Release( stm ); + end: TRACE("returning 0x%08x\n", r); return r; @@ -2757,3 +2757,93 @@ SERIALIZEDPROPERTYVALUE* WINAPI StgConvertVariantToProperty(const PROPVARIANT *p return NULL; } + +HRESULT WINAPI StgCreatePropStg(IUnknown *unk, REFFMTID fmt, const CLSID *clsid, + DWORD flags, DWORD reserved, IPropertyStorage **prop_stg) +{ + IStorage *stg; + IStream *stm; + HRESULT r; + + TRACE("%p %s %s %08x %d %p\n", unk, debugstr_guid(fmt), debugstr_guid(clsid), flags, reserved, prop_stg); + + if (!fmt || reserved) + { + r = E_INVALIDARG; + goto end; + } + + if (flags & PROPSETFLAG_NONSIMPLE) + { + r = IUnknown_QueryInterface(unk, &IID_IStorage, (void **)&stg); + if (FAILED(r)) + goto end; + + /* FIXME: if (flags & PROPSETFLAG_NONSIMPLE), we need to create a + * storage, not a stream. For now, disallow it. + */ + FIXME("PROPSETFLAG_NONSIMPLE not supported\n"); + IStorage_Release(stg); + r = STG_E_INVALIDFLAG; + } + else + { + r = IUnknown_QueryInterface(unk, &IID_IStream, (void **)&stm); + if (FAILED(r)) + goto end; + + r = PropertyStorage_ConstructEmpty(stm, fmt, flags, + STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, prop_stg); + + IStream_Release( stm ); + } + +end: + TRACE("returning 0x%08x\n", r); + return r; +} + +HRESULT WINAPI StgOpenPropStg(IUnknown *unk, REFFMTID fmt, DWORD flags, + DWORD reserved, IPropertyStorage **prop_stg) +{ + IStorage *stg; + IStream *stm; + HRESULT r; + + TRACE("%p %s %08x %d %p\n", unk, debugstr_guid(fmt), flags, reserved, prop_stg); + + if (!fmt || reserved) + { + r = E_INVALIDARG; + goto end; + } + + if (flags & PROPSETFLAG_NONSIMPLE) + { + r = IUnknown_QueryInterface(unk, &IID_IStorage, (void **)&stg); + if (FAILED(r)) + goto end; + + /* FIXME: if (flags & PROPSETFLAG_NONSIMPLE), we need to open a + * storage, not a stream. For now, disallow it. + */ + FIXME("PROPSETFLAG_NONSIMPLE not supported\n"); + IStorage_Release(stg); + r = STG_E_INVALIDFLAG; + } + else + { + r = IUnknown_QueryInterface(unk, &IID_IStream, (void **)&stm); + if (FAILED(r)) + goto end; + + r = PropertyStorage_ConstructFromStream(stm, fmt, + STGM_READWRITE|STGM_SHARE_EXCLUSIVE, prop_stg); + + IStream_Release( stm ); + } + +end: + TRACE("returning 0x%08x\n", r); + return r; +} diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 620e1dc230c..498cdce2cb0 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -142,7 +142,7 @@ reactos/dll/win32/ntprint # Synced to WineStaging-1.9.4 reactos/dll/win32/objsel # Synced to WineStaging-1.9.4 reactos/dll/win32/odbc32 # Synced to WineStaging-1.9.4. Depends on port of Linux ODBC. reactos/dll/win32/odbccp32 # Synced to WineStaging-1.9.4 -reactos/dll/win32/ole32 # Synced to WineStaging-1.9.4 +reactos/dll/win32/ole32 # Synced to WineStaging-1.9.11 reactos/dll/win32/oleacc # Synced to WineStaging-1.9.4 reactos/dll/win32/oleaut32 # Synced to WineStaging-1.9.4 reactos/dll/win32/olecli32 # Synced to WineStaging-1.9.4