Add and use IS-CAB constants

This commit is contained in:
Matt Nadareski
2022-12-28 10:21:19 -08:00
parent 9354f0f092
commit 14fb3f5758
12 changed files with 26 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ using System.IO;
using System.Text;
using BurnOutSharp.Models.InstallShieldCabinet;
using BurnOutSharp.Utilities;
using static BurnOutSharp.Models.InstallShieldCabinet.Constants;
namespace BurnOutSharp.Builders
{
@@ -328,8 +329,9 @@ namespace BurnOutSharp.Builders
{
CommonHeader commonHeader = new CommonHeader();
commonHeader.Signature = data.ReadUInt32();
if (commonHeader.Signature != 0x28635349)
byte[] signature = data.ReadBytes(4);
commonHeader.Signature = Encoding.ASCII.GetString(signature);
if (commonHeader.Signature != SignatureString)
return null;
commonHeader.Version = data.ReadUInt32();
@@ -360,15 +362,13 @@ namespace BurnOutSharp.Builders
cabDescriptor.FileTableOffset2 = data.ReadUInt32();
cabDescriptor.Reserved3 = data.ReadBytes(0x0E);
// TODO: Determine how the value "71" was chosen here
cabDescriptor.FileGroupOffsets = new uint[71];
cabDescriptor.FileGroupOffsets = new uint[MAX_FILE_GROUP_COUNT];
for (int i = 0; i < cabDescriptor.FileGroupOffsets.Length; i++)
{
cabDescriptor.FileGroupOffsets[i] = data.ReadUInt32();
}
// TODO: Determine how the value "71" was chosen here
cabDescriptor.ComponentOffsets = new uint[71];
cabDescriptor.ComponentOffsets = new uint[MAX_COMPONENT_COUNT];
for (int i = 0; i < cabDescriptor.ComponentOffsets.Length; i++)
{
cabDescriptor.ComponentOffsets[i] = data.ReadUInt32();

View File

@@ -2,10 +2,10 @@ namespace BurnOutSharp.Models.BFPK
{
public static class Constants
{
public const uint SignatureUInt32 = 0x4b504642;
public static readonly byte[] SignatureBytes = new byte[] { 0x42, 0x46, 0x50, 0x4b };
public const string SignatureString = "BFPK";
public const uint SignatureUInt32 = 0x4b504642;
}
}

View File

@@ -3,7 +3,7 @@ namespace BurnOutSharp.Models.InstallShieldCabinet
/// <see href="https://github.com/twogood/unshield/blob/main/lib/cabfile.h"/>
public sealed class CommonHeader
{
public uint Signature;
public string Signature;
public uint Version;

View File

@@ -0,0 +1,17 @@
namespace BurnOutSharp.Models.InstallShieldCabinet
{
public static class Constants
{
public static readonly byte[] SignatureBytes = new byte[] { 0x49, 0x53, 0x63, 0x28 };
public const string SignatureString = "ISc(";
public const uint SignatureUInt32 = 0x28635349;
// TODO: Determine how the value "71" was chosen here
public const int MAX_FILE_GROUP_COUNT = 71;
// TODO: Determine how the value "71" was chosen here
public const int MAX_COMPONENT_COUNT = 71;
}
}