Add and use byte array extension methods

This commit is contained in:
Matt Nadareski
2021-09-10 22:35:32 -07:00
parent 32390149f3
commit 73dd669c20
29 changed files with 312 additions and 202 deletions

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using BurnOutSharp.ExecutableType.Microsoft;
using BurnOutSharp.Matching;
using BurnOutSharp.Tools;
namespace BurnOutSharp.ProtectionType
{
@@ -74,21 +75,17 @@ namespace BurnOutSharp.ProtectionType
public static string GetVersion(string file, byte[] fileContent, List<int> positions)
{
int index = positions[0] + 20; // Begin reading after "BoG_ *90.0&!! Yy>" for old SafeDisc
int version = BitConverter.ToInt32(fileContent, index);
index += 4;
int subVersion = BitConverter.ToInt32(fileContent, index);
index += 4;
int subsubVersion = BitConverter.ToInt32(fileContent, index);
int version = fileContent.ReadInt32(ref index);
int subVersion = fileContent.ReadInt32(ref index);
int subsubVersion = fileContent.ReadInt32(ref index);
if (version != 0)
return $"{version}.{subVersion:00}.{subsubVersion:000}";
index = positions[0] + 18 + 14; // Begin reading after "BoG_ *90.0&!! Yy>" for newer SafeDisc
version = BitConverter.ToInt32(fileContent, index);
index += 4;
subVersion = BitConverter.ToInt32(fileContent, index);
index += 4;
subsubVersion = BitConverter.ToInt32(fileContent, index);
version = fileContent.ReadInt32(ref index);
subVersion = fileContent.ReadInt32(ref index);
subsubVersion = fileContent.ReadInt32(ref index);
if (version == 0)
return string.Empty;

View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Text;
using BurnOutSharp.ExecutableType.Microsoft;
using BurnOutSharp.Matching;
using BurnOutSharp.Tools;
namespace BurnOutSharp.ProtectionType
{
@@ -163,21 +164,17 @@ namespace BurnOutSharp.ProtectionType
public static string GetVersion(string file, byte[] fileContent, List<int> positions)
{
int index = positions[0] + 20; // Begin reading after "BoG_ *90.0&!! Yy>" for old SafeDisc
int version = BitConverter.ToInt32(fileContent, index);
index += 4;
int subVersion = BitConverter.ToInt32(fileContent, index);
index += 4;
int subsubVersion = BitConverter.ToInt32(fileContent, index);
int version = fileContent.ReadInt32(ref index);
int subVersion = fileContent.ReadInt32(ref index);
int subsubVersion = fileContent.ReadInt32(ref index);
if (version != 0)
return $"{version}.{subVersion:00}.{subsubVersion:000}";
index = positions[0] + 18 + 14; // Begin reading after "BoG_ *90.0&!! Yy>" for newer SafeDisc
version = BitConverter.ToInt32(fileContent, index);
index += 4;
subVersion = BitConverter.ToInt32(fileContent, index);
index += 4;
subsubVersion = BitConverter.ToInt32(fileContent, index);
version = fileContent.ReadInt32(ref index);
subVersion = fileContent.ReadInt32(ref index);
subsubVersion = fileContent.ReadInt32(ref index);
if (version == 0)
return string.Empty;