diff --git a/BurnOutSharp/PackerType/Armadillo.cs b/BurnOutSharp/PackerType/Armadillo.cs
index 695b89c1..26cfd701 100644
--- a/BurnOutSharp/PackerType/Armadillo.cs
+++ b/BurnOutSharp/PackerType/Armadillo.cs
@@ -1,21 +1,22 @@
-namespace BurnOutSharp.PackerType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.PackerType
{
public class Armadillo : IContentCheck
{
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // ".nicode" + (char)0x00
- byte?[] check = new byte?[] { 0x2E, 0x6E, 0x69, 0x63, 0x6F, 0x64, 0x65, 0x00 };
- if (fileContent.FirstPosition(check, out int position))
- return $"Armadillo" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // .nicode + (char)0x00
+ [new byte?[] { 0x2E, 0x6E, 0x69, 0x63, 0x6F, 0x64, 0x65, 0x00 }] = "Armadillo",
- // "ARMDEBUG"
- check = new byte?[] { 0x41, 0x52, 0x4D, 0x44, 0x45, 0x42, 0x55, 0x47 };
- if (fileContent.FirstPosition(check, out position))
- return $"Armadillo" + (includePosition ? $" (Index {position})" : string.Empty);
+ // ARMDEBUG
+ [new byte?[] { 0x41, 0x52, 0x4D, 0x44, 0x45, 0x42, 0x55, 0x47 }] = "Armadillo",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/PackerType/EXEStealth.cs b/BurnOutSharp/PackerType/EXEStealth.cs
index 726ffe8e..b40c8c96 100644
--- a/BurnOutSharp/PackerType/EXEStealth.cs
+++ b/BurnOutSharp/PackerType/EXEStealth.cs
@@ -1,16 +1,19 @@
-namespace BurnOutSharp.PackerType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.PackerType
{
public class EXEStealth : IContentCheck
{
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "??[[__[[_" + (char)0x00 + "{{" + (char)0x0 + (char)0x00 + "{{" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x0 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "?;??;??"
- byte?[] check = new byte?[] { 0x3F, 0x3F, 0x5B, 0x5B, 0x5F, 0x5F, 0x5B, 0x5B, 0x5F, 0x00, 0x7B, 0x7B, 0x00, 0x00, 0x7B, 0x7B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x3B, 0x3F, 0x3F, 0x3B, 0x3F, 0x3F };
- if (fileContent.FirstPosition(check, out int position))
- return $"EXE Stealth" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // ??[[__[[_ + (char)0x00 + {{ + (char)0x0 + (char)0x00 + {{ + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x0 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + ?;??;??
+ [new byte?[] { 0x3F, 0x3F, 0x5B, 0x5B, 0x5F, 0x5F, 0x5B, 0x5B, 0x5F, 0x00, 0x7B, 0x7B, 0x00, 0x00, 0x7B, 0x7B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x3B, 0x3F, 0x3F, 0x3B, 0x3F, 0x3F }] = "EXE Stealth",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/PackerType/InnoSetup.cs b/BurnOutSharp/PackerType/InnoSetup.cs
index 1c30d065..c8a76976 100644
--- a/BurnOutSharp/PackerType/InnoSetup.cs
+++ b/BurnOutSharp/PackerType/InnoSetup.cs
@@ -14,7 +14,7 @@ namespace BurnOutSharp.PackerType
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "Inno"
+ // Inno
byte?[] check = new byte?[] { 0x49, 0x6E, 0x6E, 0x6F };
if (fileContent.FirstPosition(check, out int position) && position == 0x30)
return $"Inno Setup {GetVersion(fileContent)}" + (includePosition ? $" (Index {position})" : string.Empty);
diff --git a/BurnOutSharp/PackerType/NSIS.cs b/BurnOutSharp/PackerType/NSIS.cs
index 0cf969f1..aac78d72 100644
--- a/BurnOutSharp/PackerType/NSIS.cs
+++ b/BurnOutSharp/PackerType/NSIS.cs
@@ -20,9 +20,7 @@ namespace BurnOutSharp.PackerType
// NullsoftInst
check = new byte?[] { 0x4e, 0x75, 0x6c, 0x6c, 0x73, 0x6f, 0x66, 0x74, 0x49, 0x6e, 0x73, 0x74 };
if (fileContent.FirstPosition(check, out position))
- {
return $"NSIS" + (includePosition ? $" (Index {position})" : string.Empty);
- }
return null;
}
diff --git a/BurnOutSharp/PackerType/SetupFactory.cs b/BurnOutSharp/PackerType/SetupFactory.cs
index 0412643c..8347ffa7 100644
--- a/BurnOutSharp/PackerType/SetupFactory.cs
+++ b/BurnOutSharp/PackerType/SetupFactory.cs
@@ -1,9 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
+using System.Collections.Generic;
using System.IO;
-using System.Text;
-using System.Xml;
namespace BurnOutSharp.PackerType
{
diff --git a/BurnOutSharp/PackerType/WinRARSFX.cs b/BurnOutSharp/PackerType/WinRARSFX.cs
index 0f37612c..ef2dad3e 100644
--- a/BurnOutSharp/PackerType/WinRARSFX.cs
+++ b/BurnOutSharp/PackerType/WinRARSFX.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Text;
using SharpCompress.Archives;
using SharpCompress.Archives.Rar;
@@ -15,12 +14,13 @@ namespace BurnOutSharp.PackerType
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "Software\WinRAR SFX"
- byte?[] check = new byte?[] { 0x53, 0x6F, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x5C, 0x57, 0x69, 0x6E, 0x52, 0x41, 0x52, 0x20, 0x53, 0x46, 0x58 };
- if (fileContent.FirstPosition(check, out int position))
- return "WinRAR SFX" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // Software\WinRAR SFX
+ [new byte?[] { 0x53, 0x6F, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x5C, 0x57, 0x69, 0x6E, 0x52, 0x41, 0x52, 0x20, 0x53, 0x46, 0x58 }] = "WinRAR SFX",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
public Dictionary> Scan(Scanner scanner, string file)
diff --git a/BurnOutSharp/PackerType/WinZipSFX.cs b/BurnOutSharp/PackerType/WinZipSFX.cs
index a2aedefc..3b79b3e9 100644
--- a/BurnOutSharp/PackerType/WinZipSFX.cs
+++ b/BurnOutSharp/PackerType/WinZipSFX.cs
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Text;
-using System.Xml;
using SharpCompress.Archives;
using SharpCompress.Archives.Zip;
diff --git a/BurnOutSharp/PackerType/WiseInstaller.cs b/BurnOutSharp/PackerType/WiseInstaller.cs
index 6d202efb..6d5d95ff 100644
--- a/BurnOutSharp/PackerType/WiseInstaller.cs
+++ b/BurnOutSharp/PackerType/WiseInstaller.cs
@@ -13,12 +13,13 @@ namespace BurnOutSharp.PackerType
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // WiseMain
- byte?[] check = new byte?[] { 0x57, 0x69, 0x73, 0x65, 0x4D, 0x61, 0x69, 0x6E };
- if (fileContent.FirstPosition(check, out int position))
- return "Wise Installation Wizard Module" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // WiseMain
+ [new byte?[] { 0x57, 0x69, 0x73, 0x65, 0x4D, 0x61, 0x69, 0x6E }] = "Wise Installation Wizard Module",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
///
diff --git a/BurnOutSharp/PackerType/dotFuscator.cs b/BurnOutSharp/PackerType/dotFuscator.cs
index 466a72ed..910ffd30 100644
--- a/BurnOutSharp/PackerType/dotFuscator.cs
+++ b/BurnOutSharp/PackerType/dotFuscator.cs
@@ -1,16 +1,19 @@
-namespace BurnOutSharp.PackerType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.PackerType
{
public class dotFuscator : IContentCheck
{
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "DotfuscatorAttribute"
- byte?[] check = new byte?[] { 0x44, 0x6F, 0x74, 0x66, 0x75, 0x73, 0x63, 0x61, 0x74, 0x6F, 0x72, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65 };
- if (fileContent.FirstPosition(check, out int position))
- return "dotFuscator" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // DotfuscatorAttribute
+ [new byte?[] { 0x44, 0x6F, 0x74, 0x66, 0x75, 0x73, 0x63, 0x61, 0x74, 0x6F, 0x72, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65 }] = "dotFuscator",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/AACS.cs b/BurnOutSharp/ProtectionType/AACS.cs
index 87aa9916..421107a3 100644
--- a/BurnOutSharp/ProtectionType/AACS.cs
+++ b/BurnOutSharp/ProtectionType/AACS.cs
@@ -55,6 +55,7 @@ namespace BurnOutSharp.ProtectionType
{
if (!File.Exists(path))
return null;
+
try
{
using (var fs = File.OpenRead(path))
diff --git a/BurnOutSharp/ProtectionType/ActiveMARK.cs b/BurnOutSharp/ProtectionType/ActiveMARK.cs
index f1a2d307..b977a622 100644
--- a/BurnOutSharp/ProtectionType/ActiveMARK.cs
+++ b/BurnOutSharp/ProtectionType/ActiveMARK.cs
@@ -1,21 +1,22 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class ActiveMARK : IContentCheck
{
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "TMSAMVOF"
- byte?[] check = new byte?[] { 0x54, 0x4D, 0x53, 0x41, 0x4D, 0x56, 0x4F, 0x46 };
- if (fileContent.FirstPosition(check, out int position))
- return "ActiveMARK" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // TMSAMVOF
+ [new byte?[] { 0x54, 0x4D, 0x53, 0x41, 0x4D, 0x56, 0x4F, 0x46 }] = "ActiveMARK",
- // " " + (char)0xC2 + (char)0x16 + (char)0x00 + (char)0xA8 + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0xB8 + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0x86 + (char)0xC8 + (char)0x16 + (char)0x0 + (char)0x9A + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0x10 + (char)0xC2 + (char)0x16 + (char)0x00
- check = new byte?[] { 0x20, 0xC2, 0x16, 0x00, 0xA8, 0xC1, 0x16, 0x00, 0xB8, 0xC1, 0x16, 0x00, 0x86, 0xC8, 0x16, 0x0, 0x9A, 0xC1, 0x16, 0x00, 0x10, 0xC2, 0x16, 0x00 };
- if (fileContent.FirstPosition(check, out position))
- return "ActiveMARK 5" + (includePosition ? $" (Index {position})" : string.Empty);
+ // " " + (char)0xC2 + (char)0x16 + (char)0x00 + (char)0xA8 + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0xB8 + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0x86 + (char)0xC8 + (char)0x16 + (char)0x0 + (char)0x9A + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0x10 + (char)0xC2 + (char)0x16 + (char)0x00
+ [new byte?[] { 0x20, 0xC2, 0x16, 0x00, 0xA8, 0xC1, 0x16, 0x00, 0xB8, 0xC1, 0x16, 0x00, 0x86, 0xC8, 0x16, 0x0, 0x9A, 0xC1, 0x16, 0x00, 0x10, 0xC2, 0x16, 0x00 }] = "ActiveMARK 5",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/AlphaROM.cs b/BurnOutSharp/ProtectionType/AlphaROM.cs
index 50b32c4a..812580cb 100644
--- a/BurnOutSharp/ProtectionType/AlphaROM.cs
+++ b/BurnOutSharp/ProtectionType/AlphaROM.cs
@@ -1,16 +1,19 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class AlphaROM : IContentCheck
{
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "SETTEC"
- byte?[] check = new byte?[] { 0x53, 0x45, 0x54, 0x54, 0x45, 0x43 };
- if (fileContent.FirstPosition(check, out int position))
- return "Alpha-ROM" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // SETTEC
+ [new byte?[] { 0x53, 0x45, 0x54, 0x54, 0x45, 0x43 }] = "Alpha-ROM",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/CDCheck.cs b/BurnOutSharp/ProtectionType/CDCheck.cs
index 5bb9253c..ce01cfbd 100644
--- a/BurnOutSharp/ProtectionType/CDCheck.cs
+++ b/BurnOutSharp/ProtectionType/CDCheck.cs
@@ -1,37 +1,37 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class CDCheck : IContentCheck
{
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // MGS CDCheck
- byte?[] check = new byte?[] { 0x4D, 0x47, 0x53, 0x20, 0x43, 0x44, 0x43, 0x68, 0x65, 0x63, 0x6B };
- if (fileContent.FirstPosition(check, out int position))
- return "Microsoft Game Studios CD Check" + (includePosition ? $" (Index {position})" : string.Empty);
-
- // CDCheck
- check = new byte?[] { 0x43, 0x44, 0x43, 0x68, 0x65, 0x63, 0x6B };
- if (fileContent.FirstPosition(check, out position))
- return "Executable-Based CD Check" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // MGS CDCheck
+ [new byte?[] { 0x4D, 0x47, 0x53, 0x20, 0x43, 0x44, 0x43, 0x68, 0x65, 0x63, 0x6B }] = "Microsoft Game Studios CD Check",
- return null;
+ // CDCheck
+ [new byte?[] { 0x43, 0x44, 0x43, 0x68, 0x65, 0x63, 0x6B }] = "Executable-Based CD Check",
+ };
+
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
// These content checks are too broad to be useful
private static string CheckContentsBroad(byte[] fileContent, bool includePosition = false)
{
- // GetDriveType
- byte?[] check = new byte?[] { 0x47, 0x65, 0x74, 0x44, 0x72, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65 };
- if (fileContent.FirstPosition(check, out int position))
- return "CD Check" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // GetDriveType
+ [new byte?[] { 0x47, 0x65, 0x74, 0x44, 0x72, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65 }] = "Executable-Based CD Check",
- // GetVolumeInformation
- check = new byte?[] { 0x47, 0x65, 0x74, 0x56, 0x6F, 0x6C, 0x75, 0x6D, 0x65, 0x49, 0x6E, 0x66, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E };
- if (fileContent.FirstPosition(check, out position))
- return "CD Check" + (includePosition ? $" (Index {position})" : string.Empty);
+ // GetVolumeInformation
+ [new byte?[] { 0x47, 0x65, 0x74, 0x56, 0x6F, 0x6C, 0x75, 0x6D, 0x65, 0x49, 0x6E, 0x66, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E }] = "Executable-Based CD Check",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/CDCops.cs b/BurnOutSharp/ProtectionType/CDCops.cs
index 7c8adbfc..9a395025 100644
--- a/BurnOutSharp/ProtectionType/CDCops.cs
+++ b/BurnOutSharp/ProtectionType/CDCops.cs
@@ -10,12 +10,12 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "CD-Cops, ver. "
+ // CD-Cops, ver.
byte?[] check = new byte?[] { 0x43, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73, 0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20 };
if (fileContent.FirstPosition(check, out int position))
return $"CD-Cops {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty);
- // ".grand" + (char)0x00
+ // .grand + (char)0x00
check = new byte?[] { 0x2E, 0x67, 0x72, 0x61, 0x6E, 0x64, 0x00};
if (fileContent.FirstPosition(check, out position))
return "CD-Cops" + (includePosition ? $" (Index {position})" : string.Empty);
diff --git a/BurnOutSharp/ProtectionType/CDLock.cs b/BurnOutSharp/ProtectionType/CDLock.cs
index a6e208a7..5de96d9e 100644
--- a/BurnOutSharp/ProtectionType/CDLock.cs
+++ b/BurnOutSharp/ProtectionType/CDLock.cs
@@ -10,12 +10,13 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "2" + (char)0xF2 + (char)0x02 + (char)0x82 + (char)0xC3 + (char)0xBC + (char)0x0B + "$" + (char)0x99 + (char)0xAD + "'C" + (char)0xE4 + (char)0x9D + "st" + (char)0x99 + (char)0xFA + "2$" + (char)0x9D + ")4" + (char)0xFF + "t"
- byte?[] check = new byte?[] { 0x32, 0xF2, 0x02, 0x82, 0xC3, 0xBC, 0x0B, 0x24, 0x99, 0xAD, 0x27, 0x43, 0xE4, 0x9D, 0x73, 0x74, 0x99, 0xFA, 0x32, 0x24, 0x9D, 0x29, 0x34, 0xFF, 0x74 };
- if (fileContent.FirstPosition(check, out int position))
- return "CD-Lock" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // 2 + (char)0xF2 + (char)0x02 + (char)0x82 + (char)0xC3 + (char)0xBC + (char)0x0B + $ + (char)0x99 + (char)0xAD + 'C + (char)0xE4 + (char)0x9D + st + (char)0x99 + (char)0xFA + 2$ + (char)0x9D + )4 + (char)0xFF + t
+ [new byte?[] { 0x32, 0xF2, 0x02, 0x82, 0xC3, 0xBC, 0x0B, 0x24, 0x99, 0xAD, 0x27, 0x43, 0xE4, 0x9D, 0x73, 0x74, 0x99, 0xFA, 0x32, 0x24, 0x9D, 0x29, 0x34, 0xFF, 0x74 }] = "CD-Lock",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
///
diff --git a/BurnOutSharp/ProtectionType/CDSHiELDSE.cs b/BurnOutSharp/ProtectionType/CDSHiELDSE.cs
index 3ff2bc19..1288b440 100644
--- a/BurnOutSharp/ProtectionType/CDSHiELDSE.cs
+++ b/BurnOutSharp/ProtectionType/CDSHiELDSE.cs
@@ -1,16 +1,19 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class CDSHiELDSE : IContentCheck
{
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "~0017.tmp"
- byte?[] check = new byte?[] { 0x7E, 0x30, 0x30, 0x31, 0x37, 0x2E, 0x74, 0x6D, 0x70 };
- if (fileContent.FirstPosition(check, out int position))
- return "CDSHiELD SE" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // ~0017.tmp
+ [new byte?[] { 0x7E, 0x30, 0x30, 0x31, 0x37, 0x2E, 0x74, 0x6D, 0x70 }] = "CDSHiELD SE",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/CactusDataShield.cs b/BurnOutSharp/ProtectionType/CactusDataShield.cs
index 57ecd234..714cfa97 100644
--- a/BurnOutSharp/ProtectionType/CactusDataShield.cs
+++ b/BurnOutSharp/ProtectionType/CactusDataShield.cs
@@ -11,22 +11,19 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // DATA.CDS
- byte?[] check = new byte?[] { 0x44, 0x41, 0x54, 0x41, 0x2E, 0x43, 0x44, 0x53 };
- if (fileContent.FirstPosition(check, out int position))
- return "Cactus Data Shield 200" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // DATA.CDS
+ [new byte?[] { 0x44, 0x41, 0x54, 0x41, 0x2E, 0x43, 0x44, 0x53 }] = "Cactus Data Shield 200",
- // \*.CDS
- check = new byte?[] { 0x5C, 0x2A, 0x2E, 0x43, 0x44, 0x53 };
- if (fileContent.FirstPosition(check, out position))
- return "Cactus Data Shield 200" + (includePosition ? $" (Index {position})" : string.Empty);
+ // \*.CDS
+ [new byte?[] { 0x5C, 0x2A, 0x2E, 0x43, 0x44, 0x53 }] = "Cactus Data Shield 200",
- // CDSPlayer
- check = new byte?[] { 0x43, 0x44, 0x53, 0x50, 0x6C, 0x61, 0x79, 0x65, 0x72 };
- if (fileContent.FirstPosition(check, out position))
- return "Cactus Data Shield 200" + (includePosition ? $" (Index {position})" : string.Empty);
+ // CDSPlayer
+ [new byte?[] { 0x43, 0x44, 0x53, 0x50, 0x6C, 0x61, 0x79, 0x65, 0x72 }] = "Cactus Data Shield 200",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
///
diff --git a/BurnOutSharp/ProtectionType/CengaProtectDVD.cs b/BurnOutSharp/ProtectionType/CengaProtectDVD.cs
index a7310427..5ca9289b 100644
--- a/BurnOutSharp/ProtectionType/CengaProtectDVD.cs
+++ b/BurnOutSharp/ProtectionType/CengaProtectDVD.cs
@@ -1,16 +1,19 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class CengaProtectDVD : IContentCheck
{
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // ".cenega"
- byte?[] check = new byte?[] { 0x2E, 0x63, 0x65, 0x6E, 0x65, 0x67, 0x61 };
- if (fileContent.FirstPosition(check, out int position))
- return "Cenega ProtectDVD" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // .cenega
+ [new byte?[] { 0x2E, 0x63, 0x65, 0x6E, 0x65, 0x67, 0x61 }] = "Cenega ProtectDVD",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/CodeLock.cs b/BurnOutSharp/ProtectionType/CodeLock.cs
index 96147710..366a25c2 100644
--- a/BurnOutSharp/ProtectionType/CodeLock.cs
+++ b/BurnOutSharp/ProtectionType/CodeLock.cs
@@ -1,4 +1,6 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class CodeLock : IContentCheck
{
@@ -6,22 +8,19 @@
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "icd1" + (char)0x00
- byte?[] check = new byte?[] { 0x69, 0x63, 0x64, 0x31, 0x00 };
- if (fileContent.FirstPosition(check, out int position))
- return "Code Lock" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // icd1 + (char)0x00
+ [new byte?[] { 0x69, 0x63, 0x64, 0x31, 0x00 }] = "Code Lock",
- // "icd2" + (char)0x00
- check = new byte?[] { 0x69, 0x63, 0x64, 0x32, 0x00 };
- if (fileContent.FirstPosition(check, out position))
- return "Code Lock" + (includePosition ? $" (Index {position})" : string.Empty);
+ // icd2 + (char)0x00
+ [new byte?[] { 0x69, 0x63, 0x64, 0x32, 0x00 }] = "Code Lock",
- // "CODE-LOCK.OCX"
- check = new byte?[] { 0x43, 0x4F, 0x44, 0x45, 0x2D, 0x4C, 0x4F, 0x43, 0x4B, 0x2E, 0x4F, 0x43, 0x58 };
- if (fileContent.FirstPosition(check, out position))
- return "Code Lock" + (includePosition ? $" (Index {position})" : string.Empty);
+ // CODE-LOCK.OCX
+ [new byte?[] { 0x43, 0x4F, 0x44, 0x45, 0x2D, 0x4C, 0x4F, 0x43, 0x4B, 0x2E, 0x4F, 0x43, 0x58 }] = "Code Lock",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/CopyKiller.cs b/BurnOutSharp/ProtectionType/CopyKiller.cs
index 94406027..b340d15b 100644
--- a/BurnOutSharp/ProtectionType/CopyKiller.cs
+++ b/BurnOutSharp/ProtectionType/CopyKiller.cs
@@ -10,12 +10,13 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "Tom Commander"
- byte?[] check = new byte?[] { 0x54, 0x6F, 0x6D, 0x20, 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x65, 0x72 };
- if (fileContent.FirstPosition(check, out int position))
- return "CopyKiller" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // Tom Commander
+ [new byte?[] { 0x54, 0x6F, 0x6D, 0x20, 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x65, 0x72 }] = "CopyKiller",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
///
diff --git a/BurnOutSharp/ProtectionType/GFWL.cs b/BurnOutSharp/ProtectionType/GFWL.cs
index 8f3728d2..af448611 100644
--- a/BurnOutSharp/ProtectionType/GFWL.cs
+++ b/BurnOutSharp/ProtectionType/GFWL.cs
@@ -10,12 +10,13 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "xlive.dll"
- byte?[] check = new byte?[] { 0x78, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x64, 0x6C, 0x6C };
- if (fileContent.FirstPosition(check, out int position))
- return "Games for Windows - Live" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // xlive.dll
+ [new byte?[] { 0x78, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x64, 0x6C, 0x6C }] = "Games for Windows - Live",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
///
diff --git a/BurnOutSharp/ProtectionType/Intenium.cs b/BurnOutSharp/ProtectionType/Intenium.cs
index 483a5305..5bd1d832 100644
--- a/BurnOutSharp/ProtectionType/Intenium.cs
+++ b/BurnOutSharp/ProtectionType/Intenium.cs
@@ -1,4 +1,6 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class Intenium : IContentCheck
{
@@ -21,12 +23,13 @@
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // Trial + (char)0x00 + P
- byte?[] check = new byte?[] { 0x54, 0x72, 0x69, 0x61, 0x6C, 0x00, 0x50 };
- if (fileContent.FirstPosition(check, out int position))
- return "INTENIUM Trial & Buy Protection" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // Trial + (char)0x00 + P
+ [new byte?[] { 0x54, 0x72, 0x69, 0x61, 0x6C, 0x00, 0x50 }] = "INTENIUM Trial & Buy Protection",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/KeyLock.cs b/BurnOutSharp/ProtectionType/KeyLock.cs
index 2ed86339..93df8386 100644
--- a/BurnOutSharp/ProtectionType/KeyLock.cs
+++ b/BurnOutSharp/ProtectionType/KeyLock.cs
@@ -1,16 +1,19 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class KeyLock : IContentCheck
{
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "KEY-LOCK COMMAND"
- byte?[] check = new byte?[] { 0x4B, 0x45, 0x59, 0x2D, 0x4C, 0x4F, 0x43, 0x4B, 0x20, 0x43, 0x4F, 0x4D, 0x4D, 0x41, 0x4E, 0x44 };
- if (fileContent.FirstPosition(check, out int position))
- return $"Key-Lock (Dongle)" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // KEY-LOCK COMMAND
+ [new byte?[] { 0x4B, 0x45, 0x59, 0x2D, 0x4C, 0x4F, 0x43, 0x4B, 0x20, 0x43, 0x4F, 0x4D, 0x4D, 0x41, 0x4E, 0x44 }] = "Key-Lock (Dongle)",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/OnlineRegistration.cs b/BurnOutSharp/ProtectionType/OnlineRegistration.cs
index ad63d115..a885a7f9 100644
--- a/BurnOutSharp/ProtectionType/OnlineRegistration.cs
+++ b/BurnOutSharp/ProtectionType/OnlineRegistration.cs
@@ -8,7 +8,7 @@
// I + (char)0x00 + n + (char)0x00 + t + (char)0x00 + e + (char)0x00 + r + (char)0x00 + n + (char)0x00 + a + (char)0x00 + l + (char)0x00 + N + (char)0x00 + a + (char)0x00 + m + (char)0x00 + e + (char)0x00 + + (char)0x00 + + (char)0x00 + E + (char)0x00 + R + (char)0x00 + e + (char)0x00 + g + (char)0x00
byte?[] check = new byte?[] { 0x49, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x4E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x45, 0x00, 0x52, 0x00, 0x65, 0x00, 0x67, 0x00 };
if (fileContent.FirstPosition(check, out int position))
- return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty);
+ return $"Executable-Based Online Registration {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty);
return null;
}
diff --git a/BurnOutSharp/ProtectionType/Origin.cs b/BurnOutSharp/ProtectionType/Origin.cs
index 5438bbc2..9f47c87a 100644
--- a/BurnOutSharp/ProtectionType/Origin.cs
+++ b/BurnOutSharp/ProtectionType/Origin.cs
@@ -10,12 +10,13 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // O + (char)0x00 + r + (char)0x00 + i + (char)0x00 + g + (char)0x00 + i + (char)0x00 + n + (char)0x00 + S + (char)0x00 + e + (char)0x00 + t + (char)0x00 + u + (char)0x00 + p + (char)0x00 + . + (char)0x00 + e + (char)0x00 + x + (char)0x00 + e + (char)0x00
- byte?[] check = new byte?[] { 0x4F, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x53, 0x00, 0x65, 0x00, 0x74, 0x00, 0x75, 0x00, 0x70, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x78, 0x00, 0x65, 0x00 };
- if (fileContent.FirstPosition(check, out int position))
- return "Origin" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // O + (char)0x00 + r + (char)0x00 + i + (char)0x00 + g + (char)0x00 + i + (char)0x00 + n + (char)0x00 + S + (char)0x00 + e + (char)0x00 + t + (char)0x00 + u + (char)0x00 + p + (char)0x00 + . + (char)0x00 + e + (char)0x00 + x + (char)0x00 + e + (char)0x00
+ [new byte?[] { 0x4F, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x53, 0x00, 0x65, 0x00, 0x74, 0x00, 0x75, 0x00, 0x70, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x78, 0x00, 0x65, 0x00 }] = "Origin",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
///
diff --git a/BurnOutSharp/ProtectionType/PSXAntiModchip.cs b/BurnOutSharp/ProtectionType/PSXAntiModchip.cs
index 28db69ae..b26d795b 100644
--- a/BurnOutSharp/ProtectionType/PSXAntiModchip.cs
+++ b/BurnOutSharp/ProtectionType/PSXAntiModchip.cs
@@ -1,4 +1,6 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class PSXAntiModchip : IContentCheck
{
@@ -7,17 +9,16 @@
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // " SOFTWARE TERMINATED\nCONSOLE MAY HAVE BEEN MODIFIED\n CALL 1-888-780-7690"
- byte?[] check = new byte?[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x53, 0x4F, 0x46, 0x54, 0x57, 0x41, 0x52, 0x45, 0x20, 0x54, 0x45, 0x52, 0x4D, 0x49, 0x4E, 0x41, 0x54, 0x45, 0x44, 0x5C, 0x6E, 0x43, 0x4F, 0x4E, 0x53, 0x4F, 0x4C, 0x45, 0x20, 0x4D, 0x41, 0x59, 0x20, 0x48, 0x41, 0x56, 0x45, 0x20, 0x42, 0x45, 0x45, 0x4E, 0x20, 0x4D, 0x4F, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5C, 0x6E, 0x20, 0x20, 0x20, 0x20, 0x20, 0x43, 0x41, 0x4C, 0x4C, 0x20, 0x31, 0x2D, 0x38, 0x38, 0x38, 0x2D, 0x37, 0x38, 0x30, 0x2D, 0x37, 0x36, 0x39, 0x30 };
- if (fileContent.FirstPosition(check, out int position))
- return $"PlayStation Anti-modchip (English)" + (includePosition ? $"(Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // SOFTWARE TERMINATED\nCONSOLE MAY HAVE BEEN MODIFIED\n CALL 1-888-780-7690
+ [new byte?[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x53, 0x4F, 0x46, 0x54, 0x57, 0x41, 0x52, 0x45, 0x20, 0x54, 0x45, 0x52, 0x4D, 0x49, 0x4E, 0x41, 0x54, 0x45, 0x44, 0x5C, 0x6E, 0x43, 0x4F, 0x4E, 0x53, 0x4F, 0x4C, 0x45, 0x20, 0x4D, 0x41, 0x59, 0x20, 0x48, 0x41, 0x56, 0x45, 0x20, 0x42, 0x45, 0x45, 0x4E, 0x20, 0x4D, 0x4F, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5C, 0x6E, 0x20, 0x20, 0x20, 0x20, 0x20, 0x43, 0x41, 0x4C, 0x4C, 0x20, 0x31, 0x2D, 0x38, 0x38, 0x38, 0x2D, 0x37, 0x38, 0x30, 0x2D, 0x37, 0x36, 0x39, 0x30 }] = "PlayStation Anti-modchip (English)",
- // "強制終了しました。\n本体が改造されている\nおそれがあります。"
- check = new byte?[] { 0x5F, 0x37, 0x52, 0x36, 0x7D, 0x42, 0x4E, 0x86, 0x30, 0x57, 0x30, 0x7E, 0x30, 0x57, 0x30, 0x5F, 0x30, 0x02, 0x5C, 0x6E, 0x67, 0x2C, 0x4F, 0x53, 0x30, 0x4C, 0x65, 0x39, 0x90, 0x20, 0x30, 0x55, 0x30, 0x8C, 0x30, 0x66, 0x30, 0x44, 0x30, 0x8B, 0x5C, 0x6E, 0x30, 0x4A, 0x30, 0x5D, 0x30, 0x8C, 0x30, 0x4C, 0x30, 0x42, 0x30, 0x8A, 0x30, 0x7E, 0x30, 0x59, 0x30, 0x02 };
- if (fileContent.FirstPosition(check, out position))
- return $"PlayStation Anti-modchip (Japanese)" + (includePosition ? $"(Index {position})" : string.Empty);
+ // 強制終了しました。\n本体が改造されている\nおそれがあります。
+ [new byte?[] { 0x5F, 0x37, 0x52, 0x36, 0x7D, 0x42, 0x4E, 0x86, 0x30, 0x57, 0x30, 0x7E, 0x30, 0x57, 0x30, 0x5F, 0x30, 0x02, 0x5C, 0x6E, 0x67, 0x2C, 0x4F, 0x53, 0x30, 0x4C, 0x65, 0x39, 0x90, 0x20, 0x30, 0x55, 0x30, 0x8C, 0x30, 0x66, 0x30, 0x44, 0x30, 0x8B, 0x5C, 0x6E, 0x30, 0x4A, 0x30, 0x5D, 0x30, 0x8C, 0x30, 0x4C, 0x30, 0x42, 0x30, 0x8A, 0x30, 0x7E, 0x30, 0x59, 0x30, 0x02 }] = "PlayStation Anti-modchip (Japanese)",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/RingPROTECH.cs b/BurnOutSharp/ProtectionType/RingPROTECH.cs
index 5735d362..55403afe 100644
--- a/BurnOutSharp/ProtectionType/RingPROTECH.cs
+++ b/BurnOutSharp/ProtectionType/RingPROTECH.cs
@@ -1,4 +1,6 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class RingPROTECH : IContentCheck
{
@@ -6,12 +8,13 @@
/// TODO: Investigate as this may be over-matching
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // (char)0x00 + "Allocator" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00
- byte?[] check = new byte?[] { 0x00, 0x41, 0x6C, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x6F, 0x72, 0x00, 0x00, 0x00, 0x00 };
- if (fileContent.FirstPosition(check, out int position))
- return "Ring PROTECH [Check disc for physical ring]" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // (char)0x00 + Allocator + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00
+ [new byte?[] { 0x00, 0x41, 0x6C, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x6F, 0x72, 0x00, 0x00, 0x00, 0x00 }] = "Ring PROTECH [Check disc for physical ring]",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/SVKProtector.cs b/BurnOutSharp/ProtectionType/SVKProtector.cs
index 6d93328b..6d3a527b 100644
--- a/BurnOutSharp/ProtectionType/SVKProtector.cs
+++ b/BurnOutSharp/ProtectionType/SVKProtector.cs
@@ -1,16 +1,19 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class SVKProtector : IContentCheck
{
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "?SVKP" + (char)0x00 + (char)0x00
- byte?[] check = new byte?[] { 0x3F, 0x53, 0x56, 0x4B, 0x50, 0x00, 0x00 };
- if (fileContent.FirstPosition(check, out int position))
- return "SVK Protector" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // ?SVKP + (char)0x00 + (char)0x00
+ [new byte?[] { 0x3F, 0x53, 0x56, 0x4B, 0x50, 0x00, 0x00 }] = "SVK Protector",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/SmartE.cs b/BurnOutSharp/ProtectionType/SmartE.cs
index f80dfbbc..1ed3665f 100644
--- a/BurnOutSharp/ProtectionType/SmartE.cs
+++ b/BurnOutSharp/ProtectionType/SmartE.cs
@@ -10,12 +10,13 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // BITARTS
- byte?[] check = new byte?[] { 0x42, 0x49, 0x54, 0x41, 0x52, 0x54, 0x53 };
- if (fileContent.FirstPosition(check, out int position))
- return "SmartE" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // BITARTS
+ [new byte?[] { 0x42, 0x49, 0x54, 0x41, 0x52, 0x54, 0x53 }] = "SmartE",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
///
diff --git a/BurnOutSharp/ProtectionType/Steam.cs b/BurnOutSharp/ProtectionType/Steam.cs
index 774a889e..a359d63f 100644
--- a/BurnOutSharp/ProtectionType/Steam.cs
+++ b/BurnOutSharp/ProtectionType/Steam.cs
@@ -5,7 +5,6 @@ using System.Linq;
namespace BurnOutSharp.ProtectionType
{
- // TODO: Can this be split into file and directory checks separately?
public class Steam : IPathCheck
{
///
diff --git a/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs b/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs
index 30c5398a..dfb202a9 100644
--- a/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs
+++ b/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs
@@ -1,16 +1,19 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class ThreeTwoOneStudios : IContentCheck
{
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // 3 + (char)0x00 + 1 + 2 + (char)0x00 + 1 + (char)0x00 + S + (char)0x00 + t + (char)0x00 + u + (char)0x00 + d + (char)0x00 + i + (char)0x00 + o + (char)0x00 + s + (char)0x00 + + (char)0x00 + A + (char)0x00 + c + (char)0x00 + t + (char)0x00 + i + (char)0x00 + v + (char)0x00 + a + (char)0x00 + t + (char)0x00 + i + (char)0x00 + o + (char)0x00 + n + (char)0x00
- byte?[] check = new byte?[] { 0x33, 0x00, 0x32, 0x00, 0x31, 0x00, 0x53, 0x00, 0x74, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x20, 0x00, 0x41, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x76, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00 };
- if (fileContent.FirstPosition(check, out int position))
- return "321Studios Online Activation" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // 3 + (char)0x00 + 1 + 2 + (char)0x00 + 1 + (char)0x00 + S + (char)0x00 + t + (char)0x00 + u + (char)0x00 + d + (char)0x00 + i + (char)0x00 + o + (char)0x00 + s + (char)0x00 + + (char)0x00 + A + (char)0x00 + c + (char)0x00 + t + (char)0x00 + i + (char)0x00 + v + (char)0x00 + a + (char)0x00 + t + (char)0x00 + i + (char)0x00 + o + (char)0x00 + n + (char)0x00
+ [new byte?[] { 0x33, 0x00, 0x32, 0x00, 0x31, 0x00, 0x53, 0x00, 0x74, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x20, 0x00, 0x41, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x76, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00 }] = "321Studios Online Activation",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/WTMCDProtect.cs b/BurnOutSharp/ProtectionType/WTMCDProtect.cs
index 9b92d2ac..43dbb135 100644
--- a/BurnOutSharp/ProtectionType/WTMCDProtect.cs
+++ b/BurnOutSharp/ProtectionType/WTMCDProtect.cs
@@ -10,12 +10,13 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "WTM76545"
- byte?[] check = new byte?[] { 0x57, 0x54, 0x4D, 0x37, 0x36, 0x35, 0x34, 0x35 };
- if (fileContent.FirstPosition(check, out int position))
- return "WTM CD Protect" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // WTM76545
+ [new byte?[] { 0x57, 0x54, 0x4D, 0x37, 0x36, 0x35, 0x34, 0x35 }] = "WTM CD Protect",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
///
diff --git a/BurnOutSharp/ProtectionType/XCP.cs b/BurnOutSharp/ProtectionType/XCP.cs
index 10bcc4ed..c84a5e40 100644
--- a/BurnOutSharp/ProtectionType/XCP.cs
+++ b/BurnOutSharp/ProtectionType/XCP.cs
@@ -11,22 +11,19 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // XCP.DAT
- byte?[] check = new byte?[] { 0x58, 0x43, 0x50, 0x2E, 0x44, 0x41, 0x54 };
- if (fileContent.FirstPosition(check, out int position))
- return "XCP" + (includePosition ? $" (Index {position})" : string.Empty);
-
- // XCPPlugins.dll
- check = new byte?[] { 0x58, 0x43, 0x50, 0x50, 0x6C, 0x75, 0x67, 0x69, 0x6E, 0x73, 0x2E, 0x64, 0x6C, 0x6C };
- if (fileContent.FirstPosition(check, out position))
- return "XCP" + (includePosition ? $" (Index {position})" : string.Empty);
-
- // XCPPhoenix.dll
- check = new byte?[] { 0x58, 0x43, 0x50, 0x50, 0x68, 0x6F, 0x65, 0x6E, 0x69, 0x78, 0x2E, 0x64, 0x6C, 0x6C };
- if (fileContent.FirstPosition(check, out position))
- return "XCP" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // XCP.DAT
+ [new byte?[] { 0x58, 0x43, 0x50, 0x2E, 0x44, 0x41, 0x54 }] = "XCP",
- return null;
+ // XCPPlugins.dll
+ [new byte?[] { 0x58, 0x43, 0x50, 0x50, 0x6C, 0x75, 0x67, 0x69, 0x6E, 0x73, 0x2E, 0x64, 0x6C, 0x6C }] = "XCP",
+
+ // XCPPhoenix.dll
+ [new byte?[] { 0x58, 0x43, 0x50, 0x50, 0x68, 0x6F, 0x65, 0x6E, 0x69, 0x78, 0x2E, 0x64, 0x6C, 0x6C }] = "XCP",
+ };
+
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
///
diff --git a/BurnOutSharp/ProtectionType/XtremeProtector.cs b/BurnOutSharp/ProtectionType/XtremeProtector.cs
index dfda0d8e..e3857b73 100644
--- a/BurnOutSharp/ProtectionType/XtremeProtector.cs
+++ b/BurnOutSharp/ProtectionType/XtremeProtector.cs
@@ -1,16 +1,19 @@
-namespace BurnOutSharp.ProtectionType
+using System.Collections.Generic;
+
+namespace BurnOutSharp.ProtectionType
{
public class XtremeProtector : IContentCheck
{
///
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
- // "XPROT "
- byte?[] check = new byte?[] { 0x58, 0x50, 0x52, 0x4F, 0x54, 0x20, 0x20, 0x20 };
- if (fileContent.FirstPosition(check, out int position))
- return "Xtreme-Protector" + (includePosition ? $" (Index {position})" : string.Empty);
+ var mappings = new Dictionary
+ {
+ // XPROT
+ [new byte?[] { 0x58, 0x50, 0x52, 0x4F, 0x54, 0x20, 0x20, 0x20 }] = "Xtreme-Protector",
+ };
- return null;
+ return Utilities.GetContentMatches(fileContent, mappings, includePosition);
}
}
}
diff --git a/BurnOutSharp/Utilities.cs b/BurnOutSharp/Utilities.cs
index b31ee0b9..bcecf433 100644
--- a/BurnOutSharp/Utilities.cs
+++ b/BurnOutSharp/Utilities.cs
@@ -252,17 +252,43 @@ namespace BurnOutSharp
/// Mapping of byte array to string for matching
/// True to include positional data, false otherwise
/// String representing the matched protection, null otherwise
+ ///
+ /// This is useful for checks that don't do anything special with versions or other positions.
+ /// TODO: Make variant of this that returns *all* content matches for later
+ /// TODO: Make variant of this that can take multiple content checks per check for later
+ ///
public static string GetContentMatches(byte[] fileContent, Dictionary mappings, bool includePosition = false)
+ {
+ return GetVersionedContentMatches(fileContent, mappings.Select(kvp => (kvp.Key, (Func)null, kvp.Value)).ToList(), includePosition);
+ }
+
+ ///
+ /// Get versioned content matches for a given protection
+ ///
+ /// Byte array representing the file contents
+ /// Tuple of matching byte array, version method, and string to output
+ /// True to include positional data, false otherwise
+ /// String representing the matched protection, null otherwise
+ ///
+ /// This is useful for checks that don't do anything special with versions or other positions.
+ /// TODO: Make variant of this that returns *all* content matches for later
+ /// TODO: Make variant of this that can take multiple content checks per check for later
+ ///
+ public static string GetVersionedContentMatches(byte[] fileContent, List<(byte?[], Func, string)> mappings, bool includePosition = false)
{
// If there's no mappings, we can't match
if (mappings == null || !mappings.Any())
return null;
// Loop through and try everything otherwise
- foreach (var kvp in mappings)
+ foreach (var mapping in mappings)
{
- if (fileContent.FirstPosition(kvp.Key, out int position))
- return kvp.Value + (includePosition ? $" (Index {position})" : string.Empty);
+ if (fileContent.FirstPosition(mapping.Item1, out int position))
+ {
+ string version = mapping.Item2 == null ? string.Empty : (mapping.Item2(fileContent, position) ?? "Unknown Version");
+ string protection = string.IsNullOrWhiteSpace(version) ? mapping.Item3 : $"{mapping.Item3} {version}";
+ return protection + (includePosition ? $" (Index {position})" : string.Empty);
+ }
}
return null;