From 9ab6d16dd0726ca01f049161d5ffc2a2f3c8bd3d Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Tue, 22 Oct 2019 16:23:58 +0200 Subject: [PATCH] Output an error when an unsupported CPU architecture is detected --- Il2CppInspector/Il2CppBinary.cs | 2 +- Il2CppInspector/Il2CppInspector.cs | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Il2CppInspector/Il2CppBinary.cs b/Il2CppInspector/Il2CppBinary.cs index 703fe5d..d9b019c 100644 --- a/Il2CppInspector/Il2CppBinary.cs +++ b/Il2CppInspector/Il2CppBinary.cs @@ -50,7 +50,7 @@ namespace Il2CppInspector // Get type from image architecture var type = Assembly.GetExecutingAssembly().GetType("Il2CppInspector.Il2CppBinary" + stream.Arch.ToUpper()); if (type == null) - return null; + throw new InvalidOperationException("Unsupported architecture: " + stream.Arch); var inst = (Il2CppBinary) Activator.CreateInstance(type, stream); diff --git a/Il2CppInspector/Il2CppInspector.cs b/Il2CppInspector/Il2CppInspector.cs index f095776..c33893c 100644 --- a/Il2CppInspector/Il2CppInspector.cs +++ b/Il2CppInspector/Il2CppInspector.cs @@ -174,11 +174,16 @@ namespace Il2CppInspector Console.WriteLine("Instruction set: " + image.Arch); // Architecture-agnostic load attempt - if (Il2CppBinary.Load(image, metadata.Version) is Il2CppBinary binary) { - processors.Add(new Il2CppInspector(binary, metadata)); + try { + if (Il2CppBinary.Load(image, metadata.Version) is Il2CppBinary binary) { + processors.Add(new Il2CppInspector(binary, metadata)); + } + else { + Console.Error.WriteLine("Could not process IL2CPP image"); + } } - else { - Console.Error.WriteLine("Could not process IL2CPP image"); + catch (InvalidOperationException ex) { + Console.Error.WriteLine(ex.Message); } } return processors;