[Installer]Upgrade to Windows App SDK 1.1.0 (#18603)

* Move to WinAppSDK-1.1.0

* expect.txt

* Revert "[Settings]Don't launch if explorer is running elevated"

This reverts commit c485da2816.

* Make copyright header analyze suppression module scope
This commit is contained in:
Stefan Markovic 2022-06-05 00:30:34 +02:00 committed by GitHub
parent 29f0ae0395
commit 7a7d025956
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 118 additions and 83 deletions

View File

@ -388,6 +388,7 @@ DCOM
dcomp
DComposition
ddf
DDLM
Deact
debian
debugbreak
@ -1295,6 +1296,7 @@ MYTZ
NAMECHANGE
nameof
namespace
namespaceanddescendants
Navassa
NCACTIVATE
ncc

View File

@ -10,8 +10,8 @@
<?define Dotnet6PayloadSize="57791288"?>
<?define Dotnet6PayloadHash="B5B1819CCA753B070181F50411375B80412860A3"?>
<?define WinAppSDKPayloadSize="57090456"?>
<?define WinAppSDKPayloadHash="1269BB136655325EF6D66A018269BDAB3921E56B"?>
<?define WinAppSDKPayloadSize="59625472"?>
<?define WinAppSDKPayloadHash="8696DA7FE75464E8729FFB487A6E3A6247BC53D0"?>
<?define VCRedistDownloadUrl="https://download.visualstudio.microsoft.com/download/pr/6b6923b0-3045-4379-a96f-ef5506a65d5b/426A34C6F10EA8F7DA58A8C976B586AD84DD4BAB42A0CFDBE941F1763B7755E5/VC_redist.x64.exe"?>
<?define VCRedistPayloadSize="25337776"?>
@ -27,8 +27,8 @@
<?define Dotnet6PayloadSize="51774400"?>
<?define Dotnet6PayloadHash="62C15858951B123AFD4D3E14F8BE4829A7CAFF18"?>
<?define WinAppSDKPayloadSize="57092528"?>
<?define WinAppSDKPayloadHash="377ACE2157BE077C63C650588A18CBEFD93B5B51"?>
<?define WinAppSDKPayloadSize="59625472"?>
<?define WinAppSDKPayloadHash="29F1CD6782CF840C652343C9C718DFE9D155D2F3"?>
<?define VCRedistDownloadUrl="https://download.visualstudio.microsoft.com/download/pr/6b6923b0-3045-4379-a96f-ef5506a65d5b/6114C0A7A526EA47D9ADD78C718BEA0BA32EEF0826AA5610AF76877CC5FEB7F3/VC_redist.arm64.exe"?>
<?define VCRedistPayloadSize="11596400"?>
@ -110,18 +110,19 @@
UninstallCommand="/silent /uninstall">
</ExePackage>
<ExePackage
Name="WindowsAppRuntimeInstall-1.0.3.exe"
Name="WindowsAppRuntimeInstall-1.1.0.exe"
Compressed="no"
Id="WinAppSDK101"
DownloadUrl="https://aka.ms/windowsappsdk/1.0/1.0.3/windowsappruntimeinstall-1.0.3-$(var.PowerToysPlatform).exe"
Id="WinAppSDK110"
DownloadUrl="https://aka.ms/windowsappsdk/1.1/1.1.0/windowsappruntimeinstall-1.1.0-$(var.PowerToysPlatform).exe"
InstallCommand="--force"
RepairCommand=""
Permanent="yes">
<ExitCode Value="-2147009274" Behavior="success"/>
<RemotePayload
Description="Windows App SDK 1.0.3 Runtime Install"
ProductName="Windows App SDK 1.0.3 Runtime Install"
Description="Windows App SDK 1.1.0 Runtime Install"
ProductName="Windows App SDK 1.1.0 Runtime Install"
Size="$(var.WinAppSDKPayloadSize)"
Version="1.0.3.0"
Version="1.1.0.0"
Hash="$(var.WinAppSDKPayloadHash)" />
</ExePackage>
<ExePackage

View File

@ -83,7 +83,7 @@ namespace
inline bool GetDesktopAutomationObject(REFIID riid, void** ppv)
{
CComPtr<IShellView> spsv;
// Desktop may not be available on startup
auto attempts = 5;
for (auto i = 1; i <= attempts; i++)
@ -492,31 +492,4 @@ inline bool check_user_is_admin()
freeMemory(pSID, pGroupInfo);
return false;
}
inline bool is_process_of_window_elevated(HWND window)
{
DWORD pid = 0;
GetWindowThreadProcessId(window, &pid);
if (!pid)
{
return false;
}
wil::unique_handle hProcess{ OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION,
FALSE,
pid) };
wil::unique_handle token;
if (OpenProcessToken(hProcess.get(), TOKEN_QUERY, &token))
{
TOKEN_ELEVATION elevation;
DWORD size;
if (GetTokenInformation(token.get(), TokenElevation, &elevation, sizeof(elevation), &size))
{
return elevation.TokenIsElevated != 0;
}
}
return false;
}
}

