Add support for Mach-O files

This commit is contained in:
Katy Coe
2017-10-22 02:24:10 +02:00
parent 16ae3ed108
commit 58968c237a
5 changed files with 286 additions and 5 deletions

View File

@@ -20,6 +20,7 @@ namespace Il2CppInspector
U ReadMappedObject<U>(uint uiAddr) where U : new();
U[] ReadMappedArray<U>(uint uiAddr, int count) where U : new();
uint MapVATR(uint uiAddr);
void FinalizeInit(Il2CppReader il2cpp);
byte[] ReadBytes(int count);
ulong ReadUInt64();
@@ -38,13 +39,13 @@ namespace Il2CppInspector
public virtual string Arch => throw new NotImplementedException();
public static T Load(string filename) {
public static T Load(string filename, uint offset = 0) {
using (var stream = new FileStream(filename, FileMode.Open))
return Load(stream);
return Load(stream, offset);
}
public static T Load(Stream stream) {
stream.Position = 0;
public static T Load(Stream stream, uint offset = 0) {
stream.Position = offset;
var pe = (T) Activator.CreateInstance(typeof(T), stream);
return pe.Init() ? pe : null;
}
@@ -66,5 +67,8 @@ namespace Il2CppInspector
public U[] ReadMappedArray<U>(uint uiAddr, int count) where U : new() {
return ReadArray<U>(MapVATR(uiAddr), count);
}
// Perform file format-based post-load manipulations to the IL2Cpp data
public virtual void FinalizeInit(Il2CppReader il2cpp) { }
}
}