Files
BinaryObjectScanner/BinaryObjectScanner/Packer/SetupFactory.cs

62 lines
2.3 KiB
C#
Raw Normal View History

using System;
using BinaryObjectScanner.Interfaces;
2023-09-16 02:04:47 -04:00
using SabreTools.Serialization.Wrappers;
2023-03-09 23:52:58 -05:00
namespace BinaryObjectScanner.Packer
{
2022-05-01 21:02:59 -07:00
// TODO: Add extraction, which is possible but the only tools available that can
// do this seem to be Universal Extractor 2 and InstallExplorer (https://totalcmd.net/plugring/InstallExplorer.html)
2022-07-13 12:53:08 -07:00
// https://raw.githubusercontent.com/wolfram77web/app-peid/master/userdb.txt
2024-11-04 23:21:12 -05:00
public class SetupFactory : IExecutableCheck<PortableExecutable>, IExtractableExecutable<PortableExecutable>
{
/// <inheritdoc/>
2024-11-04 23:21:12 -05:00
public string? CheckExecutable(string file, PortableExecutable pex, bool includeDebug)
{
2021-08-30 14:18:15 -07:00
// Get the sections from the executable, if possible
2023-09-17 22:37:01 -04:00
var sections = pex.Model.SectionTable;
2021-08-30 14:18:15 -07:00
if (sections == null)
return null;
// Known to detect versions 7.0.5.1 - 9.1.0.0
2023-09-17 22:37:01 -04:00
var name = pex.LegalCopyright;
if (name?.StartsWith("Setup Engine", StringComparison.OrdinalIgnoreCase) == true)
return $"Setup Factory {GetVersion(pex)}";
2021-08-30 14:18:15 -07:00
2022-04-02 16:12:23 -07:00
name = pex.ProductName;
if (name?.StartsWith("Setup Factory", StringComparison.OrdinalIgnoreCase) == true)
return $"Setup Factory {GetVersion(pex)}";
2021-08-30 14:18:15 -07:00
// Known to detect version 5.0.1 - 6.0.1.3
2022-04-02 16:12:23 -07:00
name = pex.FileDescription;
if (name?.StartsWith("Setup Factory", StringComparison.OrdinalIgnoreCase) == true)
return $"Setup Factory {GetVersion(pex)}";
// Longer version of the check that can be used if false positves become an issue:
// "Setup Factory is a trademark of Indigo Rose Corporation"
2021-08-30 14:18:15 -07:00
return null;
}
/// <inheritdoc/>
public bool Extract(string file, PortableExecutable pex, string outDir, bool includeDebug)
{
return false;
}
private string GetVersion(PortableExecutable pex)
2021-03-21 15:24:23 -07:00
{
2022-04-01 10:16:31 -07:00
// Check the product version explicitly
2023-09-17 22:37:01 -04:00
var version = pex.ProductVersion;
2021-03-21 15:24:23 -07:00
if (!string.IsNullOrEmpty(version))
2023-11-14 16:10:10 -05:00
return version!;
2022-04-01 10:16:31 -07:00
// Check the internal versions
version = pex.GetInternalVersion();
if (!string.IsNullOrEmpty(version))
2023-11-14 16:10:10 -05:00
return version!;
2021-03-22 16:25:40 -07:00
return "(Unknown Version)";
2021-03-21 15:24:23 -07:00
}
}
}