diff --git a/BinaryObjectScanner/BinaryObjectScanner.csproj b/BinaryObjectScanner/BinaryObjectScanner.csproj index 65725a6b..40199766 100644 --- a/BinaryObjectScanner/BinaryObjectScanner.csproj +++ b/BinaryObjectScanner/BinaryObjectScanner.csproj @@ -47,10 +47,10 @@ - + - + diff --git a/BinaryObjectScanner/Handler.cs b/BinaryObjectScanner/Handler.cs index a3423647..823eadb5 100644 --- a/BinaryObjectScanner/Handler.cs +++ b/BinaryObjectScanner/Handler.cs @@ -108,7 +108,7 @@ namespace BinaryObjectScanner #if NET48 public static ConcurrentDictionary> HandleExtractable(IExtractable impl, string fileName, Stream stream, Scanner scanner) #else - public static ConcurrentDictionary>? HandleExtractable(IExtractable impl, string fileName, Stream stream, Scanner scanner) + public static ConcurrentDictionary>? 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 PerformCheck(this IPathCheck impl, string path, IEnumerable files) #else - private static ConcurrentQueue? PerformCheck(this IPathCheck impl, string path, IEnumerable files) + private static ConcurrentQueue? PerformCheck(this IPathCheck impl, string? path, IEnumerable? files) #endif { // If we have an invalid path diff --git a/BinaryObjectScanner/Protection/AegiSoft.cs b/BinaryObjectScanner/Protection/AegiSoft.cs index bf820fcb..7ac980c6 100644 --- a/BinaryObjectScanner/Protection/AegiSoft.cs +++ b/BinaryObjectScanner/Protection/AegiSoft.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/AlphaDVD.cs b/BinaryObjectScanner/Protection/AlphaDVD.cs index 0a2049ef..be08cd61 100644 --- a/BinaryObjectScanner/Protection/AlphaDVD.cs +++ b/BinaryObjectScanner/Protection/AlphaDVD.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/Bitpool.cs b/BinaryObjectScanner/Protection/Bitpool.cs index ae74ad4f..e516baf9 100644 --- a/BinaryObjectScanner/Protection/Bitpool.cs +++ b/BinaryObjectScanner/Protection/Bitpool.cs @@ -38,7 +38,7 @@ namespace BinaryObjectScanner.Protection }, "Bitpool"), }; - return MatchUtil.GetAllMatches(files, matchers, any: true); + return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/ByteShield.cs b/BinaryObjectScanner/Protection/ByteShield.cs index 0e4a3ce1..302d373b 100644 --- a/BinaryObjectScanner/Protection/ByteShield.cs +++ b/BinaryObjectScanner/Protection/ByteShield.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/CDDVDCops.cs b/BinaryObjectScanner/Protection/CDDVDCops.cs index 95810992..f9734862 100644 --- a/BinaryObjectScanner/Protection/CDDVDCops.cs +++ b/BinaryObjectScanner/Protection/CDDVDCops.cs @@ -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(), matchers, any: true); } /// @@ -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 positions) +#else + public static string? GetVersion(string file, byte[]? fileContent, List positions) +#endif { + // If we have no content + if (fileContent == null) + return null; + char[] version = new ArraySegment(fileContent, positions[0] + 15, 4).Select(b => (char)b).ToArray(); if (version[0] == 0x00) return string.Empty; diff --git a/BinaryObjectScanner/Protection/CDGuard.cs b/BinaryObjectScanner/Protection/CDGuard.cs index b663b60a..ed55e883 100644 --- a/BinaryObjectScanner/Protection/CDGuard.cs +++ b/BinaryObjectScanner/Protection/CDGuard.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/CDLock.cs b/BinaryObjectScanner/Protection/CDLock.cs index 2db9955b..580b34b5 100644 --- a/BinaryObjectScanner/Protection/CDLock.cs +++ b/BinaryObjectScanner/Protection/CDLock.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/CDProtector.cs b/BinaryObjectScanner/Protection/CDProtector.cs index a3a90601..8aa7cb4a 100644 --- a/BinaryObjectScanner/Protection/CDProtector.cs +++ b/BinaryObjectScanner/Protection/CDProtector.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/CDX.cs b/BinaryObjectScanner/Protection/CDX.cs index f7e77841..4c1729e4 100644 --- a/BinaryObjectScanner/Protection/CDX.cs +++ b/BinaryObjectScanner/Protection/CDX.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/CenegaProtectDVD.cs b/BinaryObjectScanner/Protection/CenegaProtectDVD.cs index ed25050d..100d307a 100644 --- a/BinaryObjectScanner/Protection/CenegaProtectDVD.cs +++ b/BinaryObjectScanner/Protection/CenegaProtectDVD.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs b/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs index 6c59111f..18f42e5b 100644 --- a/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs +++ b/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/CopyKiller.cs b/BinaryObjectScanner/Protection/CopyKiller.cs index 9db3fa66..ef54fdbe 100644 --- a/BinaryObjectScanner/Protection/CopyKiller.cs +++ b/BinaryObjectScanner/Protection/CopyKiller.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/DVDCrypt.cs b/BinaryObjectScanner/Protection/DVDCrypt.cs index 19f5d1d8..85005fb3 100644 --- a/BinaryObjectScanner/Protection/DVDCrypt.cs +++ b/BinaryObjectScanner/Protection/DVDCrypt.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/DVDMoviePROTECT.cs b/BinaryObjectScanner/Protection/DVDMoviePROTECT.cs index e18cf0d1..5c25fecf 100644 --- a/BinaryObjectScanner/Protection/DVDMoviePROTECT.cs +++ b/BinaryObjectScanner/Protection/DVDMoviePROTECT.cs @@ -17,6 +17,8 @@ namespace BinaryObjectScanner.Protection #endif { var protections = new ConcurrentQueue(); + if (files == null) + return protections; if (Directory.Exists(Path.Combine(path, "VIDEO_TS"))) { diff --git a/BinaryObjectScanner/Protection/Denuvo.cs b/BinaryObjectScanner/Protection/Denuvo.cs index 7eeda872..22eab599 100644 --- a/BinaryObjectScanner/Protection/Denuvo.cs +++ b/BinaryObjectScanner/Protection/Denuvo.cs @@ -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(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/DinamicMultimedia.cs b/BinaryObjectScanner/Protection/DinamicMultimedia.cs index 25f000a8..8cec299c 100644 --- a/BinaryObjectScanner/Protection/DinamicMultimedia.cs +++ b/BinaryObjectScanner/Protection/DinamicMultimedia.cs @@ -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 CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/DiscGuard.cs b/BinaryObjectScanner/Protection/DiscGuard.cs index af670d1f..652befd5 100644 --- a/BinaryObjectScanner/Protection/DiscGuard.cs +++ b/BinaryObjectScanner/Protection/DiscGuard.cs @@ -171,7 +171,7 @@ namespace BinaryObjectScanner.Protection }, "DiscGuard"), }; - return MatchUtil.GetAllMatches(files, matchers, any: false); + return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false); } /// @@ -206,8 +206,16 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 private string GetVersion(string file, byte[] fileContent, List positions) +#else + private string? GetVersion(string file, byte[]? fileContent, List positions) +#endif { + // If we have no content + if (fileContent == null) + return null; + // Check the internal versions string version = GetInternalVersion(file, Array.Empty()); if (!string.IsNullOrEmpty(version)) diff --git a/BinaryObjectScanner/Protection/EasyAntiCheat.cs b/BinaryObjectScanner/Protection/EasyAntiCheat.cs index 6a737396..869ee463 100644 --- a/BinaryObjectScanner/Protection/EasyAntiCheat.cs +++ b/BinaryObjectScanner/Protection/EasyAntiCheat.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/Engine32.cs b/BinaryObjectScanner/Protection/Engine32.cs index 5a249c10..0ae40a24 100644 --- a/BinaryObjectScanner/Protection/Engine32.cs +++ b/BinaryObjectScanner/Protection/Engine32.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/FreeLock.cs b/BinaryObjectScanner/Protection/FreeLock.cs index bd4e93c5..45daad96 100644 --- a/BinaryObjectScanner/Protection/FreeLock.cs +++ b/BinaryObjectScanner/Protection/FreeLock.cs @@ -52,7 +52,7 @@ namespace BinaryObjectScanner.Protection }, "Freelock 1.3"), }; - return MatchUtil.GetAllMatches(files, matchers, any: false); + return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/GFWL.cs b/BinaryObjectScanner/Protection/GFWL.cs index 59595459..b4a591c4 100644 --- a/BinaryObjectScanner/Protection/GFWL.cs +++ b/BinaryObjectScanner/Protection/GFWL.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/Gefest.cs b/BinaryObjectScanner/Protection/Gefest.cs index 870eb45a..8060afdf 100644 --- a/BinaryObjectScanner/Protection/Gefest.cs +++ b/BinaryObjectScanner/Protection/Gefest.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/HexaLock.cs b/BinaryObjectScanner/Protection/HexaLock.cs index 2ef10de9..9935ca97 100644 --- a/BinaryObjectScanner/Protection/HexaLock.cs +++ b/BinaryObjectScanner/Protection/HexaLock.cs @@ -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(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/ImpulseReactor.cs b/BinaryObjectScanner/Protection/ImpulseReactor.cs index d76db47b..2b44c8d2 100644 --- a/BinaryObjectScanner/Protection/ImpulseReactor.cs +++ b/BinaryObjectScanner/Protection/ImpulseReactor.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/IndyVCD.cs b/BinaryObjectScanner/Protection/IndyVCD.cs index a4e0cce4..8d17b8be 100644 --- a/BinaryObjectScanner/Protection/IndyVCD.cs +++ b/BinaryObjectScanner/Protection/IndyVCD.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/JoWood.cs b/BinaryObjectScanner/Protection/JoWood.cs index c4932e98..54404fcb 100644 --- a/BinaryObjectScanner/Protection/JoWood.cs +++ b/BinaryObjectScanner/Protection/JoWood.cs @@ -70,8 +70,16 @@ namespace BinaryObjectScanner.Protection return null; } +#if NET48 public static string GetVersion(string file, byte[] fileContent, List positions) +#else + public static string? GetVersion(string file, byte[]? fileContent, List positions) +#endif { + // If we have no content + if (fileContent == null) + return null; + int position = positions[0]; char[] version = new ArraySegment(fileContent, position + 67, 8).Select(b => (char)b).ToArray(); return new string(version); diff --git a/BinaryObjectScanner/Protection/LabelGate.cs b/BinaryObjectScanner/Protection/LabelGate.cs index 53dbf7a8..a6e8d4cf 100644 --- a/BinaryObjectScanner/Protection/LabelGate.cs +++ b/BinaryObjectScanner/Protection/LabelGate.cs @@ -77,7 +77,7 @@ namespace BinaryObjectScanner.Protection }, "LabelGate CD2"), }; - return MatchUtil.GetAllMatches(files, matchers, any: false); + return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/LaserLok.cs b/BinaryObjectScanner/Protection/LaserLok.cs index f152108e..630c9333 100644 --- a/BinaryObjectScanner/Protection/LaserLok.cs +++ b/BinaryObjectScanner/Protection/LaserLok.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/Macrovision.CDilla.cs b/BinaryObjectScanner/Protection/Macrovision.CDilla.cs index 3c2db7a7..9f33682b 100644 --- a/BinaryObjectScanner/Protection/Macrovision.CDilla.cs +++ b/BinaryObjectScanner/Protection/Macrovision.CDilla.cs @@ -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(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs b/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs index 13e7dfd9..d7b8277e 100644 --- a/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs +++ b/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs @@ -68,7 +68,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 internal ConcurrentQueue CactusDataShieldCheckDirectoryPath(string path, IEnumerable files) +#else + internal ConcurrentQueue CactusDataShieldCheckDirectoryPath(string path, IEnumerable? files) +#endif { // TODO: Verify if these are OR or AND var matchers = new List @@ -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(), matchers, any: false); } /// @@ -124,8 +128,16 @@ namespace BinaryObjectScanner.Protection return MatchUtil.GetFirstMatch(path, matchers, any: true); } +#if NET48 public static string GetCactusDataShieldVersion(string firstMatchedString, IEnumerable files) +#else + public static string? GetCactusDataShieldVersion(string firstMatchedString, IEnumerable? 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)) diff --git a/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs b/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs index d80da811..6c41b07e 100644 --- a/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs +++ b/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs @@ -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(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs b/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs index 19e36768..67e4d0c7 100644 --- a/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs +++ b/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs @@ -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(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs b/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs index 396fd31f..91d6ca82 100644 --- a/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs +++ b/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs @@ -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(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/Macrovision.cs b/BinaryObjectScanner/Protection/Macrovision.cs index 75a2696f..34b51931 100644 --- a/BinaryObjectScanner/Protection/Macrovision.cs +++ b/BinaryObjectScanner/Protection/Macrovision.cs @@ -260,7 +260,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 internal ConcurrentQueue MacrovisionCheckDirectoryPath(string path, IEnumerable files) +#else + internal ConcurrentQueue MacrovisionCheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { @@ -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(), matchers, any: false); } /// @@ -470,8 +474,16 @@ namespace BinaryObjectScanner.Protection return null; } +#if NET48 internal static string GetMacrovisionVersion(string file, byte[] fileContent, List positions) +#else + internal static string? GetMacrovisionVersion(string file, byte[]? fileContent, List 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); diff --git a/BinaryObjectScanner/Protection/MediaCloQ.cs b/BinaryObjectScanner/Protection/MediaCloQ.cs index f6c6c041..13f60222 100644 --- a/BinaryObjectScanner/Protection/MediaCloQ.cs +++ b/BinaryObjectScanner/Protection/MediaCloQ.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/MediaMaxCD3.cs b/BinaryObjectScanner/Protection/MediaMaxCD3.cs index 8dfd7e48..e85405f6 100644 --- a/BinaryObjectScanner/Protection/MediaMaxCD3.cs +++ b/BinaryObjectScanner/Protection/MediaMaxCD3.cs @@ -94,7 +94,7 @@ namespace BinaryObjectScanner.Protection }, "MediaMax CD-3"), }; - return MatchUtil.GetAllMatches(files, matchers, any: false); + return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/NEACProtect.cs b/BinaryObjectScanner/Protection/NEACProtect.cs index 3a1cde52..7d2f3c11 100644 --- a/BinaryObjectScanner/Protection/NEACProtect.cs +++ b/BinaryObjectScanner/Protection/NEACProtect.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/OpenMG.cs b/BinaryObjectScanner/Protection/OpenMG.cs index aa50ab6b..6df64aca 100644 --- a/BinaryObjectScanner/Protection/OpenMG.cs +++ b/BinaryObjectScanner/Protection/OpenMG.cs @@ -95,7 +95,7 @@ namespace BinaryObjectScanner.Protection }, "OpenMG"), }; - return MatchUtil.GetAllMatches(files, matchers, any: false); + return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/Origin.cs b/BinaryObjectScanner/Protection/Origin.cs index caa0aec7..02f2e5c3 100644 --- a/BinaryObjectScanner/Protection/Origin.cs +++ b/BinaryObjectScanner/Protection/Origin.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/PlayJ.cs b/BinaryObjectScanner/Protection/PlayJ.cs index 4755a66c..c0468d1d 100644 --- a/BinaryObjectScanner/Protection/PlayJ.cs +++ b/BinaryObjectScanner/Protection/PlayJ.cs @@ -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(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/ProtectDVDVideo.cs b/BinaryObjectScanner/Protection/ProtectDVDVideo.cs index ce56df6e..64b748f1 100644 --- a/BinaryObjectScanner/Protection/ProtectDVDVideo.cs +++ b/BinaryObjectScanner/Protection/ProtectDVDVideo.cs @@ -17,6 +17,8 @@ namespace BinaryObjectScanner.Protection #endif { var protections = new ConcurrentQueue(); + if (files == null) + return protections; if (Directory.Exists(Path.Combine(path, "VIDEO_TS"))) { diff --git a/BinaryObjectScanner/Protection/ProtectDisc.cs b/BinaryObjectScanner/Protection/ProtectDisc.cs index 5942377e..8ec34bc4 100644 --- a/BinaryObjectScanner/Protection/ProtectDisc.cs +++ b/BinaryObjectScanner/Protection/ProtectDisc.cs @@ -117,8 +117,16 @@ namespace BinaryObjectScanner.Protection return matchedStringArray[2].TrimStart('V'); } +#if NET48 public static string GetVersion3till6(string file, byte[] fileContent, List positions) +#else + public static string? GetVersion3till6(string file, byte[]? fileContent, List 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 positions) +#else + public static string? GetVersion6till8(string file, byte[]? fileContent, List 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 positions) +#else + public static string? GetVersion76till10(string file, byte[]? fileContent, List positions) +#endif { + // If we have no content + if (fileContent == null) + return null; + int index = positions[0] + 37; byte subversion = fileContent[index]; index += 2; diff --git a/BinaryObjectScanner/Protection/RainbowSentinel.cs b/BinaryObjectScanner/Protection/RainbowSentinel.cs index 2e180f4e..fbf9e45a 100644 --- a/BinaryObjectScanner/Protection/RainbowSentinel.cs +++ b/BinaryObjectScanner/Protection/RainbowSentinel.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/RingPROTECH.cs b/BinaryObjectScanner/Protection/RingPROTECH.cs index e2201bb3..694af66b 100644 --- a/BinaryObjectScanner/Protection/RingPROTECH.cs +++ b/BinaryObjectScanner/Protection/RingPROTECH.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/SVKP.cs b/BinaryObjectScanner/Protection/SVKP.cs index 6b5169ff..f5d59fda 100644 --- a/BinaryObjectScanner/Protection/SVKP.cs +++ b/BinaryObjectScanner/Protection/SVKP.cs @@ -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(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/SafeLock.cs b/BinaryObjectScanner/Protection/SafeLock.cs index 3015386d..15fd9971 100644 --- a/BinaryObjectScanner/Protection/SafeLock.cs +++ b/BinaryObjectScanner/Protection/SafeLock.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/SecuROM.cs b/BinaryObjectScanner/Protection/SecuROM.cs index b8d5a01b..66dc3312 100644 --- a/BinaryObjectScanner/Protection/SecuROM.cs +++ b/BinaryObjectScanner/Protection/SecuROM.cs @@ -138,7 +138,7 @@ namespace BinaryObjectScanner.Protection }, "SecuROM 7.01"), }; - return MatchUtil.GetAllMatches(files, matchers, any: true); + return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true); } /// @@ -192,8 +192,16 @@ namespace BinaryObjectScanner.Protection return $"{version}.{subVersion}.{subSubVersion}.{subSubSubVersion}"; } +#if NET48 public static string GetV5Version(string file, byte[] fileContent, List positions) +#else + public static string? GetV5Version(string file, byte[]? fileContent, List 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; diff --git a/BinaryObjectScanner/Protection/SmartE.cs b/BinaryObjectScanner/Protection/SmartE.cs index 83c3d4e1..a3c4596f 100644 --- a/BinaryObjectScanner/Protection/SmartE.cs +++ b/BinaryObjectScanner/Protection/SmartE.cs @@ -48,7 +48,7 @@ namespace BinaryObjectScanner.Protection }, "SmartE"), }; - return MatchUtil.GetAllMatches(files, matchers, any: true); + return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/SoftLock.cs b/BinaryObjectScanner/Protection/SoftLock.cs index 3a528d7a..98c5c1e8 100644 --- a/BinaryObjectScanner/Protection/SoftLock.cs +++ b/BinaryObjectScanner/Protection/SoftLock.cs @@ -101,7 +101,7 @@ namespace BinaryObjectScanner.Protection }, "SoftLock"), }; - return MatchUtil.GetAllMatches(files, matchers, any: false); + return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/SolidShield.cs b/BinaryObjectScanner/Protection/SolidShield.cs index 0642bcd1..8aa14501 100644 --- a/BinaryObjectScanner/Protection/SolidShield.cs +++ b/BinaryObjectScanner/Protection/SolidShield.cs @@ -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(), matchers, any: true); } /// @@ -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 positions) +#else + public static string? GetExeWrapperVersion(string file, byte[]? fileContent, List positions) +#endif { + // If we have no content + if (fileContent == null) + return null; + int position = positions[0]; var id1 = new ArraySegment(fileContent, position + 5, 3); var id2 = new ArraySegment(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 positions) +#else + public static string? GetVersionPlusTages(string file, byte[]? fileContent, List positions) +#endif { + // If we have no content + if (fileContent == null) + return null; + int position = positions[0]; var id1 = new ArraySegment(fileContent, position + 4, 3); var id2 = new ArraySegment(fileContent, position + 15, 4); diff --git a/BinaryObjectScanner/Protection/StarForce.cs b/BinaryObjectScanner/Protection/StarForce.cs index bd6cf01b..9fe8a4c4 100644 --- a/BinaryObjectScanner/Protection/StarForce.cs +++ b/BinaryObjectScanner/Protection/StarForce.cs @@ -140,7 +140,7 @@ namespace BinaryObjectScanner.Protection }, "StarForce"), }; - return MatchUtil.GetAllMatches(files, matchers, any: false); + return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/Steam.cs b/BinaryObjectScanner/Protection/Steam.cs index e7c7ec48..a0489172 100644 --- a/BinaryObjectScanner/Protection/Steam.cs +++ b/BinaryObjectScanner/Protection/Steam.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/TZCopyProtection.cs b/BinaryObjectScanner/Protection/TZCopyProtection.cs index 1585df09..91613d52 100644 --- a/BinaryObjectScanner/Protection/TZCopyProtection.cs +++ b/BinaryObjectScanner/Protection/TZCopyProtection.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/Tages.cs b/BinaryObjectScanner/Protection/Tages.cs index cab738f3..65743b42 100644 --- a/BinaryObjectScanner/Protection/Tages.cs +++ b/BinaryObjectScanner/Protection/Tages.cs @@ -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(), matchers, any: false); } /// @@ -232,8 +232,16 @@ namespace BurnOutSharp.ProtectionType return "(Unknown Version)"; } +#if NET48 public static string GetVersion(string file, byte[] fileContent, List positions) +#else + public static string? GetVersion(string file, byte[]? fileContent, List 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]; diff --git a/BinaryObjectScanner/Protection/TivolaRingProtection.cs b/BinaryObjectScanner/Protection/TivolaRingProtection.cs index c728414b..a97df937 100644 --- a/BinaryObjectScanner/Protection/TivolaRingProtection.cs +++ b/BinaryObjectScanner/Protection/TivolaRingProtection.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/Uplay.cs b/BinaryObjectScanner/Protection/Uplay.cs index b7b37009..5b66056f 100644 --- a/BinaryObjectScanner/Protection/Uplay.cs +++ b/BinaryObjectScanner/Protection/Uplay.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/WMDS.cs b/BinaryObjectScanner/Protection/WMDS.cs index ed9d67c1..4dc0a22d 100644 --- a/BinaryObjectScanner/Protection/WMDS.cs +++ b/BinaryObjectScanner/Protection/WMDS.cs @@ -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(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/WTMCDProtect.cs b/BinaryObjectScanner/Protection/WTMCDProtect.cs index a2cda722..f18ed193 100644 --- a/BinaryObjectScanner/Protection/WTMCDProtect.cs +++ b/BinaryObjectScanner/Protection/WTMCDProtect.cs @@ -70,7 +70,7 @@ namespace BinaryObjectScanner.Protection }, "WTM Protection Viewer"), }; - return MatchUtil.GetAllMatches(files, matchers, any: false); + return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/WinLock.cs b/BinaryObjectScanner/Protection/WinLock.cs index da1fa89a..3921649e 100644 --- a/BinaryObjectScanner/Protection/WinLock.cs +++ b/BinaryObjectScanner/Protection/WinLock.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/XCP.cs b/BinaryObjectScanner/Protection/XCP.cs index 1a4c55f0..803833c4 100644 --- a/BinaryObjectScanner/Protection/XCP.cs +++ b/BinaryObjectScanner/Protection/XCP.cs @@ -56,6 +56,8 @@ namespace BinaryObjectScanner.Protection #endif { var protections = new ConcurrentQueue(); + 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)) diff --git a/BinaryObjectScanner/Protection/Zzxzz.cs b/BinaryObjectScanner/Protection/Zzxzz.cs index 283a1133..10679c18 100644 --- a/BinaryObjectScanner/Protection/Zzxzz.cs +++ b/BinaryObjectScanner/Protection/Zzxzz.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Protection/nProtect.cs b/BinaryObjectScanner/Protection/nProtect.cs index 33e1aa9b..ca6ae194 100644 --- a/BinaryObjectScanner/Protection/nProtect.cs +++ b/BinaryObjectScanner/Protection/nProtect.cs @@ -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(), matchers, any: true); } /// diff --git a/BinaryObjectScanner/Scanner.cs b/BinaryObjectScanner/Scanner.cs index 7651da10..e65e6e68 100644 --- a/BinaryObjectScanner/Scanner.cs +++ b/BinaryObjectScanner/Scanner.cs @@ -90,7 +90,11 @@ namespace BinaryObjectScanner /// /// Path to scan /// Dictionary of list of strings representing the found protections +#if NET48 public ConcurrentDictionary> GetProtections(string path) +#else + public ConcurrentDictionary>? GetProtections(string path) +#endif { return GetProtections(new List { 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) diff --git a/Test/Test.csproj b/Test/Test.csproj index 516d4b71..db9b5838 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -12,10 +12,10 @@ - + - +