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.

296 lines
7.4 KiB

  1. ;+---------------------------------------------------------------------------
  2. ;
  3. ; Microsoft Windows
  4. ; Copyright (C) Microsoft Corporation, 1996.
  5. ;
  6. ; File: stubless.asm
  7. ;
  8. ; Contents: This module contains interpreter support routines for
  9. ; Intel platforms.
  10. ;
  11. ; Functions: Invoke - Calls a function from an interpreter.
  12. ; ObjectStublessClient3 - ObjectStublessClient511
  13. ;
  14. ; History: 07-Nov-94 DKays Created
  15. ; 24-Apr-96 ShannonC Added Invoke and support for
  16. ; 512 stubless client methods.
  17. ;
  18. ;----------------------------------------------------------------------------
  19. .386p
  20. EXTRN _ObjectStublessClient@8:NEAR
  21. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  22. ;+---------------------------------------------------------------------------
  23. ;
  24. ; Function: REGISTER_TYPE __stdcall Invoke(MANAGER_FUNCTION pFunction,
  25. ; REGISTER_TYPE *pArgumentList,
  26. ; ULONG cArguments);
  27. ;
  28. ; Synopsis: Given a function pointer and an argument list, Invoke builds
  29. ; a stack frame and calls the function.
  30. ;
  31. ; Arguments: pFunction - Pointer to the function to be called.
  32. ;
  33. ; pArgumentList - Pointer to the buffer containing the
  34. ; function parameters.
  35. ;
  36. ; cArguments - The size of the argument list in REGISTER_TYPEs.
  37. ;
  38. ; Notes: In the __stdcall calling convention, the callee must pop
  39. ; the parameters.
  40. ;
  41. ;----------------------------------------------------------------------------
  42. _Invoke@12 PROC PUBLIC
  43. push ebp; Save ebp
  44. mov ebp, esp; Set ebp so the debugger can display the stack trace.
  45. ;Here is our stack layout.
  46. ;[ebp+0] = saved ebp
  47. ;[ebp+4] = return address
  48. ;[ebp+8] = pFunction
  49. ;[ebp+12] = pArgumentList
  50. ;[ebp+16] = cArguments
  51. push edi; Save edi
  52. push esi; Save esi
  53. pushf; Save the direction flag - pushes 2 bytes
  54. pushf; To keep stack aligned at 4 push 2 more bytes
  55. mov eax, [ebp+16]; Load number of parameters
  56. shl eax, 2; Calculate size of parameters
  57. sub esp, eax; Grow the stack
  58. ;Copy parameters from bottom to top.
  59. mov esi, [ebp+12]; Load pointer to parameters
  60. mov ecx, [ebp+16]; Load number of parameters
  61. sub eax, 4;
  62. mov edi, esp
  63. add esi, eax; Get pointer to last source parameter
  64. add edi, eax; Get pointer last destination parameter
  65. std; Set direction flag
  66. rep movsd; Copy the parameters
  67. mov eax, [ebp-12]; Get the direction flag (2+2 bytes)
  68. push eax; Push it in order to restore it
  69. popf; Restore the direction flag
  70. popf; Do it again as we pushed 4 bytes when saving the flag
  71. ;call the server
  72. mov eax, [ebp+8]; Load pointer to function.
  73. call eax
  74. mov edi, [ebp-4]; Restore edi
  75. mov esi, [ebp-8]; Restore esi
  76. mov esp, ebp; Restore stack pointer
  77. pop ebp; Restore ebp
  78. ret 12 ; Pop parameters
  79. _Invoke@12 ENDP
  80. ;
  81. ; Define ObjectStublessClient routine macro.
  82. ;
  83. StublessClientProc macro Method
  84. _ObjectStublessClient&Method&@0 PROC PUBLIC
  85. ;
  86. ; NOTE :
  87. ; Don't use edi, esi, or ebx unless you add code to save them on
  88. ; the stack!
  89. ;
  90. mov ecx, Method
  91. jmp _ObjectStubless@0
  92. _ObjectStublessClient&Method&@0 ENDP
  93. endm
  94. ;On entry, ecx contains method number.
  95. _ObjectStubless@0 PROC PUBLIC
  96. ;
  97. ; NOTE :
  98. ; Don't use edi, esi, or ebx unless you add code to save them on
  99. ; the stack!
  100. ;
  101. ;
  102. ; Do this so the debugger can figure out the stack trace correctly.
  103. ; Will make debugging much easier.
  104. ;
  105. push ebp
  106. mov ebp, esp
  107. ; Push the method number.
  108. push ecx
  109. ; Push the stack address of the parameters.
  110. mov eax, ebp
  111. add eax, 8
  112. push eax
  113. call _ObjectStublessClient@8
  114. ;
  115. ; After the call :
  116. ; Real return for the proxy is in eax.
  117. ; Parameter stack size is put in ecx by ObjectStublessClient for us.
  118. ;
  119. ; At this pointer eax (return), ecx (ParamSize), and edi, esi, ebx
  120. ; (non-volatile registers) can not be written!!!
  121. ;
  122. ; Don't forget to pop ebp.
  123. pop ebp
  124. ; Pop our return address.
  125. pop edx
  126. ; Pop params explicitly.
  127. add esp, ecx
  128. ; This will return us from whichever StublessClient routine was called.
  129. jmp edx
  130. _ObjectStubless@0 ENDP
  131. StublessClientProc 3
  132. StublessClientProc 4
  133. StublessClientProc 5
  134. StublessClientProc 6
  135. StublessClientProc 7
  136. StublessClientProc 8
  137. StublessClientProc 9
  138. StublessClientProc 10
  139. StublessClientProc 11
  140. StublessClientProc 12
  141. StublessClientProc 13
  142. StublessClientProc 14
  143. StublessClientProc 15
  144. StublessClientProc 16
  145. StublessClientProc 17
  146. StublessClientProc 18
  147. StublessClientProc 19
  148. StublessClientProc 20
  149. StublessClientProc 21
  150. StublessClientProc 22
  151. StublessClientProc 23
  152. StublessClientProc 24
  153. StublessClientProc 25
  154. StublessClientProc 26
  155. StublessClientProc 27
  156. StublessClientProc 28
  157. StublessClientProc 29
  158. StublessClientProc 30
  159. StublessClientProc 31
  160. StublessClientProc 32
  161. StublessClientProc 33
  162. StublessClientProc 34
  163. StublessClientProc 35
  164. StublessClientProc 36
  165. StublessClientProc 37
  166. StublessClientProc 38
  167. StublessClientProc 39
  168. StublessClientProc 40
  169. StublessClientProc 41
  170. StublessClientProc 42
  171. StublessClientProc 43
  172. StublessClientProc 44
  173. StublessClientProc 45
  174. StublessClientProc 46
  175. StublessClientProc 47
  176. StublessClientProc 48
  177. StublessClientProc 49
  178. StublessClientProc 50
  179. StublessClientProc 51
  180. StublessClientProc 52
  181. StublessClientProc 53
  182. StublessClientProc 54
  183. StublessClientProc 55
  184. StublessClientProc 56
  185. StublessClientProc 57
  186. StublessClientProc 58
  187. StublessClientProc 59
  188. StublessClientProc 60
  189. StublessClientProc 61
  190. StublessClientProc 62
  191. StublessClientProc 63
  192. StublessClientProc 64
  193. StublessClientProc 65
  194. StublessClientProc 66
  195. StublessClientProc 67
  196. StublessClientProc 68
  197. StublessClientProc 69
  198. StublessClientProc 70
  199. StublessClientProc 71
  200. StublessClientProc 72
  201. StublessClientProc 73
  202. StublessClientProc 74
  203. StublessClientProc 75
  204. StublessClientProc 76
  205. StublessClientProc 77
  206. StublessClientProc 78
  207. StublessClientProc 79
  208. StublessClientProc 80
  209. StublessClientProc 81
  210. StublessClientProc 82
  211. StublessClientProc 83
  212. StublessClientProc 84
  213. StublessClientProc 85
  214. StublessClientProc 86
  215. StublessClientProc 87
  216. StublessClientProc 88
  217. StublessClientProc 89
  218. StublessClientProc 90
  219. StublessClientProc 91
  220. StublessClientProc 92
  221. StublessClientProc 93
  222. StublessClientProc 94
  223. StublessClientProc 95
  224. StublessClientProc 96
  225. StublessClientProc 97
  226. StublessClientProc 98
  227. StublessClientProc 99
  228. StublessClientProc 100
  229. StublessClientProc 101
  230. StublessClientProc 102
  231. StublessClientProc 103
  232. StublessClientProc 104
  233. StublessClientProc 105
  234. StublessClientProc 106
  235. StublessClientProc 107
  236. StublessClientProc 108
  237. StublessClientProc 109
  238. StublessClientProc 110
  239. StublessClientProc 111
  240. StublessClientProc 112
  241. StublessClientProc 113
  242. StublessClientProc 114
  243. StublessClientProc 115
  244. StublessClientProc 116
  245. StublessClientProc 117
  246. StublessClientProc 118
  247. StublessClientProc 119
  248. StublessClientProc 120
  249. StublessClientProc 121
  250. StublessClientProc 122
  251. StublessClientProc 123
  252. StublessClientProc 124
  253. StublessClientProc 125
  254. StublessClientProc 126
  255. StublessClientProc 127
  256. _TEXT ends
  257. end