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

Gladish, Jacob Jacob.Gladish at sig.com
Mon Apr 13 09:18:09 EDT 2009

Is there a particular piece of memory you're looking for? Environmental variables, etc., or are you simply trying to read arbitrary bytes from another processes?

-----Original Message-----
From: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of Mike Edenfield
Sent: Sunday, April 12, 2009 7:23 PM
To: mono-devel
Subject: [Mono-dev] {kinda OT} Linux equivalent of Win32 "ReadProcessMemory"...

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


Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

More information about the Mono-devel-list mailing list