Make field offset reading use TryMapVATR to reduce exceptions
This commit is contained in:
@@ -203,19 +203,21 @@ namespace Il2CppInspector
|
|||||||
for (var i = 0; i < TypeDefinitions.Length; i++) {
|
for (var i = 0; i < TypeDefinitions.Length; i++) {
|
||||||
var def = TypeDefinitions[i];
|
var def = TypeDefinitions[i];
|
||||||
var pFieldOffsets = Binary.FieldOffsetPointers[i];
|
var pFieldOffsets = Binary.FieldOffsetPointers[i];
|
||||||
if (pFieldOffsets != 0) {
|
if (pFieldOffsets != 0)
|
||||||
bool available = true;
|
{
|
||||||
|
|
||||||
// If the target address range is not mapped in the file, assume zeroes
|
// If the target address range is not mapped in the file, assume zeroes
|
||||||
try {
|
if (BinaryImage.TryMapVATR((ulong)pFieldOffsets, out var fieldOffsetPosition))
|
||||||
BinaryImage.Position = BinaryImage.MapVATR((ulong) pFieldOffsets);
|
{
|
||||||
|
BinaryImage.Position = fieldOffsetPosition;
|
||||||
|
var fieldOffsets = BinaryImage.ReadArray<uint>(def.FieldCount);
|
||||||
|
for (var fieldIndex = 0; fieldIndex < def.FieldCount; fieldIndex++)
|
||||||
|
offsets.Add(def.FieldIndex + fieldIndex, fieldOffsets[fieldIndex]);
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException) {
|
else
|
||||||
available = false;
|
{
|
||||||
|
for (var fieldIndex = 0; fieldIndex < def.FieldCount; fieldIndex++)
|
||||||
|
offsets.Add(def.FieldIndex + fieldIndex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var f = 0; f < def.FieldCount; f++)
|
|
||||||
offsets.Add(def.FieldIndex + f, available? BinaryImage.ReadUInt32() : 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user