mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-22 08:42:51 +00:00
Version gate remaining Linq statements
This commit is contained in:
@@ -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";
|
||||
|
||||
|
||||
@@ -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!;
|
||||
}
|
||||
|
||||
@@ -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<string>();
|
||||
foreach (string result in resultsList)
|
||||
{
|
||||
if (!distinct.Contains(result))
|
||||
distinct.Add(result);
|
||||
}
|
||||
|
||||
distinct.Sort();
|
||||
return distinct;
|
||||
#else
|
||||
return [.. resultsList.Distinct().OrderBy(s => s)];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user