Matching to 1.1.1, OpenMcdf to 2.3.0

This commit is contained in:
Matt Nadareski
2023-09-18 15:53:24 -04:00
parent 0c5dff71e9
commit adf9ce5e2a
66 changed files with 188 additions and 66 deletions

View File

@@ -47,10 +47,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="OpenMcdf" Version="2.2.1.12" />
<PackageReference Include="OpenMcdf" Version="2.3.0" />
<PackageReference Include="SabreTools.Compression" Version="0.1.0" />
<PackageReference Include="SabreTools.IO" Version="1.1.1" />
<PackageReference Include="SabreTools.Matching" Version="1.1.0" />
<PackageReference Include="SabreTools.Matching" Version="1.1.1" />
<PackageReference Include="SabreTools.Serialization" Version="1.1.5" />
<PackageReference Include="SharpCompress" Version="0.32.2" />
<PackageReference Include="SharpZipLib" Version="1.4.1" />

View File

@@ -108,7 +108,7 @@ namespace BinaryObjectScanner
#if NET48
public static ConcurrentDictionary<string, ConcurrentQueue<string>> HandleExtractable(IExtractable impl, string fileName, Stream stream, Scanner scanner)
#else
public static ConcurrentDictionary<string, ConcurrentQueue<string>>? HandleExtractable(IExtractable impl, string fileName, Stream stream, Scanner scanner)
public static ConcurrentDictionary<string, ConcurrentQueue<string>>? HandleExtractable(IExtractable impl, string fileName, Stream? stream, Scanner scanner)
#endif
{
// If the extractable file itself fails
@@ -154,7 +154,7 @@ namespace BinaryObjectScanner
#if NET48
private static ConcurrentQueue<string> PerformCheck(this IPathCheck impl, string path, IEnumerable<string> files)
#else
private static ConcurrentQueue<string>? PerformCheck(this IPathCheck impl, string path, IEnumerable<string> files)
private static ConcurrentQueue<string>? PerformCheck(this IPathCheck impl, string? path, IEnumerable<string>? files)
#endif
{
// If we have an invalid path

View File

@@ -88,7 +88,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, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -27,7 +27,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, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -38,7 +38,7 @@ namespace BinaryObjectScanner.Protection
}, "Bitpool"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -148,7 +148,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("Byteshield.ini", useEndsWith: true), "ByteShield"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -167,7 +167,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, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>
@@ -194,8 +194,16 @@ namespace BinaryObjectScanner.Protection
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
#if NET48
public static string GetVersion(string file, byte[] fileContent, List<int> positions)
#else
public static string? GetVersion(string file, byte[]? fileContent, List<int> positions)
#endif
{
// If we have no content
if (fileContent == null)
return null;
char[] version = new ArraySegment<byte>(fileContent, positions[0] + 15, 4).Select(b => (char)b).ToArray();
if (version[0] == 0x00)
return string.Empty;

View File

@@ -71,7 +71,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("cdguard.dll", useEndsWith: true), "CD-Guard Copy Protection System"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -81,7 +81,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, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -39,7 +39,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("Track#1 - Track#2 Cd-Protector.wav", useEndsWith: true), "CD-Protector"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -22,7 +22,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, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -70,7 +70,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("cenega.dll", useEndsWith: true), "Cenega ProtectDVD"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -73,7 +73,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("Code-Lock Wizard.exe", useEndsWith: true), "ChosenBytes Code-Lock"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -47,7 +47,7 @@ namespace BinaryObjectScanner.Protection
//new PathMatchSet(new PathMatch("Autorun.dat", useEndsWith: true), "CopyKiller"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -19,7 +19,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, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -17,6 +17,8 @@ namespace BinaryObjectScanner.Protection
#endif
{
var protections = new ConcurrentQueue<string>();
if (files == null)
return protections;
if (Directory.Exists(Path.Combine(path, "VIDEO_TS")))
{

View File

@@ -278,7 +278,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("Denuvo Anti-Cheat Installer.exe", useEndsWith: true), "Denuvo Anti-Cheat"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>

View File

@@ -22,7 +22,11 @@ namespace BinaryObjectScanner.Protection
// https://www.gamecopyworld.com/games/pc_pc_calcio_2000.shtml
// https://www.gamecopyworld.com/games/pc_pc_futbol_2000.shtml
#if NET48
public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string> files)
#else
public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string>? files)
#endif
{
var matchers = new List<PathMatchSet>
{
@@ -38,7 +42,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, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -171,7 +171,7 @@ namespace BinaryObjectScanner.Protection
}, "DiscGuard"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>
@@ -206,8 +206,16 @@ namespace BinaryObjectScanner.Protection
}
/// <inheritdoc/>
#if NET48
private string GetVersion(string file, byte[] fileContent, List<int> positions)
#else
private string? GetVersion(string file, byte[]? fileContent, List<int> positions)
#endif
{
// If we have no content
if (fileContent == null)
return null;
// Check the internal versions
string version = GetInternalVersion(file, Array.Empty<string>());
if (!string.IsNullOrEmpty(version))

View File

@@ -131,7 +131,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("easyanticheat_x64.so", useEndsWith: true), "Easy Anti-Cheat"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -66,7 +66,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, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -52,7 +52,7 @@ namespace BinaryObjectScanner.Protection
}, "Freelock 1.3"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>

View File

@@ -54,7 +54,7 @@ namespace BurnOutSharp.ProtectionType
new PathMatchSet(new PathMatch("XLiveRedist.msi", useEndsWith: true), "Games for Windows LIVE"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -54,7 +54,7 @@ namespace BinaryObjectScanner.Protection
// Possibly related file "31AD0095.fil" that appears to contain intentional errors found in Redump entry 93700.
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -107,7 +107,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("HCPSMng.exe", useEndsWith: true), "HexaLock AutoLock 4.5"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>

View File

@@ -70,7 +70,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("ReactorActivate.exe", useEndsWith: true), GetInternalVersion, "Stardock Product Activation"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -25,7 +25,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("INDYMP3.idt", useEndsWith: true), "IndyVCD (Unconfirmed - Please report to us on Github)"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -70,8 +70,16 @@ namespace BinaryObjectScanner.Protection
return null;
}
#if NET48
public static string GetVersion(string file, byte[] fileContent, List<int> positions)
#else
public static string? GetVersion(string file, byte[]? fileContent, List<int> positions)
#endif
{
// If we have no content
if (fileContent == null)
return null;
int position = positions[0];
char[] version = new ArraySegment<byte>(fileContent, position + 67, 8).Select(b => (char)b).ToArray();
return new string(version);

View File

@@ -77,7 +77,7 @@ namespace BinaryObjectScanner.Protection
}, "LabelGate CD2"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>

View File

@@ -136,7 +136,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("laserlok.out", useEndsWith: true), "LaserLok [Check disc for physical ring]"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -195,7 +195,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("CDILLA16.EXE", useEndsWith: true), "C-Dilla License Management System"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc cref="Interfaces.IPathCheck.CheckFilePath(string)"/>

View File

@@ -68,7 +68,11 @@ namespace BinaryObjectScanner.Protection
}
/// <inheritdoc cref="Interfaces.IPathCheck.CheckDirectoryPath(string, IEnumerable{string})"/>
#if NET48
internal ConcurrentQueue<string> CactusDataShieldCheckDirectoryPath(string path, IEnumerable<string> files)
#else
internal ConcurrentQueue<string> CactusDataShieldCheckDirectoryPath(string path, IEnumerable<string>? files)
#endif
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -91,7 +95,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, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc cref="Interfaces.IPathCheck.CheckFilePath(string)"/>
@@ -124,8 +128,16 @@ namespace BinaryObjectScanner.Protection
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
#if NET48
public static string GetCactusDataShieldVersion(string firstMatchedString, IEnumerable<string> files)
#else
public static string? GetCactusDataShieldVersion(string firstMatchedString, IEnumerable<string>? files)
#endif
{
// If we have no files
if (files == null)
return null;
// Find the version.txt file first
var versionPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("version.txt", StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrWhiteSpace(versionPath))

View File

@@ -75,7 +75,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("9KMJ9G4I.EXE", useEndsWith: true), "RipGuard (Unconfirmed - Please report to us on GitHub)"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc cref="Interfaces.IPathCheck.CheckFilePath(string)"/>

View File

@@ -191,7 +191,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("CDAC13BA.EXE", useEndsWith: true), "SafeCast"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc cref="Interfaces.IPathCheck.CheckFilePath(string)"/>

View File

@@ -218,7 +218,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(".SafeDiscDVD.bundle", "SafeDisc for Macintosh"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc cref="Interfaces.IPathCheck.CheckFilePath(string)"/>

View File

@@ -260,7 +260,11 @@ namespace BinaryObjectScanner.Protection
}
/// <inheritdoc cref="IPathCheck.CheckDirectoryPath(string, IEnumerable{string})"/>
#if NET48
internal ConcurrentQueue<string> MacrovisionCheckDirectoryPath(string path, IEnumerable<string> files)
#else
internal ConcurrentQueue<string> MacrovisionCheckDirectoryPath(string path, IEnumerable<string>? files)
#endif
{
var matchers = new List<PathMatchSet>
{
@@ -268,7 +272,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new FilePathMatch("secdrv.sys"), GetSecdrvFileSizeVersion, "Macrovision Security Driver"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc cref="IPathCheck.CheckFilePath(string)"/>
@@ -470,8 +474,16 @@ namespace BinaryObjectScanner.Protection
return null;
}
#if NET48
internal static string GetMacrovisionVersion(string file, byte[] fileContent, List<int> positions)
#else
internal static string? GetMacrovisionVersion(string file, byte[]? fileContent, List<int> positions)
#endif
{
// If we have no content
if (fileContent == null)
return null;
// Begin reading 2 bytes after "BoG_ *90.0&!! Yy>" for older versions
int index = positions[0] + 18 + 2;
int version = fileContent.ReadInt32(ref index);

View File

@@ -55,7 +55,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("scvfy.exe", useEndsWith: true), "MediaCloQ"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -94,7 +94,7 @@ namespace BinaryObjectScanner.Protection
}, "MediaMax CD-3"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>

View File

@@ -73,7 +73,7 @@ namespace BinaryObjectScanner.Protection
// Known associated log files: "NeacSafe.log", "Neac.log", "NeacDll.log", "NeacLoader.log", and "NeacBak.log".
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -95,7 +95,7 @@ namespace BinaryObjectScanner.Protection
}, "OpenMG"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>

View File

@@ -44,7 +44,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("OriginSetup.exe", useEndsWith: true), "Origin"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -61,7 +61,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("PJSTREAM.DLL", useEndsWith: true), "PlayJ Music Player Component"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>

View File

@@ -17,6 +17,8 @@ namespace BinaryObjectScanner.Protection
#endif
{
var protections = new ConcurrentQueue<string>();
if (files == null)
return protections;
if (Directory.Exists(Path.Combine(path, "VIDEO_TS")))
{

View File

@@ -117,8 +117,16 @@ namespace BinaryObjectScanner.Protection
return matchedStringArray[2].TrimStart('V');
}
#if NET48
public static string GetVersion3till6(string file, byte[] fileContent, List<int> positions)
#else
public static string? GetVersion3till6(string file, byte[]? fileContent, List<int> positions)
#endif
{
// If we have no content
if (fileContent == null)
return null;
string version = GetVOBVersion(fileContent, positions[0]);
if (version.Length > 0)
return version;
@@ -126,8 +134,16 @@ namespace BinaryObjectScanner.Protection
return $"5.9-6.0 {GetVOBBuild(fileContent, positions[0])}";
}
#if NET48
public static string GetVersion6till8(string file, byte[] fileContent, List<int> positions)
#else
public static string? GetVersion6till8(string file, byte[]? fileContent, List<int> positions)
#endif
{
// If we have no content
if (fileContent == null)
return null;
string version, strBuild = string.Empty;
int index = positions[0] - 12;
@@ -178,8 +194,16 @@ namespace BinaryObjectScanner.Protection
}
}
#if NET48
public static string GetVersion76till10(string file, byte[] fileContent, List<int> positions)
#else
public static string? GetVersion76till10(string file, byte[]? fileContent, List<int> positions)
#endif
{
// If we have no content
if (fileContent == null)
return null;
int index = positions[0] + 37;
byte subversion = fileContent[index];
index += 2;

View File

@@ -134,7 +134,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("SX32W.DLL", useEndsWith: true), "Rainbow Sentinel"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -50,7 +50,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("protect.pro", useEndsWith: true), "Ring PROTECH / ProRing [Check disc for physical ring]"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -110,7 +110,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new FilePathMatch("svkpnd.dll"), "SVKP"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>

View File

@@ -36,7 +36,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("SafeLock.256", useEndsWith: true), "SafeLock"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -138,7 +138,7 @@ namespace BinaryObjectScanner.Protection
}, "SecuROM 7.01"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>
@@ -192,8 +192,16 @@ namespace BinaryObjectScanner.Protection
return $"{version}.{subVersion}.{subSubVersion}.{subSubSubVersion}";
}
#if NET48
public static string GetV5Version(string file, byte[] fileContent, List<int> positions)
#else
public static string? GetV5Version(string file, byte[]? fileContent, List<int> positions)
#endif
{
// If we have no content
if (fileContent == null)
return null;
int index = positions[0] + 8; // Begin reading after "ÊÝݬ"
byte version = (byte)(fileContent[index] & 0x0F);
index += 2;

View File

@@ -48,7 +48,7 @@ namespace BinaryObjectScanner.Protection
}, "SmartE"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -101,7 +101,7 @@ namespace BinaryObjectScanner.Protection
}, "SoftLock"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>

