Be smarter about SecuROM strings

This commit is contained in:
Matt Nadareski
2020-10-26 23:30:35 -07:00
parent a42040d644
commit 35921e3cac

View File

@@ -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<byte>(fileContent, index, 2).Select(b => (char)b).ToArray());
string subVersion = Encoding.ASCII.GetString(fileContent, index, 2);
index += 3;
string subSubVersion = new string(new ArraySegment<byte>(fileContent, index, 2).Select(b => (char)b).ToArray());
string subSubVersion = Encoding.ASCII.GetString(fileContent, index, 2);
index += 3;
string subSubSubVersion = new string(new ArraySegment<byte>(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<byte>(fileContent, index, 4).ToArray();
byte[] bytes = new ReadOnlySpan<byte>(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<byte>(fileContent, index, 2).ToArray();
bytes = new ReadOnlySpan<byte>(fileContent, index, 2).ToArray();
return $"7.{bytes[0] ^ 0x10:00}.{bytes[1] ^ 0x10:0000}"; //return "7.01-7.10"
}
}