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.

1180 lines
30 KiB

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