Update BinaryObjectScanner to 3.4.2

This commit is contained in:
Matt Nadareski
2025-09-24 13:20:29 -04:00
parent 7cf108828e
commit 51115430cb
17 changed files with 135 additions and 99 deletions

View File

@@ -30,6 +30,7 @@
- Further flesh out framework
- Add filters to handle Release Control output (Bestest)
- Cleanup last commits, add tests
- Update BinaryObjectScanner to 3.4.2
### 3.3.3 (2025-07-18)

View File

@@ -43,7 +43,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.2" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.3" />
</ItemGroup>
</Project>

View File

@@ -43,7 +43,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.2" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.3" />
</ItemGroup>
</Project>

View File

@@ -16,8 +16,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.CodeCoverage" Version="17.14.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.3" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.analyzers" Version="1.24.0" />

View File

@@ -32,7 +32,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.2" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.3" />
</ItemGroup>
</Project>

View File

@@ -16,8 +16,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.CodeCoverage" Version="17.14.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.3" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.analyzers" Version="1.24.0" />

View File

@@ -410,12 +410,7 @@ namespace MPF.Frontend
/// </summary>
/// <param name="mediaType">MediaType for specialized dumping parameters</param>
/// <param name="progress">Optional result progress callback</param>
public async Task<ResultEventArgs> Run(MediaType? mediaType,
#if NET20 || NET35 || NET40
BinaryObjectScanner.IProgress<ResultEventArgs>? progress = null)
#else
IProgress<ResultEventArgs>? progress = null)
#endif
public async Task<ResultEventArgs> Run(MediaType? mediaType, IProgress<ResultEventArgs>? progress = null)
{
// If we don't have parameters
if (_executionContext == null)
@@ -424,15 +419,9 @@ namespace MPF.Frontend
// Build default console progress indicators if none exist
if (progress == null)
{
#if NET20 || NET35 || NET40
var temp = new BinaryObjectScanner.Progress<ResultEventArgs>();
temp.ProgressChanged += ConsoleLogger.ProgressUpdated;
progress = temp;
#else
var temp = new Progress<ResultEventArgs>();
temp.ProgressChanged += ConsoleLogger.ProgressUpdated;
progress = temp;
#endif
}
// Check that we have the basics for dumping
@@ -466,13 +455,8 @@ namespace MPF.Frontend
/// <param name="seedInfo">A seed SubmissionInfo object that contains user data</param>
/// <returns>Result instance with the outcome</returns>
public async Task<ResultEventArgs> VerifyAndSaveDumpOutput(
#if NET20 || NET35 || NET40
BinaryObjectScanner.IProgress<ResultEventArgs>? resultProgress = null,
BinaryObjectScanner.IProgress<ProtectionProgress>? protectionProgress = null,
#else
IProgress<ResultEventArgs>? resultProgress = null,
IProgress<ProtectionProgress>? protectionProgress = null,
#endif
ProcessUserInfoDelegate? processUserInfo = null,
SubmissionInfo? seedInfo = null)
{
@@ -480,20 +464,6 @@ namespace MPF.Frontend
return ResultEventArgs.Failure("Error! Current configuration is not supported!");
// Build default console progress indicators if none exist
#if NET20 || NET35 || NET40
if (resultProgress == null)
{
var temp = new BinaryObjectScanner.Progress<ResultEventArgs>();
temp.ProgressChanged += ConsoleLogger.ProgressUpdated;
resultProgress = temp;
}
if (protectionProgress == null)
{
var temp = new BinaryObjectScanner.Progress<ProtectionProgress>();
temp.ProgressChanged += ConsoleLogger.ProgressUpdated;
protectionProgress = temp;
}
#else
if (resultProgress == null)
{
var temp = new Progress<ResultEventArgs>();
@@ -506,7 +476,6 @@ namespace MPF.Frontend
temp.ProgressChanged += ConsoleLogger.ProgressUpdated;
protectionProgress = temp;
}
#endif
resultProgress.Report(ResultEventArgs.Success("Gathering submission information... please wait!"));

View File

@@ -31,12 +31,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BinaryObjectScanner" Version="3.4.0" />
<PackageReference Include="BinaryObjectScanner" Version="3.4.2" />
<PackageReference Include="LibIRD" Version="1.0.0" />
<PackageReference Include="Microsoft.Management.Infrastructure" Version="3.0.0" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))" />
<PackageReference Include="Microsoft.Net.Http" Version="2.2.29" Condition="$(TargetFramework.StartsWith(`net452`))" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.2" />
<PackageReference Include="MinThreadingBridge" Version="0.11.4" Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net40`))" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.3" />
<PackageReference Include="System.Net.Http" Version="4.3.4" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))" />
</ItemGroup>

108
MPF.Frontend/Progress.cs Normal file
View File

@@ -0,0 +1,108 @@
#if NET20 || NET35 || NET40
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Threading;
using System.Diagnostics;
namespace MPF.Frontend
{
/// <summary>
/// Provides an IProgress{T} that invokes callbacks for each reported progress value.
/// </summary>
/// <typeparam name="T">Specifies the type of the progress report value.</typeparam>
/// <remarks>
/// Any handler provided to the constructor or event handlers registered with
/// the <see cref="ProgressChanged"/> event are invoked through a
/// <see cref="SynchronizationContext"/> instance captured
/// when the instance is constructed. If there is no current SynchronizationContext
/// at the time of construction, the callbacks will be invoked on the ThreadPool.
/// </remarks>
/// <see href="https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Progress.cs"/>
internal class Progress<T> : IProgress<T> where T : EventArgs
{
/// <summary>The synchronization context captured upon construction. This will never be null.</summary>
private readonly SynchronizationContext? _synchronizationContext;
/// <summary>The handler specified to the constructor. This may be null.</summary>
private readonly Action<T>? _handler;
/// <summary>A cached delegate used to post invocation to the synchronization context.</summary>
private readonly SendOrPostCallback _invokeHandlers;
/// <summary>Initializes the <see cref="Progress{T}"/>.</summary>
public Progress()
{
// Capture the current synchronization context.
// If there is no current context, we use a default instance targeting the ThreadPool.
_synchronizationContext = SynchronizationContext.Current ?? ProgressStatics.DefaultContext;
Debug.Assert(_synchronizationContext != null);
_invokeHandlers = new SendOrPostCallback(InvokeHandlers);
}
/// <summary>Initializes the <see cref="Progress{T}"/> with the specified callback.</summary>
/// <param name="handler">
/// A handler to invoke for each reported progress value. This handler will be invoked
/// in addition to any delegates registered with the <see cref="ProgressChanged"/> event.
/// Depending on the <see cref="SynchronizationContext"/> instance captured by
/// the <see cref="Progress{T}"/> at construction, it's possible that this handler instance
/// could be invoked concurrently with itself.
/// </param>
/// <exception cref="ArgumentNullException">The <paramref name="handler"/> is null (<see langword="Nothing" /> in Visual Basic).</exception>
public Progress(Action<T> handler) : this()
{
_handler = handler ?? throw new ArgumentNullException(nameof(handler));
}
/// <summary>Raised for each reported progress value.</summary>
/// <remarks>
/// Handlers registered with this event will be invoked on the
/// <see cref="SynchronizationContext"/> captured when the instance was constructed.
/// </remarks>
public event EventHandler<T>? ProgressChanged;
/// <summary>Reports a progress change.</summary>
/// <param name="value">The value of the updated progress.</param>
protected virtual void OnReport(T value)
{
// If there's no handler, don't bother going through the sync context.
// Inside the callback, we'll need to check again, in case
// an event handler is removed between now and then.
Action<T>? handler = _handler;
EventHandler<T>? changedEvent = ProgressChanged;
if (handler != null || changedEvent != null)
{
// Post the processing to the sync context.
// (If T is a value type, it will get boxed here.)
_synchronizationContext?.Post(_invokeHandlers, value);
}
}
/// <summary>Reports a progress change.</summary>
/// <param name="value">The value of the updated progress.</param>
void IProgress<T>.Report(T value) { OnReport(value); }
/// <summary>Invokes the action and event callbacks.</summary>
/// <param name="state">The progress value.</param>
private void InvokeHandlers(object? state)
{
T value = (T)state!;
Action<T>? handler = _handler;
EventHandler<T>? changedEvent = ProgressChanged;
handler?.Invoke(value);
changedEvent?.Invoke(this, value);
}
}
/// <summary>Holds static values for <see cref="Progress{T}"/>.</summary>
/// <remarks>This avoids one static instance per type T.</remarks>
internal static class ProgressStatics
{
/// <summary>A default synchronization context that targets the ThreadPool.</summary>
internal static readonly SynchronizationContext DefaultContext = new();
}
}
#endif

View File

@@ -74,11 +74,7 @@ namespace MPF.Frontend.Tools
/// <returns>Set of all detected copy protections with an optional error string</returns>
public static async Task<Dictionary<string, List<string>>> RunProtectionScanOnPath(string path,
Options options,
#if NET20 || NET35 || NET40
BinaryObjectScanner.IProgress<ProtectionProgress>? progress = null)
#else
IProgress<ProtectionProgress>? progress = null)
#endif
{
#if NET40
var found = await Task.Factory.StartNew(() =>

View File

@@ -48,13 +48,8 @@ namespace MPF.Frontend.Tools
MediaType? mediaType,
Options options,
BaseProcessor processor,
#if NET20 || NET35 || NET40
BinaryObjectScanner.IProgress<ResultEventArgs>? resultProgress = null,
BinaryObjectScanner.IProgress<ProtectionProgress>? protectionProgress = null)
#else
IProgress<ResultEventArgs>? resultProgress = null,
IProgress<ProtectionProgress>? protectionProgress = null)
#endif
{
// Split the output path for easier use
var outputDirectory = Path.GetDirectoryName(outputPath);
@@ -159,11 +154,7 @@ namespace MPF.Frontend.Tools
/// <param name="resultProgress">Optional result progress callback</param>
public async static Task<bool> FillFromRedump(Options options,
SubmissionInfo info,
#if NET20 || NET35 || NET40
BinaryObjectScanner.IProgress<ResultEventArgs>? resultProgress = null)
#else
IProgress<ResultEventArgs>? resultProgress = null)
#endif
{
// If information should not be pulled at all
if (!options.RetrieveMatchInformation)
@@ -1041,14 +1032,7 @@ namespace MPF.Frontend.Tools
/// <summary>
/// Set a content field if it doesn't already have a value
/// </summary>
private static void SetContentFieldIfNotExists(SubmissionInfo info,
SiteCode key,
Drive? drive,
#if NET20
BinaryObjectScanner.Func<Drive?, string?> valueFunc)
#else
Func<Drive?, string?> valueFunc)
#endif
private static void SetContentFieldIfNotExists(SubmissionInfo info, SiteCode key, Drive? drive, Func<Drive?, string?> valueFunc)
{
// If the field has a valid value, skip
if (ContentFieldExists(info, key, out _))
@@ -1063,13 +1047,7 @@ namespace MPF.Frontend.Tools
/// <summary>
/// Set the version if it doesn't already have a value
/// </summary>
private static void SetVersionIfNotExists(SubmissionInfo info,
Drive? drive,
#if NET20
BinaryObjectScanner.Func<Drive?, string?> valueFunc)
#else
Func<Drive?, string?> valueFunc)
#endif
private static void SetVersionIfNotExists(SubmissionInfo info, Drive? drive, Func<Drive?, string?> valueFunc)
{
// If the version already exists, skip
if (!string.IsNullOrEmpty(info.VersionAndEditions!.Version))

View File

@@ -407,17 +407,10 @@ namespace MPF.Frontend.ViewModels
DisableEventHandlers();
// Get progress indicators
#if NET20 || NET35 || NET40
var resultProgress = new BinaryObjectScanner.Progress<ResultEventArgs>();
resultProgress.ProgressChanged += ProgressUpdated;
var protectionProgress = new BinaryObjectScanner.Progress<ProtectionProgress>();
protectionProgress.ProgressChanged += ProgressUpdated;
#else
var resultProgress = new Progress<ResultEventArgs>();
resultProgress.ProgressChanged += ProgressUpdated;
var protectionProgress = new Progress<ProtectionProgress>();
protectionProgress.ProgressChanged += ProgressUpdated;
#endif
// Populate an environment
var env = new DumpEnvironment(Options,

View File

@@ -53,11 +53,7 @@ namespace MPF.Frontend.ViewModels
/// T4 - true for inquiry, false otherwise
/// TResult - true for positive, false for negative, null for neutral
/// </remarks>
#if NET20
private BinaryObjectScanner.Func<string, string, int, bool, bool?>? _displayUserMessage;
#else
private Func<string, string, int, bool, bool?>? _displayUserMessage;
#endif
/// <summary>
/// Detected media type, distinct from the selected one
@@ -599,11 +595,7 @@ namespace MPF.Frontend.ViewModels
/// </summary>
public void Init(
Action<LogLevel, string> loggerAction,
#if NET20
BinaryObjectScanner.Func<string, string, int, bool, bool?> displayUserMessage,
#else
Func<string, string, int, bool, bool?> displayUserMessage,
#endif
ProcessUserInfoDelegate processUserInfo)
{
// Set the callbacks

View File

@@ -26,8 +26,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.CodeCoverage" Version="17.14.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.3" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.analyzers" Version="1.24.0" />

View File

@@ -34,11 +34,10 @@
<ItemGroup>
<PackageReference Include="SabreTools.Hashing" Version="1.5.0" />
<PackageReference Include="SabreTools.IO" Version="1.7.3" />
<PackageReference Include="SabreTools.Matching" Version="1.6.0" />
<PackageReference Include="SabreTools.Models" Version="1.7.1" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.2" />
<PackageReference Include="SabreTools.Serialization" Version="1.9.5" />
<PackageReference Include="SabreTools.IO" Version="1.7.5" />
<PackageReference Include="SabreTools.Models" Version="1.7.2" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.3" />
<PackageReference Include="SabreTools.Serialization" Version="1.9.6" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`))" />
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.9" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))" />

