Correctly handle valid virtual addresses not mapped to the image file

This commit is contained in:
Katy Coe
2019-10-16 18:30:30 +02:00
parent 38e04b72b7
commit 41d6b45f3b
4 changed files with 17 additions and 7 deletions

View File

@@ -46,9 +46,16 @@ namespace Il2CppInspector.Reflection
// Per-module method pointer array uses the bottom 24 bits of the method's metadata token
// Derived from il2cpp::vm::MetadataCache::GetMethodPointer
else {
var method = (Definition.token & 0xffffff) - 1;
pkg.BinaryImage.Position = pkg.BinaryImage.MapVATR(Assembly.Module.methodPointers + method * 4);
VirtualAddress = pkg.BinaryImage.ReadUInt32();
var method = (Definition.token & 0xffffff);
if (method != 0) {
// In the event of an exception, the method pointer is not set in the file
// This probably means it has been optimized away by the compiler, or is an unused generic method
try {
pkg.BinaryImage.Position =
pkg.BinaryImage.MapVATR(Assembly.Module.methodPointers + (method - 1) * 4);
VirtualAddress = pkg.BinaryImage.ReadUInt32();
} catch (Exception) { }
}
}
// Remove ARM Thumb marker LSB if necessary