Search code examples
unixparent-childvirtual-address-space

Change the process virtual address space of a child process


I would like to know if it is poosible to change the virtual address space of a child process in Unix like operating system. I want to have the ability to

(a) Load/unload shared libraries

(b) Write to random user space memory locations of the child process ( not shared memory)

I basically want complete control (think windows 95 like control) over the process address space of a child process.

I know debuggers achieve this to a certain extent, but do you achieve this (system calls to be used, tutorials about subject,etc)??


Solution

  • You need to look into ptrace.

     ptrace() provides tracing and debugging facilities.  It allows one
     process (the tracing process) to control another (the traced process).
    

    You can use PTRACE_ATTACH to start tracing, PTRACE_GETREGS (SETREGS) to get/set registers, PTRACE_PEEKUSER (POKEUSER) to read/write user data and PTRACE_PEEKDATA (POKEDATA) to read/write data/code sections.