From 678f17a9541209925cf6de774fa0c1679983bc50 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Sun, 27 Oct 2019 00:50:16 +0200 Subject: [PATCH] Don't crash in x86 ConsierCode when matching prologue but next opcode is not "lea eax, address" --- Il2CppInspector/Il2CppBinaryX86.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Il2CppInspector/Il2CppBinaryX86.cs b/Il2CppInspector/Il2CppBinaryX86.cs index 20d71d2..cd3633d 100644 --- a/Il2CppInspector/Il2CppBinaryX86.cs +++ b/Il2CppInspector/Il2CppBinaryX86.cs @@ -4,6 +4,7 @@ All rights reserved. */ +using System; using System.Linq; namespace Il2CppInspector @@ -51,11 +52,20 @@ namespace Il2CppInspector return (0, 0); // lea eax, (pCgr - offset)[ebx] (Position + 6 is the opcode lea eax; Position + 8 is the operand) - image.Position += 8; - pCgr = image.MapVATR(image.ReadUInt32() + plt); - if (pCgr > image.Length) + image.Position += 6; + + // Ensure it's lea eax, #address + if (image.ReadUInt16() != 0x838D) return (0, 0); + try { + pCgr = image.MapVATR(image.ReadUInt32() + plt); + } + // Could not find a mapping in the section table + catch (InvalidOperationException) { + return (0, 0); + } + // Extract Metadata pointer // An 0x838D opcode indicates LEA (no indirection) image.Position = pCgr + 0x20;