Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Blinker 5.10 Online Reference - <b> doscreatedsalias()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 DosCreateDSAlias()
------------------------------------------------------------------------------
 Purpose:
 Create a data selector corresponding to an executable (code) selector.

 Syntax:
 USHORT BLXAPI DosCreateDSAlias(SEL codesel, PSEL datasel);

 Parameters:
 codesel  Code selector to be aliased.
 datasel  Pointer to an integer to receive the data selector (alias).

 Returns:
 Data selector corresponding to an executable code selector.
 The returned selector has the same linear base address and limit as the
 original code selector, but has a read / write code attribute.

 Description:

 Note:
 The original code selector should be locked in memory (using DosLockSeg())
 prior to creating the alias selector. This ensures that the original
 selector will not be swapped out of memory, which could later cause the
 linear base address of the segment to change when the segment is
 subsequently reloaded from disk. This is necessary because alias selectors
 do not track changes to the original selector. The original code selector
 may be unlocked by calling DosUnlockSeg() after the alias selector has been
 freed using DosFreeSelector().

 This function allows code segments to be written to.

 Example:
 #include <stdlib.h>                                                         
 #include <stdio.h>                                                          
 #include <string.h>                                                         
 #include <blx286.h>                                                         
                                                                             
 void main(void)                                                             
 {                                                                           
 SEL      datasel                                                            
                                                                             
 /* Lock the segment first */                                                
 DosLockSeg(SELECTOROF(test));                                               
 if (DosCreateDSAlias (SELECTOROF (test), &datasel) != 0)                    
    {                                                                        
    printf ("DosCreateDSAlias() failed\n");                                  
    exit (255);                                                              
    }                                                                        
 printf ("Code selector for test() is %04X\n", SELECTOROF(test));            
 printf ("Data selector is %04X\n",datasel);                                 
 DosFreeSelector(datasel);                                                   
 }                                                                           

See Also: DosCreateCSAlias() DosLockSeg()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson