From c74b5b3d29c4617f5aa635d9c69bee6fed9923c6 Mon Sep 17 00:00:00 2001 From: SilasLaspada Date: Fri, 2 Jul 2021 11:16:06 -0600 Subject: [PATCH] Improve Bitpool detection (#43) * Improve Bitpool detection * Address comments --- BurnOutSharp/ProtectionType/Bitpool.cs | 31 +++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/BurnOutSharp/ProtectionType/Bitpool.cs b/BurnOutSharp/ProtectionType/Bitpool.cs index 3212974a..6d2c204f 100644 --- a/BurnOutSharp/ProtectionType/Bitpool.cs +++ b/BurnOutSharp/ProtectionType/Bitpool.cs @@ -3,14 +3,42 @@ using BurnOutSharp.Matching; namespace BurnOutSharp.ProtectionType { - public class Bitpool : IPathCheck + /// + /// Bitpool is a copy protection that seems to resemble SafeDisc in several ways, found mostly in German releases. + /// Makes use of bad sectors, and contains what appears to be an encrypted game executable always called "CD.IDX" (similar to SafeDisc ICD files), which seems to be present in every disc protected with it. + /// The "CD.IDX" appears to purposefully contain bad sectors in most, if not all, cases. + /// A "bitpool.rsc" file is present in some, but not all Bitpool protected games. The purpose of it is so far unclear. + /// + public class Bitpool : IContentCheck, IPathCheck { + + /// + /// Set of all ContentMatchSets for this protection + /// + private static readonly List contentMatchers = new List + { + // Sometimes found in CD.IDX + // BITPOOL.RSC + new ContentMatchSet(new byte?[] + { + 0x42, 0x49, 0x54, 0x50, 0x4F, 0x4F, 0x4C, 0x2E, + 0x52, 0x53, 0x43 + }, "Bitpool"), + }; + + /// + public string CheckContents(string file, byte[] fileContent, bool includePosition = false) + { + return MatchUtil.GetFirstMatch(file, fileContent, contentMatchers, includePosition); + } + /// public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("bitpool.rsc", useEndsWith: true), "Bitpool"), + new PathMatchSet(new PathMatch("CD.IDX", useEndsWith: true), "Bitpool"), }; return MatchUtil.GetAllMatches(files, matchers, any: true); @@ -22,6 +50,7 @@ namespace BurnOutSharp.ProtectionType var matchers = new List { new PathMatchSet(new PathMatch("bitpool.rsc", useEndsWith: true), "Bitpool"), + new PathMatchSet(new PathMatch("CD.IDX", useEndsWith: true), "Bitpool"), }; return MatchUtil.GetFirstMatch(path, matchers, any: true);