I'm using runtime memory decryption of one of the Mach-O sections. For doing this I'm using vm_protect like this:
uint8_t *section_start = 0;
unsigned long section_size = 0;
section_start = getsectiondata(&_mh_execute_header, "__TEXT", "__mysection", §ion_size);
// change virtual memory protection
if (vm_protect(mach_task_self(), (vm_address_t)section_start, (vm_size_t)section_size, 0, VM_PROT_READ | VM_PROT_WRITE) != KERN_SUCCESS) {
os_log_error(my_logger, "Virtual memory protection changing to write error");
return false;
}
When I compile Debug configuration with Xcode 10, the vm_protect succeeds. However, the same code compiled with Xcode 11 fails.
I've tried to add these entitlements to the project:
com.apple.security.cs.disable-executable-page-protection
com.apple.security.cs.allow-jit
com.apple.security.cs.allow-unsigned-executable-memory
, without success.
Also changed the signing certificate to Apple Development one that is specifically for Xcode 11, the same result.
Running the project gives the same results on Catalina and Mojave - if built with Xcode 10, succeeds, with Xcode 11 - fails.
Thanks in advance.