From 8c2bedd21e464011e368446ea1401a8d6c0bdc32 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 2 Mar 2022 10:17:50 -0800 Subject: [PATCH] Add test program parameters --- BurnOutSharp/Scanner.cs | 4 ++ Test/Program.cs | 87 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 85 insertions(+), 6 deletions(-) diff --git a/BurnOutSharp/Scanner.cs b/BurnOutSharp/Scanner.cs index 9815e6f9..595734dc 100644 --- a/BurnOutSharp/Scanner.cs +++ b/BurnOutSharp/Scanner.cs @@ -25,6 +25,10 @@ namespace BurnOutSharp /// /// Determines whether all files are scanned or just executables are /// + /// + /// With the improvements to executable scannning, this should probably be removed in + /// a future update. + /// public bool ScanAllFiles { get; set; } = false; /// diff --git a/Test/Program.cs b/Test/Program.cs index ff93a57a..c3028d52 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -14,25 +14,100 @@ namespace Test var p = new Progress(); p.ProgressChanged += Changed; + // Set initial values for scanner flags + bool debug = false, allFiles = false, archives = true, packers = true; + + // Loop through the arguments to get the flags + int start; + for (start = 0; start < args.Length; start++) + { + bool breakout = false; + + switch (args[start]) + { + case "-?": + case "-h": + case "--help": + DisplayHelp(); + Console.WriteLine("Press enter to close the program..."); + Console.ReadLine(); + return; + + case "-d": + case "--debug": + debug = true; + break; + + case "-a": + case "--all-files": + allFiles = true; + break; + + case "-na": + case "--no-archives": + archives = false; + break; + + case "-np": + case "--no-packers": + packers = false; + break; + + default: + breakout = true; + break; + } + + // If we're breaking out of the loop, do so + if (breakout) + break; + } + + // If we have no arguments, show the help + if (start >= args.Length - 1) + { + DisplayHelp(); + Console.WriteLine("Press enter to close the program..."); + Console.ReadLine(); + return; + } + // Create scanner for all paths var scanner = new Scanner(p) { - IncludeDebug = true, - ScanAllFiles = false, - ScanArchives = true, - ScanPackers = true, + IncludeDebug = debug, + ScanAllFiles = allFiles, + ScanArchives = archives, + ScanPackers = packers, }; // Loop through the input paths - foreach (string arg in args) + for (int i = start; i < args.Length; i++) { - GetAndWriteProtections(scanner, arg); + GetAndWriteProtections(scanner, args[i]); } Console.WriteLine("Press enter to close the program..."); Console.ReadLine(); } + /// + /// Display help text + /// + private static void DisplayHelp() + { + Console.WriteLine("BurnOutSharp Test Program"); + Console.WriteLine(); + Console.WriteLine("test.exe file|directory ..."); + Console.WriteLine(); + Console.WriteLine("Possible options:"); + Console.WriteLine("-?, -h, --help Display this help text and quit"); + Console.WriteLine("-d, --debug Enable debug mode"); + Console.WriteLine("-a, --all-files Force scanning all files"); + Console.WriteLine("-na, --no-archives Disable scanning archives"); + Console.WriteLine("-np, --no-packers Disable scanning for packers"); + } + /// /// Wrapper to get and log protections for a single path ///