Skip to content

Commit

Permalink
Support EOF data in debug data entries.
Browse files Browse the repository at this point in the history
  • Loading branch information
DaZombieKiller committed Sep 22, 2024
1 parent f70da79 commit 4a2b36f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/AsmResolver.PE/Debug/SerializedDebugDataEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,22 @@ public SerializedDebugDataEntry(
/// <inheritdoc />
protected override IDebugDataSegment? GetContents()
{
if (_sizeOfData == 0)
return null;
BinaryStreamReader reader;

var reference = _context.File.GetReferenceToRva(_addressOfRawData);
if (!reference.CanRead)
if (_addressOfRawData == 0 || _context.File.MappingMode == File.PEMappingMode.Unmapped)
{
if (!_context.File.TryCreateReaderAtFileOffset(_pointerToRawData, out reader))
{
_context.BadImage("Debug data entry contains an invalid file offset.");
return null;
}
}
else if (!_context.File.TryCreateReaderAtRva(_addressOfRawData, out reader))
{
_context.BadImage("Debug data entry contains an invalid RVA.");
return null;
}

var reader = reference.CreateReader();
if (_sizeOfData > reader.Length)
{
_context.BadImage("Debug data entry contains a too large size.");
Expand Down

0 comments on commit 4a2b36f

Please sign in to comment.