View File

@ -3,11 +3,10 @@
#include <common/display/dpi_aware.h>
#include <common/logger/logger.h>
#include <common/utils/elevation.h>
#include <common/utils/excluded_apps.h>
#include <common/utils/process_path.h>
#include <common/utils/winapi_error.h>
#include <common/utils/window.h>
#include <common/utils/excluded_apps.h>
#include <FancyZonesLib/FancyZonesWindowProperties.h>
#include <FancyZonesLib/Settings.h>
@ -246,7 +245,30 @@ bool FancyZonesWindowUtils::IsCandidateForZoning(HWND window)
bool FancyZonesWindowUtils::IsProcessOfWindowElevated(HWND window)
{
return is_process_of_window_elevated(window);
DWORD pid = 0;
GetWindowThreadProcessId(window, &pid);
if (!pid)
{
return false;
}
wil::unique_handle hProcess{ OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION,
FALSE,
pid) };
wil::unique_handle token;
bool elevated = false;
if (OpenProcessToken(hProcess.get(), TOKEN_QUERY, &token))
{
TOKEN_ELEVATION elevation;
DWORD size;
if (GetTokenInformation(token.get(), TokenElevation, &elevation, sizeof(elevation), &size))
{
return elevation.TokenIsElevated != 0;
}
}
return false;
}
bool FancyZonesWindowUtils::IsExcludedByUser(const std::wstring& processPath) noexcept

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.0\build\native\Microsoft.WindowsAppSDK.props" Condition="Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.0\build\native\Microsoft.WindowsAppSDK.props')" />
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.props')" />
<Import Project="..\..\..\..\packages\Microsoft.WindowsAppSDK.1.0.3\build\native\Microsoft.WindowsAppSDK.props" Condition="Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.0.3\build\native\Microsoft.WindowsAppSDK.props')" />
<Import Project="..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.props')" />
<PropertyGroup Label="Globals">
<CppWinRTOptimized>true</CppWinRTOptimized>
@ -171,10 +171,10 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.WindowsAppSDK.1.0.3\build\native\Microsoft.WindowsAppSDK.targets" Condition="Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.0.3\build\native\Microsoft.WindowsAppSDK.targets')" />
<Import Project="..\..\..\..\packages\boost.1.79.0\build\boost.targets" Condition="Exists('..\..\..\..\packages\boost.1.79.0\build\boost.targets')" />
<Import Project="..\..\..\..\packages\boost_regex-vc143.1.79.0\build\boost_regex-vc143.targets" Condition="Exists('..\..\..\..\packages\boost_regex-vc143.1.79.0\build\boost_regex-vc143.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.0\build\native\Microsoft.WindowsAppSDK.targets" Condition="Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.0\build\native\Microsoft.WindowsAppSDK.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
@ -183,12 +183,12 @@
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.0.3\build\native\Microsoft.WindowsAppSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.WindowsAppSDK.1.0.3\build\native\Microsoft.WindowsAppSDK.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.0.3\build\native\Microsoft.WindowsAppSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.WindowsAppSDK.1.0.3\build\native\Microsoft.WindowsAppSDK.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\boost.1.79.0\build\boost.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\boost.1.79.0\build\boost.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\boost_regex-vc143.1.79.0\build\boost_regex-vc143.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\boost_regex-vc143.1.79.0\build\boost_regex-vc143.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.0\build\native\Microsoft.WindowsAppSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.0\build\native\Microsoft.WindowsAppSDK.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.0\build\native\Microsoft.WindowsAppSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.0\build\native\Microsoft.WindowsAppSDK.targets'))" />
</Target>
<Target Name="AddWildCardItems" AfterTargets="BuildGenerateSources">
<ItemGroup>

