[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

CreateFileMapping vs Read/WriteProcessMemory

christianlott1

8/16/2011 8:54:00 PM

If I use CreateFileMapping I must 'own' both applications. They share
a globally allocated chunk of memory.

I want to create a pointer into another process address space and use
this pointer as the 'File Map'. In other words, the other application
just reads and writes to it's memory as always, unchanged. I can do
this with ReadProcessMemory and WriteProcessMemory using the process
handle and an offset into it's process memory. I'd rather just create
a mapping so I don't need to constantly update the data (with a
timer).

Is there any way to do this? I was hoping CreateFileMapping would
accept my Process ID instead of File Handle. Maybe there is a way to
turn a Process ID + offset and range into a File Handle I can pass to
CreateFileMapping / CreateFile ie ...

Can I use CreateFile ( or some other method ) to return a handle to a
separate process address offset+range?

Thanks



1 Answer

ralph

8/16/2011 9:50:00 PM

0

On Tue, 16 Aug 2011 13:53:54 -0700 (PDT), 5k3105
<christianlott1@yahoo.com> wrote:

>If I use CreateFileMapping I must 'own' both applications. They share
>a globally allocated chunk of memory.
>
>I want to create a pointer into another process address space and use
>this pointer as the 'File Map'. In other words, the other application
>just reads and writes to it's memory as always, unchanged. I can do
>this with ReadProcessMemory and WriteProcessMemory using the process
>handle and an offset into it's process memory. I'd rather just create
>a mapping so I don't need to constantly update the data (with a
>timer).
>
>Is there any way to do this? I was hoping CreateFileMapping would
>accept my Process ID instead of File Handle. Maybe there is a way to
>turn a Process ID + offset and range into a File Handle I can pass to
>CreateFileMapping / CreateFile ie ...
>
>Can I use CreateFile ( or some other method ) to return a handle to a
>separate process address offset+range?
>
>Thanks
>
>

In general operation - No process in Windows can directly address
another process's address space, nor would you want to unless you were
writing a debugger.

It sounds like you are attempting to work with Memory-Mapped Files.
First read this:
"Managing Memory-Mapped Files"
http://msdn.microsoft.com/en-us/library/ms8...
A tad dated, but not that much, the basics are still the same. MMFs
are a major part of the VMM.
(Also note that while a shared file definitely exists in 'physical'
memory somewhere - the actual addressing of that location is almost
guareenteed to be different within the address space of any client
sharing that file. Thus no <ProcessIDOfSomeKind + Offset> is ever
going to work.)

When using VB you can not manage 'addresses' directly. The work-around
as pointed out by the following post is to define a Data Type and work
with it.
http://forums.devx.com/showthread.p...
http://vb.mvps.org/hardcore/html/sharedmemorythroughmemory-mappe...
....

There are lot's of better examples out there, but this should get you
started.

-ralph