From f715586b3b184cb28ff3df2dae117f71e4dfdd15 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Sun, 2 Feb 2020 06:45:52 +0100 Subject: [PATCH] IL2CPP: Process Il2CppGenericMethodFunctionsDefinitions and Il2CppGenericMethodIndices --- Il2CppInspector/IL2CPP/Il2CppBinary.cs | 13 ++++++++++++- Il2CppInspector/IL2CPP/Il2CppBinaryClasses.cs | 14 +++++++++++++- Il2CppInspector/IL2CPP/Il2CppInspector.cs | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Il2CppInspector/IL2CPP/Il2CppBinary.cs b/Il2CppInspector/IL2CPP/Il2CppBinary.cs index c894515..368768c 100644 --- a/Il2CppInspector/IL2CPP/Il2CppBinary.cs +++ b/Il2CppInspector/IL2CPP/Il2CppBinary.cs @@ -1,6 +1,6 @@ /* Copyright 2017 Perfare - https://github.com/Perfare/Il2CppDumper - Copyright 2017-2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com + Copyright 2017-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com All rights reserved. */ @@ -46,6 +46,9 @@ namespace Il2CppInspector // List of run-time concrete generic class and method signatures public List GenericInstances { get; private set; } + // List of constructed generic method function pointers corresponding to each possible method instantiation + public Dictionary GenericMethodPointers { get; } = new Dictionary(); + // Every defined type public List TypeReferences { get; private set; } @@ -200,6 +203,14 @@ namespace Il2CppInspector // Concrete generic class and method signatures GenericInstances = image.ReadMappedObjectPointerArray(MetadataRegistration.genericInsts, (int) MetadataRegistration.genericInstsCount); + + // Concrete generic method pointers + // TODO: Invoker pointers in tableEntry.indices.invokerIndex + var genericMethodPointers = image.ReadMappedArray(CodeRegistration.genericMethodPointers, (int) CodeRegistration.genericMethodPointersCount); + var genericMethodTable = image.ReadMappedArray(MetadataRegistration.genericMethodTable, (int) MetadataRegistration.genericMethodTableCount); + foreach (var tableEntry in genericMethodTable) { + GenericMethodPointers.Add(MethodSpecs[tableEntry.genericMethodIndex], genericMethodPointers[tableEntry.indices.methodIndex]); + } } } } diff --git a/Il2CppInspector/IL2CPP/Il2CppBinaryClasses.cs b/Il2CppInspector/IL2CPP/Il2CppBinaryClasses.cs index c59b658..6c8fea3 100644 --- a/Il2CppInspector/IL2CPP/Il2CppBinaryClasses.cs +++ b/Il2CppInspector/IL2CPP/Il2CppBinaryClasses.cs @@ -1,6 +1,6 @@ /* Copyright 2017 Perfare - https://github.com/Perfare/Il2CppDumper - Copyright 2017-2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com + Copyright 2017-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com All rights reserved. */ @@ -216,4 +216,16 @@ namespace Il2CppInspector public int classIndexIndex; public int methodIndexIndex; } + + public class Il2CppGenericMethodFunctionsDefinitions + { + public int genericMethodIndex; + public Il2CppGenericMethodIndices indices; + } + + public class Il2CppGenericMethodIndices + { + public int methodIndex; + public int invokerIndex; + } } diff --git a/Il2CppInspector/IL2CPP/Il2CppInspector.cs b/Il2CppInspector/IL2CPP/Il2CppInspector.cs index 70f8f38..49d70ab 100644 --- a/Il2CppInspector/IL2CPP/Il2CppInspector.cs +++ b/Il2CppInspector/IL2CPP/Il2CppInspector.cs @@ -60,6 +60,7 @@ namespace Il2CppInspector public Dictionary Modules => Binary.Modules; public ulong[] CustomAttributeGenerators => Binary.CustomAttributeGenerators; public Il2CppMethodSpec[] MethodSpecs => Binary.MethodSpecs; + public Dictionary GenericMethodPointers => Binary.GenericMethodPointers; // TODO: Finish all file access in the constructor and eliminate the need for this public IFileFormatReader BinaryImage => Binary.Image;