mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-04-24 15:13:23 +00:00
Add and use MZ constants
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using BurnOutSharp.Models.MSDOS;
|
||||
using BurnOutSharp.Utilities;
|
||||
using static BurnOutSharp.Models.MSDOS.Constants;
|
||||
|
||||
namespace BurnOutSharp.Builders
|
||||
{
|
||||
@@ -100,12 +102,9 @@ namespace BurnOutSharp.Builders
|
||||
|
||||
#region Standard Fields
|
||||
|
||||
header.Magic = new byte[2];
|
||||
for (int i = 0; i < header.Magic.Length; i++)
|
||||
{
|
||||
header.Magic[i] = data.ReadByteValue();
|
||||
}
|
||||
if (header.Magic[0] != 'M' || header.Magic[1] != 'Z')
|
||||
byte[] magic = data.ReadBytes(2);
|
||||
header.Magic = Encoding.ASCII.GetString(magic);
|
||||
if (header.Magic != SignatureString)
|
||||
return null;
|
||||
|
||||
header.LastPageBytes = data.ReadUInt16();
|
||||
|
||||
11
BurnOutSharp.Models/MSDOS/Constants.cs
Normal file
11
BurnOutSharp.Models/MSDOS/Constants.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace BurnOutSharp.Models.MSDOS
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public static readonly byte[] SignatureBytes = new byte[] { 0x4d, 0x5a };
|
||||
|
||||
public const string SignatureString = "MZ";
|
||||
|
||||
public const ushort SignatureUInt16 = 0x5a4d;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace BurnOutSharp.Models.MSDOS
|
||||
/// 0x5A4D (ASCII for 'M' and 'Z')
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public byte[] Magic;
|
||||
public string Magic;
|
||||
|
||||
/// <summary>
|
||||
/// Number of bytes in the last page.
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace BurnOutSharp.Wrappers
|
||||
#region Standard Fields
|
||||
|
||||
/// <inheritdoc cref="Models.MSDOS.ExecutableHeader.Magic"/>
|
||||
public byte[] Stub_Magic => _executable.Stub.Header.Magic;
|
||||
public string Stub_Magic => _executable.Stub.Header.Magic;
|
||||
|
||||
/// <inheritdoc cref="Models.MSDOS.ExecutableHeader.LastPageBytes"/>
|
||||
public ushort Stub_LastPageBytes => _executable.Stub.Header.LastPageBytes;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace BurnOutSharp.Wrappers
|
||||
#region Header
|
||||
|
||||
/// <inheritdoc cref="Models.MSDOS.ExecutableHeader.Magic"/>
|
||||
public byte[] Magic => _executable.Header.Magic;
|
||||
public string Magic => _executable.Header.Magic;
|
||||
|
||||
/// <inheritdoc cref="Models.MSDOS.ExecutableHeader.LastPageBytes"/>
|
||||
public ushort LastPageBytes => _executable.Header.LastPageBytes;
|
||||
@@ -164,7 +164,7 @@ namespace BurnOutSharp.Wrappers
|
||||
{
|
||||
Console.WriteLine(" Header Information:");
|
||||
Console.WriteLine(" -------------------------");
|
||||
Console.WriteLine($" Magic number: {BitConverter.ToString(Magic).Replace("-", string.Empty)}");
|
||||
Console.WriteLine($" Magic number: {Magic}");
|
||||
Console.WriteLine($" Last page bytes: {LastPageBytes}");
|
||||
Console.WriteLine($" Pages: {Pages}");
|
||||
Console.WriteLine($" Relocation items: {RelocationItems}");
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BurnOutSharp.Wrappers
|
||||
#region Standard Fields
|
||||
|
||||
/// <inheritdoc cref="Models.MSDOS.ExecutableHeader.Magic"/>
|
||||
public byte[] Stub_Magic => _executable.Stub.Header.Magic;
|
||||
public string Stub_Magic => _executable.Stub.Header.Magic;
|
||||
|
||||
/// <inheritdoc cref="Models.MSDOS.ExecutableHeader.LastPageBytes"/>
|
||||
public ushort Stub_LastPageBytes => _executable.Stub.Header.LastPageBytes;
|
||||
@@ -305,7 +305,7 @@ namespace BurnOutSharp.Wrappers
|
||||
{
|
||||
Console.WriteLine(" MS-DOS Stub Header Information:");
|
||||
Console.WriteLine(" -------------------------");
|
||||
Console.WriteLine($" Magic number: {BitConverter.ToString(Stub_Magic).Replace("-", string.Empty)}");
|
||||
Console.WriteLine($" Magic number: {Stub_Magic}");
|
||||
Console.WriteLine($" Last page bytes: {Stub_LastPageBytes}");
|
||||
Console.WriteLine($" Pages: {Stub_Pages}");
|
||||
Console.WriteLine($" Relocation items: {Stub_RelocationItems}");
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace BurnOutSharp.Wrappers
|
||||
#region Standard Fields
|
||||
|
||||
/// <inheritdoc cref="Models.MSDOS.ExecutableHeader.Magic"/>
|
||||
public byte[] Stub_Magic => _executable.Stub.Header.Magic;
|
||||
public string Stub_Magic => _executable.Stub.Header.Magic;
|
||||
|
||||
/// <inheritdoc cref="Models.MSDOS.ExecutableHeader.LastPageBytes"/>
|
||||
public ushort Stub_LastPageBytes => _executable.Stub.Header.LastPageBytes;
|
||||
@@ -1059,7 +1059,7 @@ namespace BurnOutSharp.Wrappers
|
||||
{
|
||||
Console.WriteLine(" MS-DOS Stub Header Information:");
|
||||
Console.WriteLine(" -------------------------");
|
||||
Console.WriteLine($" Magic number: {BitConverter.ToString(Stub_Magic).Replace("-", string.Empty)}");
|
||||
Console.WriteLine($" Magic number: {Stub_Magic}");
|
||||
Console.WriteLine($" Last page bytes: {Stub_LastPageBytes}");
|
||||
Console.WriteLine($" Pages: {Stub_Pages}");
|
||||
Console.WriteLine($" Relocation items: {Stub_RelocationItems}");
|
||||
|
||||
Reference in New Issue
Block a user