mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Changed how executables are detected and shown in cli and gui.
This commit is contained in:
@@ -55,12 +55,6 @@ namespace exeinfo
|
||||
IExecutable coffExe = new COFF(exeFs);
|
||||
IExecutable peExe = new PE(exeFs);
|
||||
|
||||
if(mzExe.Recognized)
|
||||
{
|
||||
recognized = true;
|
||||
Console.Write(mzExe.Information);
|
||||
}
|
||||
|
||||
if(neExe.Recognized)
|
||||
{
|
||||
recognized = true;
|
||||
@@ -116,6 +110,21 @@ namespace exeinfo
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(lxExe.Recognized)
|
||||
{
|
||||
recognized = true;
|
||||
Console.Write(lxExe.Information);
|
||||
}
|
||||
else if(peExe.Recognized)
|
||||
{
|
||||
recognized = true;
|
||||
Console.Write(peExe.Information);
|
||||
}
|
||||
else if(mzExe.Recognized)
|
||||
{
|
||||
recognized = true;
|
||||
Console.Write(mzExe.Information);
|
||||
}
|
||||
|
||||
if(stExe.Recognized)
|
||||
{
|
||||
@@ -123,24 +132,12 @@ namespace exeinfo
|
||||
Console.Write(stExe.Information);
|
||||
}
|
||||
|
||||
if(lxExe.Recognized)
|
||||
{
|
||||
recognized = true;
|
||||
Console.Write(lxExe.Information);
|
||||
}
|
||||
|
||||
if(coffExe.Recognized)
|
||||
{
|
||||
recognized = true;
|
||||
Console.Write(coffExe.Information);
|
||||
}
|
||||
|
||||
if(peExe.Recognized)
|
||||
{
|
||||
recognized = true;
|
||||
Console.Write(peExe.Information);
|
||||
}
|
||||
|
||||
if(!recognized) Console.WriteLine("Executable format not recognized");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ namespace exeinfogui
|
||||
{
|
||||
public class MainForm : Form
|
||||
{
|
||||
ComboBox cmbArch;
|
||||
TextBox txtFile;
|
||||
TextArea txtInformation;
|
||||
TextBox txtType;
|
||||
ComboBox cmbArch;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
@@ -50,6 +50,7 @@ namespace exeinfogui
|
||||
txtFile.Text = "";
|
||||
txtType.Text = "";
|
||||
txtInformation.Text = "";
|
||||
cmbArch.Items.Clear();
|
||||
|
||||
OpenFileDialog dlgOpen = new OpenFileDialog {Title = "Choose executable file", MultiSelect = false};
|
||||
|
||||
@@ -65,59 +66,32 @@ namespace exeinfogui
|
||||
IExecutable lxExe = new LX(exeFs);
|
||||
IExecutable coffExe = new COFF(exeFs);
|
||||
IExecutable peExe = new PE(exeFs);
|
||||
IExecutable recognizedExe = null;
|
||||
|
||||
if(mzExe.Recognized)
|
||||
{
|
||||
if(neExe.Recognized)
|
||||
{
|
||||
txtType.Text = neExe.Type;
|
||||
txtInformation.Text = neExe.Information;
|
||||
foreach(Architecture arch in neExe.Architectures)
|
||||
cmbArch.Items.Add(Enums.ArchitectureName.FirstOrDefault(t => t.arch == arch).longName);
|
||||
}
|
||||
if(mzExe.Recognized) recognizedExe = mzExe;
|
||||
|
||||
if(neExe.Recognized) recognizedExe = neExe;
|
||||
else if(lxExe.Recognized)
|
||||
{
|
||||
txtType.Text = lxExe.Type;
|
||||
txtInformation.Text = lxExe.Information;
|
||||
foreach(Architecture arch in lxExe.Architectures)
|
||||
cmbArch.Items.Add(Enums.ArchitectureName.FirstOrDefault(t => t.arch == arch).longName);
|
||||
}
|
||||
recognizedExe = lxExe;
|
||||
else if(peExe.Recognized)
|
||||
{
|
||||
txtType.Text = peExe.Type;
|
||||
txtInformation.Text = peExe.Information;
|
||||
foreach(Architecture arch in peExe.Architectures)
|
||||
cmbArch.Items.Add(Enums.ArchitectureName.FirstOrDefault(t => t.arch == arch).longName);
|
||||
}
|
||||
else
|
||||
{
|
||||
txtType.Text = mzExe.Type;
|
||||
foreach(Architecture arch in mzExe.Architectures)
|
||||
cmbArch.Items.Add(Enums.ArchitectureName.FirstOrDefault(t => t.arch == arch).longName);
|
||||
}
|
||||
|
||||
txtInformation.Text += mzExe.Information;
|
||||
}
|
||||
recognizedExe = peExe;
|
||||
else if(stExe.Recognized)
|
||||
{
|
||||
txtType.Text = stExe.Type;
|
||||
txtInformation.Text = stExe.Information;
|
||||
foreach(Architecture arch in stExe.Architectures)
|
||||
cmbArch.Items.Add(Enums.ArchitectureName.FirstOrDefault(t => t.arch == arch).longName);
|
||||
}
|
||||
recognizedExe = stExe;
|
||||
else if(coffExe.Recognized)
|
||||
{
|
||||
txtType.Text = coffExe.Type;
|
||||
txtInformation.Text = coffExe.Information;
|
||||
foreach(Architecture arch in coffExe.Architectures)
|
||||
cmbArch.Items.Add(Enums.ArchitectureName.FirstOrDefault(t => t.arch == arch).longName);
|
||||
}
|
||||
recognizedExe = coffExe;
|
||||
else
|
||||
txtType.Text = "Format not recognized";
|
||||
|
||||
cmbArch.SelectedIndex = 0;
|
||||
|
||||
exeFs.Close();
|
||||
|
||||
if(recognizedExe == null) return;
|
||||
|
||||
txtType.Text = recognizedExe.Type;
|
||||
txtInformation.Text = recognizedExe.Information;
|
||||
foreach(Architecture arch in recognizedExe.Architectures)
|
||||
cmbArch.Items.Add(Enums.ArchitectureName.FirstOrDefault(ar => ar.arch == arch).longName);
|
||||
}
|
||||
|
||||
protected void OnMnuAboutClick(object sender, EventArgs e)
|
||||
|
||||
@@ -30,11 +30,12 @@ namespace libexeinfo
|
||||
{
|
||||
public partial class LX
|
||||
{
|
||||
public string Information => GetInfo(header);
|
||||
public string Information => GetInfo(header, baseExecutable);
|
||||
|
||||
static string GetInfo(LXHeader header)
|
||||
static string GetInfo(LXHeader header, IExecutable baseExecutable)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(baseExecutable.Information);
|
||||
sb.AppendLine(header.signature == SIGNATURE16 ? "Linear Executable (LE):" : "Linear eXecutable (LX):");
|
||||
|
||||
switch(header.os_type)
|
||||
|
||||
@@ -33,11 +33,12 @@ namespace libexeinfo
|
||||
{
|
||||
public partial class NE
|
||||
{
|
||||
public string Information => GetInfo(Header);
|
||||
public string Information => GetInfo(Header, BaseExecutable);
|
||||
|
||||
public static string GetInfo(NEHeader header)
|
||||
static string GetInfo(NEHeader header, IExecutable baseExecutable)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(baseExecutable.Information);
|
||||
sb.AppendLine("New Executable (NE):");
|
||||
sb.AppendFormat("\tFile's CRC: 0x{0:X8}", header.crc).AppendLine();
|
||||
sb.AppendFormat("\tLinker version: {0}.{1}", header.linker_major, header.linker_minor).AppendLine();
|
||||
|
||||
@@ -30,11 +30,12 @@ namespace libexeinfo
|
||||
{
|
||||
public partial class PE
|
||||
{
|
||||
public string Information => GetInfo(Header, WinHeader);
|
||||
public string Information => GetInfo(Header, WinHeader, BaseExecutable);
|
||||
|
||||
static string GetInfo(PEHeader header, WindowsHeader64 winheader)
|
||||
static string GetInfo(PEHeader header, WindowsHeader64 winheader, IExecutable baseExecutable)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(baseExecutable.Information);
|
||||
sb.Append(COFF.GetInfo(header.coff));
|
||||
sb.AppendLine("Portable Executable (PE):");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user