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.

1034 lines
26 KiB

  1. ifdef IS_16
  2. include thkrp.inc
  3. include k32share.inc
  4. include public.inc
  5. include cbcheck.inc
  6. include newls.inc
  7. include newmisc.inc
  8. include frame.inc
  9. include struc.inc
  10. include cvtstruc.inc
  11. include cbcid.inc
  12. include usrcbid.inc
  13. externDef GlobalAlloc:far16
  14. externDef DefFrameProc32:far16
  15. externDef DefDlgProc32:far16
  16. externDef SendMessage32:far16
  17. externDef DefWindowProc32:far16
  18. externDef DefMDIChildProc32:far16
  19. externDef PostMessage32:far16
  20. externDef PostThreadMessage32:far16
  21. externDef GetMessage32:far16
  22. externDef PeekMessage32Ex:far16
  23. externDef TranslateAccelerator:far16
  24. externDef TranslateMDISysAccel:far16
  25. externDef TranslateMessage32:far16
  26. externDef IsDialogMessage32:far16
  27. externDef GetNullhInst:far16
  28. externDef MaphinstLS:far16
  29. externDef MaphinstSL:far16
  30. externDef GetStdCBLS:far16
  31. externDef GetStdCBSL:far16
  32. externDef ThkMsgLS:near16
  33. externDef ThkMsgSL:near16
  34. externDef CALLBACK_BODY_16:far16
  35. externDef IsValidPostedMessage:near16
  36. .286
  37. externDef abWMIndex:word
  38. .386
  39. ifdef DEBUG
  40. externDef _DebugOutput:far16
  41. DBF_WARNING equ 04000h
  42. DBF_ERROR equ 08000h
  43. DBF_USER equ 00800h
  44. endif
  45. ;-----------------------------------------------------------------------;
  46. ; DXAX2EAX
  47. ; mov dx to eax high word
  48. ;
  49. ;-----------------------------------------------------------------------;
  50. DXAX2EAX macro
  51. ror eax,16
  52. xchg ax,dx
  53. ror eax,16
  54. endm
  55. ;-----------------------------------------------------------------------;
  56. ; body_CALLMSGFILTER
  57. ;-----------------------------------------------------------------------;
  58. body_CALLMSGFILTER macro
  59. bp_pMsg equ <bp_top>
  60. bp_nCode equ <bp_top+4>
  61. si_msg16 equ <(si_space-(MSGSTRUCT16_SIZE))>
  62. mov si,sp ;;set up si for local variable frame
  63. MsgStructThkPreProc
  64. lea ax,si_msg16
  65. push ss
  66. push ax
  67. push word ptr bp_nCode
  68. push 1
  69. call CallMsgFilter32
  70. cwde
  71. MsgStructThkPostProc
  72. endm
  73. ;-----------------------------------------------------------------------;
  74. ; body_SLOWCALLWINDOWPROCA
  75. ;-----------------------------------------------------------------------;
  76. body_SLOWCALLWINDOWPROCA macro
  77. local have_stub16
  78. bp_pfn equ <bp_top >
  79. bp_hwnd equ <bp_top+ 4>
  80. bp_message equ <bp_top+ 8>
  81. bp_wParamLo equ <bp_top+ 12>
  82. bp_wParamHi equ <bp_top+ 14>
  83. bp_lParam equ <bp_top+ 16>
  84. mov si,sp ;;set up si for local variable frame
  85. MsgThkPreProc
  86. push dword ptr bp_pfn
  87. push dword ptr CBID_WNDPROC
  88. call GetStdCBSL
  89. push eax
  90. push word ptr bp_space.s16_hwnd
  91. push word ptr bp_space.s16_message
  92. push word ptr bp_space.s16_wParam.lo
  93. push dword ptr bp_space.s16_lParam
  94. push word ptr bp_space.s16_wParam.hi
  95. call CallWindowProc32
  96. or bp_space.s16_fw, TF_THUNKMSGRESULT
  97. MsgThkPostProc
  98. endm
  99. ; ---------------------------------------------------------------------------
  100. ;
  101. ; body_SENDMESSAGETHINGA
  102. ;
  103. ; ---------------------------------------------------------------------------
  104. body_SENDMESSAGETHINGA macro
  105. local mpfnSendThing
  106. local SendThingCleanup
  107. bp_type equ <bp_top >
  108. bp_hwnd equ <bp_top+ 4>
  109. bp_hwnd2 equ <bp_top+ 8>
  110. bp_message equ <bp_top+ 12>
  111. bp_wParamLo equ <bp_top+ 16>
  112. bp_wParamHi equ <bp_top+ 18>
  113. bp_lParam equ <bp_top+ 20>
  114. mov si,sp ;;set up si for local variable frame
  115. MsgThkPreProc
  116. push word ptr bp_space.s16_hwnd
  117. cmp word ptr bp_type, SMT_DEFFRAMEPROC
  118. jne @F
  119. push word ptr bp_hwnd2
  120. @@:
  121. push word ptr bp_space.s16_message
  122. push word ptr bp_space.s16_wParam.lo
  123. push dword ptr bp_space.s16_lParam
  124. push word ptr bp_space.s16_wParam.hi
  125. ;
  126. ; Which type of message call do we want to make?
  127. ; (0) SendMesage32
  128. ; (1) DefWindowProc32
  129. ; (2) DefMDIChildProc32
  130. ; (3) DefDlgProc32
  131. ; (4) DefFrameProc32
  132. ;
  133. mov bx, word ptr bp_type
  134. shl bx, 2
  135. call dword ptr cs:mpfnSendThing[bx]
  136. jmp SendThingCleanup
  137. mpfnSendThing label dword
  138. dd SendMessage32 ; 0
  139. dd DefWindowProc32 ; 1
  140. dd DefMDIChildProc32 ; 2
  141. dd DefDlgProc32 ; 3
  142. dd DefFrameProc32 ; 4
  143. SendThingCleanup:
  144. or bp_space.s16_fw, TF_THUNKMSGRESULT
  145. MsgThkPostProc
  146. endm
  147. ;-----------------------------------------------------------------------;
  148. ; body_TRANSLATEMESSAGETHING
  149. ; TMT_TRANSLATEACCELERATOR == TranslateAccelerator
  150. ; TMT_TRANSLATEMDISYSACCEL == TranslateMDISysAccel
  151. ; TMT_ISDIALOGMESSAGE == IsDialogMessage
  152. ; TMT_TRANSLATEMESSAGE == TranslateMessageA
  153. ;-----------------------------------------------------------------------;
  154. body_TRANSLATEMESSAGETHING macro
  155. local not_dde
  156. local exit
  157. local mpfnTranslate
  158. local PushMessage
  159. local MakeCall
  160. local Cleanup
  161. bp_type equ <bp_top >
  162. bp_hwnd equ <bp_top+ 4>
  163. bp_haccel equ <bp_top+ 8>
  164. bp_pMsg equ <bp_top+12>
  165. si_msg16 equ <(si_space-(MSGSTRUCT16_SIZE))>
  166. ; Check for DDE message, in which case we know no translation will occur,
  167. ; so there's no need to call the api.
  168. sub eax,eax ;assume no translation
  169. mov es,FlatData
  170. mov edi,bp_pMsg
  171. cmp word ptr es:[edi].ms32_message,WM_DDE_FIRST
  172. jb not_dde
  173. cmp word ptr es:[edi].ms32_message,WM_DDE_LAST
  174. jbe exit
  175. cmp word ptr es:[edi].ms32_message,WM_DROPFILES
  176. je exit
  177. not_dde:
  178. mov si,sp ;;set up si for local variable frame
  179. MsgStructThkPreProc ,no_load_pmsg
  180. ;
  181. ; TranslateAccelerator(hwnd, haccel pmsg);
  182. ; TranslateMDISysAccel(hwnd, pmsg);
  183. ; IsDialogMessage32(hwnd, psmg, TRUE);
  184. ; TranslateMessage32(pmsg, TRUE);
  185. ;
  186. mov bx, word ptr bp_type
  187. cmp bx, TMT_TRANSLATEMESSAGE
  188. je PushMessage
  189. ; We push hwnd for all but TranslateMessage32()
  190. push word ptr bp_hwnd
  191. ; We only push haccel for TranslateAccelerator()
  192. cmp bx, TMT_TRANSLATEACCELERATOR
  193. jne PushMessage
  194. push word ptr bp_haccel
  195. PushMessage:
  196. ; We push lpmsg for all
  197. lea ax,si_msg16
  198. push ss
  199. push ax
  200. cmp bx, TMT_ISDIALOGMESSAGE
  201. jb MakeCall
  202. ; We push TRUE for IsDialogMessage32() and TranslateMessage32()
  203. push 1
  204. MakeCall:
  205. shl bx, 2
  206. call dword ptr cs:mpfnTranslate[bx]
  207. jmp Cleanup
  208. mpfnTranslate label dword
  209. dd TranslateAccelerator
  210. dd TranslateMDISysAccel
  211. dd IsDialogMessage32
  212. dd TranslateMessage32
  213. Cleanup:
  214. cwde
  215. MsgStructThkPostProc
  216. exit:
  217. endm
  218. ;-----------------------------------------------------------------------;
  219. ; body_DISPATCHMESSAGEA
  220. ;-----------------------------------------------------------------------;
  221. body_DISPATCHMESSAGEA macro
  222. local DispatchExit
  223. bp_pMsg equ <bp_top>
  224. si_msg16 equ <(si_space-(MSGSTRUCT16_SIZE))>
  225. ; Blow off if message implies a pointer
  226. mov es, FlatData
  227. mov edi, dword ptr bp_pMsg
  228. push word ptr es:[edi].ms32_message
  229. call IsValidPostedMessage
  230. or eax, eax
  231. ifdef DEBUG
  232. jnz @F
  233. push eax
  234. push cs
  235. push offset szDispatchError
  236. push DBF_USER or DBF_ERROR
  237. call _DebugOutput
  238. add sp, 2+4
  239. pop eax
  240. jmp DispatchExit
  241. szDispatchError label byte
  242. db 'DispatchMessage: ignoring retrieved message with pointer',0
  243. @@:
  244. else
  245. jz DispatchExit
  246. endif
  247. mov si,sp ;;set up si for local variable frame
  248. MsgStructThkPreProc TF_NOTPAIRED,
  249. lea ax,si_msg16
  250. push ss
  251. push ax
  252. push 1
  253. call DispatchMessage32
  254. DXAX2EAX
  255. lea sp, si_cleanup
  256. DispatchExit:
  257. endm
  258. ;-----------------------------------------------------------------------;
  259. ; body_GETMESSAGETHINGA
  260. ;-----------------------------------------------------------------------;
  261. body_GETMESSAGETHINGA macro
  262. local GetThingExit
  263. local GetNextMessage
  264. local ItsAPeekMessage
  265. local GetThingCleanup
  266. local MessageError
  267. bp_fPeek equ <bp_top >
  268. bp_pMsg equ <bp_top+ 4>
  269. bp_hwnd equ <bp_top+ 8>
  270. bp_uMsgMin equ <bp_top+ 12>
  271. bp_uMsgMax equ <bp_top+ 16>
  272. bp_dwRemove equ <bp_top+ 20>
  273. bp_msg16 equ <(bp_space-(MSGSTRUCT16_SIZE))>
  274. si_msg16 equ <(si_space-(MSGSTRUCT16_SIZE))>
  275. sub sp,(size THKSPACE16 + MSGSTRUCT16_SIZE)
  276. mov si,sp
  277. next_message:
  278. ; Repush GM/PM parms
  279. push ss
  280. push si
  281. push word ptr bp_hwnd
  282. push word ptr bp_uMsgMin
  283. push word ptr bp_uMsgMax
  284. cmp word ptr bp_fPeek, 0
  285. jne ItsAPeekMessage
  286. push 1
  287. call GetMessage32
  288. cwde
  289. jmp GetThingCleanup
  290. ItsAPeekMessage:
  291. push dword ptr bp_dwRemove
  292. push 1
  293. call PeekMessage32Ex
  294. cwde ; Get return into EAX in case 0
  295. test ax, ax
  296. jz GetThingExit
  297. GetThingCleanup:
  298. ; SAVE API RETURN VALUE
  299. push eax
  300. ; Blow off if message has pointers (could've come from old 16-bit app)
  301. push word ptr bp_msg16.ms16_message
  302. call IsValidPostedMessage
  303. test eax, eax
  304. jz MessageError
  305. ; The message is OK to be retrieved
  306. mov si,bp ;set up frame pointer
  307. mov cx,word ptr bp_dwRemove
  308. and cx,PM_REMOVE
  309. xor cx,PM_REMOVE ;turn it into PM_NOREMOVE indicator
  310. shl cx,5
  311. .errnz PM_REMOVE - 1
  312. or cx,TF_NOTPAIRED
  313. InitLocalSpace cx,bp
  314. ; RESTORE API RETURN VALUE
  315. pop eax
  316. MsgStructThkPostProc bp,
  317. jmp GetThingExit
  318. MessageError:
  319. ifdef DEBUG
  320. push cs
  321. push offset szGetError
  322. push DBF_USER or DBF_WARNING
  323. call _DebugOutput
  324. add sp, 2+4
  325. jmp @F
  326. szGetError label byte
  327. db 'GetMessage: ignoring retrieved message with pointer',0
  328. @@:
  329. endif
  330. ; Pop off API return value to clean up stack
  331. pop eax
  332. ; If this is PeekMessage PM_REMOVE or GetMessage, then just jump back to
  333. ; the top of the Peek loop and try again. We'll skip over this one and
  334. ; get the next message.
  335. cmp word ptr bp_fPeek, 0
  336. jz next_message
  337. mov eax, dword ptr bp_dwRemove
  338. test eax, PM_REMOVE
  339. jnz next_message
  340. ; OK, so this is a PeekMessage PM_NOREMOVE call. This is a little more
  341. ; complicated. We need to call PeekMessage PM_REMOVE with the other
  342. ; parms the same so we swallow this bad message. THEN we want to jump
  343. ; back to the top of the loop and try again. Otherwise the app will
  344. ; hang forever because this bad message will never get removed from the
  345. ; front of the message list.
  346. push ss
  347. push si
  348. push word ptr bp_hwnd
  349. push word ptr bp_uMsgMin
  350. push word ptr bp_uMsgMax
  351. or eax, PM_REMOVE
  352. push eax
  353. push 1
  354. call PeekMessage32Ex
  355. ; Now we can try this again.
  356. jmp next_message
  357. GetThingExit:
  358. endm
  359. ;-----------------------------------------------------------------------;
  360. ; body_POSTMESSAGETHINGA
  361. ;-----------------------------------------------------------------------;
  362. body_POSTMESSAGETHINGA macro
  363. local mpfnPostThing
  364. local PostThingWord
  365. local PostThingParms
  366. local PostThingCleanup
  367. local exit
  368. bp_type equ <bp_top >
  369. bp_hwnd equ <bp_top+ 4>
  370. bp_message equ <bp_top+ 8>
  371. bp_wParamLo equ <bp_top+ 12>
  372. bp_wParamHi equ <bp_top+ 14>
  373. bp_lParam equ <bp_top+ 16>
  374. ; Blow this off if message implies a pointer.
  375. push word ptr bp_message
  376. call IsValidPostedMessage
  377. or eax, eax
  378. ifdef DEBUG
  379. jnz @F
  380. push eax
  381. push cs
  382. push offset szPostError
  383. push DBF_USER or DBF_ERROR
  384. call _DebugOutput
  385. add sp, 2+4
  386. pop eax
  387. jmp exit
  388. szPostError label byte
  389. db 'PostMessage: ignoring posted message with pointer',0
  390. @@:
  391. else
  392. jz exit
  393. endif
  394. mov si,sp ;;set up si for local variable frame
  395. MsgThkPreProc TF_NOTPAIRED
  396. ;
  397. ; Which type of message post do we want to make?
  398. ; (0) PostThreadMessage32 -- dword "hwnd" (idThread really)
  399. ; (1) PostMessage32
  400. ;
  401. mov eax, bp_hwnd
  402. mov bx, word ptr bp_type
  403. cmp bx, PMT_POSTTHREADMESSAGE
  404. jne PostThingWord
  405. push eax
  406. jmp PostThingParms
  407. PostThingWord:
  408. push ax
  409. PostThingParms:
  410. push word ptr bp_space.s16_message
  411. push word ptr bp_space.s16_wParam.lo
  412. push dword ptr bp_space.s16_lParam
  413. push word ptr bp_space.s16_wParam.hi
  414. shl bx, 2
  415. call dword ptr cs:mpfnPostThing[bx]
  416. jmp PostThingCleanup
  417. mpfnPostThing label dword
  418. dd PostThreadMessage32 ; PMT_POSTTHREADMESSAGE
  419. dd PostMessage32 ; PMT_POSTMESSAGE
  420. PostThingCleanup:
  421. cwde
  422. exit:
  423. endm
  424. ;-----------------------------------------------------------------------;
  425. ; body_SENDMESSAGETIMEOUTA
  426. ;-----------------------------------------------------------------------;
  427. body_SENDMESSAGETIMEOUTA macro
  428. bp_hwnd equ <bp_top >
  429. bp_message equ <bp_top+ 4>
  430. bp_wParamLo equ <bp_top+ 8>
  431. bp_wParamHi equ <bp_top+ 10>
  432. bp_lParam equ <bp_top+ 12>
  433. bp_flags equ <bp_top+ 16>
  434. bp_TimeOut equ <bp_top+ 20>
  435. bp_lpResult equ <bp_top+ 24>
  436. bp_lRet equ <[bp-4]>
  437. xor eax, eax
  438. push eax
  439. mov si,sp ;;set up si for local variable frame
  440. MsgThkPreProc , si
  441. push word ptr si_space.s16_hwnd
  442. push word ptr si_space.s16_message
  443. push word ptr si_space.s16_wParam.lo
  444. push dword ptr si_space.s16_lParam
  445. push word ptr si_space.s16_wParam.hi
  446. push word ptr bp_flags ; Only the first word of flags is used now.
  447. push dword ptr bp_TimeOut
  448. ; Push FAR ptr to si_space.s16_lResult
  449. push ss ; Push pointer to temp location.
  450. lea ax, si_space.s16_lResult
  451. push ax
  452. call SendMessageTimeOut32
  453. ; Save _REAL_ result
  454. mov word ptr bp_lRet, ax
  455. mov word ptr bp_lRet+2, dx
  456. ; Replace result with one filled in by SMTO()--the "real" message return
  457. mov ax, word ptr si_space.s16_lResult
  458. mov dx, word ptr si_space.s16_lResult+2
  459. or si_space.s16_fw, TF_THUNKMSGRESULT
  460. MsgThkPostProc si
  461. ; EAX NOW HAS "message result" return
  462. ;Did caller pass in a lpResult pointer? If so, fill it in with
  463. ;thunked result.
  464. mov edi, dword ptr bp_lpResult
  465. or edi, edi
  466. jz @F
  467. mov es, FlatData
  468. stosd es:[edi]
  469. @@:
  470. ;Now put real SMTO return into eax
  471. mov eax, dword ptr bp_lRet
  472. endm
  473. ;-----------------------------------------------------------------------;
  474. ; body_SENDMESSAGECALLBACKA
  475. ;-----------------------------------------------------------------------;
  476. body_SENDMESSAGECALLBACKA macro
  477. local cleanup
  478. local exit
  479. bp_hwnd equ <bp_top >
  480. bp_message equ <bp_top+ 4>
  481. bp_wParamLo equ <bp_top+ 8>
  482. bp_wParamHi equ <bp_top+ 10>
  483. bp_lParam equ <bp_top+ 12>
  484. bp_fnCallback equ <bp_top+ 16>
  485. bp_dwData equ <bp_top+ 20>
  486. ; Blow this off if message implies a pointer.
  487. ; Unless it is WM_WININICHANGE and the pointer is NULL
  488. cmp word ptr bp_lParam, 0 ; NULL pointer
  489. jnz check_call
  490. cmp word ptr bp_message, 1ah ; WM_WININICHANGE
  491. jz valid_call ; It's ok, let it through
  492. check_call:
  493. push word ptr bp_message
  494. call IsValidPostedMessage
  495. or eax, eax
  496. ifdef DEBUG
  497. jnz @F
  498. push eax
  499. push cs
  500. push offset szCallbackError
  501. push DBF_USER or DBF_ERROR
  502. call _DebugOutput
  503. add sp, 2+4
  504. pop eax
  505. jmp exit
  506. szCallbackError label byte
  507. db 'SendMessageCallback: message with pointer not allowed',0
  508. @@:
  509. else
  510. jz exit
  511. endif
  512. valid_call:
  513. mov si,sp ;;set up si for local variable frame
  514. MsgThkPreProc
  515. push word ptr bp_space.s16_hwnd
  516. push word ptr bp_space.s16_message
  517. push word ptr bp_space.s16_wParam.lo
  518. push dword ptr bp_space.s16_lParam
  519. push word ptr bp_space.s16_wParam.hi
  520. ; Get 16:16 callback wrapper
  521. push dword ptr bp_fnCallback
  522. push dword ptr CBID_SENDMSGCALLBACK ;callback type
  523. call GetStdCBSL ;create 16-bit callback stub
  524. push eax
  525. push dword ptr bp_dwData
  526. call SendMessageCallback32
  527. ; No msg result to thunk; this will save DX:AX return & restore to EAX
  528. MsgThkPostProc
  529. exit:
  530. endm
  531. ;-----------------------------------------------------------------------;
  532. ; body_BROADCASTSYSTEMMESSAGE
  533. ;-----------------------------------------------------------------------;
  534. body_BROADCASTSYSTEMMESSAGE macro
  535. bp_dwFlags equ <bp_top>
  536. bp_lpdwRecipientList equ <bp_top+4>
  537. ;; NOTE: There is no hwnd parameter here; However, to satisfy the MsgThkPre/PostProc
  538. ;; macros, we define a dummy bp_hwnd here.
  539. bp_hwnd equ <bp_top+ 4 >
  540. bp_message equ <bp_top+ 8>
  541. bp_wParamLo equ <bp_top+ 12>
  542. bp_wParamHi equ <bp_top+ 14>
  543. bp_lParam equ <bp_top+ 16>
  544. mov si,sp ;;set up si for local variable frame
  545. MsgThkPreProc TF_INTERPROCESS
  546. push dword ptr bp_lpdwRecipientList
  547. call MapLS
  548. push eax ;; Save the mapped selector.
  549. push dword ptr bp_dwFlags
  550. push eax ;; 16:16 lpdwRecipientList.
  551. push word ptr bp_space.s16_message
  552. push word ptr bp_space.s16_wParam.lo
  553. push dword ptr bp_space.s16_lParam
  554. call BroadcastSystemMessage
  555. pop ecx ;; Restore the 16:16 mapped selector.
  556. ; Preserve the msg result
  557. push dx
  558. push ax
  559. push ecx ;; 16:16
  560. call UnMapLS ;; Unmap.
  561. ; Restore the msg result
  562. pop ax
  563. pop dx
  564. or bp_space.s16_fw, TF_THUNKMSGRESULT
  565. MsgThkPostProc
  566. endm
  567. ;-----------------------------------------------------------------------;
  568. ; body_CALLNEXTHOOKEX
  569. ;-----------------------------------------------------------------------;
  570. ; BOGUS
  571. ; These are already defined in user.inc, but we can't include that file
  572. ; here because of conflicts with public.inc
  573. HHOOK_MAGIC equ ('H' or ('K' * 256))
  574. HOOK struc
  575. hkMagic dw ?
  576. hkPhkNext dw ?
  577. hkIdHook dw ?
  578. hkPpi dw ?
  579. hkHq dw ?
  580. hkHqCreator dw ?
  581. hkFlags dw ?
  582. hkAtomModule dw ?
  583. hkHmodOwner dd ?
  584. hkLpfn dd ?
  585. hkcCalled dw ?
  586. HOOK ends
  587. body_CALLNEXTHOOKEX macro
  588. local thk_WH_MSGFILTER
  589. local thk_WH_JOURNALRECORD
  590. local thk_WH_JOURNALPLAYBACK
  591. local thk_WH_JOURNAL
  592. local thk_WH_KEYBOARD
  593. local thk_WH_GETMESSAGE
  594. local thk_WH_CALLWNDPROC
  595. local thk_WH_CBT
  596. local thk_WH_SYSMSGFILTER
  597. local thk_WH_MOUSE
  598. local thk_WH_HARDWARE
  599. local thk_WH_DEBUG
  600. local thk_WH_SHELL
  601. local thk_WH_FOREGROUNDIDLE
  602. local thk_WH_CALLWNDPROCRET
  603. local hook_exit
  604. local npfnHookThunk
  605. local bad_hook_type
  606. local jr_null_msg
  607. local jp_push
  608. bp_hhk equ <bp_top >
  609. bp_nCode equ <bp_top+ 4>
  610. bp_wParam equ <bp_top+ 8>
  611. bp_lParam equ <bp_top+ 12>
  612. ;
  613. ; WE ARE IN USER16 NOW
  614. ; We can do the same validation that our hook functions do on hook
  615. ; handles.
  616. ;
  617. xor ax, ax
  618. cwd
  619. ; HIWORD of hook must be HHOOK_MAGIC
  620. cmp word ptr bp_hhk+2, HHOOK_MAGIC
  621. jne hook_exit
  622. ; LOWORD of hook is local ptr & therefore not NULL
  623. mov di, word ptr bp_hhk
  624. or di, di
  625. jz hook_exit
  626. ; MAGIC field inside of hook must be HHOOK_MAGIC
  627. cmp [di].hkMagic, HHOOK_MAGIC
  628. jne hook_exit
  629. mov ax, [di].hkIdHook
  630. inc ax
  631. add ax,ax
  632. xchg ax,bx
  633. jmp cs:npfnHookThunk[bx]
  634. ;dispatch table
  635. npfnHookThunk label word
  636. dw offset thk_WH_MSGFILTER
  637. dw offset thk_WH_JOURNALRECORD
  638. dw offset thk_WH_JOURNALPLAYBACK
  639. dw offset thk_WH_KEYBOARD
  640. dw offset thk_WH_GETMESSAGE
  641. dw offset thk_WH_CALLWNDPROC
  642. dw offset thk_WH_CBT
  643. dw offset thk_WH_SYSMSGFILTER
  644. dw offset thk_WH_MOUSE
  645. dw offset thk_WH_HARDWARE
  646. dw offset thk_WH_DEBUG
  647. dw offset thk_WH_SHELL
  648. dw offset thk_WH_FOREGROUNDIDLE
  649. dw offset thk_WH_CALLWNDPROCRET
  650. ;-----------------------------------------------------------------------;
  651. ;-----------------------------------------------------------------------;
  652. thk_WH_MOUSE:
  653. bp_pMhs equ <bp_lParam>
  654. si_mhs16 equ <(si_cleanup-(MOUSEHOOKSTRUCT16_SIZE))>
  655. mov si,sp
  656. MhsStructThkPreProc
  657. push dword ptr bp_hhk
  658. push word ptr bp_nCode
  659. push word ptr bp_wParam
  660. lea ax,si_mhs16
  661. push ss
  662. push ax
  663. call CallNextHookEx
  664. MhsStructThkPostProc
  665. jmp hook_exit_no_return
  666. ;-----------------------------------------------------------------------;
  667. ;-----------------------------------------------------------------------;
  668. thk_WH_JOURNALRECORD:
  669. xor dx, dx
  670. jmp thk_WH_JOURNAL
  671. thk_WH_JOURNALPLAYBACK:
  672. xor dx, dx
  673. inc dx
  674. thk_WH_JOURNAL:
  675. bp_pJhs equ <bp_lParam>
  676. si_type equ <(si_cleanup-2)>
  677. si_jhs16 equ <(si_cleanup-2-(EVENTMSG16_SIZE))>
  678. ;JhsStructThkPreProc assumes type is in DX
  679. mov si,sp
  680. JhsStructThkPreProc
  681. push dword ptr bp_hhk
  682. push word ptr bp_nCode
  683. push word ptr bp_wParam
  684. mov eax, bp_pJhs
  685. or eax, eax
  686. jnz @F
  687. push eax
  688. jmp JhsCallHook
  689. @@:
  690. lea ax, si_jhs16
  691. push ss
  692. push ax
  693. JhsCallHook:
  694. call CallNextHookEx
  695. DXAX2EAX
  696. JhsStructThkPostProc
  697. jmp hook_exit_no_return
  698. ;-----------------------------------------------------------------------;
  699. ;-----------------------------------------------------------------------;
  700. thk_WH_MSGFILTER:
  701. thk_WH_SYSMSGFILTER:
  702. thk_WH_GETMESSAGE:
  703. bp_pMsg equ <bp_lParam>
  704. si_msg16 equ <(si_space-(MSGSTRUCT16_SIZE))>
  705. mov si,sp
  706. MsgStructThkPreProc
  707. push dword ptr bp_hhk
  708. push word ptr bp_nCode
  709. push word ptr bp_wParam
  710. lea ax,si_msg16
  711. push ss
  712. push ax
  713. call CallNextHookEx
  714. DXAX2EAX
  715. MsgStructThkPostProc
  716. ; MsgStructThkPostProc puts return into EAX for us.
  717. jmp hook_exit_no_return
  718. ;-----------------------------------------------------------------------;
  719. ;-----------------------------------------------------------------------;
  720. thk_WH_CBT:
  721. mov si,sp
  722. CbtStructThkPreProc
  723. ;!!! assumes no need to copy back structures
  724. thk_WH_CBT_call:
  725. push dword ptr bp_hhk
  726. push word ptr bp_nCode
  727. push word ptr bp_wParam
  728. push dword ptr si_space.s16_lParam
  729. call CallNextHookEx
  730. CbtStructThkPostProc
  731. jmp hook_exit_no_return
  732. ;-----------------------------------------------------------------------;
  733. ;-----------------------------------------------------------------------;
  734. thk_WH_DEBUG:
  735. bp_pDhs equ <bp_lParam>
  736. si_dhs16 equ <(si_cleanup-(DEBUGHOOK16_SIZE))>
  737. mov si, sp
  738. DhsStructThkPreProc
  739. push dword ptr bp_hhk
  740. push word ptr bp_nCode
  741. push word ptr bp_wParam
  742. lea ax, si_dhs16
  743. push ss
  744. push ax
  745. call CallNextHookEx
  746. DhsStructThkPostProc
  747. jmp hook_exit_no_return
  748. ;-----------------------------------------------------------------------;
  749. ;-----------------------------------------------------------------------;
  750. thk_WH_CALLWNDPROC:
  751. bp_pCwp equ <bp_lParam>
  752. si_cwp16 equ <(si_space-(CWPSTRUCT16_SIZE))>
  753. mov si,sp
  754. CwpStructThkPreProc
  755. push dword ptr bp_hhk
  756. push word ptr bp_nCode
  757. push word ptr bp_wParam
  758. ; HACK
  759. ; Pass lpCwp16, without wParamHi on top
  760. ;
  761. lea ax,si_cwp16
  762. add ax, 2
  763. push ss
  764. push ax
  765. call CallNextHookEx
  766. CwpStructThkPostProc
  767. jmp hook_exit_no_return
  768. ;-----------------------------------------------------------------------;
  769. ;-----------------------------------------------------------------------;
  770. thk_WH_CALLWNDPROCRET:
  771. bp_pCwpRet equ <bp_lParam>
  772. si_cwpret16 equ <(si_space-(CWPRETSTRUCT16_SIZE))>
  773. mov si,sp
  774. CwpRetStructThkPreProc
  775. push dword ptr bp_hhk
  776. push word ptr bp_nCode
  777. push word ptr bp_wParam
  778. lea ax,si_cwpret16
  779. push ss
  780. push ax
  781. call CallNextHookEx
  782. CwpRetStructThkPostProc
  783. jmp hook_exit_no_return
  784. ;-----------------------------------------------------------------------;
  785. ;-----------------------------------------------------------------------;
  786. thk_WH_HARDWARE:
  787. bp_pHhs equ <bp_lParam>
  788. si_hhs16 equ <(si_space-(HARDWAREHOOKSTRUCT16_SIZE))>
  789. mov si,sp
  790. HhsStructThkPreProc
  791. push dword ptr bp_hhk
  792. push word ptr bp_nCode
  793. push word ptr bp_wParam
  794. lea ax,si_hhs16
  795. push ss
  796. push ax
  797. call CallNextHookEx
  798. HhsStructThkPostProc
  799. jmp hook_exit_no_return
  800. ;-----------------------------------------------------------------------;
  801. ;-----------------------------------------------------------------------;
  802. ;-----------------------------------------------------------------------;
  803. ;-----------------------------------------------------------------------;
  804. thk_WH_KEYBOARD:
  805. thk_WH_SHELL:
  806. thk_WH_FOREGROUNDIDLE:
  807. push dword ptr bp_hhk
  808. push word ptr bp_nCode
  809. push word ptr bp_wParam
  810. push dword ptr bp_lParam
  811. call CallNextHookEx
  812. hook_exit:
  813. DXAX2EAX
  814. hook_exit_no_return:
  815. endm
  816. endif