View File

@@ -10,7 +10,6 @@ using System.Xml.Schema;
using System.Xml.Serialization;
using SabreTools.Hashing;
using SabreTools.IO.Extensions;
using SabreTools.Matching;
using SabreTools.Models.Logiqx;
using SabreTools.Models.PIC;
using SabreTools.RedumpLib.Data;
@@ -1074,7 +1073,7 @@ namespace MPF.Processors
// Only continue to check SSv2 for XGD3
if (xgdType != 3)
return true;
// Determine if XGD3 SS.bin is SSv1 (Original Kreon) or SSv2 (0800 / Repaired Kreon)
#if NET20
var checkArr = new byte[72];
@@ -1126,8 +1125,8 @@ namespace MPF.Processors
else if (xgdType == 3)
ccrt_offset = 0x20;
int[] entry_offsets = {0, 9, 18, 27, 36, 45, 54, 63};
int[] entry_lengths = {8, 8, 8, 8, 4, 4, 4, 4};
int[] entry_offsets = { 0, 9, 18, 27, 36, 45, 54, 63 };
int[] entry_lengths = { 8, 8, 8, 8, 4, 4, 4, 4 };
for (int i = 0; i < entry_offsets.Length; i++)
{
bool emptyResponse = true;
@@ -1289,7 +1288,7 @@ namespace MPF.Processors
// Determine XGD type
if (!GetXGDType(ss, out int xgdType))
return false;
// Determine if XGD3 SS.bin is SSv1 (Original Kreon) or SSv2 (0800 / Repaired Kreon)
#if NET20
var checkArr = new byte[72];
@@ -1300,7 +1299,7 @@ namespace MPF.Processors
#endif
// Do not produce an SS hash for bad SS (SSv1 XGD3 / Unrepaired Kreon SS)
if(xgdType == 3 && !ssv2)
if (xgdType == 3 && !ssv2)
return false;
switch (xgdType)

View File

@@ -70,7 +70,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.2" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.3" />
</ItemGroup>
<ItemGroup>