Skip to content

Commit a281e83

Browse files
Initial ISO Protection Detection (#389)
* Initial * Laserlock in * This is a better way to read the string * That array copy wasn't needed either * Use static filetype method, rename filetype.iso * Initial Codelok ISO scanning * Comments with redump IDs * Add redump examples to laserlock * Change for testing * Small comment * TAGES * halfway through safedisc * Safedisc done * Fix 1 * Major oversights in puredata fixed * Finish SecuROM * ProtectDiSC done * Alpharom done * Finish StarForce, initial PR review ready * Wait, that would be really bad * One more for the road. * Small finding * Small fix for finding * Notes on finding * Several minor fixes, decisions * what do you MEAN it returns true if there are no elements in the array * Future todo * Update packages * Rebase * Fix runisochecks * First round of fixes * Second round of fixes * Tests attempt 1 * Make checks work * Individual test attempt 1 * Final tests --------- Co-authored-by: Matt Nadareski <mnadareski@outlook.com>
1 parent 9f5b292 commit a281e83

File tree

22 files changed

+925
-9
lines changed

22 files changed

+925
-9
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.IO;
2+
using BinaryObjectScanner.FileType;
3+
using Xunit;
4+
5+
namespace BinaryObjectScanner.Test.FileType
6+
{
7+
public class DiskImageTests
8+
{
9+
private static readonly SabreTools.Serialization.Wrappers.ISO9660 wrapper
10+
= new(new SabreTools.Data.Models.ISO9660.Volume(), new MemoryStream(new byte[1024]));
11+
12+
[Fact]
13+
public void DetectFile_EmptyString_Null()
14+
{
15+
string file = string.Empty;
16+
var detectable = new ISO9660(wrapper);
17+
18+
string? actual = detectable.Detect(file, includeDebug: false);
19+
Assert.Null(actual);
20+
}
21+
22+
[Fact]
23+
public void DetectStream_EmptyStream_Empty()
24+
{
25+
Stream? stream = new MemoryStream();
26+
string file = string.Empty;
27+
var detectable = new ISO9660(wrapper);
28+
29+
string? actual = detectable.Detect(stream, file, includeDebug: false);
30+
Assert.NotNull(actual);
31+
Assert.Empty(actual);
32+
}
33+
}
34+
}

BinaryObjectScanner.Test/Protection/AlphaROMTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,18 @@ public void CheckPortableExecutableTest()
1818
string? actual = checker.CheckExecutable(file, exe, includeDebug: false);
1919
Assert.Null(actual);
2020
}
21+
22+
[Fact]
23+
public void CheckDiskImageTest()
24+
{
25+
string file = "filename";
26+
SabreTools.Data.Models.ISO9660.Volume model = new();
27+
Stream source = new MemoryStream(new byte[1024]);
28+
SabreTools.Serialization.Wrappers.ISO9660 iso = new(model, source);
29+
30+
var checker = new AlphaROM();
31+
string? actual = checker.CheckDiskImage(file, iso, includeDebug: false);
32+
Assert.Null(actual);
33+
}
2134
}
2235
}

BinaryObjectScanner.Test/Protection/CopyLokTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,18 @@ public void CheckPortableExecutableTest()
1818
string? actual = checker.CheckExecutable(file, exe, includeDebug: false);
1919
Assert.Null(actual);
2020
}
21+
22+
[Fact]
23+
public void CheckDiskImageTest()
24+
{
25+
string file = "filename";
26+
SabreTools.Data.Models.ISO9660.Volume model = new();
27+
Stream source = new MemoryStream(new byte[1024]);
28+
SabreTools.Serialization.Wrappers.ISO9660 iso = new(model, source);
29+
30+
var checker = new CopyLok();
31+
string? actual = checker.CheckDiskImage(file, iso, includeDebug: false);
32+
Assert.Null(actual);
33+
}
2134
}
2235
}

BinaryObjectScanner.Test/Protection/LaserLokTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,18 @@ public void CheckFilePathTest()
4040
string? actual = checker.CheckFilePath(path);
4141
Assert.Null(actual);
4242
}
43+
44+
[Fact]
45+
public void CheckDiskImageTest()
46+
{
47+
string file = "filename";
48+
SabreTools.Data.Models.ISO9660.Volume model = new();
49+
Stream source = new MemoryStream(new byte[1024]);
50+
SabreTools.Serialization.Wrappers.ISO9660 iso = new(model, source);
51+
52+
var checker = new LaserLok();
53+
string? actual = checker.CheckDiskImage(file, iso, includeDebug: false);
54+
Assert.Null(actual);
55+
}
4356
}
4457
}

