mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 03:07:56 +01:00
[Refactor]Port C++/CX to C++/WinRT (#34198)
## Summary of the Pull Request Removes all C++/CX code, replacing it with C++/WinRT. ## Detailed Description of the Pull Request / Additional comments Removes all C++/CX code. Renames interop namespaces to be better consumed by CsWinRT. Standardizes all projects on net8.0-windows10.0.20348.0, which is a requirement for C++/WinRT usage. FileLocksmithLibInterop brought to stdcpplatest and static analysis errors were corrected. Removed now unneeded string conversion code from FileLocksmithLibInterop. Changed interop KeyboardHook to use a single hook across all instances. Required because on C++/WinRT we don't have the .NET runtime to bind a object instance to a delegate and be able to pass it to a C function pointer argument (still no idea why this worked correctly on C++/CX to be honest). This change actually makes us create less low level keyboard hooks. Changed some code that depended on arrays since WinRT/C++ returns null instead of an empty array through the interface. ## Validation Steps Performed Built and tested runtime.
This commit is contained in:
@@ -182,11 +182,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Settings.UI.Library", "src\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj", "{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PowerToys.Interop", "src\common\interop\PowerToys.Interop.vcxproj", "{F055103B-F80B-4D0C-BF48-057C55620033}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF} = {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Plugin.Folder", "src\modules\launcher\Plugins\Microsoft.Plugin.Folder\Microsoft.Plugin.Folder.csproj", "{787B8AA6-CA93-4C84-96FE-DF31110AD1C4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerLauncher.Telemetry", "src\modules\launcher\PowerLauncher.Telemetry\PowerLauncher.Telemetry.csproj", "{08C8C05F-0362-41BC-818C-724572DF8B06}"
|
||||
@@ -585,6 +580,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerToys.Settings.DSC.Sche
|
||||
{020A7474-3601-4160-A159-D7B70B77B15F} = {020A7474-3601-4160-A159-D7B70B77B15F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PowerToys.Interop", "src\common\interop\PowerToys.Interop.vcxproj", "{F055103B-F80B-4D0C-BF48-057C55620033}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
@@ -955,16 +952,6 @@ Global
|
||||
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x64.ActiveCfg = Release|x64
|
||||
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x64.Build.0 = Release|x64
|
||||
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x86.ActiveCfg = Release|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|x64.Build.0 = Debug|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|x64.ActiveCfg = Release|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|x64.Build.0 = Release|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|x86.ActiveCfg = Release|x64
|
||||
{787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Debug|x64.ActiveCfg = Debug|x64
|
||||
@@ -2601,6 +2588,18 @@ Global
|
||||
{1D6893CB-BC0C-46A8-A76C-9728706CA51A}.Release|x64.Build.0 = Release|x64
|
||||
{1D6893CB-BC0C-46A8-A76C-9728706CA51A}.Release|x86.ActiveCfg = Release|x64
|
||||
{1D6893CB-BC0C-46A8-A76C-9728706CA51A}.Release|x86.Build.0 = Release|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|x64.Build.0 = Debug|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|x86.Build.0 = Debug|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|x64.ActiveCfg = Release|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|x64.Build.0 = Release|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|x86.ActiveCfg = Release|x64
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|x86.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -2647,7 +2646,6 @@ Global
|
||||
{748417CA-F17E-487F-9411-CAFB6D3F4877} = {2F305555-C296-497E-AC20-5FA1B237996A}
|
||||
{217DF501-135C-4E38-BFC8-99D4821032EA} = {2F305555-C296-497E-AC20-5FA1B237996A}
|
||||
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033} = {5A7818A8-109C-4E1C-850D-1A654E234B0E}
|
||||
{787B8AA6-CA93-4C84-96FE-DF31110AD1C4} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
|
||||
{08C8C05F-0362-41BC-818C-724572DF8B06} = {C140A3EF-6DBF-4084-9D4C-4EB5A99FEE68}
|
||||
{5D00D290-4016-4CFE-9E41-1E7C724509BA} = {1AFB6476-670D-4E80-A464-657E01DFF482}
|
||||
@@ -2817,6 +2815,7 @@ Global
|
||||
{3A9A791E-94A9-49F8-8401-C11CE288D5FB} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
|
||||
{C0974915-8A1D-4BF0-977B-9587D3807AB7} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
|
||||
{1D6893CB-BC0C-46A8-A76C-9728706CA51A} = {557C4636-D7E1-4838-A504-7D19B725EE95}
|
||||
{F055103B-F80B-4D0C-BF48-057C55620033} = {5A7818A8-109C-4E1C-850D-1A654E234B0E}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
||||
|
||||
@@ -25,11 +25,9 @@
|
||||
<?if $(sys.BUILDARCH) = x64 ?>
|
||||
<File Source="$(var.BinDir)KeyboardManagerEditor\vcruntime140_1_app.dll" />
|
||||
<?endif ?>
|
||||
<!-- Latest CppWinRT upgrade made Keyboard Manager Editor depend on additional VC Runtime libraries. -->
|
||||
<!-- These are not in the Keyboard Manager Editor build output. So we copy them from the base build directory. -->
|
||||
<File Source="$(var.BinDir)vcruntime140.dll" />
|
||||
<File Source="$(var.BinDir)vcruntime140_1.dll" />
|
||||
<File Source="$(var.BinDir)msvcp140.dll" />
|
||||
<File Source="$(var.BinDir)KeyboardManagerEditor\vcruntime140.dll" />
|
||||
<File Source="$(var.BinDir)KeyboardManagerEditor\vcruntime140_1.dll" />
|
||||
<File Source="$(var.BinDir)KeyboardManagerEditor\msvcp140.dll" />
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
<ProjectReference Include="..\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
|
||||
<ProjectReference Include="..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Experimentation is live, forcing inclusion -->
|
||||
<ItemGroup Condition="'$(IsExperimentationLive)'!=''">
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
||||
<UseWPF>true</UseWPF>
|
||||
<AssemblyName>PowerToys.Common.UI</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="ControlzEx" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
||||
<Description>PowerToys FilePreviewCommon</Description>
|
||||
<AssemblyName>PowerToys.FilePreviewCommon</AssemblyName>
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO.Abstractions;
|
||||
using System.Reflection;
|
||||
using interop;
|
||||
using PowerToys.Interop;
|
||||
|
||||
namespace ManagedCommon
|
||||
{
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
||||
<Description>PowerToys ManagedCommon</Description>
|
||||
<AssemblyName>PowerToys.ManagedCommon</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.Interop</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.IO.Abstractions" />
|
||||
<PackageReference Include="System.Management" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
||||
<Description>PowerToys Telemetry</Description>
|
||||
<AssemblyName>PowerToys.ManagedTelemetry</AssemblyName>
|
||||
|
||||
39
src/common/interop/CommonManaged.cpp
Normal file
39
src/common/interop/CommonManaged.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "pch.h"
|
||||
#include "CommonManaged.h"
|
||||
#include "CommonManaged.g.cpp"
|
||||
#include <common/version/version.h>
|
||||
#include "../../modules/videoconference/VideoConferenceShared/MicrophoneDevice.h"
|
||||
#include "../../modules/videoconference/VideoConferenceShared/VideoCaptureDeviceList.h"
|
||||
|
||||
namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
hstring CommonManaged::GetProductVersion()
|
||||
{
|
||||
return hstring{ get_product_version() };
|
||||
}
|
||||
winrt::Windows::Foundation::Collections::IVector<hstring> CommonManaged::GetAllActiveMicrophoneDeviceNames()
|
||||
{
|
||||
auto names = std::vector<winrt::hstring>();
|
||||
for (const auto& device : MicrophoneDevice::getAllActive())
|
||||
{
|
||||
names.push_back(device->name().data());
|
||||
}
|
||||
return winrt::multi_threaded_vector(std::move(names));
|
||||
}
|
||||
winrt::Windows::Foundation::Collections::IVector<hstring> CommonManaged::GetAllVideoCaptureDeviceNames()
|
||||
{
|
||||
auto names = std::vector<winrt::hstring>();
|
||||
VideoCaptureDeviceList vcdl;
|
||||
vcdl.EnumerateDevices();
|
||||
|
||||
for (UINT32 i = 0; i < vcdl.Count(); ++i)
|
||||
{
|
||||
auto name = vcdl.GetDeviceName(i).data();
|
||||
if (name != L"PowerToys VideoConference Mute")
|
||||
{
|
||||
names.push_back(name);
|
||||
}
|
||||
}
|
||||
return winrt::multi_threaded_vector(std::move(names));
|
||||
}
|
||||
}
|
||||
20
src/common/interop/CommonManaged.h
Normal file
20
src/common/interop/CommonManaged.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "CommonManaged.g.h"
|
||||
|
||||
namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
struct CommonManaged : CommonManagedT<CommonManaged>
|
||||
{
|
||||
CommonManaged() = default;
|
||||
|
||||
static hstring GetProductVersion();
|
||||
static winrt::Windows::Foundation::Collections::IVector<hstring> GetAllActiveMicrophoneDeviceNames();
|
||||
static winrt::Windows::Foundation::Collections::IVector<hstring> GetAllVideoCaptureDeviceNames();
|
||||
};
|
||||
}
|
||||
namespace winrt::PowerToys::Interop::factory_implementation
|
||||
{
|
||||
struct CommonManaged : CommonManagedT<CommonManaged, implementation::CommonManaged>
|
||||
{
|
||||
};
|
||||
}
|
||||
11
src/common/interop/CommonManaged.idl
Normal file
11
src/common/interop/CommonManaged.idl
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace PowerToys
|
||||
{
|
||||
namespace Interop
|
||||
{
|
||||
[default_interface] static runtimeclass CommonManaged {
|
||||
static String GetProductVersion();
|
||||
static Windows.Foundation.Collections.IVector<String> GetAllActiveMicrophoneDeviceNames();
|
||||
static Windows.Foundation.Collections.IVector<String> GetAllVideoCaptureDeviceNames();
|
||||
}
|
||||
}
|
||||
}
|
||||
146
src/common/interop/Constants.cpp
Normal file
146
src/common/interop/Constants.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
#include "pch.h"
|
||||
#include "Constants.h"
|
||||
#include "Constants.g.cpp"
|
||||
#include "shared_constants.h"
|
||||
#include <ShlObj.h>
|
||||
|
||||
namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
uint32_t Constants::VK_WIN_BOTH()
|
||||
{
|
||||
return CommonSharedConstants::VK_WIN_BOTH;
|
||||
}
|
||||
hstring Constants::AppDataPath()
|
||||
{
|
||||
PWSTR local_app_path;
|
||||
winrt::check_hresult(SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &local_app_path));
|
||||
winrt::hstring result{ local_app_path };
|
||||
CoTaskMemFree(local_app_path);
|
||||
result = result + L"\\" + CommonSharedConstants::APPDATA_PATH;
|
||||
return result;
|
||||
}
|
||||
hstring Constants::PowerLauncherSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::POWER_LAUNCHER_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::PowerLauncherCentralizedHookSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::POWER_LAUNCHER_CENTRALIZED_HOOK_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::RunSendSettingsTelemetryEvent()
|
||||
{
|
||||
return CommonSharedConstants::RUN_SEND_SETTINGS_TELEMETRY_EVENT;
|
||||
}
|
||||
hstring Constants::RunExitEvent()
|
||||
{
|
||||
return CommonSharedConstants::RUN_EXIT_EVENT;
|
||||
}
|
||||
hstring Constants::FZEExitEvent()
|
||||
{
|
||||
return CommonSharedConstants::FZE_EXIT_EVENT;
|
||||
}
|
||||
hstring Constants::FZEToggleEvent()
|
||||
{
|
||||
return CommonSharedConstants::FANCY_ZONES_EDITOR_TOGGLE_EVENT;
|
||||
}
|
||||
hstring Constants::ColorPickerSendSettingsTelemetryEvent()
|
||||
{
|
||||
return CommonSharedConstants::COLOR_PICKER_SEND_SETTINGS_TELEMETRY_EVENT;
|
||||
}
|
||||
hstring Constants::ShowColorPickerSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::SHOW_COLOR_PICKER_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::ShowAdvancedPasteSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::SHOW_ADVANCED_PASTE_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::AdvancedPasteMarkdownEvent()
|
||||
{
|
||||
return CommonSharedConstants::ADVANCED_PASTE_MARKDOWN_EVENT;
|
||||
}
|
||||
hstring Constants::AdvancedPasteJsonEvent()
|
||||
{
|
||||
return CommonSharedConstants::ADVANCED_PASTE_JSON_EVENT;
|
||||
}
|
||||
hstring Constants::ShowPowerOCRSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::SHOW_POWEROCR_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::MouseJumpShowPreviewEvent()
|
||||
{
|
||||
return CommonSharedConstants::MOUSE_JUMP_SHOW_PREVIEW_EVENT;
|
||||
}
|
||||
hstring Constants::AwakeExitEvent()
|
||||
{
|
||||
return CommonSharedConstants::AWAKE_EXIT_EVENT;
|
||||
}
|
||||
hstring Constants::ShowPeekEvent()
|
||||
{
|
||||
return CommonSharedConstants::SHOW_PEEK_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::PowerAccentExitEvent()
|
||||
{
|
||||
return CommonSharedConstants::POWERACCENT_EXIT_EVENT;
|
||||
}
|
||||
hstring Constants::ShortcutGuideTriggerEvent()
|
||||
{
|
||||
return CommonSharedConstants::SHORTCUT_GUIDE_TRIGGER_EVENT;
|
||||
}
|
||||
hstring Constants::RegistryPreviewTriggerEvent()
|
||||
{
|
||||
return CommonSharedConstants::REGISTRY_PREVIEW_TRIGGER_EVENT;
|
||||
}
|
||||
hstring Constants::MeasureToolTriggerEvent()
|
||||
{
|
||||
return CommonSharedConstants::MEASURE_TOOL_TRIGGER_EVENT;
|
||||
}
|
||||
hstring Constants::GcodePreviewResizeEvent()
|
||||
{
|
||||
return CommonSharedConstants::GCODE_PREVIEW_RESIZE_EVENT;
|
||||
}
|
||||
hstring Constants::QoiPreviewResizeEvent()
|
||||
{
|
||||
return CommonSharedConstants::QOI_PREVIEW_RESIZE_EVENT;
|
||||
}
|
||||
hstring Constants::DevFilesPreviewResizeEvent()
|
||||
{
|
||||
return CommonSharedConstants::DEV_FILES_PREVIEW_RESIZE_EVENT;
|
||||
}
|
||||
hstring Constants::MarkdownPreviewResizeEvent()
|
||||
{
|
||||
return CommonSharedConstants::MARKDOWN_PREVIEW_RESIZE_EVENT;
|
||||
}
|
||||
hstring Constants::PdfPreviewResizeEvent()
|
||||
{
|
||||
return CommonSharedConstants::PDF_PREVIEW_RESIZE_EVENT;
|
||||
}
|
||||
hstring Constants::SvgPreviewResizeEvent()
|
||||
{
|
||||
return CommonSharedConstants::SVG_PREVIEW_RESIZE_EVENT;
|
||||
}
|
||||
hstring Constants::ShowHostsSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::SHOW_HOSTS_EVENT;
|
||||
}
|
||||
hstring Constants::ShowHostsAdminSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::SHOW_HOSTS_ADMIN_EVENT;
|
||||
}
|
||||
hstring Constants::CropAndLockThumbnailEvent()
|
||||
{
|
||||
return CommonSharedConstants::CROP_AND_LOCK_THUMBNAIL_EVENT;
|
||||
}
|
||||
hstring Constants::CropAndLockReparentEvent()
|
||||
{
|
||||
return CommonSharedConstants::CROP_AND_LOCK_REPARENT_EVENT;
|
||||
}
|
||||
hstring Constants::ShowEnvironmentVariablesSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::SHOW_ENVIRONMENT_VARIABLES_EVENT;
|
||||
}
|
||||
hstring Constants::ShowEnvironmentVariablesAdminSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::SHOW_ENVIRONMENT_VARIABLES_ADMIN_EVENT;
|
||||
}
|
||||
}
|
||||
50
src/common/interop/Constants.h
Normal file
50
src/common/interop/Constants.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include "Constants.g.h"
|
||||
namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
struct Constants : ConstantsT<Constants>
|
||||
{
|
||||
Constants() = default;
|
||||
|
||||
static uint32_t VK_WIN_BOTH();
|
||||
static hstring AppDataPath();
|
||||
static hstring PowerLauncherSharedEvent();
|
||||
static hstring PowerLauncherCentralizedHookSharedEvent();
|
||||
static hstring RunSendSettingsTelemetryEvent();
|
||||
static hstring RunExitEvent();
|
||||
static hstring FZEExitEvent();
|
||||
static hstring FZEToggleEvent();
|
||||
static hstring ColorPickerSendSettingsTelemetryEvent();
|
||||
static hstring ShowColorPickerSharedEvent();
|
||||
static hstring ShowAdvancedPasteSharedEvent();
|
||||
static hstring AdvancedPasteMarkdownEvent();
|
||||
static hstring AdvancedPasteJsonEvent();
|
||||
static hstring ShowPowerOCRSharedEvent();
|
||||
static hstring MouseJumpShowPreviewEvent();
|
||||
static hstring AwakeExitEvent();
|
||||
static hstring ShowPeekEvent();
|
||||
static hstring PowerAccentExitEvent();
|
||||
static hstring ShortcutGuideTriggerEvent();
|
||||
static hstring RegistryPreviewTriggerEvent();
|
||||
static hstring MeasureToolTriggerEvent();
|
||||
static hstring GcodePreviewResizeEvent();
|
||||
static hstring QoiPreviewResizeEvent();
|
||||
static hstring DevFilesPreviewResizeEvent();
|
||||
static hstring MarkdownPreviewResizeEvent();
|
||||
static hstring PdfPreviewResizeEvent();
|
||||
static hstring SvgPreviewResizeEvent();
|
||||
static hstring ShowHostsSharedEvent();
|
||||
static hstring ShowHostsAdminSharedEvent();
|
||||
static hstring CropAndLockThumbnailEvent();
|
||||
static hstring CropAndLockReparentEvent();
|
||||
static hstring ShowEnvironmentVariablesSharedEvent();
|
||||
static hstring ShowEnvironmentVariablesAdminSharedEvent();
|
||||
};
|
||||
}
|
||||
|
||||
namespace winrt::PowerToys::Interop::factory_implementation
|
||||
{
|
||||
struct Constants : ConstantsT<Constants, implementation::Constants>
|
||||
{
|
||||
};
|
||||
}
|
||||
41
src/common/interop/Constants.idl
Normal file
41
src/common/interop/Constants.idl
Normal file
@@ -0,0 +1,41 @@
|
||||
namespace PowerToys
|
||||
{
|
||||
namespace Interop
|
||||
{
|
||||
[default_interface] static runtimeclass Constants {
|
||||
static UInt32 VK_WIN_BOTH {get; };
|
||||
static String AppDataPath();
|
||||
static String PowerLauncherSharedEvent();
|
||||
static String PowerLauncherCentralizedHookSharedEvent();
|
||||
static String RunSendSettingsTelemetryEvent();
|
||||
static String RunExitEvent();
|
||||
static String FZEExitEvent();
|
||||
static String FZEToggleEvent();
|
||||
static String ColorPickerSendSettingsTelemetryEvent();
|
||||
static String ShowColorPickerSharedEvent();
|
||||
static String ShowAdvancedPasteSharedEvent();
|
||||
static String AdvancedPasteMarkdownEvent();
|
||||
static String AdvancedPasteJsonEvent();
|
||||
static String ShowPowerOCRSharedEvent();
|
||||
static String MouseJumpShowPreviewEvent();
|
||||
static String AwakeExitEvent();
|
||||
static String ShowPeekEvent();
|
||||
static String PowerAccentExitEvent();
|
||||
static String ShortcutGuideTriggerEvent();
|
||||
static String RegistryPreviewTriggerEvent();
|
||||
static String MeasureToolTriggerEvent();
|
||||
static String GcodePreviewResizeEvent();
|
||||
static String QoiPreviewResizeEvent();
|
||||
static String DevFilesPreviewResizeEvent();
|
||||
static String MarkdownPreviewResizeEvent();
|
||||
static String PdfPreviewResizeEvent();
|
||||
static String SvgPreviewResizeEvent();
|
||||
static String ShowHostsSharedEvent();
|
||||
static String ShowHostsAdminSharedEvent();
|
||||
static String CropAndLockThumbnailEvent();
|
||||
static String CropAndLockReparentEvent();
|
||||
static String ShowEnvironmentVariablesSharedEvent();
|
||||
static String ShowEnvironmentVariablesAdminSharedEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +1,89 @@
|
||||
#include "pch.h"
|
||||
#include "HotkeyManager.h"
|
||||
#include "HotkeyManager.g.cpp"
|
||||
|
||||
using namespace interop;
|
||||
|
||||
HotkeyManager::HotkeyManager()
|
||||
namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
keyboardEventCallback = gcnew KeyboardEventCallback(this, &HotkeyManager::KeyboardEventProc);
|
||||
isActiveCallback = gcnew IsActiveCallback(this, &HotkeyManager::IsActiveProc);
|
||||
filterKeyboardCallback = gcnew FilterKeyboardEvent(this, &HotkeyManager::FilterKeyboardProc);
|
||||
|
||||
keyboardHook = gcnew KeyboardHook(
|
||||
keyboardEventCallback,
|
||||
isActiveCallback,
|
||||
filterKeyboardCallback);
|
||||
hotkeys = gcnew Dictionary<HOTKEY_HANDLE, HotkeyCallback ^>();
|
||||
pressedKeys = gcnew Hotkey();
|
||||
keyboardHook->Start();
|
||||
}
|
||||
|
||||
HotkeyManager::~HotkeyManager()
|
||||
{
|
||||
delete keyboardHook;
|
||||
}
|
||||
|
||||
// When all Shortcut keys are pressed, fire the HotkeyCallback event.
|
||||
void HotkeyManager::KeyboardEventProc(KeyboardEvent ^ /*ev*/)
|
||||
{
|
||||
// pressedKeys always stores the latest keyboard state
|
||||
auto pressedKeysHandle = GetHotkeyHandle(pressedKeys);
|
||||
if (hotkeys->ContainsKey(pressedKeysHandle))
|
||||
HotkeyManager::HotkeyManager()
|
||||
{
|
||||
hotkeys[pressedKeysHandle]->Invoke();
|
||||
|
||||
// After invoking the hotkey send a dummy key to prevent Start Menu from activating
|
||||
INPUT dummyEvent[1] = {};
|
||||
dummyEvent[0].type = INPUT_KEYBOARD;
|
||||
dummyEvent[0].ki.wVk = 0xFF;
|
||||
dummyEvent[0].ki.dwFlags = KEYEVENTF_KEYUP;
|
||||
SendInput(1, dummyEvent, sizeof(INPUT));
|
||||
keyboardEventCallback = KeyboardEventCallback{ this, &HotkeyManager::KeyboardEventProc };
|
||||
isActiveCallback = IsActiveCallback{ this, &HotkeyManager::IsActiveProc };
|
||||
filterKeyboardCallback = FilterKeyboardEvent{ this, &HotkeyManager::FilterKeyboardProc };
|
||||
keyboardHook = KeyboardHook{ keyboardEventCallback, isActiveCallback, filterKeyboardCallback };
|
||||
keyboardHook.Start();
|
||||
}
|
||||
}
|
||||
|
||||
// Hotkeys are intended to be global, therefore they are always active no matter the
|
||||
// context in which the keypress occurs.
|
||||
bool HotkeyManager::IsActiveProc()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// When all Shortcut keys are pressed, fire the HotkeyCallback event.
|
||||
void HotkeyManager::KeyboardEventProc(KeyboardEvent ev)
|
||||
{
|
||||
// pressedKeys always stores the latest keyboard state
|
||||
auto pressedKeysHandle = GetHotkeyHandle(pressedKeys);
|
||||
if (hotkeys.find(pressedKeysHandle) != hotkeys.end())
|
||||
{
|
||||
hotkeys[pressedKeysHandle]();
|
||||
|
||||
// KeyboardEvent callback is only fired for relevant key events.
|
||||
bool HotkeyManager::FilterKeyboardProc(KeyboardEvent ^ ev)
|
||||
{
|
||||
// Updating the pressed keys here so we know if the keypress event should be propagated or not.
|
||||
pressedKeys->Win = (GetAsyncKeyState(VK_LWIN) & 0x8000) || (GetAsyncKeyState(VK_RWIN) & 0x8000);
|
||||
pressedKeys->Ctrl = GetAsyncKeyState(VK_CONTROL) & 0x8000;
|
||||
pressedKeys->Alt = GetAsyncKeyState(VK_MENU) & 0x8000;
|
||||
pressedKeys->Shift = GetAsyncKeyState(VK_SHIFT) & 0x8000;
|
||||
pressedKeys->Key = static_cast<unsigned char>(ev->key);
|
||||
// After invoking the hotkey send a dummy key to prevent Start Menu from activating
|
||||
INPUT dummyEvent[1] = {};
|
||||
dummyEvent[0].type = INPUT_KEYBOARD;
|
||||
dummyEvent[0].ki.wVk = 0xFF;
|
||||
dummyEvent[0].ki.dwFlags = KEYEVENTF_KEYUP;
|
||||
SendInput(1, dummyEvent, sizeof(INPUT));
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to hotkey handle
|
||||
auto pressedKeysHandle = GetHotkeyHandle(pressedKeys);
|
||||
|
||||
// Check if any hotkey matches the pressed keys if the current key event is a key down event
|
||||
if ((ev->message == WM_KEYDOWN || ev->message == WM_SYSKEYDOWN) && hotkeys->ContainsKey(pressedKeysHandle))
|
||||
// Hotkeys are intended to be global, therefore they are always active no matter the
|
||||
// context in which the keypress occurs.
|
||||
bool HotkeyManager::IsActiveProc()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool HotkeyManager::FilterKeyboardProc(KeyboardEvent ev)
|
||||
{
|
||||
// Updating the pressed keys here so we know if the keypress event should be propagated or not.
|
||||
pressedKeys.Win = (GetAsyncKeyState(VK_LWIN) & 0x8000) || (GetAsyncKeyState(VK_RWIN) & 0x8000);
|
||||
pressedKeys.Ctrl = GetAsyncKeyState(VK_CONTROL) & 0x8000;
|
||||
pressedKeys.Alt = GetAsyncKeyState(VK_MENU) & 0x8000;
|
||||
pressedKeys.Shift = GetAsyncKeyState(VK_SHIFT) & 0x8000;
|
||||
pressedKeys.Key = static_cast<unsigned char>(ev.key);
|
||||
|
||||
return false;
|
||||
}
|
||||
// Convert to hotkey handle
|
||||
auto pressedKeysHandle = GetHotkeyHandle(pressedKeys);
|
||||
|
||||
// NOTE: Replaces old hotkey if one already present.
|
||||
HOTKEY_HANDLE HotkeyManager::RegisterHotkey(Hotkey ^ hotkey, HotkeyCallback ^ callback)
|
||||
{
|
||||
auto handle = GetHotkeyHandle(hotkey);
|
||||
hotkeys[handle] = callback;
|
||||
return handle;
|
||||
}
|
||||
// Check if any hotkey matches the pressed keys if the current key event is a key down event
|
||||
if ((ev.message == WM_KEYDOWN || ev.message == WM_SYSKEYDOWN) && hotkeys.find(pressedKeysHandle)!=hotkeys.end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void HotkeyManager::UnregisterHotkey(HOTKEY_HANDLE handle)
|
||||
{
|
||||
hotkeys->Remove(handle);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
HOTKEY_HANDLE HotkeyManager::GetHotkeyHandle(Hotkey ^ hotkey)
|
||||
{
|
||||
HOTKEY_HANDLE handle = hotkey->Key;
|
||||
handle |= hotkey->Win << 8;
|
||||
handle |= hotkey->Ctrl << 9;
|
||||
handle |= hotkey->Shift << 10;
|
||||
handle |= hotkey->Alt << 11;
|
||||
return handle;
|
||||
uint16_t HotkeyManager::RegisterHotkey(winrt::PowerToys::Interop::Hotkey const& _hotkey, winrt::PowerToys::Interop::HotkeyCallback const& _callback)
|
||||
{
|
||||
auto handle = GetHotkeyHandle(_hotkey);
|
||||
hotkeys[handle] = _callback;
|
||||
return handle;
|
||||
}
|
||||
|
||||
void HotkeyManager::UnregisterHotkey(uint16_t _handle)
|
||||
{
|
||||
auto iter = hotkeys.find(_handle);
|
||||
if (iter != hotkeys.end()) {
|
||||
hotkeys.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
void HotkeyManager::Close()
|
||||
{
|
||||
}
|
||||
|
||||
uint16_t HotkeyManager::GetHotkeyHandle(Hotkey hotkey)
|
||||
{
|
||||
uint16_t handle = hotkey.Key;
|
||||
handle |= hotkey.Win << 8;
|
||||
handle |= hotkey.Ctrl << 9;
|
||||
handle |= hotkey.Shift << 10;
|
||||
handle |= hotkey.Alt << 11;
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +1,33 @@
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
#include "KeyboardHook.h"
|
||||
#include "HotkeyManager.g.h"
|
||||
|
||||
namespace interop
|
||||
namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
public
|
||||
ref struct Hotkey
|
||||
struct HotkeyManager : HotkeyManagerT<HotkeyManager>
|
||||
{
|
||||
bool Win;
|
||||
bool Ctrl;
|
||||
bool Shift;
|
||||
bool Alt;
|
||||
unsigned char Key;
|
||||
|
||||
Hotkey()
|
||||
{
|
||||
Win = false;
|
||||
Ctrl = false;
|
||||
Shift = false;
|
||||
Alt = false;
|
||||
Key = 0;
|
||||
}
|
||||
};
|
||||
|
||||
public
|
||||
delegate void HotkeyCallback();
|
||||
|
||||
typedef unsigned short HOTKEY_HANDLE;
|
||||
|
||||
public
|
||||
ref class HotkeyManager
|
||||
{
|
||||
public:
|
||||
HotkeyManager();
|
||||
~HotkeyManager();
|
||||
|
||||
HOTKEY_HANDLE RegisterHotkey(Hotkey ^ hotkey, HotkeyCallback ^ callback);
|
||||
void UnregisterHotkey(HOTKEY_HANDLE handle);
|
||||
uint16_t RegisterHotkey(winrt::PowerToys::Interop::Hotkey const& _hotkey, winrt::PowerToys::Interop::HotkeyCallback const& _callback);
|
||||
void UnregisterHotkey(uint16_t _handle);
|
||||
void Close();
|
||||
|
||||
private:
|
||||
KeyboardHook ^ keyboardHook;
|
||||
Dictionary<HOTKEY_HANDLE, HotkeyCallback ^> ^ hotkeys;
|
||||
Hotkey ^ pressedKeys;
|
||||
KeyboardEventCallback ^ keyboardEventCallback;
|
||||
IsActiveCallback ^ isActiveCallback;
|
||||
FilterKeyboardEvent ^ filterKeyboardCallback;
|
||||
KeyboardHook keyboardHook{ nullptr };
|
||||
std::map<uint16_t, HotkeyCallback> hotkeys;
|
||||
Hotkey pressedKeys{ };
|
||||
KeyboardEventCallback keyboardEventCallback;
|
||||
IsActiveCallback isActiveCallback;
|
||||
FilterKeyboardEvent filterKeyboardCallback;
|
||||
|
||||
void KeyboardEventProc(KeyboardEvent ^ ev);
|
||||
void KeyboardEventProc(KeyboardEvent ev);
|
||||
bool IsActiveProc();
|
||||
bool FilterKeyboardProc(KeyboardEvent ^ ev);
|
||||
HOTKEY_HANDLE GetHotkeyHandle(Hotkey ^ hotkey);
|
||||
bool FilterKeyboardProc(KeyboardEvent ev);
|
||||
uint16_t GetHotkeyHandle(Hotkey hotkey);
|
||||
};
|
||||
}
|
||||
namespace winrt::PowerToys::Interop::factory_implementation
|
||||
{
|
||||
struct HotkeyManager : HotkeyManagerT<HotkeyManager, implementation::HotkeyManager>
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
23
src/common/interop/HotkeyManager.idl
Normal file
23
src/common/interop/HotkeyManager.idl
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace PowerToys
|
||||
{
|
||||
namespace Interop
|
||||
{
|
||||
struct Hotkey
|
||||
{
|
||||
Boolean Win;
|
||||
Boolean Ctrl;
|
||||
Boolean Shift;
|
||||
Boolean Alt;
|
||||
UInt8 Key;
|
||||
};
|
||||
delegate void HotkeyCallback();
|
||||
|
||||
[default_interface] runtimeclass HotkeyManager : Windows.Foundation.IClosable
|
||||
{
|
||||
HotkeyManager();
|
||||
UInt16 RegisterHotkey(Hotkey _hotkey, HotkeyCallback _callback);
|
||||
void UnregisterHotkey(UInt16 _handle);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,73 +1,99 @@
|
||||
#include "pch.h"
|
||||
#include "KeyboardHook.h"
|
||||
#include <exception>
|
||||
#include <msclr/marshal.h>
|
||||
#include <msclr/marshal_cppstd.h>
|
||||
#include "KeyboardHook.g.cpp"
|
||||
#include <common/debug_control.h>
|
||||
#include <common/utils/winapi_error.h>
|
||||
|
||||
using namespace interop;
|
||||
using namespace System::Runtime::InteropServices;
|
||||
using namespace System;
|
||||
using namespace System::Diagnostics;
|
||||
|
||||
KeyboardHook::KeyboardHook(
|
||||
KeyboardEventCallback ^ keyboardEventCallback,
|
||||
IsActiveCallback ^ isActiveCallback,
|
||||
FilterKeyboardEvent ^ filterKeyboardEvent)
|
||||
namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
this->keyboardEventCallback = keyboardEventCallback;
|
||||
this->isActiveCallback = isActiveCallback;
|
||||
this->filterKeyboardEvent = filterKeyboardEvent;
|
||||
}
|
||||
std::mutex KeyboardHook::instancesMutex;
|
||||
std::unordered_set<KeyboardHook*> KeyboardHook::instances;
|
||||
|
||||
KeyboardHook::~KeyboardHook()
|
||||
{
|
||||
// Unregister low level hook procedure
|
||||
UnhookWindowsHookEx(hookHandle);
|
||||
}
|
||||
KeyboardHook::KeyboardHook(winrt::PowerToys::Interop::KeyboardEventCallback const& keyboardEventCallback, winrt::PowerToys::Interop::IsActiveCallback const& isActiveCallback, winrt::PowerToys::Interop::FilterKeyboardEvent const& filterKeyboardEvent)
|
||||
{
|
||||
this->keyboardEventCallback = keyboardEventCallback;
|
||||
this->isActiveCallback = isActiveCallback;
|
||||
this->filterKeyboardEvent = filterKeyboardEvent;
|
||||
}
|
||||
|
||||
void KeyboardHook::Start()
|
||||
{
|
||||
hookProc = gcnew HookProcDelegate(this, &KeyboardHook::HookProc);
|
||||
void KeyboardHook::Close()
|
||||
{
|
||||
std::unique_lock lock { instancesMutex };
|
||||
auto iter = instances.find(this);
|
||||
if (iter != instances.end())
|
||||
{
|
||||
instances.erase(iter);
|
||||
}
|
||||
if (instances.size() < 1 && hookHandle != nullptr)
|
||||
{
|
||||
if (UnhookWindowsHookEx(hookHandle))
|
||||
{
|
||||
hookHandle = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyboardHook::Start()
|
||||
{
|
||||
#if defined(DISABLE_LOWLEVEL_HOOKS_WHEN_DEBUGGED)
|
||||
const bool hookDisabled = IsDebuggerPresent();
|
||||
const bool hookDisabled = IsDebuggerPresent();
|
||||
#else
|
||||
const bool hookDisabled = false;
|
||||
const bool hookDisabled = false;
|
||||
#endif
|
||||
if (!hookDisabled)
|
||||
{
|
||||
// register low level hook procedure
|
||||
hookHandle = SetWindowsHookEx(
|
||||
WH_KEYBOARD_LL,
|
||||
(HOOKPROC)(void*)Marshal::GetFunctionPointerForDelegate(hookProc),
|
||||
0,
|
||||
0);
|
||||
if (hookHandle == nullptr)
|
||||
if (!hookDisabled)
|
||||
{
|
||||
DWORD errorCode = GetLastError();
|
||||
show_last_error_message(L"SetWindowsHookEx", errorCode, L"PowerToys - Interop");
|
||||
std::unique_lock lock { instancesMutex };
|
||||
assert(instances.find(this) == instances.end());
|
||||
// register low level hook procedure
|
||||
instances.insert(this);
|
||||
if (hookHandle == nullptr)
|
||||
{
|
||||
hookHandle = SetWindowsHookEx(
|
||||
WH_KEYBOARD_LL,
|
||||
HookProc,
|
||||
0,
|
||||
0);
|
||||
if (hookHandle == nullptr)
|
||||
{
|
||||
DWORD errorCode = GetLastError();
|
||||
show_last_error_message(L"SetWindowsHookEx", errorCode, L"PowerToys - Interop");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LRESULT KeyboardHook::HookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (nCode == HC_ACTION)
|
||||
{
|
||||
std::vector<KeyboardHook*> instances_copy;
|
||||
{
|
||||
/* Use a copy of instances, to iterate through the copy without needing to maintain the lock */
|
||||
std::unique_lock lock{ instancesMutex };
|
||||
instances_copy.reserve(instances.size());
|
||||
std::copy(instances.begin(), instances.end(), std::back_inserter(instances_copy));
|
||||
}
|
||||
|
||||
for (auto const& s_instance : instances_copy)
|
||||
{
|
||||
if (s_instance->isActiveCallback())
|
||||
{
|
||||
KeyboardEvent ev;
|
||||
ev.message = wParam;
|
||||
ev.key = reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam)->vkCode;
|
||||
ev.dwExtraInfo = reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam)->dwExtraInfo;
|
||||
|
||||
// Ignore the keyboard hook if the FilterkeyboardEvent returns false.
|
||||
if ((s_instance->filterKeyboardEvent != nullptr && !s_instance->filterKeyboardEvent(ev)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
s_instance->keyboardEventCallback(ev);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT __clrcall KeyboardHook::HookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (nCode == HC_ACTION && isActiveCallback->Invoke())
|
||||
{
|
||||
KeyboardEvent ^ ev = gcnew KeyboardEvent();
|
||||
ev->message = wParam;
|
||||
ev->key = reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam)->vkCode;
|
||||
ev->dwExtraInfo = reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam)->dwExtraInfo;
|
||||
|
||||
// Ignore the keyboard hook if the FilterkeyboardEvent returns false.
|
||||
if ((filterKeyboardEvent != nullptr && !filterKeyboardEvent->Invoke(ev)))
|
||||
{
|
||||
return CallNextHookEx(hookHandle, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
keyboardEventCallback->Invoke(ev);
|
||||
return 1;
|
||||
}
|
||||
return CallNextHookEx(hookHandle, nCode, wParam, lParam);
|
||||
}
|
||||
@@ -1,48 +1,35 @@
|
||||
#pragma once
|
||||
#include "KeyboardHook.g.h"
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
using namespace System::Threading;
|
||||
using namespace System::Collections::Generic;
|
||||
|
||||
namespace interop
|
||||
namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
public
|
||||
ref struct KeyboardEvent
|
||||
struct KeyboardHook : KeyboardHookT<KeyboardHook>
|
||||
{
|
||||
WPARAM message;
|
||||
int key;
|
||||
uint64_t dwExtraInfo;
|
||||
};
|
||||
|
||||
public
|
||||
delegate void KeyboardEventCallback(KeyboardEvent ^ ev);
|
||||
public
|
||||
delegate bool IsActiveCallback();
|
||||
public
|
||||
delegate bool FilterKeyboardEvent(KeyboardEvent ^ ev);
|
||||
|
||||
public
|
||||
ref class KeyboardHook
|
||||
{
|
||||
public:
|
||||
KeyboardHook(
|
||||
KeyboardEventCallback ^ keyboardEventCallback,
|
||||
IsActiveCallback ^ isActiveCallback,
|
||||
FilterKeyboardEvent ^ filterKeyboardEvent);
|
||||
~KeyboardHook();
|
||||
// KeyboardHook() = default;
|
||||
|
||||
KeyboardHook(winrt::PowerToys::Interop::KeyboardEventCallback const& keyboardEventCallback, winrt::PowerToys::Interop::IsActiveCallback const& isActiveCallback, winrt::PowerToys::Interop::FilterKeyboardEvent const& filterKeyboardEvent);
|
||||
void Start();
|
||||
void Close();
|
||||
|
||||
private:
|
||||
delegate LRESULT HookProcDelegate(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
KeyboardEventCallback ^ keyboardEventCallback;
|
||||
IsActiveCallback ^ isActiveCallback;
|
||||
FilterKeyboardEvent ^ filterKeyboardEvent;
|
||||
HHOOK hookHandle;
|
||||
HookProcDelegate ^ hookProc;
|
||||
winrt::PowerToys::Interop::KeyboardEventCallback keyboardEventCallback;
|
||||
winrt::PowerToys::Interop::IsActiveCallback isActiveCallback;
|
||||
winrt::PowerToys::Interop::FilterKeyboardEvent filterKeyboardEvent;
|
||||
|
||||
LRESULT __clrcall HookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
// This class used to be C++/CX, which meant it ran on .NET runtime and was able to send function pointer for delegates as hook procedures for SetWindowsHookEx which kept an object reference.
|
||||
// There doesn't seem to be a way to do this outside of the .NET runtime that allows us to get a proper C-style function.
|
||||
// The alternative when porting to C++/winrt is to keep track of every instance and use a single proc instead of one per object. This should also make it lighter.
|
||||
static std::mutex instancesMutex;
|
||||
static std::unordered_set<KeyboardHook*> instances;
|
||||
static inline HHOOK hookHandle = nullptr;
|
||||
static LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
}
|
||||
namespace winrt::PowerToys::Interop::factory_implementation
|
||||
{
|
||||
struct KeyboardHook : KeyboardHookT<KeyboardHook, implementation::KeyboardHook>
|
||||
{
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
23
src/common/interop/KeyboardHook.idl
Normal file
23
src/common/interop/KeyboardHook.idl
Normal file
@@ -0,0 +1,23 @@
|
||||
typedef UInt64 WPARAM;
|
||||
|
||||
namespace PowerToys
|
||||
{
|
||||
namespace Interop
|
||||
{
|
||||
struct KeyboardEvent
|
||||
{
|
||||
WPARAM message;
|
||||
Int32 key;
|
||||
UInt64 dwExtraInfo;
|
||||
};
|
||||
|
||||
[version(1.0), uuid(7b820173-a54a-4a38-b810-810e05c14344)] delegate void KeyboardEventCallback(KeyboardEvent ev);
|
||||
[version(1.0), uuid(e3a8bb91-0dfd-4d77-8472-75a47b7af8f8)] delegate Boolean IsActiveCallback();
|
||||
[version(1.0), uuid(94b900ee-d9e8-4630-9064-737eeb9c18ad)] delegate Boolean FilterKeyboardEvent(KeyboardEvent ev);
|
||||
|
||||
[default_interface] runtimeclass KeyboardHook: Windows.Foundation.IClosable {
|
||||
KeyboardHook(KeyboardEventCallback keyboardEventCallback, IsActiveCallback isActiveCallback, FilterKeyboardEvent filterKeyboardEvent);
|
||||
void Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
19
src/common/interop/LayoutMapManaged.cpp
Normal file
19
src/common/interop/LayoutMapManaged.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "pch.h"
|
||||
#include "LayoutMapManaged.h"
|
||||
#include "LayoutMapManaged.g.cpp"
|
||||
|
||||
namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
hstring LayoutMapManaged::GetKeyName(uint32_t key)
|
||||
{
|
||||
return hstring{ _map->GetKeyName(key) };
|
||||
}
|
||||
uint32_t LayoutMapManaged::GetKeyValue(hstring const& name)
|
||||
{
|
||||
return _map->GetKeyFromName(std::wstring(name));
|
||||
}
|
||||
void LayoutMapManaged::Updatelayout()
|
||||
{
|
||||
_map->UpdateLayout();
|
||||
}
|
||||
}
|
||||
24
src/common/interop/LayoutMapManaged.h
Normal file
24
src/common/interop/LayoutMapManaged.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "LayoutMapManaged.g.h"
|
||||
#include "keyboard_layout.h"
|
||||
|
||||
namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
struct LayoutMapManaged : LayoutMapManagedT<LayoutMapManaged>
|
||||
{
|
||||
LayoutMapManaged() = default;
|
||||
|
||||
hstring GetKeyName(uint32_t key);
|
||||
uint32_t GetKeyValue(hstring const& name);
|
||||
void Updatelayout();
|
||||
|
||||
private:
|
||||
std::unique_ptr<LayoutMap> _map = std::make_unique<LayoutMap>();
|
||||
};
|
||||
}
|
||||
namespace winrt::PowerToys::Interop::factory_implementation
|
||||
{
|
||||
struct LayoutMapManaged : LayoutMapManagedT<LayoutMapManaged, implementation::LayoutMapManaged>
|
||||
{
|
||||
};
|
||||
}
|
||||
12
src/common/interop/LayoutMapManaged.idl
Normal file
12
src/common/interop/LayoutMapManaged.idl
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace PowerToys
|
||||
{
|
||||
namespace Interop
|
||||
{
|
||||
[default_interface] runtimeclass LayoutMapManaged {
|
||||
LayoutMapManaged();
|
||||
String GetKeyName(UInt32 key);
|
||||
UInt32 GetKeyValue(String name);
|
||||
void Updatelayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
src/common/interop/PowerToys.Interop.def
Normal file
3
src/common/interop/PowerToys.Interop.def
Normal file
@@ -0,0 +1,3 @@
|
||||
EXPORTS
|
||||
DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
|
||||
DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" />
|
||||
<PropertyGroup>
|
||||
<AssemblyTitle>PowerToys.Interop</AssemblyTitle>
|
||||
</PropertyGroup>
|
||||
@@ -25,16 +25,25 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{F055103B-F80B-4D0C-BF48-057C55620033}</ProjectGuid>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
<RootNamespace>PowerToysInterop</RootNamespace>
|
||||
<RootNamespace>PowerToys.Interop</RootNamespace>
|
||||
<ProjectName>PowerToys.Interop</ProjectName>
|
||||
<CppWinRTOptimized>true</CppWinRTOptimized>
|
||||
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
|
||||
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
|
||||
<MinimalCoreWin>true</MinimalCoreWin>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
<AppContainerApplication>false</AppContainerApplication>
|
||||
<AppxPackage>false</AppxPackage>
|
||||
<ApplicationType>Windows Store</ApplicationType>
|
||||
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CLRSupport>NetCore</CLRSupport>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@@ -55,93 +64,122 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>PowerToysInterop;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
|
||||
<PreprocessorDefinitions>_WINRT_DLL;WINRT_LEAN_AND_MEAN;PowerToysInterop;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)src\common\interop;../../;../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<OmitDefaultLibName>false</OmitDefaultLibName>
|
||||
<AdditionalOptions>/Zc:twoPhase- </AdditionalOptions>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalOptions>%(AdditionalOptions) /bigobj /Zc:twoPhase- </AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>WindowsApp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>WindowsApp.lib;shell32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
|
||||
<ModuleDefinitionFile>PowerToys.Interop.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<AssemblyVersionFiles Include="Generated Files\AssemblyInfo.cpp" />
|
||||
</ItemGroup>
|
||||
<Target Name="GenerateAssemblyInfo" BeforeTargets="PrepareForBuild">
|
||||
<ItemGroup>
|
||||
<HeaderLines Include="#include "../pch.h"" />
|
||||
<HeaderLines Include="using namespace System%3b" />
|
||||
<HeaderLines Include="using namespace System::Reflection%3b" />
|
||||
<HeaderLines Include="using namespace System::Runtime::CompilerServices%3b" />
|
||||
<HeaderLines Include="using namespace System::Runtime::InteropServices%3b" />
|
||||
<HeaderLines Include="using namespace System::Security::Permissions%3b" />
|
||||
<HeaderLines Include="[assembly: AssemblyTitleAttribute(L"$(AssemblyTitle)")]%3b" />
|
||||
<HeaderLines Include="[assembly: AssemblyDescriptionAttribute("")]%3b" />
|
||||
<HeaderLines Include="[assembly: AssemblyConfigurationAttribute("")]%3b" />
|
||||
<HeaderLines Include="[assembly: AssemblyCompanyAttribute("$(AssemblyCompany)")]%3b" />
|
||||
<HeaderLines Include="[assembly: AssemblyCopyrightAttribute("$(AssemblyCopyright)")]%3b" />
|
||||
<HeaderLines Include="[assembly: AssemblyProductAttribute("$(AssemblyTitle)")]%3b" />
|
||||
<HeaderLines Include="[assembly: AssemblyTrademarkAttribute("")]%3b" />
|
||||
<HeaderLines Include="[assembly: AssemblyCultureAttribute("")]%3b" />
|
||||
<HeaderLines Include="[assembly: AssemblyVersionAttribute("$(Version).0")]%3b" />
|
||||
<HeaderLines Include="[assembly: ComVisible(false)]%3b" />
|
||||
<HeaderLines Include="[assembly:CLSCompliantAttribute(true)]%3b" />
|
||||
</ItemGroup>
|
||||
<WriteLinesToFile File="Generated Files\AssemblyInfo.cpp" Lines="@(HeaderLines)" Overwrite="true" Encoding="Unicode" WriteOnlyWhenDifferent="true" />
|
||||
</Target>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\modules\videoconference\VideoConferenceShared\MicrophoneDevice.h" />
|
||||
<ClInclude Include="..\..\modules\videoconference\VideoConferenceShared\VideoCaptureDeviceList.h" />
|
||||
<ClInclude Include="HotkeyManager.h" />
|
||||
<ClInclude Include="KeyboardHook.h" />
|
||||
<ClInclude Include="async_message_queue.h" />
|
||||
<ClInclude Include="CommonManaged.h">
|
||||
<DependentUpon>CommonManaged.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Constants.h">
|
||||
<DependentUpon>KeyboardListener.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HotkeyManager.h">
|
||||
<DependentUpon>HotkeyManager.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="KeyboardHook.h">
|
||||
<DependentUpon>KeyboardHook.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="keyboard_layout.h" />
|
||||
<ClInclude Include="keyboard_layout_impl.h" />
|
||||
<ClInclude Include="LayoutMapManaged.h">
|
||||
<DependentUpon>LayoutMapManaged.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="shared_constants.h" />
|
||||
<ClInclude Include="TwoWayPipeMessageIPCManaged.h">
|
||||
<DependentUpon>TwoWayPipeMessageIPCManaged.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="two_way_pipe_message_ipc.h" />
|
||||
<ClInclude Include="two_way_pipe_message_ipc_impl.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\modules\videoconference\VideoConferenceShared\MicrophoneDevice.cpp">
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<ClCompile Include="..\..\modules\videoconference\VideoConferenceShared\MicrophoneDevice.cpp" />
|
||||
<ClCompile Include="..\..\modules\videoconference\VideoConferenceShared\VideoCaptureDeviceList.cpp" />
|
||||
<ClCompile Include="CommonManaged.cpp">
|
||||
<DependentUpon>CommonManaged.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\videoconference\VideoConferenceShared\VideoCaptureDeviceList.cpp">
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<ClCompile Include="Constants.cpp">
|
||||
<DependentUpon>KeyboardListener.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Generated Files\AssemblyInfo.cpp" />
|
||||
<ClCompile Include="HotkeyManager.cpp" />
|
||||
<ClCompile Include="interop.cpp" />
|
||||
<ClCompile Include="KeyboardHook.cpp" />
|
||||
<ClCompile Include="keyboard_layout.cpp">
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<ClCompile Include="HotkeyManager.cpp">
|
||||
<DependentUpon>HotkeyManager.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="two_way_pipe_message_ipc.cpp">
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<ClCompile Include="KeyboardHook.cpp">
|
||||
<DependentUpon>KeyboardHook.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="keyboard_layout.cpp" />
|
||||
<ClCompile Include="LayoutMapManaged.cpp">
|
||||
<DependentUpon>LayoutMapManaged.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TwoWayPipeMessageIPCManaged.cpp">
|
||||
<DependentUpon>TwoWayPipeMessageIPCManaged.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="two_way_pipe_message_ipc.cpp" />
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="interop.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="PowerToys.Interop.def" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="PropertySheet.props" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Midl Include="CommonManaged.idl" />
|
||||
<Midl Include="Constants.idl" />
|
||||
<Midl Include="HotkeyManager.idl" />
|
||||
<Midl Include="KeyboardHook.idl" />
|
||||
<Midl Include="LayoutMapManaged.idl" />
|
||||
<Midl Include="TwoWayPipeMessageIPCManaged.idl" />
|
||||
</ItemGroup>
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.231216.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.231216.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
|
||||
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.231216.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.231216.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -18,12 +18,6 @@
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="KeyboardHook.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HotkeyManager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -36,23 +30,38 @@
|
||||
<ClInclude Include="shared_constants.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Constants.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="keyboard_layout.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="keyboard_layout_impl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LayoutMapManaged.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CommonManaged.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="two_way_pipe_message_ipc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="two_way_pipe_message_ipc_impl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="async_message_queue.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HotkeyManager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Constants.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="interop.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Generated Files\AssemblyInfo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="KeyboardHook.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HotkeyManager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="two_way_pipe_message_ipc.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="keyboard_layout.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -62,6 +71,30 @@
|
||||
<ClCompile Include="..\..\modules\videoconference\VideoConferenceShared\VideoCaptureDeviceList.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Constants.cpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayoutMapManaged.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CommonManaged.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="two_way_pipe_message_ipc.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HotkeyManager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Constants.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="interop.rc">
|
||||
@@ -69,9 +102,33 @@
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natvis" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="PowerToys.Interop.def">
|
||||
<Filter>Source Files</Filter>
|
||||
</None>
|
||||
<None Include="PropertySheet.props" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<Midl Include="HotkeyManager.idl">
|
||||
<Filter>Source Files</Filter>
|
||||
</Midl>
|
||||
<Midl Include="Constants.idl">
|
||||
<Filter>Source Files</Filter>
|
||||
</Midl>
|
||||
<Midl Include="LayoutMapManaged.idl">
|
||||
<Filter>Source Files</Filter>
|
||||
</Midl>
|
||||
<Midl Include="CommonManaged.idl">
|
||||
<Filter>Source Files</Filter>
|
||||
</Midl>
|
||||
<Midl Include="KeyboardHook.idl">
|
||||
<Filter>Source Files</Filter>
|
||||
</Midl>
|
||||
<Midl Include="TwoWayPipeMessageIPCManaged.idl">
|
||||
<Filter>Source Files</Filter>
|
||||
</Midl>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natvis" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
16
src/common/interop/PropertySheet.props
Normal file
16
src/common/interop/PropertySheet.props
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<!--
|
||||
To customize common C++/WinRT project properties:
|
||||
* right-click the project node
|
||||
* expand the Common Properties item
|
||||
* select the C++/WinRT property page
|
||||
|
||||
For more advanced scenarios, and complete documentation, please see:
|
||||
https://github.com/Microsoft/cppwinrt/tree/master/nuget
|
||||
-->
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup />
|
||||
</Project>
|
||||
37
src/common/interop/TwoWayPipeMessageIPCManaged.cpp
Normal file
37
src/common/interop/TwoWayPipeMessageIPCManaged.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "pch.h"
|
||||
#include "TwoWayPipeMessageIPCManaged.h"
|
||||
#include "TwoWayPipeMessageIPCManaged.g.cpp"
|
||||
#include "two_way_pipe_message_ipc_impl.h"
|
||||
#include <functional>
|
||||
|
||||
namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
TwoWayPipeMessageIPCManaged::TwoWayPipeMessageIPCManaged(hstring const& inputPipeName, hstring const& outputPipeName, winrt::PowerToys::Interop::TwoWayPipeIPCReadCallback const& _callback)
|
||||
{
|
||||
this->_callback = _callback;
|
||||
if (_callback != nullptr)
|
||||
{
|
||||
_internalReadCallback = [this](const std::wstring& msg) {
|
||||
this->_callback(msg);
|
||||
};
|
||||
}
|
||||
_pipe = new TwoWayPipeMessageIPC(std::wstring{ inputPipeName }, std::wstring{ outputPipeName }, _internalReadCallback);
|
||||
}
|
||||
|
||||
void TwoWayPipeMessageIPCManaged::Send(hstring const& msg)
|
||||
{
|
||||
_pipe->send(std::wstring{ msg });
|
||||
}
|
||||
void TwoWayPipeMessageIPCManaged::Start()
|
||||
{
|
||||
_pipe->start(nullptr);
|
||||
}
|
||||
void TwoWayPipeMessageIPCManaged::End()
|
||||
{
|
||||
_pipe->end();
|
||||
}
|
||||
void TwoWayPipeMessageIPCManaged::Close()
|
||||
{
|
||||
delete _pipe;
|
||||
}
|
||||
}
|
||||
28
src/common/interop/TwoWayPipeMessageIPCManaged.h
Normal file
28
src/common/interop/TwoWayPipeMessageIPCManaged.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "TwoWayPipeMessageIPCManaged.g.h"
|
||||
#include "two_way_pipe_message_ipc.h"
|
||||
|
||||
namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
struct TwoWayPipeMessageIPCManaged : TwoWayPipeMessageIPCManagedT<TwoWayPipeMessageIPCManaged>
|
||||
{
|
||||
TwoWayPipeMessageIPCManaged() = default;
|
||||
|
||||
TwoWayPipeMessageIPCManaged(hstring const& inputPipeName, hstring const& outputPipeName, winrt::PowerToys::Interop::TwoWayPipeIPCReadCallback const& _callback);
|
||||
void Send(hstring const& msg);
|
||||
void Start();
|
||||
void End();
|
||||
void Close();
|
||||
|
||||
private:
|
||||
TwoWayPipeMessageIPC* _pipe;
|
||||
TwoWayPipeIPCReadCallback _callback;
|
||||
std::function<void(const std::wstring& msg)> _internalReadCallback;
|
||||
};
|
||||
}
|
||||
namespace winrt::PowerToys::Interop::factory_implementation
|
||||
{
|
||||
struct TwoWayPipeMessageIPCManaged : TwoWayPipeMessageIPCManagedT<TwoWayPipeMessageIPCManaged, implementation::TwoWayPipeMessageIPCManaged>
|
||||
{
|
||||
};
|
||||
}
|
||||
14
src/common/interop/TwoWayPipeMessageIPCManaged.idl
Normal file
14
src/common/interop/TwoWayPipeMessageIPCManaged.idl
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace PowerToys
|
||||
{
|
||||
namespace Interop
|
||||
{
|
||||
delegate void TwoWayPipeIPCReadCallback(String message);
|
||||
[default_interface] runtimeclass TwoWayPipeMessageIPCManaged : Windows.Foundation.IClosable
|
||||
{
|
||||
TwoWayPipeMessageIPCManaged(String inputPipeName, String outputPipeName, TwoWayPipeIPCReadCallback _callback);
|
||||
void Send(String msg);
|
||||
void Start();
|
||||
void End();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using interop;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using PowerToys.Interop;
|
||||
|
||||
namespace Microsoft.Interop.Tests
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
|
||||
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
||||
@@ -46,7 +46,15 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.Interop</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="MSTest" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,299 +0,0 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include <msclr/marshal.h>
|
||||
#include <msclr/marshal_cppstd.h>
|
||||
#include <functional>
|
||||
#include "keyboard_layout.h"
|
||||
#include "two_way_pipe_message_ipc.h"
|
||||
#include "shared_constants.h"
|
||||
|
||||
// We cannot use C++/WinRT APIs when compiled with /clr (we'll get a runtime crash). os-detect API is used
|
||||
// in both native C++ and C++/CX.
|
||||
// We also cannot compile it as a library, since we use different cppruntime linkage in C++/CX and native C++.
|
||||
// Therefore the simplest way is to compile these functions as native using the pragmas below.
|
||||
#pragma managed(push, off)
|
||||
#include "../utils/os-detect.h"
|
||||
// TODO: move to a separate library in common
|
||||
#include "../../modules/videoconference/VideoConferenceShared/MicrophoneDevice.h"
|
||||
#include "../../modules/videoconference/VideoConferenceShared/VideoCaptureDeviceList.h"
|
||||
#pragma managed(pop)
|
||||
|
||||
#include <common/version/version.h>
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Runtime::InteropServices;
|
||||
using System::Collections::Generic::List;
|
||||
|
||||
// https://learn.microsoft.com/cpp/dotnet/how-to-wrap-native-class-for-use-by-csharp?view=vs-2019
|
||||
namespace interop
|
||||
{
|
||||
public
|
||||
ref class LayoutMapManaged
|
||||
{
|
||||
public:
|
||||
LayoutMapManaged() :
|
||||
_map(new LayoutMap) {}
|
||||
|
||||
~LayoutMapManaged()
|
||||
{
|
||||
delete _map;
|
||||
}
|
||||
|
||||
String ^ GetKeyName(DWORD key)
|
||||
{
|
||||
return gcnew String(_map->GetKeyName(key).c_str());
|
||||
}
|
||||
|
||||
DWORD GetKeyValue(String ^ name)
|
||||
{
|
||||
return _map->GetKeyFromName(msclr::interop::marshal_as<std::wstring>(name));
|
||||
}
|
||||
|
||||
void Updatelayout()
|
||||
{
|
||||
_map->UpdateLayout();
|
||||
}
|
||||
|
||||
protected:
|
||||
!LayoutMapManaged()
|
||||
{
|
||||
delete _map;
|
||||
}
|
||||
|
||||
private:
|
||||
LayoutMap* _map;
|
||||
};
|
||||
|
||||
public
|
||||
ref class TwoWayPipeMessageIPCManaged
|
||||
{
|
||||
public:
|
||||
delegate void ReadCallback(String ^ message);
|
||||
|
||||
TwoWayPipeMessageIPCManaged(String ^ inputPipeName, String ^ outputPipeName, ReadCallback ^ callback)
|
||||
{
|
||||
_wrapperCallback = gcnew InternalReadCallback(this, &TwoWayPipeMessageIPCManaged::ReadCallbackHelper);
|
||||
_callback = callback;
|
||||
|
||||
TwoWayPipeMessageIPC::callback_function cb = nullptr;
|
||||
if (callback != nullptr)
|
||||
{
|
||||
cb = (TwoWayPipeMessageIPC::callback_function)(void*)Marshal::GetFunctionPointerForDelegate(_wrapperCallback);
|
||||
}
|
||||
_pipe = new TwoWayPipeMessageIPC(
|
||||
msclr::interop::marshal_as<std::wstring>(inputPipeName),
|
||||
msclr::interop::marshal_as<std::wstring>(outputPipeName),
|
||||
cb);
|
||||
}
|
||||
|
||||
~TwoWayPipeMessageIPCManaged()
|
||||
{
|
||||
delete _pipe;
|
||||
}
|
||||
|
||||
void Send(String ^ msg)
|
||||
{
|
||||
_pipe->send(msclr::interop::marshal_as<std::wstring>(msg));
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
_pipe->start(nullptr);
|
||||
}
|
||||
|
||||
void End()
|
||||
{
|
||||
_pipe->end();
|
||||
}
|
||||
|
||||
protected:
|
||||
!TwoWayPipeMessageIPCManaged()
|
||||
{
|
||||
delete _pipe;
|
||||
}
|
||||
|
||||
private:
|
||||
delegate void InternalReadCallback(const std::wstring& msg);
|
||||
|
||||
TwoWayPipeMessageIPC* _pipe;
|
||||
ReadCallback ^ _callback;
|
||||
InternalReadCallback ^ _wrapperCallback;
|
||||
|
||||
void ReadCallbackHelper(const std::wstring& msg)
|
||||
{
|
||||
_callback(gcnew String(msg.c_str()));
|
||||
}
|
||||
};
|
||||
|
||||
public
|
||||
ref class CommonManaged
|
||||
{
|
||||
public:
|
||||
static String ^ GetProductVersion() {
|
||||
return gcnew String(get_product_version().c_str());
|
||||
}
|
||||
|
||||
static List<String ^> ^ GetAllActiveMicrophoneDeviceNames() {
|
||||
auto names = gcnew List<String ^>();
|
||||
for (const auto& device : MicrophoneDevice::getAllActive())
|
||||
{
|
||||
names->Add(gcnew String(device->name().data()));
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
static List<String ^> ^
|
||||
GetAllVideoCaptureDeviceNames() {
|
||||
auto names = gcnew List<String ^>();
|
||||
VideoCaptureDeviceList vcdl;
|
||||
vcdl.EnumerateDevices();
|
||||
|
||||
for (UINT32 i = 0; i < vcdl.Count(); ++i)
|
||||
{
|
||||
auto name = gcnew String(vcdl.GetDeviceName(i).data());
|
||||
if (name != L"PowerToys VideoConference Mute")
|
||||
{
|
||||
names->Add(name);
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
};
|
||||
|
||||
public
|
||||
ref class Constants
|
||||
{
|
||||
public:
|
||||
literal int VK_WIN_BOTH = CommonSharedConstants::VK_WIN_BOTH;
|
||||
|
||||
static String ^ AppDataPath() {
|
||||
auto localPath = Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData);
|
||||
auto powerToysPath = gcnew String(CommonSharedConstants::APPDATA_PATH);
|
||||
return System::IO::Path::Combine(localPath, powerToysPath);
|
||||
}
|
||||
|
||||
static String ^ PowerLauncherSharedEvent() {
|
||||
return gcnew String(CommonSharedConstants::POWER_LAUNCHER_SHARED_EVENT);
|
||||
}
|
||||
|
||||
static String ^ PowerLauncherCentralizedHookSharedEvent() {
|
||||
return gcnew String(CommonSharedConstants::POWER_LAUNCHER_CENTRALIZED_HOOK_SHARED_EVENT);
|
||||
}
|
||||
|
||||
static String ^ RunSendSettingsTelemetryEvent() {
|
||||
return gcnew String(CommonSharedConstants::RUN_SEND_SETTINGS_TELEMETRY_EVENT);
|
||||
}
|
||||
|
||||
static String ^ RunExitEvent() {
|
||||
return gcnew String(CommonSharedConstants::RUN_EXIT_EVENT);
|
||||
}
|
||||
|
||||
static String ^ FZEExitEvent() {
|
||||
return gcnew String(CommonSharedConstants::FZE_EXIT_EVENT);
|
||||
}
|
||||
|
||||
static String ^ FZEToggleEvent() {
|
||||
return gcnew String(CommonSharedConstants::FANCY_ZONES_EDITOR_TOGGLE_EVENT);
|
||||
}
|
||||
|
||||
static String ^ ColorPickerSendSettingsTelemetryEvent() {
|
||||
return gcnew String(CommonSharedConstants::COLOR_PICKER_SEND_SETTINGS_TELEMETRY_EVENT);
|
||||
}
|
||||
|
||||
static String ^ ShowColorPickerSharedEvent() {
|
||||
return gcnew String(CommonSharedConstants::SHOW_COLOR_PICKER_SHARED_EVENT);
|
||||
}
|
||||
|
||||
static String ^ ShowAdvancedPasteSharedEvent() {
|
||||
return gcnew String(CommonSharedConstants::SHOW_ADVANCED_PASTE_SHARED_EVENT);
|
||||
}
|
||||
|
||||
static String ^ AdvancedPasteMarkdownEvent() {
|
||||
return gcnew String(CommonSharedConstants::ADVANCED_PASTE_MARKDOWN_EVENT);
|
||||
}
|
||||
|
||||
static String ^ AdvancedPasteJsonEvent() {
|
||||
return gcnew String(CommonSharedConstants::ADVANCED_PASTE_JSON_EVENT);
|
||||
}
|
||||
|
||||
static String ^ ShowPowerOCRSharedEvent() {
|
||||
return gcnew String(CommonSharedConstants::SHOW_POWEROCR_SHARED_EVENT);
|
||||
}
|
||||
|
||||
static String ^ MouseJumpShowPreviewEvent() {
|
||||
return gcnew String(CommonSharedConstants::MOUSE_JUMP_SHOW_PREVIEW_EVENT);
|
||||
}
|
||||
|
||||
static String ^ AwakeExitEvent() {
|
||||
return gcnew String(CommonSharedConstants::AWAKE_EXIT_EVENT);
|
||||
}
|
||||
|
||||
static String^ ShowPeekEvent() {
|
||||
return gcnew String(CommonSharedConstants::SHOW_PEEK_SHARED_EVENT);
|
||||
}
|
||||
|
||||
static String ^ PowerAccentExitEvent() {
|
||||
return gcnew String(CommonSharedConstants::POWERACCENT_EXIT_EVENT);
|
||||
}
|
||||
|
||||
static String ^ ShortcutGuideTriggerEvent() {
|
||||
return gcnew String(CommonSharedConstants::SHORTCUT_GUIDE_TRIGGER_EVENT);
|
||||
}
|
||||
|
||||
static String ^ RegistryPreviewTriggerEvent() {
|
||||
return gcnew String(CommonSharedConstants::REGISTRY_PREVIEW_TRIGGER_EVENT);
|
||||
}
|
||||
|
||||
static String ^ MeasureToolTriggerEvent() {
|
||||
return gcnew String(CommonSharedConstants::MEASURE_TOOL_TRIGGER_EVENT);
|
||||
}
|
||||
|
||||
static String ^ GcodePreviewResizeEvent() {
|
||||
return gcnew String(CommonSharedConstants::GCODE_PREVIEW_RESIZE_EVENT);
|
||||
}
|
||||
|
||||
static String ^ QoiPreviewResizeEvent() {
|
||||
return gcnew String(CommonSharedConstants::QOI_PREVIEW_RESIZE_EVENT);
|
||||
}
|
||||
|
||||
static String ^ DevFilesPreviewResizeEvent() {
|
||||
return gcnew String(CommonSharedConstants::DEV_FILES_PREVIEW_RESIZE_EVENT);
|
||||
}
|
||||
|
||||
static String ^ MarkdownPreviewResizeEvent() {
|
||||
return gcnew String(CommonSharedConstants::MARKDOWN_PREVIEW_RESIZE_EVENT);
|
||||
}
|
||||
|
||||
static String ^ PdfPreviewResizeEvent() {
|
||||
return gcnew String(CommonSharedConstants::PDF_PREVIEW_RESIZE_EVENT);
|
||||
}
|
||||
|
||||
static String ^ SvgPreviewResizeEvent() {
|
||||
return gcnew String(CommonSharedConstants::SVG_PREVIEW_RESIZE_EVENT);
|
||||
}
|
||||
|
||||
static String ^ ShowHostsSharedEvent() {
|
||||
return gcnew String(CommonSharedConstants::SHOW_HOSTS_EVENT);
|
||||
}
|
||||
|
||||
static String ^ ShowHostsAdminSharedEvent() {
|
||||
return gcnew String(CommonSharedConstants::SHOW_HOSTS_ADMIN_EVENT);
|
||||
}
|
||||
|
||||
static String ^ CropAndLockThumbnailEvent() {
|
||||
return gcnew String(CommonSharedConstants::CROP_AND_LOCK_THUMBNAIL_EVENT);
|
||||
}
|
||||
|
||||
static String ^ CropAndLockReparentEvent() {
|
||||
return gcnew String(CommonSharedConstants::CROP_AND_LOCK_REPARENT_EVENT);
|
||||
}
|
||||
|
||||
static String ^ ShowEnvironmentVariablesSharedEvent() {
|
||||
return gcnew String(CommonSharedConstants::SHOW_ENVIRONMENT_VARIABLES_EVENT);
|
||||
}
|
||||
|
||||
static String ^ ShowEnvironmentVariablesAdminSharedEvent() {
|
||||
return gcnew String(CommonSharedConstants::SHOW_ENVIRONMENT_VARIABLES_ADMIN_EVENT);
|
||||
}
|
||||
};
|
||||
}
|
||||
1
src/common/interop/pch.cpp
Normal file
1
src/common/interop/pch.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "pch.h"
|
||||
@@ -3,13 +3,12 @@
|
||||
// This also affects IntelliSense performance, including code completion and many code browsing features.
|
||||
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
|
||||
// Do not add files here that you will be updating frequently as this negates the performance advantage.
|
||||
|
||||
#ifndef PCH_H
|
||||
#define PCH_H
|
||||
|
||||
#pragma once
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
// add headers that you want to pre-compile here
|
||||
#include <unknwn.h>
|
||||
#include <winrt/base.h>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <Windows.h>
|
||||
#include <Endpointvolume.h>
|
||||
|
||||
#endif //PCH_H
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
class TwoWayPipeMessageIPC
|
||||
{
|
||||
public:
|
||||
typedef void (*callback_function)(const std::wstring&);
|
||||
typedef std::function<void(const std::wstring&)>callback_function;
|
||||
TwoWayPipeMessageIPC(
|
||||
std::wstring _input_pipe_name,
|
||||
std::wstring _output_pipe_name,
|
||||
|
||||
@@ -220,7 +220,7 @@ class {{module.Name}} {
|
||||
}
|
||||
|
||||
var enumsBlock = string.Join(DoubleNewLine, enumsToEmit.Select(EmitEnumDefinition));
|
||||
var version = interop.CommonManaged.GetProductVersion().Replace("v", string.Empty);
|
||||
var version = PowerToys.Interop.CommonManaged.GetProductVersion().Replace("v", string.Empty);
|
||||
var outputResult = string.Empty;
|
||||
|
||||
outputResult += $$"""
|
||||
@@ -393,7 +393,7 @@ class {{module.Name}} {
|
||||
|
||||
public static string EmitManifestFileContents()
|
||||
{
|
||||
var version = interop.CommonManaged.GetProductVersion().Replace("v", string.Empty) + ".0";
|
||||
var version = PowerToys.Interop.CommonManaged.GetProductVersion().Replace("v", string.Empty) + ".0";
|
||||
var generatedDate = DateTime.Now.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture);
|
||||
|
||||
return $$"""
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Project="$(SolutionDir)src\Common.SelfContained.props" />
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<RootNamespace>PowerToys.Settings.DSC.Schema</RootNamespace>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
||||
@@ -36,6 +36,9 @@
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
||||
|
||||
@@ -88,9 +88,9 @@ namespace AdvancedPaste
|
||||
}
|
||||
}
|
||||
|
||||
NativeEventWaiter.WaitForEventLoop(interop.Constants.ShowAdvancedPasteSharedEvent(), OnAdvancedPasteHotkey);
|
||||
NativeEventWaiter.WaitForEventLoop(interop.Constants.AdvancedPasteMarkdownEvent(), OnAdvancedPasteMarkdownHotkey);
|
||||
NativeEventWaiter.WaitForEventLoop(interop.Constants.AdvancedPasteJsonEvent(), OnAdvancedPasteJsonHotkey);
|
||||
NativeEventWaiter.WaitForEventLoop(PowerToys.Interop.Constants.ShowAdvancedPasteSharedEvent(), OnAdvancedPasteHotkey);
|
||||
NativeEventWaiter.WaitForEventLoop(PowerToys.Interop.Constants.AdvancedPasteMarkdownEvent(), OnAdvancedPasteMarkdownHotkey);
|
||||
NativeEventWaiter.WaitForEventLoop(PowerToys.Interop.Constants.AdvancedPasteJsonEvent(), OnAdvancedPasteJsonHotkey);
|
||||
}
|
||||
|
||||
private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
|
||||
|
||||
@@ -10,7 +10,7 @@ static bool is_directory(const std::wstring path)
|
||||
}
|
||||
|
||||
// C++20 method
|
||||
static bool starts_with(std::wstring_view whole, std::wstring_view part)
|
||||
static constexpr bool starts_with(std::wstring_view whole, std::wstring_view part)
|
||||
{
|
||||
return whole.size() >= part.size() && whole.substr(0, part.size()) == part;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ std::wstring pid_to_full_path(DWORD pid)
|
||||
std::wstring result(LongMaxPathSize, L'\0');
|
||||
|
||||
// Returns zero on failure, so it's okay to resize to zero.
|
||||
auto length = GetModuleFileNameExW(process, NULL, result.data(), (DWORD)result.size());
|
||||
auto length = GetModuleFileNameExW(process, NULL, result.data(), static_cast<DWORD>(result.size()));
|
||||
result.resize(length);
|
||||
|
||||
CloseHandle(process);
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" />
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|ARM64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
@@ -30,57 +23,58 @@
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{c604b37e-9d0e-4484-8778-e8b31b0e1b3a}</ProjectGuid>
|
||||
<RootNamespace>FileLocksmithLibInterop</RootNamespace>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ProjectName>PowerToys.FileLocksmithLib.Interop</ProjectName>
|
||||
<RootNamespace>PowerToys.FileLocksmithLib.Interop</RootNamespace>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\</OutDir>
|
||||
<TargetName>PowerToys.FileLocksmithLib.Interop</TargetName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<PropertyGroup Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>NetCore</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>NetCore</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>NetCore</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>NetCore</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>NetCore</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>NetCore</CLRSupport>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>FILELOCKSMITHLIBINTEROP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalOptions>%(AdditionalOptions) /bigobj /Zc:twoPhase-</AdditionalOptions>
|
||||
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<ModuleDefinitionFile>PowerToys.FileLocksmithLibInterop.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<PropertyGroup>
|
||||
<CopyCppRuntimeToOutputDir>true</CopyCppRuntimeToOutputDir>
|
||||
</PropertyGroup>
|
||||
@@ -89,115 +83,36 @@
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;FILELOCKSMITHLIBINTEROP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<CompileAsManaged>NetCore</CompileAsManaged>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<AdditionalOptions>/Zc:twoPhase-</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;FILELOCKSMITHLIBINTEROP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<CompileAsManaged>NetCore</CompileAsManaged>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<AdditionalOptions>/Zc:twoPhase-</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;FILELOCKSMITHLIBINTEROP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<CompileAsManaged>NetCore</CompileAsManaged>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalOptions>/Zc:twoPhase-</AdditionalOptions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;FILELOCKSMITHLIBINTEROP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<CompileAsManaged>NetCore</CompileAsManaged>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalOptions>/Zc:twoPhase-</AdditionalOptions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="FileLocksmith.cpp" />
|
||||
<ClCompile Include="Interop.cpp" />
|
||||
<ClCompile Include="NativeMethods.cpp">
|
||||
<DependentUpon>NativeMethods.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NtdllBase.cpp" />
|
||||
<ClCompile Include="NtdllExtensions.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(UsePrecompiledHeaders)' != 'false'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ProcessResult.cpp">
|
||||
<DependentUpon>ProcessResult.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="FileLocksmith.h" />
|
||||
<ClInclude Include="NativeMethods.h">
|
||||
<DependentUpon>NativeMethods.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NtdllBase.h" />
|
||||
<ClInclude Include="NtdllExtensions.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="ProcessResult.h">
|
||||
<DependentUpon>ProcessResult.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -208,7 +123,23 @@
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="FileLocksmithLibInterop.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="PowerToys.Interop.def" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Midl Include="NativeMethods.idl" />
|
||||
<Midl Include="ProcessResult.idl" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -15,9 +15,6 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Interop.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -30,6 +27,12 @@
|
||||
<ClCompile Include="NtdllExtensions.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ProcessResult.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NativeMethods.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h">
|
||||
@@ -47,10 +50,27 @@
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ProcessResult.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NativeMethods.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="FileLocksmithLibInterop.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Midl Include="ProcessResult.idl">
|
||||
<Filter>Source Files</Filter>
|
||||
</Midl>
|
||||
<Midl Include="NativeMethods.idl">
|
||||
<Filter>Source Files</Filter>
|
||||
</Midl>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,208 @@
|
||||
#include "pch.h"
|
||||
#include "NativeMethods.h"
|
||||
#include "FileLocksmith.h"
|
||||
#include "../FileLocksmithLib/Constants.h"
|
||||
|
||||
namespace winrt::PowerToys::FileLocksmithLib::Interop::implementation
|
||||
{
|
||||
|
||||
#pragma region HelperMethods
|
||||
std::wstring executable_path()
|
||||
{
|
||||
return pid_to_full_path(GetCurrentProcessId());
|
||||
}
|
||||
std::wstring paths_file()
|
||||
{
|
||||
std::wstring path{ PowerToys::Interop::Constants::AppDataPath() };
|
||||
path += L"\\";
|
||||
path += constants::nonlocalizable::PowerToyName;
|
||||
path += L"\\";
|
||||
path += constants::nonlocalizable::LastRunPath;
|
||||
return path;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
com_array<winrt::PowerToys::FileLocksmithLib::Interop::ProcessResult> NativeMethods::FindProcessesRecursive(array_view<hstring const> paths)
|
||||
{
|
||||
std::vector<std::wstring> paths_cpp{ paths.begin(), paths.end() };
|
||||
|
||||
auto result_cpp = find_processes_recursive(paths_cpp);
|
||||
const auto result_size = static_cast<int>(result_cpp.size());
|
||||
|
||||
std::vector<ProcessResult> result;
|
||||
|
||||
if (result_size == 0)
|
||||
{
|
||||
return com_array<ProcessResult>();
|
||||
}
|
||||
|
||||
for (int i = 0; i < result_size; i++)
|
||||
{
|
||||
result.push_back(ProcessResult
|
||||
{
|
||||
hstring { result_cpp[i].name },
|
||||
result_cpp[i].pid,
|
||||
hstring{ result_cpp[i].user },
|
||||
winrt::com_array<hstring>
|
||||
{
|
||||
result_cpp[i].files.begin(), result_cpp[i].files.end()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return com_array<ProcessResult>{ result.begin(), result.end() };
|
||||
}
|
||||
|
||||
hstring NativeMethods::PidToFullPath(uint32_t pid)
|
||||
{
|
||||
return hstring{ pid_to_full_path(pid) };
|
||||
}
|
||||
|
||||
com_array<hstring> NativeMethods::ReadPathsFromFile()
|
||||
{
|
||||
std::ifstream stream(paths_file());
|
||||
|
||||
std::vector<std::wstring> result_cpp;
|
||||
std::wstring line;
|
||||
|
||||
bool finished = false;
|
||||
|
||||
while (!finished)
|
||||
{
|
||||
WCHAR ch{};
|
||||
// We have to read data like this
|
||||
if (!stream.read(reinterpret_cast<char*>(&ch), 2))
|
||||
{
|
||||
finished = true;
|
||||
}
|
||||
else if (ch == L'\n')
|
||||
{
|
||||
if (line.empty())
|
||||
{
|
||||
finished = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result_cpp.push_back(line);
|
||||
line = {};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
line += ch;
|
||||
}
|
||||
}
|
||||
return com_array<hstring>{ result_cpp.begin(), result_cpp.end() };
|
||||
}
|
||||
|
||||
bool NativeMethods::StartAsElevated(array_view<hstring const> paths)
|
||||
{
|
||||
std::ofstream stream(paths_file());
|
||||
const WCHAR newline = L'\n';
|
||||
|
||||
for (uint32_t i = 0; i < paths.size(); i++)
|
||||
{
|
||||
std::wstring path_cpp{ paths[i] };
|
||||
stream.write(reinterpret_cast<const char*>(path_cpp.c_str()), path_cpp.size() * sizeof(WCHAR));
|
||||
stream.write(reinterpret_cast<const char*>(&newline), sizeof(WCHAR));
|
||||
}
|
||||
|
||||
stream.write(reinterpret_cast<const char*>(&newline), sizeof(WCHAR));
|
||||
|
||||
if (!stream)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stream.close();
|
||||
|
||||
auto exec_path = executable_path();
|
||||
|
||||
SHELLEXECUTEINFOW exec_info{};
|
||||
exec_info.cbSize = sizeof(exec_info);
|
||||
exec_info.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||
exec_info.hwnd = NULL;
|
||||
exec_info.lpVerb = L"runas";
|
||||
exec_info.lpFile = exec_path.c_str();
|
||||
exec_info.lpParameters = L"--elevated";
|
||||
exec_info.lpDirectory = NULL;
|
||||
exec_info.nShow = SW_SHOW;
|
||||
exec_info.hInstApp = NULL;
|
||||
|
||||
if (ShellExecuteExW(&exec_info))
|
||||
{
|
||||
CloseHandle(exec_info.hProcess);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Adapted from "https://learn.microsoft.com/windows/win32/secauthz/enabling-and-disabling-privileges-in-c--" */
|
||||
bool NativeMethods::SetDebugPrivilege()
|
||||
{
|
||||
HANDLE hToken;
|
||||
TOKEN_PRIVILEGES tp{};
|
||||
LUID luid;
|
||||
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken) != 0)
|
||||
{
|
||||
if (!LookupPrivilegeValue(
|
||||
NULL, // lookup privilege on local system
|
||||
SE_DEBUG_NAME, // privilege to lookup
|
||||
&luid)) // receives LUID of privilege
|
||||
{
|
||||
CloseHandle(hToken);
|
||||
return false;
|
||||
}
|
||||
tp.PrivilegeCount = 1;
|
||||
tp.Privileges[0].Luid = luid;
|
||||
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
if (!AdjustTokenPrivileges(
|
||||
hToken,
|
||||
FALSE,
|
||||
&tp,
|
||||
sizeof(TOKEN_PRIVILEGES),
|
||||
NULL,
|
||||
NULL))
|
||||
{
|
||||
CloseHandle(hToken);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GetLastError() == ERROR_NOT_ALL_ASSIGNED)
|
||||
{
|
||||
CloseHandle(hToken);
|
||||
return false;
|
||||
}
|
||||
|
||||
CloseHandle(hToken);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// adapted from common/utils/elevation.h. No need to bring all dependencies to this project, though.
|
||||
// TODO: Make elevation.h lighter so that this function can be used without bringing dependencies like spdlog in.
|
||||
bool NativeMethods::IsProcessElevated()
|
||||
{
|
||||
HANDLE token = nullptr;
|
||||
bool elevated = false;
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
|
||||
{
|
||||
TOKEN_ELEVATION elevation{};
|
||||
DWORD size;
|
||||
if (GetTokenInformation(token, TokenElevation, &elevation, sizeof(elevation), &size))
|
||||
{
|
||||
elevated = (elevation.TokenIsElevated != 0);
|
||||
}
|
||||
}
|
||||
if (token)
|
||||
{
|
||||
CloseHandle(token);
|
||||
}
|
||||
return elevated;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "NativeMethods.g.h"
|
||||
|
||||
namespace winrt::PowerToys::FileLocksmithLib::Interop::implementation
|
||||
{
|
||||
struct NativeMethods : NativeMethodsT<NativeMethods>
|
||||
{
|
||||
NativeMethods() = default;
|
||||
|
||||
static com_array<winrt::PowerToys::FileLocksmithLib::Interop::ProcessResult> FindProcessesRecursive(array_view<hstring const> paths);
|
||||
static hstring PidToFullPath(uint32_t pid);
|
||||
static com_array<hstring> ReadPathsFromFile();
|
||||
static bool StartAsElevated(array_view<hstring const> paths);
|
||||
static bool SetDebugPrivilege();
|
||||
static bool IsProcessElevated();
|
||||
};
|
||||
}
|
||||
namespace winrt::PowerToys::FileLocksmithLib::Interop::factory_implementation
|
||||
{
|
||||
struct NativeMethods : NativeMethodsT<NativeMethods, implementation::NativeMethods>
|
||||
{
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import "ProcessResult.idl";
|
||||
|
||||
namespace PowerToys
|
||||
{
|
||||
namespace FileLocksmithLib
|
||||
{
|
||||
namespace Interop
|
||||
{
|
||||
[default_interface] static runtimeclass NativeMethods {
|
||||
static PowerToys.FileLocksmithLib.Interop.ProcessResult[] FindProcessesRecursive(String[] paths);
|
||||
static String PidToFullPath(UInt32 pid);
|
||||
static String[] ReadPathsFromFile();
|
||||
static Boolean StartAsElevated(String[] paths);
|
||||
static Boolean SetDebugPrivilege();
|
||||
static Boolean IsProcessElevated();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,19 +10,19 @@ Ntdll::Ntdll()
|
||||
throw std::runtime_error{ "GetModuleHandleW returned null" };
|
||||
}
|
||||
|
||||
m_NtQuerySystemInformation = (NtQuerySystemInformation_t)GetProcAddress(m_module, "NtQuerySystemInformation");
|
||||
m_NtQuerySystemInformation = reinterpret_cast<NtQuerySystemInformation_t>(GetProcAddress(m_module, "NtQuerySystemInformation"));
|
||||
if (m_NtQuerySystemInformation == 0)
|
||||
{
|
||||
throw std::runtime_error{ "GetProcAddress returned null for NtQuerySystemInformation" };
|
||||
}
|
||||
|
||||
m_NtDuplicateObject = (NtDuplicateObject_t)GetProcAddress(m_module, "NtDuplicateObject");
|
||||
m_NtDuplicateObject = reinterpret_cast<NtDuplicateObject_t>(GetProcAddress(m_module, "NtDuplicateObject"));
|
||||
if (m_NtDuplicateObject == 0)
|
||||
{
|
||||
throw std::runtime_error{ "GetProcAddress returned null for NtDuplicateObject" };
|
||||
}
|
||||
|
||||
m_NtQueryObject = (NtQueryObject_t)GetProcAddress(m_module, "NtQueryObject");
|
||||
m_NtQueryObject = reinterpret_cast<NtQueryObject_t>(GetProcAddress(m_module, "NtQueryObject"));
|
||||
if (m_NtQueryObject == 0)
|
||||
{
|
||||
throw std::runtime_error{ "GetProcAddress returned null for NtQueryObject" };
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace
|
||||
return long_filename;
|
||||
}
|
||||
|
||||
return { buffer, (UINT)lstrlenW(buffer) };
|
||||
return { buffer, static_cast<UINT>(lstrlenW(buffer)) };
|
||||
}
|
||||
|
||||
constexpr size_t DefaultModulesResultSize = 512;
|
||||
@@ -94,7 +94,7 @@ NtdllExtensions::MemoryLoopResult NtdllExtensions::NtQuerySystemInformationMemor
|
||||
while (result.memory.size() <= MaxResultBufferSize)
|
||||
{
|
||||
ULONG result_len;
|
||||
result.status = NtQuerySystemInformation(SystemInformationClass, result.memory.data(), (ULONG)result.memory.size(), &result_len);
|
||||
result.status = NtQuerySystemInformation(SystemInformationClass, result.memory.data(), static_cast<ULONG>(result.memory.size()), &result_len);
|
||||
|
||||
if (result.status == STATUS_INFO_LENGTH_MISMATCH)
|
||||
{
|
||||
@@ -123,10 +123,10 @@ std::wstring NtdllExtensions::file_handle_to_kernel_name(HANDLE file_handle, std
|
||||
}
|
||||
|
||||
ULONG return_length;
|
||||
auto status = NtQueryObject(file_handle, ObjectNameInformation, buffer.data(), (ULONG)buffer.size(), &return_length);
|
||||
auto status = NtQueryObject(file_handle, ObjectNameInformation, buffer.data(), static_cast<ULONG>(buffer.size()), &return_length);
|
||||
if (NT_SUCCESS(status))
|
||||
{
|
||||
auto object_name_info = (UNICODE_STRING*)buffer.data();
|
||||
auto object_name_info = reinterpret_cast<UNICODE_STRING*>(buffer.data());
|
||||
return unicode_to_str(*object_name_info);
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ std::vector<NtdllExtensions::HandleInfo> NtdllExtensions::handles() noexcept
|
||||
return {};
|
||||
}
|
||||
|
||||
auto info_ptr = (SYSTEM_HANDLE_INFORMATION_EX*)get_info_result.memory.data();
|
||||
auto info_ptr = reinterpret_cast<SYSTEM_HANDLE_INFORMATION_EX*>(get_info_result.memory.data());
|
||||
|
||||
std::map<ULONG_PTR, HANDLE> pid_to_handle;
|
||||
std::vector<HandleInfo> result;
|
||||
@@ -197,7 +197,7 @@ std::vector<NtdllExtensions::HandleInfo> NtdllExtensions::handles() noexcept
|
||||
}
|
||||
else
|
||||
{
|
||||
process_handle = OpenProcess(PROCESS_DUP_HANDLE, FALSE, (DWORD)pid);
|
||||
process_handle = OpenProcess(PROCESS_DUP_HANDLE, FALSE, static_cast<DWORD>(pid));
|
||||
if (!process_handle)
|
||||
{
|
||||
continue;
|
||||
@@ -215,7 +215,7 @@ std::vector<NtdllExtensions::HandleInfo> NtdllExtensions::handles() noexcept
|
||||
// }
|
||||
|
||||
HANDLE local_handle_copy;
|
||||
auto dh_result = DuplicateHandle(process_handle, (HANDLE)handle_info->HandleValue, GetCurrentProcess(), &local_handle_copy, 0, 0, DUPLICATE_SAME_ACCESS);
|
||||
auto dh_result = DuplicateHandle(process_handle, reinterpret_cast<HANDLE>(handle_info->HandleValue), GetCurrentProcess(), &local_handle_copy, 0, 0, DUPLICATE_SAME_ACCESS);
|
||||
if (dh_result == 0)
|
||||
{
|
||||
// Ignore this handle.
|
||||
@@ -224,7 +224,7 @@ std::vector<NtdllExtensions::HandleInfo> NtdllExtensions::handles() noexcept
|
||||
handle_copy = local_handle_copy;
|
||||
|
||||
ULONG return_length;
|
||||
auto status = NtQueryObject(handle_copy, ObjectTypeInformation, object_info_buffer.data(), (ULONG)object_info_buffer.size(), &return_length);
|
||||
auto status = NtQueryObject(handle_copy, ObjectTypeInformation, object_info_buffer.data(), static_cast<ULONG>(object_info_buffer.size()), &return_length);
|
||||
if (NT_ERROR(status))
|
||||
{
|
||||
// Ignore this handle.
|
||||
@@ -233,7 +233,7 @@ std::vector<NtdllExtensions::HandleInfo> NtdllExtensions::handles() noexcept
|
||||
continue;
|
||||
}
|
||||
|
||||
auto object_type_info = (OBJECT_TYPE_INFORMATION*)object_info_buffer.data();
|
||||
auto object_type_info = reinterpret_cast<OBJECT_TYPE_INFORMATION*>(object_info_buffer.data());
|
||||
auto type_name = unicode_to_str(object_type_info->Name);
|
||||
|
||||
std::wstring file_name;
|
||||
@@ -317,7 +317,7 @@ std::wstring NtdllExtensions::pid_to_user(DWORD pid)
|
||||
|
||||
std::vector<BYTE> token_buffer(token_size);
|
||||
GetTokenInformation(token, TokenUser, token_buffer.data(), token_size, &token_size);
|
||||
TOKEN_USER* user_ptr = (TOKEN_USER*)token_buffer.data();
|
||||
TOKEN_USER* user_ptr = reinterpret_cast<TOKEN_USER*>(token_buffer.data());
|
||||
PSID psid = user_ptr->User.Sid;
|
||||
DWORD user_buf_size = 0;
|
||||
DWORD domain_buf_size = 0;
|
||||
@@ -350,15 +350,15 @@ std::vector<NtdllExtensions::ProcessInfo> NtdllExtensions::processes() noexcept
|
||||
}
|
||||
|
||||
std::vector<ProcessInfo> result;
|
||||
auto info_ptr = (PSYSTEM_PROCESS_INFORMATION)get_info_result.memory.data();
|
||||
auto info_ptr = reinterpret_cast<PSYSTEM_PROCESS_INFORMATION>(get_info_result.memory.data());
|
||||
|
||||
while (info_ptr->NextEntryOffset)
|
||||
{
|
||||
info_ptr = decltype(info_ptr)((LPBYTE)info_ptr + info_ptr->NextEntryOffset);
|
||||
info_ptr = reinterpret_cast<decltype(info_ptr)>(reinterpret_cast<LPBYTE>(info_ptr) + info_ptr->NextEntryOffset);
|
||||
|
||||
ProcessInfo item;
|
||||
item.name = unicode_to_str(info_ptr->ImageName);
|
||||
item.pid = (DWORD)(uintptr_t)info_ptr->UniqueProcessId;
|
||||
item.pid = static_cast<DWORD>(reinterpret_cast<uintptr_t>(info_ptr->UniqueProcessId));
|
||||
item.modules = process_modules(item.pid);
|
||||
item.user = pid_to_user(item.pid);
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
EXPORTS
|
||||
DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
|
||||
DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "pch.h"
|
||||
#include "ProcessResult.h"
|
||||
|
||||
namespace winrt::PowerToys::FileLocksmithLib::Interop::implementation
|
||||
{
|
||||
ProcessResult::ProcessResult(hstring const& name, uint32_t pid, hstring const& user, array_view<hstring const> files)
|
||||
{
|
||||
_name = name;
|
||||
_pid = pid;
|
||||
_user = user;
|
||||
_files = { files.begin(), files.end() };
|
||||
}
|
||||
hstring ProcessResult::name()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
uint32_t ProcessResult::pid()
|
||||
{
|
||||
return _pid;
|
||||
}
|
||||
hstring ProcessResult::user()
|
||||
{
|
||||
return _user;
|
||||
}
|
||||
com_array<hstring> ProcessResult::files()
|
||||
{
|
||||
return winrt::com_array<hstring>{ _files.begin(), _files.end() };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "ProcessResult.g.h"
|
||||
|
||||
namespace winrt::PowerToys::FileLocksmithLib::Interop::implementation
|
||||
{
|
||||
struct ProcessResult : ProcessResultT<ProcessResult>
|
||||
{
|
||||
ProcessResult() = default;
|
||||
|
||||
ProcessResult(hstring const& name, uint32_t pid, hstring const& user, array_view<hstring const> files);
|
||||
hstring name();
|
||||
uint32_t pid();
|
||||
hstring user();
|
||||
com_array<hstring> files();
|
||||
|
||||
private:
|
||||
hstring _name;
|
||||
uint32_t _pid;
|
||||
hstring _user;
|
||||
com_array<hstring> _files;
|
||||
};
|
||||
}
|
||||
namespace winrt::PowerToys::FileLocksmithLib::Interop::factory_implementation
|
||||
{
|
||||
struct ProcessResult : ProcessResultT<ProcessResult, implementation::ProcessResult>
|
||||
{
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace PowerToys
|
||||
{
|
||||
namespace FileLocksmithLib
|
||||
{
|
||||
namespace Interop
|
||||
{
|
||||
[default_interface] runtimeclass ProcessResult {
|
||||
ProcessResult(String name, UInt32 pid, String user, String[] files);
|
||||
String name{ get; };
|
||||
UInt32 pid{ get; };
|
||||
String user{ get; };
|
||||
String[] files{ get; };
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,248 +0,0 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "FileLocksmith.h"
|
||||
|
||||
#include "../FileLocksmithLib/Constants.h"
|
||||
|
||||
namespace FileLocksmith::Interop
|
||||
{
|
||||
public ref struct ProcessResult
|
||||
{
|
||||
System::String^ name;
|
||||
System::UInt32 pid;
|
||||
System::String^ user;
|
||||
array<System::String^>^ files;
|
||||
};
|
||||
|
||||
System::String^ from_wstring_view(std::wstring_view str)
|
||||
{
|
||||
return gcnew System::String(str.data(), 0, static_cast<int>(str.size()));
|
||||
}
|
||||
|
||||
std::wstring from_system_string(System::String^ str)
|
||||
{
|
||||
// TODO use some built-in method
|
||||
auto chars = str->ToCharArray();
|
||||
|
||||
std::wstring result(chars->Length, 0);
|
||||
for (int i = 0; i < chars->Length; i++)
|
||||
{
|
||||
result[i] = chars[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring paths_file()
|
||||
{
|
||||
#pragma warning(suppress : 4691) // Weird warning about System::String from referenced library not being the one expected (?!)
|
||||
std::wstring path = from_system_string(interop::Constants::AppDataPath());
|
||||
path += L"\\";
|
||||
path += constants::nonlocalizable::PowerToyName;
|
||||
path += L"\\";
|
||||
path += constants::nonlocalizable::LastRunPath;
|
||||
return path;
|
||||
}
|
||||
|
||||
std::wstring executable_path()
|
||||
{
|
||||
return pid_to_full_path(GetCurrentProcessId());
|
||||
}
|
||||
|
||||
public ref struct NativeMethods
|
||||
{
|
||||
static array<ProcessResult ^> ^ FindProcessesRecursive(array<System::String^>^ paths)
|
||||
{
|
||||
const int n = paths->Length;
|
||||
|
||||
std::vector<std::wstring> paths_cpp(n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
paths_cpp[i] = from_system_string(paths[i]);
|
||||
}
|
||||
|
||||
auto result_cpp = find_processes_recursive(paths_cpp);
|
||||
const auto result_size = static_cast<int>(result_cpp.size());
|
||||
|
||||
auto result = gcnew array<ProcessResult ^>(result_size);
|
||||
for (int i = 0; i < result_size; i++)
|
||||
{
|
||||
auto item = gcnew ProcessResult;
|
||||
|
||||
item->name = from_wstring_view(result_cpp[i].name);
|
||||
item->pid = result_cpp[i].pid;
|
||||
item->user = from_wstring_view(result_cpp[i].user);
|
||||
|
||||
const int n_files = static_cast<int>(result_cpp[i].files.size());
|
||||
item->files = gcnew array<System::String ^>(n_files);
|
||||
for (int j = 0; j < n_files; j++)
|
||||
{
|
||||
item->files[j] = from_wstring_view(result_cpp[i].files[j]);
|
||||
}
|
||||
|
||||
result[i] = item;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static System::String^ PidToFullPath(System::UInt32 pid)
|
||||
{
|
||||
auto path_cpp = pid_to_full_path(pid);
|
||||
return from_wstring_view(path_cpp);
|
||||
}
|
||||
|
||||
static array<System::String^>^ ReadPathsFromFile()
|
||||
{
|
||||
std::ifstream stream(paths_file());
|
||||
|
||||
std::vector<std::wstring> result_cpp;
|
||||
std::wstring line;
|
||||
|
||||
bool finished = false;
|
||||
|
||||
while (!finished)
|
||||
{
|
||||
WCHAR ch{};
|
||||
// We have to read data like this
|
||||
if (!stream.read(reinterpret_cast<char*>(&ch), 2))
|
||||
{
|
||||
finished = true;
|
||||
}
|
||||
else if (ch == L'\n')
|
||||
{
|
||||
if (line.empty())
|
||||
{
|
||||
finished = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result_cpp.push_back(line);
|
||||
line = {};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
line += ch;
|
||||
}
|
||||
}
|
||||
|
||||
auto result = gcnew array<System::String ^>(static_cast<int>(result_cpp.size()));
|
||||
for (int i = 0; i < result->Length; i++)
|
||||
{
|
||||
result[i] = from_wstring_view(result_cpp[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static System::Boolean StartAsElevated(array<System::String ^> ^ paths)
|
||||
{
|
||||
std::ofstream stream(paths_file());
|
||||
const WCHAR newline = L'\n';
|
||||
for (int i = 0; i < paths->Length; i++)
|
||||
{
|
||||
auto path_cpp = from_system_string(paths[i]);
|
||||
stream.write(reinterpret_cast<const char*>(path_cpp.c_str()), path_cpp.size() * sizeof(WCHAR));
|
||||
stream.write(reinterpret_cast<const char*>(&newline), sizeof(WCHAR));
|
||||
}
|
||||
|
||||
stream.write(reinterpret_cast<const char*>(&newline), sizeof(WCHAR));
|
||||
|
||||
if (!stream)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stream.close();
|
||||
|
||||
auto exec_path = executable_path();
|
||||
|
||||
SHELLEXECUTEINFOW exec_info{};
|
||||
exec_info.cbSize = sizeof(exec_info);
|
||||
exec_info.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||
exec_info.hwnd = NULL;
|
||||
exec_info.lpVerb = L"runas";
|
||||
exec_info.lpFile = exec_path.c_str();
|
||||
exec_info.lpParameters = L"--elevated";
|
||||
exec_info.lpDirectory = NULL;
|
||||
exec_info.nShow = SW_SHOW;
|
||||
exec_info.hInstApp = NULL;
|
||||
|
||||
if (ShellExecuteExW(&exec_info))
|
||||
{
|
||||
CloseHandle(exec_info.hProcess);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Adapted from "https://learn.microsoft.com/windows/win32/secauthz/enabling-and-disabling-privileges-in-c--" */
|
||||
static System::Boolean SetDebugPrivilege()
|
||||
{
|
||||
HANDLE hToken;
|
||||
TOKEN_PRIVILEGES tp{};
|
||||
LUID luid;
|
||||
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken) != 0)
|
||||
{
|
||||
if (!LookupPrivilegeValue(
|
||||
NULL, // lookup privilege on local system
|
||||
SE_DEBUG_NAME, // privilege to lookup
|
||||
&luid)) // receives LUID of privilege
|
||||
{
|
||||
CloseHandle(hToken);
|
||||
return false;
|
||||
}
|
||||
tp.PrivilegeCount = 1;
|
||||
tp.Privileges[0].Luid = luid;
|
||||
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
if (!AdjustTokenPrivileges(
|
||||
hToken,
|
||||
FALSE,
|
||||
&tp,
|
||||
sizeof(TOKEN_PRIVILEGES),
|
||||
(PTOKEN_PRIVILEGES)NULL,
|
||||
(PDWORD)NULL))
|
||||
{
|
||||
CloseHandle(hToken);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GetLastError() == ERROR_NOT_ALL_ASSIGNED)
|
||||
{
|
||||
CloseHandle(hToken);
|
||||
return false;
|
||||
}
|
||||
|
||||
CloseHandle(hToken);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// adapted from common/utils/elevation.h. No need to bring all dependencies to this project, though.
|
||||
// TODO: Make elevation.h lighter so that this function can be used without bringing dependencies like spdlog in.
|
||||
static System::Boolean IsProcessElevated()
|
||||
{
|
||||
HANDLE token = nullptr;
|
||||
bool elevated = false;
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
|
||||
{
|
||||
TOKEN_ELEVATION elevation{};
|
||||
DWORD size;
|
||||
if (GetTokenInformation(token, TokenElevation, &elevation, sizeof(elevation), &size))
|
||||
{
|
||||
elevated = (elevation.TokenIsElevated != 0);
|
||||
}
|
||||
}
|
||||
if (token)
|
||||
{
|
||||
CloseHandle(token);
|
||||
}
|
||||
return elevated;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.240111.5" targetFramework="native" />
|
||||
</packages>
|
||||
@@ -17,3 +17,5 @@
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
||||
#include <winrt/PowerToys.Interop.h>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using FileLocksmith.Interop;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using PowerToys.FileLocksmithLib.Interop;
|
||||
|
||||
namespace PowerToys.FileLocksmithUI.Converters
|
||||
{
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using FileLocksmith.Interop;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using PowerToys.FileLocksmithLib.Interop;
|
||||
|
||||
namespace PowerToys.FileLocksmithUI.Converters
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace PowerToys.FileLocksmithUI.Converters
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var y = FileLocksmith.Interop.NativeMethods.PidToFullPath((uint)value);
|
||||
var y = PowerToys.FileLocksmithLib.Interop.NativeMethods.PidToFullPath((uint)value);
|
||||
Icon icon = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(y))
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using FileLocksmith.Interop;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using PowerToys.FileLocksmithLib.Interop;
|
||||
|
||||
namespace PowerToys.FileLocksmithUI.Converters
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper;PowerToys.FileLocksmithLib.Interop</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -43,11 +43,11 @@ namespace FileLocksmithUI
|
||||
return;
|
||||
}
|
||||
|
||||
bool isElevated = FileLocksmith.Interop.NativeMethods.IsProcessElevated();
|
||||
bool isElevated = PowerToys.FileLocksmithLib.Interop.NativeMethods.IsProcessElevated();
|
||||
|
||||
if (isElevated)
|
||||
{
|
||||
if (!FileLocksmith.Interop.NativeMethods.SetDebugPrivilege())
|
||||
if (!PowerToys.FileLocksmithLib.Interop.NativeMethods.SetDebugPrivilege())
|
||||
{
|
||||
Logger.LogWarning("Couldn't set debug privileges to see system processes.");
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:interop="using:FileLocksmith.Interop"
|
||||
xmlns:interop="using:PowerToys.FileLocksmithLib.Interop"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters"
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using FileLocksmith.Interop;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using PowerToys.FileLocksmithLib.Interop;
|
||||
using PowerToys.FileLocksmithUI.ViewModels;
|
||||
|
||||
namespace PowerToys.FileLocksmithUI.Views
|
||||
|
||||
@@ -11,8 +11,8 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using FileLocksmith.Interop;
|
||||
using ManagedCommon;
|
||||
using PowerToys.FileLocksmithLib.Interop;
|
||||
|
||||
namespace PowerToys.FileLocksmithUI.ViewModels
|
||||
{
|
||||
@@ -95,10 +95,14 @@ namespace PowerToys.FileLocksmithUI.ViewModels
|
||||
|
||||
_cancelProcessWatching = new CancellationTokenSource();
|
||||
|
||||
foreach (ProcessResult p in await FindProcesses(paths))
|
||||
var processes_found = await FindProcesses(paths);
|
||||
if (processes_found is not null)
|
||||
{
|
||||
Processes.Add(p);
|
||||
WatchProcess(p, _cancelProcessWatching.Token);
|
||||
foreach (ProcessResult p in processes_found)
|
||||
{
|
||||
Processes.Add(p);
|
||||
WatchProcess(p, _cancelProcessWatching.Token);
|
||||
}
|
||||
}
|
||||
|
||||
IsLoading = false;
|
||||
@@ -109,7 +113,7 @@ namespace PowerToys.FileLocksmithUI.ViewModels
|
||||
var results = new List<ProcessResult>();
|
||||
await Task.Run(() =>
|
||||
{
|
||||
results = NativeMethods.FindProcessesRecursive(paths).ToList();
|
||||
results = NativeMethods.FindProcessesRecursive(paths)?.ToList();
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Threading;
|
||||
using Common.UI;
|
||||
using interop;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using MouseJumpUI.Helpers;
|
||||
using PowerToys.Interop;
|
||||
|
||||
namespace MouseJumpUI;
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Common.UI;
|
||||
using interop;
|
||||
using PowerOCR.Utilities;
|
||||
using PowerToys.Interop;
|
||||
|
||||
namespace PowerOCR.Keyboard
|
||||
{
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace Awake
|
||||
|
||||
TrayHelper.InitializeTray(Core.Constants.FullAppName, _defaultAwakeIcon);
|
||||
|
||||
var eventHandle = new EventWaitHandle(false, EventResetMode.ManualReset, interop.Constants.AwakeExitEvent());
|
||||
var eventHandle = new EventWaitHandle(false, EventResetMode.ManualReset, PowerToys.Interop.Constants.AwakeExitEvent());
|
||||
new Thread(() =>
|
||||
{
|
||||
WaitHandle.WaitAny([eventHandle]);
|
||||
|
||||
@@ -14,8 +14,8 @@ using ColorPicker.Mouse;
|
||||
using ColorPicker.Settings;
|
||||
using ColorPicker.ViewModelContracts;
|
||||
using Common.UI;
|
||||
using interop;
|
||||
using ManagedCommon;
|
||||
using PowerToys.Interop;
|
||||
|
||||
namespace ColorPicker.ViewModels
|
||||
{
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace FancyZonesEditor
|
||||
private void App_WaitExit()
|
||||
{
|
||||
NativeEventWaiter.WaitForEventLoop(
|
||||
interop.Constants.FZEExitEvent(),
|
||||
PowerToys.Interop.Constants.FZEExitEvent(),
|
||||
() =>
|
||||
{
|
||||
Logger.LogInfo("Exit event triggered");
|
||||
|
||||
@@ -150,6 +150,9 @@
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<CopyCppRuntimeToOutputDir>true</CopyCppRuntimeToOutputDir>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="Keyboard.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="MSTest" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<ProjectGuid>{BB23A474-5058-4F75-8FA3-5FE3DE53CDF4}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Community.PowerToys.Run.Plugin.UnitConverter</RootNamespace>
|
||||
@@ -44,6 +44,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="UnitsNet" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<ProjectGuid>{4D971245-7A70-41D5-BAA0-DDB5684CAF51}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Community.PowerToys.Run.Plugin.VSCodeWorkspaces</RootNamespace>
|
||||
@@ -40,6 +40,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="MSTest" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<ProjectGuid>{D095BE44-1F2E-463E-A494-121892A75EA2}</ProjectGuid>
|
||||
<UseWPF>true</UseWPF>
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
<ExcludeAssets>runtime</ExcludeAssets> <!-- Should already be present on .net sdk runtime, so we avoid the conflicting runtime version from nuget -->
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<ProjectGuid>{9F94B303-5E21-4364-9362-64426F8DB932}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Community.PowerToys.Run.Plugin.WebSearch</RootNamespace>
|
||||
@@ -38,6 +38,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
<ExcludeAssets>runtime</ExcludeAssets> <!-- Should already be present on .net sdk runtime, so we avoid the conflicting runtime version from nuget -->
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<RootNamespace>Microsoft.Plugin.Folder.UnitTests</RootNamespace>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="MSTest" />
|
||||
<PackageReference Include="System.IO.Abstractions.TestingHelpers" />
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<ProjectGuid>{787B8AA6-CA93-4C84-96FE-DF31110AD1C4}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.Plugin.Folder</RootNamespace>
|
||||
@@ -53,6 +53,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.IO.Abstractions" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<ProjectGuid>{F8B870EB-D5F5-45BA-9CF7-A5C459818820}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.Plugin.Indexer</RootNamespace>
|
||||
@@ -29,6 +29,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Data.OleDb" />
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager">
|
||||
<!-- This package is a dependency of System.Data.OleDb, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<ProjectReference Include="..\Microsoft.Plugin.Program\Microsoft.Plugin.Program.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
<ExcludeAssets>runtime</ExcludeAssets> <!-- Should already be present on .net sdk runtime, so we avoid the conflicting runtime version from nuget -->
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<ProjectGuid>{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.Plugin.Shell</RootNamespace>
|
||||
@@ -41,6 +41,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
<ExcludeAssets>runtime</ExcludeAssets> <!-- Should already be present on .net sdk runtime, so we avoid the conflicting runtime version from nuget -->
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<RootNamespace>Microsoft.Plugin.Uri.UnitTests</RootNamespace>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="MSTest" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<ProjectGuid>{03276a39-d4e9-417c-8ffd-200b0ee5e871}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.Plugin.Uri</RootNamespace>
|
||||
@@ -38,6 +38,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
<ExcludeAssets>runtime</ExcludeAssets> <!-- Should already be present on .net sdk runtime, so we avoid the conflicting runtime version from nuget -->
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<RootNamespace>Microsoft.Plugin.WindowWalker.UnitTests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="MSTest" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<ProjectGuid>{74F1B9ED-F59C-4FE7-B473-7B453E30837E}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.Plugin.WindowWalker</RootNamespace>
|
||||
@@ -44,6 +44,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
<ExcludeAssets>runtime</ExcludeAssets> <!-- Should already be present on .net sdk runtime, so we avoid the conflicting runtime version from nuget -->
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<RootNamespace>Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests</RootNamespace>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="MSTest" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<ProjectGuid>{59BD9891-3837-438A-958D-ADC7F91F6F7E}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.PowerToys.Run.Plugin.Calculator</RootNamespace>
|
||||
@@ -44,6 +44,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="Mages" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<RootNamespace>Microsoft.PowerToys.Run.Plugin.OneNote</RootNamespace>
|
||||
<AssemblyName>Microsoft.PowerToys.Run.Plugin.OneNote</AssemblyName>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
@@ -46,6 +46,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="Interop.Microsoft.Office.Interop.OneNote" />
|
||||
<PackageReference Include="LazyCache" />
|
||||
<PackageReference Include="Microsoft.Windows.CsWin32">
|
||||
|
||||
@@ -7,8 +7,8 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Windows.Input;
|
||||
using Common.UI;
|
||||
using interop;
|
||||
using Microsoft.PowerToys.Run.Plugin.PowerToys.Properties;
|
||||
using PowerToys.Interop;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Plugin;
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using interop;
|
||||
using Microsoft.PowerToys.Run.Plugin.PowerToys.Components;
|
||||
using Microsoft.PowerToys.Run.Plugin.PowerToys.Properties;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using PowerToys.GPOWrapper;
|
||||
using PowerToys.Interop;
|
||||
using Wox.Plugin.Logger;
|
||||
|
||||
namespace Microsoft.PowerToys.Run.Plugin.PowerToys
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
@@ -20,6 +20,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="MSTest" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<RootNamespace>Microsoft.PowerToys.Run.Plugin.Registry</RootNamespace>
|
||||
<AssemblyName>Microsoft.PowerToys.Run.Plugin.Registry</AssemblyName>
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
<ExcludeAssets>runtime</ExcludeAssets> <!-- Should already be present on .net sdk runtime, so we avoid the conflicting runtime version from nuget -->
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<RootNamespace>Microsoft.PowerToys.Run.Plugin.Service</RootNamespace>
|
||||
<AssemblyName>Microsoft.PowerToys.Run.Plugin.Service</AssemblyName>
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.ServiceProcess.ServiceController" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<RootNamespace>Microsoft.PowerToys.Run.Plugin.System.UnitTests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="MSTest" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.PowerToys.Run.Plugin.System</RootNamespace>
|
||||
<AssemblyName>Microsoft.PowerToys.Run.Plugin.System</AssemblyName>
|
||||
@@ -34,6 +34,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
<ExcludeAssets>runtime</ExcludeAssets> <!-- Should already be present on .net sdk runtime, so we avoid the conflicting runtime version from nuget -->
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<RootNamespace>Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="MSTest" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.PowerToys.Run.Plugin.TimeDate</RootNamespace>
|
||||
<AssemblyName>Microsoft.PowerToys.Run.Plugin.TimeDate</AssemblyName>
|
||||
@@ -34,6 +34,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
<ExcludeAssets>runtime</ExcludeAssets> <!-- Should already be present on .net sdk runtime, so we avoid the conflicting runtime version from nuget -->
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
|
||||
<ProjectGuid>{5043CECE-E6A7-4867-9CBE-02D27D83747A}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.PowerToys.Run.Plugin.WindowsSettings</RootNamespace>
|
||||
@@ -43,6 +43,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
<ExcludeAssets>runtime</ExcludeAssets> <!-- Should already be present on .net sdk runtime, so we avoid the conflicting runtime version from nuget -->
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="MSTest" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog">
|
||||
<!-- This package is a dependency of Microsoft.Extensions.Logging.EventLog, but we need to set it here so we can exclude the assets, so it doesn't conflict with the 8.0.1 dll coming from .NET SDK. -->
|
||||
<ExcludeAssets>runtime</ExcludeAssets> <!-- Should already be present on .net sdk runtime, so we avoid the conflicting runtime version from nuget -->
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user