diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index df234498e65..6d9904a1650 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -3138,9 +3138,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject( if (CLSCTX_INPROC & dwClsContext) { - ASSEMBLY_FILE_DETAILED_INFORMATION *file_info = NULL; ACTCTX_SECTION_KEYED_DATA data; - const CLSID *clsid = NULL; data.cbSize = sizeof(data); /* search activation context first */ @@ -3153,46 +3151,11 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject( clsreg.u.actctx.module_name = (WCHAR *)((BYTE *)data.lpSectionBase + comclass->name_offset); clsreg.u.actctx.hactctx = data.hActCtx; clsreg.u.actctx.threading_model = comclass->model; - clsid = &comclass->clsid; - } - else if (FindActCtxSectionGuid(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL, - ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION, rclsid, &data)) - { - ACTIVATION_CONTEXT_QUERY_INDEX query_index; - SIZE_T required_len = 0; - - query_index.ulAssemblyIndex = data.ulAssemblyRosterIndex - 1; - query_index.ulFileIndexInAssembly = 0; - - QueryActCtxW(0, data.hActCtx, &query_index, FileInformationInAssemblyOfAssemblyInActivationContext, - NULL, 0, &required_len); - if (required_len) - { - file_info = heap_alloc(required_len); - if (file_info) - { - if (QueryActCtxW(0, data.hActCtx, &query_index, FileInformationInAssemblyOfAssemblyInActivationContext, - file_info, required_len, &required_len)) - { - clsreg.u.actctx.module_name = file_info->lpFileName; - clsreg.u.actctx.hactctx = data.hActCtx; - clsreg.u.actctx.threading_model = ThreadingModel_Both; - clsid = rclsid; - } - else - heap_free(file_info); - } - } - } - - if (clsreg.u.actctx.hactctx) - { clsreg.origin = CLASS_REG_ACTCTX; - hres = get_inproc_class_object(apt, &clsreg, clsid, iid, !(dwClsContext & WINE_CLSCTX_DONT_HOST), ppv); - ReleaseActCtx(clsreg.u.actctx.hactctx); + hres = get_inproc_class_object(apt, &clsreg, &comclass->clsid, iid, !(dwClsContext & WINE_CLSCTX_DONT_HOST), ppv); + ReleaseActCtx(data.hActCtx); apartment_release(apt); - heap_free(file_info); return hres; } } diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c index d6ccbc58823..eb172aac28d 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -347,6 +347,32 @@ static const char actctx_manifest[] = " " ""; +static const char actctx_manifest2[] = +"" +"" +"" +" " +"" +"" +" " +"" +" " +""; + DEFINE_GUID(CLSID_Testclass, 0x12345678, 0x1234, 0x1234, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0); static void test_ProgIDFromCLSID(void) @@ -692,6 +718,28 @@ static void test_CoCreateInstance(void) test_apt_type(APTTYPE_CURRENT, APTTYPEQUALIFIER_NONE); } +struct comclassredirect_data +{ + ULONG size; + ULONG flags; + DWORD model; + GUID clsid; + GUID alias; + GUID clsid2; + GUID tlid; + ULONG name_len; + ULONG name_offset; + ULONG progid_len; + ULONG progid_offset; + ULONG clrdata_len; + ULONG clrdata_offset; + DWORD miscstatus; + DWORD miscstatuscontent; + DWORD miscstatusthumbnail; + DWORD miscstatusicon; + DWORD miscstatusdocprint; +}; + static void test_CoGetClassObject(void) { HRESULT hr; @@ -763,6 +811,53 @@ static void test_CoGetClassObject(void) deactivate_context(handle, cookie); } + if ((handle = activate_context(actctx_manifest2, &cookie))) + { + struct comclassredirect_data *comclass; + ACTCTX_SECTION_KEYED_DATA data; + BOOL ret; + + /* This one will load test dll and get back specific error code. */ + hr = CoGetClassObject(&IID_Testiface7, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk); + ok(hr == 0x80001235 || broken(hr == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND)) /* winxp */, "Unexpected hr %#x.\n", hr); + + hr = CoGetClassObject(&IID_Testiface8, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk); + ok(FAILED(hr), "Unexpected hr %#x.\n", hr); + + memset(&data, 0, sizeof(data)); + data.cbSize = sizeof(data); + ret = FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION, &IID_Testiface8, &data); + ok(ret, "Section not found.\n"); + + memset(&data, 0, sizeof(data)); + data.cbSize = sizeof(data); + + /* External proxy-stubs are not accessible. */ + ret = FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, &IID_Testiface3, &data); + ok(!ret, "Unexpected return value.\n"); + + ret = FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, &IID_TestPS, &data); + ok(!ret, "Unexpected return value.\n"); + + ret = FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, &IID_Testiface7, &data); + ok(ret, "Unexpected return value.\n"); + + ret = FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, &IID_Testiface4, &data); + ok(!ret, "Unexpected return value.\n"); + + ret = FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, &IID_Testiface8, &data); + ok(ret, "Unexpected return value.\n"); + + comclass = data.lpData; + if (comclass) + { + WCHAR *name = (WCHAR *)((char *)data.lpSectionBase + comclass->name_offset); + ok(!lstrcmpW(name, L"testlib4.dll"), "Unexpected module name %s.\n", wine_dbgstr_w(name)); + } + + deactivate_context(handle, cookie); + } + CoUninitialize(); }