View File

@@ -133,7 +133,7 @@ namespace BurnOutSharp.ProtectionType
};
// TODO: Verify if these are OR or AND
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>
@@ -154,8 +154,16 @@ namespace BurnOutSharp.ProtectionType
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
#if NET48
public static string GetExeWrapperVersion(string file, byte[] fileContent, List<int> positions)
#else
public static string? GetExeWrapperVersion(string file, byte[]? fileContent, List<int> positions)
#endif
{
// If we have no content
if (fileContent == null)
return null;
int position = positions[0];
var id1 = new ArraySegment<byte>(fileContent, position + 5, 3);
var id2 = new ArraySegment<byte>(fileContent, position + 16, 4);
@@ -168,8 +176,16 @@ namespace BurnOutSharp.ProtectionType
return string.Empty;
}
#if NET48
public static string GetVersionPlusTages(string file, byte[] fileContent, List<int> positions)
#else
public static string? GetVersionPlusTages(string file, byte[]? fileContent, List<int> positions)
#endif
{
// If we have no content
if (fileContent == null)
return null;
int position = positions[0];
var id1 = new ArraySegment<byte>(fileContent, position + 4, 3);
var id2 = new ArraySegment<byte>(fileContent, position + 15, 4);

View File

@@ -140,7 +140,7 @@ namespace BinaryObjectScanner.Protection
}, "StarForce"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>

