ole32: Pass requested interface IID to CreateInstance in CoCreateInstanceEx.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2015-10-21 16:22:37 +02:00 committed by Alexandre Julliard
parent 8075101480
commit dedcd30cb8
2 changed files with 43 additions and 8 deletions

View File

@ -3271,18 +3271,26 @@ static void init_multi_qi(DWORD count, MULTI_QI *mqi)
}
}
static HRESULT return_multi_qi(IUnknown *unk, DWORD count, MULTI_QI *mqi)
static HRESULT return_multi_qi(IUnknown *unk, DWORD count, MULTI_QI *mqi, BOOL include_unk)
{
ULONG index, fetched = 0;
ULONG index = 0, fetched = 0;
for (index = 0; index < count; index++)
if (include_unk)
{
mqi[0].hr = S_OK;
mqi[0].pItf = unk;
index = fetched = 1;
}
for (; index < count; index++)
{
mqi[index].hr = IUnknown_QueryInterface(unk, mqi[index].pIID, (void**)&mqi[index].pItf);
if (mqi[index].hr == S_OK)
fetched++;
}
IUnknown_Release(unk);
if (!include_unk)
IUnknown_Release(unk);
if (fetched == 0)
return E_NOINTERFACE;
@ -3321,13 +3329,13 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstanceEx(
hr = CoCreateInstance(rclsid,
pUnkOuter,
dwClsContext,
&IID_IUnknown,
pResults[0].pIID,
(VOID**)&pUnk);
if (hr != S_OK)
return hr;
return return_multi_qi(pUnk, cmq, pResults);
return return_multi_qi(pUnk, cmq, pResults, TRUE);
}
/***********************************************************************
@ -3390,7 +3398,7 @@ HRESULT WINAPI CoGetInstanceFromFile(
IPersistFile_Release(pf);
}
return return_multi_qi(unk, count, results);
return return_multi_qi(unk, count, results, FALSE);
}
/***********************************************************************
@ -3453,7 +3461,7 @@ HRESULT WINAPI CoGetInstanceFromIStorage(
IPersistStorage_Release(ps);
}
return return_multi_qi(unk, count, results);
return return_multi_qi(unk, count, results, FALSE);
}
/***********************************************************************

View File

@ -152,6 +152,7 @@ static ULONG WINAPI Test_IClassFactory_Release(LPCLASSFACTORY iface)
return 1; /* non-heap-based object */
}
static IID create_instance_iid;
static HRESULT WINAPI Test_IClassFactory_CreateInstance(
LPCLASSFACTORY iface,
IUnknown *pUnkOuter,
@ -159,6 +160,7 @@ static HRESULT WINAPI Test_IClassFactory_CreateInstance(
LPVOID *ppvObj)
{
*ppvObj = NULL;
create_instance_iid = *riid;
if (pUnkOuter) return CLASS_E_NOAGGREGATION;
return E_NOINTERFACE;
}
@ -789,6 +791,30 @@ static void test_CoGetClassObject(void)
CoUninitialize();
}
static void test_CoCreateInstanceEx(void)
{
MULTI_QI qi_res = { &IID_IMoniker };
DWORD cookie;
HRESULT hr;
CoInitialize(NULL);
hr = CoRegisterClassObject(&CLSID_WineOOPTest, (IUnknown *)&Test_ClassFactory,
CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &cookie);
ok_ole_success(hr, "CoRegisterClassObject");
create_instance_iid = IID_NULL;
hr = CoCreateInstanceEx(&CLSID_WineOOPTest, NULL, CLSCTX_INPROC_SERVER, NULL, 1, &qi_res);
ok(hr == E_NOINTERFACE, "CoCreateInstanceEx failed: %08x\n", hr);
ok(IsEqualGUID(&create_instance_iid, qi_res.pIID), "Unexpected CreateInstance iid %s\n",
wine_dbgstr_guid(&create_instance_iid));
hr = CoRevokeClassObject(cookie);
ok_ole_success(hr, "CoRevokeClassObject");
CoUninitialize();
}
static ATOM register_dummy_class(void)
{
WNDCLASSA wc =
@ -2636,6 +2662,7 @@ START_TEST(compobj)
test_CoCreateInstance();
test_ole_menu();
test_CoGetClassObject();
test_CoCreateInstanceEx();
test_CoRegisterMessageFilter();
test_CoRegisterPSClsid();
test_CoGetPSClsid();