![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Oct 2004
Posts: 3
Rep Power: 0
![]() |
I have a memory offset for a process, but I want to access that memory from my own process. How would I (1) convert the offset to be able to use it from my program, and (2) use that real memory location in my program.
Keep in mind that I don't want to force a library into the other program, I just want to be able to modify its memory from my program. |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Sep 2004
Posts: 38
Rep Power: 0
![]() |
The problem is that in most operating systems that memory offset is not absolute, it is relative to the memory of that particular program - the fact that one program can not accidentaly step on another is considered a feature.
How you can use memory from another process will depend on what OS you are using. Some Unixes have a shared memory library where you can export a memory segment and attach to it from other processes (sys V shared memory - check for shmctl man page to see if you have it on your system). You may also want to consider using some form of RPC (named pipes, pipes, threads, doors) to communicate between processes. There is also the possibility of using 'mmap'. Pretty much any of these require modification of the "server" process to some extent and will require a semaphore or mutex to protect the memory that is shared between processes. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Oct 2004
Posts: 3
Rep Power: 0
![]() |
This is just Windows (XP), and I know that the memory location is relative to the program, that's the problem I'm trying to solve.
![]() |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Sep 2004
Posts: 38
Rep Power: 0
![]() |
Haven't done any advanced Windows programming in a while, but CreateFileMapping and MapViewOfFile are fairly close to mmap for creating a shared mem maping. Search for either of those on msdn.
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Oct 2004
Posts: 3
Rep Power: 0
![]() |
Thanks, I'll check that out.
|
|
|
|
|
|
#6 |
|
Expert Programmer
|
In Windows XP the memory offset assigned is virtual memory, it is relatively only to the application that is currently running. There are ways in windows of sharing memory, one sech way this can be done is through a DLL file which delcares shared memory segments.
Also, if you have permissions to access the memory block of another application I believe there is another way of doing it, but i could not tell you how that is done offhand. Checkout http://www.thecodeproject.com, they probably have a tutorial on there for doing it. Good luck.
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|