From ff4214877ed59da0a2ed5f02cbe1247059488a62 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 9 Dec 2022 21:25:19 -0800 Subject: [PATCH] Convert Sysiphus to string finding --- BurnOutSharp/ProtectionType/Sysiphus.cs | 43 ++++++++----------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/BurnOutSharp/ProtectionType/Sysiphus.cs b/BurnOutSharp/ProtectionType/Sysiphus.cs index 383f62c6..635febc0 100644 --- a/BurnOutSharp/ProtectionType/Sysiphus.cs +++ b/BurnOutSharp/ProtectionType/Sysiphus.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using BurnOutSharp.Interfaces; -using BurnOutSharp.Matching; using BurnOutSharp.Wrappers; namespace BurnOutSharp.ProtectionType @@ -17,44 +16,28 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - // Get the .data/DATA section, if it exists - var dataSectionRaw = pex.GetFirstSectionData(".data") ?? pex.GetFirstSectionData("DATA"); - if (dataSectionRaw != null) + // Get the .data/DATA section strings, if they exist + List strs = pex.GetFirstSectionStrings(".data") ?? pex.GetFirstSectionStrings("DATA"); + if (strs != null) { - var matchers = new List - { - // V SUHPISYS - new ContentMatchSet(new byte?[] - { - 0x56, 0x20, 0x53, 0x55, 0x48, 0x50, 0x49, 0x53, - 0x59, 0x53 - }, GetVersion, "Sysiphus"), - }; - - string match = MatchUtil.GetFirstMatch(file, dataSectionRaw, matchers, includeDebug); - if (!string.IsNullOrWhiteSpace(match)) - return match; + string str = strs.FirstOrDefault(s => s.Contains("V SUHPISYS")); + if (str != null) + return $"Sysiphus {GetVersion(str)}"; } return null; } - public static string GetVersion(string file, byte[] fileContent, List positions) + public static string GetVersion(string matchedString) { - // The version is reversed - string version = new string( - new ArraySegment(fileContent, positions[0] - 4, 4) - .Reverse() - .Select(b => (char)b) - .ToArray()) - .Trim(); + // The string is reversed + matchedString = new string(matchedString.Reverse().ToArray()).Trim(); // Check for the DVD extra string - string extra = new string( - new ArraySegment(fileContent, positions[0] + "V SUHPISYS".Length, 3) - .Select(b => (char)b) - .ToArray()); - bool isDVD = extra == "DVD"; + bool isDVD = matchedString.StartsWith("DVD"); + + // Get the version string + string version = matchedString.Substring(isDVD ? "V SUHPISYSDVD".Length : "V SUHPISYS".Length, 4).Trim(); if (char.IsNumber(version[0]) && char.IsNumber(version[2])) return isDVD ? $"DVD {version}" : version;