mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-08 18:06:34 +00:00
Add and use NE constants
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BurnOutSharp.Models.NewExecutable;
|
||||
using BurnOutSharp.Utilities;
|
||||
using static BurnOutSharp.Models.NewExecutable.Constants;
|
||||
|
||||
namespace BurnOutSharp.Builders
|
||||
{
|
||||
@@ -246,12 +248,9 @@ namespace BurnOutSharp.Builders
|
||||
// TODO: Use marshalling here instead of building
|
||||
var header = new ExecutableHeader();
|
||||
|
||||
header.Magic = new byte[2];
|
||||
for (int i = 0; i < header.Magic.Length; i++)
|
||||
{
|
||||
header.Magic[i] = data.ReadByteValue();
|
||||
}
|
||||
if (header.Magic[0] != 'N' || header.Magic[1] != 'E')
|
||||
byte[] magic = data.ReadBytes(2);
|
||||
header.Magic = Encoding.ASCII.GetString(magic);
|
||||
if (header.Magic != SignatureString)
|
||||
return null;
|
||||
|
||||
header.LinkerVersion = data.ReadByteValue();
|
||||
|
||||
11
BurnOutSharp.Models/NewExecutable/Constants.cs
Normal file
11
BurnOutSharp.Models/NewExecutable/Constants.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace BurnOutSharp.Models.NewExecutable
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public static readonly byte[] SignatureBytes = new byte[] { 0x4e, 0x45 };
|
||||
|
||||
public const string SignatureString = "NE";
|
||||
|
||||
public const ushort SignatureUInt16 = 0x454e;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace BurnOutSharp.Models.NewExecutable
|
||||
/// "E" is high-order byte.
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public byte[] Magic;
|
||||
public string Magic;
|
||||
|
||||
/// <summary>
|
||||
/// Version number of the linker.
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace BurnOutSharp.Wrappers
|
||||
#region Header
|
||||
|
||||
/// <inheritdoc cref="Models.NewExecutable.ExecutableHeader.Magic"/>
|
||||
public byte[] Magic => _executable.Header.Magic;
|
||||
public string Magic => _executable.Header.Magic;
|
||||
|
||||
/// <inheritdoc cref="Models.NewExecutable.ExecutableHeader.LinkerVersion"/>
|
||||
public byte LinkerVersion => _executable.Header.LinkerVersion;
|
||||
@@ -344,7 +344,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($" Linker version: {LinkerVersion}");
|
||||
Console.WriteLine($" Linker revision: {LinkerRevision}");
|
||||
Console.WriteLine($" Entry table offset: {EntryTableOffset}");
|
||||
|
||||
Reference in New Issue
Block a user