Rémi Bernon : combase: Lookup activatable class library in the activation context.

Alexandre Julliard julliard at winehq.org
Fri May 20 15:26:47 CDT 2022


Module: wine
Branch: master
Commit: ea0fa9f1dce7e8f5712d2612204b0bde83cde53b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ea0fa9f1dce7e8f5712d2612204b0bde83cde53b

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Tue Apr  5 23:37:01 2022 +0200

combase: Lookup activatable class library in the activation context.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/combase/roapi.c       | 21 +++++++++++++++++++++
 dlls/combase/tests/roapi.c |  8 ++++----
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/dlls/combase/roapi.c b/dlls/combase/roapi.c
index eadf0ac2ecb..78f35de39d4 100644
--- a/dlls/combase/roapi.c
+++ b/dlls/combase/roapi.c
@@ -37,8 +37,18 @@ static const char *debugstr_hstring(HSTRING hstr)
     return wine_dbgstr_wn(str, len);
 }
 
+struct activatable_class_data
+{
+    ULONG size;
+    DWORD unk;
+    DWORD module_len;
+    DWORD module_offset;
+    DWORD threading_model;
+};
+
 static HRESULT get_library_for_classid(const WCHAR *classid, WCHAR **out)
 {
+    ACTCTX_SECTION_KEYED_DATA data;
     HKEY hkey_root, hkey_class;
     DWORD type, size;
     HRESULT hr;
@@ -46,6 +56,17 @@ static HRESULT get_library_for_classid(const WCHAR *classid, WCHAR **out)
 
     *out = NULL;
 
+    /* search activation context first */
+    data.cbSize = sizeof(data);
+    if (FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
+            ACTIVATION_CONTEXT_SECTION_WINRT_ACTIVATABLE_CLASSES, classid, &data))
+    {
+        struct activatable_class_data *activatable_class = (struct activatable_class_data *)data.lpData;
+        void *ptr = (BYTE *)data.lpSectionBase + activatable_class->module_offset;
+        *out = wcsdup(ptr);
+        return S_OK;
+    }
+
     /* load class registry key */
     if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\WindowsRuntime\\ActivatableClassId",
                       0, KEY_READ, &hkey_root))
diff --git a/dlls/combase/tests/roapi.c b/dlls/combase/tests/roapi.c
index 579b1502797..f10cbb4507b 100644
--- a/dlls/combase/tests/roapi.c
+++ b/dlls/combase/tests/roapi.c
@@ -95,21 +95,19 @@ static void test_ActivationFactories(void)
     todo_wine
     ok(hr == E_NOTIMPL || broken(hr == REGDB_E_CLASSNOTREG) /* <= w1064v1809 */,
             "RoGetActivationFactory returned %#lx.\n", hr);
+    todo_wine
     ok(factory == NULL, "got factory %p.\n", factory);
+    if (factory) IActivationFactory_Release(factory);
     WindowsDeleteString(str);
     hr = WindowsCreateString(L"Wine.Test.Trusted", ARRAY_SIZE(L"Wine.Test.Trusted") - 1, &str);
     ok(hr == S_OK, "WindowsCreateString returned %#lx.\n", hr);
     hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
-    todo_wine
     ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG) /* <= w1064v1809 */,
             "RoGetActivationFactory returned %#lx.\n", hr);
     if (hr == REGDB_E_CLASSNOTREG)
         ok(!factory, "got factory %p.\n", factory);
     else
-    {
-        todo_wine
         ok(!!factory, "got factory %p.\n", factory);
-    }
     if (!factory) ref = 0;
     else ref = IActivationFactory_Release(factory);
     ok(ref == 0, "Release returned %lu\n", ref);
@@ -126,6 +124,8 @@ START_TEST(roapi)
 
     test_ActivationFactories();
 
+    SetLastError(0xdeadbeef);
     ret = DeleteFileW(L"wine.combase.test.dll");
+    todo_wine_if(!ret && GetLastError() == ERROR_ACCESS_DENIED)
     ok(ret, "Failed to delete file, error %lu\n", GetLastError());
 }




More information about the wine-cvs mailing list