[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:
Jaime Bernardo
2024-08-08 15:26:43 +01:00
committed by GitHub
parent b16e82c837
commit fb5ed13386
136 changed files with 1511 additions and 1119 deletions

View File

@@ -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)

View File

@@ -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);

View File

@@ -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>

View File

@@ -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>

View File

@@ -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;
}
}

View File

@@ -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>
{
};
}

View File

@@ -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();
}
}
}
}

View File

@@ -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" };

View File

@@ -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);

View File

@@ -0,0 +1,3 @@
EXPORTS
DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE

View File

@@ -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() };
}
}

View File

@@ -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>
{
};
}

View File

@@ -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; };
};
}
}
}

View File

@@ -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;
}
};
}

View File

@@ -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>

View File

@@ -17,3 +17,5 @@
#include <set>
#include <algorithm>
#include <fstream>
#include <winrt/PowerToys.Interop.h>

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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))

View File

@@ -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
{

View File

@@ -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>

View File

@@ -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.");
}

View File

@@ -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"

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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
{

View File

@@ -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]);

View File

@@ -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
{

View File

@@ -145,7 +145,7 @@ namespace FancyZonesEditor
private void App_WaitExit()
{
NativeEventWaiter.WaitForEventLoop(
interop.Constants.FZEExitEvent(),
PowerToys.Interop.Constants.FZEExitEvent(),
() =>
{
Logger.LogInfo("Exit event triggered");

View File

@@ -150,6 +150,9 @@
<SubType>Designer</SubType>
</None>
</ItemGroup>
<PropertyGroup>
<CopyCppRuntimeToOutputDir>true</CopyCppRuntimeToOutputDir>
</PropertyGroup>
<ItemGroup>
<Image Include="Keyboard.ico" />
</ItemGroup>

View File

@@ -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>

View File

@@ -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. -->

View File

@@ -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. -->

View File

@@ -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>

View File

@@ -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 -->

View File

@@ -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 -->

View File

@@ -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" />

View File

@@ -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. -->

View File

@@ -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. -->

View File

@@ -14,6 +14,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" />
<ProjectReference Include="..\Microsoft.Plugin.Program\Microsoft.Plugin.Program.csproj" />
</ItemGroup>

View File

@@ -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 -->

View File

@@ -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 -->

View File

@@ -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>

View File

@@ -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 -->

View File

@@ -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>

View File

@@ -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 -->

View File

@@ -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>

View File

@@ -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. -->

View File

@@ -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">

View File

@@ -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;

View File

@@ -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

View File

@@ -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>

View File

@@ -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 -->

View File

@@ -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. -->

View File

@@ -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>

View File

@@ -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 -->

View File

@@ -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>

View File

@@ -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 -->

View File

@@ -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 -->

View File

@@ -9,6 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" />
<PackageReference Include="MSTest" />
</ItemGroup>

View File

@@ -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 -->

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
<Description>PowerToys PowerLauncher Telemetry</Description>
<AssemblyName>PowerToys.PowerLauncher.Telemetry</AssemblyName>
</PropertyGroup>

View File

@@ -9,13 +9,13 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using interop;
using ManagedCommon;
using Microsoft.PowerLauncher.Telemetry;
using Microsoft.PowerToys.Telemetry;
using PowerLauncher.Helper;
using PowerLauncher.Plugin;
using PowerLauncher.ViewModel;
using PowerToys.Interop;
using Wox;
using Wox.Infrastructure;
using Wox.Infrastructure.Image;

View File

@@ -14,13 +14,13 @@ using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
using Common.UI;
using interop;
using Microsoft.PowerLauncher.Telemetry;
using Microsoft.PowerToys.Telemetry;
using PowerLauncher.Helper;
using PowerLauncher.Plugin;
using PowerLauncher.Telemetry.Events;
using PowerLauncher.ViewModel;
using PowerToys.Interop;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
using Wox.Plugin.Interfaces;

View File

@@ -17,13 +17,13 @@ using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Threading;
using Common.UI;
using interop;
using Mages.Core.Runtime.Converters;
using Microsoft.PowerLauncher.Telemetry;
using Microsoft.PowerToys.Telemetry;
using PowerLauncher.Helper;
using PowerLauncher.Plugin;
using PowerLauncher.Storage;
using PowerToys.Interop;
using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.Storage;

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
<ProjectGuid>{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}</ProjectGuid>
<OutputType>Library</OutputType>
<UseWpf>true</UseWpf>
@@ -48,6 +48,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" />
<PackageReference Include="NLog.Schema" />
<PackageReference Include="hyjiacan.pinyin4net" />
<PackageReference Include="System.Diagnostics.EventLog">

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
<ProjectGuid>{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}</ProjectGuid>
<UseWPF>true</UseWPF>
<OutputType>Library</OutputType>
@@ -48,6 +48,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" />
<PackageReference Include="NLog.Extensions.Logging" />
<!-- HACK: Microsoft.Extensions.Hosting is referenced, even if it is not used, to force dll versions to be the same as in other projects. Really only needed since OneNote uses the LazyCache and NLog dependencies, which references older assemblies. -->
<PackageReference Include="Microsoft.Extensions.Hosting" />

View File

@@ -22,6 +22,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" />
<PackageReference Include="Microsoft.Windows.CsWin32">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@@ -30,6 +30,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" />
<PackageReference Include="CommunityToolkit.Mvvm" />
<PackageReference Include="CommunityToolkit.WinUI.Converters" />
<PackageReference Include="Microsoft.WindowsAppSDK" />

View File

@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
using interop;
using ManagedCommon;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@@ -15,6 +14,7 @@ using Peek.FilePreviewer.Models;
using Peek.UI.Native;
using Peek.UI.Telemetry.Events;
using Peek.UI.Views;
using PowerToys.Interop;
namespace Peek.UI
{

View File

@@ -7,8 +7,8 @@ using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using interop;
using ManagedCommon;
using PowerToys.Interop;
namespace PowerAccent.UI;

View File

@@ -5,7 +5,7 @@
using System.Globalization;
using System.Windows.Threading;
using Common.UI;
using interop;
using PowerToys.Interop;
namespace Microsoft.PowerToys.PreviewHandler.Gcode
{

View File

@@ -5,7 +5,7 @@
using System.Globalization;
using System.Windows.Threading;
using Common.UI;
using interop;
using PowerToys.Interop;
namespace Microsoft.PowerToys.PreviewHandler.Markdown
{

View File

@@ -5,8 +5,8 @@
using System.Globalization;
using System.Windows.Threading;
using Common.UI;
using interop;
using ManagedCommon;
using PowerToys.Interop;
namespace Microsoft.PowerToys.PreviewHandler.Monaco
{

View File

@@ -4,7 +4,7 @@
using System.Globalization;
using System.Windows.Threading;
using Common.UI;
using interop;
using PowerToys.Interop;
namespace Microsoft.PowerToys.PreviewHandler.Pdf
{

View File

@@ -5,7 +5,7 @@
using System.Globalization;
using System.Windows.Threading;
using Common.UI;
using interop;
using PowerToys.Interop;
namespace Microsoft.PowerToys.PreviewHandler.Qoi
{

View File

@@ -5,7 +5,7 @@
using System.Globalization;
using System.Windows.Threading;
using Common.UI;
using interop;
using PowerToys.Interop;
namespace Microsoft.PowerToys.PreviewHandler.Svg
{

View File

@@ -9,7 +9,7 @@
<PropertyGroup>
<ProjectGuid>{748417CA-F17E-487F-9411-CAFB6D3F4877}</ProjectGuid>
<RootNamespace>PreviewHandlerCommonUnitTests</RootNamespace>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>

View File

@@ -14,7 +14,7 @@
<PropertyGroup>
<ProjectGuid>{AF2349B8-E5B6-4004-9502-687C1C7730B1}</ProjectGuid>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
<AssemblyName>PowerToys.PreviewHandlerCommon</AssemblyName>
</PropertyGroup>

View File

@@ -38,6 +38,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.Sizers" />
<PackageReference Include="CommunityToolkit.WinUI.Extensions" />

View File

@@ -1,3 +1,4 @@
#include "pch.h"
#include "MicrophoneDevice.h"
#include "Logging.h"

View File

@@ -1,3 +1,4 @@
#include "pch.h"
#include "VideoCaptureDeviceList.h"
#include "Logging.h"
#include "MediaFoundationAPIProvider.h"

View File

@@ -96,7 +96,7 @@
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
<AdditionalIncludeDirectories>$(SolutionDir)\src\;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
@@ -123,6 +123,7 @@
<ClInclude Include="DLLProviderHelpers.h" />
<ClInclude Include="Logging.h" />
<ClInclude Include="MediaFoundationAPIProvider.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="SerializedSharedMemory.h" />
<ClInclude Include="naming.h" />
<ClInclude Include="MicrophoneDevice.h" />

View File

@@ -0,0 +1,2 @@
#pragma once
// Dummy file to allow compiling VideoCaptureDeviceList.h and MicrophoneDevice.h in this project, since it's also used in PowerToys.Interop.vcxproj, which has a pch.