diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index 09ecd4e4a8..9c2069bf9a 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -278,6 +278,8 @@ CTEXT Ctl CTest CTEXT +CTest +CTEXT CTLCOLORSTATIC currentculture CURRENTDIR @@ -1195,6 +1197,8 @@ OWNERDRAWFIXED OWRj OWNDC OWNERDRAWFIXED +OWNDC +OWNERDRAWFIXED Packagemanager PACL PAINTSTRUCT @@ -1408,6 +1412,7 @@ regkey regroot REINSTALLMODE reloadable +Relogger remappings REMAPRUNDLL REMAPSUCCESSFUL @@ -1742,6 +1747,7 @@ TIcon TILEDWINDOW TILEINFO TILEDWINDOW +TILEDWINDOW TILLSON timedate timediff diff --git a/.pipelines/v2/templates/job-build-project.yml b/.pipelines/v2/templates/job-build-project.yml index e360e6aeb7..76fd5acaad 100644 --- a/.pipelines/v2/templates/job-build-project.yml +++ b/.pipelines/v2/templates/job-build-project.yml @@ -198,13 +198,13 @@ jobs: "packages.config" | "$(Agent.OS)" "packages.config" path: packages - + - ${{ if eq(parameters.useLatestWinAppSDK, true)}}: - template: .\steps-update-winappsdk-and-restore-nuget.yml parameters: versionNumber: ${{ parameters.winAppSDKVersionNumber }} useExperimentalVersion: ${{ parameters.useExperimentalVersion }} - + - ${{ if eq(parameters.useLatestWinAppSDK, false)}}: - template: .\steps-restore-nuget.yml diff --git a/.pipelines/verifyDepsJsonLibraryVersions.ps1 b/.pipelines/verifyDepsJsonLibraryVersions.ps1 index 69d9de84ae..7a7dbd5b81 100644 --- a/.pipelines/verifyDepsJsonLibraryVersions.ps1 +++ b/.pipelines/verifyDepsJsonLibraryVersions.ps1 @@ -46,10 +46,11 @@ Get-ChildItem $targetDir -Recurse -Filter *.deps.json -Exclude UITests-FancyZone $dllName = Split-Path $_.Name -leaf if([bool]($_.Value.PSObject.Properties.name -match 'fileVersion')) { $dllFileVersion = $_.Value.fileVersion - if ([string]::IsNullOrEmpty($dllFileVersion) -and $dllName.StartsWith('PowerToys.'))` { + if (([string]::IsNullOrEmpty($dllFileVersion) -or ($dllFileVersion -eq '0.0.0.0')) -and $dllName.StartsWith('PowerToys.'))` { # After VS 17.11 update some of PowerToys dlls have no fileVersion in deps.json even though the # version is correctly set. This is a workaround to skip our dlls as we are confident that all of # our dlls share the same version across the dependencies. + # After VS 17.13 these error versions started appearing as 0.0.0.0 so we've added that case to the condition as well. continue } diff --git a/.pipelines/versionAndSignCheck.ps1 b/.pipelines/versionAndSignCheck.ps1 index 077c15ff69..e941aa7efe 100644 --- a/.pipelines/versionAndSignCheck.ps1 +++ b/.pipelines/versionAndSignCheck.ps1 @@ -19,6 +19,7 @@ $versionExceptions = @( "Microsoft.Xaml.Interactions.dll", "Microsoft.Xaml.Interactivity.dll", "hyjiacan.py4n.dll", + "TraceReloggerLib.dll", "Microsoft.WindowsAppRuntime.Release.Net.dll", "Microsoft.Windows.Widgets.Projection.dll", "WinRT.Host.Shim.dll", @@ -64,6 +65,11 @@ if ($items.Count -eq 0) { } $items | ForEach-Object { + if ($_.VersionInfo.FileVersion -eq "0.0.0.0" -and $_.Name -notmatch $versionExceptions) { + # These items are exceptions that actually have the 0.0.0.0 version. + Write-Host "Version set to 0.0.0.0: " + $_.FullName + $totalFailure++; + } if ($_.VersionInfo.FileVersion -eq "1.0.0.0" -and $_.Name -notmatch $versionExceptions) { # These items are exceptions that actually have the 1.0.0.0 version. Write-Host "Version set to 1.0.0.0: " + $_.FullName diff --git a/Directory.Packages.props b/Directory.Packages.props index 6b2888838e..5a367211d4 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -31,24 +31,23 @@ - - + - + - - - - - + + + + + - + - + - + - - - + + + - + - - + + - + - - - - + + + + diff --git a/NOTICE.md b/NOTICE.md index 6ece6109c7..0a783dc510 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -1324,22 +1324,22 @@ EXHIBIT A -Mozilla Public License. - Mages 3.0.0 - Markdig.Signed 0.34.0 - MessagePack 2.5.187 -- Microsoft.Bcl.AsyncInterfaces 9.0.1 +- Microsoft.Bcl.AsyncInterfaces 9.0.2 - Microsoft.CodeAnalysis.NetAnalyzers 9.0.0 -- Microsoft.Data.Sqlite 9.0.1 +- Microsoft.Data.Sqlite 9.0.2 - Microsoft.Diagnostics.Tracing.TraceEvent 3.1.16 - Microsoft.DotNet.ILCompiler (A) -- Microsoft.Extensions.DependencyInjection 9.0.1 -- Microsoft.Extensions.Hosting 9.0.1 -- Microsoft.Extensions.Hosting.WindowsServices 9.0.1 -- Microsoft.Extensions.Logging 9.0.1 -- Microsoft.Extensions.Logging.Abstractions 9.0.1 +- Microsoft.Extensions.DependencyInjection 9.0.2 +- Microsoft.Extensions.Hosting 9.0.2 +- Microsoft.Extensions.Hosting.WindowsServices 9.0.2 +- Microsoft.Extensions.Logging 9.0.2 +- Microsoft.Extensions.Logging.Abstractions 9.0.2 - Microsoft.NET.ILLink.Tasks (A) - Microsoft.SemanticKernel 1.15.0 - Microsoft.Toolkit.Uwp.Notifications 7.1.2 - Microsoft.Web.WebView2 1.0.2903.40 -- Microsoft.Win32.SystemEvents 9.0.1 -- Microsoft.Windows.Compatibility 9.0.1 +- Microsoft.Win32.SystemEvents 9.0.2 +- Microsoft.Windows.Compatibility 9.0.2 - Microsoft.Windows.CsWin32 0.2.46-beta - Microsoft.Windows.CsWinRT 2.1.5 - Microsoft.Windows.SDK.BuildTools 10.0.22621.2428 @@ -1358,25 +1358,25 @@ EXHIBIT A -Mozilla Public License. - SharpCompress 0.37.2 - StreamJsonRpc 2.19.27 - StyleCop.Analyzers 1.2.0-beta.556 -- System.CodeDom 9.0.1 +- System.CodeDom 9.0.2 - System.CommandLine 2.0.0-beta4.22272.1 -- System.ComponentModel.Composition 9.0.1 -- System.Configuration.ConfigurationManager 9.0.1 -- System.Data.OleDb 9.0.1 +- System.ComponentModel.Composition 9.0.2 +- System.Configuration.ConfigurationManager 9.0.2 +- System.Data.OleDb 9.0.2 - System.Data.SqlClient 4.8.6 -- System.Diagnostics.EventLog 9.0.1 -- System.Diagnostics.PerformanceCounter 9.0.1 -- System.Drawing.Common 9.0.1 +- System.Diagnostics.EventLog 9.0.2 +- System.Diagnostics.PerformanceCounter 9.0.2 +- System.Drawing.Common 9.0.2 - System.IO.Abstractions 21.0.29 - System.IO.Abstractions.TestingHelpers 21.0.29 -- System.Management 9.0.1 +- System.Management 9.0.2 - System.Net.Http 4.3.4 - System.Private.Uri 4.3.2 - System.Reactive 6.0.1 -- System.Runtime.Caching 9.0.1 -- System.ServiceProcess.ServiceController 9.0.1 -- System.Text.Encoding.CodePages 9.0.1 -- System.Text.Json 9.0.1 +- System.Runtime.Caching 9.0.2 +- System.ServiceProcess.ServiceController 9.0.2 +- System.Text.Encoding.CodePages 9.0.2 +- System.Text.Json 9.0.2 - System.Text.RegularExpressions 4.3.1 - UnicodeInformation 2.6.0 - UnitsNet 5.56.0 diff --git a/doc/devdocs/settingsv2/runner-ipc.md b/doc/devdocs/settingsv2/runner-ipc.md index 465362fb19..c0e9d0be79 100644 --- a/doc/devdocs/settingsv2/runner-ipc.md +++ b/doc/devdocs/settingsv2/runner-ipc.md @@ -3,8 +3,8 @@ The Settings v2 process uses two way IPC to communicate with the runner process. ## Initialization -- On the settings' side, the two way IPC delegates are contained with the [`ShellPage.xaml.cs`](/src/settings-ui/Settings.UI/Views/ShellPage.xaml.cs) file. The delegates are static and the views for all the powerToys send the ipc information to the viewmodels as `ShellPage.DefaultSndMSGCallBack`. -- These delegates are initialized within the [`MainWindow.xaml.cs`](/src/settings-ui/Settings.UI/MainWindow.xaml.cs) file in the `Settings.Runner` project. +- On the settings' side, the two way IPC delegates are contained with the [`ShellPage.xaml.cs`](/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs) file. The delegates are static and the views for all the powerToys send the ipc information to the viewmodels as `ShellPage.DefaultSndMSGCallBack`. +- These delegates are initialized within the [`MainWindow.xaml.cs`](/src/settings-ui/Settings.UI/SettingsXAML/MainWindow.xaml.cs) file in the `Settings.Runner` project. ## Types of IPC delegates @@ -14,12 +14,12 @@ The Settings v2 process uses two way IPC to communicate with the runner process. 3. `CheckForUpdates` ## Sending information to runner -- The settings process communicates with the runner by using the delegates defined within the [`ShellPage.xaml.cs`](/src/settings-ui/Settings.UI/Views/ShellPage.xaml.cs) file. +- The settings process communicates with the runner by using the delegates defined within the [`ShellPage.xaml.cs`](/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs) file. - Depending on the type of object sending the information, the json is created accordingly. - If any information has been modified by the user in the GeneralSettings page, then the json file sent to the runner has the name set to `general`, whereas if any information has been modified by the user in any powertoy related settings page, the name of the json file being communicated with the runner is set to `powertoy`. ## Receiving information from runner -- The `ShellPage`object has a `IPCResponseHandleList` which is a list of functions which handle IPC responses. +- The `ShellPage` object has a `IPCResponseHandleList` which is a list of functions which handle IPC responses. ```csharp // receive IPC Message @@ -43,4 +43,4 @@ Program.IPCMessageReceivedCallback = (string msg) => ``` - Whenever any information is sent from the runner each of the functions in the handle list perform their action on that json object. -- One example of where information sent from the runner is being processed by the settings is in [`GeneralPage.xaml.cs`](/src/settings-ui/Settings.UI/Views/GeneralPage.xaml.cs) when the user clicks the check for updates button. The information displayed after, such as the user has the latest version installed is a result of this handle. +- One example of where information sent from the runner is being processed by the settings is in [`GeneralPage.xaml.cs`](/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs) when the user clicks the check for updates button. The information displayed after, such as the user has the latest version installed is a result of this handle. diff --git a/installer/PowerToysSetupCustomActions/CustomAction.cpp b/installer/PowerToysSetupCustomActions/CustomAction.cpp index 5473fffbf0..6ddc7a644b 100644 --- a/installer/PowerToysSetupCustomActions/CustomAction.cpp +++ b/installer/PowerToysSetupCustomActions/CustomAction.cpp @@ -38,11 +38,11 @@ TRACELOGGING_DEFINE_PROVIDER( const DWORD USERNAME_DOMAIN_LEN = DNLEN + UNLEN + 2; // Domain Name + '\' + User Name + '\0' const DWORD USERNAME_LEN = UNLEN + 1; // User Name + '\0' -static const wchar_t* POWERTOYS_EXE_COMPONENT = L"{A2C66D91-3485-4D00-B04D-91844E6B345B}"; -static const wchar_t* POWERTOYS_UPGRADE_CODE = L"{42B84BF7-5FBF-473B-9C8B-049DC16F7708}"; +static const wchar_t *POWERTOYS_EXE_COMPONENT = L"{A2C66D91-3485-4D00-B04D-91844E6B345B}"; +static const wchar_t *POWERTOYS_UPGRADE_CODE = L"{42B84BF7-5FBF-473B-9C8B-049DC16F7708}"; -constexpr inline const wchar_t* DataDiagnosticsRegKey = L"Software\\Classes\\PowerToys"; -constexpr inline const wchar_t* DataDiagnosticsRegValueName = L"AllowDataDiagnostics"; +constexpr inline const wchar_t *DataDiagnosticsRegKey = L"Software\\Classes\\PowerToys"; +constexpr inline const wchar_t *DataDiagnosticsRegValueName = L"AllowDataDiagnostics"; #define TraceLoggingWriteWrapper(provider, eventName, ...) \ if (isDataDiagnosticEnabled()) \ @@ -53,16 +53,16 @@ constexpr inline const wchar_t* DataDiagnosticsRegValueName = L"AllowDataDiagnos trace.UpdateState(false); \ } -static Shared::Trace::ETWTrace trace{ L"PowerToys_Installer" }; +static Shared::Trace::ETWTrace trace{L"PowerToys_Installer"}; inline bool isDataDiagnosticEnabled() { HKEY key{}; if (RegOpenKeyExW(HKEY_CURRENT_USER, - DataDiagnosticsRegKey, - 0, - KEY_READ, - &key) != ERROR_SUCCESS) + DataDiagnosticsRegKey, + 0, + KEY_READ, + &key) != ERROR_SUCCESS) { return false; } @@ -71,13 +71,13 @@ inline bool isDataDiagnosticEnabled() DWORD size = sizeof(isDataDiagnosticsEnabled); if (RegGetValueW( - HKEY_CURRENT_USER, - DataDiagnosticsRegKey, - DataDiagnosticsRegValueName, - RRF_RT_REG_DWORD, - nullptr, - &isDataDiagnosticsEnabled, - &size) != ERROR_SUCCESS) + HKEY_CURRENT_USER, + DataDiagnosticsRegKey, + DataDiagnosticsRegValueName, + RRF_RT_REG_DWORD, + nullptr, + &isDataDiagnosticsEnabled, + &size) != ERROR_SUCCESS) { RegCloseKey(key); return false; @@ -87,7 +87,7 @@ inline bool isDataDiagnosticEnabled() return isDataDiagnosticsEnabled == 1; } -HRESULT getInstallFolder(MSIHANDLE hInstall, std::wstring& installationDir) +HRESULT getInstallFolder(MSIHANDLE hInstall, std::wstring &installationDir) { DWORD len = 0; wchar_t _[1]; @@ -116,13 +116,13 @@ BOOL IsLocalSystem() // open process token if (!OpenProcessToken(GetCurrentProcess(), - TOKEN_QUERY, - &hToken)) + TOKEN_QUERY, + &hToken)) return FALSE; // retrieve user SID if (!GetTokenInformation(hToken, TokenUser, pTokenUser, - sizeof(bTokenUser), &cbTokenUser)) + sizeof(bTokenUser), &cbTokenUser)) { CloseHandle(hToken); return FALSE; @@ -132,7 +132,7 @@ BOOL IsLocalSystem() // allocate LocalSystem well-known SID if (!AllocateAndInitializeSid(&siaNT, 1, SECURITY_LOCAL_SYSTEM_RID, - 0, 0, 0, 0, 0, 0, 0, &pSystemSid)) + 0, 0, 0, 0, 0, 0, 0, &pSystemSid)) return FALSE; // compare the user SID from the token with the LocalSystem SID @@ -194,7 +194,7 @@ static std::filesystem::path GetUserPowerShellModulesPath() if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Documents, 0, NULL, &myDocumentsBlockPtr))) { - const std::wstring myDocuments{ myDocumentsBlockPtr }; + const std::wstring myDocuments{myDocumentsBlockPtr}; CoTaskMemFree(myDocumentsBlockPtr); return std::filesystem::path(myDocuments) / "PowerShell" / "Modules"; } @@ -231,37 +231,37 @@ UINT __stdcall LaunchPowerToysCA(MSIHANDLE hInstall) { auto action = [&commandLine](HANDLE userToken) + { + STARTUPINFO startupInfo{.cb = sizeof(STARTUPINFO), .wShowWindow = SW_SHOWNORMAL}; + PROCESS_INFORMATION processInformation; + + PVOID lpEnvironment = NULL; + CreateEnvironmentBlock(&lpEnvironment, userToken, FALSE); + + CreateProcessAsUser( + userToken, + NULL, + commandLine.data(), + NULL, + NULL, + FALSE, + CREATE_DEFAULT_ERROR_MODE | CREATE_UNICODE_ENVIRONMENT, + lpEnvironment, + NULL, + &startupInfo, + &processInformation); + + if (!CloseHandle(processInformation.hProcess)) { - STARTUPINFO startupInfo{ .cb = sizeof(STARTUPINFO), .wShowWindow = SW_SHOWNORMAL }; - PROCESS_INFORMATION processInformation; + return false; + } + if (!CloseHandle(processInformation.hThread)) + { + return false; + } - PVOID lpEnvironment = NULL; - CreateEnvironmentBlock(&lpEnvironment, userToken, FALSE); - - CreateProcessAsUser( - userToken, - NULL, - commandLine.data(), - NULL, - NULL, - FALSE, - CREATE_DEFAULT_ERROR_MODE | CREATE_UNICODE_ENVIRONMENT, - lpEnvironment, - NULL, - &startupInfo, - &processInformation); - - if (!CloseHandle(processInformation.hProcess)) - { - return false; - } - if (!CloseHandle(processInformation.hThread)) - { - return false; - } - - return true; - }; + return true; + }; if (!ImpersonateLoggedInUserAndDoSomething(action)) { @@ -271,7 +271,7 @@ UINT __stdcall LaunchPowerToysCA(MSIHANDLE hInstall) } else { - STARTUPINFO startupInfo{ .cb = sizeof(STARTUPINFO), .wShowWindow = SW_SHOWNORMAL }; + STARTUPINFO startupInfo{.cb = sizeof(STARTUPINFO), .wShowWindow = SW_SHOWNORMAL}; PROCESS_INFORMATION processInformation; @@ -315,7 +315,7 @@ UINT __stdcall CheckGPOCA(MSIHANDLE hInstall) LPWSTR currentScope = nullptr; hr = WcaGetProperty(L"InstallScope", ¤tScope); - if (std::wstring{ currentScope } == L"perUser") + if (std::wstring{currentScope} == L"perUser") { if (powertoys_gpo::getDisablePerUserInstallationValue() == powertoys_gpo::gpo_rule_configured_enabled) { @@ -356,7 +356,7 @@ UINT __stdcall ApplyModulesRegistryChangeSetsCA(MSIHANDLE hInstall) hr = getInstallFolder(hInstall, installationFolder); ExitOnFailure(hr, "Failed to get installFolder."); - for (const auto& changeSet : getAllOnByDefaultModulesChangeSets(installationFolder)) + for (const auto &changeSet : getAllOnByDefaultModulesChangeSets(installationFolder)) { if (!changeSet.apply()) { @@ -384,7 +384,7 @@ UINT __stdcall UnApplyModulesRegistryChangeSetsCA(MSIHANDLE hInstall) ExitOnFailure(hr, "Failed to initialize"); hr = getInstallFolder(hInstall, installationFolder); ExitOnFailure(hr, "Failed to get installFolder."); - for (const auto& changeSet : getAllModulesChangeSets(installationFolder)) + for (const auto &changeSet : getAllModulesChangeSets(installationFolder)) { changeSet.unApply(); } @@ -398,8 +398,8 @@ LExit: return WcaFinalize(er); } -const wchar_t* DSC_CONFIGURE_PSD1_NAME = L"Microsoft.PowerToys.Configure.psd1"; -const wchar_t* DSC_CONFIGURE_PSM1_NAME = L"Microsoft.PowerToys.Configure.psm1"; +const wchar_t *DSC_CONFIGURE_PSD1_NAME = L"Microsoft.PowerToys.Configure.psd1"; +const wchar_t *DSC_CONFIGURE_PSM1_NAME = L"Microsoft.PowerToys.Configure.psm1"; UINT __stdcall InstallDSCModuleCA(MSIHANDLE hInstall) { @@ -431,7 +431,7 @@ UINT __stdcall InstallDSCModuleCA(MSIHANDLE hInstall) ExitOnFailure(hr, "Unable to create Powershell modules folder"); } - for (const auto* filename : { DSC_CONFIGURE_PSD1_NAME, DSC_CONFIGURE_PSM1_NAME }) + for (const auto *filename : {DSC_CONFIGURE_PSD1_NAME, DSC_CONFIGURE_PSM1_NAME}) { fs::copy_file(fs::path(installationFolder) / "DSCModules" / filename, modulesPath / filename, fs::copy_options::overwrite_existing, errorCode); @@ -479,7 +479,7 @@ UINT __stdcall UninstallDSCModuleCA(MSIHANDLE hInstall) std::error_code errorCode; - for (const auto* filename : { DSC_CONFIGURE_PSD1_NAME, DSC_CONFIGURE_PSM1_NAME }) + for (const auto *filename : {DSC_CONFIGURE_PSD1_NAME, DSC_CONFIGURE_PSM1_NAME}) { fs::remove(versionedModulePath / filename, errorCode); @@ -490,7 +490,7 @@ UINT __stdcall UninstallDSCModuleCA(MSIHANDLE hInstall) } } - for (const auto* modulePath : { &versionedModulePath, &powerToysModulePath }) + for (const auto *modulePath : {&versionedModulePath, &powerToysModulePath}) { fs::remove(*modulePath, errorCode); @@ -537,7 +537,7 @@ UINT __stdcall InstallEmbeddedMSIXCA(MSIHANDLE hInstall) using namespace winrt::Windows::Management::Deployment; using namespace winrt::Windows::Foundation; - Uri msix_uri{ msix_path.wstring() }; + Uri msix_uri{msix_path.wstring()}; PackageManager pm; auto result = pm.AddPackageAsync(msix_uri, nullptr, DeploymentOptions::None).get(); if (!result) @@ -571,7 +571,7 @@ UINT __stdcall UninstallEmbeddedMSIXCA(MSIHANDLE hInstall) hr = WcaInitialize(hInstall, "UninstallEmbeddedMSIXCA"); ExitOnFailure(hr, "Failed to initialize"); - for (const auto& p : pm.FindPackagesForUser({}, package_name, publisher)) + for (const auto &p : pm.FindPackagesForUser({}, package_name, publisher)) { auto result = pm.RemovePackageAsync(p.Id().FullName()).get(); if (result) @@ -739,10 +739,10 @@ UINT __stdcall RemoveScheduledTasksCA(MSIHANDLE hInstall) HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; - ITaskService* pService = nullptr; - ITaskFolder* pTaskFolder = nullptr; - IRegisteredTaskCollection* pTaskCollection = nullptr; - ITaskFolder* pRootFolder = nullptr; + ITaskService *pService = nullptr; + ITaskFolder *pTaskFolder = nullptr; + IRegisteredTaskCollection *pTaskCollection = nullptr; + ITaskFolder *pRootFolder = nullptr; LONG numTasks = 0; hr = WcaInitialize(hInstall, "RemoveScheduledTasksCA"); @@ -755,10 +755,10 @@ UINT __stdcall RemoveScheduledTasksCA(MSIHANDLE hInstall) // ------------------------------------------------------ // Create an instance of the Task Service. hr = CoCreateInstance(CLSID_TaskScheduler, - nullptr, - CLSCTX_INPROC_SERVER, - IID_ITaskService, - reinterpret_cast(&pService)); + nullptr, + CLSCTX_INPROC_SERVER, + IID_ITaskService, + reinterpret_cast(&pService)); ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr); // Connect to the task service. @@ -786,7 +786,7 @@ UINT __stdcall RemoveScheduledTasksCA(MSIHANDLE hInstall) { // Delete all the tasks found. // If some tasks can't be deleted, the folder won't be deleted later and the user will still be notified. - IRegisteredTask* pRegisteredTask = nullptr; + IRegisteredTask *pRegisteredTask = nullptr; hr = pTaskCollection->get_Item(_variant_t(i + 1), &pRegisteredTask); if (SUCCEEDED(hr)) { @@ -1028,7 +1028,7 @@ UINT __stdcall DetectPrevInstallPathCA(MSIHANDLE hInstall) try { - if (auto install_path = GetMsiPackageInstalledPath(std::wstring{ currentScope } == L"perUser")) + if (auto install_path = GetMsiPackageInstalledPath(std::wstring{currentScope} == L"perUser")) { MsiSetPropertyW(hInstall, L"PREVIOUSINSTALLFOLDER", install_path->data()); } @@ -1068,9 +1068,9 @@ UINT __stdcall InstallCmdPalPackageCA(MSIHANDLE hInstall) } } } - catch (std::exception& e) + catch (std::exception &e) { - std::string errorMessage{ "Exception thrown while trying to install CmdPal package: " }; + std::string errorMessage{"Exception thrown while trying to install CmdPal package: "}; errorMessage += e.what(); Logger::error(errorMessage); @@ -1094,9 +1094,9 @@ UINT __stdcall UnRegisterContextMenuPackagesCA(MSIHANDLE hInstall) try { // Packages to unregister - const std::vector packagesToRemoveDisplayName{ {L"PowerRenameContextMenu"}, {L"ImageResizerContextMenu"}, {L"FileLocksmithContextMenu"}, {L"NewPlusContextMenu"}, {L"Microsoft.CmdPal"} }; + const std::vector packagesToRemoveDisplayName{{L"PowerRenameContextMenu"}, {L"ImageResizerContextMenu"}, {L"FileLocksmithContextMenu"}, {L"NewPlusContextMenu"}, {L"Microsoft.CmdPal"}}; - for (auto const& package : packagesToRemoveDisplayName) + for (auto const &package : packagesToRemoveDisplayName) { if (!package::UnRegisterPackage(package)) { @@ -1105,9 +1105,9 @@ UINT __stdcall UnRegisterContextMenuPackagesCA(MSIHANDLE hInstall) } } } - catch (std::exception& e) + catch (std::exception &e) { - std::string errorMessage{ "Exception thrown while trying to unregister sparse packages: " }; + std::string errorMessage{"Exception thrown while trying to unregister sparse packages: "}; errorMessage += e.what(); Logger::error(errorMessage); @@ -1185,7 +1185,7 @@ UINT __stdcall TerminateProcessesCA(MSIHANDLE hInstall) } wchar_t processName[MAX_PATH] = L""; - HANDLE hProcess{ OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE, FALSE, procID) }; + HANDLE hProcess{OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE, FALSE, procID)}; if (!hProcess) { continue; @@ -1206,17 +1206,17 @@ UINT __stdcall TerminateProcessesCA(MSIHANDLE hInstall) { const DWORD timeout = 500; auto windowEnumerator = [](HWND hwnd, LPARAM procIDPtr) -> BOOL + { + auto targetProcID = *reinterpret_cast(procIDPtr); + DWORD windowProcID = 0; + GetWindowThreadProcessId(hwnd, &windowProcID); + if (windowProcID == targetProcID) { - auto targetProcID = *reinterpret_cast(procIDPtr); - DWORD windowProcID = 0; - GetWindowThreadProcessId(hwnd, &windowProcID); - if (windowProcID == targetProcID) - { - DWORD_PTR _{}; - SendMessageTimeoutA(hwnd, WM_CLOSE, 0, 0, SMTO_BLOCK, timeout, &_); - } - return TRUE; - }; + DWORD_PTR _{}; + SendMessageTimeoutA(hwnd, WM_CLOSE, 0, 0, SMTO_BLOCK, timeout, &_); + } + return TRUE; + }; EnumWindows(windowEnumerator, reinterpret_cast(&procID)); Sleep(timeout); TerminateProcess(hProcess, 0); @@ -1234,7 +1234,7 @@ void initSystemLogger() { static std::once_flag initLoggerFlag; std::call_once(initLoggerFlag, []() - { + { WCHAR temp_path[MAX_PATH]; auto ret = GetTempPath(MAX_PATH, temp_path); diff --git a/src/common/updating/updating.cpp b/src/common/updating/updating.cpp index 361e77bc4f..9d80662d54 100644 --- a/src/common/updating/updating.cpp +++ b/src/common/updating/updating.cpp @@ -82,12 +82,20 @@ namespace updating // prevent the warning that may show up depend on the value of the constants (#defines) #pragma warning(push) #pragma warning(disable : 4702) +#if USE_STD_EXPECTED + std::future> get_github_version_info_async(const bool prerelease) +#else std::future> get_github_version_info_async(const bool prerelease) +#endif { // If the current version starts with 0.0.*, it means we're on a local build from a farm and shouldn't check for updates. if constexpr (VERSION_MAJOR == 0 && VERSION_MINOR == 0) { +#if USE_STD_EXPECTED + co_return std::unexpected(LOCAL_BUILD_ERROR); +#else co_return nonstd::make_unexpected(LOCAL_BUILD_ERROR); +#endif } try @@ -139,7 +147,11 @@ namespace updating catch (...) { } +#if USE_STD_EXPECTED + co_return std::unexpected(NETWORK_ERROR); +#else co_return nonstd::make_unexpected(NETWORK_ERROR); +#endif } #pragma warning(pop) diff --git a/src/common/updating/updating.h b/src/common/updating/updating.h index 155002361f..148a5e5b25 100644 --- a/src/common/updating/updating.h +++ b/src/common/updating/updating.h @@ -6,7 +6,14 @@ #include #include #include +//#if __MSVC_VERSION__ >= 1933 // MSVC begin to support std::unexpected in 19.33 +#if __has_include( ) // use the same way with excepted-lite to detect std::unexcepted, as using it as backup +#include +#define USE_STD_EXPECTED 1 +#else #include +#define USE_STD_EXPECTED 0 +#endif #include @@ -27,7 +34,11 @@ namespace updating std::future> download_new_version(const new_version_download_info& new_version); std::filesystem::path get_pending_updates_path(); +#if USE_STD_EXPECTED + std::future> get_github_version_info_async(const bool prerelease = false); +#else std::future> get_github_version_info_async(const bool prerelease = false); +#endif void cleanup_updates(); // non-localized diff --git a/src/common/utils/gpo.h b/src/common/utils/gpo.h index 4a1984c750..6b6cd1b78f 100644 --- a/src/common/utils/gpo.h +++ b/src/common/utils/gpo.h @@ -4,8 +4,10 @@ #include #include -namespace powertoys_gpo { - enum gpo_rule_configured_t { +namespace powertoys_gpo +{ + enum gpo_rule_configured_t + { gpo_rule_configured_wrong_value = -3, // The policy is set to an unrecognized value gpo_rule_configured_unavailable = -2, // Couldn't access registry gpo_rule_configured_not_configured = -1, // Policy is not configured @@ -155,16 +157,17 @@ namespace powertoys_gpo { machine_key_found = false; } - if(machine_key_found) + if (machine_key_found) { // If the path was found in the machine, we need to check if the value for the policy exists. auto res = RegQueryValueExW(key, registry_value_name.c_str(), nullptr, nullptr, reinterpret_cast(&value), &valueSize); RegCloseKey(key); - if (res != ERROR_SUCCESS) { + if (res != ERROR_SUCCESS) + { // Value not found on the path. - machine_key_found=false; + machine_key_found = false; } } @@ -173,7 +176,8 @@ namespace powertoys_gpo { // If there's no value found on the machine scope, try to get it from the user scope. if (auto res = RegOpenKeyExW(POLICIES_SCOPE_USER, POLICIES_PATH.c_str(), 0, KEY_READ, &key); res != ERROR_SUCCESS) { - if (res == ERROR_FILE_NOT_FOUND) { + if (res == ERROR_FILE_NOT_FOUND) + { return gpo_rule_configured_not_configured; } return gpo_rule_configured_unavailable; @@ -181,7 +185,8 @@ namespace powertoys_gpo { auto res = RegQueryValueExW(key, registry_value_name.c_str(), nullptr, nullptr, reinterpret_cast(&value), &valueSize); RegCloseKey(key); - if (res != ERROR_SUCCESS) { + if (res != ERROR_SUCCESS) + { return gpo_rule_configured_not_configured; } } @@ -500,7 +505,7 @@ namespace powertoys_gpo { } inline gpo_rule_configured_t getRunPluginEnabledValue(std::string pluginID) - { + { if (pluginID == "" || pluginID == " ") { // this plugin id can't exist in the registry @@ -509,7 +514,7 @@ namespace powertoys_gpo { std::wstring plugin_id(pluginID.begin(), pluginID.end()); auto individual_plugin_setting = getPolicyListValue(POWER_LAUNCHER_INDIVIDUAL_PLUGIN_ENABLED_LIST_PATH, plugin_id); - + if (individual_plugin_setting.has_value()) { if (*individual_plugin_setting == L"0") @@ -536,7 +541,7 @@ namespace powertoys_gpo { { // If no individual plugin policy exists, we check the policy with the setting for all plugins. return getConfiguredValue(POLICY_CONFIGURE_ENABLED_POWER_LAUNCHER_ALL_PLUGINS); - } + } } inline gpo_rule_configured_t getAllowedAdvancedPasteOnlineAIModelsValue() @@ -595,7 +600,7 @@ namespace powertoys_gpo { } else { - return std::wstring (); + return std::wstring(); } } diff --git a/src/common/utils/package.h b/src/common/utils/package.h index f2a5531723..cd10c22b9b 100644 --- a/src/common/utils/package.h +++ b/src/common/utils/package.h @@ -13,6 +13,7 @@ #include #include "../logger/logger.h" +#include "../version/version.h" namespace package { @@ -52,10 +53,14 @@ namespace package { for (const auto& package : packageManager.FindPackagesForUser({})) { const auto& packageFullName = std::wstring{ package.Id().FullName() }; + const auto& packageVersion = package.Id().Version(); if (packageFullName.contains(packageDisplayName)) { - return { package }; + if (packageVersion.Major == VERSION_MAJOR && packageVersion.Minor == VERSION_MINOR && packageVersion.Revision == VERSION_REVISION) + { + return { package }; + } } } @@ -79,6 +84,7 @@ namespace package { // Declare use of an external location AddPackageOptions options; options.ExternalLocationUri(externalUri); + options.ForceUpdateFromAnyVersion(true); IAsyncOperationWithProgress deploymentOperation = packageManager.AddPackageByUriAsync(packageUri, options); deploymentOperation.get(); diff --git a/src/runner/settings_window.cpp b/src/runner/settings_window.cpp index 265d3e3dc0..513c4ef60d 100644 --- a/src/runner/settings_window.cpp +++ b/src/runner/settings_window.cpp @@ -698,11 +698,11 @@ std::string ESettingsWindowNames_to_string(ESettingsWindowNames value) return "CmdPal"; case ESettingsWindowNames::ZoomIt: return "ZoomIt"; - default: - { - Logger::error(L"Can't convert ESettingsWindowNames value={} to string", static_cast(value)); - assert(false); - } + default: + { + Logger::error(L"Can't convert ESettingsWindowNames value={} to string", static_cast(value)); + assert(false); + } } return ""; } diff --git a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw index 91833b1a1d..7584819164 100644 --- a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw +++ b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw @@ -4923,6 +4923,6 @@ To record a specific window, enter the hotkey with the Alt key in the opposite m NEW - Must be all caps + Must be all caps \ No newline at end of file