From 5b78fc3f3cdbfe9e4ef6e604156040fa849321b6 Mon Sep 17 00:00:00 2001 From: Robert Xiao Date: Tue, 7 Apr 2020 01:38:16 -0700 Subject: [PATCH] Fix pointer extraction for MSVC in metadata <21. This change causes the Inspector to properly parse DLLs generated with Il2Cpp versions 5.3.0f4 through 5.3.4f1 (excluding 5.3.2f1, which is a separate problem). --- .../Architectures/Il2CppBinaryX64.cs | 2 +- .../Architectures/Il2CppBinaryX86.cs | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Il2CppInspector.Common/Architectures/Il2CppBinaryX64.cs b/Il2CppInspector.Common/Architectures/Il2CppBinaryX64.cs index 57bfc68..6a1c2d5 100644 --- a/Il2CppInspector.Common/Architectures/Il2CppBinaryX64.cs +++ b/Il2CppInspector.Common/Architectures/Il2CppBinaryX64.cs @@ -214,7 +214,7 @@ namespace Il2CppInspector offset = nextLea?.foundOffset + leaSize ?? buff2Size; } - if (leas.Count == 3) { + if ((image.Version < 21 && leas.Count == 2) || (image.Version >= 21 && leas.Count == 3)) { // Register-based argument passing? var leaRSI = leas.FirstOrDefault(l => l.Value == RSI).Key.address; var leaRDI = leas.FirstOrDefault(l => l.Value == RDI).Key.address; diff --git a/Il2CppInspector.Common/Architectures/Il2CppBinaryX86.cs b/Il2CppInspector.Common/Architectures/Il2CppBinaryX86.cs index cd3633d..4c086c4 100644 --- a/Il2CppInspector.Common/Architectures/Il2CppBinaryX86.cs +++ b/Il2CppInspector.Common/Architectures/Il2CppBinaryX86.cs @@ -32,10 +32,17 @@ namespace Il2CppInspector return (0, 0); // Jump to Il2CppCodegenRegistration - image.Position = image.MapVATR((ulong) pCgr + 6); - metadata = image.ReadUInt32(); - image.Position = image.MapVATR((ulong) pCgr + 11); - code = image.ReadUInt32(); + if(image.Version < 21) { + image.Position = image.MapVATR((ulong)pCgr + 1); + metadata = image.ReadUInt32(); + image.Position = image.MapVATR((ulong)pCgr + 6); + code = image.ReadUInt32(); + } else { + image.Position = image.MapVATR((ulong)pCgr + 6); + metadata = image.ReadUInt32(); + image.Position = image.MapVATR((ulong)pCgr + 11); + code = image.ReadUInt32(); + } return (code, metadata); }