Skip to content

Commit 76fc629

Browse files
committed
DotNetFileInfo-Tool initial commit
1 parent 06fc04a commit 76fc629

File tree

9 files changed

+230
-0
lines changed

9 files changed

+230
-0
lines changed

.github/FUNDING.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These are supported funding model platforms
2+
3+
github: jogibear9988
4+
patreon: jogibear9988

.github/workflows/build.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: GitHub CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
release:
10+
types:
11+
- released
12+
workflow_dispatch:
13+
14+
jobs:
15+
build:
16+
name: Build
17+
runs-on: windows-latest
18+
defaults:
19+
run:
20+
shell: pwsh
21+
strategy:
22+
matrix:
23+
platform: [net-x64]
24+
include:
25+
- platform: net-x64
26+
package-name: net-win64
27+
build-dir: net8.0-windows\win-x64\publish
28+
29+
steps:
30+
- uses: actions/[email protected]
31+
with:
32+
submodules: true
33+
34+
- uses: actions/[email protected]
35+
with:
36+
dotnet-version: 8.0.x
37+
dotnet-quality: ga
38+
39+
- uses: microsoft/[email protected]
40+
41+
- name: Build
42+
run: dotnet build --no-restore DotNetFileInfo
43+
44+
- name: Create output directory
45+
run: New-Item -ItemType Directory -Path C:\builtfiles\DotNetFileInfo -Force > $null
46+
continue-on-error: true
47+
48+
- name: Copy release files for upload
49+
run: Copy-Item -Path DotNetFileInfo\bin\Release\net8.0-windows\* -Destination C:\builtfiles\DotNetFileInfo -Recurse
50+
51+
- uses: actions/[email protected]
52+
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
53+
with:
54+
name: DotNetFileInfo
55+
path: C:\builtfiles\DotNetFileInfo
56+
if-no-files-found: error
57+
compression-level: 9

DotNetFileInfo.sln

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.11.34929.205
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetFileInfo", "DotNetFileInfo\DotNetFileInfo.csproj", "{24BBB385-8AA1-4727-8899-B19BA179222B}"
6+
EndProject
7+
Global
8+
GlobalSection(ExtensibilityGlobals) = postSolution
9+
SolutionGuid = {48DBEEB7-C451-4039-9214-728D2B776C35}
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{24BBB385-8AA1-4727-8899-B19BA179222B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13+
{24BBB385-8AA1-4727-8899-B19BA179222B}.Debug|Any CPU.Build.0 = Debug|Any CPU
14+
{24BBB385-8AA1-4727-8899-B19BA179222B}.Release|Any CPU.ActiveCfg = Release|Any CPU
15+
{24BBB385-8AA1-4727-8899-B19BA179222B}.Release|Any CPU.Build.0 = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
18+
Debug|Any CPU = Debug|Any CPU
19+
Release|Any CPU = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
EndGlobal

DotNetFileInfo/App.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="DotNetFileInfo.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:DotNetFileInfo"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>

DotNetFileInfo/App.xaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Configuration;
2+
using System.Data;
3+
using System.Windows;
4+
5+
namespace DotNetFileInfo
6+
{
7+
/// <summary>
8+
/// Interaction logic for App.xaml
9+
/// </summary>
10+
public partial class App : Application
11+
{
12+
}
13+
14+
}

DotNetFileInfo/AssemblyInfo.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net8.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<UseWPF>true</UseWPF>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="dnlib" Version="4.4.0" />
13+
</ItemGroup>
14+
15+
</Project>

DotNetFileInfo/MainWindow.xaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Window x:Class="DotNetFileInfo.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:DotNetFileInfo"
7+
mc:Ignorable="d"
8+
Title="DotNetFileInfo" Height="450" Width="800">
9+
<Grid AllowDrop="True" PreviewDragOver="Grid_DragOver" PreviewDrop="Grid_Drop" Background="Transparent">
10+
<Button x:Name="btnFile" Content="..." Margin="0,10,10,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="40" Click="btnFile_Click"/>
11+
<TabControl Margin="10,10,10,10">
12+
<TabItem Header="Assembly">
13+
<Grid>
14+
<DataGrid x:Name="grdAssembly" />
15+
</Grid>
16+
</TabItem>
17+
<TabItem Header="Asembly.Modules[0]">
18+
<Grid>
19+
<DataGrid x:Name="grdModule" />
20+
</Grid>
21+
</TabItem>
22+
</TabControl>
23+
24+
</Grid>
25+
</Window>

DotNetFileInfo/MainWindow.xaml.cs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using dnlib.DotNet;
2+
using Microsoft.Win32;
3+
using System.Collections;
4+
using System.Windows;
5+
6+
namespace DotNetFileInfo
7+
{
8+
/// <summary>
9+
/// Interaction logic for MainWindow.xaml
10+
/// </summary>
11+
public partial class MainWindow : Window
12+
{
13+
public MainWindow()
14+
{
15+
InitializeComponent();
16+
}
17+
18+
private void btnFile_Click(object sender, RoutedEventArgs e)
19+
{
20+
var dlg = new OpenFileDialog() { Filter = "*.exe;*.dll|*.exe;*.dll" };
21+
if (dlg.ShowDialog() == true)
22+
{
23+
LoadFile(dlg.FileName);
24+
}
25+
}
26+
27+
private void Grid_DragOver(object sender, DragEventArgs e)
28+
{
29+
e.Effects = DragDropEffects.Copy;
30+
}
31+
32+
private void Grid_Drop(object sender, DragEventArgs e)
33+
{
34+
string[] fileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
35+
if (fileList != null && fileList.Length > 0)
36+
{
37+
LoadFile(fileList[0]);
38+
}
39+
}
40+
41+
private void LoadFile(string file)
42+
{
43+
try
44+
{
45+
grdAssembly.ItemsSource = null;
46+
grdModule.ItemsSource = null;
47+
this.Title = "DotNetFileInfo - " + file;
48+
ModuleContext modCtx = ModuleDef.CreateModuleContext();
49+
using (ModuleDefMD module = ModuleDefMD.Load(file, modCtx))
50+
{
51+
grdAssembly.ItemsSource = GetPropertiesAsList(module.Assembly);
52+
grdModule.ItemsSource = GetPropertiesAsList(module.Assembly.Modules[0]);
53+
}
54+
}
55+
catch (Exception ex)
56+
{
57+
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
58+
}
59+
}
60+
61+
private IEnumerable GetPropertiesAsList(Object obj)
62+
{
63+
return obj.GetType().GetProperties().Select(x => new PropInfo { Name = x.Name, Value = x.GetValue(obj)?.ToString() ?? "null" });
64+
}
65+
66+
public class PropInfo
67+
{
68+
public string Name { get; set; }
69+
public string Value { get; set; }
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)