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.

280 lines
7.3 KiB

  1. include thkmacro.inc
  2. ;-----------------------------------------------------------------------;
  3. ; publab
  4. ;
  5. ; Make a public label from the given name, and size (if specified).
  6. ;-----------------------------------------------------------------------;
  7. publab macro name:req,label_size
  8. public name
  9. ifb <label_size>
  10. name:
  11. else
  12. name label label_size
  13. endif
  14. endm
  15. ;-----------------------------------------------------------------------;
  16. ; DefMsgTableRange
  17. ;
  18. ; tbl
  19. ; Table code-name.
  20. ;
  21. ; min32
  22. ; minimum 32-bit message number in table
  23. ;
  24. ; max32
  25. ; maximum 32-bit message number in table
  26. ;
  27. ; min16
  28. ; minimum 16-bit message number in table
  29. ;
  30. ;
  31. ; Define the message ranges for each class.
  32. ;
  33. ; For each table (e.g. WM), define the following constants:
  34. ;
  35. ; MIN32_WM minimum 32-bit message number in table
  36. ; MAX32_WM maximum 32-bit message number in table
  37. ; MIN16_WM minimum 16-bit message number in table
  38. ; MAX16_WM maximum 16-bit message number in table
  39. ; C_WM number of messages in table
  40. ;-----------------------------------------------------------------------;
  41. DefMsgTableRange macro tbl,min32,max32,min16
  42. MIN32_&tbl equ min32
  43. MAX32_&tbl equ max32
  44. C_&tbl equ max32 - min32 + 1
  45. MIN16_&tbl equ min16
  46. MAX16_&tbl equ min16 + max32 - min32
  47. endm
  48. ; name min32 max32 min16
  49. ; -----------------------
  50. DefMsgTableRange WM, 0h, 3FFh, 0h
  51. DefMsgTableRange BM, 0F0h, 0F7h, 400h
  52. DefMsgTableRange CB, 140h, 161h, 400h
  53. DefMsgTableRange DM, 400h, 402h, 400h
  54. ifdef FE_IME
  55. DefMsgTableRange EM, 0B0h, 0D9h, 400h
  56. else
  57. DefMsgTableRange EM, 0B0h, 0D7h, 400h
  58. endif
  59. DefMsgTableRange LB, 180h, 1A9h, 401h
  60. DefMsgTableRange SBM, 0E0h, 0EAh, 400h
  61. DefMsgTableRange STM, 170h, 173h, 400h
  62. DefMsgTableRange MN, 1E0h, 1E7h, 401h
  63. ; THESE MUST BE IN SAME ORDER AS TABLE ENTRIES BELOW
  64. CLASS_WM equ 00h
  65. CLASS_BM equ 01h
  66. CLASS_CB equ 02h
  67. CLASS_EM equ 03h
  68. CLASS_LB equ 04h
  69. CLASS_SBM equ 05h
  70. CLASS_STM equ 06h
  71. CLASS_MN equ 07h
  72. CLASS_MAX equ 08h
  73. CLASS_SPECIAL equ 0FEh
  74. CLASS_UNDEFINED equ 0FFh
  75. ;-----------------------------------------------------------------------;
  76. ; FullClassList
  77. ;
  78. ; This is the list of all possible thunk classes.
  79. ;-----------------------------------------------------------------------;
  80. ;The DM thunk class doesn't require any special thunks.
  81. ;FullClassList equ <WM,BM,CB,DM,EM,LB,MN,MDI,SBM,STM>
  82. FullClassList equ <WM,BM,CB,EM,LB,SBM,STM,MN>
  83. ;***********************************************************************;
  84. ; Thunk pre- and post-processing macros. These perform any necessary
  85. ; setup prior to calling the thunking subroutines.
  86. ;***********************************************************************;
  87. ;-----------------------------------------------------------------------;
  88. ; InitLocalSpace
  89. ;
  90. ; flags
  91. ; Indicates api-specific flags to be set in THKSPACE16.s16_fw.
  92. ;
  93. ;
  94. ; Initialize the variables in THKSPACE16 in a standard way.
  95. ;-----------------------------------------------------------------------;
  96. InitLocalSpace macro flags:req, base:=<si>
  97. ;;Initialize local variables.
  98. mov word ptr base&_space.s16_fw, flags
  99. xor eax, eax
  100. mov dword ptr base&_space.s16_atomClass, eax
  101. .errnz s16_atomClass - s16_fw - 2
  102. ifdef DEBUG
  103. mov dword ptr base&_space.s16_message, eax
  104. .errnz s16_message - s16_hwnd - 2
  105. dec eax
  106. mov base&_space.s16_wParam,eax
  107. mov base&_space.s16_lParam,eax
  108. mov base&_space.s16_lResult,eax
  109. mov base&_space.s16_dwExtra1,eax
  110. mov base&_space.s16_dwExtra2,eax
  111. endif
  112. endm
  113. ;-----------------------------------------------------------------------;
  114. ; MsgThkPreProc
  115. ;
  116. ; flags
  117. ; Indicates api-specific flags to be set in THKSPACE16.s16_fw.
  118. ;
  119. ; base
  120. ; Indicates which register to use for referencing stack frame.
  121. ; If not defined, default of <bp> will be used.
  122. ;
  123. ; Requirements:
  124. ; bp_hwnd be defined
  125. ; bp_message be defined
  126. ; bp_wParamLo be defined
  127. ; bp_wParamHi
  128. ; bp_lParam be defined
  129. ; base&_space be defined
  130. ;
  131. ; dir be defined as either SL or LS
  132. ;
  133. ; Results:
  134. ; SP = original SP - size THKSPACE16
  135. ; - extra space allocated by thunk, if any
  136. ; History:
  137. ; 08-07-91 BobGru
  138. ; Wrote it.
  139. ;-----------------------------------------------------------------------;
  140. MsgThkPreProc macro flags:=<0>, base:=<bp>
  141. AssertUserDS
  142. ;;Allocate local variable space
  143. sub sp,size THKSPACE16
  144. InitLocalSpace flags, base
  145. ;;Thunk the message parameters.
  146. push word ptr bp_hwnd
  147. push word ptr bp_message
  148. push word ptr bp_wParamHi
  149. push word ptr bp_wParamLo
  150. push dword ptr bp_lParam
  151. cat <call ThkMsg>,%dir
  152. endm
  153. ;-----------------------------------------------------------------------;
  154. ; MsgThkPostProc
  155. ;
  156. ; exit_label
  157. ; Name of label to jump to for exiting. If not defined, macro
  158. ; will fall out the bottom.
  159. ;
  160. ; base
  161. ; Indicates which register to use for referencing stack frame.
  162. ; If not defined, default of <bp> will be used.
  163. ;
  164. ; Requirements:
  165. ; EAX = return code
  166. ; bp_hwnd be defined
  167. ; bp_message be defined
  168. ; bp_wParamLo be defined
  169. ; bp_wParamHi be defined
  170. ; bp_lParam be defined
  171. ; base&_cleanup be defined
  172. ;
  173. ; dir be defined as either SL or LS
  174. ;
  175. ; Results:
  176. ; Message parameters are unthunked, return code is left in EAX,
  177. ; and stack frame is cleaned up.
  178. ;
  179. ; History:
  180. ; 08-07-91 BobGru
  181. ; Wrote it.
  182. ;-----------------------------------------------------------------------;
  183. MsgThkPostProc macro base:=<bp>
  184. local no_clean_up
  185. AssertUserDS
  186. ; Cleanup after thunking. Except for pointers (xmovlp, xmovs),
  187. ; we don't need to do anything. This is used for sync message
  188. ; sending only.
  189. % ifidni <dir>,<LS>
  190. ;Move return from 16bits into EAX
  191. DXAX2EAX
  192. % else
  193. ;Return from 32bits is in EAX already
  194. endif
  195. ; Save return value
  196. mov dword ptr base&_space.s16_lResult, eax
  197. ;If any cleanup necessary from thunking, do it now.
  198. test base&_space.s16_fw, TF_CLEANUP
  199. jz no_clean_up
  200. push word ptr base&_space.s16_hwnd ;;original params
  201. push word ptr base&_space.s16_message ;;
  202. push dword ptr base&_space.s16_wParam ;;
  203. push dword ptr base&_space.s16_lParam ;;
  204. % ifidni <dir>,<SL>
  205. call ThkMsgLS
  206. else
  207. call ThkMsgSL
  208. endif
  209. no_clean_up:
  210. ;Restore return result.
  211. mov eax, dword ptr base&_space.s16_lResult
  212. %ifidni <dir>,<LS>
  213. ;Return to 32bits is in EAX already
  214. %else
  215. ;Move return from 32bits into DX:AX
  216. shld edx, eax, 16
  217. endif
  218. lea sp,base&_cleanup ;;clean up stack frame
  219. endm
  220. ;----------------------------------------------------------------------------
  221. ;
  222. ; AssertUserDS
  223. ;
  224. ; Debug macro that asserts the current DS is User's DGROUP
  225. ;
  226. ;----------------------------------------------------------------------------
  227. AssertUserDS macro
  228. local DSOk
  229. ifdef DEBUG
  230. push ds
  231. pop bx
  232. cmp bx, _DATA
  233. je DSOk
  234. int 3
  235. DSOk:
  236. endif
  237. endm