2021-03-21 22:45:06 -07:00
|
|
|
using System.Collections.Generic;
|
2022-05-01 21:02:59 -07:00
|
|
|
using System.IO;
|
2022-12-09 12:35:58 -08:00
|
|
|
using System.Linq;
|
2023-03-09 11:52:28 -05:00
|
|
|
using BinaryObjectScanner.Interfaces;
|
2023-09-16 02:04:47 -04:00
|
|
|
using SabreTools.Serialization.Wrappers;
|
2021-03-21 23:36:01 -06:00
|
|
|
|
2023-03-09 23:52:58 -05:00
|
|
|
namespace BinaryObjectScanner.Packer
|
2021-03-21 23:36:01 -06:00
|
|
|
{
|
2022-05-01 21:02:59 -07:00
|
|
|
// TODO: Add extraction
|
|
|
|
|
// TODO: Verify that all versions are detected
|
2023-03-09 16:02:51 -05:00
|
|
|
public class AdvancedInstaller : IExtractable, IPortableExecutableCheck
|
2021-03-21 23:36:01 -06:00
|
|
|
{
|
2021-08-26 21:57:56 -07:00
|
|
|
/// <inheritdoc/>
|
2022-05-01 17:17:15 -07:00
|
|
|
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
2021-03-23 09:52:09 -07:00
|
|
|
{
|
2021-08-26 21:57:56 -07:00
|
|
|
// Get the sections from the executable, if possible
|
2023-09-15 22:21:05 -04:00
|
|
|
var sections = pex?.Model.SectionTable;
|
2021-08-26 21:57:56 -07:00
|
|
|
if (sections == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2022-12-09 12:35:58 -08:00
|
|
|
// Get the .rdata section strings, if they exist
|
|
|
|
|
List<string> strs = pex.GetFirstSectionStrings(".rdata");
|
|
|
|
|
if (strs != null)
|
2021-07-17 23:40:16 -07:00
|
|
|
{
|
2022-12-09 12:35:58 -08:00
|
|
|
if (strs.Any(s => s.Contains("Software\\Caphyon\\Advanced Installer")))
|
|
|
|
|
return "Caphyon Advanced Installer";
|
2021-08-26 21:57:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-05-01 21:02:59 -07:00
|
|
|
|
2023-03-09 15:46:48 -05:00
|
|
|
/// <inheritdoc/>
|
2023-09-17 00:18:04 -04:00
|
|
|
#if NET48
|
2023-03-09 17:16:39 -05:00
|
|
|
public string Extract(string file, bool includeDebug)
|
2023-09-17 00:18:04 -04:00
|
|
|
#else
|
|
|
|
|
public string? Extract(string file, bool includeDebug)
|
|
|
|
|
#endif
|
2023-03-09 15:46:48 -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:46:48 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2023-09-17 00:18:04 -04:00
|
|
|
#if NET48
|
2023-03-09 17:16:39 -05:00
|
|
|
public string Extract(Stream stream, string file, bool includeDebug)
|
2023-09-17 00:18:04 -04:00
|
|
|
#else
|
|
|
|
|
public string? Extract(Stream stream, string file, bool includeDebug)
|
|
|
|
|
#endif
|
2023-03-09 15:46:48 -05:00
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-03-21 23:36:01 -06:00
|
|
|
}
|
|
|
|
|
}
|