Reduce unnecessary complexity

This commit is contained in:
Matt Nadareski
2024-12-10 13:11:31 -05:00
parent 6fdbdd9f09
commit be69c52cfe
6 changed files with 0 additions and 97 deletions

View File

@@ -17,20 +17,6 @@ namespace BinaryObjectScanner.FileType
/// </summary>
public class Executable : IDetectable
{
#region Properties
/// <summary>
/// Determines if game engines are counted as detected protections or not
/// </summary>
public bool IncludeGameEngines { get; set; }
/// <summary>
/// Determines if packers are counted as detected protections or not
/// </summary>
public bool IncludePackers { get; set; }
#endregion
/// <inheritdoc/>
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
/// <summary>
/// Check to see if an implementation is a game engine using reflection
/// </summary>
/// <param name="impl">Implementation that was last used to check</param>
private static bool CheckIfGameEngine(object impl)
{
return impl.GetType().Namespace?.ToLowerInvariant()?.Contains("gameengine") ?? false;
}
/// <summary>
/// Check to see if an implementation is a packer using reflection
/// </summary>
/// <param name="impl">Implementation that was last used to check</param>
private static bool CheckIfPacker(object impl)
{
return impl.GetType().Namespace?.ToLowerInvariant()?.Contains("packer") ?? false;
}
#endregion
}
}

View File

@@ -15,16 +15,6 @@
/// </summary>
public bool ScanContents { get; set; }
/// <summary>
/// Determines if game engines are counted as detected protections or not
/// </summary>
public bool ScanGameEngines { get; set; }
/// <summary>
/// Determines if packers are counted as detected protections or not
/// </summary>
public bool ScanPackers { get; set; }
/// <summary>
/// Determines if path matches are used or not
/// </summary>

View File

@@ -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;

View File

@@ -30,15 +30,11 @@ namespace BinaryObjectScanner
/// </summary>
/// <param name="scanArchives">Enable scanning archive contents</param>
/// <param name="scanContents">Enable including content detections in output</param>
/// <param name="scanGameEngines">Enable including game engines in output</param>
/// <param name="scanPackers">Enable including packers in output</param>
/// <param name="scanPaths">Enable including path detections in output</param>
/// <param name="includeDebug">Enable including debug information</param>
/// <param name="fileProgress">Optional progress callback</param>
public Scanner(bool scanArchives,
bool scanContents,
bool scanGameEngines,
bool scanPackers,
bool scanPaths,
bool includeDebug,
IProgress<ProtectionProgress>? 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);
}

View File

@@ -29,17 +29,6 @@ namespace ProtectionScan
/// Scan file contents during protection scanning
/// </summary>
public bool ScanContents { get; private set; } = true;
/// <summary>
/// Scan game engines during protection scanning
/// </summary>
public bool ScanGameEngines { get; private set; } = true;
/// <summary>
/// Scan packers during protection scanning
/// </summary>
public bool ScanPackers { get; private set; } = true;
/// <summary>
/// Scan file paths during protection scanning
/// </summary>
@@ -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");
}
}

View File

@@ -34,8 +34,6 @@ namespace ProtectionScan
var scanner = new Scanner(
options.ScanArchives,
options.ScanContents,
options.ScanGameEngines,
options.ScanPackers,
options.ScanPaths,
options.Debug,
fileProgress);