Make InnoSetup like WiseInstaller

This commit is contained in:
Matt Nadareski
2021-02-26 09:32:41 -08:00
parent f4310206e9
commit 52eef84374
2 changed files with 40 additions and 8 deletions

View File

@@ -154,11 +154,6 @@ namespace BurnOutSharp.FileType
if (!string.IsNullOrWhiteSpace(protection))
Utilities.AppendToDictionary(protections, file, protection);
// Inno Setup
protection = new InnoSetup().CheckContents(file, fileContent, scanner.IncludePosition);
if (!string.IsNullOrWhiteSpace(protection))
Utilities.AppendToDictionary(protections, file, protection);
// INTENIUM Trial & Buy Protection
protection = new Intenium().CheckContents(file, fileContent, scanner.IncludePosition);
if (!string.IsNullOrWhiteSpace(protection))
@@ -271,6 +266,14 @@ namespace BurnOutSharp.FileType
// If we're looking for archives too, run scans
if (scanner.ScanArchives)
{
// Inno Setup
if (file != null && !string.IsNullOrEmpty(new InnoSetup().CheckContents(file, fileContent, scanner.IncludePosition)))
{
var subProtections = new InnoSetup().Scan(scanner, null, file);
Utilities.PrependToKeys(subProtections, file);
Utilities.AppendToDictionary(protections, subProtections);
}
// Wise Installer
if (file != null && !string.IsNullOrEmpty(new WiseInstaller().CheckContents(file, fileContent, scanner.IncludePosition)))
{
@@ -302,6 +305,11 @@ namespace BurnOutSharp.FileType
if (!string.IsNullOrWhiteSpace(protection))
Utilities.AppendToDictionary(protections, file, protection);
// Inno Setup
protection = new InnoSetup().CheckContents(file, fileContent, scanner.IncludePosition);
if (!string.IsNullOrWhiteSpace(protection))
Utilities.AppendToDictionary(protections, file, protection);
// NSIS
protection = new NSIS().CheckContents(file, fileContent, scanner.IncludePosition);
if (!string.IsNullOrWhiteSpace(protection))

View File

@@ -1,12 +1,16 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class InnoSetup : IContentCheck
public class InnoSetup : IContentCheck, IScannable
{
// TOOO: Add Inno Setup extraction
// https://github.com/dscharrer/InnoExtract
/// <inheritdoc/>
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
@@ -18,6 +22,26 @@ namespace BurnOutSharp.ProtectionType
return null;
}
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.OpenRead(file))
{
return Scan(scanner, fs, file);
}
}
// TOOO: Add Inno Setup extraction
// https://github.com/dscharrer/InnoExtract
/// <inheritdoc/>
public Dictionary<string, List<string>> Scan(Scanner scanner, Stream stream, string file)
{
return null;
}
private static string GetVersion(byte[] fileContent)
{
byte[] signature = new ArraySegment<byte>(fileContent, 0x30, 12).ToArray();