Module: wine Branch: master Commit: c2089cbd0d488e7d26858caf0a55b8e0c62a267c URL: http://source.winehq.org/git/wine.git/?a=commit;h=c2089cbd0d488e7d26858caf0a...
Author: Andrew Eikum aeikum@codeweavers.com Date: Fri Jun 13 13:01:13 2014 -0500
ole32: Respect TreatAs in CoCreateInstance.
---
dlls/ole32/compobj.c | 15 ++++++++++----- dlls/ole32/tests/compobj.c | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 98f6439..7af3bb7 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -3160,6 +3160,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance( HRESULT hres; LPCLASSFACTORY lpclf = 0; APARTMENT *apt; + CLSID clsid;
TRACE("(rclsid=%s, pUnkOuter=%p, dwClsContext=%08x, riid=%s, ppv=%p)\n", debugstr_guid(rclsid), pUnkOuter, dwClsContext, debugstr_guid(iid), ppv); @@ -3167,6 +3168,10 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance( if (ppv==0) return E_POINTER;
+ hres = CoGetTreatAsClass(rclsid, &clsid); + if(FAILED(hres)) + clsid = *rclsid; + *ppv = 0;
if (!(apt = COM_CurrentApt())) @@ -3182,7 +3187,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance( /* * The Standard Global Interface Table (GIT) object is a process-wide singleton. */ - if (IsEqualIID(rclsid, &CLSID_StdGlobalInterfaceTable)) + if (IsEqualIID(&clsid, &CLSID_StdGlobalInterfaceTable)) { IGlobalInterfaceTable *git = get_std_git(); hres = IGlobalInterfaceTable_QueryInterface(git, iid, ppv); @@ -3192,13 +3197,13 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance( return S_OK; }
- if (IsEqualCLSID(rclsid, &CLSID_ManualResetEvent)) + if (IsEqualCLSID(&clsid, &CLSID_ManualResetEvent)) return ManualResetEvent_Construct(pUnkOuter, iid, ppv);
/* * Get a class factory to construct the object we want. */ - hres = CoGetClassObject(rclsid, + hres = CoGetClassObject(&clsid, dwClsContext, NULL, &IID_IClassFactory, @@ -3215,11 +3220,11 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance( if (FAILED(hres)) { if (hres == CLASS_E_NOAGGREGATION && pUnkOuter) - FIXME("Class %s does not support aggregation\n", debugstr_guid(rclsid)); + 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(iid), - debugstr_guid(rclsid),hres); + debugstr_guid(&clsid),hres); }
return hres; diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c index 219d2f9..6d5e811 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -1903,6 +1903,7 @@ static void test_TreatAsClass(void) CLSID out; static GUID deadbeef = {0xdeadbeef,0xdead,0xbeef,{0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef}}; static const char deadbeefA[] = "{DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF}"; + IInternetProtocol *pIP = NULL; HKEY clsidkey, deadbeefkey; LONG lr;
@@ -1935,6 +1936,21 @@ static void test_TreatAsClass(void) ok(hr == S_OK, "CoGetTreatAsClass failed: %08x\n",hr); ok(IsEqualGUID(&out, &CLSID_FileProtocol), "expected to get substituted clsid\n");
+ OleInitialize(NULL); + + hr = CoCreateInstance(&deadbeef, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void **)&pIP); + if(hr == REGDB_E_CLASSNOTREG) + { + win_skip("IE not installed so can't test CoCreateInstance\n"); + goto exit; + } + + ok(hr == S_OK, "CoCreateInstance failed: %08x\n", hr); + if(pIP){ + IInternetProtocol_Release(pIP); + pIP = NULL; + } + hr = pCoTreatAsClass(&deadbeef, &CLSID_NULL); ok(hr == S_OK, "CoTreatAsClass failed: %08x\n", hr);
@@ -1942,7 +1958,17 @@ static void test_TreatAsClass(void) ok(hr == S_FALSE, "expected S_FALSE got %08x\n", hr); ok(IsEqualGUID(&out, &deadbeef), "expected to get same clsid back\n");
+ /* bizarrely, native's CoTreatAsClass takes some time to take effect in CoCreateInstance */ + Sleep(200); + + hr = CoCreateInstance(&deadbeef, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void **)&pIP); + ok(hr == REGDB_E_CLASSNOTREG, "CoCreateInstance gave wrong error: %08x\n", hr); + + if(pIP) + IInternetProtocol_Release(pIP); + exit: + OleUninitialize(); RegCloseKey(deadbeefkey); RegDeleteKeyA(clsidkey, deadbeefA); RegCloseKey(clsidkey);