Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jester831

macrumors newbie
Original poster
Aug 16, 2008
5
0
Do any of the mac programming languages have a function for reading or writing to another programs memory?
 

larkost

macrumors 6502a
Oct 13, 2007
534
1
What is your goal here? If you are looking to reach into someone else's code, or are you looking at doing inter-process communication?
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
You may also want to look in to shared memory. It may not be exactly what you need here, but it would allow you have a "buffer" shared between processes. You would need to implement some coherency checking using some sort of lock.

Another option would be using a file that you memory map in various processes. Again, coherency checking will be needed.

Cromulent already mentioned IPC, which would also be an option if these processes have a parent/child relationship.

This page describes about all of these options I've mentioned:
http://www.ecst.csuchico.edu/~beej/guide/ipc/

As an aside, I can't believe something like that exists in the Win32 API. When I searched for it, in the first page of google results there is an MSDN blog post explaining some reasons why the use of ReadProcessMemory is a bad idea anyway.
http://blogs.msdn.com/oldnewthing/archive/2006/01/17/513779.aspx

-Lee
 

Jester831

macrumors newbie
Original poster
Aug 16, 2008
5
0
It's a buddy program for another program that I did not write... stuff like shared memory and IPC isn't really viable. Soo, is it impossible then?
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
here's a write up on that topic: http://nntp.pl/readprocessmemory-and-writeprocessmemory-on-os-x/ (check out the linked pdf)

(sorry for necroing but google spits this thread here out as on of the few results for that topic and there's not much useful info in this topic)

In case that article disappears here's the $0.05 summary.
Code:
ReadProcessMemory() -> vm_read_overwrite()
WriteProcessMemory() -> vm_write()

It references the book "Mac OS X Internals: A Systems Approach" by Amit Singh.

B
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.