home *** CD-ROM | disk | FTP | other *** search
/ On Hand / On_Hand_From_Softbank_1994_Release_2_Disc_2_1994.iso / 00202 / s / disk3 / libentry.as_ / libentry.bin
Text File  |  1993-04-28  |  3KB  |  84 lines

  1. PAGE,132
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;
  4. ;       LIBENTRY.ASM
  5. ;
  6. ;       Windows dynamic link library entry routine
  7. ;
  8. ;   This module generates a code segment called INIT_TEXT.
  9. ;   It initializes the local heap if one exists and then calls
  10. ;   the C routine LibMain() which should have the form:
  11. ;   BOOL FAR PASCAL LibMain(HANDLE hInstance,
  12. ;                           WORD   wDataSeg,
  13. ;                           WORD   cbHeap,
  14. ;                           DWORD  ignore);     /* Always NULL - ignore */
  15. ;        
  16. ;   The result of the call to LibMain is returned to Windows.
  17. ;   The C routine should return TRUE if it completes initialization
  18. ;   successfully, FALSE if some error occurs.
  19. ;
  20. ;   Note - The last parameter to LibMain is included for compatibility
  21. ;   reasons.  Applications that wish to modify this file and remove the
  22. ;   parameter from LibMain may do so by simply removing the two
  23. ;   "push" instructions below marked with "****".
  24. ;
  25. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  26.  
  27. include cmacros.inc
  28.  
  29. externFP <LibMain>               ; the C routine to be called
  30.  
  31. createSeg INIT_TEXT, INIT_TEXT, BYTE, PUBLIC, CODE
  32. sBegin    INIT_TEXT
  33. assumes CS,INIT_TEXT
  34.  
  35. ?PLM=0                           ; 'C'naming
  36. externA  <_acrtused>             ; ensures that Win DLL startup code is linked
  37.  
  38. ?PLM=1                           ; 'PASCAL' naming
  39. externFP <LocalInit>             ; Windows heap init routine
  40.  
  41. cProc   LibEntry, <PUBLIC,FAR>   ; entry point into DLL
  42.  
  43. include CONVDLL.INC
  44.  
  45. cBegin
  46.         push    di               ; handle of the module instance
  47.         push    ds               ; library data segment
  48.         push    cx               ; heap size
  49.         push    es               ; Always NULL  ****  May remove (see above)
  50.         push    si               ; Always NULL  ****  May remove (see above)
  51.  
  52.         ; if we have some heap then initialize it
  53.         jcxz    callc            ; jump if no heap specified
  54.  
  55.         ; call the Windows function LocalInit() to set up the heap
  56.         ; LocalInit((LPSTR)start, WORD cbHeap);
  57.         
  58.         xor     ax,ax
  59.         cCall   LocalInit <ds, ax, cx>
  60.         or      ax,ax            ; did it do it ok ?
  61.         jz      error            ; quit if it failed
  62.  
  63.         ; invoke the C routine to do any special initialization
  64.  
  65. callc:
  66.         call    LibMain          ; invoke the 'C' routine (result in AX)
  67.         jmp short exit           ; LibMain is responsible for stack clean up
  68.  
  69. error:
  70.     pop    si         ; clean up stack on a LocalInit error
  71.         pop     es               
  72.         pop     cx               
  73.         pop     ds
  74.         pop     di
  75.  
  76. exit:
  77.  
  78. cEnd
  79.  
  80. sEnd    INIT_TEXT
  81.  
  82. end LibEntry
  83. 
  84.