Windows NT 4.0 source code leak
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.

188 lines
4.4 KiB

4 years ago
  1. page ,132
  2. ;-----------------------------Module-Header-----------------------------;
  3. ; Module Name: LIBINIT.ASM
  4. ;
  5. ; library stub to do local init for a Dynamic linked library
  6. ;
  7. ; Created: 06-27-89
  8. ; Author: Todd Laney [ToddLa]
  9. ;
  10. ; Exported Functions: none
  11. ;
  12. ; Public Functions: none
  13. ;
  14. ; Public Data: none
  15. ;
  16. ; General Description:
  17. ;
  18. ; Restrictions:
  19. ;
  20. ; This must be the first object file in the LINK line, this assures
  21. ; that the reserved parameter block is at the *base* of DGROUP
  22. ;
  23. ;-----------------------------------------------------------------------;
  24. ?PLM=1 ; PASCAL Calling convention is DEFAULT
  25. ?WIN=1 ; Windows calling convention
  26. .286
  27. .xlist
  28. include cmacros.inc
  29. ; include windows.inc
  30. .list
  31. ifndef SEGNAME
  32. SEGNAME equ <_TEXT>
  33. endif
  34. createSeg %SEGNAME, CodeSeg, word, public, CODE
  35. ;-----------------------------------------------------------------------;
  36. ;
  37. ; externs from KERNEL
  38. ;
  39. externFP <LocalInit>
  40. externFP <FatalAppExit>
  41. ;-----------------------------------------------------------------------;
  42. ;
  43. ; LibMain is the function in C code we will call on a DLL load.
  44. ; it is assumed in the same segment as we are.
  45. ;
  46. ;;;;;;;;externNP <LibMain>
  47. externFP <LibMain> ;; Use this line if LibMain is far call
  48. ;-----------------------------------------------------------------------;
  49. ;
  50. ; Stuff needed to avoid the C runtime coming in, and init the windows
  51. ; reserved parameter block at the base of DGROUP
  52. ;
  53. sBegin Data
  54. assumes DS,Data
  55. org 0 ; base of DATA segment!
  56. DD 0 ; So null pointers get 0
  57. maxRsrvPtrs = 5
  58. DW maxRsrvPtrs
  59. usedRsrvPtrs = 0
  60. labelDP <PUBLIC,rsrvptrs>
  61. DefRsrvPtr MACRO name
  62. globalW name,0
  63. usedRsrvPtrs = usedRsrvPtrs + 1
  64. ENDM
  65. DefRsrvPtr pLocalHeap ; Local heap pointer
  66. DefRsrvPtr pAtomTable ; Atom table pointer
  67. DefRsrvPtr pStackTop ; top of stack
  68. DefRsrvPtr pStackMin ; minimum value of SP
  69. DefRsrvPtr pStackBot ; bottom of stack
  70. if maxRsrvPtrs-usedRsrvPtrs
  71. DW maxRsrvPtrs-usedRsrvPtrs DUP (0)
  72. endif
  73. public __acrtused
  74. __acrtused = 1
  75. sEnd Data
  76. ;-----------------------------------------------------------------------;
  77. sBegin CodeSeg
  78. assumes cs,CodeSeg
  79. ;--------------------------Private-Routine-----------------------------;
  80. ;
  81. ; LibEntry - called when DLL is loaded
  82. ;
  83. ; Entry:
  84. ; CX = size of heap
  85. ; DI = module handle
  86. ; DS = automatic data segment
  87. ; ES:SI = address of command line (not used by a DLL)
  88. ;
  89. ; Returns:
  90. ; AX = TRUE if success
  91. ; Error Returns:
  92. ; AX = FALSE if error (ie fail load process)
  93. ; Registers Preserved:
  94. ; SI,DI,DS,BP
  95. ; Registers Destroyed:
  96. ; AX,BX,CX,DX,ES,FLAGS
  97. ; Calls:
  98. ; None
  99. ; History:
  100. ;
  101. ; 06-27-89 -by- Todd Laney [ToddLa]
  102. ; Created.
  103. ;-----------------------------------------------------------------------;
  104. assumes ds,Data
  105. assumes es,nothing
  106. cProc LibEntry,<FAR,PUBLIC,NODATA>,<>
  107. cBegin
  108. ifdef DEBUG
  109. ;
  110. ; if this module is not linked first the reserved parameter block
  111. ; will not be initialized correctly, check for this and
  112. ;
  113. lea ax,pLocalHeap
  114. cmp ax,6
  115. je RsrvPtrsOk
  116. RsrvPtrsHosed:
  117. int 3
  118. lea ax,RsrvPtrsMsg
  119. cCall FatalAppExit,<0,cs,ax>
  120. jmp short RsrvPtrsOk
  121. RsrvPtrsMsg:
  122. db 'RsrvPtrs hosed!',0
  123. RsrvPtrsOk:
  124. endif
  125. ;
  126. ; Push frame for LibMain (hModule,cbHeap,lpszCmdLine)
  127. ;
  128. push di
  129. push cx
  130. push es
  131. push si
  132. ;
  133. ; Init the local heap (if one is declared in the .def file)
  134. ;
  135. jcxz no_heap
  136. cCall LocalInit,<0,0,cx>
  137. no_heap:
  138. cCall LibMain
  139. cEnd
  140. ;--------------------------Exported-Routine-----------------------------;
  141. ;
  142. ; WEP()
  143. ;
  144. ; called when the DLL is unloaded, it is passed 1 WORD parameter that
  145. ; is TRUE if the system is going down, or zero if the app is
  146. ;
  147. ; WARNING:
  148. ;
  149. ; This function is basicly useless, you cant can any kernel function
  150. ; that may cause the LoadModule() code to be reentered..
  151. ;
  152. ;-----------------------------------------------------------------------;
  153. assumes ds,nothing
  154. assumes es,nothing
  155. cProc WEP,<FAR,PUBLIC,NODATA>,<>
  156. ParmW WhyIsThisParamBogusDave?
  157. cBegin
  158. cEnd
  159. sEnd CodeSeg
  160. end LibEntry