Reputation: 16070
My goal is to set virtual memory page permissions (as if the forked process called mprotect
) from the parent process. Can this be done with ptrace(1)
or by some other magic?
Thanks!
Upvotes: 1
Views: 415
Reputation: 14004
It can be done (via ptrace()
indeed; gdb
can do this), but not without a lot of finagling, since in order to call a function in another process, you basically have to setup its registers and stack, etc. for execution, and then continue the process, which will execute the function. One program I know off the top of my head that might have some useful source/methodology for you to look at is injectso. If you do look at injectso, look at the inject_code()
functions.
In addition, calling conventions vary by platform, so you'd have to re-jigger your code for each architecture/OS, etc.
Upvotes: 3