Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reapply "Delegate to OS RegFreeWinRT when available (>=24H1) (#4728)" (#4935) #4949

Merged
merged 42 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
04c7ea4
Reapply "Delegate to OS RegFreeWinRT when available (>=24H1) (#4728)"…
DrusTheAxe Dec 10, 2024
efeed82
Merge branch 'main' into user/drustheaxe/DynDepAndURFW-DelegateToOS
DrusTheAxe Jan 6, 2025
be41f1f
Added missing dependencies for OAuth2ManagerTests
DrusTheAxe Jan 7, 2025
806c30f
Expanded tests
DrusTheAxe Jan 7, 2025
19b7e11
Modified IsSupported with temporary debugging hack to expedite testin…
DrusTheAxe Jan 7, 2025
c89516b
Removed debug hackery
DrusTheAxe Jan 7, 2025
bd81139
Test fixes
DrusTheAxe Jan 7, 2025
9a169ea
More test fiddling
DrusTheAxe Jan 10, 2025
10fb555
Merge branch 'main' into user/drustheaxe/DynDepAndURFW-DelegateToOS
DrusTheAxe Jan 10, 2025
5a636e0
Merge branch 'main' into user/drustheaxe/DynDepAndURFW-DelegateToOS
DrusTheAxe Jan 13, 2025
c3d1d8c
Merge branch 'user/drustheaxe/DynDepAndURFW-DelegateToOS' of https://…
DrusTheAxe Jan 13, 2025
2165016
Microsoft.Windows.BadgeNotifications.Projection project is missing a …
DrusTheAxe Jan 14, 2025
bef7396
Removed redundant Import
DrusTheAxe Jan 14, 2025
f89b678
Fixed bad merge
DrusTheAxe Jan 14, 2025
3267be7
Fixed WinAppSDK framework package family name construction in GetFram…
DrusTheAxe Jan 20, 2025
bb13991
Merge branch 'main' into user/drustheaxe/DynDepAndURFW-DelegateToOS
DrusTheAxe Jan 21, 2025
3f8675b
Fixed DevCheck -CheckDependencies if packages.config has no <package>…
DrusTheAxe Jan 21, 2025
758dca4
Fix test framework package Name from name-major.minor to name.major.m…
DrusTheAxe Jan 23, 2025
8c7ef93
Workaround Windows bug https://task.ms/54835001 where IsPackage*Ready…
DrusTheAxe Jan 24, 2025
86e6194
Merge branch 'main' into user/drustheaxe/DynDepAndURFW-DelegateToOS
DrusTheAxe Jan 24, 2025
9015b70
Ran devcheck -syncdependencies
DrusTheAxe Jan 24, 2025
bd09186
Fixed failing PackageManagementTests
DrusTheAxe Jan 25, 2025
f4a8a3a
Merge branch 'main' into user/drustheaxe/DynDepAndURFW-DelegateToOS
DrusTheAxe Jan 27, 2025
9229615
Updated dependnecies via DevCheck -SyncDependencies. Removed unused M…
DrusTheAxe Jan 27, 2025
de19f8f
Updated link to latest SDK rev
DrusTheAxe Jan 27, 2025
38f1d56
Fixed dependencies (syntax and usage
DrusTheAxe Jan 27, 2025
ddabde6
Put WindowsAppRuntime_UniversalBGTaskDLL back to what's in main. No i…
DrusTheAxe Jan 27, 2025
55981ef
Fixed hardcoded versions in OAuthTestApp.vcxproj (wasn't using versio…
DrusTheAxe Jan 27, 2025
1bdc702
Fixed more bad projects - Import Microsoft.Cpp.Default.props not at t…
DrusTheAxe Jan 27, 2025
3411a5e
Fixed WindowsAppRuntime_UniversalBGTaskDLL - Import Microsoft.Cpp.Def…
DrusTheAxe Jan 27, 2025
c69ede0
Added -ShowSystemInfo (default=$true) to Testall so test run output i…
DrusTheAxe Jan 29, 2025
f6a1ecd
Fixed up test Main+Singleton+DDLM naming/constants
DrusTheAxe Jan 30, 2025
5a62cee
Fixed bug in package name constant
DrusTheAxe Jan 30, 2025
fc7bec9
Added missing project dependencies. Updated ConfigurationManager to b…
DrusTheAxe Jan 31, 2025
c599faf
Merge branch 'main' into user/drustheaxe/DynDepAndURFW-DelegateToOS
kythant Jan 31, 2025
b3a9f93
Merge branch 'main' into user/drustheaxe/DynDepAndURFW-DelegateToOS
DrusTheAxe Jan 31, 2025
b5ae0b3
Merge branch 'user/drustheaxe/DynDepAndURFW-DelegateToOS' of https://…
DrusTheAxe Jan 31, 2025
6062c2f
Fixed bad merge
DrusTheAxe Jan 31, 2025
084497f
Fixed a bad merge
DrusTheAxe Feb 1, 2025
b5ca94b
Removed temporary debugging code
DrusTheAxe Feb 1, 2025
8f27a90
Some test packages lacked ARM64 support, plus those and others weren'…
DrusTheAxe Feb 4, 2025
e99d9e0
Fixed one more ARM configuration manager misconfiguration
DrusTheAxe Feb 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion TestAll.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ param(
[Switch]$Test,

[Parameter(Mandatory=$false)]
[Switch]$List
[Switch]$List,

[Parameter(Mandatory=$false)]
[Switch]$ShowSystemInfo=$true
)

$StartTime = Get-Date
Expand Down Expand Up @@ -175,6 +178,44 @@ function Run-Tests
}
}

function Get-SystemInfo
{
$regkey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
$productname = $(Get-Item -Path $regkey).GetValue('ProductName')
$displayversion = $(Get-Item -Path $regkey).GetValue('DisplayVersion')
$currentmajor = $(Get-Item -Path $regkey).GetValue('CurrentMajorVersionNumber')
$currentminor = $(Get-Item -Path $regkey).GetValue('CurrentMinorVersionNumber')
$currentbuild = $(Get-Item -Path $regkey).GetValue('CurrentBuild')
Write-Host "Product : $($productname) $($displayversion) $($currentmajor).$($currentminor).$($currentbuild)"

$installationtype = $(Get-Item -Path $regkey).GetValue('InstallationType')
Write-Host "InstallationType: $($installationtype)"

$editionid = $(Get-Item -Path $regkey).GetValue('EditionId')
$compositioneditionid = $(Get-Item -Path $regkey).GetValue('CompositionEditionID')
if ($editionid -eq $compositioneditionid)
{
Write-Host "Edition : $($editionid)"
}
else
{
Write-Host "Edition : $($editionid) [$($compositioneditionid)]"
}

$buildlabex = $(Get-Item -Path $regkey).GetValue('BuildLabEx')
Write-Host "Build : $($buildlabex)"

$lcuver = $(Get-Item -Path $regkey).GetValue('LCUVer')
Write-Host "LCU Version : $($lcuver)"

Write-Host "Powershell : $($PSVersionTable.PSEdition) $($PSVersionTable.PSVersion)"
}

if ($ShowSystemInfo -eq $true)
{
Get-SystemInfo
}

if ($List -eq $true)
{
List-Tests | Out-String
Expand Down
151 changes: 151 additions & 0 deletions WindowsAppRuntime.sln

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion build/AzurePipelinesTemplates/WindowsAppSDK-RunTests-Steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ steps:
inputs:
targetType: filePath
filePath: tools\DevCheck\DevCheck.ps1
arguments: -NoInteractive -Offline -Verbose -CheckTestPfx -Clean -CheckDependencies -ShowSystemInfo
arguments: -NoInteractive -Offline -Verbose -CheckTestPfx -Clean -CheckDependencies -CheckVisualStudio -ShowSystemInfo
workingDirectory: '$(Build.SourcesDirectory)'

- task: DownloadPipelineArtifact@2
Expand Down Expand Up @@ -147,6 +147,17 @@ steps:
Write-Host "WhoAmI"
Write-Host (whoami /user /groups /priv)

- task: PowerShell@2
displayName: 'Dump services'
inputs:
targetType: 'inline'
script: |
Get-Service
Get-Service | Write-Host
Get-Service | Out-Host
sc.exe queryex te.service | Write-Host
sc.exe qc te.service | Write-Host

- task: PowerShell@2
displayName: 'Run TAEF Tests'
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ steps:
inputs:
targetType: filePath
filePath: tools\DevCheck\DevCheck.ps1
arguments: -NoInteractive -Offline -Verbose -CheckTestPfx -Clean -CheckDependencies -ShowSystemInfo
arguments: -NoInteractive -Offline -Verbose -CheckTestPfx -Clean -CheckDependencies -CheckVisualStudio -ShowSystemInfo
workingDirectory: '$(Build.SourcesDirectory)'

- task: PowerShell@2
Expand Down
17 changes: 11 additions & 6 deletions dev/Common/IsWindowsVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,35 @@ inline bool IsExportPresent(

inline bool IsWindows10_19H1OrGreater()
{
// GetPackageInfo2() added to kernelbase.dll in NTDDI_WIN10_19H1 (aka 19H1)
// GetPackageInfo2() added to kernelbase.dll in 19H1 (aka NTDDI_WIN10_19H1)
return IsExportPresent(L"kernelbase.dll", "GetPackageInfo2");
}

inline bool IsWindows10_20H1OrGreater()
{
// GetPackageInfo3() added to kernelbase.dll in NTDDI_WIN10_VB (aka 20H1)
// GetPackageInfo3() added to kernelbase.dll in 20H1 (aka NTDDI_WIN10_VB)
return IsExportPresent(L"kernelbase.dll", "GetPackageInfo3");
}
inline bool IsWindows11_21H2OrGreater()
{
// GetMachineTypeAttributes() added to kernelbase.dll in NTDDI_WIN10_CO (aka Windows 11 21H2)
// GetMachineTypeAttributes() added to kernelbase.dll in Windows 11 21H2 (aka NTDDI_WIN10_CO)
return IsExportPresent(L"kernelbase.dll", "GetMachineTypeAttributes");
}
inline bool IsWindows11_22H2OrGreater()
{
// GetPackageGraphRevisionId() added to kernelbase.dll in NTDDI_WIN10_NI (aka Windows 11 22H2)
// GetPackageGraphRevisionId() added to kernelbase.dll in Windows 11 22H2 (aka NTDDI_WIN10_NI)
return IsExportPresent(L"kernelbase.dll", "GetPackageGraphRevisionId");
}
inline bool IsWindows11_23H1OrGreater()
inline bool IsWindows11_24H1OrGreater()
{
// TryCreatePackageDependency2() added to in NTDDI_WIN10_GE (aka Windows 11 23H1)
// TryCreatePackageDependency2() added to in Windows 11 24H1 (aka NTDDI_WIN11_GE)
return IsExportPresent(L"kernelbase.dll", "TryCreatePackageDependency2");
}
inline bool IsWindows11_24H2OrGreater()
{
// MsixIsPackageFeatureSupported() added to in Windows 11 24H2 (aka NTDDI_WIN11_GE)
return IsExportPresent(L"appxdeploymentclient.dll", "MsixIsPackageFeatureSupported");
}
}

#endif // __ISWINDOWSVERSION_H
49 changes: 37 additions & 12 deletions dev/DynamicDependency/API/MddWin11.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <MsixDynamicDependency.h>

#include <IsWindowsVersion.h>
#include <AppModel.Identity.h>

namespace MddCore::Win11
{
Expand Down Expand Up @@ -41,7 +42,7 @@ namespace MddCore::Win11
__declspec(selectany) HMODULE g_dllApisetAppmodelRuntime_1_7{};
//TODO:47775758 GetResolved2 __declspec(selectany) decltype(&::GetResolvedPackageFullNameForPackageDependency2) g_win11GetResolvedPackageFullNameForPackageDependency2{};

__declspec(selectany) bool g_isSupported{ WindowsVersion::IsWindows11_22H2OrGreater() };
__declspec(selectany) bool g_isSupported{ WindowsVersion::IsWindows11_24H1OrGreater() };

constexpr PackageDependencyLifetimeKind ToLifetimeKind(MddPackageDependencyLifetimeKind lifetimeKind)
{
Expand Down Expand Up @@ -95,18 +96,48 @@ namespace MddCore::Win11

inline bool IsSupported()
{
#if defined(TODO_WindowsAppSDKAggregator_Test_Failures)
return MddCore::Win11::details::g_isSupported;
#else
return false;
#endif
}

inline bool IsGetResolvedPackageFullNameForPackageDependency2Supported()
{
return IsSupported() && MddCore::Win11::details::g_dllApisetAppmodelRuntime_1_7;
}

constexpr PackageDependencyProcessorArchitectures GetPackageDependencyProcessorArchitecturesCompatibleWithCallerArchitecture()
{
#if defined(_M_ARM)
return PackageDependencyProcessorArchitectures_Arm | PackageDependencyProcessorArchitectures_Neutral;
#elif defined(_M_ARM64)
return PackageDependencyProcessorArchitectures_Arm64 | PackageDependencyProcessorArchitectures_Neutral;
#elif defined(_M_IX86)
return PackageDependencyProcessorArchitectures_X86 | PackageDependencyProcessorArchitectures_Neutral;
#elif defined(_M_X64)
return PackageDependencyProcessorArchitectures_X64 | PackageDependencyProcessorArchitectures_Neutral;
#else
# error "Unknown processor architecture"
#endif
}

constexpr PackageDependencyProcessorArchitectures ToPackageDependencyProcessorArchitectures(
const MddPackageDependencyProcessorArchitectures packageDependencyProcessorArchitectures)
{
if (packageDependencyProcessorArchitectures == MddPackageDependencyProcessorArchitectures::None)
{
// Workaround Windows bug (https://task.ms/54835001) that doesn't treat PackageDependencyProcessorArchitectures::None equivalent to caller-architecture + Neutral
return GetPackageDependencyProcessorArchitecturesCompatibleWithCallerArchitecture();
}

auto win11PackageDependencyProcessorArchitectures{ PackageDependencyProcessorArchitectures_None };
WI_SetFlagIf(win11PackageDependencyProcessorArchitectures, PackageDependencyProcessorArchitectures_Neutral, WI_IsFlagSet(packageDependencyProcessorArchitectures, MddPackageDependencyProcessorArchitectures::Neutral));
WI_SetFlagIf(win11PackageDependencyProcessorArchitectures, PackageDependencyProcessorArchitectures_X86, WI_IsFlagSet(packageDependencyProcessorArchitectures, MddPackageDependencyProcessorArchitectures::X86));
WI_SetFlagIf(win11PackageDependencyProcessorArchitectures, PackageDependencyProcessorArchitectures_X64, WI_IsFlagSet(packageDependencyProcessorArchitectures, MddPackageDependencyProcessorArchitectures::X64));
WI_SetFlagIf(win11PackageDependencyProcessorArchitectures, PackageDependencyProcessorArchitectures_Arm, WI_IsFlagSet(packageDependencyProcessorArchitectures, MddPackageDependencyProcessorArchitectures::Arm));
WI_SetFlagIf(win11PackageDependencyProcessorArchitectures, PackageDependencyProcessorArchitectures_Arm64, WI_IsFlagSet(packageDependencyProcessorArchitectures, MddPackageDependencyProcessorArchitectures::Arm64));
WI_SetFlagIf(win11PackageDependencyProcessorArchitectures, PackageDependencyProcessorArchitectures_X86A64, WI_IsFlagSet(packageDependencyProcessorArchitectures, MddPackageDependencyProcessorArchitectures::X86OnArm64));
return win11PackageDependencyProcessorArchitectures;
}

inline HRESULT TryCreatePackageDependency(
PSID user,
_In_ PCWSTR packageFamilyName,
Expand All @@ -119,13 +150,7 @@ namespace MddCore::Win11
{
const ::AppModel::Identity::PackageVersion win11MinVersion{ minVersion };

auto win11PackageDependencyProcessorArchitectures{ PackageDependencyProcessorArchitectures_None };
WI_SetFlagIf(win11PackageDependencyProcessorArchitectures, PackageDependencyProcessorArchitectures_Neutral, WI_IsFlagSet(packageDependencyProcessorArchitectures, MddPackageDependencyProcessorArchitectures::Neutral));
WI_SetFlagIf(win11PackageDependencyProcessorArchitectures, PackageDependencyProcessorArchitectures_X86, WI_IsFlagSet(packageDependencyProcessorArchitectures, MddPackageDependencyProcessorArchitectures::X86));
WI_SetFlagIf(win11PackageDependencyProcessorArchitectures, PackageDependencyProcessorArchitectures_X64, WI_IsFlagSet(packageDependencyProcessorArchitectures, MddPackageDependencyProcessorArchitectures::X64));
WI_SetFlagIf(win11PackageDependencyProcessorArchitectures, PackageDependencyProcessorArchitectures_Arm, WI_IsFlagSet(packageDependencyProcessorArchitectures, MddPackageDependencyProcessorArchitectures::Arm));
WI_SetFlagIf(win11PackageDependencyProcessorArchitectures, PackageDependencyProcessorArchitectures_Arm64, WI_IsFlagSet(packageDependencyProcessorArchitectures, MddPackageDependencyProcessorArchitectures::Arm64));
WI_SetFlagIf(win11PackageDependencyProcessorArchitectures, PackageDependencyProcessorArchitectures_X86A64, WI_IsFlagSet(packageDependencyProcessorArchitectures, MddPackageDependencyProcessorArchitectures::X86OnArm64));
auto win11PackageDependencyProcessorArchitectures{ ToPackageDependencyProcessorArchitectures(packageDependencyProcessorArchitectures) };

const auto win11LifetimeKind{ MddCore::Win11::details::ToLifetimeKind(lifetimeKind) };

Expand Down
2 changes: 1 addition & 1 deletion dev/MRTCore/mrt/Core/unittests/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.94.240624002" targetFramework="native" />
<package id="Microsoft.Taef" version="10.95.240918004" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.94.240624002" targetFramework="net45" />
<package id="Microsoft.Taef" version="10.95.240918004" targetFramework="net45" />
</packages>
2 changes: 1 addition & 1 deletion dev/MRTCore/mrt/mrm/UnitTests/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.240803.1" targetFramework="native" />
<package id="Microsoft.Taef" version="10.94.240624002" targetFramework="native" />
<package id="Microsoft.Taef" version="10.95.240918004" targetFramework="native" />
</packages>
33 changes: 30 additions & 3 deletions dev/PackageManager/API/M.W.M.D.PackageDeploymentManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,34 @@ static PackageManagement_ArchitectureType ToArchitectureType(const winrt::Window
}
}

static constexpr PackageManagement_ArchitectureType GetPackageManagementArchitectureTypesCompatibleWithCallerArchitecture()
{
#if defined(_M_ARM)
return PackageManagement_ArchitectureType_Arm | PackageManagement_ArchitectureType_Neutral;
#elif defined(_M_ARM64)
return PackageManagement_ArchitectureType_Arm64 | PackageManagement_ArchitectureType_Neutral;
#elif defined(_M_IX86)
return PackageManagement_ArchitectureType_X86 | PackageManagement_ArchitectureType_Neutral;
#elif defined(_M_X64)
return PackageManagement_ArchitectureType_X64 | PackageManagement_ArchitectureType_Neutral;
#else
# error "Unknown processor architecture"
#endif
}

namespace winrt::Microsoft::Windows::ApplicationModel::DynamicDependency
{
DEFINE_ENUM_FLAG_OPERATORS(PackageDependencyProcessorArchitectures)
}
static PackageManagement_ArchitectureType ToArchitectureType(const winrt::Microsoft::Windows::ApplicationModel::DynamicDependency::PackageDependencyProcessorArchitectures processorArchitectureFilter)
{
// Workaround bug in Windows https://task.ms/54835001 not handling processor architecture filter = None as "architcture(s) supported by the calling code"
// TODO: Use IsPackageDeploymentFeatureSupported(IsPackageReadyOrNewerAvailable_ProcessorArchitectureFilter_None) when available
if (processorArchitectureFilter == winrt::Microsoft::Windows::ApplicationModel::DynamicDependency::PackageDependencyProcessorArchitectures::None)
{
return GetPackageManagementArchitectureTypesCompatibleWithCallerArchitecture();
}

auto architectureType{ PackageManagement_ArchitectureType_None };
if (WI_IsFlagSet(processorArchitectureFilter, winrt::Microsoft::Windows::ApplicationModel::DynamicDependency::PackageDependencyProcessorArchitectures::Neutral))
{
Expand Down Expand Up @@ -119,9 +141,14 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
{
case winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature::PackageUriScheme_ms_uup:
{
//TODO Feature lookup
// Relies on PackageManagement_IsFeatureSupported(L"PackageUriScheme.ms-uup") exist in Microsoft.FrameworkUdk and enabled
return ::WindowsVersion::IsExportPresent(L"appxdeploymentclient.dll", "MsixRemovePackageByUriAsync");
BOOL isSupported{};
const HRESULT hr{ PackageManagement_IsFeatureSupported(L"PackageUriScheme.ms-uup", &isSupported) };
if (hr == E_NOTIMPL)
{
return false;
}
THROW_IF_FAILED_MSG(hr, "PackageUriScheme_ms_uup");
return !!isSupported;
DrusTheAxe marked this conversation as resolved.
Show resolved Hide resolved
}
case winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature::IsPackageReadyOrNewerAvailable:
{
Expand Down
46 changes: 38 additions & 8 deletions dev/UndockedRegFreeWinRT/urfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <activation.h>
#include <VersionHelpers.h>

#include <IsWindowsVersion.h>

#include "urfw.h"

#include "catalog.h"
Expand Down Expand Up @@ -58,18 +60,18 @@ static decltype(RoGetActivationFactory)* TrueRoGetActivationFactory = RoGetActiv
static decltype(RoGetMetaDataFile)* TrueRoGetMetaDataFile = RoGetMetaDataFile;
static decltype(RoResolveNamespace)* TrueRoResolveNamespace = RoResolveNamespace;

static bool g_apisAreDetoured{};

enum class ActivationLocation
{
CurrentApartment,
CrossApartmentMTA
};

VOID CALLBACK EnsureMTAInitializedCallBack
(
VOID CALLBACK EnsureMTAInitializedCallBack(
PTP_CALLBACK_INSTANCE /*instance*/,
PVOID /*parameter*/,
PTP_WORK /*work*/
)
PTP_WORK /*work*/)
{
Microsoft::WRL::ComPtr<IComThreadingInfo> spThreadingInfo;
CoGetObjectContext(IID_PPV_ARGS(&spThreadingInfo));
Expand Down Expand Up @@ -405,10 +407,34 @@ HRESULT ExtRoLoadCatalog()

HRESULT UrfwInitialize() noexcept
{
#if defined(TODO_URFW_DELEGATE_TO_OS_19H1PLUS)
// Windows' Reg-Free WinRT first appeared in Windows 10 Version 1903, May 2019 Update (aka 19H1)
// https://blogs.windows.com/windowsdeveloper/2019/04/30/enhancing-non-packaged-desktop-apps-using-windows-runtime-components/
// Delegate to the OS' implementation when available
if (WindowsVersion::IsWindows10_19H1OrGreater())
{
return S_OK;
}
#elif defined(TODO_SEEME_PRODUCT_TARGET)
// Delegate to the OS' implementation on >= Windows 11 24H1
if (WindowsVersion::IsWindows11_22H2OrGreater())
{
return S_OK;
}
#else
// Delegate to the OS' implementation on >= Windows 11 24H1
if (WindowsVersion::IsWindows11_24H1OrGreater())
{
return S_OK;
}
#endif

// OS Reg-Free WinRT isn't available so let's do it ourselves...
DetourAttach(&(PVOID&)TrueRoActivateInstance, RoActivateInstanceDetour);
DetourAttach(&(PVOID&)TrueRoGetActivationFactory, RoGetActivationFactoryDetour);
DetourAttach(&(PVOID&)TrueRoGetMetaDataFile, RoGetMetaDataFileDetour);
DetourAttach(&(PVOID&)TrueRoResolveNamespace, RoResolveNamespaceDetour);
g_apisAreDetoured = true;
try
{
RETURN_IF_FAILED(ExtRoLoadCatalog());
Expand All @@ -422,10 +448,14 @@ HRESULT UrfwInitialize() noexcept

void UrfwShutdown() noexcept
{
DetourDetach(&(PVOID&)TrueRoActivateInstance, RoActivateInstanceDetour);
DetourDetach(&(PVOID&)TrueRoGetActivationFactory, RoGetActivationFactoryDetour);
DetourDetach(&(PVOID&)TrueRoGetMetaDataFile, RoGetMetaDataFileDetour);
DetourDetach(&(PVOID&)TrueRoResolveNamespace, RoResolveNamespaceDetour);
if (g_apisAreDetoured)
{
DetourDetach(&(PVOID&)TrueRoActivateInstance, RoActivateInstanceDetour);
DetourDetach(&(PVOID&)TrueRoGetActivationFactory, RoGetActivationFactoryDetour);
DetourDetach(&(PVOID&)TrueRoGetMetaDataFile, RoGetMetaDataFileDetour);
DetourDetach(&(PVOID&)TrueRoResolveNamespace, RoResolveNamespaceDetour);
g_apisAreDetoured = false;
}
}

extern "C" void WINAPI winrtact_Initialize()
Expand Down
Loading
Loading