mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-18 14:55:05 +00:00
Handle more C# 12 syntax
This commit is contained in:
@@ -54,6 +54,21 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Support for old .NET versions -->
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net40`))">
|
||||
<PackageReference Include="Microsoft.Bcl" Version="1.1.10" />
|
||||
<PackageReference Include="Microsoft.Bcl.Async" Version="1.0.168" />
|
||||
<PackageReference Include="Microsoft.Bcl.Build" Version="1.0.21" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="!$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))">
|
||||
<PackageReference Include="SharpCompress" Version="0.34.1" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.4.2" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net4`)) AND !$(TargetFramework.StartsWith(`net40`))">
|
||||
<PackageReference Include="System.Memory" Version="4.5.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OpenMcdf" Version="2.3.0" />
|
||||
<PackageReference Include="SabreTools.Compression" Version="0.2.0" />
|
||||
@@ -65,18 +80,4 @@
|
||||
<PackageReference Include="WiseUnpacker" Version="1.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net40`))">
|
||||
<PackageReference Include="Microsoft.Bcl" Version="1.1.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="!$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))">
|
||||
<PackageReference Include="SharpCompress" Version="0.34.1" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.4.2" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net4`)) AND !$(TargetFramework.StartsWith(`net40`))">
|
||||
<PackageReference Include="System.Memory" Version="4.5.5" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -40,9 +40,7 @@ namespace BinaryObjectScanner.FileType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (contentCheckClasses == null)
|
||||
contentCheckClasses = InitCheckClasses<IContentCheck>();
|
||||
|
||||
contentCheckClasses ??= InitCheckClasses<IContentCheck>();
|
||||
return contentCheckClasses ?? Enumerable.Empty<IContentCheck>();
|
||||
}
|
||||
}
|
||||
@@ -54,9 +52,7 @@ namespace BinaryObjectScanner.FileType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (linearExecutableCheckClasses == null)
|
||||
linearExecutableCheckClasses = InitCheckClasses<ILinearExecutableCheck>();
|
||||
|
||||
linearExecutableCheckClasses ??= InitCheckClasses<ILinearExecutableCheck>();
|
||||
return linearExecutableCheckClasses ?? Enumerable.Empty<ILinearExecutableCheck>();
|
||||
}
|
||||
}
|
||||
@@ -68,9 +64,7 @@ namespace BinaryObjectScanner.FileType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (msdosExecutableCheckClasses == null)
|
||||
msdosExecutableCheckClasses = InitCheckClasses<IMSDOSExecutableCheck>();
|
||||
|
||||
msdosExecutableCheckClasses ??= InitCheckClasses<IMSDOSExecutableCheck>();
|
||||
return msdosExecutableCheckClasses ?? Enumerable.Empty<IMSDOSExecutableCheck>();
|
||||
}
|
||||
}
|
||||
@@ -82,9 +76,7 @@ namespace BinaryObjectScanner.FileType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (newExecutableCheckClasses == null)
|
||||
newExecutableCheckClasses = InitCheckClasses<INewExecutableCheck>();
|
||||
|
||||
newExecutableCheckClasses ??= InitCheckClasses<INewExecutableCheck>();
|
||||
return newExecutableCheckClasses ?? Enumerable.Empty<INewExecutableCheck>();
|
||||
}
|
||||
}
|
||||
@@ -96,9 +88,7 @@ namespace BinaryObjectScanner.FileType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (portableExecutableCheckClasses == null)
|
||||
portableExecutableCheckClasses = InitCheckClasses<IPortableExecutableCheck>();
|
||||
|
||||
portableExecutableCheckClasses ??= InitCheckClasses<IPortableExecutableCheck>();
|
||||
return portableExecutableCheckClasses ?? Enumerable.Empty<IPortableExecutableCheck>();
|
||||
}
|
||||
}
|
||||
@@ -140,10 +130,8 @@ namespace BinaryObjectScanner.FileType
|
||||
if (!File.Exists(file))
|
||||
return null;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
return Detect(fs, file, includeDebug);
|
||||
}
|
||||
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
return Detect(fs, file, includeDebug);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -211,19 +199,17 @@ namespace BinaryObjectScanner.FileType
|
||||
return null;
|
||||
|
||||
// Read the file contents
|
||||
byte[] fileContent = new byte[0];
|
||||
byte[] fileContent = [];
|
||||
try
|
||||
{
|
||||
#if NET40
|
||||
using (BinaryReader br = new BinaryReader(stream, Encoding.Default))
|
||||
using var br = new BinaryReader(stream, Encoding.Default);
|
||||
#else
|
||||
using (BinaryReader br = new BinaryReader(stream, Encoding.Default, true))
|
||||
using var br = new BinaryReader(stream, Encoding.Default, true);
|
||||
#endif
|
||||
{
|
||||
fileContent = br.ReadBytes((int)stream.Length);
|
||||
if (fileContent == null)
|
||||
return null;
|
||||
}
|
||||
fileContent = br.ReadBytes((int)stream.Length);
|
||||
if (fileContent == null)
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -50,10 +50,7 @@ namespace System
|
||||
/// <exception cref="ArgumentNullException">The <paramref name="handler"/> is null (<see langword="Nothing" /> in Visual Basic).</exception>
|
||||
public Progress(Action<T> handler) : this()
|
||||
{
|
||||
if (handler == null)
|
||||
throw new ArgumentNullException(nameof(handler));
|
||||
|
||||
_handler = handler;
|
||||
_handler = handler ?? throw new ArgumentNullException(nameof(handler));
|
||||
}
|
||||
|
||||
/// <summary>Raised for each reported progress value.</summary>
|
||||
@@ -103,7 +100,7 @@ namespace System
|
||||
internal static class ProgressStatics
|
||||
{
|
||||
/// <summary>A default synchronization context that targets the ThreadPool.</summary>
|
||||
internal static readonly SynchronizationContext DefaultContext = new SynchronizationContext();
|
||||
internal static readonly SynchronizationContext DefaultContext = new();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,7 @@ namespace Test
|
||||
/// <summary>
|
||||
/// Set of input paths to use for operations
|
||||
/// </summary>
|
||||
public List<string> InputPaths { get; private set; } = new List<string>();
|
||||
public List<string> InputPaths { get; private set; } = [];
|
||||
|
||||
#region Extraction
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Test
|
||||
/// <summary>
|
||||
/// Parse commandline arguments into an Options object
|
||||
/// </summary>
|
||||
public static Options ParseOptions(string[] args)
|
||||
public static Options? ParseOptions(string[] args)
|
||||
{
|
||||
// If we have invalid arguments
|
||||
if (args == null || args.Length == 0)
|
||||
@@ -154,7 +154,7 @@ namespace Test
|
||||
|
||||
case "-o":
|
||||
case "--outdir":
|
||||
options.OutputPath = index + 1 < args.Length ? args[++index] : null;
|
||||
options.OutputPath = index + 1 < args.Length ? args[++index] : string.Empty;
|
||||
break;
|
||||
|
||||
#endregion
|
||||
|
||||
193
Test/Printer.cs
193
Test/Printer.cs
@@ -45,39 +45,39 @@ namespace Test
|
||||
{
|
||||
Console.WriteLine($"Attempting to print info for {file}");
|
||||
|
||||
using (Stream stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
using Stream stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
|
||||
// Read the first 8 bytes
|
||||
byte[]? magic = stream.ReadBytes(8);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
// Get the file type
|
||||
SupportedFileType ft = FileTypes.GetFileType(magic ?? []);
|
||||
if (ft == SupportedFileType.UNKNOWN)
|
||||
{
|
||||
// Read the first 8 bytes
|
||||
byte[] magic = stream.ReadBytes(8);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
string extension = Path.GetExtension(file).TrimStart('.');
|
||||
ft = FileTypes.GetFileType(extension);
|
||||
}
|
||||
|
||||
// Get the file type
|
||||
SupportedFileType ft = FileTypes.GetFileType(magic);
|
||||
if (ft == SupportedFileType.UNKNOWN)
|
||||
{
|
||||
string extension = Path.GetExtension(file).TrimStart('.');
|
||||
ft = FileTypes.GetFileType(extension);
|
||||
}
|
||||
// Print out the file format
|
||||
Console.WriteLine($"File format found: {ft}");
|
||||
|
||||
// Print out the file format
|
||||
Console.WriteLine($"File format found: {ft}");
|
||||
// Setup the wrapper to print
|
||||
var wrapper = WrapperFactory.CreateWrapper(ft, stream);
|
||||
|
||||
// Setup the wrapper to print
|
||||
var wrapper = WrapperFactory.CreateWrapper(ft, stream);
|
||||
// If we don't have a wrapper
|
||||
if (wrapper == null)
|
||||
{
|
||||
Console.WriteLine($"Either {ft} is not supported or something went wrong during parsing!");
|
||||
Console.WriteLine();
|
||||
return;
|
||||
}
|
||||
|
||||
// If we don't have a wrapper
|
||||
if (wrapper == null)
|
||||
{
|
||||
Console.WriteLine($"Either {ft} is not supported or something went wrong during parsing!");
|
||||
Console.WriteLine();
|
||||
return;
|
||||
}
|
||||
// Print the wrapper name
|
||||
Console.WriteLine($"{wrapper.Description()} wrapper created successfully!");
|
||||
|
||||
// Print the wrapper name
|
||||
Console.WriteLine($"{wrapper.Description()} wrapper created successfully!");
|
||||
|
||||
// Get the base info output name
|
||||
string filenameBase = $"info-{DateTime.Now:yyyy-MM-dd_HHmmss.ffff}";
|
||||
// Get the base info output name
|
||||
string filenameBase = $"info-{DateTime.Now:yyyy-MM-dd_HHmmss.ffff}";
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
// If we have the JSON flag
|
||||
@@ -88,22 +88,17 @@ namespace Test
|
||||
Console.WriteLine(serializedData);
|
||||
|
||||
// Write the output data
|
||||
using (var sw = new StreamWriter(File.OpenWrite($"{filenameBase}.json")))
|
||||
{
|
||||
sw.WriteLine(serializedData);
|
||||
}
|
||||
using var jsw = new StreamWriter(File.OpenWrite($"{filenameBase}.json"));
|
||||
jsw.WriteLine(serializedData);
|
||||
}
|
||||
#endif
|
||||
// Create the output data
|
||||
StringBuilder builder = wrapper.PrettyPrint();
|
||||
Console.WriteLine(builder);
|
||||
// Create the output data
|
||||
var builder = wrapper.PrettyPrint();
|
||||
Console.WriteLine(builder);
|
||||
|
||||
// Write the output data
|
||||
using (var sw = new StreamWriter(File.OpenWrite($"{filenameBase}.txt")))
|
||||
{
|
||||
sw.WriteLine(builder.ToString());
|
||||
}
|
||||
}
|
||||
// Write the output data
|
||||
using var sw = new StreamWriter(File.OpenWrite($"{filenameBase}.txt"));
|
||||
sw.WriteLine(builder.ToString());
|
||||
}
|
||||
|
||||
#region Printing Implementations
|
||||
@@ -113,38 +108,38 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this IWrapper wrapper)
|
||||
{
|
||||
switch (wrapper)
|
||||
return wrapper switch
|
||||
{
|
||||
case AACSMediaKeyBlock item: return item.PrettyPrint();
|
||||
case BDPlusSVM item: return item.PrettyPrint();
|
||||
case BFPK item: return item.PrettyPrint();
|
||||
case BSP item: return item.PrettyPrint();
|
||||
case CFB item: return item.PrettyPrint();
|
||||
case CIA item: return item.PrettyPrint();
|
||||
case GCF item: return item.PrettyPrint();
|
||||
case InstallShieldCabinet item: return item.PrettyPrint();
|
||||
case IRD item: return item.PrettyPrint();
|
||||
case LinearExecutable item: return item.PrettyPrint();
|
||||
case MicrosoftCabinet item: return item.PrettyPrint();
|
||||
case MSDOS item: return item.PrettyPrint();
|
||||
case N3DS item: return item.PrettyPrint();
|
||||
case NCF item: return item.PrettyPrint();
|
||||
case NewExecutable item: return item.PrettyPrint();
|
||||
case Nitro item: return item.PrettyPrint();
|
||||
case PAK item: return item.PrettyPrint();
|
||||
case PFF item: return item.PrettyPrint();
|
||||
case PlayJAudioFile item: return item.PrettyPrint();
|
||||
case PortableExecutable item: return item.PrettyPrint();
|
||||
case Quantum item: return item.PrettyPrint();
|
||||
case SGA item: return item.PrettyPrint();
|
||||
case VBSP item: return item.PrettyPrint();
|
||||
case VPK item: return item.PrettyPrint();
|
||||
case WAD item: return item.PrettyPrint();
|
||||
case XeMID item: return item.PrettyPrint();
|
||||
case XMID item: return item.PrettyPrint();
|
||||
case XZP item: return item.PrettyPrint();
|
||||
default: return new StringBuilder();
|
||||
}
|
||||
AACSMediaKeyBlock item => item.PrettyPrint(),
|
||||
BDPlusSVM item => item.PrettyPrint(),
|
||||
BFPK item => item.PrettyPrint(),
|
||||
BSP item => item.PrettyPrint(),
|
||||
CFB item => item.PrettyPrint(),
|
||||
CIA item => item.PrettyPrint(),
|
||||
GCF item => item.PrettyPrint(),
|
||||
InstallShieldCabinet item => item.PrettyPrint(),
|
||||
IRD item => item.PrettyPrint(),
|
||||
LinearExecutable item => item.PrettyPrint(),
|
||||
MicrosoftCabinet item => item.PrettyPrint(),
|
||||
MSDOS item => item.PrettyPrint(),
|
||||
N3DS item => item.PrettyPrint(),
|
||||
NCF item => item.PrettyPrint(),
|
||||
NewExecutable item => item.PrettyPrint(),
|
||||
Nitro item => item.PrettyPrint(),
|
||||
PAK item => item.PrettyPrint(),
|
||||
PFF item => item.PrettyPrint(),
|
||||
PlayJAudioFile item => item.PrettyPrint(),
|
||||
PortableExecutable item => item.PrettyPrint(),
|
||||
Quantum item => item.PrettyPrint(),
|
||||
SGA item => item.PrettyPrint(),
|
||||
VBSP item => item.PrettyPrint(),
|
||||
VPK item => item.PrettyPrint(),
|
||||
WAD item => item.PrettyPrint(),
|
||||
XeMID item => item.PrettyPrint(),
|
||||
XMID item => item.PrettyPrint(),
|
||||
XZP item => item.PrettyPrint(),
|
||||
_ => new StringBuilder(),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -152,7 +147,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this AACSMediaKeyBlock item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.AACSMediaKeyBlock.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -162,7 +157,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this BDPlusSVM item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.BDPlusSVM.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -172,7 +167,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this BFPK item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.BFPK.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -182,7 +177,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this BSP item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.BSP.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -192,7 +187,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this CFB item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.CFB.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -202,7 +197,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this CIA item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.CIA.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -212,7 +207,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this GCF item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.GCF.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -222,7 +217,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this InstallShieldCabinet item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.InstallShieldCabinet.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -232,7 +227,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this IRD item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.IRD.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -242,7 +237,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this LinearExecutable item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.LinearExecutable.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -252,7 +247,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this MicrosoftCabinet item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.MicrosoftCabinet.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -262,7 +257,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this MSDOS item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.MSDOS.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -272,7 +267,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this N3DS item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.N3DS.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -282,7 +277,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this NCF item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.NCF.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -292,7 +287,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this NewExecutable item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.NewExecutable.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -302,7 +297,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Nitro item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.Nitro.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -312,7 +307,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this PAK item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.PAK.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -322,7 +317,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this PFF item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.PFF.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -332,7 +327,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this PlayJAudioFile item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.PlayJAudioFile.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -342,7 +337,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this PortableExecutable item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.PortableExecutable.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -352,7 +347,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Quantum item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.Quantum.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -362,7 +357,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this SGA item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.SGA.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -372,7 +367,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this VBSP item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.VBSP.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -382,7 +377,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this VPK item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.VPK.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -392,7 +387,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this WAD item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.WAD.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -402,7 +397,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this XeMID item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.XeMID.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -412,7 +407,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this XMID item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.XMID.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
@@ -422,7 +417,7 @@ namespace Test
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this XZP item)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
SabreTools.Printing.XZP.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using BinaryObjectScanner;
|
||||
|
||||
namespace Test
|
||||
@@ -8,9 +7,9 @@ namespace Test
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
#if NET462_OR_GREATER
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
// Register the codepages
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
#endif
|
||||
|
||||
// Create progress indicator
|
||||
|
||||
@@ -29,10 +29,8 @@ namespace Test
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(File.OpenWrite($"exception-{DateTime.Now:yyyy-MM-dd_HHmmss.ffff}.txt")))
|
||||
{
|
||||
sw.WriteLine(ex);
|
||||
}
|
||||
using var sw = new StreamWriter(File.OpenWrite($"exception-{DateTime.Now:yyyy-MM-dd_HHmmss.ffff}.txt"));
|
||||
sw.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +39,7 @@ namespace Test
|
||||
/// </summary>
|
||||
/// <param name="path">File or directory path</param>
|
||||
/// <param name="protections">Dictionary of protections found, if any</param>
|
||||
private static void WriteProtectionResultFile(string path, ConcurrentDictionary<string, ConcurrentQueue<string>> protections)
|
||||
private static void WriteProtectionResultFile(string path, ConcurrentDictionary<string, ConcurrentQueue<string>>? protections)
|
||||
{
|
||||
if (protections == null)
|
||||
{
|
||||
@@ -49,25 +47,23 @@ namespace Test
|
||||
return;
|
||||
}
|
||||
|
||||
using (var sw = new StreamWriter(File.OpenWrite($"protection-{DateTime.Now:yyyy-MM-dd_HHmmss.ffff}.txt")))
|
||||
using var sw = new StreamWriter(File.OpenWrite($"protection-{DateTime.Now:yyyy-MM-dd_HHmmss.ffff}.txt"));
|
||||
foreach (string key in protections.Keys.OrderBy(k => k))
|
||||
{
|
||||
foreach (string key in protections.Keys.OrderBy(k => k))
|
||||
{
|
||||
// Skip over files with no protection
|
||||
if (protections[key] == null || !protections[key].Any())
|
||||
continue;
|
||||
// Skip over files with no protection
|
||||
if (protections[key] == null || !protections[key].Any())
|
||||
continue;
|
||||
|
||||
string line = $"{key}: {string.Join(", ", protections[key].OrderBy(p => p))}";
|
||||
Console.WriteLine(line);
|
||||
sw.WriteLine(line);
|
||||
}
|
||||
string line = $"{key}: {string.Join(", ", protections[key].OrderBy(p => p))}";
|
||||
Console.WriteLine(line);
|
||||
sw.WriteLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Protection progress changed handler
|
||||
/// </summary>
|
||||
public static void Changed(object source, ProtectionProgress value)
|
||||
public static void Changed(object? source, ProtectionProgress value)
|
||||
{
|
||||
Console.WriteLine($"{value.Percentage * 100:N2}%: {value.Filename} - {value.Protection}");
|
||||
}
|
||||
|
||||
@@ -4,13 +4,23 @@
|
||||
<TargetFrameworks>net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
||||
<OutputType>Exe</OutputType>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BinaryObjectScanner\BinaryObjectScanner.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Support for old .NET versions -->
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net40`))">
|
||||
<PackageReference Include="Microsoft.Bcl" Version="1.1.10" />
|
||||
<PackageReference Include="Microsoft.Bcl.Async" Version="1.0.168" />
|
||||
<PackageReference Include="Microsoft.Bcl.Build" Version="1.0.21" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OpenMcdf" Version="2.3.0" />
|
||||
<PackageReference Include="SabreTools.Compression" Version="0.2.0" />
|
||||
@@ -22,14 +32,4 @@
|
||||
<PackageReference Include="UnshieldSharp" Version="1.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net40`))">
|
||||
<PackageReference Include="Microsoft.Bcl" Version="1.1.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="App.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user