From 027388f5876621ca96166b28406521e5a4bbe30e Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 29 Aug 2021 21:40:25 -0700 Subject: [PATCH] Add fvinfo to CDKey; add note --- BurnOutSharp/ProtectionType/CDKey.cs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/BurnOutSharp/ProtectionType/CDKey.cs b/BurnOutSharp/ProtectionType/CDKey.cs index f24d997f..c1e6a59f 100644 --- a/BurnOutSharp/ProtectionType/CDKey.cs +++ b/BurnOutSharp/ProtectionType/CDKey.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using BurnOutSharp.Matching; using BurnOutSharp.Tools; @@ -24,6 +25,28 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckContents(string file, byte[] fileContent, bool includeDebug = false) => null; + public string CheckContents(string file, byte[] fileContent, bool includeDebug = false) + { + // Get the sections from the executable, if possible + // PortableExecutable pex = PortableExecutable.Deserialize(fileContent, 0); + // var sections = pex?.SectionTable; + // if (sections == null) + // return null; + + // TODO: Implement resource finding instead of using the built in methods + // Assembly information lives in the .rsrc section + // I need to find out how to navigate the resources in general + // as well as figure out the specific resources for both + // file info and MUI (XML) info. Once I figure this out, + // that also opens the doors to easier assembly XML checks. + + var fvinfo = Utilities.GetFileVersionInfo(file); + + string name = fvinfo?.InternalName?.Trim(); + if (!string.IsNullOrWhiteSpace(name) && name.Equals("CDKey", StringComparison.OrdinalIgnoreCase)) + return "CD-Key / Serial"; + + return null; + } } }