diff --git a/BurnOutSharp/Matching/Matcher.cs b/BurnOutSharp/Matching/Matcher.cs index c4ff63da..327f7aca 100644 --- a/BurnOutSharp/Matching/Matcher.cs +++ b/BurnOutSharp/Matching/Matcher.cs @@ -27,13 +27,13 @@ namespace BurnOutSharp.Matching #region Constructors public Matcher(byte?[] needle, string protectionName) - : this(new List() { needle }, null, protectionName) { } + : this(new List { needle }, null, protectionName) { } public Matcher(List needles, string protectionName) : this(needles, null, protectionName) { } public Matcher(byte?[] needle, Func getVersion, string protectionName) - : this(new List() { needle }, getVersion, protectionName) { } + : this(new List { needle }, getVersion, protectionName) { } public Matcher(List needles, Func getVersion, string protectionName) : this(needles.Select(n => new ContentMatch(n)).ToList(), getVersion, protectionName) { } diff --git a/BurnOutSharp/PackerType/NSIS.cs b/BurnOutSharp/PackerType/NSIS.cs index fd7fd319..fdaa0a1b 100644 --- a/BurnOutSharp/PackerType/NSIS.cs +++ b/BurnOutSharp/PackerType/NSIS.cs @@ -14,10 +14,19 @@ namespace BurnOutSharp.PackerType var matchers = new List { // Nullsoft Install System - new Matcher(new byte?[] { 0x4e, 0x75, 0x6c, 0x6c, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d }, GetVersion, "NSIS"), + new Matcher(new byte?[] + { + 0x4e, 0x75, 0x6c, 0x6c, 0x73, 0x6f, 0x66, 0x74, + 0x20, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, + 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d + }, GetVersion, "NSIS"), // NullsoftInst - new Matcher(new byte?[] { 0x4e, 0x75, 0x6c, 0x6c, 0x73, 0x6f, 0x66, 0x74, 0x49, 0x6e, 0x73, 0x74 }, "NSIS"), + new Matcher(new byte?[] + { + 0x4e, 0x75, 0x6c, 0x6c, 0x73, 0x6f, 0x66, 0x74, + 0x49, 0x6e, 0x73, 0x74 + }, "NSIS"), }; return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/PackerType/PECompact.cs b/BurnOutSharp/PackerType/PECompact.cs index e1d11dd9..4326522b 100644 --- a/BurnOutSharp/PackerType/PECompact.cs +++ b/BurnOutSharp/PackerType/PECompact.cs @@ -20,7 +20,11 @@ namespace BurnOutSharp.PackerType new Matcher(new byte?[] { 0x50, 0x45, 0x43, 0x32 }, GetVersion, "PE Compact 2 v"), // PECompact2 - new Matcher(new byte?[] { 0x50, 0x45, 0x43, 0x6F, 0x6D, 0x70, 0x61, 0x63, 0x74, 0x32 }, "PE Compact 2"), + new Matcher(new byte?[] + { + 0x50, 0x45, 0x43, 0x6F, 0x6D, 0x70, 0x61, 0x63, + 0x74, 0x32 + }, "PE Compact 2"), }; return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/PackerType/SetupFactory.cs b/BurnOutSharp/PackerType/SetupFactory.cs index e4a6a0c5..3ace43d1 100644 --- a/BurnOutSharp/PackerType/SetupFactory.cs +++ b/BurnOutSharp/PackerType/SetupFactory.cs @@ -19,7 +19,13 @@ namespace BurnOutSharp.PackerType var matchers = new List { // S.e.t.u.p. .F.a.c.t.o.r.y. - new Matcher(new byte?[] { 0x53, 0x00, 0x65, 0x00, 0x74, 0x00, 0x75, 0x00, 0x70, 0x00, 0x20, 0x00, 0x46, 0x00, 0x61, 0x00, 0x63, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x79, 0x00 }, GetVersion, "Setup Factory"), + new Matcher(new byte?[] + { + 0x53, 0x00, 0x65, 0x00, 0x74, 0x00, 0x75, 0x00, + 0x70, 0x00, 0x20, 0x00, 0x46, 0x00, 0x61, 0x00, + 0x63, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x72, 0x00, + 0x79, 0x00 + }, GetVersion, "Setup Factory"), }; return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/ProtectionType/ActiveMARK.cs b/BurnOutSharp/ProtectionType/ActiveMARK.cs index 38efa4e5..6450ed4e 100644 --- a/BurnOutSharp/ProtectionType/ActiveMARK.cs +++ b/BurnOutSharp/ProtectionType/ActiveMARK.cs @@ -13,8 +13,13 @@ namespace BurnOutSharp.ProtectionType // TMSAMVOF new Matcher(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 - new Matcher(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"), + // " " + (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)0x00 + (char)0x9A + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0x10 + (char)0xC2 + (char)0x16 + (char)0x00 + new Matcher(new byte?[] + { + 0x20, 0xC2, 0x16, 0x00, 0xA8, 0xC1, 0x16, 0x00, + 0xB8, 0xC1, 0x16, 0x00, 0x86, 0xC8, 0x16, 0x00, + 0x9A, 0xC1, 0x16, 0x00, 0x10, 0xC2, 0x16, 0x00 + }, "ActiveMARK 5"), }; return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/ProtectionType/CDCheck.cs b/BurnOutSharp/ProtectionType/CDCheck.cs index 980faaed..f20fc143 100644 --- a/BurnOutSharp/ProtectionType/CDCheck.cs +++ b/BurnOutSharp/ProtectionType/CDCheck.cs @@ -11,7 +11,11 @@ namespace BurnOutSharp.ProtectionType var matchers = new List { // MGS CDCheck - new Matcher(new byte?[] { 0x4D, 0x47, 0x53, 0x20, 0x43, 0x44, 0x43, 0x68, 0x65, 0x63, 0x6B }, "Microsoft Game Studios CD Check"), + new Matcher(new byte?[] + { + 0x4D, 0x47, 0x53, 0x20, 0x43, 0x44, 0x43, 0x68, + 0x65, 0x63, 0x6B + }, "Microsoft Game Studios CD Check"), // CDCheck new Matcher(new byte?[] { 0x43, 0x44, 0x43, 0x68, 0x65, 0x63, 0x6B }, "Executable-Based CD Check"), @@ -26,10 +30,19 @@ namespace BurnOutSharp.ProtectionType var matchers = new List { // GetDriveType - new Matcher(new byte?[] { 0x47, 0x65, 0x74, 0x44, 0x72, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65 }, "Executable-Based CD Check"), + new Matcher(new byte?[] + { + 0x47, 0x65, 0x74, 0x44, 0x72, 0x69, 0x76, 0x65, + 0x54, 0x79, 0x70, 0x65 + }, "Executable-Based CD Check"), // GetVolumeInformation - new Matcher(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"), + new Matcher(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 Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/ProtectionType/CDCops.cs b/BurnOutSharp/ProtectionType/CDCops.cs index 9a395025..3104ce0a 100644 --- a/BurnOutSharp/ProtectionType/CDCops.cs +++ b/BurnOutSharp/ProtectionType/CDCops.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using BurnOutSharp.Matching; namespace BurnOutSharp.ProtectionType { @@ -10,17 +11,20 @@ namespace BurnOutSharp.ProtectionType /// public string CheckContents(string file, byte[] fileContent, bool includePosition = false) { - // 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); + var matchers = new List + { + // CD-Cops, ver. + new Matcher(new byte?[] + { + 0x43, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73, 0x2C, + 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20 + }, GetVersion, "CD-Cops"), - // .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); + // .grand + (char)0x00 + new Matcher(new byte?[] { 0x2E, 0x67, 0x72, 0x61, 0x6E, 0x64, 0x00 }, "CD-Cops"), + }; - return null; + return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); } /// @@ -53,7 +57,7 @@ namespace BurnOutSharp.ProtectionType return null; } - private static string GetVersion(byte[] fileContent, int position) + public static string GetVersion(string file, byte[] fileContent, int position) { char[] version = new ArraySegment(fileContent, position + 15, 4).Select(b => (char)b).ToArray(); if (version[0] == 0x00) diff --git a/BurnOutSharp/ProtectionType/CDLock.cs b/BurnOutSharp/ProtectionType/CDLock.cs index a668dfc7..5b095c70 100644 --- a/BurnOutSharp/ProtectionType/CDLock.cs +++ b/BurnOutSharp/ProtectionType/CDLock.cs @@ -14,7 +14,13 @@ namespace BurnOutSharp.ProtectionType var matchers = new List { // 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 Matcher(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"), + new Matcher(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 Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/ProtectionType/CodeLock.cs b/BurnOutSharp/ProtectionType/CodeLock.cs index ce1b3298..d3bc656b 100644 --- a/BurnOutSharp/ProtectionType/CodeLock.cs +++ b/BurnOutSharp/ProtectionType/CodeLock.cs @@ -18,7 +18,11 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x69, 0x63, 0x64, 0x32, 0x00 }, "Code Lock"), // CODE-LOCK.OCX - new Matcher(new byte?[] { 0x43, 0x4F, 0x44, 0x45, 0x2D, 0x4C, 0x4F, 0x43, 0x4B, 0x2E, 0x4F, 0x43, 0x58 }, "Code Lock"), + new Matcher(new byte?[] + { + 0x43, 0x4F, 0x44, 0x45, 0x2D, 0x4C, 0x4F, 0x43, + 0x4B, 0x2E, 0x4F, 0x43, 0x58 + }, "Code Lock"), }; return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/ProtectionType/CopyKiller.cs b/BurnOutSharp/ProtectionType/CopyKiller.cs index 45601cbb..5b3b601b 100644 --- a/BurnOutSharp/ProtectionType/CopyKiller.cs +++ b/BurnOutSharp/ProtectionType/CopyKiller.cs @@ -14,7 +14,11 @@ namespace BurnOutSharp.ProtectionType var matchers = new List { // Tom Commander - new Matcher(new byte?[] { 0x54, 0x6F, 0x6D, 0x20, 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x65, 0x72 }, "CopyKiller"), + new Matcher(new byte?[] + { + 0x54, 0x6F, 0x6D, 0x20, 0x43, 0x6F, 0x6D, 0x6D, + 0x61, 0x6E, 0x64, 0x65, 0x72 + }, "CopyKiller"), }; return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/ProtectionType/DVDCops.cs b/BurnOutSharp/ProtectionType/DVDCops.cs index 6a1961a2..91f443c3 100644 --- a/BurnOutSharp/ProtectionType/DVDCops.cs +++ b/BurnOutSharp/ProtectionType/DVDCops.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.Linq; +using BurnOutSharp.Matching; namespace BurnOutSharp.ProtectionType { @@ -8,15 +10,20 @@ namespace BurnOutSharp.ProtectionType /// public string CheckContents(string file, byte[] fileContent, bool includePosition = false) { - // "DVD-Cops, ver. " - byte?[] check = new byte?[] { 0x44, 0x56, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73, 0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20 }; - if (fileContent.FirstPosition(check, out int position)) - return $"DVD-Cops {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); + var matchers = new List + { + // DVD-Cops, ver. + new Matcher(new byte?[] + { + 0x44, 0x56, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73, + 0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20 + }, GetVersion, "DVD-Cops"), + }; - return null; + return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); } - private static string GetVersion(byte[] fileContent, int position) + public static string GetVersion(string file, byte[] fileContent, int position) { char[] version = new ArraySegment(fileContent, position + 15, 4).Select(b => (char)b).ToArray(); if (version[0] == 0x00) diff --git a/BurnOutSharp/ProtectionType/ElectronicArts.cs b/BurnOutSharp/ProtectionType/ElectronicArts.cs index 3f71bcb3..f49cf36b 100644 --- a/BurnOutSharp/ProtectionType/ElectronicArts.cs +++ b/BurnOutSharp/ProtectionType/ElectronicArts.cs @@ -1,4 +1,7 @@ -namespace BurnOutSharp.ProtectionType +using System.Collections.Generic; +using BurnOutSharp.Matching; + +namespace BurnOutSharp.ProtectionType { public class ElectronicArts : IContentCheck { @@ -9,57 +12,101 @@ /// public string CheckContents(string file, byte[] fileContent, bool includePosition = false) { - // EASTL - // byte?[] check = new byte?[] { 0x45, 0x41, 0x53, 0x54, 0x4C }; - // if (fileContent.Contains(check, out int position)) - // return "Cucko (EA Custom)" + (includePosition ? $" (Index {position})" : string.Empty); + var matchers = new List + { + // EASTL + //new Matcher(new byte?[] { 0x45, 0x41, 0x53, 0x54, 0x4C }, "Cucko (EA Custom)"), - // R + (char)0x00 + e + (char)0x00 + g + (char)0x00 + i + (char)0x00 + s + (char)0x00 + t + (char)0x00 + r + (char)0x00 + a + (char)0x00 + t + (char)0x00 + i + (char)0x00 + o + (char)0x00 + n + (char)0x00 + + (char)0x00 + C + (char)0x00 + o + (char)0x00 + d + (char)0x00 + e + (char)0x00 + + (char)0x00 + i + (char)0x00 + n + (char)0x00 + s + (char)0x00 + t + (char)0x00 + a + (char)0x00 + l + (char)0x00 + l + (char)0x00 + e + (char)0x00 + r + (char)0x00 + + (char)0x00 + p + (char)0x00 + r + (char)0x00 + o + (char)0x00 + g + (char)0x00 + r + (char)0x00 + a + (char)0x00 + m + (char)0x00 - byte?[] check = new byte?[] { 0x52, 0x00, 0x65, 0x00, 0x67, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x43, 0x00, 0x6F, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x73, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x72, 0x00, 0x61, 0x00, 0x6D, 0x00 }; - if (fileContent.FirstPosition(check, out int position)) - return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); + // R + (char)0x00 + e + (char)0x00 + g + (char)0x00 + i + (char)0x00 + s + (char)0x00 + t + (char)0x00 + r + (char)0x00 + a + (char)0x00 + t + (char)0x00 + i + (char)0x00 + o + (char)0x00 + n + (char)0x00 + + (char)0x00 + C + (char)0x00 + o + (char)0x00 + d + (char)0x00 + e + (char)0x00 + + (char)0x00 + i + (char)0x00 + n + (char)0x00 + s + (char)0x00 + t + (char)0x00 + a + (char)0x00 + l + (char)0x00 + l + (char)0x00 + e + (char)0x00 + r + (char)0x00 + + (char)0x00 + p + (char)0x00 + r + (char)0x00 + o + (char)0x00 + g + (char)0x00 + r + (char)0x00 + a + (char)0x00 + m + (char)0x00 + new Matcher(new byte?[] + { + 0x52, 0x00, 0x65, 0x00, 0x67, 0x00, 0x69, 0x00, + 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, + 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, + 0x20, 0x00, 0x43, 0x00, 0x6F, 0x00, 0x64, 0x00, + 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x6E, 0x00, + 0x73, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6C, 0x00, + 0x6C, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, + 0x70, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x67, 0x00, + 0x72, 0x00, 0x61, 0x00, 0x6D, 0x00 + }, Utilities.GetFileVersion, "EA CdKey Registration Module"), - // R + (char)0x00 + e + (char)0x00 + g + (char)0x00 + i + (char)0x00 + s + (char)0x00 + t + (char)0x00 + r + (char)0x00 + a + (char)0x00 + t + (char)0x00 + i + (char)0x00 + o + (char)0x00 + n + (char)0x00 + + (char)0x00 + c + (char)0x00 + o + (char)0x00 + d + (char)0x00 + e + (char)0x00 + + (char)0x00 + i + (char)0x00 + n + (char)0x00 + s + (char)0x00 + t + (char)0x00 + a + (char)0x00 + l + (char)0x00 + l + (char)0x00 + e + (char)0x00 + r + (char)0x00 + + (char)0x00 + p + (char)0x00 + r + (char)0x00 + o + (char)0x00 + g + (char)0x00 + r + (char)0x00 + a + (char)0x00 + m + (char)0x00 - check = new byte?[] { 0x52, 0x00, 0x65, 0x00, 0x67, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x63, 0x00, 0x6F, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x73, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x72, 0x00, 0x61, 0x00, 0x6D, 0x00 }; - if (fileContent.FirstPosition(check, out position)) - return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); + // R + (char)0x00 + e + (char)0x00 + g + (char)0x00 + i + (char)0x00 + s + (char)0x00 + t + (char)0x00 + r + (char)0x00 + a + (char)0x00 + t + (char)0x00 + i + (char)0x00 + o + (char)0x00 + n + (char)0x00 + + (char)0x00 + c + (char)0x00 + o + (char)0x00 + d + (char)0x00 + e + (char)0x00 + + (char)0x00 + i + (char)0x00 + n + (char)0x00 + s + (char)0x00 + t + (char)0x00 + a + (char)0x00 + l + (char)0x00 + l + (char)0x00 + e + (char)0x00 + r + (char)0x00 + + (char)0x00 + p + (char)0x00 + r + (char)0x00 + o + (char)0x00 + g + (char)0x00 + r + (char)0x00 + a + (char)0x00 + m + (char)0x00 + new Matcher(new byte?[] + { + 0x52, 0x00, 0x65, 0x00, 0x67, 0x00, 0x69, 0x00, + 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, + 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, + 0x20, 0x00, 0x63, 0x00, 0x6F, 0x00, 0x64, 0x00, + 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x6E, 0x00, + 0x73, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6C, 0x00, + 0x6C, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, + 0x70, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x67, 0x00, + 0x72, 0x00, 0x61, 0x00, 0x6D, 0x00 + }, Utilities.GetFileVersion, "EA CdKey Registration Module"), - // A + (char)0x00 + b + (char)0x00 + o + (char)0x00 + u + (char)0x00 + t + (char)0x00 + + (char)0x00 + C + (char)0x00 + D + (char)0x00 + K + (char)0x00 + e + (char)0x00 + y + (char)0x00 - check = new byte?[] { 0x41, 0x00, 0x62, 0x00, 0x6F, 0x00, 0x75, 0x00, 0x74, 0x00, 0x20, 0x00, 0x43, 0x00, 0x44, 0x00, 0x4B, 0x00, 0x65, 0x00, 0x79, 0x00 }; - if (fileContent.FirstPosition(check, out position)) - return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); - - // 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 + C + (char)0x00 + D + (char)0x00 + K + (char)0x00 + e + (char)0x00 + y + (char)0x00 - 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, 0x43, 0x00, 0x44, 0x00, 0x4B, 0x00, 0x65, 0x00, 0x79, 0x00 }; - if (fileContent.FirstPosition(check, out position)) - return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); + // A + (char)0x00 + b + (char)0x00 + o + (char)0x00 + u + (char)0x00 + t + (char)0x00 + + (char)0x00 + C + (char)0x00 + D + (char)0x00 + K + (char)0x00 + e + (char)0x00 + y + (char)0x00 + new Matcher(new byte?[] + { + 0x41, 0x00, 0x62, 0x00, 0x6F, 0x00, 0x75, 0x00, + 0x74, 0x00, 0x20, 0x00, 0x43, 0x00, 0x44, 0x00, + 0x4B, 0x00, 0x65, 0x00, 0x79, 0x00 + }, Utilities.GetFileVersion, "EA CdKey Registration Module"), - // 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 + C + (char)0x00 + D + (char)0x00 + C + (char)0x00 + o + (char)0x00 + d + (char)0x00 + e + (char)0x00 - 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, 0x43, 0x00, 0x44, 0x00, 0x43, 0x00, 0x6F, 0x00, 0x64, 0x00, 0x65, 0x00 }; - if (fileContent.FirstPosition(check, out position)) - return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); - - // EReg Config Form - check = new byte?[] { 0x45, 0x52, 0x65, 0x67, 0x20, 0x43, 0x6F, 0x6E, 0x66, 0x69, 0x67, 0x20, 0x46, 0x6F, 0x72, 0x6D }; - if (fileContent.FirstPosition(check, out position)) - return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); + // 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 + C + (char)0x00 + D + (char)0x00 + K + (char)0x00 + e + (char)0x00 + y + (char)0x00 + new Matcher(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, 0x43, 0x00, 0x44, 0x00, 0x4B, 0x00, + 0x65, 0x00, 0x79, 0x00 + }, Utilities.GetFileVersion, "EA CdKey Registration Module"), - // ereg.ea-europe.com - check = new byte?[] { 0x65, 0x72, 0x65, 0x67, 0x2E, 0x65, 0x61, 0x2D, 0x65, 0x75, 0x72, 0x6F, 0x70, 0x65, 0x2E, 0x63, 0x6F, 0x6D }; - if (fileContent.FirstPosition(check, out position)) - return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); + // 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 + C + (char)0x00 + D + (char)0x00 + C + (char)0x00 + o + (char)0x00 + d + (char)0x00 + e + (char)0x00 + new Matcher(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, 0x43, 0x00, 0x44, 0x00, 0x43, 0x00, + 0x6F, 0x00, 0x64, 0x00, 0x65, 0x00 + }, Utilities.GetFileVersion, "EA CdKey Registration Module"), - // GenericEA + (char)0x00 + (char)0x00 + (char)0x00 + Activation - check = new byte?[] { 0x47, 0x65, 0x6E, 0x65, 0x72, 0x69, 0x63, 0x45, 0x41, 0x00, 0x00, 0x00, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6F, 0x6E }; - if (fileContent.FirstPosition(check, out position)) - return "EA DRM Protection" + (includePosition ? $" (Index {position})" : string.Empty); + // EReg Config Form + new Matcher(new byte?[] + { + 0x45, 0x52, 0x65, 0x67, 0x20, 0x43, 0x6F, 0x6E, + 0x66, 0x69, 0x67, 0x20, 0x46, 0x6F, 0x72, 0x6D + }, Utilities.GetFileVersion, "EA CdKey Registration Module"), - // E + (char)0x00 + A + (char)0x00 + + (char)0x00 + D + (char)0x00 + R + (char)0x00 + M + (char)0x00 + + (char)0x00 + H + (char)0x00 + e + (char)0x00 + l + (char)0x00 + p + (char)0x00 + e + (char)0x00 + r + (char)0x00 - check = new byte?[] { 0x45, 0x00, 0x41, 0x00, 0x20, 0x00, 0x44, 0x00, 0x52, 0x00, 0x4D, 0x00, 0x20, 0x00, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00, 0x65, 0x00, 0x72, 0x00 }; - if (fileContent.FirstPosition(check, out position)) - return "EA DRM Protection" + (includePosition ? $" (Index {position})" : string.Empty); + // ereg.ea-europe.com + new Matcher(new byte?[] + { + 0x65, 0x72, 0x65, 0x67, 0x2E, 0x65, 0x61, 0x2D, + 0x65, 0x75, 0x72, 0x6F, 0x70, 0x65, 0x2E, 0x63, + 0x6F, 0x6D + }, Utilities.GetFileVersion, "EA CdKey Registration Module"), - return null; + // GenericEA + (char)0x00 + (char)0x00 + (char)0x00 + Activation + new Matcher(new byte?[] + { + 0x47, 0x65, 0x6E, 0x65, 0x72, 0x69, 0x63, 0x45, + 0x41, 0x00, 0x00, 0x00, 0x41, 0x63, 0x74, 0x69, + 0x76, 0x61, 0x74, 0x69, 0x6F, 0x6E + }, "EA DRM Protection"), + + // E + (char)0x00 + A + (char)0x00 + + (char)0x00 + D + (char)0x00 + R + (char)0x00 + M + (char)0x00 + + (char)0x00 + H + (char)0x00 + e + (char)0x00 + l + (char)0x00 + p + (char)0x00 + e + (char)0x00 + r + (char)0x00 + new Matcher(new byte?[] + { + 0x45, 0x00, 0x41, 0x00, 0x20, 0x00, 0x44, 0x00, + 0x52, 0x00, 0x4D, 0x00, 0x20, 0x00, 0x48, 0x00, + 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00, 0x65, 0x00, + 0x72, 0x00 + }, "EA DRM Protection"), + }; + + return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/ImpulseReactor.cs b/BurnOutSharp/ProtectionType/ImpulseReactor.cs index 89935098..8d212b66 100644 --- a/BurnOutSharp/ProtectionType/ImpulseReactor.cs +++ b/BurnOutSharp/ProtectionType/ImpulseReactor.cs @@ -5,6 +5,7 @@ using System.Linq; namespace BurnOutSharp.ProtectionType { + // TODO: Figure out how to use GetContentMatches here public class ImpulseReactor : IContentCheck, IPathCheck { /// diff --git a/BurnOutSharp/ProtectionType/JoWooDXProt.cs b/BurnOutSharp/ProtectionType/JoWooDXProt.cs index d921353e..f6b0faff 100644 --- a/BurnOutSharp/ProtectionType/JoWooDXProt.cs +++ b/BurnOutSharp/ProtectionType/JoWooDXProt.cs @@ -3,6 +3,7 @@ using System.Linq; namespace BurnOutSharp.ProtectionType { + // TODO: Figure out how to use GetContentMatches here public class JoWooDXProt : IContentCheck { /// diff --git a/BurnOutSharp/ProtectionType/KeyLock.cs b/BurnOutSharp/ProtectionType/KeyLock.cs index c66d5715..4e88ca6f 100644 --- a/BurnOutSharp/ProtectionType/KeyLock.cs +++ b/BurnOutSharp/ProtectionType/KeyLock.cs @@ -11,7 +11,11 @@ namespace BurnOutSharp.ProtectionType var matchers = new List { // KEY-LOCK COMMAND - new Matcher(new byte?[] { 0x4B, 0x45, 0x59, 0x2D, 0x4C, 0x4F, 0x43, 0x4B, 0x20, 0x43, 0x4F, 0x4D, 0x4D, 0x41, 0x4E, 0x44 }, "Key-Lock (Dongle)"), + new Matcher(new byte?[] + { + 0x4B, 0x45, 0x59, 0x2D, 0x4C, 0x4F, 0x43, 0x4B, + 0x20, 0x43, 0x4F, 0x4D, 0x4D, 0x41, 0x4E, 0x44 + }, "Key-Lock (Dongle)"), }; return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/ProtectionType/LaserLock.cs b/BurnOutSharp/ProtectionType/LaserLock.cs index fc8226cf..8c2c4875 100644 --- a/BurnOutSharp/ProtectionType/LaserLock.cs +++ b/BurnOutSharp/ProtectionType/LaserLock.cs @@ -5,6 +5,7 @@ using System.Linq; namespace BurnOutSharp.ProtectionType { + // TODO: Figure out how to use GetContentMatches here public class LaserLock : IContentCheck, IPathCheck { /// diff --git a/BurnOutSharp/ProtectionType/MediaMaxCD3.cs b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs index 04f4b581..e66d5fb6 100644 --- a/BurnOutSharp/ProtectionType/MediaMaxCD3.cs +++ b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using BurnOutSharp.Matching; namespace BurnOutSharp.ProtectionType { @@ -10,17 +11,20 @@ namespace BurnOutSharp.ProtectionType /// public string CheckContents(string file, byte[] fileContent, bool includePosition = false) { - // Cd3Ctl - byte?[] check = new byte?[] { 0x43, 0x64, 0x33, 0x43, 0x74, 0x6C }; - if (fileContent.FirstPosition(check, out int position)) - return "MediaMax CD-3" + (includePosition ? $" (Index {position})" : string.Empty); + var matchers = new List + { + // Cd3Ctl + new Matcher(new byte?[] { 0x43, 0x64, 0x33, 0x43, 0x74, 0x6C }, "MediaMax CD-3"), - // DllInstallSbcp - check = new byte?[] { 0x44, 0x6C, 0x6C, 0x49, 0x6E, 0x73, 0x74, 0x61, 0x6C, 0x6C, 0x53, 0x62, 0x63, 0x70 }; - if (fileContent.FirstPosition(check, out position)) - return "MediaMax CD-3" + (includePosition ? $" (Index {position})" : string.Empty); + // DllInstallSbcp + new Matcher(new byte?[] + { + 0x44, 0x6C, 0x6C, 0x49, 0x6E, 0x73, 0x74, 0x61, + 0x6C, 0x6C, 0x53, 0x62, 0x63, 0x70 + }, "MediaMax CD-3"), + }; - return null; + return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/OnlineRegistration.cs b/BurnOutSharp/ProtectionType/OnlineRegistration.cs index a885a7f9..8bd36d8e 100644 --- a/BurnOutSharp/ProtectionType/OnlineRegistration.cs +++ b/BurnOutSharp/ProtectionType/OnlineRegistration.cs @@ -1,16 +1,27 @@ -namespace BurnOutSharp.ProtectionType +using System.Collections.Generic; +using BurnOutSharp.Matching; + +namespace BurnOutSharp.ProtectionType { public class OnlineRegistration : IContentCheck { /// public string CheckContents(string file, byte[] fileContent, bool includePosition = false) { - // 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 $"Executable-Based Online Registration {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); + var matchers = new List + { + // 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 + new Matcher(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 + }, Utilities.GetFileVersion, "Executable-Based Online Registration"), + }; - return null; + return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/PSXAntiModchip.cs b/BurnOutSharp/ProtectionType/PSXAntiModchip.cs index 05e72e49..96447300 100644 --- a/BurnOutSharp/ProtectionType/PSXAntiModchip.cs +++ b/BurnOutSharp/ProtectionType/PSXAntiModchip.cs @@ -13,10 +13,33 @@ namespace BurnOutSharp.ProtectionType var matchers = new List { // SOFTWARE TERMINATED\nCONSOLE MAY HAVE BEEN MODIFIED\n CALL 1-888-780-7690 - new Matcher(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)"), + new Matcher(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おそれがあります。 - new Matcher(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)"), + new Matcher(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 Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/ProtectionType/ProtectDisc.cs b/BurnOutSharp/ProtectionType/ProtectDisc.cs index 3ba011b6..247ff56e 100644 --- a/BurnOutSharp/ProtectionType/ProtectDisc.cs +++ b/BurnOutSharp/ProtectionType/ProtectDisc.cs @@ -6,6 +6,7 @@ using System.Threading; namespace BurnOutSharp.ProtectionType { + // TODO: Figure out how to use GetContentMatches here public class ProtectDisc : IContentCheck { /// diff --git a/BurnOutSharp/ProtectionType/RingPROTECH.cs b/BurnOutSharp/ProtectionType/RingPROTECH.cs index 41db49f5..e0c32466 100644 --- a/BurnOutSharp/ProtectionType/RingPROTECH.cs +++ b/BurnOutSharp/ProtectionType/RingPROTECH.cs @@ -12,7 +12,11 @@ namespace BurnOutSharp.ProtectionType var matchers = new List { // (char)0x00 + Allocator + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 - new Matcher(new byte?[] { 0x00, 0x41, 0x6C, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x6F, 0x72, 0x00, 0x00, 0x00, 0x00 }, "Ring PROTECH [Check disc for physical ring]"), + new Matcher(new byte?[] + { + 0x00, 0x41, 0x6C, 0x6C, 0x6F, 0x63, 0x61, 0x74, + 0x6F, 0x72, 0x00, 0x00, 0x00, 0x00 + }, "Ring PROTECH [Check disc for physical ring]"), }; return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/ProtectionType/SafeDisc.cs b/BurnOutSharp/ProtectionType/SafeDisc.cs index 9c2554aa..32e66c6f 100644 --- a/BurnOutSharp/ProtectionType/SafeDisc.cs +++ b/BurnOutSharp/ProtectionType/SafeDisc.cs @@ -7,6 +7,7 @@ using System.Text; namespace BurnOutSharp.ProtectionType { + // TODO: Figure out how to use GetContentMatches here public class SafeDisc : IContentCheck, IPathCheck { /// diff --git a/BurnOutSharp/ProtectionType/SafeLock.cs b/BurnOutSharp/ProtectionType/SafeLock.cs index 1cfcbf81..3dd42cea 100644 --- a/BurnOutSharp/ProtectionType/SafeLock.cs +++ b/BurnOutSharp/ProtectionType/SafeLock.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using BurnOutSharp.Matching; namespace BurnOutSharp.ProtectionType { @@ -10,12 +11,13 @@ namespace BurnOutSharp.ProtectionType /// public string CheckContents(string file, byte[] fileContent, bool includePosition = false) { - // "SafeLock" - byte?[] check = new byte?[] { 0x53, 0x61, 0x66, 0x65, 0x4C, 0x6F, 0x63, 0x6B }; - if (fileContent.FirstPosition(check, out int position)) - return "SafeLock" + (includePosition ? $" (Index {position})" : string.Empty); + var matchers = new List + { + // SafeLock + new Matcher(new byte?[] { 0x53, 0x61, 0x66, 0x65, 0x4C, 0x6F, 0x63, 0x6B }, "SafeLock"), + }; - return null; + return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/SecuROM.cs b/BurnOutSharp/ProtectionType/SecuROM.cs index e9eebc82..9afe6f1d 100644 --- a/BurnOutSharp/ProtectionType/SecuROM.cs +++ b/BurnOutSharp/ProtectionType/SecuROM.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using BurnOutSharp.Matching; namespace BurnOutSharp.ProtectionType { @@ -11,42 +12,41 @@ namespace BurnOutSharp.ProtectionType /// public string CheckContents(string file, byte[] fileContent, bool includePosition = false) { - // "AddD" + (char)0x03 + (char)0x00 + (char)0x00 + (char)0x00) - byte?[] check = new byte?[] { 0x41, 0x64, 0x64, 0x44, 0x03, 0x00, 0x00, 0x00 }; - if (fileContent.FirstPosition(check, out int position)) - return $"SecuROM {GetV4Version(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); + var matchers = new List + { + // AddD + (char)0x03 + (char)0x00 + (char)0x00 + (char)0x00) + new Matcher(new byte?[] { 0x41, 0x64, 0x64, 0x44, 0x03, 0x00, 0x00, 0x00 }, GetV4Version, "SecuROM"), - // (char)0xCA + (char)0xDD + (char)0xDD + (char)0xAC + (char)0x03 - check = new byte?[] { 0xCA, 0xDD, 0xDD, 0xAC, 0x03 }; - if (fileContent.FirstPosition(check, out position)) - return $"SecuROM {GetV5Version(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); + // (char)0xCA + (char)0xDD + (char)0xDD + (char)0xAC + (char)0x03 + new Matcher(new byte?[] { 0xCA, 0xDD, 0xDD, 0xAC, 0x03 }, GetV5Version, "SecuROM"), - // ".securom" + (char)0xE0 + (char)0xC0 - check = new byte?[] { 0x2E, 0x73, 0x65, 0x63, 0x75, 0x72, 0x6F, 0x6D, 0xE0, 0xC0 }; - if (fileContent.FirstPosition(check, out position) && position == 0) - return $"SecuROM {GetV7Version(fileContent)}" + (includePosition ? $" (Index {position})" : string.Empty); + // .securom + (char)0xE0 + (char)0xC0 + new Matcher(new byte?[] + { + 0x2E, 0x73, 0x65, 0x63, 0x75, 0x72, 0x6F, 0x6D, + 0xE0, 0xC0 + }, GetV7Version, "SecuROM"), - // ".securom" - check = new byte?[] { 0x2E, 0x73, 0x65, 0x63, 0x75, 0x72, 0x6F, 0x6D }; - if (fileContent.FirstPosition(check, out position)) - return $"SecuROM {GetV7Version(fileContent)}" + (includePosition ? $" (Index {position})" : string.Empty); + // .securom + new Matcher(new byte?[] { 0x2E, 0x73, 0x65, 0x63, 0x75, 0x72, 0x6F, 0x6D }, GetV7Version, "SecuROM"), - // "_and_play.dll" + (char)0x00 + "drm_pagui_doit" - check = new byte?[] { 0x5F, 0x61, 0x6E, 0x64, 0x5F, 0x70, 0x6C, 0x61, 0x79, 0x2E, 0x64, 0x6C, 0x6C, 0x00, 0x64, 0x72, 0x6D, 0x5F, 0x70, 0x61, 0x67, 0x75, 0x69, 0x5F, 0x64, 0x6F, 0x69, 0x74 }; - if (fileContent.FirstPosition(check, out position)) - return $"SecuROM Product Activation {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); + // _and_play.dll + (char)0x00 + drm_pagui_doit + new Matcher(new byte?[] + { + 0x5F, 0x61, 0x6E, 0x64, 0x5F, 0x70, 0x6C, 0x61, + 0x79, 0x2E, 0x64, 0x6C, 0x6C, 0x00, 0x64, 0x72, + 0x6D, 0x5F, 0x70, 0x61, 0x67, 0x75, 0x69, 0x5F, + 0x64, 0x6F, 0x69, 0x74 + }, Utilities.GetFileVersion, "SecuROM Product Activation"), - // ".cms_t" + (char)0x00 - check = new byte?[] { 0x2E, 0x63, 0x6D, 0x73, 0x5F, 0x74, 0x00 }; - if (fileContent.FirstPosition(check, out position)) - return "SecuROM 1-3" + (includePosition ? $" (Index {position})" : string.Empty); + // .cms_t + (char)0x00 + new Matcher(new byte?[] { 0x2E, 0x63, 0x6D, 0x73, 0x5F, 0x74, 0x00 }, "SecuROM 1-3"), - // ".cms_d" + (char)0x00 - check = new byte?[] { 0x2E, 0x63, 0x6D, 0x73, 0x5F, 0x64, 0x00 }; - if (fileContent.FirstPosition(check, out position)) - return "SecuROM 1-3" + (includePosition ? $" (Index {position})" : string.Empty); + // .cms_d + (char)0x00 + new Matcher(new byte?[] { 0x2E, 0x63, 0x6D, 0x73, 0x5F, 0x64, 0x00 }, "SecuROM 1-3"), + }; - return null; + return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); } /// @@ -92,7 +92,7 @@ namespace BurnOutSharp.ProtectionType return null; } - private static string GetV4Version(byte[] fileContent, int position) + public static string GetV4Version(string file, byte[] fileContent, int position) { int index = position + 8; // Begin reading after "AddD" char version = (char)fileContent[index]; @@ -112,7 +112,7 @@ namespace BurnOutSharp.ProtectionType return $"{version}.{subVersion}.{subSubVersion}.{subSubSubVersion}"; } - private static string GetV5Version(byte[] fileContent, int position) + public static string GetV5Version(string file, byte[] fileContent, int position) { int index = position + 8; // Begin reading after "ÊÝݬ" byte version = (byte)(fileContent[index] & 0x0F); @@ -145,7 +145,7 @@ namespace BurnOutSharp.ProtectionType return $"{version}.{subVersion[0]}{subVersion[1]}.{subSubVersion[0]}{subSubVersion[1]}.{subSubSubVersion[0]}{subSubSubVersion[1]}{subSubSubVersion[2]}{subSubSubVersion[3]}"; } - private static string GetV7Version(byte[] fileContent) + public static string GetV7Version(string file, byte[] fileContent, int position) { int index = 236; byte[] bytes = new ReadOnlySpan(fileContent, index, 4).ToArray(); diff --git a/BurnOutSharp/ProtectionType/SolidShield.cs b/BurnOutSharp/ProtectionType/SolidShield.cs index 93af43a6..94829c23 100644 --- a/BurnOutSharp/ProtectionType/SolidShield.cs +++ b/BurnOutSharp/ProtectionType/SolidShield.cs @@ -6,6 +6,7 @@ using System.Linq; namespace BurnOutSharp.ProtectionType { + // TODO: Figure out how to use GetContentMatches here public class SolidShield : IContentCheck, IPathCheck { /// diff --git a/BurnOutSharp/ProtectionType/StarForce.cs b/BurnOutSharp/ProtectionType/StarForce.cs index d8dc79ff..54f6f684 100644 --- a/BurnOutSharp/ProtectionType/StarForce.cs +++ b/BurnOutSharp/ProtectionType/StarForce.cs @@ -5,6 +5,7 @@ using System.Linq; namespace BurnOutSharp.ProtectionType { + // TODO: Figure out how to use GetContentMatches here public class StarForce : IContentCheck, IPathCheck { /// diff --git a/BurnOutSharp/ProtectionType/Sysiphus.cs b/BurnOutSharp/ProtectionType/Sysiphus.cs index c96d9cb9..73c0cf6d 100644 --- a/BurnOutSharp/ProtectionType/Sysiphus.cs +++ b/BurnOutSharp/ProtectionType/Sysiphus.cs @@ -1,24 +1,34 @@ -namespace BurnOutSharp.ProtectionType +using System.Collections.Generic; +using BurnOutSharp.Matching; + +namespace BurnOutSharp.ProtectionType { public class Sysiphus : IContentCheck { /// public string CheckContents(string file, byte[] fileContent, bool includePosition = false) { - // "V SUHPISYSDVD" - byte?[] check = new byte?[] { 0x56, 0x20, 0x53, 0x55, 0x48, 0x50, 0x49, 0x53, 0x59, 0x53, 0x44, 0x56, 0x44 }; - if (fileContent.FirstPosition(check, out int position)) - return $"Sysiphus DVD {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); + var matchers = new List + { + // V SUHPISYSDVD + new Matcher(new byte?[] + { + 0x56, 0x20, 0x53, 0x55, 0x48, 0x50, 0x49, 0x53, + 0x59, 0x53, 0x44, 0x56, 0x44 + }, GetVersion, "Sysiphus DVD"), - // "V SUHPISYS" - check = new byte?[] { 0x56, 0x20, 0x53, 0x55, 0x48, 0x50, 0x49, 0x53, 0x59, 0x53 }; - if (fileContent.FirstPosition(check, out position)) - return $"Sysiphus {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); + // V SUHPISYSDVD + new Matcher(new byte?[] + { + 0x56, 0x20, 0x53, 0x55, 0x48, 0x50, 0x49, 0x53, + 0x59, 0x53 + }, GetVersion, "Sysiphus"), + }; - return null; + return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); } - private static string GetVersion(byte[] fileContent, int position) + public static string GetVersion(string file, byte[] fileContent, int position) { int index = position - 3; char subVersion = (char)fileContent[index]; diff --git a/BurnOutSharp/ProtectionType/Tages.cs b/BurnOutSharp/ProtectionType/Tages.cs index 2aafcac6..03ef23e0 100644 --- a/BurnOutSharp/ProtectionType/Tages.cs +++ b/BurnOutSharp/ProtectionType/Tages.cs @@ -5,6 +5,7 @@ using System.Linq; namespace BurnOutSharp.ProtectionType { + // TODO: Figure out how to use GetContentMatches here public class Tages : IContentCheck, IPathCheck { /// diff --git a/BurnOutSharp/ProtectionType/ThreePLock.cs b/BurnOutSharp/ProtectionType/ThreePLock.cs index cfa8149f..80c63477 100644 --- a/BurnOutSharp/ProtectionType/ThreePLock.cs +++ b/BurnOutSharp/ProtectionType/ThreePLock.cs @@ -1,27 +1,34 @@ -namespace BurnOutSharp.ProtectionType +using System.Collections.Generic; +using BurnOutSharp.Matching; + +namespace BurnOutSharp.ProtectionType { public class ThreePLock : IContentCheck { /// public string CheckContents(string file, byte[] fileContent, bool includePosition = false) { - // .ldr - byte?[] check = new byte?[] { 0x2E, 0x6C, 0x64, 0x72 }; - if (fileContent.FirstPosition(check, out int position)) + var matchers = new List { - // .ldt - byte?[] check2 = new byte?[] { 0x2E, 0x6C, 0x64, 0x74 }; - if (fileContent.FirstPosition(check2, out int position2)) - return "3PLock" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); - } + new Matcher(new List + { + // .ldr + new byte?[] { 0x2E, 0x6C, 0x64, 0x72 }, - // This produced false positives in some DirectX 9.0c installer files - // "Y" + (char)0xC3 + "U" + (char)0x8B + (char)0xEC + (char)0x83 + (char)0xEC + "0SVW" - //check = new byte?[] { 0x59, 0xC3, 0x55, 0x8B, 0xEC, 0x83, 0xEC, 0x30, 0x53, 0x56, 0x57 }; - //if (fileContent.Contains(check, out position)) - // return "3PLock" + (includePosition ? $" (Index {position})" : string.Empty); + // .ldt + new byte?[] { 0x2E, 0x6C, 0x64, 0x74 }, + }, "3PLock"), - return null; + // This produced false positives in some DirectX 9.0c installer files + // "Y" + (char)0xC3 + "U" + (char)0x8B + (char)0xEC + (char)0x83 + (char)0xEC + "0SVW" + // new Matcher(new byte?[] + // { + // 0x59, 0xC3, 0x55, 0x8B, 0xEC, 0x83, 0xEC, 0x30, + // 0x53, 0x56, 0x57 + // }, "3PLock"), + }; + + return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs b/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs index f414ff2e..5d78f675 100644 --- a/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs +++ b/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs @@ -11,7 +11,15 @@ namespace BurnOutSharp.ProtectionType var matchers = new List { // 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 Matcher(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"), + new Matcher(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 Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs index 3ea53fec..69c83af4 100644 --- a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs +++ b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs @@ -7,6 +7,7 @@ using System.Threading; namespace BurnOutSharp.ProtectionType { + // TODO: Figure out how to use GetContentMatches here public class VOBProtectCDDVD : IContentCheck, IPathCheck { /// diff --git a/BurnOutSharp/ProtectionType/XCP.cs b/BurnOutSharp/ProtectionType/XCP.cs index 5eeb52f9..d803163a 100644 --- a/BurnOutSharp/ProtectionType/XCP.cs +++ b/BurnOutSharp/ProtectionType/XCP.cs @@ -18,10 +18,18 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x58, 0x43, 0x50, 0x2E, 0x44, 0x41, 0x54 }, "XCP"), // XCPPlugins.dll - new Matcher(new byte?[] { 0x58, 0x43, 0x50, 0x50, 0x6C, 0x75, 0x67, 0x69, 0x6E, 0x73, 0x2E, 0x64, 0x6C, 0x6C }, "XCP"), + new Matcher(new byte?[] + { + 0x58, 0x43, 0x50, 0x50, 0x6C, 0x75, 0x67, 0x69, + 0x6E, 0x73, 0x2E, 0x64, 0x6C, 0x6C + }, "XCP"), // XCPPhoenix.dll - new Matcher(new byte?[] { 0x58, 0x43, 0x50, 0x50, 0x68, 0x6F, 0x65, 0x6E, 0x69, 0x78, 0x2E, 0x64, 0x6C, 0x6C }, "XCP"), + new Matcher(new byte?[] + { + 0x58, 0x43, 0x50, 0x50, 0x68, 0x6F, 0x65, 0x6E, + 0x69, 0x78, 0x2E, 0x64, 0x6C, 0x6C + }, "XCP"), }; return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); diff --git a/BurnOutSharp/Utilities.cs b/BurnOutSharp/Utilities.cs index 1a3e30f7..be9caa49 100644 --- a/BurnOutSharp/Utilities.cs +++ b/BurnOutSharp/Utilities.cs @@ -321,6 +321,18 @@ namespace BurnOutSharp return fvinfo.ProductVersion.Replace(", ", "."); } + /// + /// Wrapper for GetFileVersion for use in matching + /// + /// File to check for version + /// Byte array representing the file contents + /// Last matched position in the contents + /// Version string, null on error + public static string GetFileVersion(string file, byte[] fileContent, int position) + { + return GetFileVersion(file); + } + /// /// Get the assembly version as determined by an embedded assembly manifest ///