Leaked source code of windows server 2003
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.

374 lines
7.7 KiB

  1. ;****************************Public Macro************************************
  2. ;
  3. ; ComposeInst Inst,p1,p2,p3,p4,p5,p6,p7,p8,p9
  4. ;
  5. ; This macro simply concatenates all arguments into one string.
  6. ;
  7. ; History:
  8. ; Thu 15-Aug-1991 16:21:14 -by- Viroon Touranachun [viroont]
  9. ; Created
  10. ;
  11. ; Module Name: stdcall.inc
  12. ;
  13. ; Copyright (c) 1991-1999 Microsoft Corporation
  14. ;****************************************************************************
  15. ;
  16. ;****************************************************************************
  17. ComposeInst macro Inst,p1,p2,p3,p4,p5,p6,p7,p8,p9
  18. &Inst &p1&p2&p3&p4&p5&p6&p7&p8&p9
  19. endm
  20. ;****************************Public Macro************************************
  21. ;
  22. ; CountArg cCount,ArgList
  23. ;
  24. ; This macro count the number of arguments in the ArgList and returns
  25. ; the value in cCount.
  26. ;
  27. ; History:
  28. ; Thu 15-Aug-1991 16:21:14 -by- Viroon Touranachun [viroont]
  29. ; Created
  30. ;
  31. ;****************************************************************************
  32. CountArg macro cCount,ArgList
  33. cCount = 0
  34. irp arg,<ArgList>
  35. cCount = cCount+1
  36. endm
  37. endm
  38. ;****************************Public Macro************************************
  39. ;
  40. ; RevPush ArgList,cCount
  41. ;
  42. ; This macro pushes the arguments in ArgList in the reverse order
  43. ; and returns the number of arguments in cCount.
  44. ;
  45. ; History:
  46. ; Thu 15-Aug-1991 16:21:14 -by- Viroon Touranachun [viroont]
  47. ; Created
  48. ;
  49. ;****************************************************************************
  50. RevPush macro ArgList,cCount
  51. Local index,x
  52. CountArg cCount,<ArgList>
  53. index = cCount
  54. rept cCount
  55. x = 0
  56. irp arg,<ArgList>
  57. x = x+1
  58. ife index-x
  59. push arg
  60. exitm
  61. endif
  62. endm
  63. index = index-1
  64. endm
  65. endm
  66. ;****************************Public Macro************************************
  67. ;
  68. ; The following sections contain calling-convention related macros for:
  69. ;
  70. ; PUBLICP Func,N
  71. ; to define a public label
  72. ;
  73. ; EXTRNP Func,N
  74. ; to define a external near label
  75. ;
  76. ; LABELP Func,N
  77. ; to label an address as a routine entry point
  78. ;
  79. ; cProc Func,N,ArgList
  80. ; to declare a routine header
  81. ;
  82. ; ProcName Name,Func,N
  83. ; to rename a function Func to Name. Using it in conjunction with
  84. ; normal function declaration (with the new name) will solve an error
  85. ; caused by a long parameter list routine that exhausts page width.
  86. ;
  87. ; cRet Func
  88. ; to return from Func routines (declared with cProc or ProcName.)
  89. ;
  90. ; endProc Func
  91. ; to declare the end of routine (declared with cProc or ProcName.)
  92. ;
  93. ; endMod Func
  94. ; to declare the end of module with an entry point at Func (declared
  95. ; with cProc or ProcName.)
  96. ;
  97. ; cCall Func,ArgList
  98. ; to call to a routine--Func--with the arguments pushed on the stack
  99. ;
  100. ; ptrCall Func,ArgList
  101. ; to call through a pointer with the arguments pushed on the stack
  102. ;
  103. ; MovAddr dest,Func,n
  104. ; to move the address of the routine--Func--into dest.
  105. ;
  106. ; Note that for the standard calling convention all the function names,
  107. ; Func, are automatically converted to Func@N where N is the number of
  108. ; bytes in the argument list.
  109. ;
  110. ; History:
  111. ; Thu 15-Aug-1991 16:21:14 -by- Viroon Touranachun [viroont]
  112. ; Created
  113. ;
  114. ;****************************************************************************
  115. IFNDEF DOS_PLATFORM
  116. IFNDEF STD_CALL
  117. ;****************************************************************************
  118. ;
  119. ; This section is used exclusively for C calling convention.
  120. ;
  121. ;****************************************************************************
  122. PUBLICP macro Func,N
  123. public &Func
  124. endm
  125. EXTRNP macro Func,N
  126. extrn &Func:NEAR
  127. endm
  128. LABELP macro Func,N
  129. &Func LABEL NEAR
  130. endm
  131. ProcName macro Name,Func,N
  132. &Name EQU <&Func>
  133. endm
  134. cProc macro Func,N,ArgList
  135. ProcName xxx&Func,Func,N
  136. xxx&Func proc &ArgList
  137. endm
  138. cRet macro Func
  139. ret
  140. endm
  141. endProc macro Func
  142. xxx&Func endp
  143. endm
  144. endMod macro Func
  145. end xxx&Func
  146. endm
  147. ptrCall macro Func,ArgList
  148. Local Bytes
  149. RevPush <ArgList>,Bytes
  150. Bytes = Bytes*4
  151. call &Func
  152. if Bytes GT 0
  153. add esp,Bytes
  154. endif
  155. endm
  156. cCall macro Func,ArgList
  157. Local Bytes
  158. RevPush <ArgList>,Bytes
  159. Bytes = Bytes*4
  160. call &Func
  161. if Bytes GT 0
  162. add esp,Bytes
  163. endif
  164. endm
  165. MovAddr macro dest,addr,n
  166. mov dest,offset FLAT:&addr
  167. endm
  168. ENDIF ; STD_CALL
  169. ELSE
  170. IFNDEF STD_CALL
  171. ;****************************************************************************
  172. ;
  173. ; This section is used exclusively for Pascal calling convention.
  174. ;
  175. ;****************************************************************************
  176. PUBLICP macro Func,N
  177. public &Func
  178. endm
  179. EXTRNP macro Func,N
  180. extrn &Func:NEAR
  181. endm
  182. LABELP macro Func,N
  183. &Func LABEL NEAR
  184. endm
  185. ProcName macro Name,Func,N
  186. &Name EQU <&Func>
  187. endm
  188. cProc macro Func,N,ArgList
  189. ProcName xxx&Func,Func,N
  190. xxx&Func proc &ArgList
  191. endm
  192. cRet macro Func
  193. ret
  194. endm
  195. endProc macro Func
  196. xxx&Func endp
  197. endm
  198. endMod macro Func
  199. end xxx&Func
  200. endm
  201. cCall macro Func,ArgList
  202. irp arg,<ArgList>
  203. push arg
  204. endm
  205. call &Func
  206. endm
  207. MovAddr macro dest,addr,n
  208. mov dest,offset FLAT:&addr
  209. endm
  210. ENDIF : ~STD_CALL
  211. ENDIF ; DOS_PLATFORM
  212. IFDEF STD_CALL
  213. ;****************************************************************************
  214. ;
  215. ; This section is used exclusively for the standard calling convention.
  216. ;
  217. ;****************************************************************************
  218. PUBLICP macro Func,N
  219. ifb <N>
  220. public &Func&@0
  221. else
  222. public &Func&@&N
  223. endif
  224. endm
  225. EXTRNP macro Func,N
  226. ifb <N>
  227. extrn &Func&@0:NEAR
  228. else
  229. extrn &Func&@&N:NEAR
  230. endif
  231. endm
  232. LABELP macro Func,N
  233. ifb <N>
  234. &Func&@0 LABEL NEAR
  235. else
  236. &Func&@&N LABEL NEAR
  237. endif
  238. endm
  239. ProcName macro Name,Func,N
  240. ifb <N>
  241. cByte&Func EQU 0
  242. &Name EQU <&Func&@0>
  243. else
  244. cByte&Func EQU N
  245. &Name EQU <&Func&@&N>
  246. endif
  247. endm
  248. cProc macro Func,N,ArgList
  249. ProcName xxx&Func,Func,N
  250. xxx&Func proc &ArgList
  251. endm
  252. cRet macro Func
  253. ret cByte&Func
  254. endm
  255. endProc macro Func
  256. xxx&Func endp
  257. endm
  258. endMod macro Func
  259. end xxx&Func
  260. endm
  261. ptrCall macro Func,ArgList
  262. Local Bytes
  263. RevPush <ArgList>,Bytes
  264. call &Func
  265. endm
  266. cCall macro Func,ArgList
  267. Local Bytes
  268. RevPush <ArgList>,Bytes
  269. Bytes = Bytes*4
  270. ComposeInst <call>,&Func,<@>,%(Bytes)
  271. endm
  272. MovAddr macro dest,addr,n
  273. ComposeInst <mov >,dest,<,offset FLAT:>,addr,<@>,n
  274. endm
  275. ENDIF ;STD_CALL
  276.