Now we want to use the system call of `
mprotect` to access and execute any function in dynamic way. It is really usage in hot patching running process. Normaly, we use `
mprotect` with flags like `PROT_WRITE` or `PROT_READ` and it should work in Linux and MacOS(before Catalina).
Recently we found that `
mprotect` with `PROT_WRITE` will fail and return zero even throught we have grant the priviledges to the process. It may be the security issue so we disable the csrutil and codesign with almost all the entitlements before testing but it still fail.
Here are the related discussion: https://github.com/flutter/flutter/issues/36714 https://github.com/agiledragon/gomonkey/issues/10 https://stackoverflow.com/questions/60654834/using-mprotect-to-make-text-segment-writable-on-macos
Are you trying to generate code? Or patch existing code within the
__TEXT section of a Mach-O image?
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"