# Error message I got (Harmony mod mprotect returned EACCES)

**URL:** https://community.revolutionarygamesstudio.com/t/error-message-i-got-harmony-mod-mprotect-returned-eacces/6551
**Category:** Bug Reports
**Created:** [June 5, 2023, 8:09pm UTC](https://community.revolutionarygamesstudio.com/t/error-message-i-got-harmony-mod-mprotect-returned-eacces/6551 "2023-06-05T20:09:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![MedicGaming](https://thrivecommunity-cdn.b-cdn.net/user_avatar/community.revolutionarygamesstudio.com/medicgaming/32/11082_2.png) [@MedicGaming](https://community.revolutionarygamesstudio.com/u/MedicGaming)
#### Post date: [June 5, 2023, 8:09pm UTC](https://community.revolutionarygamesstudio.com/t/error-message-i-got-harmony-mod-mprotect-returned-eacces/6551/1 "2023-06-05T20:09:07Z")

</div>

Mod Loading Errors - Errors occurred when loading one or more mods. Logs may contain additional information. exception: ObserverMode: mod’s Harmony loading failed with an exception: HarmonyLib.HarmonyException: Patching exception in method System.Void PlayerMicrobeInput::OnMovement(System.Single delta, System.Single forwardMovement, System.Single leftRightMovement, ActiveInputMethod inputMethod) —\> System.TypeInitializationException: The type initializer for ‘HarmonyLib.HarmonySharedState’ threw an exception. —\> System.Exception: mprotect returned EACCES  
at MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform.SetMemPerms (System.IntPtr start, System.UInt64 len, MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform+MmapProts prot) [0x00043] in \<255414689d344b1385ae719f6cce8c55\>:0  
at MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform.MakeWritable (System.IntPtr src, System.UInt32 size) [0x00000] in \<255414689d344b1385ae719f6cce8c55\>:0  
at MonoMod.RuntimeDetour.DetourHelper.MakeWritable (MonoMod.RuntimeDetour.IDetourNativePlatform plat, MonoMod.RuntimeDetour.NativeDetourData detour) [0x00000] in \<255414689d344b1385ae719f6cce8c55\>:0  
at MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform.\_HookSelftest (System.Reflection.MethodInfo from, System.Reflection.MethodInfo to) [0x00035] in \<255414689d344b1385ae719f6cce8c55\>:0  
at MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform…ctor () [0x0004a] in \<255414689d344b1385ae719f6cce8c55\>:0  
at MonoMod.RuntimeDetour.Platforms.DetourRuntimeMonoPlatform…ctor () [0x00000] in \<255414689d344b1385ae719f6cce8c55\>:0  
at MonoMod.RuntimeDetour.DetourHelper.get\_Runtime () [0x00044] in \<255414689d344b1385ae719f6cce8c55\>:0  
at HarmonyLib.HarmonySharedState…cctor () [0x000e7] in \<255414689d344b1385ae719f6cce8c55\>:0  
— End of inner exception stack trace —  
at HarmonyLib.PatchClassProcessor.ProcessPatchJob (HarmonyLib.PatchJobs`1+Job[T] job) [0x00031] in <255414689d344b1385ae719f6cce8c55>:0 --- End of inner exception stack trace --- at HarmonyLib.PatchClassProcessor.ReportException (System.Exception exception, System.Reflection.MethodBase original) [0x0010f] in <255414689d344b1385ae719f6cce8c55>:0 at HarmonyLib.PatchClassProcessor.Patch () [0x00093] in <255414689d344b1385ae719f6cce8c55>:0 at HarmonyLib.Harmony.<PatchAll>b__10_0 (System.Type type) [0x00007] in <255414689d344b1385ae719f6cce8c55>:0 at HarmonyLib.CollectionExtensions.Do[T] (System.Collections.Generic.IEnumerable`1[T] sequence, System.Action`1[T] action) [0x00014] in \<255414689d344b1385ae719f6cce8c55\>:0  
at HarmonyLib.Harmony.PatchAll (System.Reflection.Assembly assembly) [0x00006] in \<255414689d344b1385ae719f6cce8c55\>:0  
at ModLoader.LoadAutoHarmonyMod (System.String name, System.Reflection.Assembly assembly) [0x00045] in :0

---

<div class="post-metadata">

### Author: ![hhyyrylainen](https://thrivecommunity-cdn.b-cdn.net/user_avatar/community.revolutionarygamesstudio.com/hhyyrylainen/32/32_2.png) [@hhyyrylainen](https://community.revolutionarygamesstudio.com/u/hhyyrylainen)
#### Post date: [June 5, 2023, 8:33pm UTC](https://community.revolutionarygamesstudio.com/t/error-message-i-got-harmony-mod-mprotect-returned-eacces/6551/2 "2023-06-05T20:33:29Z")

</div>

Usually I would close a bug report about a mod / merge this into a thread about that mod, but in this case this issue is specifically with the mod loading system not fully working on Macs.

Specifically this issue:

> <https://github.com/Revolutionary-Games/Thrive/issues/3330>
>
> Seems like harmony loading doesn't work on mac:
> \`\`\`
> E 0:00:00.585 void MonoM…od.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform.SetMemPerms(IntPtr , UInt64 , MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform+MmapProts ): System.TypeInitializationException: The type initializer for 'HarmonyLib.HarmonySharedState' threw an exception. ---\> System.Exception: mprotect returned EACCES
> \<C++ virhe\> Unhandled exception
> \<C++ lähdekoodi\>:0 @ void MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform.SetMemPerms(IntPtr , UInt64 , MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform+MmapProts )()
> \<Pinojäljitys\>:0 @ void MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform.SetMemPerms(IntPtr , UInt64 , MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform+MmapProts )()
> :0 @ void MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform.MakeWritable(IntPtr , UInt32 )()
> :0 @ void MonoMod.RuntimeDetour.DetourHelper.MakeWritable(MonoMod.RuntimeDetour.IDetourNativePlatform , MonoMod.RuntimeDetour.NativeDetourData )()
> :0 @ void MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform.\_HookSelftest(System.Reflection.MethodInfo , System.Reflection.MethodInfo )()
> :0 @ MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform..ctor()()
> :0 @ MonoMod.RuntimeDetour.Platforms.DetourRuntimeMonoPlatform..ctor()()
> :0 @ MonoMod.RuntimeDetour.IDetourRuntimePlatform MonoMod.RuntimeDetour.DetourHelper.get\_Runtime()()
> :0 @ HarmonyLib.HarmonySharedState..cctor()()
> :0 @ --- End of inner exception stack trace ---()
> :0 @ System.Collections.Generic.IEnumerable\`1\[System.Reflection.MethodBase\] HarmonyLib.PatchProcessor.GetAllPatchedMethods()()
> :0 @ System.Collections.Generic.IEnumerable\`1\[System.Reflection.MethodBase\] HarmonyLib.Harmony.GetAllPatchedMethods()()
> :0 @ System.Collections.Generic.IEnumerable\`1\[System.Reflection.MethodBase\] HarmonyLib.Harmony.GetPatchedMethods()()
> ModLoader.cs:37 @ ModLoader..ctor()()
> 
> \`\`\`
> 
> I'll make a catch for that to allow the game for start but this should be solved so that mods can work on mac.

And the feature request to that mod making framework to add mac support (it’s been open since 2021):

> <https://github.com/pardeike/Harmony/issues/424>
>
> Harmony can't apply patch when running inside Unity 2021.2 arm version on Apple …Silicon chip. Here is an exception stack:
> 
> Exception: mprotect returned EACCES
> MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform.SetMemPerms (System.IntPtr start, System.UInt64 len, MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform+MmapProts prot) (at \<c38a8c3281a047488dac8c9d063b7abb\>:0)
> MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform.MakeWritable (System.IntPtr src, System.UInt32 size) (at \<c38a8c3281a047488dac8c9d063b7abb\>:0)
> MonoMod.RuntimeDetour.DetourHelper.MakeWritable (MonoMod.RuntimeDetour.IDetourNativePlatform plat, MonoMod.RuntimeDetour.NativeDetourData detour) (at \<c38a8c3281a047488dac8c9d063b7abb\>:0)
> MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform.\_HookSelftest (System.Reflection.MethodInfo from, System.Reflection.MethodInfo to) (at \<c38a8c3281a047488dac8c9d063b7abb\>:0)
> MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform..ctor () (at \<c38a8c3281a047488dac8c9d063b7abb\>:0)
> MonoMod.RuntimeDetour.Platforms.DetourRuntimeMonoPlatform..ctor () (at \<c38a8c3281a047488dac8c9d063b7abb\>:0)
> MonoMod.RuntimeDetour.DetourHelper.get\_Runtime () (at \<c38a8c3281a047488dac8c9d063b7abb\>:0)
> HarmonyLib.HarmonySharedState.WithState\[T\] (System.Func\`1\[TResult\] action) (at \<c38a8c3281a047488dac8c9d063b7abb\>:0)
> HarmonyLib.HarmonySharedState.GetPatchInfo (System.Reflection.MethodBase method) (at \<c38a8c3281a047488dac8c9d063b7abb\>:0)
> HarmonyLib.PatchProcessor.Patch () (at \<c38a8c3281a047488dac8c9d063b7abb\>:0)
> HarmonyLib.Harmony.Patch (System.Reflection.MethodBase original, HarmonyLib.HarmonyMethod prefix, HarmonyLib.HarmonyMethod postfix, HarmonyLib.HarmonyMethod transpiler, HarmonyLib.HarmonyMethod finalizer) (at \<c38a8c3281a047488dac8c9d063b7abb\>:0)
> Fiftytwo.AddressablesAnalyzeHack.InstallAddressablesAnalyzeHack () (at Assets/Scripts/Editor/AddressablesAnalyzeHack.cs:73)
