From 7cdf6a8c7993c15dffba8bb814ec4ac79d4e52af Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 10 Sep 2021 22:02:57 -0700 Subject: [PATCH] Identify and use .rsrc item for MediaMax --- BurnOutSharp/ProtectionType/MediaMaxCD3.cs | 25 +++++----------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/BurnOutSharp/ProtectionType/MediaMaxCD3.cs b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs index b4026db6..dd22af88 100644 --- a/BurnOutSharp/ProtectionType/MediaMaxCD3.cs +++ b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using BurnOutSharp.ExecutableType.Microsoft; using BurnOutSharp.Matching; +using BurnOutSharp.Tools; namespace BurnOutSharp.ProtectionType { @@ -17,6 +18,10 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; + var resource = Utilities.FindResourceInSection(pex.ResourceSection, dataContains: "Cd3Ctl"); + if (resource != null) + return $"MediaMax CD-3"; + // Get the .rdata section, if it exists var rdataSection = sections.FirstOrDefault(s => Encoding.ASCII.GetString(s.Name).StartsWith(".rdata")); if (rdataSection != null) @@ -40,26 +45,6 @@ namespace BurnOutSharp.ProtectionType return match; } - // TODO: Find this inside of the .rsrc section using the executable header - // Get the .rsrc section, if it exists - var rsrcSection = sections.FirstOrDefault(s => Encoding.ASCII.GetString(s.Name).StartsWith(".rsrc")); - if (rsrcSection != null) - { - int sectionAddr = (int)rsrcSection.PointerToRawData; - int sectionEnd = sectionAddr + (int)rsrcSection.VirtualSize; - var matchers = new List - { - // Cd3Ctl - new ContentMatchSet( - new ContentMatch(new byte?[] { 0x43, 0x64, 0x33, 0x43, 0x74, 0x6C }, start: sectionAddr, end: sectionEnd), - "MediaMax CD-3"), - }; - - string match = MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug); - if (!string.IsNullOrWhiteSpace(match)) - return match; - } - // Get the .data section, if it exists var dataSection = sections.FirstOrDefault(s => Encoding.ASCII.GetString(s.Name).StartsWith(".data")); if (dataSection != null)