[ Home | Alpha index | Topic index | Tutorials | Download | Feedback ]

The OS/2 API Project


[ Syntax | Params | Returns | Include | Usage | Structs | Gotchas | Code | Also ]


rc = DosGetSharedMem( pBaseAddress, ulAttributeFlags );


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

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 desired.

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.


The following values can be returned

Include Info

#include <bsememf.h>
#include <os2.h>

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.

Relevant Structures


Sample Code

#define INCL_DOSMEMMGR #include <os2.h> #include <bsememf.h> 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. */ }

See Also

DosAllocSharedMem, DosGetNamedSharedMem, DosGiveSharedMem


Stefan Mars - mars@lysator.liu.se


Last modified March 16/1996
Please send all errors, comments, and suggestions to: timur@vnet.ibm.com

The OS/2 API Project