Files
BinaryObjectScanner/BurnOutSharp/ProtectionType/SafeLock.cs

55 lines
2.5 KiB
C#
Raw Normal View History

2022-04-02 21:36:29 -07:00
using System.IO;
using System.Collections.Concurrent;
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;
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
{
2021-02-26 00:32:09 -08:00
/// <inheritdoc/>
public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
2021-11-21 21:18:56 -08:00
// Technically all need to exist but some might be renamed
var matchers = new List<PathMatchSet>
{
2022-04-02 21:36:29 -07:00
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}SafeLock.DAT", useEndsWith: true), "SafeLock"),
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"),
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"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
2021-03-19 15:41:49 -07:00
}
/// <inheritdoc/>
public string CheckFilePath(string path)
{
var matchers = new List<PathMatchSet>
{
2022-04-02 21:36:29 -07:00
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}SafeLock.DAT", useEndsWith: true), "SafeLock"),
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"),
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"),
};
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}