diff --git a/BepInEx.IL2CPP/Hook/IL2CPPDetourMethodPatcher.cs b/BepInEx.IL2CPP/Hook/IL2CPPDetourMethodPatcher.cs index e7d17ce..90aaeec 100644 --- a/BepInEx.IL2CPP/Hook/IL2CPPDetourMethodPatcher.cs +++ b/BepInEx.IL2CPP/Hook/IL2CPPDetourMethodPatcher.cs @@ -55,8 +55,18 @@ namespace BepInEx.IL2CPP.Hook 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)."); - + { + var fieldInfoField = UnhollowerUtils.GetIl2CppFieldInfoPointerFieldForGeneratedFieldAccessor(Original); + + if (fieldInfoField != null) + { + throw new Exception($"Method {Original.FullDescription()} is a field accessor, it can't be patched."); + } + + // Generated method is probably unstripped, it can be safely handed to IL handler + return; + } + // Get the native MethodInfo struct for the target method originalNativeMethodInfo = (Il2CppMethodInfo*)(IntPtr)methodField.GetValue(null);