View File

@ -5,5 +5,5 @@
<package id="Microsoft.Windows.CppWinRT" version="2.0.220418.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220201.1" targetFramework="native" />
<package id="Microsoft.Windows.SDK.BuildTools" version="10.0.22000.197" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK" version="1.0.3" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK" version="1.1.0" targetFramework="native" />
</packages>

View File

@ -69,7 +69,6 @@ public:
IFACEMETHOD(GetSelected)(_Out_ bool* selected) = 0;
IFACEMETHOD(PutSelected)(_In_ bool selected) = 0;
IFACEMETHOD(GetId)(_Out_ int *id) = 0;
IFACEMETHOD(GetIconIndex)(_Out_ int* iconIndex) = 0;
IFACEMETHOD(GetDepth)(_Out_ UINT* depth) = 0;
IFACEMETHOD(PutDepth)(_In_ int depth) = 0;
IFACEMETHOD(ShouldRenameItem)(_In_ DWORD flags, _Out_ bool* shouldRename) = 0;

View File

@ -1,6 +1,5 @@
#include "pch.h"
#include "PowerRenameItem.h"
#include <common/themes/icon_helpers.h>
int CPowerRenameItem::s_id = 0;
@ -180,16 +179,6 @@ IFACEMETHODIMP CPowerRenameItem::GetId(_Out_ int* id)
return S_OK;
}
IFACEMETHODIMP CPowerRenameItem::GetIconIndex(_Out_ int* iconIndex)
{
if (m_iconIndex == -1)
{
GetIconIndexFromPath((PCWSTR)m_path, &m_iconIndex);
}
*iconIndex = m_iconIndex;
return S_OK;
}
IFACEMETHODIMP CPowerRenameItem::GetDepth(_Out_ UINT* depth)
{
*depth = m_depth;

View File

@ -27,7 +27,6 @@ public:
IFACEMETHODIMP GetSelected(_Out_ bool* selected);
IFACEMETHODIMP PutSelected(_In_ bool selected);
IFACEMETHODIMP GetId(_Out_ int* id);
IFACEMETHODIMP GetIconIndex(_Out_ int* iconIndex);
IFACEMETHODIMP GetDepth(_Out_ UINT* depth);
IFACEMETHODIMP PutDepth(_In_ int depth);
IFACEMETHODIMP Reset();

View File

@ -122,7 +122,4 @@
<data name="BUGREPORT_SUCCESS" xml:space="preserve">
<value>Bug report .zip file has been created on your Desktop.</value>
</data>
<data name="CANNOT_LAUNCH_SETTINGS_NONELEVATED" xml:space="preserve">
<value>Cannot start PowerToys.Settings process non-elevated, because explorer.exe process is elevated. Consider enabling UAC.</value>
</data>
</root>

View File

@ -11,7 +11,6 @@
#include "restart_elevated.h"
#include "UpdateUtils.h"
#include "centralized_kb_hook.h"
#include "Generated Files/resource.h"
#include <common/utils/json.h>
#include <common/SettingsAPI/settings_helpers.cpp>
@ -21,7 +20,6 @@
#include <common/utils/elevation.h>
#include <common/utils/process_path.h>
#include <common/utils/timeutil.h>
#include <common/utils/resources.h>
#include <common/utils/winapi_error.h>
#include <common/updating/updateState.h>
#include <common/themes/windows_colors.h>
@ -199,6 +197,67 @@ void receive_json_send_to_main_thread(const std::wstring& msg)
dispatch_run_on_main_ui_thread(dispatch_received_json_callback, copy);
}
// Try to run the Settings process with non-elevated privileges.
BOOL run_settings_non_elevated(LPCWSTR executable_path, LPWSTR executable_args, PROCESS_INFORMATION* process_info)
{
HWND hwnd = GetShellWindow();
if (!hwnd)
{
return false;
}
DWORD pid;
GetWindowThreadProcessId(hwnd, &pid);
winrt::handle process{ OpenProcess(PROCESS_CREATE_PROCESS, FALSE, pid) };
if (!process)
{
return false;
}
SIZE_T size = 0;
InitializeProcThreadAttributeList(nullptr, 1, 0, &size);
auto pproc_buffer = std::unique_ptr<char[]>{ new (std::nothrow) char[size] };
auto pptal = reinterpret_cast<PPROC_THREAD_ATTRIBUTE_LIST>(pproc_buffer.get());
if (!pptal)
{
return false;
}
if (!InitializeProcThreadAttributeList(pptal, 1, 0, &size))
{
return false;
}
if (!UpdateProcThreadAttribute(pptal,
0,
PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
&process,
sizeof(process),
nullptr,
nullptr))
{
return false;
}
STARTUPINFOEX siex = { 0 };
siex.lpAttributeList = pptal;
siex.StartupInfo.cb = sizeof(siex);
BOOL process_created = CreateProcessW(executable_path,
executable_args,
nullptr,
nullptr,
FALSE,
EXTENDED_STARTUPINFO_PRESENT,
nullptr,
nullptr,
&siex.StartupInfo,
process_info);
g_isLaunchInProgress = false;
return process_created;
}
DWORD g_settings_process_id = 0;
void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::optional<std::wstring> settings_window)
@ -296,24 +355,13 @@ void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::op
if (is_process_elevated())
{
const bool explorer_is_elevated = is_process_of_window_elevated(GetShellWindow());
if (explorer_is_elevated)
auto res = RunNonElevatedFailsafe(executable_path, executable_args, get_module_folderpath());
process_created = res.has_value();
if (process_created)
{
MessageBoxW(nullptr,
GET_RESOURCE_STRING(IDS_CANNOT_LAUNCH_SETTINGS_NONELEVATED).c_str(),
L"PowerToys",
MB_OK | MB_ICONERROR);
}
else
{
auto res = RunNonElevatedFailsafe(executable_path, executable_args, get_module_folderpath());
process_created = res.has_value();
if (process_created)
{
process_info.dwProcessId = res->processID;
process_info.hProcess = res->processHandle.release();
g_isLaunchInProgress = false;
}
process_info.dwProcessId = res->processID;
process_info.hProcess = res->processHandle.release();
g_isLaunchInProgress = false;
}
}

