mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-02-11 21:29:18 +00:00
51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.IO;
|
|
using BurnOutSharp.Interfaces;
|
|
using static BurnOutSharp.Utilities.Dictionary;
|
|
|
|
namespace BurnOutSharp.FileType
|
|
{
|
|
/// <summary>
|
|
/// StarForce Filesystem file
|
|
/// </summary>
|
|
/// <see href="https://forum.xentax.com/viewtopic.php?f=21&t=2084"/>
|
|
public class SFFS : IScannable
|
|
{
|
|
/// <inheritdoc/>
|
|
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, string file)
|
|
{
|
|
if (!File.Exists(file))
|
|
return null;
|
|
|
|
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
|
|
{
|
|
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);
|
|
|
|
if (Tools.Utilities.GetFileType(magic) == SupportedFileType.SFFS)
|
|
{
|
|
AppendToDictionary(protections, file, "StarForce Filesystem Container");
|
|
return protections;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (scanner.IncludeDebug) Console.WriteLine(ex);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|