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.

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