Add ReadMappedObjectPointerArray

This commit is contained in:
Katy Coe
2019-10-16 16:30:49 +02:00
parent d49a066424
commit a638e86c38

View File

@@ -32,6 +32,7 @@ namespace Il2CppInspector
ushort ReadUInt16();
byte ReadByte();
string ReadMappedNullTerminatedString(uint uiAddr);
List<U> ReadMappedObjectPointerArray<U>(uint uiAddr, int count) where U : new();
}
internal class FileFormatReader<T> : BinaryObjectReader, IFileFormatReader where T : FileFormatReader<T>
@@ -96,6 +97,15 @@ namespace Il2CppInspector
return ReadNullTerminatedString(MapVATR(uiAddr));
}
// Reads a list of pointers, then reads each object pointed to
public List<U> ReadMappedObjectPointerArray<U>(uint uiAddr, int count) where U : new() {
var pointers = ReadMappedArray<uint>(uiAddr, count);
var array = new List<U>();
for (int i = 0; i < count; i++)
array.Add(ReadMappedObject<U>(pointers[i]));
return array;
}
// Perform file format-based post-load manipulations to the IL2Cpp data
public virtual void FinalizeInit(Il2CppBinary il2cpp) { }
}