2022-04-02 00:23:32 -06:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
2023-03-09 11:52:28 -05:00
|
|
|
|
using BinaryObjectScanner.Interfaces;
|
2023-03-07 16:59:14 -05:00
|
|
|
|
using BinaryObjectScanner.Wrappers;
|
2022-04-02 00:23:32 -06:00
|
|
|
|
|
2023-03-09 23:52:58 -05:00
|
|
|
|
namespace BinaryObjectScanner.Packer
|
2022-04-02 00:23:32 -06:00
|
|
|
|
{
|
|
|
|
|
|
// 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
|
2023-03-09 16:02:51 -05:00
|
|
|
|
public class AutoPlayMediaStudio : IExtractable, IPortableExecutableCheck
|
2022-04-02 00:23:32 -06:00
|
|
|
|
{
|
|
|
|
|
|
/// <inheritdoc/>
|
2022-05-01 17:17:15 -07:00
|
|
|
|
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
2022-04-02 00:23:32 -06:00
|
|
|
|
{
|
|
|
|
|
|
// 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;
|
2022-08-21 20:34:59 -07:00
|
|
|
|
if (name?.StartsWith("AutoPlay Media Studio", StringComparison.OrdinalIgnoreCase) == true)
|
2022-04-02 00:23:32 -06:00
|
|
|
|
return $"AutoPlay Media Studio {GetVersion(pex)}";
|
|
|
|
|
|
|
|
|
|
|
|
// Currently too vague, may be re-enabled in the future
|
|
|
|
|
|
/*
|
|
|
|
|
|
name = Utilities.GetLegalCopyright(pex);
|
2022-08-21 20:34:59 -07:00
|
|
|
|
if (name?.StartsWith("Runtime Engine", StringComparison.OrdinalIgnoreCase) == true)
|
2022-04-02 00:23:32 -06:00
|
|
|
|
return $"AutoPlay Media Studio {GetVersion(pex)}";
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-09 15:33:21 -05:00
|
|
|
|
/// <inheritdoc/>
|
2023-03-09 17:16:39 -05:00
|
|
|
|
public string Extract(string file, bool includeDebug)
|
2023-03-09 15:33:21 -05:00
|
|
|
|
{
|
|
|
|
|
|
if (!File.Exists(file))
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
|
|
|
|
|
|
{
|
2023-03-09 17:16:39 -05:00
|
|
|
|
return Extract(fs, file, includeDebug);
|
2023-03-09 15:33:21 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2023-03-09 17:16:39 -05:00
|
|
|
|
public string Extract(Stream stream, string file, bool includeDebug)
|
2023-03-09 15:33:21 -05:00
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2022-04-02 00:23:32 -06:00
|
|
|
|
|
|
|
|
|
|
private string GetVersion(PortableExecutable pex)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Check the product version explicitly
|
2022-04-02 16:12:23 -07:00
|
|
|
|
string version = pex.ProductVersion;
|
2022-04-02 00:23:32 -06:00
|
|
|
|
if (!string.IsNullOrEmpty(version))
|
|
|
|
|
|
return version;
|
|
|
|
|
|
|
|
|
|
|
|
// Check the internal versions
|
2023-03-09 23:19:27 -05:00
|
|
|
|
version = pex.GetInternalVersion();
|
2022-04-02 00:23:32 -06:00
|
|
|
|
if (!string.IsNullOrEmpty(version))
|
|
|
|
|
|
return version;
|
|
|
|
|
|
|
|
|
|
|
|
return "(Unknown Version)";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|