From 21e77b7965b9702ace6a87f6b6146e4fb97212ba Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Sun, 2 Feb 2020 07:20:02 +0100 Subject: [PATCH] IL2CPP: Implement GetGenericMethodPointer and VirtualAddress for concrete generic methods from MethodSpecs --- Il2CppInspector/IL2CPP/Il2CppInspector.cs | 9 +++++++++ Il2CppInspector/Reflection/MethodBase.cs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Il2CppInspector/IL2CPP/Il2CppInspector.cs b/Il2CppInspector/IL2CPP/Il2CppInspector.cs index fd7ff07..08cb4c1 100644 --- a/Il2CppInspector/IL2CPP/Il2CppInspector.cs +++ b/Il2CppInspector/IL2CPP/Il2CppInspector.cs @@ -230,6 +230,7 @@ namespace Il2CppInspector } } + // Get a method pointer if available public (ulong Start, ulong End)? GetMethodPointer(Il2CppCodeGenModule module, Il2CppMethodDefinition methodDef) { // Find method pointer if (methodDef.methodIndex < 0) @@ -268,6 +269,14 @@ namespace Il2CppInspector return (start & 0xffff_ffff_ffff_fffe, FunctionAddresses[start]); } + // Get a concrete generic method pointer if available + public (ulong Start, ulong End)? GetGenericMethodPointer(Il2CppMethodSpec spec) { + if (GenericMethodPointers.TryGetValue(spec, out var start)) { + return (start & 0xffff_ffff_ffff_fffe, FunctionAddresses[start]); + } + return null; + } + public static List LoadFromFile(string codeFile, string metadataFile) { // Load the metadata file Metadata metadata; diff --git a/Il2CppInspector/Reflection/MethodBase.cs b/Il2CppInspector/Reflection/MethodBase.cs index 557350e..4ae5f73 100644 --- a/Il2CppInspector/Reflection/MethodBase.cs +++ b/Il2CppInspector/Reflection/MethodBase.cs @@ -160,7 +160,7 @@ namespace Il2CppInspector.Reflection DeclaredParameters.Add(new ParameterInfo(model, p, genericArguments[p.ParameterType.GenericParameterPosition])); } - // TODO: Populate VirtualAddress via Il2CppGenericMethodFunctionsDefinitions + VirtualAddress = model.Package.GetGenericMethodPointer(spec); } public string GetAccessModifierString() => this switch {