DosGetSharedMem

Syntax
DosGetSharedMem( pBaseAddress, ulAttributeFlags )

Parameters

 * PVOID pBaseAddress (input):This is the base virtual address of the gettable and shared memory block.
 * ULONG ulAttributeFlags (input):Flags that describe the desired access protection.

Access protection

 * PAG_READ (0x00000001) tells the system that read access is desired.
 * PAG_WRITE (0x00000002) tells the system that write access is desired.
 * PAG_EXECUTE (0x00000004) tells the system that execute access is desired.
 * PAG_GUARD (0x00000008) tells the system that access to the memory object should cause a guard page exception to be raised, in the subject process.

At least one of PAG_READ,PAG_WRITE or PAG_EXECUTE must be set.

Returns
APIRET rc The following values can be returned:

Usage Explanation
DosGetSharedMem is used to get access to a shared memory block. This will take the virtual address of the memory block and allocate it to the virtual-address space of the process. The virtual address should be the same as the one returned when the gettable shared memory block was created. For the process to know this address, some sort of information exchange must occur between the process, and the process that created the gettable shared memory block.

The shared memory must be gettable (it must have been created by DosAllocSharedMem, with OBJ_GETTABLE set).

The desired access protection must be compatible with the access protection that was set when the gettable shared memory block was created.

Sample Code

 * 1) define INCL_DOSMEMMGR
 * 2) include 
 * 3) include 

PVOID pBaseAddress; /* Pointer to the base address of the allocated memory. */

ULONG ulAttributeFlags; /* Flags describing the memory block's characteristics. */

APIRET rc; /* Recieving the return code */

AttributeFlags = PAG_WRITE | PAG_READ | PAG_COMMIT; /* We request read and write access to the shared memory */ /* block, and also to have the pages of the memory block */ /* committed at once within the virtual memory. */

rc = DosGetSharedMem( pBaseAddress, ulAttributeFlags);

if (rc != 0) {  /* We have an error we must take care of. */ }