Skip to content

Commit e679608

Browse files
committed
- Improve performance using NtDll API to find locking information instead of Sysinternals Handle.
1 parent 5285b5c commit e679608

30 files changed

Lines changed: 519 additions & 360 deletions

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ insert_final_newline = true
77
charset = utf-8
88
indent_style = space
99
indent_size = 4
10+
max_line_length = 150
1011

11-
[*.{xml,wxs, csproj, wixproj, config, sln, svg, manifest, json}]
12+
[*.{xml,wxs,csproj,wixproj,config,sln,svg,manifest,json,yaml}]
1213
indent_size = 2

.github/workflows/main.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ on: push
22

33
jobs:
44
build:
5-
runs-on: windows-latest
5+
runs-on: windows-2022
66
steps:
7-
- uses: actions/checkout@v3
8-
- run: .\build.ps1
9-
- uses: softprops/action-gh-release@v1
7+
- uses: actions/checkout@v4
8+
- run: ./build.ps1
9+
- uses: softprops/action-gh-release@v2
1010
if: startsWith(github.ref, 'refs/tags/')
11-
env:
12-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1311
with:
1412
draft: true
1513
files: Build/Release/Installer/*.msi.zip
16-
- uses: actions/upload-artifact@v3
14+
- uses: actions/upload-artifact@v4
1715
with:
1816
name: Build artifacts
1917
path: Build/Release/Installer/*.msi.zip

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
# ShowWhatProcessLocksFile
2-
A simple clone of [PowerToys File Locksmith](https://learn.microsoft.com/en-us/windows/powertoys/file-locksmith) utility to discover what processes lock a specific file or folder that has the following advantages:
3-
* Supports older versions of Windows
2+
3+
A simple clone of [PowerToys File Locksmith](https://learn.microsoft.com/en-us/windows/powertoys/file-locksmith) utility to discover what processes lock a specific file or folder.
4+
5+
## Advantages over File Locksmith
6+
* Much faster
47
* Lightweight
8+
* Supports older versions of Windows
9+
* Doesn't require admin rights to be installed
10+
11+
## Screenshots
12+
13+
### Context menu
514

6-
# Screenshots
7-
## Context menu
815
<img src="doc/ContextMenu.png" width="70%" height="70%"/>
916

10-
## Application
17+
### Application
18+
1119
<img src="doc/Screenshot.png" width="70%" height="70%"/>
1220

13-
# System requirements
14-
* Windows 8 x64 or higher (you might need to install [.Net Framework 4.6.2](https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net462-web-installer))
21+
## System requirements
1522

16-
# How it works
17-
The application uses [Sysinternals Handle](https://learn.microsoft.com/en-us/sysinternals/downloads/handle) from the [Sysinternals-console-utils-with-Unicode-support](https://github.com/PolarGoose/Sysinternals-console-utils-with-Unicode-support) to get information about locking processes.
23+
* Windows 7 x64 or higher (you might need to install [.Net Framework 4.6.2](https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net462-web-installer))
24+
25+
## How to use
1826

19-
# How to use
2027
* Download `ShowWhatProcessLocksFile.msi.zip` from the latest [release](https://github.com/PolarGoose/ShowWhatProcessLocksFile/releases).
2128
* Run the installer. The installer will install this program to the `%AppData%\ShowWhatProcessLocksFile` folder and add a `Show what locks this file` Windows File Explorer context menu element.
2229
* Use `Show what locks this file` File Explorer's context menu to select a file or folder
2330
* To terminate a process, select it and open a context menu by clicking the right mouse button
2431
* If you want to uninstall the program, use `Control Panel\Programs\Programs and Features`. Uninstaller will remove an integration with the context menu and all installed files.
2532

26-
# How to build
33+
## How to build
34+
2735
* To work with the codebase, use `Visual Studio 2022` with a plugin [HeatWave for VS2022](https://marketplace.visualstudio.com/items?itemName=FireGiant.FireGiantHeatWaveDev17).
2836
* To build a release, run `.\build.ps1` (`git.exe` should be in your PATH)

build.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Function CheckReturnCodeOfPreviousCommand($msg) {
1717
Function GetVersion() {
1818
$gitCommand = Get-Command -Name git
1919

20-
$tag = & $gitCommand describe --exact-match --tags HEAD
20+
try { $tag = & $gitCommand describe --exact-match --tags HEAD } catch { }
2121
if(-Not $?) {
2222
Info "The commit is not tagged. Use 'v0.0-dev' as a version instead"
2323
$tag = "v0.0-dev"
@@ -74,15 +74,22 @@ Info "Version: '$version'. InstallerVersion: '$installerVersion'"
7474
Info "Build project"
7575
& $msbuild `
7676
/property:RestorePackagesConfig=true `
77-
/property:MSBuildWarningsAsMessages=NU1503 `
7877
/property:Configuration=Release `
7978
/property:DebugType=None `
8079
/property:Version=$version `
8180
/property:InstallerVersion=$installerVersion `
81+
/verbosity:Minimal `
8282
/target:"restore;build" `
8383
$root/$projectName.sln
8484
CheckReturnCodeOfPreviousCommand "build failed"
8585

86+
Info "Run tests"
87+
dotnet test `
88+
--no-build `
89+
--configuration Release `
90+
$root/$projectName.sln
91+
CheckReturnCodeOfPreviousCommand "tests failed"
92+
8693
RemoveFileIfExists "$publishDir/${projectName}.msi.zip"
8794
Info "Create zip archive from msi installer"
8895
Compress-Archive -Path "$publishDir/$projectName.msi" -DestinationPath "$publishDir/${projectName}.msi.zip"

nuget.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<config>
4-
<add key="repositoryPath" value="build/nuget" />
5-
<add key="globalPackagesFolder" value="build/nuget" />
4+
<add key="repositoryPath" value="build/nuget"/>
5+
<add key="globalPackagesFolder" value="build/nuget"/>
66
</config>
77
</configuration>

src/App/Gui/Controls/ProcessInfoListViewModel.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
21
using System.Collections;
3-
using System.Collections.Generic;
4-
using System.Linq;
52
using ShowWhatProcessLocksFile.Gui.Utils;
63
using ShowWhatProcessLocksFile.LockFinding;
74

src/App/Gui/Controls/ProcessInfoView.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
<TextBlock Grid.Column="2" Grid.Row="0" Margin="5" FontSize="12">
3131
<Run FontWeight="Bold" Text="{Binding Process.ProcessName, Mode=OneWay}" /> <LineBreak />
3232
Pid: <Run Text="{Binding Process.Pid, Mode=OneWay}" />,
33-
User: <Run Text="{Binding Process.UserNameWithDomain, Mode=OneWay}" />,
33+
User: <Run Text="{Binding Process.DomainAndUserName, Mode=OneWay}" />,
3434
<Run Text="{Binding Process.ProcessExecutableFullName, Mode=OneWay}" />
3535
</TextBlock>
3636

3737
<ItemsControl Grid.Row="1"
3838
Grid.Column="0"
3939
Grid.ColumnSpan="3"
40-
ItemsSource="{Binding Process.LockedPath}"
40+
ItemsSource="{Binding Process.LockedFileFullNames}"
4141
Visibility="{Binding IsExpanded, Converter={StaticResource BooleanToCollapsedVisibilityConverter}}">
4242
<ItemsControl.ItemTemplate>
4343
<DataTemplate>

src/App/Gui/Controls/ProcessInfoViewModel.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
namespace ShowWhatProcessLocksFile.Gui.Controls;
55

6-
internal class ProcessInfoViewModel : ViewModelBase
6+
internal class ProcessInfoViewModel(ProcessInfo process) : ViewModelBase
77
{
8-
public ProcessInfo Process { get; }
8+
public ProcessInfo Process { get; } = process;
99

1010
private bool isExpanded;
1111

@@ -18,9 +18,4 @@ public bool IsExpanded
1818
OnPropertyChanged();
1919
}
2020
}
21-
22-
public ProcessInfoViewModel(ProcessInfo process)
23-
{
24-
Process = process;
25-
}
2621
}

src/App/Gui/Controls/ProgressBarWithTextView.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:ShowWhatProcessLocksFile.Gui.Controls"
7-
x:Name="self"
87
mc:Ignorable="d"
98
d:DesignHeight="450" d:DesignWidth="800"
109
d:DataContext="{d:DesignInstance Type=local:ProgressBarWithTextViewModel, IsDesignTimeCreatable=False}">

src/App/Gui/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
xmlns:utils="clr-namespace:ShowWhatProcessLocksFile.Gui.Utils"
88
xmlns:controls="clr-namespace:ShowWhatProcessLocksFile.Gui.Controls"
99
mc:Ignorable="d"
10-
x:Name="self"
10+
x:Name="Self"
1111
Title="{Binding Title}" Height="450" Width="800"
1212
d:DataContext="{d:DesignInstance Type=local:MainWindowViewModel, IsDesignTimeCreatable=False}">
1313
<Window.Resources>

0 commit comments

Comments
 (0)