From ffbb01c25cb6efe43161899b6cf8cb2152a2bbcd Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 7 Mar 2023 11:31:55 -0500 Subject: [PATCH] Migrate CDS path checks --- .../ProtectionType/CactusDataShield.cs | 96 +------------------ .../Macrovision.CactusDataShield.cs | 89 +++++++++++++++++ BurnOutSharp/ProtectionType/Macrovision.cs | 14 ++- 3 files changed, 103 insertions(+), 96 deletions(-) diff --git a/BurnOutSharp/ProtectionType/CactusDataShield.cs b/BurnOutSharp/ProtectionType/CactusDataShield.cs index 8d1e5941..1d9b327a 100644 --- a/BurnOutSharp/ProtectionType/CactusDataShield.cs +++ b/BurnOutSharp/ProtectionType/CactusDataShield.cs @@ -1,17 +1,11 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.IO; +using System.Collections.Generic; using System.Linq; -using System.Text; using BurnOutSharp.Interfaces; using BurnOutSharp.Matching; -using BurnOutSharp.Wrappers; namespace BurnOutSharp.ProtectionType { - - public class CactusDataShield : IContentCheck, IPathCheck + public class CactusDataShield : IContentCheck { /// public string CheckContents(string file, byte[] fileContent, bool includeDebug) @@ -35,91 +29,5 @@ namespace BurnOutSharp.ProtectionType return null; } - - /// - public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) - { - // TODO: Verify if these are OR or AND - var matchers = new List - { - // Found in "Volumia!" by Puur (Barcode 7 43218 63282 2) (Discogs Release Code [r795427]). - // Modified version of the PlayJ Music Player specificaly for CDS, as indicated by the About page present when running the executable. - // The file "DATA16.BML" is also present on this disc but the name is too generic to check for. - new PathMatchSet(new PathMatch("CACTUSPJ.exe", useEndsWith: true), "PlayJ Music Player (Cactus Data Shield 200)"), - - // Found in "Volumia!" by Puur (Barcode 7 43218 63282 2) (Discogs Release Code [r795427]). - // In "Volumina! - Puur" (7 43218 63282 2), this file is composed of multiple PLJ files combined together. - // In later versions, this file is a padded dummy file. ("Ich Habe Einen Traum" by Uwe Busse (Barcode 9 002723 251203)). - new PathMatchSet(new PathMatch("YUCCA.CDS", useEndsWith: true), "Cactus Data Shield 200"), - - // TODO: Find samples of the following: - new PathMatchSet(new PathMatch("CDSPlayer.app", useEndsWith: true), GetVersion, "Cactus Data Shield"), - new PathMatchSet(new PathMatch("wmmp.exe", useEndsWith: true), GetVersion, "Cactus Data Shield"), - - // The file "00000001.TMP" (with a filesize of 2,048 bytes) can be found in CDS-300, as well as SafeDisc. - // Due to this file being used in both protections, this file is detected within the general Macrovision checks. - }; - - return MatchUtil.GetAllMatches(files, matchers, any: true); - } - - /// - public string CheckFilePath(string path) - { - var matchers = new List - { - // Found in "Volumia!" by Puur (Barcode 7 43218 63282 2) (Discogs Release Code [r795427]). - // Modified version of the PlayJ Music Player specificaly for CDS, as indicated by the About page present when running the executable. - // The file "DATA16.BML" is also present on this disc but the name is too generic to check for. - new PathMatchSet(new PathMatch("CACTUSPJ.exe", useEndsWith: true), "PlayJ Music Player (Cactus Data Shield 200)"), - - // Found in "Volumia!" by Puur (Barcode 7 43218 63282 2) (Discogs Release Code [r795427]), - // In "Volumia! - Puur", this file is composed of multiple PLJ files combined together. - // In later versions, this file is a padded dummy file. ("Ich Habe Einen Traum" by Uwe Busse (Barcode 9 002723 251203)). - new PathMatchSet(new PathMatch("YUCCA.CDS", useEndsWith: true), "Cactus Data Shield 200"), - - // TODO: Find samples of the following: - new PathMatchSet(new PathMatch("CDSPlayer.app", useEndsWith: true), "Cactus Data Shield 200"), - new PathMatchSet(new PathMatch("wmmp.exe", useEndsWith: true), "Cactus Data Shield 200"), - - // The file "00000001.TMP" (with a filesize of 2,048 bytes) can be found in CDS-300, as well as SafeDisc. - // Due to this file being used in both protections, this file is detected within the general Macrovision checks. - }; - - return MatchUtil.GetFirstMatch(path, matchers, any: true); - } - - // TODO: Simplify version checking. - public static string GetVersion(string firstMatchedString, IEnumerable files) - { - // Find the version.txt file first - string versionPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("version.txt", StringComparison.OrdinalIgnoreCase)); - if (!string.IsNullOrWhiteSpace(versionPath)) - { - string version = GetInternalVersion(versionPath); - if (!string.IsNullOrWhiteSpace(version)) - return version; - } - - return "200"; - } - - private static string GetInternalVersion(string path) - { - if (!File.Exists(path)) - return null; - - try - { - using (var sr = new StreamReader(path, Encoding.Default)) - { - return $"{sr.ReadLine().Substring(3)} ({sr.ReadLine()})"; - } - } - catch - { - return null; - } - } } } diff --git a/BurnOutSharp/ProtectionType/Macrovision.CactusDataShield.cs b/BurnOutSharp/ProtectionType/Macrovision.CactusDataShield.cs index 88c85c10..da1bee1c 100644 --- a/BurnOutSharp/ProtectionType/Macrovision.CactusDataShield.cs +++ b/BurnOutSharp/ProtectionType/Macrovision.CactusDataShield.cs @@ -1,6 +1,10 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Text; +using BurnOutSharp.Matching; using BurnOutSharp.Wrappers; namespace BurnOutSharp.ProtectionType @@ -53,5 +57,90 @@ namespace BurnOutSharp.ProtectionType return null; } + + /// + internal ConcurrentQueue CactusDataShieldCheckDirectoryPath(string path, IEnumerable files) + { + // TODO: Verify if these are OR or AND + var matchers = new List + { + // Found in "Volumia!" by Puur (Barcode 7 43218 63282 2) (Discogs Release Code [r795427]). + // Modified version of the PlayJ Music Player specificaly for CDS, as indicated by the About page present when running the executable. + // The file "DATA16.BML" is also present on this disc but the name is too generic to check for. + new PathMatchSet(new PathMatch("CACTUSPJ.exe", useEndsWith: true), "PlayJ Music Player (Cactus Data Shield 200)"), + + // Found in "Volumia!" by Puur (Barcode 7 43218 63282 2) (Discogs Release Code [r795427]). + // In "Volumina! - Puur" (7 43218 63282 2), this file is composed of multiple PLJ files combined together. + // In later versions, this file is a padded dummy file. ("Ich Habe Einen Traum" by Uwe Busse (Barcode 9 002723 251203)). + new PathMatchSet(new PathMatch("YUCCA.CDS", useEndsWith: true), "Cactus Data Shield 200"), + + // TODO: Find samples of the following: + new PathMatchSet(new PathMatch("CDSPlayer.app", useEndsWith: true), GetCactusDataShieldVersion, "Cactus Data Shield"), + new PathMatchSet(new PathMatch("wmmp.exe", useEndsWith: true), GetCactusDataShieldVersion, "Cactus Data Shield"), + + // The file "00000001.TMP" (with a filesize of 2,048 bytes) can be found in CDS-300, as well as SafeDisc. + // Due to this file being used in both protections, this file is detected within the general Macrovision checks. + }; + + return MatchUtil.GetAllMatches(files, matchers, any: false); + } + + /// + internal string CactusDataShieldCheckFilePath(string path) + { + var matchers = new List + { + // Found in "Volumia!" by Puur (Barcode 7 43218 63282 2) (Discogs Release Code [r795427]). + // Modified version of the PlayJ Music Player specificaly for CDS, as indicated by the About page present when running the executable. + // The file "DATA16.BML" is also present on this disc but the name is too generic to check for. + new PathMatchSet(new PathMatch("CACTUSPJ.exe", useEndsWith: true), "PlayJ Music Player (Cactus Data Shield 200)"), + + // Found in "Volumia!" by Puur (Barcode 7 43218 63282 2) (Discogs Release Code [r795427]), + // In "Volumia! - Puur", this file is composed of multiple PLJ files combined together. + // In later versions, this file is a padded dummy file. ("Ich Habe Einen Traum" by Uwe Busse (Barcode 9 002723 251203)). + new PathMatchSet(new PathMatch("YUCCA.CDS", useEndsWith: true), "Cactus Data Shield 200"), + + // TODO: Find samples of the following: + new PathMatchSet(new PathMatch("CDSPlayer.app", useEndsWith: true), "Cactus Data Shield 200"), + new PathMatchSet(new PathMatch("wmmp.exe", useEndsWith: true), "Cactus Data Shield 200"), + + // The file "00000001.TMP" (with a filesize of 2,048 bytes) can be found in CDS-300, as well as SafeDisc. + // Due to this file being used in both protections, this file is detected within the general Macrovision checks. + }; + + return MatchUtil.GetFirstMatch(path, matchers, any: true); + } + + public static string GetCactusDataShieldVersion(string firstMatchedString, IEnumerable files) + { + // Find the version.txt file first + string versionPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("version.txt", StringComparison.OrdinalIgnoreCase)); + if (!string.IsNullOrWhiteSpace(versionPath)) + { + string version = GetCactusDataShieldInternalVersion(versionPath); + if (!string.IsNullOrWhiteSpace(version)) + return version; + } + + return "200"; + } + + private static string GetCactusDataShieldInternalVersion(string path) + { + if (!File.Exists(path)) + return null; + + try + { + using (var sr = new StreamReader(path, Encoding.Default)) + { + return $"{sr.ReadLine().Substring(3)} ({sr.ReadLine()})"; + } + } + catch + { + return null; + } + } } } diff --git a/BurnOutSharp/ProtectionType/Macrovision.cs b/BurnOutSharp/ProtectionType/Macrovision.cs index 80f838cb..e387b997 100644 --- a/BurnOutSharp/ProtectionType/Macrovision.cs +++ b/BurnOutSharp/ProtectionType/Macrovision.cs @@ -106,11 +106,16 @@ namespace BurnOutSharp.ProtectionType { ConcurrentQueue results = new ConcurrentQueue(); - // Run Macrovision file checks - var macrovision = CDillaCheckDirectoryPath(path, files); + // Run Macrovision directory checks + var macrovision = MacrovisionCheckDirectoryPath(path, files); if (macrovision != null && !macrovision.IsEmpty) results.AddRange(macrovision); + // Run Cactus Data Shield directory checks + var cactusDataShield = CactusDataShieldCheckDirectoryPath(path, files); + if (cactusDataShield != null && !cactusDataShield.IsEmpty) + results.AddRange(cactusDataShield); + // Run C-Dilla directory checks var cDilla = CDillaCheckDirectoryPath(path, files); if (cDilla != null && !cDilla.IsEmpty) @@ -142,6 +147,11 @@ namespace BurnOutSharp.ProtectionType if (!string.IsNullOrWhiteSpace(macrovision)) resultsList.Add(macrovision); + // Run Cactus Data Shield file checks + string cactusDataShield = CactusDataShieldCheckFilePath(path); + if (!string.IsNullOrWhiteSpace(cactusDataShield)) + resultsList.Add(cactusDataShield); + // Run C-Dilla file checks string cDilla = CDillaCheckFilePath(path); if (!string.IsNullOrWhiteSpace(cDilla))