FileFormatReader: Add TryMapVATR
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2017-2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
|
Copyright 2017-2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
@@ -34,6 +34,7 @@ namespace Il2CppInspector
|
|||||||
U[] ReadMappedArray<U>(ulong uiAddr, int count) where U : new();
|
U[] ReadMappedArray<U>(ulong uiAddr, int count) where U : new();
|
||||||
long[] ReadMappedWordArray(ulong uiAddr, int count);
|
long[] ReadMappedWordArray(ulong uiAddr, int count);
|
||||||
uint MapVATR(ulong uiAddr);
|
uint MapVATR(ulong uiAddr);
|
||||||
|
bool TryMapVATR(ulong uiAddr, out uint fileOffset);
|
||||||
|
|
||||||
byte[] ReadBytes(int count);
|
byte[] ReadBytes(int count);
|
||||||
ulong ReadUInt64();
|
ulong ReadUInt64();
|
||||||
@@ -147,6 +148,17 @@ namespace Il2CppInspector
|
|||||||
// No mapping by default
|
// No mapping by default
|
||||||
public virtual uint MapVATR(ulong uiAddr) => (uint) uiAddr;
|
public virtual uint MapVATR(ulong uiAddr) => (uint) uiAddr;
|
||||||
|
|
||||||
|
// Try to map an RVA to an offset in the file image
|
||||||
|
public bool TryMapVATR(ulong uiAddr, out uint fileOffset) {
|
||||||
|
try {
|
||||||
|
fileOffset = MapVATR(uiAddr);
|
||||||
|
return true;
|
||||||
|
} catch (InvalidOperationException) {
|
||||||
|
fileOffset = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Read a file format dependent word (32 or 64 bits)
|
// 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
|
// The primitive mappings in Bin2Object will automatically read a uint if the file is 32-bit
|
||||||
public long ReadWord() => ReadObject<long>();
|
public long ReadWord() => ReadObject<long>();
|
||||||
|
|||||||
Reference in New Issue
Block a user