Refactor Il2CppBinary loads

This commit is contained in:
Katy Coe
2019-10-21 11:07:30 +02:00
parent 2ae0904226
commit 3fb3b15d8f
2 changed files with 18 additions and 19 deletions

View File

@@ -9,6 +9,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
namespace Il2CppInspector
{
@@ -44,6 +45,19 @@ namespace Il2CppInspector
Configure(Image, codeRegistration, metadataRegistration);
}
// Load and initialize a binary of any supported architecture
public static Il2CppBinary Load(IFileFormatReader stream, double metadataVersion) {
// Get type from image architecture
var type = Assembly.GetExecutingAssembly().GetType("Il2CppInspector.Il2CppBinary" + stream.Arch.ToUpper());
if (type == null)
return null;
var inst = (Il2CppBinary) Activator.CreateInstance(type, new object[] {stream});
// Try to process the IL2CPP image; return the instance if succeeded, otherwise null
return inst.Initialize(metadataVersion) ? inst : null;
}
// Architecture-specific search function
protected abstract (uint, uint) ConsiderCode(uint loc, uint globalOffset);