mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-02-09 21:32:11 +00:00
* Add support for PlayJ * Add support for detecting PlayJ format audio files and PlayJ Music Player related files. * Add an incomplete summary for Cactus Data Shield. * Improve Cactus Data Shield Detection for CDS-200 (PlayJ). * Address PlayJ PR comments Fix whitespace and improve safety of PlayJ header check. * Address further PlayJ PR comments Reduce redundancy and further improve safety.
58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using BurnOutSharp.Interfaces;
|
|
using BurnOutSharp.Tools;
|
|
|
|
namespace BurnOutSharp.FileType
|
|
{
|
|
public class PLJ : IScannable
|
|
{
|
|
/// <inheritdoc/>
|
|
public bool ShouldScan(byte[] magic)
|
|
{
|
|
// https://www.iana.org/assignments/media-types/audio/vnd.everad.plj
|
|
if (magic.StartsWith(new byte?[] { 0xFF, 0x9D, 0x53, 0x4B }))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, string file)
|
|
{
|
|
if (!File.Exists(file))
|
|
return null;
|
|
|
|
using (var fs = File.OpenRead(file))
|
|
{
|
|
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 (ShouldScan(magic))
|
|
{
|
|
Utilities.AppendToDictionary(protections, file, "PlayJ Audio File");
|
|
return protections;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (scanner.IncludeDebug) Console.WriteLine(ex);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|