mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Added required operating system name and version to executable interface.
This commit is contained in:
@@ -28,6 +28,18 @@
|
|||||||
</StackLayoutItem>
|
</StackLayoutItem>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</StackLayoutItem>
|
</StackLayoutItem>
|
||||||
|
<StackLayoutItem HorizontalAlignment="Stretch">
|
||||||
|
<StackLayout Orientation="Horizontal">
|
||||||
|
<Label ID="lblOs">Required operating system:</Label>
|
||||||
|
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||||
|
<TextBox ID="txtOs" ReadOnly="True" />
|
||||||
|
</StackLayoutItem>
|
||||||
|
<Label ID="lblSubsystem" Visible="False">Subsystem:</Label>
|
||||||
|
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||||
|
<TextBox ID="txtSubsystem" ReadOnly="True" Visible="False" />
|
||||||
|
</StackLayoutItem>
|
||||||
|
</StackLayout>
|
||||||
|
</StackLayoutItem>
|
||||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||||
<StackLayout Orientation="Vertical">
|
<StackLayout Orientation="Vertical">
|
||||||
<Label ID="lblInformation">Information:</Label>
|
<Label ID="lblInformation">Information:</Label>
|
||||||
|
|||||||
@@ -36,8 +36,11 @@ namespace exeinfogui
|
|||||||
public class MainForm : Form
|
public class MainForm : Form
|
||||||
{
|
{
|
||||||
ComboBox cmbArch;
|
ComboBox cmbArch;
|
||||||
|
Label lblSubsystem;
|
||||||
TextBox txtFile;
|
TextBox txtFile;
|
||||||
TextArea txtInformation;
|
TextArea txtInformation;
|
||||||
|
TextBox txtOs;
|
||||||
|
TextBox txtSubsystem;
|
||||||
TextBox txtType;
|
TextBox txtType;
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
@@ -51,6 +54,8 @@ namespace exeinfogui
|
|||||||
txtType.Text = "";
|
txtType.Text = "";
|
||||||
txtInformation.Text = "";
|
txtInformation.Text = "";
|
||||||
cmbArch.Items.Clear();
|
cmbArch.Items.Clear();
|
||||||
|
lblSubsystem.Visible = false;
|
||||||
|
txtSubsystem.Visible = false;
|
||||||
|
|
||||||
OpenFileDialog dlgOpen = new OpenFileDialog {Title = "Choose executable file", MultiSelect = false};
|
OpenFileDialog dlgOpen = new OpenFileDialog {Title = "Choose executable file", MultiSelect = false};
|
||||||
|
|
||||||
@@ -82,8 +87,6 @@ namespace exeinfogui
|
|||||||
else
|
else
|
||||||
txtType.Text = "Format not recognized";
|
txtType.Text = "Format not recognized";
|
||||||
|
|
||||||
cmbArch.SelectedIndex = 0;
|
|
||||||
|
|
||||||
exeFs.Close();
|
exeFs.Close();
|
||||||
|
|
||||||
if(recognizedExe == null) return;
|
if(recognizedExe == null) return;
|
||||||
@@ -92,6 +95,20 @@ namespace exeinfogui
|
|||||||
txtInformation.Text = recognizedExe.Information;
|
txtInformation.Text = recognizedExe.Information;
|
||||||
foreach(Architecture arch in recognizedExe.Architectures)
|
foreach(Architecture arch in recognizedExe.Architectures)
|
||||||
cmbArch.Items.Add(Enums.ArchitectureName.FirstOrDefault(ar => ar.arch == arch).longName);
|
cmbArch.Items.Add(Enums.ArchitectureName.FirstOrDefault(ar => ar.arch == arch).longName);
|
||||||
|
cmbArch.SelectedIndex = 0;
|
||||||
|
|
||||||
|
if(recognizedExe.RequiredOperatingSystem.MajorVersion > 0)
|
||||||
|
txtOs.Text = $"{recognizedExe.RequiredOperatingSystem.Name}" +
|
||||||
|
$" {recognizedExe.RequiredOperatingSystem.MajorVersion}" +
|
||||||
|
$".{recognizedExe.RequiredOperatingSystem.MinorVersion}";
|
||||||
|
else txtOs.Text = recognizedExe.RequiredOperatingSystem.Name;
|
||||||
|
|
||||||
|
if(!string.IsNullOrEmpty(recognizedExe.RequiredOperatingSystem.Subsystem))
|
||||||
|
{
|
||||||
|
lblSubsystem.Visible = true;
|
||||||
|
txtSubsystem.Visible = true;
|
||||||
|
txtSubsystem.Text = recognizedExe.RequiredOperatingSystem.Subsystem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnMnuAboutClick(object sender, EventArgs e)
|
protected void OnMnuAboutClick(object sender, EventArgs e)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@@ -67,12 +68,13 @@ namespace libexeinfo
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Header for this executable
|
/// Header for this executable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AtariHeader Header { get; private set; }
|
public AtariHeader Header { get; private set; }
|
||||||
public Stream BaseStream { get; }
|
public Stream BaseStream { get; }
|
||||||
public bool IsBigEndian => true;
|
public bool IsBigEndian => true;
|
||||||
public bool Recognized { get; private set; }
|
public bool Recognized { get; private set; }
|
||||||
public string Type { get; private set; }
|
public string Type { get; private set; }
|
||||||
public Architecture[] Architectures => new[] {Architecture.M68K};
|
public IEnumerable<Architecture> Architectures => new[] {Architecture.M68K};
|
||||||
|
public OperatingSystem RequiredOperatingSystem => new OperatingSystem {Name = "Atari TOS"};
|
||||||
|
|
||||||
void Initialize()
|
void Initialize()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@@ -68,12 +69,14 @@ namespace libexeinfo
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Header for this executable
|
/// Header for this executable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public COFFHeader Header { get; private set; }
|
public COFFHeader Header { get; private set; }
|
||||||
public Stream BaseStream { get; }
|
public Stream BaseStream { get; }
|
||||||
public bool IsBigEndian { get; private set; }
|
public bool IsBigEndian { get; private set; }
|
||||||
public bool Recognized { get; private set; }
|
public bool Recognized { get; private set; }
|
||||||
public string Type { get; private set; }
|
public string Type { get; private set; }
|
||||||
public Architecture[] Architectures => new[] {MachineTypeToArchitecture(Header.machine)};
|
public IEnumerable<Architecture> Architectures => new[] {MachineTypeToArchitecture(Header.machine)};
|
||||||
|
public OperatingSystem RequiredOperatingSystem =>
|
||||||
|
new OperatingSystem {Name = "Unknown"}; // TODO: Know
|
||||||
|
|
||||||
void Initialize()
|
void Initialize()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.IO;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace libexeinfo
|
namespace libexeinfo
|
||||||
{
|
{
|
||||||
@@ -27,6 +28,10 @@ namespace libexeinfo
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Architectures that the executable can run on
|
/// Architectures that the executable can run on
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Architecture[] Architectures { get; }
|
IEnumerable<Architecture> Architectures { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Operating system the executable requires to run on
|
||||||
|
/// </summary>
|
||||||
|
OperatingSystem RequiredOperatingSystem { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@@ -75,11 +76,12 @@ namespace libexeinfo
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="FileStream" /> that contains the executable represented by this instance
|
/// The <see cref="FileStream" /> that contains the executable represented by this instance
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Stream BaseStream { get; }
|
public Stream BaseStream { get; }
|
||||||
public bool IsBigEndian => false;
|
public bool IsBigEndian { get; private set; }
|
||||||
public bool Recognized { get; private set; }
|
public bool Recognized { get; private set; }
|
||||||
public string Type { get; private set; }
|
public string Type { get; private set; }
|
||||||
public Architecture[] Architectures => new[] {CpuToArchitecture(header.cpu_type)};
|
public IEnumerable<Architecture> Architectures => new[] {CpuToArchitecture(header.cpu_type)};
|
||||||
|
public OperatingSystem RequiredOperatingSystem { get; private set; }
|
||||||
|
|
||||||
void Initialize()
|
void Initialize()
|
||||||
{
|
{
|
||||||
@@ -102,7 +104,36 @@ namespace libexeinfo
|
|||||||
|
|
||||||
if(!Recognized) return;
|
if(!Recognized) return;
|
||||||
|
|
||||||
Type = header.signature == SIGNATURE16 ? "Linear Executable (LE)" : "Linear eXecutable (LX)";
|
Type = header.signature == SIGNATURE16 ? "Linear Executable (LE)" : "Linear eXecutable (LX)";
|
||||||
|
IsBigEndian = header.byte_order == 1 || header.word_order == 1;
|
||||||
|
|
||||||
|
OperatingSystem reqOs = new OperatingSystem();
|
||||||
|
switch(header.os_type)
|
||||||
|
{
|
||||||
|
case TargetOS.OS2:
|
||||||
|
reqOs.Name = "OS/2";
|
||||||
|
if(header.module_flags.HasFlag(ModuleFlags.PMIncompatible) &&
|
||||||
|
!header.module_flags.HasFlag(ModuleFlags.PMCompatible) ||
|
||||||
|
!header.module_flags.HasFlag(ModuleFlags.PMIncompatible) &&
|
||||||
|
header.module_flags.HasFlag(ModuleFlags.PMCompatible)) reqOs.Subsystem = "Console";
|
||||||
|
else if(header.module_flags.HasFlag(ModuleFlags.PMIncompatible) &&
|
||||||
|
header.module_flags.HasFlag(ModuleFlags.PMCompatible))
|
||||||
|
reqOs.Subsystem = "Presentation Manager";
|
||||||
|
break;
|
||||||
|
case TargetOS.Windows:
|
||||||
|
case TargetOS.Win32:
|
||||||
|
case TargetOS.Unknown:
|
||||||
|
reqOs.Name = "Windows";
|
||||||
|
break;
|
||||||
|
case TargetOS.DOS:
|
||||||
|
reqOs.Name = "Windows";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
reqOs.Name = $"Unknown code {(ushort)header.os_type}";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
RequiredOperatingSystem = reqOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@@ -78,9 +79,10 @@ namespace libexeinfo
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true this instance correctly represents a DOS relocatable executable
|
/// If true this instance correctly represents a DOS relocatable executable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Recognized { get; private set; }
|
public bool Recognized { get; private set; }
|
||||||
public string Type { get; private set; }
|
public string Type { get; private set; }
|
||||||
public Architecture[] Architectures => new[] {Architecture.I86};
|
public IEnumerable<Architecture> Architectures => new[] {Architecture.I86};
|
||||||
|
public OperatingSystem RequiredOperatingSystem => new OperatingSystem {Name = "DOS"};
|
||||||
|
|
||||||
void Initialize()
|
void Initialize()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -64,105 +64,123 @@ namespace libexeinfo
|
|||||||
if(header.program_flags.HasFlag(ProgramFlags.i87))
|
if(header.program_flags.HasFlag(ProgramFlags.i87))
|
||||||
sb.AppendLine("\tApplication uses floating point instructions");
|
sb.AppendLine("\tApplication uses floating point instructions");
|
||||||
|
|
||||||
if(header.target_os == TargetOS.OS2)
|
switch(header.target_os)
|
||||||
{
|
{
|
||||||
sb.AppendLine("\tOS/2 application");
|
case TargetOS.OS2:
|
||||||
if(header.os_major > 0)
|
sb.AppendLine("\tOS/2 application");
|
||||||
sb.AppendFormat("\tApplication requires OS/2 {0}.{1} to run", header.os_major, header.os_minor)
|
if(header.os_major > 0)
|
||||||
.AppendLine();
|
sb.AppendFormat("\tApplication requires OS/2 {0}.{1} to run", header.os_major, header.os_minor)
|
||||||
else sb.AppendLine("\tApplication requires OS/2 1.0 to run");
|
.AppendLine();
|
||||||
if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
else sb.AppendLine("\tApplication requires OS/2 1.0 to run");
|
||||||
!header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
sb.AppendLine("\tApplication is full screen, unaware of Presentation Manager");
|
!header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
else if(!header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
sb.AppendLine("\tApplication is full screen, unaware of Presentation Manager");
|
||||||
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
else if(!header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
sb.AppendLine("\tApplication is aware of Presentation Manager, but doesn't use it");
|
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
else if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
sb.AppendLine("\tApplication is aware of Presentation Manager, but doesn't use it");
|
||||||
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
else if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
sb.AppendLine("\tApplication uses Presentation Manager");
|
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
if(header.os2_flags.HasFlag(OS2Flags.LongFilename))
|
sb.AppendLine("\tApplication uses Presentation Manager");
|
||||||
sb.AppendLine("\tApplication supports long filenames");
|
if(header.os2_flags.HasFlag(OS2Flags.LongFilename))
|
||||||
if(header.os2_flags.HasFlag(OS2Flags.ProtectedMode2))
|
sb.AppendLine("\tApplication supports long filenames");
|
||||||
sb.AppendLine("\tApplication uses OS/2 2.x protected mode");
|
if(header.os2_flags.HasFlag(OS2Flags.ProtectedMode2))
|
||||||
if(header.os2_flags.HasFlag(OS2Flags.ProportionalFonts))
|
sb.AppendLine("\tApplication uses OS/2 2.x protected mode");
|
||||||
sb.AppendLine("\tApplication uses OS/2 2.x proportional fonts");
|
if(header.os2_flags.HasFlag(OS2Flags.ProportionalFonts))
|
||||||
if(header.os2_flags.HasFlag(OS2Flags.GangloadArea))
|
sb.AppendLine("\tApplication uses OS/2 2.x proportional fonts");
|
||||||
sb.AppendFormat("\tGangload area starts at {0} an runs for {1} bytes", header.return_thunks_offset,
|
if(header.os2_flags.HasFlag(OS2Flags.GangloadArea))
|
||||||
header.segment_reference_thunks).AppendLine();
|
sb.AppendFormat("\tGangload area starts at {0} an runs for {1} bytes",
|
||||||
else
|
header.return_thunks_offset, header.segment_reference_thunks).AppendLine();
|
||||||
{
|
else
|
||||||
|
{
|
||||||
|
sb.AppendFormat("\tReturn thunks are at: {0}", header.return_thunks_offset)
|
||||||
|
.AppendLine();
|
||||||
|
sb.AppendFormat("\tSegment reference thunks are at: {0}", header.segment_reference_thunks)
|
||||||
|
.AppendLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case TargetOS.Windows:
|
||||||
|
case TargetOS.Win32:
|
||||||
|
case TargetOS.Unknown:
|
||||||
|
switch(header.target_os)
|
||||||
|
{
|
||||||
|
case TargetOS.Windows:
|
||||||
|
case TargetOS.Unknown:
|
||||||
|
sb.AppendLine("\t16-bit Windows application");
|
||||||
|
break;
|
||||||
|
case TargetOS.Win32:
|
||||||
|
sb.AppendLine("\t32-bit Windows application");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(header.os_major > 0)
|
||||||
|
sb.AppendFormat("\tApplication requires Windows {0}.{1} to run", header.os_major,
|
||||||
|
header.os_minor).AppendLine();
|
||||||
|
else
|
||||||
|
switch(header.target_os)
|
||||||
|
{
|
||||||
|
case TargetOS.Windows:
|
||||||
|
sb.AppendLine("\tApplication requires Windows 2.0 to run");
|
||||||
|
break;
|
||||||
|
case TargetOS.Unknown:
|
||||||
|
sb.AppendLine("\tApplication requires Windows 1.0 to run");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
|
!header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
|
sb.AppendLine("\tApplication is full screen, unaware of Windows");
|
||||||
|
else if(!header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
|
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
|
sb.AppendLine("\tApplication is aware of Windows, but doesn't use it");
|
||||||
|
else if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
|
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
|
sb.AppendLine("\tApplication uses Windows");
|
||||||
sb.AppendFormat("\tReturn thunks are at: {0}", header.return_thunks_offset).AppendLine();
|
sb.AppendFormat("\tReturn thunks are at: {0}", header.return_thunks_offset).AppendLine();
|
||||||
sb.AppendFormat("\tSegment reference thunks are at: {0}", header.segment_reference_thunks)
|
sb.AppendFormat("\tSegment reference thunks are at: {0}", header.segment_reference_thunks)
|
||||||
.AppendLine();
|
.AppendLine();
|
||||||
}
|
break;
|
||||||
}
|
case TargetOS.DOS:
|
||||||
else if(header.target_os == TargetOS.Windows || header.target_os == TargetOS.Win32 ||
|
sb.AppendLine("\tDOS application");
|
||||||
header.target_os == TargetOS.Unknown)
|
sb.AppendFormat("\tApplication requires DOS {0}.{1} to run", header.os_major, header.os_minor)
|
||||||
{
|
|
||||||
if(header.target_os == TargetOS.Windows || header.target_os == TargetOS.Unknown)
|
|
||||||
sb.AppendLine("\t16-bit Windows application");
|
|
||||||
else if(header.target_os == TargetOS.Win32)
|
|
||||||
sb.AppendLine("\t32-bit Windows application");
|
|
||||||
if(header.os_major > 0)
|
|
||||||
sb.AppendFormat("\tApplication requires Windows {0}.{1} to run", header.os_major, header.os_minor)
|
|
||||||
.AppendLine();
|
.AppendLine();
|
||||||
else if(header.target_os == TargetOS.Windows)
|
if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
sb.AppendLine("\tApplication requires Windows 2.0 to run");
|
!header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
else if(header.target_os == TargetOS.Unknown)
|
sb.AppendLine("\tApplication is full screen, unaware of Windows");
|
||||||
sb.AppendLine("\tApplication requires Windows 1.0 to run");
|
else if(!header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
!header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
sb.AppendLine("\tApplication is aware of Windows, but doesn't use it");
|
||||||
sb.AppendLine("\tApplication is full screen, unaware of Windows");
|
else if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
else if(!header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
sb.AppendLine("\tApplication uses Windows");
|
||||||
sb.AppendLine("\tApplication is aware of Windows, but doesn't use it");
|
sb.AppendFormat("\tReturn thunks are at: {0}", header.return_thunks_offset).AppendLine();
|
||||||
else if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
sb.AppendFormat("\tSegment reference thunks are at: {0}", header.segment_reference_thunks)
|
||||||
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
.AppendLine();
|
||||||
sb.AppendLine("\tApplication uses Windows");
|
break;
|
||||||
sb.AppendFormat("\tReturn thunks are at: {0}", header.return_thunks_offset).AppendLine();
|
case TargetOS.Borland:
|
||||||
sb.AppendFormat("\tSegment reference thunks are at: {0}", header.segment_reference_thunks).AppendLine();
|
sb.AppendLine("\tBorland Operating System Services application");
|
||||||
}
|
sb.AppendFormat("\tApplication requires DOS {0}.{1} to run", header.os_major, header.os_minor)
|
||||||
else if(header.target_os == TargetOS.DOS)
|
.AppendLine();
|
||||||
{
|
if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
sb.AppendLine("\tDOS application");
|
!header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
sb.AppendFormat("\tApplication requires DOS {0}.{1} to run", header.os_major, header.os_minor)
|
sb.AppendLine("\tApplication is full screen, unaware of Windows");
|
||||||
.AppendLine();
|
else if(!header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
!header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
sb.AppendLine("\tApplication is aware of Windows, but doesn't use it");
|
||||||
sb.AppendLine("\tApplication is full screen, unaware of Windows");
|
else if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
else if(!header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
sb.AppendLine("\tApplication uses Windows");
|
||||||
sb.AppendLine("\tApplication is aware of Windows, but doesn't use it");
|
sb.AppendFormat("\tReturn thunks are at: {0}", header.return_thunks_offset).AppendLine();
|
||||||
else if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
sb.AppendFormat("\tSegment reference thunks are at: {0}", header.segment_reference_thunks)
|
||||||
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
.AppendLine();
|
||||||
sb.AppendLine("\tApplication uses Windows");
|
break;
|
||||||
sb.AppendFormat("\tReturn thunks are at: {0}", header.return_thunks_offset).AppendLine();
|
default:
|
||||||
sb.AppendFormat("\tSegment reference thunks are at: {0}", header.segment_reference_thunks).AppendLine();
|
sb.AppendFormat("\tApplication for unknown OS {0}", (byte)header.target_os).AppendLine();
|
||||||
}
|
sb.AppendFormat("\tApplication requires OS {0}.{1} to run", header.os_major, header.os_minor)
|
||||||
else if(header.target_os == TargetOS.Borland)
|
.AppendLine();
|
||||||
{
|
sb.AppendFormat("\tReturn thunks are at: {0}", header.return_thunks_offset).AppendLine();
|
||||||
sb.AppendLine("\tBorland Operating System Services application");
|
sb.AppendFormat("\tSegment reference thunks are at: {0}", header.segment_reference_thunks)
|
||||||
sb.AppendFormat("\tApplication requires DOS {0}.{1} to run", header.os_major, header.os_minor)
|
.AppendLine();
|
||||||
.AppendLine();
|
break;
|
||||||
if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
|
||||||
!header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
|
||||||
sb.AppendLine("\tApplication is full screen, unaware of Windows");
|
|
||||||
else if(!header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
|
||||||
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
|
||||||
sb.AppendLine("\tApplication is aware of Windows, but doesn't use it");
|
|
||||||
else if(header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
|
||||||
header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
|
||||||
sb.AppendLine("\tApplication uses Windows");
|
|
||||||
sb.AppendFormat("\tReturn thunks are at: {0}", header.return_thunks_offset).AppendLine();
|
|
||||||
sb.AppendFormat("\tSegment reference thunks are at: {0}", header.segment_reference_thunks).AppendLine();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sb.AppendFormat("\tApplication for unknown OS {0}", (byte)header.target_os).AppendLine();
|
|
||||||
sb.AppendFormat("\tApplication requires OS {0}.{1} to run", header.os_major, header.os_minor)
|
|
||||||
.AppendLine();
|
|
||||||
sb.AppendFormat("\tReturn thunks are at: {0}", header.return_thunks_offset).AppendLine();
|
|
||||||
sb.AppendFormat("\tSegment reference thunks are at: {0}", header.segment_reference_thunks).AppendLine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(header.application_flags.HasFlag(ApplicationFlags.Errors)) sb.AppendLine("\tExecutable has errors");
|
if(header.application_flags.HasFlag(ApplicationFlags.Errors)) sb.AppendLine("\tExecutable has errors");
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@@ -73,11 +74,11 @@ namespace libexeinfo
|
|||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream BaseStream { get; }
|
public Stream BaseStream { get; }
|
||||||
public bool IsBigEndian => false;
|
public bool IsBigEndian => false;
|
||||||
public bool Recognized { get; private set; }
|
public bool Recognized { get; private set; }
|
||||||
public string Type { get; private set; }
|
public string Type { get; private set; }
|
||||||
public Architecture[] Architectures =>
|
public IEnumerable<Architecture> Architectures =>
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
Header.target_os == TargetOS.Win32 || Header.program_flags.HasFlag(ProgramFlags.i386)
|
Header.target_os == TargetOS.Win32 || Header.program_flags.HasFlag(ProgramFlags.i386)
|
||||||
@@ -86,6 +87,7 @@ namespace libexeinfo
|
|||||||
? Architecture.I286
|
? Architecture.I286
|
||||||
: Architecture.I86
|
: Architecture.I86
|
||||||
};
|
};
|
||||||
|
public OperatingSystem RequiredOperatingSystem { get; private set; }
|
||||||
|
|
||||||
void Initialize()
|
void Initialize()
|
||||||
{
|
{
|
||||||
@@ -109,6 +111,71 @@ namespace libexeinfo
|
|||||||
|
|
||||||
Recognized = true;
|
Recognized = true;
|
||||||
Type = "New Executable (NE)";
|
Type = "New Executable (NE)";
|
||||||
|
|
||||||
|
OperatingSystem reqOs = new OperatingSystem();
|
||||||
|
|
||||||
|
switch(Header.target_os)
|
||||||
|
{
|
||||||
|
case TargetOS.OS2:
|
||||||
|
reqOs.Name = "OS/2";
|
||||||
|
if(Header.os_major > 0)
|
||||||
|
{
|
||||||
|
reqOs.MajorVersion = Header.os_major;
|
||||||
|
reqOs.MinorVersion = Header.os_minor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reqOs.MajorVersion = 1;
|
||||||
|
reqOs.MinorVersion = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
|
!Header.application_flags.HasFlag(ApplicationFlags.GUICompatible) ||
|
||||||
|
!Header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
|
Header.application_flags.HasFlag(ApplicationFlags.GUICompatible)) reqOs.Subsystem = "Console";
|
||||||
|
else if(Header.application_flags.HasFlag(ApplicationFlags.FullScreen) &&
|
||||||
|
Header.application_flags.HasFlag(ApplicationFlags.GUICompatible))
|
||||||
|
reqOs.Subsystem = "Presentation Manager";
|
||||||
|
break;
|
||||||
|
case TargetOS.Windows:
|
||||||
|
case TargetOS.Win32:
|
||||||
|
case TargetOS.Unknown:
|
||||||
|
reqOs.Name = "Windows";
|
||||||
|
if(Header.os_major > 0)
|
||||||
|
{
|
||||||
|
reqOs.MajorVersion = Header.os_major;
|
||||||
|
reqOs.MinorVersion = Header.os_minor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
switch(Header.target_os)
|
||||||
|
{
|
||||||
|
case TargetOS.Windows:
|
||||||
|
reqOs.MajorVersion = 2;
|
||||||
|
reqOs.MinorVersion = 0;
|
||||||
|
break;
|
||||||
|
case TargetOS.Unknown:
|
||||||
|
reqOs.MajorVersion = 1;
|
||||||
|
reqOs.MinorVersion = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case TargetOS.DOS:
|
||||||
|
case TargetOS.Borland:
|
||||||
|
reqOs.Name = "DOS";
|
||||||
|
reqOs.MajorVersion = Header.os_major;
|
||||||
|
reqOs.MinorVersion = Header.os_minor;
|
||||||
|
if(Header.target_os == TargetOS.Borland) reqOs.Subsystem = "Borland Operating System Services";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
reqOs.Name = $"Unknown code {(byte)Header.target_os}";
|
||||||
|
reqOs.MajorVersion = Header.os_major;
|
||||||
|
reqOs.MinorVersion = Header.os_minor;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
RequiredOperatingSystem = reqOs;
|
||||||
|
|
||||||
if(Header.resource_entries <= 0) return;
|
if(Header.resource_entries <= 0) return;
|
||||||
|
|
||||||
Resources = GetResources(BaseStream, BaseExecutable.Header.new_offset, Header.resource_table_offset);
|
Resources = GetResources(BaseStream, BaseExecutable.Header.new_offset, Header.resource_table_offset);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@@ -72,11 +73,13 @@ namespace libexeinfo
|
|||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream BaseStream { get; }
|
public Stream BaseStream { get; }
|
||||||
public bool IsBigEndian => false;
|
public bool IsBigEndian => false;
|
||||||
public bool Recognized { get; private set; }
|
public bool Recognized { get; private set; }
|
||||||
public string Type { get; private set; }
|
public string Type { get; private set; }
|
||||||
public Architecture[] Architectures => new[] {COFF.MachineTypeToArchitecture(Header.coff.machine)};
|
public IEnumerable<Architecture> Architectures =>
|
||||||
|
new[] {COFF.MachineTypeToArchitecture(Header.coff.machine)};
|
||||||
|
public OperatingSystem RequiredOperatingSystem { get; private set; }
|
||||||
|
|
||||||
void Initialize()
|
void Initialize()
|
||||||
{
|
{
|
||||||
@@ -121,6 +124,62 @@ namespace libexeinfo
|
|||||||
Marshal.FreeHGlobal(hdrPtr);
|
Marshal.FreeHGlobal(hdrPtr);
|
||||||
WinHeader = ToPlus(hdr32);
|
WinHeader = ToPlus(hdr32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OperatingSystem reqOs = new OperatingSystem();
|
||||||
|
|
||||||
|
switch(WinHeader.subsystem)
|
||||||
|
{
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_UNKNOWN:
|
||||||
|
reqOs.Name = "Unknown";
|
||||||
|
break;
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_NATIVE:
|
||||||
|
reqOs.Name = "Windows NT";
|
||||||
|
reqOs.Subsystem = "Native";
|
||||||
|
break;
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_WINDOWS_GUI:
|
||||||
|
reqOs.Name = WinHeader.majorOperatingSystemVersion < 3 ? "Windows NT" : "Windows";
|
||||||
|
reqOs.Subsystem = "GUI";
|
||||||
|
break;
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_WINDOWS_CUI:
|
||||||
|
reqOs.Name = WinHeader.majorOperatingSystemVersion < 3 ? "Windows NT" : "Windows";
|
||||||
|
reqOs.Subsystem = "Console";
|
||||||
|
break;
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_OS2_CUI:
|
||||||
|
reqOs.Name = "Windows NT";
|
||||||
|
reqOs.Subsystem = "OS/2";
|
||||||
|
break;
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_POSIX_CUI:
|
||||||
|
reqOs.Name = "Windows NT";
|
||||||
|
reqOs.Subsystem = "POSIX";
|
||||||
|
break;
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_NATIVE_WINDOWS:
|
||||||
|
reqOs.Name = "Windows";
|
||||||
|
reqOs.Subsystem = "Native";
|
||||||
|
break;
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_WINDOWS_CE_GUI:
|
||||||
|
reqOs.Name = "Windows CE";
|
||||||
|
break;
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_EFI_APPLICATION:
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_EFI_ROM:
|
||||||
|
reqOs.Name = "EFI";
|
||||||
|
break;
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_XBOX:
|
||||||
|
reqOs.Name = "Xbox OS";
|
||||||
|
break;
|
||||||
|
case Subsystems.IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION:
|
||||||
|
reqOs.Name = "Windows NT";
|
||||||
|
reqOs.Subsystem = "Boot environment";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
reqOs.Name = $"Unknown code ${(ushort)WinHeader.subsystem}";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
reqOs.MajorVersion = WinHeader.majorOperatingSystemVersion;
|
||||||
|
reqOs.MinorVersion = WinHeader.minorOperatingSystemVersion;
|
||||||
|
RequiredOperatingSystem = reqOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
10
libexeinfo/Structs.cs
Normal file
10
libexeinfo/Structs.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace libexeinfo
|
||||||
|
{
|
||||||
|
public struct OperatingSystem
|
||||||
|
{
|
||||||
|
public string Name;
|
||||||
|
public int MajorVersion;
|
||||||
|
public int MinorVersion;
|
||||||
|
public string Subsystem;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -80,6 +80,7 @@
|
|||||||
<Compile Include="COFF\Info.cs" />
|
<Compile Include="COFF\Info.cs" />
|
||||||
<Compile Include="COFF\COFF.cs" />
|
<Compile Include="COFF\COFF.cs" />
|
||||||
<Compile Include="COFF\MachineTypes.cs" />
|
<Compile Include="COFF\MachineTypes.cs" />
|
||||||
|
<Compile Include="Structs.cs" />
|
||||||
<Compile Include="Swapping.cs" />
|
<Compile Include="Swapping.cs" />
|
||||||
<Compile Include="PE\Subsystems.cs" />
|
<Compile Include="PE\Subsystems.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user