home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / msj / msjv3_1 / lim4 / load_ovr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-02  |  1.3 KB  |  45 lines

  1. /*
  2.  
  3. Figure 10
  4. ========
  5.  
  6.  
  7. /******************************************************************/
  8. /* This function implements the DOS load function 0x4b. It sets   */
  9. /* AL to 3 which cause the function to load the exe and apply a   */
  10. /* relocation factor to it, but it does not execute the file.     */
  11. /******************************************************************/
  12.  
  13. int load_overlay(load_file_name,relocation_ptr,page)
  14. char *load_file_name ;
  15. char *(*relocation_ptr);
  16. unsigned int page; /* physical page at which to load */
  17.   
  18. {
  19. struct reloc {
  20.   unsigned int load_seg;
  21.   unsigned int reloc_factor;
  22.   } reloc_struct;
  23.   struct reloc *reloc_struct_ptr;
  24.  
  25.   /* setup up structure to pass to load call */
  26.  
  27.   reloc_struct.load_seg = FP_SEG(*relocation_ptr) + (page * 0x400);
  28.   reloc_struct.reloc_factor = FP_SEG(*relocation_ptr) + 
  29.                                (page * 0x400); 
  30.   
  31.   /* Set up register structures for Intdos call */
  32.  
  33.   inregs.h.ah = 0x4B ;   /* Dos Exec function code */
  34.   inregs.h.al = 3;       /* load but do not execute */
  35.   inregs.x.dx  = FP_OFF(load_file_name);
  36.   segregs.ds   = FP_SEG(load_file_name);
  37.  
  38.   reloc_struct_ptr = &reloc_struct ;
  39.   inregs.x.bx  = FP_OFF(reloc_struct_ptr);
  40.   segregs.es  = FP_SEG(reloc_struct_ptr);
  41.  
  42.   intdosx(&inregs, &outregs, &segregs);
  43.  
  44. }
  45.