From 2f3b0d72769817344fe3858c70199eaf8b03d67b Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Mon, 20 Jul 2020 22:48:40 +0200 Subject: [PATCH] AppModel/IDA: Typed MethodInvokers for 5.3.0-5.6.7 don't use Il2CppMethodPointer --- Il2CppInspector.Common/Outputs/IDAPythonScript.cs | 2 +- Il2CppInspector.Common/Reflection/MethodInvoker.cs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Il2CppInspector.Common/Outputs/IDAPythonScript.cs b/Il2CppInspector.Common/Outputs/IDAPythonScript.cs index 88bb8ed..563d099 100755 --- a/Il2CppInspector.Common/Outputs/IDAPythonScript.cs +++ b/Il2CppInspector.Common/Outputs/IDAPythonScript.cs @@ -110,7 +110,7 @@ typedef __int64 int64_t; writeSectionHeader("Method.Invoke thunks"); foreach (var method in model.ILModel.MethodInvokers.Where(m => m != null)) { - writeTypedName(method.VirtualAddress.Start, method.Signature, method.Name); + writeTypedName(method.VirtualAddress.Start, method.GetSignature(model.UnityVersion), method.Name); } } diff --git a/Il2CppInspector.Common/Reflection/MethodInvoker.cs b/Il2CppInspector.Common/Reflection/MethodInvoker.cs index 08894f1..d4a2732 100644 --- a/Il2CppInspector.Common/Reflection/MethodInvoker.cs +++ b/Il2CppInspector.Common/Reflection/MethodInvoker.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using Il2CppInspector.Cpp.UnityHeaders; namespace Il2CppInspector.Reflection { @@ -56,8 +57,11 @@ namespace Il2CppInspector.Reflection public string Name => $"RuntimeInvoker_{!IsStatic}{ReturnType.BaseName.ToCIdentifier()}_" + string.Join("_", ParameterTypes.Select(p => p.BaseName.ToCIdentifier())); // Display as a C++ method signature; MethodInfo* is the same as RuntimeMethod* (see codegen/il2cpp-codegen-metadata.h) - public string Signature => $"void* {Name}(Il2CppMethodPointer pointer, const MethodInfo* methodMetadata, void* obj, void** args)"; + public string GetSignature(UnityVersion version) => + version.CompareTo("2017.1.0") >= 0 + ? $"void* {Name}(Il2CppMethodPointer pointer, const MethodInfo* methodMetadata, void* obj, void** args)" + : $"void* {Name}(const MethodInfo* method, void* obj, void** args)"; - public override string ToString() => Signature; + public override string ToString() => GetSignature(new UnityVersion("2017.1.0")); } }