From cdc4d509ee78c51e4e0901455ad23b4b5bb3bae1 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 20 Mar 2021 19:00:22 -0700 Subject: [PATCH] Modify array finding, part 1 --- BurnOutSharp/PackerType/Armadillo.cs | 4 +- BurnOutSharp/PackerType/EXEStealth.cs | 2 +- BurnOutSharp/PackerType/InnoSetup.cs | 2 +- BurnOutSharp/PackerType/NSIS.cs | 4 +- BurnOutSharp/PackerType/PECompact.cs | 2 +- BurnOutSharp/PackerType/SetupFactory.cs | 2 +- BurnOutSharp/PackerType/UPX.cs | 12 +-- BurnOutSharp/PackerType/WinZipSFX.cs | 44 +++++----- BurnOutSharp/PackerType/WiseInstaller.cs | 2 +- BurnOutSharp/PackerType/dotFuscator.cs | 2 +- BurnOutSharp/ProtectionType/ActiveMARK.cs | 4 +- BurnOutSharp/ProtectionType/AlphaROM.cs | 2 +- BurnOutSharp/ProtectionType/CDCheck.cs | 8 +- BurnOutSharp/ProtectionType/CDCops.cs | 4 +- BurnOutSharp/ProtectionType/CDLock.cs | 2 +- BurnOutSharp/ProtectionType/CDSHiELDSE.cs | 2 +- .../ProtectionType/CactusDataShield.cs | 6 +- .../ProtectionType/CengaProtectDVD.cs | 2 +- BurnOutSharp/ProtectionType/CodeLock.cs | 6 +- BurnOutSharp/ProtectionType/CopyKiller.cs | 2 +- BurnOutSharp/ProtectionType/DVDCops.cs | 2 +- BurnOutSharp/ProtectionType/ElectronicArts.cs | 18 ++-- BurnOutSharp/ProtectionType/GFWL.cs | 2 +- BurnOutSharp/ProtectionType/ImpulseReactor.cs | 4 +- BurnOutSharp/ProtectionType/Intenium.cs | 2 +- BurnOutSharp/ProtectionType/JoWooDXProt.cs | 6 +- BurnOutSharp/ProtectionType/KeyLock.cs | 2 +- BurnOutSharp/ProtectionType/LaserLock.cs | 10 +-- BurnOutSharp/ProtectionType/MediaMaxCD3.cs | 4 +- .../ProtectionType/OnlineRegistration.cs | 2 +- BurnOutSharp/ProtectionType/Origin.cs | 2 +- BurnOutSharp/ProtectionType/PSXAntiModchip.cs | 4 +- BurnOutSharp/ProtectionType/ProtectDisc.cs | 4 +- BurnOutSharp/ProtectionType/RingPROTECH.cs | 2 +- BurnOutSharp/ProtectionType/SVKProtector.cs | 2 +- BurnOutSharp/ProtectionType/SafeDisc.cs | 10 +-- BurnOutSharp/ProtectionType/SafeLock.cs | 2 +- BurnOutSharp/ProtectionType/SecuROM.cs | 14 ++-- BurnOutSharp/ProtectionType/SmartE.cs | 2 +- BurnOutSharp/ProtectionType/SolidShield.cs | 20 ++--- BurnOutSharp/ProtectionType/StarForce.cs | 14 ++-- BurnOutSharp/ProtectionType/Sysiphus.cs | 4 +- BurnOutSharp/ProtectionType/Tages.cs | 6 +- BurnOutSharp/ProtectionType/ThreePLock.cs | 4 +- .../ProtectionType/ThreeTwoOneStudios.cs | 2 +- .../ProtectionType/VOBProtectCDDVD.cs | 6 +- BurnOutSharp/ProtectionType/WTMCDProtect.cs | 2 +- BurnOutSharp/ProtectionType/XCP.cs | 6 +- .../ProtectionType/XtremeProtector.cs | 2 +- BurnOutSharp/Utilities.cs | 84 ++++++++++++------- 50 files changed, 190 insertions(+), 168 deletions(-) diff --git a/BurnOutSharp/PackerType/Armadillo.cs b/BurnOutSharp/PackerType/Armadillo.cs index 33f3033f..7a4f5441 100644 --- a/BurnOutSharp/PackerType/Armadillo.cs +++ b/BurnOutSharp/PackerType/Armadillo.cs @@ -7,12 +7,12 @@ { // ".nicode" + (char)0x00 byte[] check = new byte[] { 0x2E, 0x6E, 0x69, 0x63, 0x6F, 0x64, 0x65, 0x00 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"Armadillo" + (includePosition ? $" (Index {position})" : string.Empty); // "ARMDEBUG" check = new byte[] { 0x41, 0x52, 0x4D, 0x44, 0x45, 0x42, 0x55, 0x47 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"Armadillo" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/PackerType/EXEStealth.cs b/BurnOutSharp/PackerType/EXEStealth.cs index 7eaadd44..1e18c44d 100644 --- a/BurnOutSharp/PackerType/EXEStealth.cs +++ b/BurnOutSharp/PackerType/EXEStealth.cs @@ -7,7 +7,7 @@ { // "??[[__[[_" + (char)0x00 + "{{" + (char)0x0 + (char)0x00 + "{{" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x0 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "?;??;??" byte[] check = new byte[] { 0x3F, 0x3F, 0x5B, 0x5B, 0x5F, 0x5F, 0x5B, 0x5B, 0x5F, 0x00, 0x7B, 0x7B, 0x00, 0x00, 0x7B, 0x7B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x3B, 0x3F, 0x3F, 0x3B, 0x3F, 0x3F }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"EXE Stealth" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/PackerType/InnoSetup.cs b/BurnOutSharp/PackerType/InnoSetup.cs index 75b91dfa..d479f045 100644 --- a/BurnOutSharp/PackerType/InnoSetup.cs +++ b/BurnOutSharp/PackerType/InnoSetup.cs @@ -16,7 +16,7 @@ namespace BurnOutSharp.PackerType { // "Inno" byte[] check = new byte[] { 0x49, 0x6E, 0x6E, 0x6F }; - if (fileContent.Contains(check, out int position) && position == 0x30) + if (fileContent.FirstPosition(check, out int position) && position == 0x30) return $"Inno Setup {GetVersion(fileContent)}" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/PackerType/NSIS.cs b/BurnOutSharp/PackerType/NSIS.cs index 6595e1fe..bbcafa80 100644 --- a/BurnOutSharp/PackerType/NSIS.cs +++ b/BurnOutSharp/PackerType/NSIS.cs @@ -11,7 +11,7 @@ namespace BurnOutSharp.PackerType { // Nullsoft Install System byte[] check = new byte[] { 0x4e, 0x75, 0x6c, 0x6c, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) { string version = GetVersion(fileContent, position); return $"NSIS {version}" + (includePosition ? $" (Index {position})" : string.Empty); @@ -19,7 +19,7 @@ namespace BurnOutSharp.PackerType // NullsoftInst check = new byte[] { 0x4e, 0x75, 0x6c, 0x6c, 0x73, 0x6f, 0x66, 0x74, 0x49, 0x6e, 0x73, 0x74 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { return $"NSIS" + (includePosition ? $" (Index {position})" : string.Empty); } diff --git a/BurnOutSharp/PackerType/PECompact.cs b/BurnOutSharp/PackerType/PECompact.cs index db7b6950..7feb1cf8 100644 --- a/BurnOutSharp/PackerType/PECompact.cs +++ b/BurnOutSharp/PackerType/PECompact.cs @@ -7,7 +7,7 @@ { // "PEC2" byte[] check = new byte[] { 0x50, 0x45, 0x43, 0x32 }; - if (fileContent.Contains(check, out int position, end: 2048)) + if (fileContent.FirstPosition(check, out int position, end: 2048)) return "PE Compact 2" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/PackerType/SetupFactory.cs b/BurnOutSharp/PackerType/SetupFactory.cs index e67961f5..61daea5b 100644 --- a/BurnOutSharp/PackerType/SetupFactory.cs +++ b/BurnOutSharp/PackerType/SetupFactory.cs @@ -20,7 +20,7 @@ namespace BurnOutSharp.PackerType byte[] check = new byte[] { 0x53, 0x00, 0x65, 0x00, 0x74, 0x00, 0x75, 0x00, 0x70, 0x00, 0x20, 0x00, 0x46, 0x00, 0x61, 0x00, 0x63, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x79, 0x00, 0x20, 0x00, 0x69, 0x00, 0x73, 0x00, 0x20, 0x00, 0x61, 0x00, 0x20, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x72, 0x00, 0x6B, 0x00, 0x20, 0x00, 0x6F, 0x00, 0x66, 0x00, 0x20, 0x00, 0x49, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x69, 0x00, 0x67, 0x00, 0x6F, 0x00, 0x20, 0x00, 0x52, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x65, 0x00, 0x20, 0x00, 0x43, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x70, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E }; */ // "S.e.t.u.p. .F.a.c.t.o.r.y." byte[] check = new byte[] { 0x53, 0x00, 0x65, 0x00, 0x74, 0x00, 0x75, 0x00, 0x70, 0x00, 0x20, 0x00, 0x46, 0x00, 0x61, 0x00, 0x63, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x79, 0x00 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) { // Check the manifest version first string version = Utilities.GetManifestVersion(fileContent); diff --git a/BurnOutSharp/PackerType/UPX.cs b/BurnOutSharp/PackerType/UPX.cs index 9f8dc142..e9ebef77 100644 --- a/BurnOutSharp/PackerType/UPX.cs +++ b/BurnOutSharp/PackerType/UPX.cs @@ -9,7 +9,7 @@ namespace BurnOutSharp.PackerType { // UPX! byte[] check = new byte[] { 0x55, 0x50, 0x58, 0x21 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) { string version = GetVersion(fileContent, position); return $"UPX {version}" + (includePosition ? $" (Index {position})" : string.Empty); @@ -17,7 +17,7 @@ namespace BurnOutSharp.PackerType // NOS check = new byte[] { 0x55, 0x50, 0x58, 0x21 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { string version = GetVersion(fileContent, position); return $"UPX (NOS Variant) {version}" + (includePosition ? $" (Index {position})" : string.Empty); @@ -25,11 +25,11 @@ namespace BurnOutSharp.PackerType // UPX0 check = new byte[] { 0x55, 0x50, 0x58, 0x30 }; - if (fileContent.Contains(check, out position, end: 2048)) + if (fileContent.FirstPosition(check, out position, end: 2048)) { // UPX1 byte[] check2 = new byte[] { 0x55, 0x50, 0x58, 0x31 }; - if (fileContent.Contains(check2, out int position2, end: 2048)) + if (fileContent.FirstPosition(check2, out int position2, end: 2048)) { return $"UPX (Unknown Version)" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); } @@ -37,11 +37,11 @@ namespace BurnOutSharp.PackerType // NOS0 check = new byte[] { 0x4E, 0x4F, 0x53, 0x30 }; - if (fileContent.Contains(check, out position, end: 2048)) + if (fileContent.FirstPosition(check, out position, end: 2048)) { // NOS1 byte[] check2 = new byte[] { 0x4E, 0x4F, 0x53, 0x31 }; - if (fileContent.Contains(check2, out int position2, end: 2048)) + if (fileContent.FirstPosition(check2, out int position2, end: 2048)) { return $"UPX (NOS Variant) (Unknown Version)" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); } diff --git a/BurnOutSharp/PackerType/WinZipSFX.cs b/BurnOutSharp/PackerType/WinZipSFX.cs index 7eaac48a..5d686564 100644 --- a/BurnOutSharp/PackerType/WinZipSFX.cs +++ b/BurnOutSharp/PackerType/WinZipSFX.cs @@ -18,12 +18,12 @@ namespace BurnOutSharp.PackerType { // WinZip Self-Extractor byte[] check = new byte[] { 0x57, 0x69, 0x6E, 0x5A, 0x69, 0x70, 0x20, 0x53, 0x65, 0x6C, 0x66, 0x2D, 0x45, 0x78, 0x74, 0x72, 0x61, 0x63, 0x74, 0x6F, 0x72 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"WinZip SFX {GetVersion(fileContent)}" + (includePosition ? $" (Index {position})" : string.Empty); // _winzip_ check = new byte[] { 0x5F, 0x77, 0x69, 0x6E, 0x7A, 0x69, 0x70, 0x5F }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"WinZip SFX {GetVersion(fileContent)}" + (includePosition ? $" (Index {position})" : string.Empty); return null; @@ -115,7 +115,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "2.0 (MS-DOS/16-bit)"; check = new byte[] @@ -129,7 +129,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "2.0 (16-bit)"; check = new byte[] @@ -143,7 +143,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "Compact Version 2.0 (16-bit)"; check = new byte[] @@ -157,7 +157,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "Software Installation Version 2.0 (16-bit)"; check = new byte[] @@ -171,7 +171,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "2.1 RC2 (MS-DOS/16-bit)"; check = new byte[] @@ -185,7 +185,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "2.1 RC2 (16-bit)"; check = new byte[] @@ -199,7 +199,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "Compact Version 2.1 RC2 (16-bit)"; check = new byte[] @@ -213,7 +213,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "Software Installation Version 2.1 RC2 (16-bit)"; check = new byte[] @@ -227,7 +227,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "2.1 (MS-DOS/16-bit)"; check = new byte[] @@ -241,7 +241,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "2.1 (16-bit)"; check = new byte[] @@ -255,7 +255,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "Compact Version 2.1 (16-bit)"; check = new byte[] @@ -270,7 +270,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "Software Installation Version 2.1 (16-bit)"; #endregion @@ -289,7 +289,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x56, 0x57, 0x39, 0x35, 0x53, 0x45, 0x2E, 0x53, 0x46, 0x58, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "2.0 (32-bit)"; // .............]�92....�P..............�P..�P..�P..VW95SRE.SFX @@ -304,7 +304,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x56, 0x57, 0x39, 0x35, 0x53, 0x52, 0x45, 0x2E, 0x53, 0x46, 0x58, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "Software Installation Version 2.0 (32-bit)"; // .............���3....�P..............�P..�P..�P..VW95SE.SFX @@ -319,7 +319,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x56, 0x57, 0x39, 0x35, 0x53, 0x45, 0x2E, 0x53, 0x46, 0x58, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "2.1 RC2 (32-bit)"; // .............���3....�P..............�P..�P..�P..VW95SRE.SFX @@ -334,7 +334,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x56, 0x57, 0x39, 0x35, 0x53, 0x52, 0x45, 0x2E, 0x53, 0x46, 0x58, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "Software Installation Version 2.1 RC2 (32-bit)"; // .............U��3....�P..............�P..�P..�P..VW95SE.SFX @@ -349,7 +349,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x56, 0x57, 0x39, 0x35, 0x53, 0x45, 0x2E, 0x53, 0x46, 0x58, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "2.1 (32-bit)"; // .............{��3....�P..............�P..�P..�P..VW95SRE.SFX @@ -364,7 +364,7 @@ namespace BurnOutSharp.PackerType 0x00, 0x56, 0x57, 0x39, 0x35, 0x53, 0x52, 0x45, 0x2E, 0x53, 0x46, 0x58, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "Software Installation Version 2.1 (32-bit)"; #endregion @@ -382,7 +382,7 @@ namespace BurnOutSharp.PackerType 0xD8, 0x39, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "2.2.4003"; // PE..L.....[:........�........V...*.......?.......p....@. @@ -396,7 +396,7 @@ namespace BurnOutSharp.PackerType 0x8F, 0x3F, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, }; - if (fileContent.Contains(check, out _)) + if (fileContent.FirstPosition(check, out _)) return "Software Installation Version 2.2.4003"; #endregion diff --git a/BurnOutSharp/PackerType/WiseInstaller.cs b/BurnOutSharp/PackerType/WiseInstaller.cs index 582eb7d8..7d84b286 100644 --- a/BurnOutSharp/PackerType/WiseInstaller.cs +++ b/BurnOutSharp/PackerType/WiseInstaller.cs @@ -15,7 +15,7 @@ namespace BurnOutSharp.PackerType { // WiseMain byte[] check = new byte[] { 0x57, 0x69, 0x73, 0x65, 0x4D, 0x61, 0x69, 0x6E }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "Wise Installation Wizard Module" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/PackerType/dotFuscator.cs b/BurnOutSharp/PackerType/dotFuscator.cs index dcb28a34..b15c7ec9 100644 --- a/BurnOutSharp/PackerType/dotFuscator.cs +++ b/BurnOutSharp/PackerType/dotFuscator.cs @@ -7,7 +7,7 @@ { // "DotfuscatorAttribute" byte[] check = new byte[] { 0x44, 0x6F, 0x74, 0x66, 0x75, 0x73, 0x63, 0x61, 0x74, 0x6F, 0x72, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "dotFuscator" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/ActiveMARK.cs b/BurnOutSharp/ProtectionType/ActiveMARK.cs index c014adf8..38f8a34d 100644 --- a/BurnOutSharp/ProtectionType/ActiveMARK.cs +++ b/BurnOutSharp/ProtectionType/ActiveMARK.cs @@ -7,12 +7,12 @@ { // "TMSAMVOF" byte[] check = new byte[] { 0x54, 0x4D, 0x53, 0x41, 0x4D, 0x56, 0x4F, 0x46 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "ActiveMARK" + (includePosition ? $" (Index {position})" : string.Empty); // " " + (char)0xC2 + (char)0x16 + (char)0x00 + (char)0xA8 + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0xB8 + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0x86 + (char)0xC8 + (char)0x16 + (char)0x0 + (char)0x9A + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0x10 + (char)0xC2 + (char)0x16 + (char)0x00 check = new byte[] { 0x20, 0xC2, 0x16, 0x00, 0xA8, 0xC1, 0x16, 0x00, 0xB8, 0xC1, 0x16, 0x00, 0x86, 0xC8, 0x16, 0x0, 0x9A, 0xC1, 0x16, 0x00, 0x10, 0xC2, 0x16, 0x00 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "ActiveMARK 5" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/AlphaROM.cs b/BurnOutSharp/ProtectionType/AlphaROM.cs index e3a619e0..f5b6b948 100644 --- a/BurnOutSharp/ProtectionType/AlphaROM.cs +++ b/BurnOutSharp/ProtectionType/AlphaROM.cs @@ -7,7 +7,7 @@ { // "SETTEC" byte[] check = new byte[] { 0x53, 0x45, 0x54, 0x54, 0x45, 0x43 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "Alpha-ROM" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/CDCheck.cs b/BurnOutSharp/ProtectionType/CDCheck.cs index 11967952..abf3d2c4 100644 --- a/BurnOutSharp/ProtectionType/CDCheck.cs +++ b/BurnOutSharp/ProtectionType/CDCheck.cs @@ -7,12 +7,12 @@ { // MGS CDCheck byte[] check = new byte[] { 0x4D, 0x47, 0x53, 0x20, 0x43, 0x44, 0x43, 0x68, 0x65, 0x63, 0x6B }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "Microsoft Game Studios CD Check" + (includePosition ? $" (Index {position})" : string.Empty); // CDCheck check = new byte[] { 0x43, 0x44, 0x43, 0x68, 0x65, 0x63, 0x6B }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "Executable-Based CD Check" + (includePosition ? $" (Index {position})" : string.Empty); return null; @@ -23,12 +23,12 @@ { // GetDriveType byte[] check = new byte[] { 0x47, 0x65, 0x74, 0x44, 0x72, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "CD Check" + (includePosition ? $" (Index {position})" : string.Empty); // GetVolumeInformation check = new byte[] { 0x47, 0x65, 0x74, 0x56, 0x6F, 0x6C, 0x75, 0x6D, 0x65, 0x49, 0x6E, 0x66, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "CD Check" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/CDCops.cs b/BurnOutSharp/ProtectionType/CDCops.cs index 04a33a8f..7c8c9ed9 100644 --- a/BurnOutSharp/ProtectionType/CDCops.cs +++ b/BurnOutSharp/ProtectionType/CDCops.cs @@ -12,12 +12,12 @@ namespace BurnOutSharp.ProtectionType { // "CD-Cops, ver. " byte[] check = new byte[] { 0x43, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73, 0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"CD-Cops {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); // ".grand" + (char)0x00 check = new byte[] { 0x2E, 0x67, 0x72, 0x61, 0x6E, 0x64, 0x00}; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "CD-Cops" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/CDLock.cs b/BurnOutSharp/ProtectionType/CDLock.cs index e64a8665..4da38efe 100644 --- a/BurnOutSharp/ProtectionType/CDLock.cs +++ b/BurnOutSharp/ProtectionType/CDLock.cs @@ -12,7 +12,7 @@ namespace BurnOutSharp.ProtectionType { // "2" + (char)0xF2 + (char)0x02 + (char)0x82 + (char)0xC3 + (char)0xBC + (char)0x0B + "$" + (char)0x99 + (char)0xAD + "'C" + (char)0xE4 + (char)0x9D + "st" + (char)0x99 + (char)0xFA + "2$" + (char)0x9D + ")4" + (char)0xFF + "t" byte[] check = new byte[] { 0x32, 0xF2, 0x02, 0x82, 0xC3, 0xBC, 0x0B, 0x24, 0x99, 0xAD, 0x27, 0x43, 0xE4, 0x9D, 0x73, 0x74, 0x99, 0xFA, 0x32, 0x24, 0x9D, 0x29, 0x34, 0xFF, 0x74 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "CD-Lock" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/CDSHiELDSE.cs b/BurnOutSharp/ProtectionType/CDSHiELDSE.cs index 8b413db5..a33be28d 100644 --- a/BurnOutSharp/ProtectionType/CDSHiELDSE.cs +++ b/BurnOutSharp/ProtectionType/CDSHiELDSE.cs @@ -7,7 +7,7 @@ { // "~0017.tmp" byte[] check = new byte[] { 0x7E, 0x30, 0x30, 0x31, 0x37, 0x2E, 0x74, 0x6D, 0x70 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "CDSHiELD SE" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/CactusDataShield.cs b/BurnOutSharp/ProtectionType/CactusDataShield.cs index 97396755..89e6a09d 100644 --- a/BurnOutSharp/ProtectionType/CactusDataShield.cs +++ b/BurnOutSharp/ProtectionType/CactusDataShield.cs @@ -13,17 +13,17 @@ namespace BurnOutSharp.ProtectionType { // DATA.CDS byte[] check = new byte[] { 0x44, 0x41, 0x54, 0x41, 0x2E, 0x43, 0x44, 0x53 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "Cactus Data Shield 200" + (includePosition ? $" (Index {position})" : string.Empty); // \*.CDS check = new byte[] { 0x5C, 0x2A, 0x2E, 0x43, 0x44, 0x53 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "Cactus Data Shield 200" + (includePosition ? $" (Index {position})" : string.Empty); // CDSPlayer check = new byte[] { 0x43, 0x44, 0x53, 0x50, 0x6C, 0x61, 0x79, 0x65, 0x72 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "Cactus Data Shield 200" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/CengaProtectDVD.cs b/BurnOutSharp/ProtectionType/CengaProtectDVD.cs index ef904a26..847e92ae 100644 --- a/BurnOutSharp/ProtectionType/CengaProtectDVD.cs +++ b/BurnOutSharp/ProtectionType/CengaProtectDVD.cs @@ -7,7 +7,7 @@ { // ".cenega" byte[] check = new byte[] { 0x2E, 0x63, 0x65, 0x6E, 0x65, 0x67, 0x61 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "Cenega ProtectDVD" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/CodeLock.cs b/BurnOutSharp/ProtectionType/CodeLock.cs index 1a805e35..ae91bbaa 100644 --- a/BurnOutSharp/ProtectionType/CodeLock.cs +++ b/BurnOutSharp/ProtectionType/CodeLock.cs @@ -8,17 +8,17 @@ { // "icd1" + (char)0x00 byte[] check = new byte[] { 0x69, 0x63, 0x64, 0x31, 0x00 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "Code Lock" + (includePosition ? $" (Index {position})" : string.Empty); // "icd2" + (char)0x00 check = new byte[] { 0x69, 0x63, 0x64, 0x32, 0x00 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "Code Lock" + (includePosition ? $" (Index {position})" : string.Empty); // "CODE-LOCK.OCX" check = new byte[] { 0x43, 0x4F, 0x44, 0x45, 0x2D, 0x4C, 0x4F, 0x43, 0x4B, 0x2E, 0x4F, 0x43, 0x58 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "Code Lock" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/CopyKiller.cs b/BurnOutSharp/ProtectionType/CopyKiller.cs index f25af48e..665e35ef 100644 --- a/BurnOutSharp/ProtectionType/CopyKiller.cs +++ b/BurnOutSharp/ProtectionType/CopyKiller.cs @@ -12,7 +12,7 @@ namespace BurnOutSharp.ProtectionType { // "Tom Commander" byte[] check = new byte[] { 0x54, 0x6F, 0x6D, 0x20, 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x65, 0x72 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "CopyKiller" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/DVDCops.cs b/BurnOutSharp/ProtectionType/DVDCops.cs index a4782654..d20a9a1b 100644 --- a/BurnOutSharp/ProtectionType/DVDCops.cs +++ b/BurnOutSharp/ProtectionType/DVDCops.cs @@ -10,7 +10,7 @@ namespace BurnOutSharp.ProtectionType { // "DVD-Cops, ver. " byte[] check = new byte[] { 0x44, 0x56, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73, 0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"DVD-Cops {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/ElectronicArts.cs b/BurnOutSharp/ProtectionType/ElectronicArts.cs index 6c98a0c7..852c691a 100644 --- a/BurnOutSharp/ProtectionType/ElectronicArts.cs +++ b/BurnOutSharp/ProtectionType/ElectronicArts.cs @@ -16,47 +16,47 @@ // R + (char)0x00 + e + (char)0x00 + g + (char)0x00 + i + (char)0x00 + s + (char)0x00 + t + (char)0x00 + r + (char)0x00 + a + (char)0x00 + t + (char)0x00 + i + (char)0x00 + o + (char)0x00 + n + (char)0x00 + + (char)0x00 + C + (char)0x00 + o + (char)0x00 + d + (char)0x00 + e + (char)0x00 + + (char)0x00 + i + (char)0x00 + n + (char)0x00 + s + (char)0x00 + t + (char)0x00 + a + (char)0x00 + l + (char)0x00 + l + (char)0x00 + e + (char)0x00 + r + (char)0x00 + + (char)0x00 + p + (char)0x00 + r + (char)0x00 + o + (char)0x00 + g + (char)0x00 + r + (char)0x00 + a + (char)0x00 + m + (char)0x00 byte[] check = new byte[] { 0x52, 0x00, 0x65, 0x00, 0x67, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x43, 0x00, 0x6F, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x73, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x72, 0x00, 0x61, 0x00, 0x6D, 0x00 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); // R + (char)0x00 + e + (char)0x00 + g + (char)0x00 + i + (char)0x00 + s + (char)0x00 + t + (char)0x00 + r + (char)0x00 + a + (char)0x00 + t + (char)0x00 + i + (char)0x00 + o + (char)0x00 + n + (char)0x00 + + (char)0x00 + c + (char)0x00 + o + (char)0x00 + d + (char)0x00 + e + (char)0x00 + + (char)0x00 + i + (char)0x00 + n + (char)0x00 + s + (char)0x00 + t + (char)0x00 + a + (char)0x00 + l + (char)0x00 + l + (char)0x00 + e + (char)0x00 + r + (char)0x00 + + (char)0x00 + p + (char)0x00 + r + (char)0x00 + o + (char)0x00 + g + (char)0x00 + r + (char)0x00 + a + (char)0x00 + m + (char)0x00 check = new byte[] { 0x52, 0x00, 0x65, 0x00, 0x67, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x63, 0x00, 0x6F, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x73, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x72, 0x00, 0x61, 0x00, 0x6D, 0x00 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); // A + (char)0x00 + b + (char)0x00 + o + (char)0x00 + u + (char)0x00 + t + (char)0x00 + + (char)0x00 + C + (char)0x00 + D + (char)0x00 + K + (char)0x00 + e + (char)0x00 + y + (char)0x00 check = new byte[] { 0x41, 0x00, 0x62, 0x00, 0x6F, 0x00, 0x75, 0x00, 0x74, 0x00, 0x20, 0x00, 0x43, 0x00, 0x44, 0x00, 0x4B, 0x00, 0x65, 0x00, 0x79, 0x00 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); // I + (char)0x00 + n + (char)0x00 + t + (char)0x00 + e + (char)0x00 + r + (char)0x00 + n + (char)0x00 + a + (char)0x00 + l + (char)0x00 + N + (char)0x00 + a + (char)0x00 + m + (char)0x00 + e + (char)0x00 + + (char)0x00 + + (char)0x00 + C + (char)0x00 + D + (char)0x00 + K + (char)0x00 + e + (char)0x00 + y + (char)0x00 check = new byte[] { 0x49, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x4E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x43, 0x00, 0x44, 0x00, 0x4B, 0x00, 0x65, 0x00, 0x79, 0x00 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); // I + (char)0x00 + n + (char)0x00 + t + (char)0x00 + e + (char)0x00 + r + (char)0x00 + n + (char)0x00 + a + (char)0x00 + l + (char)0x00 + N + (char)0x00 + a + (char)0x00 + m + (char)0x00 + e + (char)0x00 + + (char)0x00 + + (char)0x00 + C + (char)0x00 + D + (char)0x00 + C + (char)0x00 + o + (char)0x00 + d + (char)0x00 + e + (char)0x00 check = new byte[] { 0x49, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x4E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x43, 0x00, 0x44, 0x00, 0x43, 0x00, 0x6F, 0x00, 0x64, 0x00, 0x65, 0x00 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); // EReg Config Form check = new byte[] { 0x45, 0x52, 0x65, 0x67, 0x20, 0x43, 0x6F, 0x6E, 0x66, 0x69, 0x67, 0x20, 0x46, 0x6F, 0x72, 0x6D }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); // ereg.ea-europe.com check = new byte[] { 0x65, 0x72, 0x65, 0x67, 0x2E, 0x65, 0x61, 0x2D, 0x65, 0x75, 0x72, 0x6F, 0x70, 0x65, 0x2E, 0x63, 0x6F, 0x6D }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); // GenericEA + (char)0x00 + (char)0x00 + (char)0x00 + Activation check = new byte[] { 0x47, 0x65, 0x6E, 0x65, 0x72, 0x69, 0x63, 0x45, 0x41, 0x00, 0x00, 0x00, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6F, 0x6E }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "EA DRM Protection" + (includePosition ? $" (Index {position})" : string.Empty); // E + (char)0x00 + A + (char)0x00 + + (char)0x00 + D + (char)0x00 + R + (char)0x00 + M + (char)0x00 + + (char)0x00 + H + (char)0x00 + e + (char)0x00 + l + (char)0x00 + p + (char)0x00 + e + (char)0x00 + r + (char)0x00 check = new byte[] { 0x45, 0x00, 0x41, 0x00, 0x20, 0x00, 0x44, 0x00, 0x52, 0x00, 0x4D, 0x00, 0x20, 0x00, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00, 0x65, 0x00, 0x72, 0x00 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "EA DRM Protection" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/GFWL.cs b/BurnOutSharp/ProtectionType/GFWL.cs index 1a006a7f..7e2b5d87 100644 --- a/BurnOutSharp/ProtectionType/GFWL.cs +++ b/BurnOutSharp/ProtectionType/GFWL.cs @@ -12,7 +12,7 @@ namespace BurnOutSharp.ProtectionType { // "xlive.dll" byte[] check = new byte[] { 0x78, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x64, 0x6C, 0x6C }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "Games for Windows - Live" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/ImpulseReactor.cs b/BurnOutSharp/ProtectionType/ImpulseReactor.cs index 678e9766..8d9e96a5 100644 --- a/BurnOutSharp/ProtectionType/ImpulseReactor.cs +++ b/BurnOutSharp/ProtectionType/ImpulseReactor.cs @@ -12,11 +12,11 @@ namespace BurnOutSharp.ProtectionType { // "CVPInitializeClient" byte[] check = new byte[] { 0x43, 0x56, 0x50, 0x49, 0x6E, 0x69, 0x74, 0x69, 0x61, 0x6C, 0x69, 0x7A, 0x65, 0x43, 0x6C, 0x69, 0x65, 0x6E, 0x74 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) { // "A" + (char)0x00 + "T" + (char)0x00 + "T" + (char)0x00 + "L" + (char)0x00 + "I" + (char)0x00 + "S" + (char)0x00 + "T" + (char)0x00 + (char)0x00 + (char)0x00 + "E" + (char)0x00 + "L" + (char)0x00 + "E" + (char)0x00 + "M" + (char)0x00 + "E" + (char)0x00 + "N" + (char)0x00 + "T" + (char)0x00 + (char)0x00 + (char)0x00 + "N" + (char)0x00 + "O" + (char)0x00 + "T" + (char)0x00 + "A" + (char)0x00 + "T" + (char)0x00 + "I" + (char)0x00 + "O" + (char)0x00 + "N" byte[] check2 = new byte[] { 0x41, 0x00, 0x54, 0x00, 0x54, 0x00, 0x4C, 0x00, 0x49, 0x00, 0x53, 0x00, 0x54, 0x00, 0x00, 0x00, 0x45, 0x00, 0x4C, 0x00, 0x45, 0x00, 0x4D, 0x00, 0x45, 0x00, 0x4E, 0x00, 0x54, 0x00, 0x00, 0x00, 0x4E, 0x00, 0x4F, 0x00, 0x54, 0x00, 0x41, 0x00, 0x54, 0x00, 0x49, 0x00, 0x4F, 0x00, 0x4E }; - if (fileContent.Contains(check2, out int position2)) + if (fileContent.FirstPosition(check2, out int position2)) return $"Impulse Reactor {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); else return "Impulse Reactor" + (includePosition ? $" (Index {position})" : string.Empty); diff --git a/BurnOutSharp/ProtectionType/Intenium.cs b/BurnOutSharp/ProtectionType/Intenium.cs index e90772f2..b8cf3181 100644 --- a/BurnOutSharp/ProtectionType/Intenium.cs +++ b/BurnOutSharp/ProtectionType/Intenium.cs @@ -23,7 +23,7 @@ { // Trial + (char)0x00 + P byte[] check = new byte[] { 0x54, 0x72, 0x69, 0x61, 0x6C, 0x00, 0x50 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "INTENIUM Trial & Buy Protection" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/JoWooDXProt.cs b/BurnOutSharp/ProtectionType/JoWooDXProt.cs index 8aba374d..16ec6a89 100644 --- a/BurnOutSharp/ProtectionType/JoWooDXProt.cs +++ b/BurnOutSharp/ProtectionType/JoWooDXProt.cs @@ -10,11 +10,11 @@ namespace BurnOutSharp.ProtectionType { // ".ext " byte[] check = new byte[] { 0x2E, 0x65, 0x78, 0x74, 0x20, 0x20, 0x20, 0x20 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) { // "kernel32.dll" + (char)0x00 + (char)0x00 + (char)0x00 + "VirtualProtect" byte[] check2 = new byte[] { 0x6B, 0x65, 0x72, 0x6E, 0x65, 0x6C, 0x33, 0x32, 0x2E, 0x64, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x56, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6C, 0x50, 0x72, 0x6F, 0x74, 0x65, 0x63, 0x74 }; - if (fileContent.Contains(check2, out int position2)) + if (fileContent.FirstPosition(check2, out int position2)) return $"JoWooD X-Prot {GetVersion(fileContent, --position2)}" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); else return $"JoWooD X-Prot v1" + (includePosition ? $" (Index {position})" : string.Empty); @@ -22,7 +22,7 @@ namespace BurnOutSharp.ProtectionType // "@HC09 " check = new byte[] { 0x40, 0x48, 0x43, 0x30, 0x39, 0x20, 0x20, 0x20, 0x20 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"JoWooD X-Prot v2" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/KeyLock.cs b/BurnOutSharp/ProtectionType/KeyLock.cs index 860d6ef4..71af9339 100644 --- a/BurnOutSharp/ProtectionType/KeyLock.cs +++ b/BurnOutSharp/ProtectionType/KeyLock.cs @@ -7,7 +7,7 @@ { // "KEY-LOCK COMMAND" byte[] check = new byte[] { 0x4B, 0x45, 0x59, 0x2D, 0x4C, 0x4F, 0x43, 0x4B, 0x20, 0x43, 0x4F, 0x4D, 0x4D, 0x41, 0x4E, 0x44 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"Key-Lock (Dongle)" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/LaserLock.cs b/BurnOutSharp/ProtectionType/LaserLock.cs index 8243fe73..e8516cb2 100644 --- a/BurnOutSharp/ProtectionType/LaserLock.cs +++ b/BurnOutSharp/ProtectionType/LaserLock.cs @@ -12,11 +12,11 @@ namespace BurnOutSharp.ProtectionType { // "Packed by SPEEnc V2 Asterios Parlamentas.PE" byte[] check = new byte[] { 0x50, 0x61, 0x63, 0x6B, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x53, 0x50, 0x45, 0x45, 0x6E, 0x63, 0x20, 0x56, 0x32, 0x20, 0x41, 0x73, 0x74, 0x65, 0x72, 0x69, 0x6F, 0x73, 0x20, 0x50, 0x61, 0x72, 0x6C, 0x61, 0x6D, 0x65, 0x6E, 0x74, 0x61, 0x73, 0x2E, 0x50, 0x45 }; - bool containsCheck = fileContent.Contains(check, out int position); + bool containsCheck = fileContent.FirstPosition(check, out int position); // "GetModuleHandleA" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "GetProcAddress" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "LoadLibraryA" + (char)0x00 + (char)0x00 + "KERNEL32.dll" + (char)0x00 + "ëy" + (char)0x01 + "SNIF" byte[] check2 = { 0x47, 0x65, 0x74, 0x4D, 0x6F, 0x64, 0x75, 0x6C, 0x65, 0x48, 0x61, 0x6E, 0x64, 0x6C, 0x65, 0x41, 0x00, 0x00, 0x00, 0x00, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x63, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x6F, 0x61, 0x64, 0x4C, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x41, 0x00, 0x00, 0x4B, 0x45, 0x52, 0x4E, 0x45, 0x4C, 0x33, 0x32, 0x2E, 0x64, 0x6C, 0x6C, 0x00, 0xEB, 0x79, 0x01, 0x53, 0x4E, 0x49, 0x46 }; - bool containsCheck2 = fileContent.Contains(check2, out int position2); + bool containsCheck2 = fileContent.FirstPosition(check2, out int position2); if (containsCheck && containsCheck2) return $"LaserLock {GetVersion(fileContent, position2)} {GetBuild(fileContent, true)}" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); @@ -30,12 +30,12 @@ namespace BurnOutSharp.ProtectionType // ":\\LASERLOK\\LASERLOK.IN" + (char)0x00 + "C:\\NOMOUSE.SP" check = new byte[] { 0x3A, 0x5C, 0x5C, 0x4C, 0x41, 0x53, 0x45, 0x52, 0x4C, 0x4F, 0x4B, 0x5C, 0x5C, 0x4C, 0x41, 0x53, 0x45, 0x52, 0x4C, 0x4F, 0x4B, 0x2E, 0x49, 0x4E, 0x00, 0x43, 0x3A, 0x5C, 0x5C, 0x4E, 0x4F, 0x4D, 0x4F, 0x55, 0x53, 0x45, 0x2E, 0x53, 0x50 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "LaserLock 3" + (includePosition ? $" (Index {position})" : string.Empty); // "LASERLOK_INIT" + (char)0xC + "LASERLOK_RUN" + (char)0xE + "LASERLOK_CHECK" + (char)0xF + "LASERLOK_CHECK2" + (char)0xF + "LASERLOK_CHECK3" check = new byte[] { 0x4C, 0x41, 0x53, 0x45, 0x52, 0x4C, 0x4F, 0x4B, 0x5F, 0x49, 0x4E, 0x49, 0x54, 0x0C, 0x4C, 0x41, 0x53, 0x45, 0x52, 0x4C, 0x4F, 0x4B, 0x5F, 0x52, 0x55, 0x4E, 0x0E, 0x4C, 0x41, 0x53, 0x45, 0x52, 0x4C, 0x4F, 0x4B, 0x5F, 0x43, 0x48, 0x45, 0x43, 0x4B, 0x0F, 0x4C, 0x41, 0x53, 0x45, 0x52, 0x4C, 0x4F, 0x4B, 0x5F, 0x43, 0x48, 0x45, 0x43, 0x4B, 0x32, 0x0F, 0x4C, 0x41, 0x53, 0x45, 0x52, 0x4C, 0x4F, 0x4B, 0x5F, 0x43, 0x48, 0x45, 0x43, 0x4B, 0x33 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "LaserLock 5" + (includePosition ? $" (Index {position})" : string.Empty); return null; @@ -86,7 +86,7 @@ namespace BurnOutSharp.ProtectionType { // "Unkown" + (char)0x00 + "Unkown" // TODO: Is this supposed to be "Unknown"? byte[] check = new byte[] { 0x55, 0x6E, 0x6B, 0x6F, 0x77, 0x6E, 0x00, 0x55, 0x6E, 0x6B, 0x6F, 0x77, 0x6E }; - fileContent.Contains(check, out int position); + fileContent.FirstPosition(check, out int position); string year, month, day; if (versionTwo) { diff --git a/BurnOutSharp/ProtectionType/MediaMaxCD3.cs b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs index 1c8fe21c..596ec153 100644 --- a/BurnOutSharp/ProtectionType/MediaMaxCD3.cs +++ b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs @@ -12,12 +12,12 @@ namespace BurnOutSharp.ProtectionType { // Cd3Ctl byte[] check = new byte[] { 0x43, 0x64, 0x33, 0x43, 0x74, 0x6C }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "MediaMax CD-3" + (includePosition ? $" (Index {position})" : string.Empty); // DllInstallSbcp check = new byte[] { 0x44, 0x6C, 0x6C, 0x49, 0x6E, 0x73, 0x74, 0x61, 0x6C, 0x6C, 0x53, 0x62, 0x63, 0x70 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "MediaMax CD-3" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/OnlineRegistration.cs b/BurnOutSharp/ProtectionType/OnlineRegistration.cs index 04c0647c..b8bd92f1 100644 --- a/BurnOutSharp/ProtectionType/OnlineRegistration.cs +++ b/BurnOutSharp/ProtectionType/OnlineRegistration.cs @@ -7,7 +7,7 @@ { // I + (char)0x00 + n + (char)0x00 + t + (char)0x00 + e + (char)0x00 + r + (char)0x00 + n + (char)0x00 + a + (char)0x00 + l + (char)0x00 + N + (char)0x00 + a + (char)0x00 + m + (char)0x00 + e + (char)0x00 + + (char)0x00 + + (char)0x00 + E + (char)0x00 + R + (char)0x00 + e + (char)0x00 + g + (char)0x00 byte[] check = new byte[] { 0x49, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x4E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x45, 0x00, 0x52, 0x00, 0x65, 0x00, 0x67, 0x00 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"EA CdKey Registration Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/Origin.cs b/BurnOutSharp/ProtectionType/Origin.cs index 80dde3ca..0c43b36c 100644 --- a/BurnOutSharp/ProtectionType/Origin.cs +++ b/BurnOutSharp/ProtectionType/Origin.cs @@ -12,7 +12,7 @@ namespace BurnOutSharp.ProtectionType { // O + (char)0x00 + r + (char)0x00 + i + (char)0x00 + g + (char)0x00 + i + (char)0x00 + n + (char)0x00 + S + (char)0x00 + e + (char)0x00 + t + (char)0x00 + u + (char)0x00 + p + (char)0x00 + . + (char)0x00 + e + (char)0x00 + x + (char)0x00 + e + (char)0x00 byte[] check = 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 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "Origin" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/PSXAntiModchip.cs b/BurnOutSharp/ProtectionType/PSXAntiModchip.cs index 07e857db..07839791 100644 --- a/BurnOutSharp/ProtectionType/PSXAntiModchip.cs +++ b/BurnOutSharp/ProtectionType/PSXAntiModchip.cs @@ -9,12 +9,12 @@ { // " SOFTWARE TERMINATED\nCONSOLE MAY HAVE BEEN MODIFIED\n CALL 1-888-780-7690" byte[] check = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x53, 0x4F, 0x46, 0x54, 0x57, 0x41, 0x52, 0x45, 0x20, 0x54, 0x45, 0x52, 0x4D, 0x49, 0x4E, 0x41, 0x54, 0x45, 0x44, 0x5C, 0x6E, 0x43, 0x4F, 0x4E, 0x53, 0x4F, 0x4C, 0x45, 0x20, 0x4D, 0x41, 0x59, 0x20, 0x48, 0x41, 0x56, 0x45, 0x20, 0x42, 0x45, 0x45, 0x4E, 0x20, 0x4D, 0x4F, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5C, 0x6E, 0x20, 0x20, 0x20, 0x20, 0x20, 0x43, 0x41, 0x4C, 0x4C, 0x20, 0x31, 0x2D, 0x38, 0x38, 0x38, 0x2D, 0x37, 0x38, 0x30, 0x2D, 0x37, 0x36, 0x39, 0x30 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"PlayStation Anti-modchip (English)" + (includePosition ? $"(Index {position})" : string.Empty); // "強制終了しました。\n本体が改造されている\nおそれがあります。" check = new byte[] { 0x5F, 0x37, 0x52, 0x36, 0x7D, 0x42, 0x4E, 0x86, 0x30, 0x57, 0x30, 0x7E, 0x30, 0x57, 0x30, 0x5F, 0x30, 0x02, 0x5C, 0x6E, 0x67, 0x2C, 0x4F, 0x53, 0x30, 0x4C, 0x65, 0x39, 0x90, 0x20, 0x30, 0x55, 0x30, 0x8C, 0x30, 0x66, 0x30, 0x44, 0x30, 0x8B, 0x5C, 0x6E, 0x30, 0x4A, 0x30, 0x5D, 0x30, 0x8C, 0x30, 0x4C, 0x30, 0x42, 0x30, 0x8A, 0x30, 0x7E, 0x30, 0x59, 0x30, 0x02 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"PlayStation Anti-modchip (Japanese)" + (includePosition ? $"(Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/ProtectDisc.cs b/BurnOutSharp/ProtectionType/ProtectDisc.cs index 28fc9ad6..f72c1404 100644 --- a/BurnOutSharp/ProtectionType/ProtectDisc.cs +++ b/BurnOutSharp/ProtectionType/ProtectDisc.cs @@ -13,7 +13,7 @@ namespace BurnOutSharp.ProtectionType { // "HúMETINF" byte[] check = new byte[] { 0x48, 0xFA, 0x4D, 0x45, 0x54, 0x49, 0x4E, 0x46 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) { string version = SearchProtectDiscVersion(file, fileContent); if (version.Length > 0) @@ -33,7 +33,7 @@ namespace BurnOutSharp.ProtectionType // "ACE-PCD" check = new byte[] { 0x41, 0x43, 0x45, 0x2D, 0x50, 0x43, 0x44 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { string version = SearchProtectDiscVersion(file, fileContent); if (version.Length > 0) diff --git a/BurnOutSharp/ProtectionType/RingPROTECH.cs b/BurnOutSharp/ProtectionType/RingPROTECH.cs index 600da096..6d8cb52d 100644 --- a/BurnOutSharp/ProtectionType/RingPROTECH.cs +++ b/BurnOutSharp/ProtectionType/RingPROTECH.cs @@ -8,7 +8,7 @@ { // (char)0x00 + "Allocator" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 byte[] check = new byte[] { 0x00, 0x41, 0x6C, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x6F, 0x72, 0x00, 0x00, 0x00, 0x00 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "Ring PROTECH [Check disc for physical ring]" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/SVKProtector.cs b/BurnOutSharp/ProtectionType/SVKProtector.cs index 361199cb..47e562f7 100644 --- a/BurnOutSharp/ProtectionType/SVKProtector.cs +++ b/BurnOutSharp/ProtectionType/SVKProtector.cs @@ -7,7 +7,7 @@ { // "?SVKP" + (char)0x00 + (char)0x00 byte[] check = new byte[] { 0x3F, 0x53, 0x56, 0x4B, 0x50, 0x00, 0x00 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "SVK Protector" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/SafeDisc.cs b/BurnOutSharp/ProtectionType/SafeDisc.cs index 42d4f334..e5dc55b0 100644 --- a/BurnOutSharp/ProtectionType/SafeDisc.cs +++ b/BurnOutSharp/ProtectionType/SafeDisc.cs @@ -14,11 +14,11 @@ namespace BurnOutSharp.ProtectionType { // "BoG_ *90.0&!! Yy>" byte[] check = new byte[] { 0x42, 0x6F, 0x47, 0x5F, 0x20, 0x2A, 0x39, 0x30, 0x2E, 0x30, 0x26, 0x21, 0x21, 0x20, 0x20, 0x59, 0x79, 0x3E }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) { // "product activation library" byte[] check2 = new byte[] { 0x70, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x20, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x6C, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79 }; - if (fileContent.Contains(check2, out int position2)) + if (fileContent.FirstPosition(check2, out int position2)) return $"SafeCast {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); else return $"SafeDisc {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); @@ -26,7 +26,7 @@ namespace BurnOutSharp.ProtectionType // (char)0x00 + (char)0x00 + "BoG_" check = new byte[] { 0x00, 0x00, 0x42, 0x6F, 0x47, 0x5F }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { string version = SearchSafeDiscVersion(file, fileContent); if (version.Length > 0) @@ -37,7 +37,7 @@ namespace BurnOutSharp.ProtectionType // "stxt774" check = new byte[] { 0x73, 0x74, 0x78, 0x74, 0x37, 0x37, 0x34 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { string version = SearchSafeDiscVersion(file, fileContent); if (version.Length > 0) @@ -48,7 +48,7 @@ namespace BurnOutSharp.ProtectionType // "stxt371" check = new byte[] { 0x73, 0x74, 0x78, 0x74, 0x33, 0x37, 0x31 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { string version = SearchSafeDiscVersion(file, fileContent); if (version.Length > 0) diff --git a/BurnOutSharp/ProtectionType/SafeLock.cs b/BurnOutSharp/ProtectionType/SafeLock.cs index 0ad76225..2805c8af 100644 --- a/BurnOutSharp/ProtectionType/SafeLock.cs +++ b/BurnOutSharp/ProtectionType/SafeLock.cs @@ -12,7 +12,7 @@ namespace BurnOutSharp.ProtectionType { // "SafeLock" byte[] check = new byte[] { 0x53, 0x61, 0x66, 0x65, 0x4C, 0x6F, 0x63, 0x6B }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "SafeLock" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/SecuROM.cs b/BurnOutSharp/ProtectionType/SecuROM.cs index 7bd56665..9bba5e4c 100644 --- a/BurnOutSharp/ProtectionType/SecuROM.cs +++ b/BurnOutSharp/ProtectionType/SecuROM.cs @@ -13,37 +13,37 @@ namespace BurnOutSharp.ProtectionType { // "AddD" + (char)0x03 + (char)0x00 + (char)0x00 + (char)0x00) byte[] check = new byte[] { 0x41, 0x64, 0x64, 0x44, 0x03, 0x00, 0x00, 0x00 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"SecuROM {GetV4Version(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); // (char)0xCA + (char)0xDD + (char)0xDD + (char)0xAC + (char)0x03 check = new byte[] { 0xCA, 0xDD, 0xDD, 0xAC, 0x03 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"SecuROM {GetV5Version(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); // ".securom" + (char)0xE0 + (char)0xC0 check = new byte[] { 0x2E, 0x73, 0x65, 0x63, 0x75, 0x72, 0x6F, 0x6D, 0xE0, 0xC0 }; - if (fileContent.Contains(check, out position) && position == 0) + if (fileContent.FirstPosition(check, out position) && position == 0) return $"SecuROM {GetV7Version(fileContent)}" + (includePosition ? $" (Index {position})" : string.Empty); // ".securom" check = new byte[] { 0x2E, 0x73, 0x65, 0x63, 0x75, 0x72, 0x6F, 0x6D }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"SecuROM {GetV7Version(fileContent)}" + (includePosition ? $" (Index {position})" : string.Empty); // "_and_play.dll" + (char)0x00 + "drm_pagui_doit" check = new byte[] { 0x5F, 0x61, 0x6E, 0x64, 0x5F, 0x70, 0x6C, 0x61, 0x79, 0x2E, 0x64, 0x6C, 0x6C, 0x00, 0x64, 0x72, 0x6D, 0x5F, 0x70, 0x61, 0x67, 0x75, 0x69, 0x5F, 0x64, 0x6F, 0x69, 0x74 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"SecuROM Product Activation {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); // ".cms_t" + (char)0x00 check = new byte[] { 0x2E, 0x63, 0x6D, 0x73, 0x5F, 0x74, 0x00 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "SecuROM 1-3" + (includePosition ? $" (Index {position})" : string.Empty); // ".cms_d" + (char)0x00 check = new byte[] { 0x2E, 0x63, 0x6D, 0x73, 0x5F, 0x64, 0x00 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "SecuROM 1-3" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/SmartE.cs b/BurnOutSharp/ProtectionType/SmartE.cs index d9356a0e..3acdca31 100644 --- a/BurnOutSharp/ProtectionType/SmartE.cs +++ b/BurnOutSharp/ProtectionType/SmartE.cs @@ -12,7 +12,7 @@ namespace BurnOutSharp.ProtectionType { // BITARTS byte[] check = new byte[] { 0x42, 0x49, 0x54, 0x41, 0x52, 0x54, 0x53 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "SmartE" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/SolidShield.cs b/BurnOutSharp/ProtectionType/SolidShield.cs index 6428b8ce..9f34a78a 100644 --- a/BurnOutSharp/ProtectionType/SolidShield.cs +++ b/BurnOutSharp/ProtectionType/SolidShield.cs @@ -13,12 +13,12 @@ namespace BurnOutSharp.ProtectionType { // "D" + (char)0x00 + "V" + (char)0x00 + "M" + (char)0x00 + " " + (char)0x00 + "L" + (char)0x00 + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y" byte[] check = new byte[] { 0x44, 0x00, 0x56, 0x00, 0x4D, 0x00, 0x20, 0x00, 0x4C, 0x00, 0x69, 0x00, 0x62, 0x00, 0x72, 0x00, 0x61, 0x00, 0x72, 0x00, 0x79 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"SolidShield {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); // "S" + (char)0x00 + "o" + (char)0x00 + "l" + (char)0x00 + "i" + (char)0x00 + "d" + (char)0x00 + "s" + (char)0x00 + "h" + (char)0x00 + "i" + (char)0x00 + "e" + (char)0x00 + "l" + (char)0x00 + "d" + (char)0x00 + " " + (char)0x00 + "L" + (char)0x00 + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y" check = new byte[] { 0x53, 0x00, 0x6F, 0x00, 0x6C, 0x00, 0x69, 0x00, 0x64, 0x00, 0x73, 0x00, 0x68, 0x00, 0x69, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x64, 0x00, 0x20, 0x00, 0x4C, 0x00, 0x69, 0x00, 0x62, 0x00, 0x72, 0x00, 0x61, 0x00, 0x72, 0x00, 0x79 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { string companyName = string.Empty; if (file != null) @@ -30,7 +30,7 @@ namespace BurnOutSharp.ProtectionType // "S" + (char)0x00 + "o" + (char)0x00 + "l" + (char)0x00 + "i" + (char)0x00 + "d" + (char)0x00 + "s" + (char)0x00 + "h" + (char)0x00 + "i" + (char)0x00 + "e" + (char)0x00 + "l" + (char)0x00 + "d" + (char)0x00 + " " + (char)0x00 + "A" + (char)0x00 + "c" + (char)0x00 + "t" + (char)0x00 + "i" + (char)0x00 + "v" + (char)0x00 + "a" + (char)0x00 + "t" + (char)0x00 + "i" + (char)0x00 + "o" + (char)0x00 + "n" + (char)0x00 + " " + (char)0x00 + "L" + (char)0x00 + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y" check = new byte[] { 0x53, 0x00, 0x6F, 0x00, 0x6C, 0x00, 0x69, 0x00, 0x64, 0x00, 0x73, 0x00, 0x68, 0x00, 0x69, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x64, 0x00, 0x20, 0x00, 0x41, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x76, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x4C, 0x00, 0x69, 0x00, 0x62, 0x00, 0x72, 0x00, 0x61, 0x00, 0x72, 0x00, 0x79 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { string companyName = string.Empty; if (file != null) @@ -42,7 +42,7 @@ namespace BurnOutSharp.ProtectionType // (char)0xEF + (char)0xBE + (char)0xAD + (char)0xDE check = new byte[] { }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { var id1 = new ArraySegment(fileContent, position + 5, 3); var id2 = new ArraySegment(fileContent, position + 16, 4); @@ -55,7 +55,7 @@ namespace BurnOutSharp.ProtectionType // "A" + (char)0x00 + "c" + (char)0x00 + "t" + (char)0x00 + "i" + (char)0x00 + "v" + (char)0x00 + "a" + (char)0x00 + "t" + (char)0x00 + "i" + (char)0x00 + "o" + (char)0x00 + "n" + (char)0x00 + " " + (char)0x00 + "M" + (char)0x00 + "a" + (char)0x00 + "n" + (char)0x00 + "a" + (char)0x00 + "g" + (char)0x00 + "e" + (char)0x00 + "r" check = new byte[] { 0x41, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x76, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x4d, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x67, 0x00, 0x65, 0x00, 0x72 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { string companyName = string.Empty; if (file != null) @@ -67,12 +67,12 @@ namespace BurnOutSharp.ProtectionType // dvm.dll check = new byte[] { 0x64, 0x76, 0x6D, 0x2E, 0x64, 0x6C, 0x6C }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"SolidShield EXE Wrapper" + (includePosition ? $" (Index {position})" : string.Empty); // (char)0xAD + (char)0xDE + (char)0xFE + (char)0xCA check = new byte[] { 0xAD, 0xDE, 0xFE, 0xCA }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { var id1 = new ArraySegment(fileContent, position + 4, 3); var id2 = new ArraySegment(fileContent, position + 15, 4); @@ -88,7 +88,7 @@ namespace BurnOutSharp.ProtectionType { // "T" + (char)0x00 + "a" + (char)0x00 + "g" + (char)0x00 + "e" + (char)0x00 + "s" + (char)0x00 + "S" + (char)0x00 + "e" + (char)0x00 + "t" + (char)0x00 + "u" + (char)0x00 + "p" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "0" + (char)0x00 + (char)0x8 + (char)0x00 + (char)0x1 + (char)0x0 + "F" + (char)0x00 + "i" + (char)0x00 + "l" + (char)0x00 + "e" + (char)0x00 + "V" + (char)0x00 + "e" + (char)0x00 + "r" + (char)0x00 + "s" + (char)0x00 + "i" + (char)0x00 + "o" + (char)0x00 + "n" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 byte[] check2 = new byte[] { 0x54, 0x61, 0x67, 0x65, 0x73, 0x53, 0x65, 0x74, 0x75, 0x70, 0x30, 0x08, 0x01, 0x00, 0x46, 0x69, 0x6C, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x00, 0x00, 0x00, 0x00 }; - if (fileContent.Contains(check2, out int position2)) + if (fileContent.FirstPosition(check2, out int position2)) { position2--; // TODO: Verify this subtract return $"SolidShield 2 + Tagès {fileContent[position2 + 0x38]}.{fileContent[position2 + 0x38 + 4]}.{fileContent[position2 + 0x38 + 8]}.{fileContent[position + 0x38 + 12]}" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); @@ -102,12 +102,12 @@ namespace BurnOutSharp.ProtectionType // "Solidshield" check = new byte[] { 0x53, 0x6F, 0x6C, 0x69, 0x64, 0x73, 0x68, 0x69, 0x65, 0x6C, 0x64 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"SolidShield {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); // "B" + (char)0x00 + "I" + (char)0x00 + "N" + (char)0x00 + (char)0x7 + (char)0x00 + "I" + (char)0x00 + "D" + (char)0x00 + "R" + (char)0x00 + "_" + (char)0x00 + "S" + (char)0x00 + "G" + (char)0x00 + "T" + (char)0x0 check = new byte[] { 0x42, 0x00, 0x49, 0x00, 0x4E, 0x00, 0x07, 0x00, 0x49, 0x00, 0x44, 0x00, 0x52, 0x00, 0x5F, 0x00, 0x53, 0x00, 0x47, 0x00, 0x54, 0x00 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "SolidShield" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/StarForce.cs b/BurnOutSharp/ProtectionType/StarForce.cs index 925b15d7..85ccaaa8 100644 --- a/BurnOutSharp/ProtectionType/StarForce.cs +++ b/BurnOutSharp/ProtectionType/StarForce.cs @@ -12,7 +12,7 @@ namespace BurnOutSharp.ProtectionType { // "(" + (char)0x00 + "c" + (char)0x00 + ")" + (char)0x00 + " " + (char)0x00 + "P" + (char)0x00 + "r" + (char)0x00 + "o" + (char)0x00 + "t" + (char)0x00 + "e" + (char)0x00 + "c" + (char)0x00 + "t" + (char)0x00 + "i" + (char)0x00 + "o" + (char)0x00 + "n" + (char)0x00 + " " + (char)0x00 + "T" + (char)0x00 + "e" + (char)0x00 + "c" + (char)0x00 + "h" + (char)0x00 + "n" + (char)0x00 + "o" + (char)0x00 + "l" + (char)0x00 + "o" + (char)0x00 + "g" + (char)0x00 + "y" + (char)0x00 byte[] check = new byte[] { 0x28, 0x00, 0x63, 0x00, 0x29, 0x00, 0x20, 0x00, 0x50, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x54, 0x00, 0x65, 0x00, 0x63, 0x00, 0x68, 0x00, 0x6E, 0x00, 0x6F, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x79, 0x00 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) { // "PSA_GetDiscLabel" // byte[] check2 = new byte[] { 0x50, 0x53, 0x41, 0x5F, 0x47, 0x65, 0x74, 0x44, 0x69, 0x73, 0x63, 0x4C, 0x61, 0x62, 0x65, 0x6C }; @@ -22,7 +22,7 @@ namespace BurnOutSharp.ProtectionType // "TradeName" byte[] check2 = new byte[] { 0x54, 0x72, 0x61, 0x64, 0x65, 0x4E, 0x61, 0x6D, 0x65 }; - if (fileContent.Contains(check2, out int position2) && position2 != 0) + if (fileContent.FirstPosition(check2, out int position2) && position2 != 0) return $"StarForce {Utilities.GetFileVersion(file)} ({fileContent.Skip(position2 + 22).TakeWhile(c => c != 0x00)})" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); else return $"StarForce {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); @@ -30,7 +30,7 @@ namespace BurnOutSharp.ProtectionType // "Protection Technology, Ltd." check = new byte[] { 0x50, 0x72, 0x6F, 0x74, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x79, 0x2C, 0x20, 0x4C, 0x74, 0x64, 0x2E }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { // "PSA_GetDiscLabel" // byte[] check2 = new byte[] { 0x50, 0x53, 0x41, 0x5F, 0x47, 0x65, 0x74, 0x44, 0x69, 0x73, 0x63, 0x4C, 0x61, 0x62, 0x65, 0x6C }; @@ -40,7 +40,7 @@ namespace BurnOutSharp.ProtectionType // "TradeName" byte[] check2 = new byte[] { 0x54, 0x72, 0x61, 0x64, 0x65, 0x4E, 0x61, 0x6D, 0x65 }; - if (fileContent.Contains(check2, out int position2) && position2 != 0) + if (fileContent.FirstPosition(check2, out int position2) && position2 != 0) return $"StarForce {Utilities.GetFileVersion(file)} ({fileContent.Skip(position2 + 22).TakeWhile(c => c != 0x00)})" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); else return $"StarForce {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); @@ -48,17 +48,17 @@ namespace BurnOutSharp.ProtectionType // ".sforce" check = new byte[] { 0x2E, 0x73, 0x66, 0x6F, 0x72, 0x63, 0x65 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "StarForce 3-5" + (includePosition ? $" (Index {position})" : string.Empty); // ".brick" check = new byte[] { 0x2E, 0x62, 0x72, 0x69, 0x63, 0x6B }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "StarForce 3-5" + (includePosition ? $" (Index {position})" : string.Empty); // "P" + (char)0x00 + "r" + (char)0x00 + "o" + (char)0x00 + "t" + (char)0x00 + "e" + (char)0x00 + "c" + (char)0x00 + "t" + (char)0x00 + "e" + (char)0x00 + "d" + (char)0x00 + " " + (char)0x00 + "M" + (char)0x00 + "o" + (char)0x00 + "d" + (char)0x00 + "u" + (char)0x00 + "l" + (char)0x00 + "e" check = new byte[] { 0x50, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x65, 0x00, 0x64, 0x00, 0x20, 0x00, 0x4d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x65 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "StarForce 5" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/Sysiphus.cs b/BurnOutSharp/ProtectionType/Sysiphus.cs index 6917d052..8ce61f95 100644 --- a/BurnOutSharp/ProtectionType/Sysiphus.cs +++ b/BurnOutSharp/ProtectionType/Sysiphus.cs @@ -7,12 +7,12 @@ { // "V SUHPISYSDVD" byte[] check = new byte[] { 0x56, 0x20, 0x53, 0x55, 0x48, 0x50, 0x49, 0x53, 0x59, 0x53, 0x44, 0x56, 0x44 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"Sysiphus DVD {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); // "V SUHPISYS" check = new byte[] { 0x56, 0x20, 0x53, 0x55, 0x48, 0x50, 0x49, 0x53, 0x59, 0x53 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"Sysiphus {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/Tages.cs b/BurnOutSharp/ProtectionType/Tages.cs index 2baa499d..191db74e 100644 --- a/BurnOutSharp/ProtectionType/Tages.cs +++ b/BurnOutSharp/ProtectionType/Tages.cs @@ -12,17 +12,17 @@ namespace BurnOutSharp.ProtectionType { // "protected-tages-runtime.exe" byte[] check = new byte[] { 0x70, 0x72, 0x6F, 0x74, 0x65, 0x63, 0x74, 0x65, 0x64, 0x2D, 0x74, 0x61, 0x67, 0x65, 0x73, 0x2D, 0x72, 0x75, 0x6E, 0x74, 0x69, 0x6D, 0x65, 0x2E, 0x65, 0x78, 0x65 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"TAGES {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); // "tagesprotection.com" check = new byte[] { 0x74, 0x61, 0x67, 0x65, 0x73, 0x70, 0x72, 0x6F, 0x74, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x2E, 0x63, 0x6F, 0x6D }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return $"TAGES {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty); // (char)0xE8 + "u" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0xE8 check = new byte[] { 0xE8, 0x75, 0x00, 0x00, 0x00, 0xE8 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { // (char)0xFF + (char)0xFF + "h" if (new ArraySegment(fileContent, --position + 8, 3).SequenceEqual(new byte[] { 0xFF, 0xFF, 0x68 })) // TODO: Verify this subtract diff --git a/BurnOutSharp/ProtectionType/ThreePLock.cs b/BurnOutSharp/ProtectionType/ThreePLock.cs index 28dd51b1..b5738f93 100644 --- a/BurnOutSharp/ProtectionType/ThreePLock.cs +++ b/BurnOutSharp/ProtectionType/ThreePLock.cs @@ -7,11 +7,11 @@ { // .ldr byte[] check = new byte[] { 0x2E, 0x6C, 0x64, 0x72 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) { // .ldt byte[] check2 = new byte[] { 0x2E, 0x6C, 0x64, 0x74 }; - if (fileContent.Contains(check2, out int position2)) + if (fileContent.FirstPosition(check2, out int position2)) return "3PLock" + (includePosition ? $" (Index {position}, {position2})" : string.Empty); } diff --git a/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs b/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs index 47c2af45..151a26ab 100644 --- a/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs +++ b/BurnOutSharp/ProtectionType/ThreeTwoOneStudios.cs @@ -7,7 +7,7 @@ { // 3 + (char)0x00 + 1 + 2 + (char)0x00 + 1 + (char)0x00 + S + (char)0x00 + t + (char)0x00 + u + (char)0x00 + d + (char)0x00 + i + (char)0x00 + o + (char)0x00 + s + (char)0x00 + + (char)0x00 + A + (char)0x00 + c + (char)0x00 + t + (char)0x00 + i + (char)0x00 + v + (char)0x00 + a + (char)0x00 + t + (char)0x00 + i + (char)0x00 + o + (char)0x00 + n + (char)0x00 byte[] check = new byte[] { 0x33, 0x00, 0x32, 0x00, 0x31, 0x00, 0x53, 0x00, 0x74, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x20, 0x00, 0x41, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x76, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "321Studios Online Activation" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs index 30283367..6f6148ed 100644 --- a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs +++ b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs @@ -14,12 +14,12 @@ namespace BurnOutSharp.ProtectionType { // "VOB ProtectCD" byte[] check = new byte[] { 0x56, 0x4F, 0x42, 0x20, 0x50, 0x72, 0x6F, 0x74, 0x65, 0x63, 0x74, 0x43, 0x44 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return $"VOB ProtectCD/DVD {GetOldVersion(fileContent, --position)}" + (includePosition ? $" (Index {position})" : string.Empty); // TODO: Verify this subtract // "DCP-BOV" + (char)0x00 + (char)0x00 check = new byte[] { 0x44, 0x43, 0x50, 0x2D, 0x42, 0x4F, 0x56, 0x00, 0x00 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) { string version = GetVersion(fileContent, --position); // TODO: Verify this subtract if (version.Length > 0) @@ -39,7 +39,7 @@ namespace BurnOutSharp.ProtectionType // ".vob.pcd" check = new byte[] { 0x2E, 0x76, 0x6F, 0x62, 0x2E, 0x70, 0x63, 0x64 }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "VOB ProtectCD" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/WTMCDProtect.cs b/BurnOutSharp/ProtectionType/WTMCDProtect.cs index 51e04fc7..d4039bfc 100644 --- a/BurnOutSharp/ProtectionType/WTMCDProtect.cs +++ b/BurnOutSharp/ProtectionType/WTMCDProtect.cs @@ -12,7 +12,7 @@ namespace BurnOutSharp.ProtectionType { // "WTM76545" byte[] check = new byte[] { 0x57, 0x54, 0x4D, 0x37, 0x36, 0x35, 0x34, 0x35 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "WTM CD Protect" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/XCP.cs b/BurnOutSharp/ProtectionType/XCP.cs index 66a4f107..214b8cc6 100644 --- a/BurnOutSharp/ProtectionType/XCP.cs +++ b/BurnOutSharp/ProtectionType/XCP.cs @@ -13,17 +13,17 @@ namespace BurnOutSharp.ProtectionType { // XCP.DAT byte[] check = new byte[] { 0x58, 0x43, 0x50, 0x2E, 0x44, 0x41, 0x54 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "XCP" + (includePosition ? $" (Index {position})" : string.Empty); // XCPPlugins.dll check = new byte[] { 0x58, 0x43, 0x50, 0x50, 0x6C, 0x75, 0x67, 0x69, 0x6E, 0x73, 0x2E, 0x64, 0x6C, 0x6C }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "XCP" + (includePosition ? $" (Index {position})" : string.Empty); // XCPPhoenix.dll check = new byte[] { 0x58, 0x43, 0x50, 0x50, 0x68, 0x6F, 0x65, 0x6E, 0x69, 0x78, 0x2E, 0x64, 0x6C, 0x6C }; - if (fileContent.Contains(check, out position)) + if (fileContent.FirstPosition(check, out position)) return "XCP" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/ProtectionType/XtremeProtector.cs b/BurnOutSharp/ProtectionType/XtremeProtector.cs index d348bea6..2eb3f085 100644 --- a/BurnOutSharp/ProtectionType/XtremeProtector.cs +++ b/BurnOutSharp/ProtectionType/XtremeProtector.cs @@ -7,7 +7,7 @@ { // "XPROT " byte[] check = new byte[] { 0x58, 0x50, 0x52, 0x4F, 0x54, 0x20, 0x20, 0x20 }; - if (fileContent.Contains(check, out int position)) + if (fileContent.FirstPosition(check, out int position)) return "Xtreme-Protector" + (includePosition ? $" (Index {position})" : string.Empty); return null; diff --git a/BurnOutSharp/Utilities.cs b/BurnOutSharp/Utilities.cs index 21ff54d2..3434194a 100644 --- a/BurnOutSharp/Utilities.cs +++ b/BurnOutSharp/Utilities.cs @@ -157,37 +157,23 @@ namespace BurnOutSharp #region Byte Arrays /// - /// Search for a byte array in another array + /// Find the first position of one array in another, if possible /// - public static bool Contains(this byte[] stack, byte[] needle, out int position, int start = 0, int end = -1) + public static bool FirstPosition(this byte[] stack, byte[] needle, out int position, int start = 0, int end = -1) { - // Initialize the found position to -1 - position = -1; + (bool found, int foundPosition) = FindPosition(stack, needle, start, end, false); + position = foundPosition; + return found; + } - // If either array is null or empty, we can't do anything - if (stack == null || stack.Length == 0 || needle == null || needle.Length == 0) - return false; - - // If the needle array is larger than the stack array, it can't be contained within - if (needle.Length > stack.Length) - return false; - - // If start or end are not set properly, set them to defaults - if (start < 0) - start = 0; - if (end < 0) - end = stack.Length - needle.Length; - - for (int i = start; i < end; i++) - { - if (stack.EqualAt(needle, i)) - { - position = i; - return true; - } - } - - return false; + /// + /// Find the last position of one array in another, if possible + /// + public static bool LastPosition(this byte[] stack, byte[] needle, out int position, int start = 0, int end = -1) + { + (bool found, int foundPosition) = FindPosition(stack, needle, start, end, true); + position = foundPosition; + return found; } /// @@ -195,7 +181,43 @@ namespace BurnOutSharp /// public static bool StartsWith(this byte[] stack, byte[] needle) { - return stack.Contains(needle, out int _, start: 0, end: 1); + return stack.FirstPosition(needle, out int _, start: 0, end: 1); + } + + /// + /// See if a byte array ends with another + /// + public static bool EndsWith(this byte[] stack, byte[] needle) + { + return stack.FirstPosition(needle, out int _, start: stack.Length - needle.Length); + } + + /// + /// Find the position of one array in another, if possible + /// + private static (bool, int) FindPosition(byte[] stack, byte[] needle, int start, int end, bool reverse) + { + // If either array is null or empty, we can't do anything + if (stack == null || stack.Length == 0 || needle == null || needle.Length == 0) + return (false, -1); + + // If the needle array is larger than the stack array, it can't be contained within + if (needle.Length > stack.Length) + return (false, -1); + + // If start or end are not set properly, set them to defaults + if (start < 0) + start = 0; + if (end < 0) + end = stack.Length - needle.Length; + + for (int i = reverse ? end : start; reverse ? i > start : i < end; i += reverse ? -1 : 1) + { + if (stack.EqualAt(needle, i)) + return (true, i); + } + + return (false, -1); } /// @@ -243,12 +265,12 @@ namespace BurnOutSharp { // byte[] manifestEnd = new byte[] { 0x3C, 0x2F, 0x61, 0x73, 0x73, 0x65, 0x6D, 0x62, 0x6C, 0x79, 0x3E }; - if (!fileContent.Contains(manifestEnd, out int manifestEndPosition, start: manifestStartPosition)) + if (!fileContent.FirstPosition(manifestEnd, out int manifestEndPosition, start: manifestStartPosition)) return null; // Read in the manifest to a string