2022-04-02 21:36:29 -07:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Collections.Concurrent;
|
2021-07-18 09:44:23 -07:00
|
|
|
|
using System.Collections.Generic;
|
2022-05-01 17:41:50 -07:00
|
|
|
|
using BurnOutSharp.Interfaces;
|
2021-03-21 22:19:38 -07:00
|
|
|
|
using BurnOutSharp.Matching;
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
|
|
|
|
|
namespace BurnOutSharp.ProtectionType
|
|
|
|
|
|
{
|
2021-11-21 21:18:56 -08:00
|
|
|
|
// https://www.cdrinfo.pl/cdr/porady/safelock/safelock.php3
|
2021-11-24 21:59:54 -08:00
|
|
|
|
// Notes for possible future content checks:
|
|
|
|
|
|
// - Protected files (that haven't been renamed) will contain a couple of strings at the end:
|
|
|
|
|
|
// + SafeLock.dat
|
|
|
|
|
|
// + Proszê w³o¿yæ p³ytê CD do CDROM-u
|
|
|
|
|
|
// + Proszê w³o¿yæ oryginaln¹ p³ytê CD do CDROM-u
|
|
|
|
|
|
// - Also at the end is an ASCII number possibly indicating version:
|
|
|
|
|
|
// + 0.99.15 uses "3144288522"
|
|
|
|
|
|
// + 0.99.22 uses "1614884465"
|
|
|
|
|
|
// + 1.0.4 uses "3574069264"
|
|
|
|
|
|
// - All of the above is at the very end of the file
|
|
|
|
|
|
// - All auxiliary files (like .001, .128, and .dat) seem to be encrypted or padding data
|
2021-11-21 21:18:56 -08:00
|
|
|
|
public class SafeLock : IPathCheck
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-02-26 00:32:09 -08:00
|
|
|
|
/// <inheritdoc/>
|
2021-07-18 09:44:23 -07:00
|
|
|
|
public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string> files)
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-11-21 21:18:56 -08:00
|
|
|
|
// Technically all need to exist but some might be renamed
|
2021-03-23 10:36:14 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2022-04-02 21:36:29 -07:00
|
|
|
|
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}SafeLock.DAT", useEndsWith: true), "SafeLock"),
|
2021-03-23 10:36:14 -07:00
|
|
|
|
new PathMatchSet(new PathMatch("SafeLock.001", useEndsWith: true), "SafeLock"),
|
2021-11-21 21:18:56 -08:00
|
|
|
|
new PathMatchSet(new PathMatch("SafeLock.002", useEndsWith: true), "SafeLock"),
|
2021-03-23 10:36:14 -07:00
|
|
|
|
new PathMatchSet(new PathMatch("SafeLock.128", useEndsWith: true), "SafeLock"),
|
2021-11-21 21:18:56 -08:00
|
|
|
|
new PathMatchSet(new PathMatch("SafeLock.256", useEndsWith: true), "SafeLock"),
|
2021-03-23 10:36:14 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
2021-03-23 13:35:12 -07:00
|
|
|
|
return MatchUtil.GetAllMatches(files, matchers, any: true);
|
2021-03-19 15:41:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public string CheckFilePath(string path)
|
|
|
|
|
|
{
|
2021-03-23 10:36:14 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2022-04-02 21:36:29 -07:00
|
|
|
|
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}SafeLock.DAT", useEndsWith: true), "SafeLock"),
|
2021-03-23 10:36:14 -07:00
|
|
|
|
new PathMatchSet(new PathMatch("SafeLock.001", useEndsWith: true), "SafeLock"),
|
2021-11-21 21:18:56 -08:00
|
|
|
|
new PathMatchSet(new PathMatch("SafeLock.002", useEndsWith: true), "SafeLock"),
|
2021-03-23 10:36:14 -07:00
|
|
|
|
new PathMatchSet(new PathMatch("SafeLock.128", useEndsWith: true), "SafeLock"),
|
2021-11-21 21:18:56 -08:00
|
|
|
|
new PathMatchSet(new PathMatch("SafeLock.256", useEndsWith: true), "SafeLock"),
|
2021-03-23 10:36:14 -07:00
|
|
|
|
};
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
2021-03-23 10:36:14 -07:00
|
|
|
|
return MatchUtil.GetFirstMatch(path, matchers, any: true);
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|