using System.IO;
namespace BurnOutSharp.Wrappers
{
public class LinearExecutable
{
#region Pass-Through Properties
#region MS-DOS Stub
#region Standard Fields
///
public byte[] Stub_Magic => _executable.Stub.Header.Magic;
///
public ushort Stub_LastPageBytes => _executable.Stub.Header.LastPageBytes;
///
public ushort Stub_Pages => _executable.Stub.Header.Pages;
///
public ushort Stub_RelocationItems => _executable.Stub.Header.RelocationItems;
///
public ushort Stub_HeaderParagraphSize => _executable.Stub.Header.HeaderParagraphSize;
///
public ushort Stub_MinimumExtraParagraphs => _executable.Stub.Header.MinimumExtraParagraphs;
///
public ushort Stub_MaximumExtraParagraphs => _executable.Stub.Header.MaximumExtraParagraphs;
///
public ushort Stub_InitialSSValue => _executable.Stub.Header.InitialSSValue;
///
public ushort Stub_Stub_InitialSPValue => _executable.Stub.Header.InitialSPValue;
///
public ushort Stub_Checksum => _executable.Stub.Header.Checksum;
///
public ushort Stub_InitialIPValue => _executable.Stub.Header.InitialIPValue;
///
public ushort Stub_InitialCSValue => _executable.Stub.Header.InitialCSValue;
///
public ushort Stub_RelocationTableAddr => _executable.Stub.Header.RelocationTableAddr;
///
public ushort Stub_OverlayNumber => _executable.Stub.Header.OverlayNumber;
#endregion
#region PE Extensions
///
public ushort[] Stub_Reserved1 => _executable.Stub.Header.Reserved1;
///
public ushort Stub_OEMIdentifier => _executable.Stub.Header.OEMIdentifier;
///
public ushort Stub_OEMInformation => _executable.Stub.Header.OEMInformation;
///
public ushort[] Stub_Reserved2 => _executable.Stub.Header.Reserved2;
///
public uint Stub_NewExeHeaderAddr => _executable.Stub.Header.NewExeHeaderAddr;
#endregion
#endregion
// TODO: Determine what properties can be passed through
#endregion
#region Extension Properties
// TODO: Determine what extension properties are needed
#endregion
#region Instance Variables
///
/// Internal representation of the executable
///
private Models.LinearExecutable.Executable _executable;
#endregion
///
/// Private constructor
///
private LinearExecutable() { }
///
/// Create an LE/LX executable from a byte array and offset
///
/// Byte array representing the executable
/// Offset within the array to parse
/// An LE/LX executable wrapper on success, null on failure
public static LinearExecutable Create(byte[] data, int offset)
{
var executable = Builder.LinearExecutable.ParseExecutable(data, offset);
if (executable == null)
return null;
var wrapper = new LinearExecutable { _executable = executable };
return wrapper;
}
///
/// Create an LE/LX executable from a Stream
///
/// Stream representing the executable
/// An LE/LX executable wrapper on success, null on failure
public static LinearExecutable Create(Stream data)
{
var executable = Builder.LinearExecutable.ParseExecutable(data);
if (executable == null)
return null;
var wrapper = new LinearExecutable { _executable = executable };
return wrapper;
}
}
}