[Mono-dev] {kinda OT} Linux equivalent of Win32 "ReadProcessMemory"...

Mike Edenfield kutulu at kutulu.org
Sun Apr 12 19:22:54 EDT 2009


I'm trying to port a utility from Windows that needs to read memory from
a running application.  It's using P/Invoke to call ReadProcessMemory,
which obviously isn't going to work on Linux.

Conceptually, I think this should be "easy":  use
Process.GetProcessByName().Id to get the pid of my target process,
open /proc/{pid}/mem as a filestream, and start reading.  The fact that
it seems so easy is what concerns me.  In particular:
  
* Has anyone actually done something like this and run into non-obvious
problems?  I'm most concerned that there are some gotchas in how Linux
manages memory, though if its just a matter of trial and error to find
the right spots in memory I'm already assuming that's coming.

* Is there an easier way to do this that I'm missing?  I briefly looked
for a glibc function that was similar to ReadProcessMemory and came up
empty.

--Mike



More information about the Mono-devel-list mailing list