diff --git a/BurnOutSharp/FileType/Executable.cs b/BurnOutSharp/FileType/Executable.cs index 2fe4f145..c2406a55 100644 --- a/BurnOutSharp/FileType/Executable.cs +++ b/BurnOutSharp/FileType/Executable.cs @@ -100,9 +100,8 @@ namespace BurnOutSharp.FileType } // If we have an IScannable implementation - if (contentCheckClass is IScannable) + if (contentCheckClass is IScannable scannable) { - IScannable scannable = contentCheckClass as IScannable; if (file != null && !string.IsNullOrEmpty(protection)) { var subProtections = scannable.Scan(scanner, null, file); diff --git a/BurnOutSharp/FileType/MicrosoftCAB.cs b/BurnOutSharp/FileType/MicrosoftCAB.cs index 310a9cd6..c683f335 100644 --- a/BurnOutSharp/FileType/MicrosoftCAB.cs +++ b/BurnOutSharp/FileType/MicrosoftCAB.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.IO; using LibMSPackN; diff --git a/BurnOutSharp/PackerType/MicrosoftCABSFX.cs b/BurnOutSharp/PackerType/MicrosoftCABSFX.cs index 69e82de5..1ed22850 100644 --- a/BurnOutSharp/PackerType/MicrosoftCABSFX.cs +++ b/BurnOutSharp/PackerType/MicrosoftCABSFX.cs @@ -1,12 +1,17 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; +using System.IO; using BurnOutSharp.Matching; 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 class MicrosoftCABSFX : IContentCheck, IScannable { + /// + public bool ShouldScan(byte[] magic) => true; + /// public string CheckContents(string file, byte[] fileContent, bool includePosition = false) { @@ -65,6 +70,24 @@ namespace BurnOutSharp.PackerType return MatchUtil.GetFirstMatch(file, fileContent, matchers, includePosition); } + /// + public ConcurrentDictionary> Scan(Scanner scanner, string file) + { + if (!File.Exists(file)) + return null; + + using (var fs = File.OpenRead(file)) + { + return Scan(scanner, fs, file); + } + } + + /// + public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) + { + 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) {