home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l231 / 3.ddi / LIB / DLLENTRY.AS$ / DLLENTRY
Encoding:
Text File  |  1992-09-08  |  1.6 KB  |  43 lines

  1. ; DLLENTRY.ASM
  2. ;
  3. ; Entry code for example Windows dynamic link library.  When Windows first
  4. ; loads the DLL, control comes here first.
  5. ;
  6. ; This module generates a code segment called INIT_TEXT.  It calls the API
  7. ; function LocalInit to initialize the local heap (if one exists), then calls 
  8. ; the API function UnlockSegment to unlock the heap segment.  (The call to
  9. ; to UnlockSegment is not necessary in protected mode.)  If successful,
  10. ; DLLEntry calls the DLL's data initialization routine, prototyped like this:
  11. ;
  12. ;                       BOOL FAR PASCAL LibMain( void );
  13. ;
  14. ; DLLEntry returns the result of all this to Windows:  TRUE if successful,
  15. ; FALSE otherwise.  Note DLLEntry differs from LibEntry of the Windows SDK in
  16. ; that it does not pass arguements to LibMain.
  17. ;
  18. ; Refer to Chapter 11 of the Programmer's Guide for further information.
  19.  
  20. .MODEL  small, pascal, farstack
  21. .286
  22.  
  23. INCLUDE WIN.INC
  24.  
  25. LibMain PROTO FAR PASCAL
  26.  
  27. .CODE
  28. DLLEntry        PROC FAR PASCAL PUBLIC          ; Entry point for DLL
  29.  
  30. ; On entry, DS = data segment and CX = heap size
  31.         jcxz    @F                      ; If no heap, skip
  32.         INVOKE  LocalInit, ds, 0, cx    ; Else set up the heap
  33.         .IF     ( ax )                  ; If successful,
  34.         INVOKE  UnlockSegment, -1       ;   unlock the data segment
  35. @@:             call    LibMain                 ; Call DLL's data init routine
  36.         mov     ax, TRUE                ; Return AX = TRUE if okay,
  37.         .ENDIF                          ;   else if LocalInit error,
  38.         ret                             ;   return AX = FALSE
  39.  
  40. DLLEntry        ENDP
  41.  
  42. END             DLLEntry
  43.