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.

117 lines
3.2 KiB

  1. PAGE,132
  2. ;***************************************************************************
  3. ;*
  4. ;* DLLENTRY.ASM
  5. ;*
  6. ;* TOOLHELP.DLL Entry code
  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 TOOLPRIV.INC
  22. extrn LocalInit:FAR
  23. extrn GlobalUnwire:FAR
  24. sBegin CODE
  25. assumes CS,CODE
  26. externNP ToolHelpLibMain
  27. externNP HelperReleaseSelector
  28. externNP NotifyUnInit
  29. externNP InterruptUnInit
  30. ?PLM=0
  31. externA <_acrtused> ;Ensures that Win DLL startup code is linked
  32. ?PLM=1
  33. ; LibEntry
  34. ;
  35. ; KERNEL calls this when the TOOLHELP is loaded the first time
  36. cProc LibEntry, <PUBLIC,FAR>
  37. cBegin
  38. push di ;Handle of the module instance
  39. push ds ;Library data segment
  40. push cx ;Heap size
  41. push es ;Command line segment
  42. push si ;Command line offset
  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 our initialization routine
  52. callc:
  53. call ToolHelpLibMain ;Invoke the 'C' routine (result in AX)
  54. jmp SHORT exit
  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. ; WEP
  64. ; Windows Exit Procedure
  65. cProc WEP, <FAR,PUBLIC>, <si,di,ds>
  66. parmW wState
  67. cBegin
  68. ;** Make sure our DS is safe
  69. mov ax,_DATA ;Get the DS value
  70. lar cx,ax ;Is it OK?
  71. jz @F
  72. jmp SHORT WEP_Bad ;No
  73. @@: and cx,8a00h ;Clear all but P, Code/Data, R/W bits
  74. cmp cx,8200h ;Is it P, R/W, Code/Data?
  75. jne WEP_Bad ;No
  76. mov ax,_DATA ;Get our DS now
  77. mov ds,ax
  78. ;** Uninstall the Register PTrace notifications if necessary
  79. cmp wNotifyInstalled,0
  80. jz @F
  81. cCall NotifyUnInit
  82. @@:
  83. ;** Release fault handlers
  84. cmp wIntInstalled,0
  85. jz @F
  86. cCall InterruptUnInit
  87. @@:
  88. ;** Release our roving selector
  89. test wTHFlags, TH_WIN30STDMODE
  90. jz @F
  91. cCall HelperReleaseSelector, <wSel>
  92. @@:
  93. WEP_Bad:
  94. mov ax,1
  95. cEnd
  96. sEnd
  97. END LibEntry