Modify array finding, part 1

This commit is contained in:
Matt Nadareski
2021-03-20 19:00:22 -07:00
parent 07882f7632
commit cdc4d509ee
50 changed files with 190 additions and 168 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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)";
// .............]<5D>92....<2E>P..............<2E>P..<2E>P..<2E>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)";
// .............<2E><><EFBFBD>3....<2E>P..............<2E>P..<2E>P..<2E>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)";
// .............<2E><><EFBFBD>3....<2E>P..............<2E>P..<2E>P..<2E>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<><55>3....<2E>P..............<2E>P..<2E>P..<2E>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)";
// .............{<7B><>3....<2E>P..............<2E>P..<2E>P..<2E>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.....[:........<2E>........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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<byte>(fileContent, position + 5, 3);
var id2 = new ArraySegment<byte>(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<byte>(fileContent, position + 4, 3);
var id2 = new ArraySegment<byte>(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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<byte>(fileContent, --position + 8, 3).SequenceEqual(new byte[] { 0xFF, 0xFF, 0x68 })) // TODO: Verify this subtract

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -157,37 +157,23 @@ namespace BurnOutSharp
#region Byte Arrays
/// <summary>
/// Search for a byte array in another array
/// Find the first position of one array in another, if possible
/// </summary>
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;
/// <summary>
/// Find the last position of one array in another, if possible
/// </summary>
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;
}
/// <summary>
@@ -195,7 +181,43 @@ namespace BurnOutSharp
/// </summary>
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);
}
/// <summary>
/// See if a byte array ends with another
/// </summary>
public static bool EndsWith(this byte[] stack, byte[] needle)
{
return stack.FirstPosition(needle, out int _, start: stack.Length - needle.Length);
}
/// <summary>
/// Find the position of one array in another, if possible
/// </summary>
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);
}
/// <summary>
@@ -243,12 +265,12 @@ namespace BurnOutSharp
{
// <?xml
byte[] manifestStart = new byte[] { 0x3C, 0x3F, 0x78, 0x6D, 0x6C };
if (!fileContent.Contains(manifestStart, out int manifestStartPosition))
if (!fileContent.LastPosition(manifestStart, out int manifestStartPosition))
return null;
// </assembly>
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