Let's say I have this function defined in a child process:
Code:
void hello()
{
    printf("hello\n");
}
And I know the function's address in the virtual memory of the child process, say 0x8049cc4.

How can I share this location in memory and have the parent read it so that I can call it from the parent process. Like this:
Code:
typedef void (*hello_t)();
hello_t hello = (hello_t)0x8049cc4; //this is where I need help
hello();
The important part to remember when proposing a solution is that the function is called in the child process still. The real function requires variables in the child process.

I know this is possible using a shared library and LD_PRELOAD, but I wish to avoid this. However, I could accept a method to load a shared library into the process after it has already started, but I wish to avoid any "illegal" methods.


Thanks.