Updated combase-RoApi patchset

This commit is contained in:
Alistair Leslie-Hughes 2018-04-08 10:54:30 +10:00
parent bd8446fa57
commit 35999cf261
3 changed files with 211 additions and 28 deletions

View File

@ -0,0 +1,196 @@
From 45b77996f35a193f0586110cd03377e8a04bda20 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 17 Jan 2016 01:42:05 +0100
Subject: [PATCH] combase: Implement RoGetActivationFactory.
---
dlls/combase/Makefile.in | 2 +-
dlls/combase/roapi.c | 139 +++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 135 insertions(+), 6 deletions(-)
diff --git a/dlls/combase/Makefile.in b/dlls/combase/Makefile.in
index b1d759e49a8..df051ad2934 100644
--- a/dlls/combase/Makefile.in
+++ b/dlls/combase/Makefile.in
@@ -1,5 +1,5 @@
MODULE = combase.dll
-IMPORTS = ole32 uuid
+IMPORTS = advapi32 ole32 uuid
C_SRCS = \
roapi.c \
diff --git a/dlls/combase/roapi.c b/dlls/combase/roapi.c
index a2d625202d9..f7862fb774a 100644
--- a/dlls/combase/roapi.c
+++ b/dlls/combase/roapi.c
@@ -1,5 +1,6 @@
/*
* Copyright 2014 Martin Storsjo
+ * Copyright 2016 Michael Müller
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -15,16 +16,96 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-
+#define COBJMACROS
#include "objbase.h"
+#include "initguid.h"
#include "roapi.h"
#include "roparameterizediid.h"
-#include "hstring.h"
+#include "winstring.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(combase);
+static const char *debugstr_hstring(HSTRING hstr)
+{
+ const WCHAR *str;
+ UINT32 len;
+ if (hstr && !((ULONG_PTR)hstr >> 16)) return "(invalid)";
+ str = WindowsGetStringRawBuffer(hstr, &len);
+ return wine_dbgstr_wn(str, len);
+}
+
+static HRESULT get_library_for_classid(const WCHAR *classid, WCHAR **out)
+{
+ static const WCHAR classkeyW[] = {'S','o','f','t','w','a','r','e','\\',
+ 'M','i','c','r','o','s','o','f','t','\\',
+ 'W','i','n','d','o','w','s','R','u','n','t','i','m','e','\\',
+ 'A','c','t','i','v','a','t','a','b','l','e','C','l','a','s','s','I','d',0};
+ static const WCHAR dllpathW[] = {'D','l','l','P','a','t','h',0};
+ HKEY hkey_root, hkey_class;
+ DWORD type, size;
+ HRESULT hr;
+ WCHAR *buf = NULL;
+
+ *out = NULL;
+
+ /* load class registry key */
+ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, classkeyW, 0, KEY_READ, &hkey_root))
+ return REGDB_E_READREGDB;
+ if (RegOpenKeyExW(hkey_root, classid, 0, KEY_READ, &hkey_class))
+ {
+ WARN("Class %s not found in registry\n", debugstr_w(classid));
+ RegCloseKey(hkey_root);
+ return REGDB_E_CLASSNOTREG;
+ }
+ RegCloseKey(hkey_root);
+
+ /* load (and expand) DllPath registry value */
+ if (RegQueryValueExW(hkey_class, dllpathW, NULL, &type, NULL, &size))
+ {
+ hr = REGDB_E_READREGDB;
+ goto done;
+ }
+ if (type != REG_SZ && type != REG_EXPAND_SZ)
+ {
+ hr = REGDB_E_READREGDB;
+ goto done;
+ }
+ if (!(buf = HeapAlloc(GetProcessHeap(), 0, size)))
+ {
+ hr = E_OUTOFMEMORY;
+ goto done;
+ }
+ if (RegQueryValueExW(hkey_class, dllpathW, NULL, NULL, (BYTE *)buf, &size))
+ {
+ hr = REGDB_E_READREGDB;
+ goto done;
+ }
+ if (type == REG_EXPAND_SZ)
+ {
+ WCHAR *expanded;
+ DWORD len = ExpandEnvironmentStringsW(buf, NULL, 0);
+ if (!(expanded = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
+ {
+ hr = E_OUTOFMEMORY;
+ goto done;
+ }
+ ExpandEnvironmentStringsW(buf, expanded, len);
+ HeapFree(GetProcessHeap(), 0, buf);
+ buf = expanded;
+ }
+
+ *out = buf;
+ return S_OK;
+
+done:
+ HeapFree(GetProcessHeap(), 0, buf);
+ RegCloseKey(hkey_class);
+ return hr;
+}
+
+
/***********************************************************************
* RoInitialize (combase.@)
*/
@@ -51,10 +132,58 @@ void WINAPI RoUninitialize(void)
/***********************************************************************
* RoGetActivationFactory (combase.@)
*/
-HRESULT WINAPI RoGetActivationFactory(HSTRING classid, REFIID iid, void **factory)
+HRESULT WINAPI RoGetActivationFactory(HSTRING classid, REFIID iid, void **class_factory)
{
- FIXME("stub: %p %p %p\n", classid, iid, factory);
- return E_NOTIMPL;
+ PFNGETACTIVATIONFACTORY pDllGetActivationFactory;
+ IActivationFactory *factory;
+ WCHAR *library;
+ HMODULE module;
+ HRESULT hr;
+
+ FIXME("(%s, %s, %p): semi-stub\n", debugstr_hstring(classid), debugstr_guid(iid), class_factory);
+
+ if (!iid || !class_factory)
+ return E_INVALIDARG;
+
+ hr = get_library_for_classid(WindowsGetStringRawBuffer(classid, NULL), &library);
+ if (FAILED(hr))
+ {
+ ERR("Failed to find library for %s\n", debugstr_hstring(classid));
+ return hr;
+ }
+
+ if (!(module = LoadLibraryW(library)))
+ {
+ ERR("Failed to load module %s\n", debugstr_w(library));
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ goto done;
+ }
+
+ if (!(pDllGetActivationFactory = (void *)GetProcAddress(module, "DllGetActivationFactory")))
+ {
+ ERR("Module %s does not implement DllGetActivationFactory\n", debugstr_w(library));
+ hr = E_FAIL;
+ goto done;
+ }
+
+ TRACE("Found library %s for class %s\n", debugstr_w(library), debugstr_hstring(classid));
+
+ hr = pDllGetActivationFactory(classid, &factory);
+ if (SUCCEEDED(hr))
+ {
+ hr = IActivationFactory_QueryInterface(factory, iid, class_factory);
+ if (SUCCEEDED(hr))
+ {
+ TRACE("Created interface %p\n", *class_factory);
+ module = NULL;
+ }
+ IActivationFactory_Release(factory);
+ }
+
+done:
+ HeapFree(GetProcessHeap(), 0, library);
+ if (module) FreeLibrary(module);
+ return hr;
}
/***********************************************************************
--
2.16.3

View File

@ -1,16 +1,16 @@
From 8274b8bb8f25d89c2f01b1724aed7e9e2eb5614b Mon Sep 17 00:00:00 2001
From 4707618a4e4d1ecb55362e95052465266055eada Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 17 Jan 2016 01:45:30 +0100
Subject: [PATCH 2/7] combase: Implement RoActivateInstance.
Subject: [PATCH] combase: Implement RoActivateInstance.
---
.../api-ms-win-core-winrt-l1-1-0.spec | 2 +-
dlls/combase/combase.spec | 2 +-
dlls/combase/roapi.c | 24 +++++++++++++++++++++-
3 files changed, 25 insertions(+), 3 deletions(-)
.../api-ms-win-core-winrt-l1-1-0.spec | 2 +-
dlls/combase/combase.spec | 2 +-
dlls/combase/roapi.c | 20 ++++++++++++++++++++
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/dlls/api-ms-win-core-winrt-l1-1-0/api-ms-win-core-winrt-l1-1-0.spec b/dlls/api-ms-win-core-winrt-l1-1-0/api-ms-win-core-winrt-l1-1-0.spec
index 74c9d27..978c3dc 100644
index 74c9d27aae3..978c3dc6d07 100644
--- a/dlls/api-ms-win-core-winrt-l1-1-0/api-ms-win-core-winrt-l1-1-0.spec
+++ b/dlls/api-ms-win-core-winrt-l1-1-0/api-ms-win-core-winrt-l1-1-0.spec
@@ -1,4 +1,4 @@
@ -20,7 +20,7 @@ index 74c9d27..978c3dc 100644
@ stub RoGetApartmentIdentifier
@ stdcall RoInitialize(long) combase.RoInitialize
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec
index c238eb8..f42bdae 100644
index c238eb82db7..f42bdae605b 100644
--- a/dlls/combase/combase.spec
+++ b/dlls/combase/combase.spec
@@ -242,7 +242,7 @@
@ -33,26 +33,10 @@ index c238eb8..f42bdae 100644
@ stub RoClearError
@ stub RoFailFastWithErrorContext
diff --git a/dlls/combase/roapi.c b/dlls/combase/roapi.c
index a2d62520..a272d2c 100644
index f7862fb774a..bfd07fb3f4e 100644
--- a/dlls/combase/roapi.c
+++ b/dlls/combase/roapi.c
@@ -15,12 +15,14 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-
+#define COBJMACROS
#include "objbase.h"
+#include "initguid.h"
#include "roapi.h"
#include "roparameterizediid.h"
#include "hstring.h"
+
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(combase);
@@ -69,3 +71,23 @@ HRESULT WINAPI RoGetParameterizedTypeInstanceIID(UINT32 name_element_count, cons
@@ -198,3 +198,23 @@ HRESULT WINAPI RoGetParameterizedTypeInstanceIID(UINT32 name_element_count, cons
if (hiid) *hiid = INVALID_HANDLE_VALUE;
return E_NOTIMPL;
}
@ -77,5 +61,5 @@ index a2d62520..a272d2c 100644
+ return hr;
+}
--
1.9.1
2.16.3

View File

@ -2782,10 +2782,12 @@ fi
# |
# | Modified files:
# | * dlls/api-ms-win-core-winrt-l1-1-0/api-ms-win-core-winrt-l1-1-0.spec, dlls/api-ms-win-core-winrt-registration-l1-1-0/api-
# | ms-win-core-winrt-registration-l1-1-0.spec, dlls/combase/combase.spec, dlls/combase/roapi.c, include/roapi.h
# | ms-win-core-winrt-registration-l1-1-0.spec, dlls/combase/Makefile.in, dlls/combase/combase.spec, dlls/combase/roapi.c,
# | include/roapi.h
# |
if test "$enable_combase_RoApi" -eq 1; then
patch_apply combase-RoApi/0002-include-roapi.h-Add-further-typedefs.patch
patch_apply combase-RoApi/0003-combase-Implement-RoGetActivationFactory.patch
patch_apply combase-RoApi/0004-combase-Implement-RoActivateInstance.patch
patch_apply combase-RoApi/0005-combase-Add-stub-for-RoGetApartmentIdentifier.patch
patch_apply combase-RoApi/0007-combase-Add-stub-for-RoRegisterForApartmentShutdown.patch
@ -2794,6 +2796,7 @@ if test "$enable_combase_RoApi" -eq 1; then
patch_apply combase-RoApi/0010-combase-Add-stub-for-CleanupTlsOleState.patch
(
printf '%s\n' '+ { "Michael Müller", "include/roapi.h: Add further typedefs.", 1 },';
printf '%s\n' '+ { "Michael Müller", "combase: Implement RoGetActivationFactory.", 1 },';
printf '%s\n' '+ { "Michael Müller", "combase: Implement RoActivateInstance.", 1 },';
printf '%s\n' '+ { "Michael Müller", "combase: Add stub for RoGetApartmentIdentifier.", 1 },';
printf '%s\n' '+ { "Michael Müller", "combase: Add stub for RoRegisterForApartmentShutdown.", 1 },';