Jump to content

DosCreateCSAlias: Difference between revisions

From EDM2
Created page with "==Description== This call creates a code segment alias descriptor for a data segment passed as input. ==Syntax== <PRE> DosCreateCSAlias (DataSelector, CodeSelector) </P..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
This call creates a code segment alias descriptor for a data segment passed as input.
This call creates a code segment alias descriptor for a data segment passed as input.


==Syntax==
==Syntax==
<PRE>
  DosCreateCSAlias (DataSelector, CodeSelector)
  DosCreateCSAlias


    (DataSelector, CodeSelector)
</PRE>
==Parameters==
==Parameters==
; DataSelector (SEL) - input : Data segment selector.  
;DataSelector ([[SEL]]) - input : Data segment selector.
 
;CodeSelector (PSEL) - output : Address where the selector of the code segment alias descriptor is returned.
; CodeSelector (PSEL) - output : Address where the selector of the code segment alias descriptor is returned.


==Return Code==
==Return Code==
rc (USHORT) - return
;rc (USHORT) - return:Return code descriptions are:
 
*0 NO_ERROR
Return code descriptions are:
*5 ERROR_ACCESS_DENIED
 
* 0       NO_ERROR
* 5       ERROR_ACCESS_DENIED  


==Remarks==
==Remarks==
Line 29: Line 21:


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.
==Bindings==
 
===C===
 
==Example Code==
===C Binding===
<PRE>
<PRE>
#define INCL_DOSMEMMGR
#define INCL_DOSMEMMGR
Line 43: Line 32:
USHORT  rc = DosCreateCSAlias(DataSelector, CodeSelector);
USHORT  rc = DosCreateCSAlias(DataSelector, CodeSelector);


SEL             DataSelector;  /* Data segment selector */
SEL     DataSelector;  /* Data segment selector */
PSEL             CodeSelector;  /* Code segment selector (returned) */
PSEL   CodeSelector;  /* Code segment selector (returned) */


USHORT           rc;            /* return code */
USHORT rc;            /* return code */
</PRE>
</PRE>
'''Example'''


This example requests a block of memory (data segment) then requests a descriptor of the segment marking it as a code segment.  
===MASM===
<PRE>
EXTRN  DosCreateCSAlias:FAR
INCL_DOSMEMMGR      EQU 1
 
PUSH  WORD    DataSelector  ;Data segment selector
PUSH@  WORD    CodeSelector  ;Code segment selector (returned)
CALL  DosCreateCSAlias
 
Returns WORD
</PRE>
 
==Example==
This example requests a block of memory (data segment) then requests a descriptor of the segment marking it as a code segment.
<PRE>
<PRE>
#define INCL_DOSMEMMGR
#define INCL_DOSMEMMGR
Line 68: Line 69:
</PRE>
</PRE>


===MASM Binding===
[[Category:Dos16]]
<PRE>
EXTRN  DosCreateCSAlias:FAR
INCL_DOSMEMMGR      EQU 1
 
PUSH  WORD    DataSelector  ;Data segment selector
PUSH@  WORD    CodeSelector  ;Code segment selector (returned)
CALL  DosCreateCSAlias
 
Returns WORD
</PRE>
==Related Functions==
*
 
 
[[Category:The OS/2 API Project]]

Latest revision as of 12:58, 29 February 2020

This call creates a code segment alias descriptor for a data segment passed as input.

Syntax

DosCreateCSAlias (DataSelector, CodeSelector)

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

Bindings

C

#define INCL_DOSMEMMGR

USHORT  rc = DosCreateCSAlias(DataSelector, CodeSelector);

SEL     DataSelector;  /* Data segment selector */
PSEL    CodeSelector;  /* Code segment selector (returned) */

USHORT  rc;            /* return code */

MASM

EXTRN  DosCreateCSAlias:FAR
INCL_DOSMEMMGR      EQU 1

PUSH   WORD    DataSelector  ;Data segment selector
PUSH@  WORD    CodeSelector  ;Code segment selector (returned)
CALL   DosCreateCSAlias

Returns WORD

Example

This example requests a block of memory (data segment) then requests a descriptor of the segment marking it as a code segment.

#define INCL_DOSMEMMGR

#define NUMBER_OF_BYTES 120
#define ALLOC_FLAG SEG_GETTABLE

SEL    CodeSel;
SEL    Selector;
USHORT rc;

   if(!DosAllocSeg(NUMBER_OF_BYTES,         /* # of bytes requested */
                   &Selector,               /* Selector allocated */
                   ALLOC_FLAG))             /* Allocation flags */
      rc = DosCreateCSAlias(Selector,       /* Data segment selector */
                            &CodeSel);      /* Code segment selector */