mirror of
https://github.com/reactos/wine.git
synced 2025-02-28 16:56:24 +00:00
ole32: Respect TreatAs in CoCreateInstance.
This commit is contained in:
parent
42f5118570
commit
c2089cbd0d
@ -3160,6 +3160,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(
|
|||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
LPCLASSFACTORY lpclf = 0;
|
LPCLASSFACTORY lpclf = 0;
|
||||||
APARTMENT *apt;
|
APARTMENT *apt;
|
||||||
|
CLSID clsid;
|
||||||
|
|
||||||
TRACE("(rclsid=%s, pUnkOuter=%p, dwClsContext=%08x, riid=%s, ppv=%p)\n", debugstr_guid(rclsid),
|
TRACE("(rclsid=%s, pUnkOuter=%p, dwClsContext=%08x, riid=%s, ppv=%p)\n", debugstr_guid(rclsid),
|
||||||
pUnkOuter, dwClsContext, debugstr_guid(iid), ppv);
|
pUnkOuter, dwClsContext, debugstr_guid(iid), ppv);
|
||||||
@ -3167,6 +3168,10 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(
|
|||||||
if (ppv==0)
|
if (ppv==0)
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
|
|
||||||
|
hres = CoGetTreatAsClass(rclsid, &clsid);
|
||||||
|
if(FAILED(hres))
|
||||||
|
clsid = *rclsid;
|
||||||
|
|
||||||
*ppv = 0;
|
*ppv = 0;
|
||||||
|
|
||||||
if (!(apt = COM_CurrentApt()))
|
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.
|
* 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();
|
IGlobalInterfaceTable *git = get_std_git();
|
||||||
hres = IGlobalInterfaceTable_QueryInterface(git, iid, ppv);
|
hres = IGlobalInterfaceTable_QueryInterface(git, iid, ppv);
|
||||||
@ -3192,13 +3197,13 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsEqualCLSID(rclsid, &CLSID_ManualResetEvent))
|
if (IsEqualCLSID(&clsid, &CLSID_ManualResetEvent))
|
||||||
return ManualResetEvent_Construct(pUnkOuter, iid, ppv);
|
return ManualResetEvent_Construct(pUnkOuter, iid, ppv);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get a class factory to construct the object we want.
|
* Get a class factory to construct the object we want.
|
||||||
*/
|
*/
|
||||||
hres = CoGetClassObject(rclsid,
|
hres = CoGetClassObject(&clsid,
|
||||||
dwClsContext,
|
dwClsContext,
|
||||||
NULL,
|
NULL,
|
||||||
&IID_IClassFactory,
|
&IID_IClassFactory,
|
||||||
@ -3215,11 +3220,11 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(
|
|||||||
if (FAILED(hres))
|
if (FAILED(hres))
|
||||||
{
|
{
|
||||||
if (hres == CLASS_E_NOAGGREGATION && pUnkOuter)
|
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
|
else
|
||||||
FIXME("no instance created for interface %s of class %s, hres is 0x%08x\n",
|
FIXME("no instance created for interface %s of class %s, hres is 0x%08x\n",
|
||||||
debugstr_guid(iid),
|
debugstr_guid(iid),
|
||||||
debugstr_guid(rclsid),hres);
|
debugstr_guid(&clsid),hres);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hres;
|
return hres;
|
||||||
|
@ -1903,6 +1903,7 @@ static void test_TreatAsClass(void)
|
|||||||
CLSID out;
|
CLSID out;
|
||||||
static GUID deadbeef = {0xdeadbeef,0xdead,0xbeef,{0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef}};
|
static GUID deadbeef = {0xdeadbeef,0xdead,0xbeef,{0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef}};
|
||||||
static const char deadbeefA[] = "{DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF}";
|
static const char deadbeefA[] = "{DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF}";
|
||||||
|
IInternetProtocol *pIP = NULL;
|
||||||
HKEY clsidkey, deadbeefkey;
|
HKEY clsidkey, deadbeefkey;
|
||||||
LONG lr;
|
LONG lr;
|
||||||
|
|
||||||
@ -1935,6 +1936,21 @@ static void test_TreatAsClass(void)
|
|||||||
ok(hr == S_OK, "CoGetTreatAsClass failed: %08x\n",hr);
|
ok(hr == S_OK, "CoGetTreatAsClass failed: %08x\n",hr);
|
||||||
ok(IsEqualGUID(&out, &CLSID_FileProtocol), "expected to get substituted clsid\n");
|
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);
|
hr = pCoTreatAsClass(&deadbeef, &CLSID_NULL);
|
||||||
ok(hr == S_OK, "CoTreatAsClass failed: %08x\n", hr);
|
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(hr == S_FALSE, "expected S_FALSE got %08x\n", hr);
|
||||||
ok(IsEqualGUID(&out, &deadbeef), "expected to get same clsid back\n");
|
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:
|
exit:
|
||||||
|
OleUninitialize();
|
||||||
RegCloseKey(deadbeefkey);
|
RegCloseKey(deadbeefkey);
|
||||||
RegDeleteKeyA(clsidkey, deadbeefA);
|
RegDeleteKeyA(clsidkey, deadbeefA);
|
||||||
RegCloseKey(clsidkey);
|
RegCloseKey(clsidkey);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user