From 35a4771f89aff65d9635318c810bfa978892b45b Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 26 Oct 2022 21:10:33 -0700 Subject: [PATCH] Split out obvious SafeCast from SafeDisc (nw) --- .../ProtectionType/Macrovision.SafeCast.cs | 46 ++++++++++++++++++- .../ProtectionType/Macrovision.SafeDisc.cs | 19 +------- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/BurnOutSharp/ProtectionType/Macrovision.SafeCast.cs b/BurnOutSharp/ProtectionType/Macrovision.SafeCast.cs index b500c00a..514e7d73 100644 --- a/BurnOutSharp/ProtectionType/Macrovision.SafeCast.cs +++ b/BurnOutSharp/ProtectionType/Macrovision.SafeCast.cs @@ -14,6 +14,50 @@ namespace BurnOutSharp.ProtectionType /// public partial class Macrovision { - // TODO: Add methods for specific PE, path, and version checks here + internal string SafeCastCheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug) + { + // Get the sections from the executable, if possible + var sections = pex?.SectionTable; + if (sections == null) + return null; + + string name = pex.FileDescription; + if (name?.Equals("SafeCast2", StringComparison.OrdinalIgnoreCase) == true) + return $"SafeCast"; + + return null; + } + + /// + internal ConcurrentQueue SafeCastCheckDirectoryPath(string path, IEnumerable files) + { + var matchers = new List + { + // Found in multiple versions of SafeCast, including Redump entry 83145 and IA item "TurboTax_Deluxe_Tax_Year_2002_for_Wndows_2.00R_Intuit_2002_352282". + new PathMatchSet(new PathMatch("cdac14ba.dll", useEndsWith: true), "SafeCast"), + + // Found in Redump entry 83145. + new PathMatchSet(new PathMatch("CDAC21BA.DLL", useEndsWith: true), "SafeCast"), + }; + + return MatchUtil.GetAllMatches(files, matchers, any: false); + } + + /// + internal string SafeCastCheckFilePath(string path) + { + var matchers = new List + { + new PathMatchSet(new PathMatch("cdac11ba.exe", useEndsWith: true), "SafeCast"), + + // Found in multiple versions of SafeCast, including Redump entry 83145 and IA item "TurboTax_Deluxe_Tax_Year_2002_for_Wndows_2.00R_Intuit_2002_352282". + new PathMatchSet(new PathMatch("cdac14ba.dll", useEndsWith: true), "SafeCast"), + + // Found in Redump entry 83145. + new PathMatchSet(new PathMatch("CDAC21BA.DLL", useEndsWith: true), "SafeCast"), + }; + + return MatchUtil.GetFirstMatch(path, matchers, any: true); + } } } diff --git a/BurnOutSharp/ProtectionType/Macrovision.SafeDisc.cs b/BurnOutSharp/ProtectionType/Macrovision.SafeDisc.cs index 9d426970..5f94118d 100644 --- a/BurnOutSharp/ProtectionType/Macrovision.SafeDisc.cs +++ b/BurnOutSharp/ProtectionType/Macrovision.SafeDisc.cs @@ -43,11 +43,8 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.FileDescription; - if (name?.Equals("SafeCast2", StringComparison.OrdinalIgnoreCase) == true) - return $"SafeCast"; - // Present in "secdrv.sys" files found in SafeDisc 2.80.010+. + string name = pex.FileDescription; if (name?.Equals("Macrovision SECURITY Driver", StringComparison.OrdinalIgnoreCase) == true) return $"SafeDisc Security Driver {GetSecDrvExecutableVersion(pex)}"; @@ -172,12 +169,6 @@ namespace BurnOutSharp.ProtectionType // Found on Redump entry 42762. new PathMatchSet(".SafeDiscDVD.bundle", "SafeDisc for Macintosh"), - - // Found in multiple versions of SafeCast, including Redump entry 83145 and IA item "TurboTax_Deluxe_Tax_Year_2002_for_Wndows_2.00R_Intuit_2002_352282". - new PathMatchSet(new PathMatch("cdac14ba.dll", useEndsWith: true), "SafeCast"), - - // Found in Redump entry 83145. - new PathMatchSet(new PathMatch("CDAC21BA.DLL", useEndsWith: true), "SafeCast"), }; return MatchUtil.GetAllMatches(files, matchers, any: false); @@ -230,14 +221,6 @@ namespace BurnOutSharp.ProtectionType // Found in Redump entry 42762. new PathMatchSet(".SafeDiscDVD.bundle", "SafeDisc for Macintosh"), - - new PathMatchSet(new PathMatch("cdac11ba.exe", useEndsWith: true), "SafeCast"), - - // Found in multiple versions of SafeCast, including Redump entry 83145 and IA item "TurboTax_Deluxe_Tax_Year_2002_for_Wndows_2.00R_Intuit_2002_352282". - new PathMatchSet(new PathMatch("cdac14ba.dll", useEndsWith: true), "SafeCast"), - - // Found in Redump entry 83145. - new PathMatchSet(new PathMatch("CDAC21BA.DLL", useEndsWith: true), "SafeCast"), }; return MatchUtil.GetFirstMatch(path, matchers, any: true);