SharedMemory Base address mapping

SharedMemory Base address mapping

Post by TmFkYX » Wed, 05 May 2004 07:46:03


Hi

I wonder... Is it possible to define the address to which shared memory will be mapped
In other words is it possible to apriory define the address MapViewOfFile returns
Dlls are being loaded and relocated on the relocation table during Process Creation, is it possible to use/manipulate this mechanism somehow...

Nadav.
 
 
 

SharedMemory Base address mapping

Post by William De » Wed, 05 May 2004 09:10:37


will be mapped?
returns?
Creation, is it possible to use/manipulate this mechanism somehow... ?

Check the docs for MapViewOfFileEx() to see if it will do what you want.

Note that in general, because a virtual address is available in one process
you can not make any claim about the same address in other.

Regards,
Will

 
 
 

SharedMemory Base address mapping

Post by TmFkYX » Wed, 05 May 2004 16:56:02

Hi William

Thanks for your reply, I wonder... Concerning the shared mem mapping is the first thing I do on process startup, doesn't existing memory layout of multiple process may include cases where no two processes may have the same memory block mapped to the same address, e.g. a memory block of about 0.25GB is about to be mapped to the same address of several process ( using MapViewOfFileEx ), is it possible that no continues memory block at the same address ( in each process ) can be found for all process, what is the feasibility for such a scenario? I guess I would have to implement some hand-shake mechanism to achieve this task ( in case it is feasible )..

Nadav
 
 
 

SharedMemory Base address mapping

Post by William De » Thu, 06 May 2004 02:25:14


You are welcome.


I should have been clearer but yes, it is possible that two processes may
not be able to share the same sized block at a common "virtual address". The
point is that the mapping is "per-process". Unlike the case on 9x, it is a
process' view of the shared memory which is associated with an address. On
9x, the shared memory block itself is associated with the shared address.


Yes, you could do that.

I would, however, suggest that you not store pointers in the shared memory.
That's because unless those pointers reference locations in the shared
memory, they are invalid outside of the process that "created" them. In
other words, you can only share references to what is truly shared. :-) So,
if you find a need to share pointers you would store offsets from the start
of the shared memory instead. In that way, each of the processes mapping the
memory could map at any convenient address.

Regards,
Will