❯ clang main.m
main.m:19:32: error: implicit declaration of function 'mach_vm_allocate' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
kern_return_t kernReturn = mach_vm_allocate(mach_task_self(), &address, shellcodeLength, VM_FLAGS_ANYWHERE);
^
main.m:19:32: note: did you mean 'mach_port_allocate'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/mach_port.h:131:15: note: 'mach_port_allocate' declared here
kern_return_t mach_port_allocate
^
main.m:23:42: warning: format specifies type 'void *' but the argument has type 'mach_vm_address_t' (aka 'unsigned long long') [-Wformat]
printf(" |-> Address: %p\n", address);
~~ ^~~~~~~
%llu
main.m:31:18: error: implicit declaration of function 'mach_vm_protect' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
kernReturn = mach_vm_protect(mach_task_self(), address, shellcodeLength, false, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE);
^
main.m:31:18: note: did you mean 'vm_protect'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/vm_map.h:119:15: note: 'vm_protect' declared here
kern_return_t vm_protect
^
main.m:42:18: error: implicit declaration of function 'mach_vm_write' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
kernReturn = mach_vm_write(mach_task_self(), address, shellcode, shellcodeLength);
^
main.m:42:18: note: did you mean 'mach_vm_wire'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/host_priv.h:315:15: note: 'mach_vm_wire' declared here
kern_return_t mach_vm_wire
^
1 warning and 3 errors generated.
===================================
❯ clang main.m -std=c89
main.m:19:32: error: implicit declaration of function 'mach_vm_allocate' [-Werror,-Wimplicit-function-declaration]
kern_return_t kernReturn = mach_vm_allocate(mach_task_self(), &address, shellcodeLength, VM_FLAGS_ANYWHERE);
^
main.m:19:32: note: did you mean 'mach_port_allocate'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/mach_port.h:131:15: note: 'mach_port_allocate' declared here
kern_return_t mach_port_allocate
^
main.m:23:42: warning: format specifies type 'void *' but the argument has type 'mach_vm_address_t' (aka 'unsigned long long') [-Wformat]
printf(" |-> Address: %p\n", address);
~~ ^~~~~~~
%llu
main.m:31:18: error: implicit declaration of function 'mach_vm_protect' [-Werror,-Wimplicit-function-declaration]
kernReturn = mach_vm_protect(mach_task_self(), address, shellcodeLength, false, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE);
^
main.m:31:18: note: did you mean 'vm_protect'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/vm_map.h:119:15: note: 'vm_protect' declared here
kern_return_t vm_protect
^
main.m:42:18: error: implicit declaration of function 'mach_vm_write' [-Werror,-Wimplicit-function-declaration]
kernReturn = mach_vm_write(mach_task_self(), address, shellcode, shellcodeLength);
^
main.m:42:18: note: did you mean 'mach_vm_wire'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/host_priv.h:315:15: note: 'mach_vm_wire' declared here
kern_return_t mach_vm_wire
^
1 warning and 3 errors generated.
======================================
so, how can i build it?