From 405c895352f3a4c21fa7d5018b64fad437f08c2b Mon Sep 17 00:00:00 2001 From: TheRogueArchivist Date: Wed, 14 Dec 2022 13:11:23 -0700 Subject: [PATCH] Add support for CD-Guard (#181) * why is there so much DRM I am going to cry * Add support for detecting CD-Guard, as well as notes. * Add CD-Guard to README. * Address PR comments * Ignore case in import/export checks. --- BurnOutSharp/ProtectionType/CDGuard.cs | 81 ++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 82 insertions(+) create mode 100644 BurnOutSharp/ProtectionType/CDGuard.cs diff --git a/BurnOutSharp/ProtectionType/CDGuard.cs b/BurnOutSharp/ProtectionType/CDGuard.cs new file mode 100644 index 00000000..d884b1aa --- /dev/null +++ b/BurnOutSharp/ProtectionType/CDGuard.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using BurnOutSharp.Interfaces; +using BurnOutSharp.Matching; +using BurnOutSharp.Wrappers; + +namespace BurnOutSharp.ProtectionType +{ + /// + /// CD-Guard is a DRM from Russia that's similar to CD-Cops and may be related to StarForce, meaning it likely needs DPM. + /// It may have been developed by Russobit-M, though the same source also says that StarForce was created by the same company as well, which seems unlikely (https://m.linkdatasecurity.com/pnews6.htm). + /// Others online have been confused by this as well (https://forum.ixbt.com/topic.cgi?id=31:009712). + /// A game referred to as having CD-Guard by http://lastboss.ru/games/RUS/randevu-s-neznakomkoi-2 that was published by Russobit-M is known to have an early version of StarForce (Redump entry 97088). + /// The FAQ on the game's official website indicates that StarForce specifically is present (https://web.archive.org/web/20011220224222/http://www.aha.ru/~exe_soft/russian/exesoft.htm). + /// It's unknown for sure if there were two separate versions of this game that contained separate protections, or if the game never actually contained CD-Guard, or if CD-Guard was an early name for the StarForce line of products. + /// There is a re-release of an earlier game by the same developer that seems to include both CD-Guard and StarForce drivers, with the CD-Guard driver seemingly not used during installation, nor installed onto the system (IA item "pahgeby-he3hakomkou"). + /// + /// Additional resources and references: + /// https://gamecopyworld.com/games/pc_omikron.shtml + /// https://forum.ixbt.com/topic.cgi?id=31:3985 + /// + public class CDGuard : IPathCheck, IPortableExecutableCheck + { + /// + public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug) + { + // Get the sections from the executable, if possible + var sections = pex?.SectionTable; + if (sections == null) + return null; + + // TODO: Investigate the numerous ".guard" sections present in "Randevu.exe" in Redump entry 97142. + + // Get the export directory table + if (pex.ExportTable?.ExportDirectoryTable != null) + { + // Found in "cdguard.dll" in Redump entry 97142 and IA item "pahgeby-he3hakomkou". + bool match = pex.ExportTable.ExportDirectoryTable.Name?.Equals("cdguard.dll", StringComparison.OrdinalIgnoreCase) == true; + if (match) + return "CD-Guard Copy Protection System"; + } + + // Get the import directory table + if (pex.ImportTable?.ImportDirectoryTable != null) + { + // Found in "Randevu.exe" in Redump entry 97142. + bool match = pex.ImportTable.ImportDirectoryTable.Any(idte => idte.Name?.Equals("cdguard.dll", StringComparison.OrdinalIgnoreCase) == true); + if (match) + return "CD-Guard Copy Protection System"; + } + + return null; + } + + /// + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) + { + var matchers = new List + { + // Found in Redump entry 97142. + new PathMatchSet(new PathMatch("cdguard.dll", useEndsWith: true), "CD-Guard Copy Protection System"), + }; + + return MatchUtil.GetAllMatches(files, matchers, any: true); + } + + /// + public string CheckFilePath(string path) + { + var matchers = new List + { + // Found in Redump entry 97142. + new PathMatchSet(new PathMatch("cdguard.dll", useEndsWith: true), "CD-Guard Copy Protection System"), + }; + + return MatchUtil.GetFirstMatch(path, matchers, any: true); + } + } +} diff --git a/README.md b/README.md index b37783ec..55801df5 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ Below is a list of protections detected by BurnOutSharp. The two columns explain | C-Dilla License Management Solution / CD-Secure / CD-Compress | True | True | | | Cactus Data Shield | True | True | | | CD-Cops / DVD-Cops | True | True | Partially unconfirmed² | +| CD-Guard | True | True | | | CD-Lock | True | True | | | CD-Protector | False | True | | | CD-X | False | True | Unconfirmed¹ |