From 550086791bf1d6baca868487828acfaa2435acba Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 27 Sep 2019 23:52:24 -0700 Subject: [PATCH 01/14] Separate protections into their own classes --- BurnOutSharp/BurnOutSharp.csproj | 80 + BurnOutSharp/ProtectionFind.cs | 1708 +++++------------ BurnOutSharp/ProtectionType/AACS.cs | 33 + BurnOutSharp/ProtectionType/ActiveMARK.cs | 22 + BurnOutSharp/ProtectionType/Alcatraz.cs | 7 + BurnOutSharp/ProtectionType/AlphaAudio.cs | 7 + BurnOutSharp/ProtectionType/AlphaDVD.cs | 26 + BurnOutSharp/ProtectionType/AlphaROM.cs | 13 + BurnOutSharp/ProtectionType/Armadillo.cs | 14 + BurnOutSharp/ProtectionType/Bitpool.cs | 26 + BurnOutSharp/ProtectionType/ByteShield.cs | 32 + BurnOutSharp/ProtectionType/CDCheck.cs | 14 + BurnOutSharp/ProtectionType/CDCops.cs | 64 + BurnOutSharp/ProtectionType/CDLock.cs | 38 + BurnOutSharp/ProtectionType/CDProtector.cs | 37 + BurnOutSharp/ProtectionType/CDSHiELDSE.cs | 13 + BurnOutSharp/ProtectionType/CDX.cs | 35 + .../ProtectionType/CactusDataShield.cs | 64 + .../ProtectionType/CengaProtectDVD.cs | 13 + BurnOutSharp/ProtectionType/CodeLock.cs | 18 + BurnOutSharp/ProtectionType/CopyKiller.cs | 34 + BurnOutSharp/ProtectionType/CopyLok.cs | 7 + BurnOutSharp/ProtectionType/CrypKey.cs | 7 + BurnOutSharp/ProtectionType/Cucko.cs | 14 + BurnOutSharp/ProtectionType/DBB.cs | 7 + BurnOutSharp/ProtectionType/DVDCops.cs | 30 + BurnOutSharp/ProtectionType/DVDCrypt.cs | 26 + .../ProtectionType/DVDMoviePROTECT.cs | 29 + BurnOutSharp/ProtectionType/DiscGuard.cs | 33 + BurnOutSharp/ProtectionType/EACdKey.cs | 13 + BurnOutSharp/ProtectionType/EXEStealth.cs | 17 + BurnOutSharp/ProtectionType/FADE.cs | 7 + BurnOutSharp/ProtectionType/FreeLock.cs | 26 + BurnOutSharp/ProtectionType/GFWL.cs | 34 + .../ProtectionType/HexalockAutoLock.cs | 37 + BurnOutSharp/ProtectionType/ImpulseReactor.cs | 47 + BurnOutSharp/ProtectionType/IndyVCD.cs | 33 + BurnOutSharp/ProtectionType/InnoSetup.cs | 45 + BurnOutSharp/ProtectionType/JoWooDXProt.cs | 49 + BurnOutSharp/ProtectionType/Key2AudioXS.cs | 33 + BurnOutSharp/ProtectionType/KeyLock.cs | 13 + BurnOutSharp/ProtectionType/LaserLock.cs | 133 ++ BurnOutSharp/ProtectionType/LockBlocks.cs | 7 + BurnOutSharp/ProtectionType/MediaCloQ.cs | 26 + BurnOutSharp/ProtectionType/MediaMaxCD3.cs | 26 + BurnOutSharp/ProtectionType/MusicGuard.cs | 7 + BurnOutSharp/ProtectionType/Origin.cs | 26 + BurnOutSharp/ProtectionType/PECompact.cs | 13 + BurnOutSharp/ProtectionType/PSXAntiModchip.cs | 53 + BurnOutSharp/ProtectionType/Phenoprotect.cs | 7 + .../ProtectionType/ProtectDVDVideo.cs | 28 + BurnOutSharp/ProtectionType/ProtectDisc.cs | 157 ++ BurnOutSharp/ProtectionType/RingPROTECH.cs | 13 + BurnOutSharp/ProtectionType/Roxxe.cs | 7 + BurnOutSharp/ProtectionType/SAFEAUDIO.cs | 7 + BurnOutSharp/ProtectionType/SVKProtector.cs | 13 + BurnOutSharp/ProtectionType/SafeCast.cs | 26 + BurnOutSharp/ProtectionType/SafeDisc.cs | 204 ++ BurnOutSharp/ProtectionType/SafeDiscLite.cs | 26 + BurnOutSharp/ProtectionType/SafeLock.cs | 43 + BurnOutSharp/ProtectionType/SecuROM.cs | 161 ++ BurnOutSharp/ProtectionType/SmartE.cs | 41 + BurnOutSharp/ProtectionType/SoftLock.cs | 33 + BurnOutSharp/ProtectionType/SolidShield.cs | 143 ++ BurnOutSharp/ProtectionType/StarForce.cs | 68 + BurnOutSharp/ProtectionType/Steam.cs | 38 + BurnOutSharp/ProtectionType/Sysiphus.cs | 36 + .../ProtectionType/TZCopyProtector.cs | 26 + BurnOutSharp/ProtectionType/Tages.cs | 94 + BurnOutSharp/ProtectionType/TheBongle.cs | 7 + .../ProtectionType/TheCopyProtectedCD.cs | 7 + BurnOutSharp/ProtectionType/ThreePLock.cs | 17 + BurnOutSharp/ProtectionType/Uplay.cs | 26 + .../ProtectionType/VOBProtectCDDVD.cs | 118 ++ BurnOutSharp/ProtectionType/WTMCDProtect.cs | 45 + BurnOutSharp/ProtectionType/Winlock.cs | 26 + BurnOutSharp/ProtectionType/XCP.cs | 35 + .../ProtectionType/XtremeProtector.cs | 13 + BurnOutSharp/ProtectionType/Zzxzz.cs | 28 + BurnOutSharp/ProtectionType/dotFuscator.cs | 13 + BurnOutSharp/Utilities.cs | 288 +++ Test/Program.cs | 2 + 82 files changed, 3679 insertions(+), 1213 deletions(-) create mode 100644 BurnOutSharp/ProtectionType/AACS.cs create mode 100644 BurnOutSharp/ProtectionType/ActiveMARK.cs create mode 100644 BurnOutSharp/ProtectionType/Alcatraz.cs create mode 100644 BurnOutSharp/ProtectionType/AlphaAudio.cs create mode 100644 BurnOutSharp/ProtectionType/AlphaDVD.cs create mode 100644 BurnOutSharp/ProtectionType/AlphaROM.cs create mode 100644 BurnOutSharp/ProtectionType/Armadillo.cs create mode 100644 BurnOutSharp/ProtectionType/Bitpool.cs create mode 100644 BurnOutSharp/ProtectionType/ByteShield.cs create mode 100644 BurnOutSharp/ProtectionType/CDCheck.cs create mode 100644 BurnOutSharp/ProtectionType/CDCops.cs create mode 100644 BurnOutSharp/ProtectionType/CDLock.cs create mode 100644 BurnOutSharp/ProtectionType/CDProtector.cs create mode 100644 BurnOutSharp/ProtectionType/CDSHiELDSE.cs create mode 100644 BurnOutSharp/ProtectionType/CDX.cs create mode 100644 BurnOutSharp/ProtectionType/CactusDataShield.cs create mode 100644 BurnOutSharp/ProtectionType/CengaProtectDVD.cs create mode 100644 BurnOutSharp/ProtectionType/CodeLock.cs create mode 100644 BurnOutSharp/ProtectionType/CopyKiller.cs create mode 100644 BurnOutSharp/ProtectionType/CopyLok.cs create mode 100644 BurnOutSharp/ProtectionType/CrypKey.cs create mode 100644 BurnOutSharp/ProtectionType/Cucko.cs create mode 100644 BurnOutSharp/ProtectionType/DBB.cs create mode 100644 BurnOutSharp/ProtectionType/DVDCops.cs create mode 100644 BurnOutSharp/ProtectionType/DVDCrypt.cs create mode 100644 BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs create mode 100644 BurnOutSharp/ProtectionType/DiscGuard.cs create mode 100644 BurnOutSharp/ProtectionType/EACdKey.cs create mode 100644 BurnOutSharp/ProtectionType/EXEStealth.cs create mode 100644 BurnOutSharp/ProtectionType/FADE.cs create mode 100644 BurnOutSharp/ProtectionType/FreeLock.cs create mode 100644 BurnOutSharp/ProtectionType/GFWL.cs create mode 100644 BurnOutSharp/ProtectionType/HexalockAutoLock.cs create mode 100644 BurnOutSharp/ProtectionType/ImpulseReactor.cs create mode 100644 BurnOutSharp/ProtectionType/IndyVCD.cs create mode 100644 BurnOutSharp/ProtectionType/InnoSetup.cs create mode 100644 BurnOutSharp/ProtectionType/JoWooDXProt.cs create mode 100644 BurnOutSharp/ProtectionType/Key2AudioXS.cs create mode 100644 BurnOutSharp/ProtectionType/KeyLock.cs create mode 100644 BurnOutSharp/ProtectionType/LaserLock.cs create mode 100644 BurnOutSharp/ProtectionType/LockBlocks.cs create mode 100644 BurnOutSharp/ProtectionType/MediaCloQ.cs create mode 100644 BurnOutSharp/ProtectionType/MediaMaxCD3.cs create mode 100644 BurnOutSharp/ProtectionType/MusicGuard.cs create mode 100644 BurnOutSharp/ProtectionType/Origin.cs create mode 100644 BurnOutSharp/ProtectionType/PECompact.cs create mode 100644 BurnOutSharp/ProtectionType/PSXAntiModchip.cs create mode 100644 BurnOutSharp/ProtectionType/Phenoprotect.cs create mode 100644 BurnOutSharp/ProtectionType/ProtectDVDVideo.cs create mode 100644 BurnOutSharp/ProtectionType/ProtectDisc.cs create mode 100644 BurnOutSharp/ProtectionType/RingPROTECH.cs create mode 100644 BurnOutSharp/ProtectionType/Roxxe.cs create mode 100644 BurnOutSharp/ProtectionType/SAFEAUDIO.cs create mode 100644 BurnOutSharp/ProtectionType/SVKProtector.cs create mode 100644 BurnOutSharp/ProtectionType/SafeCast.cs create mode 100644 BurnOutSharp/ProtectionType/SafeDisc.cs create mode 100644 BurnOutSharp/ProtectionType/SafeDiscLite.cs create mode 100644 BurnOutSharp/ProtectionType/SafeLock.cs create mode 100644 BurnOutSharp/ProtectionType/SecuROM.cs create mode 100644 BurnOutSharp/ProtectionType/SmartE.cs create mode 100644 BurnOutSharp/ProtectionType/SoftLock.cs create mode 100644 BurnOutSharp/ProtectionType/SolidShield.cs create mode 100644 BurnOutSharp/ProtectionType/StarForce.cs create mode 100644 BurnOutSharp/ProtectionType/Steam.cs create mode 100644 BurnOutSharp/ProtectionType/Sysiphus.cs create mode 100644 BurnOutSharp/ProtectionType/TZCopyProtector.cs create mode 100644 BurnOutSharp/ProtectionType/Tages.cs create mode 100644 BurnOutSharp/ProtectionType/TheBongle.cs create mode 100644 BurnOutSharp/ProtectionType/TheCopyProtectedCD.cs create mode 100644 BurnOutSharp/ProtectionType/ThreePLock.cs create mode 100644 BurnOutSharp/ProtectionType/Uplay.cs create mode 100644 BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs create mode 100644 BurnOutSharp/ProtectionType/WTMCDProtect.cs create mode 100644 BurnOutSharp/ProtectionType/Winlock.cs create mode 100644 BurnOutSharp/ProtectionType/XCP.cs create mode 100644 BurnOutSharp/ProtectionType/XtremeProtector.cs create mode 100644 BurnOutSharp/ProtectionType/Zzxzz.cs create mode 100644 BurnOutSharp/ProtectionType/dotFuscator.cs create mode 100644 BurnOutSharp/Utilities.cs diff --git a/BurnOutSharp/BurnOutSharp.csproj b/BurnOutSharp/BurnOutSharp.csproj index 18a29bc6..bce3162c 100644 --- a/BurnOutSharp/BurnOutSharp.csproj +++ b/BurnOutSharp/BurnOutSharp.csproj @@ -38,6 +38,7 @@ + @@ -57,6 +58,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BurnOutSharp/ProtectionFind.cs b/BurnOutSharp/ProtectionFind.cs index 15daa9be..5e40dfc3 100644 --- a/BurnOutSharp/ProtectionFind.cs +++ b/BurnOutSharp/ProtectionFind.cs @@ -18,10 +18,11 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Text; +using System.Threading; +using BurnOutSharp.ProtectionType; using LibMSPackN; using UnshieldSharp; @@ -35,23 +36,6 @@ public static class ProtectionFind /// Path to scan for protection(s) /// Optional progress indicator that will return a float in the range from 0 to 1 /// Dictionary of filename to protection mappings, if possible - /// - /// TODO: Sector scanning? - /// The following protections are known, but not detected: - /// - Alcatraz (http://www.kdg-mt.com/1/product_d_6.html) - /// - AlphaAudio (http://settec.net/eng/pro_cd.html) - /// - CopyLok / CodeLok (http://web.archive.org/web/20041215075727/http://www.panlok.com/codelok2.htm) - /// - CrypKey (http://www.crypkey.com/products/cdlock/cdmain.html) - /// - DBB (http://web.archive.org/web/20040604233815/www.wkit.com/sites/wkit/setup/eng/index.asp) - /// - FADE (http://www.codemasters.com/news/displayarticles.php?showarticle=500) - /// - LockBlocks (https://www.cdmediaworld.com/hardware/cdrom/cd_protections_lockblocks.shtml) - /// - MusicGuard (http://web.archive.org/web/20020606000647/http://www.musicguard.com) - /// - Phenoprotect (https://www.cdmediaworld.com/hardware/cdrom/cd_protections_phenoprotect.shtml) - /// - Roxxe (http://web.archive.org/web/20050309084802/http://www.roxxe.cz) - /// - SAFEAUDIO (https://www.cdmediaworld.com/hardware/cdrom/cd_protections_safeaudio.shtml) - /// - The Bongle (http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm) - /// - The Copy-Protected CD (http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm) - /// public static Dictionary Scan(string path, IProgress progress = null) { var protections = new Dictionary(); @@ -59,80 +43,56 @@ public static Dictionary Scan(string path, IProgress !String.IsNullOrWhiteSpace(p.Value)) == 0) + if (protections.Count(p => !string.IsNullOrWhiteSpace(p.Value)) == 0) { protections = new Dictionary(); } @@ -140,6 +100,241 @@ public static Dictionary Scan(string path, IProgress + /// Scan a path for indications of copy protection + /// + /// + /// + /// + private static string ScanPath(string path, bool isDirectory) + { + List protections = new List(); + string protection; + + // If we have a directory, get the files in the directory for searching + IEnumerable files = null; + if (isDirectory) + files = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories); + + // AACS + protection = AACS.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Alpha-DVD + protection = AlphaDVD.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Bitpool + protection = Bitpool.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // ByteShield + protection = ByteShield.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Cactus Data Shield + protection = CactusDataShield.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CD-Cops + protection = CDCops.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CD-Lock + protection = CDLock.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CD-Protector + protection = CDProtector.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CD-X + protection = CDX.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + /* + // CopyKiller + protection = CopyKiller.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + */ + + // DiscGuard + protection = DiscGuard.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // DVD Crypt + protection = DVDCrypt.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // DVD-Movie-PROTECT + protection = DVDMoviePROTECT.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // FreeLock + protection = FreeLock.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Games for Windows - Live + protection = GFWL.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Hexalock AutoLock + protection = HexalockAutoLock.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Impulse Reactor + protection = ImpulseReactor.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // IndyVCD + protection = IndyVCD.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Key2Audio XS + protection = Key2AudioXS.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // LaserLock + protection = LaserLock.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // MediaCloQ + protection = MediaCloQ.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // MediaMax CD3 + protection = MediaMaxCD3.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Origin + protection = Origin.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Protect DVD-Video + protection = ProtectDVDVideo.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // PSX Anti-modchip + protection = PSXAntiModchip.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SafeCast + protection = SafeCast.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SafeDisc Lite + protection = SafeDiscLite.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SafeLock + protection = SafeLock.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SecuROM + protection = SecuROM.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SmartE + protection = SmartE.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SoftLock + protection = SoftLock.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SolidShield + protection = SolidShield.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // StarForce + protection = StarForce.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Steam + protection = Steam.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // TAGES + protection = Tages.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // TZCopyProtector + protection = TZCopyProtector.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Uplay + protection = Uplay.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // VOB ProtectCD/DVD + protection = VOBProtectCDDVD.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Winlock + protection = Winlock.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // WTM CD Protect + protection = WTMCDProtect.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // XCP + protection = XCP.CheckPath(path, files, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Zzxzz + protection = Zzxzz.CheckPath(path, isDirectory); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Now combine any found protections, or null if empty + if (protections.Count() == 0) + return null; + else + return string.Join(", ", protections); + } + /// /// Scan an individual file for copy protection /// @@ -154,7 +349,7 @@ private static string ScanInFile(string file) { using (BinaryReader br = new BinaryReader(File.OpenRead(file))) { - magic = new String(br.ReadChars(8)); + magic = new string(br.ReadChars(8)); } } catch @@ -163,6 +358,9 @@ private static string ScanInFile(string file) return null; } + // Files can be protected in multiple ways + List protections = new List(); + #region Executable Content Checks // Windows Executable and DLL @@ -172,258 +370,194 @@ private static string ScanInFile(string file) { // Load the current file and check for specialty strings first StreamReader sr = new StreamReader(file, Encoding.Default); - int position = -1; - string FileContent = sr.ReadToEnd(); + string protection; + string fileContent = sr.ReadToEnd(); sr.Close(); + // 3PLock + protection = ThreePLock.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // ActiveMARK + protection = ActiveMARK.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Alpha-ROM + protection = AlphaROM.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Armadillo + protection = Armadillo.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + // CD-Cops - if ((position = FileContent.IndexOf("CD-Cops, ver. ")) > -1) - return "CD-Cops " + GetCDDVDCopsVersion(file, position); + protection = CDCops.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CD-Lock + protection = CDLock.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CDSHiELD SE + protection = CDSHiELDSE.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CD Check + protection = CDCheck.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Cenega ProtectDVD + protection = CengaProtectDVD.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Code Lock + protection = CodeLock.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CopyKiller + protection = CopyKiller.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Cucko (EA Custom) + protection = Cucko.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // dotFuscator + protection = dotFuscator.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); // DVD-Cops - if ((position = FileContent.IndexOf("DVD-Cops, ver. ")) > -1) - return "DVD-Cops " + GetCDDVDCopsVersion(file, position); + protection = DVDCops.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // EA CdKey Registration Module + protection = EACdKey.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // EXE Stealth + protection = EXEStealth.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Games for Windows - Live + protection = GFWL.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); // Impulse Reactor - if (FileContent.Contains("CVPInitializeClient") - && FileContent.Contains("A" + (char)0x00 + "T" + (char)0x00 + "T" + (char)0x00 + "L" + (char)0x00 + "I" - + (char)0x00 + "S" + (char)0x00 + "T" + (char)0x00 + (char)0x00 + (char)0x00 + "E" + (char)0x00 + "L" - + (char)0x00 + "E" + (char)0x00 + "M" + (char)0x00 + "E" + (char)0x00 + "N" + (char)0x00 + "T" + (char)0x00 - + (char)0x00 + (char)0x00 + "N" + (char)0x00 + "O" + (char)0x00 + "T" + (char)0x00 + "A" + (char)0x00 + "T" - + (char)0x00 + "I" + (char)0x00 + "O" + (char)0x00 + "N")) - return "Impulse Reactor " + GetFileVersion(file); + protection = ImpulseReactor.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); // Inno Setup - if ((position = FileContent.IndexOf("Inno")) == 0x30) - { - // TOOO: Add Inno Setup extraction - return "Inno Setup " + GetInnoSetupVersion(file); - } + protection = InnoSetup.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); // JoWooD X-Prot - if (FileContent.Contains(".ext ") - && (position = FileContent.IndexOf("kernel32.dll" + (char)0x00 + (char)0x00 + (char)0x00 + "VirtualProtect")) > -1) - return "JoWooD X-Prot " + GetJoWooDXProt1Version(file, --position); + protection = JoWooDXProt.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); - // LaserLock - if (FileContent.Contains("Packed by SPEEnc V2 Asterios Parlamentas.PE") - && (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 " + GetLaserLockVersion(FileContent, position) + " " + GetLaserLockBuild(FileContent, true); + // Key-Lock (Dongle) + protection = KeyLock.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); - if (FileContent.Contains("Packed by SPEEnc V2 Asterios Parlamentas.PE")) - return "LaserLock Marathon " + GetLaserLockBuild(FileContent, false); + // LaserLock + protection = LaserLock.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); - 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 " + GetLaserLockVersion(FileContent, --position) + " " + GetLaserLockBuild(FileContent, false); + // PE Compact + protection = PECompact.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); // ProtectDisc - if ((position = FileContent.IndexOf("HúMETINF")) > -1) - { - string version = EVORE.SearchProtectDiscVersion(file); - if (version.Length > 0) - { - string[] astrVersionArray = version.Split('.'); - if (astrVersionArray[0] == "9") - { - if (GetProtectDiscVersionBuild76till10(file, position, out int ibuild).Length > 0) - return "ProtectDisc " + astrVersionArray[0] + "." + astrVersionArray[1] + astrVersionArray[2] + "." + astrVersionArray[3] + " (Build " + ibuild + ")"; - } - else - return "ProtectDisc " + astrVersionArray[0] + "." + astrVersionArray[1] + "." + astrVersionArray[2] + " (Build " + astrVersionArray[3] + ")"; - } - } - - if ((position = FileContent.IndexOf("ACE-PCD")) > -1) - { - string version = EVORE.SearchProtectDiscVersion(file); - if (version.Length > 0) - { - string[] astrVersionArray = version.Split('.'); - return "ProtectDisc " + astrVersionArray[0] + "." + astrVersionArray[1] + "." + astrVersionArray[2] + " (Build " + astrVersionArray[3] + ")"; - } + protection = ProtectDisc.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); - return "ProtectDisc " + GetProtectDiscVersionBuild6till8(file, position); - } + // Ring PROTECH + protection = RingPROTECH.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); // SafeDisc / SafeCast - if ((position = FileContent.IndexOf("BoG_ *90.0&!! Yy>")) > -1) - { - if (FileContent.IndexOf("product activation library") > 0) - return "SafeCast " + GetSafeDiscVersion(file, position); - else - return "SafeDisc " + GetSafeDiscVersion(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; + protection = SafeDisc.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); - return "SafeDisc 3.20-4.xx (version removed)"; - } + // SafeLock + protection = SafeLock.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); // SecuROM - if ((position = FileContent.IndexOf("AddD" + (char)0x03 + (char)0x00 + (char)0x00 + (char)0x00)) > -1) - return "SecuROM " + GetSecuROM4Version(file, position); - - if ((position = FileContent.IndexOf("" + (char)0xCA + (char)0xDD + (char)0xDD + (char)0xAC + (char)0x03)) > -1) - return "SecuROM " + GetSecuROM4and5Version(file, position); + protection = SecuROM.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); - if (FileContent.Contains(".securom") - || FileContent.StartsWith(".securom" + (char)0xE0 + (char)0xC0)) - return "SecuROM " + GetSecuROM7Version(file); - - if (FileContent.Contains("_and_play.dll" + (char)0x00 + "drm_pagui_doit")) - return "SecuROM Product Activation " + GetFileVersion(file); + // SmartE + protection = SmartE.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); // SolidShield - if (FileContent.Contains("D" + (char)0x00 + "V" + (char)0x00 + "M" + (char)0x00 + " " + (char)0x00 + "L" + (char)0x00 - + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y")) - return "SolidShield " + GetFileVersion(file); - - 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") - || 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 + "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 - + "L" + (char)0x00 + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y")) - { - string companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower(); - if (companyName.Contains("solidshield") || companyName.Contains("tages")) - return "SolidShield Core.dll " + GetFileVersion(file); - } - - 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); - - if (id1 == "" + (char)0x00 + (char)0x00 + (char)0x00 && id2 == "" + (char)0x00 + (char)0x10 + (char)0x00 + (char)0x00) - return "SolidShield 1 (SolidShield EXE Wrapper)"; - else if (id1 == ".o&" && id2 == "ÛÅ›¹") - return "SolidShield 2 (SolidShield v2 EXE Wrapper)"; // TODO: Verify against other SolidShield 2 discs - } - - 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")) - { - string companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower(); - if (companyName.Contains("solidshield") || companyName.Contains("tages")) - return "SolidShield Activation Manager Module " + GetFileVersion(file); - } - - 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 - && FileContent.Substring(position + 15, 4) == "" + (char)0x00 + (char)0x10 + (char)0x00 + (char)0x00) - { - return "SolidShield 2 (SolidShield v2 EXE Wrapper)"; - } - else if (FileContent.Substring(position + 4, 3) == "" + (char)0x00 + (char)0x00 + (char)0x00 - && FileContent.Substring(position + 15, 4) == "" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00) - { - position = FileContent.IndexOf("T" + (char)0x00 + "a" + (char)0x00 + "g" + (char)0x00 + "e" + (char)0x00 + "s" - + (char)0x00 + "S" + (char)0x00 + "e" + (char)0x00 + "t" + (char)0x00 + "u" + (char)0x00 + "p" - + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "0" + (char)0x00 + (char)0x8 - + (char)0x00 + (char)0x1 + (char)0x0 + "F" + (char)0x00 + "i" + (char)0x00 + "l" + (char)0x00 + "e" - + (char)0x00 + "V" + (char)0x00 + "e" + (char)0x00 + "r" + (char)0x00 + "s" + (char)0x00 + "i" + (char)0x00 - + "o" + (char)0x00 + "n" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00); - if (position > -1) - { - position--; // TODO: Verify this subtract - return "SolidShield 2 + Tagès " + FileContent.Substring(position + 0x38, 1) + "." + FileContent.Substring(position + 0x38 + 4, 1) + "." + FileContent.Substring(position + 0x38 + 8, 1) + "." + FileContent.Substring(position + 0x38 + 12, 1); - } - else - { - return "SolidShield 2 (SolidShield v2 EXE Wrapper)"; - } - } - } - - if ((position = FileContent.IndexOf("Solidshield")) > 0) - return "SolidShield " + GetSolidShieldVersion(file, position); + protection = SolidShield.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); // StarForce - if (FileContent.Contains("(" + (char)0x00 + "c" + (char)0x00 + ")" + (char)0x00 + " " + (char)0x00 + "P" + (char)0x00 - + "r" + (char)0x00 + "o" + (char)0x00 + "t" + (char)0x00 + "e" + (char)0x00 + "c" + (char)0x00 + "t" + (char)0x00 - + "i" + (char)0x00 + "o" + (char)0x00 + "n" + (char)0x00 + " " + (char)0x00 + "T" + (char)0x00 + "e" + (char)0x00 - + "c" + (char)0x00 + "h" + (char)0x00 + "n" + (char)0x00 + "o" + (char)0x00 + "l" + (char)0x00 + "o" + (char)0x00 - + "g" + (char)0x00 + "y" + (char)0x00) - || FileContent.Contains("Protection Technology, Ltd.")) - { - //if (FileContent.Contains("PSA_GetDiscLabel") - //if (FileContent.Contains("(c) Protection Technology") - position = FileContent.IndexOf("TradeName") - 1; - if (position != -1 && position != -2) - return "StarForce " + GetFileVersion(file) + " (" + FileContent.Substring(position + 22, 30).Split((char)0x00)[0] + ")"; - else - return "StarForce " + GetFileVersion(file); - } + protection = StarForce.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); - // Sysiphus / Sysiphus DVD - if ((position = FileContent.IndexOf("V SUHPISYSDVD")) > -1) - return "Sysiphus DVD " + GetSysiphusVersion(file, position); + // SVK Protector + protection = SVKProtector.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); - if ((position = FileContent.IndexOf("V SUHPISYS")) > -1) - return "Sysiphus " + GetSysiphusVersion(file, position); + // Sysiphus / Sysiphus DVD + protection = Sysiphus.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); // TAGES - if (FileContent.Contains("protected-tages-runtime.exe") || - FileContent.Contains("tagesprotection.com")) - return "TAGES " + GetFileVersion(file); - - if ((position = FileContent.IndexOf("" + (char)0xE8 + "u" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0xE8)) > -1 - && FileContent.Substring(--position + 8, 3) == "" + (char)0xFF + (char)0xFF + "h") // TODO: Verify this subtract - return "TAGES " + GetTagesVersion(file, position); + protection = Tages.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); // VOB ProtectCD/DVD - if ((position = FileContent.IndexOf("VOB ProtectCD")) > -1) - return "VOB ProtectCD/DVD " + GetProtectCDoldVersion(file, --position); // TODO: Verify this subtract - - if ((position = FileContent.IndexOf("DCP-BOV" + (char)0x00 + (char)0x00)) > -1) - { - string version = GetVOBProtectCDDVDVersion(file, --position); // TODO: Verify this subtract - if (version.Length > 0) - { - return "VOB ProtectCD/DVD " + version; - } - - version = EVORE.SearchProtectDiscVersion(file); - if (version.Length > 0) - { - if (version.StartsWith("2")) - { - version = "6" + version.Substring(1); - } - return "VOB ProtectCD/DVD " + version; - } - - return "VOB ProtectCD/DVD 5.9-6.0" + GetVOBProtectCDDVDBuild(file, position); - } - - // Create mappings for checking against - var mappings = CreateInternalProtectionMapping(); - - // Loop through all of the string-only possible matches - foreach (string key in mappings.Keys) - { - if (FileContent.Contains(key)) - { - return mappings[key]; - } - } + protection = VOBProtectCDDVD.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // WTM CD Protect + protection = WTMCDProtect.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Xtreme-Protector + protection = XtremeProtector.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); } catch { } } @@ -445,7 +579,9 @@ private static string ScanInFile(string file) // CD-Key if (FileContent.Contains("a valid serial number is required") || FileContent.Contains("serial number is located")) - return "CD-Key / Serial"; + { + protections.Add("CD-Key / Serial"); + } } catch { @@ -469,7 +605,6 @@ private static string ScanInFile(string file) { try { - List protections = new List(); string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(tempPath); @@ -486,7 +621,7 @@ private static string ScanInFile(string file) } catch { } - if (!String.IsNullOrEmpty(protection)) + if (!string.IsNullOrEmpty(protection)) protections.Add(protection); } } @@ -496,8 +631,6 @@ private static string ScanInFile(string file) Directory.Delete(tempPath, true); } catch { } - - return string.Join(", ", protections); } catch { } } @@ -507,29 +640,28 @@ private static string ScanInFile(string file) { try { - List protections = new List(); string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(tempPath); - MSCabinet cabfile = new MSCabinet(file); - foreach (var sub in cabfile.GetFiles()) + using (MSCabinet cabfile = new MSCabinet(file)) { - string tempfile = Path.Combine(tempPath, sub.Filename); - sub.ExtractTo(tempfile); - string protection = ScanInFile(tempfile); - File.Delete(tempfile); + foreach (var sub in cabfile.GetFiles()) + { + string tempfile = Path.Combine(tempPath, sub.Filename); + sub.ExtractTo(tempfile); + string protection = ScanInFile(tempfile); + File.Delete(tempfile); - if (!String.IsNullOrEmpty(protection)) - protections.Add(protection); - } + if (!string.IsNullOrEmpty(protection)) + protections.Add(protection); + } - try - { - Directory.Delete(tempPath, true); + try + { + Directory.Delete(tempPath, true); + } + catch { } } - catch { } - - return string.Join(", ", protections); } catch { } } @@ -550,920 +682,70 @@ private static string ScanInFile(string file) #endregion - #region Name Checks - - FileInfo fi = new FileInfo(file); - - // Cactus Data Shield - if (Path.GetFileName(file) == "CDSPlayer.app") - using (StreamReader cactusReader = new StreamReader(file)) - return "Cactus Data Shield " + cactusReader.ReadLine().Substring(3) + "(" + cactusReader.ReadLine() + ")"; - - // Impulse Reactor - if (Path.GetFileName(file) == "ImpulseReactor.dll") - return "Impulse Reactor " + GetFileVersion(file); - - // LaserLock - if (Path.GetFileName(file) == "NOMOUSE.SP") - return "LaserLock " + GetLaserLockVersion16Bit(file); - - // SafeDisc - if (Path.GetFileName(file) == "DPLAYERX.DLL") - { - if (fi.Length == 81408) - return "SafeDisc 1.0x"; - else if (fi.Length == 155648) - return "SafeDisc 1.1x"; - else if (fi.Length == 156160) - return "SafeDisc 1.1x-1.2x"; - else if (fi.Length == 163328) - return "SafeDisc 1.3x"; - else if (fi.Length == 165888) - return "SafeDisc 1.35"; - else if (fi.Length == 172544) - return "SafeDisc 1.40"; - else if (fi.Length == 173568) - return "SafeDisc 1.4x"; - else if (fi.Length == 136704) - return "SafeDisc 1.4x"; - else if (fi.Length == 138752) - return "SafeDisc 1.5x"; - else - return "SafeDisc 1"; - } - else if (Path.GetFileName(file).ToLower() == "drvmgt.dll") - { - if (fi.Length == 34816) - return "SafeDisc 1.0x"; - else if (fi.Length == 32256) - return "SafeDisc 1.1x-1.3x"; - else if (fi.Length == 31744) - return "SafeDisc 1.4x"; - else if (fi.Length == 34304) - return "SafeDisc 1.5x-2.40"; - else if (fi.Length == 35840) - return "SafeDisc 2.51-2.60"; - else if (fi.Length == 40960) - return "SafeDisc 2.70"; - else if (fi.Length == 23552) - return "SafeDisc 2.80"; - else if (fi.Length == 41472) - return "SafeDisc 2.90-3.10"; - else if (fi.Length == 24064) - return "SafeDisc 3.15-3.20"; - else - return "SafeDisc v2 or greater"; - } - else if (Path.GetFileName(file).ToLower() == "secdrv.sys") - { - if (fi.Length == 20128) - return "SafeDisc 2.10"; - else if (fi.Length == 27440) - return "SafeDisc 2.30"; - else if (fi.Length == 28624) - return "SafeDisc 2.40"; - else if (fi.Length == 18768) - return "SafeDisc 2.50"; - else if (fi.Length == 28400) - return "SafeDisc 2.51"; - else if (fi.Length == 29392) - return "SafeDisc 2.60"; - else if (fi.Length == 11376) - return "SafeDisc 2.70"; - else if (fi.Length == 12464) - return "SafeDisc 2.80"; - else if (fi.Length == 12400) - return "SafeDisc 2.90"; - else if (fi.Length == 12528) - return "SafeDisc 3.10"; - else if (fi.Length == 12528) - return "SafeDisc 3.15"; - else if (fi.Length == 11973) - return "SafeDisc 3.20"; - else - return "SafeDisc v2 or greater"; - } - - // SolidShield - if (Path.GetFileName(file) == "dvm.dll") - return "SolidShield " + ScanInFile(file); - else if (Path.GetFileName(file) == "hc.dll") - return "SolidShield " + ScanInFile(file); - else if (Path.GetFileName(file) == "solidshield-cd.dll") - return "SolidShield " + ScanInFile(file); - else if (Path.GetFileName(file) == "c11prot.dll") - return "SolidShield " + ScanInFile(file); - - // TAGES - if (Path.GetFileName(file) == "TagesClient.exe") - return "TAGES Activation Client " + GetFileVersion(file); - else if (Path.GetFileName(file) == "TagesSetup.exe") - return "TAGES Setup " + GetFileVersion(file); - else if (Path.GetFileName(file) == "TagesSetup_x64.exe") - return "TAGES Setup " + GetFileVersion(file); - - // WTM Copy Protection - if (Path.GetFileName(file) == "Viewer.exe") - return "WTM Copy Protection " + GetFileVersion(file); - - #endregion - - return ""; - } - - #region Path-Based Protections - - private static bool DVDMoviePROTECT(string path, string[] files) - { - if (Directory.Exists(Path.Combine(path, "VIDEO_TS"))) - { - string[] bupfiles = files.Where(s => s.EndsWith(".bup")).ToArray(); - for (int i = 0; i < bupfiles.Length; i++) - { - FileInfo bupfile = new FileInfo(bupfiles[i]); - FileInfo ifofile = new FileInfo(bupfile.DirectoryName + "\\" + bupfile.Name.Substring(0, bupfile.Name.Length - bupfile.Extension.Length) + ".ifo"); - if (bupfile.Length != ifofile.Length) - return true; - } - } - - return false; - } - - private static bool ProtectDVDVideo(string path, string[] files) - { - if (Directory.Exists(Path.Combine(path, "VIDEO_TS"))) - { - string[] ifofiles = files.Where(s => s.EndsWith(".ifo")).ToArray(); - for (int i = 0; i < ifofiles.Length; i++) - { - FileInfo ifofile = new FileInfo(ifofiles[i]); - if (ifofile.Length == 0) - return true; - } - } - - return false; - } - - private static bool PSXAntiModchip(string path, string[] files) - { - if (files.Where(s => s.ToLower().EndsWith(".cnf")).Count() > 0) - { - foreach (string file in files) - { - try - { - // Load the current file and check for specialty strings first - StreamReader sr = new StreamReader(file, Encoding.Default); - string FileContent = sr.ReadToEnd(); - sr.Close(); - - if (FileContent.Contains(" SOFTWARE TERMINATED\nCONSOLE MAY HAVE BEEN MODIFIED\n CALL 1-888-780-7690") - || FileContent.Contains("強制終了しました。\n本体が改造されている\nおそれがあります。")) - return true; - - } - catch { } - } - } - - return false; - } - - #endregion - - #region Version detections - - private static string GetCDDVDCopsVersion(string file, int position) - { - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream); - br.BaseStream.Seek(position + 15, SeekOrigin.Begin); // Begin reading after "CD-Cops, ver." - char[] version = br.ReadChars(4); - if (version[0] == 0x00) - return ""; - return new string(version); - } - - private static string GetInnoSetupVersion(string file) - { - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream); - br.BaseStream.Seek(0x30, SeekOrigin.Begin); - string signature = new String(br.ReadChars(12)); - - if (signature == "rDlPtS02" + (char)0x87 + "eVx") - return "1.2.10"; - else if (signature == "rDlPtS04" + (char)0x87 + "eVx") - return "4.0.0"; - else if (signature == "rDlPtS05" + (char)0x87 + "eVx") - return "4.0.3"; - else if (signature == "rDlPtS06" + (char)0x87 + "eVx") - return "4.0.10"; - else if (signature == "rDlPtS07" + (char)0x87 + "eVx") - return "4.1.6"; - else if (signature == "rDlPtS" + (char)0xcd + (char)0xe6 + (char)0xd7 + "{" + (char)0x0b + "*") - return "5.1.5"; - else if (signature == "nS5W7dT" + (char)0x83 + (char)0xaa + (char)0x1b + (char)0x0f + "j") - return "5.1.5"; - - return string.Empty; - } - - private static string GetJoWooDXProt1Version(string file, int position) - { - char[] version = new char[5]; - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream); - br.BaseStream.Seek(position + 67, SeekOrigin.Begin); - version[0] = br.ReadChar(); - br.ReadByte(); - version[1] = br.ReadChar(); - br.ReadByte(); - version[2] = br.ReadChar(); - br.ReadByte(); - version[3] = br.ReadChar(); - version[4] = br.ReadChar(); - br.Close(); - - return version[0] + "." + version[1] + "." + version[2] + "." + version[3] + version[4]; - } - - private static string GetLaserLockBuild(string FileContent, bool Version2) - { - int position = FileContent.IndexOf("Unkown" + (char)0 + "Unkown"); - string Year; - string Month; - string Day; - if (Version2) - { - Day = FileContent.Substring(position + 14, 2); - Month = FileContent.Substring(position + 14 + 3, 2); - Year = "20" + FileContent.Substring(position + 14 + 6, 2); - } + // Return blank if nothing found, or comma-separated list of protections + if (protections.Count() == 0) + return string.Empty; else - { - Day = FileContent.Substring(position + 13, 2); - Month = FileContent.Substring(position + 13 + 3, 2); - Year = "20" + FileContent.Substring(position + 13 + 6, 2); - } - - return "(Build " + Year + "-" + Month + "-" + Day + ")"; - } - - private static string GetLaserLockVersion(string FileContent, int position) - { - return FileContent.Substring(position + 76, 4); - } - - private static string GetLaserLockVersion16Bit(string file) - { - char[] version = new char[3]; - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream); - br.BaseStream.Seek(71, SeekOrigin.Begin); - version[0] = br.ReadChar(); - br.ReadByte(); - version[1] = br.ReadChar(); - version[2] = br.ReadChar(); - br.Close(); - - if (Char.IsNumber(version[0]) && Char.IsNumber(version[1]) && Char.IsNumber(version[2])) - return version[0] + "." + version[1] + version[2]; - return ""; + return string.Join(", ", protections); } - private static string GetProtectCDoldVersion(string file, int position) - { - char[] version = new char[3]; - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream); - br.BaseStream.Seek(position + 16, SeekOrigin.Begin); // Begin reading after "VOB ProtectCD" - version[0] = br.ReadChar(); - br.ReadByte(); - version[1] = br.ReadChar(); - version[2] = br.ReadChar(); - br.Close(); - if (Char.IsNumber(version[0]) && Char.IsNumber(version[1]) && Char.IsNumber(version[2])) - return version[0] + "." + version[1] + version[2]; - return "old"; - } - - private static string GetProtectDiscVersionBuild6till8(string file, int position) - { - string version; - string strBuild; - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream); - - br.BaseStream.Seek(position - 12, SeekOrigin.Begin); - if (br.ReadByte() == 0xA && br.ReadByte() == 0xD && br.ReadByte() == 0xA && br.ReadByte() == 0xD) // ProtectDisc 6-7 with Build Number in plain text - { - br.BaseStream.Seek(position - 12 - 6, SeekOrigin.Begin); - if (new string(br.ReadChars(6)) == "Henrik") // ProtectDisc 7 - { - version = "7.1-7.5"; - br.BaseStream.Seek(position - 12 - 6 - 6, SeekOrigin.Begin); - } - else // ProtectDisc 6 - { - version = "6"; - br.BaseStream.Seek(position - 12 - 10, SeekOrigin.Begin); - while (true) //search for e.g. "Build 050913 - September 2005" - { - if (Char.IsNumber(br.ReadChar())) - break; - br.BaseStream.Seek(-2, SeekOrigin.Current); //search upwards - } - - br.BaseStream.Seek(-5, SeekOrigin.Current); - } - } - else - { - br.BaseStream.Seek(position + 28, SeekOrigin.Begin); - if (br.ReadByte() == 0xFB) - { - br.Close(); - return "7.6-7.x"; - } - else - { - br.Close(); - return "8.0"; - } - } - strBuild = "" + br.ReadChar() + br.ReadChar() + br.ReadChar() + br.ReadChar() + br.ReadChar(); - br.Close(); - return version + " (Build " + strBuild + ")"; - } - - private static string GetProtectDiscVersionBuild76till10(string file, int position, out int irefBuild) + /// + /// Scan a disc sector by sector for protection + /// + /// + /// https://stackoverflow.com/questions/8819188/c-sharp-classes-to-undelete-files/8820157#8820157 + /// TODO: Finish implementation + /// + private static string ScanSectors(char driveLetter, int sectorsize) { - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream); - br.BaseStream.Seek(position + 37, SeekOrigin.Begin); - byte subversion = br.ReadByte(); - br.ReadByte(); - byte version = br.ReadByte(); - br.BaseStream.Seek(position + 49, SeekOrigin.Begin); - irefBuild = br.ReadInt32(); - br.BaseStream.Seek(position + 53, SeekOrigin.Begin); - byte versionindicatorPD9 = br.ReadByte(); - br.BaseStream.Seek(position + 0x40, SeekOrigin.Begin); - byte subsubversionPD9x = br.ReadByte(); - byte subversionPD9x2 = br.ReadByte(); - byte subversionPD9x1 = br.ReadByte(); - br.Close(); - - // version 7 - if (version == 0xAC) - return "7." + (subversion ^ 0x43) + " (Build " + irefBuild + ")"; - // version 8 - else if (version == 0xA2) + string fsName = Utilities.GetFileSystemName(driveLetter); + + // Gets a handle to the physical disk + IntPtr hDisk = Utilities.CreateFile($"\\\\.\\{driveLetter}:", + FileAccess.Read, + FileShare.ReadWrite, + IntPtr.Zero, + FileMode.Open, + 0, + IntPtr.Zero); + + // If we have a good pointer + if (hDisk.ToInt32() != -1) { - if (subversion == 0x46) + // Setup vars + byte[] buffer = new byte[sectorsize]; + IntPtr pt = IntPtr.Zero; + NativeOverlapped no = new NativeOverlapped(); + + // Set initial offset + Utilities.SetFilePointerEx( + hDisk, + 0, + ref pt, + Utilities.FileBegin); + + // Read a whole sector + while (true) { - if ((irefBuild & 0x3A00) == 0x3A00) - return "8.2" + " (Build " + irefBuild + ")"; - else - return "8.1" + " (Build " + irefBuild + ")"; + buffer = new byte[sectorsize]; + Utilities.ReadFileEx( + hDisk, + buffer, + (uint)sectorsize, + ref no, + null); + + Utilities.SetFilePointerEx( + hDisk, + sectorsize, + ref pt, + Utilities.FileCurrent); } - return "8." + (subversion ^ 0x47) + " (Build " + irefBuild + ")"; - } - // version 9 - else if (version == 0xA3) - { - // version removed or not given - if ((subversionPD9x2 == 0x5F && subversionPD9x1 == 0x61) || (subversionPD9x1 == 0 && subversionPD9x2 == 0)) - { - if (versionindicatorPD9 == 0xB) - return "9.0-9.4" + " (Build " + irefBuild + ")"; - else if (versionindicatorPD9 == 0xC) - { - if (subversionPD9x2 == 0x5F && subversionPD9x1 == 0x61) - return "9.5-9.11" + " (Build " + irefBuild + ")"; - else if (subversionPD9x1 == 0 && subversionPD9x2 == 0) - return "9.11-9.20" + " (Build " + irefBuild + ")"; - } - else - return "9." + subversionPD9x1 + subversionPD9x2 + "." + subsubversionPD9x + " (Build " + irefBuild + ")"; - } - } - else if (version == 0xA0) - { - // version removed - if (subversionPD9x1 != 0 || subversionPD9x2 != 0) - return "10." + subversionPD9x1 + "." + subsubversionPD9x + " (Build " + irefBuild + ")"; - else - return "10.x (Build " + irefBuild + ")"; } - else - return "7.6-10.x (Build " + irefBuild + ")"; - - return ""; - } - - private static string GetSafeDiscVersion(string file, int position) - { - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream); - br.BaseStream.Seek(position + 20, SeekOrigin.Begin); // Begin reading after "BoG_ *90.0&!! Yy>" for old SafeDisc - int version = br.ReadInt32(); - int subVersion = br.ReadInt32(); - int subsubVersion = br.ReadInt32(); - if (version != 0) - return version + "." + subVersion.ToString("00") + "." + subsubVersion.ToString("000"); - br.BaseStream.Seek(position + 18 + 14, SeekOrigin.Begin); // Begin reading after "BoG_ *90.0&!! Yy>" for newer SafeDisc - version = br.ReadInt32(); - subVersion = br.ReadInt32(); - subsubVersion = br.ReadInt32(); - br.Close(); - if (version == 0) - return ""; - return version + "." + subVersion.ToString("00") + "." + subsubVersion.ToString("000"); - } - - private static string GetSecuROM4Version(string file, int position) - { - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream, Encoding.Default); - br.BaseStream.Seek(position + 8, SeekOrigin.Begin); // Begin reading after "AddD" - char version = br.ReadChar(); - br.ReadByte(); - char subVersion1 = br.ReadChar(); - char subVersion2 = br.ReadChar(); - br.ReadByte(); - char subsubVersion1 = br.ReadChar(); - char subsubVersion2 = br.ReadChar(); - br.ReadByte(); - char subsubsubVersion1 = br.ReadChar(); - char subsubsubVersion2 = br.ReadChar(); - char subsubsubVersion3 = br.ReadChar(); - char subsubsubVersion4 = br.ReadChar(); - br.Close(); - return version + "." + subVersion1 + subVersion2 + "." + subsubVersion1 + subsubVersion2 + "." + subsubsubVersion1 + subsubsubVersion2 + subsubsubVersion3 + subsubsubVersion4; - } - - private static string GetSecuROM4and5Version(string file, int position) - { - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream); - br.BaseStream.Seek(position + 8, SeekOrigin.Begin); // Begin reading after "ÊÝݬ" - byte version = (byte)(br.ReadByte() & 0xF); - br.ReadByte(); - byte subVersion1 = (byte)(br.ReadByte() ^ 36); - byte subVersion2 = (byte)(br.ReadByte() ^ 28); - br.ReadByte(); - byte subsubVersion1 = (byte)(br.ReadByte() ^ 42); - byte subsubVersion2 = (byte)(br.ReadByte() ^ 8); - br.ReadByte(); - byte subsubsubVersion1 = (byte)(br.ReadByte() ^ 16); - byte subsubsubVersion2 = (byte)(br.ReadByte() ^ 116); - byte subsubsubVersion3 = (byte)(br.ReadByte() ^ 34); - byte subsubsubVersion4 = (byte)(br.ReadByte() ^ 22); - br.Close(); - if (version == 0 || version > 9) - return ""; - return version + "." + subVersion1 + subVersion2 + "." + subsubVersion1 + subsubVersion2 + "." + subsubsubVersion1 + subsubsubVersion2 + subsubsubVersion3 + subsubsubVersion4; - } - - private static string GetSecuROM7Version(string file) - { - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream); - br.BaseStream.Seek(236, SeekOrigin.Begin); - byte[] bytes = br.ReadBytes(4); - // if (bytes[0] == 0xED && bytes[3] == 0x5C { - if (bytes[3] == 0x5C) - { - //SecuROM 7 new and 8 - br.Close(); - return (bytes[0] ^ 0xEA).ToString() + "." + (bytes[1] ^ 0x2C).ToString("00") + "." + (bytes[2] ^ 0x8).ToString("0000"); - } - else // SecuROM 7 old - { - br.BaseStream.Seek(122, SeekOrigin.Begin); - bytes = br.ReadBytes(2); - br.Close(); - return "7." + (bytes[0] ^ 0x10).ToString("00") + "." + (bytes[1] ^ 0x10).ToString("0000"); - //return "7.01-7.10" - } - } - - private static string GetSolidShieldVersion(string file, int position) - { - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream, Encoding.Default); - br.BaseStream.Seek(position + 12, SeekOrigin.Begin); // Begin reading after "Solidshield" - char version = br.ReadChar(); - br.ReadByte(); - char subVersion = br.ReadChar(); - br.ReadByte(); - char subsubVersion = br.ReadChar(); - br.ReadByte(); - char subsubsubVersion = br.ReadChar(); - br.Close(); - return version + "." + subVersion + "." + subsubVersion + "." + subsubsubVersion; - } - - private static string GetSysiphusVersion(string file, int position) - { - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream, Encoding.Default); - br.BaseStream.Seek(position - 3, SeekOrigin.Begin); - char subVersion = br.ReadChar(); - br.ReadChar(); - char version = br.ReadChar(); - br.Close(); - if (Char.IsNumber(version) && Char.IsNumber(subVersion)) - return version + "." + subVersion; - else - return ""; - } - - private static string GetTagesVersion(string file, int position) - { - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream); - br.BaseStream.Seek(position + 7, SeekOrigin.Begin); - byte bVersion = br.ReadByte(); - br.Close(); - switch (bVersion) - { - case 0x1B: - return "5.3-5.4"; - case 0x14: - return "5.5.0"; - case 0x4: - return "5.5.2"; - } - return ""; - } - - private static string GetVOBProtectCDDVDBuild(string file, int position) - { - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream); - br.BaseStream.Seek(position - 13, SeekOrigin.Begin); - if (!Char.IsNumber(br.ReadChar())) - return ""; //Build info removed - br.BaseStream.Seek(position - 4, SeekOrigin.Begin); - int build = br.ReadInt16(); - br.Close(); - return " (Build " + build + ")"; - } - - private static string GetVOBProtectCDDVDVersion(string file, int position) - { - BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream, Encoding.Default); - br.BaseStream.Seek(position - 2, SeekOrigin.Begin); - byte version = br.ReadByte(); - if (version == 5) - { - br.BaseStream.Seek(position - 4, SeekOrigin.Begin); - byte subsubVersion = (byte)((br.ReadByte() & 0xF0) >> 4); - byte subVersion = (byte)((br.ReadByte() & 0xF0) >> 4); - br.Close(); - return version + "." + subVersion + "." + subsubVersion; - } - else - return ""; - } - - #endregion - - #region Helper methods - - /// - /// Create a list of filenames and extensions mapped to protections for when only file existence matters - /// - private static CaseInsensitiveDictionary CreateFilenameProtectionMapping() - { - var mapping = new CaseInsensitiveDictionary(); - - // AACS - mapping.Add("VTKF000.AACS", "AACS"); // Path.Combine("aacs", "VTKF000.AACS") - mapping.Add("CPSUnit00001.cci", "AACS"); // Path.Combine("AACS", "CPSUnit00001.cci") - - // Alpha-DVD - mapping.Add("PlayDVD.exe", "Alpha-DVD"); - - // Bitpool - mapping.Add("bitpool.rsc", "Bitpool"); - - // ByteShield - mapping.Add("Byteshield.dll", "ByteShield"); - mapping.Add(".bbz", "ByteShield"); - - // Cactus Data Shield - mapping.Add("yucca.cds", "Cactus Data Shield 200"); - mapping.Add("wmmp.exe", "Cactus Data Shield 200"); - mapping.Add("PJSTREAM.DLL", "Cactus Data Shield 200"); - mapping.Add("CACTUSPJ.exe", "Cactus Data Shield 200"); - mapping.Add("CDSPlayer.app", "Cactus Data Shield 200"); - - // CD-Cops - mapping.Add("CDCOPS.DLL", "CD-Cops"); - mapping.Add(".GZ_", "CD-Cops"); - mapping.Add(".W_X", "CD-Cops"); - mapping.Add(".Qz", "CD-Cops"); - mapping.Add(".QZ_", "CD-Cops"); - - // CD-Lock - mapping.Add(".AFP", "CD-Lock"); - - // CD-Protector - mapping.Add("_cdp16.dat", "CD-Protector"); - mapping.Add("_cdp16.dll", "CD-Protector"); - mapping.Add("_cdp32.dat", "CD-Protector"); - mapping.Add("_cdp32.dll", "CD-Protector"); - - // CD-X - mapping.Add("CHKCDX16.DLL", "CD-X"); - mapping.Add("CHKCDX32.DLL", "CD-X"); - mapping.Add("CHKCDXNT.DLL", "CD-X"); - - // CopyKiller - // mapping.Add("Autorun.dat", "CopyKiller"); - - // DiscGuard - mapping.Add("IOSLINK.VXD", "DiscGuard"); - mapping.Add("IOSLINK.DLL", "DiscGuard"); - mapping.Add("IOSLINK.SYS", "DiscGuard"); - - // DVD Crypt - mapping.Add("DvdCrypt.pdb", "DVD Crypt"); - - // FreeLock - mapping.Add("FREELOCK.IMG", "FreeLock"); - - // Games for Windows - Live - mapping.Add("XLiveRedist.msi", "Games for Windows - Live"); - - // Hexalock AutoLock - mapping.Add("Start_Here.exe", "Hexalock AutoLock"); - mapping.Add("HCPSMng.exe", "Hexalock AutoLock"); - mapping.Add("MFINT.DLL", "Hexalock AutoLock"); - mapping.Add("MFIMP.DLL", "Hexalock AutoLock"); - - // Impulse Reactor - mapping.Add("ImpulseReactor.dll", "Impulse Reactor"); - - // IndyVCD - mapping.Add("INDYVCD.AX", "IndyVCD"); - mapping.Add("INDYMP3.idt", "IndyVCD"); - - // Key2Audio XS - mapping.Add("SDKHM.EXE", "Key2Audio XS"); - mapping.Add("SDKHM.DLL", "Key2Audio XS"); - - // LaserLock - mapping.Add("NOMOUSE.SP", "LaserLock"); - mapping.Add("NOMOUSE.COM", "LaserLock"); - mapping.Add("l16dll.dll", "LaserLock"); - mapping.Add("laserlok.in", "LaserLock"); - mapping.Add("laserlok.o10", "LaserLock"); - mapping.Add("laserlok.011", "LaserLock"); - - // MediaCloQ - mapping.Add("sunncomm.ico", "MediaCloQ"); - - // MediaMax CD3 - mapping.Add("LaunchCd.exe", "MediaMax CD3"); - - // Origin - mapping.Add("OriginSetup.exe", "Origin"); - - // SafeCast - mapping.Add("cdac11ba.exe", "SafeCast"); - - // SafeDisc - mapping.Add("00000001.TMP", "SafeDisc v1 or greater"); - mapping.Add("CLCD16.DLL", "SafeDisc"); - mapping.Add("CLCD32.DLL", "SafeDisc"); - mapping.Add("CLOKSPL.EXE", "SafeDisc"); - mapping.Add("DPLAYERX.DLL", "SafeDisc"); - mapping.Add("drvmgt.dll", "SafeDisc v1 or greater"); - mapping.Add(".icd", "SafeDisc 1"); - mapping.Add(".016", "SafeDisc 1"); - mapping.Add(".256", "SafeDisc 1"); - - // SafeDisc v2 or greater - mapping.Add("00000002.TMP", "SafeDisc v2 or greater"); - mapping.Add("secdrv.sys", "SafeDisc v2 or greater"); - - // SafeDisc Lite - mapping.Add("00000001.LT1", "SafeDisc Lite"); - - // SafeLock - mapping.Add("SafeLock.dat", "SafeLock"); - mapping.Add("SafeLock.001", "SafeLock"); - mapping.Add("SafeLock.128", "SafeLock"); - - // SecuROM - mapping.Add("CMS16.DLL", "SecuROM"); - mapping.Add("CMS_95.DLL", "SecuROM"); - mapping.Add("CMS_NT.DLL", "SecuROM"); - mapping.Add("CMS32_95.DLL", "SecuROM"); - mapping.Add("CMS32_NT.DLL", "SecuROM"); - - // SecuROM New - mapping.Add("SINTF32.DLL", "SecuROM New"); - mapping.Add("SINTF16.DLL", "SecuROM New"); - mapping.Add("SINTFNT.DLL", "SecuROM New"); - - // SmartE - mapping.Add("00001.TMP", "SmartE"); - mapping.Add("00002.TMP", "SmartE"); - - // SolidShield - mapping.Add("dvm.dll", "SolidShield"); - mapping.Add("hc.dll", "SolidShield"); - mapping.Add("solidshield-cd.dll", "SolidShield"); - mapping.Add("c11prot.dll", "SolidShield"); - - // SoftLock - mapping.Add("SOFTLOCKI.dat", "SoftLock"); - mapping.Add("SOFTLOCKC.dat", "SoftLock"); - - // StarForce - mapping.Add("protect.dll", "StarForce"); - mapping.Add("protect.exe", "StarForce"); - - // Steam - mapping.Add("SteamInstall.exe", "Steam"); - mapping.Add("SteamInstall.ini", "Steam"); - mapping.Add("SteamInstall.msi", "Steam"); - mapping.Add("SteamRetailInstaller.dmg", "Steam"); - mapping.Add("SteamSetup.exe", "Steam"); - - // TAGES - mapping.Add("Tages.dll", "TAGES"); - mapping.Add("tagesclient.exe", "TAGES"); - mapping.Add("TagesSetup.exe", "TAGES"); - mapping.Add("TagesSetup_x64.exe", "TAGES"); - mapping.Add("Wave.aif", "TAGES"); - - // TZCopyProtector - mapping.Add("_742893.016", "TZCopyProtector"); - - // Uplay - mapping.Add("UplayInstaller.exe", "Uplay"); - - // VOB ProtectCD/DVD - mapping.Add("VOB-PCD.KEY", "VOB ProtectCD/DVD"); - - // Winlock - mapping.Add("WinLock.PSX", "Winlock"); - - // WTM CD Protect - mapping.Add(".IMP", "WTM CD Protect"); - - // WTM Copy Protection - mapping.Add("imp.dat", "WTM Copy Protection"); - mapping.Add("wtmfiles.dat", "WTM Copy Protection"); - mapping.Add("Viewer.exe", "WTM Copy Protection"); - // XCP - mapping.Add("XCP.DAT", "XCP"); - mapping.Add("ECDPlayerControl.ocx", "XCP"); - mapping.Add("go.exe", "XCP"); // Path.Combine("contents", "go.exe") - - // Zzxzz - mapping.Add("Zzz.aze", "Zzxzz"); // Path.Combine("Zzxxzz", "Zzz.aze") + Utilities.CloseHandle(hDisk); - return mapping; + return null; } - - /// - /// Create a list of strings mapped to protections for when secondary strings and position doesn't matter - /// - private static Dictionary CreateInternalProtectionMapping() - { - var mapping = new Dictionary(); - - // 3PLock - mapping[".ldr"] = "3PLock"; - mapping[".ldt"] = "3PLock"; - // mapping["Y" + (char)0xC3 + "U" + (char)0x8B + (char)0xEC + (char)0x83 + (char)0xEC + "0SVW"] = "3PLock"; // YÃU‹ìƒì0SVW - - // ActiveMARK - mapping["TMSAMVOF"] = "ActiveMARK"; - - // ActiveMARK 5 - mapping[" " + (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] = "ActiveMARK 5"; - - // Alpha-ROM - mapping["SETTEC"] = "Alpha-ROM"; - - // Armadillo - mapping[".nicode" + (char)0x00] = "Armadillo"; - mapping["ARMDEBUG"] = "Armadillo"; - - // CD-Cops - mapping[".grand" + (char)0x00] = "CD-Cops"; - - // CD-Lock - mapping["2" + (char)0xF2 + (char)0x02 + (char)0x82 + (char)0xC3 + (char)0xBC + (char)0x0B - + "$" + (char)0x99 + (char)0xAD + "'C" + (char)0xE4 + (char)0x9D + "st" - + (char)0x99 + (char)0xFA + "2$" + (char)0x9D + ")4" + (char)0xFF + "t"] = "CD-Lock"; - - // CDSHiELD SE - mapping["~0017.tmp"] = "CDSHiELD SE"; - - // CD Check - //mapping["GetDriveType"] = "CD Check"; - //mapping["GetVolumeInformation"] = "CD Check"; - - // Cenega ProtectDVD - mapping[".cenega"] = "Cenega ProtectDVD"; - - // Code Lock - mapping["icd1" + (char)0x00] = "Code Lock"; - mapping["icd2" + (char)0x00] = "Code Lock"; - mapping["CODE-LOCK.OCX"] = "Code Lock"; - - // CopyKiller - mapping["Tom Commander"] = "CopyKiller"; - - // Cucko (EA Custom) - TODO: Verify this doesn't over-match - mapping["EASTL"] = "Cucko (EA Custom)"; - - // dotFuscator - Not a protection - //mapping["DotfuscatorAttribute"] = "dotFuscator"; - - // EA CdKey Registration Module - mapping["ereg.ea-europe.com"] = "EA CdKey Registration Module"; - - // EXE Stealth - mapping["??[[__[[_" + (char)0x00 + "{{" + (char)0x0 - + (char)0x00 + "{{" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x0 - + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "?;??;??"] = "EXE Stealth"; - - // Games for Windows - Live - mapping["xlive.dll"] = "Games for Windows - Live"; - - // Impulse Reactor - mapping["CVPInitializeClient"] = "Impulse Reactor"; - - // JoWooD X-Prot - mapping[".ext "] = "JoWooD X-Prot v1"; - mapping["@HC09 "] = "JoWooD X-Prot v2"; - - // Key-Lock (Dongle) - mapping["KEY-LOCK COMMAND"] = "Key-Lock (Dongle)"; - - // LaserLock - mapping[":\\LASERLOK\\LASERLOK.IN" + (char)0x00 + "C:\\NOMOUSE.SP"] = "LaserLock 3"; - mapping["LASERLOK_INIT" + (char)0xC + "LASERLOK_RUN" + (char)0xE + "LASERLOK_CHECK" - + (char)0xF + "LASERLOK_CHECK2" + (char)0xF + "LASERLOK_CHECK3"] = "LaserLock 5"; - - // PE Compact 2 - Not a protection - //mapping["PEC2"] = "PE Compact 2"; - - // Ring PROTECH - mapping[(char)0x00 + "Allocator" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00] = "Ring PROTECH"; - - // SafeLock - mapping["SafeLock"] = "SafeLock"; - - // SecuROM - mapping[".cms_t" + (char)0x00] = "SecuROM 1-3"; - mapping[".cms_d" + (char)0x00] = "SecuROM 1-3"; - - // SmartE - mapping["BITARTS"] = "SmartE"; - - // SolidShield - mapping["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] = "SolidShield"; - - // StarForce - mapping[".sforce"] = "StarForce 3-5"; - mapping[".brick"] = "StarForce 3-5"; - mapping["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"] = "StarForce 5"; - - // SVK Protector - mapping["?SVKP" + (char)0x00 + (char)0x00] = "SVK Protector"; - - // VOB ProtectCD/DVD - mapping[".vob.pcd"] = "VOB ProtectCD"; - - // WTM CD Protect - mapping["WTM76545"] = "WTM CD Protect"; - - // Xtreme-Protector - mapping["XPROT "] = "Xtreme-Protector"; - - return mapping; - } - - /// - /// Get the file version as reported by the filesystem - /// - private static string GetFileVersion(string file) - { - FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(file); - if (fvinfo.FileVersion == null) - return ""; - if (fvinfo.FileVersion != "") - return fvinfo.FileVersion.Replace(", ", "."); - else - return fvinfo.ProductVersion.Replace(", ", "."); - } - - #endregion } } diff --git a/BurnOutSharp/ProtectionType/AACS.cs b/BurnOutSharp/ProtectionType/AACS.cs new file mode 100644 index 00000000..f1ebe072 --- /dev/null +++ b/BurnOutSharp/ProtectionType/AACS.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class AACS + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => f.Contains(Path.Combine("aacs", "VTKF000.AACS"))) > 0 + && files.Count(f => f.Contains(Path.Combine("AACS", "CPSUnit00001.cci"))) > 0) + { + return "AACS"; + } + } + else + { + string filename = Path.GetFileName(path); + if (filename.Equals("VTKF000.AACS", StringComparison.OrdinalIgnoreCase) + || filename.Equals("CPSUnit00001.cci", StringComparison.OrdinalIgnoreCase)) + { + return "AACS"; + } + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/ActiveMARK.cs b/BurnOutSharp/ProtectionType/ActiveMARK.cs new file mode 100644 index 00000000..a66063e8 --- /dev/null +++ b/BurnOutSharp/ProtectionType/ActiveMARK.cs @@ -0,0 +1,22 @@ +namespace BurnOutSharp.ProtectionType +{ + public class ActiveMARK + { + 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 + + (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)) + { + return "ActiveMARK 5"; + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/Alcatraz.cs b/BurnOutSharp/ProtectionType/Alcatraz.cs new file mode 100644 index 00000000..8ceac6ac --- /dev/null +++ b/BurnOutSharp/ProtectionType/Alcatraz.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class Alcatraz + { + // TODO: Implement - http://www.kdg-mt.com/1/product_d_6.html + } +} diff --git a/BurnOutSharp/ProtectionType/AlphaAudio.cs b/BurnOutSharp/ProtectionType/AlphaAudio.cs new file mode 100644 index 00000000..727d4d77 --- /dev/null +++ b/BurnOutSharp/ProtectionType/AlphaAudio.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class AlphaAudio + { + // TODO: Implement - http://settec.net/eng/pro_cd.html + } +} diff --git a/BurnOutSharp/ProtectionType/AlphaDVD.cs b/BurnOutSharp/ProtectionType/AlphaDVD.cs new file mode 100644 index 00000000..393086ad --- /dev/null +++ b/BurnOutSharp/ProtectionType/AlphaDVD.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class AlphaDVD + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("PlayDVD.exe", StringComparison.OrdinalIgnoreCase)) > 0) + return "Alpha-DVD"; + } + else + { + if (Path.GetFileName(path).Equals("PlayDVD.exe", StringComparison.OrdinalIgnoreCase)) + return "Alpha-DVD"; + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/AlphaROM.cs b/BurnOutSharp/ProtectionType/AlphaROM.cs new file mode 100644 index 00000000..b6d6292d --- /dev/null +++ b/BurnOutSharp/ProtectionType/AlphaROM.cs @@ -0,0 +1,13 @@ +namespace BurnOutSharp.ProtectionType +{ + public class AlphaROM + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("SETTEC")) + return "Alpha-ROM"; + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/Armadillo.cs b/BurnOutSharp/ProtectionType/Armadillo.cs new file mode 100644 index 00000000..39aaa58a --- /dev/null +++ b/BurnOutSharp/ProtectionType/Armadillo.cs @@ -0,0 +1,14 @@ +namespace BurnOutSharp.ProtectionType +{ + public class Armadillo + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains(".nicode" + (char)0x00) + || fileContent.Contains("ARMDEBUG")) + return "Armadillo"; + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/Bitpool.cs b/BurnOutSharp/ProtectionType/Bitpool.cs new file mode 100644 index 00000000..d590bf2e --- /dev/null +++ b/BurnOutSharp/ProtectionType/Bitpool.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class Bitpool + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("bitpool.rsc", StringComparison.OrdinalIgnoreCase)) > 0) + return "Bitpool"; + } + else + { + 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 new file mode 100644 index 00000000..811ec527 --- /dev/null +++ b/BurnOutSharp/ProtectionType/ByteShield.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class ByteShield + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("Byteshield.dll", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetExtension(f).Trim('.').Equals("bbz", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "ByteShield"; + } + } + else + { + 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/CDCheck.cs b/BurnOutSharp/ProtectionType/CDCheck.cs new file mode 100644 index 00000000..4a18b340 --- /dev/null +++ b/BurnOutSharp/ProtectionType/CDCheck.cs @@ -0,0 +1,14 @@ +namespace BurnOutSharp.ProtectionType +{ + public class CDCheck + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("GetDriveType") + || fileContent.Contains("GetVolumeInformation")) + return "CD Check"; + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/CDCops.cs b/BurnOutSharp/ProtectionType/CDCops.cs new file mode 100644 index 00000000..3ff45089 --- /dev/null +++ b/BurnOutSharp/ProtectionType/CDCops.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class CDCops + { + public static string CheckContents(string file, string fileContent) + { + int position; + if ((position = fileContent.IndexOf("CD-Cops, ver. ")) > -1) + return "CD-Cops " + GetVersion(file, position); + + else if (fileContent.Contains(".grand" + (char)0x00)) + return "CD-Cops"; + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("CDCOPS.DLL", StringComparison.OrdinalIgnoreCase)) > 0 + && (files.Count(f => Path.GetExtension(f).Trim('.').Equals("GZ_", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetExtension(f).Trim('.').Equals("W_X", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetExtension(f).Trim('.').Equals("Qz", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetExtension(f).Trim('.').Equals("QZ_", StringComparison.OrdinalIgnoreCase)) > 0)) + { + 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 null; + } + + private static string GetVersion(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(position + 15, SeekOrigin.Begin); // Begin reading after "CD-Cops, ver." + char[] version = br.ReadChars(4); + if (version[0] == 0x00) + return ""; + + return new string(version); + } + } + } +} diff --git a/BurnOutSharp/ProtectionType/CDLock.cs b/BurnOutSharp/ProtectionType/CDLock.cs new file mode 100644 index 00000000..ae89b29b --- /dev/null +++ b/BurnOutSharp/ProtectionType/CDLock.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class CDLock + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("2" + (char)0xF2 + (char)0x02 + (char)0x82 + (char)0xC3 + (char)0xBC + (char)0x0B + + "$" + (char)0x99 + (char)0xAD + "'C" + (char)0xE4 + (char)0x9D + "st" + + (char)0x99 + (char)0xFA + "2$" + (char)0x9D + ")4" + (char)0xFF + "t")) + { + return "CD-Lock"; + } + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetExtension(f).Trim('.').Equals("AFP", StringComparison.OrdinalIgnoreCase)) > 0) + return "CD-Lock"; + } + else + { + 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 new file mode 100644 index 00000000..b2a0df8b --- /dev/null +++ b/BurnOutSharp/ProtectionType/CDProtector.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class CDProtector + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Confirm if OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("_cdp16.dat", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("_cdp16.dll", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("_cdp32.dat", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("_cdp32.dll", StringComparison.OrdinalIgnoreCase)) > 0) + { + 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 null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/CDSHiELDSE.cs b/BurnOutSharp/ProtectionType/CDSHiELDSE.cs new file mode 100644 index 00000000..31d27ca7 --- /dev/null +++ b/BurnOutSharp/ProtectionType/CDSHiELDSE.cs @@ -0,0 +1,13 @@ +namespace BurnOutSharp.ProtectionType +{ + public class CDSHiELDSE + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("~0017.tmp")) + return "CDSHiELD SE"; + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/CDX.cs b/BurnOutSharp/ProtectionType/CDX.cs new file mode 100644 index 00000000..2f183652 --- /dev/null +++ b/BurnOutSharp/ProtectionType/CDX.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class CDX + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Confirm if OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("CHKCDX16.DLL", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("CHKCDX32.DLL", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("CHKCDXNT.DLL", StringComparison.OrdinalIgnoreCase)) > 0) + { + 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 null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/CactusDataShield.cs b/BurnOutSharp/ProtectionType/CactusDataShield.cs new file mode 100644 index 00000000..7e4830a8 --- /dev/null +++ b/BurnOutSharp/ProtectionType/CactusDataShield.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class CactusDataShield + { + public static string CheckContents(string file) + { + if (Path.GetFileName(file) == "CDSPlayer.app") + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var sr = new StreamReader(fs)) + { + return "Cactus Data Shield " + sr.ReadLine().Substring(3) + "(" + sr.ReadLine() + ")"; + } + } + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Verify if these are OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase)) > 0) + { + string file = files.First(f => Path.GetFileName(f).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase)); + string protection = CheckContents(file); + if (!string.IsNullOrWhiteSpace(protection)) + return protection; + } + else if (files.Count(f => Path.GetFileName(f).Equals("yucca.cds", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("wmmp.exe", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("PJSTREAM.DLL", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "Cactus Data Shield 200"; + } + } + else + { + if (Path.GetFileName(path).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase)) + { + string protection = CheckContents(path); + if (!string.IsNullOrWhiteSpace(protection)) + return protection; + } + else if (Path.GetFileName(path).Equals("yucca.cds", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("wmmp.exe", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("PJSTREAM.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase)) + { + return "Cactus Data Shield 200"; + } + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/CengaProtectDVD.cs b/BurnOutSharp/ProtectionType/CengaProtectDVD.cs new file mode 100644 index 00000000..a4161587 --- /dev/null +++ b/BurnOutSharp/ProtectionType/CengaProtectDVD.cs @@ -0,0 +1,13 @@ +namespace BurnOutSharp.ProtectionType +{ + public class CengaProtectDVD + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains(".cenega")) + return "Cenega ProtectDVD"; + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/CodeLock.cs b/BurnOutSharp/ProtectionType/CodeLock.cs new file mode 100644 index 00000000..1e2fce3f --- /dev/null +++ b/BurnOutSharp/ProtectionType/CodeLock.cs @@ -0,0 +1,18 @@ +namespace BurnOutSharp.ProtectionType +{ + public class CodeLock + { + public static string CheckContents(string fileContent) + { + // TODO: Check if OR or AND + if (fileContent.Contains("icd1" + (char)0x00) + || fileContent.Contains("icd2" + (char)0x00) + || fileContent.Contains("CODE-LOCK.OCX")) + { + return "Code Lock"; + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/CopyKiller.cs b/BurnOutSharp/ProtectionType/CopyKiller.cs new file mode 100644 index 00000000..9cf55571 --- /dev/null +++ b/BurnOutSharp/ProtectionType/CopyKiller.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class CopyKiller + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("Tom Commander")) + return "CopyKiller"; + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("Autorun.dat", StringComparison.OrdinalIgnoreCase)) > 0) + return "CopyKiller"; + } + else + { + if (Path.GetFileName(path).Equals("Autorun.dat", StringComparison.OrdinalIgnoreCase)) + return "CopyKiller"; + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/CopyLok.cs b/BurnOutSharp/ProtectionType/CopyLok.cs new file mode 100644 index 00000000..245d6fee --- /dev/null +++ b/BurnOutSharp/ProtectionType/CopyLok.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class CopyLok + { + // TODO: Implement - http://web.archive.org/web/20041215075727/http://www.panlok.com/codelok2.htm + } +} diff --git a/BurnOutSharp/ProtectionType/CrypKey.cs b/BurnOutSharp/ProtectionType/CrypKey.cs new file mode 100644 index 00000000..9306575d --- /dev/null +++ b/BurnOutSharp/ProtectionType/CrypKey.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class CrypKey + { + // TODO: Implement - http://www.crypkey.com/products/cdlock/cdmain.html + } +} diff --git a/BurnOutSharp/ProtectionType/Cucko.cs b/BurnOutSharp/ProtectionType/Cucko.cs new file mode 100644 index 00000000..56d5588c --- /dev/null +++ b/BurnOutSharp/ProtectionType/Cucko.cs @@ -0,0 +1,14 @@ +namespace BurnOutSharp.ProtectionType +{ + public class Cucko + { + public static string CheckContents(string fileContent) + { + // TODO: Verify this doesn't over-match + if (fileContent.Contains("EASTL")) + return "Cucko (EA Custom)"; + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/DBB.cs b/BurnOutSharp/ProtectionType/DBB.cs new file mode 100644 index 00000000..18af56c9 --- /dev/null +++ b/BurnOutSharp/ProtectionType/DBB.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class DBB + { + // TODO: Implement - http://web.archive.org/web/20040604233815/www.wkit.com/sites/wkit/setup/eng/index.asp + } +} diff --git a/BurnOutSharp/ProtectionType/DVDCops.cs b/BurnOutSharp/ProtectionType/DVDCops.cs new file mode 100644 index 00000000..ac028ed1 --- /dev/null +++ b/BurnOutSharp/ProtectionType/DVDCops.cs @@ -0,0 +1,30 @@ +using System.IO; + +namespace BurnOutSharp.ProtectionType +{ + public class DVDCops + { + public static string CheckContents(string file, string fileContent) + { + int position; + if ((position = fileContent.IndexOf("DVD-Cops, ver. ")) > -1) + return "DVD-Cops " + GetVersion(file, position); + + return null; + } + + private static string GetVersion(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(position + 15, SeekOrigin.Begin); // Begin reading after "CD-Cops, ver." + char[] version = br.ReadChars(4); + if (version[0] == 0x00) + return ""; + + return new string(version); + } + } + } +} diff --git a/BurnOutSharp/ProtectionType/DVDCrypt.cs b/BurnOutSharp/ProtectionType/DVDCrypt.cs new file mode 100644 index 00000000..eaa16a3b --- /dev/null +++ b/BurnOutSharp/ProtectionType/DVDCrypt.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class DVDCrypt + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("DvdCrypt.pdb", StringComparison.OrdinalIgnoreCase)) > 0) + return "DVD Crypt"; + } + else + { + 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 new file mode 100644 index 00000000..9e453a9a --- /dev/null +++ b/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class DVDMoviePROTECT + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (!isDirectory) + return null; + + if (Directory.Exists(Path.Combine(path, "VIDEO_TS"))) + { + string[] bupfiles = files.Where(s => s.EndsWith(".bup")).ToArray(); + for (int i = 0; i < bupfiles.Length; i++) + { + FileInfo bupfile = new FileInfo(bupfiles[i]); + FileInfo ifofile = new FileInfo(bupfile.DirectoryName + "\\" + bupfile.Name.Substring(0, bupfile.Name.Length - bupfile.Extension.Length) + ".ifo"); + if (bupfile.Length != ifofile.Length) + return "DVD-Movie-PROTECT"; ; + } + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/DiscGuard.cs b/BurnOutSharp/ProtectionType/DiscGuard.cs new file mode 100644 index 00000000..22ffd913 --- /dev/null +++ b/BurnOutSharp/ProtectionType/DiscGuard.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class DiscGuard + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("IOSLINK.VXD", StringComparison.OrdinalIgnoreCase)) > 0 + && files.Count(f => Path.GetFileName(f).Equals("IOSLINK.SYS", StringComparison.OrdinalIgnoreCase)) > 0) + { + 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 null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/EACdKey.cs b/BurnOutSharp/ProtectionType/EACdKey.cs new file mode 100644 index 00000000..fd196f2f --- /dev/null +++ b/BurnOutSharp/ProtectionType/EACdKey.cs @@ -0,0 +1,13 @@ +namespace BurnOutSharp.ProtectionType +{ + public class EACdKey + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("ereg.ea-europe.com")) + return "EA CdKey Registration Module"; + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/EXEStealth.cs b/BurnOutSharp/ProtectionType/EXEStealth.cs new file mode 100644 index 00000000..fe03597c --- /dev/null +++ b/BurnOutSharp/ProtectionType/EXEStealth.cs @@ -0,0 +1,17 @@ +namespace BurnOutSharp.ProtectionType +{ + public class EXEStealth + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("??[[__[[_" + (char)0x00 + "{{" + (char)0x0 + + (char)0x00 + "{{" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x0 + + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "?;??;??")) + { + return "EXE Stealth"; + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/FADE.cs b/BurnOutSharp/ProtectionType/FADE.cs new file mode 100644 index 00000000..6c8276a9 --- /dev/null +++ b/BurnOutSharp/ProtectionType/FADE.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class FADE + { + // TODO: Implement - http://www.codemasters.com/news/displayarticles.php?showarticle=500 + } +} diff --git a/BurnOutSharp/ProtectionType/FreeLock.cs b/BurnOutSharp/ProtectionType/FreeLock.cs new file mode 100644 index 00000000..b5f1459d --- /dev/null +++ b/BurnOutSharp/ProtectionType/FreeLock.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class FreeLock + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("FREELOCK.IMG", StringComparison.OrdinalIgnoreCase)) > 0) + return "FreeLock"; + } + else + { + 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 new file mode 100644 index 00000000..59fc939e --- /dev/null +++ b/BurnOutSharp/ProtectionType/GFWL.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class GFWL + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("xlive.dll")) + return "Games for Windows - Live"; + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("XLiveRedist.msi", StringComparison.OrdinalIgnoreCase)) > 0) + return "Games for Windows - Live"; + } + else + { + 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 new file mode 100644 index 00000000..ac662eba --- /dev/null +++ b/BurnOutSharp/ProtectionType/HexalockAutoLock.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class HexalockAutoLock + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Verify if these are OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("Start_Here.exe", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("HCPSMng.exe", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("MFINT.DLL", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("MFIMP.DLL", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "Hexalock AutoLock"; + } + } + else + { + 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 null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/ImpulseReactor.cs b/BurnOutSharp/ProtectionType/ImpulseReactor.cs new file mode 100644 index 00000000..5da16b39 --- /dev/null +++ b/BurnOutSharp/ProtectionType/ImpulseReactor.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class ImpulseReactor + { + public static string CheckContents(string file, string fileContent) + { + if (fileContent.Contains("CVPInitializeClient")) + { + if (fileContent.Contains("A" + (char)0x00 + "T" + (char)0x00 + "T" + (char)0x00 + "L" + (char)0x00 + "I" + + (char)0x00 + "S" + (char)0x00 + "T" + (char)0x00 + (char)0x00 + (char)0x00 + "E" + (char)0x00 + "L" + + (char)0x00 + "E" + (char)0x00 + "M" + (char)0x00 + "E" + (char)0x00 + "N" + (char)0x00 + "T" + (char)0x00 + + (char)0x00 + (char)0x00 + "N" + (char)0x00 + "O" + (char)0x00 + "T" + (char)0x00 + "A" + (char)0x00 + "T" + + (char)0x00 + "I" + (char)0x00 + "O" + (char)0x00 + "N")) + { + return "Impulse Reactor " + Utilities.GetFileVersion(file); + } + else + { + return "Impulse Reactor"; + } + } + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase)) > 0) + 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)) + return "Impulse Reactor " + Utilities.GetFileVersion(path); + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/IndyVCD.cs b/BurnOutSharp/ProtectionType/IndyVCD.cs new file mode 100644 index 00000000..53d42bea --- /dev/null +++ b/BurnOutSharp/ProtectionType/IndyVCD.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class IndyVCD + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Verify if these are OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("INDYVCD.AX", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("INDYMP3.idt", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "IndyVCD"; + } + } + else + { + if (Path.GetFileName(path).Equals("INDYVCD.AX", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("INDYMP3.idt", StringComparison.OrdinalIgnoreCase)) + { + return "IndyVCD"; + } + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/InnoSetup.cs b/BurnOutSharp/ProtectionType/InnoSetup.cs new file mode 100644 index 00000000..07d1e96c --- /dev/null +++ b/BurnOutSharp/ProtectionType/InnoSetup.cs @@ -0,0 +1,45 @@ +using System.IO; + +namespace BurnOutSharp.ProtectionType +{ + public class InnoSetup + { + public static string CheckContents(string file, string fileContent) + { + if (fileContent.IndexOf("Inno") == 0x30) + { + // TOOO: Add Inno Setup extraction + return "Inno Setup " + GetVersion(file); + } + + return null; + } + + private static string GetVersion(string file) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(0x30, SeekOrigin.Begin); + string signature = new string(br.ReadChars(12)); + + if (signature == "rDlPtS02" + (char)0x87 + "eVx") + return "1.2.10"; + else if (signature == "rDlPtS04" + (char)0x87 + "eVx") + return "4.0.0"; + else if (signature == "rDlPtS05" + (char)0x87 + "eVx") + return "4.0.3"; + else if (signature == "rDlPtS06" + (char)0x87 + "eVx") + return "4.0.10"; + else if (signature == "rDlPtS07" + (char)0x87 + "eVx") + return "4.1.6"; + else if (signature == "rDlPtS" + (char)0xcd + (char)0xe6 + (char)0xd7 + "{" + (char)0x0b + "*") + return "5.1.5"; + else if (signature == "nS5W7dT" + (char)0x83 + (char)0xaa + (char)0x1b + (char)0x0f + "j") + return "5.1.5"; + + return string.Empty; + } + } + } +} diff --git a/BurnOutSharp/ProtectionType/JoWooDXProt.cs b/BurnOutSharp/ProtectionType/JoWooDXProt.cs new file mode 100644 index 00000000..80dfa1d5 --- /dev/null +++ b/BurnOutSharp/ProtectionType/JoWooDXProt.cs @@ -0,0 +1,49 @@ +using System.IO; + +namespace BurnOutSharp.ProtectionType +{ + public class JoWooDXProt + { + public static string CheckContents(string file, string fileContent) + { + int position; + if (fileContent.Contains(".ext ")) + { + if ((position = fileContent.IndexOf("kernel32.dll" + (char)0x00 + (char)0x00 + (char)0x00 + "VirtualProtect")) > -1) + { + return "JoWooD X-Prot " + GetVersion(file, --position); + } + else + { + return "JoWooD X-Prot v1"; + } + } + else if (fileContent.Contains("@HC09 ")) + { + return "JoWooD X-Prot v2"; + } + + return null; + } + + private static string GetVersion(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + char[] version = new char[5]; + br.BaseStream.Seek(position + 67, SeekOrigin.Begin); + version[0] = br.ReadChar(); + br.ReadByte(); + version[1] = br.ReadChar(); + br.ReadByte(); + version[2] = br.ReadChar(); + br.ReadByte(); + version[3] = br.ReadChar(); + version[4] = br.ReadChar(); + + return version[0] + "." + version[1] + "." + version[2] + "." + version[3] + version[4]; + } + } + } +} diff --git a/BurnOutSharp/ProtectionType/Key2AudioXS.cs b/BurnOutSharp/ProtectionType/Key2AudioXS.cs new file mode 100644 index 00000000..8888ffcb --- /dev/null +++ b/BurnOutSharp/ProtectionType/Key2AudioXS.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class Key2AudioXS + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Verify if these are OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("SDKHM.EXE", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("SDKHM.DLL", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "Key2Audio XS"; + } + } + else + { + if (Path.GetFileName(path).Equals("SDKHM.EXE", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("SDKHM.DLL", StringComparison.OrdinalIgnoreCase)) + { + return "Key2Audio XS"; + } + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/KeyLock.cs b/BurnOutSharp/ProtectionType/KeyLock.cs new file mode 100644 index 00000000..802db143 --- /dev/null +++ b/BurnOutSharp/ProtectionType/KeyLock.cs @@ -0,0 +1,13 @@ +namespace BurnOutSharp.ProtectionType +{ + public class KeyLock + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("KEY-LOCK COMMAND")) + return "Key-Lock (Dongle)"; + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/LaserLock.cs b/BurnOutSharp/ProtectionType/LaserLock.cs new file mode 100644 index 00000000..68d264a0 --- /dev/null +++ b/BurnOutSharp/ProtectionType/LaserLock.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class LaserLock + { + public static string CheckContents(string file, string fileContent) + { + int position; + if (fileContent.Contains("Packed by SPEEnc V2 Asterios Parlamentas.PE") + && (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, true); + } + + else 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 + + "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") + { + return "LaserLock " + GetVersion16Bit(file); + } + + else 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" + + (char)0xF + "LASERLOK_CHECK2" + (char)0xF + "LASERLOK_CHECK3")) + { + return "LaserLock 5"; + } + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (Directory.Exists(Path.Combine(path, "LASERLOK"))) + { + return "LaserLock"; + } + + // TODO: Verify if these are OR or AND + else if (files.Count(f => Path.GetFileName(f).Equals("NOMOUSE.SP", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("NOMOUSE.COM", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("l16dll.dll", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("laserlok.in", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("laserlok.o10", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("laserlok.011", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "LaserLock"; + } + } + else + { + 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; + } + + private static string GetBuild(string fileContent, bool versionTwo) + { + // TODO: Is this supposed to be "Unknown"? + int position = fileContent.IndexOf("Unkown" + (char)0 + "Unkown"); + string year, month, day; + if (versionTwo) + { + day = fileContent.Substring(position + 14, 2); + month = fileContent.Substring(position + 14 + 3, 2); + year = "20" + fileContent.Substring(position + 14 + 6, 2); + } + else + { + day = fileContent.Substring(position + 13, 2); + month = fileContent.Substring(position + 13 + 3, 2); + year = "20" + fileContent.Substring(position + 13 + 6, 2); + } + + return "(Build " + year + "-" + month + "-" + day + ")"; + } + + private static string GetVersion(string FileContent, int position) + { + return FileContent.Substring(position + 76, 4); + } + + private static string GetVersion16Bit(string file) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + char[] version = new char[3]; + br.BaseStream.Seek(71, SeekOrigin.Begin); + version[0] = br.ReadChar(); + br.ReadByte(); + version[1] = br.ReadChar(); + version[2] = br.ReadChar(); + + if (char.IsNumber(version[0]) && char.IsNumber(version[1]) && char.IsNumber(version[2])) + return version[0] + "." + version[1] + version[2]; + + return ""; + } + } + } +} diff --git a/BurnOutSharp/ProtectionType/LockBlocks.cs b/BurnOutSharp/ProtectionType/LockBlocks.cs new file mode 100644 index 00000000..600f0728 --- /dev/null +++ b/BurnOutSharp/ProtectionType/LockBlocks.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class LockBlocks + { + // TODO: Implement - https://www.cdmediaworld.com/hardware/cdrom/cd_protections_lockblocks.shtml + } +} diff --git a/BurnOutSharp/ProtectionType/MediaCloQ.cs b/BurnOutSharp/ProtectionType/MediaCloQ.cs new file mode 100644 index 00000000..1b49d058 --- /dev/null +++ b/BurnOutSharp/ProtectionType/MediaCloQ.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class MediaCloQ + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("sunncomm.ico", StringComparison.OrdinalIgnoreCase)) > 0) + return "MediaCloQ"; + } + else + { + 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 new file mode 100644 index 00000000..40c17d5e --- /dev/null +++ b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class MediaMaxCD3 + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("LaunchCd.exe", StringComparison.OrdinalIgnoreCase)) > 0) + return "MediaMax CD3"; + } + else + { + if (Path.GetFileName(path).Equals("LaunchCd.exe", StringComparison.OrdinalIgnoreCase)) + return "MediaMax CD3"; + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/MusicGuard.cs b/BurnOutSharp/ProtectionType/MusicGuard.cs new file mode 100644 index 00000000..2f0397e9 --- /dev/null +++ b/BurnOutSharp/ProtectionType/MusicGuard.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class MusicGuard + { + // TODO: Implement - http://web.archive.org/web/20020606000647/http://www.musicguard.com + } +} diff --git a/BurnOutSharp/ProtectionType/Origin.cs b/BurnOutSharp/ProtectionType/Origin.cs new file mode 100644 index 00000000..7653820c --- /dev/null +++ b/BurnOutSharp/ProtectionType/Origin.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class Origin + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("OriginSetup.exe", StringComparison.OrdinalIgnoreCase)) > 0) + return "Origin"; + } + else + { + if (Path.GetFileName(path).Equals("OriginSetup.exe", StringComparison.OrdinalIgnoreCase)) + return "Origin"; + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/PECompact.cs b/BurnOutSharp/ProtectionType/PECompact.cs new file mode 100644 index 00000000..a38d2af5 --- /dev/null +++ b/BurnOutSharp/ProtectionType/PECompact.cs @@ -0,0 +1,13 @@ +namespace BurnOutSharp.ProtectionType +{ + public class PECompact + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("PEC2")) + return "PE Compact 2"; + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/PSXAntiModchip.cs b/BurnOutSharp/ProtectionType/PSXAntiModchip.cs new file mode 100644 index 00000000..1ce4c55e --- /dev/null +++ b/BurnOutSharp/ProtectionType/PSXAntiModchip.cs @@ -0,0 +1,53 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class PSXAntiModchip + { + public static string CheckContents(string file, string fileContent) + { + 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おそれがあります。")) + return "PlayStation Anti-modchip (Japanese)"; + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Where(s => s.ToLowerInvariant().EndsWith(".cnf")).Count() > 0) + { + foreach (string file in files) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var sr = new StreamReader(fs)) + { + string fileContent = sr.ReadToEnd(); + string protection = CheckContents(path, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + return protection; + } + } + } + } + else + { + using (var fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var sr = new StreamReader(fs)) + { + string fileContent = sr.ReadToEnd(); + string protection = CheckContents(path, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + return protection; + } + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/Phenoprotect.cs b/BurnOutSharp/ProtectionType/Phenoprotect.cs new file mode 100644 index 00000000..1de32b27 --- /dev/null +++ b/BurnOutSharp/ProtectionType/Phenoprotect.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class Phenoprotect + { + // TODO: Implement - https://www.cdmediaworld.com/hardware/cdrom/cd_protections_phenoprotect.shtml + } +} diff --git a/BurnOutSharp/ProtectionType/ProtectDVDVideo.cs b/BurnOutSharp/ProtectionType/ProtectDVDVideo.cs new file mode 100644 index 00000000..451cc0ee --- /dev/null +++ b/BurnOutSharp/ProtectionType/ProtectDVDVideo.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class ProtectDVDVideo + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (!isDirectory) + return null; + + if (Directory.Exists(Path.Combine(path, "VIDEO_TS"))) + { + string[] ifofiles = files.Where(s => s.EndsWith(".ifo")).ToArray(); + for (int i = 0; i < ifofiles.Length; i++) + { + FileInfo ifofile = new FileInfo(ifofiles[i]); + if (ifofile.Length == 0) + return "Protect DVD-Video"; + } + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/ProtectDisc.cs b/BurnOutSharp/ProtectionType/ProtectDisc.cs new file mode 100644 index 00000000..f2633ee3 --- /dev/null +++ b/BurnOutSharp/ProtectionType/ProtectDisc.cs @@ -0,0 +1,157 @@ +using System; +using System.IO; + +namespace BurnOutSharp.ProtectionType +{ + public class ProtectDisc + { + public static string CheckContents(string file, string fileContent) + { + int position; + if ((position = fileContent.IndexOf("HúMETINF")) > -1) + { + string version = EVORE.SearchProtectDiscVersion(file); + if (version.Length > 0) + { + string[] astrVersionArray = version.Split('.'); + if (astrVersionArray[0] == "9") + { + if (GetVersionBuild76till10(file, position, out int ibuild).Length > 0) + return "ProtectDisc " + astrVersionArray[0] + "." + astrVersionArray[1] + astrVersionArray[2] + "." + astrVersionArray[3] + " (Build " + ibuild + ")"; + } + else + return "ProtectDisc " + astrVersionArray[0] + "." + astrVersionArray[1] + "." + astrVersionArray[2] + " (Build " + astrVersionArray[3] + ")"; + } + } + + if ((position = fileContent.IndexOf("ACE-PCD")) > -1) + { + string version = EVORE.SearchProtectDiscVersion(file); + if (version.Length > 0) + { + string[] astrVersionArray = version.Split('.'); + return "ProtectDisc " + astrVersionArray[0] + "." + astrVersionArray[1] + "." + astrVersionArray[2] + " (Build " + astrVersionArray[3] + ")"; + } + + return "ProtectDisc " + GetVersionBuild6till8(file, position); + } + + return null; + } + + private static string GetVersionBuild6till8(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + string version; + string strBuild; + + br.BaseStream.Seek(position - 12, SeekOrigin.Begin); + if (br.ReadByte() == 0xA && br.ReadByte() == 0xD && br.ReadByte() == 0xA && br.ReadByte() == 0xD) // ProtectDisc 6-7 with Build Number in plain text + { + br.BaseStream.Seek(position - 12 - 6, SeekOrigin.Begin); + if (new string(br.ReadChars(6)) == "Henrik") // ProtectDisc 7 + { + version = "7.1-7.5"; + br.BaseStream.Seek(position - 12 - 6 - 6, SeekOrigin.Begin); + } + else // ProtectDisc 6 + { + version = "6"; + br.BaseStream.Seek(position - 12 - 10, SeekOrigin.Begin); + while (true) //search for e.g. "Build 050913 - September 2005" + { + if (Char.IsNumber(br.ReadChar())) + break; + br.BaseStream.Seek(-2, SeekOrigin.Current); //search upwards + } + + br.BaseStream.Seek(-5, SeekOrigin.Current); + } + } + else + { + br.BaseStream.Seek(position + 28, SeekOrigin.Begin); + if (br.ReadByte() == 0xFB) + { + return "7.6-7.x"; + } + else + { + return "8.0"; + } + } + strBuild = "" + br.ReadChar() + br.ReadChar() + br.ReadChar() + br.ReadChar() + br.ReadChar(); + return version + " (Build " + strBuild + ")"; + } + } + + private static string GetVersionBuild76till10(string file, int position, out int irefBuild) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(position + 37, SeekOrigin.Begin); + byte subversion = br.ReadByte(); + br.ReadByte(); + byte version = br.ReadByte(); + br.BaseStream.Seek(position + 49, SeekOrigin.Begin); + irefBuild = br.ReadInt32(); + br.BaseStream.Seek(position + 53, SeekOrigin.Begin); + byte versionindicatorPD9 = br.ReadByte(); + br.BaseStream.Seek(position + 0x40, SeekOrigin.Begin); + byte subsubversionPD9x = br.ReadByte(); + byte subversionPD9x2 = br.ReadByte(); + byte subversionPD9x1 = br.ReadByte(); + + // version 7 + if (version == 0xAC) + return "7." + (subversion ^ 0x43) + " (Build " + irefBuild + ")"; + // version 8 + else if (version == 0xA2) + { + if (subversion == 0x46) + { + if ((irefBuild & 0x3A00) == 0x3A00) + return "8.2" + " (Build " + irefBuild + ")"; + else + return "8.1" + " (Build " + irefBuild + ")"; + } + return "8." + (subversion ^ 0x47) + " (Build " + irefBuild + ")"; + } + // version 9 + else if (version == 0xA3) + { + // version removed or not given + if ((subversionPD9x2 == 0x5F && subversionPD9x1 == 0x61) || (subversionPD9x1 == 0 && subversionPD9x2 == 0)) + { + if (versionindicatorPD9 == 0xB) + return "9.0-9.4" + " (Build " + irefBuild + ")"; + else if (versionindicatorPD9 == 0xC) + { + if (subversionPD9x2 == 0x5F && subversionPD9x1 == 0x61) + return "9.5-9.11" + " (Build " + irefBuild + ")"; + else if (subversionPD9x1 == 0 && subversionPD9x2 == 0) + return "9.11-9.20" + " (Build " + irefBuild + ")"; + } + else + return "9." + subversionPD9x1 + subversionPD9x2 + "." + subsubversionPD9x + " (Build " + irefBuild + ")"; + } + } + else if (version == 0xA0) + { + // version removed + if (subversionPD9x1 != 0 || subversionPD9x2 != 0) + return "10." + subversionPD9x1 + "." + subsubversionPD9x + " (Build " + irefBuild + ")"; + else + return "10.x (Build " + irefBuild + ")"; + } + else + return "7.6-10.x (Build " + irefBuild + ")"; + + return ""; + } + } + } +} diff --git a/BurnOutSharp/ProtectionType/RingPROTECH.cs b/BurnOutSharp/ProtectionType/RingPROTECH.cs new file mode 100644 index 00000000..ffa50b12 --- /dev/null +++ b/BurnOutSharp/ProtectionType/RingPROTECH.cs @@ -0,0 +1,13 @@ +namespace BurnOutSharp.ProtectionType +{ + public class RingPROTECH + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains((char)0x00 + "Allocator" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00)) + return "Ring PROTECH"; + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/Roxxe.cs b/BurnOutSharp/ProtectionType/Roxxe.cs new file mode 100644 index 00000000..ac88614c --- /dev/null +++ b/BurnOutSharp/ProtectionType/Roxxe.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class Roxxe + { + // TODO: Implement - http://web.archive.org/web/20050309084802/http://www.roxxe.cz + } +} diff --git a/BurnOutSharp/ProtectionType/SAFEAUDIO.cs b/BurnOutSharp/ProtectionType/SAFEAUDIO.cs new file mode 100644 index 00000000..717226c2 --- /dev/null +++ b/BurnOutSharp/ProtectionType/SAFEAUDIO.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class SAFEAUDIO + { + // TODO: Implement - https://www.cdmediaworld.com/hardware/cdrom/cd_protections_safeaudio.shtml + } +} diff --git a/BurnOutSharp/ProtectionType/SVKProtector.cs b/BurnOutSharp/ProtectionType/SVKProtector.cs new file mode 100644 index 00000000..0dbb00c8 --- /dev/null +++ b/BurnOutSharp/ProtectionType/SVKProtector.cs @@ -0,0 +1,13 @@ +namespace BurnOutSharp.ProtectionType +{ + public class SVKProtector + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("?SVKP" + (char)0x00 + (char)0x00)) + return "SVK Protector"; + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/SafeCast.cs b/BurnOutSharp/ProtectionType/SafeCast.cs new file mode 100644 index 00000000..065cb5ac --- /dev/null +++ b/BurnOutSharp/ProtectionType/SafeCast.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class SafeCast + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("cdac11ba.exe", StringComparison.OrdinalIgnoreCase)) > 0) + return "SafeCast"; + } + else + { + 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 new file mode 100644 index 00000000..8c4d0c25 --- /dev/null +++ b/BurnOutSharp/ProtectionType/SafeDisc.cs @@ -0,0 +1,204 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class SafeDisc + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: These are all cop-outs that don't check the existence of the other files + if (files.Count(f => Path.GetFileName(f).Equals("DPLAYERX.DLL", StringComparison.OrdinalIgnoreCase)) > 0) + { + return GetDPlayerXVersion(path); + } + else if (files.Count(f => Path.GetFileName(f).Equals("drvmgt.dll", StringComparison.OrdinalIgnoreCase)) > 0) + { + return GetDrvmgtVersion(path); + } + else if (files.Count(f => Path.GetFileName(f).Equals("secdrv.sys", StringComparison.OrdinalIgnoreCase)) > 0) + { + return GetSecdrvVersion(path); + } + } + else + { + // 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) + || Path.GetExtension(path).Trim('.').Equals("016", StringComparison.OrdinalIgnoreCase) + || Path.GetExtension(path).Trim('.').Equals("256", StringComparison.OrdinalIgnoreCase)) + { + return "SafeDisc 1"; + } + + // V1 or greater + else if (Path.GetFileName(path).Equals("00000001.TMP", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("CLCD32.DLL", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("CLOKSPL.EXE", StringComparison.OrdinalIgnoreCase)) + { + return "SafeDisc 1 or greater"; + } + + // 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; + } + + 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); + if (fi.Length == 81408) + return "SafeDisc 1.0x"; + else if (fi.Length == 155648) + return "SafeDisc 1.1x"; + else if (fi.Length == 156160) + return "SafeDisc 1.1x-1.2x"; + else if (fi.Length == 163328) + return "SafeDisc 1.3x"; + else if (fi.Length == 165888) + return "SafeDisc 1.35"; + else if (fi.Length == 172544) + return "SafeDisc 1.40"; + else if (fi.Length == 173568) + return "SafeDisc 1.4x"; + else if (fi.Length == 136704) + return "SafeDisc 1.4x"; + else if (fi.Length == 138752) + return "SafeDisc 1.5x"; + else + return "SafeDisc 1"; + } + + private static string GetDrvmgtVersion(string file) + { + FileInfo fi = new FileInfo(file); + if (fi.Length == 34816) + return "SafeDisc 1.0x"; + else if (fi.Length == 32256) + return "SafeDisc 1.1x-1.3x"; + else if (fi.Length == 31744) + return "SafeDisc 1.4x"; + else if (fi.Length == 34304) + return "SafeDisc 1.5x-2.40"; + else if (fi.Length == 35840) + return "SafeDisc 2.51-2.60"; + else if (fi.Length == 40960) + return "SafeDisc 2.70"; + else if (fi.Length == 23552) + return "SafeDisc 2.80"; + else if (fi.Length == 41472) + return "SafeDisc 2.90-3.10"; + else if (fi.Length == 24064) + return "SafeDisc 3.15-3.20"; + else + return "SafeDisc 1 or greater"; + } + + private static string GetSecdrvVersion(string file) + { + FileInfo fi = new FileInfo(file); + if (fi.Length == 20128) + return "SafeDisc 2.10"; + else if (fi.Length == 27440) + return "SafeDisc 2.30"; + else if (fi.Length == 28624) + return "SafeDisc 2.40"; + else if (fi.Length == 18768) + return "SafeDisc 2.50"; + else if (fi.Length == 28400) + return "SafeDisc 2.51"; + else if (fi.Length == 29392) + return "SafeDisc 2.60"; + else if (fi.Length == 11376) + return "SafeDisc 2.70"; + else if (fi.Length == 12464) + return "SafeDisc 2.80"; + else if (fi.Length == 12400) + return "SafeDisc 2.90"; + else if (fi.Length == 12528) + return "SafeDisc 3.10"; + else if (fi.Length == 12528) + return "SafeDisc 3.15"; + else if (fi.Length == 11973) + return "SafeDisc 3.20"; + else + return "SafeDisc 2 or greater"; + } + + private static string GetVersion(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(position + 20, SeekOrigin.Begin); // Begin reading after "BoG_ *90.0&!! Yy>" for old SafeDisc + int version = br.ReadInt32(); + int subVersion = br.ReadInt32(); + int subsubVersion = br.ReadInt32(); + + if (version != 0) + return version + "." + subVersion.ToString("00") + "." + subsubVersion.ToString("000"); + + br.BaseStream.Seek(position + 18 + 14, SeekOrigin.Begin); // Begin reading after "BoG_ *90.0&!! Yy>" for newer SafeDisc + version = br.ReadInt32(); + subVersion = br.ReadInt32(); + subsubVersion = br.ReadInt32(); + + if (version == 0) + return ""; + + return version + "." + subVersion.ToString("00") + "." + subsubVersion.ToString("000"); + } + } + } +} diff --git a/BurnOutSharp/ProtectionType/SafeDiscLite.cs b/BurnOutSharp/ProtectionType/SafeDiscLite.cs new file mode 100644 index 00000000..ffe05eec --- /dev/null +++ b/BurnOutSharp/ProtectionType/SafeDiscLite.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class SafeDiscLite + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("00000001.LT1", StringComparison.OrdinalIgnoreCase)) > 0) + return "SafeDisc Lite"; + } + else + { + 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 new file mode 100644 index 00000000..af1c6085 --- /dev/null +++ b/BurnOutSharp/ProtectionType/SafeLock.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class SafeLock + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("SafeLock")) + return "SafeLock"; + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Verify if these are OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("SafeLock.dat", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("SafeLock.001", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("SafeLock.128", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "SafeLock"; + } + } + else + { + 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 null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/SecuROM.cs b/BurnOutSharp/ProtectionType/SecuROM.cs new file mode 100644 index 00000000..44440401 --- /dev/null +++ b/BurnOutSharp/ProtectionType/SecuROM.cs @@ -0,0 +1,161 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class SecuROM + { + public static string CheckContents(string file, string fileContent) + { + 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) + { + return "SecuROM " + GetV5Version(file, position); + } + + else 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")) + { + return "SecuROM Product Activation " + Utilities.GetFileVersion(file); + } + + else 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) + || fileContent.Contains(".cms_d" + (char)0x00)) + { + return "SecuROM 1-3"; + } + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Verify if these are OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("CMS16.DLL", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("CMS_95.DLL", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("CMS_NT.DLL", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("CMS32_95.DLL", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("CMS32_NT.DLL", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "SecuROM"; + } + else if (files.Count(f => Path.GetFileName(f).Equals("SINTF32.DLL", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("SINTF16.DLL", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("SINTFNT.DLL", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "SecuROM New"; + } + } + else + { + 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; + } + + private static string GetV4Version(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(position + 8, SeekOrigin.Begin); // Begin reading after "AddD" + char version = br.ReadChar(); + br.ReadByte(); + char subVersion1 = br.ReadChar(); + char subVersion2 = br.ReadChar(); + br.ReadByte(); + char subsubVersion1 = br.ReadChar(); + char subsubVersion2 = br.ReadChar(); + br.ReadByte(); + char subsubsubVersion1 = br.ReadChar(); + char subsubsubVersion2 = br.ReadChar(); + char subsubsubVersion3 = br.ReadChar(); + char subsubsubVersion4 = br.ReadChar(); + + return version + "." + subVersion1 + subVersion2 + "." + subsubVersion1 + subsubVersion2 + "." + subsubsubVersion1 + subsubsubVersion2 + subsubsubVersion3 + subsubsubVersion4; + } + } + + private static string GetV5Version(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(position + 8, SeekOrigin.Begin); // Begin reading after "ÊÝݬ" + byte version = (byte)(br.ReadByte() & 0xF); + br.ReadByte(); + byte subVersion1 = (byte)(br.ReadByte() ^ 36); + byte subVersion2 = (byte)(br.ReadByte() ^ 28); + br.ReadByte(); + byte subsubVersion1 = (byte)(br.ReadByte() ^ 42); + byte subsubVersion2 = (byte)(br.ReadByte() ^ 8); + br.ReadByte(); + byte subsubsubVersion1 = (byte)(br.ReadByte() ^ 16); + byte subsubsubVersion2 = (byte)(br.ReadByte() ^ 116); + byte subsubsubVersion3 = (byte)(br.ReadByte() ^ 34); + byte subsubsubVersion4 = (byte)(br.ReadByte() ^ 22); + + if (version == 0 || version > 9) + return ""; + + return version + "." + subVersion1 + subVersion2 + "." + subsubVersion1 + subsubVersion2 + "." + subsubsubVersion1 + subsubsubVersion2 + subsubsubVersion3 + subsubsubVersion4; + } + } + + private static string GetV7Version(string file) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(236, SeekOrigin.Begin); + byte[] bytes = br.ReadBytes(4); + // if (bytes[0] == 0xED && bytes[3] == 0x5C { + if (bytes[3] == 0x5C) + { + //SecuROM 7 new and 8 + return (bytes[0] ^ 0xEA).ToString() + "." + (bytes[1] ^ 0x2C).ToString("00") + "." + (bytes[2] ^ 0x8).ToString("0000"); + } + else // SecuROM 7 old + { + br.BaseStream.Seek(122, SeekOrigin.Begin); + bytes = br.ReadBytes(2); + return "7." + (bytes[0] ^ 0x10).ToString("00") + "." + (bytes[1] ^ 0x10).ToString("0000"); + //return "7.01-7.10" + } + } + } + } +} diff --git a/BurnOutSharp/ProtectionType/SmartE.cs b/BurnOutSharp/ProtectionType/SmartE.cs new file mode 100644 index 00000000..a26bc552 --- /dev/null +++ b/BurnOutSharp/ProtectionType/SmartE.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class SmartE + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("BITARTS")) + return "SmartE"; + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Verify if these are OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("00001.TMP", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("00002.TMP", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "SmartE"; + } + } + else + { + if (Path.GetFileName(path).Equals("00001.TMP", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("00002.TMP", StringComparison.OrdinalIgnoreCase)) + { + return "SmartE"; + } + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/SoftLock.cs b/BurnOutSharp/ProtectionType/SoftLock.cs new file mode 100644 index 00000000..ba3f594d --- /dev/null +++ b/BurnOutSharp/ProtectionType/SoftLock.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class SoftLock + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Verify if these are OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("SOFTLOCKI.dat", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("SOFTLOCKC.dat", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "SoftLock"; + } + } + else + { + if (Path.GetFileName(path).Equals("SOFTLOCKI.dat", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("SOFTLOCKC.dat", StringComparison.OrdinalIgnoreCase)) + { + return "SoftLock"; + } + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/SolidShield.cs b/BurnOutSharp/ProtectionType/SolidShield.cs new file mode 100644 index 00000000..7b81c0cf --- /dev/null +++ b/BurnOutSharp/ProtectionType/SolidShield.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class SolidShield + { + public static string CheckContents(string file, string fileContent) + { + int position; + if (fileContent.Contains("D" + (char)0x00 + "V" + (char)0x00 + "M" + (char)0x00 + " " + (char)0x00 + "L" + (char)0x00 + + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y")) + { + return "SolidShield " + Utilities.GetFileVersion(file); + } + + else 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") + || 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 + "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 + + "L" + (char)0x00 + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y")) + { + string companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower(); + if (companyName.Contains("solidshield") || companyName.Contains("tages")) + return "SolidShield Core.dll " + Utilities.GetFileVersion(file); + } + + else 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); + + if (id1 == "" + (char)0x00 + (char)0x00 + (char)0x00 && id2 == "" + (char)0x00 + (char)0x10 + (char)0x00 + (char)0x00) + return "SolidShield 1 (SolidShield EXE Wrapper)"; + else if (id1 == ".o&" && id2 == "ÛÅ›¹") + 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 + + "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")) + { + string companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower(); + if (companyName.Contains("solidshield") || companyName.Contains("tages")) + return "SolidShield Activation Manager Module " + Utilities.GetFileVersion(file); + } + + else 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 + && fileContent.Substring(position + 15, 4) == "" + (char)0x00 + (char)0x10 + (char)0x00 + (char)0x00) + { + return "SolidShield 2 (SolidShield v2 EXE Wrapper)"; + } + else if (fileContent.Substring(position + 4, 3) == "" + (char)0x00 + (char)0x00 + (char)0x00 + && fileContent.Substring(position + 15, 4) == "" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00) + { + position = fileContent.IndexOf("T" + (char)0x00 + "a" + (char)0x00 + "g" + (char)0x00 + "e" + (char)0x00 + "s" + + (char)0x00 + "S" + (char)0x00 + "e" + (char)0x00 + "t" + (char)0x00 + "u" + (char)0x00 + "p" + + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "0" + (char)0x00 + (char)0x8 + + (char)0x00 + (char)0x1 + (char)0x0 + "F" + (char)0x00 + "i" + (char)0x00 + "l" + (char)0x00 + "e" + + (char)0x00 + "V" + (char)0x00 + "e" + (char)0x00 + "r" + (char)0x00 + "s" + (char)0x00 + "i" + (char)0x00 + + "o" + (char)0x00 + "n" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00); + if (position > -1) + { + position--; // TODO: Verify this subtract + return "SolidShield 2 + Tagès " + fileContent.Substring(position + 0x38, 1) + "." + fileContent.Substring(position + 0x38 + 4, 1) + "." + fileContent.Substring(position + 0x38 + 8, 1) + "." + fileContent.Substring(position + 0x38 + 12, 1); + } + else + { + return "SolidShield 2 (SolidShield v2 EXE Wrapper)"; + } + } + } + + else 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 + + "I" + (char)0x00 + "D" + (char)0x00 + "R" + (char)0x00 + "_" + (char)0x00 + + "S" + (char)0x00 + "G" + (char)0x00 + "T" + (char)0x0)) + { + return "SolidShield"; + } + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Verify if these are OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("dvm.dll", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("hc.dll", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("solidshield-cd.dll", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("c11prot.dll", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "SolidShield"; + } + } + else + { + 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 null; + } + + private static string GetVersion(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(position + 12, SeekOrigin.Begin); // Begin reading after "Solidshield" + char version = br.ReadChar(); + br.ReadByte(); + char subVersion = br.ReadChar(); + br.ReadByte(); + char subsubVersion = br.ReadChar(); + br.ReadByte(); + char subsubsubVersion = br.ReadChar(); + return version + "." + subVersion + "." + subsubVersion + "." + subsubsubVersion; + } + } + } +} diff --git a/BurnOutSharp/ProtectionType/StarForce.cs b/BurnOutSharp/ProtectionType/StarForce.cs new file mode 100644 index 00000000..07f89e45 --- /dev/null +++ b/BurnOutSharp/ProtectionType/StarForce.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class StarForce + { + public static string CheckContents(string file, string fileContent) + { + int position; + if (fileContent.Contains("(" + (char)0x00 + "c" + (char)0x00 + ")" + (char)0x00 + " " + (char)0x00 + "P" + (char)0x00 + + "r" + (char)0x00 + "o" + (char)0x00 + "t" + (char)0x00 + "e" + (char)0x00 + "c" + (char)0x00 + "t" + (char)0x00 + + "i" + (char)0x00 + "o" + (char)0x00 + "n" + (char)0x00 + " " + (char)0x00 + "T" + (char)0x00 + "e" + (char)0x00 + + "c" + (char)0x00 + "h" + (char)0x00 + "n" + (char)0x00 + "o" + (char)0x00 + "l" + (char)0x00 + "o" + (char)0x00 + + "g" + (char)0x00 + "y" + (char)0x00) + || fileContent.Contains("Protection Technology, Ltd.")) + { + //if (FileContent.Contains("PSA_GetDiscLabel") + //if (FileContent.Contains("(c) Protection Technology") + position = fileContent.IndexOf("TradeName") - 1; + if (position != -1 && position != -2) + return "StarForce " + Utilities.GetFileVersion(file) + " (" + fileContent.Substring(position + 22, 30).Split((char)0x00)[0] + ")"; + else + return "StarForce " + Utilities.GetFileVersion(file); + } + + else 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 + + "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")) + { + return "StarForce 5"; + } + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Verify if these are OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("protect.dll", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("protect.exe", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "StarForce"; + } + } + else + { + if (Path.GetFileName(path).Equals("protect.dll", StringComparison.OrdinalIgnoreCase) + || Path.GetFileName(path).Equals("protect.exe", StringComparison.OrdinalIgnoreCase)) + { + return "StarForce"; + } + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/Steam.cs b/BurnOutSharp/ProtectionType/Steam.cs new file mode 100644 index 00000000..0e0834ce --- /dev/null +++ b/BurnOutSharp/ProtectionType/Steam.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class Steam + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("SteamInstall.exe", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("SteamInstall.ini", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("SteamInstall.msi", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("SteamRetailInstaller.dmg", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("SteamSetup.exe", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "Steam"; + } + } + else + { + 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 null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/Sysiphus.cs b/BurnOutSharp/ProtectionType/Sysiphus.cs new file mode 100644 index 00000000..2fc5ad54 --- /dev/null +++ b/BurnOutSharp/ProtectionType/Sysiphus.cs @@ -0,0 +1,36 @@ +using System.IO; + +namespace BurnOutSharp.ProtectionType +{ + public class Sysiphus + { + public static string CheckContents(string file, string fileContent) + { + int position; + if ((position = fileContent.IndexOf("V SUHPISYSDVD")) > -1) + return "Sysiphus DVD " + GetVersion(file, position); + + if ((position = fileContent.IndexOf("V SUHPISYS")) > -1) + return "Sysiphus " + GetVersion(file, position); + + return null; + } + + private static string GetVersion(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(position - 3, SeekOrigin.Begin); + char subVersion = br.ReadChar(); + br.ReadChar(); + char version = br.ReadChar(); + + if (char.IsNumber(version) && char.IsNumber(subVersion)) + return version + "." + subVersion; + else + return ""; + } + } + } +} diff --git a/BurnOutSharp/ProtectionType/TZCopyProtector.cs b/BurnOutSharp/ProtectionType/TZCopyProtector.cs new file mode 100644 index 00000000..043513e4 --- /dev/null +++ b/BurnOutSharp/ProtectionType/TZCopyProtector.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class TZCopyProtector + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("_742893.016", StringComparison.OrdinalIgnoreCase)) > 0) + return "TZCopyProtector"; + } + else + { + 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 new file mode 100644 index 00000000..62c658bd --- /dev/null +++ b/BurnOutSharp/ProtectionType/Tages.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class Tages + { + public static string CheckContents(string file, string fileContent) + { + int position; + if (fileContent.Contains("protected-tages-runtime.exe") || + fileContent.Contains("tagesprotection.com")) + return "TAGES " + Utilities.GetFileVersion(file); + + if ((position = fileContent.IndexOf("" + (char)0xE8 + "u" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0xE8)) > -1 + && fileContent.Substring(--position + 8, 3) == "" + (char)0xFF + (char)0xFF + "h") // TODO: Verify this subtract + return "TAGES " + GetVersion(file, position); + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // 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"; + } + else 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); + } + else 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); + } + else 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); + } + } + else + { + 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; + } + + private static string GetVersion(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(position + 7, SeekOrigin.Begin); + byte bVersion = br.ReadByte(); + switch (bVersion) + { + case 0x1B: + return "5.3-5.4"; + case 0x14: + return "5.5.0"; + case 0x4: + return "5.5.2"; + } + return ""; + } + } + } +} diff --git a/BurnOutSharp/ProtectionType/TheBongle.cs b/BurnOutSharp/ProtectionType/TheBongle.cs new file mode 100644 index 00000000..f31511d1 --- /dev/null +++ b/BurnOutSharp/ProtectionType/TheBongle.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class TheBongle + { + // TODO: Implement - http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm + } +} diff --git a/BurnOutSharp/ProtectionType/TheCopyProtectedCD.cs b/BurnOutSharp/ProtectionType/TheCopyProtectedCD.cs new file mode 100644 index 00000000..70cdf83d --- /dev/null +++ b/BurnOutSharp/ProtectionType/TheCopyProtectedCD.cs @@ -0,0 +1,7 @@ +namespace BurnOutSharp.ProtectionType +{ + public class TheCopyProtectedCD + { + // TODO: Implement - http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm + } +} diff --git a/BurnOutSharp/ProtectionType/ThreePLock.cs b/BurnOutSharp/ProtectionType/ThreePLock.cs new file mode 100644 index 00000000..dd22e49a --- /dev/null +++ b/BurnOutSharp/ProtectionType/ThreePLock.cs @@ -0,0 +1,17 @@ +namespace BurnOutSharp.ProtectionType +{ + public class ThreePLock + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains(".ldr") + || fileContent.Contains(".ldt")) + // || fileContent.Contains("Y" + (char)0xC3 + "U" + (char)0x8B + (char)0xEC + (char)0x83 + (char)0xEC + "0SVW") + { + return "3PLock"; + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/Uplay.cs b/BurnOutSharp/ProtectionType/Uplay.cs new file mode 100644 index 00000000..a85ea8cf --- /dev/null +++ b/BurnOutSharp/ProtectionType/Uplay.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class Uplay + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("UplayInstaller.exe", StringComparison.OrdinalIgnoreCase)) > 0) + return "Uplay"; + } + else + { + 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 new file mode 100644 index 00000000..5513f9f1 --- /dev/null +++ b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class VOBProtectCDDVD + { + public static string CheckContents(string file, string fileContent) + { + 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) + { + string version = GetVersion(file, --position); // TODO: Verify this subtract + if (version.Length > 0) + { + return "VOB ProtectCD/DVD " + version; + } + + version = EVORE.SearchProtectDiscVersion(file); + if (version.Length > 0) + { + if (version.StartsWith("2")) + { + version = "6" + version.Substring(1); + } + return "VOB ProtectCD/DVD " + version; + } + + return "VOB ProtectCD/DVD 5.9-6.0" + GetBuild(file, position); + } + + else if (fileContent.Contains(".vob.pcd")) + { + return "VOB ProtectCD"; + } + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("VOB-PCD.KEY", StringComparison.OrdinalIgnoreCase)) > 0) + return "VOB ProtectCD/DVD"; + } + else + { + if (Path.GetFileName(path).Equals("VOB-PCD.KEY", StringComparison.OrdinalIgnoreCase)) + return "VOB ProtectCD/DVD"; + } + + return null; + } + + private static string GetBuild(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(position - 13, SeekOrigin.Begin); + if (!char.IsNumber(br.ReadChar())) + return ""; //Build info removed + + br.BaseStream.Seek(position - 4, SeekOrigin.Begin); + int build = br.ReadInt16(); + return " (Build " + build + ")"; + } + } + + private static string GetOldVersion(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + char[] version = new char[3]; + br.BaseStream.Seek(position + 16, SeekOrigin.Begin); // Begin reading after "VOB ProtectCD" + version[0] = br.ReadChar(); + br.ReadByte(); + version[1] = br.ReadChar(); + version[2] = br.ReadChar(); + + if (char.IsNumber(version[0]) && char.IsNumber(version[1]) && char.IsNumber(version[2])) + return version[0] + "." + version[1] + version[2]; + + return "old"; + } + } + + private static string GetVersion(string file, int position) + { + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var br = new BinaryReader(fs)) + { + br.BaseStream.Seek(position - 2, SeekOrigin.Begin); + byte version = br.ReadByte(); + if (version == 5) + { + br.BaseStream.Seek(position - 4, SeekOrigin.Begin); + byte subsubVersion = (byte)((br.ReadByte() & 0xF0) >> 4); + byte subVersion = (byte)((br.ReadByte() & 0xF0) >> 4); + return version + "." + subVersion + "." + subsubVersion; + } + else + { + return ""; + } + } + } + } +} diff --git a/BurnOutSharp/ProtectionType/WTMCDProtect.cs b/BurnOutSharp/ProtectionType/WTMCDProtect.cs new file mode 100644 index 00000000..aa586c94 --- /dev/null +++ b/BurnOutSharp/ProtectionType/WTMCDProtect.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class WTMCDProtect + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("WTM76545")) + return "WTM CD Protect"; + + return null; + } + + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Verify if these are OR or AND + if (files.Count(f => Path.GetExtension(f).Trim('.').Equals("IMP", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("imp.dat", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("wtmfiles.dat", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("Viewer.exe", StringComparison.OrdinalIgnoreCase)) > 0) + { + return "WTM CD Protect"; + } + } + else + { + 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 null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/Winlock.cs b/BurnOutSharp/ProtectionType/Winlock.cs new file mode 100644 index 00000000..63a1c960 --- /dev/null +++ b/BurnOutSharp/ProtectionType/Winlock.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class Winlock + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + if (files.Count(f => Path.GetFileName(f).Equals("WinLock.PSX", StringComparison.OrdinalIgnoreCase)) > 0) + return "Winlock"; + } + else + { + 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 new file mode 100644 index 00000000..f89932b6 --- /dev/null +++ b/BurnOutSharp/ProtectionType/XCP.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace BurnOutSharp.ProtectionType +{ + public class XCP + { + public static string CheckPath(string path, IEnumerable files, bool isDirectory) + { + if (isDirectory) + { + // TODO: Verify if these are OR or AND + if (files.Count(f => Path.GetFileName(f).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase)) > 0 + || files.Count(f => Path.GetFileName(f).Equals("go.exe", StringComparison.OrdinalIgnoreCase)) > 0) // Path.Combine("contents", "go.exe") + { + return "XCP"; + } + } + else + { + 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 null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/XtremeProtector.cs b/BurnOutSharp/ProtectionType/XtremeProtector.cs new file mode 100644 index 00000000..03893d1b --- /dev/null +++ b/BurnOutSharp/ProtectionType/XtremeProtector.cs @@ -0,0 +1,13 @@ +namespace BurnOutSharp.ProtectionType +{ + public class XtremeProtector + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("XPROT ")) + return "Xtreme-Protector"; + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/Zzxzz.cs b/BurnOutSharp/ProtectionType/Zzxzz.cs new file mode 100644 index 00000000..feb06dde --- /dev/null +++ b/BurnOutSharp/ProtectionType/Zzxzz.cs @@ -0,0 +1,28 @@ +using System; +using System.IO; + +namespace BurnOutSharp.ProtectionType +{ + public class Zzxzz + { + public static string CheckPath(string path, bool isDirectory) + { + if (isDirectory) + { + 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"; + } + + return null; + } + } +} diff --git a/BurnOutSharp/ProtectionType/dotFuscator.cs b/BurnOutSharp/ProtectionType/dotFuscator.cs new file mode 100644 index 00000000..c8ac53cd --- /dev/null +++ b/BurnOutSharp/ProtectionType/dotFuscator.cs @@ -0,0 +1,13 @@ +namespace BurnOutSharp.ProtectionType +{ + public class dotFuscator + { + public static string CheckContents(string fileContent) + { + if (fileContent.Contains("DotfuscatorAttribute")) + return "dotFuscator"; + + return null; + } + } +} diff --git a/BurnOutSharp/Utilities.cs b/BurnOutSharp/Utilities.cs new file mode 100644 index 00000000..5756171a --- /dev/null +++ b/BurnOutSharp/Utilities.cs @@ -0,0 +1,288 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; + +namespace BurnOutSharp +{ + public static class Utilities + { + /// + /// Get the file version as reported by the filesystem + /// + public static string GetFileVersion(string file) + { + FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(file); + if (fvinfo.FileVersion == null) + return ""; + if (fvinfo.FileVersion != "") + return fvinfo.FileVersion.Replace(", ", "."); + else + return fvinfo.ProductVersion.Replace(", ", "."); + } + + /// + /// Get the filesystem name for the given drive letter + /// + /// + /// http://pinvoke.net/default.aspx/kernel32/GetVolumeInformation.html + /// + public static string GetFileSystemName(char driveLetter) + { + string fsName = null; + + StringBuilder volname = new StringBuilder(261); + StringBuilder fsname = new StringBuilder(261); + + if (GetVolumeInformation($"{driveLetter}:\\", volname, volname.Capacity, out uint sernum, out uint maxlen, out FileSystemFeature flags, fsname, fsname.Capacity)) + { + // Now you know the file system of your drive + // NTFS or FAT16 or UDF for instance + fsName = fsname.ToString(); + } + + return fsName; + } + + #region P/Invoke + + // https://stackoverflow.com/questions/8819188/c-sharp-classes-to-undelete-files/8820157#8820157 + + // Move Method + public const uint FileBegin = 0; + public const uint FileCurrent = 1; + public const uint FileEnd = 2; + + // Handle Constants + public const uint INVALID_HANDLE_VALUE = 0; + public const int IOCTL_STORAGE_GET_DEVICE_NUMBER = 0x2D1080; + + [DllImport("kernel32.dll", SetLastError = true)] + public static extern bool CloseHandle(IntPtr handle); + + [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] + public static extern IntPtr CreateFile( + [MarshalAs(UnmanagedType.LPTStr)] string filename, + [MarshalAs(UnmanagedType.U4)] FileAccess access, + [MarshalAs(UnmanagedType.U4)] FileShare share, + IntPtr securityAttributes, // optional SECURITY_ATTRIBUTES struct or IntPtr.Zero + [MarshalAs(UnmanagedType.U4)] FileMode creationDisposition, + [MarshalAs(UnmanagedType.U4)] FileAttributes flagsAndAttributes, + IntPtr templateFile); + + [DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public extern static bool GetVolumeInformation( + string rootPathName, + StringBuilder volumeNameBuffer, + int volumeNameSize, + out uint volumeSerialNumber, + out uint maximumComponentLength, + out FileSystemFeature fileSystemFlags, + StringBuilder fileSystemNameBuffer, + int nFileSystemNameSize); + + [DllImport("Kernel32.dll", SetLastError = true)] + public extern static bool DeviceIoControl( + IntPtr hDevice, + uint IoControlCode, + IntPtr InMediaRemoval, + uint InBufferSize, + IntPtr OutBuffer, + int OutBufferSize, + out int BytesReturned, + IntPtr Overlapped); + + // Used to read in a file + [DllImport("kernel32.dll")] + public static extern bool ReadFile( + IntPtr hFile, + byte[] lpBuffer, + uint nNumberOfBytesToRead, + ref uint lpNumberOfBytesRead, + IntPtr lpOverlapped); + + [DllImport("kernel32.dll")] + public static extern bool ReadFileEx( + IntPtr hFile, + [Out] byte[] lpBuffer, + uint nNumberOfBytesToRead, + [In] ref NativeOverlapped lpOverlapped, + IOCompletionCallback lpCompletionRoutine); + + // Used to set the offset in file to start reading + [DllImport("kernel32.dll")] + public static extern bool SetFilePointerEx( + IntPtr hFile, + long liDistanceToMove, + ref IntPtr lpNewFilePointer, + uint dwMoveMethod); + + [StructLayout(LayoutKind.Sequential)] + struct STORAGE_DEVICE_NUMBER + { + public int DeviceType; + public int DeviceNumber; + public int PartitionNumber; + } + + public enum MEDIA_TYPE : uint + { + Unknown, + F5_1Pt2_512, + F3_1Pt44_512, + F3_2Pt88_512, + F3_20Pt8_512, + F3_720_512, + F5_360_512, + F5_320_512, + F5_320_1024, + F5_180_512, + F5_160_512, + RemovableMedia, + FixedMedia, + F3_120M_512, + F3_640_512, + F5_640_512, + F5_720_512, + F3_1Pt2_512, + F3_1Pt23_1024, + F5_1Pt23_1024, + F3_128Mb_512, + F3_230Mb_512, + F8_256_128, + F3_200Mb_512, + F3_240M_512, + F3_32M_512 + } + + [StructLayout(LayoutKind.Sequential)] + public struct DISK_GEOMETRY + { + public long Cylinders; + public MEDIA_TYPE MediaType; + public int TracksPerCylinder; + public int SectorsPerTrack; + public int BytesPerSector; + + public long DiskSize + { + get + { + return Cylinders * (long)TracksPerCylinder * (long)SectorsPerTrack * (long)BytesPerSector; + } + } + } + + [Flags] + public enum FileSystemFeature : uint + { + /// + /// The file system preserves the case of file names when it places a name on disk. + /// + CasePreservedNames = 2, + + /// + /// The file system supports case-sensitive file names. + /// + CaseSensitiveSearch = 1, + + /// + /// The specified volume is a direct access (DAX) volume. This flag was introduced in Windows 10, version 1607. + /// + DaxVolume = 0x20000000, + + /// + /// The file system supports file-based compression. + /// + FileCompression = 0x10, + + /// + /// The file system supports named streams. + /// + NamedStreams = 0x40000, + + /// + /// The file system preserves and enforces access control lists (ACL). + /// + PersistentACLS = 8, + + /// + /// The specified volume is read-only. + /// + ReadOnlyVolume = 0x80000, + + /// + /// The volume supports a single sequential write. + /// + SequentialWriteOnce = 0x100000, + + /// + /// The file system supports the Encrypted File System (EFS). + /// + SupportsEncryption = 0x20000, + + /// + /// The specified volume supports extended attributes. An extended attribute is a piece of + /// application-specific metadata that an application can associate with a file and is not part + /// of the file's data. + /// + SupportsExtendedAttributes = 0x00800000, + + /// + /// The specified volume supports hard links. For more information, see Hard Links and Junctions. + /// + SupportsHardLinks = 0x00400000, + + /// + /// The file system supports object identifiers. + /// + SupportsObjectIDs = 0x10000, + + /// + /// The file system supports open by FileID. For more information, see FILE_ID_BOTH_DIR_INFO. + /// + SupportsOpenByFileId = 0x01000000, + + /// + /// The file system supports re-parse points. + /// + SupportsReparsePoints = 0x80, + + /// + /// The file system supports sparse files. + /// + SupportsSparseFiles = 0x40, + + /// + /// The volume supports transactions. + /// + SupportsTransactions = 0x200000, + + /// + /// The specified volume supports update sequence number (USN) journals. For more information, + /// see Change Journal Records. + /// + SupportsUsnJournal = 0x02000000, + + /// + /// The file system supports Unicode in file names as they appear on disk. + /// + UnicodeOnDisk = 4, + + /// + /// The specified volume is a compressed volume, for example, a DoubleSpace volume. + /// + VolumeIsCompressed = 0x8000, + + /// + /// The file system supports disk quotas. + /// + VolumeQuotas = 0x20 + } + + #endregion + } +} diff --git a/Test/Program.cs b/Test/Program.cs index 1c2fade1..96f44b40 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -16,6 +16,8 @@ static void Main(string[] args) } Console.ReadLine(); + + //ProtectionFind.ScanSectors('D', 2048); } private static void Changed(object source, FileProtection value) From 5a2755d7c71bc30c01d3a8e7a301e2b52ed3219b Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 27 Sep 2019 23:57:32 -0700 Subject: [PATCH 02/14] Consistent comments --- BurnOutSharp/ProtectionType/CDProtector.cs | 2 +- BurnOutSharp/ProtectionType/CDX.cs | 2 +- BurnOutSharp/ProtectionType/CodeLock.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BurnOutSharp/ProtectionType/CDProtector.cs b/BurnOutSharp/ProtectionType/CDProtector.cs index b2a0df8b..9247852c 100644 --- a/BurnOutSharp/ProtectionType/CDProtector.cs +++ b/BurnOutSharp/ProtectionType/CDProtector.cs @@ -11,7 +11,7 @@ public static string CheckPath(string path, IEnumerable files, bool isDi { if (isDirectory) { - // TODO: Confirm if OR or AND + // TODO: Verify if these are OR or AND if (files.Count(f => Path.GetFileName(f).Equals("_cdp16.dat", StringComparison.OrdinalIgnoreCase)) > 0 || files.Count(f => Path.GetFileName(f).Equals("_cdp16.dll", StringComparison.OrdinalIgnoreCase)) > 0 || files.Count(f => Path.GetFileName(f).Equals("_cdp32.dat", StringComparison.OrdinalIgnoreCase)) > 0 diff --git a/BurnOutSharp/ProtectionType/CDX.cs b/BurnOutSharp/ProtectionType/CDX.cs index 2f183652..5aebba88 100644 --- a/BurnOutSharp/ProtectionType/CDX.cs +++ b/BurnOutSharp/ProtectionType/CDX.cs @@ -11,7 +11,7 @@ public static string CheckPath(string path, IEnumerable files, bool isDi { if (isDirectory) { - // TODO: Confirm if OR or AND + // TODO: Verify if these are OR or AND if (files.Count(f => Path.GetFileName(f).Equals("CHKCDX16.DLL", StringComparison.OrdinalIgnoreCase)) > 0 || files.Count(f => Path.GetFileName(f).Equals("CHKCDX32.DLL", StringComparison.OrdinalIgnoreCase)) > 0 || files.Count(f => Path.GetFileName(f).Equals("CHKCDXNT.DLL", StringComparison.OrdinalIgnoreCase)) > 0) diff --git a/BurnOutSharp/ProtectionType/CodeLock.cs b/BurnOutSharp/ProtectionType/CodeLock.cs index 1e2fce3f..ad66e48f 100644 --- a/BurnOutSharp/ProtectionType/CodeLock.cs +++ b/BurnOutSharp/ProtectionType/CodeLock.cs @@ -4,7 +4,7 @@ public class CodeLock { public static string CheckContents(string fileContent) { - // TODO: Check if OR or AND + // TODO: Verify if these are OR or AND if (fileContent.Contains("icd1" + (char)0x00) || fileContent.Contains("icd2" + (char)0x00) || fileContent.Contains("CODE-LOCK.OCX")) From 2938033fa6a6317b27160ded72fef2b0f8d24e4b Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 28 Sep 2019 00:01:22 -0700 Subject: [PATCH 03/14] Remove unused class --- BurnOutSharp/BurnOutSharp.csproj | 1 - BurnOutSharp/CaseInsensitiveDictionary.cs | 95 ----------------------- 2 files changed, 96 deletions(-) delete mode 100644 BurnOutSharp/CaseInsensitiveDictionary.cs diff --git a/BurnOutSharp/BurnOutSharp.csproj b/BurnOutSharp/BurnOutSharp.csproj index bce3162c..07b67cda 100644 --- a/BurnOutSharp/BurnOutSharp.csproj +++ b/BurnOutSharp/BurnOutSharp.csproj @@ -53,7 +53,6 @@ - diff --git a/BurnOutSharp/CaseInsensitiveDictionary.cs b/BurnOutSharp/CaseInsensitiveDictionary.cs deleted file mode 100644 index 0a577593..00000000 --- a/BurnOutSharp/CaseInsensitiveDictionary.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; - -namespace BurnOutSharp -{ - internal class CaseInsensitiveDictionary : IDictionary - { - private Dictionary _dict = new Dictionary(); - - public TValue this[string key] - { - get - { - key = key.ToLower(); - if (_dict.ContainsKey(key)) - return _dict[key]; - throw new ArgumentException("Key could not be found in the dictionary"); - } - set - { - key = key.ToLower(); - _dict[key] = value; - } - } - - public ICollection Keys => _dict.Keys; - - public ICollection Values => _dict.Values; - - public int Count => _dict.Count; - - public bool IsReadOnly => false; - - public void Add(string key, TValue value) - { - key = key.ToLower(); - _dict[key] = value; - } - - public void Add(KeyValuePair item) - { - string key = item.Key.ToLower(); - _dict[key] = item.Value; ; - } - - public void Clear() - { - _dict.Clear(); - } - - public bool Contains(KeyValuePair item) - { - KeyValuePair temp = new KeyValuePair(item.Key.ToLower(), item.Value); - return _dict.Contains(temp); - } - - public bool ContainsKey(string key) - { - return _dict.ContainsKey(key.ToLower()); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - throw new NotImplementedException(); - } - - public IEnumerator> GetEnumerator() - { - return _dict.GetEnumerator(); - } - - public bool Remove(string key) - { - return _dict.Remove(key.ToLower()); - } - - public bool Remove(KeyValuePair item) - { - throw new NotImplementedException(); - } - - public bool TryGetValue(string key, out TValue value) - { - key = key.ToLower(); - return _dict.TryGetValue(key, out value); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return _dict.GetEnumerator(); - } - } -} From c109aceb24daeffdf2eabf871f6d12b7086963e1 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 28 Sep 2019 00:05:44 -0700 Subject: [PATCH 04/14] Update nuspec --- BurnOutSharp/BurnOutSharp.nuspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BurnOutSharp/BurnOutSharp.nuspec b/BurnOutSharp/BurnOutSharp.nuspec index 3efb71c8..702b389c 100644 --- a/BurnOutSharp/BurnOutSharp.nuspec +++ b/BurnOutSharp/BurnOutSharp.nuspec @@ -2,7 +2,7 @@ BurnOutSharp - 1.03.7.1 + 1.03.8.0 BurnOutSharp Matt Nadareski, Gernot Knippen Matt Nadareski, Gernot Knippen @@ -10,7 +10,7 @@ https://github.com/mnadareski/BurnOutSharp false Port of BurnOut to C#, with additions - Copyright (c)2005-2010 Gernot Knippen, Copyright (c)2018 Matt Nadareski + Copyright (c)2005-2010 Gernot Knippen, Copyright (c)2018-2019 Matt Nadareski protection scan burnout From ca0d6954704f741a11594e183dfd8719295758b9 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 28 Sep 2019 01:51:06 -0700 Subject: [PATCH 05/14] 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 @@ private static string ScanPath(string path, bool isDirectory) 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 class ActiveMARK 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 @@ public static string CheckContents(string file, string fileContent) 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 @@ public static string CheckContents(string file, string fileContent) 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 @@ public static string CheckContents(string file, string fileContent) 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 @@ public class PSXAntiModchip { 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 @@ public static string CheckPath(string path, IEnumerable files, bool isDi 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 @@ public static string CheckContents(string file, string fileContent) { 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 @@ public static string CheckContents(string file, string fileContent) 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 @@ public static string CheckContents(string file, string fileContent) 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 @@ public static string CheckContents(string file, string fileContent) 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 @@ public static string CheckContents(string file, string fileContent) 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 @@ public static string CheckContents(string file, string fileContent) } } - 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 @@ public static string CheckContents(string file, string fileContent) 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 @@ public static string CheckPath(string path, IEnumerable files, bool isDi { 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 @@ public static string CheckContents(string file, string fileContent) { 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 @@ public static string CheckContents(string file, string fileContent) 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; } From 5ffaedc024fe49740182c0e10f7c8eb2d49306e0 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 29 Sep 2019 11:57:46 -0700 Subject: [PATCH 06/14] Keep path scanning on individual files, for now --- BurnOutSharp/ProtectionFind.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/BurnOutSharp/ProtectionFind.cs b/BurnOutSharp/ProtectionFind.cs index 34e8fe43..b9bb9375 100644 --- a/BurnOutSharp/ProtectionFind.cs +++ b/BurnOutSharp/ProtectionFind.cs @@ -46,10 +46,10 @@ public static Dictionary Scan(string path, IProgress Scan(string path, IProgress Date: Sun, 29 Sep 2019 12:08:31 -0700 Subject: [PATCH 07/14] Fix test program output --- BurnOutSharp/ProtectionFind.cs | 2 +- Test/Program.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BurnOutSharp/ProtectionFind.cs b/BurnOutSharp/ProtectionFind.cs index b9bb9375..64b9310f 100644 --- a/BurnOutSharp/ProtectionFind.cs +++ b/BurnOutSharp/ProtectionFind.cs @@ -97,7 +97,7 @@ public static Dictionary Scan(string path, IProgress Date: Mon, 30 Sep 2019 11:08:44 -0700 Subject: [PATCH 08/14] Filename is no longer expected --- BurnOutSharp.sln | 9 +- BurnOutSharp/EVORE.cs | 21 + BurnOutSharp/ProtectionFind.cs | 521 +++++++++++------- BurnOutSharp/ProtectionType/CDCops.cs | 3 + BurnOutSharp/ProtectionType/DVDCops.cs | 3 + BurnOutSharp/ProtectionType/InnoSetup.cs | 3 + BurnOutSharp/ProtectionType/JoWooDXProt.cs | 3 + BurnOutSharp/ProtectionType/LaserLock.cs | 2 +- BurnOutSharp/ProtectionType/ProtectDisc.cs | 6 + BurnOutSharp/ProtectionType/SafeDisc.cs | 12 + BurnOutSharp/ProtectionType/SecuROM.cs | 9 + BurnOutSharp/ProtectionType/SolidShield.cs | 13 +- BurnOutSharp/ProtectionType/Sysiphus.cs | 3 + BurnOutSharp/ProtectionType/Tages.cs | 3 + .../ProtectionType/VOBProtectCDDVD.cs | 9 + BurnOutSharp/Utilities.cs | 3 + 16 files changed, 426 insertions(+), 197 deletions(-) diff --git a/BurnOutSharp.sln b/BurnOutSharp.sln index e7ba4788..c82b3e74 100644 --- a/BurnOutSharp.sln +++ b/BurnOutSharp.sln @@ -1,12 +1,17 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2026 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29306.81 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BurnOutSharp", "BurnOutSharp\BurnOutSharp.csproj", "{1DA4212E-6071-4951-B45D-BB74A7838246}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{88735BA2-778D-4192-8EB2-FFF6843719E2}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{68D10531-99CB-40B1-8912-73FA286C9433}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/BurnOutSharp/EVORE.cs b/BurnOutSharp/EVORE.cs index 140012dc..2d2a4723 100644 --- a/BurnOutSharp/EVORE.cs +++ b/BurnOutSharp/EVORE.cs @@ -37,6 +37,9 @@ private struct Section private static Process StartSafe(string file) { + if (file == null) + return string.Empty; + Process startingprocess = new Process(); startingprocess.StartInfo.FileName = file; startingprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; @@ -56,6 +59,9 @@ private static Process StartSafe(string file) private static string MakeTempFile(string file, string sExtension = ".exe") { + if (file == null) + return string.Empty; + FileInfo filei = new FileInfo(file); try { @@ -69,6 +75,9 @@ private static string MakeTempFile(string file, string sExtension = ".exe") private static bool IsEXE(string file) { + if (file == null) + return false; + BinaryReader breader = new BinaryReader(File.OpenRead(file)); breader.ReadBytes(60); int PEHeaderOffset = breader.ReadInt32(); @@ -85,6 +94,9 @@ private static bool IsEXE(string file) private static string[] CopyDependentDlls(string exefile) { + if (exefile == null) + return null; + FileInfo fiExe = new FileInfo(exefile); Section[] sections = ReadSections(exefile); BinaryReader breader = new BinaryReader(File.OpenRead(exefile), Encoding.Default); @@ -141,6 +153,9 @@ private static string[] CopyDependentDlls(string exefile) private static Section[] ReadSections(string exefile) { + if (exefile == null) + return null; + BinaryReader breader = new BinaryReader(File.OpenRead(exefile)); breader.ReadBytes(60); uint PEHeaderOffset = breader.ReadUInt32(); @@ -184,6 +199,9 @@ private static uint RVA2Offset(uint RVA, Section[] sections) public static string SearchProtectDiscVersion(string file) { + if (file == null) + return string.Empty; + Process exe = new Process(); Process[] processes = new Process[0]; string version = ""; @@ -339,6 +357,9 @@ public static string SearchProtectDiscVersion(string file) public static string SearchSafeDiscVersion(string file) { + if (file == null) + return string.Empty; + Process exe = new Process(); string version = ""; DateTime timestart; diff --git a/BurnOutSharp/ProtectionFind.cs b/BurnOutSharp/ProtectionFind.cs index 64b9310f..e4910eaa 100644 --- a/BurnOutSharp/ProtectionFind.cs +++ b/BurnOutSharp/ProtectionFind.cs @@ -116,7 +116,7 @@ public static Dictionary Scan(string path, IProgress /// /// - private static string ScanPath(string path, bool isDirectory) + public static string ScanPath(string path, bool isDirectory) { List protections = new List(); string protection; @@ -353,7 +353,8 @@ private static string ScanPath(string path, bool isDirectory) /// /// Scan an individual file for copy protection /// - private static string ScanInFile(string file) + /// File path for scanning + public static string ScanInFile(string file) { // Get the extension for certain checks string extension = Path.GetExtension(file).ToLower().TrimStart('.'); @@ -383,196 +384,14 @@ private static string ScanInFile(string file) { try { - // Load the current file and check for specialty strings first - StreamReader sr = new StreamReader(file, Encoding.Default); - string protection; - string fileContent = sr.ReadToEnd(); - sr.Close(); + // Load the current file content + string fileContent = null; + using (StreamReader sr = new StreamReader(file)) + { + fileContent = sr.ReadToEnd(); + } - // 3PLock - protection = ThreePLock.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // ActiveMARK - protection = ActiveMARK.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // Alpha-ROM - protection = AlphaROM.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // Armadillo - protection = Armadillo.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // CD-Cops - protection = CDCops.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // CD-Lock - protection = CDLock.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // CDSHiELD SE - protection = CDSHiELDSE.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // CD Check - protection = CDCheck.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // Cenega ProtectDVD - protection = CengaProtectDVD.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // Code Lock - protection = CodeLock.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // CopyKiller - protection = CopyKiller.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // Cucko (EA Custom) - protection = Cucko.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // dotFuscator - protection = dotFuscator.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // DVD-Cops - protection = DVDCops.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // EA CdKey Registration Module - protection = EACdKey.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // EXE Stealth - protection = EXEStealth.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // Games for Windows - Live - protection = GFWL.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // Impulse Reactor - protection = ImpulseReactor.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // Inno Setup - protection = InnoSetup.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // JoWooD X-Prot - protection = JoWooDXProt.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // Key-Lock (Dongle) - protection = KeyLock.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // LaserLock - protection = LaserLock.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // PE Compact - protection = PECompact.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // ProtectDisc - protection = ProtectDisc.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // Ring PROTECH - protection = RingPROTECH.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // SafeDisc / SafeCast - protection = SafeDisc.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // SafeLock - protection = SafeLock.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // SecuROM - protection = SecuROM.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // SmartE - protection = SmartE.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // SolidShield - protection = SolidShield.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // StarForce - protection = StarForce.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // SVK Protector - protection = SVKProtector.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // Sysiphus / Sysiphus DVD - protection = Sysiphus.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // TAGES - protection = Tages.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // VOB ProtectCD/DVD - protection = VOBProtectCDDVD.CheckContents(file, fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // WTM CD Protect - protection = WTMCDProtect.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); - - // Xtreme-Protector - protection = XtremeProtector.CheckContents(fileContent); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); + protections.AddRange(ScanFileContent(file, fileContent)); } catch { } } @@ -602,7 +421,6 @@ private static string ScanInFile(string file) { // We don't care what the error was } - // No-op } #endregion @@ -704,6 +522,325 @@ private static string ScanInFile(string file) return string.Join(", ", protections); } + /// + /// Scan an individual stream for copy protection + /// + /// Generic stream to scan + /// File path to be used for name checks (optional) + public static string ScanInFile(Stream stream, string file = null) + { + // Assume the first part of the stream is the start of a file + string magic = ""; + try + { + using (BinaryReader br = new BinaryReader(stream, Encoding.Default, true)) + { + magic = new string(br.ReadChars(8)); + } + } + catch + { + // We don't care what the issue was, we can't open the file + return null; + } + + // If we can, seek to the beginning of the stream + if (stream.CanSeek) + stream.Seek(0, SeekOrigin.Begin); + + // Files can be protected in multiple ways + List protections = new List(); + + #region Executable Content Checks + + // Windows Executable and DLL + if (magic.StartsWith("MZ")) + { + try + { + // Load the current file content + string fileContent = null; + using (StreamReader sr = new StreamReader(stream)) + { + fileContent = sr.ReadToEnd(); + } + + protections.AddRange(ScanFileContent(file, fileContent)); + } + catch { } + } + + #endregion + + #region Textfile Content Checks + + if (magic.StartsWith("{\rtf") // Rich Text File + || magic.StartsWith("" + (char)0xd0 + (char)0xcf + (char)0x11 + (char)0xe0 + (char)0xa1 + (char)0xb1 + (char)0x1a + (char)0xe1)) // Microsoft Office File (old) + { + try + { + // Load the current file content + string fileContent = null; + using (StreamReader sr = new StreamReader(stream)) + { + fileContent = sr.ReadToEnd(); + } + + // CD-Key + if (fileContent.Contains("a valid serial number is required") + || fileContent.Contains("serial number is located")) + { + protections.Add("CD-Key / Serial"); + } + } + catch + { + // We don't care what the error was + } + } + + #endregion + + #region Archive Content Checks + + // 7-zip + if (magic.StartsWith("7z" + (char)0xbc + (char)0xaf + (char)0x27 + (char)0x1c)) + { + // No-op + } + + // InstallShield CAB + else if (magic.StartsWith("ISc")) + { + // TODO: Update UnshieldSharp to include generic stream support + } + + // Microsoft CAB + else if (magic.StartsWith("MSCF")) + { + // TODO: See if LibMSPackN can use generic streams + } + + // PKZIP + else if (magic.StartsWith("PK" + (char)03 + (char)04) + || magic.StartsWith("PK" + (char)05 + (char)06) + || magic.StartsWith("PK" + (char)07 + (char)08)) + { + // No-op + } + + // RAR + else if (magic.StartsWith("Rar!")) + { + // No-op + } + + #endregion + + // Return blank if nothing found, or comma-separated list of protections + if (protections.Count() == 0) + return string.Empty; + else + return string.Join(", ", protections); + } + + /// + /// Scan the contents of a file for protection + /// + private static List ScanFileContent(string file, string fileContent) + { + // Files can be protected in multiple ways + List protections = new List(); + string protection; + + // 3PLock + protection = ThreePLock.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // ActiveMARK + protection = ActiveMARK.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Alpha-ROM + protection = AlphaROM.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Armadillo + protection = Armadillo.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CD-Cops + protection = CDCops.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CD-Lock + protection = CDLock.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CDSHiELD SE + protection = CDSHiELDSE.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CD Check + protection = CDCheck.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Cenega ProtectDVD + protection = CengaProtectDVD.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Code Lock + protection = CodeLock.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // CopyKiller + protection = CopyKiller.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Cucko (EA Custom) + protection = Cucko.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // dotFuscator + protection = dotFuscator.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // DVD-Cops + protection = DVDCops.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // EA CdKey Registration Module + protection = EACdKey.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // EXE Stealth + protection = EXEStealth.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Games for Windows - Live + protection = GFWL.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Impulse Reactor + protection = ImpulseReactor.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Inno Setup + protection = InnoSetup.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // JoWooD X-Prot + protection = JoWooDXProt.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Key-Lock (Dongle) + protection = KeyLock.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // LaserLock + protection = LaserLock.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // PE Compact + protection = PECompact.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // ProtectDisc + protection = ProtectDisc.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Ring PROTECH + protection = RingPROTECH.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SafeDisc / SafeCast + protection = SafeDisc.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SafeLock + protection = SafeLock.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SecuROM + protection = SecuROM.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SmartE + protection = SmartE.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SolidShield + protection = SolidShield.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // StarForce + protection = StarForce.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // SVK Protector + protection = SVKProtector.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Sysiphus / Sysiphus DVD + protection = Sysiphus.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // TAGES + protection = Tages.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // VOB ProtectCD/DVD + protection = VOBProtectCDDVD.CheckContents(file, fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // WTM CD Protect + protection = WTMCDProtect.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + // Xtreme-Protector + protection = XtremeProtector.CheckContents(fileContent); + if (!string.IsNullOrWhiteSpace(protection)) + protections.Add(protection); + + return protections; + } + /// /// Scan a disc sector by sector for protection /// diff --git a/BurnOutSharp/ProtectionType/CDCops.cs b/BurnOutSharp/ProtectionType/CDCops.cs index d9d7c12e..4d169ebd 100644 --- a/BurnOutSharp/ProtectionType/CDCops.cs +++ b/BurnOutSharp/ProtectionType/CDCops.cs @@ -49,6 +49,9 @@ public static string CheckPath(string path, IEnumerable files, bool isDi private static string GetVersion(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { diff --git a/BurnOutSharp/ProtectionType/DVDCops.cs b/BurnOutSharp/ProtectionType/DVDCops.cs index ac028ed1..8c598d9a 100644 --- a/BurnOutSharp/ProtectionType/DVDCops.cs +++ b/BurnOutSharp/ProtectionType/DVDCops.cs @@ -15,6 +15,9 @@ public static string CheckContents(string file, string fileContent) private static string GetVersion(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { diff --git a/BurnOutSharp/ProtectionType/InnoSetup.cs b/BurnOutSharp/ProtectionType/InnoSetup.cs index 07d1e96c..fcff8855 100644 --- a/BurnOutSharp/ProtectionType/InnoSetup.cs +++ b/BurnOutSharp/ProtectionType/InnoSetup.cs @@ -17,6 +17,9 @@ public static string CheckContents(string file, string fileContent) private static string GetVersion(string file) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { diff --git a/BurnOutSharp/ProtectionType/JoWooDXProt.cs b/BurnOutSharp/ProtectionType/JoWooDXProt.cs index 5b820bc9..68ece9ce 100644 --- a/BurnOutSharp/ProtectionType/JoWooDXProt.cs +++ b/BurnOutSharp/ProtectionType/JoWooDXProt.cs @@ -27,6 +27,9 @@ public static string CheckContents(string file, string fileContent) private static string GetVersion(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { diff --git a/BurnOutSharp/ProtectionType/LaserLock.cs b/BurnOutSharp/ProtectionType/LaserLock.cs index bec29a9c..c6a02fac 100644 --- a/BurnOutSharp/ProtectionType/LaserLock.cs +++ b/BurnOutSharp/ProtectionType/LaserLock.cs @@ -28,7 +28,7 @@ public static string CheckContents(string file, string fileContent) return "LaserLock " + GetVersion(fileContent, --position) + " " + GetBuild(fileContent, false); } - if (Path.GetFileName(file) == "NOMOUSE.SP") + if (file != null && Path.GetFileName(file) == "NOMOUSE.SP") return "LaserLock " + GetVersion16Bit(file); if (fileContent.Contains(":\\LASERLOK\\LASERLOK.IN" + (char)0x00 + "C:\\NOMOUSE.SP")) diff --git a/BurnOutSharp/ProtectionType/ProtectDisc.cs b/BurnOutSharp/ProtectionType/ProtectDisc.cs index f2633ee3..9461e78c 100644 --- a/BurnOutSharp/ProtectionType/ProtectDisc.cs +++ b/BurnOutSharp/ProtectionType/ProtectDisc.cs @@ -41,6 +41,9 @@ public static string CheckContents(string file, string fileContent) private static string GetVersionBuild6till8(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { @@ -89,6 +92,9 @@ private static string GetVersionBuild6till8(string file, int position) private static string GetVersionBuild76till10(string file, int position, out int irefBuild) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { diff --git a/BurnOutSharp/ProtectionType/SafeDisc.cs b/BurnOutSharp/ProtectionType/SafeDisc.cs index 2331b8d5..674d385a 100644 --- a/BurnOutSharp/ProtectionType/SafeDisc.cs +++ b/BurnOutSharp/ProtectionType/SafeDisc.cs @@ -97,6 +97,9 @@ public static string CheckPath(string path, IEnumerable files, bool isDi private static string GetDPlayerXVersion(string file) { + if (file == null) + return string.Empty; + FileInfo fi = new FileInfo(file); if (fi.Length == 81408) return "SafeDisc 1.0x"; @@ -122,6 +125,9 @@ private static string GetDPlayerXVersion(string file) private static string GetDrvmgtVersion(string file) { + if (file == null) + return string.Empty; + FileInfo fi = new FileInfo(file); if (fi.Length == 34816) return "SafeDisc 1.0x"; @@ -147,6 +153,9 @@ private static string GetDrvmgtVersion(string file) private static string GetSecdrvVersion(string file) { + if (file == null) + return string.Empty; + FileInfo fi = new FileInfo(file); if (fi.Length == 20128) return "SafeDisc 2.10"; @@ -178,6 +187,9 @@ private static string GetSecdrvVersion(string file) private static string GetVersion(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { diff --git a/BurnOutSharp/ProtectionType/SecuROM.cs b/BurnOutSharp/ProtectionType/SecuROM.cs index 327e17eb..f2cc994b 100644 --- a/BurnOutSharp/ProtectionType/SecuROM.cs +++ b/BurnOutSharp/ProtectionType/SecuROM.cs @@ -80,6 +80,9 @@ public static string CheckPath(string path, IEnumerable files, bool isDi private static string GetV4Version(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { @@ -103,6 +106,9 @@ private static string GetV4Version(string file, int position) private static string GetV5Version(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { @@ -129,6 +135,9 @@ private static string GetV5Version(string file, int position) private static string GetV7Version(string file) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { diff --git a/BurnOutSharp/ProtectionType/SolidShield.cs b/BurnOutSharp/ProtectionType/SolidShield.cs index cb9bb338..3548b90c 100644 --- a/BurnOutSharp/ProtectionType/SolidShield.cs +++ b/BurnOutSharp/ProtectionType/SolidShield.cs @@ -27,7 +27,10 @@ public static string CheckContents(string file, string fileContent) + "a" + (char)0x00 + "t" + (char)0x00 + "i" + (char)0x00 + "o" + (char)0x00 + "n" + (char)0x00 + " " + (char)0x00 + "L" + (char)0x00 + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y")) { - string companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower(); + string companyName = string.Empty; + if (file != null) + companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower(); + if (companyName.Contains("solidshield") || companyName.Contains("tages")) return "SolidShield Core.dll " + Utilities.GetFileVersion(file); } @@ -47,7 +50,10 @@ public static string CheckContents(string file, string fileContent) + "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")) { - string companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower(); + string companyName = string.Empty; + if (file != null) + companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower(); + if (companyName.Contains("solidshield") || companyName.Contains("tages")) return "SolidShield Activation Manager Module " + Utilities.GetFileVersion(file); } @@ -125,6 +131,9 @@ public static string CheckPath(string path, IEnumerable files, bool isDi private static string GetVersion(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { diff --git a/BurnOutSharp/ProtectionType/Sysiphus.cs b/BurnOutSharp/ProtectionType/Sysiphus.cs index 2fc5ad54..370c91d9 100644 --- a/BurnOutSharp/ProtectionType/Sysiphus.cs +++ b/BurnOutSharp/ProtectionType/Sysiphus.cs @@ -18,6 +18,9 @@ public static string CheckContents(string file, string fileContent) private static string GetVersion(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { diff --git a/BurnOutSharp/ProtectionType/Tages.cs b/BurnOutSharp/ProtectionType/Tages.cs index 06574356..e708630d 100644 --- a/BurnOutSharp/ProtectionType/Tages.cs +++ b/BurnOutSharp/ProtectionType/Tages.cs @@ -80,6 +80,9 @@ public static string CheckPath(string path, IEnumerable files, bool isDi private static string GetVersion(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { diff --git a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs index b15522fb..f4fd2e4c 100644 --- a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs +++ b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs @@ -58,6 +58,9 @@ public static string CheckPath(string path, IEnumerable files, bool isDi private static string GetBuild(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { @@ -73,6 +76,9 @@ private static string GetBuild(string file, int position) private static string GetOldVersion(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { @@ -92,6 +98,9 @@ private static string GetOldVersion(string file, int position) private static string GetVersion(string file, int position) { + if (file == null) + return string.Empty; + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var br = new BinaryReader(fs)) { diff --git a/BurnOutSharp/Utilities.cs b/BurnOutSharp/Utilities.cs index 5756171a..341ed0ba 100644 --- a/BurnOutSharp/Utilities.cs +++ b/BurnOutSharp/Utilities.cs @@ -14,6 +14,9 @@ public static class Utilities /// public static string GetFileVersion(string file) { + if (file == null) + return string.Empty; + FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(file); if (fvinfo.FileVersion == null) return ""; From 392f9dae0ca12f221c048716cadecd6484d31dd5 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 30 Sep 2019 11:29:38 -0700 Subject: [PATCH 09/14] Fix build --- BurnOutSharp/EVORE.cs | 2 +- BurnOutSharp/ProtectionType/ProtectDisc.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/BurnOutSharp/EVORE.cs b/BurnOutSharp/EVORE.cs index 2d2a4723..44515653 100644 --- a/BurnOutSharp/EVORE.cs +++ b/BurnOutSharp/EVORE.cs @@ -38,7 +38,7 @@ private struct Section private static Process StartSafe(string file) { if (file == null) - return string.Empty; + return null; Process startingprocess = new Process(); startingprocess.StartInfo.FileName = file; diff --git a/BurnOutSharp/ProtectionType/ProtectDisc.cs b/BurnOutSharp/ProtectionType/ProtectDisc.cs index 9461e78c..e27528c1 100644 --- a/BurnOutSharp/ProtectionType/ProtectDisc.cs +++ b/BurnOutSharp/ProtectionType/ProtectDisc.cs @@ -92,6 +92,7 @@ private static string GetVersionBuild6till8(string file, int position) private static string GetVersionBuild76till10(string file, int position, out int irefBuild) { + irefBuild = 0; if (file == null) return string.Empty; From cfcb608990c98fe2f15ea77cf9ee829e6f680a9e Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 30 Sep 2019 11:46:53 -0700 Subject: [PATCH 10/14] Update all to 4.7.2 --- BurnOutSharp/BurnOutSharp.csproj | 3 ++- Test/App.config | 6 +++--- Test/Test.csproj | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/BurnOutSharp/BurnOutSharp.csproj b/BurnOutSharp/BurnOutSharp.csproj index 07b67cda..ecc7c826 100644 --- a/BurnOutSharp/BurnOutSharp.csproj +++ b/BurnOutSharp/BurnOutSharp.csproj @@ -9,8 +9,9 @@ Properties BurnOutSharp BurnOutSharp - v4.6.1 + v4.7.2 512 + true diff --git a/Test/App.config b/Test/App.config index 731f6de6..ecdcf8a5 100644 --- a/Test/App.config +++ b/Test/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/Test/Test.csproj b/Test/Test.csproj index 4500f522..9e95b0ed 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -8,9 +8,10 @@ Exe Test Test - v4.6.1 + v4.7.2 512 true + AnyCPU From 44922a1f6bea13ef1758868c0340ada7115664c0 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 30 Sep 2019 12:09:03 -0700 Subject: [PATCH 11/14] Fix encoding issue, add note --- BurnOutSharp/ProtectionFind.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BurnOutSharp/ProtectionFind.cs b/BurnOutSharp/ProtectionFind.cs index e4910eaa..a23eee4a 100644 --- a/BurnOutSharp/ProtectionFind.cs +++ b/BurnOutSharp/ProtectionFind.cs @@ -386,7 +386,7 @@ public static string ScanInFile(string file) { // Load the current file content string fileContent = null; - using (StreamReader sr = new StreamReader(file)) + using (StreamReader sr = new StreamReader(file, Encoding.Default)) { fileContent = sr.ReadToEnd(); } @@ -560,7 +560,7 @@ public static string ScanInFile(Stream stream, string file = null) { // Load the current file content string fileContent = null; - using (StreamReader sr = new StreamReader(stream)) + using (StreamReader sr = new StreamReader(stream, Encoding.Default)) { fileContent = sr.ReadToEnd(); } @@ -647,6 +647,7 @@ public static string ScanInFile(Stream stream, string file = null) /// /// Scan the contents of a file for protection /// + /// TODO: This needs to work on a byte array of file content instead of string private static List ScanFileContent(string file, string fileContent) { // Files can be protected in multiple ways From b8bbc0b333624498dfc136bdb8d7d687618c7789 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 30 Sep 2019 12:10:32 -0700 Subject: [PATCH 12/14] Update packages --- BurnOutSharp/BurnOutSharp.csproj | 8 ++++---- BurnOutSharp/packages.config | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/BurnOutSharp/BurnOutSharp.csproj b/BurnOutSharp/BurnOutSharp.csproj index ecc7c826..a5dfb468 100644 --- a/BurnOutSharp/BurnOutSharp.csproj +++ b/BurnOutSharp/BurnOutSharp.csproj @@ -31,11 +31,11 @@ 4 - - ..\packages\LessIO.0.5.0\lib\net40\LessIO.dll + + ..\packages\LessIO.0.6.16\lib\net40\LessIO.dll - - ..\packages\libmspack4n.0.8.0\lib\net40\libmspackn.dll + + ..\packages\libmspack4n.0.9.10\lib\net40\libmspackn.dll diff --git a/BurnOutSharp/packages.config b/BurnOutSharp/packages.config index 3da4fadb..ad7349c7 100644 --- a/BurnOutSharp/packages.config +++ b/BurnOutSharp/packages.config @@ -1,7 +1,7 @@  - - + + \ No newline at end of file From 9422ba01e7545a2a8e2d3be8578e6804fb28cd50 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 30 Sep 2019 12:17:15 -0700 Subject: [PATCH 13/14] Remove backups --- BurnOutSharp/BurnOutSharp.csproj | 27 ++++++++++++++------------- BurnOutSharp/packages.config | 7 ------- 2 files changed, 14 insertions(+), 20 deletions(-) delete mode 100644 BurnOutSharp/packages.config diff --git a/BurnOutSharp/BurnOutSharp.csproj b/BurnOutSharp/BurnOutSharp.csproj index a5dfb468..c5077bbb 100644 --- a/BurnOutSharp/BurnOutSharp.csproj +++ b/BurnOutSharp/BurnOutSharp.csproj @@ -31,12 +31,6 @@ 4 - - ..\packages\LessIO.0.6.16\lib\net40\LessIO.dll - - - ..\packages\libmspack4n.0.9.10\lib\net40\libmspackn.dll - @@ -46,12 +40,6 @@ - - ..\packages\UnshieldSharp.1.4.2.2\lib\net461\UnshieldSharp.dll - - - ..\packages\zlib.net.1.0.4.0\lib\zlib.net.dll - @@ -140,7 +128,20 @@ - + + + + 0.6.16 + + + 0.9.10 + + + 1.4.2.2 + + + 1.0.4 + \ No newline at end of file diff --git a/BurnOutSharp/packages.config b/BurnOutSharp/packages.config deleted file mode 100644 index ad7349c7..00000000 --- a/BurnOutSharp/packages.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file From c7a9485bf3039d51440c21b933f17bc48565c204 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 30 Sep 2019 20:08:12 -0700 Subject: [PATCH 14/14] Update all --- BurnOutSharp/BurnOutSharp.csproj | 138 ++----------------------------- BurnOutSharp/BurnOutSharp.nuspec | 10 ++- 2 files changed, 16 insertions(+), 132 deletions(-) diff --git a/BurnOutSharp/BurnOutSharp.csproj b/BurnOutSharp/BurnOutSharp.csproj index c5077bbb..ebcbb478 100644 --- a/BurnOutSharp/BurnOutSharp.csproj +++ b/BurnOutSharp/BurnOutSharp.csproj @@ -1,134 +1,14 @@ - - - + + - Debug - AnyCPU - {1DA4212E-6071-4951-B45D-BB74A7838246} - Library - Properties - BurnOutSharp - BurnOutSharp - v4.7.2 - 512 - + net462;net472;netcoreapp3.0 + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + 0.6.16 @@ -137,11 +17,11 @@ 0.9.10 - 1.4.2.2 + 1.4.2.3 1.0.4 - - \ No newline at end of file + + diff --git a/BurnOutSharp/BurnOutSharp.nuspec b/BurnOutSharp/BurnOutSharp.nuspec index 702b389c..6403a26a 100644 --- a/BurnOutSharp/BurnOutSharp.nuspec +++ b/BurnOutSharp/BurnOutSharp.nuspec @@ -15,11 +15,15 @@ - + - - + + + + + + \ No newline at end of file