Commit bbf0abde authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

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

parent 862ae1a6
......@@ -323,37 +323,33 @@ CompositeMonikerImpl_GetSizeMax(IMoniker* iface,ULARGE_INTEGER* pcbSize)
return S_OK;
}
/******************************************************************************
* CompositeMoniker_BindToObject
******************************************************************************/
static HRESULT WINAPI
CompositeMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc,
IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult)
static HRESULT WINAPI CompositeMonikerImpl_BindToObject(IMoniker *iface, IBindCtx *pbc,
IMoniker *pmkToLeft, REFIID riid, void **result)
{
HRESULT res;
IRunningObjectTable *prot;
IRunningObjectTable *rot;
IUnknown *object;
HRESULT hr;
IMoniker *tempMk,*antiMk,*rightMostMk;
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;
*ppvResult=0;
/* 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);
*result = NULL;
if (SUCCEEDED(res)){
/* if the requested class was loaded before ! we don't need to reload it */
res = IRunningObjectTable_GetObject(prot,iface,(IUnknown**)ppvResult);
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 (res==S_OK)
return res;
hr = IUnknown_QueryInterface(object, riid, result);
IUnknown_Release(object);
}
}
else{
......@@ -364,17 +360,17 @@ CompositeMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc,
IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL);
IEnumMoniker_Release(enumMoniker);
res=CreateAntiMoniker(&antiMk);
res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
hr = CreateAntiMoniker(&antiMk);
hr = IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
IMoniker_Release(antiMk);
res=IMoniker_BindToObject(rightMostMk,pbc,tempMk,riid,ppvResult);
hr = IMoniker_BindToObject(rightMostMk,pbc,tempMk,riid,result);
IMoniker_Release(tempMk);
IMoniker_Release(rightMostMk);
}
return res;
return hr;
}
/******************************************************************************
......
......@@ -2906,8 +2906,9 @@ static void test_generic_composite_moniker(void)
{
IMoniker *moniker, *inverse, *inverse2, *moniker1, *moniker2, *moniker3, *moniker4;
IEnumMoniker *enummoniker;
IRunningObjectTable *rot;
DWORD hash, cookie;
HRESULT hr;
DWORD hash;
IBindCtx *bindctx;
FILETIME filetime;
IUnknown *unknown;
......@@ -3032,15 +3033,9 @@ todo_wine
hr = IMoniker_GetTimeOfLastChange(moniker, bindctx, NULL, &filetime);
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);
ok(hr == E_INVALIDARG, "IMoniker_BindToStorage should return E_INVALIDARG, not 0x%08x\n", hr);
IBindCtx_Release(bindctx);
hr = IMoniker_Inverse(moniker, &inverse);
ok(hr == S_OK, "Failed to get inverse, hr %#x.\n", hr);
TEST_MONIKER_TYPE(inverse, MKSYS_GENERICCOMPOSITE);
......@@ -3059,7 +3054,36 @@ todo_wine
todo_wine
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);
IBindCtx_Release(bindctx);
}
static void test_pointer_moniker(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment