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

@@ -167,27 +167,12 @@ namespace Il2CppInspector
// Multi-image binaries may contain more than one Il2Cpp image
var processors = new List<Il2CppInspector>();
foreach (var image in stream.Images) {
Il2CppBinary binary;
// We are currently supporting x86 and ARM architectures
switch (image.Arch) {
case "x86":
binary = new Il2CppBinaryX86(image);
break;
case "ARM":
binary = new Il2CppBinaryARM(image);
break;
default:
Console.Error.WriteLine("Unsupported architecture");
return null;
}
// Find code and metadata regions
if (!binary.Initialize(metadata.Version)) {
Console.Error.WriteLine("Could not process IL2CPP image");
// Architecture-agnostic load attempt
if (Il2CppBinary.Load(image, metadata.Version) is Il2CppBinary binary) {
processors.Add(new Il2CppInspector(binary, metadata));
}
else {
processors.Add(new Il2CppInspector(binary, metadata));
Console.Error.WriteLine("Could not process IL2CPP image");
}
}
return processors;