Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/compobj.c | 41 ++++++++++++++++++++++++++++++++++++-- dlls/ole32/tests/compobj.c | 1 - 2 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 4e48f6add6..0dc0d39c22 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -3138,7 +3138,9 @@ 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 */ @@ -3151,11 +3153,46 @@ 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, &comclass->clsid, iid, !(dwClsContext & WINE_CLSCTX_DONT_HOST), ppv); - ReleaseActCtx(data.hActCtx); + hres = get_inproc_class_object(apt, &clsreg, clsid, iid, !(dwClsContext & WINE_CLSCTX_DONT_HOST), ppv); + ReleaseActCtx(clsreg.u.actctx.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 5e72eb650e..a6d26678f4 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -757,7 +757,6 @@ static void test_CoGetClassObject(void) IUnknown_Release(pUnk);
hr = CoGetClassObject(&IID_Testiface7, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk); - todo_wine ok(hr == 0x80001235, "Unexpected hr %#x.\n", hr);
hr = CoGetClassObject(&IID_Testiface8, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk);