Allow users to customize protection scanning

This commit is contained in:
Matt Nadareski
2021-05-06 21:47:57 -07:00
parent 818fb5ab34
commit ebaf9539b2
6 changed files with 75 additions and 7 deletions

View File

@@ -2,6 +2,7 @@
- Enum, no more
- Sony works backward
- Add experimental dark mode
- Allow users to customize protection scanning
### 2.0 (2021-04-23)
- Rename DICUI to Media Preservation Frontend (MPF)

View File

@@ -1363,7 +1363,7 @@ namespace MPF.Data
{
if (Options.ScanForProtection)
{
(bool success, string output) = await Validators.RunProtectionScanOnPath($"{Drive.Letter}:\\", progress);
(bool success, string output) = await Validators.RunProtectionScanOnPath($"{Drive.Letter}:\\", this.Options, progress);
if (success)
return output;
else

View File

@@ -329,6 +329,46 @@ namespace MPF.Data
#endregion
#region Protection Scanning Options
/// <summary>
/// Scan archive contents during protection scanning
/// </summary>
public bool ScanArchivesForProtection
{
get { return GetBooleanSetting(_settings, "ScanArchivesForProtection", true); }
set { _settings["ScanArchivesForProtection"] = value.ToString(); }
}
/// <summary>
/// Scan for executable packers during protection scanning
/// </summary>
public bool ScanPackersForProtection
{
get { return GetBooleanSetting(_settings, "ScanPackersForProtection", false); }
set { _settings["ScanPackersForProtection"] = value.ToString(); }
}
/// <summary>
/// Force scanning all files for protection
/// </summary>
public bool ForceScanningForProtection
{
get { return GetBooleanSetting(_settings, "ForceScanningForProtection", false); }
set { _settings["ForceScanningForProtection"] = value.ToString(); }
}
/// <summary>
/// Include debug information with scan results
/// </summary>
public bool IncludeDebugProtectionInformation
{
get { return GetBooleanSetting(_settings, "IncludeDebugProtectionInformation", false); }
set { _settings["IncludeDebugProtectionInformation"] = value.ToString(); }
}
#endregion
#region Logging Options
/// <summary>

View File

@@ -1023,9 +1023,10 @@ namespace MPF.Utilities
/// Run protection scan on a given dump environment
/// </summary>
/// <param name="path">Path to scan for protection</param>
/// <param name="options">Options object that determines what to scan</param>
/// <param name="progress">Optional progress callback</param>
/// <returns>TCopy protection detected in the envirionment, if any</returns>
public static async Task<(bool, string)> RunProtectionScanOnPath(string path, IProgress<ProtectionProgress> progress = null)
public static async Task<(bool, string)> RunProtectionScanOnPath(string path, Options options, IProgress<ProtectionProgress> progress = null)
{
try
{
@@ -1033,10 +1034,10 @@ namespace MPF.Utilities
{
var scanner = new Scanner(progress)
{
IncludePosition = false, // Debug flag to include protection position in file
ScanAllFiles = false, // Forces all files to be scanned as executables
ScanArchives = true, // Allows archives to have internals extracted and scanned
ScanPackers = false, // Allows executable packers to be detected
IncludePosition = options.IncludeDebugProtectionInformation,
ScanAllFiles = options.ForceScanningForProtection,
ScanArchives = options.ScanArchivesForProtection,
ScanPackers = options.ScanPackersForProtection,
};
return scanner.GetProtections(path);
});

View File

@@ -744,7 +744,7 @@ namespace MPF.Windows
var progress = new Progress<ProtectionProgress>();
progress.ProgressChanged += ProgressUpdated;
(bool success, string output) = await Validators.RunProtectionScanOnPath(drive.Letter + ":\\", progress);
(bool success, string output) = await Validators.RunProtectionScanOnPath(drive.Letter + ":\\", this.Options, progress);
// If SmartE is detected on the current disc, remove `/sf` from the flags for DIC only
if (Env.Options.InternalProgram == InternalProgram.DiscImageCreator && output.Contains("SmartE"))

View File

@@ -223,6 +223,32 @@
</StackPanel>
</TabItem>
<TabItem Header="Protection Scanning" Style="{DynamicResource CustomTabItemStyle}">
<StackPanel>
<UniformGrid Columns="2" Rows="2">
<CheckBox VerticalAlignment="Center" Content="Scan Archive Contents"
IsChecked="{Binding Options.ScanArchivesForProtection}"
ToolTip="Enable scanning archive contents during protection scanning (may drastically increase scanning time but is more accurate)" Margin="0,4"
/>
<CheckBox VerticalAlignment="Center" Content="Include Executable Packers"
IsChecked="{Binding Options.ScanPackersForProtection}"
ToolTip="Include executable packers in outputted protections" Margin="0,4"
/>
<CheckBox VerticalAlignment="Center" Content="Force Scanning All Files"
IsChecked="{Binding Options.ForceScanningForProtection}"
ToolTip="Force scanning all files even if they're not executables" Margin="0,4"
/>
<CheckBox VerticalAlignment="Center" Content="Include Debug Information"
IsChecked="{Binding Options.IncludeDebugProtectionInformation}"
ToolTip="Include debug information during protection scans" Margin="0,4"
/>
</UniformGrid>
</StackPanel>
</TabItem>
<TabItem Header="Aaru" Style="{DynamicResource CustomTabItemStyle}">
<UniformGrid Columns="2" Rows="3">
<CheckBox VerticalAlignment="Center" Content="Enable Debug Output"