BinaryObjectScanner.Test/Protection/MacrovisionTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,18 @@ public void CheckFilePathTest()
5353
string? actual = checker.CheckFilePath(path);
5454
Assert.Null(actual);
5555
}
56+
57+
[Fact]
58+
public void CheckDiskImageTest()
59+
{
60+
string file = "filename";
61+
SabreTools.Data.Models.ISO9660.Volume model = new();
62+
Stream source = new MemoryStream(new byte[1024]);
63+
SabreTools.Serialization.Wrappers.ISO9660 iso = new(model, source);
64+
65+
var checker = new Macrovision();
66+
string? actual = checker.CheckDiskImage(file, iso, includeDebug: false);
67+
Assert.Null(actual);
68+
}
5669
}
5770
}

BinaryObjectScanner.Test/Protection/ProtectDiscTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,18 @@ public void CheckFilePathTest()
4040
string? actual = checker.CheckFilePath(path);
4141
Assert.Null(actual);
4242
}
43+
44+
[Fact]
45+
public void CheckDiskImageTest()
46+
{
47+
string file = "filename";
48+
SabreTools.Data.Models.ISO9660.Volume model = new();
49+
Stream source = new MemoryStream(new byte[1024]);
50+
SabreTools.Serialization.Wrappers.ISO9660 iso = new(model, source);
51+
52+
var checker = new ProtectDISC();
53+
string? actual = checker.CheckDiskImage(file, iso, includeDebug: false);
54+
Assert.Null(actual);
55+
}
4356
}
4457
}

BinaryObjectScanner.Test/Protection/SecuROMTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,18 @@ public void CheckFilePathTest()
4040
string? actual = checker.CheckFilePath(path);
4141
Assert.Null(actual);
4242
}
43+
44+
[Fact]
45+
public void CheckDiskImageTest()
46+
{
47+
string file = "filename";
48+
SabreTools.Data.Models.ISO9660.Volume model = new();
49+
Stream source = new MemoryStream(new byte[1024]);
50+
SabreTools.Serialization.Wrappers.ISO9660 iso = new(model, source);
51+
52+
var checker = new SecuROM();
53+
string? actual = checker.CheckDiskImage(file, iso, includeDebug: false);
54+
Assert.Null(actual);
55+
}
4356
}
4457
}

BinaryObjectScanner.Test/Protection/StarForceTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,18 @@ public void CheckFilePathTest()
4040
string? actual = checker.CheckFilePath(path);
4141
Assert.Null(actual);
4242
}
43+
44+
[Fact]
45+
public void CheckDiskImageTest()
46+
{
47+
string file = "filename";
48+
SabreTools.Data.Models.ISO9660.Volume model = new();
49+
Stream source = new MemoryStream(new byte[1024]);
50+
SabreTools.Serialization.Wrappers.ISO9660 iso = new(model, source);
51+
52+
var checker = new StarForce();
53+
string? actual = checker.CheckDiskImage(file, iso, includeDebug: false);
54+
Assert.Null(actual);
55+
}
4356
}
4457
}

BinaryObjectScanner.Test/Protection/TAGESTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,18 @@ public void CheckFilePathTest()
4040
string? actual = checker.CheckFilePath(path);
4141
Assert.Null(actual);
4242
}
43+
44+
[Fact]
45+
public void CheckDiskImageTest()
46+
{
47+
string file = "filename";
48+
SabreTools.Data.Models.ISO9660.Volume model = new();
49+
Stream source = new MemoryStream(new byte[1024]);
50+
SabreTools.Serialization.Wrappers.ISO9660 iso = new(model, source);
51+
52+
var checker = new TAGES();
53+
string? actual = checker.CheckDiskImage(file, iso, includeDebug: false);
54+
Assert.Null(actual);
55+
}
4356
}
4457
}

BinaryObjectScanner/Data/StaticChecks.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ public static IContentCheck[] ContentCheckClasses
2222
}
2323
}
2424

25+
/// <summary>
26+
/// Cache for all IISOCheck<ISO> types
27+
/// </summary>
28+
public static IDiskImageCheck<ISO9660>[] ISO9660CheckClasses
29+
{
30+
get
31+
{
32+
iso9660CheckClasses ??= InitCheckClasses<IDiskImageCheck<ISO9660>>();
33+
return iso9660CheckClasses;
34+
}
35+
}
36+
2537
/// <summary>
2638
/// Cache for all IExecutableCheck<LinearExecutable> types
2739
/// </summary>
@@ -91,6 +103,12 @@ public static IExecutableCheck<PortableExecutable>[] PortableExecutableCheckClas
91103
/// </summary>
92104
private static IContentCheck[]? contentCheckClasses;
93105

106+
107+
/// <summary>
108+
/// Cache for all IISOCheck<ISO9660> types
109+
/// </summary>
110+
private static IDiskImageCheck<ISO9660>[]? iso9660CheckClasses;
111+
94112
/// <summary>
95113
/// Cache for all IExecutableCheck<LinearExecutable> types
96114
/// </summary>

0 commit comments

Comments
 (0)