Fix crash in SolidShield scanning (fixes #76)

This commit is contained in:
Matt Nadareski
2022-02-10 10:37:57 -08:00
parent 56f009ac56
commit d9d84a01e5
2 changed files with 11 additions and 2 deletions

View File

@@ -343,7 +343,16 @@ namespace BurnOutSharp.ExecutableType.Microsoft
int startingIndex = (int)Math.Max(section.PointerToRawData + offset, 0);
int readLength = (int)Math.Min(section.VirtualSize - offset, content.Length);
return content.ReadBytes(ref startingIndex, readLength);
try
{
return content.ReadBytes(ref startingIndex, readLength);
}
catch
{
// Just absorb errors for now
// TODO: Investigate why and when this would be hit
return null;
}
}
#endregion

View File

@@ -75,7 +75,7 @@ namespace BurnOutSharp.ProtectionType
// Search the last two available sections
var sectionNames = pex.GetSectionNames();
for (int i = sectionNames.Length - 2; i < sectionNames.Length; i++)
for (int i = (sectionNames.Length >= 2 ? sectionNames.Length - 2 : 0); i < sectionNames.Length; i++)
{
var nthSectionRaw = pex.ReadRawSection(fileContent, sectionNames[i], first: false);
if (nthSectionRaw != null)