Explorar o código

Report proper error when trying to patch autogenerated field access properties

ghorsington %!s(int64=3) %!d(string=hai) anos
pai
achega
23ab09eac7
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      BepInEx.IL2CPP/Hook/IL2CPPDetourMethodPatcher.cs

+ 6 - 1
BepInEx.IL2CPP/Hook/IL2CPPDetourMethodPatcher.cs

@@ -52,8 +52,13 @@ namespace BepInEx.IL2CPP.Hook
 		{
 			try
 			{
+				var methodField = UnhollowerUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(Original);
+
+				if (methodField == null)
+					throw new Exception($"No IL2CPP equivalent found for {Original.FullDescription()}. The target might have been automatically generated by Unhollower (e.g. field accessor).");
+				
 				// Get the native MethodInfo struct for the target method
-				originalNativeMethodInfo = (Il2CppMethodInfo*)(IntPtr)UnhollowerUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(Original).GetValue(null);
+				originalNativeMethodInfo = (Il2CppMethodInfo*)(IntPtr)methodField.GetValue(null);
 				
 				// Create a trampoline from the original target method