From a6b494841f83d47ffdf5a46879323982cfa81417 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 2 Dec 2024 00:35:04 -0500 Subject: [PATCH] Add and use new nullable string extensions --- .../EnumerableExtensionsTests.cs | 48 --- BinaryObjectScanner.Test/ExtensionsTests.cs | 304 ++++++++++++++++++ BinaryObjectScanner/EnumerableExtensions.cs | 27 -- BinaryObjectScanner/Extensions.cs | 70 ++++ BinaryObjectScanner/Packer/ASPack.cs | 32 +- .../Packer/AutoPlayMediaStudio.cs | 12 +- BinaryObjectScanner/Packer/InstallAnywhere.cs | 4 +- .../Packer/IntelInstallationFramework.cs | 8 +- BinaryObjectScanner/Packer/MicrosoftCABSFX.cs | 4 +- BinaryObjectScanner/Packer/NSIS.cs | 4 +- BinaryObjectScanner/Packer/SetupFactory.cs | 6 +- BinaryObjectScanner/Packer/SevenZipSFX.cs | 16 +- BinaryObjectScanner/Packer/WinRARSFX.cs | 2 +- BinaryObjectScanner/Protection/ByteShield.cs | 20 +- BinaryObjectScanner/Protection/CDCheck.cs | 6 +- BinaryObjectScanner/Protection/CDGuard.cs | 2 +- BinaryObjectScanner/Protection/CDKey.cs | 2 +- .../Protection/CenegaProtectDVD.cs | 2 +- BinaryObjectScanner/Protection/Channelware.cs | 12 +- .../Protection/ChosenBytesCodeLock.cs | 2 +- BinaryObjectScanner/Protection/CopyKiller.cs | 2 +- BinaryObjectScanner/Protection/CrypKey.cs | 10 +- BinaryObjectScanner/Protection/Denuvo.cs | 10 +- BinaryObjectScanner/Protection/DigiGuard.cs | 6 +- BinaryObjectScanner/Protection/DiscGuard.cs | 8 +- .../Protection/ElectronicArts.cs | 8 +- BinaryObjectScanner/Protection/GFWL.cs | 4 +- BinaryObjectScanner/Protection/HexaLock.cs | 6 +- .../Protection/ImpulseReactor.cs | 8 +- .../Protection/KalypsoLauncher.cs | 4 +- BinaryObjectScanner/Protection/LabelGate.cs | 4 +- .../Protection/MGIRegistration.cs | 2 +- .../Protection/Macrovision.CDilla.cs | 14 +- .../Macrovision.CactusDataShield.cs | 2 +- .../Protection/Macrovision.FLEXnet.cs | 14 +- .../Protection/Macrovision.RipGuard.cs | 4 +- .../Protection/Macrovision.SafeCast.cs | 18 +- .../Protection/Macrovision.SafeDisc.cs | 12 +- BinaryObjectScanner/Protection/Macrovision.cs | 4 +- BinaryObjectScanner/Protection/MediaCloQ.cs | 4 +- BinaryObjectScanner/Protection/MediaMax.cs | 4 +- BinaryObjectScanner/Protection/NProtect.cs | 16 +- .../Protection/OnlineRegistration.cs | 2 +- BinaryObjectScanner/Protection/OpenMG.cs | 16 +- BinaryObjectScanner/Protection/Origin.cs | 4 +- BinaryObjectScanner/Protection/PlayJ.cs | 6 +- .../Protection/RainbowSentinel.cs | 28 +- BinaryObjectScanner/Protection/RealArcade.cs | 2 +- BinaryObjectScanner/Protection/SecuROM.cs | 12 +- BinaryObjectScanner/Protection/SoftLock.cs | 4 +- BinaryObjectScanner/Protection/SolidShield.cs | 16 +- BinaryObjectScanner/Protection/StarForce.cs | 22 +- BinaryObjectScanner/Protection/Steam.cs | 14 +- BinaryObjectScanner/Protection/Tages.cs | 8 +- BinaryObjectScanner/Protection/Uplay.cs | 18 +- BinaryObjectScanner/Protection/WMDS.cs | 2 +- .../Protection/WTMCDProtect.cs | 6 +- 57 files changed, 599 insertions(+), 308 deletions(-) delete mode 100644 BinaryObjectScanner.Test/EnumerableExtensionsTests.cs create mode 100644 BinaryObjectScanner.Test/ExtensionsTests.cs delete mode 100644 BinaryObjectScanner/EnumerableExtensions.cs create mode 100644 BinaryObjectScanner/Extensions.cs diff --git a/BinaryObjectScanner.Test/EnumerableExtensionsTests.cs b/BinaryObjectScanner.Test/EnumerableExtensionsTests.cs deleted file mode 100644 index 7b73e87e..00000000 --- a/BinaryObjectScanner.Test/EnumerableExtensionsTests.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using Xunit; - -namespace BinaryObjectScanner.Test -{ - public class EnumerableExtensionsTests - { - [Fact] - public void IterateWithAction_EmptyEnumerable_Success() - { - List set = new List(); - Action action = (s) => s.ToLowerInvariant(); - - set.IterateWithAction(action); - Assert.Empty(set); - } - - [Fact] - public void IterateWithAction_EmptyAction_Success() - { - List set = ["a", "b", "c"]; - Action action = (s) => { }; - - set.IterateWithAction(action); - Assert.Equal(3, set.Count); - } - - [Fact] - public void IterateWithAction_Valid_Success() - { - List set = ["a", "b", "c"]; - List actual = new List(); - - Action action = (s) => - { - lock (actual) - { - actual.Add(s.ToUpperInvariant()); - } - }; - - set.IterateWithAction(action); - Assert.Equal(3, set.Count); - Assert.Equal(3, actual.Count); - } - } -} \ No newline at end of file diff --git a/BinaryObjectScanner.Test/ExtensionsTests.cs b/BinaryObjectScanner.Test/ExtensionsTests.cs new file mode 100644 index 00000000..ceb5284c --- /dev/null +++ b/BinaryObjectScanner.Test/ExtensionsTests.cs @@ -0,0 +1,304 @@ +using System; +using System.Collections.Generic; +using Xunit; + +namespace BinaryObjectScanner.Test +{ + public class ExtensionsTests + { + #region IterateWithAction + + [Fact] + public void IterateWithAction_EmptyEnumerable_Success() + { + List set = new List(); + Action action = (s) => s.ToLowerInvariant(); + + set.IterateWithAction(action); + Assert.Empty(set); + } + + [Fact] + public void IterateWithAction_EmptyAction_Success() + { + List set = ["a", "b", "c"]; + Action action = (s) => { }; + + set.IterateWithAction(action); + Assert.Equal(3, set.Count); + } + + [Fact] + public void IterateWithAction_Valid_Success() + { + List set = ["a", "b", "c"]; + List actual = new List(); + + Action action = (s) => + { + lock (actual) + { + actual.Add(s.ToUpperInvariant()); + } + }; + + set.IterateWithAction(action); + Assert.Equal(3, set.Count); + Assert.Equal(3, actual.Count); + } + + #endregion + + #region OptionalContains + + [Fact] + public void OptionalContains_NullStringNoComparison_False() + { + string? str = null; + string prefix = "prefix"; + + bool actual = str.OptionalContains(prefix); + Assert.False(actual); + } + + [Fact] + public void OptionalContains_NullStringComparison_False() + { + string? str = null; + string prefix = "prefix"; + + bool actual = str.OptionalContains(prefix, StringComparison.OrdinalIgnoreCase); + Assert.False(actual); + } + + [Fact] + public void OptionalContains_EmptyStringNoComparison_False() + { + string? str = string.Empty; + string prefix = "prefix"; + + bool actual = str.OptionalContains(prefix); + Assert.False(actual); + } + + [Fact] + public void OptionalContains_EmptyStringComparison_False() + { + string? str = string.Empty; + string prefix = "prefix"; + + bool actual = str.OptionalContains(prefix, StringComparison.OrdinalIgnoreCase); + Assert.False(actual); + } + + [Fact] + public void OptionalContains_NoMatchNoComparison_False() + { + string? str = "postfix"; + string prefix = "prefix"; + + bool actual = str.OptionalContains(prefix); + Assert.False(actual); + } + + [Fact] + public void OptionalContains_NoMatchComparison_False() + { + string? str = "postfix"; + string prefix = "prefix"; + + bool actual = str.OptionalContains(prefix, StringComparison.OrdinalIgnoreCase); + Assert.False(actual); + } + + [Fact] + public void OptionalContains_MatchesNoComparison_True() + { + string? str = "prefix"; + string prefix = "prefix"; + + bool actual = str.OptionalContains(prefix); + Assert.True(actual); + } + + [Fact] + public void OptionalContains_MatchesComparison_True() + { + string? str = "prefix"; + string prefix = "prefix"; + + bool actual = str.OptionalContains(prefix, StringComparison.OrdinalIgnoreCase); + Assert.True(actual); + } + + #endregion + + #region OptionalEquals + + [Fact] + public void OptionalEquals_NullStringNoComparison_False() + { + string? str = null; + string prefix = "prefix"; + + bool actual = str.OptionalEquals(prefix); + Assert.False(actual); + } + + [Fact] + public void OptionalEquals_NullStringComparison_False() + { + string? str = null; + string prefix = "prefix"; + + bool actual = str.OptionalEquals(prefix, StringComparison.OrdinalIgnoreCase); + Assert.False(actual); + } + + [Fact] + public void OptionalEquals_EmptyStringNoComparison_False() + { + string? str = string.Empty; + string prefix = "prefix"; + + bool actual = str.OptionalEquals(prefix); + Assert.False(actual); + } + + [Fact] + public void OptionalEquals_EmptyStringComparison_False() + { + string? str = string.Empty; + string prefix = "prefix"; + + bool actual = str.OptionalEquals(prefix, StringComparison.OrdinalIgnoreCase); + Assert.False(actual); + } + + [Fact] + public void OptionalEquals_NoMatchNoComparison_False() + { + string? str = "postfix"; + string prefix = "prefix"; + + bool actual = str.OptionalEquals(prefix); + Assert.False(actual); + } + + [Fact] + public void OptionalEquals_NoMatchComparison_False() + { + string? str = "postfix"; + string prefix = "prefix"; + + bool actual = str.OptionalEquals(prefix, StringComparison.OrdinalIgnoreCase); + Assert.False(actual); + } + + [Fact] + public void OptionalEquals_MatchesNoComparison_True() + { + string? str = "prefix"; + string prefix = "prefix"; + + bool actual = str.OptionalEquals(prefix); + Assert.True(actual); + } + + [Fact] + public void OptionalEquals_MatchesComparison_True() + { + string? str = "prefix"; + string prefix = "prefix"; + + bool actual = str.OptionalEquals(prefix, StringComparison.OrdinalIgnoreCase); + Assert.True(actual); + } + + #endregion + + #region OptionalStartsWith + + [Fact] + public void OptionalStartsWith_NullStringNoComparison_False() + { + string? str = null; + string prefix = "prefix"; + + bool actual = str.OptionalStartsWith(prefix); + Assert.False(actual); + } + + [Fact] + public void OptionalStartsWith_NullStringComparison_False() + { + string? str = null; + string prefix = "prefix"; + + bool actual = str.OptionalStartsWith(prefix, StringComparison.OrdinalIgnoreCase); + Assert.False(actual); + } + + [Fact] + public void OptionalStartsWith_EmptyStringNoComparison_False() + { + string? str = string.Empty; + string prefix = "prefix"; + + bool actual = str.OptionalStartsWith(prefix); + Assert.False(actual); + } + + [Fact] + public void OptionalStartsWith_EmptyStringComparison_False() + { + string? str = string.Empty; + string prefix = "prefix"; + + bool actual = str.OptionalStartsWith(prefix, StringComparison.OrdinalIgnoreCase); + Assert.False(actual); + } + + [Fact] + public void OptionalStartsWith_NoMatchNoComparison_False() + { + string? str = "postfix"; + string prefix = "prefix"; + + bool actual = str.OptionalStartsWith(prefix); + Assert.False(actual); + } + + [Fact] + public void OptionalStartsWith_NoMatchComparison_False() + { + string? str = "postfix"; + string prefix = "prefix"; + + bool actual = str.OptionalStartsWith(prefix, StringComparison.OrdinalIgnoreCase); + Assert.False(actual); + } + + [Fact] + public void OptionalStartsWith_MatchesNoComparison_True() + { + string? str = "prefix"; + string prefix = "prefix"; + + bool actual = str.OptionalStartsWith(prefix); + Assert.True(actual); + } + + [Fact] + public void OptionalStartsWith_MatchesComparison_True() + { + string? str = "prefix"; + string prefix = "prefix"; + + bool actual = str.OptionalStartsWith(prefix, StringComparison.OrdinalIgnoreCase); + Assert.True(actual); + } + + #endregion + } +} \ No newline at end of file diff --git a/BinaryObjectScanner/EnumerableExtensions.cs b/BinaryObjectScanner/EnumerableExtensions.cs deleted file mode 100644 index 5eb63948..00000000 --- a/BinaryObjectScanner/EnumerableExtensions.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace BinaryObjectScanner -{ - internal static class EnumerableExtensions - { - /// - /// Wrap iterating through an enumerable with an action - /// - /// - /// .NET Frameworks 2.0 and 3.5 process in series. - /// .NET Frameworks 4.0 onward process in parallel. - /// - public static void IterateWithAction(this IEnumerable source, Action action) - { -#if NET20 || NET35 - foreach (var item in source) - { - action(item); - } -#else - System.Threading.Tasks.Parallel.ForEach(source, action); -#endif - } - } -} \ No newline at end of file diff --git a/BinaryObjectScanner/Extensions.cs b/BinaryObjectScanner/Extensions.cs new file mode 100644 index 00000000..db2ad0cf --- /dev/null +++ b/BinaryObjectScanner/Extensions.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; + +namespace BinaryObjectScanner +{ + internal static class Extensions + { + /// + /// Wrap iterating through an enumerable with an action + /// + /// + /// .NET Frameworks 2.0 and 3.5 process in series. + /// .NET Frameworks 4.0 onward process in parallel. + /// + public static void IterateWithAction(this IEnumerable source, Action action) + { +#if NET20 || NET35 + foreach (var item in source) + { + action(item); + } +#else + System.Threading.Tasks.Parallel.ForEach(source, action); +#endif + } + + /// + public static bool OptionalContains(this string? self, string value) + => OptionalContains(self, value, StringComparison.Ordinal); + + /// + public static bool OptionalContains(this string? self, string value, StringComparison comparisonType) + { + if (self == null) + return false; + +#if NETFRAMEWORK + return self.Contains(value); +#else + return self.Contains(value, comparisonType); +#endif + } + + /// + public static bool OptionalEquals(this string? self, string value) + => OptionalEquals(self, value, StringComparison.Ordinal); + + /// + public static bool OptionalEquals(this string? self, string value, StringComparison comparisonType) + { + if (self == null) + return false; + + return self.Equals(value, comparisonType); + } + + /// + public static bool OptionalStartsWith(this string? self, string value) + => OptionalStartsWith(self, value, StringComparison.Ordinal); + + /// + public static bool OptionalStartsWith(this string? self, string value, StringComparison comparisonType) + { + if (self == null) + return false; + + return self.StartsWith(value, comparisonType); + } + } +} \ No newline at end of file diff --git a/BinaryObjectScanner/Packer/ASPack.cs b/BinaryObjectScanner/Packer/ASPack.cs index cc4f3dee..a57b76c7 100644 --- a/BinaryObjectScanner/Packer/ASPack.cs +++ b/BinaryObjectScanner/Packer/ASPack.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Text; using BinaryObjectScanner.Interfaces; using SabreTools.Matching; using SabreTools.Matching.Content; @@ -22,28 +21,23 @@ namespace BinaryObjectScanner.Packer if (pex.ContainsSection(".aspack", exact: true)) return "ASPack 2.29"; - // TODO: Re-enable all Entry Point checks after implementing // Use the entry point data, if it exists - // if (pex.EntryPointRaw != null) - // { - // var matchers = GenerateMatchers(); - // var match = MatchUtil.GetFirstMatch(file, pex.EntryPointRaw, matchers, includeDebug); - // if (!string.IsNullOrEmpty(match)) - // return match; - // } + if (pex.EntryPointData != null) + { + var matchers = GenerateMatchers(); + var match = MatchUtil.GetFirstMatch(file, pex.EntryPointData, matchers, includeDebug); + if (!string.IsNullOrEmpty(match)) + return match; + } // Get the .adata* section, if it exists - var adataSection = pex.GetFirstSection(".adata", exact: false); - if (adataSection?.Name != null) + var adataSectionRaw = pex.GetFirstSectionData(".adata", exact: false); + if (adataSectionRaw != null) { - var adataSectionRaw = pex.GetFirstSectionData(Encoding.UTF8.GetString(adataSection.Name)); - if (adataSectionRaw != null) - { - var matchers = GenerateMatchers(); - var match = MatchUtil.GetFirstMatch(file, adataSectionRaw, matchers, includeDebug); - if (!string.IsNullOrEmpty(match)) - return match; - } + var matchers = GenerateMatchers(); + var match = MatchUtil.GetFirstMatch(file, adataSectionRaw, matchers, includeDebug); + if (!string.IsNullOrEmpty(match)) + return match; } return null; diff --git a/BinaryObjectScanner/Packer/AutoPlayMediaStudio.cs b/BinaryObjectScanner/Packer/AutoPlayMediaStudio.cs index 0b35d138..886a3390 100644 --- a/BinaryObjectScanner/Packer/AutoPlayMediaStudio.cs +++ b/BinaryObjectScanner/Packer/AutoPlayMediaStudio.cs @@ -19,15 +19,13 @@ namespace BinaryObjectScanner.Packer // Known to detect versions 5.0.0.3 - 8.1.0.0 var name = pex.ProductName; - if (name?.StartsWith("AutoPlay Media Studio", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("AutoPlay Media Studio", StringComparison.OrdinalIgnoreCase)) return $"AutoPlay Media Studio {GetVersion(pex)}"; - // Currently too vague, may be re-enabled in the future - /* - name = Utilities.GetLegalCopyright(pex); - if (name?.StartsWith("Runtime Engine", StringComparison.OrdinalIgnoreCase) == true) - return $"AutoPlay Media Studio {GetVersion(pex)}"; - */ + // TODO: Currently too vague, may be re-enabled in the future + // name = Utilities.GetLegalCopyright(pex); + // if (name.OptionalStartsWith("Runtime Engine", StringComparison.OrdinalIgnoreCase)) + // return $"AutoPlay Media Studio {GetVersion(pex)}"; return null; } diff --git a/BinaryObjectScanner/Packer/InstallAnywhere.cs b/BinaryObjectScanner/Packer/InstallAnywhere.cs index b4697f81..74fec49f 100644 --- a/BinaryObjectScanner/Packer/InstallAnywhere.cs +++ b/BinaryObjectScanner/Packer/InstallAnywhere.cs @@ -17,11 +17,11 @@ namespace BinaryObjectScanner.Packer return null; var name= pex.FileDescription; - if (name?.StartsWith("InstallAnywhere Self Extractor", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("InstallAnywhere Self Extractor", StringComparison.OrdinalIgnoreCase)) return $"InstallAnywhere {GetVersion(pex)}"; name = pex.ProductName; - if (name?.StartsWith("InstallAnywhere", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("InstallAnywhere", StringComparison.OrdinalIgnoreCase)) return $"InstallAnywhere {GetVersion(pex)}"; return null; diff --git a/BinaryObjectScanner/Packer/IntelInstallationFramework.cs b/BinaryObjectScanner/Packer/IntelInstallationFramework.cs index 8d5e27cf..bc61cbad 100644 --- a/BinaryObjectScanner/Packer/IntelInstallationFramework.cs +++ b/BinaryObjectScanner/Packer/IntelInstallationFramework.cs @@ -16,15 +16,15 @@ namespace BinaryObjectScanner.Packer return null; var name= pex.FileDescription; - if (name?.Equals("Intel(R) Installation Framework", StringComparison.OrdinalIgnoreCase) == true - || name?.Equals("Intel Installation Framework", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Intel(R) Installation Framework", StringComparison.OrdinalIgnoreCase) + || name.OptionalEquals("Intel Installation Framework", StringComparison.OrdinalIgnoreCase)) { return $"Intel Installation Framework {pex.GetInternalVersion()}"; } name = pex.ProductName; - if (name?.Equals("Intel(R) Installation Framework", StringComparison.OrdinalIgnoreCase) == true - || name?.Equals("Intel Installation Framework", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Intel(R) Installation Framework", StringComparison.OrdinalIgnoreCase) + || name.OptionalEquals("Intel Installation Framework", StringComparison.OrdinalIgnoreCase)) { return $"Intel Installation Framework {pex.GetInternalVersion()}"; } diff --git a/BinaryObjectScanner/Packer/MicrosoftCABSFX.cs b/BinaryObjectScanner/Packer/MicrosoftCABSFX.cs index 216a62a8..307826af 100644 --- a/BinaryObjectScanner/Packer/MicrosoftCABSFX.cs +++ b/BinaryObjectScanner/Packer/MicrosoftCABSFX.cs @@ -17,11 +17,11 @@ namespace BinaryObjectScanner.Packer return null; var name= pex.InternalName; - if (name?.Equals("Wextract", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Wextract", StringComparison.OrdinalIgnoreCase)) return $"Microsoft CAB SFX {GetVersion(pex)}"; name = pex.OriginalFilename; - if (name?.Equals("WEXTRACT.EXE", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("WEXTRACT.EXE", StringComparison.OrdinalIgnoreCase)) return $"Microsoft CAB SFX {GetVersion(pex)}"; // Get the .data/DATA section strings, if they exist diff --git a/BinaryObjectScanner/Packer/NSIS.cs b/BinaryObjectScanner/Packer/NSIS.cs index 5a329d1d..16f702a9 100644 --- a/BinaryObjectScanner/Packer/NSIS.cs +++ b/BinaryObjectScanner/Packer/NSIS.cs @@ -15,8 +15,8 @@ namespace BinaryObjectScanner.Packer return null; var name = pex.AssemblyDescription; - if (name?.StartsWith("Nullsoft Install System") == true) - return $"NSIS {name.Substring("Nullsoft Install System".Length).Trim()}"; + if (name.OptionalStartsWith("Nullsoft Install System")) + return $"NSIS {name!.Substring("Nullsoft Install System".Length).Trim()}"; // Get the .data/DATA section strings, if they exist var strs = pex.GetFirstSectionStrings(".data") ?? pex.GetFirstSectionStrings("DATA"); diff --git a/BinaryObjectScanner/Packer/SetupFactory.cs b/BinaryObjectScanner/Packer/SetupFactory.cs index 5408fe5a..18da1fbc 100644 --- a/BinaryObjectScanner/Packer/SetupFactory.cs +++ b/BinaryObjectScanner/Packer/SetupFactory.cs @@ -19,16 +19,16 @@ namespace BinaryObjectScanner.Packer // Known to detect versions 7.0.5.1 - 9.1.0.0 var name = pex.LegalCopyright; - if (name?.StartsWith("Setup Engine", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("Setup Engine", StringComparison.OrdinalIgnoreCase)) return $"Setup Factory {GetVersion(pex)}"; name = pex.ProductName; - if (name?.StartsWith("Setup Factory", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("Setup Factory", StringComparison.OrdinalIgnoreCase)) return $"Setup Factory {GetVersion(pex)}"; // Known to detect version 5.0.1 - 6.0.1.3 name = pex.FileDescription; - if (name?.StartsWith("Setup Factory", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("Setup Factory", StringComparison.OrdinalIgnoreCase)) return $"Setup Factory {GetVersion(pex)}"; // Longer version of the check that can be used if false positves become an issue: diff --git a/BinaryObjectScanner/Packer/SevenZipSFX.cs b/BinaryObjectScanner/Packer/SevenZipSFX.cs index da0da068..a97d76be 100644 --- a/BinaryObjectScanner/Packer/SevenZipSFX.cs +++ b/BinaryObjectScanner/Packer/SevenZipSFX.cs @@ -14,25 +14,25 @@ namespace BinaryObjectScanner.Packer return null; // Get the assembly description, if possible - if (pex.AssemblyDescription?.StartsWith("7-Zip Self-extracting Archive") == true) - return $"7-Zip SFX {pex.AssemblyDescription.Substring("7-Zip Self-extracting Archive ".Length)}"; + if (pex.AssemblyDescription.OptionalStartsWith("7-Zip Self-extracting Archive")) + return $"7-Zip SFX {pex.AssemblyDescription!.Substring("7-Zip Self-extracting Archive ".Length)}"; // Get the file description, if it exists - if (pex.FileDescription?.Equals("7z SFX") == true) + if (pex.FileDescription.OptionalEquals("7z SFX")) return "7-Zip SFX"; - if (pex.FileDescription?.Equals("7z Self-Extract Setup") == true) + if (pex.FileDescription.OptionalEquals("7z Self-Extract Setup")) return "7-Zip SFX"; // Get the original filename, if it exists - if (pex.OriginalFilename?.Equals("7z.sfx.exe") == true) + if (pex.OriginalFilename.OptionalEquals("7z.sfx.exe")) return "7-Zip SFX"; - else if (pex.OriginalFilename?.Equals("7zS.sfx") == true) + else if (pex.OriginalFilename.OptionalEquals("7zS.sfx")) return "7-Zip SFX"; // Get the internal name, if it exists - if (pex.InternalName?.Equals("7z.sfx") == true) + if (pex.InternalName.OptionalEquals("7z.sfx")) return "7-Zip SFX"; - else if (pex.InternalName?.Equals("7zS.sfx") == true) + else if (pex.InternalName.OptionalEquals("7zS.sfx")) return "7-Zip SFX"; // If any dialog boxes match diff --git a/BinaryObjectScanner/Packer/WinRARSFX.cs b/BinaryObjectScanner/Packer/WinRARSFX.cs index e7a60a37..6484daee 100644 --- a/BinaryObjectScanner/Packer/WinRARSFX.cs +++ b/BinaryObjectScanner/Packer/WinRARSFX.cs @@ -14,7 +14,7 @@ namespace BinaryObjectScanner.Packer return null; var name = pex.AssemblyDescription; - if (name?.Contains("WinRAR archiver") == true) + if (name.OptionalContains("WinRAR archiver")) return "WinRAR SFX"; if (pex.FindDialogByTitle("WinRAR self-extracting archive").Count > 0) diff --git a/BinaryObjectScanner/Protection/ByteShield.cs b/BinaryObjectScanner/Protection/ByteShield.cs index 9f5a28a5..b8d5f183 100644 --- a/BinaryObjectScanner/Protection/ByteShield.cs +++ b/BinaryObjectScanner/Protection/ByteShield.cs @@ -49,27 +49,27 @@ namespace BinaryObjectScanner.Protection // Found in "LineRider2.exe" in Redump entry 6236 var name = pex.FileDescription; - if (name?.Equals("ByteShield Client") == true) + if (name.OptionalEquals("ByteShield Client")) return $"ByteShield Activation Client {pex.GetInternalVersion()}"; // Found in "LineRider2.exe" in Redump entry 6236 name = pex.InternalName; - if (name?.Equals("ByteShield") == true) + if (name.OptionalEquals("ByteShield")) return $"ByteShield Activation Client {pex.GetInternalVersion()}"; // Found in "LineRider2.exe" in Redump entry 6236 name = pex.OriginalFilename; - if (name?.Equals("ByteShield.EXE") == true) + if (name.OptionalEquals("ByteShield.EXE")) return $"ByteShield Activation Client {pex.GetInternalVersion()}"; // Found in "LineRider2.exe" in Redump entry 6236 name = pex.ProductName; - if (name?.Equals("ByteShield Client") == true) + if (name.OptionalEquals("ByteShield Client")) return $"ByteShield Activation Client {pex.GetInternalVersion()}"; // Found in "ByteShield.dll" in Redump entry 6236 name = pex.Model.ExportTable?.ExportDirectoryTable?.Name; - if (name?.Equals("ByteShield Client") == true) + if (name.OptionalEquals("ByteShield Client")) return "ByteShield Component Module"; // Found in "LineRider2.exe" in Redump entry 6236 @@ -91,7 +91,7 @@ namespace BinaryObjectScanner.Protection if (strs != null) { // Found in "LineRider2.exe" in Redump entry 6236 - if (strs.Exists(s => s?.Contains("ByteShield") == true)) + if (strs.Exists(s => s.OptionalContains("ByteShield"))) return "ByteShield"; } @@ -100,15 +100,15 @@ namespace BinaryObjectScanner.Protection if (strs != null) { // Found in "ByteShield.dll" in Redump entry 6236 - if (strs.Exists(s => s?.Contains("Byte|Shield") == true)) + if (strs.Exists(s => s.OptionalContains("Byte|Shield"))) return "ByteShield Component Module"; // Found in "ByteShield.dll" in Redump entry 6236 - else if (strs.Exists(s => s?.Contains("Byteshield0") == true)) + else if (strs.Exists(s => s.OptionalContains("Byteshield0"))) return "ByteShield Component Module"; // Found in "ByteShield.dll" in Redump entry 6236 - else if (strs.Exists(s => s?.Contains("ByteShieldLoader") == true)) + else if (strs.Exists(s => s.OptionalContains("ByteShieldLoader"))) return "ByteShield Component Module"; } @@ -118,7 +118,7 @@ namespace BinaryObjectScanner.Protection { // TODO: Figure out if this specifically indicates if the file is encrypted // Found in "LineRider2.bbz" in Redump entry 6236 - if (strs.Exists(s => s?.Contains("ByteShield") == true)) + if (strs.Exists(s => s.OptionalContains("ByteShield"))) return "ByteShield"; } diff --git a/BinaryObjectScanner/Protection/CDCheck.cs b/BinaryObjectScanner/Protection/CDCheck.cs index 9dbab535..f5fd59ac 100644 --- a/BinaryObjectScanner/Protection/CDCheck.cs +++ b/BinaryObjectScanner/Protection/CDCheck.cs @@ -14,17 +14,17 @@ namespace BinaryObjectScanner.Protection return null; var name = pex.Comments; - if (name?.Contains("CDCheck utlity for Microsoft Game Studios") == true) + if (name.OptionalContains("CDCheck utlity for Microsoft Game Studios")) return "Microsoft Game Studios CD Check"; // To broad to be of use //name = pex.InternalName; - //if (name?.Contains("CDCheck") == true) + //if (name.OptionalContains("CDCheck")) // return "Microsoft Game Studios CD Check"; // To broad to be of use //name = pex.OriginalFilename; - //if (name?.Contains("CDCheck.exe") == true) + //if (name.OptionalContains("CDCheck.exe")) // return "Microsoft Game Studios CD Check"; return null; diff --git a/BinaryObjectScanner/Protection/CDGuard.cs b/BinaryObjectScanner/Protection/CDGuard.cs index 9265b2d0..6e240b96 100644 --- a/BinaryObjectScanner/Protection/CDGuard.cs +++ b/BinaryObjectScanner/Protection/CDGuard.cs @@ -36,7 +36,7 @@ namespace BinaryObjectScanner.Protection if (pex.Model.ExportTable?.ExportDirectoryTable != null) { // Found in "cdguard.dll" in Redump entry 97142 and IA item "pahgeby-he3hakomkou". - bool match = pex.Model.ExportTable.ExportDirectoryTable.Name?.Equals("cdguard.dll", StringComparison.OrdinalIgnoreCase) == true; + bool match = pex.Model.ExportTable.ExportDirectoryTable.Name.OptionalEquals("cdguard.dll", StringComparison.OrdinalIgnoreCase); if (match) return "CD-Guard Copy Protection System"; } diff --git a/BinaryObjectScanner/Protection/CDKey.cs b/BinaryObjectScanner/Protection/CDKey.cs index 03c9fc08..53f66750 100644 --- a/BinaryObjectScanner/Protection/CDKey.cs +++ b/BinaryObjectScanner/Protection/CDKey.cs @@ -15,7 +15,7 @@ namespace BinaryObjectScanner.Protection return null; var name = pex.InternalName; - if (name?.Equals("CDKey", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("CDKey", StringComparison.OrdinalIgnoreCase)) return "CD-Key / Serial"; return null; diff --git a/BinaryObjectScanner/Protection/CenegaProtectDVD.cs b/BinaryObjectScanner/Protection/CenegaProtectDVD.cs index 0b77fa18..077b8a74 100644 --- a/BinaryObjectScanner/Protection/CenegaProtectDVD.cs +++ b/BinaryObjectScanner/Protection/CenegaProtectDVD.cs @@ -26,7 +26,7 @@ namespace BinaryObjectScanner.Protection if (pex.Model.ExportTable?.ExportDirectoryTable != null) { // Found in "cenega.dll" in IA item "speed-pack". - bool match = pex.Model.ExportTable.ExportDirectoryTable.Name?.Equals("ProtectDVD.dll", StringComparison.OrdinalIgnoreCase) == true; + bool match = pex.Model.ExportTable.ExportDirectoryTable.Name.OptionalEquals("ProtectDVD.dll", StringComparison.OrdinalIgnoreCase); if (match) return "Cenega ProtectDVD"; } diff --git a/BinaryObjectScanner/Protection/Channelware.cs b/BinaryObjectScanner/Protection/Channelware.cs index 29f911e6..a82d17e1 100644 --- a/BinaryObjectScanner/Protection/Channelware.cs +++ b/BinaryObjectScanner/Protection/Channelware.cs @@ -32,29 +32,29 @@ namespace BinaryObjectScanner.Protection // Found in "AbeWincw.dll" in Redump entry 116358 and in "TOYSGMcw.dll" in the "TOYSTORY" installation folder from Redump entry 12354. var name = pex.ProductName; - if (name?.Equals("ChannelWare Utilities") == true) + if (name.OptionalEquals("ChannelWare Utilities")) return "Channelware"; // Found in "cwbrowse.exe" in the "Channelware" folder installed from Redump entry 12354. - if (name?.Equals("Channelware Browser Launcher") == true) + if (name.OptionalEquals("Channelware Browser Launcher")) return "Channelware"; // Found in "cwuninst.exe" in the "Channelware" folder installed from Redump entry 12354. - if (name?.Equals("Channelware Launcher Uninstall Application") == true) + if (name.OptionalEquals("Channelware Launcher Uninstall Application")) return "Channelware"; // Found in "cwbrowse.exe" in the "Channelware\CWBrowse" folder installed from Redump entry 116358. - if (name?.Equals("Channelware Authorization Server Browser Launcher") == true) + if (name.OptionalEquals("Channelware Authorization Server Browser Launcher")) return "Channelware"; name = pex.FileDescription; // Found in "cwuninst.exe" in the "Channelware" folder installed from Redump entry 12354. - if (name?.Equals("Channelware Launcher Uninstall") == true) + if (name.OptionalEquals("Channelware Launcher Uninstall")) return "Channelware"; name = pex.LegalTrademarks; // Found in "CWAuto.dll" and "Upgrader.exe" in the "TOYSTORY" installation folder from Redump entry 12354. - if (name?.Equals("Channelware") == true) + if (name.OptionalEquals("Channelware")) return "Channelware"; return null; diff --git a/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs b/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs index acdcdf4e..ac20e898 100644 --- a/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs +++ b/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs @@ -32,7 +32,7 @@ namespace BinaryObjectScanner.Protection // Found in "Code-Lock.ocx" in Code-Lock version 2.35. // Also worth noting is the File Description for this file, which is "A future for you, a challenge for the rest.". var name = pex.ProductName; - if (name?.StartsWith("Code-Lock", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("Code-Lock", StringComparison.OrdinalIgnoreCase)) return $"ChosenBytes Code-Lock {pex.ProductVersion}"; // Get the .text section strings, if they exist diff --git a/BinaryObjectScanner/Protection/CopyKiller.cs b/BinaryObjectScanner/Protection/CopyKiller.cs index 1a5ec663..8d52faa5 100644 --- a/BinaryObjectScanner/Protection/CopyKiller.cs +++ b/BinaryObjectScanner/Protection/CopyKiller.cs @@ -29,7 +29,7 @@ namespace BinaryObjectScanner.Protection // TODO: Figure out why this check doesn't work. // Found in "autorun.exe" in CopyKiller V3.64, V3.99, and V3.99a. var name = pex.ProductName; - if (name?.StartsWith("CopyKiller", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("CopyKiller", StringComparison.OrdinalIgnoreCase)) return "CopyKiller V3.64+"; return null; diff --git a/BinaryObjectScanner/Protection/CrypKey.cs b/BinaryObjectScanner/Protection/CrypKey.cs index 84596854..8d214a8f 100644 --- a/BinaryObjectScanner/Protection/CrypKey.cs +++ b/BinaryObjectScanner/Protection/CrypKey.cs @@ -45,22 +45,22 @@ namespace BinaryObjectScanner.Protection // Found in 'cki32k.dll' var name = pex.CompanyName; - if (name?.StartsWith("CrypKey") == true) + if (name.OptionalStartsWith("CrypKey")) return $"CrypKey {version}".TrimEnd(); - + name = pex.FileDescription; // Found in "CKSEC_32.DLL" in IA item "NBECRORV11". - if (name?.StartsWith("CrypKey Instant security library") == true) + if (name.OptionalStartsWith("CrypKey Instant security library")) return $"CrypKey Instant {pex.GetInternalVersion()}"; // Found in 'cki32k.dll' - if (name?.StartsWith("CrypKey") == true) + if (name.OptionalStartsWith("CrypKey")) return $"CrypKey {version}".TrimEnd(); // Found in 'cki32k.dll' name = pex.LegalCopyright; - if (name?.Contains("CrypKey") == true) + if (name.OptionalContains("CrypKey")) return $"CrypKey {version}".TrimEnd(); // Found in 'cki32k.dll' diff --git a/BinaryObjectScanner/Protection/Denuvo.cs b/BinaryObjectScanner/Protection/Denuvo.cs index ddab30a9..20b86266 100644 --- a/BinaryObjectScanner/Protection/Denuvo.cs +++ b/BinaryObjectScanner/Protection/Denuvo.cs @@ -43,23 +43,23 @@ namespace BinaryObjectScanner.Protection // Found in "denuvo-anti-cheat.sys". var name = pex.FileDescription; - if (name?.Equals("Denuvo Anti-Cheat Driver", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Denuvo Anti-Cheat Driver", StringComparison.OrdinalIgnoreCase)) return $"Denuvo Anti-Cheat"; // Found in "denuvo-anti-cheat-update-service.exe"/"Denuvo Anti-Cheat Installer.exe". - if (name?.Equals("Denuvo Anti-Cheat Update Service", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Denuvo Anti-Cheat Update Service", StringComparison.OrdinalIgnoreCase)) return $"Denuvo Anti-Cheat"; // Found in "denuvo-anti-cheat-update-service-launcher.dll". - if (name?.Equals("Denuvo Anti-Cheat Update Service Launcher", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Denuvo Anti-Cheat Update Service Launcher", StringComparison.OrdinalIgnoreCase)) return $"Denuvo Anti-Cheat"; // Found in "denuvo-anti-cheat-runtime.dll". - if (name?.Equals("Denuvo Anti-Cheat Runtime", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Denuvo Anti-Cheat Runtime", StringComparison.OrdinalIgnoreCase)) return $"Denuvo Anti-Cheat"; // Found in "denuvo-anti-cheat-crash-report.exe". - if (name?.Equals("Denuvo Anti-Cheat Crash Report Tool", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Denuvo Anti-Cheat Crash Report Tool", StringComparison.OrdinalIgnoreCase)) return $"Denuvo Anti-Cheat"; // Data sourced from: diff --git a/BinaryObjectScanner/Protection/DigiGuard.cs b/BinaryObjectScanner/Protection/DigiGuard.cs index dcecd9a2..4ce52bde 100644 --- a/BinaryObjectScanner/Protection/DigiGuard.cs +++ b/BinaryObjectScanner/Protection/DigiGuard.cs @@ -35,17 +35,17 @@ namespace BinaryObjectScanner.Protection // Found in "Start.exe" in IA item "Nova_DellBigWIGDVD_USA"/Redump entry 108588. var name = pex.FileDescription; - if (name?.Equals("DigiGuard3 Client") == true) + if (name.OptionalEquals("DigiGuard3 Client")) return $"DigiGuard3"; // Found in "Start.exe" in IA item "Nova_DellBigWIGDVD_USA"/Redump entry 108588. name = pex.LegalTrademarks; - if (name?.Equals("DigiGuard") == true) + if (name.OptionalEquals("DigiGuard")) return $"DigiGuard"; // Found in "PJS3.exe" in IA item "Nova_DellBigWIGDVD_USA"/Redump entry 108588. name = pex.ProductName; - if (name?.Equals("Greenleaf Wrapper3") == true) + if (name.OptionalEquals("Greenleaf Wrapper3")) return $"DigiGuard"; return null; diff --git a/BinaryObjectScanner/Protection/DiscGuard.cs b/BinaryObjectScanner/Protection/DiscGuard.cs index ca896970..a42b9137 100644 --- a/BinaryObjectScanner/Protection/DiscGuard.cs +++ b/BinaryObjectScanner/Protection/DiscGuard.cs @@ -47,21 +47,21 @@ namespace BinaryObjectScanner.Protection // Found in "IOSLinksys.dll" (Redump entries 31914, 46743, 46961, 79284, and 79374). var name = pex.FileDescription; - if (name?.StartsWith("IOSLinkNT", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("IOSLinkNT", StringComparison.OrdinalIgnoreCase)) return "DiscGuard"; // Found in "T29.dll" (Redump entry 31914). - if (name?.StartsWith("TTR Technologies DiscGuard (tm)", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("TTR Technologies DiscGuard (tm)", StringComparison.OrdinalIgnoreCase)) return $"DiscGuard {GetVersion(pex)}"; // Found in "T29.dll" (Redump entry 31914). name = pex.ProductName; - if (name?.StartsWith("DiscGuard (tm)", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("DiscGuard (tm)", StringComparison.OrdinalIgnoreCase)) return "DiscGuard"; // Found in "IOSLinksys.dll" (Redump entries 31914, 46743, 46961, 79284, and 79374). name = pex.ProductName; - if (name?.StartsWith("TTR Technologies Ltd. DiscGuard (tm)", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("TTR Technologies Ltd. DiscGuard (tm)", StringComparison.OrdinalIgnoreCase)) return "DiscGuard"; // Found in "Alternate.exe" (Redump entry 31914) and "Alt.exe" (Redump entries 46743, 46961, 79284, and 79374). diff --git a/BinaryObjectScanner/Protection/ElectronicArts.cs b/BinaryObjectScanner/Protection/ElectronicArts.cs index 61691ab0..ae3e1099 100644 --- a/BinaryObjectScanner/Protection/ElectronicArts.cs +++ b/BinaryObjectScanner/Protection/ElectronicArts.cs @@ -15,15 +15,15 @@ namespace BinaryObjectScanner.Protection return null; var name = pex.FileDescription; - if (name?.Contains("EReg MFC Application") == true) + if (name.OptionalContains("EReg MFC Application")) return $"EA CdKey Registration Module {pex.GetInternalVersion()}"; - else if (name?.Contains("Registration code installer program") == true) + else if (name.OptionalContains("Registration code installer program")) return $"EA CdKey Registration Module {pex.GetInternalVersion()}"; - else if (name?.Equals("EA DRM Helper", StringComparison.OrdinalIgnoreCase) == true) + else if (name.OptionalEquals("EA DRM Helper", StringComparison.OrdinalIgnoreCase)) return $"EA DRM Protection {pex.GetInternalVersion()}"; name = pex.InternalName; - if (name?.Equals("CDCode", StringComparison.Ordinal) == true) + if (name.OptionalEquals("CDCode", StringComparison.Ordinal)) return $"EA CdKey Registration Module {pex.GetInternalVersion()}"; if (pex.FindDialogByTitle("About CDKey").Count > 0) diff --git a/BinaryObjectScanner/Protection/GFWL.cs b/BinaryObjectScanner/Protection/GFWL.cs index cb970148..99557785 100644 --- a/BinaryObjectScanner/Protection/GFWL.cs +++ b/BinaryObjectScanner/Protection/GFWL.cs @@ -18,9 +18,9 @@ namespace BinaryObjectScanner.Protection return null; var name = pex.FileDescription; - if (name?.StartsWith("Games for Windows - LIVE Zero Day Piracy Protection", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("Games for Windows - LIVE Zero Day Piracy Protection", StringComparison.OrdinalIgnoreCase)) return $"Games for Windows LIVE - Zero Day Piracy Protection Module {pex.GetInternalVersion()}"; - else if (name?.StartsWith("Games for Windows", StringComparison.OrdinalIgnoreCase) == true) + else if (name.OptionalStartsWith("Games for Windows", StringComparison.OrdinalIgnoreCase)) return $"Games for Windows LIVE {pex.GetInternalVersion()}"; // Get the import directory table diff --git a/BinaryObjectScanner/Protection/HexaLock.cs b/BinaryObjectScanner/Protection/HexaLock.cs index 08e9d36a..99007341 100644 --- a/BinaryObjectScanner/Protection/HexaLock.cs +++ b/BinaryObjectScanner/Protection/HexaLock.cs @@ -42,16 +42,16 @@ namespace BinaryObjectScanner.Protection // TODO: Fix the following checks, as this information is visible via Windows Explorer but isn't currently being seen by BOS. // Found in "HCPSMng.exe". var name = pex.FileDescription; - if (name?.StartsWith("HCPS Manager", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("HCPS Manager", StringComparison.OrdinalIgnoreCase)) return $"Hexalock AutoLock 4.5"; // Found in the file typically named "Start_Here.exe". - if (name?.StartsWith("HCPS Loader", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("HCPS Loader", StringComparison.OrdinalIgnoreCase)) return $"Hexalock AutoLock 4.5"; // Found in both "HCPSMng.exe" and in the file typically named "Start_Here.exe". name = pex.ProductName; - if (name?.StartsWith("HCPS", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("HCPS", StringComparison.OrdinalIgnoreCase)) return $"Hexalock AutoLock 4.5"; // Get the .text section strings, if they exist diff --git a/BinaryObjectScanner/Protection/ImpulseReactor.cs b/BinaryObjectScanner/Protection/ImpulseReactor.cs index 673ac6eb..71f9d309 100644 --- a/BinaryObjectScanner/Protection/ImpulseReactor.cs +++ b/BinaryObjectScanner/Protection/ImpulseReactor.cs @@ -21,21 +21,21 @@ namespace BinaryObjectScanner.Protection return null; var name = pex.FileDescription; - if (name?.Contains("ImpulseReactor Dynamic Link Library") == true) + if (name.OptionalContains("ImpulseReactor Dynamic Link Library")) return $"Impulse Reactor Core Module {pex.GetInternalVersion()}"; name = pex.ProductName; - if (name?.Contains("ImpulseReactor Dynamic Link Library") == true) + if (name.OptionalContains("ImpulseReactor Dynamic Link Library")) return $"Impulse Reactor Core Module {pex.GetInternalVersion()}"; name = pex.OriginalFilename; - if (name?.Contains("ReactorActivate.exe") == true) + if (name.OptionalContains("ReactorActivate.exe")) return $"Stardock Product Activation {pex.GetInternalVersion()}"; // TODO: Check for CVP* instead? bool containsCheck = false; if (pex.Model.ExportTable?.ExportNameTable?.Strings != null) - containsCheck = Array.Exists(pex.Model.ExportTable.ExportNameTable.Strings, s => s?.StartsWith("CVPInitializeClient") ?? false); + containsCheck = Array.Exists(pex.Model.ExportTable.ExportNameTable.Strings, s => s.OptionalStartsWith("CVPInitializeClient")); // Get the .rdata section strings, if they exist bool containsCheck2 = false; diff --git a/BinaryObjectScanner/Protection/KalypsoLauncher.cs b/BinaryObjectScanner/Protection/KalypsoLauncher.cs index d68368b3..8235a080 100644 --- a/BinaryObjectScanner/Protection/KalypsoLauncher.cs +++ b/BinaryObjectScanner/Protection/KalypsoLauncher.cs @@ -34,13 +34,13 @@ namespace BinaryObjectScanner.Protection var name = pex.InternalName; // Found in "KalypsoLauncher.dll" in Redump entry 95617. - if (name?.Contains("KalypsoLauncher.dll") == true) + if (name.OptionalContains("KalypsoLauncher.dll")) return $"Kalypso Launcher {pex.GetInternalVersion()}"; name = pex.OriginalFilename; // Found in "KalypsoLauncher.dll" in Redump entry 95617. - if (name?.Contains("KalypsoLauncher.dll") == true) + if (name.OptionalContains("KalypsoLauncher.dll")) return $"Kalypso Launcher {pex.GetInternalVersion()}"; // Get the .text section strings, if they exist diff --git a/BinaryObjectScanner/Protection/LabelGate.cs b/BinaryObjectScanner/Protection/LabelGate.cs index ab4078ec..649b707f 100644 --- a/BinaryObjectScanner/Protection/LabelGate.cs +++ b/BinaryObjectScanner/Protection/LabelGate.cs @@ -28,11 +28,11 @@ namespace BinaryObjectScanner.Protection // Should be present on all LabelGate CD2 discs (Redump entry 95010 and product ID SVWC-7185). var name = pex.FileDescription; - if (name?.StartsWith("MAGIQLIP2 Installer", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("MAGIQLIP2 Installer", StringComparison.OrdinalIgnoreCase)) return $"LabelGate CD2 Media Player"; name = pex.ProductName; - if (name?.StartsWith("MQSTART", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("MQSTART", StringComparison.OrdinalIgnoreCase)) return $"LabelGate CD2 Media Player"; // Get the .data/DATA section strings, if they exist diff --git a/BinaryObjectScanner/Protection/MGIRegistration.cs b/BinaryObjectScanner/Protection/MGIRegistration.cs index 33343a39..643a107d 100644 --- a/BinaryObjectScanner/Protection/MGIRegistration.cs +++ b/BinaryObjectScanner/Protection/MGIRegistration.cs @@ -17,7 +17,7 @@ namespace BinaryObjectScanner.Protection var name = pex.ProductName; // Found in "Register.dll" in IA item "MGIPhotoSuite4.0AndPhotoVista2.02001". - if (name?.Equals("MGI Registration Utility", StringComparison.Ordinal) == true) + if (name.OptionalEquals("MGI Registration Utility", StringComparison.Ordinal)) return $"MGI Registration {pex.GetInternalVersion()}"; // Found in "Register.dll" from "VideoWaveIII" in IA item "mgi-videowave-iii-version-3.00-mgi-software-2000". diff --git a/BinaryObjectScanner/Protection/Macrovision.CDilla.cs b/BinaryObjectScanner/Protection/Macrovision.CDilla.cs index adcc890d..58e08448 100644 --- a/BinaryObjectScanner/Protection/Macrovision.CDilla.cs +++ b/BinaryObjectScanner/Protection/Macrovision.CDilla.cs @@ -70,33 +70,33 @@ namespace BinaryObjectScanner.Protection var name = pex.FileDescription; // Found in in "cdilla52.dll" from C-Dilla LMS version 3.24.010. - if (name?.Equals("32-bit C-Dilla DLL", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("32-bit C-Dilla DLL", StringComparison.OrdinalIgnoreCase)) return $"C-Dilla License Management System"; // Found in "CdaIns32.dll" and "CdSet32.exe" from version 3.27.000 of C-Dilla LMS. - if (name?.Equals("C-Dilla Windows 32-Bit RTS Installer", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("C-Dilla Windows 32-Bit RTS Installer", StringComparison.OrdinalIgnoreCase)) return $"C-Dilla License Management System Version {pex.ProductVersion}"; // Found in "CDILLA32.DLL"/"CDILLA64.EXE" from C-Dilla LMS version 3.27.000 for Windows 3.1. - if (name?.Equals("C-Dilla Windows 3.1x RTS", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("C-Dilla Windows 3.1x RTS", StringComparison.OrdinalIgnoreCase)) return $"C-Dilla License Management System Version {pex.ProductVersion}"; // Found in "CDILLA13.DLL"/"CDILLA32.DLL"/"CDILLA64.EXE" from C-Dilla LMS version 3.27.000 for Windows 95. - if (name?.Equals("C-Dilla Windows 95 RTS", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("C-Dilla Windows 95 RTS", StringComparison.OrdinalIgnoreCase)) return $"C-Dilla License Management System Version {pex.ProductVersion}"; // Found in "CDANT.SYS"/"CDILLA13.DLL"/"CDILLA32.DLL"/"CDILLA64.EXE" from C-Dilla LMSversion 3.27.000 for Windows NT. - if (name?.Equals("C-Dilla Windows NT RTS", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("C-Dilla Windows NT RTS", StringComparison.OrdinalIgnoreCase)) return $"C-Dilla License Management System Version {pex.ProductVersion}"; // Found in "CDANTSRV.EXE" from C-Dilla LMS version 3.27.000 for Windows NT, and an embedded executable contained in Redump entry 95524. - if (name?.Equals("C-Dilla RTS Service", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("C-Dilla RTS Service", StringComparison.OrdinalIgnoreCase)) return $"C-Dilla RTS Service Version {pex.ProductVersion}"; name = pex.ProductName; // Found in "CDANTSRV.EXE" from version 3.27.000 of C-Dilla LMS. - if (name?.Equals("CD-Secure/CD-Compress Windows NT", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("CD-Secure/CD-Compress Windows NT", StringComparison.OrdinalIgnoreCase)) return $"C-Dilla License Management System Version {pex.ProductVersion}"; // Get string table resources diff --git a/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs b/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs index 117d328c..7eb2b5fb 100644 --- a/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs +++ b/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs @@ -57,7 +57,7 @@ namespace BinaryObjectScanner.Protection // Found in various files in "Les Paul & Friends" (Barcode 4 98806 834170). var name = pex.ProductName; - if (name?.Equals("CDS300", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("CDS300", StringComparison.OrdinalIgnoreCase)) return $"Cactus Data Shield 300"; return null; diff --git a/BinaryObjectScanner/Protection/Macrovision.FLEXnet.cs b/BinaryObjectScanner/Protection/Macrovision.FLEXnet.cs index daee1321..b03e74df 100644 --- a/BinaryObjectScanner/Protection/Macrovision.FLEXnet.cs +++ b/BinaryObjectScanner/Protection/Macrovision.FLEXnet.cs @@ -22,37 +22,37 @@ namespace BinaryObjectScanner.Protection var name = pex.ProductName; // Found in "IsSvcInstDanceEJay7.dll" in IA item "computer200709dvd" (Dance eJay 7). - if (name?.Equals("FLEXnet Activation Toolkit", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("FLEXnet Activation Toolkit", StringComparison.OrdinalIgnoreCase)) return "FLEXnet"; // Found in "INSTALLS.EXE", "LMGR326B.DLL", "LMGRD.EXE", and "TAKEFIVE.EXE" in IA item "prog-17_202403". - if (name?.Equals("Globetrotter Software Inc lmgr326b Flexlm", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Globetrotter Software Inc lmgr326b Flexlm", StringComparison.OrdinalIgnoreCase)) return $"FlexLM {pex.ProductVersion}"; // Generic case to catch unknown versions. - if (name?.Contains("Flexlm") == true) + if (name.OptionalContains("Flexlm")) return "FlexLM (Unknown Version - Please report to us on GitHub)"; name = pex.FileDescription; // Found in "INSTALLS.EXE", "LMGR326B.DLL", "LMGRD.EXE", and "TAKEFIVE.EXE" in IA item "prog-17_202403". - if (name?.Equals("lmgr326b", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("lmgr326b", StringComparison.OrdinalIgnoreCase)) return $"FlexLM {pex.ProductVersion}"; name = pex.LegalTrademarks; // Found in "INSTALLS.EXE", "LMGR326B.DLL", "LMGRD.EXE", and "TAKEFIVE.EXE" in IA item "prog-17_202403". - if (name?.Equals("Flexible License Manager,FLEXlm,Globetrotter,FLEXID", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Flexible License Manager,FLEXlm,Globetrotter,FLEXID", StringComparison.OrdinalIgnoreCase)) return $"FlexLM {pex.ProductVersion}"; - if (name?.Contains("FLEXlm") == true) + if (name.OptionalContains("FLEXlm")) return $"FlexLM {pex.ProductVersion}"; name = pex.OriginalFilename; // Found in "INSTALLS.EXE", "LMGR326B.DLL", "LMGRD.EXE", and "TAKEFIVE.EXE" in IA item "prog-17_202403". // It isn't known why these various executables have the same original filename. - if (name?.Equals("lmgr326b.dll", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("lmgr326b.dll", StringComparison.OrdinalIgnoreCase)) return $"FlexLM {pex.ProductVersion}"; // Get the .data/DATA section strings, if they exist diff --git a/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs b/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs index f778d194..ce637d06 100644 --- a/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs +++ b/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs @@ -28,12 +28,12 @@ namespace BinaryObjectScanner.Protection // Found in "RGASDEV.SYS" in the Black Lagoon Season 1 DVD Steelbook box set (Geneon ID 12970). var name = pex.FileDescription; - if (name?.Equals("rgasdev", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("rgasdev", StringComparison.OrdinalIgnoreCase)) return "RipGuard"; // Found in "RGASDEV.SYS" in the Black Lagoon Season 1 DVD Steelbook box set (Geneon ID 12970). name = pex.ProductName; - if (name?.Equals("rgasdev", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("rgasdev", StringComparison.OrdinalIgnoreCase)) return "RipGuard"; if (!string.IsNullOrEmpty(file) && File.Exists(file)) diff --git a/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs b/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs index a2f99b8d..0f312c59 100644 --- a/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs +++ b/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs @@ -104,41 +104,41 @@ namespace BinaryObjectScanner.Protection // Found in "32bit\Tax02\cdac14ba.dll" in IA item "TurboTax Deluxe Tax Year 2002 for Wndows (2.00R)(Intuit)(2002)(352282)". var name = pex.FileDescription; - if (name?.Equals("SafeCast2", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("SafeCast2", StringComparison.OrdinalIgnoreCase)) return "SafeCast"; // Found in "cdac01ba.dll" from IA item "ejay_nestle_trial". // TODO: Figure out a reasonable way to parse version. - if (name?.Equals("CdaC01BA", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("CdaC01BA", StringComparison.OrdinalIgnoreCase)) return $"SafeCast"; // Found in "C2CDEL.EXE" in IA item "britney-spears-special-edition-cd-rom". - if (name?.Equals("32-bit SafeCast Copy To Clear Delete", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("32-bit SafeCast Copy To Clear Delete", StringComparison.OrdinalIgnoreCase)) return $"SafeCast"; // Found in "C2C.DLL" in IA item "britney-spears-special-edition-cd-rom". - if (name?.Equals("32-bit SafeCast Shell Copy To Clear DLL", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("32-bit SafeCast Shell Copy To Clear DLL", StringComparison.OrdinalIgnoreCase)) return $"SafeCast"; // Found in "SCRfrsh.exe" in Redump entry 102979. - if (name?.Equals("32-bit SafeCast Toolkit", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("32-bit SafeCast Toolkit", StringComparison.OrdinalIgnoreCase)) return $"SafeCast {pex.FileVersion}"; // Found in "CDAC14BA.DLL" in Redump entry 95524. - if (name?.Equals("32-bit SafeCast Anchor Installer", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("32-bit SafeCast Anchor Installer", StringComparison.OrdinalIgnoreCase)) return $"SafeCast"; // Found in "CDAC21BA.DLL" in Redump entry 95524. - if (name?.Equals("32-bit CdaC20BA", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("32-bit CdaC20BA", StringComparison.OrdinalIgnoreCase)) return $"SafeCast"; // Found in hidden resource of "32bit\Tax02\cdac14ba.dll" in IA item "TurboTax Deluxe Tax Year 2002 for Wndows (2.00R)(Intuit)(2002)(352282)". name = pex.ProductName; - if (name?.Equals("SafeCast Windows NT", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("SafeCast Windows NT", StringComparison.OrdinalIgnoreCase)) return "SafeCast"; // Found in "cdac01ba.dll" from IA item "ejay_nestle_trial". - if (name?.Equals("SafeCast", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("SafeCast", StringComparison.OrdinalIgnoreCase)) return "SafeCast"; // Check for CDSHARE/DISAG_SH sections diff --git a/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs b/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs index ad1b50b4..b4ec4661 100644 --- a/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs +++ b/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs @@ -81,30 +81,30 @@ namespace BinaryObjectScanner.Protection var name = pex.FileDescription; // Present in "Diag.exe" files from SafeDisc 4.50.000+. - if (name?.Equals("SafeDisc SRV Tool APP", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("SafeDisc SRV Tool APP", StringComparison.OrdinalIgnoreCase)) return $"SafeDisc SRV Tool APP {GetSafeDiscDiagExecutableVersion(pex)}"; // Present in "Setup.exe" from the later "safedisc.exe" driver update provided by Macrovision. - if (name?.Equals("Macrovision SecDrv Update", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Macrovision SecDrv Update", StringComparison.OrdinalIgnoreCase)) return "Macrovision SecDrv Update Installer"; // Present on all "CLOKSPL.DLL" versions before SafeDisc 1.06.000. Found on Redump entries 61731 and 66004. name = pex.ProductName; - if (name?.Equals("SafeDisc CDROM Protection System", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("SafeDisc CDROM Protection System", StringComparison.OrdinalIgnoreCase)) return "SafeDisc 1.00.025-1.01.044"; // Present in "Diag.exe" files from SafeDisc 4.50.000+. - else if (name?.Equals("SafeDisc SRV Tool APP", StringComparison.OrdinalIgnoreCase) == true) + else if (name.OptionalEquals("SafeDisc SRV Tool APP", StringComparison.OrdinalIgnoreCase)) return $"SafeDisc SRV Tool APP {GetSafeDiscDiagExecutableVersion(pex)}"; // Present in "Setup.exe" from the later "safedisc.exe" driver update provided by Macrovision. - if (name?.Equals("Macrovision SecDrv Update", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Macrovision SecDrv Update", StringComparison.OrdinalIgnoreCase)) return "Macrovision SecDrv Update Installer"; // Present on all "CLOKSPL.EXE" versions before SafeDisc 1.06.000. Found on Redump entries 61731 and 66004. // Only found so far on SafeDisc 1.00.025-1.01.044, but the report is currently left generic due to the generic nature of the check. name = pex.FileDescription; - if (name?.Equals("SafeDisc", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("SafeDisc", StringComparison.OrdinalIgnoreCase)) return "SafeDisc"; // Found in Redump entries 20729 and 65569. diff --git a/BinaryObjectScanner/Protection/Macrovision.cs b/BinaryObjectScanner/Protection/Macrovision.cs index 095b97ce..7b4fc8c9 100644 --- a/BinaryObjectScanner/Protection/Macrovision.cs +++ b/BinaryObjectScanner/Protection/Macrovision.cs @@ -58,13 +58,13 @@ namespace BinaryObjectScanner.Protection var name = pex.FileDescription; // Present in "secdrv.sys" files found in SafeDisc 2.80.010+. - if (name?.Equals("Macrovision SECURITY Driver", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Macrovision SECURITY Driver", StringComparison.OrdinalIgnoreCase)) resultsList.Add($"Macrovision Security Driver {GetSecDrvExecutableVersion(pex)}"); // Found in hidden resource of "32bit\Tax02\cdac14ba.dll" in IA item "TurboTax Deluxe Tax Year 2002 for Wndows (2.00R)(Intuit)(2002)(352282)". // Known versions: // 4.16.050 Windows NT 2002/04/24 - if (name?.Equals("Macrovision RTS Service", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Macrovision RTS Service", StringComparison.OrdinalIgnoreCase)) resultsList.Add($"Macrovision RTS Service {pex.FileVersion}"); // The stxt371 and stxt774 sections are found in various newer Macrovision products, including various versions of CDS-300, SafeCast, and SafeDisc. diff --git a/BinaryObjectScanner/Protection/MediaCloQ.cs b/BinaryObjectScanner/Protection/MediaCloQ.cs index 6926c089..5b22a061 100644 --- a/BinaryObjectScanner/Protection/MediaCloQ.cs +++ b/BinaryObjectScanner/Protection/MediaCloQ.cs @@ -25,12 +25,12 @@ namespace BinaryObjectScanner.Protection // Found in scvfy.exe on "Charley Pride - A Tribute to Jim Reeves" (barcode "7 816190222-2 4"). var name = pex.FileDescription; - if (name?.StartsWith("scvfy MFC Application", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("scvfy MFC Application", StringComparison.OrdinalIgnoreCase)) return $"MediaCloQ"; // Found in scvfy.exe on "Charley Pride - A Tribute to Jim Reeves" (barcode "7 816190222-2 4"). name = pex.ProductName; - if (name?.StartsWith("scvfy Application", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("scvfy Application", StringComparison.OrdinalIgnoreCase)) return $"MediaCloQ"; return null; diff --git a/BinaryObjectScanner/Protection/MediaMax.cs b/BinaryObjectScanner/Protection/MediaMax.cs index 25df04cc..b33de5b2 100644 --- a/BinaryObjectScanner/Protection/MediaMax.cs +++ b/BinaryObjectScanner/Protection/MediaMax.cs @@ -25,11 +25,11 @@ namespace BinaryObjectScanner.Protection // Used to detect "LicGen.exe", found on "All That I Am" by Santana (Barcode 8 2876-59773-2 6) var name = pex.FileDescription; - if (name?.StartsWith("LicGen Module", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("LicGen Module", StringComparison.OrdinalIgnoreCase)) return $"MediaMax CD-3"; name = pex.ProductName; - if (name?.StartsWith("LicGen Module", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("LicGen Module", StringComparison.OrdinalIgnoreCase)) return $"MediaMax CD-3"; if (pex.FindGenericResource("Cd3Ctl").Count > 0) diff --git a/BinaryObjectScanner/Protection/NProtect.cs b/BinaryObjectScanner/Protection/NProtect.cs index cef2f7e6..be6f95e5 100644 --- a/BinaryObjectScanner/Protection/NProtect.cs +++ b/BinaryObjectScanner/Protection/NProtect.cs @@ -43,37 +43,37 @@ namespace BinaryObjectScanner.Protection var name = pex.FileDescription; // Found in "GameGuard.des" in Redump entry 90526 and 99598, and "Soulworker" (Steam Depot 1377581, Manifest 5092481117079359342). - if (name?.Contains("nProtect GameGuard Launcher") == true) + if (name.OptionalContains("nProtect GameGuard Launcher")) return $"nProtect GameGuard ({pex.GetInternalVersion()})"; // Found in "npkcrypt.dll" in Redump entry 90526. - if (name?.Contains("nProtect KeyCrypt Driver Support Dll") == true) + if (name.OptionalContains("nProtect KeyCrypt Driver Support Dll")) return $"nProtect KeyCrypt ({pex.GetInternalVersion()})"; // Found in "npkcrypt.sys" and "npkcusb.sys" in Redump entry 90526. - if (name?.Contains("nProtect KeyCrypt Driver") == true) + if (name.OptionalContains("nProtect KeyCrypt Driver")) return $"nProtect KeyCrypt ({pex.GetInternalVersion()})"; // Found in "npkpdb.dll" in Redump entry 90526. - if (name?.Contains("nProtect KeyCrypt Program Database DLL") == true) + if (name.OptionalContains("nProtect KeyCrypt Program Database DLL")) return $"nProtect KeyCrypt ({pex.GetInternalVersion()})"; name = pex.ProductName; // Found in "GameGuard.des" in Redump entry 90526 and 99598. - if (name?.Contains("nProtect GameGuard Launcher") == true) + if (name.OptionalContains("nProtect GameGuard Launcher")) return $"nProtect GameGuard ({pex.GetInternalVersion()})"; // Found in "npkcrypt.dll" in Redump entry 90526. - if (name?.Contains("nProtect KeyCrypt Driver Support Dll") == true) + if (name.OptionalContains("nProtect KeyCrypt Driver Support Dll")) return $"nProtect KeyCrypt ({pex.GetInternalVersion()})"; // Found in "npkcrypt.sys" and "npkcusb.sys" in Redump entry 90526. - if (name?.Contains("nProtect KeyCrypt Driver") == true) + if (name.OptionalContains("nProtect KeyCrypt Driver")) return $"nProtect KeyCrypt ({pex.GetInternalVersion()})"; // Found in "npkpdb.dll" in Redump entry 90526. - if (name?.Contains("nProtect KeyCrypt Program Database DLL") == true) + if (name.OptionalContains("nProtect KeyCrypt Program Database DLL")) return $"nProtect KeyCrypt ({pex.GetInternalVersion()})"; return null; diff --git a/BinaryObjectScanner/Protection/OnlineRegistration.cs b/BinaryObjectScanner/Protection/OnlineRegistration.cs index bab2f639..c011dcde 100644 --- a/BinaryObjectScanner/Protection/OnlineRegistration.cs +++ b/BinaryObjectScanner/Protection/OnlineRegistration.cs @@ -16,7 +16,7 @@ namespace BinaryObjectScanner.Protection // TODO: Is this too broad in general? var name = pex.InternalName; - if (name?.StartsWith("EReg", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("EReg", StringComparison.OrdinalIgnoreCase)) return $"Executable-Based Online Registration {pex.GetInternalVersion()}"; return null; diff --git a/BinaryObjectScanner/Protection/OpenMG.cs b/BinaryObjectScanner/Protection/OpenMG.cs index b5061cd7..606655c4 100644 --- a/BinaryObjectScanner/Protection/OpenMG.cs +++ b/BinaryObjectScanner/Protection/OpenMG.cs @@ -26,38 +26,38 @@ namespace BinaryObjectScanner.Protection // Found in many different OpenMG related files ("Touch" by Amerie). var name = pex.LegalTrademarks; - if (name?.StartsWith("OpenMG", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("OpenMG", StringComparison.OrdinalIgnoreCase)) return $"OpenMG"; // Found in "OMGDBP.OCX" ("Touch" by Amerie). name = pex.FileDescription; - if (name?.StartsWith("LGDiscComp Module", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("LGDiscComp Module", StringComparison.OrdinalIgnoreCase)) return $"OpenMG"; // Found in "OMGDWRAP.DLL" ("Touch" by Amerie). - if (name?.StartsWith("LGDSimplePlayer Module", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("LGDSimplePlayer Module", StringComparison.OrdinalIgnoreCase)) return $"OpenMG"; // Found in "OMGLGD.DLL" ("Touch" by Amerie). - if (name?.StartsWith("omglgd Module", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("omglgd Module", StringComparison.OrdinalIgnoreCase)) return $"OpenMG"; // Found in "OMGUTILS.DLL" ("Touch" by Amerie). - if (name?.StartsWith("OpenMG Utility", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("OpenMG Utility", StringComparison.OrdinalIgnoreCase)) return $"OpenMG"; // Found in "SALWRAP.DLL" ("Touch" by Amerie). - if (name?.StartsWith("Secure Application Loader Wrapper", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("Secure Application Loader Wrapper", StringComparison.OrdinalIgnoreCase)) return $"OpenMG"; // Found in "SDKHM.DLL" ("Touch" by Amerie). // Not every copy of this file has this File Description (Redump entry 95010). - if (name?.StartsWith("SDKHM (KEEP)", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("SDKHM (KEEP)", StringComparison.OrdinalIgnoreCase)) return $"OpenMG"; // Found in "SDKHM.EXE" ("Touch" by Amerie). // Not every copy of this file has this File Description (Redump entry 95010). - if (name?.StartsWith("SDKHM (KEPT)", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("SDKHM (KEPT)", StringComparison.OrdinalIgnoreCase)) return $"OpenMG"; return null; diff --git a/BinaryObjectScanner/Protection/Origin.cs b/BinaryObjectScanner/Protection/Origin.cs index 253fbb27..2a40a32b 100644 --- a/BinaryObjectScanner/Protection/Origin.cs +++ b/BinaryObjectScanner/Protection/Origin.cs @@ -18,11 +18,11 @@ namespace BinaryObjectScanner.Protection return null; var name = pex.FileDescription; - if (name?.Equals("Origin", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Origin", StringComparison.OrdinalIgnoreCase)) return "Origin"; name = pex.ProductName; - if (name?.Equals("Origin", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Origin", StringComparison.OrdinalIgnoreCase)) return "Origin"; return null; diff --git a/BinaryObjectScanner/Protection/PlayJ.cs b/BinaryObjectScanner/Protection/PlayJ.cs index 13ed4e4b..f45268fe 100644 --- a/BinaryObjectScanner/Protection/PlayJ.cs +++ b/BinaryObjectScanner/Protection/PlayJ.cs @@ -23,17 +23,17 @@ namespace BinaryObjectScanner.Protection // Found in "PlayJ.exe" (https://web.archive.org/web/20010417025347/http://dlp.playj.com:80/playj/PlayJIns266.exe) and "CACTUSPJ.exe" ("Volumia!" by Puur (Barcode 7 43218 63282 2) (Discogs Release Code [r795427])). var name = pex.FileDescription; - if (name?.StartsWith("PlayJ Music Player", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("PlayJ Music Player", StringComparison.OrdinalIgnoreCase)) return $"PlayJ Music Player"; // Found in "PJSTREAM.DLL" ("Volumia!" by Puur (Barcode 7 43218 63282 2) (Discogs Release Code [r795427])). name = pex.FileDescription; - if (name?.StartsWith("EVAUX32 Module", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("EVAUX32 Module", StringComparison.OrdinalIgnoreCase)) return $"PlayJ Music Player Component"; // Found in "PlayJ.exe" (https://web.archive.org/web/20010417025347/http://dlp.playj.com:80/playj/PlayJIns266.exe) and "CACTUSPJ.exe" ("Volumia!" by Puur (Barcode 7 43218 63282 2) (Discogs Release Code [r795427])). name = pex.ProductName; - if (name?.StartsWith("PlayJ", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("PlayJ", StringComparison.OrdinalIgnoreCase)) return $"PlayJ"; return null; diff --git a/BinaryObjectScanner/Protection/RainbowSentinel.cs b/BinaryObjectScanner/Protection/RainbowSentinel.cs index aa0f2199..42880bc3 100644 --- a/BinaryObjectScanner/Protection/RainbowSentinel.cs +++ b/BinaryObjectScanner/Protection/RainbowSentinel.cs @@ -139,63 +139,63 @@ namespace BinaryObjectScanner.Protection var name = pex.FileDescription; // Found in "RNBOVTMP.DLL" in BA entry "Autodesk AutoCAD LT 98 (1998) (CD) [English] [Dutch]". - if (name?.Equals("Rainbow Technologies Virtual Device Driver", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Rainbow Technologies Virtual Device Driver", StringComparison.OrdinalIgnoreCase)) return $"Rainbow Sentinel {pex.ProductVersion}"; // Found in "SENTTEMP.DLL" in BA entry "Autodesk AutoCAD LT 98 (1998) (CD) [English] [Dutch]". - if (name?.Equals("Rainbow Technologies Sentinel Driver", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Rainbow Technologies Sentinel Driver", StringComparison.OrdinalIgnoreCase)) return $"Rainbow Sentinel {pex.ProductVersion}"; // Found in "SETUPX86.EXE"/"SENTW95.EXE" in BA entry "Autodesk AutoCAD LT 98 (1998) (CD) [English] [Dutch]". - if (name?.Equals("Sentinel Driver Setup DLL", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Sentinel Driver Setup DLL", StringComparison.OrdinalIgnoreCase)) return $"Rainbow Sentinel {pex.ProductVersion}"; // Found in "SNTI386.DLL"/"SENTW95.DLL" in BA entry "Autodesk AutoCAD LT 98 (1998) (CD) [English] [Dutch]". - if (name?.Equals("Install, Setup - Sentinel Driver", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Install, Setup - Sentinel Driver", StringComparison.OrdinalIgnoreCase)) return $"Rainbow Sentinel {pex.ProductVersion}"; // Found in "wd126.zip/WDSHARE.EXE/SX32W.DL_" in IA item "ASMEsMechanicalEngineeringToolkit1997December" and "WDSHARE.ZIP/WDSHARE.EXE/SX32W.DL_" in IA item "aplicaciones-windows". - if (name?.Equals("Rainbow Technologies SentinelSuperPro WIN32 DLL", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Rainbow Technologies SentinelSuperPro WIN32 DLL", StringComparison.OrdinalIgnoreCase)) return $"Rainbow Sentinel SuperPro {pex.ProductVersion}"; // Found in "SP32W.DLL" in IA item "pcwkcd-1296". - if (name?.Equals("Rainbow Technologies SentinelPro WIN32 DLL", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Rainbow Technologies SentinelPro WIN32 DLL", StringComparison.OrdinalIgnoreCase)) return $"Rainbow SentinelPro {pex.ProductVersion}"; // Found in "NSRVGX.EXE" in IA item "czchip199707cd". - if (name?.Equals("NetSentinel Server for WIN 32", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("NetSentinel Server for WIN 32", StringComparison.OrdinalIgnoreCase)) return "Rainbow NetSentinel Server for Win32"; // Found in "\disc4\cad\sdcc_200.zip\DISK1\_USER1.HDR\Language_Independent_Intel_32_Files\SNTNLUSB.SYS" in "CICA 32 For Windows CD-ROM (Walnut Creek) (October 1999) (Disc 4).iso" in IA item "CICA_32_For_Windows_CD-ROM_Walnut_Creek_October_1999". // TODO: Check if the version included with this is useful. - if (name?.Equals("Rainbow Technologies Sentinel Device Driver", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Rainbow Technologies Sentinel Device Driver", StringComparison.OrdinalIgnoreCase)) return "Rainbow Sentinel Driver"; name = pex.ProductName; // Found in multiple files in BA entry "Autodesk AutoCAD LT 98 (1998) (CD) [English] [Dutch]", including "RNBOVTMP.DLL", "SENTTEMP.DLL", and "SNTI386.DLL". - if (name?.Equals("Rainbow Technologies Sentinel", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Rainbow Technologies Sentinel", StringComparison.OrdinalIgnoreCase)) return $"Rainbow Sentinel {pex.ProductVersion}"; // Found in "SETUPX86.EXE"/"SENTW95.EXE" in BA entry "Autodesk AutoCAD LT 98 (1998) (CD) [English] [Dutch]". - if (name?.Equals("Sentinel Driver Setup", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Sentinel Driver Setup", StringComparison.OrdinalIgnoreCase)) return $"Rainbow Sentinel {pex.ProductVersion}"; // Found in "wd126.zip/WDSHARE.EXE/SX32W.DL_" in IA item "ASMEsMechanicalEngineeringToolkit1997December" and "WDSHARE.ZIP/WDSHARE.EXE/SX32W.DL_" in IA item "aplicaciones-windows". - if (name?.Equals("Rainbow Technologies SentinelSuperPro WIN32 DLL", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Rainbow Technologies SentinelSuperPro WIN32 DLL", StringComparison.OrdinalIgnoreCase)) return $"Rainbow Sentinel SuperPro {pex.ProductVersion}"; // Found in "SP32W.DLL" in IA item "pcwkcd-1296". - if (name?.Equals("Rainbow Technologies SentinelPro WIN32 DLL", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Rainbow Technologies SentinelPro WIN32 DLL", StringComparison.OrdinalIgnoreCase)) return $"Rainbow SentinelPro {pex.ProductVersion}"; // Found in "F481_SetupSysDriver.exe.B391C18A_6953_11D4_82CB_00D0B72E1DB9"/"SetupSysDriver.exe" in IA item "chip-cds-2001-08". - if (name?.Equals("Sentinel System Driver", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Sentinel System Driver", StringComparison.OrdinalIgnoreCase)) return $"Rainbow Sentinel {pex.ProductVersion}"; // Found in "\disc4\cad\sdcc_200.zip\DISK1\_USER1.HDR\Language_Independent_Intel_32_Files\SNTNLUSB.SYS" in "CICA 32 For Windows CD-ROM (Walnut Creek) (October 1999) (Disc 4).iso" in IA item "CICA_32_For_Windows_CD-ROM_Walnut_Creek_October_1999". // TODO: Check if the version included with this is useful. - if (name?.Equals("Rainbow Technologies USB Security Device Driver", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalEquals("Rainbow Technologies USB Security Device Driver", StringComparison.OrdinalIgnoreCase)) return "Rainbow Sentinel Driver"; // Get the .data/DATA section strings, if they exist diff --git a/BinaryObjectScanner/Protection/RealArcade.cs b/BinaryObjectScanner/Protection/RealArcade.cs index d4ec8aa3..dd923ec5 100644 --- a/BinaryObjectScanner/Protection/RealArcade.cs +++ b/BinaryObjectScanner/Protection/RealArcade.cs @@ -34,7 +34,7 @@ namespace BinaryObjectScanner.Protection // Found in "RngInterstitial.dll" in the RealArcade installation directory in IA item "Nova_RealArcadeCD_USA". var name = pex.FileDescription; - if (name?.Contains("RngInterstitial") == true) + if (name.OptionalContains("RngInterstitial")) return "RealArcade"; return null; diff --git a/BinaryObjectScanner/Protection/SecuROM.cs b/BinaryObjectScanner/Protection/SecuROM.cs index 4de2a597..8e30ca44 100644 --- a/BinaryObjectScanner/Protection/SecuROM.cs +++ b/BinaryObjectScanner/Protection/SecuROM.cs @@ -20,23 +20,23 @@ namespace BinaryObjectScanner.Protection return null; var name = pex.FileDescription; - if (name?.Contains("SecuROM PA") == true) + if (name.OptionalContains("SecuROM PA")) return $"SecuROM Product Activation v{pex.GetInternalVersion()}"; name = pex.InternalName; - if (name?.Equals("paul.dll") == true) + if (name.OptionalEquals("paul.dll")) return $"SecuROM Product Activation v{pex.GetInternalVersion()}"; - else if (name?.Equals("paul_dll_activate_and_play.dll") == true) + else if (name.OptionalEquals("paul_dll_activate_and_play.dll")) return $"SecuROM Product Activation v{pex.GetInternalVersion()}"; - else if (name?.Equals("paul_dll_preview_and_review.dll") == true) + else if (name.OptionalEquals("paul_dll_preview_and_review.dll")) return $"SecuROM Product Activation v{pex.GetInternalVersion()}"; name = pex.OriginalFilename; - if (name?.Equals("paul_dll_activate_and_play.dll") == true) + if (name.OptionalEquals("paul_dll_activate_and_play.dll")) return $"SecuROM Product Activation v{pex.GetInternalVersion()}"; name = pex.ProductName; - if (name?.Contains("SecuROM Activate & Play") == true) + if (name.OptionalContains("SecuROM Activate & Play")) return $"SecuROM Product Activation v{pex.GetInternalVersion()}"; // Get the matrosch section, if it exists diff --git a/BinaryObjectScanner/Protection/SoftLock.cs b/BinaryObjectScanner/Protection/SoftLock.cs index 80502fd4..24d46671 100644 --- a/BinaryObjectScanner/Protection/SoftLock.cs +++ b/BinaryObjectScanner/Protection/SoftLock.cs @@ -23,12 +23,12 @@ namespace BinaryObjectScanner.Protection // Found in "IALib.DLL" in IA item "TAFSEERVER4SETUP" var name = pex.InternalName; - if (name?.Equals("Softlock Protected Application") == true) + if (name.OptionalEquals("Softlock Protected Application")) return "SoftLock"; // Found in "IALib.DLL" in IA item "TAFSEERVER4SETUP" name = pex.Comments; - if (name?.Equals("Softlock Protected Application") == true) + if (name.OptionalEquals("Softlock Protected Application")) return "SoftLock"; // Found in "IALib.DLL" in IA item "TAFSEERVER4SETUP" diff --git a/BinaryObjectScanner/Protection/SolidShield.cs b/BinaryObjectScanner/Protection/SolidShield.cs index f512507a..ad99b7d6 100644 --- a/BinaryObjectScanner/Protection/SolidShield.cs +++ b/BinaryObjectScanner/Protection/SolidShield.cs @@ -23,31 +23,31 @@ namespace BinaryObjectScanner.Protection return null; var name = pex.FileDescription; - if (name?.StartsWith("DVM Library", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("DVM Library", StringComparison.OrdinalIgnoreCase)) return $"SolidShield {pex.GetInternalVersion()}"; - else if (name?.StartsWith("Solidshield Activation Library", StringComparison.OrdinalIgnoreCase) == true) + else if (name.OptionalStartsWith("Solidshield Activation Library", StringComparison.OrdinalIgnoreCase)) return $"SolidShield Core.dll {pex.GetInternalVersion()}"; - else if (name?.StartsWith("Activation Manager", StringComparison.OrdinalIgnoreCase) == true) + else if (name.OptionalStartsWith("Activation Manager", StringComparison.OrdinalIgnoreCase)) return $"SolidShield Activation Manager Module {GetInternalVersion(pex)}"; // Found in "tvdm.dll" in Redump entry 68166. - else if (name?.StartsWith("Solidshield Library", StringComparison.OrdinalIgnoreCase) == true) + else if (name.OptionalStartsWith("Solidshield Library", StringComparison.OrdinalIgnoreCase)) return $"SolidShield {GetInternalVersion(pex)}"; name = pex.ProductName; - if (name?.StartsWith("Solidshield Activation Library", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("Solidshield Activation Library", StringComparison.OrdinalIgnoreCase)) return $"SolidShield Core.dll {pex.GetInternalVersion()}"; - else if (name?.StartsWith("Solidshield Library", StringComparison.OrdinalIgnoreCase) == true) + else if (name.OptionalStartsWith("Solidshield Library", StringComparison.OrdinalIgnoreCase)) return $"SolidShield Core.dll {pex.GetInternalVersion()}"; - else if (name?.StartsWith("Activation Manager", StringComparison.OrdinalIgnoreCase) == true) + else if (name.OptionalStartsWith("Activation Manager", StringComparison.OrdinalIgnoreCase)) return $"SolidShield Activation Manager Module {GetInternalVersion(pex)}"; // Found in "tvdm.dll" in Redump entry 68166. - else if (name?.StartsWith("Solidshield Library", StringComparison.OrdinalIgnoreCase) == true) + else if (name.OptionalStartsWith("Solidshield Library", StringComparison.OrdinalIgnoreCase)) return $"SolidShield {GetInternalVersion(pex)}"; // Get the .init section, if it exists diff --git a/BinaryObjectScanner/Protection/StarForce.cs b/BinaryObjectScanner/Protection/StarForce.cs index 160f2103..afa5ec55 100644 --- a/BinaryObjectScanner/Protection/StarForce.cs +++ b/BinaryObjectScanner/Protection/StarForce.cs @@ -33,49 +33,49 @@ namespace BinaryObjectScanner.Protection // "Helper Application" - Found in "protect.x64" and "protect.x86" in Redump entry 81756. // Found in "sfdrvrem.exe" in Redump entry 102677. - if (name?.Contains("FrontLine Drivers Removal Tool") == true) + if (name.OptionalContains("FrontLine Drivers Removal Tool")) return $"StarForce FrontLine Driver Removal Tool"; // Found in "protect.exe" in Redump entry 94805. - if (name?.Contains("FrontLine Protection GUI Application") == true) + if (name.OptionalContains("FrontLine Protection GUI Application")) return $"StarForce {pex.GetInternalVersion()}"; // Found in "protect.dll" in Redump entry 94805. - if (name?.Contains("FrontLine Protection Library") == true) + if (name.OptionalContains("FrontLine Protection Library")) return $"StarForce {pex.GetInternalVersion()}"; // Found in "protect.x64" and "protect.x86" in Redump entry 94805. - if (name?.Contains("FrontLine Helper") == true) + if (name.OptionalContains("FrontLine Helper")) return $"StarForce {pex.GetInternalVersion()}"; // TODO: Find a sample of this check. - if (name?.Contains("Protected Module") == true) + if (name.OptionalContains("Protected Module")) return $"StarForce 5"; name = pex.LegalCopyright; - if (name?.StartsWith("(c) Protection Technology") == true) // (c) Protection Technology (StarForce)? + if (name.OptionalStartsWith("(c) Protection Technology")) // (c) Protection Technology (StarForce)? return $"StarForce {pex.GetInternalVersion()}"; - else if (name?.Contains("Protection Technology") == true) // Protection Technology (StarForce)? + else if (name.OptionalContains("Protection Technology")) // Protection Technology (StarForce)? return $"StarForce {pex.GetInternalVersion()}"; // TODO: Decide if internal name checks are safe to use. name = pex.InternalName; // Found in "protect.x64" and "protect.x86" in Redump entry 94805. - if (name?.Equals("CORE.ADMIN", StringComparison.Ordinal) == true) + if (name.OptionalEquals("CORE.ADMIN", StringComparison.Ordinal)) return $"StarForce {pex.GetInternalVersion()}"; // These checks currently disabled due being possibly too generic: // Found in "protect.dll" in Redump entry 94805. - // if (name?.Equals("CORE.DLL", StringComparison.Ordinal) == true) + // if (name.OptionalEquals("CORE.DLL", StringComparison.Ordinal)) // return $"StarForce {Tools.Utilities.GetInternalVersion(pex)}"; // // Found in "protect.exe" in Redump entry 94805. - // if (name?.Equals("CORE.EXE", StringComparison.Ordinal) == true) + // if (name.OptionalEquals("CORE.EXE", StringComparison.Ordinal)) // return $"StarForce {Tools.Utilities.GetInternalVersion(pex)}"; // - // else if (name?.Equals("protect.exe", StringComparison.Ordinal) == true) + // else if (name.OptionalEquals("protect.exe", StringComparison.Ordinal)) // return $"StarForce {Tools.Utilities.GetInternalVersion(pex)}"; // Check the export name table diff --git a/BinaryObjectScanner/Protection/Steam.cs b/BinaryObjectScanner/Protection/Steam.cs index 7b31c831..48bab049 100644 --- a/BinaryObjectScanner/Protection/Steam.cs +++ b/BinaryObjectScanner/Protection/Steam.cs @@ -17,21 +17,21 @@ namespace BinaryObjectScanner.Protection return null; var name = pex.FileDescription; - if (name?.Contains("Steam Autorun Setup") == true) + if (name.OptionalContains("Steam Autorun Setup")) return "Steam"; - else if (name?.Contains("Steam Client API") == true) + else if (name.OptionalContains("Steam Client API")) return "Steam"; - else if (name?.Contains("Steam Client Engine") == true) + else if (name.OptionalContains("Steam Client Engine")) return $"Steam Client Engine {pex.GetInternalVersion()}"; - else if (name?.Contains("Steam Client Service") == true) + else if (name.OptionalContains("Steam Client Service")) return "Steam"; name = pex.ProductName; - if (name?.Contains("Steam Autorun Setup") == true) + if (name.OptionalContains("Steam Autorun Setup")) return "Steam"; - else if (name?.Contains("Steam Client API") == true) + else if (name.OptionalContains("Steam Client API")) return "Steam"; - else if (name?.Contains("Steam Client Service") == true) + else if (name.OptionalContains("Steam Client Service")) return "Steam"; /// TODO: Add entry point checks diff --git a/BinaryObjectScanner/Protection/Tages.cs b/BinaryObjectScanner/Protection/Tages.cs index b9bc72fc..10318f58 100644 --- a/BinaryObjectScanner/Protection/Tages.cs +++ b/BinaryObjectScanner/Protection/Tages.cs @@ -30,15 +30,15 @@ namespace BinaryObjectScanner.Protection // - TagesClient.dat (Does not always exist) var name = pex.FileDescription; - if (name?.StartsWith("TagesSetup", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("TagesSetup", StringComparison.OrdinalIgnoreCase)) return $"TAGES Driver Setup {GetVersion(pex)}"; - else if (name?.StartsWith("Tagès activation client", StringComparison.OrdinalIgnoreCase) == true) + else if (name.OptionalStartsWith("Tagès activation client", StringComparison.OrdinalIgnoreCase)) return $"TAGES Activation Client {GetVersion(pex)}"; name = pex.ProductName; - if (name?.StartsWith("Application TagesSetup", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("Application TagesSetup", StringComparison.OrdinalIgnoreCase)) return $"TAGES Driver Setup {GetVersion(pex)}"; - else if (name?.StartsWith("T@GES", StringComparison.OrdinalIgnoreCase) == true) + else if (name.OptionalStartsWith("T@GES", StringComparison.OrdinalIgnoreCase)) return $"TAGES Activation Client {GetVersion(pex)}"; // TODO: Add entry point check diff --git a/BinaryObjectScanner/Protection/Uplay.cs b/BinaryObjectScanner/Protection/Uplay.cs index d2ef8c5c..8a156d56 100644 --- a/BinaryObjectScanner/Protection/Uplay.cs +++ b/BinaryObjectScanner/Protection/Uplay.cs @@ -18,26 +18,26 @@ namespace BinaryObjectScanner.Protection return null; var name = pex.FileDescription; - if (name?.Contains("Ubisoft Connect Installer") == true) + if (name.OptionalContains("Ubisoft Connect Installer")) return "Uplay / Ubisoft Connect"; - else if (name?.Contains("Ubisoft Connect Service") == true) + else if (name.OptionalContains("Ubisoft Connect Service")) return "Uplay / Ubisoft Connect"; - else if (name?.Contains("Ubisoft Connect WebCore") == true) + else if (name.OptionalContains("Ubisoft Connect WebCore")) return "Uplay / Ubisoft Connect"; - else if (name?.Contains("Ubisoft Crash Reporter") == true) + else if (name.OptionalContains("Ubisoft Crash Reporter")) return "Uplay / Ubisoft Connect"; - else if (name?.Contains("Ubisoft Game Launcher") == true) + else if (name.OptionalContains("Ubisoft Game Launcher")) return "Uplay / Ubisoft Connect"; - else if (name?.Contains("Ubisoft Uplay Installer") == true) + else if (name.OptionalContains("Ubisoft Uplay Installer")) return "Uplay / Ubisoft Connect"; - else if (name?.Contains("Uplay launcher") == true) + else if (name.OptionalContains("Uplay launcher")) return "Uplay / Ubisoft Connect"; // There's also a variant that looks like "Uplay installer" name = pex.ProductName; - if (name?.Contains("Ubisoft Connect") == true) + if (name.OptionalContains("Ubisoft Connect")) return "Uplay / Ubisoft Connect"; - else if (name?.Contains("Uplay") == true) + else if (name.OptionalContains("Uplay")) return "Uplay / Ubisoft Connect"; return null; diff --git a/BinaryObjectScanner/Protection/WMDS.cs b/BinaryObjectScanner/Protection/WMDS.cs index 741a5a01..f97ac370 100644 --- a/BinaryObjectScanner/Protection/WMDS.cs +++ b/BinaryObjectScanner/Protection/WMDS.cs @@ -25,7 +25,7 @@ namespace BinaryObjectScanner.Protection // Found on "All That I Am" by Santana (Barcode 8 2876-59773-2 6) var name = pex.FileDescription; - if (name?.StartsWith("Windows Media Data Session Licensing Engine", StringComparison.OrdinalIgnoreCase) == true) + if (name.OptionalStartsWith("Windows Media Data Session Licensing Engine", StringComparison.OrdinalIgnoreCase)) return "Windows Media Data Session DRM"; // Found in "autorun.exe" ("Touch" by Amerie). diff --git a/BinaryObjectScanner/Protection/WTMCDProtect.cs b/BinaryObjectScanner/Protection/WTMCDProtect.cs index 54757217..ae9565d5 100644 --- a/BinaryObjectScanner/Protection/WTMCDProtect.cs +++ b/BinaryObjectScanner/Protection/WTMCDProtect.cs @@ -18,15 +18,15 @@ namespace BinaryObjectScanner.Protection return null; var name = pex.FileDescription; - if (name?.Contains("Copy Protection Viewer") == true) + if (name.OptionalContains("Copy Protection Viewer")) return "WTM Protection Viewer"; name = pex.LegalTrademarks; - if (name?.Contains("WTM Copy Protection") == true) + if (name.OptionalContains("WTM Copy Protection")) return "WTM Protection Viewer"; name = pex.ProductName; - if (name?.Contains("WTM Copy Protection Viewer") == true) + if (name.OptionalContains("WTM Copy Protection Viewer")) return "WTM Protection Viewer"; // Get the code/CODE section strings, if they exist