From 79baebdb93232af9c9e9ee1f5ad225ffab640805 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Wed, 16 Oct 2019 08:50:34 +0200 Subject: [PATCH] Update Il2CPP structs for new v24 iterations --- Il2CppInspector/Il2CppBinaryClasses.cs | 39 ++++++++++++++++++++---- Il2CppInspector/MetadataClasses.cs | 41 ++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 7 deletions(-) diff --git a/Il2CppInspector/Il2CppBinaryClasses.cs b/Il2CppInspector/Il2CppBinaryClasses.cs index d0ebc78..b2bfa35 100644 --- a/Il2CppInspector/Il2CppBinaryClasses.cs +++ b/Il2CppInspector/Il2CppBinaryClasses.cs @@ -1,6 +1,6 @@ /* Copyright 2017 Perfare - https://github.com/Perfare/Il2CppDumper - Copyright 2017 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com + Copyright 2017-2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com All rights reserved. */ @@ -9,6 +9,7 @@ using NoisyCowStudios.Bin2Object; namespace Il2CppInspector { + // From class-internals.h / il2cpp-class-internals.h public class Il2CppCodeRegistration { // Moved to Il2CppCodeGenModule in later versions of v24 @@ -66,6 +67,22 @@ namespace Il2CppInspector public uint pcodeGenModules; } + // Introduced in metadata v24.1 (replaces method pointers in Il2CppCodeRegistration) + public class Il2CppCodeGenModule + { + public uint moduleName; + public uint methodPointerCount; + public uint methodPointers; + public uint invokerIndices; + public uint reversePInvokeWrapperCount; + public uint reversePInvokeWrapperIndices; + public uint rgctxRangesCount; + public uint rgctxRanges; + public uint rgctxsCount; + public uint rgctxs; + public uint debuggerMetadata; + } + #pragma warning disable CS0649 public class Il2CppMetadataRegistration { @@ -90,6 +107,7 @@ namespace Il2CppInspector } #pragma warning restore CS0649 + // From blob.h / il2cpp-blob.h public enum Il2CppTypeEnum { IL2CPP_TYPE_END = 0x00, /* End of List */ @@ -132,16 +150,27 @@ namespace Il2CppInspector IL2CPP_TYPE_ENUM = 0x55 /* an enumeration */ } + // From metadata.h / il2cpp-runtime-metadata.h public class Il2CppType { + /* + union + { + TypeDefinitionIndex klassIndex; // for VALUETYPE and CLASS + const Il2CppType* type; // for PTR and SZARRAY + Il2CppArrayType* array; // for ARRAY + GenericParameterIndex genericParameterIndex; // for VAR and MVAR + Il2CppGenericClass* generic_class; // for GENERICINST + } + */ public uint datapoint; - public uint bits; + public uint bits; // this should be private but we need it to be public for BinaryObjectReader to work - public uint attrs => bits & 0xffff; + public uint attrs => bits & 0xffff; /* param attributes or field flags */ public Il2CppTypeEnum type => (Il2CppTypeEnum)((bits >> 16) & 0xff); - public uint num_mods => (bits >> 24) & 0x3f; + public uint num_mods => (bits >> 24) & 0x3f; /* max 64 modifiers follow at the end */ public bool byref => ((bits >> 30) & 1) == 1; - public bool pinned => (bits >> 31) == 1; + public bool pinned => (bits >> 31) == 1; /* valid when included in a local var signature */ } public class Il2CppGenericClass diff --git a/Il2CppInspector/MetadataClasses.cs b/Il2CppInspector/MetadataClasses.cs index df6b4eb..3d0e817 100644 --- a/Il2CppInspector/MetadataClasses.cs +++ b/Il2CppInspector/MetadataClasses.cs @@ -1,6 +1,6 @@ /* Copyright 2017 Perfare - https://github.com/Perfare/Il2CppDumper - Copyright 2017 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com + Copyright 2017-2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com All rights reserved. */ @@ -9,6 +9,12 @@ using NoisyCowStudios.Bin2Object; namespace Il2CppInspector { + // Unity 5.6.2p3 -> v23 + // Unity 5.6.4f1 -> v23 + // Unity 2017.2f3 -> v24 + // Unity 2019.2.8f1 -> v24.1 + + // From il2cpp-metadata.h #pragma warning disable CS0649 public class Il2CppGlobalMetadataHeader { @@ -112,6 +118,11 @@ namespace Il2CppInspector public int entryPointIndex; public uint token; + + [Version(Min = 24.1)] + public int customAttributeStart; + [Version(Min = 24.1)] + public uint customAttributeCount; } #pragma warning restore CS0649 @@ -119,7 +130,11 @@ namespace Il2CppInspector { public int nameIndex; public int namespaceIndex; + + // Removed in later versions of metadata v24 + [Version(Max = 24.0)] public int customAttributeIndex; + public int byvalTypeIndex; public int byrefTypeIndex; @@ -180,13 +195,23 @@ namespace Il2CppInspector public int declaringType; public int returnType; public int parameterStart; + + [Version(Max = 24.0)] public int customAttributeIndex; + public int genericContainerIndex; + + [Version(Max = 24.0)] public int methodIndex; + [Version(Max = 24.0)] public int invokerIndex; - public int delegateWrapperIndex; // (was renamed to reversePInvokeWrapperIndex in v22) + [Version(Max = 24.0)] + public int reversePInvokeWrapperIndex; // (was renamed from delegateWrapperIndex in v22) + [Version(Max = 24.0)] public int rgctxStartIndex; + [Version(Max = 24.0)] public int rgctxCount; + public uint token; public ushort flags; public ushort iflags; @@ -198,7 +223,10 @@ namespace Il2CppInspector { public int nameIndex; public uint token; + + [Version(Max = 24.0)] public int customAttributeIndex; + public int typeIndex; } @@ -206,7 +234,10 @@ namespace Il2CppInspector { public int nameIndex; public int typeIndex; + + [Version(Max = 24.0)] public int customAttributeIndex; + public uint token; } @@ -223,7 +254,10 @@ namespace Il2CppInspector public int get; public int set; public uint attrs; + + [Version(Max = 24.0)] public int customAttributeIndex; + public uint token; } @@ -234,7 +268,10 @@ namespace Il2CppInspector public int add; public int remove; public int raise; + + [Version(Max = 24.0)] public int customAttributeIndex; + public uint token; } }