From 1bc8fe7ff67085efce49051c395bd15808a0c656 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 11 Sep 2021 16:58:05 -0700 Subject: [PATCH] Fix version finding for MS-CAB SFX --- BurnOutSharp/PackerType/MicrosoftCABSFX.cs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/BurnOutSharp/PackerType/MicrosoftCABSFX.cs b/BurnOutSharp/PackerType/MicrosoftCABSFX.cs index 1ac02836..01b7ccfc 100644 --- a/BurnOutSharp/PackerType/MicrosoftCABSFX.cs +++ b/BurnOutSharp/PackerType/MicrosoftCABSFX.cs @@ -40,12 +40,12 @@ namespace BurnOutSharp.PackerType { 0x77, 0x65, 0x78, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5F, 0x63, 0x6C, 0x65, 0x61, 0x6E, 0x75, 0x70, - }, GetVersion, "Microsoft CAB SFX"), + }, "Microsoft CAB SFX"), }; string match = MatchUtil.GetFirstMatch(file, pex.DataSectionRaw, matchers, includeDebug); if (!string.IsNullOrWhiteSpace(match)) - return match; + return $"Microsoft CAB SFX v{Utilities.GetFileVersion(pex)}".TrimEnd('v'); } // Get the .text section, if it exists @@ -56,12 +56,12 @@ namespace BurnOutSharp.PackerType /* This detects a different but similar type of SFX that uses Microsoft CAB files. Further research is needed to see if it's just a different version or entirely separate. */ // MSCFu - new ContentMatchSet(new byte?[] { 0x4D, 0x53, 0x43, 0x46, 0x75 }, GetVersion, "Microsoft CAB SFX"), + new ContentMatchSet(new byte?[] { 0x4D, 0x53, 0x43, 0x46, 0x75 }, "Microsoft CAB SFX"), }; string match = MatchUtil.GetFirstMatch(file, pex.TextSectionRaw, matchers, includeDebug); if (!string.IsNullOrWhiteSpace(match)) - return match; + return $"Microsoft CAB SFX v{Utilities.GetFileVersion(pex)}".TrimEnd('v'); } return null; @@ -84,15 +84,5 @@ namespace BurnOutSharp.PackerType { return null; } - - // This method of version detection is suboptimal because the version is sometimes the version of the included software, not the SFX itself. - public static string GetVersion(string file, byte[] fileContent, List positions) - { - string version = Utilities.GetFileVersion(fileContent); - if (!string.IsNullOrWhiteSpace(version)) - return $"v{version}"; - - return string.Empty; - } } }