Use SourceArray for NE checks

This commit is contained in:
Matt Nadareski
2022-03-14 22:43:26 -07:00
parent 0fa6673d21
commit 3820546c07
6 changed files with 10 additions and 11 deletions

View File

@@ -146,7 +146,7 @@ namespace BurnOutSharp.FileType
bool foundProtection = false;
// Check using custom content checks first
string protection = contentCheckClass.CheckNEContents(file, fileContent, scanner.IncludeDebug, nex);
string protection = contentCheckClass.CheckNEContents(file, scanner.IncludeDebug, nex);
foundProtection |= !string.IsNullOrWhiteSpace(protection);
if (ShouldAddProtection(contentCheckClass, scanner, protection))
Utilities.AppendToDictionary(protections, file, protection);

View File

@@ -9,10 +9,9 @@ namespace BurnOutSharp
/// Check a path for protections based on file contents
/// </summary>
/// <param name="file">File to check for protection indicators</param>
/// <param name="fileContent">Byte array representing the file contents</param>
/// <param name="includeDebug">True to include debug data, false otherwise</param>
/// <param name="nex">NewExecutable representing the read-in file</param>
/// <returns>String containing any protections found in the file</returns>
string CheckNEContents(string file, byte[] fileContent, bool includeDebug, NewExecutable nex);
string CheckNEContents(string file, bool includeDebug, NewExecutable nex);
}
}

View File

@@ -16,7 +16,7 @@ namespace BurnOutSharp.PackerType
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
public string CheckNEContents(string file, byte[] fileContent, bool includeDebug, NewExecutable nex)
public string CheckNEContents(string file, bool includeDebug, NewExecutable nex)
{
// Get the DOS stub from the executable, if possible
var stub = nex?.DOSStubHeader;
@@ -26,7 +26,7 @@ namespace BurnOutSharp.PackerType
// Check for "Inno" in the reserved words
if (stub.Reserved2[4] == 0x6E49 && stub.Reserved2[5] == 0x6F6E)
{
string version = GetOldVersion(file, fileContent);
string version = GetOldVersion(file, nex.SourceArray);
if (!string.IsNullOrWhiteSpace(version))
return $"Inno Setup {version}";

View File

@@ -18,7 +18,7 @@ namespace BurnOutSharp.PackerType
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
public string CheckNEContents(string file, byte[] fileContent, bool includeDebug, NewExecutable nex)
public string CheckNEContents(string file, bool includeDebug, NewExecutable nex)
{
// Get the DOS stub from the executable, if possible
var stub = nex?.DOSStubHeader;
@@ -29,7 +29,7 @@ namespace BurnOutSharp.PackerType
if (!string.IsNullOrWhiteSpace(version))
return $"WinZip SFX {version}";
version = GetNEUnknownHeaderVersion(nex, file, fileContent, includeDebug);
version = GetNEUnknownHeaderVersion(nex, file, nex.SourceArray, includeDebug);
if (!string.IsNullOrWhiteSpace(version))
return $"WinZip SFX {version}";

View File

@@ -16,7 +16,7 @@ namespace BurnOutSharp.PackerType
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
public string CheckNEContents(string file, byte[] fileContent, bool includeDebug, NewExecutable nex)
public string CheckNEContents(string file, bool includeDebug, NewExecutable nex)
{
// Get the DOS stub from the executable, if possible
var stub = nex?.DOSStubHeader;
@@ -31,7 +31,7 @@ namespace BurnOutSharp.PackerType
new ContentMatchSet(new byte?[] { 0x57, 0x69, 0x73, 0x65, 0x4D, 0x61, 0x69, 0x6E }, "Wise Installation Wizard Module"),
};
return MatchUtil.GetFirstMatch(file, fileContent, neMatchSets, includeDebug);
return MatchUtil.GetFirstMatch(file, nex.SourceArray, neMatchSets, includeDebug);
}
/// <inheritdoc/>

View File

@@ -41,7 +41,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckNEContents(string file, byte[] fileContent, bool includeDebug, NewExecutable nex)
public string CheckNEContents(string file, bool includeDebug, NewExecutable nex)
{
// Get the DOS stub from the executable, if possible
var stub = nex?.DOSStubHeader;
@@ -63,7 +63,7 @@ namespace BurnOutSharp.ProtectionType
}, GetVersion, "CD-Cops"),
};
return MatchUtil.GetFirstMatch(file, fileContent, neMatchSets, includeDebug);
return MatchUtil.GetFirstMatch(file, nex.SourceArray, neMatchSets, includeDebug);
}
/// <inheritdoc/>