egametang/ET · critical · NotSupportedException

Unsupported runtime

Error message

Unsupported runtime

What it means

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.

Source

Thrown at Packages/cn.etetet.hybridclr/Scripts/Editor/Share/3rds/UnityHook/HookUtils_OSX.cs:27

namespace MonoHook
{
    public static unsafe class HookUtils
    {
        static bool jit_write_protect_supported;
        private static readonly long _Pagesize;


        static HookUtils()
        {
            try
            {
                jit_write_protect_supported = pthread_jit_write_protect_supported_np() != 0;
            }
            catch { }

            PropertyInfo p_SystemPageSize = typeof(Environment).GetProperty("SystemPageSize");
            if (p_SystemPageSize == null)
                throw new NotSupportedException("Unsupported runtime");
            _Pagesize = (int)p_SystemPageSize.GetValue(null, new object[0]);
        }

        public static void MemCpy(void* pDst, void* pSrc, int len)
        {
            byte* pDst_ = (byte*)pDst;
            byte* pSrc_ = (byte*)pSrc;

            for (int i = 0; i < len; i++)
                *pDst_++ = *pSrc_++;
        }

        public static void MemCpy_Jit(void* pDst, byte[] src)
        {
            if (!jit_write_protect_supported)
            {
                fixed(void * pSrc = &src[0])
                {

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Upgrade Unity to a recent version whose bundled Mono exposes Environment.SystemPageSize.
  2. Fork HookUtils_OSX.cs to fall back to sysconf(_SC_PAGESIZE) via P/Invoke when the property is absent.
  3. Reinstall or repair the Unity editor if the Mono runtime is corrupted.
  4. If the hooking feature is non-essential, disable it to avoid the static constructor entirely.

Example fix

// before
PropertyInfo p = typeof(Environment).GetProperty("SystemPageSize");
if (p == null) throw new NotSupportedException("Unsupported runtime");

// after — fallback for macOS
PropertyInfo p = typeof(Environment).GetProperty("SystemPageSize");
_Pagesize = p != null
    ? (int)p.GetValue(null)
    : (int)sysconf(_SC_PAGESIZE); // P/Invoke libc
Defensive patterns

Strategy: validation

Validate before calling

// On macOS, check before using HookUtils
PropertyInfo prop = typeof(Environment).GetProperty("SystemPageSize");
if (prop == null)
{
    Debug.LogError("macOS runtime lacks Environment.SystemPageSize. " +
        "Upgrade Unity or patch HookUtils_OSX with a sysconf fallback.");
    return;
}

Type guard

static bool IsMacOSRuntimeSupported()
{
    return typeof(Environment).GetProperty("SystemPageSize") != null;
}

Try / catch

try
{
    HookUtils.SetAddrFlagsToRWX(ptr, size);
}
catch (NotSupportedException ex) when (ex.Message == "Unsupported runtime")
{
    Debug.LogError("macOS runtime unsupported by HookUtils. " +
        "Upgrade Unity or fork HookUtils_OSX.cs to use sysconf(_SC_PAGESIZE).");
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/bf854aa5bce868ba. Report an issue: GitHub.