Implement mapping from file offset to virtual address (all file formats)
This commit is contained in:
@@ -35,6 +35,8 @@ namespace Il2CppInspector
|
||||
long[] ReadMappedWordArray(ulong uiAddr, int count);
|
||||
uint MapVATR(ulong uiAddr);
|
||||
bool TryMapVATR(ulong uiAddr, out uint fileOffset);
|
||||
ulong MapFileOffsetToVA(uint offset);
|
||||
bool TryMapFileOffsetToVA(uint offset, out ulong va);
|
||||
|
||||
byte[] ReadBytes(int count);
|
||||
ulong ReadUInt64();
|
||||
@@ -159,6 +161,22 @@ namespace Il2CppInspector
|
||||
}
|
||||
}
|
||||
|
||||
// Map an offset into the file image to an RVA
|
||||
// No mapping by default
|
||||
public virtual ulong MapFileOffsetToVA(uint offset) => offset;
|
||||
|
||||
// Try to map an offset into the file image to an RVA
|
||||
public bool TryMapFileOffsetToVA(uint offset, out ulong va) {
|
||||
try {
|
||||
va = MapFileOffsetToVA(offset);
|
||||
return true;
|
||||
}
|
||||
catch (InvalidOperationException) {
|
||||
va = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Read a file format dependent word (32 or 64 bits)
|
||||
// The primitive mappings in Bin2Object will automatically read a uint if the file is 32-bit
|
||||
public long ReadWord() => ReadObject<long>();
|
||||
|
||||
Reference in New Issue
Block a user