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.

1176 lines
31 KiB

  1. ;----------------------------------------------------------------------------
  2. ; Thunk direction
  3. ;----------------------------------------------------------------------------
  4. dir equ <LS>
  5. ;----------------------------------------------------------------------------
  6. ; Define the order of message thunk classes
  7. ;----------------------------------------------------------------------------
  8. ;The DM thunk class doesn't require any special thunks.
  9. ;ClassList equ <WM,DM>
  10. ClassList equ <WM>
  11. ;***********************************************************************;
  12. ; Thunk pre- and post-processing macros. These perform any necessary
  13. ; setup prior to calling the thunking subroutines.
  14. ;***********************************************************************;
  15. ;----------------------------------------------------------------------------
  16. ; MsgStructThkPreProc
  17. ;
  18. ; flags
  19. ; Indicates api-specific flags to set in s16_fw.
  20. ;
  21. ; noprethunk
  22. ; If non-blank, indicates that the message structure is uninitialized
  23. ; and should not be thunked before calling the API.
  24. ;
  25. ; no_load_pmsg
  26. ; Indicates that es:edi already contains pmsg, so don't reload it.
  27. ;
  28. ; Requirements:
  29. ; bp_pMsg be defined
  30. ; si_space be defined
  31. ; si_msg16 be defined
  32. ;
  33. ; Results:
  34. ; SP = original SP - size THKSPACE16 - size MSGSTRUCT16
  35. ; - extra space allocated by thunk, if any
  36. ; History:
  37. ; 08-07-91 BobGru
  38. ; Wrote it.
  39. ;----------------------------------------------------------------------------
  40. MsgStructThkPreProc macro flags:=<0>, no_load_pmsg, base:=<si>
  41. AssertUserDS
  42. ;;Allocate local variable space
  43. sub sp,size THKSPACE16 + MSGSTRUCT16_SIZE
  44. InitLocalSpace flags, base
  45. ifb <no_load_pmsg>
  46. mov es, FlatData
  47. mov edi, bp_pMsg
  48. endif
  49. ;;Pack the non-thunked message structure elements into the msg16 structure.
  50. mov eax, dword ptr es:[edi].ms32_time
  51. mov dword ptr base&_msg16.ms16_time, eax
  52. mov ax, word ptr es:[edi].ms32_pt.pt32_x
  53. mov word ptr base&_msg16.ms16_pt.pt16_x, ax
  54. mov ax, word ptr es:[edi].ms32_pt.pt32_y
  55. mov word ptr base&_msg16.ms16_pt.pt16_y, ax
  56. ;;Thunk the message parameters.
  57. push word ptr es:[edi].ms32_hwnd
  58. push word ptr es:[edi].ms32_message
  59. push dword ptr es:[edi].ms32_wParam
  60. push dword ptr es:[edi].ms32_lParam
  61. call ThkMsgLS
  62. ;;Pack the thunked parameters into the msg16 structure.
  63. mov ax, word ptr base&_space.s16_hwnd
  64. mov word ptr base&_msg16.ms16_hwnd, ax
  65. mov ax, word ptr base&_space.s16_message
  66. mov word ptr base&_msg16.ms16_message, ax
  67. mov ax, word ptr base&_space.s16_wParam.lo
  68. mov word ptr base&_msg16.ms16_wParamLo, ax
  69. mov eax, dword ptr base&_space.s16_lParam
  70. mov dword ptr base&_msg16.ms16_lParam, eax
  71. mov ax, word ptr base&_space.s16_wParam.hi
  72. mov word ptr base&_msg16.ms16_wParamHi, ax
  73. endm
  74. ;----------------------------------------------------------------------------
  75. ; MsgStructThkPostProc
  76. ;
  77. ; no_copyout_pmsg
  78. ; If non-blank, don't unthunk the message structure since it's an
  79. ; input-only parameter.
  80. ;
  81. ; Requirements:
  82. ; bp_pMsg be defined
  83. ; si_space be defined
  84. ; si_msg16 be defined
  85. ; si_cleanup be defined
  86. ;
  87. ; Results:
  88. ;----------------------------------------------------------------------------
  89. MsgStructThkPostProc macro base:=<si>, no_copyout_pmsg
  90. AssertUserDS
  91. ; Save return code. We're not thunking it, but we want to save it.
  92. mov dword ptr base&_space.s16_lResult, eax
  93. push word ptr base&_msg16.ms16_hwnd
  94. push word ptr base&_msg16.ms16_message
  95. push word ptr base&_msg16.ms16_wParamHi
  96. push word ptr base&_msg16.ms16_wParamLo
  97. push dword ptr base&_msg16.ms16_lParam
  98. call ThkMsgSL ;;destroys EDI
  99. ifb <no_copyout_pmsg>
  100. ;;Copy the 32-bit message parameters from si_space back into the
  101. ;;msgstruct32 structure.
  102. mov es, FlatData
  103. mov edi,bp_pMsg
  104. cld
  105. xor eax, eax
  106. mov ax, word ptr base&_space.s16_hwnd
  107. stosd es:[edi]
  108. .errnz ms32_hwnd
  109. mov ax, word ptr base&_space.s16_message
  110. stosd es:[edi]
  111. .errnz ms32_message - ms32_hwnd - 4
  112. mov eax, dword ptr base&_space.s16_wParam
  113. stosd es:[edi]
  114. .errnz ms32_wParam - ms32_message - 4
  115. mov eax, dword ptr base&_space.s16_lParam
  116. stosd es:[edi]
  117. .errnz ms32_lParam - ms32_wParam - 4
  118. mov eax, base&_msg16.ms16_time
  119. stosd es:[edi]
  120. .errnz ms32_time - ms32_lParam - 4
  121. movsx eax,word ptr (base&_msg16.ms16_pt.pt16_x)
  122. stosd es:[edi]
  123. .errnz ms32_pt - ms32_time - 4
  124. .errnz MSGSTRUCT32_SIZE - ms32_pt - 8
  125. .errnz pt32_x
  126. movsx eax,word ptr (base&_msg16.ms16_pt.pt16_y)
  127. stosd es:[edi]
  128. .errnz pt32_y - pt32_x - 4
  129. .errnz POINT32_SIZE - pt32_y - 4
  130. endif
  131. ; Put return value back
  132. mov eax, dword ptr base&_space.s16_lResult
  133. % ifidni <base>,<si>
  134. lea sp,si_cleanup
  135. endif
  136. endm
  137. ;----------------------------------------------------------------------------
  138. ; CwpStructThkPreProc
  139. ;
  140. ; flags
  141. ; Indicates api-specific flags to set in s16_fw.
  142. ;
  143. ; noprethunk
  144. ; If non-blank, indicates that the message structure is uninitialized
  145. ; and should not be thunked before calling the API.
  146. ;
  147. ; Requirements:
  148. ; bp_pCwp be defined
  149. ; si_space be defined
  150. ; si_cwp16 be defined
  151. ;
  152. ; Results:
  153. ; SP = original SP - size THKSPACE16 - size CWPSTRUCT16
  154. ; - extra space allocated by thunk, if any
  155. ; History:
  156. ; 08-07-91 BobGru
  157. ; Wrote it.
  158. ;----------------------------------------------------------------------------
  159. CwpStructThkPreProc macro flags:=<0>
  160. AssertUserDS
  161. ;;Allocate local variable space
  162. sub sp,size THKSPACE16 + CWPSTRUCT16_SIZE
  163. InitLocalSpace flags
  164. mov es,FlatData
  165. mov edi,bp_pCwp
  166. ;;Thunk the message parameters.
  167. push word ptr es:[edi].cwp32_hwnd
  168. push word ptr es:[edi].cwp32_message
  169. push dword ptr es:[edi].cwp32_wParam
  170. push dword ptr es:[edi].cwp32_lParam
  171. call ThkMsgLS
  172. ;;Pack the thunked parameters into the cwp16 structure.
  173. mov ax, word ptr si_space.s16_hwnd
  174. mov word ptr si_cwp16.cwp16_hwnd, ax
  175. mov ax, word ptr si_space.s16_message
  176. mov word ptr si_cwp16.cwp16_message, ax
  177. mov ax, word ptr si_space.s16_wParam.hi
  178. mov word ptr si_cwp16.cwp16_wParamHi, ax
  179. mov ax, word ptr si_space.s16_wParam.lo
  180. mov word ptr si_cwp16.cwp16_wParamLo, ax
  181. mov eax, dword ptr si_space.s16_lParam
  182. mov dword ptr si_cwp16.cwp16_lParam, eax
  183. endm
  184. ;----------------------------------------------------------------------------
  185. ; CwpStructThkPostProc
  186. ;
  187. ; retsize
  188. ; Either AX or DXAX, determines the size of the return code.
  189. ; checknull
  190. ; If non-blank, indicates that if the return code is zero, the
  191. ; message structure should not be unthunked, since it is uninitialized.
  192. ; noprethunk
  193. ; If non-blank, indicates that the lParam field of the thunk space
  194. ; should not be initialized from the value passed in, since there
  195. ; was no value passed in.
  196. ;
  197. ; Requirements:
  198. ; bp_pCwp be defined
  199. ; si_space be defined
  200. ; si_cwp16 be defined
  201. ; si_cleanup be defined
  202. ;
  203. ; Results:
  204. ;----------------------------------------------------------------------------
  205. CwpStructThkPostProc macro
  206. AssertUserDS
  207. ; Save hook return result. Since we are NOT setting TF_THUNKMSGRESULT,
  208. ; lResult shouldn't be touched. We can use it as a temp buffer.
  209. mov word ptr si_space.s16_lResult, ax
  210. mov word ptr si_space.s16_lResult+2, dx
  211. push word ptr si_cwp16.cwp16_hwnd
  212. push word ptr si_cwp16.cwp16_message
  213. push word ptr si_cwp16.cwp16_wParamHi
  214. push word ptr si_cwp16.cwp16_wParamLo
  215. push dword ptr si_cwp16.cwp16_lParam
  216. call ThkMsgSL ;;destroys EDI
  217. ;;Copy the 32-bit message parameters from si_space back into the
  218. ;;CWPSTRUCT32 structure.
  219. mov es, FlatData
  220. mov edi, bp_pCwp
  221. cld
  222. mov eax, si_space.s16_lParam
  223. stosd es:[edi]
  224. .errnz cwp32_lParam
  225. mov eax,si_space.s16_wParam
  226. stosd es:[edi]
  227. .errnz cwp32_wParam - cwp32_lParam - 4
  228. xor eax, eax
  229. mov ax, word ptr si_space.s16_message
  230. stosd es:[edi]
  231. .errnz cwp32_message - cwp32_wParam - 4
  232. mov ax, word ptr si_space.s16_hwnd
  233. stosd es:[edi]
  234. .errnz cwp32_hwnd - cwp32_message - 4
  235. .errnz CWPSTRUCT32_SIZE - cwp32_hwnd - 4
  236. ; Restore hook return code to EAX
  237. mov eax, dword ptr si_space.s16_lResult
  238. lea sp,si_cleanup
  239. endm
  240. ;----------------------------------------------------------------------------
  241. ; CwpRetStructThkPreProc
  242. ;
  243. ; flags
  244. ; Indicates api-specific flags to set in s16_fw.
  245. ;
  246. ; noprethunk
  247. ; If non-blank, indicates that the message structure is uninitialized
  248. ; and should not be thunked before calling the API.
  249. ;
  250. ; Requirements:
  251. ; bp_pCwpRet be defined
  252. ; si_space be defined
  253. ; si_cwpret16 be defined
  254. ;
  255. ; Results:
  256. ; SP = original SP - size THKSPACE16 - size CWPRETSTRUCT16
  257. ; - extra space allocated by thunk, if any
  258. ; History:
  259. ; 08-07-91 BobGru
  260. ; Wrote it.
  261. ;----------------------------------------------------------------------------
  262. CwpRetStructThkPreProc macro
  263. AssertUserDS
  264. ;;Allocate local variable space
  265. sub sp,size THKSPACE16 + CWPRETSTRUCT16_SIZE
  266. InitLocalSpace TF_THUNKMSGRESULT
  267. mov es, FlatData
  268. mov edi,bp_pCwpRet
  269. ;Thunk the message parameters.
  270. mov eax, dword ptr es:[edi].cwpret32_lResult
  271. mov dword ptr si_space.s16_lResult, eax
  272. push word ptr es:[edi].cwpret32_hwnd
  273. push word ptr es:[edi].cwpret32_message
  274. push dword ptr es:[edi].cwpret32_wParam
  275. push dword ptr es:[edi].cwpret32_lParam
  276. call ThkMsgLS
  277. ; Copy the thunked parms back
  278. mov eax, dword ptr si_space.s16_lResult
  279. mov dword ptr si_cwpret16.cwpret16_lResult, eax
  280. mov ax, word ptr si_space.s16_wParam.hi
  281. mov word ptr si_cwpret16.cwpret16_wParamHi, ax
  282. mov eax, dword ptr si_space.s16_lParam
  283. mov dword ptr si_cwpret16.cwpret16_lParam, eax
  284. mov ax, word ptr si_space.s16_wParam.lo
  285. mov word ptr si_cwpret16.cwpret16_wParamLo, ax
  286. mov ax, word ptr si_space.s16_message
  287. mov word ptr si_cwpret16.cwpret16_message, ax
  288. mov ax, word ptr si_space.s16_hwnd
  289. mov word ptr si_cwpret16.cwpret16_hwnd, ax
  290. endm
  291. ;----------------------------------------------------------------------------
  292. ; CwpRetStructThkPostProc
  293. ;
  294. ; retsize
  295. ; Either AX or DXAX, determines the size of the return code.
  296. ; checknull
  297. ; If non-blank, indicates that if the return code is zero, the
  298. ; message structure should not be unthunked, since it is uninitialized.
  299. ; noprethunk
  300. ; If non-blank, indicates that the lParam field of the thunk space
  301. ; should not be initialized from the value passed in, since there
  302. ; was no value passed in.
  303. ;
  304. ; Requirements:
  305. ; bp_pCwp be defined
  306. ; si_space be defined
  307. ; si_cwp16 be defined
  308. ; si_cleanup be defined
  309. ;
  310. ; Results:
  311. ;----------------------------------------------------------------------------
  312. CwpRetStructThkPostProc macro
  313. AssertUserDS
  314. ;;Thunk the message parameters. Before calling the thunk, put the
  315. ;;original lParam value in the si_space structure, so that the xmovs
  316. ;;macro can find it.
  317. ;;
  318. ;;Push the 16-bit message parameters and copy the 32-bit lParam into
  319. ;;si_space. Afterwards, si_space will contain the 32-bit values to
  320. ;;return to the system.
  321. ifdef DEBUG
  322. ; Better have TF_THUNKMSGRESULT set
  323. test si_space.s16_fw, TF_THUNKMSGRESULT
  324. jnz @F
  325. int 3
  326. @@:
  327. endif
  328. ; Save 16bit hook return code
  329. push dx
  330. push ax
  331. ; Save message return result to be thunked.
  332. mov eax, dword ptr si_cwpret16.cwpret16_lResult
  333. mov dword ptr si_space.s16_lResult, eax
  334. push word ptr si_cwpret16.cwpret16_hwnd
  335. push word ptr si_cwpret16.cwpret16_message
  336. push word ptr si_cwpret16.cwpret16_wParamHi
  337. push word ptr si_cwpret16.cwpret16_wParamLo
  338. push dword ptr si_cwpret16.cwpret16_lParam
  339. call ThkMsgSL ;;destroys EDI
  340. ;;Copy the 32-bit message parameters from si_space back into the
  341. ;;CWPSTRUCT32 structure.
  342. mov es, FlatData
  343. mov edi,bp_pCwpRet
  344. cld
  345. ; Result
  346. mov eax, dword ptr si_space.s16_lResult
  347. stosd es:[edi]
  348. .errnz cwpret32_lResult
  349. mov eax, dword ptr si_space.s16_lParam
  350. stosd es:[edi]
  351. .errnz cwpret32_lParam - cwpret32_lResult - 4
  352. mov eax, dword ptr si_space.s16_wParam
  353. stosd es:[edi]
  354. .errnz cwpret32_wParam - cwpret32_lParam - 4
  355. xor eax, eax
  356. mov ax, word ptr si_space.s16_message
  357. stosd es:[edi]
  358. .errnz cwpret32_message - cwpret32_wParam - 4
  359. mov ax, word ptr si_space.s16_hwnd
  360. stosd es:[edi]
  361. .errnz cwpret32_hwnd - cwpret32_message - 4
  362. .errnz CWPRETSTRUCT32_SIZE - cwpret32_hwnd - 4
  363. ; Restore 32bit hook return code
  364. pop eax
  365. lea sp,si_cleanup
  366. endm
  367. ;----------------------------------------------------------------------------
  368. ; HhsStructThkPreProc
  369. ;
  370. ; flags
  371. ; Indicates api-specific flags to set in s16_fw.
  372. ;
  373. ; noprethunk
  374. ; If non-blank, indicates that the message structure is uninitialized
  375. ; and should not be thunked before calling the API.
  376. ;
  377. ; Requirements:
  378. ; bp_pHhs be defined
  379. ; si_space be defined
  380. ; si_hhs16 be defined
  381. ;
  382. ; Results:
  383. ; SP = original SP - size THKSPACE16 - size HARDWAREHOOKSTRUCT16
  384. ; - extra space allocated by thunk, if any
  385. ; History:
  386. ; 08-07-91 BobGru
  387. ; Wrote it.
  388. ;----------------------------------------------------------------------------
  389. HhsStructThkPreProc macro flags:=<0>
  390. AssertUserDS
  391. ;;Allocate local variable space
  392. sub sp,size THKSPACE16 + HARDWAREHOOKSTRUCT16_SIZE
  393. InitLocalSpace flags
  394. mov es, FlatData
  395. mov edi,bp_pHhs
  396. ;;Thunk the message parameters.
  397. push word ptr es:[edi].hhs32_hwnd
  398. push word ptr es:[edi].hhs32_message
  399. push dword ptr es:[edi].hhs32_wParam
  400. push dword ptr es:[edi].hhs32_lParam
  401. call ThkMsgLS
  402. ;;Pack the thunked parameters into the msg16 structure.
  403. mov ax, word ptr si_space.s16_hwnd
  404. mov word ptr si_hhs16.hhs16_hwnd, ax
  405. mov ax, word ptr si_space.s16_message
  406. mov word ptr si_hhs16.hhs16_message, ax
  407. mov ax, word ptr si_space.s16_wParam.lo
  408. mov word ptr si_hhs16.hhs16_wParamLo, ax
  409. mov eax, dword ptr si_space.s16_lParam
  410. mov dword ptr si_hhs16.hhs16_lParam, eax
  411. mov ax, word ptr si_space.s16_wParam.hi
  412. mov word ptr si_hhs16.hhs16_wParamHi, ax
  413. endm
  414. ;----------------------------------------------------------------------------
  415. ; HhsStructThkPostProc
  416. ;
  417. ; retsize
  418. ; Either AX or DXAX, determines the size of the return code.
  419. ; checknull
  420. ; If non-blank, indicates that if the return code is zero, the
  421. ; message structure should not be unthunked, since it is uninitialized.
  422. ; noprethunk
  423. ; If non-blank, indicates that the lParam field of the thunk space
  424. ; should not be initialized from the value passed in, since there
  425. ; was no value passed in.
  426. ;
  427. ; Requirements:
  428. ; bp_pHhs be defined
  429. ; si_space be defined
  430. ; si_hhs16 be defined
  431. ; si_cleanup be defined
  432. ;
  433. ; Results:
  434. ;----------------------------------------------------------------------------
  435. HhsStructThkPostProc macro
  436. AssertUserDS
  437. ; Save 16bit hook return code
  438. mov si_space.s16_lResult.lo, ax
  439. mov si_space.s16_lResult.hi, dx
  440. push word ptr si_hhs16.hhs16_hwnd
  441. push word ptr si_hhs16.hhs16_message
  442. push word ptr si_hhs16.hhs16_wParamHi
  443. push word ptr si_hhs16.hhs16_wParamLo
  444. push dword ptr si_hhs16.hhs16_lParam
  445. call ThkMsgSL ;;destroys EDI
  446. ;;Copy the 32-bit message parameters from si_space back into the
  447. ;;HARDWAREHOOKSTRUCT32 structure.
  448. mov es, FlatData
  449. mov edi,bp_pHhs
  450. cld
  451. xor eax, eax
  452. mov ax, word ptr si_space.s16_hwnd
  453. stosd es:[edi]
  454. .errnz hhs32_hwnd
  455. mov ax, word ptr si_space.s16_message
  456. stosd es:[edi]
  457. .errnz hhs32_message - hhs32_hwnd - 4
  458. mov eax,si_space.s16_wParam
  459. stosd es:[edi]
  460. .errnz hhs32_wParam - hhs32_message - 4
  461. mov eax,si_space.s16_lParam
  462. stosd es:[edi]
  463. .errnz hhs32_lParam - hhs32_wParam - 4
  464. .errnz HARDWAREHOOKSTRUCT32_SIZE - hhs32_lParam - 4
  465. ;Restore 32bit hook return code
  466. mov eax, dword ptr si_space.s16_lResult
  467. lea sp,si_cleanup
  468. endm
  469. ;----------------------------------------------------------------------------
  470. ; CbtStructThkPreProc
  471. ;
  472. ; flags
  473. ; Indicates api-specific flags to set in s16_fw.
  474. ;
  475. ; noprethunk
  476. ; If non-blank, indicates that the message structure is uninitialized
  477. ; and should not be thunked before calling the API.
  478. ;
  479. ; Requirements:
  480. ; bp_nType be defined
  481. ; bp_pMsg be defined
  482. ; si_space be defined
  483. ;----------------------------------------------------------------------------
  484. CbtStructThkPreProc macro flags:=<0>
  485. local cbt_hook_error
  486. local HookDispatch
  487. local MAX_CBT_CODE
  488. local thk_HCBT_MOVESIZE
  489. local thk_HCBT_MINMAX
  490. local thk_HCBT_QS
  491. local thk_HCBT_CREATEWND
  492. local thk_HCBT_DESTROYWND
  493. local thk_HCBT_ACTIVATE
  494. local thk_HCBT_CLICKSKIPPED
  495. local thk_HCBT_KEYSKIPPED
  496. local thk_HCBT_SYSCOMMAND
  497. local thk_HCBT_SETFOCUS
  498. local si_cbtc
  499. AssertUserDS
  500. ;;Allocate local variable space
  501. sub sp,size THKSPACE16
  502. InitLocalSpace flags
  503. ; Convert wParam -- same for all HCBT_ hooks
  504. mov eax, dword ptr bp_wParam
  505. mov dword ptr si_space.s16_wParam, eax
  506. mov bx,bp_nCode
  507. cmp bx,MAX_CBT_CODE
  508. ja cbt_hook_error
  509. add bx,bx
  510. jmp cs:HookDispatch[bx]
  511. HookDispatch label word
  512. dw offset thk_HCBT_MOVESIZE
  513. dw offset thk_HCBT_MINMAX
  514. dw offset thk_HCBT_QS
  515. dw offset thk_HCBT_CREATEWND
  516. dw offset thk_HCBT_DESTROYWND
  517. dw offset thk_HCBT_ACTIVATE
  518. dw offset thk_HCBT_CLICKSKIPPED
  519. dw offset thk_HCBT_KEYSKIPPED
  520. dw offset thk_HCBT_SYSCOMMAND
  521. dw offset thk_HCBT_SETFOCUS
  522. MAX_CBT_CODE equ ($-HookDispatch)/2
  523. ;Error -- invalid CBT code. Fall through to the minimal thunking.
  524. cbt_hook_error:
  525. thk_HCBT_DESTROYWND:
  526. thk_HCBT_KEYSKIPPED:
  527. thk_HCBT_MINMAX:
  528. thk_HCBT_QS:
  529. thk_HCBT_SETFOCUS: ;!!!need spec for this one
  530. thk_HCBT_SYSCOMMAND:
  531. mov eax, dword ptr bp_pMsg
  532. mov dword ptr si_space.s16_lParam, eax
  533. jmp thk_WH_CBT_call
  534. thk_HCBT_ACTIVATE:
  535. sub sp,CBTACTIVATESTRUCT16_SIZE
  536. xchg bx,si ;save frame pointer
  537. mov di,ss ;init DS:ESI --> source, ES:EDI --> dest
  538. mov es,di
  539. movzx edi,sp
  540. mov esi,bp_pMsg
  541. push ds
  542. mov ds, FlatData
  543. cld
  544. call cvtCBTACTIVATESTRUCTLS
  545. pop ds
  546. xchg bx,si ;restore frame pointer
  547. or word ptr si_space.s16_fw, TF_CLEANUP
  548. mov word ptr si_space.s16_lParam[0],sp
  549. mov word ptr si_space.s16_lParam[2],ss
  550. jmp thk_WH_CBT_call
  551. thk_HCBT_MOVESIZE:
  552. sub sp,RECT16_SIZE
  553. xchg bx,si ;save frame pointer
  554. mov di,ss ;init DS:ESI --> source, ES:EDI --> dest
  555. mov es,di
  556. movzx edi,sp
  557. mov esi,bp_pMsg
  558. push ds
  559. mov ds, FlatData
  560. cld
  561. call cvtRECTLS
  562. pop ds
  563. xchg bx,si ;restore frame pointer
  564. or word ptr si_space.s16_fw, TF_CLEANUP
  565. mov word ptr si_space.s16_lParam[0],sp
  566. mov word ptr si_space.s16_lParam[2],ss
  567. jmp thk_WH_CBT_call
  568. thk_HCBT_CREATEWND:
  569. si_cbtc equ <(si_space-CBT_CREATEWND16_SIZE)>
  570. sub sp,CREATESTRUCT16_SIZE+CBT_CREATEWND16_SIZE
  571. lea ax,si_cbtc
  572. mov word ptr si_space.s16_lParam[0],ax
  573. mov word ptr si_space.s16_lParam[2],ss
  574. ;Repack the CBT_CREATEWND structure here, then set up for
  575. ;the cvtCREATESTRUCTLS macro.
  576. mov es, FlatData
  577. mov edi,bp_pMsg
  578. mov ax, word ptr es:[edi].cbtc32_hwndInsertAfter
  579. mov word ptr si_cbtc.cbtc16_hwndInsertAfter, ax
  580. mov word ptr si_cbtc.cbtc16_lpcs[0],sp
  581. mov word ptr si_cbtc.cbtc16_lpcs[2],ss
  582. ;Space has already been allocated for the new CREATESTRUCT,
  583. ;and SS:SP points to it. Set up for the macro in the usual way.
  584. xchg bx,si ;save frame pointer
  585. mov di,ss ;init DS:ESI --> source, ES:EDI --> dest
  586. mov es,di
  587. movzx edi,sp
  588. push ds
  589. mov ds, FlatData
  590. mov esi,bp_pMsg
  591. mov esi, dword ptr ds:[esi].cbtc32_lpcs
  592. cld
  593. call cvtCREATESTRUCTLS
  594. pop ds
  595. xchg bx,si ;restore frame pointer
  596. ;Adjust pointer to skip wIdHi
  597. add word ptr si_cbtc.cbtc16_lpcs[0],2
  598. ; Set TF_CLEANUP bit now so that unmaps happen when we convert
  599. ; createstruct back.
  600. or word ptr si_space.s16_fw, TF_CLEANUP
  601. ;Safety check that we haven't forgotten any fields of the structure.
  602. .errnz cbtc16_lpcs
  603. .errnz cbtc16_hwndInsertAfter - cbtc16_lpcs - 4
  604. .errnz CBT_CREATEWND16_SIZE - cbtc16_hwndInsertAfter - 2
  605. jmp thk_WH_CBT_call
  606. thk_HCBT_CLICKSKIPPED:
  607. sub sp,MOUSEHOOKSTRUCT16_SIZE
  608. xchg bx,si ;save frame pointer
  609. mov di,ss ;init DS:ESI --> source, ES:EDI --> dest
  610. mov es,di
  611. movzx edi,sp
  612. mov esi,bp_pMsg
  613. push ds
  614. mov ds, FlatData
  615. cld
  616. call cvtMOUSEHOOKSTRUCTLS
  617. pop ds
  618. xchg bx,si ;restore frame pointer
  619. or word ptr si_space.s16_fw, TF_CLEANUP
  620. mov word ptr si_space.s16_lParam[0],sp
  621. mov word ptr si_space.s16_lParam[2],ss
  622. ;!!! am assuming don't need to unpack MOUSEHOOKSTRUCT
  623. jmp thk_WH_CBT_call
  624. endm
  625. ;----------------------------------------------------------------------------
  626. ;
  627. ; CbtStructThkPostProc
  628. ;
  629. ; We need to cleanup after making 16-bit call. Any HCBT_ codes with
  630. ; LP to structures in lParam require cleanup. This structure must be
  631. ; copied and converted back. I.E., SRC is 16-bits, DST is 32-bits.
  632. ;
  633. ;----------------------------------------------------------------------------
  634. CbtStructThkPostProc macro
  635. local cbt_hook_error
  636. local cbt_done
  637. local HookDispatch
  638. local MAX_CBT_CODE
  639. local thk_HCBT_MOVESIZE
  640. local thk_HCBT_MINMAX
  641. local thk_HCBT_QS
  642. local thk_HCBT_CREATEWND
  643. local thk_HCBT_DESTROYWND
  644. local thk_HCBT_ACTIVATE
  645. local thk_HCBT_CLICKSKIPPED
  646. local thk_HCBT_KEYSKIPPED
  647. local thk_HCBT_SYSCOMMAND
  648. local thk_HCBT_SETFOCUS
  649. AssertUserDS
  650. ; Save 16bit return code
  651. mov si_space.s16_lResult.lo, ax
  652. mov si_space.s16_lResult.hi, dx
  653. ; Copy back any structures
  654. mov bx, bp_nCode
  655. cmp bx, MAX_CBT_CODE
  656. ja cbt_hook_error
  657. add bx, bx
  658. jmp cs:HookDispatch[bx]
  659. HookDispatch label word
  660. dw offset thk_HCBT_MOVESIZE
  661. dw offset thk_HCBT_MINMAX
  662. dw offset thk_HCBT_QS
  663. dw offset thk_HCBT_CREATEWND
  664. dw offset thk_HCBT_DESTROYWND
  665. dw offset thk_HCBT_ACTIVATE
  666. dw offset thk_HCBT_CLICKSKIPPED
  667. dw offset thk_HCBT_KEYSKIPPED
  668. dw offset thk_HCBT_SYSCOMMAND
  669. dw offset thk_HCBT_SETFOCUS
  670. MAX_CBT_CODE equ ($-HookDispatch)/2
  671. thk_HCBT_CREATEWND:
  672. si_cbtc equ <(si_space-CBT_CREATEWND16_SIZE)>
  673. ; lParam is an LPCBT_CREATEWND, which contains an embedded LPCREATESTRUCT
  674. push ds
  675. push esi
  676. push edi
  677. ; 32-bit LPCBT_CREATEWND
  678. mov es, FlatData ; Do this before changing DS
  679. mov edi, bp_pMsg
  680. ; 16-bit LPCBT_CREATEWND Save frame pointer in BX!
  681. mov bx, si
  682. lds si, dword ptr si_space.s16_lParam
  683. ; Copy back the HWND
  684. movzx eax, word ptr ds:[si].cbtc16_hwndInsertAfter
  685. mov dword ptr es:[edi].cbtc32_hwndInsertAfter, eax
  686. ; Cleanup the CREATESTRUCT
  687. ; 32-bit LPCREATESTRUCT
  688. mov edi, dword ptr es:[edi].cbtc32_lpcs
  689. ; 16-bit LPCREATESTRUCT
  690. lds si, dword ptr ds:[si].cbtc16_lpcs
  691. sub si, 2
  692. movzx esi, si
  693. cld
  694. call cvtCREATESTRUCTSL
  695. pop edi
  696. pop esi
  697. pop ds
  698. jmp cbt_done
  699. thk_HCBT_ACTIVATE:
  700. ; lParam is an LPCBTACTIVATESTRUCT
  701. push ds
  702. push esi
  703. push edi
  704. ; 32-bit LPCBTACTIVATESTRUCT
  705. mov es, FlatData
  706. mov edi, bp_pMsg
  707. ; 16-bit LPCBTACTIVATESTRUCT
  708. mov bx, si
  709. lds si, dword ptr si_space.s16_lParam
  710. movzx esi, si
  711. cld
  712. call cvtCBTACTIVATESTRUCTSL
  713. pop edi
  714. pop esi
  715. pop ds
  716. jmp cbt_done
  717. thk_HCBT_MOVESIZE:
  718. ; lParam is an LPRECT
  719. push ds
  720. push esi
  721. push edi
  722. ; 32-bit LPRECT
  723. mov es, FlatData
  724. mov edi, bp_pMsg
  725. ; 16-bit LPRECT
  726. mov bx, si
  727. lds si, dword ptr si_space.s16_lParam
  728. movzx esi, si
  729. cld
  730. call cvtRECTSL
  731. pop edi
  732. pop esi
  733. pop ds
  734. jmp cbt_done
  735. thk_HCBT_CLICKSKIPPED:
  736. ; lParam is an LPMOUSEHOOKSTRUCT
  737. push ds
  738. push esi
  739. push edi
  740. ; 32-bit LPMOUSEHOOKSTRUCT
  741. mov es, FlatData
  742. mov edi, bp_pMsg
  743. ; 16-bit LPMOUSEHOOKSTRUCT
  744. mov bx, si
  745. lds si, dword ptr si_space.s16_lParam
  746. movzx esi, si
  747. cld
  748. call cvtMOUSEHOOKSTRUCTSL
  749. pop edi
  750. pop esi
  751. pop ds
  752. jmp cbt_done
  753. cbt_hook_error:
  754. ; Error -- invalid CBT code.
  755. ; FALL THRU
  756. thk_HCBT_DESTROYWND:
  757. thk_HCBT_KEYSKIPPED:
  758. thk_HCBT_MINMAX:
  759. thk_HCBT_QS:
  760. thk_HCBT_SETFOCUS:
  761. thk_HCBT_SYSCOMMAND:
  762. ; No cleanup required
  763. cbt_done:
  764. ;Restore 32bit return code
  765. mov eax, dword ptr si_space.s16_lResult
  766. lea sp,si_cleanup
  767. endm
  768. ;----------------------------------------------------------------------------
  769. ; MhsStructThkPreProc
  770. ;
  771. ; Requirements:
  772. ; bp_pMhs be defined
  773. ;
  774. ; Results:
  775. ; SP = original SP - size MOUSEHOOKSTRUCT16
  776. ; History:
  777. ; 04-10-92 BobGru
  778. ; Wrote it.
  779. ;----------------------------------------------------------------------------
  780. MhsStructThkPreProc macro
  781. AssertUserDS
  782. sub sp,MOUSEHOOKSTRUCT16_SIZE
  783. xchg bx,si ;save frame pointer
  784. mov di,ss ;init DS:ESI --> source, ES:EDI --> dest
  785. mov es,di
  786. movzx edi,sp ;do before any pushes
  787. push ds
  788. mov ds,FlatData
  789. mov esi,bp_pMhs
  790. cld
  791. call cvtMOUSEHOOKSTRUCTLS
  792. pop ds
  793. xchg bx,si ;restore frame pointer
  794. endm
  795. ;----------------------------------------------------------------------------
  796. ; MhsStructThkPostProc
  797. ;
  798. ; Requirements:
  799. ; bp_pMhs be defined
  800. ;
  801. ; Results:
  802. ;
  803. ; History:
  804. ; 04-10-92 BobGru
  805. ; Wrote it.
  806. ;----------------------------------------------------------------------------
  807. MhsStructThkPostProc macro
  808. AssertUserDS
  809. xchg bx,si ;save frame pointer
  810. movzx esi,sp ;do before any pushes
  811. push ds
  812. ;Save return code
  813. push dx
  814. push ax
  815. mov es,FlatData ;do this while DS=DATA
  816. mov di,ss ;init DS:ESI --> source, ES:EDI --> dest
  817. mov ds,di
  818. mov edi,bp_pMhs
  819. cld
  820. call cvtMOUSEHOOKSTRUCTSL
  821. ;Restore return code
  822. pop eax
  823. pop ds
  824. xchg bx,si ;restore frame pointer
  825. lea sp,si_cleanup
  826. endm
  827. ;----------------------------------------------------------------------------
  828. ; JhsStructThkPreProc
  829. ;
  830. ; Requirements:
  831. ; bp_pJhs be defined
  832. ; si_type ""
  833. ; DX must be 0 or 1; 0 for JOURNALRECORD, 1 for JOURNALPLAYBACK
  834. ;
  835. ; Results:
  836. ; SP = original SP - size EVENTMSG16
  837. ;----------------------------------------------------------------------------
  838. JhsStructThkPreProc macro
  839. AssertUserDS
  840. push dx
  841. sub sp,EVENTMSG16_SIZE
  842. xchg bx,si ;save frame pointer
  843. mov di,ss ;init DS:ESI --> source, ES:EDI --> dest
  844. mov es,di
  845. movzx edi,sp ;do before any pushes
  846. push ds
  847. mov ds,FlatData
  848. mov esi,bp_pJhs
  849. or esi,esi
  850. jz @F
  851. cld
  852. call cvtEVENTMSGLS
  853. @@:
  854. pop ds
  855. xchg bx,si ;restore frame pointer
  856. endm
  857. ;----------------------------------------------------------------------------
  858. ; JhsStructThkPostProc
  859. ;
  860. ; Requirements:
  861. ; bp_pJhs be defined
  862. ; si_type ""
  863. ; DX must be 0 or 1; 0 for JOURNALRECORD, 1 for JOURNALPLAYBACK
  864. ;
  865. ; Results:
  866. ;
  867. ;----------------------------------------------------------------------------
  868. JhsStructThkPostProc macro
  869. AssertUserDS
  870. ; Restore DX. Do this first before we trash SI.
  871. mov dx, word ptr si_type
  872. xchg bx,si ;save frame pointer
  873. movzx esi,sp ;do before any pushes
  874. push ds
  875. ;Save return code
  876. push eax
  877. mov es,FlatData ;do this while DS=DATA
  878. mov di,ss ;init DS:ESI --> source, ES:EDI --> dest
  879. mov ds,di
  880. mov edi,bp_pJhs
  881. or edi,edi
  882. jz @F
  883. cld
  884. call cvtEVENTMSGSL
  885. @@:
  886. ;Restore return code
  887. pop eax
  888. pop ds
  889. xchg bx,si ;restore frame pointer
  890. lea sp,si_cleanup
  891. endm
  892. ;----------------------------------------------------------------------------
  893. ;
  894. ; DhsStructThkPreProc
  895. ; Thunks L->S for WH_DEBUG
  896. ;
  897. ;----------------------------------------------------------------------------
  898. DhsStructThkPreProc macro
  899. AssertUserDS
  900. sub sp, DEBUGHOOK16_SIZE
  901. xchg bx, si
  902. mov di, ss
  903. mov es, di
  904. movzx edi, sp
  905. push ds
  906. mov ds, FlatData
  907. mov esi, bp_pDhs
  908. cld
  909. ; EXPECTS AX TO BE hook type
  910. ; RETURNS hTask in AX
  911. mov ax, word ptr bp_wParam
  912. call cvtDEBUGHOOKLS
  913. mov word ptr bp_wParam, ax
  914. pop ds
  915. xchg bx, si
  916. endm
  917. ;----------------------------------------------------------------------------
  918. ;
  919. ; DhsStructThkPostProc
  920. ; Cleans up S->L for WH_DEBUG
  921. ;
  922. ;----------------------------------------------------------------------------
  923. DhsStructThkPostProc macro
  924. AssertUserDS
  925. xchg bx, si
  926. movzx esi, sp
  927. push ds
  928. ; Save return AFTER setting up ESI with SP
  929. push dx
  930. push ax
  931. mov es, FlatData
  932. mov di, ss
  933. mov ds, di
  934. mov edi, bp_pDhs
  935. cld
  936. ; EXPECTS AX to be hTask
  937. ; RETURNS whType in AX (don't need it anymore)
  938. mov ax, word ptr bp_wParam
  939. call cvtDEBUGHOOKSL
  940. ; Restore return
  941. pop eax
  942. pop ds
  943. xchg bx, si
  944. lea sp, si_cleanup
  945. endm