Skip to content

Commit

Permalink
BUGFIX: Set offset/rva of r2r sections
Browse files Browse the repository at this point in the history
  • Loading branch information
Washi1337 committed Jan 4, 2025
1 parent ffcaf54 commit 490176a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,35 @@ public IReadyToRunSection ReadSection(PEReaderContext context, ReadyToRunSection
{
return type switch
{
CompilerIdentifier => new CompilerIdentifierSection(reader.ReadAsciiString()),
CompilerIdentifier => ReadCompilerIdentifierSection(ref reader),
ImportSections => new SerializedImportSectionsSection(context, ref reader),
RuntimeFunctions when context.File.FileHeader.Machine == MachineType.Amd64 => new SerializedX64RuntimeFunctionsSection(context, ref reader),
MethodDefEntryPoints => new SerializedMethodEntryPointsSection(ref reader),
ReadyToRunSectionType.DebugInfo => new SerializedDebugInfoSection(context, reader),
_ => new CustomReadyToRunSection(type, reader.ReadSegment(reader.Length))
_ => ReadUnsupportedReadyToRunSection(ref reader)
};

CompilerIdentifierSection ReadCompilerIdentifierSection(ref BinaryStreamReader reader)
{
ulong offset = reader.Offset;
uint rva = reader.Rva;

var section = new CompilerIdentifierSection(reader.ReadAsciiString());
section.UpdateOffsets(new RelocationParameters(offset, rva));

return section;
}

CustomReadyToRunSection ReadUnsupportedReadyToRunSection(ref BinaryStreamReader reader)
{
ulong offset = reader.Offset;
uint rva = reader.Rva;

var section = new CustomReadyToRunSection(type, reader.ReadSegment(reader.Length));
section.UpdateOffsets(new RelocationParameters(offset, rva));

return section;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public class SerializedDebugInfoSection : DebugInfoSection
/// <param name="reader">The input stream.</param>
public SerializedDebugInfoSection(PEReaderContext context, BinaryStreamReader reader)
{
Offset = reader.Offset;
Rva = reader.Rva;

_context = context;
_reader = reader;
}
Expand Down

0 comments on commit 490176a

Please sign in to comment.