From 9a160b3127a9510f9e158623aaf41913ef221955 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 25 Apr 2022 12:34:39 -0700 Subject: [PATCH] Split Directory/File checks for SafeDisc --- BurnOutSharp/ProtectionType/SafeDisc.cs | 97 ++++++++++++++++--------- 1 file changed, 61 insertions(+), 36 deletions(-) diff --git a/BurnOutSharp/ProtectionType/SafeDisc.cs b/BurnOutSharp/ProtectionType/SafeDisc.cs index 4af37386..4c78d2d6 100644 --- a/BurnOutSharp/ProtectionType/SafeDisc.cs +++ b/BurnOutSharp/ProtectionType/SafeDisc.cs @@ -12,40 +12,6 @@ namespace BurnOutSharp.ProtectionType // the same generic BoG_ string. The current combination check doesn't seem consistent public class SafeDisc : IPEContentCheck, IPathCheck { - /// - /// Set of all PathMatchSets for this protection - /// - private static readonly List pathMatchers = new List - { - new PathMatchSet(new List - { - new PathMatch("CLCD16.DLL", useEndsWith: true), - new PathMatch("CLCD32.DLL", useEndsWith: true), - new PathMatch("CLOKSPL.EXE", useEndsWith: true), - //new PathMatch(".icd", useEndsWith: true), // Over-matches in a very specific case - }, "SafeDisc 1/Lite"), - - new PathMatchSet(new List - { - new PathMatch("00000001.TMP", useEndsWith: true), - //new PathMatch(".016", useEndsWith: true), // Potentially over-matching - //new PathMatch(".256", useEndsWith: true), // Potentially over-matching - }, "SafeDisc 1-3"), - - new PathMatchSet(new PathMatch("00000002.TMP", useEndsWith: true), "SafeDisc 2"), - - new PathMatchSet(new PathMatch("DPLAYERX.DLL", useEndsWith: true), GetDPlayerXVersion, "SafeDisc (dplayerx.dll)"), - new PathMatchSet(new PathMatch("drvmgt.dll", useEndsWith: true), GetDrvmgtVersion, "SafeDisc (drvmgt.dll)"), - new PathMatchSet(new PathMatch("secdrv.sys", useEndsWith: true), GetSecdrvVersion, "SafeDisc (secdrv.sys)"), - - new PathMatchSet(new PathMatch("00000001.LT1", useEndsWith: true), "SafeDisc Lite"), - - new PathMatchSet(".SafeDiscDVD.bundle", "SafeDisc for Macintosh"), - - new PathMatchSet(new PathMatch("cdac11ba.exe", useEndsWith: true), "SafeCast"), - new PathMatchSet(new PathMatch("cdac14ba.dll", useEndsWith: true), "SafeCast"), - }; - /// public string CheckPEContents(string file, PortableExecutable pex, bool includeDebug) { @@ -90,13 +56,72 @@ namespace BurnOutSharp.ProtectionType /// public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) { - return MatchUtil.GetAllMatches(files, pathMatchers, any: false); + var matchers = new List + { + new PathMatchSet(new List + { + new PathMatch("CLCD16.DLL", useEndsWith: true), + new PathMatch("CLCD32.DLL", useEndsWith: true), + new PathMatch("CLOKSPL.EXE", useEndsWith: true), + new PathMatch(".icd", useEndsWith: true), + }, "SafeDisc 1/Lite"), + + new PathMatchSet(new List + { + new PathMatch("00000001.TMP", useEndsWith: true), + new PathMatch(".016", useEndsWith: true), + new PathMatch(".256", useEndsWith: true), + }, "SafeDisc 1-3"), + + new PathMatchSet(new PathMatch("00000002.TMP", useEndsWith: true), "SafeDisc 2"), + + new PathMatchSet(new PathMatch("DPLAYERX.DLL", useEndsWith: true), GetDPlayerXVersion, "SafeDisc (dplayerx.dll)"), + new PathMatchSet(new PathMatch("drvmgt.dll", useEndsWith: true), GetDrvmgtVersion, "SafeDisc (drvmgt.dll)"), + new PathMatchSet(new PathMatch("secdrv.sys", useEndsWith: true), GetSecdrvVersion, "SafeDisc (secdrv.sys)"), + + new PathMatchSet(new PathMatch("00000001.LT1", useEndsWith: true), "SafeDisc Lite"), + + new PathMatchSet(".SafeDiscDVD.bundle", "SafeDisc for Macintosh"), + + new PathMatchSet(new PathMatch("cdac11ba.exe", useEndsWith: true), "SafeCast"), + new PathMatchSet(new PathMatch("cdac14ba.dll", useEndsWith: true), "SafeCast"), + }; + + return MatchUtil.GetAllMatches(files, matchers, any: false); } /// public string CheckFilePath(string path) { - return MatchUtil.GetFirstMatch(path, pathMatchers, any: true); + var matchers = new List + { + new PathMatchSet(new List + { + new PathMatch("CLCD16.DLL", useEndsWith: true), + new PathMatch("CLCD32.DLL", useEndsWith: true), + new PathMatch("CLOKSPL.EXE", useEndsWith: true), + }, "SafeDisc 1/Lite"), + + new PathMatchSet(new List + { + new PathMatch("00000001.TMP", useEndsWith: true), + }, "SafeDisc 1-3"), + + new PathMatchSet(new PathMatch("00000002.TMP", useEndsWith: true), "SafeDisc 2"), + + new PathMatchSet(new PathMatch("DPLAYERX.DLL", useEndsWith: true), GetDPlayerXVersion, "SafeDisc (dplayerx.dll)"), + new PathMatchSet(new PathMatch("drvmgt.dll", useEndsWith: true), GetDrvmgtVersion, "SafeDisc (drvmgt.dll)"), + new PathMatchSet(new PathMatch("secdrv.sys", useEndsWith: true), GetSecdrvVersion, "SafeDisc (secdrv.sys)"), + + new PathMatchSet(new PathMatch("00000001.LT1", useEndsWith: true), "SafeDisc Lite"), + + new PathMatchSet(".SafeDiscDVD.bundle", "SafeDisc for Macintosh"), + + new PathMatchSet(new PathMatch("cdac11ba.exe", useEndsWith: true), "SafeCast"), + new PathMatchSet(new PathMatch("cdac14ba.dll", useEndsWith: true), "SafeCast"), + }; + + return MatchUtil.GetFirstMatch(path, matchers, any: true); } public static string Get320to4xVersion(string file, byte[] fileContent, List positions) => "3.20-4.xx (version removed)";