no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Next revision | |||
— | en:docs:fapi:doscreatecsalias [2018/08/31 07:38] – created prokushev | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | ==Syntax== | ||
+ | | ||
+ | |||
+ | ==Parameters== | ||
+ | ; | ||
+ | ; | ||
+ | |||
+ | ==Return Code== | ||
+ | rc (USHORT) - return | ||
+ | Return code descriptions are: | ||
+ | * 0 NO_ERROR | ||
+ | * 5 ERROR_ACCESS_DENIED | ||
+ | |||
+ | ==Remarks== | ||
+ | A selector returned by a call to DosAllocSeg with no sharing options specified can be used as the data segment specified with DosCreateCSAlias. However, to be CS alias, the segment must be a privilege level 2 or privilege level 3 non-shared segment. | ||
+ | |||
+ | A CS alias segment must be exclusively accessible by the process and cannot be a huge segment. Selectors of shared memory segments and dynamically linked global data segments cannot be used as input for DosCreateCSAlias. | ||
+ | |||
+ | The code segment selector returned by DosCreateCSAlias is valid for CS. If a procedure is stored in the data segment, it can be called using the CS alias. The procedure may be called from privilege level 3 or I/O privilege level. | ||
+ | |||
+ | Use DosFreeSeg to free a CS alias selector created with DosCreateCSAlias. Procedures in the segment can continue to be referenced if the data selector for the aliased segment is passed to DosFreeSeg, because the CS alias selector is not affected. Once both selectors have been passed to DosFreeSeg, the segment is deallocated. | ||
+ | |||
+ | ===Family API Considerations=== | ||
+ | The returned selector is the segment address of the allocated memory. When the returned selector or the original selector is freed, OS/2 immediately deallocates the block of memory. | ||
+ | |||
+ | ==Example Code== | ||
+ | ===C Binding=== | ||
+ | <PRE> | ||
+ | #define INCL_DOSMEMMGR | ||
+ | |||
+ | USHORT | ||
+ | |||
+ | SEL DataSelector; | ||
+ | PSEL | ||
+ | |||
+ | USHORT | ||
+ | </ | ||
+ | ''' | ||
+ | |||
+ | This example requests a block of memory (data segment) then requests a descriptor of the segment marking it as a code segment. | ||
+ | <PRE> | ||
+ | #define INCL_DOSMEMMGR | ||
+ | |||
+ | #define NUMBER_OF_BYTES 120 | ||
+ | #define ALLOC_FLAG SEG_GETTABLE | ||
+ | |||
+ | SEL CodeSel; | ||
+ | SEL Selector; | ||
+ | USHORT rc; | ||
+ | |||
+ | | ||
+ | & | ||
+ | | ||
+ | rc = DosCreateCSAlias(Selector, | ||
+ | & | ||
+ | </ | ||
+ | |||
+ | ===MASM Binding=== | ||
+ | <PRE> | ||
+ | EXTRN DosCreateCSAlias: | ||
+ | INCL_DOSMEMMGR | ||
+ | |||
+ | PUSH | ||
+ | PUSH@ WORD CodeSelector | ||
+ | CALL | ||
+ | |||
+ | Returns WORD | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====== Note ====== | ||
+ | |||
+ | Text based on [[http:// | ||
+ | |||
+ | {{page> | ||
+ | |||