Skip to content

Commit

Permalink
Add RoGetActivationFactory to NanaZip.Frieren.RuntimeObjectWrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
MouriNaruto committed Sep 22, 2024
1 parent beddaab commit 2e3a07e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions NanaZip.Frieren/NanaZip.Frieren.RuntimeObjectWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<ProcType>(
::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,
Expand Down
2 changes: 1 addition & 1 deletion NanaZip.UI.Classic/NanaZip.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</ClCompile>
<Link>
<LargeAddressAware>true</LargeAddressAware>
<AdditionalDependencies>comctl32.lib;htmlhelp.lib;comdlg32.lib;Mpr.lib;%(AdditionalDependencies);runtimeobject.lib;</AdditionalDependencies>
<AdditionalDependencies>comctl32.lib;htmlhelp.lib;comdlg32.lib;Mpr.lib;%(AdditionalDependencies);</AdditionalDependencies>
<DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
Expand Down

0 comments on commit 2e3a07e

Please sign in to comment.