Skip to content

Commit 4768c03

Browse files
committed
[fix] fixed hook failed in version below MacOS 11
1 parent 10dc749 commit 4768c03

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

Editor/3rds/UnityHook/HookUtils_OSX.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ public static unsafe class HookUtils
1616

1717
static HookUtils()
1818
{
19-
jit_write_protect_supported = pthread_jit_write_protect_supported_np() != 0;
19+
try
20+
{
21+
jit_write_protect_supported = pthread_jit_write_protect_supported_np() != 0;
22+
}
23+
catch { }
2024

2125
PropertyInfo p_SystemPageSize = typeof(Environment).GetProperty("SystemPageSize");
2226
if (p_SystemPageSize == null)
@@ -35,6 +39,16 @@ public static void MemCpy(void* pDst, void* pSrc, int len)
3539

3640
public static void MemCpy_Jit(void* pDst, byte[] src)
3741
{
42+
if (!jit_write_protect_supported)
43+
{
44+
fixed(void * pSrc = &src[0])
45+
{
46+
MemCpy(pDst, pSrc, src.Length);
47+
}
48+
49+
return;
50+
}
51+
3852
fixed(void * p = &src[0])
3953
{
4054
memcpy_jit(new IntPtr(pDst), new IntPtr(p), src.Length);

0 commit comments

Comments
 (0)