diff --git a/BurnOutSharp/PackerType/Armadillo.cs b/BurnOutSharp/PackerType/Armadillo.cs index cfa9204e..1af61985 100644 --- a/BurnOutSharp/PackerType/Armadillo.cs +++ b/BurnOutSharp/PackerType/Armadillo.cs @@ -17,7 +17,7 @@ namespace BurnOutSharp.PackerType new Matcher(new byte?[] { 0x41, 0x52, 0x4D, 0x44, 0x45, 0x42, 0x55, 0x47 }, "Armadillo"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/PackerType/EXEStealth.cs b/BurnOutSharp/PackerType/EXEStealth.cs index b4abfcb0..145cfbfa 100644 --- a/BurnOutSharp/PackerType/EXEStealth.cs +++ b/BurnOutSharp/PackerType/EXEStealth.cs @@ -21,7 +21,7 @@ namespace BurnOutSharp.PackerType }, "EXE Stealth"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/PackerType/InnoSetup.cs b/BurnOutSharp/PackerType/InnoSetup.cs index e73226be..056108de 100644 --- a/BurnOutSharp/PackerType/InnoSetup.cs +++ b/BurnOutSharp/PackerType/InnoSetup.cs @@ -23,7 +23,7 @@ namespace BurnOutSharp.PackerType "Inno Setup"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/PackerType/NSIS.cs b/BurnOutSharp/PackerType/NSIS.cs index fdaa0a1b..9af6f50e 100644 --- a/BurnOutSharp/PackerType/NSIS.cs +++ b/BurnOutSharp/PackerType/NSIS.cs @@ -29,7 +29,7 @@ namespace BurnOutSharp.PackerType }, "NSIS"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } public static string GetVersion(string file, byte[] fileContent, int index) diff --git a/BurnOutSharp/PackerType/PECompact.cs b/BurnOutSharp/PackerType/PECompact.cs index 4326522b..b388651b 100644 --- a/BurnOutSharp/PackerType/PECompact.cs +++ b/BurnOutSharp/PackerType/PECompact.cs @@ -27,7 +27,7 @@ namespace BurnOutSharp.PackerType }, "PE Compact 2"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } public static string GetVersion(string file, byte[] fileContent, int position) diff --git a/BurnOutSharp/PackerType/SetupFactory.cs b/BurnOutSharp/PackerType/SetupFactory.cs index 3ace43d1..03eaa559 100644 --- a/BurnOutSharp/PackerType/SetupFactory.cs +++ b/BurnOutSharp/PackerType/SetupFactory.cs @@ -28,7 +28,7 @@ namespace BurnOutSharp.PackerType }, GetVersion, "Setup Factory"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/PackerType/UPX.cs b/BurnOutSharp/PackerType/UPX.cs index eebfc4b9..192f0db5 100644 --- a/BurnOutSharp/PackerType/UPX.cs +++ b/BurnOutSharp/PackerType/UPX.cs @@ -42,7 +42,7 @@ namespace BurnOutSharp.PackerType ), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } public static string GetVersion(string file, byte[] fileContent, int index) diff --git a/BurnOutSharp/PackerType/WinRARSFX.cs b/BurnOutSharp/PackerType/WinRARSFX.cs index e082a2e3..339b214a 100644 --- a/BurnOutSharp/PackerType/WinRARSFX.cs +++ b/BurnOutSharp/PackerType/WinRARSFX.cs @@ -26,7 +26,7 @@ namespace BurnOutSharp.PackerType }, "WinRAR SFX"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } public Dictionary> Scan(Scanner scanner, string file) diff --git a/BurnOutSharp/PackerType/WinZipSFX.cs b/BurnOutSharp/PackerType/WinZipSFX.cs index d9b074d1..39fde7a9 100644 --- a/BurnOutSharp/PackerType/WinZipSFX.cs +++ b/BurnOutSharp/PackerType/WinZipSFX.cs @@ -29,7 +29,7 @@ namespace BurnOutSharp.PackerType new Matcher(new byte?[] { 0x5F, 0x77, 0x69, 0x6E, 0x7A, 0x69, 0x70, 0x5F }, GetVersion, "WinZip SFX"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/PackerType/WiseInstaller.cs b/BurnOutSharp/PackerType/WiseInstaller.cs index 62595796..7df7d59b 100644 --- a/BurnOutSharp/PackerType/WiseInstaller.cs +++ b/BurnOutSharp/PackerType/WiseInstaller.cs @@ -20,7 +20,7 @@ namespace BurnOutSharp.PackerType new Matcher(new byte?[] { 0x57, 0x69, 0x73, 0x65, 0x4D, 0x61, 0x69, 0x6E }, "Wise Installation Wizard Module"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/PackerType/dotFuscator.cs b/BurnOutSharp/PackerType/dotFuscator.cs index 5e7a696b..43ff6fe8 100644 --- a/BurnOutSharp/PackerType/dotFuscator.cs +++ b/BurnOutSharp/PackerType/dotFuscator.cs @@ -19,7 +19,7 @@ namespace BurnOutSharp.PackerType }, "dotFuscator"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/ActiveMARK.cs b/BurnOutSharp/ProtectionType/ActiveMARK.cs index 6450ed4e..52712d6e 100644 --- a/BurnOutSharp/ProtectionType/ActiveMARK.cs +++ b/BurnOutSharp/ProtectionType/ActiveMARK.cs @@ -22,7 +22,7 @@ namespace BurnOutSharp.ProtectionType }, "ActiveMARK 5"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/AlphaROM.cs b/BurnOutSharp/ProtectionType/AlphaROM.cs index 3d669fa8..0cb4448b 100644 --- a/BurnOutSharp/ProtectionType/AlphaROM.cs +++ b/BurnOutSharp/ProtectionType/AlphaROM.cs @@ -14,7 +14,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x53, 0x45, 0x54, 0x54, 0x45, 0x43 }, "Alpha-ROM"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/CDCheck.cs b/BurnOutSharp/ProtectionType/CDCheck.cs index f20fc143..e8e069d4 100644 --- a/BurnOutSharp/ProtectionType/CDCheck.cs +++ b/BurnOutSharp/ProtectionType/CDCheck.cs @@ -21,7 +21,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x43, 0x44, 0x43, 0x68, 0x65, 0x63, 0x6B }, "Executable-Based CD Check"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } // These content checks are too broad to be useful @@ -45,7 +45,7 @@ namespace BurnOutSharp.ProtectionType }, "Executable-Based CD Check"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/CDCops.cs b/BurnOutSharp/ProtectionType/CDCops.cs index 3104ce0a..8ebabe53 100644 --- a/BurnOutSharp/ProtectionType/CDCops.cs +++ b/BurnOutSharp/ProtectionType/CDCops.cs @@ -24,7 +24,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x2E, 0x67, 0x72, 0x61, 0x6E, 0x64, 0x00 }, "CD-Cops"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/CDLock.cs b/BurnOutSharp/ProtectionType/CDLock.cs index 5b095c70..60a52933 100644 --- a/BurnOutSharp/ProtectionType/CDLock.cs +++ b/BurnOutSharp/ProtectionType/CDLock.cs @@ -23,7 +23,7 @@ namespace BurnOutSharp.ProtectionType }, "CD-Lock"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/CDSHiELDSE.cs b/BurnOutSharp/ProtectionType/CDSHiELDSE.cs index c9f75c5d..90cf7d76 100644 --- a/BurnOutSharp/ProtectionType/CDSHiELDSE.cs +++ b/BurnOutSharp/ProtectionType/CDSHiELDSE.cs @@ -14,7 +14,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x7E, 0x30, 0x30, 0x31, 0x37, 0x2E, 0x74, 0x6D, 0x70 }, "CDSHiELD SE"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/CactusDataShield.cs b/BurnOutSharp/ProtectionType/CactusDataShield.cs index 0b9a2c8d..60c04902 100644 --- a/BurnOutSharp/ProtectionType/CactusDataShield.cs +++ b/BurnOutSharp/ProtectionType/CactusDataShield.cs @@ -24,7 +24,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x43, 0x44, 0x53, 0x50, 0x6C, 0x61, 0x79, 0x65, 0x72 }, "Cactus Data Shield 200"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/CengaProtectDVD.cs b/BurnOutSharp/ProtectionType/CengaProtectDVD.cs index 80d3033f..70e331e9 100644 --- a/BurnOutSharp/ProtectionType/CengaProtectDVD.cs +++ b/BurnOutSharp/ProtectionType/CengaProtectDVD.cs @@ -14,7 +14,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x2E, 0x63, 0x65, 0x6E, 0x65, 0x67, 0x61 }, "Cenega ProtectDVD"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/CodeLock.cs b/BurnOutSharp/ProtectionType/CodeLock.cs index d3bc656b..a03c8d15 100644 --- a/BurnOutSharp/ProtectionType/CodeLock.cs +++ b/BurnOutSharp/ProtectionType/CodeLock.cs @@ -25,7 +25,7 @@ namespace BurnOutSharp.ProtectionType }, "Code Lock"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/CopyKiller.cs b/BurnOutSharp/ProtectionType/CopyKiller.cs index 5b3b601b..6fb404e1 100644 --- a/BurnOutSharp/ProtectionType/CopyKiller.cs +++ b/BurnOutSharp/ProtectionType/CopyKiller.cs @@ -21,7 +21,7 @@ namespace BurnOutSharp.ProtectionType }, "CopyKiller"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/DVDCops.cs b/BurnOutSharp/ProtectionType/DVDCops.cs index 91f443c3..ad7b014b 100644 --- a/BurnOutSharp/ProtectionType/DVDCops.cs +++ b/BurnOutSharp/ProtectionType/DVDCops.cs @@ -20,7 +20,7 @@ namespace BurnOutSharp.ProtectionType }, GetVersion, "DVD-Cops"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } public static string GetVersion(string file, byte[] fileContent, int position) diff --git a/BurnOutSharp/ProtectionType/ElectronicArts.cs b/BurnOutSharp/ProtectionType/ElectronicArts.cs index f49cf36b..7874658e 100644 --- a/BurnOutSharp/ProtectionType/ElectronicArts.cs +++ b/BurnOutSharp/ProtectionType/ElectronicArts.cs @@ -106,7 +106,7 @@ namespace BurnOutSharp.ProtectionType }, "EA DRM Protection"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/GFWL.cs b/BurnOutSharp/ProtectionType/GFWL.cs index e148cd21..579a8908 100644 --- a/BurnOutSharp/ProtectionType/GFWL.cs +++ b/BurnOutSharp/ProtectionType/GFWL.cs @@ -17,7 +17,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x78, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x64, 0x6C, 0x6C }, "Games for Windows - Live"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/Intenium.cs b/BurnOutSharp/ProtectionType/Intenium.cs index 1e27c3d5..21e1c399 100644 --- a/BurnOutSharp/ProtectionType/Intenium.cs +++ b/BurnOutSharp/ProtectionType/Intenium.cs @@ -30,7 +30,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x54, 0x72, 0x69, 0x61, 0x6C, 0x00, 0x50 }, "INTENIUM Trial & Buy Protection"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/KeyLock.cs b/BurnOutSharp/ProtectionType/KeyLock.cs index 4e88ca6f..cf8015db 100644 --- a/BurnOutSharp/ProtectionType/KeyLock.cs +++ b/BurnOutSharp/ProtectionType/KeyLock.cs @@ -18,7 +18,7 @@ namespace BurnOutSharp.ProtectionType }, "Key-Lock (Dongle)"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/MediaMaxCD3.cs b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs index e66d5fb6..906f9584 100644 --- a/BurnOutSharp/ProtectionType/MediaMaxCD3.cs +++ b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs @@ -24,7 +24,7 @@ namespace BurnOutSharp.ProtectionType }, "MediaMax CD-3"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/OnlineRegistration.cs b/BurnOutSharp/ProtectionType/OnlineRegistration.cs index 8bd36d8e..33a52789 100644 --- a/BurnOutSharp/ProtectionType/OnlineRegistration.cs +++ b/BurnOutSharp/ProtectionType/OnlineRegistration.cs @@ -21,7 +21,7 @@ namespace BurnOutSharp.ProtectionType }, Utilities.GetFileVersion, "Executable-Based Online Registration"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/Origin.cs b/BurnOutSharp/ProtectionType/Origin.cs index 4baf2ae9..ce3120ce 100644 --- a/BurnOutSharp/ProtectionType/Origin.cs +++ b/BurnOutSharp/ProtectionType/Origin.cs @@ -17,7 +17,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x4F, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x53, 0x00, 0x65, 0x00, 0x74, 0x00, 0x75, 0x00, 0x70, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x78, 0x00, 0x65, 0x00 }, "Origin"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/PSXAntiModchip.cs b/BurnOutSharp/ProtectionType/PSXAntiModchip.cs index 96447300..23a3a8e9 100644 --- a/BurnOutSharp/ProtectionType/PSXAntiModchip.cs +++ b/BurnOutSharp/ProtectionType/PSXAntiModchip.cs @@ -42,7 +42,7 @@ namespace BurnOutSharp.ProtectionType }, "PlayStation Anti-modchip (Japanese)"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/RingPROTECH.cs b/BurnOutSharp/ProtectionType/RingPROTECH.cs index e0c32466..c7396b4f 100644 --- a/BurnOutSharp/ProtectionType/RingPROTECH.cs +++ b/BurnOutSharp/ProtectionType/RingPROTECH.cs @@ -19,7 +19,7 @@ namespace BurnOutSharp.ProtectionType }, "Ring PROTECH [Check disc for physical ring]"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/SVKProtector.cs b/BurnOutSharp/ProtectionType/SVKProtector.cs index c4c899b7..4635443a 100644 --- a/BurnOutSharp/ProtectionType/SVKProtector.cs +++ b/BurnOutSharp/ProtectionType/SVKProtector.cs @@ -14,7 +14,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x3F, 0x53, 0x56, 0x4B, 0x50, 0x00, 0x00 }, "SVK Protector"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/SafeLock.cs b/BurnOutSharp/ProtectionType/SafeLock.cs index 3dd42cea..d5bbf222 100644 --- a/BurnOutSharp/ProtectionType/SafeLock.cs +++ b/BurnOutSharp/ProtectionType/SafeLock.cs @@ -17,7 +17,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x53, 0x61, 0x66, 0x65, 0x4C, 0x6F, 0x63, 0x6B }, "SafeLock"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/SecuROM.cs b/BurnOutSharp/ProtectionType/SecuROM.cs index 9afe6f1d..64288112 100644 --- a/BurnOutSharp/ProtectionType/SecuROM.cs +++ b/BurnOutSharp/ProtectionType/SecuROM.cs @@ -46,7 +46,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x2E, 0x63, 0x6D, 0x73, 0x5F, 0x64, 0x00 }, "SecuROM 1-3"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/SmartE.cs b/BurnOutSharp/ProtectionType/SmartE.cs index 9373bdbc..1e6f5def 100644 --- a/BurnOutSharp/ProtectionType/SmartE.cs +++ b/BurnOutSharp/ProtectionType/SmartE.cs @@ -17,7 +17,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x42, 0x49, 0x54, 0x41, 0x52, 0x54, 0x53 }, "SmartE"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/Sysiphus.cs b/BurnOutSharp/ProtectionType/Sysiphus.cs index 73c0cf6d..c9597c9b 100644 --- a/BurnOutSharp/ProtectionType/Sysiphus.cs +++ b/BurnOutSharp/ProtectionType/Sysiphus.cs @@ -25,7 +25,7 @@ namespace BurnOutSharp.ProtectionType }, GetVersion, "Sysiphus"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } public static string GetVersion(string file, byte[] fileContent, int position) diff --git a/BurnOutSharp/ProtectionType/ThreePLock.cs b/BurnOutSharp/ProtectionType/ThreePLock.cs index 80c63477..f61856c1 100644 --- a/BurnOutSharp/ProtectionType/ThreePLock.cs +++ b/BurnOutSharp/ProtectionType/ThreePLock.cs @@ -28,7 +28,7 @@ namespace BurnOutSharp.ProtectionType // }, "3PLock"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs b/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs index 5d78f675..0f226324 100644 --- a/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs +++ b/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs @@ -22,7 +22,7 @@ namespace BurnOutSharp.ProtectionType }, "321Studios Online Activation"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/ProtectionType/WTMCDProtect.cs b/BurnOutSharp/ProtectionType/WTMCDProtect.cs index fc70958b..08014d22 100644 --- a/BurnOutSharp/ProtectionType/WTMCDProtect.cs +++ b/BurnOutSharp/ProtectionType/WTMCDProtect.cs @@ -17,7 +17,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x57, 0x54, 0x4D, 0x37, 0x36, 0x35, 0x34, 0x35 }, "WTM CD Protect"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/XCP.cs b/BurnOutSharp/ProtectionType/XCP.cs index d803163a..5e8ab71c 100644 --- a/BurnOutSharp/ProtectionType/XCP.cs +++ b/BurnOutSharp/ProtectionType/XCP.cs @@ -32,7 +32,7 @@ namespace BurnOutSharp.ProtectionType }, "XCP"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } /// diff --git a/BurnOutSharp/ProtectionType/XtremeProtector.cs b/BurnOutSharp/ProtectionType/XtremeProtector.cs index 203be39c..e45e14e7 100644 --- a/BurnOutSharp/ProtectionType/XtremeProtector.cs +++ b/BurnOutSharp/ProtectionType/XtremeProtector.cs @@ -14,7 +14,7 @@ namespace BurnOutSharp.ProtectionType new Matcher(new byte?[] { 0x58, 0x50, 0x52, 0x4F, 0x54, 0x20, 0x20, 0x20 }, "Xtreme-Protector"), }; - return Utilities.GetContentMatches(file, fileContent, matchers, includePosition); + return Utilities.GetFirstContentMatch(file, fileContent, matchers, includePosition); } } } diff --git a/BurnOutSharp/Utilities.cs b/BurnOutSharp/Utilities.cs index be9caa49..fd8bcd07 100644 --- a/BurnOutSharp/Utilities.cs +++ b/BurnOutSharp/Utilities.cs @@ -157,6 +157,29 @@ namespace BurnOutSharp #region Byte Arrays + /// + /// Find all positions of one array in another, if possible, if possible + /// + public static List FindAllPositions(this byte[] stack, byte?[] needle, int start = 0, int end = -1) + { + // Get the outgoing list + List positions = new List(); + + // Initialize the loop variables + bool found = true; + int lastPosition = start; + + // Loop over and get all positions + while (found) + { + (found, lastPosition) = FindPosition(stack, needle, lastPosition, end, false); + if (found) + positions.Add(lastPosition); + } + + return positions; + } + /// /// Find the first position of one array in another, if possible /// @@ -247,59 +270,33 @@ namespace BurnOutSharp #region Protection /// - /// Get content matches for a given protection + /// Get all content matches for a given list of matchers + /// + /// File to check for matches + /// Byte array representing the file contents + /// Enumerable of matchers to be run on the file + /// True to include positional data, false otherwise + /// List of strings representing the matched protections, null or empty otherwise + public static List GetAllContentMatches(string file, byte[] fileContent, IEnumerable matchers, bool includePosition = false) + { + return FindAllContentMatches(file, fileContent, matchers, includePosition, false); + } + + /// + /// Get first content match for a given list of matchers /// /// File to check for matches /// Byte array representing the file contents /// Enumerable of matchers to be run on the file /// True to include positional data, false otherwise /// String representing the matched protection, null otherwise - /// TODO: Make variant of this that returns *all* content matches for later - public static string GetContentMatches(string file, byte[] fileContent, IEnumerable matchers, bool includePosition = false) + public static string GetFirstContentMatch(string file, byte[] fileContent, IEnumerable matchers, bool includePosition = false) { - // If there's no mappings, we can't match - if (matchers == null || !matchers.Any()) + var contentMatches = FindAllContentMatches(file, fileContent, matchers, includePosition, false); + if (contentMatches == null || !contentMatches.Any()) return null; - - // Loop through and try everything otherwise - foreach (var matcher in matchers) - { - // Setup for a single matcher - bool allMatches = true; - List positions = new List(); - - // Loop through all content matches and make sure all pass - foreach (var contentMatch in matcher.ContentMatches) - { - if (!fileContent.FirstPosition(contentMatch.Needle, out int position, contentMatch.Start, contentMatch.End)) - { - allMatches = false; - break; - } - else - { - positions.Add(position); - } - } - - // If not all matches pass, then we continue - if (!allMatches) - continue; - - // Format the list of all positions found - string positionsString = string.Join(", ", positions); - - // If we there is no version method, just return the protection name - if (matcher.GetVersion == null) - return (matcher.ProtectionName ?? "Unknown Protection") + (includePosition ? $" (Index {positionsString})" : string.Empty); - - // Otherwise, invoke the version method - // TODO: Pass all positions to the version finding method - string version = matcher.GetVersion(file, fileContent, positions[0]) ?? "Unknown Version"; - return $"{matcher.ProtectionName} {version}" + (includePosition ? $" (Index {positionsString})" : string.Empty); - } - - return null; + + return contentMatches.First(); } /// @@ -385,6 +382,79 @@ namespace BurnOutSharp } } + /// + /// Get the required set of content matches on a per Matcher basis + /// + /// File to check for matches + /// Byte array representing the file contents + /// Enumerable of matchers to be run on the file + /// True to include positional data, false otherwise + /// True to stop after the first match, false otherwise + /// List of strings representing the matched protections, null or empty otherwise + private static List FindAllContentMatches( + string file, + byte[] fileContent, + IEnumerable matchers, + bool includePosition, + bool stopAfterFirst) + { + // If there's no mappings, we can't match + if (matchers == null || !matchers.Any()) + return null; + + // Initialize the list of matched protections + List matchedProtections = new List(); + + // Loop through and try everything otherwise + foreach (var matcher in matchers) + { + // Setup for a single matcher + bool allMatches = true; + List positions = new List(); + + // Loop through all content matches and make sure all pass + foreach (var contentMatch in matcher.ContentMatches) + { + if (!fileContent.FirstPosition(contentMatch.Needle, out int position, contentMatch.Start, contentMatch.End)) + { + allMatches = false; + break; + } + else + { + positions.Add(position); + } + } + + // If not all matches pass, then we continue + if (!allMatches) + continue; + + // Format the list of all positions found + string positionsString = string.Join(", ", positions); + + // If we there is no version method, just return the protection name + if (matcher.GetVersion == null) + { + matchedProtections.Add((matcher.ProtectionName ?? "Unknown Protection") + (includePosition ? $" (Index {positionsString})" : string.Empty)); + } + + // Otherwise, invoke the version method + // TODO: Pass all positions to the version finding method + else + { + string version = matcher.GetVersion(file, fileContent, positions[0]) ?? "Unknown Version"; + matchedProtections.Add($"{matcher.ProtectionName} {version}" + (includePosition ? $" (Index {positionsString})" : string.Empty)); + } + + // If we're stopping after the first protection, bail out here + if (stopAfterFirst) + return matchedProtections; + } + + return matchedProtections; + } + #endregion } }