From 9562a0eaf70569d37dcc273a58726a06e7c3ea58 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 9 Dec 2022 12:33:12 -0800 Subject: [PATCH] Convert XCP to string finding --- BurnOutSharp/ProtectionType/XCP.cs | 37 +++++++++--------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/BurnOutSharp/ProtectionType/XCP.cs b/BurnOutSharp/ProtectionType/XCP.cs index 862e2d3a..e866930a 100644 --- a/BurnOutSharp/ProtectionType/XCP.cs +++ b/BurnOutSharp/ProtectionType/XCP.cs @@ -5,7 +5,6 @@ using System.IO; using System.Linq; using BurnOutSharp.FileType; using BurnOutSharp.Interfaces; -using BurnOutSharp.Matching; using BurnOutSharp.Wrappers; namespace BurnOutSharp.ProtectionType @@ -21,35 +20,21 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - // Get the .rdata section, if it exists - if (pex.ContainsSection(".rdata")) + // Get the .rdata section strings, if they exist + List strs = pex.GetFirstSectionStrings(".rdata"); + if (strs != null) { - var matchers = new List - { - // XCP.DAT - new ContentMatchSet(new byte?[] { 0x58, 0x43, 0x50, 0x2E, 0x44, 0x41, 0x54 }, "XCP"), + if (strs.Any(s => s.Contains("XCP.DAT"))) + return "XCP"; - // xcpdrive - new ContentMatchSet(new byte?[] { 0x78, 0x63, 0x70, 0x64, 0x72, 0x69, 0x76, 0x65 }, "XCP"), + if (strs.Any(s => s.Contains("xcpdrive"))) + return "XCP"; - // XCPPlugins.dll - new ContentMatchSet(new byte?[] - { - 0x58, 0x43, 0x50, 0x50, 0x6C, 0x75, 0x67, 0x69, - 0x6E, 0x73, 0x2E, 0x64, 0x6C, 0x6C - }, "XCP"), + if (strs.Any(s => s.Contains("XCPPlugins.dll"))) + return "XCP"; - // XCPPhoenix.dll - new ContentMatchSet(new byte?[] - { - 0x58, 0x43, 0x50, 0x50, 0x68, 0x6F, 0x65, 0x6E, - 0x69, 0x78, 0x2E, 0x64, 0x6C, 0x6C - }, "XCP"), - }; - - string match = MatchUtil.GetFirstMatch(file, pex.GetFirstSectionData(".rdata"), matchers, includeDebug); - if (!string.IsNullOrWhiteSpace(match)) - return match; + if (strs.Any(s => s.Contains("XCPPhoenix.dll"))) + return "XCP"; } return null;