diff --git a/BinaryObjectScanner/Handler.cs b/BinaryObjectScanner/Handler.cs index 4a9a81cc..a3423647 100644 --- a/BinaryObjectScanner/Handler.cs +++ b/BinaryObjectScanner/Handler.cs @@ -36,7 +36,11 @@ namespace BinaryObjectScanner /// /// Cache for all IPathCheck types /// +#if NET48 private static IEnumerable pathCheckClasses; +#else + private static IEnumerable? pathCheckClasses; +#endif #endregion @@ -48,7 +52,11 @@ namespace BinaryObjectScanner /// Path of the file or directory to check /// Scanner object to use for options and scanning /// Set of protections in file, null on error +#if NET48 public static ConcurrentDictionary> HandlePathChecks(string path, IEnumerable files) +#else + public static ConcurrentDictionary> HandlePathChecks(string path, IEnumerable? files) +#endif { // Create the output dictionary var protections = new ConcurrentDictionary>(); @@ -79,9 +87,13 @@ namespace BinaryObjectScanner /// Stream to scan the contents of /// True to include debug data, false otherwise /// Set of protections in file, null on error +#if NET48 public static ConcurrentQueue HandleDetectable(IDetectable impl, string fileName, Stream stream, bool includeDebug) +#else + public static ConcurrentQueue? HandleDetectable(IDetectable impl, string fileName, Stream stream, bool includeDebug) +#endif { - string protection = impl.Detect(stream, fileName, includeDebug); + var protection = impl.Detect(stream, fileName, includeDebug); return ProcessProtectionString(protection); } @@ -93,13 +105,17 @@ namespace BinaryObjectScanner /// Stream to scan the contents of /// Scanner object to use on extractable contents /// Set of protections in file, null on error +#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) +#endif { // If the extractable file itself fails try { // Extract and get the output path - string tempPath = impl.Extract(stream, fileName, scanner.IncludeDebug); + var tempPath = impl.Extract(stream, fileName, scanner.IncludeDebug); if (tempPath == null) return null; @@ -135,7 +151,11 @@ namespace BinaryObjectScanner /// IPathCheck class representing the file type /// Path of the file or directory to check /// Set of protections in path, null on error +#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) +#endif { // If we have an invalid path if (string.IsNullOrWhiteSpace(path)) @@ -147,7 +167,7 @@ namespace BinaryObjectScanner // If we have a file path if (File.Exists(path)) { - string protection = impl.CheckFilePath(path); + var protection = impl.CheckFilePath(path); var subProtections = ProcessProtectionString(protection); if (subProtections != null) protections.AddRange(subProtections); @@ -180,9 +200,9 @@ namespace BinaryObjectScanner /// private static IEnumerable InitCheckClasses(Assembly assembly) { - return assembly.GetTypes() - .Where(t => t.IsClass && t.GetInterface(typeof(T).Name) != null) - .Select(t => (T)Activator.CreateInstance(t)); + return assembly.GetTypes()? + .Where(t => t.IsClass && t.GetInterface(typeof(T).Name) != null)? + .Select(t => (T)Activator.CreateInstance(t)) ?? Array.Empty(); } #endregion @@ -194,7 +214,11 @@ namespace BinaryObjectScanner /// /// Protection string to process /// Set of protections parsed, null on error +#if NET48 private static ConcurrentQueue ProcessProtectionString(string protection) +#else + private static ConcurrentQueue? ProcessProtectionString(string? protection) +#endif { // If we have an invalid protection string if (string.IsNullOrWhiteSpace(protection)) diff --git a/BinaryObjectScanner/Interfaces/IPathCheck.cs b/BinaryObjectScanner/Interfaces/IPathCheck.cs index 6ea51191..126d5657 100644 --- a/BinaryObjectScanner/Interfaces/IPathCheck.cs +++ b/BinaryObjectScanner/Interfaces/IPathCheck.cs @@ -17,7 +17,11 @@ namespace BinaryObjectScanner.Interfaces /// Path to check for protection indicators /// Enumerable of strings representing files in a directory /// This can do some limited content checking as well, but it's suggested to use a content check instead, if possible +#if NET48 ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files); +#else + ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files); +#endif /// /// Check a file path for protections based on path name diff --git a/BinaryObjectScanner/Protection/AegiSoft.cs b/BinaryObjectScanner/Protection/AegiSoft.cs index 8942826a..bf820fcb 100644 --- a/BinaryObjectScanner/Protection/AegiSoft.cs +++ b/BinaryObjectScanner/Protection/AegiSoft.cs @@ -71,7 +71,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/AlphaDVD.cs b/BinaryObjectScanner/Protection/AlphaDVD.cs index 87f013fe..0a2049ef 100644 --- a/BinaryObjectScanner/Protection/AlphaDVD.cs +++ b/BinaryObjectScanner/Protection/AlphaDVD.cs @@ -16,7 +16,11 @@ namespace BinaryObjectScanner.Protection public class AlphaDVD : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/Bitpool.cs b/BinaryObjectScanner/Protection/Bitpool.cs index e39838b0..ae74ad4f 100644 --- a/BinaryObjectScanner/Protection/Bitpool.cs +++ b/BinaryObjectScanner/Protection/Bitpool.cs @@ -13,7 +13,11 @@ namespace BinaryObjectScanner.Protection public class Bitpool : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/ByteShield.cs b/BinaryObjectScanner/Protection/ByteShield.cs index f5156c91..0e4a3ce1 100644 --- a/BinaryObjectScanner/Protection/ByteShield.cs +++ b/BinaryObjectScanner/Protection/ByteShield.cs @@ -134,7 +134,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { // TODO: Investigate reference to "bbz650.tmp" in "Byteshield.dll" (Redump entry 6236) // Files with the ".bbz" extension are associated with ByteShield, but the extenstion is known to be used in other places as well. diff --git a/BinaryObjectScanner/Protection/CDDVDCops.cs b/BinaryObjectScanner/Protection/CDDVDCops.cs index 1dd2f09d..95810992 100644 --- a/BinaryObjectScanner/Protection/CDDVDCops.cs +++ b/BinaryObjectScanner/Protection/CDDVDCops.cs @@ -146,7 +146,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { // TODO: Original had "CDCOPS.DLL" required and all the rest in a combined OR var matchers = new List diff --git a/BinaryObjectScanner/Protection/CDGuard.cs b/BinaryObjectScanner/Protection/CDGuard.cs index e98fc96f..b663b60a 100644 --- a/BinaryObjectScanner/Protection/CDGuard.cs +++ b/BinaryObjectScanner/Protection/CDGuard.cs @@ -59,7 +59,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/CDLock.cs b/BinaryObjectScanner/Protection/CDLock.cs index 6f7c8271..2db9955b 100644 --- a/BinaryObjectScanner/Protection/CDLock.cs +++ b/BinaryObjectScanner/Protection/CDLock.cs @@ -65,7 +65,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/CDProtector.cs b/BinaryObjectScanner/Protection/CDProtector.cs index a22c2843..a3a90601 100644 --- a/BinaryObjectScanner/Protection/CDProtector.cs +++ b/BinaryObjectScanner/Protection/CDProtector.cs @@ -17,7 +17,11 @@ namespace BinaryObjectScanner.Protection public class CDProtector : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/CDX.cs b/BinaryObjectScanner/Protection/CDX.cs index 35bc2cf5..f7e77841 100644 --- a/BinaryObjectScanner/Protection/CDX.cs +++ b/BinaryObjectScanner/Protection/CDX.cs @@ -8,7 +8,11 @@ namespace BinaryObjectScanner.Protection public class CDX : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { // TODO: Verify if these are OR or AND var matchers = new List diff --git a/BinaryObjectScanner/Protection/CenegaProtectDVD.cs b/BinaryObjectScanner/Protection/CenegaProtectDVD.cs index 4aba15da..ed25050d 100644 --- a/BinaryObjectScanner/Protection/CenegaProtectDVD.cs +++ b/BinaryObjectScanner/Protection/CenegaProtectDVD.cs @@ -57,7 +57,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs b/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs index 290a9efc..6c59111f 100644 --- a/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs +++ b/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs @@ -58,7 +58,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/CopyKiller.cs b/BinaryObjectScanner/Protection/CopyKiller.cs index 24312c80..9db3fa66 100644 --- a/BinaryObjectScanner/Protection/CopyKiller.cs +++ b/BinaryObjectScanner/Protection/CopyKiller.cs @@ -34,7 +34,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { // TODO: The following checks are overly broad and should be refined // TODO: Look into .PFF files as an indicator. At least one disc has those oversized files diff --git a/BinaryObjectScanner/Protection/DVDCrypt.cs b/BinaryObjectScanner/Protection/DVDCrypt.cs index 763a1b26..19f5d1d8 100644 --- a/BinaryObjectScanner/Protection/DVDCrypt.cs +++ b/BinaryObjectScanner/Protection/DVDCrypt.cs @@ -8,7 +8,11 @@ namespace BinaryObjectScanner.Protection public class DVDCrypt : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/DVDMoviePROTECT.cs b/BinaryObjectScanner/Protection/DVDMoviePROTECT.cs index 84286cf8..e18cf0d1 100644 --- a/BinaryObjectScanner/Protection/DVDMoviePROTECT.cs +++ b/BinaryObjectScanner/Protection/DVDMoviePROTECT.cs @@ -10,7 +10,11 @@ namespace BinaryObjectScanner.Protection public class DVDMoviePROTECT : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var protections = new ConcurrentQueue(); diff --git a/BinaryObjectScanner/Protection/Denuvo.cs b/BinaryObjectScanner/Protection/Denuvo.cs index 4d2badb1..7eeda872 100644 --- a/BinaryObjectScanner/Protection/Denuvo.cs +++ b/BinaryObjectScanner/Protection/Denuvo.cs @@ -259,7 +259,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/DiscGuard.cs b/BinaryObjectScanner/Protection/DiscGuard.cs index c8cddabf..af670d1f 100644 --- a/BinaryObjectScanner/Protection/DiscGuard.cs +++ b/BinaryObjectScanner/Protection/DiscGuard.cs @@ -141,7 +141,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/EasyAntiCheat.cs b/BinaryObjectScanner/Protection/EasyAntiCheat.cs index e8cf916e..6a737396 100644 --- a/BinaryObjectScanner/Protection/EasyAntiCheat.cs +++ b/BinaryObjectScanner/Protection/EasyAntiCheat.cs @@ -84,7 +84,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { // TODO: Search for the presence of the folder "EasyAntiCheat" specifically, which is present in every checked version so far. var matchers = new List diff --git a/BinaryObjectScanner/Protection/Engine32.cs b/BinaryObjectScanner/Protection/Engine32.cs index b7ade925..5a249c10 100644 --- a/BinaryObjectScanner/Protection/Engine32.cs +++ b/BinaryObjectScanner/Protection/Engine32.cs @@ -55,7 +55,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/FreeLock.cs b/BinaryObjectScanner/Protection/FreeLock.cs index ec8dbb68..bd4e93c5 100644 --- a/BinaryObjectScanner/Protection/FreeLock.cs +++ b/BinaryObjectScanner/Protection/FreeLock.cs @@ -15,7 +15,11 @@ namespace BinaryObjectScanner.Protection // TODO: Add an MS-DOS executable check for "FREELOCK.EXE". /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/GFWL.cs b/BinaryObjectScanner/Protection/GFWL.cs index abdcef75..59595459 100644 --- a/BinaryObjectScanner/Protection/GFWL.cs +++ b/BinaryObjectScanner/Protection/GFWL.cs @@ -40,7 +40,11 @@ namespace BurnOutSharp.ProtectionType } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/Gefest.cs b/BinaryObjectScanner/Protection/Gefest.cs index d33ca758..870eb45a 100644 --- a/BinaryObjectScanner/Protection/Gefest.cs +++ b/BinaryObjectScanner/Protection/Gefest.cs @@ -43,7 +43,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/HexaLock.cs b/BinaryObjectScanner/Protection/HexaLock.cs index cd7620b0..2ef10de9 100644 --- a/BinaryObjectScanner/Protection/HexaLock.cs +++ b/BinaryObjectScanner/Protection/HexaLock.cs @@ -72,7 +72,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/ImpulseReactor.cs b/BinaryObjectScanner/Protection/ImpulseReactor.cs index 2e4b5b4a..d76db47b 100644 --- a/BinaryObjectScanner/Protection/ImpulseReactor.cs +++ b/BinaryObjectScanner/Protection/ImpulseReactor.cs @@ -58,7 +58,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/IndyVCD.cs b/BinaryObjectScanner/Protection/IndyVCD.cs index b660a349..a4e0cce4 100644 --- a/BinaryObjectScanner/Protection/IndyVCD.cs +++ b/BinaryObjectScanner/Protection/IndyVCD.cs @@ -12,7 +12,11 @@ namespace BinaryObjectScanner.Protection public class IndyVCD : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { // TODO: Verify if these are OR or AND var matchers = new List diff --git a/BinaryObjectScanner/Protection/LabelGate.cs b/BinaryObjectScanner/Protection/LabelGate.cs index 4ac6d435..53dbf7a8 100644 --- a/BinaryObjectScanner/Protection/LabelGate.cs +++ b/BinaryObjectScanner/Protection/LabelGate.cs @@ -53,7 +53,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/LaserLok.cs b/BinaryObjectScanner/Protection/LaserLok.cs index 49a9c99c..f152108e 100644 --- a/BinaryObjectScanner/Protection/LaserLok.cs +++ b/BinaryObjectScanner/Protection/LaserLok.cs @@ -115,7 +115,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/Macrovision.cs b/BinaryObjectScanner/Protection/Macrovision.cs index e8e4d8ef..75a2696f 100644 --- a/BinaryObjectScanner/Protection/Macrovision.cs +++ b/BinaryObjectScanner/Protection/Macrovision.cs @@ -170,7 +170,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var results = new ConcurrentQueue(); diff --git a/BinaryObjectScanner/Protection/MediaCloQ.cs b/BinaryObjectScanner/Protection/MediaCloQ.cs index 48747661..f6c6c041 100644 --- a/BinaryObjectScanner/Protection/MediaCloQ.cs +++ b/BinaryObjectScanner/Protection/MediaCloQ.cs @@ -41,7 +41,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/MediaMaxCD3.cs b/BinaryObjectScanner/Protection/MediaMaxCD3.cs index 25bdf3a9..8dfd7e48 100644 --- a/BinaryObjectScanner/Protection/MediaMaxCD3.cs +++ b/BinaryObjectScanner/Protection/MediaMaxCD3.cs @@ -67,7 +67,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/NEACProtect.cs b/BinaryObjectScanner/Protection/NEACProtect.cs index 1a904f76..3a1cde52 100644 --- a/BinaryObjectScanner/Protection/NEACProtect.cs +++ b/BinaryObjectScanner/Protection/NEACProtect.cs @@ -54,7 +54,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/OpenMG.cs b/BinaryObjectScanner/Protection/OpenMG.cs index 39963323..aa50ab6b 100644 --- a/BinaryObjectScanner/Protection/OpenMG.cs +++ b/BinaryObjectScanner/Protection/OpenMG.cs @@ -68,7 +68,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/Origin.cs b/BinaryObjectScanner/Protection/Origin.cs index 48349ea8..caa0aec7 100644 --- a/BinaryObjectScanner/Protection/Origin.cs +++ b/BinaryObjectScanner/Protection/Origin.cs @@ -33,7 +33,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/PlayJ.cs b/BinaryObjectScanner/Protection/PlayJ.cs index b3b1e365..4755a66c 100644 --- a/BinaryObjectScanner/Protection/PlayJ.cs +++ b/BinaryObjectScanner/Protection/PlayJ.cs @@ -44,7 +44,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/ProtectDVDVideo.cs b/BinaryObjectScanner/Protection/ProtectDVDVideo.cs index 2dd849a1..ce56df6e 100644 --- a/BinaryObjectScanner/Protection/ProtectDVDVideo.cs +++ b/BinaryObjectScanner/Protection/ProtectDVDVideo.cs @@ -10,7 +10,11 @@ namespace BinaryObjectScanner.Protection public class ProtectDVDVideo : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var protections = new ConcurrentQueue(); diff --git a/BinaryObjectScanner/Protection/RainbowSentinel.cs b/BinaryObjectScanner/Protection/RainbowSentinel.cs index 8c146a88..2e180f4e 100644 --- a/BinaryObjectScanner/Protection/RainbowSentinel.cs +++ b/BinaryObjectScanner/Protection/RainbowSentinel.cs @@ -101,7 +101,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/RingPROTECH.cs b/BinaryObjectScanner/Protection/RingPROTECH.cs index 03d3f2a7..e2201bb3 100644 --- a/BinaryObjectScanner/Protection/RingPROTECH.cs +++ b/BinaryObjectScanner/Protection/RingPROTECH.cs @@ -38,7 +38,11 @@ namespace BinaryObjectScanner.Protection // TODO: Confirm if these checks are only for ProRing or if they are also for older Ring PROTECH /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/SVKP.cs b/BinaryObjectScanner/Protection/SVKP.cs index 6874b36d..6b5169ff 100644 --- a/BinaryObjectScanner/Protection/SVKP.cs +++ b/BinaryObjectScanner/Protection/SVKP.cs @@ -94,7 +94,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/SafeLock.cs b/BinaryObjectScanner/Protection/SafeLock.cs index 6933bda7..3015386d 100644 --- a/BinaryObjectScanner/Protection/SafeLock.cs +++ b/BinaryObjectScanner/Protection/SafeLock.cs @@ -20,7 +20,11 @@ namespace BinaryObjectScanner.Protection public class SafeLock : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { // Technically all need to exist but some might be renamed var matchers = new List diff --git a/BinaryObjectScanner/Protection/SecuROM.cs b/BinaryObjectScanner/Protection/SecuROM.cs index 4b74acea..b8d5a01b 100644 --- a/BinaryObjectScanner/Protection/SecuROM.cs +++ b/BinaryObjectScanner/Protection/SecuROM.cs @@ -109,7 +109,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/SmartE.cs b/BinaryObjectScanner/Protection/SmartE.cs index 1f0a4a2b..83c3d4e1 100644 --- a/BinaryObjectScanner/Protection/SmartE.cs +++ b/BinaryObjectScanner/Protection/SmartE.cs @@ -33,7 +33,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/SoftLock.cs b/BinaryObjectScanner/Protection/SoftLock.cs index 79a2a299..3a528d7a 100644 --- a/BinaryObjectScanner/Protection/SoftLock.cs +++ b/BinaryObjectScanner/Protection/SoftLock.cs @@ -86,7 +86,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/SolidShield.cs b/BinaryObjectScanner/Protection/SolidShield.cs index dd283fe6..0642bcd1 100644 --- a/BinaryObjectScanner/Protection/SolidShield.cs +++ b/BinaryObjectScanner/Protection/SolidShield.cs @@ -113,7 +113,11 @@ namespace BurnOutSharp.ProtectionType } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/StarForce.cs b/BinaryObjectScanner/Protection/StarForce.cs index af383b64..bd6cf01b 100644 --- a/BinaryObjectScanner/Protection/StarForce.cs +++ b/BinaryObjectScanner/Protection/StarForce.cs @@ -104,7 +104,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/Steam.cs b/BinaryObjectScanner/Protection/Steam.cs index c0487157..e7c7ec48 100644 --- a/BinaryObjectScanner/Protection/Steam.cs +++ b/BinaryObjectScanner/Protection/Steam.cs @@ -45,7 +45,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/TZCopyProtection.cs b/BinaryObjectScanner/Protection/TZCopyProtection.cs index 83b50b60..1585df09 100644 --- a/BinaryObjectScanner/Protection/TZCopyProtection.cs +++ b/BinaryObjectScanner/Protection/TZCopyProtection.cs @@ -53,7 +53,11 @@ namespace BinaryObjectScanner.Protection public class TZCopyProtection : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/Tages.cs b/BinaryObjectScanner/Protection/Tages.cs index 0c2a8796..cab738f3 100644 --- a/BinaryObjectScanner/Protection/Tages.cs +++ b/BinaryObjectScanner/Protection/Tages.cs @@ -66,7 +66,11 @@ namespace BurnOutSharp.ProtectionType } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/TivolaRingProtection.cs b/BinaryObjectScanner/Protection/TivolaRingProtection.cs index 8b99c155..c728414b 100644 --- a/BinaryObjectScanner/Protection/TivolaRingProtection.cs +++ b/BinaryObjectScanner/Protection/TivolaRingProtection.cs @@ -12,7 +12,11 @@ namespace BinaryObjectScanner.Protection public class TivolaRingProtection : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/Uplay.cs b/BinaryObjectScanner/Protection/Uplay.cs index 81901b62..b7b37009 100644 --- a/BinaryObjectScanner/Protection/Uplay.cs +++ b/BinaryObjectScanner/Protection/Uplay.cs @@ -48,7 +48,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/WMDS.cs b/BinaryObjectScanner/Protection/WMDS.cs index 14cced7b..ed9d67c1 100644 --- a/BinaryObjectScanner/Protection/WMDS.cs +++ b/BinaryObjectScanner/Protection/WMDS.cs @@ -47,7 +47,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/WTMCDProtect.cs b/BinaryObjectScanner/Protection/WTMCDProtect.cs index 512f38d1..a2cda722 100644 --- a/BinaryObjectScanner/Protection/WTMCDProtect.cs +++ b/BinaryObjectScanner/Protection/WTMCDProtect.cs @@ -55,7 +55,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/WinLock.cs b/BinaryObjectScanner/Protection/WinLock.cs index e680d0fe..da1fa89a 100644 --- a/BinaryObjectScanner/Protection/WinLock.cs +++ b/BinaryObjectScanner/Protection/WinLock.cs @@ -19,7 +19,11 @@ namespace BinaryObjectScanner.Protection public class WinLock : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/XCP.cs b/BinaryObjectScanner/Protection/XCP.cs index 7a06a7e7..1a4c55f0 100644 --- a/BinaryObjectScanner/Protection/XCP.cs +++ b/BinaryObjectScanner/Protection/XCP.cs @@ -49,7 +49,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var protections = new ConcurrentQueue(); diff --git a/BinaryObjectScanner/Protection/Zzxzz.cs b/BinaryObjectScanner/Protection/Zzxzz.cs index 686b3860..283a1133 100644 --- a/BinaryObjectScanner/Protection/Zzxzz.cs +++ b/BinaryObjectScanner/Protection/Zzxzz.cs @@ -10,7 +10,11 @@ namespace BinaryObjectScanner.Protection public class Zzxzz : IPathCheck { /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/Protection/nProtect.cs b/BinaryObjectScanner/Protection/nProtect.cs index 490df752..33e1aa9b 100644 --- a/BinaryObjectScanner/Protection/nProtect.cs +++ b/BinaryObjectScanner/Protection/nProtect.cs @@ -82,7 +82,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable files) +#else + public ConcurrentQueue CheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { diff --git a/BinaryObjectScanner/ProtectionProgress.cs b/BinaryObjectScanner/ProtectionProgress.cs index e3f23837..56de515c 100644 --- a/BinaryObjectScanner/ProtectionProgress.cs +++ b/BinaryObjectScanner/ProtectionProgress.cs @@ -11,7 +11,7 @@ #if NET48 public string Filename { get; private set; } #else - public string Filename { get; init; } + public string? Filename { get; init; } #endif /// @@ -29,10 +29,14 @@ #if NET48 public string Protection { get; private set; } #else - public string Protection { get; init; } + public string? Protection { get; init; } #endif +#if NET48 public ProtectionProgress(string filename, float percentage, string protection) +#else + public ProtectionProgress(string? filename, float percentage, string? protection) +#endif { this.Filename = filename; this.Percentage = percentage; diff --git a/BinaryObjectScanner/Scanner.cs b/BinaryObjectScanner/Scanner.cs index 3c2ae147..7651da10 100644 --- a/BinaryObjectScanner/Scanner.cs +++ b/BinaryObjectScanner/Scanner.cs @@ -18,34 +18,38 @@ namespace BinaryObjectScanner #region Options /// - public bool ScanArchives => options?.ScanArchives ?? false; + public bool ScanArchives => _options?.ScanArchives ?? false; /// - public bool ScanContents => options?.ScanContents ?? false; + public bool ScanContents => _options?.ScanContents ?? false; /// - public bool ScanGameEngines => options?.ScanGameEngines ?? false; + public bool ScanGameEngines => _options?.ScanGameEngines ?? false; /// - public bool ScanPackers => options?.ScanPackers ?? false; + public bool ScanPackers => _options?.ScanPackers ?? false; /// - public bool ScanPaths => options?.ScanPaths ?? false; + public bool ScanPaths => _options?.ScanPaths ?? false; /// - public bool IncludeDebug => options?.IncludeDebug ?? false; + public bool IncludeDebug => _options?.IncludeDebug ?? false; /// /// Options object for configuration /// - private readonly Options options; + private readonly Options _options; #endregion /// /// Optional progress callback during scanning /// - private readonly IProgress fileProgress; +#if NET48 + private readonly IProgress _fileProgress; +#else + private readonly IProgress? _fileProgress; +#endif /// /// Constructor @@ -57,9 +61,13 @@ namespace BinaryObjectScanner /// Enable including path detections in output /// Enable including debug information /// Optional progress callback +#if NET48 public Scanner(bool scanArchives, bool scanContents, bool scanGameEngines, bool scanPackers, bool scanPaths, bool includeDebug, IProgress fileProgress = null) +#else + public Scanner(bool scanArchives, bool scanContents, bool scanGameEngines, bool scanPackers, bool scanPaths, bool includeDebug, IProgress? fileProgress = null) +#endif { - this.options = new Options + this._options = new Options { ScanArchives = scanArchives, ScanContents = scanContents, @@ -69,7 +77,7 @@ namespace BinaryObjectScanner IncludeDebug = includeDebug, }; - this.fileProgress = fileProgress; + this._fileProgress = fileProgress; // Register the codepages Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); @@ -91,7 +99,11 @@ namespace BinaryObjectScanner /// Scan the list of paths and get all found protections /// /// Dictionary of list of strings representing the found protections +#if NET48 public ConcurrentDictionary> GetProtections(List paths) +#else + public ConcurrentDictionary>? GetProtections(List? paths) +#endif { // If we have no paths, we can't scan if (paths == null || !paths.Any()) @@ -101,7 +113,7 @@ namespace BinaryObjectScanner DateTime startTime = DateTime.UtcNow; // Checkpoint - this.fileProgress?.Report(new ProtectionProgress(null, 0, null)); + this._fileProgress?.Report(new ProtectionProgress(null, 0, null)); // Temp variables for reporting string tempFilePath = Path.GetTempPath(); @@ -136,7 +148,7 @@ namespace BinaryObjectScanner reportableFileName = reportableFileName.Substring(tempFilePathWithGuid.Length); // Checkpoint - this.fileProgress?.Report(new ProtectionProgress(reportableFileName, i / (float)files.Count, "Checking file" + (file != reportableFileName ? " from archive" : string.Empty))); + this._fileProgress?.Report(new ProtectionProgress(reportableFileName, i / (float)files.Count, "Checking file" + (file != reportableFileName ? " from archive" : string.Empty))); // Scan for path-detectable protections if (ScanPaths) @@ -159,9 +171,9 @@ namespace BinaryObjectScanner } // Checkpoint - protections.TryGetValue(file, out ConcurrentQueue fullProtectionList); + protections.TryGetValue(file, out var fullProtectionList); string fullProtection = (fullProtectionList != null && fullProtectionList.Any() ? string.Join(", ", fullProtectionList) : null); - this.fileProgress?.Report(new ProtectionProgress(reportableFileName, (i + 1) / (float)files.Count, fullProtection ?? string.Empty)); + this._fileProgress?.Report(new ProtectionProgress(reportableFileName, (i + 1) / (float)files.Count, fullProtection ?? string.Empty)); } } @@ -174,7 +186,7 @@ namespace BinaryObjectScanner reportableFileName = reportableFileName.Substring(tempFilePathWithGuid.Length); // Checkpoint - this.fileProgress?.Report(new ProtectionProgress(reportableFileName, 0, "Checking file" + (path != reportableFileName ? " from archive" : string.Empty))); + this._fileProgress?.Report(new ProtectionProgress(reportableFileName, 0, "Checking file" + (path != reportableFileName ? " from archive" : string.Empty))); // Scan for path-detectable protections if (ScanPaths) @@ -197,9 +209,9 @@ namespace BinaryObjectScanner } // Checkpoint - protections.TryGetValue(path, out ConcurrentQueue fullProtectionList); + protections.TryGetValue(path, out var fullProtectionList); string fullProtection = (fullProtectionList != null && fullProtectionList.Any() ? string.Join(", ", fullProtectionList) : null); - this.fileProgress?.Report(new ProtectionProgress(reportableFileName, 1, fullProtection ?? string.Empty)); + this._fileProgress?.Report(new ProtectionProgress(reportableFileName, 1, fullProtection ?? string.Empty)); } // Throw on an invalid path @@ -225,7 +237,11 @@ namespace BinaryObjectScanner /// /// Path to the file to scan /// Dictionary of list of strings representing the found protections +#if NET48 private ConcurrentDictionary> GetInternalProtections(string file) +#else + private ConcurrentDictionary>? GetInternalProtections(string file) +#endif { // Quick sanity check before continuing if (!File.Exists(file)) @@ -256,7 +272,11 @@ namespace BinaryObjectScanner /// Name of the source file of the stream, for tracking /// Stream to scan the contents of /// Dictionary of list of strings representing the found protections +#if NET48 private ConcurrentDictionary> GetInternalProtections(string fileName, Stream stream) +#else + private ConcurrentDictionary>? GetInternalProtections(string fileName, Stream stream) +#endif { // Quick sanity check before continuing if (stream == null || !stream.CanRead || !stream.CanSeek) @@ -379,7 +399,11 @@ namespace BinaryObjectScanner /// Ideally, we wouldn't need to circumvent the proper handling of file types just for Executable, /// but due to the complexity of scanning, this is not currently possible. /// +#if NET48 private ConcurrentDictionary> ProcessExecutable(Executable executable, string fileName, Stream stream) +#else + private ConcurrentDictionary>? ProcessExecutable(Executable executable, string fileName, Stream stream) +#endif { // Try to create a wrapper for the proper executable type var wrapper = WrapperFactory.CreateExecutableWrapper(stream); @@ -464,10 +488,14 @@ namespace BinaryObjectScanner /// Name of the source file of the stream, for tracking /// Stream to scan the contents of /// Set of protections found from extraction, null on error +#if NET48 private ConcurrentDictionary> HandleExtractableProtections(IEnumerable classes, string fileName, Stream stream) +#else + private ConcurrentDictionary>? HandleExtractableProtections(IEnumerable? classes, string fileName, Stream stream) +#endif { // If we have an invalid set of classes - if (classes?.Any() != true) + if (classes == null || !classes.Any()) return null; // Create the output dictionary