From f6157ef79bff9dbc8c5e295288224821cc204818 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 9 Mar 2023 15:07:35 -0500 Subject: [PATCH] Implementations act the same --- BurnOutSharp/FileType/BFPK.cs | 54 +--- BurnOutSharp/FileType/BSP.cs | 54 +--- BurnOutSharp/FileType/BZip2.cs | 54 +--- BurnOutSharp/FileType/CFB.cs | 55 +--- BurnOutSharp/FileType/GCF.cs | 54 +--- BurnOutSharp/FileType/GZIP.cs | 54 +--- .../FileType/InstallShieldArchiveV3.cs | 55 +--- BurnOutSharp/FileType/InstallShieldCAB.cs | 55 +--- BurnOutSharp/FileType/MPQ.cs | 60 +--- BurnOutSharp/FileType/MicrosoftCAB.cs | 54 +--- BurnOutSharp/FileType/MicrosoftLZ.cs | 54 +--- BurnOutSharp/FileType/PAK.cs | 54 +--- BurnOutSharp/FileType/PFF.cs | 54 +--- BurnOutSharp/FileType/PKZIP.cs | 54 +--- BurnOutSharp/FileType/RAR.cs | 73 +---- BurnOutSharp/FileType/SGA.cs | 54 +--- BurnOutSharp/FileType/SevenZip.cs | 54 +--- BurnOutSharp/FileType/TapeArchive.cs | 54 +--- BurnOutSharp/FileType/VBSP.cs | 54 +--- BurnOutSharp/FileType/VPK.cs | 54 +--- BurnOutSharp/FileType/WAD.cs | 54 +--- BurnOutSharp/FileType/XZ.cs | 54 +--- BurnOutSharp/FileType/XZP.cs | 54 +--- BurnOutSharp/Scanner.cs | 260 +++--------------- BurnOutSharp/Tools/Utilities.cs | 37 ++- 25 files changed, 83 insertions(+), 1484 deletions(-) diff --git a/BurnOutSharp/FileType/BFPK.cs b/BurnOutSharp/FileType/BFPK.cs index b2371786..b5fbcc3e 100644 --- a/BurnOutSharp/FileType/BFPK.cs +++ b/BurnOutSharp/FileType/BFPK.cs @@ -1,16 +1,13 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// BFPK custom archive format /// - public class BFPK : IExtractable, IScannable + public class BFPK : IExtractable { /// public string Extract(string file) @@ -41,54 +38,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the BFPK file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/BSP.cs b/BurnOutSharp/FileType/BSP.cs index 46b33b40..131b470a 100644 --- a/BurnOutSharp/FileType/BSP.cs +++ b/BurnOutSharp/FileType/BSP.cs @@ -1,16 +1,13 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// Half-Life Level /// - public class BSP : IExtractable, IScannable + public class BSP : IExtractable { /// public string Extract(string file) @@ -42,54 +39,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the BSP file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/BZip2.cs b/BurnOutSharp/FileType/BZip2.cs index 2442d406..022821c1 100644 --- a/BurnOutSharp/FileType/BZip2.cs +++ b/BurnOutSharp/FileType/BZip2.cs @@ -1,18 +1,15 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; using SharpCompress.Compressors; using SharpCompress.Compressors.BZip2; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// bzip2 archive /// - public class BZip2 : IExtractable, IScannable + public class BZip2 : IExtractable { /// public string Extract(string file) @@ -44,54 +41,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the BZip2 file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/CFB.cs b/BurnOutSharp/FileType/CFB.cs index 933685a8..8b56d605 100644 --- a/BurnOutSharp/FileType/CFB.cs +++ b/BurnOutSharp/FileType/CFB.cs @@ -1,18 +1,15 @@ using System; -using System.Collections.Concurrent; using System.IO; using System.Text; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; using OpenMcdf; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// Compound File Binary /// - public class CFB : IExtractable, IScannable + public class CFB : IExtractable { /// public string Extract(string file) @@ -71,56 +68,6 @@ namespace BurnOutSharp.FileType return tempPath; } - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - // TODO: Add stream opening support - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the MSI file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } - /// Adapted from LibMSI public static string DecodeStreamName(string input) { diff --git a/BurnOutSharp/FileType/GCF.cs b/BurnOutSharp/FileType/GCF.cs index e395680e..b7d1063c 100644 --- a/BurnOutSharp/FileType/GCF.cs +++ b/BurnOutSharp/FileType/GCF.cs @@ -1,16 +1,13 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// Half-Life Game Cache File /// - public class GCF : IExtractable, IScannable + public class GCF : IExtractable { /// public string Extract(string file) @@ -41,54 +38,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the GCF file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/GZIP.cs b/BurnOutSharp/FileType/GZIP.cs index bd2b2c10..d1691f9b 100644 --- a/BurnOutSharp/FileType/GZIP.cs +++ b/BurnOutSharp/FileType/GZIP.cs @@ -1,18 +1,15 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; using SharpCompress.Archives; using SharpCompress.Archives.GZip; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// gzip archive /// - public class GZIP : IExtractable, IScannable + public class GZIP : IExtractable { /// public string Extract(string file) @@ -48,54 +45,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the gzip file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/InstallShieldArchiveV3.cs b/BurnOutSharp/FileType/InstallShieldArchiveV3.cs index 453219bc..fc2a77d9 100644 --- a/BurnOutSharp/FileType/InstallShieldArchiveV3.cs +++ b/BurnOutSharp/FileType/InstallShieldArchiveV3.cs @@ -1,18 +1,15 @@ using System; -using System.Collections.Concurrent; using System.IO; using System.Linq; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; using UnshieldSharp.Archive; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// InstallShield archive v3 /// - public class InstallShieldArchiveV3 : IExtractable, IScannable + public class InstallShieldArchiveV3 : IExtractable { /// public string Extract(string file) @@ -52,55 +49,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - // TODO: Add stream opening support - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the archive itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/InstallShieldCAB.cs b/BurnOutSharp/FileType/InstallShieldCAB.cs index 12263183..91296ffb 100644 --- a/BurnOutSharp/FileType/InstallShieldCAB.cs +++ b/BurnOutSharp/FileType/InstallShieldCAB.cs @@ -1,18 +1,15 @@ using System; -using System.Collections.Concurrent; using System.IO; using System.Text.RegularExpressions; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; using UnshieldSharp.Cabinet; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// InstallShield cabinet file /// - public class InstallShieldCAB : IExtractable, IScannable + public class InstallShieldCAB : IExtractable { /// public string Extract(string file) @@ -71,55 +68,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - // TODO: Add stream opening support - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the cab file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/MPQ.cs b/BurnOutSharp/FileType/MPQ.cs index edb3d876..1deaf37b 100644 --- a/BurnOutSharp/FileType/MPQ.cs +++ b/BurnOutSharp/FileType/MPQ.cs @@ -1,19 +1,16 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; #if NET48 using StormLibSharp; #endif -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// MoPaQ game data archive /// - public class MPQ : IExtractable, IScannable + public class MPQ : IExtractable { /// public string Extract(string file) @@ -68,61 +65,6 @@ namespace BurnOutSharp.FileType } return tempPath; -#endif - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - // TODO: Add stream opening support - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { -#if NET6_0_OR_GREATER - // Not supported for .NET 6.0 due to Windows DLL requirements - return null; -#else - // If the MPQ file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; #endif } } diff --git a/BurnOutSharp/FileType/MicrosoftCAB.cs b/BurnOutSharp/FileType/MicrosoftCAB.cs index 02ede1a4..e65e3e83 100644 --- a/BurnOutSharp/FileType/MicrosoftCAB.cs +++ b/BurnOutSharp/FileType/MicrosoftCAB.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; using BinaryObjectScanner.Wrappers; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { @@ -13,7 +10,7 @@ namespace BurnOutSharp.FileType /// /// Specification available at /// - public class MicrosoftCAB : IExtractable, IScannable + public class MicrosoftCAB : IExtractable { /// public string Extract(string file) @@ -46,54 +43,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the cab file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/MicrosoftLZ.cs b/BurnOutSharp/FileType/MicrosoftLZ.cs index 1547262c..d0c52901 100644 --- a/BurnOutSharp/FileType/MicrosoftLZ.cs +++ b/BurnOutSharp/FileType/MicrosoftLZ.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.Concurrent; using System.IO; using BinaryObjectScanner.Compression; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { @@ -12,7 +9,7 @@ namespace BurnOutSharp.FileType /// Microsoft LZ-compressed Files (LZ32) /// /// This is treated like an archive type due to the packing style - public class MicrosoftLZ : IExtractable, IScannable + public class MicrosoftLZ : IExtractable { /// public string Extract(string file) @@ -57,54 +54,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the LZ file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/PAK.cs b/BurnOutSharp/FileType/PAK.cs index 9f14c592..38180fc0 100644 --- a/BurnOutSharp/FileType/PAK.cs +++ b/BurnOutSharp/FileType/PAK.cs @@ -1,16 +1,13 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// Half-Life Package File /// - public class PAK : IExtractable, IScannable + public class PAK : IExtractable { /// public string Extract(string file) @@ -41,54 +38,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the PAK file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/PFF.cs b/BurnOutSharp/FileType/PFF.cs index e75d315f..31f95716 100644 --- a/BurnOutSharp/FileType/PFF.cs +++ b/BurnOutSharp/FileType/PFF.cs @@ -1,16 +1,13 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// NovaLogic Game Archive Format /// - public class PFF : IExtractable, IScannable + public class PFF : IExtractable { /// public string Extract(string file) @@ -41,54 +38,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the PFF file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/PKZIP.cs b/BurnOutSharp/FileType/PKZIP.cs index 0d9b9248..057be339 100644 --- a/BurnOutSharp/FileType/PKZIP.cs +++ b/BurnOutSharp/FileType/PKZIP.cs @@ -1,18 +1,15 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; using SharpCompress.Archives; using SharpCompress.Archives.Zip; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// PKWARE ZIP archive and derivatives /// - public class PKZIP : IExtractable, IScannable + public class PKZIP : IExtractable { /// public string Extract(string file) @@ -49,54 +46,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the zip file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/RAR.cs b/BurnOutSharp/FileType/RAR.cs index aa558577..86e98a3a 100644 --- a/BurnOutSharp/FileType/RAR.cs +++ b/BurnOutSharp/FileType/RAR.cs @@ -1,18 +1,15 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; using SharpCompress.Archives; using SharpCompress.Archives.Rar; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// RAR archive /// - public class RAR : IExtractable, IScannable + public class RAR : IExtractable { /// public string Extract(string file) @@ -48,73 +45,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the rar file itself fails - try - { - string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); - Directory.CreateDirectory(tempPath); - - using (RarArchive rarFile = RarArchive.Open(stream)) - { - foreach (var entry in rarFile.Entries) - { - // If an individual entry fails - try - { - // If we have a directory, skip it - if (entry.IsDirectory) - continue; - - string tempFile = Path.Combine(tempPath, entry.Key); - entry.WriteToFile(tempFile); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - } - } - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/SGA.cs b/BurnOutSharp/FileType/SGA.cs index 1b0273ee..d081afc5 100644 --- a/BurnOutSharp/FileType/SGA.cs +++ b/BurnOutSharp/FileType/SGA.cs @@ -1,16 +1,13 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// SGA game archive /// - public class SGA : IExtractable, IScannable + public class SGA : IExtractable { /// public string Extract(string file) @@ -41,54 +38,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the SGA file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/SevenZip.cs b/BurnOutSharp/FileType/SevenZip.cs index f12bbd6b..06250b28 100644 --- a/BurnOutSharp/FileType/SevenZip.cs +++ b/BurnOutSharp/FileType/SevenZip.cs @@ -1,18 +1,15 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; using SharpCompress.Archives; using SharpCompress.Archives.SevenZip; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// 7-zip archive /// - public class SevenZip : IExtractable, IScannable + public class SevenZip : IExtractable { /// public string Extract(string file) @@ -48,54 +45,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the 7-zip file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/TapeArchive.cs b/BurnOutSharp/FileType/TapeArchive.cs index eade86e5..aa032995 100644 --- a/BurnOutSharp/FileType/TapeArchive.cs +++ b/BurnOutSharp/FileType/TapeArchive.cs @@ -1,18 +1,15 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; using SharpCompress.Archives; using SharpCompress.Archives.Tar; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// Tape archive /// - public class TapeArchive : IExtractable, IScannable + public class TapeArchive : IExtractable { /// public string Extract(string file) @@ -48,54 +45,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the tar file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/VBSP.cs b/BurnOutSharp/FileType/VBSP.cs index 59d4cd61..9e3f1540 100644 --- a/BurnOutSharp/FileType/VBSP.cs +++ b/BurnOutSharp/FileType/VBSP.cs @@ -1,16 +1,13 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// Half-Life 2 Level /// - public class VBSP : IExtractable, IScannable + public class VBSP : IExtractable { /// public string Extract(string file) @@ -41,54 +38,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the VBSP file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/VPK.cs b/BurnOutSharp/FileType/VPK.cs index 71119689..ae6a1f70 100644 --- a/BurnOutSharp/FileType/VPK.cs +++ b/BurnOutSharp/FileType/VPK.cs @@ -1,16 +1,13 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// Valve Package File /// - public class VPK : IExtractable, IScannable + public class VPK : IExtractable { /// public string Extract(string file) @@ -41,54 +38,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the VPK file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/WAD.cs b/BurnOutSharp/FileType/WAD.cs index ea098ed2..5db71400 100644 --- a/BurnOutSharp/FileType/WAD.cs +++ b/BurnOutSharp/FileType/WAD.cs @@ -1,16 +1,13 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// Half-Life Texture Package File /// - public class WAD : IExtractable, IScannable + public class WAD : IExtractable { /// public string Extract(string file) @@ -41,54 +38,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the WAD file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/XZ.cs b/BurnOutSharp/FileType/XZ.cs index 42aea043..0c66e1ca 100644 --- a/BurnOutSharp/FileType/XZ.cs +++ b/BurnOutSharp/FileType/XZ.cs @@ -1,17 +1,14 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; using SharpCompress.Compressors.Xz; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// xz archive /// - public class XZ : IExtractable, IScannable + public class XZ : IExtractable { /// public string Extract(string file) @@ -43,54 +40,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the xz file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/XZP.cs b/BurnOutSharp/FileType/XZP.cs index ceeab3b9..6889051f 100644 --- a/BurnOutSharp/FileType/XZP.cs +++ b/BurnOutSharp/FileType/XZP.cs @@ -1,16 +1,13 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; namespace BurnOutSharp.FileType { /// /// XBox Package File /// - public class XZP : IExtractable, IScannable + public class XZP : IExtractable { /// public string Extract(string file) @@ -41,54 +38,5 @@ namespace BurnOutSharp.FileType return tempPath; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the XZP file itself fails - try - { - // Extract and get the output path - string tempPath = Extract(stream, file); - if (tempPath == null) - return null; - - // Collect and format all found protections - var protections = scanner.GetProtections(tempPath); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - // Remove temporary path references - StripFromKeys(protections, tempPath); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/Scanner.cs b/BurnOutSharp/Scanner.cs index 1e3e3e9a..7b11099c 100644 --- a/BurnOutSharp/Scanner.cs +++ b/BurnOutSharp/Scanner.cs @@ -341,255 +341,59 @@ namespace BurnOutSharp if (fileType == SupportedFileType.UNKNOWN) return null; - // Create a scannable for the given file type - var scannable = Tools.Utilities.CreateScannable(fileType); - if (scannable == null) - return null; - #region Non-Archive File Types + // Create a scannable for the given file type + var scannable = Tools.Utilities.CreateScannable(fileType); + // If we're scanning file contents - if (ScanContents) + if (scannable != null && ScanContents) { - // AACS media key block - if (scannable is AACSMediaKeyBlock) - { - var subProtections = scannable.Scan(this, stream, fileName); - AppendToDictionary(protections, subProtections); - } - - // BD+ SVM - if (scannable is BDPlusSVM) - { - var subProtections = scannable.Scan(this, stream, fileName); - AppendToDictionary(protections, subProtections); - } - - // Executable - if (scannable is Executable) - { - var subProtections = scannable.Scan(this, stream, fileName); - AppendToDictionary(protections, subProtections); - } - - // LDSCRYPT - if (scannable is LDSCRYPT) - { - var subProtections = scannable.Scan(this, stream, fileName); - AppendToDictionary(protections, subProtections); - } - - // PLJ - if (scannable is PLJ) - { - var subProtections = scannable.Scan(this, stream, fileName); - AppendToDictionary(protections, subProtections); - } - - // SFFS - if (scannable is SFFS) - { - var subProtections = scannable.Scan(this, stream, fileName); - AppendToDictionary(protections, subProtections); - } - - // Text-based files - if (scannable is Textfile) - { - var subProtections = scannable.Scan(this, stream, fileName); - AppendToDictionary(protections, subProtections); - } + var subProtections = scannable.Scan(this, stream, fileName); + AppendToDictionary(protections, subProtections); } #endregion #region Archive File Types + // Create an extractable for the given file type + var extractable = Tools.Utilities.CreateExtractable(fileType); + // If we're scanning archives - if (ScanArchives) + if (extractable != null && ScanArchives) { - // 7-Zip archive - if (scannable is SevenZip) + // If the archive file itself fails + try { - var subProtections = scannable.Scan(this, stream, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } + // Extract and get the output path + string tempPath = extractable.Extract(stream, fileName); + if (tempPath == null) + return null; - // BFPK archive - if (scannable is BFPK) - { - var subProtections = scannable.Scan(this, stream, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } + // Collect and format all found protections + var subProtections = GetProtections(tempPath); - // BSP - if (scannable is BSP) - { - var subProtections = scannable.Scan(this, stream, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } + // If temp directory cleanup fails + try + { + Directory.Delete(tempPath, true); + } + catch (Exception ex) + { + if (IncludeDebug) Console.WriteLine(ex); + } - // BZip2 - if (scannable is BZip2) - { - var subProtections = scannable.Scan(this, stream, fileName); + // Prepare the returned protections + StripFromKeys(protections, tempPath); PrependToKeys(subProtections, fileName); AppendToDictionary(protections, subProtections); - } - // CFB - if (fileName != null && scannable is CFB) - { - var subProtections = scannable.Scan(this, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); + return protections; } - - // GCF - if (scannable is GCF) + catch (Exception ex) { - var subProtections = scannable.Scan(this, stream, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // GZIP - if (scannable is GZIP) - { - var subProtections = scannable.Scan(this, stream, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // InstallShield Archive V3 (Z) - if (fileName != null && scannable is InstallShieldArchiveV3) - { - var subProtections = scannable.Scan(this, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // InstallShield Cabinet - if (fileName != null && scannable is InstallShieldCAB) - { - var subProtections = scannable.Scan(this, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // Microsoft Cabinet - if (fileName != null && scannable is MicrosoftCAB) - { - var subProtections = scannable.Scan(this, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // Microsoft LZ - if (fileName != null && scannable is MicrosoftLZ) - { - var subProtections = scannable.Scan(this, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // MoPaQ archive - if (fileName != null && scannable is MPQ) - { - var subProtections = scannable.Scan(this, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // PAK - if (fileName != null && scannable is PAK) - { - var subProtections = scannable.Scan(this, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // PFF - if (fileName != null && scannable is PFF) - { - var subProtections = scannable.Scan(this, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // PKZIP archive (and derivatives) - if (scannable is PKZIP) - { - var subProtections = scannable.Scan(this, stream, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // RAR archive - if (scannable is RAR) - { - var subProtections = scannable.Scan(this, stream, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // SGA - if (scannable is SGA) - { - var subProtections = scannable.Scan(this, stream, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // Tape Archive - if (scannable is TapeArchive) - { - var subProtections = scannable.Scan(this, stream, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // VBSP - if (fileName != null && scannable is VBSP) - { - var subProtections = scannable.Scan(this, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // VPK - if (fileName != null && scannable is VPK) - { - var subProtections = scannable.Scan(this, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // WAD - if (scannable is WAD) - { - var subProtections = scannable.Scan(this, stream, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // XZ - if (scannable is XZ) - { - var subProtections = scannable.Scan(this, stream, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); - } - - // XZP - if (scannable is XZP) - { - var subProtections = scannable.Scan(this, stream, fileName); - PrependToKeys(subProtections, fileName); - AppendToDictionary(protections, subProtections); + if (IncludeDebug) Console.WriteLine(ex); } } diff --git a/BurnOutSharp/Tools/Utilities.cs b/BurnOutSharp/Tools/Utilities.cs index 5b738a09..d5498372 100644 --- a/BurnOutSharp/Tools/Utilities.cs +++ b/BurnOutSharp/Tools/Utilities.cs @@ -5,6 +5,7 @@ using BurnOutSharp.Interfaces; using BinaryObjectScanner.Matching; using BinaryObjectScanner.Utilities; using BinaryObjectScanner.Wrappers; +using BinaryObjectScanner.Interfaces; namespace BurnOutSharp.Tools { @@ -788,26 +789,22 @@ namespace BurnOutSharp.Tools } /// - /// Create an instance of a scannable based on file type + /// Create an instance of an extractable based on file type /// - public static IScannable CreateScannable(SupportedFileType fileType) + public static IExtractable CreateExtractable(SupportedFileType fileType) { switch (fileType) { - case SupportedFileType.AACSMediaKeyBlock: return new FileType.AACSMediaKeyBlock(); - case SupportedFileType.BDPlusSVM: return new FileType.BDPlusSVM(); case SupportedFileType.BFPK: return new FileType.BFPK(); case SupportedFileType.BSP: return new FileType.BSP(); case SupportedFileType.BZip2: return new FileType.BZip2(); case SupportedFileType.CFB: return new FileType.CFB(); //case SupportedFileType.CIA: return new FileType.CIA(); - case SupportedFileType.Executable: return new FileType.Executable(); + //case SupportedFileType.Executable: return new FileType.Executable(); case SupportedFileType.GCF: return new FileType.GCF(); case SupportedFileType.GZIP: return new FileType.GZIP(); - //case FileTypes.IniFile: return new FileType.IniFile(); case SupportedFileType.InstallShieldArchiveV3: return new FileType.InstallShieldArchiveV3(); case SupportedFileType.InstallShieldCAB: return new FileType.InstallShieldCAB(); - case SupportedFileType.LDSCRYPT: return new FileType.LDSCRYPT(); case SupportedFileType.MicrosoftCAB: return new FileType.MicrosoftCAB(); case SupportedFileType.MicrosoftLZ: return new FileType.MicrosoftLZ(); case SupportedFileType.MPQ: return new FileType.MPQ(); @@ -817,14 +814,13 @@ namespace BurnOutSharp.Tools case SupportedFileType.PAK: return new FileType.PAK(); case SupportedFileType.PFF: return new FileType.PFF(); case SupportedFileType.PKZIP: return new FileType.PKZIP(); - case SupportedFileType.PLJ: return new FileType.PLJ(); + //case SupportedFileType.PLJ: return new FileType.PLJ(); //case SupportedFileType.Quantum: return new FileType.Quantum(); case SupportedFileType.RAR: return new FileType.RAR(); case SupportedFileType.SevenZip: return new FileType.SevenZip(); case SupportedFileType.SFFS: return new FileType.SFFS(); case SupportedFileType.SGA: return new FileType.SGA(); case SupportedFileType.TapeArchive: return new FileType.TapeArchive(); - case SupportedFileType.Textfile: return new FileType.Textfile(); case SupportedFileType.VBSP: return new FileType.VBSP(); case SupportedFileType.VPK: return new FileType.VPK(); case SupportedFileType.WAD: return new FileType.WAD(); @@ -834,6 +830,29 @@ namespace BurnOutSharp.Tools } } + /// + /// Create an instance of a scannable based on file type + /// + public static IScannable CreateScannable(SupportedFileType fileType) + { + switch (fileType) + { + case SupportedFileType.AACSMediaKeyBlock: return new FileType.AACSMediaKeyBlock(); + case SupportedFileType.BDPlusSVM: return new FileType.BDPlusSVM(); + //case SupportedFileType.CIA: return new FileType.CIA(); + case SupportedFileType.Executable: return new FileType.Executable(); + //case FileTypes.IniFile: return new FileType.IniFile(); + case SupportedFileType.LDSCRYPT: return new FileType.LDSCRYPT(); + //case SupportedFileType.N3DS: return new FileType.N3DS(); + //case SupportedFileType.NCF: return new FileType.NCF(); + //case SupportedFileType.Nitro: return new FileType.Nitro(); + case SupportedFileType.PLJ: return new FileType.PLJ(); + case SupportedFileType.SFFS: return new FileType.SFFS(); + case SupportedFileType.Textfile: return new FileType.Textfile(); + default: return null; + } + } + /// /// Create an instance of a wrapper based on file type ///