From a2888e3371360d1ae22a143de1d703631e411338 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 19 Mar 2021 15:41:49 -0700 Subject: [PATCH] Split IPathCheck method --- BurnOutSharp/IPathCheck.cs | 16 ++- BurnOutSharp/ProtectionType/AACS.cs | 61 ++++++---- BurnOutSharp/ProtectionType/AlphaDVD.cs | 23 ++-- BurnOutSharp/ProtectionType/BD+.cs | 67 ----------- BurnOutSharp/ProtectionType/BDPlus.cs | 68 +++++++++++ BurnOutSharp/ProtectionType/Bitpool.cs | 23 ++-- BurnOutSharp/ProtectionType/ByteShield.cs | 31 ++--- BurnOutSharp/ProtectionType/CDCops.cs | 43 +++---- BurnOutSharp/ProtectionType/CDLock.cs | 23 ++-- BurnOutSharp/ProtectionType/CDProtector.cs | 41 +++---- BurnOutSharp/ProtectionType/CDX.cs | 37 +++--- .../ProtectionType/CactusDataShield.cs | 55 ++++----- BurnOutSharp/ProtectionType/CopyKiller.cs | 28 ++--- BurnOutSharp/ProtectionType/DVDCrypt.cs | 23 ++-- .../ProtectionType/DVDMoviePROTECT.cs | 11 +- BurnOutSharp/ProtectionType/DiscGuard.cs | 34 +++--- BurnOutSharp/ProtectionType/FreeLock.cs | 23 ++-- BurnOutSharp/ProtectionType/GFWL.cs | 23 ++-- .../ProtectionType/HexalockAutoLock.cs | 37 +++--- BurnOutSharp/ProtectionType/ImpulseReactor.cs | 21 ++-- BurnOutSharp/ProtectionType/IndyVCD.cs | 29 ++--- BurnOutSharp/ProtectionType/Key2AudioXS.cs | 29 ++--- BurnOutSharp/ProtectionType/LaserLock.cs | 61 +++++----- BurnOutSharp/ProtectionType/MediaCloQ.cs | 23 ++-- BurnOutSharp/ProtectionType/MediaMaxCD3.cs | 23 ++-- BurnOutSharp/ProtectionType/Origin.cs | 23 ++-- .../ProtectionType/ProtectDVDVideo.cs | 11 +- BurnOutSharp/ProtectionType/SafeCast.cs | 23 ++-- BurnOutSharp/ProtectionType/SafeDisc.cs | 113 +++++++++--------- BurnOutSharp/ProtectionType/SafeDiscLite.cs | 23 ++-- BurnOutSharp/ProtectionType/SafeLock.cs | 33 ++--- BurnOutSharp/ProtectionType/SecuROM.cs | 65 +++++----- BurnOutSharp/ProtectionType/SmartE.cs | 29 ++--- BurnOutSharp/ProtectionType/SoftLock.cs | 29 ++--- BurnOutSharp/ProtectionType/SolidShield.cs | 37 +++--- BurnOutSharp/ProtectionType/StarForce.cs | 29 ++--- BurnOutSharp/ProtectionType/Steam.cs | 39 +++--- .../ProtectionType/TZCopyProtector.cs | 23 ++-- BurnOutSharp/ProtectionType/Tages.cs | 95 ++++++++------- BurnOutSharp/ProtectionType/Uplay.cs | 23 ++-- .../ProtectionType/VOBProtectCDDVD.cs | 23 ++-- BurnOutSharp/ProtectionType/WTMCDProtect.cs | 37 +++--- BurnOutSharp/ProtectionType/Winlock.cs | 23 ++-- BurnOutSharp/ProtectionType/XCP.cs | 45 +++---- BurnOutSharp/ProtectionType/Zzxzz.cs | 29 ++--- BurnOutSharp/Scanner.cs | 8 +- 46 files changed, 839 insertions(+), 774 deletions(-) delete mode 100644 BurnOutSharp/ProtectionType/BD+.cs create mode 100644 BurnOutSharp/ProtectionType/BDPlus.cs diff --git a/BurnOutSharp/IPathCheck.cs b/BurnOutSharp/IPathCheck.cs index 7638bb07..4fd8c80b 100644 --- a/BurnOutSharp/IPathCheck.cs +++ b/BurnOutSharp/IPathCheck.cs @@ -5,12 +5,18 @@ namespace BurnOutSharp public interface IPathCheck { /// - /// Check a path for protections based on file and directory names + /// Check a file path for protections based on path name /// /// Path to check for protection indicators - /// True if the path represents a directory, false otherwise - /// Enumerable of strings representing files in a directory if the path is a directory, assumed null otherwise - /// String containing any protections found in the path - string CheckPath(string path, bool isDirectory, IEnumerable files); + /// Enumerable of strings representing files in a directory + /// This can do some limited content checking as well, but it's suggested to use IContentCheck instead, if possible + string CheckDirectoryPath(string path, IEnumerable files); + + /// + /// Check a file path for protections based on path name + /// + /// Path to check for protection indicators + /// This can do some limited content checking as well, but it's suggested to use IContentCheck instead, if possible + string CheckFilePath(string path); } } diff --git a/BurnOutSharp/ProtectionType/AACS.cs b/BurnOutSharp/ProtectionType/AACS.cs index 717879f1..db1df395 100644 --- a/BurnOutSharp/ProtectionType/AACS.cs +++ b/BurnOutSharp/ProtectionType/AACS.cs @@ -8,40 +8,49 @@ namespace BurnOutSharp.ProtectionType public class AACS : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // HD-DVD + if (files.Any(f => f.Contains(Path.Combine("AACS", "MKBROM.AACS")))) { - if (files.Any(f => f.Contains(Path.Combine("AACS", "MKBROM.AACS")))) - { - string file = files.FirstOrDefault(f => Path.GetFileName(f).Equals("MKBROM.AACS", StringComparison.OrdinalIgnoreCase)); - int? version = GetVersion(file); - return (version == null ? "AACS (Unknown Version)" : $"AACS Version {version}"); - } - if (files.Any(f => f.Contains(Path.Combine("AACS", "MKB_RO.inf")))) - { - string file = files.FirstOrDefault(f => Path.GetFileName(f).Equals("MKB_RO.inf", StringComparison.OrdinalIgnoreCase)); - int? version = GetVersion(file); - return (version == null ? "AACS (Unknown Version)" : $"AACS Version {version}"); - } + string file = files.FirstOrDefault(f => Path.GetFileName(f).Equals("MKBROM.AACS", StringComparison.OrdinalIgnoreCase)); + int? version = GetVersion(file); + return version == null ? "AACS (Unknown Version)" : $"AACS Version {version}"; } - else + + // BD-ROM + if (files.Any(f => f.Contains(Path.Combine("AACS", "MKB_RO.inf")))) { - string filename = Path.GetFileName(path); - if (filename.Equals("MKBROM.AACS", StringComparison.OrdinalIgnoreCase)) - { - int? version = GetVersion(path); - return (version == null ? "AACS (Unknown Version)" : $"AACS Version {version}"); - } - if (filename.Equals("MKB_RO.inf", StringComparison.OrdinalIgnoreCase)) - { - int? version = GetVersion(path); - return (version == null ? "AACS (Unknown Version)" : $"AACS Version {version}"); - } + string file = files.FirstOrDefault(f => Path.GetFileName(f).Equals("MKB_RO.inf", StringComparison.OrdinalIgnoreCase)); + int? version = GetVersion(file); + return version == null ? "AACS (Unknown Version)" : $"AACS Version {version}"; } return null; } + + /// + public string CheckFilePath(string path) + { + string filename = Path.GetFileName(path); + + // HD-DVD + if (filename.Equals("MKBROM.AACS", StringComparison.OrdinalIgnoreCase)) + { + int? version = GetVersion(path); + return version == null ? "AACS (Unknown Version)" : $"AACS Version {version}"; + } + + // BD-ROM + if (filename.Equals("MKB_RO.inf", StringComparison.OrdinalIgnoreCase)) + { + int? version = GetVersion(path); + return version == null ? "AACS (Unknown Version)" : $"AACS Version {version}"; + } + + return null; + } + private static int? GetVersion(string path) { if (!File.Exists(path)) diff --git a/BurnOutSharp/ProtectionType/AlphaDVD.cs b/BurnOutSharp/ProtectionType/AlphaDVD.cs index 3f4ffca0..13d19478 100644 --- a/BurnOutSharp/ProtectionType/AlphaDVD.cs +++ b/BurnOutSharp/ProtectionType/AlphaDVD.cs @@ -8,20 +8,21 @@ namespace BurnOutSharp.ProtectionType public class AlphaDVD : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("PlayDVD.exe", StringComparison.OrdinalIgnoreCase))) - return "Alpha-DVD"; - } - else - { - if (Path.GetFileName(path).Equals("PlayDVD.exe", StringComparison.OrdinalIgnoreCase)) - return "Alpha-DVD"; - } + if (files.Any(f => Path.GetFileName(f).Equals("PlayDVD.exe", StringComparison.OrdinalIgnoreCase))) + return "Alpha-DVD"; return null; } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("PlayDVD.exe", StringComparison.OrdinalIgnoreCase)) + return "Alpha-DVD"; + + return null; + } } } diff --git a/BurnOutSharp/ProtectionType/BD+.cs b/BurnOutSharp/ProtectionType/BD+.cs deleted file mode 100644 index 0c5c81e5..00000000 --- a/BurnOutSharp/ProtectionType/BD+.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace BurnOutSharp.ProtectionType -{ - public class BDPlus : IPathCheck - { - /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) - { - // Multiple .svm files should always be present, but as far as I can tell, 00000.svm is the first one made and should be present no matter what. - if (isDirectory) - { - if (files.Any(f => f.Contains(Path.Combine("BDSVM", "00000.svm"))) - && files.Any(f => f.Contains(Path.Combine("BDSVM", "BACKUP", "00000.svm")))) - { - string file = files.FirstOrDefault(f => Path.GetFileName(f).Equals("00000.svm", StringComparison.OrdinalIgnoreCase)); - string version = GetVersion(file); - return (version == null ? "BD+ (Unknown Version)" : $"BD+ Version {version}"); - } - } - else - { - string filename = Path.GetFileName(path); - if (filename.Equals("00000.svm", StringComparison.OrdinalIgnoreCase)) - { - string version = GetVersion(path); - return (version == null ? "BD+ (Unknown Version)" : $"BD+ Version {version}"); - } - } - return null; - } - - // Version detection logic from libbdplus was used to implement this - private static string GetVersion(string path) - { - try - { - using (var fs = File.OpenRead(path)) - { - fs.Seek(0x0d, SeekOrigin.Begin); - int year1 = fs.ReadByte(); - int year2 = fs.ReadByte(); - int month = fs.ReadByte(); - int day = fs.ReadByte(); - - int year = (year1 << 8) | year2; - - // If the result isn't a valid date, report it as an unknown version - if (year < 2006 || year > 2100 || month < 1 || month > 12 || day < 1 || day > 31) - { - return null; - } - - return $"{year}/{month}/{day}"; - } - } - catch - { - return null; - } - } - } -} - diff --git a/BurnOutSharp/ProtectionType/BDPlus.cs b/BurnOutSharp/ProtectionType/BDPlus.cs new file mode 100644 index 00000000..967890d5 --- /dev/null +++ b/BurnOutSharp/ProtectionType/BDPlus.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class BDPlus : IPathCheck + { + /// + public string CheckDirectoryPath(string path, IEnumerable files) + { + if (files.Any(f => f.Contains(Path.Combine("BDSVM", "00000.svm"))) + && files.Any(f => f.Contains(Path.Combine("BDSVM", "BACKUP", "00000.svm")))) + { + string file = files.FirstOrDefault(f => Path.GetFileName(f).Equals("00000.svm", StringComparison.OrdinalIgnoreCase)); + string version = GetVersion(file); + return version == null ? "BD+ (Unknown Version)" : $"BD+ Version {version}"; + } + + return null; + } + + /// + public string CheckFilePath(string path) + { + string filename = Path.GetFileName(path); + if (filename.Equals("00000.svm", StringComparison.OrdinalIgnoreCase)) + { + string version = GetVersion(path); + return version == null ? "BD+ (Unknown Version)" : $"BD+ Version {version}"; + } + + return null; + } + + /// Version detection logic from libbdplus was used to implement this + private static string GetVersion(string path) + { + try + { + using (var fs = File.OpenRead(path)) + { + fs.Seek(0x0d, SeekOrigin.Begin); + int year1 = fs.ReadByte(); + int year2 = fs.ReadByte(); + int month = fs.ReadByte(); + int day = fs.ReadByte(); + + int year = (year1 << 8) | year2; + + // If the result isn't a valid date, report it as an unknown version + if (year < 2006 || year > 2100 || month < 1 || month > 12 || day < 1 || day > 31) + { + return null; + } + + return $"{year}/{month}/{day}"; + } + } + catch + { + return null; + } + } + } +} + diff --git a/BurnOutSharp/ProtectionType/Bitpool.cs b/BurnOutSharp/ProtectionType/Bitpool.cs index 29e03bdd..b3daaca4 100644 --- a/BurnOutSharp/ProtectionType/Bitpool.cs +++ b/BurnOutSharp/ProtectionType/Bitpool.cs @@ -8,20 +8,21 @@ namespace BurnOutSharp.ProtectionType public class Bitpool : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("bitpool.rsc", StringComparison.OrdinalIgnoreCase))) - return "Bitpool"; - } - else - { - if (Path.GetFileName(path).Equals("bitpool.rsc", StringComparison.OrdinalIgnoreCase)) - return "Bitpool"; - } + if (files.Any(f => Path.GetFileName(f).Equals("bitpool.rsc", StringComparison.OrdinalIgnoreCase))) + return "Bitpool"; return null; } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("bitpool.rsc", StringComparison.OrdinalIgnoreCase)) + return "Bitpool"; + + return null; + } } } diff --git a/BurnOutSharp/ProtectionType/ByteShield.cs b/BurnOutSharp/ProtectionType/ByteShield.cs index 101aa41a..7814822f 100644 --- a/BurnOutSharp/ProtectionType/ByteShield.cs +++ b/BurnOutSharp/ProtectionType/ByteShield.cs @@ -8,26 +8,27 @@ namespace BurnOutSharp.ProtectionType public class ByteShield : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + if (files.Any(f => Path.GetFileName(f).Equals("Byteshield.dll", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetExtension(f).Trim('.').Equals("bbz", StringComparison.OrdinalIgnoreCase))) { - if (files.Any(f => Path.GetFileName(f).Equals("Byteshield.dll", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetExtension(f).Trim('.').Equals("bbz", StringComparison.OrdinalIgnoreCase))) - { - return "ByteShield"; - } - } - else - { - if (Path.GetFileName(path).Equals("Byteshield.dll", StringComparison.OrdinalIgnoreCase) - || Path.GetExtension(path).Trim('.').Equals("bbz", StringComparison.OrdinalIgnoreCase)) - { - return "ByteShield"; - } + return "ByteShield"; } return null; } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("Byteshield.dll", StringComparison.OrdinalIgnoreCase) + || Path.GetExtension(path).Trim('.').Equals("bbz", StringComparison.OrdinalIgnoreCase)) + { + return "ByteShield"; + } + + return null; + } } } diff --git a/BurnOutSharp/ProtectionType/CDCops.cs b/BurnOutSharp/ProtectionType/CDCops.cs index 129e0b38..04a33a8f 100644 --- a/BurnOutSharp/ProtectionType/CDCops.cs +++ b/BurnOutSharp/ProtectionType/CDCops.cs @@ -24,34 +24,35 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + if (files.Any(f => Path.GetFileName(f).Equals("CDCOPS.DLL", StringComparison.OrdinalIgnoreCase)) + && (files.Any(f => Path.GetExtension(f).Trim('.').Equals("GZ_", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetExtension(f).Trim('.').Equals("W_X", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetExtension(f).Trim('.').Equals("Qz", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetExtension(f).Trim('.').Equals("QZ_", StringComparison.OrdinalIgnoreCase)))) { - if (files.Any(f => Path.GetFileName(f).Equals("CDCOPS.DLL", StringComparison.OrdinalIgnoreCase)) - && (files.Any(f => Path.GetExtension(f).Trim('.').Equals("GZ_", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetExtension(f).Trim('.').Equals("W_X", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetExtension(f).Trim('.').Equals("Qz", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetExtension(f).Trim('.').Equals("QZ_", StringComparison.OrdinalIgnoreCase)))) - { - return "CD-Cops"; - } - } - else - { - if (Path.GetFileName(path).Equals("CDCOPS.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetExtension(path).Trim('.').Equals("GZ_", StringComparison.OrdinalIgnoreCase) - || Path.GetExtension(path).Trim('.').Equals("W_X", StringComparison.OrdinalIgnoreCase) - || Path.GetExtension(path).Trim('.').Equals("Qz", StringComparison.OrdinalIgnoreCase) - || Path.GetExtension(path).Trim('.').Equals("QZ_", StringComparison.OrdinalIgnoreCase)) - { - return "CD-Cops"; - } + return "CD-Cops"; } return null; } + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("CDCOPS.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetExtension(path).Trim('.').Equals("GZ_", StringComparison.OrdinalIgnoreCase) + || Path.GetExtension(path).Trim('.').Equals("W_X", StringComparison.OrdinalIgnoreCase) + || Path.GetExtension(path).Trim('.').Equals("Qz", StringComparison.OrdinalIgnoreCase) + || Path.GetExtension(path).Trim('.').Equals("QZ_", StringComparison.OrdinalIgnoreCase)) + { + return "CD-Cops"; + } + + return null; + } + private static string GetVersion(byte[] fileContent, int position) { char[] version = new ArraySegment(fileContent, position + 15, 4).Select(b => (char)b).ToArray(); diff --git a/BurnOutSharp/ProtectionType/CDLock.cs b/BurnOutSharp/ProtectionType/CDLock.cs index 472100fc..e64a8665 100644 --- a/BurnOutSharp/ProtectionType/CDLock.cs +++ b/BurnOutSharp/ProtectionType/CDLock.cs @@ -19,20 +19,21 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetExtension(f).Trim('.').Equals("AFP", StringComparison.OrdinalIgnoreCase))) - return "CD-Lock"; - } - else - { - if (Path.GetExtension(path).Trim('.').Equals("AFP", StringComparison.OrdinalIgnoreCase)) - return "CD-Lock"; - } + if (files.Any(f => Path.GetExtension(f).Trim('.').Equals("AFP", StringComparison.OrdinalIgnoreCase))) + return "CD-Lock"; return null; } + + /// + public string CheckFilePath(string path) + { + if (Path.GetExtension(path).Trim('.').Equals("AFP", StringComparison.OrdinalIgnoreCase)) + return "CD-Lock"; + + return null; + } } } diff --git a/BurnOutSharp/ProtectionType/CDProtector.cs b/BurnOutSharp/ProtectionType/CDProtector.cs index 0357a708..69e78eeb 100644 --- a/BurnOutSharp/ProtectionType/CDProtector.cs +++ b/BurnOutSharp/ProtectionType/CDProtector.cs @@ -8,31 +8,32 @@ namespace BurnOutSharp.ProtectionType public class CDProtector : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("_cdp16.dat", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("_cdp16.dll", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("_cdp32.dat", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("_cdp32.dll", StringComparison.OrdinalIgnoreCase))) { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("_cdp16.dat", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("_cdp16.dll", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("_cdp32.dat", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("_cdp32.dll", StringComparison.OrdinalIgnoreCase))) - { - return "CD-Protector"; - } - } - else - { - if (Path.GetFileName(path).Equals("_cdp16.dat", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("_cdp16.dll", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("_cdp32.dat", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("_cdp32.dll", StringComparison.OrdinalIgnoreCase)) - { - return "CD-Protector"; - } + return "CD-Protector"; } return null; } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("_cdp16.dat", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("_cdp16.dll", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("_cdp32.dat", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("_cdp32.dll", StringComparison.OrdinalIgnoreCase)) + { + return "CD-Protector"; + } + + return null; + } } } diff --git a/BurnOutSharp/ProtectionType/CDX.cs b/BurnOutSharp/ProtectionType/CDX.cs index 8b9181f8..bab33e71 100644 --- a/BurnOutSharp/ProtectionType/CDX.cs +++ b/BurnOutSharp/ProtectionType/CDX.cs @@ -8,29 +8,30 @@ namespace BurnOutSharp.ProtectionType public class CDX : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("CHKCDX16.DLL", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("CHKCDX32.DLL", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("CHKCDXNT.DLL", StringComparison.OrdinalIgnoreCase))) { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("CHKCDX16.DLL", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("CHKCDX32.DLL", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("CHKCDXNT.DLL", StringComparison.OrdinalIgnoreCase))) - { - return "CD-X"; - } - } - else - { - if (Path.GetFileName(path).Equals("CHKCDX16.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("CHKCDX32.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("CHKCDXNT.DLL", StringComparison.OrdinalIgnoreCase)) - { - return "CD-X"; - } + return "CD-X"; } return null; } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("CHKCDX16.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("CHKCDX32.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("CHKCDXNT.DLL", StringComparison.OrdinalIgnoreCase)) + { + return "CD-X"; + } + + return null; + } } } diff --git a/BurnOutSharp/ProtectionType/CactusDataShield.cs b/BurnOutSharp/ProtectionType/CactusDataShield.cs index bb001e49..97396755 100644 --- a/BurnOutSharp/ProtectionType/CactusDataShield.cs +++ b/BurnOutSharp/ProtectionType/CactusDataShield.cs @@ -30,42 +30,43 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + if (files.Any(f => Path.GetFileName(f).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("PJSTREAM.DLL", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("wmmp.exe", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetExtension(f).Trim('.').Equals("cds", StringComparison.OrdinalIgnoreCase))) { - if (files.Any(f => Path.GetFileName(f).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("PJSTREAM.DLL", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("wmmp.exe", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetExtension(f).Trim('.').Equals("cds", StringComparison.OrdinalIgnoreCase))) + string versionPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("version.txt", StringComparison.OrdinalIgnoreCase)); + if (!string.IsNullOrWhiteSpace(versionPath)) { - string versionPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("version.txt", StringComparison.OrdinalIgnoreCase)); - if (!string.IsNullOrWhiteSpace(versionPath)) - { - string version = GetVersion(versionPath); - if (!string.IsNullOrWhiteSpace(version)) - return $"Cactus Data Shield {version}"; - } + string version = GetVersion(versionPath); + if (!string.IsNullOrWhiteSpace(version)) + return $"Cactus Data Shield {version}"; + } - return "Cactus Data Shield 200"; - } - } - else - { - if (Path.GetFileName(path).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("PJSTREAM.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("wmmp.exe", StringComparison.OrdinalIgnoreCase) - || Path.GetExtension(path).Trim('.').Equals("cds", StringComparison.OrdinalIgnoreCase)) - { - return "Cactus Data Shield 200"; - } + return "Cactus Data Shield 200"; } return null; } + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("PJSTREAM.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("wmmp.exe", StringComparison.OrdinalIgnoreCase) + || Path.GetExtension(path).Trim('.').Equals("cds", StringComparison.OrdinalIgnoreCase)) + { + return "Cactus Data Shield 200"; + } + + return null; + } + private static string GetVersion(string path) { if (!File.Exists(path)) diff --git a/BurnOutSharp/ProtectionType/CopyKiller.cs b/BurnOutSharp/ProtectionType/CopyKiller.cs index 319673ba..f25af48e 100644 --- a/BurnOutSharp/ProtectionType/CopyKiller.cs +++ b/BurnOutSharp/ProtectionType/CopyKiller.cs @@ -19,23 +19,23 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - return null; - // TODO: The following checks are overly broad and should be refined - //if (isDirectory) - //{ - // if (files.Any(f => Path.GetFileName(f).Equals("Autorun.dat", StringComparison.OrdinalIgnoreCase))) - // return "CopyKiller"; - //} - //else - //{ - // if (Path.GetFileName(path).Equals("Autorun.dat", StringComparison.OrdinalIgnoreCase)) - // return "CopyKiller"; - //} + // if (files.Any(f => Path.GetFileName(f).Equals("Autorun.dat", StringComparison.OrdinalIgnoreCase))) + // return "CopyKiller"; - //return null; + return null; + } + + /// + public string CheckFilePath(string path) + { + // TODO: The following checks are overly broad and should be refined + // if (Path.GetFileName(path).Equals("Autorun.dat", StringComparison.OrdinalIgnoreCase)) + // return "CopyKiller"; + + return null; } } } diff --git a/BurnOutSharp/ProtectionType/DVDCrypt.cs b/BurnOutSharp/ProtectionType/DVDCrypt.cs index 7283234a..cb1e0703 100644 --- a/BurnOutSharp/ProtectionType/DVDCrypt.cs +++ b/BurnOutSharp/ProtectionType/DVDCrypt.cs @@ -8,20 +8,21 @@ namespace BurnOutSharp.ProtectionType public class DVDCrypt : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("DvdCrypt.pdb", StringComparison.OrdinalIgnoreCase))) - return "DVD Crypt"; - } - else - { - if (Path.GetFileName(path).Equals("DvdCrypt.pdb", StringComparison.OrdinalIgnoreCase)) - return "DVD Crypt"; - } + if (files.Any(f => Path.GetFileName(f).Equals("DvdCrypt.pdb", StringComparison.OrdinalIgnoreCase))) + return "DVD Crypt"; return null; } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("DvdCrypt.pdb", StringComparison.OrdinalIgnoreCase)) + return "DVD Crypt"; + + return null; + } } } diff --git a/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs b/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs index 14a0fe39..5ad04bad 100644 --- a/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs +++ b/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs @@ -7,11 +7,8 @@ namespace BurnOutSharp.ProtectionType public class DVDMoviePROTECT : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (!isDirectory) - return null; - if (Directory.Exists(Path.Combine(path, "VIDEO_TS"))) { string[] bupfiles = files.Where(s => s.EndsWith(".bup")).ToArray(); @@ -26,5 +23,11 @@ namespace BurnOutSharp.ProtectionType return null; } + + /// + public string CheckFilePath(string path) + { + return null; + } } } diff --git a/BurnOutSharp/ProtectionType/DiscGuard.cs b/BurnOutSharp/ProtectionType/DiscGuard.cs index d755c783..41a5a1a0 100644 --- a/BurnOutSharp/ProtectionType/DiscGuard.cs +++ b/BurnOutSharp/ProtectionType/DiscGuard.cs @@ -8,27 +8,29 @@ namespace BurnOutSharp.ProtectionType public class DiscGuard : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + if (files.Any(f => Path.GetFileName(f).Equals("IOSLINK.VXD", StringComparison.OrdinalIgnoreCase)) + && files.Any(f => Path.GetFileName(f).Equals("IOSLINK.DLL", StringComparison.OrdinalIgnoreCase)) + && files.Any(f => Path.GetFileName(f).Equals("IOSLINK.SYS", StringComparison.OrdinalIgnoreCase))) { - if (files.Any(f => Path.GetFileName(f).Equals("IOSLINK.VXD", StringComparison.OrdinalIgnoreCase)) - && files.Any(f => Path.GetFileName(f).Equals("IOSLINK.SYS", StringComparison.OrdinalIgnoreCase))) - { - return "DiscGuard"; - } - } - else - { - if (Path.GetFileName(path).Equals("IOSLINK.VXD", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("IOSLINK.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("IOSLINK.SYS", StringComparison.OrdinalIgnoreCase)) - { - return "DiscGuard"; - } + return "DiscGuard"; } return null; } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("IOSLINK.VXD", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("IOSLINK.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("IOSLINK.SYS", StringComparison.OrdinalIgnoreCase)) + { + return "DiscGuard"; + } + + return null; + } } } diff --git a/BurnOutSharp/ProtectionType/FreeLock.cs b/BurnOutSharp/ProtectionType/FreeLock.cs index 2eac5aae..88b96c13 100644 --- a/BurnOutSharp/ProtectionType/FreeLock.cs +++ b/BurnOutSharp/ProtectionType/FreeLock.cs @@ -8,18 +8,19 @@ namespace BurnOutSharp.ProtectionType public class FreeLock : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("FREELOCK.IMG", StringComparison.OrdinalIgnoreCase))) - return "FreeLock"; - } - else - { - if (Path.GetFileName(path).Equals("FREELOCK.IMG", StringComparison.OrdinalIgnoreCase)) - return "FreeLock"; - } + if (files.Any(f => Path.GetFileName(f).Equals("FREELOCK.IMG", StringComparison.OrdinalIgnoreCase))) + return "FreeLock"; + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("FREELOCK.IMG", StringComparison.OrdinalIgnoreCase)) + return "FreeLock"; return null; } diff --git a/BurnOutSharp/ProtectionType/GFWL.cs b/BurnOutSharp/ProtectionType/GFWL.cs index db7b3164..1a006a7f 100644 --- a/BurnOutSharp/ProtectionType/GFWL.cs +++ b/BurnOutSharp/ProtectionType/GFWL.cs @@ -19,18 +19,19 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("XLiveRedist.msi", StringComparison.OrdinalIgnoreCase))) - return "Games for Windows - Live"; - } - else - { - if (Path.GetFileName(path).Equals("XLiveRedist.msi", StringComparison.OrdinalIgnoreCase)) - return "Games for Windows - Live"; - } + if (files.Any(f => Path.GetFileName(f).Equals("XLiveRedist.msi", StringComparison.OrdinalIgnoreCase))) + return "Games for Windows - Live"; + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("XLiveRedist.msi", StringComparison.OrdinalIgnoreCase)) + return "Games for Windows - Live"; return null; } diff --git a/BurnOutSharp/ProtectionType/HexalockAutoLock.cs b/BurnOutSharp/ProtectionType/HexalockAutoLock.cs index d11993ed..dcf63250 100644 --- a/BurnOutSharp/ProtectionType/HexalockAutoLock.cs +++ b/BurnOutSharp/ProtectionType/HexalockAutoLock.cs @@ -8,28 +8,29 @@ namespace BurnOutSharp.ProtectionType public class HexalockAutoLock : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("Start_Here.exe", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("HCPSMng.exe", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("MFINT.DLL", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("MFIMP.DLL", StringComparison.OrdinalIgnoreCase))) { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("Start_Here.exe", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("HCPSMng.exe", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("MFINT.DLL", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("MFIMP.DLL", StringComparison.OrdinalIgnoreCase))) - { - return "Hexalock AutoLock"; - } + return "Hexalock AutoLock"; } - else + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("Start_Here.exe", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("HCPSMng.exe", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("MFINT.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("MFIMP.DLL", StringComparison.OrdinalIgnoreCase)) { - if (Path.GetFileName(path).Equals("Start_Here.exe", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("HCPSMng.exe", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("MFINT.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("MFIMP.DLL", StringComparison.OrdinalIgnoreCase)) - { - return "Hexalock AutoLock"; - } + return "Hexalock AutoLock"; } return null; diff --git a/BurnOutSharp/ProtectionType/ImpulseReactor.cs b/BurnOutSharp/ProtectionType/ImpulseReactor.cs index 1bd8ffe4..678e9766 100644 --- a/BurnOutSharp/ProtectionType/ImpulseReactor.cs +++ b/BurnOutSharp/ProtectionType/ImpulseReactor.cs @@ -26,18 +26,19 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase))) - return "Impulse Reactor " + Utilities.GetFileVersion(files.First(f => Path.GetFileName(f).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase))); - } - else - { - if (Path.GetFileName(path).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase)) + if (files.Any(f => Path.GetFileName(f).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase))) + return "Impulse Reactor " + Utilities.GetFileVersion(files.First(f => Path.GetFileName(f).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase))); + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase)) return "Impulse Reactor " + Utilities.GetFileVersion(path); - } return null; } diff --git a/BurnOutSharp/ProtectionType/IndyVCD.cs b/BurnOutSharp/ProtectionType/IndyVCD.cs index d4512218..4ac9cbfd 100644 --- a/BurnOutSharp/ProtectionType/IndyVCD.cs +++ b/BurnOutSharp/ProtectionType/IndyVCD.cs @@ -8,24 +8,25 @@ namespace BurnOutSharp.ProtectionType public class IndyVCD : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("INDYVCD.AX", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("INDYMP3.idt", StringComparison.OrdinalIgnoreCase))) { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("INDYVCD.AX", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("INDYMP3.idt", StringComparison.OrdinalIgnoreCase))) - { - return "IndyVCD"; - } + return "IndyVCD"; } - else + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("INDYVCD.AX", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("INDYMP3.idt", StringComparison.OrdinalIgnoreCase)) { - if (Path.GetFileName(path).Equals("INDYVCD.AX", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("INDYMP3.idt", StringComparison.OrdinalIgnoreCase)) - { - return "IndyVCD"; - } + return "IndyVCD"; } return null; diff --git a/BurnOutSharp/ProtectionType/Key2AudioXS.cs b/BurnOutSharp/ProtectionType/Key2AudioXS.cs index e083b387..ee78d511 100644 --- a/BurnOutSharp/ProtectionType/Key2AudioXS.cs +++ b/BurnOutSharp/ProtectionType/Key2AudioXS.cs @@ -8,24 +8,25 @@ namespace BurnOutSharp.ProtectionType public class Key2AudioXS : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("SDKHM.EXE", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("SDKHM.DLL", StringComparison.OrdinalIgnoreCase))) { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("SDKHM.EXE", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("SDKHM.DLL", StringComparison.OrdinalIgnoreCase))) - { - return "key2AudioXS"; - } + return "key2AudioXS"; } - else + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("SDKHM.EXE", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("SDKHM.DLL", StringComparison.OrdinalIgnoreCase)) { - if (Path.GetFileName(path).Equals("SDKHM.EXE", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("SDKHM.DLL", StringComparison.OrdinalIgnoreCase)) - { - return "key2AudioXS"; - } + return "key2AudioXS"; } return null; diff --git a/BurnOutSharp/ProtectionType/LaserLock.cs b/BurnOutSharp/ProtectionType/LaserLock.cs index b86ed44e..8243fe73 100644 --- a/BurnOutSharp/ProtectionType/LaserLock.cs +++ b/BurnOutSharp/ProtectionType/LaserLock.cs @@ -42,40 +42,41 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + if (Directory.Exists(Path.Combine(path, "LASERLOK"))) { - if (Directory.Exists(Path.Combine(path, "LASERLOK"))) - { - return "LaserLock"; - } - - // TODO: Verify if these are OR or AND - else if (files.Any(f => Path.GetFileName(f).Equals("NOMOUSE.SP", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("NOMOUSE.COM", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("l16dll.dll", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("laserlok.in", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("laserlok.o10", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("laserlok.011", StringComparison.OrdinalIgnoreCase))) - { - return "LaserLock"; - } + return "LaserLock"; } - else - { - if (path != null && string.Equals(Path.GetFileName(path), "NOMOUSE.SP", StringComparison.OrdinalIgnoreCase)) - return $"LaserLock {GetVersion16Bit(path)}"; - if (Path.GetFileName(path).Equals("NOMOUSE.SP", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("NOMOUSE.COM", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("l16dll.dll", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("laserlok.in", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("laserlok.o10", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("laserlok.011", StringComparison.OrdinalIgnoreCase)) - { - return "LaserLock"; - } + // TODO: Verify if these are OR or AND + else if (files.Any(f => Path.GetFileName(f).Equals("NOMOUSE.SP", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("NOMOUSE.COM", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("l16dll.dll", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("laserlok.in", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("laserlok.o10", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("laserlok.011", StringComparison.OrdinalIgnoreCase))) + { + return "LaserLock"; + } + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (path != null && string.Equals(Path.GetFileName(path), "NOMOUSE.SP", StringComparison.OrdinalIgnoreCase)) + return $"LaserLock {GetVersion16Bit(path)}"; + + if (Path.GetFileName(path).Equals("NOMOUSE.SP", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("NOMOUSE.COM", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("l16dll.dll", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("laserlok.in", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("laserlok.o10", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("laserlok.011", StringComparison.OrdinalIgnoreCase)) + { + return "LaserLock"; } return null; diff --git a/BurnOutSharp/ProtectionType/MediaCloQ.cs b/BurnOutSharp/ProtectionType/MediaCloQ.cs index b9acd499..c01f1b4d 100644 --- a/BurnOutSharp/ProtectionType/MediaCloQ.cs +++ b/BurnOutSharp/ProtectionType/MediaCloQ.cs @@ -8,18 +8,19 @@ namespace BurnOutSharp.ProtectionType public class MediaCloQ : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("sunncomm.ico", StringComparison.OrdinalIgnoreCase))) - return "MediaCloQ"; - } - else - { - if (Path.GetFileName(path).Equals("sunncomm.ico", StringComparison.OrdinalIgnoreCase)) - return "MediaCloQ"; - } + if (files.Any(f => Path.GetFileName(f).Equals("sunncomm.ico", StringComparison.OrdinalIgnoreCase))) + return "MediaCloQ"; + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("sunncomm.ico", StringComparison.OrdinalIgnoreCase)) + return "MediaCloQ"; return null; } diff --git a/BurnOutSharp/ProtectionType/MediaMaxCD3.cs b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs index 3c9d1481..1c8fe21c 100644 --- a/BurnOutSharp/ProtectionType/MediaMaxCD3.cs +++ b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs @@ -24,18 +24,19 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("LaunchCd.exe", StringComparison.OrdinalIgnoreCase))) - return "MediaMax CD-3"; - } - else - { - if (Path.GetFileName(path).Equals("LaunchCd.exe", StringComparison.OrdinalIgnoreCase)) - return "MediaMax CD-3"; - } + if (files.Any(f => Path.GetFileName(f).Equals("LaunchCd.exe", StringComparison.OrdinalIgnoreCase))) + return "MediaMax CD-3"; + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("LaunchCd.exe", StringComparison.OrdinalIgnoreCase)) + return "MediaMax CD-3"; return null; } diff --git a/BurnOutSharp/ProtectionType/Origin.cs b/BurnOutSharp/ProtectionType/Origin.cs index 62befb3a..80dde3ca 100644 --- a/BurnOutSharp/ProtectionType/Origin.cs +++ b/BurnOutSharp/ProtectionType/Origin.cs @@ -19,18 +19,19 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - 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"; - } + if (files.Any(f => Path.GetFileName(f).Equals("OriginSetup.exe", StringComparison.OrdinalIgnoreCase))) + return "Origin"; + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("OriginSetup.exe", StringComparison.OrdinalIgnoreCase)) + return "Origin"; return null; } diff --git a/BurnOutSharp/ProtectionType/ProtectDVDVideo.cs b/BurnOutSharp/ProtectionType/ProtectDVDVideo.cs index 996f8c5f..3c3be189 100644 --- a/BurnOutSharp/ProtectionType/ProtectDVDVideo.cs +++ b/BurnOutSharp/ProtectionType/ProtectDVDVideo.cs @@ -7,11 +7,8 @@ namespace BurnOutSharp.ProtectionType public class ProtectDVDVideo : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (!isDirectory) - return null; - if (Directory.Exists(Path.Combine(path, "VIDEO_TS"))) { string[] ifofiles = files.Where(s => s.EndsWith(".ifo")).ToArray(); @@ -22,7 +19,13 @@ namespace BurnOutSharp.ProtectionType return "Protect DVD-Video"; } } + + return null; + } + /// + public string CheckFilePath(string path) + { return null; } } diff --git a/BurnOutSharp/ProtectionType/SafeCast.cs b/BurnOutSharp/ProtectionType/SafeCast.cs index 81d2ace8..0f309e9a 100644 --- a/BurnOutSharp/ProtectionType/SafeCast.cs +++ b/BurnOutSharp/ProtectionType/SafeCast.cs @@ -8,18 +8,19 @@ namespace BurnOutSharp.ProtectionType public class SafeCast : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("cdac11ba.exe", StringComparison.OrdinalIgnoreCase))) - return "SafeCast"; - } - else - { - if (Path.GetFileName(path).Equals("cdac11ba.exe", StringComparison.OrdinalIgnoreCase)) - return "SafeCast"; - } + if (files.Any(f => Path.GetFileName(f).Equals("cdac11ba.exe", StringComparison.OrdinalIgnoreCase))) + return "SafeCast"; + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("cdac11ba.exe", StringComparison.OrdinalIgnoreCase)) + return "SafeCast"; return null; } diff --git a/BurnOutSharp/ProtectionType/SafeDisc.cs b/BurnOutSharp/ProtectionType/SafeDisc.cs index 0099611a..0556f49c 100644 --- a/BurnOutSharp/ProtectionType/SafeDisc.cs +++ b/BurnOutSharp/ProtectionType/SafeDisc.cs @@ -61,69 +61,70 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: These are all cop-outs that don't check the existence of the other files + if (files.Any(f => Path.GetFileName(f).Equals("DPLAYERX.DLL", StringComparison.OrdinalIgnoreCase))) { - // TODO: These are all cop-outs that don't check the existence of the other files - if (files.Any(f => Path.GetFileName(f).Equals("DPLAYERX.DLL", StringComparison.OrdinalIgnoreCase))) - { - string file = files.First(f => Path.GetFileName(f).Equals("DPLAYERX.DLL", StringComparison.OrdinalIgnoreCase)); - return GetDPlayerXVersion(file); - } - else if (files.Any(f => Path.GetFileName(f).Equals("drvmgt.dll", StringComparison.OrdinalIgnoreCase))) - { - string file = files.First(f => Path.GetFileName(f).Equals("drvmgt.dll", StringComparison.OrdinalIgnoreCase)); - return GetDrvmgtVersion(file); - } - else if (files.Any(f => Path.GetFileName(f).Equals("secdrv.sys", StringComparison.OrdinalIgnoreCase))) - { - string file = files.First(f => Path.GetFileName(f).Equals("secdrv.sys", StringComparison.OrdinalIgnoreCase)); - return GetSecdrvVersion(file); - } - else if (path.EndsWith(".SafeDiscDVD.bundle", StringComparison.OrdinalIgnoreCase)) - { - return "SafeDisc for Macintosh"; - } + string file = files.First(f => Path.GetFileName(f).Equals("DPLAYERX.DLL", StringComparison.OrdinalIgnoreCase)); + return GetDPlayerXVersion(file); } - else + else if (files.Any(f => Path.GetFileName(f).Equals("drvmgt.dll", StringComparison.OrdinalIgnoreCase))) { - // V1 - if (Path.GetFileName(path).Equals("CLCD16.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("CLCD32.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("CLOKSPL.EXE", StringComparison.OrdinalIgnoreCase) - || Path.GetExtension(path).Trim('.').Equals("icd", StringComparison.OrdinalIgnoreCase)) - { - return "SafeDisc 1"; - } + string file = files.First(f => Path.GetFileName(f).Equals("drvmgt.dll", StringComparison.OrdinalIgnoreCase)); + return GetDrvmgtVersion(file); + } + else if (files.Any(f => Path.GetFileName(f).Equals("secdrv.sys", StringComparison.OrdinalIgnoreCase))) + { + string file = files.First(f => Path.GetFileName(f).Equals("secdrv.sys", StringComparison.OrdinalIgnoreCase)); + return GetSecdrvVersion(file); + } + else if (path.EndsWith(".SafeDiscDVD.bundle", StringComparison.OrdinalIgnoreCase)) + { + return "SafeDisc for Macintosh"; + } + + return null; + } - // V1 or greater - else if (Path.GetFileName(path).Equals("00000001.TMP", StringComparison.OrdinalIgnoreCase) - || Path.GetExtension(path).Trim('.').Equals("016", StringComparison.OrdinalIgnoreCase) - || Path.GetExtension(path).Trim('.').Equals("256", StringComparison.OrdinalIgnoreCase)) - { - return "SafeDisc 1 or greater"; - } + /// + public string CheckFilePath(string path) + { + // V1 + if (Path.GetFileName(path).Equals("CLCD16.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("CLCD32.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("CLOKSPL.EXE", StringComparison.OrdinalIgnoreCase) + || Path.GetExtension(path).Trim('.').Equals("icd", StringComparison.OrdinalIgnoreCase)) + { + return "SafeDisc 1"; + } - // V2 or greater - else if (Path.GetFileName(path).Equals("00000002.TMP", StringComparison.OrdinalIgnoreCase)) - { - return "SafeDisc 2 or greater"; - } + // V1 or greater + else if (Path.GetFileName(path).Equals("00000001.TMP", StringComparison.OrdinalIgnoreCase) + || Path.GetExtension(path).Trim('.').Equals("016", StringComparison.OrdinalIgnoreCase) + || Path.GetExtension(path).Trim('.').Equals("256", StringComparison.OrdinalIgnoreCase)) + { + return "SafeDisc 1 or greater"; + } - // Specific Versions - else if (Path.GetFileName(path).Equals("DPLAYERX.DLL", StringComparison.OrdinalIgnoreCase)) - { - return GetDPlayerXVersion(path); - } - else if (Path.GetFileName(path).Equals("drvmgt.dll", StringComparison.OrdinalIgnoreCase)) - { - return GetDrvmgtVersion(path); - } - else if (Path.GetFileName(path).Equals("secdrv.sys", StringComparison.OrdinalIgnoreCase)) - { - return GetSecdrvVersion(path); - } + // V2 or greater + else if (Path.GetFileName(path).Equals("00000002.TMP", StringComparison.OrdinalIgnoreCase)) + { + return "SafeDisc 2 or greater"; + } + + // Specific Versions + else if (Path.GetFileName(path).Equals("DPLAYERX.DLL", StringComparison.OrdinalIgnoreCase)) + { + return GetDPlayerXVersion(path); + } + else if (Path.GetFileName(path).Equals("drvmgt.dll", StringComparison.OrdinalIgnoreCase)) + { + return GetDrvmgtVersion(path); + } + else if (Path.GetFileName(path).Equals("secdrv.sys", StringComparison.OrdinalIgnoreCase)) + { + return GetSecdrvVersion(path); } return null; diff --git a/BurnOutSharp/ProtectionType/SafeDiscLite.cs b/BurnOutSharp/ProtectionType/SafeDiscLite.cs index a20b7cc3..675726db 100644 --- a/BurnOutSharp/ProtectionType/SafeDiscLite.cs +++ b/BurnOutSharp/ProtectionType/SafeDiscLite.cs @@ -8,18 +8,19 @@ namespace BurnOutSharp.ProtectionType public class SafeDiscLite : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("00000001.LT1", StringComparison.OrdinalIgnoreCase))) - return "SafeDisc Lite"; - } - else - { - if (Path.GetFileName(path).Equals("00000001.LT1", StringComparison.OrdinalIgnoreCase)) - return "SafeDisc Lite"; - } + if (files.Any(f => Path.GetFileName(f).Equals("00000001.LT1", StringComparison.OrdinalIgnoreCase))) + return "SafeDisc Lite"; + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("00000001.LT1", StringComparison.OrdinalIgnoreCase)) + return "SafeDisc Lite"; return null; } diff --git a/BurnOutSharp/ProtectionType/SafeLock.cs b/BurnOutSharp/ProtectionType/SafeLock.cs index 3b2b9750..0ad76225 100644 --- a/BurnOutSharp/ProtectionType/SafeLock.cs +++ b/BurnOutSharp/ProtectionType/SafeLock.cs @@ -19,26 +19,27 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("SafeLock.dat", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("SafeLock.001", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("SafeLock.128", StringComparison.OrdinalIgnoreCase))) { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("SafeLock.dat", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("SafeLock.001", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("SafeLock.128", StringComparison.OrdinalIgnoreCase))) - { - return "SafeLock"; - } + return "SafeLock"; } - else + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("SafeLock.dat", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("SafeLock.001", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("SafeLock.128", StringComparison.OrdinalIgnoreCase)) { - if (Path.GetFileName(path).Equals("SafeLock.dat", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("SafeLock.001", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("SafeLock.128", StringComparison.OrdinalIgnoreCase)) - { - return "SafeLock"; - } + return "SafeLock"; } return null; diff --git a/BurnOutSharp/ProtectionType/SecuROM.cs b/BurnOutSharp/ProtectionType/SecuROM.cs index 7d65b385..7bd56665 100644 --- a/BurnOutSharp/ProtectionType/SecuROM.cs +++ b/BurnOutSharp/ProtectionType/SecuROM.cs @@ -50,42 +50,43 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("CMS16.DLL", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("CMS_95.DLL", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("CMS_NT.DLL", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("CMS32_95.DLL", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("CMS32_NT.DLL", StringComparison.OrdinalIgnoreCase))) { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("CMS16.DLL", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("CMS_95.DLL", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("CMS_NT.DLL", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("CMS32_95.DLL", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("CMS32_NT.DLL", StringComparison.OrdinalIgnoreCase))) - { - return "SecuROM"; - } - else if (files.Any(f => Path.GetFileName(f).Equals("SINTF32.DLL", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("SINTF16.DLL", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("SINTFNT.DLL", StringComparison.OrdinalIgnoreCase))) - { - return "SecuROM New"; - } + return "SecuROM"; } - else + else if (files.Any(f => Path.GetFileName(f).Equals("SINTF32.DLL", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("SINTF16.DLL", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("SINTFNT.DLL", StringComparison.OrdinalIgnoreCase))) { - if (Path.GetFileName(path).Equals("CMS16.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("CMS_95.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("CMS_NT.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("CMS32_95.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("CMS32_NT.DLL", StringComparison.OrdinalIgnoreCase)) - { - return "SecuROM"; - } - else if (Path.GetFileName(path).Equals("SINTF32.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("SINTF16.DLL", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("SINTFNT.DLL", StringComparison.OrdinalIgnoreCase)) - { - return "SecuROM New"; - } + return "SecuROM New"; + } + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("CMS16.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("CMS_95.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("CMS_NT.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("CMS32_95.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("CMS32_NT.DLL", StringComparison.OrdinalIgnoreCase)) + { + return "SecuROM"; + } + else if (Path.GetFileName(path).Equals("SINTF32.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("SINTF16.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("SINTFNT.DLL", StringComparison.OrdinalIgnoreCase)) + { + return "SecuROM New"; } return null; diff --git a/BurnOutSharp/ProtectionType/SmartE.cs b/BurnOutSharp/ProtectionType/SmartE.cs index 1db38e7f..d9356a0e 100644 --- a/BurnOutSharp/ProtectionType/SmartE.cs +++ b/BurnOutSharp/ProtectionType/SmartE.cs @@ -19,24 +19,25 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("00001.TMP", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("00002.TMP", StringComparison.OrdinalIgnoreCase))) { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("00001.TMP", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("00002.TMP", StringComparison.OrdinalIgnoreCase))) - { - return "SmartE"; - } + return "SmartE"; } - else + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("00001.TMP", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("00002.TMP", StringComparison.OrdinalIgnoreCase)) { - if (Path.GetFileName(path).Equals("00001.TMP", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("00002.TMP", StringComparison.OrdinalIgnoreCase)) - { - return "SmartE"; - } + return "SmartE"; } return null; diff --git a/BurnOutSharp/ProtectionType/SoftLock.cs b/BurnOutSharp/ProtectionType/SoftLock.cs index 92a1da2b..3451f142 100644 --- a/BurnOutSharp/ProtectionType/SoftLock.cs +++ b/BurnOutSharp/ProtectionType/SoftLock.cs @@ -8,24 +8,25 @@ namespace BurnOutSharp.ProtectionType public class SoftLock : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("SOFTLOCKI.dat", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("SOFTLOCKC.dat", StringComparison.OrdinalIgnoreCase))) { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("SOFTLOCKI.dat", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("SOFTLOCKC.dat", StringComparison.OrdinalIgnoreCase))) - { - return "SoftLock"; - } + return "SoftLock"; } - else + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("SOFTLOCKI.dat", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("SOFTLOCKC.dat", StringComparison.OrdinalIgnoreCase)) { - if (Path.GetFileName(path).Equals("SOFTLOCKI.dat", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("SOFTLOCKC.dat", StringComparison.OrdinalIgnoreCase)) - { - return "SoftLock"; - } + return "SoftLock"; } return null; diff --git a/BurnOutSharp/ProtectionType/SolidShield.cs b/BurnOutSharp/ProtectionType/SolidShield.cs index a3cc7787..6428b8ce 100644 --- a/BurnOutSharp/ProtectionType/SolidShield.cs +++ b/BurnOutSharp/ProtectionType/SolidShield.cs @@ -114,28 +114,29 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("dvm.dll", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("hc.dll", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("solidshield-cd.dll", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("c11prot.dll", StringComparison.OrdinalIgnoreCase))) { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("dvm.dll", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("hc.dll", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("solidshield-cd.dll", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("c11prot.dll", StringComparison.OrdinalIgnoreCase))) - { - return "SolidShield"; - } + return "SolidShield"; } - else + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("dvm.dll", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("hc.dll", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("solidshield-cd.dll", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("c11prot.dll", StringComparison.OrdinalIgnoreCase)) { - if (Path.GetFileName(path).Equals("dvm.dll", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("hc.dll", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("solidshield-cd.dll", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("c11prot.dll", StringComparison.OrdinalIgnoreCase)) - { - return "SolidShield"; - } + return "SolidShield"; } return null; diff --git a/BurnOutSharp/ProtectionType/StarForce.cs b/BurnOutSharp/ProtectionType/StarForce.cs index e0330cad..925b15d7 100644 --- a/BurnOutSharp/ProtectionType/StarForce.cs +++ b/BurnOutSharp/ProtectionType/StarForce.cs @@ -65,24 +65,25 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("protect.dll", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("protect.exe", StringComparison.OrdinalIgnoreCase))) { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("protect.dll", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("protect.exe", StringComparison.OrdinalIgnoreCase))) - { - return "StarForce"; - } + return "StarForce"; } - else + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("protect.dll", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("protect.exe", StringComparison.OrdinalIgnoreCase)) { - if (Path.GetFileName(path).Equals("protect.dll", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("protect.exe", StringComparison.OrdinalIgnoreCase)) - { - return "StarForce"; - } + return "StarForce"; } return null; diff --git a/BurnOutSharp/ProtectionType/Steam.cs b/BurnOutSharp/ProtectionType/Steam.cs index 80be8ee8..774a889e 100644 --- a/BurnOutSharp/ProtectionType/Steam.cs +++ b/BurnOutSharp/ProtectionType/Steam.cs @@ -9,29 +9,30 @@ namespace BurnOutSharp.ProtectionType public class Steam : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + if (files.Any(f => Path.GetFileName(f).Equals("SteamInstall.exe", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("SteamInstall.ini", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("SteamInstall.msi", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("SteamRetailInstaller.dmg", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("SteamSetup.exe", StringComparison.OrdinalIgnoreCase))) { - if (files.Any(f => Path.GetFileName(f).Equals("SteamInstall.exe", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("SteamInstall.ini", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("SteamInstall.msi", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("SteamRetailInstaller.dmg", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("SteamSetup.exe", StringComparison.OrdinalIgnoreCase))) - { - return "Steam"; - } + return "Steam"; } - else + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("SteamInstall.exe", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("SteamInstall.ini", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("SteamInstall.msi", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("SteamRetailInstaller.dmg", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("SteamSetup.exe", StringComparison.OrdinalIgnoreCase)) { - if (Path.GetFileName(path).Equals("SteamInstall.exe", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("SteamInstall.ini", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("SteamInstall.msi", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("SteamRetailInstaller.dmg", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("SteamSetup.exe", StringComparison.OrdinalIgnoreCase)) - { - return "Steam"; - } + return "Steam"; } return null; diff --git a/BurnOutSharp/ProtectionType/TZCopyProtector.cs b/BurnOutSharp/ProtectionType/TZCopyProtector.cs index fba258d2..96eb543e 100644 --- a/BurnOutSharp/ProtectionType/TZCopyProtector.cs +++ b/BurnOutSharp/ProtectionType/TZCopyProtector.cs @@ -8,18 +8,19 @@ namespace BurnOutSharp.ProtectionType public class TZCopyProtector : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("_742893.016", StringComparison.OrdinalIgnoreCase))) - return "TZCopyProtector"; - } - else - { - if (Path.GetFileName(path).Equals("_742893.016", StringComparison.OrdinalIgnoreCase)) - return "TZCopyProtector"; - } + if (files.Any(f => Path.GetFileName(f).Equals("_742893.016", StringComparison.OrdinalIgnoreCase))) + return "TZCopyProtector"; + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("_742893.016", StringComparison.OrdinalIgnoreCase)) + return "TZCopyProtector"; return null; } diff --git a/BurnOutSharp/ProtectionType/Tages.cs b/BurnOutSharp/ProtectionType/Tages.cs index 319dd715..2baa499d 100644 --- a/BurnOutSharp/ProtectionType/Tages.cs +++ b/BurnOutSharp/ProtectionType/Tages.cs @@ -33,58 +33,57 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + List protections = new List(); + + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("Tages.dll", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("Wave.aif", StringComparison.OrdinalIgnoreCase))) { - List protections = new List(); - - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("Tages.dll", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("Wave.aif", StringComparison.OrdinalIgnoreCase))) - { - protections.Add("TAGES"); - } - if (files.Any(f => Path.GetFileName(f).Equals("tagesclient.exe", StringComparison.OrdinalIgnoreCase))) - { - string file = files.First(f => Path.GetFileName(f).Equals("tagesclient.exe", StringComparison.OrdinalIgnoreCase)); - protections.Add("TAGES Activation Client " + Utilities.GetFileVersion(file)); - } - if (files.Any(f => Path.GetFileName(f).Equals("TagesSetup.exe", StringComparison.OrdinalIgnoreCase))) - { - string file = files.First(f => Path.GetFileName(f).Equals("TagesSetup.exe", StringComparison.OrdinalIgnoreCase)); - protections.Add("TAGES Setup " + Utilities.GetFileVersion(file)); - } - if (files.Any(f => Path.GetFileName(f).Equals("TagesSetup_x64.exe", StringComparison.OrdinalIgnoreCase))) - { - string file = files.First(f => Path.GetFileName(f).Equals("TagesSetup_x64.exe", StringComparison.OrdinalIgnoreCase)); - protections.Add("TAGES Setup " + Utilities.GetFileVersion(file)); - } - - if (protections.Count() == 0) - return null; - else - return string.Join(", ", protections); + protections.Add("TAGES"); } - else + if (files.Any(f => Path.GetFileName(f).Equals("tagesclient.exe", StringComparison.OrdinalIgnoreCase))) { - if (Path.GetFileName(path).Equals("Tages.dll", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("Wave.aif", StringComparison.OrdinalIgnoreCase)) - { - return "TAGES"; - } - else if (Path.GetFileName(path).Equals("tagesclient.exe", StringComparison.OrdinalIgnoreCase)) - { - return "TAGES Activation Client " + Utilities.GetFileVersion(path); - } - else if (Path.GetFileName(path).Equals("TagesSetup.exe", StringComparison.OrdinalIgnoreCase)) - { - return "TAGES Setup " + Utilities.GetFileVersion(path); - } - else if (Path.GetFileName(path).Equals("TagesSetup_x64.exe", StringComparison.OrdinalIgnoreCase)) - { - return "TAGES Setup " + Utilities.GetFileVersion(path); - } + string file = files.First(f => Path.GetFileName(f).Equals("tagesclient.exe", StringComparison.OrdinalIgnoreCase)); + protections.Add("TAGES Activation Client " + Utilities.GetFileVersion(file)); + } + if (files.Any(f => Path.GetFileName(f).Equals("TagesSetup.exe", StringComparison.OrdinalIgnoreCase))) + { + string file = files.First(f => Path.GetFileName(f).Equals("TagesSetup.exe", StringComparison.OrdinalIgnoreCase)); + protections.Add("TAGES Setup " + Utilities.GetFileVersion(file)); + } + if (files.Any(f => Path.GetFileName(f).Equals("TagesSetup_x64.exe", StringComparison.OrdinalIgnoreCase))) + { + string file = files.First(f => Path.GetFileName(f).Equals("TagesSetup_x64.exe", StringComparison.OrdinalIgnoreCase)); + protections.Add("TAGES Setup " + Utilities.GetFileVersion(file)); + } + + if (protections.Count() == 0) + return null; + else + return string.Join(", ", protections); + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("Tages.dll", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("Wave.aif", StringComparison.OrdinalIgnoreCase)) + { + return "TAGES"; + } + else if (Path.GetFileName(path).Equals("tagesclient.exe", StringComparison.OrdinalIgnoreCase)) + { + return "TAGES Activation Client " + Utilities.GetFileVersion(path); + } + else if (Path.GetFileName(path).Equals("TagesSetup.exe", StringComparison.OrdinalIgnoreCase)) + { + return "TAGES Setup " + Utilities.GetFileVersion(path); + } + else if (Path.GetFileName(path).Equals("TagesSetup_x64.exe", StringComparison.OrdinalIgnoreCase)) + { + return "TAGES Setup " + Utilities.GetFileVersion(path); } return null; diff --git a/BurnOutSharp/ProtectionType/Uplay.cs b/BurnOutSharp/ProtectionType/Uplay.cs index 0acaa635..d471034d 100644 --- a/BurnOutSharp/ProtectionType/Uplay.cs +++ b/BurnOutSharp/ProtectionType/Uplay.cs @@ -8,18 +8,19 @@ namespace BurnOutSharp.ProtectionType public class Uplay : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("UplayInstaller.exe", StringComparison.OrdinalIgnoreCase))) - return "Uplay"; - } - else - { - if (Path.GetFileName(path).Equals("UplayInstaller.exe", StringComparison.OrdinalIgnoreCase)) - return "Uplay"; - } + if (files.Any(f => Path.GetFileName(f).Equals("UplayInstaller.exe", StringComparison.OrdinalIgnoreCase))) + return "Uplay"; + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("UplayInstaller.exe", StringComparison.OrdinalIgnoreCase)) + return "Uplay"; return null; } diff --git a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs index 221bfca1..30283367 100644 --- a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs +++ b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs @@ -46,18 +46,19 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("VOB-PCD.KEY", StringComparison.OrdinalIgnoreCase))) - return "VOB ProtectCD/DVD"; - } - else - { - if (Path.GetFileName(path).Equals("VOB-PCD.KEY", StringComparison.OrdinalIgnoreCase)) - return "VOB ProtectCD/DVD"; - } + if (files.Any(f => Path.GetFileName(f).Equals("VOB-PCD.KEY", StringComparison.OrdinalIgnoreCase))) + return "VOB ProtectCD/DVD"; + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("VOB-PCD.KEY", StringComparison.OrdinalIgnoreCase)) + return "VOB ProtectCD/DVD"; return null; } diff --git a/BurnOutSharp/ProtectionType/WTMCDProtect.cs b/BurnOutSharp/ProtectionType/WTMCDProtect.cs index 18f80819..51e04fc7 100644 --- a/BurnOutSharp/ProtectionType/WTMCDProtect.cs +++ b/BurnOutSharp/ProtectionType/WTMCDProtect.cs @@ -19,28 +19,29 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetExtension(f).Trim('.').Equals("IMP", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("imp.dat", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("wtmfiles.dat", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("Viewer.exe", StringComparison.OrdinalIgnoreCase))) { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetExtension(f).Trim('.').Equals("IMP", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("imp.dat", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("wtmfiles.dat", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("Viewer.exe", StringComparison.OrdinalIgnoreCase))) - { - return "WTM CD Protect"; - } + return "WTM CD Protect"; } - else + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetExtension(path).Trim('.').Equals("IMP", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("imp.dat", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("wtmfiles.dat", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("Viewer.exe", StringComparison.OrdinalIgnoreCase)) { - if (Path.GetExtension(path).Trim('.').Equals("IMP", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("imp.dat", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("wtmfiles.dat", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("Viewer.exe", StringComparison.OrdinalIgnoreCase)) - { - return "WTM CD Protect"; - } + return "WTM CD Protect"; } return null; diff --git a/BurnOutSharp/ProtectionType/Winlock.cs b/BurnOutSharp/ProtectionType/Winlock.cs index 05861bb4..b0831d63 100644 --- a/BurnOutSharp/ProtectionType/Winlock.cs +++ b/BurnOutSharp/ProtectionType/Winlock.cs @@ -8,18 +8,19 @@ namespace BurnOutSharp.ProtectionType public class Winlock : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (files.Any(f => Path.GetFileName(f).Equals("WinLock.PSX", StringComparison.OrdinalIgnoreCase))) - return "Winlock"; - } - else - { - if (Path.GetFileName(path).Equals("WinLock.PSX", StringComparison.OrdinalIgnoreCase)) - return "Winlock"; - } + if (files.Any(f => Path.GetFileName(f).Equals("WinLock.PSX", StringComparison.OrdinalIgnoreCase))) + return "Winlock"; + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("WinLock.PSX", StringComparison.OrdinalIgnoreCase)) + return "Winlock"; return null; } diff --git a/BurnOutSharp/ProtectionType/XCP.cs b/BurnOutSharp/ProtectionType/XCP.cs index f61c2179..66a4f107 100644 --- a/BurnOutSharp/ProtectionType/XCP.cs +++ b/BurnOutSharp/ProtectionType/XCP.cs @@ -30,34 +30,35 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) + // TODO: Verify if these are OR or AND + if (files.Any(f => Path.GetFileName(f).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase)) + || files.Any(f => Path.GetFileName(f).Equals("go.exe", StringComparison.OrdinalIgnoreCase))) // Path.Combine("contents", "go.exe") { - // TODO: Verify if these are OR or AND - if (files.Any(f => Path.GetFileName(f).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase)) - || files.Any(f => Path.GetFileName(f).Equals("go.exe", StringComparison.OrdinalIgnoreCase))) // Path.Combine("contents", "go.exe") + string versionDatPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("VERSION.DAT", StringComparison.OrdinalIgnoreCase)); + if (!string.IsNullOrWhiteSpace(versionDatPath)) { - string versionDatPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("VERSION.DAT", StringComparison.OrdinalIgnoreCase)); - if (!string.IsNullOrWhiteSpace(versionDatPath)) - { - string xcpVersion = GetDatVersion(versionDatPath); - if (!string.IsNullOrWhiteSpace(xcpVersion)) - return xcpVersion; - } + string xcpVersion = GetDatVersion(versionDatPath); + if (!string.IsNullOrWhiteSpace(xcpVersion)) + return xcpVersion; + } - return "XCP"; - } + return "XCP"; } - else + + return null; + } + + /// + public string CheckFilePath(string path) + { + if (Path.GetFileName(path).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("go.exe", StringComparison.OrdinalIgnoreCase)) { - if (Path.GetFileName(path).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase) - || Path.GetFileName(path).Equals("go.exe", StringComparison.OrdinalIgnoreCase)) - { - return "XCP"; - } + return "XCP"; } return null; diff --git a/BurnOutSharp/ProtectionType/Zzxzz.cs b/BurnOutSharp/ProtectionType/Zzxzz.cs index 46297d37..78033a7b 100644 --- a/BurnOutSharp/ProtectionType/Zzxzz.cs +++ b/BurnOutSharp/ProtectionType/Zzxzz.cs @@ -7,22 +7,23 @@ namespace BurnOutSharp.ProtectionType public class Zzxzz : IPathCheck { /// - public string CheckPath(string path, bool isDirectory, IEnumerable files) + public string CheckDirectoryPath(string path, IEnumerable files) { - if (isDirectory) - { - if (File.Exists(Path.Combine(path, "Zzxzz", "Zzz.aze"))) - return "Zzxzz"; + if (File.Exists(Path.Combine(path, "Zzxzz", "Zzz.aze"))) + return "Zzxzz"; - else if (Directory.Exists(Path.Combine(path, "Zzxzz"))) - return "Zzxzz"; - } - else - { - string filename = Path.GetFileName(path); - if (filename.Equals("Zzz.aze", StringComparison.OrdinalIgnoreCase)) - return "Zzxzz"; - } + else if (Directory.Exists(Path.Combine(path, "Zzxzz"))) + return "Zzxzz"; + + return null; + } + + /// + public string CheckFilePath(string path) + { + string filename = Path.GetFileName(path); + if (filename.Equals("Zzz.aze", StringComparison.OrdinalIgnoreCase)) + return "Zzxzz"; return null; } diff --git a/BurnOutSharp/Scanner.cs b/BurnOutSharp/Scanner.cs index 49e064cf..6d2f099d 100644 --- a/BurnOutSharp/Scanner.cs +++ b/BurnOutSharp/Scanner.cs @@ -198,7 +198,13 @@ namespace BurnOutSharp foreach (var pathCheckClass in pathCheckClasses) { IPathCheck pathCheck = Activator.CreateInstance(pathCheckClass) as IPathCheck; - string protection = pathCheck.CheckPath(path, isDirectory, files); + + string protection = null; + if (isDirectory) + protection = pathCheck.CheckDirectoryPath(path, files); + else + protection = pathCheck.CheckFilePath(path); + if (!string.IsNullOrWhiteSpace(protection)) protections.Add(protection); }