From f069c4d3ba9e46b1bc0fa9628067a6f1f15f3e7d Mon Sep 17 00:00:00 2001 From: WNP78 Date: Thu, 20 Jun 2024 19:26:46 +0100 Subject: [PATCH 1/2] Fix class injector abstract method handling to support newer unity versions where Il2CppParameterInfo doesn't exist. --- Il2CppInterop.Runtime/Injection/ClassInjector.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Il2CppInterop.Runtime/Injection/ClassInjector.cs b/Il2CppInterop.Runtime/Injection/ClassInjector.cs index e287a086..b8ee0f0e 100644 --- a/Il2CppInterop.Runtime/Injection/ClassInjector.cs +++ b/Il2CppInterop.Runtime/Injection/ClassInjector.cs @@ -362,10 +362,13 @@ static void FindAbstractMethods(List list, INativeClass for (var i = 0; i < m.ParametersCount; i++) { + var parameterName = IL2CPP.il2cpp_method_get_param_name(baseMethod.Pointer, (uint)i); + var otherParameterName = IL2CPP.il2cpp_method_get_param_name(m.Pointer, (uint)i); + var parameterInfo = UnityVersionHandler.Wrap(baseMethod.Parameters, i); var otherParameterInfo = UnityVersionHandler.Wrap(m.Parameters, i); - if (Marshal.PtrToStringAnsi(parameterInfo.Name) != Marshal.PtrToStringAnsi(otherParameterInfo.Name)) return false; + if (Marshal.PtrToStringAnsi(parameterName) != Marshal.PtrToStringAnsi(otherParameterName)) return false; if (GetIl2CppTypeFullName(parameterInfo.ParameterType) != GetIl2CppTypeFullName(otherParameterInfo.ParameterType)) return false; } From dd279c1feb22a61dc92636c095077148ab9f0ee1 Mon Sep 17 00:00:00 2001 From: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> Date: Sun, 8 Sep 2024 08:43:30 -0700 Subject: [PATCH 2/2] Remove parameter name check and add return type check --- Il2CppInterop.Runtime/Injection/ClassInjector.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Il2CppInterop.Runtime/Injection/ClassInjector.cs b/Il2CppInterop.Runtime/Injection/ClassInjector.cs index b8ee0f0e..6db08110 100644 --- a/Il2CppInterop.Runtime/Injection/ClassInjector.cs +++ b/Il2CppInterop.Runtime/Injection/ClassInjector.cs @@ -359,17 +359,13 @@ static void FindAbstractMethods(List list, INativeClass { if (Marshal.PtrToStringAnsi(m.Name) != name) return false; if (m.ParametersCount != baseMethod.ParametersCount) return false; + if (GetIl2CppTypeFullName(m.ReturnType) != GetIl2CppTypeFullName(baseMethod.ReturnType)) return false; for (var i = 0; i < m.ParametersCount; i++) { - var parameterName = IL2CPP.il2cpp_method_get_param_name(baseMethod.Pointer, (uint)i); - var otherParameterName = IL2CPP.il2cpp_method_get_param_name(m.Pointer, (uint)i); - var parameterInfo = UnityVersionHandler.Wrap(baseMethod.Parameters, i); var otherParameterInfo = UnityVersionHandler.Wrap(m.Parameters, i); - if (Marshal.PtrToStringAnsi(parameterName) != Marshal.PtrToStringAnsi(otherParameterName)) return false; - if (GetIl2CppTypeFullName(parameterInfo.ParameterType) != GetIl2CppTypeFullName(otherParameterInfo.ParameterType)) return false; }