2022-12-13 12:42:55 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using BurnOutSharp.Interfaces;
|
2022-12-15 00:13:24 -08:00
|
|
|
|
using static BurnOutSharp.Utilities.Dictionary;
|
2022-12-13 12:42:55 -07:00
|
|
|
|
|
|
|
|
|
|
namespace BurnOutSharp.FileType
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// StarForce Filesystem file
|
|
|
|
|
|
/// </summary>
|
2022-12-14 22:15:43 -08:00
|
|
|
|
/// <see href="https://forum.xentax.com/viewtopic.php?f=21&t=2084"/>
|
2022-12-13 12:42:55 -07:00
|
|
|
|
public class SFFS : IScannable
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, string file)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!File.Exists(file))
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
2022-12-22 22:03:32 -08:00
|
|
|
|
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
|
2022-12-13 12:42:55 -07:00
|
|
|
|
{
|
|
|
|
|
|
return Scan(scanner, fs, file);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, Stream stream, string file)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protections = new ConcurrentDictionary<string, ConcurrentQueue<string>>();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] magic = new byte[16];
|
|
|
|
|
|
stream.Read(magic, 0, 16);
|
|
|
|
|
|
|
2022-12-15 00:13:24 -08:00
|
|
|
|
if (Tools.Utilities.GetFileType(magic) == SupportedFileType.SFFS)
|
2022-12-13 12:42:55 -07:00
|
|
|
|
{
|
2022-12-15 00:13:24 -08:00
|
|
|
|
AppendToDictionary(protections, file, "StarForce Filesystem Container");
|
2022-12-13 12:42:55 -07:00
|
|
|
|
return protections;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (scanner.IncludeDebug) Console.WriteLine(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|