From 930b00f58816cbb7000d6f5b8338be2bbd3b5f40 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Tue, 12 Jan 2021 01:10:30 +0100 Subject: [PATCH] IL2CPP: Add plugin warning when failing to analyze --- Il2CppInspector.Common/IL2CPP/Il2CppBinary.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Il2CppInspector.Common/IL2CPP/Il2CppBinary.cs b/Il2CppInspector.Common/IL2CPP/Il2CppBinary.cs index c7afbe5..3eec983 100644 --- a/Il2CppInspector.Common/IL2CPP/Il2CppBinary.cs +++ b/Il2CppInspector.Common/IL2CPP/Il2CppBinary.cs @@ -106,7 +106,7 @@ namespace Il2CppInspector StatusUpdate($"Analyzing IL2CPP data for {Image.Format}/{Image.Arch} image"); DiscoverAPIExports(); - PrepareMetadata(codeRegistration, metadataRegistration); + TryPrepareMetadata(codeRegistration, metadataRegistration); } // Load and initialize a binary of any supported architecture @@ -164,7 +164,7 @@ namespace Il2CppInspector if (!((FindMetadataFromSymbols() ?? FindMetadataFromCode()) is (ulong code, ulong meta))) return false; - PrepareMetadata(code, meta); + TryPrepareMetadata(code, meta); return true; } @@ -175,7 +175,7 @@ namespace Il2CppInspector if (!((FindMetadataFromSymbols() ?? FindMetadataFromCode() ?? FindMetadataFromData(metadata)) is (ulong code, ulong meta))) return false; - PrepareMetadata(code, meta, metadata); + TryPrepareMetadata(code, meta, metadata); return true; } @@ -246,6 +246,17 @@ namespace Il2CppInspector // Architecture-specific search function protected abstract (ulong, ulong) ConsiderCode(IFileFormatStream image, uint loc); + + // Load all of the discovered metadata in the binary + private void TryPrepareMetadata(ulong codeRegistration, ulong metadataRegistration, Metadata metadata = null) { + try { + PrepareMetadata(codeRegistration, metadataRegistration); + } + catch (Exception ex) when (!(ex is NotSupportedException)) { + throw new InvalidOperationException($"Could not analyze IL2CPP data. Ensure that the latest core plugins package is installed and all core plugins are enabled before filing a bug report. The error was: {ex.Message}", ex); + } + } + // Load all of the discovered metadata in the binary private void PrepareMetadata(ulong codeRegistration, ulong metadataRegistration, Metadata metadata = null) { // Store locations