mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-08 18:06:34 +00:00
Reduce unnecessary complexity
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,6 @@ namespace ProtectionScan
|
||||
var scanner = new Scanner(
|
||||
options.ScanArchives,
|
||||
options.ScanContents,
|
||||
options.ScanGameEngines,
|
||||
options.ScanPackers,
|
||||
options.ScanPaths,
|
||||
options.Debug,
|
||||
fileProgress);
|
||||
|
||||
Reference in New Issue
Block a user