From 22aa1642a69cab927edad07d601ebfd53e061892 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 23 Sep 2021 13:33:48 -0700 Subject: [PATCH] Partial cleanup of CD/DVD-Cops; add notes --- BurnOutSharp/ProtectionType/CDDVDCops.cs | 44 +++++++++--------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/BurnOutSharp/ProtectionType/CDDVDCops.cs b/BurnOutSharp/ProtectionType/CDDVDCops.cs index 7bf85b40..944c601a 100644 --- a/BurnOutSharp/ProtectionType/CDDVDCops.cs +++ b/BurnOutSharp/ProtectionType/CDDVDCops.cs @@ -12,37 +12,25 @@ namespace BurnOutSharp.ProtectionType /// public string CheckContents(string file, byte[] fileContent, bool includeDebug, PortableExecutable pex, NewExecutable nex) { - // Get the sections from the executable, if possible - var sections = pex?.SectionTable; - if (sections == null) - return null; - - // Get the .grand section, if it exists - var grandSectionRaw = pex.ReadRawSection(fileContent, ".grand", first: true); - if (grandSectionRaw != null) + // Try to read the contents as a PE executable + if (pex != null) { - var matchers = new List - { - // CD-Cops, ver. - new ContentMatchSet(new byte?[] - { - 0x43, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73, 0x2C, - 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20 - }, GetVersion, "CD-Cops"), + var sections = pex?.SectionTable; + if (sections == null) + return null; - // DVD-Cops, ver. - new ContentMatchSet(new byte?[] - { - 0x44, 0x56, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73, - 0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20 - }, GetVersion, "DVD-Cops"), - }; + // Get the .grand section, if it exists -- TODO: Confirm is this is in DVD-Cops as well + bool grandSection = pex.ContainsSection(".grand", exact: true); + if (grandSection) + return "CD-Cops"; + } - string match = MatchUtil.GetFirstMatch(file, grandSectionRaw, matchers, includeDebug); - if (!string.IsNullOrWhiteSpace(match)) - return match; - - // return "CD-Cops (Unknown Version)"; + // Try to read the contents as an NE executable + if (nex != null) + { + // TODO: Do something with these strings in the NE header(?) + // - CDCOPS + // - CDcops assembly-language DLL } // TODO: Obtain a sample to find where this string is in a typical executable