Files
BinaryObjectScanner/BurnOutSharp/PackerType/AutoPlayMediaStudio.cs

71 lines
2.4 KiB
C#
Raw Normal View History

using System;
using System.Collections.Concurrent;
using System.IO;
2022-05-01 17:41:50 -07:00
using BurnOutSharp.Interfaces;
using BurnOutSharp.Wrappers;
namespace BurnOutSharp.PackerType
{
// Created by IndigoRose (creators of Setup Factory), primarily to be used to create autorun menus for various media.
// Official website: https://www.autoplay.org/
2022-05-01 21:02:59 -07:00
// TODO: Add extraction
2022-05-01 17:17:15 -07:00
public class AutoPlayMediaStudio : IPortableExecutableCheck, IScannable
{
/// <inheritdoc/>
2022-05-01 17:17:15 -07:00
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
if (sections == null)
return null;
// Known to detect versions 5.0.0.3 - 8.1.0.0
2022-04-02 16:12:23 -07:00
string name = pex.ProductName;
if (name?.StartsWith("AutoPlay Media Studio", StringComparison.OrdinalIgnoreCase) == true)
return $"AutoPlay Media Studio {GetVersion(pex)}";
// Currently too vague, may be re-enabled in the future
/*
name = Utilities.GetLegalCopyright(pex);
if (name?.StartsWith("Runtime Engine", StringComparison.OrdinalIgnoreCase) == true)
return $"AutoPlay Media Studio {GetVersion(pex)}";
*/
return null;
}
/// <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))
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, Stream stream, string file)
{
return null;
}
private string GetVersion(PortableExecutable pex)
{
// Check the product version explicitly
2022-04-02 16:12:23 -07:00
string version = pex.ProductVersion;
if (!string.IsNullOrEmpty(version))
return version;
// Check the internal versions
2022-12-15 00:13:24 -08:00
version = Tools.Utilities.GetInternalVersion(pex);
if (!string.IsNullOrEmpty(version))
return version;
return "(Unknown Version)";
}
}
}