Files
BinaryObjectScanner/BinaryObjectScanner/FileType/MSDOS.cs

49 lines
1.6 KiB
C#
Raw Normal View History

2025-09-06 09:53:34 -04:00
using System.Collections.Generic;
using System.IO;
using BinaryObjectScanner.Data;
2026-01-27 09:30:58 -05:00
#pragma warning disable IDE0290 // Use primary constructor
2025-09-06 09:53:34 -04:00
namespace BinaryObjectScanner.FileType
{
/// <summary>
/// MS-DOS executable (MZ)
/// </summary>
public class MSDOS : Executable<SabreTools.Serialization.Wrappers.MSDOS>
{
2025-09-06 10:40:26 -04:00
/// <inheritdoc/>
public MSDOS(SabreTools.Serialization.Wrappers.MSDOS wrapper) : base(wrapper) { }
2025-09-06 10:40:26 -04:00
2025-09-06 09:53:34 -04:00
/// <inheritdoc/>
public override string? Detect(Stream stream, string file, bool includeDebug)
{
// Create the output dictionary
var protections = new ProtectionDictionary();
// Only use generic content checks if we're in debug mode
if (includeDebug)
{
var contentProtections = RunContentChecks(file, stream, includeDebug);
protections.Append(file, contentProtections.Values);
}
// Standard checks
var subProtections
2025-11-06 13:43:49 -05:00
= RunExecutableChecks(file, StaticChecks.MSDOSExecutableCheckClasses, includeDebug);
2025-09-06 09:53:34 -04:00
protections.Append(file, subProtections.Values);
// If there are no protections
if (protections.Count == 0)
return null;
// Create the internal list
var protectionList = new List<string>();
foreach (string key in protections.Keys)
{
protectionList.AddRange(protections[key]);
}
return string.Join(";", [.. protectionList]);
}
}
}