Skip to content

Commit ddf8c39

Browse files
committed
Use AddD reader instead of manual
1 parent d234549 commit ddf8c39

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

BinaryObjectScanner/Protection/SecuROM.cs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Text;
44
using BinaryObjectScanner.Interfaces;
5+
using SabreTools.Data.Models.PKZIP;
56
using SabreTools.IO;
67
using SabreTools.IO.Extensions;
78
using SabreTools.IO.Matching;
@@ -277,23 +278,18 @@ public List<string> CheckDirectoryPath(string path, List<string>? files)
277278
if (!found)
278279
return null;
279280

280-
// Read the version starting 4 bytes after the signature
281-
index += 8;
282-
char major = (char)overlayData[index];
283-
index += 2;
284-
285-
string minor = Encoding.ASCII.GetString(overlayData, index, 2);
286-
index += 3;
287-
288-
string patch = Encoding.ASCII.GetString(overlayData, index, 2);
289-
index += 3;
290-
291-
string revision = Encoding.ASCII.GetString(overlayData, index, 4);
281+
// Deserialize the AddD header
282+
var reader = new SabreTools.Serialization.Readers.SecuROMAddD();
283+
var addD = reader.Deserialize(overlayData, index);
284+
if (addD == null)
285+
return null;
292286

293-
if (!char.IsNumber(major))
287+
// Format the version
288+
string version = $"{addD.Version}.{addD.Build}";
289+
if (!char.IsNumber(version[0]))
294290
return "(very old, v3 or less)";
295291

296-
return $"{major}.{minor}.{patch}.{revision}";
292+
return version;
297293
}
298294

299295
/// <summary>

0 commit comments

Comments
 (0)