diff --git a/BinaryObjectScanner/BinaryObjectScanner.csproj b/BinaryObjectScanner/BinaryObjectScanner.csproj
index f5bb3863..c4c3629c 100644
--- a/BinaryObjectScanner/BinaryObjectScanner.csproj
+++ b/BinaryObjectScanner/BinaryObjectScanner.csproj
@@ -69,7 +69,6 @@
-
diff --git a/BinaryObjectScanner/FileType/Executable.cs b/BinaryObjectScanner/FileType/Executable.cs
index 654b26c6..c1bc3a4b 100644
--- a/BinaryObjectScanner/FileType/Executable.cs
+++ b/BinaryObjectScanner/FileType/Executable.cs
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
+#if NET35_OR_GREATER || NETCOREAPP
using System.Linq;
+#endif
using BinaryObjectScanner.Data;
using BinaryObjectScanner.Interfaces;
using SabreTools.IO.Extensions;
@@ -267,9 +269,20 @@ namespace BinaryObjectScanner.FileType
return protections;
// If we have any extractable packers
+#if NET20
+ var extractables = new List>();
+ foreach (var check in checks)
+ {
+ if (check == null || check is not IExtractableExecutable extractable)
+ continue;
+
+ extractables.Add(extractable);
+ }
+#else
var extractables = checks
.Where(c => c is IExtractableExecutable)
.Select(c => c as IExtractableExecutable);
+#endif
extractables.IterateWithAction(extractable =>
{
var subProtections = PerformExtractableCheck(extractable!, file, exe, getProtections, includeDebug);
diff --git a/BinaryObjectScanner/Protection/CDDVDCops.cs b/BinaryObjectScanner/Protection/CDDVDCops.cs
index 84152581..5e264d27 100644
--- a/BinaryObjectScanner/Protection/CDDVDCops.cs
+++ b/BinaryObjectScanner/Protection/CDDVDCops.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
+#if NET35_OR_GREATER || NETCOREAPP
using System.Linq;
+#endif
using System.Text;
using BinaryObjectScanner.Interfaces;
using SabreTools.Matching;
@@ -125,9 +127,28 @@ namespace BinaryObjectScanner.Protection
// Check the imported-name table
// Found in "h3blade.exe" in Redump entry 85077.
+#if NET20
+ bool intMatch = false;
+ if (nex.Model.ImportedNameTable?.Values != null)
+ {
+ foreach (var inte in nex.Model.ImportedNameTable.Values)
+ {
+ if (inte?.NameString == null || inte.NameString.Length == 0)
+ continue;
+
+ string ns = Encoding.ASCII.GetString(inte.NameString);
+ if (ns.Contains("CDCOPS"))
+ {
+ intMatch = true;
+ break;
+ }
+ }
+ }
+#else
bool intMatch = nex.Model.ImportedNameTable?.Values?
.Select(inte => inte?.NameString == null ? string.Empty : Encoding.ASCII.GetString(inte.NameString))
.Any(s => s.Contains("CDCOPS")) ?? false;
+#endif
if (intMatch)
return "CD-Cops";
diff --git a/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs b/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs
index f914c7b9..117d328c 100644
--- a/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs
+++ b/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
+#if NET35_OR_GREATER || NETCOREAPP
using System.Linq;
+#endif
using System.Text;
using SabreTools.Matching;
using SabreTools.Matching.Paths;
@@ -121,10 +123,22 @@ namespace BinaryObjectScanner.Protection
return string.Empty;
// Find the version.txt file first
+#if NET20
+ string? versionPath = null;
+ foreach (string file in files)
+ {
+ if (Path.GetFileName(file).Equals("version.txt", StringComparison.OrdinalIgnoreCase))
+ {
+ versionPath = file;
+ break;
+ }
+ }
+#else
var versionPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("version.txt", StringComparison.OrdinalIgnoreCase));
+#endif
if (!string.IsNullOrEmpty(versionPath))
{
- var version = GetCactusDataShieldInternalVersion(versionPath);
+ var version = GetCactusDataShieldInternalVersion(versionPath!);
if (!string.IsNullOrEmpty(version))
return version!;
}
diff --git a/BinaryObjectScanner/Protection/Macrovision.cs b/BinaryObjectScanner/Protection/Macrovision.cs
index ff9247ad..095b97ce 100644
--- a/BinaryObjectScanner/Protection/Macrovision.cs
+++ b/BinaryObjectScanner/Protection/Macrovision.cs
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
+#if NET35_OR_GREATER || NETCOREAPP
using System.Linq;
+#endif
using BinaryObjectScanner.Interfaces;
using SabreTools.IO.Extensions;
using SabreTools.Matching;
@@ -631,7 +633,19 @@ namespace BinaryObjectScanner.Protection
}
// Get distinct and order
+#if NET20
+ var distinct = new List();
+ foreach (string result in resultsList)
+ {
+ if (!distinct.Contains(result))
+ distinct.Add(result);
+ }
+
+ distinct.Sort();
+ return distinct;
+#else
return [.. resultsList.Distinct().OrderBy(s => s)];
+#endif
}
}
}
diff --git a/ProtectionScan/Program.cs b/ProtectionScan/Program.cs
index 8e93712f..c45963de 100644
--- a/ProtectionScan/Program.cs
+++ b/ProtectionScan/Program.cs
@@ -1,6 +1,8 @@
using System;
using System.IO;
+#if NET35_OR_GREATER || NETCOREAPP
using System.Linq;
+#endif
using BinaryObjectScanner;
namespace ProtectionScan
@@ -85,13 +87,26 @@ namespace ProtectionScan
}
using var sw = new StreamWriter(File.OpenWrite($"protection-{DateTime.Now:yyyy-MM-dd_HHmmss.ffff}.txt"));
+#if NET20
+ var keysArr = new string[protections.Keys.Count];
+ protections.Keys.CopyTo(keysArr, 0);
+ Array.Sort(keysArr);
+ foreach (string key in keysArr)
+#else
foreach (string key in protections.Keys.OrderBy(k => k))
+#endif
{
// Skip over files with no protection
if (protections[key] == null || protections[key].Count == 0)
continue;
- string line = $"{key}: {string.Join(", ", [.. protections[key].OrderBy(p => p)])}";
+#if NET20
+ string[] fileProtections = [.. protections[key]];
+ Array.Sort(fileProtections);
+#else
+ string[] fileProtections = [.. protections[key].OrderBy(p => p)];
+#endif
+ string line = $"{key}: {string.Join(", ", fileProtections)}";
Console.WriteLine(line);
sw.WriteLine(line);
}