From 35921e3caca588b381266f100204c8d1f4fca8fa Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 26 Oct 2020 23:30:35 -0700 Subject: [PATCH] Be smarter about SecuROM strings --- BurnOutSharp/ProtectionType/SecuROM.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/BurnOutSharp/ProtectionType/SecuROM.cs b/BurnOutSharp/ProtectionType/SecuROM.cs index e3a5fce5..84c0b076 100644 --- a/BurnOutSharp/ProtectionType/SecuROM.cs +++ b/BurnOutSharp/ProtectionType/SecuROM.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; namespace BurnOutSharp.ProtectionType { @@ -94,13 +95,13 @@ namespace BurnOutSharp.ProtectionType char version = (char)fileContent[index]; index += 2; - string subVersion = new string(new ArraySegment(fileContent, index, 2).Select(b => (char)b).ToArray()); + string subVersion = Encoding.ASCII.GetString(fileContent, index, 2); index += 3; - string subSubVersion = new string(new ArraySegment(fileContent, index, 2).Select(b => (char)b).ToArray()); + string subSubVersion = Encoding.ASCII.GetString(fileContent, index, 2); index += 3; - string subSubSubVersion = new string(new ArraySegment(fileContent, index, 4).Select(b => (char)b).ToArray()); + string subSubSubVersion = Encoding.ASCII.GetString(fileContent, index, 4); if (!char.IsNumber(version)) return "(very old, v3 or less)"; @@ -144,7 +145,7 @@ namespace BurnOutSharp.ProtectionType private static string GetV7Version(byte[] fileContent) { int index = 236; - byte[] bytes = new ArraySegment(fileContent, index, 4).ToArray(); + byte[] bytes = new ReadOnlySpan(fileContent, index, 4).ToArray(); //SecuROM 7 new and 8 if (bytes[3] == 0x5C) // if (bytes[0] == 0xED && bytes[3] == 0x5C { @@ -156,7 +157,7 @@ namespace BurnOutSharp.ProtectionType else { index = 122; - bytes = new ArraySegment(fileContent, index, 2).ToArray(); + bytes = new ReadOnlySpan(fileContent, index, 2).ToArray(); return $"7.{bytes[0] ^ 0x10:00}.{bytes[1] ^ 0x10:0000}"; //return "7.01-7.10" } }