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

48525090 Delegate DynamicDependencies to OS API when available #4136

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
48 changes: 48 additions & 0 deletions WindowsAppRuntime.sln
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.Managemen
{B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UndockedRegFreeWinRT", "UndockedRegFreeWinRT", "{6FFE9EEB-E20C-427A-A3C9-1E48D6904E1E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "URFW_WinAppSDK", "test\UndockedRegFreeWinRT\URFW_WinAppSDK\URFW_WinAppSDK.vcxproj", "{E0BD4D47-AA5C-4354-961D-032E2AB612E1}"
ProjectSection(ProjectDependencies) = postProject
{14560FF9-B7AC-45B5-A120-2B49380B0D0D} = {14560FF9-B7AC-45B5-A120-2B49380B0D0D}
{B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "URFW_ExeUsingWinAppSDK", "test\UndockedRegFreeWinRT\URFW_ExeUsingWinAppSDK\URFW_ExeUsingWinAppSDK.vcxproj", "{14560FF9-B7AC-45B5-A120-2B49380B0D0D}"
ProjectSection(ProjectDependencies) = postProject
{B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -2402,6 +2415,38 @@ Global
{57E6CCBE-EDEB-4300-8334-98A591D11B3F}.Release|x64.Build.0 = Release|x64
{57E6CCBE-EDEB-4300-8334-98A591D11B3F}.Release|x86.ActiveCfg = Release|x86
{57E6CCBE-EDEB-4300-8334-98A591D11B3F}.Release|x86.Build.0 = Release|x86
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|Any CPU.ActiveCfg = Debug|x64
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|Any CPU.Build.0 = Debug|x64
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|ARM64.ActiveCfg = Debug|ARM64
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|ARM64.Build.0 = Debug|ARM64
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|x64.ActiveCfg = Debug|x64
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|x64.Build.0 = Debug|x64
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|x86.ActiveCfg = Debug|Win32
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|x86.Build.0 = Debug|Win32
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|Any CPU.ActiveCfg = Release|x64
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|Any CPU.Build.0 = Release|x64
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|ARM64.ActiveCfg = Release|ARM64
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|ARM64.Build.0 = Release|ARM64
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|x64.ActiveCfg = Release|x64
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|x64.Build.0 = Release|x64
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|x86.ActiveCfg = Release|Win32
{E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|x86.Build.0 = Release|Win32
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|Any CPU.ActiveCfg = Debug|x64
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|Any CPU.Build.0 = Debug|x64
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|ARM64.ActiveCfg = Debug|ARM64
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|ARM64.Build.0 = Debug|ARM64
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|x64.ActiveCfg = Debug|x64
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|x64.Build.0 = Debug|x64
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|x86.ActiveCfg = Debug|Win32
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|x86.Build.0 = Debug|Win32
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|Any CPU.ActiveCfg = Release|x64
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|Any CPU.Build.0 = Release|x64
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|ARM64.ActiveCfg = Release|ARM64
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|ARM64.Build.0 = Release|ARM64
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|x64.ActiveCfg = Release|x64
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|x64.Build.0 = Release|x64
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|x86.ActiveCfg = Release|Win32
{14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2612,6 +2657,9 @@ Global
{48948EF9-8B91-4F7A-98AD-0F8FA3EFAA38} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
{B5798CEB-4E60-4D2D-B456-7C406B5F5B67} = {48948EF9-8B91-4F7A-98AD-0F8FA3EFAA38}
{57E6CCBE-EDEB-4300-8334-98A591D11B3F} = {716C26A0-E6B0-4981-8412-D14A4D410531}
{6FFE9EEB-E20C-427A-A3C9-1E48D6904E1E} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
{E0BD4D47-AA5C-4354-961D-032E2AB612E1} = {6FFE9EEB-E20C-427A-A3C9-1E48D6904E1E}
{14560FF9-B7AC-45B5-A120-2B49380B0D0D} = {6FFE9EEB-E20C-427A-A3C9-1E48D6904E1E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4B3D7591-CFEC-4762-9A07-ABE99938FB77}
Expand Down
41 changes: 34 additions & 7 deletions dev/Common/IsWindowsVersion.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#ifndef __ISWINDOWSVERSION_H
Expand Down Expand Up @@ -31,30 +31,57 @@ inline bool IsExportPresent(
return true;
}

inline bool IsMinVersion(
uint64_t minVersion)
{
PCWSTR subkey{ L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" };
auto regkey{ wil::reg::open_unique_key(HKEY_LOCAL_MACHINE, subkey) };
const uint64_t major{ wil::reg::get_value_dword(regkey.get(), L"CurrentMajorVersionNumber") };
const uint64_t minor{ wil::reg::get_value_dword(regkey.get(), L"CurrentMinorVersionNumber") };
const std::wstring buildAsString{ wil::reg::get_value_string(regkey.get(), L"CurrentBuildNumber") };
const uint64_t build{ std::stoul(buildAsString.c_str(), nullptr, 10) };
const uint64_t revision{ wil::reg::get_value_dword(regkey.get(), L"BaseBuildRevisionNumber") };
const uint64_t version{ (major << 48) | (minor << 32) | (build << 16) | revision };
return version >= minVersion;
}

constexpr uint64_t ToVersion64(uint32_t major, uint32_t minor=0, uint32_t build=0, uint32_t revision=0)
{
return (static_cast<uint64_t>(major) << 48) |
(static_cast<uint64_t>(minor) << 32) |
(static_cast<uint64_t>(build) << 16) |
static_cast<uint64_t>(revision);
}

inline bool IsWindows10_19H1OrGreater()
{
// GetPackageInfo2() added to kernelbase.dll in NTDDI_WIN10_19H1 (aka 19H1)
// GetPackageInfo2() added to kernelbase.dll in NTDDI_WIN10_19H1 (aka Windows 10 19H1 aka 10.0.18363.0)
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 NTDDI_WIN10_VB (aka Windows 10 20H1 aka 10.0.19041.0)
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 NTDDI_WIN10_CO (aka Windows 11 21H2 aka 10.0.22021.0)
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 NTDDI_WIN10_NI (aka Windows 11 22H2 aka 10.0.22621.0)
return IsExportPresent(L"kernelbase.dll", "GetPackageGraphRevisionId");
}
inline bool IsWindows11_23H1OrGreater()
inline bool IsWindows11_23H2OrGreater()
{
// No good symbol to probe so version check (Windows 11 23H2 aka 10.0.22631.0)
return IsMinVersion(ToVersion64(10, 0, 22631, 0));
}
inline bool IsWindows11_24H2OrGreater()
{
// TryCreatePackageDependency2() added to in NTDDI_WIN10_GE (aka Windows 11 23H1)
// TryCreatePackageDependency2() added to in NTDDI_WIN10_GE (aka Windows 11 24H2 aka TBD)
return IsExportPresent(L"api-ms-win-appmodel-runtime-l1-1-7.dll", "TryCreatePackageDependency2");
}
}
Expand Down
4 changes: 2 additions & 2 deletions dev/Common/Security.IntegrityLevel.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#ifndef __SECURITY_INTEGRITYLEVEL_H
Expand All @@ -8,7 +8,7 @@ namespace Security::IntegrityLevel
{
inline DWORD GetIntegrityLevel(HANDLE token = nullptr)
{
wistd::unique_ptr<TOKEN_MANDATORY_LABEL> tokenMandatoryLabel{
auto tokenMandatoryLabel{
wil::get_token_information_failfast<TOKEN_MANDATORY_LABEL>(
!token ? GetCurrentThreadEffectiveToken() : token) };
return *GetSidSubAuthority((*tokenMandatoryLabel).Label.Sid,
Expand Down
4 changes: 2 additions & 2 deletions dev/Common/Security.User.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#ifndef __SECURITY_USER_H
Expand All @@ -13,7 +13,7 @@ inline bool IsLocalSystem(HANDLE token = nullptr)
DWORD localSystemSidBufferSize{ ARRAYSIZE(localSystemSidBuffer) };
THROW_IF_WIN32_BOOL_FALSE(CreateWellKnownSid(WinLocalSystemSid, nullptr, localSystemSid, &localSystemSidBufferSize));

wistd::unique_ptr<TOKEN_USER> user{ wil::get_token_information<TOKEN_USER>(!token ? GetCurrentThreadEffectiveToken() : token) };
const auto user{ wil::get_token_information<TOKEN_USER>(!token ? GetCurrentThreadEffectiveToken() : token) };
PSID userSid{ user->User.Sid };

return !!EqualSid(userSid, localSystemSid);
Expand Down
4 changes: 2 additions & 2 deletions dev/Common/WindowsAppRuntime.VersionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ STDAPI WindowsAppRuntime_VersionInfo_TestInitialize(
const bool mainPackageFamilyNameIsEmpty{ !mainPackageFamilyName || (*mainPackageFamilyName == L'0') };
if (MddCore::Win11::IsSupported())
{
// Framework is optional but Main is never specified
FAIL_FAST_HR_IF(E_UNEXPECTED, !mainPackageFamilyNameIsEmpty);
// Framework is optional but Main is never used
mainPackageFamilyName = nullptr;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion dev/DeploymentAgent/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.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.240122.1" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion dev/Kozani/KozaniAppGraph/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<package id="Microsoft.SourceLink.Common" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.240122.1" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion dev/Kozani/KozaniHostRuntime/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<package id="Microsoft.SourceLink.Common" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.240122.1" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion dev/Kozani/KozaniManager/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<package id="Microsoft.SourceLink.Common" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.240122.1" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK.Protobuf" version="3.21.12" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion dev/Kozani/KozaniManagerRuntime/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<package id="Microsoft.SourceLink.Common" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.240122.1" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion dev/Kozani/KozaniPackage/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<package id="Microsoft.SourceLink.Common" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.240122.1" targetFramework="native" />
</packages>
Loading