Add IScannable interface

This commit is contained in:
Matt Nadareski
2021-02-26 09:26:23 -08:00
parent 7cfa9649e4
commit f4310206e9
18 changed files with 379 additions and 110 deletions

View File

@@ -7,9 +7,10 @@ using SharpCompress.Compressors.Deflate;
namespace BurnOutSharp.FileType
{
internal class BFPK
internal class BFPK : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
if (magic.StartsWith(new byte[] { 0x42, 0x46, 0x50, 0x4b }))
return true;
@@ -17,7 +18,20 @@ namespace BurnOutSharp.FileType
return false;
}
public static Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// If the BFPK file itself fails
try

View File

@@ -1,15 +1,15 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SharpCompress.Compressors;
using SharpCompress.Compressors.BZip2;
namespace BurnOutSharp.FileType
{
internal class BZip2
internal class BZip2 : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
if (magic.StartsWith(new byte[] { 0x42, 0x52, 0x68 }))
return true;
@@ -17,9 +17,22 @@ namespace BurnOutSharp.FileType
return false;
}
public static Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
// If the 7-zip file itself fails
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// If the BZip2 file itself fails
try
{
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

View File

@@ -6,9 +6,10 @@ using BurnOutSharp.ProtectionType;
namespace BurnOutSharp.FileType
{
internal class Executable
internal class Executable : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
// DOS MZ executable file format (and descendants)
if (magic.StartsWith(new byte[] { 0x4d, 0x5a }))
@@ -41,7 +42,20 @@ namespace BurnOutSharp.FileType
return false;
}
public static Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file = null)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// Load the current file content
byte[] fileContent = null;
@@ -56,7 +70,6 @@ namespace BurnOutSharp.FileType
// Files can be protected in multiple ways
var protections = new Dictionary<string, List<string>>();
var subProtections = new Dictionary<string, List<string>>();
string protection;
#region Protections
@@ -236,11 +249,6 @@ namespace BurnOutSharp.FileType
if (!string.IsNullOrWhiteSpace(protection))
Utilities.AppendToDictionary(protections, file, protection);
// Wise Installer
subProtections = WiseInstaller.CheckContents(scanner, file, fileContent);
if (subProtections != null && subProtections.Count > 0)
Utilities.AppendToDictionary(protections, subProtections);
// WTM CD Protect
protection = new WTMCDProtect().CheckContents(file, fileContent, scanner.IncludePosition);
if (!string.IsNullOrWhiteSpace(protection))
@@ -258,6 +266,22 @@ namespace BurnOutSharp.FileType
#endregion
#region Archive-as-Executable Formats / Installers
// If we're looking for archives too, run scans
if (scanner.ScanArchives)
{
// Wise Installer
if (file != null && !string.IsNullOrEmpty(new WiseInstaller().CheckContents(file, fileContent, scanner.IncludePosition)))
{
var subProtections = new WiseInstaller().Scan(scanner, null, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
}
#endregion
#region Packers
// If we're looking for packers too, run scans
@@ -292,6 +316,11 @@ namespace BurnOutSharp.FileType
protection = new UPX().CheckContents(file, fileContent, scanner.IncludePosition);
if (!string.IsNullOrWhiteSpace(protection))
Utilities.AppendToDictionary(protections, file, protection);
// Wise Installer
protection = new WiseInstaller().CheckContents(file, fileContent, scanner.IncludePosition);
if (!string.IsNullOrWhiteSpace(protection))
Utilities.AppendToDictionary(protections, file, protection);
}
#endregion

View File

@@ -6,9 +6,10 @@ using SharpCompress.Archives.GZip;
namespace BurnOutSharp.FileType
{
internal class GZIP
internal class GZIP : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
if (magic.StartsWith(new byte[] { 0x1f, 0x8b }))
return true;
@@ -16,7 +17,20 @@ namespace BurnOutSharp.FileType
return false;
}
public static Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// If the gzip file itself fails
try

View File

@@ -6,9 +6,10 @@ using UnshieldSharp;
namespace BurnOutSharp.FileType
{
internal class InstallShieldCAB
internal class InstallShieldCAB : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
if (magic.StartsWith(new byte[] { 0x49, 0x53, 0x63 }))
return true;
@@ -16,8 +17,21 @@ namespace BurnOutSharp.FileType
return false;
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
// TODO: Add stream opening support
public static Dictionary<string, List<string>> Scan(Scanner scanner, string file)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// Get the name of the first cabinet file or header
string directory = Path.GetDirectoryName(file);

View File

@@ -5,9 +5,10 @@ using StormLibSharp;
namespace BurnOutSharp.FileType
{
internal class MPQ
internal class MPQ : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
if (magic.StartsWith(new byte[] { 0x4d, 0x50, 0x51, 0x1a }))
return true;
@@ -15,8 +16,21 @@ namespace BurnOutSharp.FileType
return false;
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
// TODO: Add stream opening support
public static Dictionary<string, List<string>> Scan(Scanner scanner, string file)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// If the mpq file itself fails
try

View File

@@ -7,9 +7,10 @@ using Microsoft.Deployment.WindowsInstaller;
namespace BurnOutSharp.FileType
{
internal class MSI
internal class MSI : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
#if NET_FRAMEWORK
if (magic.StartsWith(new byte[] { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 }))
@@ -19,8 +20,21 @@ namespace BurnOutSharp.FileType
return false;
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
// TODO: Add stream opening support
public static Dictionary<string, List<string>> Scan(Scanner scanner, string file)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
#if NET_FRAMEWORK
// If the MSI file itself fails

View File

@@ -8,9 +8,10 @@ using LibMSPackN;
namespace BurnOutSharp.FileType
{
// Specification available at http://download.microsoft.com/download/5/0/1/501ED102-E53F-4CE0-AA6B-B0F93629DDC6/Exchange/%5BMS-CAB%5D.pdf
internal class MicrosoftCAB
internal class MicrosoftCAB : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
#if NET_FRAMEWORK
if (magic.StartsWith(new byte[] { 0x4d, 0x53, 0x43, 0x46 }))
@@ -20,8 +21,21 @@ namespace BurnOutSharp.FileType
return false;
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
// TODO: Add stream opening support
public static Dictionary<string, List<string>> Scan(Scanner scanner, string file)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
#if NET_FRAMEWORK
// If the cab file itself fails

View File

@@ -6,9 +6,10 @@ using SharpCompress.Archives.Zip;
namespace BurnOutSharp.FileType
{
internal class PKZIP
internal class PKZIP : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
// PKZIP
if (magic.StartsWith(new byte[] { 0x50, 0x4b, 0x03, 0x04 }))
@@ -25,7 +26,20 @@ namespace BurnOutSharp.FileType
return false;
}
public static Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// If the zip file itself fails
try

View File

@@ -6,9 +6,10 @@ using SharpCompress.Archives.Rar;
namespace BurnOutSharp.FileType
{
internal class RAR
internal class RAR : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
// RAR archive version 1.50 onwards
if (magic.StartsWith(new byte[] { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 }))
@@ -21,7 +22,20 @@ namespace BurnOutSharp.FileType
return false;
}
public static Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// If the rar file itself fails
try

View File

@@ -6,9 +6,10 @@ using SharpCompress.Archives.SevenZip;
namespace BurnOutSharp.FileType
{
internal class SevenZip
internal class SevenZip : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
if (magic.StartsWith(new byte[] { 0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c }))
return true;
@@ -16,7 +17,20 @@ namespace BurnOutSharp.FileType
return false;
}
public static Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// If the 7-zip file itself fails
try

View File

@@ -6,9 +6,10 @@ using SharpCompress.Archives.Tar;
namespace BurnOutSharp.FileType
{
internal class TapeArchive
internal class TapeArchive : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
if (magic.StartsWith(new byte[] { 0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30, 0x30 }))
return true;
@@ -19,7 +20,20 @@ namespace BurnOutSharp.FileType
return false;
}
public static Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// If the tar file itself fails
try

View File

@@ -5,9 +5,21 @@ using System.Text;
namespace BurnOutSharp.FileType
{
internal class Textfile
internal class Textfile : IScannable
{
public static bool ShouldScan(byte[] magic, string extension)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
return ShouldScan(magic, null);
}
/// <summary>
/// Determine if a file signature or extension matches one of the expected values
/// </summary>
/// <param name="magic">Byte array representing the file header</param>
/// <param name="extension">Extension for the file being checked</param>
/// <returns>True if the signature is valid, false otherwise</returns>
public bool ShouldScan(byte[] magic, string extension)
{
// Rich Text File
if (magic.StartsWith(new byte[] { 0x7b, 0x5c, 0x72, 0x74, 0x66, 0x31 }))
@@ -26,15 +38,29 @@ namespace BurnOutSharp.FileType
return true;
// Generic textfile (no header)
if (string.Equals(extension.TrimStart('.'), "txt", StringComparison.OrdinalIgnoreCase))
if (string.Equals(extension?.TrimStart('.'), "txt", StringComparison.OrdinalIgnoreCase))
return true;
return false;
}
public static List<string> Scan(Stream stream)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
List<string> protections = new List<string>();
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// Files can be protected in multiple ways
var protections = new Dictionary<string, List<string>>();
try
{
@@ -47,13 +73,13 @@ namespace BurnOutSharp.FileType
// CD-Key
if (fileContent.Contains("a valid serial number is required"))
protections.Add("CD-Key / Serial");
Utilities.AppendToDictionary(protections, file, "CD-Key / Serial");
else if (fileContent.Contains("serial number is located"))
protections.Add("CD-Key / Serial");
Utilities.AppendToDictionary(protections, file, "CD-Key / Serial");
// MediaMax
if (fileContent.Contains("MediaMax technology"))
protections.Add("MediaMax CD-3");
Utilities.AppendToDictionary(protections, file, "MediaMax CD-3");
}
catch
{

View File

@@ -5,9 +5,10 @@ using HLExtract.Net;
namespace BurnOutSharp.FileType
{
internal class Valve
internal class Valve : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
// GCF
if (magic.StartsWith(new byte[] { 0x01, 0x00, 0x00, 0x00 }))
@@ -32,8 +33,21 @@ namespace BurnOutSharp.FileType
return false;
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
// TODO: Add stream opening support
public static Dictionary<string, List<string>> Scan(Scanner scanner, string file)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(tempPath);

View File

@@ -5,9 +5,10 @@ using SharpCompress.Compressors.Xz;
namespace BurnOutSharp.FileType
{
internal class XZ
internal class XZ : IScannable
{
public static bool ShouldScan(byte[] magic)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic)
{
if (magic.StartsWith(new byte[] { 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00 }))
return true;
@@ -15,7 +16,20 @@ namespace BurnOutSharp.FileType
return false;
}
public static Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// If the xz file itself fails
try

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.IO;
namespace BurnOutSharp
{
public interface IScannable
{
/// <summary>
/// Determine if a file signature matches one of the expected values
/// </summary>
/// <param name="magic">Byte array representing the file header</param>
/// <returns>True if the signature is valid, false otherwise</returns>
bool ShouldScan(byte[] magic);
/// <summary>
/// Scan a file for all internal protections
/// </summary>
/// <param name="scanner">Scanner object for state tracking</param>
/// <param name="file">Path to the input file</param>
/// <returns>Dictionary mapping paths to protection lists</returns>
/// <remarks>Ideally, this should just point to the other scan implementation</remarks>
Dictionary<string, List<string>> Scan(Scanner scanner, string file);
/// <summary>
/// Scan a stream for all internal protections
/// </summary>
/// <param name="scanner">Scanner object for state tracking</param>
/// <param name="stream">Stream representing the input file</param>
/// <param name="file">Path to the input file</param>
/// <returns>Dictionary mapping paths to protection lists</returns>
Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string filename);
}
}

View File

@@ -5,35 +5,36 @@ using Wise = WiseUnpacker.WiseUnpacker;
namespace BurnOutSharp.ProtectionType
{
public class WiseInstaller
public class WiseInstaller : IContentCheck, IScannable
{
public static Dictionary<string, List<string>> CheckContents(Scanner scanner, string file, byte[] fileContent)
/// <inheritdoc/>
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
// WiseMain
byte[] check = new byte[] { 0x57, 0x69, 0x73, 0x65, 0x4D, 0x61, 0x69, 0x6E };
if (fileContent.Contains(check, out int position))
{
Dictionary<string, List<string>> protections = new Dictionary<string, List<string>>();
if (scanner.ScanPackers)
protections[file ?? "NO FILENAME"] = new List<string> { "Wise Installation Wizard Module" + (scanner.IncludePosition ? $" (Index {position})" : string.Empty) };
if (file == null || !File.Exists(file))
return protections;
if (scanner.ScanArchives)
{
var subProtections = Scan(scanner, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
return protections;
}
return "Wise Installation Wizard Module" + (includePosition ? $" (Index {position})" : string.Empty);
return null;
}
public static Dictionary<string, List<string>> Scan(Scanner scanner, string file)
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
// If the installer file itself fails
try
@@ -63,6 +64,5 @@ namespace BurnOutSharp.ProtectionType
return null;
}
}
}

View File

@@ -441,17 +441,17 @@ namespace BurnOutSharp
#region Non-Archive File Types
// Executable
if (ScanAllFiles || Executable.ShouldScan(magic))
if (ScanAllFiles || new Executable().ShouldScan(magic))
{
var subProtections = Executable.Scan(this, fs, file);
var subProtections = new Executable().Scan(this, fs, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// Text-based files
if (ScanAllFiles || Textfile.ShouldScan(magic, extension))
if (ScanAllFiles || new Textfile().ShouldScan(magic, extension))
{
var subProtections = Textfile.Scan(fs);
Utilities.AppendToDictionary(protections, file, subProtections);
var subProtections = new Textfile().Scan(this, fs, file);
Utilities.AppendToDictionary(protections, subProtections);
}
#endregion
@@ -462,105 +462,105 @@ namespace BurnOutSharp
if (ScanArchives)
{
// 7-Zip archive
if (SevenZip.ShouldScan(magic))
if (new SevenZip().ShouldScan(magic))
{
var subProtections = SevenZip.Scan(this, fs);
var subProtections = new SevenZip().Scan(this, fs, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// BFPK archive
if (BFPK.ShouldScan(magic))
if (new BFPK().ShouldScan(magic))
{
var subProtections = BFPK.Scan(this, fs);
var subProtections = new BFPK().Scan(this, fs, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// BZip2
if (BZip2.ShouldScan(magic))
if (new BZip2().ShouldScan(magic))
{
var subProtections = BZip2.Scan(this, fs);
var subProtections = new BZip2().Scan(this, fs, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// GZIP
if (GZIP.ShouldScan(magic))
if (new GZIP().ShouldScan(magic))
{
var subProtections = GZIP.Scan(this, fs);
var subProtections = new GZIP().Scan(this, fs, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// InstallShield Cabinet
if (file != null && InstallShieldCAB.ShouldScan(magic))
if (file != null && new InstallShieldCAB().ShouldScan(magic))
{
var subProtections = InstallShieldCAB.Scan(this, file);
var subProtections = new InstallShieldCAB().Scan(this, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// Microsoft Cabinet
if (file != null && MicrosoftCAB.ShouldScan(magic))
if (file != null && new MicrosoftCAB().ShouldScan(magic))
{
var subProtections = MicrosoftCAB.Scan(this, file);
var subProtections = new MicrosoftCAB().Scan(this, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// MSI
if (file != null && MSI.ShouldScan(magic))
if (file != null && new MSI().ShouldScan(magic))
{
var subProtections = MSI.Scan(this, file);
var subProtections = new MSI().Scan(this, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// MPQ archive
if (file != null && MPQ.ShouldScan(magic))
if (file != null && new MPQ().ShouldScan(magic))
{
var subProtections = MPQ.Scan(this, file);
var subProtections = new MPQ().Scan(this, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// PKZIP archive (and derivatives)
if (PKZIP.ShouldScan(magic))
if (new PKZIP().ShouldScan(magic))
{
var subProtections = PKZIP.Scan(this, fs);
var subProtections = new PKZIP().Scan(this, fs, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// RAR archive
if (RAR.ShouldScan(magic))
if (new RAR().ShouldScan(magic))
{
var subProtections = RAR.Scan(this, fs);
var subProtections = new RAR().Scan(this, fs, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// Tape Archive
if (TapeArchive.ShouldScan(magic))
if (new TapeArchive().ShouldScan(magic))
{
var subProtections = TapeArchive.Scan(this, fs);
var subProtections = new TapeArchive().Scan(this, fs, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// Valve archive formats
if (file != null && Valve.ShouldScan(magic))
if (file != null && new Valve().ShouldScan(magic))
{
var subProtections = Valve.Scan(this, file);
var subProtections = new Valve().Scan(this, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// XZ
if (XZ.ShouldScan(magic))
if (new XZ().ShouldScan(magic))
{
var subProtections = XZ.Scan(this, fs);
var subProtections = new XZ().Scan(this, fs, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}