From 177641894e4e18823fe8c9515f8a2ddb8ac0d3ac Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 23 Aug 2021 23:09:05 -0700 Subject: [PATCH] Clean up MS-CAB SFX a little --- BurnOutSharp/PackerType/MicrosoftCABSFX.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/BurnOutSharp/PackerType/MicrosoftCABSFX.cs b/BurnOutSharp/PackerType/MicrosoftCABSFX.cs index 06f1f75c..e86f32b4 100644 --- a/BurnOutSharp/PackerType/MicrosoftCABSFX.cs +++ b/BurnOutSharp/PackerType/MicrosoftCABSFX.cs @@ -7,9 +7,6 @@ namespace BurnOutSharp.PackerType // TODO: Add extraction, which should be possible with LibMSPackN, but it refuses to extract due to SFX files lacking the typical CAB identifiers. public class MicrosoftCABSFX : IContentCheck { - /// - public bool ShouldScan(byte[] magic) => true; - /// public string CheckContents(string file, byte[] fileContent, bool includePosition = false) { @@ -18,11 +15,23 @@ namespace BurnOutSharp.PackerType string name = fvinfo?.InternalName.Trim(); if (!string.IsNullOrWhiteSpace(name) && name.Equals("Wextract", StringComparison.OrdinalIgnoreCase)) - return $"Microsoft CAB SFX v{Utilities.GetFileVersion(file)}"; + { + string version = GetVersion(file, fileContent, null); + if (!string.IsNullOrWhiteSpace(version)) + return $"Microsoft CAB SFX v{Utilities.GetFileVersion(file)}"; + + return "Microsoft CAB SFX"; + } name = fvinfo?.OriginalFilename.Trim(); if (!string.IsNullOrWhiteSpace(name) && name.Equals("WEXTRACT.EXE", StringComparison.OrdinalIgnoreCase)) - return $"Microsoft CAB SFX v{Utilities.GetFileVersion(file)}"; + { + string version = GetVersion(file, fileContent, null); + if (!string.IsNullOrWhiteSpace(version)) + return $"Microsoft CAB SFX v{Utilities.GetFileVersion(file)}"; + + return "Microsoft CAB SFX"; + } var matchers = new List {