Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.7 KiB

  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. include cmacros.inc
  27. externFP <LibMain> ; the C routine to be called
  28. createSeg INIT_TEXT, INIT_TEXT, BYTE, PUBLIC, CODE
  29. sBegin INIT_TEXT
  30. assumes CS,INIT_TEXT
  31. ?PLM=0 ; 'C'naming
  32. ;externA <_acrtused> ; ensures that Win DLL startup code is linked
  33. ?PLM=1 ; 'PASCAL' naming
  34. externFP <LocalInit> ; Windows heap init routine
  35. cProc LibEntry, <PUBLIC,FAR> ; entry point into DLL
  36. include CONVDLL.INC
  37. cBegin
  38. push di ; handle of the module instance
  39. push ds ; library data segment
  40. push cx ; heap size
  41. push es ; Always NULL **** May remove (see above)
  42. push si ; Always NULL **** May remove (see above)
  43. ; if we have some heap then initialize it
  44. jcxz callc ; jump if no heap specified
  45. ; call the Windows function LocalInit() to set up the heap
  46. ; LocalInit((LPSTR)start, WORD cbHeap);
  47. xor ax,ax
  48. cCall LocalInit <ds, ax, cx>
  49. or ax,ax ; did it do it ok ?
  50. jz error ; quit if it failed
  51. ; invoke the C routine to do any special initialization
  52. callc:
  53. call LibMain ; invoke the 'C' routine (result in AX)
  54. jmp short exit ; LibMain is responsible for stack clean up
  55. error:
  56. pop si ; clean up stack on a LocalInit error
  57. pop es
  58. pop cx
  59. pop ds
  60. pop di
  61. exit:
  62. cEnd
  63. sEnd INIT_TEXT
  64. end LibEntry
  65.