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.

265 lines
4.8 KiB

  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. .386p
  27. .xlist
  28. include cmacros.inc
  29. .list
  30. ifndef SEGNAME
  31. SEGNAME equ <_TEXT>
  32. endif
  33. ifndef WEPSEG
  34. WEPSEG equ <_WEP>
  35. endif
  36. createSeg %SEGNAME, CodeSeg, word, public, CODE
  37. createSeg %WEPSEG, WepCodeSeg, word, public, CODE
  38. ;-----------------------------------------------------------------------;
  39. ; external functions
  40. ;
  41. externFP LocalInit ; in KERNEL
  42. externFP LibMain ; C code to do DLL init
  43. ;-----------------------------------------------------------------------;
  44. ;
  45. ; Stuff needed to avoid the C runtime coming in, and init the windows
  46. ; reserved parameter block at the base of DGROUP
  47. ;
  48. %out link me first!!
  49. sBegin Data
  50. assumes DS,Data
  51. org 0 ; base of DATA segment!
  52. DD 0 ; So null pointers get 0
  53. maxRsrvPtrs = 5
  54. DW maxRsrvPtrs
  55. usedRsrvPtrs = 0
  56. labelDP <PUBLIC,rsrvptrs>
  57. DefRsrvPtr MACRO name
  58. globalW name,0
  59. usedRsrvPtrs = usedRsrvPtrs + 1
  60. ENDM
  61. DefRsrvPtr pLocalHeap ; Local heap pointer
  62. DefRsrvPtr pAtomTable ; Atom table pointer
  63. DefRsrvPtr pStackTop ; top of stack
  64. DefRsrvPtr pStackMin ; minimum value of SP
  65. DefRsrvPtr pStackBot ; bottom of stack
  66. if maxRsrvPtrs-usedRsrvPtrs
  67. DW maxRsrvPtrs-usedRsrvPtrs DUP (0)
  68. endif
  69. public __acrtused
  70. __acrtused = 1
  71. public g_SegTEXT
  72. globalW g_SegTEXT,0
  73. sEnd Data
  74. extrn gDeviceAddress:dword
  75. ;-----------------------------------------------------------------------;
  76. sBegin CodeSeg
  77. assumes cs,CodeSeg
  78. extrn WODCOMPLETEIO:FAR
  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)
  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. cProc LibEntry,<FAR,PUBLIC,NODATA>,<>
  105. cBegin
  106. ;
  107. ; Push frame for LibMain (hModule,cbHeap,lpszCmdLine)
  108. ;
  109. push di
  110. push cx
  111. push es
  112. push si
  113. ;
  114. ; Init the local heap (if one is declared in the .def file)
  115. ;
  116. jcxz no_heap
  117. cCall LocalInit,<0,0,cx>
  118. no_heap:
  119. mov ax, SEG _TEXT
  120. mov g_SegTEXT, ax
  121. cCall LibMain
  122. cEnd
  123. cProc int1,<FAR,PUBLIC,NODATA>
  124. cBegin
  125. int 1
  126. cEnd
  127. public DEVICECALLBACK, OPENPIN, WRITEPIN
  128. DeviceCallBack proc far
  129. push bp
  130. mov bp, sp
  131. push ds
  132. push si
  133. push di
  134. push ds
  135. push si
  136. call WODCOMPLETEIO
  137. pop di
  138. pop si
  139. pop ds
  140. pop bp
  141. ret
  142. DEVICECALLBACK endp
  143. .386p
  144. OpenPin proc far
  145. push bp
  146. mov bp, sp
  147. push ds
  148. push fs
  149. push si
  150. push di
  151. push ds
  152. pop fs
  153. assume ds:nothing, fs:DGROUP
  154. mov ax, 1 ; OPEN_PIN
  155. mov si, [bp].6
  156. mov ds, [bp].8
  157. call dword ptr fs:[gDeviceAddress]
  158. pop di
  159. pop si
  160. pop fs
  161. pop ds
  162. pop bp
  163. ret 4
  164. OpenPin endp
  165. WritePin proc far
  166. push bp
  167. mov bp, sp
  168. push ds
  169. push fs
  170. push si
  171. push di
  172. push ds
  173. pop fs
  174. assume es:nothing, ds:nothing, fs:DGROUP
  175. mov ax, 3 ; WRITE_PIN
  176. mov si, [bp].6
  177. mov ds, [bp].8
  178. push cs
  179. pop es
  180. mov di, offset DeviceCallBack
  181. call dword ptr fs:[gDeviceAddress]
  182. pop di
  183. pop si
  184. pop fs
  185. pop ds
  186. pop bp
  187. ret 4
  188. WritePin endp
  189. sEnd CodeSeg
  190. ;--------------------------Exported-Routine-----------------------------;
  191. ;
  192. ; WEP()
  193. ;
  194. ; called when the DLL is unloaded, it is passed 1 WORD parameter that
  195. ; is TRUE if the system is going down, or zero if the app is.
  196. ; All WEP's need to be in fixed code segments.
  197. ;
  198. ; WARNING:
  199. ;
  200. ; This function is basicly useless, you cant can any kernel function
  201. ; that may cause the LoadModule() code to be reentered.
  202. ;
  203. ;-----------------------------------------------------------------------;
  204. sBegin WepCodeSeg
  205. assumes cs,WepCodeSeg
  206. assumes ds,nothing
  207. assumes es,nothing
  208. cProc WEP,<FAR,PUBLIC,NODATA>,<>
  209. ParmW WhyIsThisParamBogusDave?
  210. cBegin
  211. cEnd
  212. sEnd WepCodeSeg
  213. end LibEntry
  214.