From 53ce3aee74b12e1256e64ff55af1bca3a4f98877 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 20 Oct 2021 21:06:43 -0700 Subject: [PATCH] Refine Alpha-ROM checks; add notes --- BurnOutSharp/ProtectionType/AlphaROM.cs | 34 ++++++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/BurnOutSharp/ProtectionType/AlphaROM.cs b/BurnOutSharp/ProtectionType/AlphaROM.cs index 96db4a14..b696db6a 100644 --- a/BurnOutSharp/ProtectionType/AlphaROM.cs +++ b/BurnOutSharp/ProtectionType/AlphaROM.cs @@ -4,19 +4,39 @@ using BurnOutSharp.Matching; namespace BurnOutSharp.ProtectionType { + // TODO: Confirm this with more than one sample, if possible + // TODO: Alternative string possibilities: + // - \AlphaDiscLog.txt + // - \SETTEC + // - AlphaROM + // - SETTEC0000SETTEC1111 + // - SOFTWARE\SETTEC + // TODO: Are there version numbers? public class AlphaROM : IContentCheck { /// public string CheckContents(string file, byte[] fileContent, bool includeDebug, PortableExecutable pex, NewExecutable nex) { - // TODO: Obtain a sample to find where this string is in a typical executable - var contentMatchSets = new List + // Get the sections from the executable, if possible + var sections = pex?.SectionTable; + if (sections == null) + return null; + + // Get the .data section, if it exists + if (pex.DataSectionRaw != null) { - // SETTEC - new ContentMatchSet(new byte?[] { 0x53, 0x45, 0x54, 0x54, 0x45, 0x43 }, "Alpha-ROM"), - }; - - return MatchUtil.GetFirstMatch(file, fileContent, contentMatchSets, includeDebug); + var matchers = new List + { + // SETTEC + new ContentMatchSet(new byte?[] { 0x53, 0x45, 0x54, 0x54, 0x45, 0x43 }, "Alpha-ROM"), + }; + + string match = MatchUtil.GetFirstMatch(file, pex.DataSectionRaw, matchers, includeDebug); + if (!string.IsNullOrWhiteSpace(match)) + return match; + } + + return null; } } }