From 4ce4d0e799fe25bac667e30e7a98a144e2337b45 Mon Sep 17 00:00:00 2001 From: LukeFZ <17146677+LukeFZ@users.noreply.github.com> Date: Sun, 18 Aug 2024 23:20:49 +0200 Subject: [PATCH 1/2] backport 29/31 version fixes from new versioning branch --- Il2CppInspector.Common/IL2CPP/Il2CppBinary.cs | 4 ++-- Il2CppInspector.Common/IL2CPP/Metadata.cs | 19 +++++++++++++++++++ .../IL2CPP/MetadataClasses.cs | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Il2CppInspector.Common/IL2CPP/Il2CppBinary.cs b/Il2CppInspector.Common/IL2CPP/Il2CppBinary.cs index f07220bb..19c98a40 100644 --- a/Il2CppInspector.Common/IL2CPP/Il2CppBinary.cs +++ b/Il2CppInspector.Common/IL2CPP/Il2CppBinary.cs @@ -294,9 +294,9 @@ private void PrepareMetadata(ulong codeRegistration, ulong metadataRegistration) CodeRegistration = Image.ReadMappedObject(codeRegistration); } - if (Image.Version == 29 && (long)CodeRegistration.genericMethodPointersCount - MetadataRegistration.genericMethodTableCount > 0x10000) + if (Image.Version is 29 or 31 && (long)CodeRegistration.genericMethodPointersCount - MetadataRegistration.genericMethodTableCount > 0x10000) { - Image.Version = 29.1; + Image.Version += 0.1; codeRegistration -= 2 * pointerSize; CodeRegistration = Image.ReadMappedObject(codeRegistration); } diff --git a/Il2CppInspector.Common/IL2CPP/Metadata.cs b/Il2CppInspector.Common/IL2CPP/Metadata.cs index 57841d86..2dffda9b 100644 --- a/Il2CppInspector.Common/IL2CPP/Metadata.cs +++ b/Il2CppInspector.Common/IL2CPP/Metadata.cs @@ -191,6 +191,25 @@ private void Initialize() Header.attributeDataRangeSize / Sizeof(typeof(Il2CppCustomAttributeDataRange))); } + if (Version is 29 or 31) + { + // 29.2/31.2 added a new isUnmanagedCallersOnly flag to Il2CppMethodDefinition. + // This offsets all subsequent entries by one - we can detect this by checking the + // top token byte (which should always be 0x06). + + if (Methods.Length >= 2) + { + var secondToken = Methods[1].token; + if (secondToken >> 24 != 0x6) + { + Version += 0.2; + + Methods = ReadArray(Header.methodsOffset, + Header.methodsCount / Sizeof(typeof(Il2CppMethodDefinition))); + } + } + } + // Get all metadata strings var pluginGetStringsResult = PluginHooks.GetStrings(this); if (pluginGetStringsResult.IsDataModified && !pluginGetStringsResult.IsInvalid) diff --git a/Il2CppInspector.Common/IL2CPP/MetadataClasses.cs b/Il2CppInspector.Common/IL2CPP/MetadataClasses.cs index 2d1ef86a..577298df 100644 --- a/Il2CppInspector.Common/IL2CPP/MetadataClasses.cs +++ b/Il2CppInspector.Common/IL2CPP/MetadataClasses.cs @@ -343,7 +343,7 @@ public class Il2CppMethodDefinition public ushort parameterCount; [Version(Min = 29.2, Max = 31)] - public bool isUnmanagedCallersOnly; + public byte isUnmanagedCallersOnly; } public class Il2CppParameterDefinition From 5b0476fcc572e51e8184ef6105330e75b21f80b0 Mon Sep 17 00:00:00 2001 From: LukeFZ <17146677+LukeFZ@users.noreply.github.com> Date: Sun, 18 Aug 2024 23:23:32 +0200 Subject: [PATCH 2/2] add remaining 31.1/31.2 versioning conditions --- Il2CppInspector.Common/IL2CPP/Il2CppBinaryClasses.cs | 10 +++++++--- Il2CppInspector.Common/IL2CPP/MetadataClasses.cs | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Il2CppInspector.Common/IL2CPP/Il2CppBinaryClasses.cs b/Il2CppInspector.Common/IL2CPP/Il2CppBinaryClasses.cs index dbfe0326..b7a3a782 100644 --- a/Il2CppInspector.Common/IL2CPP/Il2CppBinaryClasses.cs +++ b/Il2CppInspector.Common/IL2CPP/Il2CppBinaryClasses.cs @@ -60,15 +60,19 @@ public class Il2CppCodeRegistration [Version(Min = 22, Max = 29)] public ulong unresolvedVirtualCallCount; - [Version(Min = 29.1)] + [Version(Min = 29.1, Max = 29.1)] + [Version(Min = 31.1, Max = 31.1)] public ulong unresolvedIndirectCallCount; [Version(Min = 22)] public ulong unresolvedVirtualCallPointers; - [Version(Min = 29.1)] + [Version(Min = 29.1, Max = 29.1)] + [Version(Min = 31.1, Max = 31.1)] public ulong unresolvedInstanceCallPointers; - [Version(Min = 29.1)] + + [Version(Min = 29.1, Max = 29.1)] + [Version(Min = 31.1, Max = 31.1)] public ulong unresolvedStaticCallPointers; // Added in metadata v23 diff --git a/Il2CppInspector.Common/IL2CPP/MetadataClasses.cs b/Il2CppInspector.Common/IL2CPP/MetadataClasses.cs index 577298df..3a0d406f 100644 --- a/Il2CppInspector.Common/IL2CPP/MetadataClasses.cs +++ b/Il2CppInspector.Common/IL2CPP/MetadataClasses.cs @@ -342,7 +342,8 @@ public class Il2CppMethodDefinition public ushort slot; public ushort parameterCount; - [Version(Min = 29.2, Max = 31)] + [Version(Min = 29.2, Max = 29.2)] + [Version(Min = 31.2, Max = 31.2)] public byte isUnmanagedCallersOnly; }