Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 1st, 2004, 8:22 PM   #1
AndOrXor
Newbie
 
Join Date: Oct 2004
Posts: 3
Rep Power: 0 AndOrXor is on a distinguished road
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.
AndOrXor is offline   Reply With Quote
Old Oct 1st, 2004, 9:35 PM   #2
Ashcroft
Programmer
 
Join Date: Sep 2004
Posts: 38
Rep Power: 0 Ashcroft is on a distinguished road
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.
Ashcroft is offline   Reply With Quote
Old Oct 1st, 2004, 11:09 PM   #3
AndOrXor
Newbie
 
Join Date: Oct 2004
Posts: 3
Rep Power: 0 AndOrXor is on a distinguished road
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.
AndOrXor is offline   Reply With Quote
Old Oct 2nd, 2004, 12:06 AM   #4
Ashcroft
Programmer
 
Join Date: Sep 2004
Posts: 38
Rep Power: 0 Ashcroft is on a distinguished road
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.
Ashcroft is offline   Reply With Quote
Old Oct 2nd, 2004, 12:12 AM   #5
AndOrXor
Newbie
 
Join Date: Oct 2004
Posts: 3
Rep Power: 0 AndOrXor is on a distinguished road
Thanks, I'll check that out.
AndOrXor is offline   Reply With Quote
Old Oct 2nd, 2004, 12:56 PM   #6
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
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
kurifu is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:16 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC