Files
BinaryObjectScanner/BurnOutSharp/ProtectionType/SmartE.cs

50 lines
1.8 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2021-04-01 11:20:13 -07:00
using System.IO;
2021-03-21 15:34:19 -07:00
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
2021-02-26 01:26:49 -08:00
public class SmartE : IContentCheck, IPathCheck
{
/// <summary>
/// Set of all ContentMatchSets for this protection
/// </summary>
2021-03-23 16:43:23 -07:00
private static readonly List<ContentMatchSet> contentMatchers = new List<ContentMatchSet>
{
// BITARTS
new ContentMatchSet(new byte?[] { 0x42, 0x49, 0x54, 0x41, 0x52, 0x54, 0x53 }, "SmartE"),
};
2021-02-26 01:26:49 -08:00
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
return MatchUtil.GetFirstMatch(file, fileContent, contentMatchers, includePosition);
}
2021-02-26 00:32:09 -08:00
/// <inheritdoc/>
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
2021-03-19 15:41:49 -07:00
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
{
2021-04-01 11:20:13 -07:00
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}00001.TMP", useEndsWith: true), "SmartE"),
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}00002.TMP", useEndsWith: true), "SmartE"),
};
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>
{
2021-04-01 11:20:13 -07:00
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}00001.TMP", useEndsWith: true), "SmartE"),
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}00002.TMP", useEndsWith: true), "SmartE"),
};
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}