From 78e189019548a67720fd0accc1b0a853aa986852 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Tue, 19 Jul 2022 00:40:29 +0200 Subject: [PATCH] SandboxTest: Also load and register the Image3dAPI type library to enable marshsaling of the corresponding interfaces. --- DummyLoader/Main.cpp | 5 ++--- SandboxTest/Main.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/DummyLoader/Main.cpp b/DummyLoader/Main.cpp index a5715d9..def6e71 100644 --- a/DummyLoader/Main.cpp +++ b/DummyLoader/Main.cpp @@ -40,14 +40,13 @@ STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID // DllRegisterServer - Adds entries to the system registry. STDAPI DllRegisterServer() { - // registers object, typelib and all interfaces in typelib - return _AtlModule.DllRegisterServer(false); // skip TypeLib registration since that is the responsibility of the host + return _AtlModule.DllRegisterServer(FALSE); // skip TypeLib registration since that is the responsibility of the host } // DllUnregisterServer - Removes entries from the system registry. STDAPI DllUnregisterServer() { - return _AtlModule.DllUnregisterServer(); + return _AtlModule.DllUnregisterServer(FALSE); // skip TypeLib unregistration for consistency with DllRegisterServer } // DllInstall - Adds/Removes entries to the system registry per user per machine. diff --git a/SandboxTest/Main.cpp b/SandboxTest/Main.cpp index 5e88c3d..627ca7a 100644 --- a/SandboxTest/Main.cpp +++ b/SandboxTest/Main.cpp @@ -198,6 +198,21 @@ int wmain(int argc, wchar_t *argv[]) { } } + // register type library to enable out-of-proc Image3dAPI calls + // only works if running as admin + CComPtr typelib; + HRESULT hr = LoadTypeLibEx(L"Image3dAPI.tlb", REGKIND_REGISTER, &typelib); + CHECK(hr); + +#if 0 + // unregister type library + TLIBATTR * tlb_attr = nullptr; + CHECK(typelib->GetLibAttr(&tlb_attr)); + hr = UnRegisterTypeLib(tlb_attr->guid, tlb_attr->wMajorVerNum, tlb_attr->wMinorVerNum, tlb_attr->lcid, tlb_attr->syskind); + CHECK(hr); + typelib->ReleaseTLibAttr(tlb_attr); +#endif + // create loader in a separate "low integrity" dllhost.exe process CComPtr loader; CComPtr source;