Code clean-up and spaces instead of tabs
@@ -501,8 +501,8 @@
|
||||
</Directory>
|
||||
<Directory Id="PowerAccentInstallFolder" Name="$(var.PowerAccentProjectName)">
|
||||
</Directory>
|
||||
<Directory Id="FileLocksmithInstallFolder" Name="$(var.FileLocksmithProjectName)">
|
||||
</Directory>
|
||||
<Directory Id="FileLocksmithInstallFolder" Name="$(var.FileLocksmithProjectName)">
|
||||
</Directory>
|
||||
<Directory Id="PowerRenameInstallFolder" Name="$(var.PowerRenameProjectName)">
|
||||
<Directory Id="PowerRenameAssetsFolder" Name="Assets" />
|
||||
<Directory Id="PowerRenameMicrosoftUIXamlInstallFolder" Name="Microsoft.UI.Xaml">
|
||||
@@ -882,26 +882,26 @@
|
||||
<?endforeach?>
|
||||
</DirectoryRef>
|
||||
|
||||
<!-- FileLocksmith -->
|
||||
<DirectoryRef Id="FileLocksmithInstallFolder" FileSource="$(var.BinDir)modules\$(var.FileLocksmithProjectName)">
|
||||
<?foreach File in $(var.FileLocksmithFiles)?>
|
||||
<Component Id="FileLocksmith_$(var.File)" Win64="yes">
|
||||
<File Id="FileLocksmithFile_$(var.File)" Source="$(var.BinDir)modules\$(var.FileLocksmithProjectName)\$(var.File)" />
|
||||
</Component>
|
||||
<?endforeach?>
|
||||
<!-- !Warning! Make sure to change Component Guid if you update something here -->
|
||||
<Component Id="Module_FileLocksmith" Guid="108D3EC1-E6E0-4E81-88EF-25966133CB41" Win64="yes">
|
||||
<RegistryKey Root="HKLM" Key="Software\Classes\CLSID\{84D68575-E186-46AD-B0CB-BAEB45EE29C0}">
|
||||
<RegistryValue Type="string" Value="File Locksmith Shell Extension" />
|
||||
<RegistryValue Type="string" Name="ContextMenuOptIn" Value="" />
|
||||
<RegistryValue Type="string" Key="InprocServer32" Value="[FileLocksmithInstallFolder]PowerToys.FileLocksmithExt.dll" />
|
||||
<RegistryValue Type="string" Key="InprocServer32" Name="ThreadingModel" Value="Apartment" />
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKLM" Key="Software\Classes\AllFileSystemObjects\ShellEx\ContextMenuHandlers\FileLocksmithExt">
|
||||
<RegistryValue Type="string" Value="{84D68575-E186-46AD-B0CB-BAEB45EE29C0}"/>
|
||||
</RegistryKey>
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
<!-- FileLocksmith -->
|
||||
<DirectoryRef Id="FileLocksmithInstallFolder" FileSource="$(var.BinDir)modules\$(var.FileLocksmithProjectName)">
|
||||
<?foreach File in $(var.FileLocksmithFiles)?>
|
||||
<Component Id="FileLocksmith_$(var.File)" Win64="yes">
|
||||
<File Id="FileLocksmithFile_$(var.File)" Source="$(var.BinDir)modules\$(var.FileLocksmithProjectName)\$(var.File)" />
|
||||
</Component>
|
||||
<?endforeach?>
|
||||
<!-- !Warning! Make sure to change Component Guid if you update something here -->
|
||||
<Component Id="Module_FileLocksmith" Guid="108D3EC1-E6E0-4E81-88EF-25966133CB41" Win64="yes">
|
||||
<RegistryKey Root="HKLM" Key="Software\Classes\CLSID\{84D68575-E186-46AD-B0CB-BAEB45EE29C0}">
|
||||
<RegistryValue Type="string" Value="File Locksmith Shell Extension" />
|
||||
<RegistryValue Type="string" Name="ContextMenuOptIn" Value="" />
|
||||
<RegistryValue Type="string" Key="InprocServer32" Value="[FileLocksmithInstallFolder]PowerToys.FileLocksmithExt.dll" />
|
||||
<RegistryValue Type="string" Key="InprocServer32" Name="ThreadingModel" Value="Apartment" />
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKLM" Key="Software\Classes\AllFileSystemObjects\ShellEx\ContextMenuHandlers\FileLocksmithExt">
|
||||
<RegistryValue Type="string" Value="{84D68575-E186-46AD-B0CB-BAEB45EE29C0}"/>
|
||||
</RegistryKey>
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
|
||||
<!-- PowerRename -->
|
||||
<DirectoryRef Id="PowerRenameInstallFolder" FileSource="$(var.BinDir)modules\$(var.PowerRenameProjectName)">
|
||||
@@ -1268,9 +1268,9 @@
|
||||
<ComponentRef Id="DesktopShortcut" />
|
||||
<ComponentRef Id="Module_PowerRename" />
|
||||
<ComponentRef Id="Module_FileLocksmith" />
|
||||
<?foreach File in $(var.FileLocksmithFiles)?>
|
||||
<ComponentRef Id="FileLocksmith_$(var.File)" />
|
||||
<?endforeach?>
|
||||
<?foreach File in $(var.FileLocksmithFiles)?>
|
||||
<ComponentRef Id="FileLocksmith_$(var.File)" />
|
||||
<?endforeach?>
|
||||
<?foreach File in $(var.PowerAccentFiles)?>
|
||||
<ComponentRef Id="PowerAccent_$(var.File)" />
|
||||
<?endforeach?>
|
||||
@@ -2005,16 +2005,16 @@
|
||||
<File Id="Hosts_WinAppSDKLoc_$(var.IdSafeLanguage)_XamlMui_File" Source="$(var.BinDir)modules\$(var.HostsProjectName)\$(var.Language)\Microsoft.ui.xaml.dll.mui" />
|
||||
<File Id="Hosts_WinAppSDKLoc_$(var.IdSafeLanguage)_XamlPhoneMui_File" Source="$(var.BinDir)modules\$(var.HostsProjectName)\$(var.Language)\Microsoft.UI.Xaml.Phone.dll.mui" />
|
||||
</Component>
|
||||
<Component
|
||||
Id="FileLocksmith_WinAppSDKLoc_$(var.IdSafeLanguage)_Component"
|
||||
Directory="WinAppSDKLoc$(var.IdSafeLanguage)FileLocksmithInstallFolder"
|
||||
Guid="$(var.CompGUIDPrefix)05">
|
||||
<File Id="FileLocksmith_WinAppSDKLoc_$(var.IdSafeLanguage)_XamlMui_File" Source="$(var.BinDir)modules\$(var.FileLocksmithProjectName)\$(var.Language)\Microsoft.ui.xaml.dll.mui" />
|
||||
<File Id="FileLocksmith_WinAppSDKLoc_$(var.IdSafeLanguage)_XamlPhoneMui_File" Source="$(var.BinDir)modules\$(var.FileLocksmithProjectName)\$(var.Language)\Microsoft.UI.Xaml.Phone.dll.mui" />
|
||||
</Component>
|
||||
<?undef IdSafeLanguage?>
|
||||
<?undef CompGUIDPrefix?>
|
||||
<?endforeach?>
|
||||
<Component
|
||||
Id="FileLocksmith_WinAppSDKLoc_$(var.IdSafeLanguage)_Component"
|
||||
Directory="WinAppSDKLoc$(var.IdSafeLanguage)FileLocksmithInstallFolder"
|
||||
Guid="$(var.CompGUIDPrefix)05">
|
||||
<File Id="FileLocksmith_WinAppSDKLoc_$(var.IdSafeLanguage)_XamlMui_File" Source="$(var.BinDir)modules\$(var.FileLocksmithProjectName)\$(var.Language)\Microsoft.ui.xaml.dll.mui" />
|
||||
<File Id="FileLocksmith_WinAppSDKLoc_$(var.IdSafeLanguage)_XamlPhoneMui_File" Source="$(var.BinDir)modules\$(var.FileLocksmithProjectName)\$(var.Language)\Microsoft.UI.Xaml.Phone.dll.mui" />
|
||||
</Component>
|
||||
<?undef IdSafeLanguage?>
|
||||
<?undef CompGUIDPrefix?>
|
||||
<?endforeach?>
|
||||
</ComponentGroup>
|
||||
</Fragment>
|
||||
<Fragment>
|
||||
|
||||
@@ -5,25 +5,25 @@
|
||||
// Non-localizable constants
|
||||
namespace constants::nonlocalizable
|
||||
{
|
||||
// Description of the registry key
|
||||
constexpr WCHAR RegistryKeyDescription[] = L"File Locksmith Shell Extension";
|
||||
// Description of the registry key
|
||||
constexpr WCHAR RegistryKeyDescription[] = L"File Locksmith Shell Extension";
|
||||
|
||||
// File name of the UI executable
|
||||
constexpr WCHAR FileNameUIExe[] = L"PowerToys.FileLocksmithUI.exe";
|
||||
// File name of the UI executable
|
||||
constexpr WCHAR FileNameUIExe[] = L"PowerToys.FileLocksmithUI.exe";
|
||||
|
||||
// String key used by PowerToys
|
||||
// String key used by PowerToys
|
||||
constexpr WCHAR PowerToyKey[] = L"File Locksmith";
|
||||
|
||||
// Nonlocalized name of this PowerToy, for logs, etc
|
||||
// Nonlocalized name of this PowerToy, for logs, etc
|
||||
constexpr WCHAR PowerToyName[] = L"File Locksmith";
|
||||
|
||||
// JSON key used to store whether the module is enabled
|
||||
// JSON key used to store whether the module is enabled
|
||||
constexpr WCHAR JsonKeyEnabled[] = L"Enabled";
|
||||
|
||||
// Path of the JSON file used to store settings
|
||||
// Path of the JSON file used to store settings
|
||||
constexpr WCHAR DataFilePath[] = L"\\file-locksmith-settings.json";
|
||||
|
||||
// Name of the file where the list of files to checked will be stored
|
||||
// Name of the file where the list of files to checked will be stored
|
||||
constexpr WCHAR LastRunPath[] = L"\\last-run.log";
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <common/logger/logger.h>
|
||||
#include <common/logger/logger_settings.h>
|
||||
#include <common/utils/logger_helper.h>
|
||||
#include <optional>
|
||||
|
||||
#include "Constants.h"
|
||||
#include "dllmain.h"
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace FileLocksmithGUI
|
||||
{
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<Application
|
||||
x:Class="FileLocksmithGUI.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:FileLocksmithGUI">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
|
||||
<!-- Other merged dictionaries here -->
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<!-- Other app resources here -->
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -1,46 +0,0 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "App.xaml.h"
|
||||
#include "MainWindow.xaml.h"
|
||||
|
||||
using namespace winrt;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Microsoft::UI::Xaml;
|
||||
using namespace Microsoft::UI::Xaml::Controls;
|
||||
using namespace Microsoft::UI::Xaml::Navigation;
|
||||
using namespace FileLocksmithGUI;
|
||||
using namespace FileLocksmithGUI::implementation;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the singleton application object. This is the first line of authored code
|
||||
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||
/// </summary>
|
||||
App::App()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
|
||||
UnhandledException([this](IInspectable const&, UnhandledExceptionEventArgs const& e)
|
||||
{
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
auto errorMessage = e.Message();
|
||||
__debugbreak();
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the application is launched normally by the end user. Other entry points
|
||||
/// will be used such as when the application is launched to open a specific file.
|
||||
/// </summary>
|
||||
/// <param name="e">Details about the launch request and process.</param>
|
||||
void App::OnLaunched(LaunchActivatedEventArgs const&)
|
||||
{
|
||||
window = make<MainWindow>();
|
||||
window.Activate();
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "App.xaml.g.h"
|
||||
|
||||
namespace winrt::FileLocksmithGUI::implementation
|
||||
{
|
||||
struct App : AppT<App>
|
||||
{
|
||||
App();
|
||||
|
||||
void OnLaunched(Microsoft::UI::Xaml::LaunchActivatedEventArgs const&);
|
||||
|
||||
private:
|
||||
winrt::Microsoft::UI::Xaml::Window window{ nullptr };
|
||||
};
|
||||
}
|
||||
|
Before Width: | Height: | Size: 432 B |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 637 B |
|
Before Width: | Height: | Size: 283 B |
|
Before Width: | Height: | Size: 456 B |
|
Before Width: | Height: | Size: 2.0 KiB |
@@ -1,241 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.4\build\native\Microsoft.WindowsAppSDK.props" Condition="Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.4\build\native\Microsoft.WindowsAppSDK.props')" />
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.props')" />
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.194\build\Microsoft.Windows.SDK.BuildTools.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.194\build\Microsoft.Windows.SDK.BuildTools.props')" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<CppWinRTOptimized>true</CppWinRTOptimized>
|
||||
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
|
||||
<MinimalCoreWin>true</MinimalCoreWin>
|
||||
<ProjectGuid>{bbd45704-f220-4774-9c92-d55d822c9e75}</ProjectGuid>
|
||||
<ProjectName>FileLocksmithGUI</ProjectName>
|
||||
<RootNamespace>FileLocksmithGUI</RootNamespace>
|
||||
<!--
|
||||
$(TargetName) should be same as $(RootNamespace) so that the produced binaries (.exe/.pri/etc.)
|
||||
have a name that matches the .winmd
|
||||
-->
|
||||
<TargetName>PowerToys.FileLocksmithGUI</TargetName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
|
||||
<AppContainerApplication>false</AppContainerApplication>
|
||||
<AppxPackage>false</AppxPackage>
|
||||
<ApplicationType>Windows Store</ApplicationType>
|
||||
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
||||
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<EnableMsixTooling>true</EnableMsixTooling>
|
||||
<WindowsPackageType>None</WindowsPackageType>
|
||||
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|arm64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>arm64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|arm64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>arm64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<DesktopCompatible>true</DesktopCompatible>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<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>
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup Condition="'$(WindowsPackageType)'!='None' and Exists('Package.appxmanifest')">
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Manifest Include="app.manifest" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="App.xaml.h">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MainWindow.xaml.h">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ProcessEntry.xaml.h">
|
||||
<DependentUpon>ProcessEntry.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml" />
|
||||
<Page Include="MainWindow.xaml" />
|
||||
<Page Include="ProcessEntry.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="App.xaml.cpp">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MainWindow.xaml.cpp">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
<ClCompile Include="ProcessEntry.xaml.cpp">
|
||||
<DependentUpon>ProcessEntry.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Midl Include="App.idl">
|
||||
<SubType>Code</SubType>
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Midl>
|
||||
<Midl Include="MainWindow.idl">
|
||||
<SubType>Code</SubType>
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
</Midl>
|
||||
<Midl Include="ProcessEntry.idl">
|
||||
<DependentUpon>ProcessEntry.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Midl>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="readme.txt">
|
||||
<DeploymentContent>false</DeploymentContent>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="Assets\LockScreenLogo.scale-200.png" />
|
||||
<Image Include="Assets\SplashScreen.scale-200.png" />
|
||||
<Image Include="Assets\Square150x150Logo.scale-200.png" />
|
||||
<Image Include="Assets\Square44x44Logo.scale-200.png" />
|
||||
<Image Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Image Include="Assets\StoreLogo.png" />
|
||||
<Image Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||
</ItemGroup>
|
||||
<!--
|
||||
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
|
||||
Tools extension to be activated for this project even if the Windows App SDK Nuget
|
||||
package has not yet been restored.
|
||||
-->
|
||||
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
|
||||
<ProjectCapability Include="Msix" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\Themes\Themes.vcxproj">
|
||||
<Project>{98537082-0fdb-40de-abd8-0dc5a4269bab}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\FileLocksmithLib\FileLocksmithLib.vcxproj">
|
||||
<Project>{8290cf58-0e97-45c4-ab41-f3c7c3128aec}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<!--
|
||||
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
|
||||
Explorer "Package and Publish" context menu entry to be enabled for this project even if
|
||||
the Windows App SDK Nuget package has not yet been restored.
|
||||
-->
|
||||
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
|
||||
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm64'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileLocksmith\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm64'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileLocksmith\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileLocksmith\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileLocksmith\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileLocksmith\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileLocksmith\</OutDir>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.210806.1\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.210806.1\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.194\build\Microsoft.Windows.SDK.BuildTools.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.194\build\Microsoft.Windows.SDK.BuildTools.targets')" />
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
|
||||
<Import Project="..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.4\build\native\Microsoft.WindowsAppSDK.targets" Condition="Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.4\build\native\Microsoft.WindowsAppSDK.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.SDK.BuildTools.10.0.22000.194\build\Microsoft.Windows.SDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.194\build\Microsoft.Windows.SDK.BuildTools.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.194\build\Microsoft.Windows.SDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.194\build\Microsoft.Windows.SDK.BuildTools.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.4\build\native\Microsoft.WindowsAppSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.4\build\native\Microsoft.WindowsAppSDK.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.4\build\native\Microsoft.WindowsAppSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.WindowsAppSDK.1.1.4\build\native\Microsoft.WindowsAppSDK.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="MainWindow.xaml" />
|
||||
<Page Include="ProcessEntry.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Midl Include="App.idl" />
|
||||
<Midl Include="MainWindow.idl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp" />
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="Assets\Wide310x150Logo.scale-200.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="Assets\StoreLogo.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="Assets\Square150x150Logo.scale-200.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="Assets\Square44x44Logo.scale-200.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="Assets\SplashScreen.scale-200.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="Assets\LockScreenLogo.scale-200.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Assets">
|
||||
<UniqueIdentifier>{bbd45704-f220-4774-9c92-d55d822c9e75}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="readme.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Manifest Include="app.manifest" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace FileLocksmithGUI
|
||||
{
|
||||
[default_interface]
|
||||
runtimeclass MainWindow : Microsoft.UI.Xaml.Window
|
||||
{
|
||||
MainWindow();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<Window
|
||||
x:Class="FileLocksmithGUI.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:FileLocksmithGUI"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Grid>
|
||||
<Button Margin="8,8,8,0" Click="onRefreshClick" HorizontalAlignment="Right">Refresh</Button>
|
||||
</Grid>
|
||||
|
||||
<ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<StackPanel x:Name="stackPanel" Orientation="Vertical"/>
|
||||
</ScrollViewer>
|
||||
</StackPanel>
|
||||
|
||||
</Window>
|
||||
@@ -1,213 +0,0 @@
|
||||
#include "pch.h"
|
||||
#include "MainWindow.xaml.h"
|
||||
#if __has_include("MainWindow.g.cpp")
|
||||
#include "MainWindow.g.cpp"
|
||||
#endif
|
||||
|
||||
#include "../FileLocksmithLib/IPC.h"
|
||||
#include "../FileLocksmithLib/FileLocksmith.h"
|
||||
|
||||
#include "../../../common/Themes/theme_helpers.h"
|
||||
#include "../../../common/Themes/theme_listener.h"
|
||||
|
||||
#pragma comment(lib, "shcore") // GetDpiForMonitor
|
||||
#pragma comment(lib, "dwmapi") // Themes
|
||||
|
||||
using namespace winrt;
|
||||
using namespace Microsoft::UI;
|
||||
using namespace Microsoft::UI::Xaml;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
|
||||
namespace
|
||||
{
|
||||
ThemeListener theme_listener{};
|
||||
HWND native_handle;
|
||||
|
||||
void handle_theme()
|
||||
{
|
||||
auto theme = theme_listener.AppTheme;
|
||||
auto isDark = theme == AppTheme::Dark;
|
||||
ThemeHelpers::SetImmersiveDarkMode(native_handle, isDark);
|
||||
}
|
||||
}
|
||||
|
||||
namespace winrt::FileLocksmithGUI::implementation
|
||||
{
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
m_paths = ipc::read_paths_from_stdin();
|
||||
|
||||
Title(L"File Locksmith");
|
||||
|
||||
// Set up theme
|
||||
find_native_handle();
|
||||
native_handle = m_native_handle;
|
||||
theme_listener.AddChangedHandler(handle_theme);
|
||||
handle_theme();
|
||||
|
||||
place_and_resize();
|
||||
InitializeComponent();
|
||||
|
||||
start_finding_processes();
|
||||
}
|
||||
|
||||
void MainWindow::start_finding_processes()
|
||||
{
|
||||
std::thread([&] {
|
||||
find_processes();
|
||||
}).detach();
|
||||
|
||||
display_progress_ring();
|
||||
}
|
||||
|
||||
void MainWindow::find_processes()
|
||||
{
|
||||
auto process_info = find_processes_recursive(m_paths);
|
||||
|
||||
// Show results using the UI thread
|
||||
DispatcherQueue().TryEnqueue([&, process_info = std::move(process_info)] {
|
||||
stackPanel().Children().Clear();
|
||||
|
||||
for (const auto& process : process_info)
|
||||
{
|
||||
ProcessEntry entry(process.name, process.pid, process.files.size());
|
||||
|
||||
for (auto path : process.files)
|
||||
{
|
||||
entry.AddPath(path);
|
||||
}
|
||||
|
||||
stackPanel().Children().Append(entry);
|
||||
|
||||
// Launch a thread to erase this entry if the process exits
|
||||
std::thread([&, pid = process.pid] {
|
||||
watch_process(pid);
|
||||
}).detach();
|
||||
}
|
||||
|
||||
display_no_results_if_empty();
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::find_native_handle()
|
||||
{
|
||||
auto windowNative{ this->try_as<::IWindowNative>() };
|
||||
winrt::check_bool(windowNative);
|
||||
windowNative->get_WindowHandle(&m_native_handle);
|
||||
}
|
||||
|
||||
void MainWindow::place_and_resize()
|
||||
{
|
||||
if (!m_native_handle)
|
||||
{
|
||||
find_native_handle();
|
||||
}
|
||||
|
||||
// Get mouse cursor position
|
||||
POINT cursorPosition{0, 0};
|
||||
GetCursorPos(&cursorPosition);
|
||||
::Windows::Graphics::PointInt32 point{ cursorPosition.x, cursorPosition.y };
|
||||
|
||||
// Get monitor area for mouse position
|
||||
auto display_area = Windowing::DisplayArea::GetFromPoint(point, Windowing::DisplayAreaFallback::Nearest);
|
||||
HMONITOR monitor = MonitorFromPoint(cursorPosition, MONITOR_DEFAULTTOPRIMARY);
|
||||
MONITORINFOEXW monitor_info;
|
||||
monitor_info.cbSize = sizeof(MONITORINFOEX);
|
||||
GetMonitorInfoW(monitor, &monitor_info);
|
||||
UINT dpi_x, dpi_y;
|
||||
GetDpiForMonitor(monitor, MONITOR_DPI_TYPE::MDT_EFFECTIVE_DPI, &dpi_x, &dpi_y);
|
||||
UINT window_dpi = GetDpiForWindow(m_native_handle);
|
||||
|
||||
int width = 758;
|
||||
int height = 480;
|
||||
|
||||
winrt::Windows::Graphics::RectInt32 rect;
|
||||
|
||||
// Scale window size
|
||||
rect.Width = (int32_t)(width * (float)window_dpi / dpi_x);
|
||||
rect.Height = (int32_t)(height * (float)window_dpi / dpi_y);
|
||||
|
||||
// Center to screen
|
||||
rect.X = display_area.WorkArea().X + display_area.WorkArea().Width / 2 - width / 2;
|
||||
rect.Y = display_area.WorkArea().Y + display_area.WorkArea().Height / 2 - height / 2;
|
||||
|
||||
// Get app window
|
||||
auto window_id = GetWindowIdFromWindow(m_native_handle);
|
||||
auto app_window = Windowing::AppWindow::GetFromWindowId(window_id);
|
||||
|
||||
app_window.MoveAndResize(rect);
|
||||
}
|
||||
|
||||
void MainWindow::display_no_results_if_empty()
|
||||
{
|
||||
if (stackPanel().Children().Size() == 0)
|
||||
{
|
||||
// Construct the UI element and display it
|
||||
Controls::TextBlock text_block;
|
||||
|
||||
text_block.Text(L"No results.");
|
||||
text_block.FontSize(24.0);
|
||||
text_block.HorizontalAlignment(HorizontalAlignment::Center);
|
||||
text_block.VerticalAlignment(VerticalAlignment::Center);
|
||||
|
||||
stackPanel().Children().Append(text_block);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::display_progress_ring()
|
||||
{
|
||||
stackPanel().Children().Clear();
|
||||
|
||||
Controls::ProgressRing ring;
|
||||
ring.Width(64);
|
||||
ring.Height(64);
|
||||
ring.Margin(Thickness{ .Top = 16 });
|
||||
ring.IsIndeterminate(true);
|
||||
|
||||
stackPanel().Children().Append(ring);
|
||||
}
|
||||
|
||||
void MainWindow::watch_process(DWORD pid)
|
||||
{
|
||||
HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, pid);
|
||||
|
||||
if (!process)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto wait_result = WaitForSingleObject(process, INFINITE);
|
||||
CloseHandle(process);
|
||||
|
||||
if (wait_result == WAIT_OBJECT_0)
|
||||
{
|
||||
// Find entry with this PID and erase it
|
||||
DispatcherQueue().TryEnqueue([&, pid] {
|
||||
|
||||
for (uint32_t i = 0; i < stackPanel().Children().Size(); i++)
|
||||
{
|
||||
auto element = stackPanel().Children().GetAt(i);
|
||||
auto process_entry = element.try_as<ProcessEntry>();
|
||||
if (!process_entry)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (process_entry.Pid() == pid)
|
||||
{
|
||||
stackPanel().Children().RemoveAt(i);
|
||||
display_no_results_if_empty();
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onRefreshClick(Windows::Foundation::IInspectable const&, RoutedEventArgs const&)
|
||||
{
|
||||
start_finding_processes();
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "MainWindow.g.h"
|
||||
#include "../FileLocksmithLib/FileLocksmith.h"
|
||||
|
||||
namespace winrt::FileLocksmithGUI::implementation
|
||||
{
|
||||
struct MainWindow : MainWindowT<MainWindow>
|
||||
{
|
||||
MainWindow();
|
||||
void onRefreshClick(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
|
||||
private:
|
||||
void start_finding_processes();
|
||||
void find_processes();
|
||||
void find_native_handle();
|
||||
void place_and_resize();
|
||||
void display_no_results_if_empty();
|
||||
void display_progress_ring();
|
||||
void watch_process(DWORD pid);
|
||||
|
||||
HWND m_native_handle = NULL;
|
||||
std::vector<std::wstring> m_paths;
|
||||
};
|
||||
}
|
||||
|
||||
namespace winrt::FileLocksmithGUI::factory_implementation
|
||||
{
|
||||
struct MainWindow : MainWindowT<MainWindow, implementation::MainWindow>
|
||||
{
|
||||
};
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||
IgnorableNamespaces="uap rescap">
|
||||
|
||||
<Identity
|
||||
Name="fc28f10c-afe2-4208-b33c-e6b9d0d19af3"
|
||||
Publisher="CN=Admin"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<Properties>
|
||||
<DisplayName>FileLocksmithGUI</DisplayName>
|
||||
<PublisherDisplayName>Admin</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="$targetentrypoint$">
|
||||
<uap:VisualElements
|
||||
DisplayName="FileLocksmithGUI"
|
||||
Description="FileLocksmithGUI"
|
||||
BackgroundColor="transparent"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<rescap:Capability Name="runFullTrust" />
|
||||
</Capabilities>
|
||||
</Package>
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace FileLocksmithGUI
|
||||
{
|
||||
[default_interface]
|
||||
runtimeclass ProcessEntry : Microsoft.UI.Xaml.Controls.UserControl
|
||||
{
|
||||
ProcessEntry(String process, UInt32 pid, UInt64 num_files);
|
||||
UInt32 Pid();
|
||||
void AddPath(String file);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<UserControl
|
||||
x:Class="FileLocksmithGUI.ProcessEntry"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:FileLocksmithGUI"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Expander Margin="8,8,8,0" HorizontalAlignment="Stretch">
|
||||
<Expander.Header>
|
||||
<Grid>
|
||||
<BitmapIcon Name="processIcon"></BitmapIcon>
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch">
|
||||
<TextBlock Margin="4" FontSize="28" Name="processName"/>
|
||||
<Grid HorizontalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.25*"/>
|
||||
<ColumnDefinition Width="0.25*"/>
|
||||
<ColumnDefinition Width="0.5*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Margin="4" FontSize="12" Name="processPid" HorizontalAlignment="Left"/>
|
||||
<TextBlock Grid.Column="1" Margin="4" FontSize="12" Name="processFileCount" HorizontalAlignment="Left"/>
|
||||
<TextBlock Grid.Column="2" Margin="4" FontSize="12" Name="processUser" HorizontalAlignment="Left"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<Button Margin="4" Click="killProcessClick" HorizontalAlignment="Right">End Task</Button>
|
||||
</Grid>
|
||||
</Expander.Header>
|
||||
<Expander.Content>
|
||||
<StackPanel Margin="4" Orientation="Vertical" Name="filesContainer"/>
|
||||
</Expander.Content>
|
||||
</Expander>
|
||||
|
||||
</UserControl>
|
||||
@@ -1,59 +0,0 @@
|
||||
#include "pch.h"
|
||||
#include "ProcessEntry.xaml.h"
|
||||
#if __has_include("ProcessEntry.g.cpp")
|
||||
#include "ProcessEntry.g.cpp"
|
||||
#endif
|
||||
|
||||
#include "../FileLocksmithLib/FileLocksmith.h"
|
||||
|
||||
using namespace winrt;
|
||||
using namespace Microsoft::UI::Xaml;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
|
||||
namespace winrt::FileLocksmithGUI::implementation
|
||||
{
|
||||
ProcessEntry::ProcessEntry(const winrt::hstring& process, DWORD pid, uint64_t num_files)
|
||||
{
|
||||
InitializeComponent();
|
||||
processName().Text(process);
|
||||
|
||||
auto processPidStr = L"Process ID: " + std::to_wstring(pid);
|
||||
auto processFileCountStr = L"Files used: " + std::to_wstring(num_files);
|
||||
auto processUserStr = L"User: " + pid_to_user(pid);
|
||||
|
||||
processPid().Text(processPidStr);
|
||||
processFileCount().Text(processFileCountStr);
|
||||
processUser().Text(processUserStr);
|
||||
|
||||
m_pid = pid;
|
||||
}
|
||||
|
||||
DWORD ProcessEntry::Pid()
|
||||
{
|
||||
return m_pid;
|
||||
}
|
||||
|
||||
void ProcessEntry::AddPath(const winrt::hstring& path)
|
||||
{
|
||||
Controls::TextBlock entry;
|
||||
entry.IsTextSelectionEnabled(true);
|
||||
entry.Text(path);
|
||||
entry.HorizontalAlignment(HorizontalAlignment::Left);
|
||||
|
||||
filesContainer().Children().Append(entry);
|
||||
}
|
||||
|
||||
void ProcessEntry::killProcessClick(Windows::Foundation::IInspectable const&, RoutedEventArgs const&)
|
||||
{
|
||||
HANDLE process = OpenProcess(PROCESS_TERMINATE, FALSE, m_pid);
|
||||
if (!process || !TerminateProcess(process, 1))
|
||||
{
|
||||
MessageBoxW(NULL, L"Failed to kill process.", L"Error", MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
CloseHandle(process);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "winrt/Microsoft.UI.Xaml.h"
|
||||
#include "winrt/Microsoft.UI.Xaml.Markup.h"
|
||||
#include "winrt/Microsoft.UI.Xaml.Controls.Primitives.h"
|
||||
#include "ProcessEntry.g.h"
|
||||
|
||||
namespace winrt::FileLocksmithGUI::implementation
|
||||
{
|
||||
struct ProcessEntry : ProcessEntryT<ProcessEntry>
|
||||
{
|
||||
ProcessEntry(const winrt::hstring& process, DWORD pid, uint64_t num_files);
|
||||
DWORD Pid();
|
||||
void AddPath(const winrt::hstring& path);
|
||||
|
||||
void killProcessClick(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
|
||||
private:
|
||||
DWORD m_pid;
|
||||
};
|
||||
}
|
||||
|
||||
namespace winrt::FileLocksmithGUI::factory_implementation
|
||||
{
|
||||
struct ProcessEntry : ProcessEntryT<ProcessEntry, implementation::ProcessEntry>
|
||||
{
|
||||
};
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="FileLocksmithGUI.app"/>
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<!-- The combination of below two tags have the following effect:
|
||||
1) Per-Monitor for >= Windows 10 Anniversary Update
|
||||
2) System < Windows 10 Anniversary Update
|
||||
-->
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
</assembly>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.220418.1" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220201.1" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.SDK.BuildTools" version="10.0.22000.194" targetFramework="native" />
|
||||
<package id="Microsoft.WindowsAppSDK" version="1.1.4" targetFramework="native" />
|
||||
</packages>
|
||||
@@ -1 +0,0 @@
|
||||
#include "pch.h"
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
#include <windows.h>
|
||||
#include <unknwn.h>
|
||||
#include <restrictederrorinfo.h>
|
||||
#include <hstring.h>
|
||||
#include <ShellScalingApi.h>
|
||||
|
||||
// Undefine GetCurrentTime macro to prevent
|
||||
// conflict with Storyboard::GetCurrentTime
|
||||
#undef GetCurrentTime
|
||||
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <winrt/Windows.ApplicationModel.Activation.h>
|
||||
#include <winrt/Microsoft.UI.Composition.h>
|
||||
#include <winrt/Microsoft.UI.Interop.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.Controls.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.Controls.Primitives.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.Data.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.Interop.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.Markup.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.Media.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.Navigation.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.Shapes.h>
|
||||
#include <winrt/Microsoft.UI.Dispatching.h>
|
||||
#include <winrt/Microsoft.UI.Windowing.h>
|
||||
#include <wil/cppwinrt_helpers.h>
|
||||
#include <microsoft.ui.xaml.window.h>
|
||||
@@ -1,27 +0,0 @@
|
||||
========================================================================
|
||||
FileLocksmithGUI Project Overview
|
||||
========================================================================
|
||||
|
||||
This project demonstrates how to get started writing WinUI3 apps directly
|
||||
with standard C++, using the Windows App SDK and C++/WinRT packages and
|
||||
XAML compiler support to generate implementation headers from interface
|
||||
(IDL) files. These headers can then be used to implement the local
|
||||
Windows Runtime classes referenced in the app's XAML pages.
|
||||
|
||||
Steps:
|
||||
1. Create an interface (IDL) file to define any local Windows Runtime
|
||||
classes referenced in the app's XAML pages.
|
||||
2. Build the project once to generate implementation templates under
|
||||
the "Generated Files" folder, as well as skeleton class definitions
|
||||
under "Generated Files\sources".
|
||||
3. Use the skeleton class definitions for reference to implement your
|
||||
Windows Runtime classes.
|
||||
|
||||
========================================================================
|
||||
Learn more about Windows App SDK here:
|
||||
https://docs.microsoft.com/windows/apps/windows-app-sdk/
|
||||
Learn more about WinUI3 here:
|
||||
https://docs.microsoft.com/windows/apps/winui/winui3/
|
||||
Learn more about C++/WinRT here:
|
||||
http://aka.ms/cppwinrt/
|
||||
========================================================================
|
||||
@@ -1,149 +0,0 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "FileLocksmith.h"
|
||||
#include "NtdllExtensions.h"
|
||||
|
||||
static bool is_directory(const std::wstring path)
|
||||
{
|
||||
DWORD attributes = GetFileAttributesW(path.c_str());
|
||||
return attributes != INVALID_FILE_ATTRIBUTES && attributes & FILE_ATTRIBUTE_DIRECTORY;
|
||||
}
|
||||
|
||||
std::vector<ProcessResult> find_processes_recursive(const std::vector<std::wstring>& paths)
|
||||
{
|
||||
NtdllExtensions nt_ext;
|
||||
|
||||
// TODO use a trie!
|
||||
|
||||
// This maps kernel names of files within `paths` to their normal paths.
|
||||
std::map<std::wstring, std::wstring> kernel_names_files;
|
||||
|
||||
// This maps kernel names of directories within `paths` to their normal paths.
|
||||
std::map<std::wstring, std::wstring> kernel_names_dirs;
|
||||
|
||||
for (const auto& path : paths)
|
||||
{
|
||||
auto kernel_path = nt_ext.path_to_kernel_name(path.c_str());
|
||||
if (!kernel_path.empty())
|
||||
{
|
||||
(is_directory(path) ? kernel_names_dirs : kernel_names_files)[kernel_path] = path;
|
||||
}
|
||||
}
|
||||
|
||||
std::map<DWORD, std::vector<std::wstring>> pid_files;
|
||||
|
||||
// Returns a normal path of the file specified by kernel_name, if it matches
|
||||
// the search criteria. Otherwise, return an empty string.
|
||||
auto kernel_paths_contain = [&](const std::wstring& kernel_name) -> std::wstring
|
||||
{
|
||||
// Normal equivalence
|
||||
if (auto it = kernel_names_files.find(kernel_name); it != kernel_names_files.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
if (auto it = kernel_names_dirs.find(kernel_name); it != kernel_names_dirs.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
for (const auto& [dir_kernel_name, dir_path] : kernel_names_dirs)
|
||||
{
|
||||
if (kernel_name.starts_with(dir_kernel_name + L"\\"))
|
||||
{
|
||||
return dir_path + kernel_name.substr(dir_kernel_name.size());
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
};
|
||||
|
||||
for (const auto& handle_info : nt_ext.handles())
|
||||
{
|
||||
if (handle_info.type_name == L"File")
|
||||
{
|
||||
auto path = kernel_paths_contain(handle_info.kernel_file_name);
|
||||
if (!path.empty())
|
||||
{
|
||||
pid_files[handle_info.pid].push_back(std::move(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ProcessResult> result;
|
||||
|
||||
for (const auto& process_info : nt_ext.processes())
|
||||
{
|
||||
if (auto it = pid_files.find(process_info.pid); it != pid_files.end())
|
||||
{
|
||||
result.push_back(ProcessResult
|
||||
{
|
||||
.name = process_info.name,
|
||||
.pid = process_info.pid,
|
||||
.files = it->second
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring pid_to_user(DWORD pid)
|
||||
{
|
||||
HANDLE process = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
|
||||
|
||||
if (process == NULL)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::wstring user = L"";
|
||||
std::wstring domain = L"";
|
||||
|
||||
HANDLE token = NULL;
|
||||
|
||||
if (OpenProcessToken(process, TOKEN_QUERY, &token))
|
||||
{
|
||||
DWORD token_size = 0;
|
||||
GetTokenInformation(token, TokenUser, NULL, 0, &token_size);
|
||||
|
||||
if (token_size > 0)
|
||||
{
|
||||
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();
|
||||
PSID psid = user_ptr->User.Sid;
|
||||
DWORD user_size = 0;
|
||||
DWORD domain_size = 0;
|
||||
SID_NAME_USE sid_name;
|
||||
LookupAccountSidW(NULL, psid, NULL, &user_size, NULL, &domain_size, &sid_name);
|
||||
user.resize(user_size + 1);
|
||||
domain.resize(domain_size + 1);
|
||||
LookupAccountSidW(NULL, psid, user.data(), &user_size, domain.data(), &domain_size, &sid_name);
|
||||
user[user_size] = L'\0';
|
||||
domain[domain_size] = L'\0';
|
||||
}
|
||||
|
||||
CloseHandle(token);
|
||||
}
|
||||
|
||||
CloseHandle(process);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
constexpr size_t LongMaxPathSize = 65536;
|
||||
|
||||
std::wstring pid_to_full_path(DWORD pid)
|
||||
{
|
||||
HANDLE process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, 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());
|
||||
result.resize(length);
|
||||
|
||||
CloseHandle(process);
|
||||
return result;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
struct ProcessResult
|
||||
{
|
||||
std::wstring name;
|
||||
DWORD pid;
|
||||
std::vector<std::wstring> files;
|
||||
};
|
||||
|
||||
// Second version, checks handles towards files and all subfiles and folders of given dirs, if any.
|
||||
std::vector<ProcessResult> find_processes_recursive(const std::vector<std::wstring>& paths);
|
||||
|
||||
// Gives the user name of the account running this process
|
||||
std::wstring pid_to_user(DWORD pid);
|
||||
|
||||
// Gives the full path of the executable, given the process id
|
||||
std::wstring pid_to_full_path(DWORD pid);
|
||||
@@ -1,244 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<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>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{8290cf58-0e97-45c4-ab41-f3c7c3128aec}</ProjectGuid>
|
||||
<RootNamespace>FileLocksmithLib</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</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">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileLocksmith\</OutDir>
|
||||
<TargetName>PowerToys.FileLocksmithLib</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileLocksmith\</OutDir>
|
||||
<TargetName>PowerToys.FileLocksmithLib</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileLocksmith\</OutDir>
|
||||
<TargetName>PowerToys.FileLocksmithLib</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileLocksmith\</OutDir>
|
||||
<TargetName>PowerToys.FileLocksmithLib</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileLocksmith\</OutDir>
|
||||
<TargetName>PowerToys.FileLocksmithLib</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileLocksmith\</OutDir>
|
||||
<TargetName>PowerToys.FileLocksmithLib</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="FileLocksmith.h" />
|
||||
<ClInclude Include="IPC.h" />
|
||||
<ClInclude Include="NtdllBase.h" />
|
||||
<ClInclude Include="NtdllExtensions.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="FileLocksmith.cpp" />
|
||||
<ClCompile Include="IPC.cpp" />
|
||||
<ClCompile Include="NtdllBase.cpp" />
|
||||
<ClCompile Include="NtdllExtensions.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NtdllBase.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NtdllExtensions.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IPC.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FileLocksmith.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NtdllBase.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NtdllExtensions.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IPC.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FileLocksmith.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,122 +0,0 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "IPC.h"
|
||||
|
||||
constexpr DWORD DefaultPipeBufferSize = 8192;
|
||||
constexpr DWORD DefaultPipeTimeoutMillis = 200;
|
||||
|
||||
namespace ipc
|
||||
{
|
||||
Writer::Writer()
|
||||
{
|
||||
start();
|
||||
}
|
||||
|
||||
Writer::~Writer()
|
||||
{
|
||||
finish();
|
||||
}
|
||||
|
||||
HRESULT Writer::start()
|
||||
{
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
sa.bInheritHandle = TRUE;
|
||||
|
||||
if (!CreatePipe(&m_read_pipe, &m_write_pipe, &sa, 0))
|
||||
{
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Writer::add_path(LPCWSTR path)
|
||||
{
|
||||
int length = lstrlenW(path);
|
||||
DWORD written;
|
||||
if (!WriteFile(m_write_pipe, path, length * sizeof(WCHAR), &written, NULL))
|
||||
{
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
if (written != length * sizeof(WCHAR))
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
WCHAR line_break = L'\n';
|
||||
if (!WriteFile(m_write_pipe, &line_break, sizeof(WCHAR), &written, NULL))
|
||||
{
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
if (written != sizeof(WCHAR))
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void Writer::finish()
|
||||
{
|
||||
add_path(L"");
|
||||
|
||||
if (m_write_pipe)
|
||||
{
|
||||
CloseHandle(m_write_pipe);
|
||||
m_write_pipe = NULL;
|
||||
}
|
||||
|
||||
if (m_read_pipe)
|
||||
{
|
||||
CloseHandle(m_read_pipe);
|
||||
m_read_pipe = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
HANDLE Writer::get_read_handle()
|
||||
{
|
||||
HANDLE result = m_read_pipe;
|
||||
m_read_pipe = NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::wstring> read_paths_from_stdin()
|
||||
{
|
||||
std::vector<std::wstring> result;
|
||||
std::wstring line;
|
||||
|
||||
bool finished = false;
|
||||
|
||||
while (!finished)
|
||||
{
|
||||
WCHAR ch;
|
||||
// We have to read data like this
|
||||
if (!std::cin.read(reinterpret_cast<char*>(&ch), 2))
|
||||
{
|
||||
finished = true;
|
||||
}
|
||||
else if (ch == L'\n')
|
||||
{
|
||||
if (line.empty())
|
||||
{
|
||||
finished = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.push_back(line);
|
||||
line = {};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
line += ch;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
namespace ipc
|
||||
{
|
||||
class Writer
|
||||
{
|
||||
public:
|
||||
Writer();
|
||||
~Writer();
|
||||
HRESULT start();
|
||||
HRESULT add_path(LPCWSTR path);
|
||||
void finish();
|
||||
HANDLE get_read_handle();
|
||||
private:
|
||||
HANDLE m_read_pipe = NULL;
|
||||
HANDLE m_write_pipe = NULL;
|
||||
};
|
||||
|
||||
std::vector<std::wstring> read_paths_from_stdin();
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "NtdllBase.h"
|
||||
|
||||
Ntdll::Ntdll()
|
||||
{
|
||||
m_module = GetModuleHandleW(L"ntdll.dll");
|
||||
if (m_module == 0)
|
||||
{
|
||||
throw std::runtime_error{ "GetModuleHandleW returned null" };
|
||||
}
|
||||
|
||||
m_NtQuerySystemInformation = (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");
|
||||
if (m_NtDuplicateObject == 0)
|
||||
{
|
||||
throw std::runtime_error{ "GetProcAddress returned null for NtDuplicateObject" };
|
||||
}
|
||||
|
||||
m_NtQueryObject = (NtQueryObject_t)GetProcAddress(m_module, "NtQueryObject");
|
||||
if (m_NtQueryObject == 0)
|
||||
{
|
||||
throw std::runtime_error{ "GetProcAddress returned null for NtQueryObject" };
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS Ntdll::NtQuerySystemInformation(
|
||||
ULONG SystemInformationClass,
|
||||
PVOID SystemInformation,
|
||||
ULONG SystemInformationLength,
|
||||
PULONG ReturnLength)
|
||||
{
|
||||
return m_NtQuerySystemInformation(SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength);
|
||||
}
|
||||
|
||||
NTSTATUS Ntdll::NtDuplicateObject(
|
||||
HANDLE SourceProcessHandle,
|
||||
HANDLE SourceHandle,
|
||||
HANDLE TargetProcessHandle,
|
||||
PHANDLE TargetHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
ULONG Attributes,
|
||||
ULONG Options)
|
||||
{
|
||||
return m_NtDuplicateObject(SourceProcessHandle, SourceHandle, TargetProcessHandle, TargetHandle, DesiredAccess, Attributes, Options);
|
||||
}
|
||||
|
||||
NTSTATUS Ntdll::NtQueryObject(
|
||||
HANDLE ObjectHandle,
|
||||
ULONG ObjectInformationClass,
|
||||
PVOID ObjectInformation,
|
||||
ULONG ObjectInformationLength,
|
||||
PULONG ReturnLength)
|
||||
{
|
||||
return m_NtQueryObject(ObjectHandle, ObjectInformationClass, ObjectInformation, ObjectInformationLength, ReturnLength);
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#define DECLARE_NTDLL_FUNCTION(name, ...) \
|
||||
private: \
|
||||
typedef NTSTATUS(NTAPI* name ## _t)( \
|
||||
__VA_ARGS__ \
|
||||
); \
|
||||
name ## _t m_ ## name; \
|
||||
public: \
|
||||
NTSTATUS name(__VA_ARGS__);
|
||||
|
||||
class Ntdll
|
||||
{
|
||||
private:
|
||||
HMODULE m_module;
|
||||
public:
|
||||
struct SYSTEM_HANDLE
|
||||
{
|
||||
ULONG ProcessId;
|
||||
BYTE ObjectTypeNumber;
|
||||
BYTE Flags;
|
||||
USHORT Handle;
|
||||
PVOID Object;
|
||||
ACCESS_MASK GrantedAccess;
|
||||
};
|
||||
|
||||
struct SYSTEM_HANDLE_INFORMATION
|
||||
{
|
||||
ULONG HandleCount;
|
||||
SYSTEM_HANDLE Handles[1];
|
||||
};
|
||||
|
||||
enum POOL_TYPE
|
||||
{
|
||||
NonPagedPool,
|
||||
PagedPool,
|
||||
NonPagedPoolMustSucceed,
|
||||
DontUseThisType,
|
||||
NonPagedPoolCacheAligned,
|
||||
PagedPoolCacheAligned,
|
||||
NonPagedPoolCacheAlignedMustS
|
||||
};
|
||||
|
||||
struct OBJECT_TYPE_INFORMATION
|
||||
{
|
||||
UNICODE_STRING Name;
|
||||
ULONG TotalNumberOfObjects;
|
||||
ULONG TotalNumberOfHandles;
|
||||
ULONG TotalPagedPoolUsage;
|
||||
ULONG TotalNonPagedPoolUsage;
|
||||
ULONG TotalNamePoolUsage;
|
||||
ULONG TotalHandleTableUsage;
|
||||
ULONG HighWaterNumberOfObjects;
|
||||
ULONG HighWaterNumberOfHandles;
|
||||
ULONG HighWaterPagedPoolUsage;
|
||||
ULONG HighWaterNonPagedPoolUsage;
|
||||
ULONG HighWaterNamePoolUsage;
|
||||
ULONG HighWaterHandleTableUsage;
|
||||
ULONG InvalidAttributes;
|
||||
GENERIC_MAPPING GenericMapping;
|
||||
ULONG ValidAccess;
|
||||
BOOLEAN SecurityRequired;
|
||||
BOOLEAN MaintainHandleCount;
|
||||
USHORT MaintainTypeList;
|
||||
POOL_TYPE PoolType;
|
||||
ULONG PagedPoolUsage;
|
||||
ULONG NonPagedPoolUsage;
|
||||
};
|
||||
|
||||
Ntdll();
|
||||
|
||||
DECLARE_NTDLL_FUNCTION(NtQuerySystemInformation,
|
||||
ULONG SystemInformationClass,
|
||||
PVOID SystemInformation,
|
||||
ULONG SystemInformationLength,
|
||||
PULONG ReturnLength
|
||||
)
|
||||
|
||||
DECLARE_NTDLL_FUNCTION(NtDuplicateObject,
|
||||
HANDLE SourceProcessHandle,
|
||||
HANDLE SourceHandle,
|
||||
HANDLE TargetProcessHandle,
|
||||
PHANDLE TargetHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
ULONG Attributes,
|
||||
ULONG Options
|
||||
)
|
||||
|
||||
DECLARE_NTDLL_FUNCTION(NtQueryObject,
|
||||
HANDLE ObjectHandle,
|
||||
ULONG ObjectInformationClass,
|
||||
PVOID ObjectInformation,
|
||||
ULONG ObjectInformationLength,
|
||||
PULONG ReturnLength
|
||||
);
|
||||
};
|
||||
@@ -1,200 +0,0 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "NtdllExtensions.h"
|
||||
|
||||
#define STATUS_INFO_LENGTH_MISMATCH ((LONG)0xC0000004)
|
||||
|
||||
// Calls NtQuerySystemInformation and returns a buffer containing the result.
|
||||
|
||||
namespace
|
||||
{
|
||||
std::wstring_view unicode_to_view(UNICODE_STRING unicode_str)
|
||||
{
|
||||
return std::wstring_view(unicode_str.Buffer, unicode_str.Length / sizeof(WCHAR));
|
||||
}
|
||||
|
||||
std::wstring unicode_to_str(UNICODE_STRING unicode_str)
|
||||
{
|
||||
return std::wstring(unicode_str.Buffer, unicode_str.Length / sizeof(WCHAR));
|
||||
}
|
||||
}
|
||||
|
||||
NtdllExtensions::MemoryLoopResult NtdllExtensions::NtQuerySystemInformationMemoryLoop(ULONG SystemInformationClass)
|
||||
{
|
||||
MemoryLoopResult result;
|
||||
result.memory.resize(DefaultResultBufferSize);
|
||||
|
||||
while (result.memory.size() <= MaxResultBufferSize)
|
||||
{
|
||||
ULONG result_len;
|
||||
result.status = NtQuerySystemInformation(SystemInformationClass, result.memory.data(), (ULONG)result.memory.size(), &result_len);
|
||||
|
||||
if (result.status == STATUS_INFO_LENGTH_MISMATCH)
|
||||
{
|
||||
result.memory.resize(result.memory.size() * 2);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (NT_ERROR(result.status))
|
||||
{
|
||||
result.memory.clear();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
result.status = STATUS_INFO_LENGTH_MISMATCH;
|
||||
result.memory.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring NtdllExtensions::file_handle_to_kernel_name(HANDLE file_handle, std::vector<BYTE>& buffer)
|
||||
{
|
||||
if (GetFileType(file_handle) != FILE_TYPE_DISK)
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
|
||||
ULONG return_length;
|
||||
auto status = NtQueryObject(file_handle, ObjectNameInformation, buffer.data(), (ULONG)buffer.size(), &return_length);
|
||||
if (NT_SUCCESS(status))
|
||||
{
|
||||
auto object_name_info = (UNICODE_STRING*)buffer.data();
|
||||
return unicode_to_str(*object_name_info);
|
||||
}
|
||||
|
||||
return L"";
|
||||
}
|
||||
|
||||
std::wstring NtdllExtensions::file_handle_to_kernel_name(HANDLE file_handle)
|
||||
{
|
||||
std::vector<BYTE> buffer(DefaultResultBufferSize);
|
||||
return file_handle_to_kernel_name(file_handle, buffer);
|
||||
}
|
||||
|
||||
std::wstring NtdllExtensions::path_to_kernel_name(LPCWSTR path)
|
||||
{
|
||||
HANDLE file_handle = CreateFileW(path, 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||
if (file_handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto kernel_name = file_handle_to_kernel_name(file_handle);
|
||||
CloseHandle(file_handle);
|
||||
return kernel_name;
|
||||
}
|
||||
|
||||
std::vector<NtdllExtensions::HandleInfo> NtdllExtensions::handles() noexcept
|
||||
{
|
||||
auto get_info_result = NtQuerySystemInformationMemoryLoop(SystemHandleInformation);
|
||||
if (NT_ERROR(get_info_result.status))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto info_ptr = (SYSTEM_HANDLE_INFORMATION*)get_info_result.memory.data();
|
||||
|
||||
std::map<DWORD, HANDLE> pid_to_handle;
|
||||
std::vector<HandleInfo> result;
|
||||
|
||||
std::vector<BYTE> object_info_buffer(DefaultResultBufferSize);
|
||||
|
||||
for (ULONG i = 0; i < info_ptr->HandleCount; i++)
|
||||
{
|
||||
auto handle_info = info_ptr->Handles + i;
|
||||
DWORD pid = handle_info->ProcessId;
|
||||
|
||||
HANDLE process_handle = NULL;
|
||||
auto iter = pid_to_handle.find(pid);
|
||||
if (iter != pid_to_handle.end())
|
||||
{
|
||||
process_handle = iter->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
process_handle = OpenProcess(PROCESS_DUP_HANDLE, FALSE, pid);
|
||||
if (!process_handle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pid_to_handle[pid] = process_handle;
|
||||
}
|
||||
|
||||
// According to this:
|
||||
// https://stackoverflow.com/questions/46384048/enumerate-handles
|
||||
// NtQueryObject could hang
|
||||
|
||||
// TODO uncomment and investigate
|
||||
// if (handle_info->GrantedAccess == 0x0012019f) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
HANDLE handle_copy;
|
||||
|
||||
auto dh_result = DuplicateHandle(process_handle, (HANDLE)handle_info->Handle, GetCurrentProcess(), &handle_copy, 0, 0, DUPLICATE_SAME_ACCESS);
|
||||
if (dh_result == 0)
|
||||
{
|
||||
// Ignore this handle.
|
||||
continue;
|
||||
}
|
||||
|
||||
ULONG return_length;
|
||||
auto status = NtQueryObject(handle_copy, ObjectTypeInformation, object_info_buffer.data(), (ULONG)object_info_buffer.size(), &return_length);
|
||||
if (NT_ERROR(status))
|
||||
{
|
||||
// Ignore this handle.
|
||||
CloseHandle(handle_copy);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto object_type_info = (OBJECT_TYPE_INFORMATION*)object_info_buffer.data();
|
||||
auto type_name = unicode_to_str(object_type_info->Name);
|
||||
|
||||
std::wstring file_name = file_handle_to_kernel_name(handle_copy, object_info_buffer);
|
||||
|
||||
if (type_name == L"File")
|
||||
{
|
||||
file_name = file_handle_to_kernel_name(handle_copy, object_info_buffer);
|
||||
}
|
||||
|
||||
result.push_back(HandleInfo{ pid, handle_info->Handle, type_name, file_name });
|
||||
CloseHandle(handle_copy);
|
||||
}
|
||||
|
||||
for (auto [pid, handle] : pid_to_handle)
|
||||
{
|
||||
CloseHandle(handle);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Returns the list of all processes.
|
||||
// On failure, returns an empty vector.
|
||||
|
||||
std::vector<NtdllExtensions::ProcessInfo> NtdllExtensions::processes() noexcept
|
||||
{
|
||||
auto get_info_result = NtQuerySystemInformationMemoryLoop(SystemProcessInformation);
|
||||
|
||||
if (NT_ERROR(get_info_result.status))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<ProcessInfo> result;
|
||||
auto info_ptr = (PSYSTEM_PROCESS_INFORMATION)get_info_result.memory.data();
|
||||
|
||||
while (info_ptr->NextEntryOffset)
|
||||
{
|
||||
info_ptr = decltype(info_ptr)((LPBYTE)info_ptr + info_ptr->NextEntryOffset);
|
||||
|
||||
ProcessInfo item;
|
||||
item.name = unicode_to_str(info_ptr->ImageName);
|
||||
item.pid = (DWORD)(uintptr_t)info_ptr->UniqueProcessId;
|
||||
|
||||
result.push_back(item);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#include "NtdllBase.h"
|
||||
|
||||
class NtdllExtensions : protected Ntdll
|
||||
{
|
||||
private:
|
||||
constexpr static size_t DefaultResultBufferSize = 64 * 1024;
|
||||
constexpr static size_t MaxResultBufferSize = 1024 * 1024 * 1024;
|
||||
|
||||
constexpr static int ObjectNameInformation = 1;
|
||||
constexpr static int SystemHandleInformation = 16;
|
||||
|
||||
struct MemoryLoopResult
|
||||
{
|
||||
NTSTATUS status = 0;
|
||||
std::vector<BYTE> memory;
|
||||
};
|
||||
|
||||
// Calls NtQuerySystemInformation and returns a buffer containing the result.
|
||||
MemoryLoopResult NtQuerySystemInformationMemoryLoop(ULONG SystemInformationClass);
|
||||
|
||||
std::wstring file_handle_to_kernel_name(HANDLE file_handle, std::vector<BYTE>& buffer);
|
||||
|
||||
public:
|
||||
struct ProcessInfo
|
||||
{
|
||||
DWORD pid = 0;
|
||||
std::wstring name;
|
||||
};
|
||||
|
||||
struct HandleInfo
|
||||
{
|
||||
DWORD pid;
|
||||
USHORT handle;
|
||||
std::wstring type_name;
|
||||
std::wstring kernel_file_name;
|
||||
};
|
||||
|
||||
std::wstring file_handle_to_kernel_name(HANDLE file_handle);
|
||||
|
||||
std::wstring path_to_kernel_name(LPCWSTR path);
|
||||
|
||||
std::vector<HandleInfo> handles() noexcept;
|
||||
|
||||
// Returns the list of all processes.
|
||||
// On failure, returns an empty vector.
|
||||
std::vector<ProcessInfo> processes() noexcept;
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
// pch.cpp: source file corresponding to the pre-compiled header
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
|
||||
@@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// System headers
|
||||
#define NOMINMAX
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <winternl.h>
|
||||
#include <Psapi.h>
|
||||
|
||||
// C++ standard library headers
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
struct ProcessResult
|
||||
{
|
||||
std::wstring name;
|
||||
DWORD pid;
|
||||
std::wstring name;
|
||||
DWORD pid;
|
||||
std::vector<std::wstring> files;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,67 +1,68 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\..\Version.props" />
|
||||
<Import Project="..\..\..\Version.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyTitle>PowerToys.FileLocksmith</AssemblyTitle>
|
||||
<AssemblyDescription>PowerToys File Locksmith</AssemblyDescription>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
|
||||
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)\modules\FileLocksmith</OutputPath>
|
||||
<RootNamespace>PowerToys.FileLocksmithUI</RootNamespace>
|
||||
<AssemblyName>PowerToys.FileLocksmithUI</AssemblyName>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<RuntimeIdentifiers>win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<GenerateSatelliteAssembliesForCore>true</GenerateSatelliteAssembliesForCore>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
|
||||
<WindowsPackageType>None</WindowsPackageType>
|
||||
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
|
||||
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
|
||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyTitle>PowerToys.FileLocksmith</AssemblyTitle>
|
||||
<AssemblyDescription>PowerToys File Locksmith</AssemblyDescription>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
|
||||
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)\modules\FileLocksmith</OutputPath>
|
||||
<RootNamespace>PowerToys.FileLocksmithUI</RootNamespace>
|
||||
<AssemblyName>PowerToys.FileLocksmithUI</AssemblyName>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<RuntimeIdentifiers>win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<GenerateSatelliteAssembliesForCore>true</GenerateSatelliteAssembliesForCore>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
|
||||
<WindowsPackageType>None</WindowsPackageType>
|
||||
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
|
||||
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
|
||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<NoWarn>0436</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<NoWarn>0436</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Views\MainPage.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Views\MainPage.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Labs.WinUI.SettingsControls" Version="0.0.2" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.UI" Version="7.1.2" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.5" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22000.194" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
<PackageReference Include="WinUIEx" Version="1.8.0" />
|
||||
<Manifest Include="$(ApplicationManifest)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Labs.WinUI.SettingsControls" Version="0.0.2" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.UI" Version="7.1.2" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.5" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22000.194" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
<PackageReference Include="WinUIEx" Version="1.8.0" />
|
||||
<Manifest Include="$(ApplicationManifest)" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
|
||||
<!-- Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
|
||||
Tools extension to be activated for this project even if the Windows App SDK Nuget
|
||||
package has not yet been restored -->
|
||||
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnablePreviewMsixTooling)'=='true'">
|
||||
<ProjectCapability Include="Msix" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="icon.ico" />
|
||||
</ItemGroup> <ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\interop\PowerToys.Interop.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
||||
<ProjectReference Include="..\FileLocksmithLibInterop\FileLocksmithLibInterop.vcxproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Views\MainPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnablePreviewMsixTooling)'=='true'">
|
||||
<ProjectCapability Include="Msix" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="icon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\interop\PowerToys.Interop.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
||||
<ProjectReference Include="..\FileLocksmithLibInterop\FileLocksmithLibInterop.vcxproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Views\MainPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <compare>
|
||||
#include <optional>
|
||||
|
||||
/*
|
||||
DLL Interface for PowerToys. The powertoy_create() (see below) must return
|
||||
|
||||