From aebc139d52a2c703cc8bb743a2f46e97e5bac4fc Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 20 Feb 2021 22:13:48 -0800 Subject: [PATCH] I lied, keep it separate --- BurnOutSharp/FileType/Executable.cs | 5 +++ BurnOutSharp/ProtectionType/ElectronicArts.cs | 28 +-------------- BurnOutSharp/ProtectionType/Origin.cs | 36 +++++++++++++++++++ BurnOutSharp/Scanner.cs | 10 +++--- 4 files changed, 47 insertions(+), 32 deletions(-) create mode 100644 BurnOutSharp/ProtectionType/Origin.cs diff --git a/BurnOutSharp/FileType/Executable.cs b/BurnOutSharp/FileType/Executable.cs index 7f5638a0..26f5e340 100644 --- a/BurnOutSharp/FileType/Executable.cs +++ b/BurnOutSharp/FileType/Executable.cs @@ -171,6 +171,11 @@ namespace BurnOutSharp.FileType if (!string.IsNullOrWhiteSpace(protection)) Utilities.AppendToDictionary(protections, file, protection); + // Origin + protection = Origin.CheckContents(fileContent, scanner.IncludePosition); + if (!string.IsNullOrWhiteSpace(protection)) + Utilities.AppendToDictionary(protections, file, protection); + // ProtectDisc protection = ProtectDisc.CheckContents(file, fileContent, scanner.IncludePosition); if (!string.IsNullOrWhiteSpace(protection)) diff --git a/BurnOutSharp/ProtectionType/ElectronicArts.cs b/BurnOutSharp/ProtectionType/ElectronicArts.cs index 2280172d..7ce5a36c 100644 --- a/BurnOutSharp/ProtectionType/ElectronicArts.cs +++ b/BurnOutSharp/ProtectionType/ElectronicArts.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace BurnOutSharp.ProtectionType +namespace BurnOutSharp.ProtectionType { public class ElectronicArts { @@ -48,27 +43,6 @@ namespace BurnOutSharp.ProtectionType if (fileContent.Contains(check, out position)) return "EA DRM Protection" + (includePosition ? $" (Index {position})" : string.Empty); - // 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 - 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.Contains(check, out position)) - return "Origin" + (includePosition ? $" (Index {position})" : string.Empty); - - return null; - } - - public static string CheckPath(string path, IEnumerable files, bool isDirectory) - { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("OriginSetup.exe", StringComparison.OrdinalIgnoreCase))) - return "Origin"; - } - else - { - if (Path.GetFileName(path).Equals("OriginSetup.exe", StringComparison.OrdinalIgnoreCase)) - return "Origin"; - } - return null; } } diff --git a/BurnOutSharp/ProtectionType/Origin.cs b/BurnOutSharp/ProtectionType/Origin.cs new file mode 100644 index 00000000..ce9b8e38 --- /dev/null +++ b/BurnOutSharp/ProtectionType/Origin.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class Origin + { + public static string CheckContents(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.Contains(check, out int position)) + return "Origin" + (includePosition ? $" (Index {position})" : string.Empty); + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Any(f => Path.GetFileName(f).Equals("OriginSetup.exe", StringComparison.OrdinalIgnoreCase))) + return "Origin"; + } + else + { + if (Path.GetFileName(path).Equals("OriginSetup.exe", StringComparison.OrdinalIgnoreCase)) + return "Origin"; + } + + return null; + } + } +} diff --git a/BurnOutSharp/Scanner.cs b/BurnOutSharp/Scanner.cs index 5c728901..48e7412c 100644 --- a/BurnOutSharp/Scanner.cs +++ b/BurnOutSharp/Scanner.cs @@ -253,11 +253,6 @@ namespace BurnOutSharp if (!string.IsNullOrWhiteSpace(protection)) protections.Add(protection); - // EA Protections - protection = ElectronicArts.CheckPath(path, files, isDirectory); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - // FreeLock protection = FreeLock.CheckPath(path, files, isDirectory); if (!string.IsNullOrWhiteSpace(protection)) @@ -303,6 +298,11 @@ namespace BurnOutSharp if (!string.IsNullOrWhiteSpace(protection)) protections.Add(protection); + // Origin + protection = Origin.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + // Protect DVD-Video protection = ProtectDVDVideo.CheckPath(path, files, isDirectory); if (!string.IsNullOrWhiteSpace(protection))