View File

@@ -91,7 +91,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("steamxboxutil64.exe", useEndsWith: true), "Steam"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -70,7 +70,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, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -158,7 +158,7 @@ namespace BurnOutSharp.ProtectionType
new PathMatchSet(new PathMatch("GAME.KWN", useEndsWith: true), "TAGES (BASIC?)"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>
@@ -232,8 +232,16 @@ namespace BurnOutSharp.ProtectionType
return "(Unknown Version)";
}
#if NET48
public static string GetVersion(string file, byte[] fileContent, List<int> positions)
#else
public static string? GetVersion(string file, byte[]? fileContent, List<int> positions)
#endif
{
// If we have no content
if (fileContent == null)
return null;
// TODO: Determine difference between API and BASIC
byte typeByte = fileContent[positions[0] + 6];
byte versionByte = fileContent[positions[0] + 7];

View File

@@ -23,7 +23,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(Path.Combine("ZDAT", "webmast.dxx").Replace("\\", "/"), "Tivola Ring Protection [Check disc for physical ring]"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -67,7 +67,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new FilePathMatch("UplayWebCore.exe"), "Uplay / Ubisoft Connect"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -64,7 +64,7 @@ namespace BinaryObjectScanner.Protection
}, "Windows Media Data Session DRM"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>

View File

@@ -70,7 +70,7 @@ namespace BinaryObjectScanner.Protection
}, "WTM Protection Viewer"),
};
return MatchUtil.GetAllMatches(files, matchers, any: false);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: false);
}
/// <inheritdoc/>

