diff options
author | Zeex <zeex@rocketmail.com> | 2020-11-11 01:54:03 +0600 |
---|---|---|
committer | Zeex <zeex@rocketmail.com> | 2020-11-11 01:54:05 +0600 |
commit | a292bd33e1212057f7abc86210b5eeefc3c68e7f (patch) | |
tree | ca5a5ebc7b2e9c94f90c9a40bcfea866d0dba42e /subhook_unix.c | |
parent | 063df0fd5c82194a8579a4ea6c8700a0b22642cb (diff) | |
download | subhook-a292bd33e1212057f7abc86210b5eeefc3c68e7f.zip subhook-a292bd33e1212057f7abc86210b5eeefc3c68e7f.tar.gz subhook-a292bd33e1212057f7abc86210b5eeefc3c68e7f.tar.bz2 |
Don't use MAP_32BIT on macOS
This flag requires use of entitlements i.e. code signing...
Diffstat (limited to 'subhook_unix.c')
-rw-r--r-- | subhook_unix.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/subhook_unix.c b/subhook_unix.c index d0d1251..6a5410b 100644 --- a/subhook_unix.c +++ b/subhook_unix.c @@ -40,15 +40,18 @@ int subhook_unprotect(void *address, size_t size) { } void *subhook_alloc_code(size_t size) { - return mmap(NULL, - size, - SUBHOOK_CODE_PROTECT_FLAGS, - #ifdef MAP_32BIT - MAP_32BIT | - #endif - MAP_PRIVATE | MAP_ANONYMOUS, - -1, - 0); + void *address; + + address = mmap(NULL, + size, + SUBHOOK_CODE_PROTECT_FLAGS, + #if defined MAP_32BIT && !defined __APPLE__ + MAP_32BIT | + #endif + MAP_PRIVATE | MAP_ANONYMOUS, + -1, + 0); + return address == MAP_FAILED ? NULL : address; } int subhook_free_code(void *address, size_t size) { |