[ Home |
Alpha index |
Topic index |
The OS/2 API Project
[ Syntax |
rc = DosGiveSharedMem( pBaseAddress,
- PVOID pBaseAddress (input)
- This should contain the base address of the shared and giveable memory block. It should
be the same address as the one returned when the block was created, using DosAllocSharedMem.
- PID idProcessId (input)
- The identifier of the process that should get access to the shared memory block.
- ULONG ulAttributeFlags (input)
- Attribute flags describing the desired access protection of the shared memory block.
- Setting PAG_READ (0x00000001) tells the system that read access is desired.
- Setting PAG_WRITE (0x00000002) tells the system that write access is desired.
- Setting PAG_EXECUTE (0x00000004) tells the system that execute access is
- Setting 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.
- APIRET rc
- The following values can be returned
DosGiveSharedMem is used to give another process access to a shared memory
block. This will allocate the virtual address of the memory block into the
virtual-address space of the process that recieves the access of the memory
block. This is very similar to the process using DosGetSharedMem by itself to gain access to
the shared memory block.
The shared memory block that is specified with the virtual address must be
a giveable block. That is, it must have been created using
DosAllocSharedMem with the
OBJ_GIVEABLE attribute set.
The desired access protection must also be compatible with the access
protection the shared memory block received when it was created.
/* Pointer to the shared memory block. */
/* Flags describing the memory block */
/* Identificarion of the process that should be */
/* granted access to the shared and giveable */
/* memory block. */
/* Just for taking care of the return code */
/* So we create another process, and store the identification in */
/* ProcessID. We also use DosAllocSharedMem to create a */
/* shared and givable memory block, storing the base address */
/* of this block in BaseAddress. For this example we assume the */
/* memory block was created as giveable, readable and writeable. */
AttributeFlags = PAG_WRITE | PAG_READ;
rc = DosGiveSharedMem( BaseAddress, ProcessID, AttributeFlags);
if (rc != 0)
/* We have an error we must take care of. */
Stefan Mars -
Last modified March 16/1996
Please send all errors, comments, and suggestions to:
The OS/2 API Project