Implement mapping from file offset to virtual address (all file formats)

This commit is contained in:
Katy Coe
2020-07-27 21:10:59 +02:00
parent 8b2c254235
commit 613747fc9a
6 changed files with 71 additions and 11 deletions

View File

@@ -27,6 +27,11 @@ namespace Il2CppInspector
var section = sections.First(x => uiAddr >= x.Address && uiAddr <= x.Address + x.Size);
return (uint) uiAddr - (section.Address - section.ImageOffset);
}
public override ulong MapFileOffsetToVA(uint offset) {
var section = sections.First(x => offset >= x.ImageOffset && offset < x.ImageOffset + x.Size);
return section.Address + offset - section.ImageOffset;
}
}
internal class MachOReader64 : MachOReader<ulong, MachOReader64, Convert64>
@@ -44,6 +49,11 @@ namespace Il2CppInspector
var section = sections.First(x => uiAddr >= x.Address && uiAddr <= x.Address + x.Size);
return (uint) (uiAddr - (section.Address - section.ImageOffset));
}
public override ulong MapFileOffsetToVA(uint offset) {
var section = sections.First(x => offset >= x.ImageOffset && offset < x.ImageOffset + x.Size);
return section.Address + offset - section.ImageOffset;
}
}
// We need this convoluted generic TReader declaration so that "static T FileFormatReader.Load(Stream)"