home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / mag&info / msjv7_4.zip / NETBIOS2.ARJ / LIBENTRY.ASM < prev    next >
Assembly Source File  |  1992-07-01  |  2KB  |  69 lines

  1. ;==========================================================================
  2. ; PROGRAM: libentry.asm
  3. ;
  4. ; PURPOSE: Provided DLL entry point for Windows to call into
  5. ;
  6. ; FUNCTIONS:
  7. ;           Libentry - Windows calls this routine to initialize the DLL
  8. ;
  9. ; HISTORY:
  10. ;           January, 1992       Ray Patch       Created
  11. ;
  12. ;==========================================================================
  13.  
  14. PAGE    ,132
  15.  
  16.     extrn LibMain:far          ; the C routine to be called
  17.     extrn LocalInit:far        ; Windows heap init routine
  18.     extrn __acrtused:abs       ; ensures that Win DLL startup code is linked
  19.  
  20.     public LibEntry            ; entry point for the DLL
  21.  
  22. INIT_TEXT segment byte public 'CODE'
  23.         assume cs:INIT_TEXT
  24.  
  25. LibEntry   proc far
  26.  
  27.            push    di          ; handle of the module instance
  28.            push    ds          ; library data segment
  29.            push    cx          ; heap size
  30.            push    es          ; command line segment
  31.            push    si          ; command line offset
  32.  
  33.     ; if we have some heap then initialize it
  34.  
  35.            jcxz    callc       ; jump if no heap specified
  36.  
  37.     ; call the Windows function LocalInit() to set up the heap
  38.     ; LocalInit((LPSTR)start, WORD cbHeap);
  39.  
  40.            push    ds          ; Heap segment
  41.            xor     ax,ax
  42.            push    ax          ; Heap start offset in segment
  43.            push    cx          ; Heap end offset in segment
  44.            call    LocalInit   ; try to initialize it
  45.            or      ax,ax       ; did it do it ok ?
  46.            jz      nocall      ; quit if it failed
  47.  
  48.     ; invoke the C routine to do any special initialization
  49.  
  50. callc:
  51.            call    LibMain     ; invoke the 'C' routine (result in AX)
  52.            jmp short exit      ; LibMain is responsible for stack clean up
  53.  
  54. nocall:                        ; clean up passed params
  55.            pop     si          ; if LocalInit fails. 
  56.            pop     es
  57.            pop     cx
  58.            pop     ds
  59.            pop     di
  60.  
  61. exit:
  62.            ret                 ; return the result
  63.  
  64. LibEntry endp
  65.  
  66. INIT_TEXT  ends
  67.  
  68.            end LibEntry
  69.