From ca0d6954704f741a11594e183dfd8719295758b9 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 28 Sep 2019 01:51:06 -0700 Subject: [PATCH] Else-If causes some issues --- BurnOutSharp/ProtectionFind.cs | 5 ++ BurnOutSharp/ProtectionType/ActiveMARK.cs | 4 +- BurnOutSharp/ProtectionType/CDCops.cs | 2 +- BurnOutSharp/ProtectionType/JoWooDXProt.cs | 5 +- BurnOutSharp/ProtectionType/LaserLock.cs | 16 ++---- BurnOutSharp/ProtectionType/PSXAntiModchip.cs | 4 +- BurnOutSharp/ProtectionType/SafeDisc.cs | 50 +++++++++---------- BurnOutSharp/ProtectionType/SecuROM.cs | 18 ++----- BurnOutSharp/ProtectionType/SolidShield.cs | 12 ++--- BurnOutSharp/ProtectionType/StarForce.cs | 4 +- BurnOutSharp/ProtectionType/Tages.cs | 21 +++++--- .../ProtectionType/VOBProtectCDDVD.cs | 8 +-- 12 files changed, 71 insertions(+), 78 deletions(-) diff --git a/BurnOutSharp/ProtectionFind.cs b/BurnOutSharp/ProtectionFind.cs index 5e40dfc3..34e8fe43 100644 --- a/BurnOutSharp/ProtectionFind.cs +++ b/BurnOutSharp/ProtectionFind.cs @@ -248,6 +248,11 @@ namespace BurnOutSharp if (!string.IsNullOrWhiteSpace(protection)) protections.Add(protection); + // SafeDisc + protection = SafeDisc.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + // SafeDisc Lite protection = SafeDiscLite.CheckPath(path, files, isDirectory); if (!string.IsNullOrWhiteSpace(protection)) diff --git a/BurnOutSharp/ProtectionType/ActiveMARK.cs b/BurnOutSharp/ProtectionType/ActiveMARK.cs index a66063e8..8c59cf45 100644 --- a/BurnOutSharp/ProtectionType/ActiveMARK.cs +++ b/BurnOutSharp/ProtectionType/ActiveMARK.cs @@ -5,11 +5,9 @@ public static string CheckContents(string fileContent) { if (fileContent.Contains("TMSAMVOF")) - { return "ActiveMARK"; - } - else if (fileContent.Contains(" " + (char)0xC2 + (char)0x16 + (char)0x00 + (char)0xA8 + (char)0xC1 + (char)0x16 + if (fileContent.Contains(" " + (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)) { diff --git a/BurnOutSharp/ProtectionType/CDCops.cs b/BurnOutSharp/ProtectionType/CDCops.cs index 3ff45089..d9d7c12e 100644 --- a/BurnOutSharp/ProtectionType/CDCops.cs +++ b/BurnOutSharp/ProtectionType/CDCops.cs @@ -13,7 +13,7 @@ namespace BurnOutSharp.ProtectionType if ((position = fileContent.IndexOf("CD-Cops, ver. ")) > -1) return "CD-Cops " + GetVersion(file, position); - else if (fileContent.Contains(".grand" + (char)0x00)) + if (fileContent.Contains(".grand" + (char)0x00)) return "CD-Cops"; return null; diff --git a/BurnOutSharp/ProtectionType/JoWooDXProt.cs b/BurnOutSharp/ProtectionType/JoWooDXProt.cs index 80dfa1d5..5b820bc9 100644 --- a/BurnOutSharp/ProtectionType/JoWooDXProt.cs +++ b/BurnOutSharp/ProtectionType/JoWooDXProt.cs @@ -18,10 +18,9 @@ namespace BurnOutSharp.ProtectionType return "JoWooD X-Prot v1"; } } - else if (fileContent.Contains("@HC09 ")) - { + + if (fileContent.Contains("@HC09 ")) return "JoWooD X-Prot v2"; - } return null; } diff --git a/BurnOutSharp/ProtectionType/LaserLock.cs b/BurnOutSharp/ProtectionType/LaserLock.cs index 68d264a0..bec29a9c 100644 --- a/BurnOutSharp/ProtectionType/LaserLock.cs +++ b/BurnOutSharp/ProtectionType/LaserLock.cs @@ -18,29 +18,23 @@ namespace BurnOutSharp.ProtectionType return "LaserLock " + GetVersion(fileContent, position) + " " + GetBuild(fileContent, true); } - else if (fileContent.Contains("Packed by SPEEnc V2 Asterios Parlamentas.PE")) - { + if (fileContent.Contains("Packed by SPEEnc V2 Asterios Parlamentas.PE")) return "LaserLock Marathon " + GetBuild(fileContent, false); - } - else if ((position = fileContent.IndexOf("GetModuleHandleA" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + if ((position = fileContent.IndexOf("GetModuleHandleA" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "GetProcAddress" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "LoadLibraryA" + (char)0x00 + (char)0x00 + "KERNEL32.dll" + (char)0x00 + "ëy" + (char)0x01 + "SNIF")) > -1) { return "LaserLock " + GetVersion(fileContent, --position) + " " + GetBuild(fileContent, false); } - else if (Path.GetFileName(file) == "NOMOUSE.SP") - { + if (Path.GetFileName(file) == "NOMOUSE.SP") return "LaserLock " + GetVersion16Bit(file); - } - else if (fileContent.Contains(":\\LASERLOK\\LASERLOK.IN" + (char)0x00 + "C:\\NOMOUSE.SP")) - { + if (fileContent.Contains(":\\LASERLOK\\LASERLOK.IN" + (char)0x00 + "C:\\NOMOUSE.SP")) return "LaserLock 3"; - } - else if (fileContent.Contains("LASERLOK_INIT" + (char)0xC + "LASERLOK_RUN" + (char)0xE + "LASERLOK_CHECK" + if (fileContent.Contains("LASERLOK_INIT" + (char)0xC + "LASERLOK_RUN" + (char)0xE + "LASERLOK_CHECK" + (char)0xF + "LASERLOK_CHECK2" + (char)0xF + "LASERLOK_CHECK3")) { return "LaserLock 5"; diff --git a/BurnOutSharp/ProtectionType/PSXAntiModchip.cs b/BurnOutSharp/ProtectionType/PSXAntiModchip.cs index 1ce4c55e..e2402e56 100644 --- a/BurnOutSharp/ProtectionType/PSXAntiModchip.cs +++ b/BurnOutSharp/ProtectionType/PSXAntiModchip.cs @@ -8,9 +8,11 @@ namespace BurnOutSharp.ProtectionType { public static string CheckContents(string file, string fileContent) { + // TODO: Detect Red Hand protection if (fileContent.Contains(" SOFTWARE TERMINATED\nCONSOLE MAY HAVE BEEN MODIFIED\n CALL 1-888-780-7690")) return "PlayStation Anti-modchip (English)"; - else if (fileContent.Contains("強制終了しました。\n本体が改造されている\nおそれがあります。")) + + if (fileContent.Contains("強制終了しました。\n本体が改造されている\nおそれがあります。")) return "PlayStation Anti-modchip (Japanese)"; return null; diff --git a/BurnOutSharp/ProtectionType/SafeDisc.cs b/BurnOutSharp/ProtectionType/SafeDisc.cs index 8c4d0c25..2331b8d5 100644 --- a/BurnOutSharp/ProtectionType/SafeDisc.cs +++ b/BurnOutSharp/ProtectionType/SafeDisc.cs @@ -7,6 +7,31 @@ namespace BurnOutSharp.ProtectionType { public class SafeDisc { + public static string CheckContents(string file, string fileContent) + { + int position; + if ((position = fileContent.IndexOf("BoG_ *90.0&!! Yy>")) > -1) + { + if (fileContent.IndexOf("product activation library") > 0) + return "SafeCast " + GetVersion(file, position); + else + return "SafeDisc " + GetVersion(file, position); + } + + if (fileContent.Contains((char)0x00 + (char)0x00 + "BoG_") + || fileContent.Contains("stxt774") + || fileContent.Contains("stxt371")) + { + string version = EVORE.SearchSafeDiscVersion(file); + if (version.Length > 0) + return "SafeDisc " + version; + + return "SafeDisc 3.20-4.xx (version removed)"; + } + + return null; + } + public static string CheckPath(string path, IEnumerable files, bool isDirectory) { if (isDirectory) @@ -70,31 +95,6 @@ namespace BurnOutSharp.ProtectionType return null; } - public static string CheckContents(string file, string fileContent) - { - int position; - if ((position = fileContent.IndexOf("BoG_ *90.0&!! Yy>")) > -1) - { - if (fileContent.IndexOf("product activation library") > 0) - return "SafeCast " + GetVersion(file, position); - else - return "SafeDisc " + GetVersion(file, position); - } - - if (fileContent.Contains((char)0x00 + (char)0x00 + "BoG_") - || fileContent.Contains("stxt774") - || fileContent.Contains("stxt371")) - { - string version = EVORE.SearchSafeDiscVersion(file); - if (version.Length > 0) - return "SafeDisc " + version; - - return "SafeDisc 3.20-4.xx (version removed)"; - } - - return null; - } - private static string GetDPlayerXVersion(string file) { FileInfo fi = new FileInfo(file); diff --git a/BurnOutSharp/ProtectionType/SecuROM.cs b/BurnOutSharp/ProtectionType/SecuROM.cs index 44440401..327e17eb 100644 --- a/BurnOutSharp/ProtectionType/SecuROM.cs +++ b/BurnOutSharp/ProtectionType/SecuROM.cs @@ -11,32 +11,24 @@ namespace BurnOutSharp.ProtectionType { int position; if ((position = fileContent.IndexOf("AddD" + (char)0x03 + (char)0x00 + (char)0x00 + (char)0x00)) > -1) - { return "SecuROM " + GetV4Version(file, position); - } - else if ((position = fileContent.IndexOf("" + (char)0xCA + (char)0xDD + (char)0xDD + (char)0xAC + (char)0x03)) > -1) - { + if ((position = fileContent.IndexOf("" + (char)0xCA + (char)0xDD + (char)0xDD + (char)0xAC + (char)0x03)) > -1) return "SecuROM " + GetV5Version(file, position); - } - else if (fileContent.Contains(".securom") + if (fileContent.Contains(".securom") || fileContent.StartsWith(".securom" + (char)0xE0 + (char)0xC0)) { return "SecuROM " + GetV7Version(file); } - else if (fileContent.Contains("_and_play.dll" + (char)0x00 + "drm_pagui_doit")) - { + if (fileContent.Contains("_and_play.dll" + (char)0x00 + "drm_pagui_doit")) return "SecuROM Product Activation " + Utilities.GetFileVersion(file); - } - else if (fileContent.Contains("_and_play.dll" + (char)0x00 + "drm_pagui_doit")) - { + if (fileContent.Contains("_and_play.dll" + (char)0x00 + "drm_pagui_doit")) return "SecuROM Product Activation " + Utilities.GetFileVersion(file); - } - else if (fileContent.Contains(".cms_t" + (char)0x00) + if (fileContent.Contains(".cms_t" + (char)0x00) || fileContent.Contains(".cms_d" + (char)0x00)) { return "SecuROM 1-3"; diff --git a/BurnOutSharp/ProtectionType/SolidShield.cs b/BurnOutSharp/ProtectionType/SolidShield.cs index 7b81c0cf..cb9bb338 100644 --- a/BurnOutSharp/ProtectionType/SolidShield.cs +++ b/BurnOutSharp/ProtectionType/SolidShield.cs @@ -17,7 +17,7 @@ namespace BurnOutSharp.ProtectionType return "SolidShield " + Utilities.GetFileVersion(file); } - else if (fileContent.Contains("S" + (char)0x00 + "o" + (char)0x00 + "l" + (char)0x00 + "i" + (char)0x00 + "d" + (char)0x00 + if (fileContent.Contains("S" + (char)0x00 + "o" + (char)0x00 + "l" + (char)0x00 + "i" + (char)0x00 + "d" + (char)0x00 + "s" + (char)0x00 + "h" + (char)0x00 + "i" + (char)0x00 + "e" + (char)0x00 + "l" + (char)0x00 + "d" + (char)0x00 + " " + (char)0x00 + "L" + (char)0x00 + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y") @@ -32,7 +32,7 @@ namespace BurnOutSharp.ProtectionType return "SolidShield Core.dll " + Utilities.GetFileVersion(file); } - else if ((position = fileContent.IndexOf("" + (char)0xEF + (char)0xBE + (char)0xAD + (char)0xDE)) > -1) + if ((position = fileContent.IndexOf("" + (char)0xEF + (char)0xBE + (char)0xAD + (char)0xDE)) > -1) { var id1 = fileContent.Substring(position + 5, 3); var id2 = fileContent.Substring(position + 16, 4); @@ -43,7 +43,7 @@ namespace BurnOutSharp.ProtectionType return "SolidShield 2 (SolidShield v2 EXE Wrapper)"; // TODO: Verify against other SolidShield 2 discs } - else if (fileContent.Contains("A" + (char)0x00 + "c" + (char)0x00 + "t" + (char)0x00 + "i" + (char)0x00 + "v" + (char)0x00 + if (fileContent.Contains("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 + " " + (char)0x00 + "M" + (char)0x00 + "a" + (char)0x00 + "n" + (char)0x00 + "a" + (char)0x00 + "g" + (char)0x00 + "e" + (char)0x00 + "r")) { @@ -52,7 +52,7 @@ namespace BurnOutSharp.ProtectionType return "SolidShield Activation Manager Module " + Utilities.GetFileVersion(file); } - else if ((position = fileContent.IndexOf("" + (char)0xAD + (char)0xDE + (char)0xFE + (char)0xCA)) > -1) + if ((position = fileContent.IndexOf("" + (char)0xAD + (char)0xDE + (char)0xFE + (char)0xCA)) > -1) { if ((fileContent[position + 3] == (char)0x04 || fileContent[position + 3] == (char)0x05) && fileContent.Substring(position + 4, 3) == "" + (char)0x00 + (char)0x00 + (char)0x00 @@ -81,12 +81,12 @@ namespace BurnOutSharp.ProtectionType } } - else if ((position = fileContent.IndexOf("Solidshield")) > 0) + if ((position = fileContent.IndexOf("Solidshield")) > 0) { return "SolidShield " + GetVersion(file, position); } - else if (fileContent.Contains("B" + (char)0x00 + "I" + (char)0x00 + "N" + (char)0x00 + (char)0x7 + (char)0x00 + + if (fileContent.Contains("B" + (char)0x00 + "I" + (char)0x00 + "N" + (char)0x00 + (char)0x7 + (char)0x00 + "I" + (char)0x00 + "D" + (char)0x00 + "R" + (char)0x00 + "_" + (char)0x00 + "S" + (char)0x00 + "G" + (char)0x00 + "T" + (char)0x0)) { diff --git a/BurnOutSharp/ProtectionType/StarForce.cs b/BurnOutSharp/ProtectionType/StarForce.cs index 07f89e45..d7d7ba47 100644 --- a/BurnOutSharp/ProtectionType/StarForce.cs +++ b/BurnOutSharp/ProtectionType/StarForce.cs @@ -26,13 +26,13 @@ namespace BurnOutSharp.ProtectionType return "StarForce " + Utilities.GetFileVersion(file); } - else if (fileContent.Contains(".sforce") + if (fileContent.Contains(".sforce") || fileContent.Contains(".brick")) { return "StarForce 3-5"; } - else if (fileContent.Contains("P" + (char)0x00 + "r" + (char)0x00 + "o" + (char)0x00 + "t" + (char)0x00 + "e" + (char)0x00 + if (fileContent.Contains("P" + (char)0x00 + "r" + (char)0x00 + "o" + (char)0x00 + "t" + (char)0x00 + "e" + (char)0x00 + "c" + (char)0x00 + "t" + (char)0x00 + "e" + (char)0x00 + "d" + (char)0x00 + " " + (char)0x00 + "M" + (char)0x00 + "o" + (char)0x00 + "d" + (char)0x00 + "u" + (char)0x00 + "l" + (char)0x00 + "e")) { diff --git a/BurnOutSharp/ProtectionType/Tages.cs b/BurnOutSharp/ProtectionType/Tages.cs index 62c658bd..06574356 100644 --- a/BurnOutSharp/ProtectionType/Tages.cs +++ b/BurnOutSharp/ProtectionType/Tages.cs @@ -25,27 +25,34 @@ namespace BurnOutSharp.ProtectionType { if (isDirectory) { + List protections = new List(); + // TODO: Verify if these are OR or AND if (files.Count(f => Path.GetFileName(f).Equals("Tages.dll", StringComparison.OrdinalIgnoreCase)) > 0 || files.Count(f => Path.GetFileName(f).Equals("Wave.aif", StringComparison.OrdinalIgnoreCase)) > 0) { - return "TAGES"; + protections.Add("TAGES"); } - else if (files.Count(f => Path.GetFileName(f).Equals("tagesclient.exe", StringComparison.OrdinalIgnoreCase)) > 0) + if (files.Count(f => Path.GetFileName(f).Equals("tagesclient.exe", StringComparison.OrdinalIgnoreCase)) > 0) { string file = files.First(f => Path.GetFileName(f).Equals("tagesclient.exe", StringComparison.OrdinalIgnoreCase)); - return "TAGES Activation Client " + Utilities.GetFileVersion(file); + protections.Add("TAGES Activation Client " + Utilities.GetFileVersion(file)); } - else if (files.Count(f => Path.GetFileName(f).Equals("TagesSetup.exe", StringComparison.OrdinalIgnoreCase)) > 0) + if (files.Count(f => Path.GetFileName(f).Equals("TagesSetup.exe", StringComparison.OrdinalIgnoreCase)) > 0) { string file = files.First(f => Path.GetFileName(f).Equals("TagesSetup.exe", StringComparison.OrdinalIgnoreCase)); - return "TAGES Setup " + Utilities.GetFileVersion(file); + protections.Add("TAGES Setup " + Utilities.GetFileVersion(file)); } - else if (files.Count(f => Path.GetFileName(f).Equals("TagesSetup_x64.exe", StringComparison.OrdinalIgnoreCase)) > 0) + if (files.Count(f => Path.GetFileName(f).Equals("TagesSetup_x64.exe", StringComparison.OrdinalIgnoreCase)) > 0) { string file = files.First(f => Path.GetFileName(f).Equals("TagesSetup_x64.exe", StringComparison.OrdinalIgnoreCase)); - return "TAGES Setup " + Utilities.GetFileVersion(file); + protections.Add("TAGES Setup " + Utilities.GetFileVersion(file)); } + + if (protections.Count() == 0) + return null; + else + return string.Join(", ", protections); } else { diff --git a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs index 5513f9f1..b15522fb 100644 --- a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs +++ b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs @@ -11,11 +11,9 @@ namespace BurnOutSharp.ProtectionType { int position; if ((position = fileContent.IndexOf("VOB ProtectCD")) > -1) - { return "VOB ProtectCD/DVD " + GetOldVersion(file, --position); // TODO: Verify this subtract - } - else if ((position = fileContent.IndexOf("DCP-BOV" + (char)0x00 + (char)0x00)) > -1) + if ((position = fileContent.IndexOf("DCP-BOV" + (char)0x00 + (char)0x00)) > -1) { string version = GetVersion(file, --position); // TODO: Verify this subtract if (version.Length > 0) @@ -36,10 +34,8 @@ namespace BurnOutSharp.ProtectionType return "VOB ProtectCD/DVD 5.9-6.0" + GetBuild(file, position); } - else if (fileContent.Contains(".vob.pcd")) - { + if (fileContent.Contains(".vob.pcd")) return "VOB ProtectCD"; - } return null; }