Add Fat Mach-O (Universal Binary) support
Fix fieldOffsets bug in some metadata versions Add support for generic multi-architecture binaries Add Mach-O section RVA mapping
This commit is contained in:
@@ -5,7 +5,9 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using NoisyCowStudios.Bin2Object;
|
||||
|
||||
namespace Il2CppInspector
|
||||
@@ -13,6 +15,9 @@ namespace Il2CppInspector
|
||||
public interface IFileFormatReader
|
||||
{
|
||||
BinaryObjectReader Stream { get; }
|
||||
uint NumImages { get; }
|
||||
IEnumerable<IFileFormatReader> Images { get; }
|
||||
IFileFormatReader this[uint index] { get; }
|
||||
long Position { get; set; }
|
||||
string Arch { get; }
|
||||
uint GlobalOffset { get; }
|
||||
@@ -35,17 +40,26 @@ namespace Il2CppInspector
|
||||
|
||||
public BinaryObjectReader Stream => this;
|
||||
|
||||
public uint NumImages { get; protected set; } = 1;
|
||||
|
||||
public uint GlobalOffset { get; protected set; }
|
||||
|
||||
public virtual string Arch => throw new NotImplementedException();
|
||||
|
||||
public static T Load(string filename, uint offset = 0) {
|
||||
using (var stream = new FileStream(filename, FileMode.Open))
|
||||
return Load(stream, offset);
|
||||
public IEnumerable<IFileFormatReader> Images {
|
||||
get {
|
||||
for (uint i = 0; i < NumImages; i++)
|
||||
yield return this[i];
|
||||
}
|
||||
}
|
||||
|
||||
public static T Load(Stream stream, uint offset = 0) {
|
||||
stream.Position = offset;
|
||||
public static T Load(string filename) {
|
||||
using (var stream = new FileStream(filename, FileMode.Open))
|
||||
return Load(stream);
|
||||
}
|
||||
|
||||
public static T Load(Stream stream) {
|
||||
stream.Position = 0;
|
||||
var pe = (T) Activator.CreateInstance(typeof(T), stream);
|
||||
return pe.Init() ? pe : null;
|
||||
}
|
||||
@@ -53,11 +67,21 @@ namespace Il2CppInspector
|
||||
// Confirm file is valid and set up RVA mappings
|
||||
protected virtual bool Init() => throw new NotImplementedException();
|
||||
|
||||
// Choose a sub-binary within the image for multi-architecture binaries
|
||||
public virtual IFileFormatReader this[uint index] {
|
||||
get {
|
||||
if (index == 0)
|
||||
return this;
|
||||
throw new IndexOutOfRangeException("Binary image index out of bounds");
|
||||
}
|
||||
}
|
||||
|
||||
// Find search locations in the machine code for Il2Cpp data
|
||||
public virtual uint[] GetSearchLocations() => throw new NotImplementedException();
|
||||
|
||||
|
||||
// Map an RVA to an offset into the file image
|
||||
public virtual uint MapVATR(uint uiAddr) => throw new NotImplementedException();
|
||||
// No mapping by default
|
||||
public virtual uint MapVATR(uint uiAddr) => uiAddr;
|
||||
|
||||
// Retrieve object(s) from specified RVA(s)
|
||||
public U ReadMappedObject<U>(uint uiAddr) where U : new() {
|
||||
|
||||
Reference in New Issue
Block a user