diff --git a/dlls/combase/combase.c b/dlls/combase/combase.c index edd6ac0b285..4e15bd970e8 100644 --- a/dlls/combase/combase.c +++ b/dlls/combase/combase.c @@ -1306,3 +1306,47 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *out *obj = multi_qi.pItf; return hr; } + +/*********************************************************************** + * CoCreateInstanceEx (combase.@) + */ +HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstanceEx(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, + COSERVERINFO *server_info, ULONG count, MULTI_QI *results) +{ + IClassFactory *factory; + IUnknown *unk = NULL; + CLSID clsid; + HRESULT hr; + + TRACE("%s, %p, %#x, %p, %u, %p\n", debugstr_guid(rclsid), outer, cls_context, server_info, count, results); + + if (!count || !results) + return E_INVALIDARG; + + if (server_info) + FIXME("Server info is not supported.\n"); + + init_multi_qi(count, results, E_NOINTERFACE); + + hr = CoGetTreatAsClass(rclsid, &clsid); + if (FAILED(hr)) + clsid = *rclsid; + + hr = CoGetClassObject(&clsid, cls_context, NULL, &IID_IClassFactory, (void **)&factory); + if (FAILED(hr)) + return hr; + + hr = IClassFactory_CreateInstance(factory, outer, results[0].pIID, (void **)&unk); + IClassFactory_Release(factory); + if (FAILED(hr)) + { + if (hr == CLASS_E_NOAGGREGATION && outer) + FIXME("Class %s does not support aggregation\n", debugstr_guid(&clsid)); + else + FIXME("no instance created for interface %s of class %s, hr %#x.\n", + debugstr_guid(results[0].pIID), debugstr_guid(&clsid), hr); + return hr; + } + + return return_multi_qi(unk, count, results, TRUE); +} diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index 6698c23c76d..0daf321d69b 100644 --- a/dlls/combase/combase.spec +++ b/dlls/combase/combase.spec @@ -81,7 +81,7 @@ @ stdcall CoCreateFreeThreadedMarshaler(ptr ptr) @ stdcall CoCreateGuid(ptr) @ stdcall CoCreateInstance(ptr ptr long ptr ptr) -@ stdcall CoCreateInstanceEx(ptr ptr long ptr long ptr) ole32.CoCreateInstanceEx +@ stdcall CoCreateInstanceEx(ptr ptr long ptr long ptr) @ stub CoCreateInstanceFromApp @ stub CoCreateObjectInContext @ stub CoDeactivateObject diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index cf1feeb3f41..dd51542af53 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -2918,100 +2918,6 @@ HRESULT WINAPI CoResumeClassObjects(void) return S_OK; } -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 = hr; - } -} - -static HRESULT return_multi_qi(IUnknown *unk, DWORD count, MULTI_QI *mqi, BOOL include_unk) -{ - ULONG index = 0, fetched = 0; - - 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++; - } - - if (!include_unk) - IUnknown_Release(unk); - - if (fetched == 0) - return E_NOINTERFACE; - - return fetched == count ? S_OK : CO_S_NOTALLINTERFACES; -} - -/*********************************************************************** - * CoCreateInstanceEx [OLE32.@] - */ -HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstanceEx( - REFCLSID rclsid, - LPUNKNOWN pUnkOuter, - DWORD dwClsContext, - COSERVERINFO* pServerInfo, - ULONG cmq, - MULTI_QI* pResults) -{ - IUnknown *unk = NULL; - IClassFactory *cf; - CLSID clsid; - HRESULT hres; - - TRACE("(%s %p %x %p %u %p)\n", debugstr_guid(rclsid), pUnkOuter, dwClsContext, pServerInfo, cmq, pResults); - - if (!cmq || !pResults) - return E_INVALIDARG; - - if (pServerInfo) - FIXME("() non-NULL pServerInfo not supported!\n"); - - init_multi_qi(cmq, pResults, E_NOINTERFACE); - - hres = CoGetTreatAsClass(rclsid, &clsid); - if(FAILED(hres)) - clsid = *rclsid; - - /* - * Get a class factory to construct the object we want. - */ - hres = CoGetClassObject(&clsid, dwClsContext, NULL, &IID_IClassFactory, (void**)&cf); - if (FAILED(hres)) - return hres; - - /* - * Create the object and don't forget to release the factory - */ - hres = IClassFactory_CreateInstance(cf, pUnkOuter, pResults[0].pIID, (void**)&unk); - IClassFactory_Release(cf); - if (FAILED(hres)) - { - if (hres == CLASS_E_NOAGGREGATION && pUnkOuter) - FIXME("Class %s does not support aggregation\n", debugstr_guid(&clsid)); - else - FIXME("no instance created for interface %s of class %s, hres is 0x%08x\n", - debugstr_guid(pResults[0].pIID), - debugstr_guid(&clsid),hres); - return hres; - } - - return return_multi_qi(unk, cmq, pResults, TRUE); -} - /*********************************************************************** * CoLoadLibrary (OLE32.@) * diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index a8101df80bc..57db6e38b76 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -13,7 +13,7 @@ @ stdcall CoCreateFreeThreadedMarshaler(ptr ptr) combase.CoCreateFreeThreadedMarshaler @ stdcall CoCreateGuid(ptr) combase.CoCreateGuid @ stdcall CoCreateInstance(ptr ptr long ptr ptr) combase.CoCreateInstance -@ stdcall CoCreateInstanceEx(ptr ptr long ptr long ptr) +@ stdcall CoCreateInstanceEx(ptr ptr long ptr long ptr) combase.CoCreateInstanceEx @ stdcall CoDecrementMTAUsage(ptr) @ stdcall CoDisableCallCancellation(ptr) @ stdcall CoDisconnectObject(ptr long)