ole32/composite: Return requested interface in BindToObject() in NULL left moniker path.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-09-21 15:05:07 +03:00 committed by Alexandre Julliard
parent 862ae1a634
commit bbf0abdea5
2 changed files with 53 additions and 33 deletions

View File

@ -323,37 +323,33 @@ CompositeMonikerImpl_GetSizeMax(IMoniker* iface,ULARGE_INTEGER* pcbSize)
return S_OK; return S_OK;
} }
/****************************************************************************** static HRESULT WINAPI CompositeMonikerImpl_BindToObject(IMoniker *iface, IBindCtx *pbc,
* CompositeMoniker_BindToObject IMoniker *pmkToLeft, REFIID riid, void **result)
******************************************************************************/
static HRESULT WINAPI
CompositeMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc,
IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult)
{ {
HRESULT res; IRunningObjectTable *rot;
IRunningObjectTable *prot; IUnknown *object;
HRESULT hr;
IMoniker *tempMk,*antiMk,*rightMostMk; IMoniker *tempMk,*antiMk,*rightMostMk;
IEnumMoniker *enumMoniker; IEnumMoniker *enumMoniker;
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), result);
if (ppvResult==NULL) if (!result)
return E_POINTER; return E_POINTER;
*ppvResult=0; *result = NULL;
/* If pmkToLeft is NULL, this method looks for the moniker in the ROT, and if found, queries the retrieved */
/* object for the requested interface pointer. */
if(pmkToLeft==NULL){
res=IBindCtx_GetRunningObjectTable(pbc,&prot); if (!pmkToLeft)
{
hr = IBindCtx_GetRunningObjectTable(pbc, &rot);
if (SUCCEEDED(hr))
{
hr = IRunningObjectTable_GetObject(rot, iface, &object);
IRunningObjectTable_Release(rot);
if (FAILED(hr)) return E_INVALIDARG;
if (SUCCEEDED(res)){ hr = IUnknown_QueryInterface(object, riid, result);
IUnknown_Release(object);
/* if the requested class was loaded before ! we don't need to reload it */
res = IRunningObjectTable_GetObject(prot,iface,(IUnknown**)ppvResult);
if (res==S_OK)
return res;
} }
} }
else{ else{
@ -364,17 +360,17 @@ CompositeMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc,
IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL); IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL);
IEnumMoniker_Release(enumMoniker); IEnumMoniker_Release(enumMoniker);
res=CreateAntiMoniker(&antiMk); hr = CreateAntiMoniker(&antiMk);
res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk); hr = IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
IMoniker_Release(antiMk); IMoniker_Release(antiMk);
res=IMoniker_BindToObject(rightMostMk,pbc,tempMk,riid,ppvResult); hr = IMoniker_BindToObject(rightMostMk,pbc,tempMk,riid,result);
IMoniker_Release(tempMk); IMoniker_Release(tempMk);
IMoniker_Release(rightMostMk); IMoniker_Release(rightMostMk);
} }
return res; return hr;
} }
/****************************************************************************** /******************************************************************************

View File

@ -2906,8 +2906,9 @@ static void test_generic_composite_moniker(void)
{ {
IMoniker *moniker, *inverse, *inverse2, *moniker1, *moniker2, *moniker3, *moniker4; IMoniker *moniker, *inverse, *inverse2, *moniker1, *moniker2, *moniker3, *moniker4;
IEnumMoniker *enummoniker; IEnumMoniker *enummoniker;
IRunningObjectTable *rot;
DWORD hash, cookie;
HRESULT hr; HRESULT hr;
DWORD hash;
IBindCtx *bindctx; IBindCtx *bindctx;
FILETIME filetime; FILETIME filetime;
IUnknown *unknown; IUnknown *unknown;
@ -3032,15 +3033,9 @@ todo_wine
hr = IMoniker_GetTimeOfLastChange(moniker, bindctx, NULL, &filetime); hr = IMoniker_GetTimeOfLastChange(moniker, bindctx, NULL, &filetime);
ok(hr == MK_E_NOTBINDABLE, "IMoniker_GetTimeOfLastChange should return MK_E_NOTBINDABLE, not 0x%08x\n", hr); ok(hr == MK_E_NOTBINDABLE, "IMoniker_GetTimeOfLastChange should return MK_E_NOTBINDABLE, not 0x%08x\n", hr);
hr = IMoniker_BindToObject(moniker, bindctx, NULL, &IID_IUnknown, (void **)&unknown);
todo_wine
ok(hr == E_INVALIDARG, "IMoniker_BindToObject should return E_INVALIDARG, not 0x%08x\n", hr);
hr = IMoniker_BindToStorage(moniker, bindctx, NULL, &IID_IUnknown, (void **)&unknown); hr = IMoniker_BindToStorage(moniker, bindctx, NULL, &IID_IUnknown, (void **)&unknown);
ok(hr == E_INVALIDARG, "IMoniker_BindToStorage should return E_INVALIDARG, not 0x%08x\n", hr); ok(hr == E_INVALIDARG, "IMoniker_BindToStorage should return E_INVALIDARG, not 0x%08x\n", hr);
IBindCtx_Release(bindctx);
hr = IMoniker_Inverse(moniker, &inverse); hr = IMoniker_Inverse(moniker, &inverse);
ok(hr == S_OK, "Failed to get inverse, hr %#x.\n", hr); ok(hr == S_OK, "Failed to get inverse, hr %#x.\n", hr);
TEST_MONIKER_TYPE(inverse, MKSYS_GENERICCOMPOSITE); TEST_MONIKER_TYPE(inverse, MKSYS_GENERICCOMPOSITE);
@ -3059,7 +3054,36 @@ todo_wine
todo_wine todo_wine
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
/* BindToObject() */
hr = IMoniker_BindToObject(moniker, bindctx, NULL, &IID_IUnknown, (void **)&unknown);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IBindCtx_GetRunningObjectTable(bindctx, &rot);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IRunningObjectTable_Register(rot, ROTFLAGS_REGISTRATIONKEEPSALIVE, (IUnknown *)moniker,
moniker, &cookie);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMoniker_BindToObject(moniker, bindctx, NULL, &IID_IUnknown, (void **)&unknown);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unknown);
hr = IMoniker_BindToObject(moniker, bindctx, NULL, &IID_IMoniker, (void **)&unknown);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unknown);
hr = IMoniker_BindToObject(moniker, bindctx, NULL, &IID_IDispatch, (void **)&unknown);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IRunningObjectTable_Revoke(rot, cookie);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IRunningObjectTable_Release(rot);
IMoniker_Release(moniker); IMoniker_Release(moniker);
IBindCtx_Release(bindctx);
} }
static void test_pointer_moniker(void) static void test_pointer_moniker(void)