From ab8d5ec4752a226ac9178f141044853899eaad59 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 27 Sep 2025 22:02:10 -0400 Subject: [PATCH] Split unknown AddD field, fix TODO --- .../Models/SecuROM/AddD.cs | 27 ++++++++++++------- .../Readers/SecuROMAddD.cs | 17 ++++++++++-- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/SabreTools.Serialization/Models/SecuROM/AddD.cs b/SabreTools.Serialization/Models/SecuROM/AddD.cs index 89477bf6..aafb1e7f 100644 --- a/SabreTools.Serialization/Models/SecuROM/AddD.cs +++ b/SabreTools.Serialization/Models/SecuROM/AddD.cs @@ -37,19 +37,26 @@ public string? Build { get; set; } /// - /// Unknown (0x14h), Variable number of bytes before entry table + /// Unknown + /// + /// 44 bytes + public byte[]? Unknown1 { get; set; } + + /// + /// Product ID? /// /// - /// 44 bytes in EXPUNGED, 3.17.00.0017, 3.17.00.0019, 4.47.00.0039 - /// 112 bytes in 4.84.00.0054, 4.84.69.0037, 4.84.76.7966, 4.84.76.7968, 4.85.07.0009 - /// 112 byte range contains a fixed-length string at 0x2C, possibly a product ID? - /// "801400-001" in 4.84.00.0054 - /// "594130-001" in 4.84.69.0037 - /// "554900-001" in 4.84.76.7966 - /// "554900-001" in 4.84.76.7968 - /// "548520-001" in 4.85.07.0009 + /// 10 bytes, only present in 4.84.00.0054, 4.84.69.0037, 4.84.76.7966, 4.84.76.7968, 4.85.07.0009 /// - public byte[]? Unknown { get; set; } + public string? ProductId { get; set; } + + /// + /// Unknown + /// + /// + /// 58 bytes, only present in 4.84.00.0054, 4.84.69.0037, 4.84.76.7966, 4.84.76.7968, 4.85.07.0009 + /// + public byte[]? Unknown2 { get; set; } /// /// Entry table diff --git a/SabreTools.Serialization/Readers/SecuROMAddD.cs b/SabreTools.Serialization/Readers/SecuROMAddD.cs index d95f1661..63c66c11 100644 --- a/SabreTools.Serialization/Readers/SecuROMAddD.cs +++ b/SabreTools.Serialization/Readers/SecuROMAddD.cs @@ -1,5 +1,6 @@ using System.IO; using System.Text; +using System.Text.RegularExpressions; using SabreTools.Data.Models.SecuROM; using SabreTools.IO.Extensions; using static SabreTools.Data.Models.SecuROM.Constants; @@ -48,9 +49,21 @@ namespace SabreTools.Serialization.Readers obj.Version = data.ReadNullTerminatedAnsiString(); byte[] buildBytes = data.ReadBytes(4); obj.Build = Encoding.ASCII.GetString(buildBytes); + obj.Unknown1 = data.ReadBytes(44); - // TODO: Figure out how to determine how many bytes are here consistently - obj.Unknown = data.ReadBytes(1); + // Peek at the next 10 bytes + long currentOffset = data.Position; + byte[] temp = data.ReadBytes(10); + string tempString = Encoding.ASCII.GetString(temp); + data.Seek(currentOffset, SeekOrigin.Begin); + + // If the temp string is a regex match for an ID + if (Regex.IsMatch(tempString, @"[0-9]{6}-[0-9]{3}")) + { + byte[] productIdBytes = data.ReadBytes(10); + obj.ProductId = Encoding.ASCII.GetString(productIdBytes); + obj.Unknown2 = data.ReadBytes(58); + } obj.Entries = new AddDEntry[obj.EntryCount]; for (int i = 0; i < obj.Entries.Length; i++)