Skip to content

Commit ea01f34

Browse files
committed
Show Win32 version info for all PE files (native and managed)
Add Version Info tab with FileVersionInfo fields (description, version, company, copyright, etc.). For native files, show version resource summary in Full Name field and auto-select Version Info tab.
1 parent 5f36c9c commit ea01f34

3 files changed

Lines changed: 127 additions & 7 deletions

File tree

AssemblyInformation.Model/AssemblyInformationLoader.cs

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ public AssemblyInformationLoader(string filePath)
7373
/// </summary>
7474
public string ApphostManagedDll { get; private set; }
7575

76+
/// <summary>
77+
/// Win32 version resource information (available for all PE files).
78+
/// </summary>
79+
public FileVersionInfo VersionInfo { get; private set; }
80+
7681
public AssemblyName[] GetReferencedAssemblies()
7782
{
7883
if (!IsManaged) return Array.Empty<AssemblyName>();
@@ -85,20 +90,44 @@ public AssemblyName[] GetReferencedAssemblies()
8590

8691
private void LoadInformation()
8792
{
93+
// Read Win32 version resources (available for all PE files)
94+
try { VersionInfo = FileVersionInfo.GetVersionInfo(FilePath); } catch { }
95+
8896
DetermineExecutableKind();
8997
if (IsManaged)
9098
{
9199
DetermineMetadata();
92100
}
93-
else if (AssemblyFullName == null)
101+
else
94102
{
95-
// Only set defaults if DetermineExecutableKind didn't already set them
96-
// (e.g. single-file bundle sets its own values)
97-
AssemblyFullName = Path.GetFileName(FilePath);
98-
FrameworkVersion = "N/A (native)";
103+
// For native files, build a rich display name from version resources
104+
AssemblyFullName = BuildNativeDisplayName();
105+
FrameworkVersion ??= "N/A (native)";
99106
}
100107
}
101108

109+
private string BuildNativeDisplayName()
110+
{
111+
if (VersionInfo == null)
112+
return Path.GetFileName(FilePath);
113+
114+
var parts = new List<string>();
115+
116+
if (!string.IsNullOrEmpty(VersionInfo.FileDescription))
117+
parts.Add(VersionInfo.FileDescription);
118+
else
119+
parts.Add(Path.GetFileName(FilePath));
120+
121+
if (!string.IsNullOrEmpty(VersionInfo.FileVersion))
122+
parts.Add($"Version: {VersionInfo.FileVersion}");
123+
if (!string.IsNullOrEmpty(VersionInfo.CompanyName))
124+
parts.Add(VersionInfo.CompanyName);
125+
if (!string.IsNullOrEmpty(VersionInfo.LegalCopyright))
126+
parts.Add(VersionInfo.LegalCopyright);
127+
128+
return parts.Count > 0 ? string.Join("\r\n", parts) : Path.GetFileName(FilePath);
129+
}
130+
102131
private void DetermineExecutableKind()
103132
{
104133
using var stream = File.OpenRead(FilePath);

AssemblyInformation/FormMain.Designer.cs

Lines changed: 52 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AssemblyInformation/FormMain.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ private void LoadAssembly(string assemblyPath)
5656
dependencyTreeView.Nodes.Clear();
5757
referenceListListBox.Items.Clear();
5858
referringAssembliesListtBox.Items.Clear();
59+
versionInfoListView.Items.Clear();
5960

6061
_assemblyPath = assemblyPath;
6162
assemblyInformation = new AssemblyInformationLoader(assemblyPath);
@@ -107,6 +108,8 @@ private void FormMainLoad(object sender, EventArgs e)
107108
frameWorkVersion.Text = assemblyInformation.FrameworkVersion;
108109
txtFullName.Text = assemblyInformation.AssemblyFullName;
109110

111+
FillVersionInfo();
112+
110113
if (!assemblyInformation.IsManaged)
111114
{
112115
// Native binary - show what we have, disable .NET-specific fields
@@ -124,6 +127,8 @@ private void FormMainLoad(object sender, EventArgs e)
124127
txtEditAndContinue.Text = "N/A";
125128
txtEditAndContinue.BackColor = SystemColors.Control;
126129
txtEditAndContinue.ForeColor = SystemColors.GrayText;
130+
// Show Version Info tab by default for native files (references are empty)
131+
tabControl1.SelectedTab = tabPage4;
127132
return;
128133
}
129134

@@ -190,12 +195,48 @@ private void FormMainLoad(object sender, EventArgs e)
190195
txtEditAndContinue.ForeColor = Color.White;
191196
}
192197

198+
// Reset to first tab for managed assemblies
199+
tabControl1.SelectedIndex = 0;
200+
193201
DependencyWalker dependencyWalker = new DependencyWalker();
194202
directDependencies = dependencyWalker.FindDependencies(_assemblyPath, false, out _).ToList();
195203

196204
FillAssemblyReferences(directDependencies);
197205
}
198206

207+
private void FillVersionInfo()
208+
{
209+
versionInfoListView.Items.Clear();
210+
var vi = assemblyInformation.VersionInfo;
211+
if (vi == null) return;
212+
213+
void AddItem(string property, string value)
214+
{
215+
if (!string.IsNullOrEmpty(value))
216+
versionInfoListView.Items.Add(new ListViewItem(new[] { property, value }));
217+
}
218+
219+
AddItem("File Description", vi.FileDescription);
220+
AddItem("File Version", vi.FileVersion);
221+
AddItem("Product Name", vi.ProductName);
222+
AddItem("Product Version", vi.ProductVersion);
223+
AddItem("Company Name", vi.CompanyName);
224+
AddItem("Legal Copyright", vi.LegalCopyright);
225+
AddItem("Legal Trademarks", vi.LegalTrademarks);
226+
AddItem("Original Filename", vi.OriginalFilename);
227+
AddItem("Internal Name", vi.InternalName);
228+
AddItem("Comments", vi.Comments);
229+
AddItem("Language", vi.Language);
230+
AddItem("Private Build", vi.PrivateBuild);
231+
AddItem("Special Build", vi.SpecialBuild);
232+
233+
if (vi.IsDebug) AddItem("Is Debug", "Yes");
234+
if (vi.IsPatched) AddItem("Is Patched", "Yes");
235+
if (vi.IsPreRelease) AddItem("Is Pre-Release", "Yes");
236+
if (vi.IsPrivateBuild) AddItem("Is Private Build", "Yes");
237+
if (vi.IsSpecialBuild) AddItem("Is Special Build", "Yes");
238+
}
239+
199240
private void FormMainFormClosing(object sender, FormClosingEventArgs e)
200241
{
201242
if (_assemblyPath != null)

0 commit comments

Comments
 (0)