Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/pointermoniker.c | 49 ++++++++++++++++++++----------------- dlls/ole32/tests/moniker.c | 41 ++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 24 deletions(-)
diff --git a/dlls/ole32/pointermoniker.c b/dlls/ole32/pointermoniker.c index a62ce3e7b7..c1a0e2ae1c 100644 --- a/dlls/ole32/pointermoniker.c +++ b/dlls/ole32/pointermoniker.c @@ -48,9 +48,10 @@ typedef struct PointerMonikerImpl{
static inline PointerMonikerImpl *impl_from_IMoniker(IMoniker *iface) { -return CONTAINING_RECORD(iface, PointerMonikerImpl, IMoniker_iface); + return CONTAINING_RECORD(iface, PointerMonikerImpl, IMoniker_iface); }
+static PointerMonikerImpl *unsafe_impl_from_IMoniker(IMoniker *iface); static HRESULT WINAPI PointerMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject) { @@ -58,7 +59,6 @@ PointerMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** 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;
@@ -337,26 +337,20 @@ PointerMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoni /****************************************************************************** * PointerMoniker_IsEqual ******************************************************************************/ -static HRESULT WINAPI -PointerMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker) +static HRESULT WINAPI PointerMonikerImpl_IsEqual(IMoniker *iface, IMoniker *other) { - PointerMonikerImpl *This = impl_from_IMoniker(iface); - DWORD mkSys; + PointerMonikerImpl *moniker = impl_from_IMoniker(iface), *other_moniker;
- TRACE("(%p,%p)\n",iface,pmkOtherMoniker); - - if (pmkOtherMoniker==NULL) - return S_FALSE; + TRACE("%p, %p.\n", iface, other);
- IMoniker_IsSystemMoniker(pmkOtherMoniker,&mkSys); + if (!other) + return E_INVALIDARG;
- if (mkSys==MKSYS_POINTERMONIKER) - { - PointerMonikerImpl *pOtherMoniker = impl_from_IMoniker(pmkOtherMoniker); - return This->pObject == pOtherMoniker->pObject ? S_OK : S_FALSE; - } - else + other_moniker = unsafe_impl_from_IMoniker(other); + if (!other_moniker) return S_FALSE; + + return moniker->pObject == other_moniker->pObject ? S_OK : S_FALSE; }
/****************************************************************************** @@ -412,18 +406,20 @@ PointerMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk) /****************************************************************************** * PointerMoniker_CommonPrefixWith ******************************************************************************/ -static HRESULT WINAPI -PointerMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix) +static HRESULT WINAPI PointerMonikerImpl_CommonPrefixWith(IMoniker *iface, IMoniker *other, IMoniker **prefix) { - TRACE("(%p, %p)\n", pmkOther, ppmkPrefix); + TRACE("%p, %p, %p.\n", iface, other, prefix); + + if (!prefix || !other) + return E_INVALIDARG;
- *ppmkPrefix = NULL; + *prefix = NULL;
- if (PointerMonikerImpl_IsEqual(iface, pmkOther)) + if (PointerMonikerImpl_IsEqual(iface, other) == S_OK) { IMoniker_AddRef(iface);
- *ppmkPrefix=iface; + *prefix = iface;
return MK_S_US; } @@ -539,6 +535,13 @@ static const IMonikerVtbl VT_PointerMonikerImpl = PointerMonikerImpl_IsSystemMoniker };
+static PointerMonikerImpl *unsafe_impl_from_IMoniker(IMoniker *iface) +{ + if (iface->lpVtbl != &VT_PointerMonikerImpl) + return NULL; + return CONTAINING_RECORD(iface, PointerMonikerImpl, IMoniker_iface); +} + /****************************************************************************** * PointerMoniker_Construct (local function) *******************************************************************************/ diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index 8c533d1ff7..bec5c76caa 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -2625,7 +2625,7 @@ todo_wine
static void test_pointer_moniker(void) { - IMoniker *moniker, *inverse; + IMoniker *moniker, *moniker2, *prefix, *inverse; IEnumMoniker *enummoniker; HRESULT hr; DWORD moniker_type; @@ -2748,6 +2748,45 @@ todo_wine ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
IMoniker_Release(moniker); + + /* CommonPrefixWith() */ + hr = CreatePointerMoniker((IUnknown *)&Test_ClassFactory, &moniker); + ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr); + + hr = CreatePointerMoniker((IUnknown *)&Test_ClassFactory, &moniker2); + ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr); + + hr = IMoniker_IsEqual(moniker, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IMoniker_IsEqual(moniker, moniker2); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMoniker_CommonPrefixWith(moniker, moniker2, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IMoniker_CommonPrefixWith(moniker, NULL, &prefix); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IMoniker_CommonPrefixWith(moniker, moniker2, &prefix); + ok(hr == MK_S_US, "Unexpected hr %#x.\n", hr); + ok(prefix == moniker, "Unexpected pointer.\n"); + IMoniker_Release(prefix); + + IMoniker_Release(moniker2); + + hr = CreatePointerMoniker((IUnknown *)moniker, &moniker2); + ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr); + + hr = IMoniker_IsEqual(moniker, moniker2); + ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr); + + hr = IMoniker_CommonPrefixWith(moniker, moniker2, &prefix); + ok(hr == MK_E_NOPREFIX, "Unexpected hr %#x.\n", hr); + + IMoniker_Release(moniker2); + + IMoniker_Release(moniker); }
static void test_bind_context(void)
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/tests/moniker.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index bec5c76caa..8b150738b2 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -1311,6 +1311,13 @@ static const BYTE expected_item_moniker_comparison_data5[] = 'S',0x00, 'T',0x00,0x00,0x00, };
+static const BYTE expected_item_moniker_comparison_data6[] = +{ + 0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00, + 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46, + 0x00,0x00, +}; + static const BYTE expected_item_moniker_saved_data[] = { 0x02,0x00,0x00,0x00, '!',0x00,0x05,0x00, @@ -1341,6 +1348,12 @@ static const BYTE expected_item_moniker_saved_data5[] = 0x00,0x00,0x00, 'T', 'e', 's', 't',0x00, };
+static const BYTE expected_item_moniker_saved_data6[] = +{ + 0x01,0x00,0x00,0x00,0x00,0x01,0x00,0x00, + 0x00,0x00, +}; + static const BYTE expected_item_moniker_marshal_data[] = { 0x4d,0x45,0x4f,0x57,0x04,0x00,0x00,0x00, @@ -1401,6 +1414,18 @@ static const BYTE expected_item_moniker_marshal_data5[] = 0x00,0x00,0x00, 'T', 'e', 's', 't',0x00, };
+static const BYTE expected_item_moniker_marshal_data6[] = +{ + 0x4d,0x45,0x4f,0x57,0x04,0x00,0x00,0x00, + 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46, + 0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00, + 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46, + 0x00,0x00,0x00,0x00,0x22,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x01,0x00,0x00, + 0x00,0x00, +}; + static const BYTE expected_anti_moniker_marshal_data[] = { 0x4d,0x45,0x4f,0x57,0x04,0x00,0x00,0x00, @@ -2239,6 +2264,18 @@ todo_wine IMoniker_Release(moniker); IMoniker_Release(moniker2); } + + /* Default instance. */ + hr = CoCreateInstance(&CLSID_ItemMoniker, NULL, CLSCTX_SERVER, &IID_IMoniker, (void **)&moniker); + ok(hr == S_OK, "Failed to create item moniker, hr %#x.\n", hr); + + test_moniker("item moniker 6", moniker, + expected_item_moniker_marshal_data6, sizeof(expected_item_moniker_marshal_data6), + expected_item_moniker_saved_data6, sizeof(expected_item_moniker_saved_data6), + expected_item_moniker_comparison_data6, sizeof(expected_item_moniker_comparison_data6), + 34, L""); + + IMoniker_Release(moniker); }
static void stream_write_dword(IStream *stream, DWORD value)
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/itemmoniker.c | 132 +++++++++++++++------------------------ 1 file changed, 49 insertions(+), 83 deletions(-)
diff --git a/dlls/ole32/itemmoniker.c b/dlls/ole32/itemmoniker.c index c85e263774..7ebfaea6b6 100644 --- a/dlls/ole32/itemmoniker.c +++ b/dlls/ole32/itemmoniker.c @@ -137,8 +137,6 @@ static HRESULT set_container_lock(IOleItemContainer *container, IBindCtx *pbc) return hr; }
-static HRESULT ItemMonikerImpl_Destroy(ItemMonikerImpl* iface); - /******************************************************************************* * ItemMoniker_QueryInterface *******************************************************************************/ @@ -195,17 +193,20 @@ static ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface) ******************************************************************************/ static ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface) { - ItemMonikerImpl *This = impl_from_IMoniker(iface); - ULONG ref; - - TRACE("(%p)\n",This); + ItemMonikerImpl *moniker = impl_from_IMoniker(iface); + ULONG refcount = InterlockedDecrement(&moniker->ref);
- ref = InterlockedDecrement(&This->ref); + TRACE("%p, refcount %u.\n", iface, refcount);
- /* destroy the object if there are no more references to it */ - if (ref == 0) ItemMonikerImpl_Destroy(This); + if (!refcount) + { + if (moniker->pMarshal) IUnknown_Release(moniker->pMarshal); + heap_free(moniker->itemName); + heap_free(moniker->itemDelimiter); + heap_free(moniker); + }
- return ref; + return refcount; }
/****************************************************************************** @@ -1008,107 +1009,72 @@ static const IROTDataVtbl VT_ROTDataImpl = };
/****************************************************************************** - * ItemMoniker_Construct (local function) - *******************************************************************************/ -static HRESULT ItemMonikerImpl_Construct(ItemMonikerImpl* This, const WCHAR *delimiter, const WCHAR *name) + * CreateItemMoniker [OLE32.@] + ******************************************************************************/ +HRESULT WINAPI CreateItemMoniker(const WCHAR *delimiter, const WCHAR *name, IMoniker **ret) { + ItemMonikerImpl *moniker; int str_len; + HRESULT hr; + + TRACE("%s, %s, %p.\n", debugstr_w(delimiter), debugstr_w(name), ret);
- TRACE("(%p, %s, %s)\n", This, debugstr_w(delimiter), debugstr_w(name)); + if (!(moniker = heap_alloc_zero(sizeof(*moniker)))) + return E_OUTOFMEMORY;
- /* Initialize the virtual function table. */ - This->IMoniker_iface.lpVtbl = &VT_ItemMonikerImpl; - This->IROTData_iface.lpVtbl = &VT_ROTDataImpl; - This->ref = 0; - This->pMarshal = NULL; - This->itemDelimiter = NULL; + moniker->IMoniker_iface.lpVtbl = &VT_ItemMonikerImpl; + moniker->IROTData_iface.lpVtbl = &VT_ROTDataImpl; + moniker->ref = 1;
str_len = (lstrlenW(name) + 1) * sizeof(WCHAR); - This->itemName = heap_alloc(str_len); - if (!This->itemName) - return E_OUTOFMEMORY; - memcpy(This->itemName, name, str_len); + moniker->itemName = heap_alloc(str_len); + if (!moniker->itemName) + { + hr = E_OUTOFMEMORY; + goto failed; + } + memcpy(moniker->itemName, name, str_len);
if (delimiter) { str_len = (lstrlenW(delimiter) + 1) * sizeof(WCHAR); - This->itemDelimiter = heap_alloc(str_len); - if (!This->itemDelimiter) + moniker->itemDelimiter = heap_alloc(str_len); + if (!moniker->itemDelimiter) { - heap_free(This->itemName); - return E_OUTOFMEMORY; + hr = E_OUTOFMEMORY; + goto failed; } - memcpy(This->itemDelimiter, delimiter, str_len); + memcpy(moniker->itemDelimiter, delimiter, str_len); }
- return S_OK; -} - -/****************************************************************************** - * ItemMoniker_Destroy (local function) - *******************************************************************************/ -static HRESULT ItemMonikerImpl_Destroy(ItemMonikerImpl* This) -{ - TRACE("(%p)\n",This); - - if (This->pMarshal) IUnknown_Release(This->pMarshal); - HeapFree(GetProcessHeap(),0,This->itemName); - HeapFree(GetProcessHeap(),0,This->itemDelimiter); - HeapFree(GetProcessHeap(),0,This); + *ret = &moniker->IMoniker_iface;
return S_OK; -} - -/****************************************************************************** - * CreateItemMoniker [OLE32.@] - ******************************************************************************/ -HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim, LPCOLESTR lpszItem, IMoniker **ppmk) -{ - ItemMonikerImpl* newItemMoniker; - HRESULT hr; - - TRACE("(%s,%s,%p)\n",debugstr_w(lpszDelim),debugstr_w(lpszItem),ppmk); - - newItemMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(ItemMonikerImpl));
- if (!newItemMoniker) - return STG_E_INSUFFICIENTMEMORY; +failed: + IMoniker_Release(&moniker->IMoniker_iface);
- hr = ItemMonikerImpl_Construct(newItemMoniker,lpszDelim,lpszItem); - - if (FAILED(hr)){ - HeapFree(GetProcessHeap(),0,newItemMoniker); - return hr; - } - - return ItemMonikerImpl_QueryInterface(&newItemMoniker->IMoniker_iface,&IID_IMoniker, - (void**)ppmk); + return hr; }
-HRESULT WINAPI ItemMoniker_CreateInstance(IClassFactory *iface, - IUnknown *pUnk, REFIID riid, void **ppv) +HRESULT WINAPI ItemMoniker_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv) { - ItemMonikerImpl* newItemMoniker; - HRESULT hr; - static const WCHAR wszEmpty[] = { 0 }; + static const WCHAR emptyW[] = { 0 }; + IMoniker *moniker; + HRESULT hr;
- TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv); + TRACE("(%p, %s, %p)\n", outer, debugstr_guid(riid), ppv);
*ppv = NULL;
- if (pUnk) + if (outer) return CLASS_E_NOAGGREGATION;
- newItemMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(ItemMonikerImpl)); - if (!newItemMoniker) - return E_OUTOFMEMORY; - - hr = ItemMonikerImpl_Construct(newItemMoniker, wszEmpty, wszEmpty); + if (FAILED(hr = CreateItemMoniker(emptyW, emptyW, &moniker))) + return hr;
- if (SUCCEEDED(hr)) - hr = ItemMonikerImpl_QueryInterface(&newItemMoniker->IMoniker_iface, riid, ppv); - if (FAILED(hr)) - HeapFree(GetProcessHeap(),0,newItemMoniker); + hr = IMoniker_QueryInterface(moniker, riid, ppv); + IMoniker_Release(moniker);
return hr; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=63965
Your paranoid android.
=== debian10 (64 bit WoW report) ===
ole32: clipboard.c:1454: Test failed: got 800401d0 clipboard.c:1464: Test failed: got 800401d0 clipboard.c:1470: Test failed: got 800401d0 clipboard.c:1471: Test failed: got 0 clipboard.c:1483: Test failed: got 800401d0 clipboard.c:1484: Test failed: got 0 clipboard.c:1489: Test failed: got 800401d0 clipboard.c:1490: Test failed: got 0 clipboard.c:1529: Test failed: gle 5 clipboard.c:1531: Test failed: gle 1418 clipboard.c:1533: Test failed: gle 1418 clipboard.c:1541: Test failed: got 800401d0 Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x004069a5).
Report errors: ole32:clipboard crashed (c0000005)
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/itemmoniker.c | 70 ++++++++++++++++++-------------------- dlls/ole32/tests/moniker.c | 66 ++++++++++++++++++++++++++++++++--- 2 files changed, 95 insertions(+), 41 deletions(-)
diff --git a/dlls/ole32/itemmoniker.c b/dlls/ole32/itemmoniker.c index 7ebfaea6b6..111b111a1a 100644 --- a/dlls/ole32/itemmoniker.c +++ b/dlls/ole32/itemmoniker.c @@ -648,53 +648,51 @@ static HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash) /****************************************************************************** * ItemMoniker_IsRunning ******************************************************************************/ -static HRESULT WINAPI ItemMonikerImpl_IsRunning(IMoniker* iface, - IBindCtx* pbc, - IMoniker* pmkToLeft, - IMoniker* pmkNewlyRunning) +static HRESULT WINAPI ItemMonikerImpl_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, + IMoniker *pmkNewlyRunning) { - ItemMonikerImpl *This = impl_from_IMoniker(iface); + ItemMonikerImpl *moniker = impl_from_IMoniker(iface); + IOleItemContainer *container; IRunningObjectTable* rot; - HRESULT res; - IOleItemContainer *poic=0; + HRESULT hr;
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning);
- /* If pmkToLeft is NULL, this method returns TRUE if pmkNewlyRunning is non-NULL and is equal to this */ - /* moniker. Otherwise, the method checks the ROT to see whether this moniker is running. */ - if (pmkToLeft==NULL) - if ((pmkNewlyRunning!=NULL)&&(IMoniker_IsEqual(pmkNewlyRunning,iface)==S_OK)) - return S_OK; - else { - if (pbc==NULL) - return E_INVALIDARG; - - res=IBindCtx_GetRunningObjectTable(pbc,&rot); - - if (FAILED(res)) - return res; - - res = IRunningObjectTable_IsRunning(rot,iface); + if (!pbc) + return E_INVALIDARG;
- IRunningObjectTable_Release(rot); + if (!pmkToLeft) + { + if (pmkNewlyRunning) + { + return IMoniker_IsEqual(iface, pmkNewlyRunning); } - else{ - - /* If pmkToLeft is non-NULL, the method calls IMoniker::BindToObject on the pmkToLeft parameter, */ - /* requesting an IOleItemContainer interface pointer. The method then calls IOleItemContainer::IsRunning,*/ - /* passing the string contained within this moniker. */ - - res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic); - - if (SUCCEEDED(res)){ - - res=IOleItemContainer_IsRunning(poic,This->itemName); + else + { + hr = IBindCtx_GetRunningObjectTable(pbc, &rot); + if (SUCCEEDED(hr)) + { + hr = IRunningObjectTable_IsRunning(rot, iface); + IRunningObjectTable_Release(rot); + } + } + } + else + { + /* Container itself must be running too. */ + hr = IMoniker_IsRunning(pmkToLeft, pbc, NULL, NULL); + if (hr != S_OK) + return hr;
- IOleItemContainer_Release(poic); + hr = IMoniker_BindToObject(pmkToLeft, pbc, NULL, &IID_IOleItemContainer, (void **)&container); + if (SUCCEEDED(hr)) + { + hr = IOleItemContainer_IsRunning(container, moniker->itemName); + IOleItemContainer_Release(container); } }
- return res; + return hr; }
/****************************************************************************** diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index 8b150738b2..7d4c8224ad 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -385,6 +385,7 @@ static HRESULT WINAPI test_item_container_GetObjectStorage(IOleItemContainer *if
static HRESULT WINAPI test_item_container_IsRunning(IOleItemContainer *iface, LPOLESTR item) { + ok(0, "Unexpected call.\n"); return E_NOTIMPL; }
@@ -569,7 +570,7 @@ Moniker_IsRunning(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning) { CHECK_EXPECTED_METHOD("Moniker_IsRunning"); - return E_NOTIMPL; + return 0x8beef000; }
static HRESULT WINAPI @@ -1999,6 +2000,11 @@ static void test_item_moniker(void) { L"%", L"A", 0x41 }, { L"%", L"a", 0x41 }, }; + static const char *methods_isrunning[] = + { + "Moniker_IsRunning", + NULL + }; IMoniker *moniker, *moniker2, *reduced; HRESULT hr; DWORD moniker_type, i; @@ -2012,10 +2018,12 @@ static void test_item_moniker(void) struct test_moniker *container_moniker; WCHAR displayname[16] = L"display name"; IEnumMoniker *enummoniker; + IRunningObjectTable *rot; WCHAR *display_name; BIND_OPTS bind_opts; LARGE_INTEGER pos; IStream *stream; + DWORD cookie;
hr = CreateItemMoniker(NULL, wszObjectName, &moniker); ok(hr == S_OK, "Failed to create item moniker, hr %#x.\n", hr); @@ -2139,19 +2147,65 @@ todo_wine "dwMkSys != MKSYS_ITEMMONIKER, instead was 0x%08x\n", moniker_type);
+ container_moniker = create_test_moniker(); + /* IsRunning test */ hr = IMoniker_IsRunning(moniker, NULL, NULL, NULL); ok(hr == E_INVALIDARG, "IMoniker_IsRunning should return E_INVALIDARG, not 0x%08x\n", hr);
+ hr = IMoniker_IsRunning(moniker, NULL, &container_moniker->IMoniker_iface, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + hr = IMoniker_IsRunning(moniker, bindctx, NULL, NULL); ok(hr == S_FALSE, "IMoniker_IsRunning should return S_FALSE, not 0x%08x\n", hr);
+ hr = CreateItemMoniker(wszDelimiter, wszObjectName, &moniker2); + ok(hr == S_OK, "Failed to create a moniker, hr %#x.\n", hr); + hr = IMoniker_IsRunning(moniker, bindctx, NULL, moniker2); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + IMoniker_Release(moniker2); + + /* Different moniker as newly running. */ + hr = CreateItemMoniker(wszDelimiter, L"Item123", &moniker2); + ok(hr == S_OK, "Failed to create a moniker, hr %#x.\n", hr); + + hr = IMoniker_IsRunning(moniker, bindctx, NULL, moniker2); + ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr); + + hr = IBindCtx_GetRunningObjectTable(bindctx, &rot); + ok(hr == S_OK, "Failed to get ROT, hr %#x.\n", hr); + + hr = IRunningObjectTable_Register(rot, ROTFLAGS_REGISTRATIONKEEPSALIVE, (IUnknown *)moniker, moniker, &cookie); + ok(hr == S_OK, "Failed to register, hr %#x.\n", hr); + + hr = IRunningObjectTable_IsRunning(rot, moniker); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMoniker_IsRunning(moniker, bindctx, NULL, moniker2); + ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr); + + hr = IMoniker_IsRunning(moniker, bindctx, NULL, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IRunningObjectTable_Revoke(rot, cookie); + ok(hr == S_OK, "Failed to revoke registration, hr %#x.\n", hr); + + IRunningObjectTable_Release(rot); + + expected_method_list = methods_isrunning; + hr = IMoniker_IsRunning(moniker, bindctx, &container_moniker->IMoniker_iface, NULL); + ok(hr == 0x8beef000, "Unexpected hr %#x.\n", hr); + + expected_method_list = methods_isrunning; + hr = IMoniker_IsRunning(moniker, bindctx, &container_moniker->IMoniker_iface, moniker2); + ok(hr == 0x8beef000, "Unexpected hr %#x.\n", hr); + + IMoniker_Release(moniker2); + /* BindToObject() */ hr = IMoniker_BindToObject(moniker, bindctx, NULL, &IID_IUnknown, (void **)&unknown); ok(hr == E_INVALIDARG, "IMoniker_BindToStorage should return E_INVALIDARG, not 0x%08x\n", hr);
- container_moniker = create_test_moniker(); - hr = IMoniker_BindToObject(moniker, bindctx, &container_moniker->IMoniker_iface, &IID_IUnknown, (void **)&unknown); ok(hr == (0x8bee0000 | BINDSPEED_INDEFINITE), "Unexpected hr %#x.\n", hr);
@@ -2275,6 +2329,9 @@ todo_wine expected_item_moniker_comparison_data6, sizeof(expected_item_moniker_comparison_data6), 34, L"");
+ hr = CoCreateInstance(&CLSID_ItemMoniker, (IUnknown *)moniker, CLSCTX_SERVER, &IID_IMoniker, (void **)&moniker2); + ok(FAILED(hr), "Unexpected hr %#x.\n", hr); + IMoniker_Release(moniker); }
@@ -2622,8 +2679,7 @@ todo_wine ok(hr == E_INVALIDARG, "IMoniker_IsRunning should return E_INVALIDARG, not 0x%08x\n", hr);
hr = IMoniker_IsRunning(moniker, bindctx, NULL, NULL); - todo_wine - ok(hr == S_FALSE, "IMoniker_IsRunning should return S_FALSE, not 0x%08x\n", hr); + ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
hr = IMoniker_GetTimeOfLastChange(moniker, bindctx, NULL, &filetime); ok(hr == MK_E_NOTBINDABLE, "IMoniker_GetTimeOfLastChange should return MK_E_NOTBINDABLE, not 0x%08x\n", hr);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/itemmoniker.c | 34 ++++++++++++++++------------------ dlls/ole32/tests/moniker.c | 5 ++++- 2 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/dlls/ole32/itemmoniker.c b/dlls/ole32/itemmoniker.c index 111b111a1a..19876aa363 100644 --- a/dlls/ole32/itemmoniker.c +++ b/dlls/ole32/itemmoniker.c @@ -462,33 +462,31 @@ static HRESULT WINAPI ItemMonikerImpl_BindToObject(IMoniker* iface, /****************************************************************************** * ItemMoniker_BindToStorage ******************************************************************************/ -static HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker* iface, - IBindCtx* pbc, - IMoniker* pmkToLeft, - REFIID riid, - VOID** ppvResult) +static HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riid, + void **ppvResult) { - ItemMonikerImpl *This = impl_from_IMoniker(iface); - HRESULT res; - IOleItemContainer *poic=0; + ItemMonikerImpl *moniker = impl_from_IMoniker(iface); + IOleItemContainer *container; + HRESULT hr;
- TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvResult); + TRACE("%p, %p, %p, %s, %p.\n", iface, pbc, pmkToLeft, debugstr_guid(riid), ppvResult);
- *ppvResult=0; + *ppvResult = 0;
- if(pmkToLeft==NULL) + if (!pmkToLeft) return E_INVALIDARG;
- res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic); - - if (SUCCEEDED(res)){ - - res=IOleItemContainer_GetObjectStorage(poic,This->itemName,pbc,riid,ppvResult); + hr = IMoniker_BindToObject(pmkToLeft, pbc, NULL, &IID_IOleItemContainer, (void **)&container); + if (SUCCEEDED(hr)) + { + if (FAILED(hr = set_container_lock(container, pbc))) + WARN("Failed to lock container, hr %#x.\n", hr);
- IOleItemContainer_Release(poic); + hr = IOleItemContainer_GetObjectStorage(container, moniker->itemName, pbc, riid, ppvResult); + IOleItemContainer_Release(container); }
- return res; + return hr; }
/****************************************************************************** diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index 7d4c8224ad..231551b244 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -380,7 +380,7 @@ static HRESULT WINAPI test_item_container_GetObject(IOleItemContainer *iface, LP static HRESULT WINAPI test_item_container_GetObjectStorage(IOleItemContainer *iface, LPOLESTR item, IBindCtx *pbc, REFIID riid, void **obj) { - return E_NOTIMPL; + return 0x8bee0001; }
static HRESULT WINAPI test_item_container_IsRunning(IOleItemContainer *iface, LPOLESTR item) @@ -2235,6 +2235,9 @@ todo_wine hr = IMoniker_BindToStorage(moniker, bindctx, NULL, &IID_IUnknown, (void **)&unknown); ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+ hr = IMoniker_BindToStorage(moniker, bindctx, &container_moniker->IMoniker_iface, &IID_IUnknown, (void **)&unknown); + ok(hr == 0x8bee0001, "Unexpected hr %#x.\n", hr); + /* ParseDisplayName() */ hr = IMoniker_ParseDisplayName(moniker, bindctx, NULL, displayname, &eaten, &moniker2); ok(hr == MK_E_SYNTAX, "Unexpected hr %#x.\n", hr);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=63967
Your paranoid android.
=== debian10 (32 bit Chinese:China report) ===
ole32: clipboard.c:864: Test failed: didn't find cf_dataobject clipboard.c:865: Test failed: didn't find cf_ole_priv_data clipboard.c:626: Test failed: got 800401d0 clipboard.c:1019: Test failed: failed to clear clipboard, hr = 0x800401d0. clipboard.c:626: Test failed: got 800401d0 clipboard.c:1029: Test failed: expected data_cmpl ref=0, got 4 clipboard.c:1051: Test failed: OleIsCurrentClipboard returned 0 clipboard.c:1119: Test failed: 1 WM_DRAWCLIPBOARD received
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=63963
Your paranoid android.
=== debian10 (32 bit report) ===
ole32: clipboard.c:1051: Test failed: OleIsCurrentClipboard returned 0 clipboard.c:1119: Test failed: 1 WM_DRAWCLIPBOARD received