Don't crash in x86 ConsierCode when matching prologue but next opcode is not "lea eax, address"

This commit is contained in:
Katy Coe
2019-10-27 00:50:16 +02:00
parent 9ee2e7567c
commit 678f17a954

View File

@@ -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;