Use content matching helper, part 4

This commit is contained in:
Matt Nadareski
2021-03-21 22:19:38 -07:00
parent d01826ffa4
commit cf9bd99f3d
33 changed files with 370 additions and 159 deletions

View File

@@ -27,13 +27,13 @@ namespace BurnOutSharp.Matching
#region Constructors
public Matcher(byte?[] needle, string protectionName)
: this(new List<byte?[]>() { needle }, null, protectionName) { }
: this(new List<byte?[]> { needle }, null, protectionName) { }
public Matcher(List<byte?[]> needles, string protectionName)
: this(needles, null, protectionName) { }
public Matcher(byte?[] needle, Func<string, byte[], int, string> getVersion, string protectionName)
: this(new List<byte?[]>() { needle }, getVersion, protectionName) { }
: this(new List<byte?[]> { needle }, getVersion, protectionName) { }
public Matcher(List<byte?[]> needles, Func<string, byte[], int, string> getVersion, string protectionName)
: this(needles.Select(n => new ContentMatch(n)).ToList(), getVersion, protectionName) { }

View File

@@ -14,10 +14,19 @@ namespace BurnOutSharp.PackerType
var matchers = new List<Matcher>
{
// Nullsoft Install System
new Matcher(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 }, GetVersion, "NSIS"),
new Matcher(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
}, GetVersion, "NSIS"),
// NullsoftInst
new Matcher(new byte?[] { 0x4e, 0x75, 0x6c, 0x6c, 0x73, 0x6f, 0x66, 0x74, 0x49, 0x6e, 0x73, 0x74 }, "NSIS"),
new Matcher(new byte?[]
{
0x4e, 0x75, 0x6c, 0x6c, 0x73, 0x6f, 0x66, 0x74,
0x49, 0x6e, 0x73, 0x74
}, "NSIS"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -20,7 +20,11 @@ namespace BurnOutSharp.PackerType
new Matcher(new byte?[] { 0x50, 0x45, 0x43, 0x32 }, GetVersion, "PE Compact 2 v"),
// PECompact2
new Matcher(new byte?[] { 0x50, 0x45, 0x43, 0x6F, 0x6D, 0x70, 0x61, 0x63, 0x74, 0x32 }, "PE Compact 2"),
new Matcher(new byte?[]
{
0x50, 0x45, 0x43, 0x6F, 0x6D, 0x70, 0x61, 0x63,
0x74, 0x32
}, "PE Compact 2"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -19,7 +19,13 @@ namespace BurnOutSharp.PackerType
var matchers = new List<Matcher>
{
// S.e.t.u.p. .F.a.c.t.o.r.y.
new Matcher(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 }, GetVersion, "Setup Factory"),
new Matcher(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
}, GetVersion, "Setup Factory"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -13,8 +13,13 @@ namespace BurnOutSharp.ProtectionType
// TMSAMVOF
new Matcher(new byte?[] { 0x54, 0x4D, 0x53, 0x41, 0x4D, 0x56, 0x4F, 0x46 }, "ActiveMARK"),
// " " + (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
new Matcher(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 }, "ActiveMARK 5"),
// " " + (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)0x00 + (char)0x9A + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0x10 + (char)0xC2 + (char)0x16 + (char)0x00
new Matcher(new byte?[]
{
0x20, 0xC2, 0x16, 0x00, 0xA8, 0xC1, 0x16, 0x00,
0xB8, 0xC1, 0x16, 0x00, 0x86, 0xC8, 0x16, 0x00,
0x9A, 0xC1, 0x16, 0x00, 0x10, 0xC2, 0x16, 0x00
}, "ActiveMARK 5"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -11,7 +11,11 @@ namespace BurnOutSharp.ProtectionType
var matchers = new List<Matcher>
{
// MGS CDCheck
new Matcher(new byte?[] { 0x4D, 0x47, 0x53, 0x20, 0x43, 0x44, 0x43, 0x68, 0x65, 0x63, 0x6B }, "Microsoft Game Studios CD Check"),
new Matcher(new byte?[]
{
0x4D, 0x47, 0x53, 0x20, 0x43, 0x44, 0x43, 0x68,
0x65, 0x63, 0x6B
}, "Microsoft Game Studios CD Check"),
// CDCheck
new Matcher(new byte?[] { 0x43, 0x44, 0x43, 0x68, 0x65, 0x63, 0x6B }, "Executable-Based CD Check"),
@@ -26,10 +30,19 @@ namespace BurnOutSharp.ProtectionType
var matchers = new List<Matcher>
{
// GetDriveType
new Matcher(new byte?[] { 0x47, 0x65, 0x74, 0x44, 0x72, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65 }, "Executable-Based CD Check"),
new Matcher(new byte?[]
{
0x47, 0x65, 0x74, 0x44, 0x72, 0x69, 0x76, 0x65,
0x54, 0x79, 0x70, 0x65
}, "Executable-Based CD Check"),
// GetVolumeInformation
new Matcher(new byte?[] { 0x47, 0x65, 0x74, 0x56, 0x6F, 0x6C, 0x75, 0x6D, 0x65, 0x49, 0x6E, 0x66, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E }, "Executable-Based CD Check"),
new Matcher(new byte?[]
{
0x47, 0x65, 0x74, 0x56, 0x6F, 0x6C, 0x75, 0x6D,
0x65, 0x49, 0x6E, 0x66, 0x6F, 0x72, 0x6D, 0x61,
0x74, 0x69, 0x6F, 0x6E
}, "Executable-Based CD Check"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -10,17 +11,20 @@ namespace BurnOutSharp.ProtectionType
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
// CD-Cops, ver.
byte?[] check = new byte?[] { 0x43, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73, 0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20 };
if (fileContent.FirstPosition(check, out int position))
return $"CD-Cops {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty);
var matchers = new List<Matcher>
{
// CD-Cops, ver.
new Matcher(new byte?[]
{
0x43, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73, 0x2C,
0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20
}, GetVersion, "CD-Cops"),
// .grand + (char)0x00
check = new byte?[] { 0x2E, 0x67, 0x72, 0x61, 0x6E, 0x64, 0x00};
if (fileContent.FirstPosition(check, out position))
return "CD-Cops" + (includePosition ? $" (Index {position})" : string.Empty);
// .grand + (char)0x00
new Matcher(new byte?[] { 0x2E, 0x67, 0x72, 0x61, 0x6E, 0x64, 0x00 }, "CD-Cops"),
};
return null;
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);
}
/// <inheritdoc/>
@@ -53,7 +57,7 @@ namespace BurnOutSharp.ProtectionType
return null;
}
private static string GetVersion(byte[] fileContent, int position)
public static string GetVersion(string file, byte[] fileContent, int position)
{
char[] version = new ArraySegment<byte>(fileContent, position + 15, 4).Select(b => (char)b).ToArray();
if (version[0] == 0x00)

View File

@@ -14,7 +14,13 @@ namespace BurnOutSharp.ProtectionType
var matchers = new List<Matcher>
{
// 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
new Matcher(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 }, "CD-Lock"),
new Matcher(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
}, "CD-Lock"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -18,7 +18,11 @@ namespace BurnOutSharp.ProtectionType
new Matcher(new byte?[] { 0x69, 0x63, 0x64, 0x32, 0x00 }, "Code Lock"),
// CODE-LOCK.OCX
new Matcher(new byte?[] { 0x43, 0x4F, 0x44, 0x45, 0x2D, 0x4C, 0x4F, 0x43, 0x4B, 0x2E, 0x4F, 0x43, 0x58 }, "Code Lock"),
new Matcher(new byte?[]
{
0x43, 0x4F, 0x44, 0x45, 0x2D, 0x4C, 0x4F, 0x43,
0x4B, 0x2E, 0x4F, 0x43, 0x58
}, "Code Lock"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -14,7 +14,11 @@ namespace BurnOutSharp.ProtectionType
var matchers = new List<Matcher>
{
// Tom Commander
new Matcher(new byte?[] { 0x54, 0x6F, 0x6D, 0x20, 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x65, 0x72 }, "CopyKiller"),
new Matcher(new byte?[]
{
0x54, 0x6F, 0x6D, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
0x61, 0x6E, 0x64, 0x65, 0x72
}, "CopyKiller"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -8,15 +10,20 @@ namespace BurnOutSharp.ProtectionType
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
// "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.FirstPosition(check, out int position))
return $"DVD-Cops {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty);
var matchers = new List<Matcher>
{
// DVD-Cops, ver.
new Matcher(new byte?[]
{
0x44, 0x56, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73,
0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20
}, GetVersion, "DVD-Cops"),
};
return null;
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);
}
private static string GetVersion(byte[] fileContent, int position)
public static string GetVersion(string file, byte[] fileContent, int position)
{
char[] version = new ArraySegment<byte>(fileContent, position + 15, 4).Select(b => (char)b).ToArray();
if (version[0] == 0x00)

View File

@@ -1,4 +1,7 @@
namespace BurnOutSharp.ProtectionType
using System.Collections.Generic;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
public class ElectronicArts : IContentCheck
{
@@ -9,57 +12,101 @@
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
// EASTL
// byte?[] check = new byte?[] { 0x45, 0x41, 0x53, 0x54, 0x4C };
// if (fileContent.Contains(check, out int position))
// return "Cucko (EA Custom)" + (includePosition ? $" (Index {position})" : string.Empty);
var matchers = new List<Matcher>
{
// EASTL
//new Matcher(new byte?[] { 0x45, 0x41, 0x53, 0x54, 0x4C }, "Cucko (EA Custom)"),
// 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.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
new Matcher(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
}, Utilities.GetFileVersion, "EA CdKey Registration Module"),
// 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.FirstPosition(check, out 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
new Matcher(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
}, Utilities.GetFileVersion, "EA CdKey Registration Module"),
// 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.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.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
new Matcher(new byte?[]
{
0x41, 0x00, 0x62, 0x00, 0x6F, 0x00, 0x75, 0x00,
0x74, 0x00, 0x20, 0x00, 0x43, 0x00, 0x44, 0x00,
0x4B, 0x00, 0x65, 0x00, 0x79, 0x00
}, Utilities.GetFileVersion, "EA CdKey Registration Module"),
// 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.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.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
new Matcher(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
}, Utilities.GetFileVersion, "EA CdKey Registration Module"),
// 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.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
new Matcher(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
}, Utilities.GetFileVersion, "EA CdKey Registration Module"),
// 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.FirstPosition(check, out position))
return "EA DRM Protection" + (includePosition ? $" (Index {position})" : string.Empty);
// EReg Config Form
new Matcher(new byte?[]
{
0x45, 0x52, 0x65, 0x67, 0x20, 0x43, 0x6F, 0x6E,
0x66, 0x69, 0x67, 0x20, 0x46, 0x6F, 0x72, 0x6D
}, Utilities.GetFileVersion, "EA CdKey Registration Module"),
// 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.FirstPosition(check, out position))
return "EA DRM Protection" + (includePosition ? $" (Index {position})" : string.Empty);
// ereg.ea-europe.com
new Matcher(new byte?[]
{
0x65, 0x72, 0x65, 0x67, 0x2E, 0x65, 0x61, 0x2D,
0x65, 0x75, 0x72, 0x6F, 0x70, 0x65, 0x2E, 0x63,
0x6F, 0x6D
}, Utilities.GetFileVersion, "EA CdKey Registration Module"),
return null;
// GenericEA + (char)0x00 + (char)0x00 + (char)0x00 + Activation
new Matcher(new byte?[]
{
0x47, 0x65, 0x6E, 0x65, 0x72, 0x69, 0x63, 0x45,
0x41, 0x00, 0x00, 0x00, 0x41, 0x63, 0x74, 0x69,
0x76, 0x61, 0x74, 0x69, 0x6F, 0x6E
}, "EA DRM Protection"),
// 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
new Matcher(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
}, "EA DRM Protection"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);
}
}
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
namespace BurnOutSharp.ProtectionType
{
// TODO: Figure out how to use GetContentMatches here
public class ImpulseReactor : IContentCheck, IPathCheck
{
/// <inheritdoc/>

View File

@@ -3,6 +3,7 @@ using System.Linq;
namespace BurnOutSharp.ProtectionType
{
// TODO: Figure out how to use GetContentMatches here
public class JoWooDXProt : IContentCheck
{
/// <inheritdoc/>

View File

@@ -11,7 +11,11 @@ namespace BurnOutSharp.ProtectionType
var matchers = new List<Matcher>
{
// KEY-LOCK COMMAND
new Matcher(new byte?[] { 0x4B, 0x45, 0x59, 0x2D, 0x4C, 0x4F, 0x43, 0x4B, 0x20, 0x43, 0x4F, 0x4D, 0x4D, 0x41, 0x4E, 0x44 }, "Key-Lock (Dongle)"),
new Matcher(new byte?[]
{
0x4B, 0x45, 0x59, 0x2D, 0x4C, 0x4F, 0x43, 0x4B,
0x20, 0x43, 0x4F, 0x4D, 0x4D, 0x41, 0x4E, 0x44
}, "Key-Lock (Dongle)"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -5,6 +5,7 @@ using System.Linq;
namespace BurnOutSharp.ProtectionType
{
// TODO: Figure out how to use GetContentMatches here
public class LaserLock : IContentCheck, IPathCheck
{
/// <inheritdoc/>

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -10,17 +11,20 @@ namespace BurnOutSharp.ProtectionType
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
// Cd3Ctl
byte?[] check = new byte?[] { 0x43, 0x64, 0x33, 0x43, 0x74, 0x6C };
if (fileContent.FirstPosition(check, out int position))
return "MediaMax CD-3" + (includePosition ? $" (Index {position})" : string.Empty);
var matchers = new List<Matcher>
{
// Cd3Ctl
new Matcher(new byte?[] { 0x43, 0x64, 0x33, 0x43, 0x74, 0x6C }, "MediaMax CD-3"),
// DllInstallSbcp
check = new byte?[] { 0x44, 0x6C, 0x6C, 0x49, 0x6E, 0x73, 0x74, 0x61, 0x6C, 0x6C, 0x53, 0x62, 0x63, 0x70 };
if (fileContent.FirstPosition(check, out position))
return "MediaMax CD-3" + (includePosition ? $" (Index {position})" : string.Empty);
// DllInstallSbcp
new Matcher(new byte?[]
{
0x44, 0x6C, 0x6C, 0x49, 0x6E, 0x73, 0x74, 0x61,
0x6C, 0x6C, 0x53, 0x62, 0x63, 0x70
}, "MediaMax CD-3"),
};
return null;
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);
}
/// <inheritdoc/>

View File

@@ -1,16 +1,27 @@
namespace BurnOutSharp.ProtectionType
using System.Collections.Generic;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
public class OnlineRegistration : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
// 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.FirstPosition(check, out int position))
return $"Executable-Based Online Registration {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty);
var matchers = new List<Matcher>
{
// 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
new Matcher(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
}, Utilities.GetFileVersion, "Executable-Based Online Registration"),
};
return null;
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);
}
}
}

View File

@@ -13,10 +13,33 @@ namespace BurnOutSharp.ProtectionType
var matchers = new List<Matcher>
{
// SOFTWARE TERMINATED\nCONSOLE MAY HAVE BEEN MODIFIED\n CALL 1-888-780-7690
new Matcher(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 }, "PlayStation Anti-modchip (English)"),
new Matcher(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
}, "PlayStation Anti-modchip (English)"),
// 強制終了しました。\n本体が改造されている\nおそれがあります。
new Matcher(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 }, "PlayStation Anti-modchip (Japanese)"),
new Matcher(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
}, "PlayStation Anti-modchip (Japanese)"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -6,6 +6,7 @@ using System.Threading;
namespace BurnOutSharp.ProtectionType
{
// TODO: Figure out how to use GetContentMatches here
public class ProtectDisc : IContentCheck
{
/// <inheritdoc/>

View File

@@ -12,7 +12,11 @@ namespace BurnOutSharp.ProtectionType
var matchers = new List<Matcher>
{
// (char)0x00 + Allocator + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00
new Matcher(new byte?[] { 0x00, 0x41, 0x6C, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x6F, 0x72, 0x00, 0x00, 0x00, 0x00 }, "Ring PROTECH [Check disc for physical ring]"),
new Matcher(new byte?[]
{
0x00, 0x41, 0x6C, 0x6C, 0x6F, 0x63, 0x61, 0x74,
0x6F, 0x72, 0x00, 0x00, 0x00, 0x00
}, "Ring PROTECH [Check disc for physical ring]"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -7,6 +7,7 @@ using System.Text;
namespace BurnOutSharp.ProtectionType
{
// TODO: Figure out how to use GetContentMatches here
public class SafeDisc : IContentCheck, IPathCheck
{
/// <inheritdoc/>

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -10,12 +11,13 @@ namespace BurnOutSharp.ProtectionType
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
// "SafeLock"
byte?[] check = new byte?[] { 0x53, 0x61, 0x66, 0x65, 0x4C, 0x6F, 0x63, 0x6B };
if (fileContent.FirstPosition(check, out int position))
return "SafeLock" + (includePosition ? $" (Index {position})" : string.Empty);
var matchers = new List<Matcher>
{
// SafeLock
new Matcher(new byte?[] { 0x53, 0x61, 0x66, 0x65, 0x4C, 0x6F, 0x63, 0x6B }, "SafeLock"),
};
return null;
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);
}
/// <inheritdoc/>

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -11,42 +12,41 @@ namespace BurnOutSharp.ProtectionType
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
// "AddD" + (char)0x03 + (char)0x00 + (char)0x00 + (char)0x00)
byte?[] check = new byte?[] { 0x41, 0x64, 0x64, 0x44, 0x03, 0x00, 0x00, 0x00 };
if (fileContent.FirstPosition(check, out int position))
return $"SecuROM {GetV4Version(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty);
var matchers = new List<Matcher>
{
// AddD + (char)0x03 + (char)0x00 + (char)0x00 + (char)0x00)
new Matcher(new byte?[] { 0x41, 0x64, 0x64, 0x44, 0x03, 0x00, 0x00, 0x00 }, GetV4Version, "SecuROM"),
// (char)0xCA + (char)0xDD + (char)0xDD + (char)0xAC + (char)0x03
check = new byte?[] { 0xCA, 0xDD, 0xDD, 0xAC, 0x03 };
if (fileContent.FirstPosition(check, out position))
return $"SecuROM {GetV5Version(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty);
// (char)0xCA + (char)0xDD + (char)0xDD + (char)0xAC + (char)0x03
new Matcher(new byte?[] { 0xCA, 0xDD, 0xDD, 0xAC, 0x03 }, GetV5Version, "SecuROM"),
// ".securom" + (char)0xE0 + (char)0xC0
check = new byte?[] { 0x2E, 0x73, 0x65, 0x63, 0x75, 0x72, 0x6F, 0x6D, 0xE0, 0xC0 };
if (fileContent.FirstPosition(check, out position) && position == 0)
return $"SecuROM {GetV7Version(fileContent)}" + (includePosition ? $" (Index {position})" : string.Empty);
// .securom + (char)0xE0 + (char)0xC0
new Matcher(new byte?[]
{
0x2E, 0x73, 0x65, 0x63, 0x75, 0x72, 0x6F, 0x6D,
0xE0, 0xC0
}, GetV7Version, "SecuROM"),
// ".securom"
check = new byte?[] { 0x2E, 0x73, 0x65, 0x63, 0x75, 0x72, 0x6F, 0x6D };
if (fileContent.FirstPosition(check, out position))
return $"SecuROM {GetV7Version(fileContent)}" + (includePosition ? $" (Index {position})" : string.Empty);
// .securom
new Matcher(new byte?[] { 0x2E, 0x73, 0x65, 0x63, 0x75, 0x72, 0x6F, 0x6D }, GetV7Version, "SecuROM"),
// "_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.FirstPosition(check, out position))
return $"SecuROM Product Activation {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty);
// _and_play.dll + (char)0x00 + drm_pagui_doit
new Matcher(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
}, Utilities.GetFileVersion, "SecuROM Product Activation"),
// ".cms_t" + (char)0x00
check = new byte?[] { 0x2E, 0x63, 0x6D, 0x73, 0x5F, 0x74, 0x00 };
if (fileContent.FirstPosition(check, out position))
return "SecuROM 1-3" + (includePosition ? $" (Index {position})" : string.Empty);
// .cms_t + (char)0x00
new Matcher(new byte?[] { 0x2E, 0x63, 0x6D, 0x73, 0x5F, 0x74, 0x00 }, "SecuROM 1-3"),
// ".cms_d" + (char)0x00
check = new byte?[] { 0x2E, 0x63, 0x6D, 0x73, 0x5F, 0x64, 0x00 };
if (fileContent.FirstPosition(check, out position))
return "SecuROM 1-3" + (includePosition ? $" (Index {position})" : string.Empty);
// .cms_d + (char)0x00
new Matcher(new byte?[] { 0x2E, 0x63, 0x6D, 0x73, 0x5F, 0x64, 0x00 }, "SecuROM 1-3"),
};
return null;
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);
}
/// <inheritdoc/>
@@ -92,7 +92,7 @@ namespace BurnOutSharp.ProtectionType
return null;
}
private static string GetV4Version(byte[] fileContent, int position)
public static string GetV4Version(string file, byte[] fileContent, int position)
{
int index = position + 8; // Begin reading after "AddD"
char version = (char)fileContent[index];
@@ -112,7 +112,7 @@ namespace BurnOutSharp.ProtectionType
return $"{version}.{subVersion}.{subSubVersion}.{subSubSubVersion}";
}
private static string GetV5Version(byte[] fileContent, int position)
public static string GetV5Version(string file, byte[] fileContent, int position)
{
int index = position + 8; // Begin reading after "ÊÝݬ"
byte version = (byte)(fileContent[index] & 0x0F);
@@ -145,7 +145,7 @@ namespace BurnOutSharp.ProtectionType
return $"{version}.{subVersion[0]}{subVersion[1]}.{subSubVersion[0]}{subSubVersion[1]}.{subSubSubVersion[0]}{subSubSubVersion[1]}{subSubSubVersion[2]}{subSubSubVersion[3]}";
}
private static string GetV7Version(byte[] fileContent)
public static string GetV7Version(string file, byte[] fileContent, int position)
{
int index = 236;
byte[] bytes = new ReadOnlySpan<byte>(fileContent, index, 4).ToArray();

View File

@@ -6,6 +6,7 @@ using System.Linq;
namespace BurnOutSharp.ProtectionType
{
// TODO: Figure out how to use GetContentMatches here
public class SolidShield : IContentCheck, IPathCheck
{
/// <inheritdoc/>

View File

@@ -5,6 +5,7 @@ using System.Linq;
namespace BurnOutSharp.ProtectionType
{
// TODO: Figure out how to use GetContentMatches here
public class StarForce : IContentCheck, IPathCheck
{
/// <inheritdoc/>

View File

@@ -1,24 +1,34 @@
namespace BurnOutSharp.ProtectionType
using System.Collections.Generic;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
public class Sysiphus : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
// "V SUHPISYSDVD"
byte?[] check = new byte?[] { 0x56, 0x20, 0x53, 0x55, 0x48, 0x50, 0x49, 0x53, 0x59, 0x53, 0x44, 0x56, 0x44 };
if (fileContent.FirstPosition(check, out int position))
return $"Sysiphus DVD {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty);
var matchers = new List<Matcher>
{
// V SUHPISYSDVD
new Matcher(new byte?[]
{
0x56, 0x20, 0x53, 0x55, 0x48, 0x50, 0x49, 0x53,
0x59, 0x53, 0x44, 0x56, 0x44
}, GetVersion, "Sysiphus DVD"),
// "V SUHPISYS"
check = new byte?[] { 0x56, 0x20, 0x53, 0x55, 0x48, 0x50, 0x49, 0x53, 0x59, 0x53 };
if (fileContent.FirstPosition(check, out position))
return $"Sysiphus {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty);
// V SUHPISYSDVD
new Matcher(new byte?[]
{
0x56, 0x20, 0x53, 0x55, 0x48, 0x50, 0x49, 0x53,
0x59, 0x53
}, GetVersion, "Sysiphus"),
};
return null;
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);
}
private static string GetVersion(byte[] fileContent, int position)
public static string GetVersion(string file, byte[] fileContent, int position)
{
int index = position - 3;
char subVersion = (char)fileContent[index];

View File

@@ -5,6 +5,7 @@ using System.Linq;
namespace BurnOutSharp.ProtectionType
{
// TODO: Figure out how to use GetContentMatches here
public class Tages : IContentCheck, IPathCheck
{
/// <inheritdoc/>

View File

@@ -1,27 +1,34 @@
namespace BurnOutSharp.ProtectionType
using System.Collections.Generic;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
public class ThreePLock : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
// .ldr
byte?[] check = new byte?[] { 0x2E, 0x6C, 0x64, 0x72 };
if (fileContent.FirstPosition(check, out int position))
var matchers = new List<Matcher>
{
// .ldt
byte?[] check2 = new byte?[] { 0x2E, 0x6C, 0x64, 0x74 };
if (fileContent.FirstPosition(check2, out int position2))
return "3PLock" + (includePosition ? $" (Index {position}, {position2})" : string.Empty);
}
new Matcher(new List<byte?[]>
{
// .ldr
new byte?[] { 0x2E, 0x6C, 0x64, 0x72 },
// This produced false positives in some DirectX 9.0c installer files
// "Y" + (char)0xC3 + "U" + (char)0x8B + (char)0xEC + (char)0x83 + (char)0xEC + "0SVW"
//check = new byte?[] { 0x59, 0xC3, 0x55, 0x8B, 0xEC, 0x83, 0xEC, 0x30, 0x53, 0x56, 0x57 };
//if (fileContent.Contains(check, out position))
// return "3PLock" + (includePosition ? $" (Index {position})" : string.Empty);
// .ldt
new byte?[] { 0x2E, 0x6C, 0x64, 0x74 },
}, "3PLock"),
return null;
// This produced false positives in some DirectX 9.0c installer files
// "Y" + (char)0xC3 + "U" + (char)0x8B + (char)0xEC + (char)0x83 + (char)0xEC + "0SVW"
// new Matcher(new byte?[]
// {
// 0x59, 0xC3, 0x55, 0x8B, 0xEC, 0x83, 0xEC, 0x30,
// 0x53, 0x56, 0x57
// }, "3PLock"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);
}
}
}

View File

@@ -11,7 +11,15 @@ namespace BurnOutSharp.ProtectionType
var matchers = new List<Matcher>
{
// 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
new Matcher(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 }, "321Studios Online Activation"),
new Matcher(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
}, "321Studios Online Activation"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -7,6 +7,7 @@ using System.Threading;
namespace BurnOutSharp.ProtectionType
{
// TODO: Figure out how to use GetContentMatches here
public class VOBProtectCDDVD : IContentCheck, IPathCheck
{
/// <inheritdoc/>

View File

@@ -18,10 +18,18 @@ namespace BurnOutSharp.ProtectionType
new Matcher(new byte?[] { 0x58, 0x43, 0x50, 0x2E, 0x44, 0x41, 0x54 }, "XCP"),
// XCPPlugins.dll
new Matcher(new byte?[] { 0x58, 0x43, 0x50, 0x50, 0x6C, 0x75, 0x67, 0x69, 0x6E, 0x73, 0x2E, 0x64, 0x6C, 0x6C }, "XCP"),
new Matcher(new byte?[]
{
0x58, 0x43, 0x50, 0x50, 0x6C, 0x75, 0x67, 0x69,
0x6E, 0x73, 0x2E, 0x64, 0x6C, 0x6C
}, "XCP"),
// XCPPhoenix.dll
new Matcher(new byte?[] { 0x58, 0x43, 0x50, 0x50, 0x68, 0x6F, 0x65, 0x6E, 0x69, 0x78, 0x2E, 0x64, 0x6C, 0x6C }, "XCP"),
new Matcher(new byte?[]
{
0x58, 0x43, 0x50, 0x50, 0x68, 0x6F, 0x65, 0x6E,
0x69, 0x78, 0x2E, 0x64, 0x6C, 0x6C
}, "XCP"),
};
return Utilities.GetContentMatches(file, fileContent, matchers, includePosition);

View File

@@ -321,6 +321,18 @@ namespace BurnOutSharp
return fvinfo.ProductVersion.Replace(", ", ".");
}
/// <summary>
/// Wrapper for GetFileVersion for use in matching
/// </summary>
/// <param name="file">File to check for version</param>
/// <param name="fileContent">Byte array representing the file contents</param>
/// <param name="position">Last matched position in the contents</param>
/// <returns>Version string, null on error</returns>
public static string GetFileVersion(string file, byte[] fileContent, int position)
{
return GetFileVersion(file);
}
/// <summary>
/// Get the assembly version as determined by an embedded assembly manifest
/// </summary>