Purpose
DosAliasMem creates a private Read/Write alias or an LDT code segment alias to part of an existing memory object. The alias object is accessible only to the process that created it. The original object must be accessible to the caller of DosAliasMem.
Syntax
#define INCL_DOSMEMMGR #include os2.h>
APIRET APIENTRY DosAliasMem
Parameters
pMem (PMEM) input
sel = (SEL) ((ULONG) (*ppAlias) >> 13 | 7)flags (FLAGS) input
OBJ_SELMAPALL (0x00000800)
If OBJ_SELMAPALL is not specified, then size is rounded up to a 4K multiple and the alias created inherits the permissions from the pages of the original object.
OBJ_TILE may be specified, but currently this is enforced whether or not specified. This forces LDT selectors to be based on 64K boundaries.
Returns
ulrc (APIRET) returns
DosAliasMem returns one of the following values
87
Remarks
An export for DosAliasMem does not appear in versions of OS2386.LIB distributed prior to Warp Server for e-business. When using older versions, the following statements should be added to the link edit .DEF file
importsDosAliasMem = DOSCALLS.298
An alias is removed by calling DosFreeMem with the alias address.
Though it is possible to create a Read/Write alias to a code segment to allow code modification this is not recommended. On Pentium(R) processors, and later, pipe-lining techniques used by the processor might allow the processor not to be aware of the modified code, if appropriate pipe-line serialization is not performed by the programmer. For further information see the processor documentation.
Related Functions
Example Code
#define INCL_DOSMEMMGR#include int main(int argc, char *argv[], char *envp[]) { PVOID pAlias; PVOID pMem; APIRET rc; /* alias a read-only shared memory object as a private read/write */ /* object. This will allow clients of this object to read only */ /* while allowing the owner to update it. */ rc=DosAllocSharedMem( pMem,NULL,128*1024, PAG_READ+PAG_COMMIT+OBJ_GIVEABLE); rc = DosAliasMem(pMem, 128*1024, pAlias, OBJ_TILE); . . . . return 0; }