Files
BinaryObjectScanner/BinaryObjectScanner/Protection/FreeLock.cs

85 lines
3.5 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using BinaryObjectScanner.Interfaces;
2023-09-16 22:08:18 -04:00
using SabreTools.Matching;
2024-10-03 12:01:08 -04:00
using SabreTools.Matching.Paths;
namespace BinaryObjectScanner.Protection
{
/// <summary>
/// Freelock is software intended to allow users to burn a copy protected PSX CD-R.
/// It adds multiple garbage tracks to the end of the disc and creates intentional errors on the disc by attempting to burn a corrupted file.
/// <see href="https://github.com/TheRogueArchivist/DRML/blob/main/entries/Freelock/Freelock.md"/>
/// </summary>
public class Freelock : IPathCheck
{
// TODO: Add an MS-DOS executable check for "FREELOCK.EXE".
2021-02-26 00:32:09 -08:00
/// <inheritdoc/>
2024-11-20 17:10:03 -05:00
public List<string> CheckDirectoryPath(string path, List<string>? files)
{
2021-03-22 23:02:01 -07:00
var matchers = new List<PathMatchSet>
{
// The disk image that every version of Freelock is distributed through.
2023-11-22 13:28:13 -05:00
new(new FilePathMatch("FREELOCK.IMG"), "Freelock Disk Image"),
// Found in every "FREELOCK.IMG".
2023-11-22 13:28:13 -05:00
new(new FilePathMatch("FREELOCK.EXE"), "Freelock"),
new(new FilePathMatch("FREELOCK.TXT"), "Freelock"),
// Found in "FREELOCK.IMG" from Freelock 1.0-1.2.
2023-11-22 13:28:13 -05:00
new(new FilePathMatch("FREELOCK"), "Freelock 1.0-1.2"),
// Found in "FREELOCK.IMG" from Freelock 1.2+.
2023-11-22 13:28:13 -05:00
new(new FilePathMatch("GENLOCK.EXE"), "Freelock 1.2+"),
new(new FilePathMatch("freelock.ico"), "Freelock 1.2+"),
new(new FilePathMatch("freelock.pif"), "Freelock 1.2+"),
// Created by "GENLOCK.EXE" in Freelock 1.2+.
2023-11-22 13:28:13 -05:00
new(new FilePathMatch("FREELOCK.DAT"), "Freelock 1.2+"),
// Found in "FREELOCK.IMG" From Freelock 1.3.
2023-11-22 13:28:13 -05:00
new(new FilePathMatch("FREELOCK.13"), "Freelock 1.3"),
// Found in "FREELOCK.IMG" From Freelock 1.3.
2024-10-31 22:42:20 -04:00
new(
[
2023-11-22 13:28:13 -05:00
new FilePathMatch("FREELOCK.13"),
new FilePathMatch("FL.DAT"),
2024-10-31 22:42:20 -04:00
], "Freelock 1.3"),
2021-03-22 23:02:01 -07:00
};
2023-11-14 16:10:10 -05:00
return MatchUtil.GetAllMatches(files, matchers, any: false);
2021-03-19 15:41:49 -07:00
}
/// <inheritdoc/>
2023-09-17 22:37:01 -04:00
public string? CheckFilePath(string path)
2021-03-19 15:41:49 -07:00
{
2021-03-22 23:02:01 -07:00
var matchers = new List<PathMatchSet>
{
// The disk image that every version of Freelock is distributed through.
2023-11-22 13:28:13 -05:00
new(new FilePathMatch("FREELOCK.IMG"), "Freelock Disk Image"),
// Found in every "FREELOCK.IMG".
2023-11-22 13:28:13 -05:00
new(new FilePathMatch("FREELOCK.EXE"), "Freelock"),
new(new FilePathMatch("FREELOCK.TXT"), "Freelock"),
// Found in "FREELOCK.IMG" from Freelock 1.0-1.2.
2023-11-22 13:28:13 -05:00
new(new FilePathMatch("FREELOCK"), "Freelock 1.0-1.2"),
// Found in "FREELOCK.IMG" from Freelock 1.2+.
2023-11-22 13:28:13 -05:00
new(new FilePathMatch("GENLOCK.EXE"), "Freelock 1.2+"),
new(new FilePathMatch("freelock.ico"), "Freelock 1.2+"),
new(new FilePathMatch("freelock.pif"), "Freelock 1.2+"),
// Created by "GENLOCK.EXE" in Freelock 1.2+.
2023-11-22 13:28:13 -05:00
new(new FilePathMatch("FREELOCK.DAT"), "Freelock 1.2+"),
// Found in "FREELOCK.IMG" From Freelock 1.3.
2023-11-22 13:28:13 -05:00
new(new FilePathMatch("FREELOCK.13"), "Freelock 1.3"),
2021-03-22 23:02:01 -07:00
};
2021-03-22 23:02:01 -07:00
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}