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

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
Suppose I want to build a C++ program that can manipulate another program's data. My program knows where this data is located and what kind of data it's supposed to be dealing with (int, string, etc.). How do I tell my program to access and change this data?

----------

I think I found my answer:

http://stackoverflow.com/questions/6016156/accessing-memory-of-other-applications-c

I'll have to use an API that OS X Yosemite supports; given Apple's obsession with security, I doubt any such API exists.

Edit: Another answerer says I could also try launching the program in question from within my program.
 
Last edited:
Assuming you control the code in both processes, the most straight-forward way is to use the shared memory system calls. You create a shared memory area and then map that area into the memory space of both processes. Then any modifications made by one process will show up in the other process. Synchronization is going to be up to you.

The system calls are calls like shmat(), shmget(), shm_open(), etc. Depending on what kind of interface you're looking for to create the shared memory area. There are man pages which describe those functions and probably docs in the Apple Documentation set.

If you aren't writing the code for both processes then you are going to need to go through the Darwin kernel to get access.
 
Assuming you control the code in both processes, the most straight-forward way is to use the shared memory system calls. You create a shared memory area and then map that area into the memory space of both processes. Then any modifications made by one process will show up in the other process. Synchronization is going to be up to you.

The system calls are calls like shmat(), shmget(), shm_open(), etc. Depending on what kind of interface you're looking for to create the shared memory area. There are man pages which describe those functions and probably docs in the Apple Documentation set.

If you aren't writing the code for both processes then you are going to need to go through the Darwin kernel to get access.

Thanks. Would you mind posting how to go through the kernel? It may be online, but it'd be nice for the searcher who comes across this thread to have all this information in one place.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.