View File

@ -73,3 +73,8 @@ using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Not part of the project. WindowsAppSDK file.", Scope = "type", Target = "~T:Microsoft.WindowsAppSDK.Runtime.Packages.Singleton")]
[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1516:Elements should be separated by blank line", Justification = "Not part of the project. WindowsAppSDK file.", Scope = "type", Target = "~T:Microsoft.WindowsAppSDK.Runtime.Packages.Singleton")]
[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1516:Elements should be separated by blank line", Justification = "Not part of the project. WindowsAppSDK file.", Scope = "type", Target = "~T:Microsoft.WindowsAppSDK.Runtime.Packages.Main")]
[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1513:Closing brace should be followed by blank line", Justification = "Not part of the project. WindowsAppSDK file.", Scope = "namespaceanddescendants", Target = "Microsoft.WindowsAppSDK.Runtime.Packages")]
[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1516:Elements should be separated by blank line", Justification = "Not part of the project. WindowsAppSDK file.", Scope = "namespaceanddescendants", Target = "Microsoft.WindowsAppSDK.Runtime.Packages")]
[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1403:File may only contain a single namespace", Justification = "Not part of the project. WindowsAppSDK file.", Scope = "namespaceanddescendants", Target = "Microsoft.WindowsAppSDK.Runtime.Packages.DDLM")]
[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Not part of the project. WindowsAppSDK file.", Scope = "namespaceanddescendants", Target = "Microsoft.WindowsAppSDK.Runtime.Packages.DDLM")]
[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1636:File header copyright text should match", Justification = "Not part of the project. WindowsAppSDK file.", Scope = "module")]

View File

@ -56,7 +56,7 @@
<ItemGroup>
<PackageReference Include="CommunityToolkit.WinUI.UI" Version="7.1.2" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.3" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.0" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22000.194" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.8" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">