in reply to Reading memory of a different process

No, usually not. There are two things to prevent that. First, the address you get is an address that local to your process. You might run the process several times, and get the same address, while in physical memory, it's mapped to a different place each time (in fact, it's very likely it will be mapped to a different place, and during the lifetime of the process, the physical address might change (think swapping)). Secondly, your OS will not allow you to access the memory of another process directly.

That's not to say there it's entirely impossible. Most modern (Unix) OSses do have some API to access the memory. Either in its entire, like /dev/mem, or on a process by process bases using /proc/PID/mem.

Note that the typical way of sharing memory between processes involves setting up a shared memory segment. IPC::SysV might help you set it up.

  • Comment on Re: Reading memory of a different process

Replies are listed 'Best First'.
Re^2: Reading memory of a different process
by Anonymous Monk on Feb 01, 2005 at 11:05 UTC
    Most modern (Unix) OSses do have some API to access the memory (...) /proc/PID/mem

    Hi AM,

    I've read the proc manpage on Linux and it looks like I should be able to read the memory with something as simple as cating the file, but I always get nothing back (Perl's sysread returns undef). cat /proc/PID/maps however works.

    Is this normal?