View File

@@ -31,7 +31,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("WinLock.PSX", useEndsWith: true), "WinLock"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -56,6 +56,8 @@ namespace BinaryObjectScanner.Protection
#endif
{
var protections = new ConcurrentQueue<string>();
if (files == null)
return protections;
// TODO: Verify if these are OR or AND
if (files.Any(f => Path.GetFileName(f).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase))

View File

@@ -22,7 +22,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet($"Zzxzz/", "Zzxzz"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -101,7 +101,7 @@ namespace BinaryObjectScanner.Protection
new PathMatchSet(new PathMatch("npkpdb.dll", useEndsWith: true), "nProtect KeyCrypt"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
return MatchUtil.GetAllMatches(files ?? System.Array.Empty<string>(), matchers, any: true);
}
/// <inheritdoc/>

View File

@@ -90,7 +90,11 @@ namespace BinaryObjectScanner
/// </summary>
/// <param name="path">Path to scan</param>
/// <returns>Dictionary of list of strings representing the found protections</returns>
#if NET48
public ConcurrentDictionary<string, ConcurrentQueue<string>> GetProtections(string path)
#else
public ConcurrentDictionary<string, ConcurrentQueue<string>>? GetProtections(string path)
#endif
{
return GetProtections(new List<string> { path });
}
@@ -172,7 +176,7 @@ namespace BinaryObjectScanner
// Checkpoint
protections.TryGetValue(file, out var fullProtectionList);
string fullProtection = (fullProtectionList != null && fullProtectionList.Any() ? string.Join(", ", fullProtectionList) : null);
var fullProtection = (fullProtectionList != null && fullProtectionList.Any() ? string.Join(", ", fullProtectionList) : null);
this._fileProgress?.Report(new ProtectionProgress(reportableFileName, (i + 1) / (float)files.Count, fullProtection ?? string.Empty));
}
}
@@ -210,7 +214,7 @@ namespace BinaryObjectScanner
// Checkpoint
protections.TryGetValue(path, out var fullProtectionList);
string fullProtection = (fullProtectionList != null && fullProtectionList.Any() ? string.Join(", ", fullProtectionList) : null);
var fullProtection = (fullProtectionList != null && fullProtectionList.Any() ? string.Join(", ", fullProtectionList) : null);
this._fileProgress?.Report(new ProtectionProgress(reportableFileName, 1, fullProtection ?? string.Empty));
}
@@ -340,7 +344,7 @@ namespace BinaryObjectScanner
AppendToDictionary(protections, fileName, subProtections);
}
string subProtection = detectable.Detect(stream, fileName, IncludeDebug);
var subProtection = detectable.Detect(stream, fileName, IncludeDebug);
if (!string.IsNullOrWhiteSpace(subProtection))
{
// If we have an indicator of multiple protections
@@ -505,6 +509,10 @@ namespace BinaryObjectScanner
var extractables = classes.Where(c => c is IExtractable).Select(c => c as IExtractable);
Parallel.ForEach(extractables, extractable =>
{
// If we have an invalid extractable somehow
if (extractable == null)
return;
// Get the protection for the class, if possible
var extractedProtections = Handler.HandleExtractable(extractable, fileName, stream, this);
if (extractedProtections != null)

View File

@@ -12,10 +12,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="OpenMcdf" Version="2.2.1.12" />
<PackageReference Include="OpenMcdf" Version="2.3.0" />
<PackageReference Include="SabreTools.Compression" Version="0.1.0" />
<PackageReference Include="SabreTools.IO" Version="1.1.1" />
<PackageReference Include="SabreTools.Matching" Version="1.1.0" />
<PackageReference Include="SabreTools.Matching" Version="1.1.1" />
<PackageReference Include="SabreTools.Models" Version="1.1.2" />
<PackageReference Include="SabreTools.Printing" Version="1.1.0" />
<PackageReference Include="SabreTools.Serialization" Version="1.1.5" />