From c18e9b353823ceef93646d7b94f3d4d5c1dcbb25 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 28 Oct 2020 11:13:26 -0700 Subject: [PATCH] Combine EA protection checks, add/fix reg checks --- BurnOutSharp/FileType/Executable.cs | 7 +------ BurnOutSharp/ProtectionType/EACdKey.cs | 15 --------------- BurnOutSharp/ProtectionType/ElectronicArts.cs | 17 ++++++++++++++++- 3 files changed, 17 insertions(+), 22 deletions(-) delete mode 100644 BurnOutSharp/ProtectionType/EACdKey.cs diff --git a/BurnOutSharp/FileType/Executable.cs b/BurnOutSharp/FileType/Executable.cs index 63d26644..9d84024f 100644 --- a/BurnOutSharp/FileType/Executable.cs +++ b/BurnOutSharp/FileType/Executable.cs @@ -128,13 +128,8 @@ namespace BurnOutSharp.FileType if (!string.IsNullOrWhiteSpace(protection)) protections.Add(protection); - // EA CdKey Registration Module - protection = EACdKey.CheckContents(fileContent, includePosition); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - // EA Protections - protection = ElectronicArts.CheckContents(fileContent, includePosition); + protection = ElectronicArts.CheckContents(file, fileContent, includePosition); if (!string.IsNullOrWhiteSpace(protection)) protections.Add(protection); diff --git a/BurnOutSharp/ProtectionType/EACdKey.cs b/BurnOutSharp/ProtectionType/EACdKey.cs deleted file mode 100644 index e9e492f4..00000000 --- a/BurnOutSharp/ProtectionType/EACdKey.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace BurnOutSharp.ProtectionType -{ - public class EACdKey - { - public static string CheckContents(byte[] fileContent, bool includePosition = false) - { - // "ereg.ea-europe.com" - byte[] check = new byte[] { 0x65, 0x72, 0x65, 0x67, 0x2E, 0x65, 0x61, 0x2D, 0x65, 0x75, 0x72, 0x6F, 0x70, 0x65, 0x2E, 0x63, 0x6F, 0x6D }; - if (fileContent.Contains(check, out int position)) - return "EA CdKey Registration Module" + (includePosition ? $" (Index {position})" : string.Empty); - - return null; - } - } -} diff --git a/BurnOutSharp/ProtectionType/ElectronicArts.cs b/BurnOutSharp/ProtectionType/ElectronicArts.cs index a62847a1..dfe10b5f 100644 --- a/BurnOutSharp/ProtectionType/ElectronicArts.cs +++ b/BurnOutSharp/ProtectionType/ElectronicArts.cs @@ -3,13 +3,28 @@ public class ElectronicArts { // TODO: Verify this doesn't over-match - public static string CheckContents(byte[] fileContent, bool includePosition = false) + public static 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); + // 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 + 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 }; + if (fileContent.Contains(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 + 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 }; + if (fileContent.Contains(check, out position)) + return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); + + // 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.Contains(check, out position)) + return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); + // 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.Contains(check, out position))