{"record":{"id":"bf854aa5bce868ba","repo":"egametang/ET","slug":"unsupported-runtime-bf854a","errorCode":null,"errorMessage":"Unsupported runtime","messagePattern":"Unsupported runtime","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"critical","filePath":"Packages/cn.etetet.hybridclr/Scripts/Editor/Share/3rds/UnityHook/HookUtils_OSX.cs","lineNumber":27,"sourceCode":"namespace MonoHook\n{\n    public static unsafe class HookUtils\n    {\n        static bool jit_write_protect_supported;\n        private static readonly long _Pagesize;\n\n\n        static HookUtils()\n        {\n            try\n            {\n                jit_write_protect_supported = pthread_jit_write_protect_supported_np() != 0;\n            }\n            catch { }\n\n            PropertyInfo p_SystemPageSize = typeof(Environment).GetProperty(\"SystemPageSize\");\n            if (p_SystemPageSize == null)\n                throw new NotSupportedException(\"Unsupported runtime\");\n            _Pagesize = (int)p_SystemPageSize.GetValue(null, new object[0]);\n        }\n\n        public static void MemCpy(void* pDst, void* pSrc, int len)\n        {\n            byte* pDst_ = (byte*)pDst;\n            byte* pSrc_ = (byte*)pSrc;\n\n            for (int i = 0; i < len; i++)\n                *pDst_++ = *pSrc_++;\n        }\n\n        public static void MemCpy_Jit(void* pDst, byte[] src)\n        {\n            if (!jit_write_protect_supported)\n            {\n                fixed(void * pSrc = &src[0])\n                {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.hybridclr/Scripts/Editor/Share/3rds/UnityHook/HookUtils_OSX.cs#L9-L45","documentation":"Thrown in the OSX-specific HookUtils static constructor when typeof(Environment).GetProperty(\"SystemPageSize\") returns null. Identical logic to the non-OSX HookUtils, but in the macOS code path which also initializes pthread_jit_write_protect state for Apple Silicon. If the runtime lacks SystemPageSize, the hooking subsystem cannot compute page-aligned addresses and throws NotSupportedException.","triggerScenarios":"First access to any HookUtils member on macOS triggers the static constructor. If Environment.SystemPageSize is absent (very old or custom Mono), the constructor throws, preventing hook initialization on macOS.","commonSituations":"Running an old Unity version on macOS with an outdated Mono runtime; running under a stripped or modified .NET runtime on macOS; using a Unity version where Mono was patched in a way that removed or hid the property.","solutions":["Upgrade Unity to a recent version whose bundled Mono exposes Environment.SystemPageSize.","Fork HookUtils_OSX.cs to fall back to sysconf(_SC_PAGESIZE) via P/Invoke when the property is absent.","Reinstall or repair the Unity editor if the Mono runtime is corrupted.","If the hooking feature is non-essential, disable it to avoid the static constructor entirely."],"exampleFix":"// before\nPropertyInfo p = typeof(Environment).GetProperty(\"SystemPageSize\");\nif (p == null) throw new NotSupportedException(\"Unsupported runtime\");\n\n// after — fallback for macOS\nPropertyInfo p = typeof(Environment).GetProperty(\"SystemPageSize\");\n_Pagesize = p != null\n    ? (int)p.GetValue(null)\n    : (int)sysconf(_SC_PAGESIZE); // P/Invoke libc","handlingStrategy":"validation","validationCode":"// On macOS, check before using HookUtils\nPropertyInfo prop = typeof(Environment).GetProperty(\"SystemPageSize\");\nif (prop == null)\n{\n    Debug.LogError(\"macOS runtime lacks Environment.SystemPageSize. \" +\n        \"Upgrade Unity or patch HookUtils_OSX with a sysconf fallback.\");\n    return;\n}","typeGuard":"static bool IsMacOSRuntimeSupported()\n{\n    return typeof(Environment).GetProperty(\"SystemPageSize\") != null;\n}","tryCatchPattern":"try\n{\n    HookUtils.SetAddrFlagsToRWX(ptr, size);\n}\ncatch (NotSupportedException ex) when (ex.Message == \"Unsupported runtime\")\n{\n    Debug.LogError(\"macOS runtime unsupported by HookUtils. \" +\n        \"Upgrade Unity or fork HookUtils_OSX.cs to use sysconf(_SC_PAGESIZE).\");\n}","preventionTips":["Check runtime compatibility at startup before initializing hooks on macOS.","Keep Unity updated; older macOS builds may bundle outdated Mono.","For custom macOS runtimes, provide a HookUtils_OSX fork with sysconf fallback.","Gate hook initialization behind a capability check to fail gracefully."],"tags":["unityhook","runtime","macos","mono","compatibility","page-size"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}