Skip to content

Commit 04c7ea4

Browse files
committed
Reapply "Delegate to OS RegFreeWinRT when available (>=24H1) (#4728)" (#4935)
This reverts commit c088336.
1 parent ff735c5 commit 04c7ea4

File tree

63 files changed

+455
-103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+455
-103
lines changed

build/AzurePipelinesTemplates/WindowsAppSDK-RunTests-Steps.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ steps:
1111
inputs:
1212
targetType: filePath
1313
filePath: tools\DevCheck\DevCheck.ps1
14-
arguments: -NoInteractive -Offline -Verbose -CheckTestPfx -Clean -CheckDependencies -ShowSystemInfo
14+
arguments: -NoInteractive -Offline -Verbose -CheckTestPfx -Clean -CheckDependencies -CheckVisualStudio -ShowSystemInfo
1515
workingDirectory: '$(Build.SourcesDirectory)'
1616

1717
- task: DownloadPipelineArtifact@2
@@ -147,6 +147,17 @@ steps:
147147
Write-Host "WhoAmI"
148148
Write-Host (whoami /user /groups /priv)
149149
150+
- task: PowerShell@2
151+
displayName: 'Dump services'
152+
inputs:
153+
targetType: 'inline'
154+
script: |
155+
Get-Service
156+
Get-Service | Write-Host
157+
Get-Service | Out-Host
158+
sc.exe queryex te.service | Write-Host
159+
sc.exe qc te.service | Write-Host
160+
150161
- task: PowerShell@2
151162
displayName: 'Run TAEF Tests'
152163
inputs:

build/AzurePipelinesTemplates/WindowsAppSDK-SetupBuildEnvironment-Steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ steps:
7272
inputs:
7373
targetType: filePath
7474
filePath: tools\DevCheck\DevCheck.ps1
75-
arguments: -NoInteractive -Offline -Verbose -CheckTestPfx -Clean -CheckDependencies -ShowSystemInfo
75+
arguments: -NoInteractive -Offline -Verbose -CheckTestPfx -Clean -CheckDependencies -CheckVisualStudio -ShowSystemInfo
7676
workingDirectory: '$(Build.SourcesDirectory)'
7777
7878
- task: PowerShell@2

dev/Common/IsWindowsVersion.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,35 @@ inline bool IsExportPresent(
3333

3434
inline bool IsWindows10_19H1OrGreater()
3535
{
36-
// GetPackageInfo2() added to kernelbase.dll in NTDDI_WIN10_19H1 (aka 19H1)
36+
// GetPackageInfo2() added to kernelbase.dll in 19H1 (aka NTDDI_WIN10_19H1)
3737
return IsExportPresent(L"kernelbase.dll", "GetPackageInfo2");
3838
}
3939

4040
inline bool IsWindows10_20H1OrGreater()
4141
{
42-
// GetPackageInfo3() added to kernelbase.dll in NTDDI_WIN10_VB (aka 20H1)
42+
// GetPackageInfo3() added to kernelbase.dll in 20H1 (aka NTDDI_WIN10_VB)
4343
return IsExportPresent(L"kernelbase.dll", "GetPackageInfo3");
4444
}
4545
inline bool IsWindows11_21H2OrGreater()
4646
{
47-
// GetMachineTypeAttributes() added to kernelbase.dll in NTDDI_WIN10_CO (aka Windows 11 21H2)
47+
// GetMachineTypeAttributes() added to kernelbase.dll in Windows 11 21H2 (aka NTDDI_WIN10_CO)
4848
return IsExportPresent(L"kernelbase.dll", "GetMachineTypeAttributes");
4949
}
5050
inline bool IsWindows11_22H2OrGreater()
5151
{
52-
// GetPackageGraphRevisionId() added to kernelbase.dll in NTDDI_WIN10_NI (aka Windows 11 22H2)
52+
// GetPackageGraphRevisionId() added to kernelbase.dll in Windows 11 22H2 (aka NTDDI_WIN10_NI)
5353
return IsExportPresent(L"kernelbase.dll", "GetPackageGraphRevisionId");
5454
}
55-
inline bool IsWindows11_23H1OrGreater()
55+
inline bool IsWindows11_24H1OrGreater()
5656
{
57-
// TryCreatePackageDependency2() added to in NTDDI_WIN10_GE (aka Windows 11 23H1)
57+
// TryCreatePackageDependency2() added to in Windows 11 24H1 (aka NTDDI_WIN11_GE)
5858
return IsExportPresent(L"kernelbase.dll", "TryCreatePackageDependency2");
5959
}
60+
inline bool IsWindows11_24H2OrGreater()
61+
{
62+
// MsixIsPackageFeatureSupported() added to in Windows 11 24H2 (aka NTDDI_WIN11_GE)
63+
return IsExportPresent(L"appxdeploymentclient.dll", "MsixIsPackageFeatureSupported");
64+
}
6065
}
6166

6267
#endif // __ISWINDOWSVERSION_H

dev/DynamicDependency/API/MddWin11.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace MddCore::Win11
4141
__declspec(selectany) HMODULE g_dllApisetAppmodelRuntime_1_7{};
4242
//TODO:47775758 GetResolved2 __declspec(selectany) decltype(&::GetResolvedPackageFullNameForPackageDependency2) g_win11GetResolvedPackageFullNameForPackageDependency2{};
4343

44-
__declspec(selectany) bool g_isSupported{ WindowsVersion::IsWindows11_22H2OrGreater() };
44+
__declspec(selectany) bool g_isSupported{ WindowsVersion::IsWindows11_24H1OrGreater() };
4545

4646
constexpr PackageDependencyLifetimeKind ToLifetimeKind(MddPackageDependencyLifetimeKind lifetimeKind)
4747
{
@@ -95,11 +95,7 @@ namespace MddCore::Win11
9595

9696
inline bool IsSupported()
9797
{
98-
#if defined(TODO_WindowsAppSDKAggregator_Test_Failures)
9998
return MddCore::Win11::details::g_isSupported;
100-
#else
101-
return false;
102-
#endif
10399
}
104100

105101
inline bool IsGetResolvedPackageFullNameForPackageDependency2Supported()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Taef" version="10.94.240624002" targetFramework="native" />
3+
<package id="Microsoft.Taef" version="10.95.240918004" targetFramework="native" />
44
</packages>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Taef" version="10.94.240624002" targetFramework="net45" />
3+
<package id="Microsoft.Taef" version="10.95.240918004" targetFramework="net45" />
44
</packages>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.240803.1" targetFramework="native" />
4-
<package id="Microsoft.Taef" version="10.94.240624002" targetFramework="native" />
4+
<package id="Microsoft.Taef" version="10.95.240918004" targetFramework="native" />
55
</packages>

dev/PackageManager/API/M.W.M.D.PackageDeploymentManager.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,14 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
119119
{
120120
case winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature::PackageUriScheme_ms_uup:
121121
{
122-
//TODO Feature lookup
123-
// Relies on PackageManagement_IsFeatureSupported(L"PackageUriScheme.ms-uup") exist in Microsoft.FrameworkUdk and enabled
124-
return ::WindowsVersion::IsExportPresent(L"appxdeploymentclient.dll", "MsixRemovePackageByUriAsync");
122+
BOOL isSupported{};
123+
const HRESULT hr{ PackageManagement_IsFeatureSupported(L"PackageUriScheme.ms-uup", &isSupported) };
124+
if (hr == E_NOTIMPL)
125+
{
126+
return false;
127+
}
128+
THROW_IF_FAILED_MSG(hr, "PackageUriScheme_ms_uup");
129+
return !!isSupported;
125130
}
126131
case winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature::IsPackageReadyOrNewerAvailable:
127132
{

dev/UndockedRegFreeWinRT/urfw.cpp

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <activation.h>
1010
#include <VersionHelpers.h>
1111

12+
#include <IsWindowsVersion.h>
13+
1214
#include "urfw.h"
1315

1416
#include "catalog.h"
@@ -58,18 +60,18 @@ static decltype(RoGetActivationFactory)* TrueRoGetActivationFactory = RoGetActiv
5860
static decltype(RoGetMetaDataFile)* TrueRoGetMetaDataFile = RoGetMetaDataFile;
5961
static decltype(RoResolveNamespace)* TrueRoResolveNamespace = RoResolveNamespace;
6062

63+
static bool g_apisAreDetoured{};
64+
6165
enum class ActivationLocation
6266
{
6367
CurrentApartment,
6468
CrossApartmentMTA
6569
};
6670

67-
VOID CALLBACK EnsureMTAInitializedCallBack
68-
(
71+
VOID CALLBACK EnsureMTAInitializedCallBack(
6972
PTP_CALLBACK_INSTANCE /*instance*/,
7073
PVOID /*parameter*/,
71-
PTP_WORK /*work*/
72-
)
74+
PTP_WORK /*work*/)
7375
{
7476
Microsoft::WRL::ComPtr<IComThreadingInfo> spThreadingInfo;
7577
CoGetObjectContext(IID_PPV_ARGS(&spThreadingInfo));
@@ -405,10 +407,34 @@ HRESULT ExtRoLoadCatalog()
405407

406408
HRESULT UrfwInitialize() noexcept
407409
{
410+
#if defined(TODO_URFW_DELEGATE_TO_OS_19H1PLUS)
411+
// Windows' Reg-Free WinRT first appeared in Windows 10 Version 1903, May 2019 Update (aka 19H1)
412+
// https://blogs.windows.com/windowsdeveloper/2019/04/30/enhancing-non-packaged-desktop-apps-using-windows-runtime-components/
413+
// Delegate to the OS' implementation when available
414+
if (WindowsVersion::IsWindows10_19H1OrGreater())
415+
{
416+
return S_OK;
417+
}
418+
#elif defined(TODO_SEEME_PRODUCT_TARGET)
419+
// Delegate to the OS' implementation on >= Windows 11 24H1
420+
if (WindowsVersion::IsWindows11_22H2OrGreater())
421+
{
422+
return S_OK;
423+
}
424+
#else
425+
// Delegate to the OS' implementation on >= Windows 11 24H1
426+
if (WindowsVersion::IsWindows11_24H1OrGreater())
427+
{
428+
return S_OK;
429+
}
430+
#endif
431+
432+
// OS Reg-Free WinRT isn't available so let's do it ourselves...
408433
DetourAttach(&(PVOID&)TrueRoActivateInstance, RoActivateInstanceDetour);
409434
DetourAttach(&(PVOID&)TrueRoGetActivationFactory, RoGetActivationFactoryDetour);
410435
DetourAttach(&(PVOID&)TrueRoGetMetaDataFile, RoGetMetaDataFileDetour);
411436
DetourAttach(&(PVOID&)TrueRoResolveNamespace, RoResolveNamespaceDetour);
437+
g_apisAreDetoured = true;
412438
try
413439
{
414440
RETURN_IF_FAILED(ExtRoLoadCatalog());
@@ -422,10 +448,14 @@ HRESULT UrfwInitialize() noexcept
422448

423449
void UrfwShutdown() noexcept
424450
{
425-
DetourDetach(&(PVOID&)TrueRoActivateInstance, RoActivateInstanceDetour);
426-
DetourDetach(&(PVOID&)TrueRoGetActivationFactory, RoGetActivationFactoryDetour);
427-
DetourDetach(&(PVOID&)TrueRoGetMetaDataFile, RoGetMetaDataFileDetour);
428-
DetourDetach(&(PVOID&)TrueRoResolveNamespace, RoResolveNamespaceDetour);
451+
if (g_apisAreDetoured)
452+
{
453+
DetourDetach(&(PVOID&)TrueRoActivateInstance, RoActivateInstanceDetour);
454+
DetourDetach(&(PVOID&)TrueRoGetActivationFactory, RoGetActivationFactoryDetour);
455+
DetourDetach(&(PVOID&)TrueRoGetMetaDataFile, RoGetMetaDataFileDetour);
456+
DetourDetach(&(PVOID&)TrueRoResolveNamespace, RoResolveNamespaceDetour);
457+
g_apisAreDetoured = false;
458+
}
429459
}
430460

431461
extern "C" void WINAPI winrtact_Initialize()

eng/Version.Dependencies.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<Dependency Name="Microsoft.Build.Tasks.Git" Version="1.1.1"/>
3030
<Dependency Name="Microsoft.SourceLink.Common" Version="1.1.1"/>
3131
<Dependency Name="Microsoft.SourceLink.GitHub" Version="1.1.1"/>
32-
<Dependency Name="Microsoft.Taef" Version="10.94.240624002"/>
32+
<Dependency Name="Microsoft.Taef" Version="10.95.240918004"/>
3333
<Dependency Name="Microsoft.Telemetry.Inbox.Native" Version="10.0.19041.1-191206-1406.vb-release.x86fre" />
3434
<Dependency Name="Microsoft.Windows.CppWinRT" Version="2.0.230706.1"/>
3535
<Dependency Name="Microsoft.Windows.ImplementationLibrary" Version="1.0.240803.1"/>

0 commit comments

Comments
 (0)