From be69c52cfe60fac482a77134df5a7320f51b638d Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 10 Dec 2024 13:11:31 -0500 Subject: [PATCH] Reduce unnecessary complexity --- BinaryObjectScanner/FileType/Executable.cs | 52 --------------------- BinaryObjectScanner/Options.cs | 10 ---- BinaryObjectScanner/Packer/WiseInstaller.cs | 1 - BinaryObjectScanner/Scanner.cs | 9 ---- ProtectionScan/Options.cs | 23 --------- ProtectionScan/Program.cs | 2 - 6 files changed, 97 deletions(-) diff --git a/BinaryObjectScanner/FileType/Executable.cs b/BinaryObjectScanner/FileType/Executable.cs index e01e910d..a6dcfb1b 100644 --- a/BinaryObjectScanner/FileType/Executable.cs +++ b/BinaryObjectScanner/FileType/Executable.cs @@ -17,20 +17,6 @@ namespace BinaryObjectScanner.FileType /// public class Executable : IDetectable { - #region Properties - - /// - /// Determines if game engines are counted as detected protections or not - /// - public bool IncludeGameEngines { get; set; } - - /// - /// Determines if packers are counted as detected protections or not - /// - public bool IncludePackers { get; set; } - - #endregion - /// public string? Detect(string file, bool includeDebug) { @@ -192,14 +178,6 @@ namespace BinaryObjectScanner.FileType if (string.IsNullOrEmpty(protection)) return; - // If we are filtering on game engines - if (CheckIfGameEngine(checkClass) && !IncludeGameEngines) - return; - - // If we are filtering on packers - if (CheckIfPacker(checkClass) && !IncludePackers) - return; - protections.Append(checkClass, protection); }); @@ -230,14 +208,6 @@ namespace BinaryObjectScanner.FileType if (string.IsNullOrEmpty(protection)) return; - // If we are filtering on game engines - if (CheckIfGameEngine(checkClass) && !IncludeGameEngines) - return; - - // If we are filtering on packers - if (CheckIfPacker(checkClass) && !IncludePackers) - return; - protections.Append(checkClass, protection); }); @@ -348,27 +318,5 @@ namespace BinaryObjectScanner.FileType } #endregion - - #region Helpers - - /// - /// Check to see if an implementation is a game engine using reflection - /// - /// Implementation that was last used to check - private static bool CheckIfGameEngine(object impl) - { - return impl.GetType().Namespace?.ToLowerInvariant()?.Contains("gameengine") ?? false; - } - - /// - /// Check to see if an implementation is a packer using reflection - /// - /// Implementation that was last used to check - private static bool CheckIfPacker(object impl) - { - return impl.GetType().Namespace?.ToLowerInvariant()?.Contains("packer") ?? false; - } - - #endregion } } diff --git a/BinaryObjectScanner/Options.cs b/BinaryObjectScanner/Options.cs index 9a9af387..a10a464e 100644 --- a/BinaryObjectScanner/Options.cs +++ b/BinaryObjectScanner/Options.cs @@ -15,16 +15,6 @@ /// public bool ScanContents { get; set; } - /// - /// Determines if game engines are counted as detected protections or not - /// - public bool ScanGameEngines { get; set; } - - /// - /// Determines if packers are counted as detected protections or not - /// - public bool ScanPackers { get; set; } - /// /// Determines if path matches are used or not /// diff --git a/BinaryObjectScanner/Packer/WiseInstaller.cs b/BinaryObjectScanner/Packer/WiseInstaller.cs index f1d6b05f..bbfb38ce 100644 --- a/BinaryObjectScanner/Packer/WiseInstaller.cs +++ b/BinaryObjectScanner/Packer/WiseInstaller.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using BinaryObjectScanner.Interfaces; -using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Content; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Scanner.cs b/BinaryObjectScanner/Scanner.cs index 09028561..2ee9e9a3 100644 --- a/BinaryObjectScanner/Scanner.cs +++ b/BinaryObjectScanner/Scanner.cs @@ -30,15 +30,11 @@ namespace BinaryObjectScanner /// /// Enable scanning archive contents /// Enable including content detections in output - /// Enable including game engines in output - /// Enable including packers in output /// Enable including path detections in output /// Enable including debug information /// Optional progress callback public Scanner(bool scanArchives, bool scanContents, - bool scanGameEngines, - bool scanPackers, bool scanPaths, bool includeDebug, IProgress? fileProgress = null) @@ -47,8 +43,6 @@ namespace BinaryObjectScanner { ScanArchives = scanArchives, ScanContents = scanContents, - ScanGameEngines = scanGameEngines, - ScanPackers = scanPackers, ScanPaths = scanPaths, IncludeDebug = includeDebug, }; @@ -273,9 +267,6 @@ namespace BinaryObjectScanner // If we have an executable, it needs to bypass normal handling if (detectable is Executable executable) { - executable.IncludeGameEngines = _options.ScanGameEngines; - executable.IncludePackers = _options.ScanPackers; - var subProtections = executable.DetectDict(stream, fileName, GetProtections, _options.IncludeDebug); protections.Append(subProtections); } diff --git a/ProtectionScan/Options.cs b/ProtectionScan/Options.cs index e14a2bb0..56521c99 100644 --- a/ProtectionScan/Options.cs +++ b/ProtectionScan/Options.cs @@ -29,17 +29,6 @@ namespace ProtectionScan /// Scan file contents during protection scanning /// public bool ScanContents { get; private set; } = true; - - /// - /// Scan game engines during protection scanning - /// - public bool ScanGameEngines { get; private set; } = true; - - /// - /// Scan packers during protection scanning - /// - public bool ScanPackers { get; private set; } = true; - /// /// Scan file paths during protection scanning /// @@ -85,16 +74,6 @@ namespace ProtectionScan options.ScanContents = false; break; - case "-ng": - case "--no-game-engines": - options.ScanGameEngines = false; - break; - - case "-np": - case "--no-packers": - options.ScanPackers = false; - break; - case "-ns": case "--no-paths": options.ScanPaths = false; @@ -130,8 +109,6 @@ namespace ProtectionScan Console.WriteLine("-d, --debug Enable debug mode"); Console.WriteLine("-nc, --no-contents Disable scanning for content checks"); Console.WriteLine("-na, --no-archives Disable scanning archives"); - Console.WriteLine("-ng, --no-game-engines Disable scanning for game engines"); - Console.WriteLine("-np, --no-packers Disable scanning for packers"); Console.WriteLine("-ns, --no-paths Disable scanning for path checks"); } } diff --git a/ProtectionScan/Program.cs b/ProtectionScan/Program.cs index c45963de..fc60ef68 100644 --- a/ProtectionScan/Program.cs +++ b/ProtectionScan/Program.cs @@ -34,8 +34,6 @@ namespace ProtectionScan var scanner = new Scanner( options.ScanArchives, options.ScanContents, - options.ScanGameEngines, - options.ScanPackers, options.ScanPaths, options.Debug, fileProgress);