diff --git a/BinaryObjectScanner/BinaryObjectScanner.csproj b/BinaryObjectScanner/BinaryObjectScanner.csproj
index b142f3b7..14cd9c31 100644
--- a/BinaryObjectScanner/BinaryObjectScanner.csproj
+++ b/BinaryObjectScanner/BinaryObjectScanner.csproj
@@ -2,7 +2,7 @@
- net48;net6.0;net7.0
+ net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0
win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64
true
latest
@@ -32,7 +32,7 @@
-
+
$(DefaultItemExcludes);
_EXTERNAL\**;
@@ -40,7 +40,7 @@
-
+
true
contentFiles;content
@@ -55,19 +55,22 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
+
diff --git a/BinaryObjectScanner/FileType/BFPK.cs b/BinaryObjectScanner/FileType/BFPK.cs
index 80078a58..41c103af 100644
--- a/BinaryObjectScanner/FileType/BFPK.cs
+++ b/BinaryObjectScanner/FileType/BFPK.cs
@@ -1,8 +1,10 @@
using System;
using System.IO;
using BinaryObjectScanner.Interfaces;
+#if NET462_OR_GREATER
using SharpCompress.Compressors;
using SharpCompress.Compressors.Deflate;
+#endif
namespace BinaryObjectScanner.FileType
{
@@ -48,7 +50,7 @@ namespace BinaryObjectScanner.FileType
return null;
}
}
-
+
///
/// Extract all files from the BFPK to an output directory
///
@@ -121,12 +123,14 @@ namespace BinaryObjectScanner.FileType
{
fs.Write(data, 0, compressedSize);
}
+#if NET462_OR_GREATER
else
{
MemoryStream ms = new MemoryStream(data);
ZlibStream zs = new ZlibStream(ms, CompressionMode.Decompress);
zs.CopyTo(fs);
}
+#endif
}
return true;
diff --git a/BinaryObjectScanner/FileType/BZip2.cs b/BinaryObjectScanner/FileType/BZip2.cs
index 97149cda..30def76e 100644
--- a/BinaryObjectScanner/FileType/BZip2.cs
+++ b/BinaryObjectScanner/FileType/BZip2.cs
@@ -1,8 +1,10 @@
using System;
using System.IO;
using BinaryObjectScanner.Interfaces;
+#if NET462_OR_GREATER
using SharpCompress.Compressors;
using SharpCompress.Compressors.BZip2;
+#endif
namespace BinaryObjectScanner.FileType
{
@@ -29,6 +31,7 @@ namespace BinaryObjectScanner.FileType
if (stream == null)
return null;
+#if NET462_OR_GREATER
try
{
// Create a temp output directory
@@ -51,6 +54,9 @@ namespace BinaryObjectScanner.FileType
if (includeDebug) Console.WriteLine(ex);
return null;
}
+#else
+ return null;
+#endif
}
}
}
diff --git a/BinaryObjectScanner/FileType/Executable.cs b/BinaryObjectScanner/FileType/Executable.cs
index c545612a..3a6c3739 100644
--- a/BinaryObjectScanner/FileType/Executable.cs
+++ b/BinaryObjectScanner/FileType/Executable.cs
@@ -214,7 +214,11 @@ namespace BinaryObjectScanner.FileType
byte[] fileContent = new byte[0];
try
{
+#if NET40
+ using (BinaryReader br = new BinaryReader(stream, Encoding.Default))
+#else
using (BinaryReader br = new BinaryReader(stream, Encoding.Default, true))
+#endif
{
fileContent = br.ReadBytes((int)stream.Length);
if (fileContent == null)
@@ -408,10 +412,14 @@ namespace BinaryObjectScanner.FileType
return assembly.GetTypes()?
.Where(t => t.IsClass && t.GetInterface(typeof(T).Name) != null)?
.Select(t => (T?)Activator.CreateInstance(t))
+#if NET40 || NET452
+ .Cast() ?? [];
+#else
.Cast() ?? Array.Empty();
+#endif
}
-#endregion
+ #endregion
#region Helpers
diff --git a/BinaryObjectScanner/FileType/GZIP.cs b/BinaryObjectScanner/FileType/GZIP.cs
index 25c7f3df..60397232 100644
--- a/BinaryObjectScanner/FileType/GZIP.cs
+++ b/BinaryObjectScanner/FileType/GZIP.cs
@@ -1,8 +1,10 @@
using System;
using System.IO;
using BinaryObjectScanner.Interfaces;
+#if NET462_OR_GREATER
using SharpCompress.Archives;
using SharpCompress.Archives.GZip;
+#endif
namespace BinaryObjectScanner.FileType
{
@@ -29,6 +31,7 @@ namespace BinaryObjectScanner.FileType
if (stream == null)
return null;
+#if NET462_OR_GREATER
try
{
// Create a temp output directory
@@ -62,6 +65,9 @@ namespace BinaryObjectScanner.FileType
if (includeDebug) Console.WriteLine(ex);
return null;
}
+#else
+ return null;
+#endif
}
}
}
diff --git a/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs b/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs
index baf20a6a..eda9de97 100644
--- a/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs
+++ b/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs
@@ -37,13 +37,13 @@ namespace BinaryObjectScanner.FileType
{
try
{
- string tempFile = Path.Combine(tempPath, cfile.FullPath);
+ string tempFile = Path.Combine(tempPath, cfile.FullPath!);
var directoryName = Path.GetDirectoryName(tempFile);
if (directoryName != null && !Directory.Exists(directoryName))
Directory.CreateDirectory(directoryName);
- (byte[] fileContents, string error) = archive.Extract(cfile.FullPath);
- if (!string.IsNullOrWhiteSpace(error))
+ (byte[]? fileContents, string? error) = archive.Extract(cfile.FullPath!);
+ if (fileContents == null || !string.IsNullOrWhiteSpace(error))
continue;
using (FileStream fs = File.OpenWrite(tempFile))
diff --git a/BinaryObjectScanner/FileType/InstallShieldCAB.cs b/BinaryObjectScanner/FileType/InstallShieldCAB.cs
index ab705959..9e9a9c6a 100644
--- a/BinaryObjectScanner/FileType/InstallShieldCAB.cs
+++ b/BinaryObjectScanner/FileType/InstallShieldCAB.cs
@@ -60,7 +60,10 @@ namespace BinaryObjectScanner.FileType
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(tempPath);
- InstallShieldCabinet cabfile = InstallShieldCabinet.Open(file);
+ var cabfile = InstallShieldCabinet.Open(file);
+ if (cabfile == null)
+ return null;
+
for (int i = 0; i < cabfile.FileCount; i++)
{
try
@@ -72,8 +75,8 @@ namespace BinaryObjectScanner.FileType
string tempFile;
try
{
- string filename = cabfile.FileName(i);
- tempFile = Path.Combine(tempPath, filename);
+ string? filename = cabfile.FileName(i);
+ tempFile = Path.Combine(tempPath, filename ?? string.Empty);
}
catch
{
diff --git a/BinaryObjectScanner/FileType/MPQ.cs b/BinaryObjectScanner/FileType/MPQ.cs
index e4c835e8..55a571a5 100644
--- a/BinaryObjectScanner/FileType/MPQ.cs
+++ b/BinaryObjectScanner/FileType/MPQ.cs
@@ -1,7 +1,7 @@
using System;
using System.IO;
using BinaryObjectScanner.Interfaces;
-#if NET48
+#if NETFRAMEWORK && !NET40
using StormLibSharp;
#endif
@@ -28,7 +28,7 @@ namespace BinaryObjectScanner.FileType
///
public string? Extract(Stream? stream, string file, bool includeDebug)
{
-#if NETCOREAPP || NET5_0_OR_GREATER
+#if NET40 || NETCOREAPP || NET5_0_OR_GREATER
// Not supported for .NET Core and modern .NET due to Windows DLL requirements
return null;
#else
diff --git a/BinaryObjectScanner/FileType/PKZIP.cs b/BinaryObjectScanner/FileType/PKZIP.cs
index 7dfcfe5b..c89283da 100644
--- a/BinaryObjectScanner/FileType/PKZIP.cs
+++ b/BinaryObjectScanner/FileType/PKZIP.cs
@@ -1,8 +1,10 @@
using System;
using System.IO;
using BinaryObjectScanner.Interfaces;
+#if NET462_OR_GREATER
using SharpCompress.Archives;
using SharpCompress.Archives.Zip;
+#endif
namespace BinaryObjectScanner.FileType
{
@@ -29,6 +31,7 @@ namespace BinaryObjectScanner.FileType
if (stream == null)
return null;
+#if NET462_OR_GREATER
try
{
// Create a temp output directory
@@ -65,6 +68,9 @@ namespace BinaryObjectScanner.FileType
if (includeDebug) Console.WriteLine(ex);
return null;
}
+#else
+ return null;
+#endif
}
}
}
diff --git a/BinaryObjectScanner/FileType/RAR.cs b/BinaryObjectScanner/FileType/RAR.cs
index 0796378b..be5ccb70 100644
--- a/BinaryObjectScanner/FileType/RAR.cs
+++ b/BinaryObjectScanner/FileType/RAR.cs
@@ -1,8 +1,10 @@
using System;
using System.IO;
using BinaryObjectScanner.Interfaces;
+#if NET462_OR_GREATER
using SharpCompress.Archives;
using SharpCompress.Archives.Rar;
+#endif
namespace BinaryObjectScanner.FileType
{
@@ -29,6 +31,7 @@ namespace BinaryObjectScanner.FileType
if (stream == null)
return null;
+#if NET462_OR_GREATER
try
{
// Create a temp output directory
@@ -62,6 +65,9 @@ namespace BinaryObjectScanner.FileType
if (includeDebug) Console.WriteLine(ex);
return null;
}
+#else
+ return null;
+#endif
}
}
}
diff --git a/BinaryObjectScanner/FileType/SGA.cs b/BinaryObjectScanner/FileType/SGA.cs
index fdd817cf..e0d8b8b9 100644
--- a/BinaryObjectScanner/FileType/SGA.cs
+++ b/BinaryObjectScanner/FileType/SGA.cs
@@ -3,7 +3,9 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using BinaryObjectScanner.Interfaces;
+#if NET462_OR_GREATER
using ICSharpCode.SharpZipLib.Zip.Compression;
+#endif
namespace BinaryObjectScanner.FileType
{
@@ -141,17 +143,10 @@ namespace BinaryObjectScanner.FileType
var folder = default(object);
switch (item.Model.Header?.MajorVersion)
{
-#if NET48
- case 4: folder = (item.Model.Directory as SabreTools.Models.SGA.Directory4)?.Folders?.FirstOrDefault(f => index >= f.FileStartIndex && index <= f.FileEndIndex); break;
- case 5: folder = (item.Model.Directory as SabreTools.Models.SGA.Directory5)?.Folders?.FirstOrDefault(f => index >= f.FileStartIndex && index <= f.FileEndIndex); break;
- case 6: folder = (item.Model.Directory as SabreTools.Models.SGA.Directory6)?.Folders?.FirstOrDefault(f => index >= f.FileStartIndex && index <= f.FileEndIndex); break;
- case 7: folder = (item.Model.Directory as SabreTools.Models.SGA.Directory7)?.Folders?.FirstOrDefault(f => index >= f.FileStartIndex && index <= f.FileEndIndex); break;
-#else
case 4: folder = (item.Model.Directory as SabreTools.Models.SGA.Directory4)?.Folders?.FirstOrDefault(f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex); break;
case 5: folder = (item.Model.Directory as SabreTools.Models.SGA.Directory5)?.Folders?.FirstOrDefault(f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex); break;
case 6: folder = (item.Model.Directory as SabreTools.Models.SGA.Directory6)?.Folders?.FirstOrDefault(f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex); break;
case 7: folder = (item.Model.Directory as SabreTools.Models.SGA.Directory7)?.Folders?.FirstOrDefault(f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex); break;
-#endif
default: return false;
}
@@ -229,10 +224,14 @@ namespace BinaryObjectScanner.FileType
else
{
// Decompress the data
+#if NET462_OR_GREATER
data = new byte[outputFileSize];
Inflater inflater = new Inflater();
inflater.SetInput(compressedData);
inflater.Inflate(data);
+#else
+ data = new byte[outputFileSize];
+#endif
}
// If we have an invalid output directory
diff --git a/BinaryObjectScanner/FileType/SevenZip.cs b/BinaryObjectScanner/FileType/SevenZip.cs
index 420fadf4..18fa32b5 100644
--- a/BinaryObjectScanner/FileType/SevenZip.cs
+++ b/BinaryObjectScanner/FileType/SevenZip.cs
@@ -1,8 +1,10 @@
using System;
using System.IO;
using BinaryObjectScanner.Interfaces;
+#if NET462_OR_GREATER
using SharpCompress.Archives;
using SharpCompress.Archives.SevenZip;
+#endif
namespace BinaryObjectScanner.FileType
{
@@ -26,6 +28,7 @@ namespace BinaryObjectScanner.FileType
///
public string? Extract(Stream? stream, string file, bool includeDebug)
{
+#if NET462_OR_GREATER
try
{
// Create a temp output directory
@@ -59,6 +62,9 @@ namespace BinaryObjectScanner.FileType
if (includeDebug) Console.WriteLine(ex);
return null;
}
+#else
+ return null;
+#endif
}
}
}
diff --git a/BinaryObjectScanner/FileType/TapeArchive.cs b/BinaryObjectScanner/FileType/TapeArchive.cs
index a85661ca..674d0527 100644
--- a/BinaryObjectScanner/FileType/TapeArchive.cs
+++ b/BinaryObjectScanner/FileType/TapeArchive.cs
@@ -1,8 +1,10 @@
using System;
using System.IO;
using BinaryObjectScanner.Interfaces;
+#if NET462_OR_GREATER
using SharpCompress.Archives;
using SharpCompress.Archives.Tar;
+#endif
namespace BinaryObjectScanner.FileType
{
@@ -29,6 +31,7 @@ namespace BinaryObjectScanner.FileType
if (stream == null)
return null;
+#if NET462_OR_GREATER
try
{
// Create a temp output directory
@@ -62,6 +65,9 @@ namespace BinaryObjectScanner.FileType
if (includeDebug) Console.WriteLine(ex);
return null;
}
+#else
+ return null;
+#endif
}
}
}
diff --git a/BinaryObjectScanner/FileType/Textfile.cs b/BinaryObjectScanner/FileType/Textfile.cs
index 5f5a0d24..09b8d0d0 100644
--- a/BinaryObjectScanner/FileType/Textfile.cs
+++ b/BinaryObjectScanner/FileType/Textfile.cs
@@ -33,7 +33,11 @@ namespace BinaryObjectScanner.FileType
{
// Load the current file content
var fileContent = string.Empty;
+#if NET40
+ using (var sr = new StreamReader(stream, Encoding.Default, true, 1024 * 1024))
+#else
using (var sr = new StreamReader(stream, Encoding.Default, true, 1024 * 1024, true))
+#endif
{
fileContent = sr.ReadToEnd();
}
diff --git a/BinaryObjectScanner/FileType/XZ.cs b/BinaryObjectScanner/FileType/XZ.cs
index bbfc6f49..ce4aa70e 100644
--- a/BinaryObjectScanner/FileType/XZ.cs
+++ b/BinaryObjectScanner/FileType/XZ.cs
@@ -1,7 +1,9 @@
using System;
using System.IO;
using BinaryObjectScanner.Interfaces;
+#if NET462_OR_GREATER
using SharpCompress.Compressors.Xz;
+#endif
namespace BinaryObjectScanner.FileType
{
@@ -25,6 +27,7 @@ namespace BinaryObjectScanner.FileType
///
public string? Extract(Stream? stream, string file, bool includeDebug)
{
+#if NET462_OR_GREATER
try
{
// Create a temp output directory
@@ -47,6 +50,9 @@ namespace BinaryObjectScanner.FileType
if (includeDebug) Console.WriteLine(ex);
return null;
}
+#else
+ return null;
+#endif
}
}
}
diff --git a/BinaryObjectScanner/Handler.cs b/BinaryObjectScanner/Handler.cs
index 5cc58db2..2362136c 100644
--- a/BinaryObjectScanner/Handler.cs
+++ b/BinaryObjectScanner/Handler.cs
@@ -185,7 +185,11 @@ namespace BinaryObjectScanner
{
return assembly.GetTypes()?
.Where(t => t.IsClass && t.GetInterface(typeof(T).Name) != null)?
+#if NET40 || NET452
+ .Select(t => (T?)Activator.CreateInstance(t)) ?? [];
+#else
.Select(t => (T?)Activator.CreateInstance(t)) ?? Array.Empty();
+#endif
}
#endregion
diff --git a/BinaryObjectScanner/Interfaces/IProgress.cs b/BinaryObjectScanner/Interfaces/IProgress.cs
new file mode 100644
index 00000000..e4fe415d
--- /dev/null
+++ b/BinaryObjectScanner/Interfaces/IProgress.cs
@@ -0,0 +1,19 @@
+#if NET40
+
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace System
+{
+ /// Defines a provider for progress updates.
+ /// The type of progress update value.
+ ///
+ public interface IProgress
+ {
+ /// Reports a progress update.
+ /// The value of the updated progress.
+ void Report(T value);
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/BinaryObjectScanner/Packer/AutoPlayMediaStudio.cs b/BinaryObjectScanner/Packer/AutoPlayMediaStudio.cs
index 276cff06..6d6eaad8 100644
--- a/BinaryObjectScanner/Packer/AutoPlayMediaStudio.cs
+++ b/BinaryObjectScanner/Packer/AutoPlayMediaStudio.cs
@@ -56,12 +56,12 @@ namespace BinaryObjectScanner.Packer
// Check the product version explicitly
var version = pex.ProductVersion;
if (!string.IsNullOrEmpty(version))
- return version;
+ return version!;
// Check the internal versions
version = pex.GetInternalVersion();
if (!string.IsNullOrEmpty(version))
- return version;
+ return version!;
return "(Unknown Version)";
}
diff --git a/BinaryObjectScanner/Packer/CExe.cs b/BinaryObjectScanner/Packer/CExe.cs
index 24dcf3e1..2e2497a2 100644
--- a/BinaryObjectScanner/Packer/CExe.cs
+++ b/BinaryObjectScanner/Packer/CExe.cs
@@ -3,7 +3,9 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using BinaryObjectScanner.Interfaces;
+#if NET462_OR_GREATER
using ICSharpCode.SharpZipLib.Zip.Compression;
+#endif
using SabreTools.Matching;
using SabreTools.Serialization.Wrappers;
@@ -88,6 +90,7 @@ namespace BinaryObjectScanner.Packer
try
{
// Inflate the data into the buffer
+#if NET462_OR_GREATER
Inflater inflater = new Inflater();
inflater.SetInput(payload);
data = new byte[payload.Length * 4];
@@ -95,6 +98,9 @@ namespace BinaryObjectScanner.Packer
// Trim the buffer to the proper size
data = new ReadOnlySpan(data, 0, read).ToArray();
+#else
+ data = null;
+#endif
}
catch
{
diff --git a/BinaryObjectScanner/Packer/InstallAnywhere.cs b/BinaryObjectScanner/Packer/InstallAnywhere.cs
index 8994c1cd..8d3e3b41 100644
--- a/BinaryObjectScanner/Packer/InstallAnywhere.cs
+++ b/BinaryObjectScanner/Packer/InstallAnywhere.cs
@@ -51,7 +51,7 @@ namespace BinaryObjectScanner.Packer
// Check the internal versions
var version = pex.GetInternalVersion();
if (!string.IsNullOrEmpty(version))
- return version;
+ return version!;
return "(Unknown Version)";
}
diff --git a/BinaryObjectScanner/Packer/NSIS.cs b/BinaryObjectScanner/Packer/NSIS.cs
index c3863dd1..b0ad4a6f 100644
--- a/BinaryObjectScanner/Packer/NSIS.cs
+++ b/BinaryObjectScanner/Packer/NSIS.cs
@@ -18,7 +18,7 @@ namespace BinaryObjectScanner.Packer
return null;
var description = pex.AssemblyDescription;
- if (!string.IsNullOrWhiteSpace(description) && description.StartsWith("Nullsoft Install System"))
+ if (!string.IsNullOrWhiteSpace(description) && description!.StartsWith("Nullsoft Install System"))
return $"NSIS {description.Substring("Nullsoft Install System".Length).Trim()}";
// Get the .data/DATA section strings, if they exist
diff --git a/BinaryObjectScanner/Packer/SetupFactory.cs b/BinaryObjectScanner/Packer/SetupFactory.cs
index 9e262766..3f56364b 100644
--- a/BinaryObjectScanner/Packer/SetupFactory.cs
+++ b/BinaryObjectScanner/Packer/SetupFactory.cs
@@ -61,12 +61,12 @@ namespace BinaryObjectScanner.Packer
// Check the product version explicitly
var version = pex.ProductVersion;
if (!string.IsNullOrEmpty(version))
- return version;
+ return version!;
// Check the internal versions
version = pex.GetInternalVersion();
if (!string.IsNullOrEmpty(version))
- return version;
+ return version!;
return "(Unknown Version)";
}
diff --git a/BinaryObjectScanner/Packer/WinRARSFX.cs b/BinaryObjectScanner/Packer/WinRARSFX.cs
index 7a11389f..24eefc4e 100644
--- a/BinaryObjectScanner/Packer/WinRARSFX.cs
+++ b/BinaryObjectScanner/Packer/WinRARSFX.cs
@@ -3,9 +3,11 @@ using System.IO;
using System.Linq;
using BinaryObjectScanner.Interfaces;
using SabreTools.Serialization.Wrappers;
+#if NET462_OR_GREATER
using SharpCompress.Archives;
using SharpCompress.Archives.Rar;
using SharpCompress.Readers;
+#endif
namespace BinaryObjectScanner.Packer
{
@@ -45,6 +47,7 @@ namespace BinaryObjectScanner.Packer
///
public string? Extract(Stream? stream, string file, bool includeDebug)
{
+#if NET462_OR_GREATER
try
{
// Should be using stream instead of file, but stream fails to extract anything. My guess is that the executable portion of the archive is causing stream to fail, but not file.
@@ -81,6 +84,9 @@ namespace BinaryObjectScanner.Packer
if (includeDebug) Console.WriteLine(ex);
return null;
}
+#else
+ return null;
+#endif
}
}
}
diff --git a/BinaryObjectScanner/Packer/WinZipSFX.cs b/BinaryObjectScanner/Packer/WinZipSFX.cs
index 2cdc2a83..8a0dca9b 100644
--- a/BinaryObjectScanner/Packer/WinZipSFX.cs
+++ b/BinaryObjectScanner/Packer/WinZipSFX.cs
@@ -4,8 +4,10 @@ using System.Linq;
using System.Text;
using BinaryObjectScanner.Interfaces;
using SabreTools.Serialization.Wrappers;
+#if NET462_OR_GREATER
using SharpCompress.Archives;
using SharpCompress.Archives.Zip;
+#endif
namespace BinaryObjectScanner.Packer
{
@@ -75,6 +77,7 @@ namespace BinaryObjectScanner.Packer
///
public string? Extract(Stream? stream, string file, bool includeDebug)
{
+#if NET462_OR_GREATER
try
{
// Should be using stream instead of file, but stream fails to extract anything. My guess is that the executable portion of the archive is causing stream to fail, but not file.
@@ -111,6 +114,9 @@ namespace BinaryObjectScanner.Packer
if (includeDebug) Console.WriteLine(ex);
return null;
}
+#else
+ return null;
+#endif
}
///
diff --git a/BinaryObjectScanner/Progress.cs b/BinaryObjectScanner/Progress.cs
new file mode 100644
index 00000000..b5ba9f9b
--- /dev/null
+++ b/BinaryObjectScanner/Progress.cs
@@ -0,0 +1,110 @@
+#if 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.Threading;
+using System.Diagnostics;
+
+namespace System
+{
+ ///
+ /// Provides an IProgress{T} that invokes callbacks for each reported progress value.
+ ///
+ /// Specifies the type of the progress report value.
+ ///
+ /// Any handler provided to the constructor or event handlers registered with
+ /// the event are invoked through a
+ /// 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.
+ ///
+ ///
+ public class Progress : IProgress where T : EventArgs
+ {
+ /// The synchronization context captured upon construction. This will never be null.
+ private readonly SynchronizationContext _synchronizationContext;
+ /// The handler specified to the constructor. This may be null.
+ private readonly Action? _handler;
+ /// A cached delegate used to post invocation to the synchronization context.
+ private readonly SendOrPostCallback _invokeHandlers;
+
+ /// Initializes the .
+ 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);
+ }
+
+ /// Initializes the with the specified callback.
+ ///
+ /// A handler to invoke for each reported progress value. This handler will be invoked
+ /// in addition to any delegates registered with the event.
+ /// Depending on the instance captured by
+ /// the at construction, it's possible that this handler instance
+ /// could be invoked concurrently with itself.
+ ///
+ /// The is null ( in Visual Basic).
+ public Progress(Action handler) : this()
+ {
+ if (handler == null)
+ throw new ArgumentNullException(nameof(handler));
+
+ _handler = handler;
+ }
+
+ /// Raised for each reported progress value.
+ ///
+ /// Handlers registered with this event will be invoked on the
+ /// captured when the instance was constructed.
+ ///
+ public event EventHandler? ProgressChanged;
+
+ /// Reports a progress change.
+ /// The value of the updated progress.
+ 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? handler = _handler;
+ EventHandler? 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);
+ }
+ }
+
+ /// Reports a progress change.
+ /// The value of the updated progress.
+ void IProgress.Report(T value) { OnReport(value); }
+
+ /// Invokes the action and event callbacks.
+ /// The progress value.
+ private void InvokeHandlers(object? state)
+ {
+ T value = (T)state!;
+
+ Action? handler = _handler;
+ EventHandler? changedEvent = ProgressChanged;
+
+ handler?.Invoke(value);
+ changedEvent?.Invoke(this, value);
+ }
+ }
+
+ /// Holds static values for .
+ /// This avoids one static instance per type T.
+ internal static class ProgressStatics
+ {
+ /// A default synchronization context that targets the ThreadPool.
+ internal static readonly SynchronizationContext DefaultContext = new SynchronizationContext();
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/BinaryObjectScanner/Protection/AegiSoft.cs b/BinaryObjectScanner/Protection/AegiSoft.cs
index 578b614e..d7c56ca6 100644
--- a/BinaryObjectScanner/Protection/AegiSoft.cs
+++ b/BinaryObjectScanner/Protection/AegiSoft.cs
@@ -80,7 +80,7 @@ namespace BinaryObjectScanner.Protection
// These files are "Asc001.dll", "Asc002.dll", "Asc003.dll", "Asc005.dll", and "Asc006.exe" (Found in Redump entry 73521/IA item "Nova_HoyleCasino99USA").
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/AlphaDVD.cs b/BinaryObjectScanner/Protection/AlphaDVD.cs
index 8dbf1770..6b61bbe9 100644
--- a/BinaryObjectScanner/Protection/AlphaDVD.cs
+++ b/BinaryObjectScanner/Protection/AlphaDVD.cs
@@ -23,7 +23,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("PlayDVD.exe", useEndsWith: true), "Alpha-DVD (Unconfirmed - Please report to us on Github)"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/Bitpool.cs b/BinaryObjectScanner/Protection/Bitpool.cs
index 78f970a2..ff8d0e13 100644
--- a/BinaryObjectScanner/Protection/Bitpool.cs
+++ b/BinaryObjectScanner/Protection/Bitpool.cs
@@ -34,7 +34,7 @@ namespace BinaryObjectScanner.Protection
}, "Bitpool"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/ByteShield.cs b/BinaryObjectScanner/Protection/ByteShield.cs
index 9b1a92a8..bbbdc274 100644
--- a/BinaryObjectScanner/Protection/ByteShield.cs
+++ b/BinaryObjectScanner/Protection/ByteShield.cs
@@ -140,7 +140,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("Byteshield.ini", useEndsWith: true), "ByteShield"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/CDDVDCops.cs b/BinaryObjectScanner/Protection/CDDVDCops.cs
index d302c4fe..5a08a0f8 100644
--- a/BinaryObjectScanner/Protection/CDDVDCops.cs
+++ b/BinaryObjectScanner/Protection/CDDVDCops.cs
@@ -199,7 +199,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch(".Qz", matchExact: true, useEndsWith: true), "CD-Cops (Unconfirmed - Please report to us on Github)"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
@@ -228,7 +228,13 @@ namespace BinaryObjectScanner.Protection
if (fileContent == null)
return null;
+#if NET40
+ byte[] versionBytes = new byte[4];
+ Array.Copy(fileContent, positions[0] + 15, versionBytes, 0, 4);
+ char[] version = versionBytes.Select(b => (char)b).ToArray();
+#else
char[] version = new ArraySegment(fileContent, positions[0] + 15, 4).Select(b => (char)b).ToArray();
+#endif
if (version[0] == 0x00)
return string.Empty;
diff --git a/BinaryObjectScanner/Protection/CDGuard.cs b/BinaryObjectScanner/Protection/CDGuard.cs
index e80d28ba..07659d81 100644
--- a/BinaryObjectScanner/Protection/CDGuard.cs
+++ b/BinaryObjectScanner/Protection/CDGuard.cs
@@ -63,7 +63,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("cdguard.dll", useEndsWith: true), "CD-Guard Copy Protection System"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/CDLock.cs b/BinaryObjectScanner/Protection/CDLock.cs
index 5eb6053f..5f85bdcb 100644
--- a/BinaryObjectScanner/Protection/CDLock.cs
+++ b/BinaryObjectScanner/Protection/CDLock.cs
@@ -73,7 +73,7 @@ namespace BinaryObjectScanner.Protection
// There is also a "$$$$$$$$.$$$" file present on some discs, but it isn't known if this is directly related to CD-Lock (Redump entries 37788 and 43221).
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/CDProtector.cs b/BinaryObjectScanner/Protection/CDProtector.cs
index 67a5a877..cf4e46c3 100644
--- a/BinaryObjectScanner/Protection/CDProtector.cs
+++ b/BinaryObjectScanner/Protection/CDProtector.cs
@@ -35,7 +35,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("Track#1 - Track#2 Cd-Protector.wav", useEndsWith: true), "CD-Protector"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/CDX.cs b/BinaryObjectScanner/Protection/CDX.cs
index 0c2e1ebb..8e72af81 100644
--- a/BinaryObjectScanner/Protection/CDX.cs
+++ b/BinaryObjectScanner/Protection/CDX.cs
@@ -18,7 +18,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("CHKCDXNT.DLL", useEndsWith: true), "CD-X (Unconfirmed - Please report to us on Github)"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/CenegaProtectDVD.cs b/BinaryObjectScanner/Protection/CenegaProtectDVD.cs
index ae4aff8f..7472dd18 100644
--- a/BinaryObjectScanner/Protection/CenegaProtectDVD.cs
+++ b/BinaryObjectScanner/Protection/CenegaProtectDVD.cs
@@ -62,7 +62,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("cenega.dll", useEndsWith: true), "Cenega ProtectDVD"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs b/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs
index 63fab072..8385bd25 100644
--- a/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs
+++ b/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs
@@ -65,7 +65,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("Code-Lock Wizard.exe", useEndsWith: true), "ChosenBytes Code-Lock"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/CopyKiller.cs b/BinaryObjectScanner/Protection/CopyKiller.cs
index 92f88d87..d1ed11b2 100644
--- a/BinaryObjectScanner/Protection/CopyKiller.cs
+++ b/BinaryObjectScanner/Protection/CopyKiller.cs
@@ -39,7 +39,7 @@ namespace BinaryObjectScanner.Protection
//new PathMatchSet(new PathMatch("Autorun.dat", useEndsWith: true), "CopyKiller"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/DVDCrypt.cs b/BinaryObjectScanner/Protection/DVDCrypt.cs
index be80e377..cab49777 100644
--- a/BinaryObjectScanner/Protection/DVDCrypt.cs
+++ b/BinaryObjectScanner/Protection/DVDCrypt.cs
@@ -15,7 +15,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("DvdCrypt.pdb", useEndsWith: true), "DVD Crypt (Unconfirmed - Please report to us on Github)"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/Denuvo.cs b/BinaryObjectScanner/Protection/Denuvo.cs
index d1d23fdf..d827a3c6 100644
--- a/BinaryObjectScanner/Protection/Denuvo.cs
+++ b/BinaryObjectScanner/Protection/Denuvo.cs
@@ -270,7 +270,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("Denuvo Anti-Cheat Installer.exe", useEndsWith: true), "Denuvo Anti-Cheat"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/DigiGuard.cs b/BinaryObjectScanner/Protection/DigiGuard.cs
index 2022c7fa..24c227e8 100644
--- a/BinaryObjectScanner/Protection/DigiGuard.cs
+++ b/BinaryObjectScanner/Protection/DigiGuard.cs
@@ -63,7 +63,7 @@ namespace BinaryObjectScanner.Protection
// There are at least two additional specifically named DecryptWrap files, "DecryptWrapTW2000.exe" and "DecryptWrapTW2KCode.exe" in IA item "Nova_DellBigWIGDVD_USA"/Redump entry 108588.
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/DinamicMultimedia.cs b/BinaryObjectScanner/Protection/DinamicMultimedia.cs
index 26c51155..ccd3d303 100644
--- a/BinaryObjectScanner/Protection/DinamicMultimedia.cs
+++ b/BinaryObjectScanner/Protection/DinamicMultimedia.cs
@@ -38,7 +38,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch(Path.Combine("XCONTROL", "COMPSCO._01").Replace("\\", "/"), useEndsWith: true), "Dinamic Multimedia Protection/LockBlocks [Check disc for 2 physical rings]"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/DiscGuard.cs b/BinaryObjectScanner/Protection/DiscGuard.cs
index 3e1570d2..eb77cfcf 100644
--- a/BinaryObjectScanner/Protection/DiscGuard.cs
+++ b/BinaryObjectScanner/Protection/DiscGuard.cs
@@ -163,7 +163,7 @@ namespace BinaryObjectScanner.Protection
}, "DiscGuard"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
@@ -188,7 +188,7 @@ namespace BinaryObjectScanner.Protection
// Check the internal versions
var version = pex.GetInternalVersion();
if (!string.IsNullOrEmpty(version))
- return version;
+ return version!;
return "(Unknown Version)";
}
@@ -201,14 +201,14 @@ namespace BinaryObjectScanner.Protection
return null;
// Check the internal versions
- string version = GetInternalVersion(file, Array.Empty());
+ string version = GetInternalVersion(file);
if (!string.IsNullOrEmpty(version))
return version;
return string.Empty;
}
- private string GetInternalVersion(string firstMatchedString, IEnumerable files)
+ private string GetInternalVersion(string firstMatchedString)
{
try
{
diff --git a/BinaryObjectScanner/Protection/EasyAntiCheat.cs b/BinaryObjectScanner/Protection/EasyAntiCheat.cs
index bdcecf94..93f17798 100644
--- a/BinaryObjectScanner/Protection/EasyAntiCheat.cs
+++ b/BinaryObjectScanner/Protection/EasyAntiCheat.cs
@@ -31,17 +31,17 @@ namespace BinaryObjectScanner.Protection
var name = pex.FileDescription;
// Found in "VideoHorrorSociety.exe" ("Video Horror Society", Patch 1.0.70309, Steam).
- if (!string.IsNullOrEmpty(name) && name.Contains("Easy Anti-Cheat Bootstrapper (EOS)"))
+ if (!string.IsNullOrEmpty(name) && name!.Contains("Easy Anti-Cheat Bootstrapper (EOS)"))
return "Easy Anti-Cheat (EOS Version)";
// Found in "EasyAntiCheat_EOS_Setup.exe" ("Video Horror Society", Patch 1.0.70309, Steam) and "EasyAntiCheat_EOS.exe", which is found installed in "Program Files (x86)\EasyAntiCheat_EOS".
- else if (!string.IsNullOrEmpty(name) && name.Contains("Easy Anti-Cheat Service (EOS)"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Easy Anti-Cheat Service (EOS)"))
return "Easy Anti-Cheat (EOS Version)";
// These two generic checks are both general enough to detect the majority of files known to contain Easy Anti-Cheat, as well as specific enough to avoid false positives.
- else if (!string.IsNullOrEmpty(name) && name.Contains("EasyAntiCheat"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("EasyAntiCheat"))
return "Easy Anti-Cheat";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Easy Anti-Cheat"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Easy Anti-Cheat"))
return "Easy Anti-Cheat";
// For documentation, known exact File Descriptions and their associated files are listed below:
@@ -57,17 +57,17 @@ namespace BinaryObjectScanner.Protection
name = pex.ProductName;
// Found in multiple files, including "VideoHorrorSociety.exe" ("Video Horror Society", Patch 1.0.70309, Steam) and "start_protected_game.exe" ("VRChat", Version 2022.2.2p2, Oculus).
- if (!string.IsNullOrEmpty(name) && name.Contains("Easy Anti-Cheat Bootstrapper (EOS)"))
+ if (!string.IsNullOrEmpty(name) && name!.Contains("Easy Anti-Cheat Bootstrapper (EOS)"))
return "Easy Anti-Cheat (EOS Version)";
// Found in multiple files, including "EasyAntiCheat_EOS_Setup.exe" ("Video Horror Society", Patch 1.0.70309, Steam; "VRChat", Version 2022.2.2p2, Oculus) and "EasyAntiCheat.exe", which is found installed in "Program Files (x86)\EasyAntiCheat_EOS".
- else if (!string.IsNullOrEmpty(name) && name.Contains("Easy Anti-Cheat Service (EOS)"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Easy Anti-Cheat Service (EOS)"))
return "Easy Anti-Cheat (EOS Version)";
// These two generic checks are both general enough to detect the majority of files known to contain Easy Anti-Cheat, as well as specific enough to avoid false positives.
- else if (!string.IsNullOrEmpty(name) && name.Contains("EasyAntiCheat"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("EasyAntiCheat"))
return "Easy Anti-Cheat";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Easy Anti-Cheat"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Easy Anti-Cheat"))
return "Easy Anti-Cheat";
// For documentation, known exact Product Names and their associated files are listed below:
@@ -123,7 +123,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("easyanticheat_x64.so", useEndsWith: true), "Easy Anti-Cheat"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/Engine32.cs b/BinaryObjectScanner/Protection/Engine32.cs
index 4cf0c821..d6c24bbd 100644
--- a/BinaryObjectScanner/Protection/Engine32.cs
+++ b/BinaryObjectScanner/Protection/Engine32.cs
@@ -58,7 +58,7 @@ namespace BinaryObjectScanner.Protection
// The file "engine32.dll" is present in every known instance of this DRM, but isn't being checked for currently due to the generic file name.
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/FreeLock.cs b/BinaryObjectScanner/Protection/FreeLock.cs
index 83616c68..cc6d0f7b 100644
--- a/BinaryObjectScanner/Protection/FreeLock.cs
+++ b/BinaryObjectScanner/Protection/FreeLock.cs
@@ -48,7 +48,7 @@ namespace BinaryObjectScanner.Protection
}, "Freelock 1.3"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/GFWL.cs b/BinaryObjectScanner/Protection/GFWL.cs
index bd97d595..8969c4b4 100644
--- a/BinaryObjectScanner/Protection/GFWL.cs
+++ b/BinaryObjectScanner/Protection/GFWL.cs
@@ -46,7 +46,7 @@ namespace BinaryObjectScanner.ProtectionType
new PathMatchSet(new PathMatch("XLiveRedist.msi", useEndsWith: true), "Games for Windows LIVE"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/Gefest.cs b/BinaryObjectScanner/Protection/Gefest.cs
index 8de343cb..8339e20e 100644
--- a/BinaryObjectScanner/Protection/Gefest.cs
+++ b/BinaryObjectScanner/Protection/Gefest.cs
@@ -46,7 +46,7 @@ namespace BinaryObjectScanner.Protection
// Possibly related file "31AD0095.fil" that appears to contain intentional errors found in Redump entry 93700.
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/HexaLock.cs b/BinaryObjectScanner/Protection/HexaLock.cs
index 9e58c9ec..e250fc36 100644
--- a/BinaryObjectScanner/Protection/HexaLock.cs
+++ b/BinaryObjectScanner/Protection/HexaLock.cs
@@ -99,7 +99,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("HCPSMng.exe", useEndsWith: true), "HexaLock AutoLock 4.5"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/ImpulseReactor.cs b/BinaryObjectScanner/Protection/ImpulseReactor.cs
index 58a4de87..858bc5ec 100644
--- a/BinaryObjectScanner/Protection/ImpulseReactor.cs
+++ b/BinaryObjectScanner/Protection/ImpulseReactor.cs
@@ -62,7 +62,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("ReactorActivate.exe", useEndsWith: true), GetInternalVersion, "Stardock Product Activation"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
@@ -77,7 +77,7 @@ namespace BinaryObjectScanner.Protection
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
- private string GetInternalVersion(string firstMatchedString, IEnumerable files)
+ private string? GetInternalVersion(string firstMatchedString, IEnumerable? files)
{
try
{
diff --git a/BinaryObjectScanner/Protection/IndyVCD.cs b/BinaryObjectScanner/Protection/IndyVCD.cs
index 466e124d..e964d459 100644
--- a/BinaryObjectScanner/Protection/IndyVCD.cs
+++ b/BinaryObjectScanner/Protection/IndyVCD.cs
@@ -21,7 +21,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("INDYMP3.idt", useEndsWith: true), "IndyVCD (Unconfirmed - Please report to us on Github)"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/JoWood.cs b/BinaryObjectScanner/Protection/JoWood.cs
index 666a95ea..4161d06d 100644
--- a/BinaryObjectScanner/Protection/JoWood.cs
+++ b/BinaryObjectScanner/Protection/JoWood.cs
@@ -73,7 +73,13 @@ namespace BinaryObjectScanner.Protection
return null;
int position = positions[0];
+#if NET40
+ byte[] versionBytes = new byte[8];
+ Array.Copy(fileContent, position + 67, versionBytes, 0, 8);
+ char[] version = versionBytes.Select(b => (char)b).ToArray();
+#else
char[] version = new ArraySegment(fileContent, position + 67, 8).Select(b => (char)b).ToArray();
+#endif
return new string(version);
}
}
diff --git a/BinaryObjectScanner/Protection/LabelGate.cs b/BinaryObjectScanner/Protection/LabelGate.cs
index 2760fd1d..93d130e5 100644
--- a/BinaryObjectScanner/Protection/LabelGate.cs
+++ b/BinaryObjectScanner/Protection/LabelGate.cs
@@ -69,7 +69,7 @@ namespace BinaryObjectScanner.Protection
}, "LabelGate CD2"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/LaserLok.cs b/BinaryObjectScanner/Protection/LaserLok.cs
index 07d5904f..482e1ea0 100644
--- a/BinaryObjectScanner/Protection/LaserLok.cs
+++ b/BinaryObjectScanner/Protection/LaserLok.cs
@@ -128,7 +128,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("laserlok.out", useEndsWith: true), "LaserLok [Check disc for physical ring]"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
@@ -169,20 +169,44 @@ namespace BinaryObjectScanner.Protection
if (versionTwo)
{
int index = position + 14;
+#if NET40
+ byte[] temp = new byte[2];
+ Array.Copy(sectionContent, index, temp, 0, 2);
+ day = new string(temp.Select(b => (char)b).ToArray());
+ index += 3;
+ Array.Copy(sectionContent, index, temp, 0, 2);
+ month = new string(temp.Select(b => (char)b).ToArray());
+ index += 3;
+ Array.Copy(sectionContent, index, temp, 0, 2);
+ year = "20" + new string(temp.Select(b => (char)b).ToArray());
+#else
day = new string(new ArraySegment(sectionContent, index, 2).Select(b => (char)b).ToArray());
index += 3;
month = new string(new ArraySegment(sectionContent, index, 2).Select(b => (char)b).ToArray());
index += 3;
year = "20" + new string(new ArraySegment(sectionContent, index, 2).Select(b => (char)b).ToArray());
+#endif
}
else
{
int index = position + 13;
+#if NET40
+ byte[] temp = new byte[2];
+ Array.Copy(sectionContent, index, temp, 0, 2);
+ day = new string(temp.Select(b => (char)b).ToArray());
+ index += 3;
+ Array.Copy(sectionContent, index, temp, 0, 2);
+ month = new string(temp.Select(b => (char)b).ToArray());
+ index += 3;
+ Array.Copy(sectionContent, index, temp, 0, 2);
+ year = "20" + new string(temp.Select(b => (char)b).ToArray());
+#else
day = new string(new ArraySegment(sectionContent, index, 2).Select(b => (char)b).ToArray());
index += 3;
month = new string(new ArraySegment(sectionContent, index, 2).Select(b => (char)b).ToArray());
index += 3;
year = "20" + new string(new ArraySegment(sectionContent, index, 2).Select(b => (char)b).ToArray());
+#endif
}
return $"(Build {year}-{month}-{day})";
@@ -194,10 +218,16 @@ namespace BinaryObjectScanner.Protection
if (sectionContent == null)
return null;
+#if NET40
+ byte[] temp = new byte[4];
+ Array.Copy(sectionContent, position + 76, temp, 0, 4);
+ return new string(temp.Select(b => (char)b).ToArray());
+#else
return new string(new ArraySegment(sectionContent, position + 76, 4).Select(b => (char)b).ToArray());
+#endif
}
- public static string GetVersion16Bit(string firstMatchedString, IEnumerable files)
+ public static string? GetVersion16Bit(string firstMatchedString, IEnumerable? files)
{
if (!File.Exists(firstMatchedString))
return string.Empty;
@@ -211,7 +241,13 @@ namespace BinaryObjectScanner.Protection
private static string GetVersion16Bit(byte[] fileContent)
{
+#if NET40
+ byte[] temp = new byte[7];
+ Array.Copy(fileContent, 71, temp, 0, 7);
+ char[] version = temp.Select(b => (char)b).ToArray();
+#else
char[] version = new ArraySegment(fileContent, 71, 7).Select(b => (char)b).ToArray();
+#endif
if (char.IsNumber(version[0]) && char.IsNumber(version[2]) && char.IsNumber(version[3]))
{
if (char.IsNumber(version[5]) && char.IsNumber(version[6]))
diff --git a/BinaryObjectScanner/Protection/Macrovision.CDilla.cs b/BinaryObjectScanner/Protection/Macrovision.CDilla.cs
index 1da414e5..ef6e97f8 100644
--- a/BinaryObjectScanner/Protection/Macrovision.CDilla.cs
+++ b/BinaryObjectScanner/Protection/Macrovision.CDilla.cs
@@ -187,7 +187,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("CDILLA16.EXE", useEndsWith: true), "C-Dilla License Management System"),
};
- return MatchUtil.GetAllMatches(files ?? Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs b/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs
index cc136b96..8162c64d 100644
--- a/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs
+++ b/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs
@@ -87,7 +87,7 @@ namespace BinaryObjectScanner.Protection
// Due to this file being used in both protections, this file is detected within the general Macrovision checks.
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs b/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs
index 758a670f..eac74ec4 100644
--- a/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs
+++ b/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs
@@ -71,7 +71,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("9KMJ9G4I.EXE", useEndsWith: true), "RipGuard (Unconfirmed - Please report to us on GitHub)"),
};
- return MatchUtil.GetAllMatches(files ?? Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs b/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs
index 09f47f00..c000baa6 100644
--- a/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs
+++ b/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs
@@ -183,7 +183,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("CDAC13BA.EXE", useEndsWith: true), "SafeCast"),
};
- return MatchUtil.GetAllMatches(files ?? Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs b/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs
index bbf122c1..8c33280e 100644
--- a/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs
+++ b/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs
@@ -214,7 +214,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(".SafeDiscDVD.bundle", "SafeDisc for Macintosh"),
};
- return MatchUtil.GetAllMatches(files ?? Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
@@ -294,7 +294,7 @@ namespace BinaryObjectScanner.Protection
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
- internal static string GetSafeDiscCLCD16Version(string firstMatchedString, IEnumerable files)
+ internal static string GetSafeDiscCLCD16Version(string firstMatchedString, IEnumerable? files)
{
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
return string.Empty;
@@ -318,7 +318,7 @@ namespace BinaryObjectScanner.Protection
}
}
- internal static string GetSafeDiscCLCD32Version(string firstMatchedString, IEnumerable files)
+ internal static string GetSafeDiscCLCD32Version(string firstMatchedString, IEnumerable? files)
{
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
return string.Empty;
@@ -407,7 +407,7 @@ namespace BinaryObjectScanner.Protection
}
}
- internal static string GetSafeDiscCLOKSPLVersion(string firstMatchedString, IEnumerable files)
+ internal static string GetSafeDiscCLOKSPLVersion(string firstMatchedString, IEnumerable? files)
{
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
return string.Empty;
@@ -501,7 +501,7 @@ namespace BinaryObjectScanner.Protection
}
}
- internal static string GetSafeDiscDPlayerXVersion(string firstMatchedString, IEnumerable files)
+ internal static string GetSafeDiscDPlayerXVersion(string firstMatchedString, IEnumerable? files)
{
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
return string.Empty;
@@ -563,7 +563,7 @@ namespace BinaryObjectScanner.Protection
}
}
- internal static string GetSafeDiscDrvmgtVersion(string firstMatchedString, IEnumerable files)
+ internal static string GetSafeDiscDrvmgtVersion(string firstMatchedString, IEnumerable? files)
{
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
return string.Empty;
diff --git a/BinaryObjectScanner/Protection/Macrovision.cs b/BinaryObjectScanner/Protection/Macrovision.cs
index bb42c780..0ef33ca4 100644
--- a/BinaryObjectScanner/Protection/Macrovision.cs
+++ b/BinaryObjectScanner/Protection/Macrovision.cs
@@ -252,7 +252,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new FilePathMatch("secdrv.sys"), GetSecdrvFileSizeVersion, "Macrovision Security Driver"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
@@ -267,7 +267,7 @@ namespace BinaryObjectScanner.Protection
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
- internal static string Get00000001TMPVersion(string firstMatchedString, IEnumerable files)
+ internal static string? Get00000001TMPVersion(string firstMatchedString, IEnumerable? files)
{
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
return string.Empty;
@@ -293,7 +293,7 @@ namespace BinaryObjectScanner.Protection
}
// TODO: Verify these checks and remove any that may not be needed, file version checks should remove the need for any checks for 2.80+.
- internal static string GetSecdrvFileSizeVersion(string firstMatchedString, IEnumerable files)
+ internal static string? GetSecdrvFileSizeVersion(string firstMatchedString, IEnumerable? files)
{
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
return string.Empty;
diff --git a/BinaryObjectScanner/Protection/MediaCloQ.cs b/BinaryObjectScanner/Protection/MediaCloQ.cs
index 2c3b42c1..11c635ae 100644
--- a/BinaryObjectScanner/Protection/MediaCloQ.cs
+++ b/BinaryObjectScanner/Protection/MediaCloQ.cs
@@ -47,7 +47,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("scvfy.exe", useEndsWith: true), "MediaCloQ"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/MediaMaxCD3.cs b/BinaryObjectScanner/Protection/MediaMaxCD3.cs
index a9fc3fce..42eeeb73 100644
--- a/BinaryObjectScanner/Protection/MediaMaxCD3.cs
+++ b/BinaryObjectScanner/Protection/MediaMaxCD3.cs
@@ -86,7 +86,7 @@ namespace BinaryObjectScanner.Protection
}, "MediaMax CD-3"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/NEACProtect.cs b/BinaryObjectScanner/Protection/NEACProtect.cs
index 2f633610..7ae8582d 100644
--- a/BinaryObjectScanner/Protection/NEACProtect.cs
+++ b/BinaryObjectScanner/Protection/NEACProtect.cs
@@ -43,7 +43,7 @@ namespace BinaryObjectScanner.Protection
// Found in "NeacSafe64.sys" and "NeacSafe.sys".
// TODO: Fix Product Name not being properly grabbed from the file.
- if (!string.IsNullOrEmpty(name) && name.Contains("neacsafe"))
+ if (!string.IsNullOrEmpty(name) && name!.Contains("neacsafe"))
return "NEAC Protect";
return null;
@@ -65,7 +65,7 @@ namespace BinaryObjectScanner.Protection
// Known associated log files: "NeacSafe.log", "Neac.log", "NeacDll.log", "NeacLoader.log", and "NeacBak.log".
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/OpenMG.cs b/BinaryObjectScanner/Protection/OpenMG.cs
index 5e2899e3..f2aa6d8a 100644
--- a/BinaryObjectScanner/Protection/OpenMG.cs
+++ b/BinaryObjectScanner/Protection/OpenMG.cs
@@ -87,7 +87,7 @@ namespace BinaryObjectScanner.Protection
}, "OpenMG"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/Origin.cs b/BinaryObjectScanner/Protection/Origin.cs
index 91125efb..cd6330a7 100644
--- a/BinaryObjectScanner/Protection/Origin.cs
+++ b/BinaryObjectScanner/Protection/Origin.cs
@@ -36,7 +36,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("OriginSetup.exe", useEndsWith: true), "Origin"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/PlayJ.cs b/BinaryObjectScanner/Protection/PlayJ.cs
index 5487359b..a7967649 100644
--- a/BinaryObjectScanner/Protection/PlayJ.cs
+++ b/BinaryObjectScanner/Protection/PlayJ.cs
@@ -53,7 +53,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("PJSTREAM.DLL", useEndsWith: true), "PlayJ Music Player Component"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/ProtectDisc.cs b/BinaryObjectScanner/Protection/ProtectDisc.cs
index 08b3a255..341d0072 100644
--- a/BinaryObjectScanner/Protection/ProtectDisc.cs
+++ b/BinaryObjectScanner/Protection/ProtectDisc.cs
@@ -136,12 +136,24 @@ namespace BinaryObjectScanner.Protection
int index = positions[0] - 12;
// Version 6-7 with Build Number in plain text
+#if NET40
+ byte[] temp = new byte[4];
+ Array.Copy(fileContent, index, temp, 0, 4);
+ if (temp.SequenceEqual(new byte[] { 0x0A, 0x0D, 0x0A, 0x0D }))
+#else
if (new ArraySegment(fileContent, index, 4).SequenceEqual(new byte[] { 0x0A, 0x0D, 0x0A, 0x0D }))
+#endif
{
index = positions[0] - 12 - 6;
// Version 7
+#if NET40
+ temp = new byte[6];
+ Array.Copy(fileContent, index, temp, 0, 6);
+ if (new string(temp.Select(b => (char)b).ToArray()) == "Henrik")
+#else
if (new string(new ArraySegment(fileContent, index, 6).Select(b => (char)b).ToArray()) == "Henrik")
+#endif
{
version = "7.1-7.5";
index = positions[0] - 12 - 6 - 6;
@@ -164,7 +176,13 @@ namespace BinaryObjectScanner.Protection
index -= 5;
}
+#if NET40
+ temp = new byte[6];
+ Array.Copy(fileContent, index, temp, 0, 6);
+ char[] arrBuild = temp.Select(b => (char)b).ToArray();
+#else
char[] arrBuild = new ArraySegment(fileContent, index, 6).Select(b => (char)b).ToArray();
+#endif
if (!Int32.TryParse(new string(arrBuild), out int intBuild))
strBuild = $"[Build {new string(arrBuild).Trim()}]";
else
diff --git a/BinaryObjectScanner/Protection/RainbowSentinel.cs b/BinaryObjectScanner/Protection/RainbowSentinel.cs
index f3c68cb3..45a318d9 100644
--- a/BinaryObjectScanner/Protection/RainbowSentinel.cs
+++ b/BinaryObjectScanner/Protection/RainbowSentinel.cs
@@ -126,7 +126,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("SX32W.DLL", useEndsWith: true), "Rainbow Sentinel"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/RingPROTECH.cs b/BinaryObjectScanner/Protection/RingPROTECH.cs
index 98d2292c..26a136e0 100644
--- a/BinaryObjectScanner/Protection/RingPROTECH.cs
+++ b/BinaryObjectScanner/Protection/RingPROTECH.cs
@@ -42,7 +42,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("protect.pro", useEndsWith: true), "Ring PROTECH / ProRing [Check disc for physical ring]"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/SVKP.cs b/BinaryObjectScanner/Protection/SVKP.cs
index 48994514..45fe83ee 100644
--- a/BinaryObjectScanner/Protection/SVKP.cs
+++ b/BinaryObjectScanner/Protection/SVKP.cs
@@ -102,7 +102,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new FilePathMatch("svkpnd.dll"), "SVKP"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/SafeLock.cs b/BinaryObjectScanner/Protection/SafeLock.cs
index 8a3ef7c9..4b28191b 100644
--- a/BinaryObjectScanner/Protection/SafeLock.cs
+++ b/BinaryObjectScanner/Protection/SafeLock.cs
@@ -32,7 +32,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("SafeLock.256", useEndsWith: true), "SafeLock"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/SecuROM.cs b/BinaryObjectScanner/Protection/SecuROM.cs
index be7ec34f..a4d7ded9 100644
--- a/BinaryObjectScanner/Protection/SecuROM.cs
+++ b/BinaryObjectScanner/Protection/SecuROM.cs
@@ -65,7 +65,11 @@ namespace BinaryObjectScanner.Protection
if (nthSection == null)
continue;
+#if NET40 || NET452
+ string nthSectionName = Encoding.UTF8.GetString(nthSection.Name ?? []).TrimEnd('\0');
+#else
string nthSectionName = Encoding.UTF8.GetString(nthSection.Name ?? Array.Empty()).TrimEnd('\0');
+#endif
if (nthSectionName != ".idata" && nthSectionName != ".rsrc")
{
var nthSectionData = pex.GetFirstSectionData(nthSectionName);
@@ -130,7 +134,7 @@ namespace BinaryObjectScanner.Protection
}, "SecuROM 7.01"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
@@ -217,7 +221,12 @@ namespace BinaryObjectScanner.Protection
private static string GetV7Version(PortableExecutable pex)
{
int index = 172; // 64 bytes for DOS stub, 236 bytes in total
+#if NETFRAMEWORK
+ byte[] bytes = new byte[4];
+ Array.Copy(pex.StubExecutableData, index, bytes, 0, 4);
+#else
byte[] bytes = new ReadOnlySpan(pex.StubExecutableData, index, 4).ToArray();
+#endif
//SecuROM 7 new and 8
if (bytes[3] == 0x5C) // if (bytes[0] == 0xED && bytes[3] == 0x5C {
@@ -229,7 +238,12 @@ namespace BinaryObjectScanner.Protection
else
{
index = 58; // 64 bytes for DOS stub, 122 bytes in total
+#if NETFRAMEWORK
+ bytes = new byte[2];
+ Array.Copy(pex.StubExecutableData, index, bytes, 0, 2);
+#else
bytes = new ReadOnlySpan(pex.StubExecutableData, index, 2).ToArray();
+#endif
return $"7.{bytes[0] ^ 0x10:00}.{bytes[1] ^ 0x10:0000}"; //return "7.01-7.10"
}
}
@@ -258,7 +272,13 @@ namespace BinaryObjectScanner.Protection
if (!success)
return "8";
- byte[] bytes = new ReadOnlySpan(dataSectionRaw, position + 0xAC, 3).ToArray();
+#if NETFRAMEWORK
+ byte[] bytes = new byte[3];
+ Array.Copy(dataSectionRaw, position + 0xAC, bytes, 0, 3);
+#else
+ byte[] bytes = new ReadOnlySpan(dataSectionRaw, position + 0xAC, 3).ToArray();
+#endif
+
return $"{bytes[0] ^ 0xCA}.{bytes[1] ^ 0x39:00}.{bytes[2] ^ 0x51:0000}";
}
}
diff --git a/BinaryObjectScanner/Protection/SmartE.cs b/BinaryObjectScanner/Protection/SmartE.cs
index 5be6358d..91ec91f7 100644
--- a/BinaryObjectScanner/Protection/SmartE.cs
+++ b/BinaryObjectScanner/Protection/SmartE.cs
@@ -40,7 +40,7 @@ namespace BinaryObjectScanner.Protection
}, "SmartE"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/SoftLock.cs b/BinaryObjectScanner/Protection/SoftLock.cs
index cb67f109..6ddd6b82 100644
--- a/BinaryObjectScanner/Protection/SoftLock.cs
+++ b/BinaryObjectScanner/Protection/SoftLock.cs
@@ -93,7 +93,7 @@ namespace BinaryObjectScanner.Protection
}, "SoftLock"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/SolidShield.cs b/BinaryObjectScanner/Protection/SolidShield.cs
index 2e443967..81a2862a 100644
--- a/BinaryObjectScanner/Protection/SolidShield.cs
+++ b/BinaryObjectScanner/Protection/SolidShield.cs
@@ -125,7 +125,7 @@ namespace BinaryObjectScanner.ProtectionType
};
// TODO: Verify if these are OR or AND
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
@@ -149,8 +149,21 @@ namespace BinaryObjectScanner.ProtectionType
return null;
int position = positions[0];
+
+#if NET40
+ byte[] id1 = new byte[3];
+ Array.Copy(fileContent, position + 5, id1, 0, 3);
+ byte[] id2 = new byte[4];
+ Array.Copy(fileContent, position + 16, id2, 0, 3);
+#else
var id1 = new ArraySegment(fileContent, position + 5, 3);
var id2 = new ArraySegment(fileContent, position + 16, 4);
+#endif
+
+ if (id1.SequenceEqual(new byte[] { 0x00, 0x00, 0x00 }) && id2.SequenceEqual(new byte[] { 0x00, 0x10, 0x00, 0x00 }))
+ return "v1";
+ else if (id1.SequenceEqual(new byte[] { 0x2E, 0x6F, 0x26 }) && id2.SequenceEqual(new byte[] { 0xDB, 0xC5, 0x20, 0x3A })) // new byte[] { 0xDB, 0xC5, 0x20, 0x3A, 0xB9 }
+ return "v2"; // TODO: Verify against other SolidShield 2 discs
if (id1.SequenceEqual(new byte[] { 0x00, 0x00, 0x00 }) && id2.SequenceEqual(new byte[] { 0x00, 0x10, 0x00, 0x00 }))
return "v1";
@@ -167,8 +180,15 @@ namespace BinaryObjectScanner.ProtectionType
return null;
int position = positions[0];
+#if NET40
+ byte[] id1 = new byte[3];
+ Array.Copy(fileContent, position + 4, id1, 0, 3);
+ byte[] id2 = new byte[4];
+ Array.Copy(fileContent, position + 15, id2, 0, 3);
+#else
var id1 = new ArraySegment(fileContent, position + 4, 3);
var id2 = new ArraySegment(fileContent, position + 15, 4);
+#endif
if ((fileContent[position + 3] == 0x04 || fileContent[position + 3] == 0x05)
&& id1.SequenceEqual(new byte[] { 0x00, 0x00, 0x00 })
diff --git a/BinaryObjectScanner/Protection/StarForce.cs b/BinaryObjectScanner/Protection/StarForce.cs
index 621af19d..e22786e0 100644
--- a/BinaryObjectScanner/Protection/StarForce.cs
+++ b/BinaryObjectScanner/Protection/StarForce.cs
@@ -132,7 +132,7 @@ namespace BinaryObjectScanner.Protection
}, "StarForce"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/Steam.cs b/BinaryObjectScanner/Protection/Steam.cs
index fa5d58c7..75b6b8e5 100644
--- a/BinaryObjectScanner/Protection/Steam.cs
+++ b/BinaryObjectScanner/Protection/Steam.cs
@@ -17,21 +17,21 @@ namespace BinaryObjectScanner.Protection
return null;
var name = pex.FileDescription;
- if (!string.IsNullOrEmpty(name) && name.Contains("Steam Autorun Setup"))
+ if (!string.IsNullOrEmpty(name) && name!.Contains("Steam Autorun Setup"))
return "Steam";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Steam Client API"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Steam Client API"))
return "Steam";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Steam Client Engine"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Steam Client Engine"))
return $"Steam Client Engine {pex.GetInternalVersion()}";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Steam Client Service"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Steam Client Service"))
return "Steam";
name = pex.ProductName;
- if (!string.IsNullOrEmpty(name) && name.Contains("Steam Autorun Setup"))
+ if (!string.IsNullOrEmpty(name) && name!.Contains("Steam Autorun Setup"))
return "Steam";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Steam Client API"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Steam Client API"))
return "Steam";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Steam Client Service"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Steam Client Service"))
return "Steam";
/// TODO: Add entry point checks
@@ -83,7 +83,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("steamxboxutil64.exe", useEndsWith: true), "Steam"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/TZCopyProtection.cs b/BinaryObjectScanner/Protection/TZCopyProtection.cs
index f5922802..8c92bc28 100644
--- a/BinaryObjectScanner/Protection/TZCopyProtection.cs
+++ b/BinaryObjectScanner/Protection/TZCopyProtection.cs
@@ -66,7 +66,7 @@ namespace BinaryObjectScanner.Protection
// Newer versions of TZCopyProtection also create files with a TZC extension, though their purpose is currently unknown.
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/Tages.cs b/BinaryObjectScanner/Protection/Tages.cs
index 3155fcaf..d6b12db8 100644
--- a/BinaryObjectScanner/Protection/Tages.cs
+++ b/BinaryObjectScanner/Protection/Tages.cs
@@ -150,7 +150,7 @@ namespace BinaryObjectScanner.ProtectionType
new PathMatchSet(new PathMatch("GAME.KWN", useEndsWith: true), "TAGES (BASIC?)"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
@@ -215,7 +215,7 @@ namespace BinaryObjectScanner.ProtectionType
// Check the internal versions
var version = pex.GetInternalVersion();
if (!string.IsNullOrEmpty(version))
- return version;
+ return version!;
return "(Unknown Version)";
}
diff --git a/BinaryObjectScanner/Protection/TivolaRingProtection.cs b/BinaryObjectScanner/Protection/TivolaRingProtection.cs
index 42445a40..8f73c03a 100644
--- a/BinaryObjectScanner/Protection/TivolaRingProtection.cs
+++ b/BinaryObjectScanner/Protection/TivolaRingProtection.cs
@@ -19,7 +19,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(Path.Combine("ZDAT", "webmast.dxx").Replace("\\", "/"), "Tivola Ring Protection [Check disc for physical ring]"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/Uplay.cs b/BinaryObjectScanner/Protection/Uplay.cs
index fb529053..ed619642 100644
--- a/BinaryObjectScanner/Protection/Uplay.cs
+++ b/BinaryObjectScanner/Protection/Uplay.cs
@@ -18,26 +18,26 @@ namespace BinaryObjectScanner.Protection
return null;
var name = pex.FileDescription;
- if (!string.IsNullOrEmpty(name) && name.Contains("Ubisoft Connect Installer"))
+ if (!string.IsNullOrEmpty(name) && name!.Contains("Ubisoft Connect Installer"))
return "Uplay / Ubisoft Connect";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Ubisoft Connect Service"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Ubisoft Connect Service"))
return "Uplay / Ubisoft Connect";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Ubisoft Connect WebCore"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Ubisoft Connect WebCore"))
return "Uplay / Ubisoft Connect";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Ubisoft Crash Reporter"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Ubisoft Crash Reporter"))
return "Uplay / Ubisoft Connect";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Ubisoft Game Launcher"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Ubisoft Game Launcher"))
return "Uplay / Ubisoft Connect";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Ubisoft Uplay Installer"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Ubisoft Uplay Installer"))
return "Uplay / Ubisoft Connect";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Uplay launcher"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Uplay launcher"))
return "Uplay / Ubisoft Connect";
// There's also a variant that looks like "Uplay installer"
name = pex.ProductName;
- if (!string.IsNullOrEmpty(name) && name.Contains("Ubisoft Connect"))
+ if (!string.IsNullOrEmpty(name) && name!.Contains("Ubisoft Connect"))
return "Uplay / Ubisoft Connect";
- else if (!string.IsNullOrEmpty(name) && name.Contains("Uplay"))
+ else if (!string.IsNullOrEmpty(name) && name!.Contains("Uplay"))
return "Uplay / Ubisoft Connect";
return null;
@@ -59,7 +59,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new FilePathMatch("UplayWebCore.exe"), "Uplay / Ubisoft Connect"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/WMDS.cs b/BinaryObjectScanner/Protection/WMDS.cs
index f000331b..0e07f2a5 100644
--- a/BinaryObjectScanner/Protection/WMDS.cs
+++ b/BinaryObjectScanner/Protection/WMDS.cs
@@ -56,7 +56,7 @@ namespace BinaryObjectScanner.Protection
}, "Windows Media Data Session DRM"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/WTMCDProtect.cs b/BinaryObjectScanner/Protection/WTMCDProtect.cs
index 599788b2..f0d79bf0 100644
--- a/BinaryObjectScanner/Protection/WTMCDProtect.cs
+++ b/BinaryObjectScanner/Protection/WTMCDProtect.cs
@@ -62,7 +62,7 @@ namespace BinaryObjectScanner.Protection
}, "WTM Protection Viewer"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false);
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
}
///
diff --git a/BinaryObjectScanner/Protection/WinLock.cs b/BinaryObjectScanner/Protection/WinLock.cs
index 609d6c4b..32f9c551 100644
--- a/BinaryObjectScanner/Protection/WinLock.cs
+++ b/BinaryObjectScanner/Protection/WinLock.cs
@@ -27,7 +27,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("WinLock.PSX", useEndsWith: true), "WinLock"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/Zzxzz.cs b/BinaryObjectScanner/Protection/Zzxzz.cs
index f20c0538..6e979dfb 100644
--- a/BinaryObjectScanner/Protection/Zzxzz.cs
+++ b/BinaryObjectScanner/Protection/Zzxzz.cs
@@ -18,7 +18,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet($"Zzxzz/", "Zzxzz"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/Protection/nProtect.cs b/BinaryObjectScanner/Protection/nProtect.cs
index cf314d73..2e82ee15 100644
--- a/BinaryObjectScanner/Protection/nProtect.cs
+++ b/BinaryObjectScanner/Protection/nProtect.cs
@@ -93,7 +93,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("npkpdb.dll", useEndsWith: true), "nProtect KeyCrypt"),
};
- return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true);
+ return MatchUtil.GetAllMatches(files, matchers, any: true);
}
///
diff --git a/BinaryObjectScanner/ProtectionProgress.cs b/BinaryObjectScanner/ProtectionProgress.cs
index e393cf23..cc81362a 100644
--- a/BinaryObjectScanner/ProtectionProgress.cs
+++ b/BinaryObjectScanner/ProtectionProgress.cs
@@ -3,12 +3,16 @@
///
/// Struct representing protection scanning progress
///
+#if NET40
+ public class ProtectionProgress : System.EventArgs
+#else
public struct ProtectionProgress
+#endif
{
///
/// Filename to report progress for
///
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETCOREAPP3_1
public string? Filename { get; private set; }
#else
public string? Filename { get; init; }
@@ -17,7 +21,7 @@
///
/// Value between 0 and 1 representign the percentage completed
///
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETCOREAPP3_1
public float Percentage { get; private set; }
#else
public float Percentage { get; init; }
@@ -26,7 +30,7 @@
///
/// Protection information to report
///
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETCOREAPP3_1
public string? Protection { get; private set; }
#else
public string? Protection { get; init; }
diff --git a/BinaryObjectScanner/Scanner.cs b/BinaryObjectScanner/Scanner.cs
index 60ed24f8..03eb572c 100644
--- a/BinaryObjectScanner/Scanner.cs
+++ b/BinaryObjectScanner/Scanner.cs
@@ -71,8 +71,10 @@ namespace BinaryObjectScanner
this._fileProgress = fileProgress;
+#if NET462_OR_GREATER
// Register the codepages
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+#endif
}
#region Scanning
diff --git a/README.md b/README.md
index dea02da8..a06afbac 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ The following libraries (or ports thereof) are used for file handling:
- [openmcdf](https://github.com/ironfede/openmcdf) - MSI extraction
- [SharpCompress](https://github.com/adamhathcock/sharpcompress) - Common archive format extraction
- [SharpZipLib](https://github.com/icsharpcode/SharpZipLib) - zlib-based extraction
-- [StormLibSharp](https://github.com/robpaveza/stormlibsharp) - MoPaQ extraction [Unused in .NET 6.0 builds due to Windows-specific libraries]
+- [StormLibSharp](https://github.com/robpaveza/stormlibsharp) - MoPaQ extraction [Unused in .NET 6, .NET 7, or .NET 8 builds due to Windows-specific libraries]
- [UnshieldSharp](https://github.com/mnadareski/UnshieldSharp) - InstallShield CAB extraction
- [WiseUnpacker](https://github.com/mnadareski/WiseUnpacker) - Wise Installer extraction
diff --git a/Test/Extractor.cs b/Test/Extractor.cs
index a85c6ad7..95d1f48d 100644
--- a/Test/Extractor.cs
+++ b/Test/Extractor.cs
@@ -6,6 +6,7 @@ using BinaryObjectScanner.Utilities;
using OpenMcdf;
using SabreTools.IO;
using SabreTools.Serialization.Wrappers;
+#if NET462_OR_GREATER
using SharpCompress.Archives;
using SharpCompress.Archives.GZip;
using SharpCompress.Archives.Rar;
@@ -15,6 +16,7 @@ using SharpCompress.Archives.Zip;
using SharpCompress.Compressors;
using SharpCompress.Compressors.BZip2;
using SharpCompress.Compressors.Xz;
+#endif
using UnshieldSharp.Archive;
using UnshieldSharp.Cabinet;
@@ -76,6 +78,7 @@ namespace Test
Console.WriteLine();
// If the 7-zip file itself fails
+#if NET462_OR_GREATER
try
{
using (SevenZipArchive sevenZipFile = SevenZipArchive.Open(stream))
@@ -105,6 +108,10 @@ namespace Test
Console.WriteLine($"Something went wrong extracting 7-zip: {ex}");
Console.WriteLine();
}
+#else
+ Console.WriteLine($"Extracting 7-zip not supported on this .NET version");
+ Console.WriteLine();
+#endif
}
// BFPK archive
@@ -169,6 +176,7 @@ namespace Test
Console.WriteLine("Extracting bzip2 contents");
Console.WriteLine();
+#if NET462_OR_GREATER
using (var bz2File = new BZip2Stream(stream, CompressionMode.Decompress, true))
{
// If an individual entry fails
@@ -186,6 +194,10 @@ namespace Test
Console.WriteLine();
}
}
+#else
+ Console.WriteLine($"Extracting bzip2 not supported on this .NET version");
+ Console.WriteLine();
+#endif
}
// CFB
@@ -274,6 +286,7 @@ namespace Test
Console.WriteLine("Extracting gzip contents");
Console.WriteLine();
+#if NET462_OR_GREATER
using (var zipFile = GZipArchive.Open(stream))
{
foreach (var entry in zipFile.Entries)
@@ -296,6 +309,10 @@ namespace Test
}
}
}
+#else
+ Console.WriteLine($"Extracting gzip not supported on this .NET version");
+ Console.WriteLine();
+#endif
}
// InstallShield Archive V3 (Z)
@@ -449,7 +466,7 @@ namespace Test
}
}
-#if NET48
+#if NETFRAMEWORK && !NET40
// MoPaQ (MPQ) archive
else if (ft == SupportedFileType.MPQ)
{
@@ -570,6 +587,7 @@ namespace Test
Console.WriteLine();
// If the zip file itself fails
+#if NET462_OR_GREATER
try
{
using (ZipArchive zipFile = ZipArchive.Open(stream))
@@ -600,6 +618,10 @@ namespace Test
Console.WriteLine($"Something went wrong extracting PKZIP: {ex}");
Console.WriteLine();
}
+#else
+ Console.WriteLine($"Extracting PKZIP not supported on this .NET version");
+ Console.WriteLine();
+#endif
}
// Quantum
@@ -637,6 +659,7 @@ namespace Test
Console.WriteLine();
// If the rar file itself fails
+#if NET462_OR_GREATER
try
{
using (RarArchive rarFile = RarArchive.Open(stream))
@@ -666,6 +689,10 @@ namespace Test
Console.WriteLine($"Something went wrong extracting RAR: {ex}");
Console.WriteLine();
}
+#else
+ Console.WriteLine($"Extracting RAR not supported on this .NET version");
+ Console.WriteLine();
+#endif
}
// SGA
@@ -702,7 +729,8 @@ namespace Test
Console.WriteLine("Extracting Tape Archive contents");
Console.WriteLine();
- // If the rar file itself fails
+ // If the tar file itself fails
+#if NET462_OR_GREATER
try
{
using (TarArchive tarFile = TarArchive.Open(stream))
@@ -732,6 +760,10 @@ namespace Test
Console.WriteLine($"Something went wrong extracting Tape Archive: {ex}");
Console.WriteLine();
}
+#else
+ Console.WriteLine($"Extracting Tape Archive not supported on this .NET version");
+ Console.WriteLine();
+#endif
}
// VBSP
@@ -822,6 +854,7 @@ namespace Test
Console.WriteLine("Extracting xz contents");
Console.WriteLine();
+#if NET462_OR_GREATER
using (var xzFile = new XZStream(stream))
{
// If an individual entry fails
@@ -839,6 +872,10 @@ namespace Test
Console.WriteLine();
}
}
+#else
+ Console.WriteLine($"Extracting xz not supported on this .NET version");
+ Console.WriteLine();
+#endif
}
// XZP
diff --git a/Test/Options.cs b/Test/Options.cs
index 71f87d20..ef241765 100644
--- a/Test/Options.cs
+++ b/Test/Options.cs
@@ -42,7 +42,7 @@ namespace Test
///
public bool EnableInformation { get; private set; } = false;
-#if NET6_0_OR_GREATER
+#if NETCOREAPP3_1_OR_GREATER
///
/// Enable JSON output
///
diff --git a/Test/Program.cs b/Test/Program.cs
index 24d71670..65bdb8f7 100644
--- a/Test/Program.cs
+++ b/Test/Program.cs
@@ -8,8 +8,10 @@ namespace Test
{
static void Main(string[] args)
{
+#if NET462_OR_GREATER
// Register the codepages
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+#endif
// Create progress indicator
var fileProgress = new Progress();
diff --git a/Test/Test.csproj b/Test/Test.csproj
index 84aca277..06cabb7d 100644
--- a/Test/Test.csproj
+++ b/Test/Test.csproj
@@ -1,9 +1,8 @@
- net48;net6.0;net7.0
- win-x86;win-x64;linux-x64;osx-x64
- false
+ net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0
+ win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64
Exe
@@ -13,13 +12,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+