en:docs:fapi:doscreatecsalias

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:docs:fapi:doscreatecsalias [2021/08/20 03:23] prokusheven:docs:fapi:doscreatecsalias [2021/12/05 06:38] (current) prokushev
Line 2: Line 2:
 ====== DosCreateCSAlias ====== ====== DosCreateCSAlias ======
  
-==Syntax== +===== Syntax =====
- DosCreateCSAlias (DataSelector, CodeSelector)+
  
-==Parameters== +<code c> 
-;DataSelector (SEL) - input : Data segment selector. +DosCreateCSAlias (DataSelector, CodeSelector) 
-;CodeSelector (PSEL) - output : Address where the selector of the code segment alias descriptor is returned.+</code> 
 + 
 +===== Parameters ===== 
 + 
 +  DataSelector ([[SEL]]) - input : Data segment selector. 
 +  CodeSelector ([[PSEL]]) - output : Address where the selector of the code segment alias descriptor is returned. 
 + 
 +===== Return Code ===== 
 + 
 + 
 +rc ([[USHORT]]) - return
  
-==Return Code== 
- rc (USHORT) - return 
 Return code descriptions are: Return code descriptions are:
-* 0        NO_ERROR +  * 0        NO_ERROR 
-* 5        ERROR_ACCESS_DENIED +  * 5        ERROR_ACCESS_DENIED  
 + 
 +===== Remarks =====
  
-==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 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. 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.
Line 22: Line 30:
 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. 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.+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 ====
  
-===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. 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== +==== Example Code ==== 
-===C Binding===+ 
 +=== C Binding ===
  
 +<code c>
   #define INCL_DOSMEMMGR   #define INCL_DOSMEMMGR
      
Line 38: Line 49:
      
   USHORT           rc;            /* return code */   USHORT           rc;            /* return code */
 +</code>
 +=== Example ===
  
-'''Example''' 
  
 This example requests a block of memory (data segment) then requests a descriptor of the segment marking it as a code segment.  This example requests a block of memory (data segment) then requests a descriptor of the segment marking it as a code segment. 
  
 +<code c>
   #define INCL_DOSMEMMGR   #define INCL_DOSMEMMGR
      
Line 57: Line 70:
       rc = DosCreateCSAlias(Selector,       /* Data segment selector */       rc = DosCreateCSAlias(Selector,       /* Data segment selector */
                             &CodeSel);      /* Code segment selector */                             &CodeSel);      /* Code segment selector */
 +</code>
  
-===MASM Binding=== +=== MASM Binding === 
 +<code asm>
   EXTRN  DosCreateCSAlias:FAR   EXTRN  DosCreateCSAlias:FAR
   INCL_DOSMEMMGR      EQU 1   INCL_DOSMEMMGR      EQU 1
Line 66: Line 80:
   PUSH@  WORD    CodeSelector  ;Code segment selector (returned)   PUSH@  WORD    CodeSelector  ;Code segment selector (returned)
   CALL   DosCreateCSAlias   CALL   DosCreateCSAlias
-  +</code>  
 Returns WORD Returns WORD
  
  
-====== Note ======+==== Note ==== 
  
 Text based on [[http://www.edm2.com/index.php/DosCreateCSAlias]] Text based on [[http://www.edm2.com/index.php/DosCreateCSAlias]]