From 2e3a07e4930dd1e154d4ae90ba51a718e43508d8 Mon Sep 17 00:00:00 2001 From: MouriNaruto Date: Sun, 22 Sep 2024 23:27:44 +0800 Subject: [PATCH] Add RoGetActivationFactory to NanaZip.Frieren.RuntimeObjectWrapper. --- .../NanaZip.Frieren.RuntimeObjectWrapper.cpp | 36 +++++++++++++++++++ NanaZip.UI.Classic/NanaZip.vcxproj | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/NanaZip.Frieren/NanaZip.Frieren.RuntimeObjectWrapper.cpp b/NanaZip.Frieren/NanaZip.Frieren.RuntimeObjectWrapper.cpp index 66c845203..af0562f34 100644 --- a/NanaZip.Frieren/NanaZip.Frieren.RuntimeObjectWrapper.cpp +++ b/NanaZip.Frieren/NanaZip.Frieren.RuntimeObjectWrapper.cpp @@ -50,6 +50,23 @@ namespace return CachedResult; } + static FARPROC GetRoGetActivationFactoryProcAddress() + { + static FARPROC CachedResult = ([]() -> FARPROC + { + HMODULE ModuleHandle = ::GetComBaseModuleHandle(); + if (ModuleHandle) + { + return ::GetProcAddress( + ModuleHandle, + "RoGetActivationFactory"); + } + return nullptr; + }()); + + return CachedResult; + } + static FARPROC GetRoOriginateLanguageExceptionProcAddress() { static FARPROC CachedResult = ([]() -> FARPROC @@ -170,6 +187,25 @@ namespace } } +EXTERN_C HRESULT WINAPI RoGetActivationFactory( + _In_ HSTRING activatableClassId, + _In_ REFIID iid, + _Out_ LPVOID* factory) +{ + using ProcType = decltype(::RoGetActivationFactory)*; + + ProcType ProcAddress = reinterpret_cast( + ::GetRoGetActivationFactoryProcAddress()); + + if (ProcAddress) + { + return ProcAddress(activatableClassId, iid, factory); + } + + *factory = nullptr; + return CLASS_E_CLASSNOTAVAILABLE; +} + EXTERN_C BOOL WINAPI RoOriginateLanguageException( _In_ HRESULT error, _In_opt_ HSTRING message, diff --git a/NanaZip.UI.Classic/NanaZip.vcxproj b/NanaZip.UI.Classic/NanaZip.vcxproj index 4f1d6d03c..7bda030c6 100644 --- a/NanaZip.UI.Classic/NanaZip.vcxproj +++ b/NanaZip.UI.Classic/NanaZip.vcxproj @@ -34,7 +34,7 @@ true - comctl32.lib;htmlhelp.lib;comdlg32.lib;Mpr.lib;%(AdditionalDependencies);runtimeobject.lib; + comctl32.lib;htmlhelp.lib;comdlg32.lib;Mpr.lib;%(AdditionalDependencies); mpr.dll;%(DelayLoadDLLs)