Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1084 lines
30 KiB

  1. ; Copyright (c) 1998-1999 Microsoft Corporation
  2. ;
  3. ; ntcbc.tpl - 64-bit win32k.sys to 32-bit user32.dll callback thunks
  4. ;
  5. ;
  6. [Macros]
  7. ; Expand all parameters into local variables
  8. MacroName=ApiLocals
  9. Begin=
  10. @IfArgs(@ListCol@ArgList(//@ArgLocal;))
  11. @IfArgs(@ListCol@ArgList(@ArgHostType @ArgHostName;))
  12. @IfArgs(NT32@NArgType(1) Dummy;)
  13. End=
  14. ; Generate the prolog stuff for a thunked API. When done, RetVal is the
  15. ; return value.
  16. MacroName=ApiProlog
  17. Begin=
  18. // @NL
  19. // @ApiName - @ApiNum @NL
  20. @ApiFnRet @NL
  21. @ApiFnMod
  22. whcb@ApiName(@ArgList(@ListCol@ArgMod @ArgType @IfArgs(@ArgName)@ArgMore(,))) {@NL
  23. @NL
  24. End=
  25. ; Generate the epilog for a thunked API.
  26. MacroName=ApiEpilog
  27. Begin=
  28. if (UserCallbackData.UserBuffer != NULL ) {@NL
  29. RtlCopyMemory (UserCallbackData.UserBuffer, UserCallbackData.OutputBuffer, UserCallbackData.OutputLength ); @NL
  30. Wow64FreeHeap (UserCallbackData.OutputBuffer); @NL
  31. UserCallbackData.OutputBuffer = UserCallbackData.UserBuffer;@NL
  32. }@NL
  33. return NtCallbackReturn(UserCallbackData.OutputBuffer, @NL
  34. UserCallbackData.OutputLength, @NL
  35. RetVal); @NL
  36. End=
  37. MacroName=GenCallbackThunk
  38. NumArgs=1
  39. Begin=
  40. @NL
  41. @IfApiCode(Header)
  42. @NL
  43. @ApiProlog
  44. // @NL
  45. // Begin: IfApiCode(ApiEntry) @NL
  46. @NL
  47. @IfApiCode(ApiEntry)
  48. @NL
  49. @Indent(
  50. @NL
  51. @IfApiRet(@ApiFnRet RetVal;) @NL
  52. USERCALLBACKDATA UserCallbackData; @NL
  53. @NL
  54. // @NL
  55. // Begin: ApiLocals @NL
  56. @NL
  57. @ApiLocals
  58. @NL
  59. // @NL
  60. // Begin: Types(Locals) @NL
  61. @NL
  62. @Types(Locals)
  63. @NL
  64. // @NL
  65. // Begin: IfApiCode(Locals) @NL
  66. @IfApiCode(Locals)
  67. @NL
  68. APIPROFILE(@ApiNum); @NL
  69. #if DBG @NL
  70. LOGPRINT((TRACELOG, "whcb@ApiName(@ApiNum) thunk: @IfArgs(@ArgList(@ArgName: %x@ArgMore(,)))\n"@IfArgs(, @ArgList((@ArgName)@ArgMore(,))))); @NL
  71. #endif @NL
  72. @NL
  73. // @NL
  74. //Begin: Types(PreCall) @NL
  75. @NL
  76. @Types(PreCall)
  77. @NL
  78. // @NL
  79. // Begin: IfApiCode(PreCall) @NL
  80. @NL
  81. @IfApiCode(PreCall)
  82. @NL
  83. // @NL
  84. // Begin: CallApi @NL
  85. @NL
  86. @IfApiRet(RetVal=)Wow64KiUserCallbackDispatcher(&UserCallbackData, @ApiNum, @ArgList((ULONG)@ArgHostName, sizeof(*Dummy)@ArgMore(,)))); @NL
  87. Dummy; // get rid of 'unreferenced local' warnings
  88. @NL
  89. // @NL
  90. // Begin: Types(PostCall) @NL
  91. @NL
  92. @Types(PostCall)
  93. @NL
  94. // @NL
  95. // Begin: ApiCode(PostCall) @NL
  96. @IfApiCode(PostCall)
  97. @NL
  98. #if DBG @NL
  99. LOGPRINT((TRACELOG, "whcb@ApiName(@ApiNum) end: @IfApiRet(retval: %x)\n"@IfApiRet(,RetVal))); @NL
  100. #endif @NL
  101. @NL
  102. // @NL
  103. // Begin: ApiEpilog @NL
  104. @ApiEpilog
  105. @NL
  106. // @NL
  107. // Begin: IfApiCode(ApiExit) @NL
  108. @NL
  109. @IfApiCode(ApiExit)
  110. @NL
  111. }@NL
  112. @NL
  113. @NL
  114. End=
  115. MacroName=GenVoidArgsCallbackThunk
  116. NumArgs=1
  117. Begin=
  118. @NL
  119. @IfApiCode(Header)
  120. @NL
  121. @ApiProlog
  122. // @NL
  123. // Begin: IfApiCode(ApiEntry) @NL
  124. @NL
  125. @IfApiCode(ApiEntry)
  126. @NL
  127. @Indent(
  128. @NL
  129. @IfApiRet(@ApiFnRet RetVal;) @NL
  130. USERCALLBACKDATA UserCallbackData; @NL
  131. @NL
  132. // @NL
  133. // Begin: IfApiCode(Locals) @NL
  134. @IfApiCode(Locals)
  135. @NL
  136. #if DBG @NL
  137. LOGPRINT((TRACELOG, "whcb@ApiName(@ApiNum) thunk: @IfArgs(@ArgList(@ArgName: %x@ArgMore(,)))\n"@IfArgs(, @ArgList((@ArgName)@ArgMore(,))))); @NL
  138. #endif @NL
  139. @NL
  140. // @NL
  141. // Begin: IfApiCode(PreCall) @NL
  142. @NL
  143. @IfApiCode(PreCall)
  144. @NL
  145. // @NL
  146. // Begin: CallApi @NL
  147. @NL
  148. @IfApiRet(RetVal=)Wow64KiUserCallbackDispatcher(&UserCallbackData, @ApiNum, 0, 0); @NL
  149. @NL
  150. // @NL
  151. // Begin: ApiCode(PostCall) @NL
  152. @IfApiCode(PostCall)
  153. @NL
  154. #if DBG @NL
  155. LOGPRINT((TRACELOG, "whcb@ApiName(@ApiNum) end: @IfApiRet(retval: %x)\n"@IfApiRet(,RetVal))); @NL
  156. #endif @NL
  157. @NL
  158. // @NL
  159. // Begin: ApiEpilog @NL
  160. @ApiEpilog
  161. @NL
  162. // @NL
  163. // Begin: IfApiCode(ApiExit) @NL
  164. @NL
  165. @IfApiCode(ApiExit)
  166. @NL
  167. }@NL
  168. @NL
  169. @NL
  170. End=
  171. ;
  172. ; Usage: PostCall ThunkCallbackReturn(FieldName)
  173. ; Where:
  174. ; FieldName is the name of the field within the _FNxxxMSG struct to thunk
  175. ;
  176. ; This macro works only in cases where the field in FieldName is not
  177. ; pointer-dependent. If the field in FieldName is pointer-dependent, use
  178. ; ThunkCallbackReturnType to ensure the type is treated as an OUT param
  179. ;
  180. MacroName=ThunkCallbackReturn
  181. NumArgs=1
  182. Begin=
  183. WOWASSERT(UserCallbackData.OutputLength == sizeof(CALLBACKSTATUS)); @NL
  184. WOWASSERT(sizeof(@ArgList(((NT32@NArgType(1))@ArgHostName)->@MArg(1)@ArgMore(,))) == ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput); @NL
  185. @NL
  186. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput = sizeof(@ArgList(@ArgName->@MArg(1)@ArgMore(,))); @NL
  187. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput = &@ArgList(@ArgName->@MArg(1)@ArgMore(,)); @NL
  188. @NL
  189. End=
  190. ;
  191. ; Usage: PostCall ThunkCallbackReturnType(FieldName, FieldType)
  192. ; Where:
  193. ; FieldName is the name of the field within the _FNxxxMSG struct to thunk
  194. ; FieldType is the type of that field (byval, not a pointer)
  195. ;
  196. MacroName=ThunkCallbackReturnType
  197. NumArgs=2
  198. Begin=
  199. WOWASSERT(UserCallbackData.OutputLength == sizeof(CALLBACKSTATUS)); @NL
  200. WOWASSERT(sizeof(@ArgList(((NT32@NArgType(1))@ArgHostName)->@MArg(1)@ArgMore(,))) == ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput); @NL
  201. @NL
  202. @ForceType(PostCall,pmsg->@MArg(1),(*((NT32@MArg(2)*)((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput)),@MArg(2),OUT)
  203. @NL
  204. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput = sizeof(@ArgList(@ArgName->@MArg(1)@ArgMore(,))); @NL
  205. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput = &@ArgList(@ArgName->@MArg(1)@ArgMore(,)); @NL
  206. @NL
  207. End=
  208. MacroName=ThunkMessageXProc
  209. NumArgs=1
  210. Begin=
  211. ((NT32@MArg(1) *)pmsgHost)->xParam = NtWow64MapKernelClientFnToClientFn((PROC) pmsg->xParam); @NL
  212. End=
  213. MacroName=ThunkHookMessageXProc
  214. NumArgs=1
  215. Begin=
  216. ((NT32@MArg(1) *)pmsgHost)->ghh.xParam = NtWow64MapKernelClientFnToClientFn((PROC) pmsg->ghh.xParam); @NL
  217. End=
  218. [Types]
  219. TemplateName=MSG
  220. Also=LPMSG
  221. Locals=
  222. #error @ArgName(@ArgType) requires manual thunking. @NL
  223. End=
  224. PreCall=
  225. #error @ArgName(@ArgType) requires manual thunking. @NL
  226. End=
  227. PostCall=
  228. #error @ArgName(@ArgType) requires manual thunking. @NL
  229. End=
  230. TemplateName=PROC
  231. IndLevel=0
  232. Direction=IN
  233. PreCall=
  234. @ArgHostName = NtWow64MapKernelClientFnToClientFn(@ArgName); @NL
  235. End=
  236. TemplateName=PROC
  237. IndLevel=0
  238. Direction=OUT
  239. PostCall=
  240. @ArgName = NtWow64MapClientFnToKernelClientFn((PROC)@ArgHostName); @NL
  241. End=
  242. TemplateName=CAPTUREBUF
  243. IndLevel=0
  244. Direction=IN
  245. Locals=
  246. // @ArgName(@ArgType) is special IN @NL
  247. End=
  248. PreCall=
  249. // @NL
  250. // Note: @ArgName(@ArgType) is a IN struct @NL
  251. FixupCaptureBuf64(&@ArgName); @NL
  252. @StructIN
  253. @NL
  254. End=
  255. PostCall=
  256. // Note: @ArgName(@ArgType) is a IN struct - nothing to do @NL
  257. @NL
  258. End=
  259. TemplateName=FNDWORDMSG
  260. IndLevel=1
  261. Direction=IN
  262. Locals=
  263. @StructPtrLocal
  264. End=
  265. PreCall=
  266. @StructPtrIN
  267. // check for a WM_SYSTIMER message and thunk it if needed. @NL
  268. if (WOW64_ISPTR(@ArgName) && WM_SYSTIMER == @ArgName->msg) { @Indent( @NL
  269. if (gdwWM_SYSTIMERProcHiBits == 0) { @Indent( @NL
  270. gdwWM_SYSTIMERProcHiBits = (DWORD) (@ArgName->lParam >> 32); @NL
  271. )} @NL
  272. WOWASSERT(gdwWM_SYSTIMERProcHiBits == (DWORD) (@ArgName->lParam >> 32)); @NL
  273. WOWASSERT(@ArgName->lParam != 0); @NL
  274. )} @NL
  275. End=
  276. TemplateName=FNINOUTNCCALCSIZEMSG
  277. NoType=u
  278. IndLevel=1
  279. Direction=IN
  280. PreCall=
  281. @StructPtrIN
  282. if (@ArgName->wParam != 0) { @NL
  283. memcpy(&(((NT32@ArgType)@ArgHostName)->u.p.params.rgrc),&(@ArgName->u.p.params.rgrc),sizeof(((NT32@ArgType)@ArgHostName)->u.p.params.rgrc)); @NL
  284. ((NT32@ArgType)@ArgHostName)->u.p.params.lppos = (_int32) &((NT32@ArgType)@ArgHostName)->u.p.pos; @NL
  285. @ForceType(PreCall,@ArgName->u.p.pos,((NT32@ArgType)@ArgHostName)->u.p.pos,WINDOWPOS,IN)
  286. } else { @NL
  287. @ForceType(PreCall,@ArgName->u.rc,((NT32@ArgType)@ArgHostName)->u.rc,RECT,IN)
  288. } @NL
  289. End=
  290. TemplateName=FNDWORDOPTINLPMSGMSG
  291. NoType=pmsgstruct
  292. NoType=msgstruct
  293. IndLevel=1
  294. Direction=IN
  295. Locals=
  296. @StructPtrLocal
  297. End=
  298. PreCall=
  299. @StructPtrIN
  300. if (WOW64_ISPTR(@ArgName)) { @Indent( @NL
  301. ((@ArgHostTypeInd *)@ArgHostName)->pmsgstruct = (NT32LPMSG)((@ArgType)@ArgName)->pmsgstruct; @NL
  302. // BUG BUG: This struct really needs WPARAM and LPARAM thunked. @NL
  303. // I suspect most apps wont put messages in this message though. @NL
  304. // This structure is used for the WM_GETDLGCODE message. @NL
  305. Wow64ShallowThunkMSG64TO32((NT32MSG *)&(((@ArgHostTypeInd *)@ArgHostName)->msgstruct), &(((@ArgType)@ArgName)->msgstruct)); @NL
  306. )} @NL
  307. End=
  308. TemplateName=FNHKOPTINLPEVENTMSGMSG
  309. NoType=peventmsgmsg
  310. NoType=eventmsgmsg
  311. IndLevel=1
  312. Direction=IN
  313. Locals=
  314. @StructPtrLocal
  315. End=
  316. PreCall=
  317. @StructPtrIN
  318. if (WOW64_ISPTR(@ArgName)) { @Indent( @NL
  319. ((@ArgHostTypeInd *)@ArgHostName)->peventmsgmsg = (NT32LPEVENTMSGMSG)((@ArgType)@ArgName)->peventmsgmsg; @NL
  320. Wow64ShallowThunkEVENTMSG64TO32((NT32EVENTMSG *)&(((@ArgHostTypeInd *)@ArgHostName)->eventmsgmsg), &(((@ArgType)@ArgName)->eventmsgmsg)); @NL
  321. )} @NL
  322. End=
  323. TemplateName=FNHKINLPMSGDATA
  324. NoType=msg
  325. IndLevel=0
  326. Direction=IN
  327. Locals=
  328. @StructLocal
  329. End=
  330. PreCall=
  331. @StructIN
  332. // This structure is only used by the WH_MSGFILTER, WH_SYSMSGFILTER, and WH_GETMESSAGE thunks. @NL
  333. // Since this are only posted messages, they can't have any pointers to structures. @NL
  334. Wow64ShallowThunkMSG64TO32((NT32MSG*)&@ArgHostName.msg, &@ArgName.msg);@NL
  335. End=
  336. TemplateName=FNHKINLPMSGDATA
  337. NoType=msg
  338. IndLevel=0
  339. Direction=OUT
  340. Locals=
  341. @StructLocal
  342. End=
  343. PreCall=
  344. // @ArgName(@ArgType)Nothing to do. @NL
  345. End=
  346. PostCall=
  347. @StructOUT
  348. // This structure is only used by the WH_MSGFILTER, WH_SYSMSGFILTER, and WH_GETMESSAGE thunks. @NL
  349. // Since this are only posted messages, they can't have any pointers to structures. @NL
  350. Wow64ShallowThunkMSG32TO64(&@ArgName.msg, (NT32MSG*)&@ArgHostName.msg);@NL
  351. End=
  352. TemplateName=LPHELPINFO
  353. IndLevel=0
  354. Direction=IN
  355. Locals=
  356. // @ArgName(@ArgType) is an IN LPHELPINFO. Nothing to do. @NL
  357. End=
  358. PreCall=
  359. // IMPORTANT!!
  360. // These callbacks occure inside a regular kernel NT API thunk. @NL
  361. // This means that the temp memory for this will be still be reclaimed since @NL
  362. // that function will eventually exit. @NL
  363. @ArgHostName = (NT32LPHELPINFO)Wow64ShallowAllocThunkHELPINFO64TO32(@ArgName); @NL
  364. End=
  365. PostCall=
  366. // @ArgName(@ArgType) is an IN LPHELPINFO. Nothing to do. @NL
  367. End=
  368. TemplateName=LPHLP
  369. IndLevel=0
  370. Direction=IN
  371. Locals=
  372. // @ArgName(@ArgType) is an IN LPHLP. Nothing to do. @NL
  373. End=
  374. PreCall=
  375. // IMPORTANT!!
  376. // These callbacks occure inside a regular kernel NT API thunk. @NL
  377. // This means that the temp memory for this will be still be reclaimed since @NL
  378. // that function will eventually exit. @NL
  379. @ArgHostName = (NT32LPHLP)Wow64ShallowAllocThunkHLP64TO32(@ArgName); @NL
  380. End=
  381. PostCall=
  382. // @ArgName(@ArgType) is an IN LPHLP. Nothing to do. @NL
  383. End=
  384. [IFunc]
  385. TemplateName=Callbacks
  386. Header=
  387. End=
  388. Locals=
  389. End=
  390. PreCall=
  391. End=
  392. ApiEntry=
  393. End=
  394. PostCall=
  395. End=
  396. Begin=
  397. @GenCallbackThunk(@ApiName)
  398. End=
  399. ApiExit=
  400. End=
  401. ; These APIs are prototyped as taking PVOIDs as their arguments.
  402. ; They really don't have args and the default IFunc generates
  403. ; a compile error trying to decide how many bytes of args to pass
  404. ; along to the 32-bit callback.
  405. [EFunc]
  406. TemplateName=ClientFontSweep
  407. Also=ClientLoadLocalT1Fonts
  408. Also=ClientLoadRemoteT1Fonts
  409. Also=ClientThreadSetup
  410. Also=ClientDeliverUserApc
  411. Also=ClientNoMemoryPopup
  412. Also=ClientLoadOLE
  413. Begin=
  414. @GenVoidArgsCallbackThunk(@ApiName)
  415. End=
  416. ; These APIs all take a struct containing a ULONG_PTR xparam;
  417. ; which may contain a Kernel's view of a Client side Function address
  418. TemplateName=fnOUTDWORDDWORD
  419. PreCall=
  420. @ThunkMessageXProc(FNOUTDWORDDWORDMSG)
  421. End=
  422. TemplateName=fnOUTDWORDINDWORD
  423. PreCall=
  424. @ThunkMessageXProc(FNOUTDWORDINDWORDMSG)
  425. End=
  426. TemplateName=fnOPTOUTLPDWORDOPTOUTLPDWORD
  427. PreCall=
  428. @ThunkMessageXProc(FNOPTOUTLPDWORDOPTOUTLPDWORDMSG)
  429. End=
  430. TemplateName=fnDWORDOPTINLPMSG
  431. PreCall=
  432. @ThunkMessageXProc(FNDWORDOPTINLPMSGMSG)
  433. End=
  434. TemplateName=fnCOPYDATA
  435. PreCall=
  436. @ThunkMessageXProc(FNCOPYDATAMSG)
  437. End=
  438. TemplateName=fnSENTDDEMSG
  439. PreCall=
  440. @ThunkMessageXProc(FNSENTDDEMSGMSG)
  441. End=
  442. TemplateName=fnDWORD
  443. PreCall=
  444. @ThunkMessageXProc(FNDWORDMSG)
  445. End=
  446. TemplateName=fnINWPARAMCHAR
  447. PreCall=
  448. @ThunkMessageXProc(FNINWPARAMCHARMSG)
  449. End=
  450. TemplateName=fnINWPARAMDBCSCHAR
  451. PreCall=
  452. @ThunkMessageXProc(FNINWPARAMDBCSCHARMSG)
  453. End=
  454. TemplateName=fnINOUTDRAG
  455. PreCall=
  456. @ThunkMessageXProc(FNINOUTDRAGMSG)
  457. End=
  458. PostCall=
  459. @ThunkCallbackReturnType(ds,DROPSTRUCT)
  460. End=
  461. TemplateName=fnGETTEXTLENGTHS
  462. PreCall=
  463. @ThunkMessageXProc(FNGETTEXTLENGTHSMSG)
  464. End=
  465. TemplateName=fnINLPCREATESTRUCT
  466. PreCall=
  467. @ThunkMessageXProc(FNINLPCREATESTRUCTMSG)
  468. End=
  469. PostCall=
  470. // @NL
  471. // Let's sign extend retval if it is -1 @NL
  472. // @NL
  473. if (((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->retval == 0x00000000ffffffffUI64) { @NL
  474. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->retval = (ULONG_PTR) -1; @NL
  475. } @NL
  476. End=
  477. TemplateName=fnINLPMDICREATESTRUCT
  478. PreCall=
  479. @ThunkMessageXProc(FNINLPMDICREATESTRUCTMSG)
  480. End=
  481. TemplateName=fnINPAINTCLIPBRD
  482. PreCall=
  483. @ThunkMessageXProc(FNINPAINTCLIPBRDMSG)
  484. End=
  485. TemplateName=fnINSIZECLIPBRD
  486. PreCall=
  487. @ThunkMessageXProc(FNINSIZECLIPBRDMSG)
  488. End=
  489. TemplateName=fnINDESTROYCLIPBRD
  490. PreCall=
  491. @ThunkMessageXProc(FNINDESTROYCLIPBRDMSG)
  492. End=
  493. TemplateName=fnINOUTLPSCROLLINFO
  494. PreCall=
  495. @ThunkMessageXProc(FNINOUTLPSCROLLINFOMSG)
  496. End=
  497. PostCall=
  498. @ThunkCallbackReturnType(info,SCROLLINFO)
  499. End=
  500. TemplateName=fnINOUTLPPOINT5
  501. PreCall=
  502. @ThunkMessageXProc(FNINOUTLPPOINT5MSG)
  503. End=
  504. PostCall=
  505. @ThunkCallbackReturnType(point5,POINT5)
  506. End=
  507. TemplateName=fnINOUTLPRECT
  508. PreCall=
  509. @ThunkMessageXProc(FNINOUTLPRECTMSG)
  510. End=
  511. PostCall=
  512. @ThunkCallbackReturnType(rect,RECT)
  513. End=
  514. TemplateName=fnINOUTNCCALCSIZE
  515. PreCall=
  516. @ThunkMessageXProc(FNINOUTNCCALCSIZEMSG)
  517. End=
  518. PostCall=
  519. if (pmsg->wParam != 0) { @NL
  520. pmsg->u.p.params.lppos = &pmsg->u.p.pos; @NL
  521. @ForceType(PostCall,pmsg->u.p.params,(*(NT32NCCALCSIZE_PARAMS*)((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput),NCCALCSIZE_PARAMS,OUT)
  522. @ForceType(PostCall,pmsg->u.p.pos,(*(NT32WINDOWPOS*)(sizeof(NT32NCCALCSIZE_PARAMS) + (BYTE*)((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput)),WINDOWPOS,OUT)
  523. } else { @NL
  524. @ForceType(PostCall,pmsg->u.rc,(*(RECT*)((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput),RECT,OUT)
  525. } @NL
  526. @ThunkCallbackReturn(u)
  527. End=
  528. TemplateName=fnINOUTSTYLECHANGE
  529. PreCall=
  530. @ThunkMessageXProc(FNINOUTSTYLECHANGEMSG)
  531. End=
  532. PostCall=
  533. @ThunkCallbackReturnType(ss,STYLESTRUCT)
  534. End=
  535. TemplateName=fnOUTLPRECT
  536. PreCall=
  537. @ThunkMessageXProc(FNOUTLPRECTMSG)
  538. End=
  539. ; The OUT rect is not pointer-dependent and the automatic thunking
  540. ; will return the pOutput/cbOutput fields back for us.
  541. TemplateName=fnINLPCOMPAREITEMSTRUCT
  542. PreCall=
  543. @ThunkMessageXProc(FNINLPCOMPAREITEMSTRUCTMSG)
  544. End=
  545. TemplateName=fnINLPDELETEITEMSTRUCT
  546. PreCall=
  547. @ThunkMessageXProc(FNINLPDELETEITEMSTRUCTMSG)
  548. End=
  549. TemplateName=fnINLPHLPSTRUCT
  550. PreCall=
  551. @ThunkMessageXProc(FNINLPHLPSTRUCTMSG)
  552. End=
  553. TemplateName=fnINLPHELPINFOSTRUCT
  554. PreCall=
  555. @ThunkMessageXProc(FNINLPHELPINFOSTRUCTMSG)
  556. End=
  557. TemplateName=fnINLPDRAWITEMSTRUCT
  558. PreCall=
  559. @ThunkMessageXProc(FNINLPDRAWITEMSTRUCTMSG)
  560. End=
  561. TemplateName=fnINOUTLPMEASUREITEMSTRUCT
  562. PreCall=
  563. @ThunkMessageXProc(FNINOUTLPMEASUREITEMSTRUCTMSG)
  564. End=
  565. PostCall=
  566. @ThunkCallbackReturnType(measureitemstruct,MEASUREITEMSTRUCT)
  567. End=
  568. TemplateName=fnINSTRING
  569. PreCall=
  570. @ThunkMessageXProc(FNINSTRINGMSG)
  571. End=
  572. TemplateName=fnINSTRINGNULL
  573. PreCall=
  574. @ThunkMessageXProc(FNINSTRINGNULLMSG)
  575. End=
  576. TemplateName=fnINLPKDRAWSWITCHWND
  577. PreCall=
  578. @ThunkMessageXProc(FNINLPKDRAWSWITCHWNDMSG)
  579. End=
  580. TemplateName=fnINDEVICECHANGE
  581. Locals=
  582. PDEV_BROADCAST_HANDLE pHdr64; @NL
  583. LPARAM lParam; @NL
  584. NT32DEV_BROADCAST_HANDLE *pHdr32; @NL
  585. ULONG DevHandle32Size; @NL
  586. End=
  587. PreCall=
  588. @ThunkMessageXProc(FNINDEVICECHANGEMSG)
  589. @Indent(
  590. // @NL
  591. // Check to see if this is DBT_CUSTOMEVENT / DEV_BORADCASTHANDLE and if so @NL
  592. // thunk it @NL
  593. // @NL
  594. lParam = (LPARAM)pmsg->pwsz; @NL
  595. pHdr64 = (PDEV_BROADCAST_HANDLE)lParam; @NL
  596. if ((pHdr64 != NULL) && @NL
  597. (pmsg->msg == WM_DEVICECHANGE)) { @NL
  598. @NL
  599. switch (pHdr64->dbch_devicetype) { @NL
  600. case DBT_DEVTYP_HANDLE: @NL
  601. @NL
  602. if (pHdr64->dbch_size > 0) { @NL
  603. @NL
  604. DevHandle32Size = pHdr64->dbch_size - @NL
  605. (sizeof (DEV_BROADCAST_HANDLE) - sizeof(NT32DEV_BROADCAST_HANDLE));@NL
  606. pHdr32 = Wow64AllocateTemp (DevHandle32Size); @NL
  607. if (pHdr32 == NULL) { @NL
  608. return 0; @NL
  609. } @NL
  610. @NL
  611. if (WOW64_ISPTR(pHdr64)) { @NL
  612. pHdr32->dbch_size = (DWORD)pHdr64->dbch_size; @NL
  613. pHdr32->dbch_devicetype = pHdr64->dbch_devicetype; @NL
  614. pHdr32->dbch_reserved = (DWORD)pHdr64->dbch_reserved; @NL
  615. @NL
  616. pHdr32->dbch_handle = (NT32HANDLE)pHdr64->dbch_handle; @NL
  617. pHdr32->dbch_hdevnotify = (NT32HDEVNOTIFY)pHdr64->dbch_hdevnotify; @NL
  618. @NL
  619. RtlCopyMemory (&pHdr32->dbch_eventguid, @NL
  620. &pHdr64->dbch_eventguid, @NL
  621. sizeof (GUID)); @NL
  622. @NL
  623. pHdr32->dbch_nameoffset = pHdr64->dbch_nameoffset; @NL
  624. @NL
  625. pHdr32->dbch_size = DevHandle32Size; @NL
  626. RtlCopyMemory (pHdr32->dbch_data, @NL
  627. pHdr64->dbch_data, @NL
  628. pHdr64->dbch_size - FIELD_OFFSET (DEV_BROADCAST_HANDLE, dbch_data));@NL
  629. ((NT32FNINDEVICECHANGEMSG *)(pmsgHost))->pwsz = PtrToLong(pHdr32);@NL
  630. } @NL
  631. } @NL
  632. break; @NL
  633. } @NL
  634. }
  635. )
  636. End=
  637. TemplateName=fnOUTSTRING
  638. PreCall=
  639. @ThunkMessageXProc(FNOUTSTRINGMSG)
  640. End=
  641. TemplateName=fnINCNTOUTSTRING
  642. PreCall=
  643. @ThunkMessageXProc(FNINCNTOUTSTRINGMSG)
  644. End=
  645. TemplateName=fnINCNTOUTSTRINGNULL
  646. PreCall=
  647. @ThunkMessageXProc(FNINCNTOUTSTRINGNULLMSG)
  648. End=
  649. TemplateName=fnPOUTLPINT
  650. PreCall=
  651. @ThunkMessageXProc(FNPOUTLPINTMSG)
  652. End=
  653. ; the default OUT thunking will handle the pOutput/cbOutput
  654. TemplateName=fnPOPTINLPUINT
  655. PreCall=
  656. @ThunkMessageXProc(FNPOPTINLPUINTMSG)
  657. End=
  658. TemplateName=fnINOUTLPWINDOWPOS
  659. PreCall=
  660. @ThunkMessageXProc(FNINOUTLPWINDOWPOSMSG)
  661. End=
  662. PostCall=
  663. @ThunkCallbackReturnType(wp,WINDOWPOS)
  664. End=
  665. TemplateName=fnINLPWINDOWPOS
  666. PreCall=
  667. @ThunkMessageXProc(FNINLPWINDOWPOSMSG)
  668. End=
  669. TemplateName=fnINOUTNEXTMENU
  670. PreCall=
  671. @ThunkMessageXProc(FNINOUTNEXTMENUMSG)
  672. End=
  673. PostCall=
  674. @ThunkCallbackReturnType(mnm,MDINEXTMENU)
  675. End=
  676. TemplateName=fnHkINLPCBTCREATESTRUCT
  677. Locals=
  678. End=
  679. PostCall=
  680. @ThunkCallbackReturnType(d,CREATESTRUCTDATA)
  681. End=
  682. TemplateName=fnHkINLPRECT
  683. PreCall=
  684. @ThunkMessageXProc(FNHKINLPRECTMSG)
  685. End=
  686. PostCall=
  687. @ThunkCallbackReturnType(rect,RECT)
  688. End=
  689. TemplateName=fnHkINDWORD
  690. Locals=
  691. End=
  692. PreCall=
  693. @ThunkHookMessageXProc(FNHKINDWORDMSG)
  694. End=
  695. PostCall=
  696. @ThunkCallbackReturnType(flags,DWORD)
  697. End=
  698. TemplateName=fnHkINLPMSG
  699. Locals=
  700. End=
  701. PreCall=
  702. @ThunkHookMessageXProc(FNHKINLPMSGMSG)
  703. End=
  704. PostCall=
  705. @ThunkCallbackReturnType(d,FNHKINLPMSGDATA)
  706. End=
  707. TemplateName=fnHkINLPMOUSEHOOKSTRUCT
  708. Locals=
  709. End=
  710. PreCall=
  711. @ThunkHookMessageXProc(FNHKINLPMOUSEHOOKSTRUCTEXMSG)
  712. End=
  713. PostCall=
  714. @ThunkCallbackReturnType(flags,DWORD)
  715. End=
  716. TemplateName=fnHkINLPKBDLLHOOKSTRUCT
  717. Locals=
  718. End=
  719. PreCall=
  720. @ThunkHookMessageXProc(FNHKINLPKBDLLHOOKSTRUCTMSG)
  721. End=
  722. PostCall=
  723. @ThunkCallbackReturnType(kbdllhookstruct,KBDLLHOOKSTRUCT)
  724. End=
  725. TemplateName=fnHkINLPMSLLHOOKSTRUCT
  726. Locals=
  727. End=
  728. PreCall=
  729. @ThunkHookMessageXProc(FNHKINLPMSLLHOOKSTRUCTMSG)
  730. End=
  731. PostCall=
  732. @ThunkCallbackReturnType(msllhookstruct,MSLLHOOKSTRUCT)
  733. End=
  734. TemplateName=fnHkOPTINLPEVENTMSG
  735. PreCall=
  736. @ThunkMessageXProc(FNHKOPTINLPEVENTMSGMSG)
  737. End=
  738. PostCall=
  739. @ThunkCallbackReturnType(eventmsgmsg,EVENTMSG)
  740. End=
  741. TemplateName=fnHkINLPDEBUGHOOKSTRUCT
  742. PreCall=
  743. @ThunkMessageXProc(FNHKINLPDEBUGHOOKSTRUCTMSG)
  744. End=
  745. TemplateName=fnHkINLPCBTACTIVATESTRUCT
  746. PreCall=
  747. @ThunkMessageXProc(FNHKINLPCBTACTIVATESTRUCTMSG)
  748. End=
  749. TemplateName=fnClientGetListboxString
  750. PreCall=
  751. @ThunkMessageXProc(CLIENTGETLISTBOXSTRINGMSG)
  752. End=
  753. TemplateName=ClientGetCharsetInfo
  754. Locals=
  755. End=
  756. PostCall=
  757. @ThunkCallbackReturnType(cs,CHARSETINFO)
  758. End=
  759. TemplateName=ClientCopyDDEIn1
  760. Locals=
  761. INTDDEINFO IntDdeInfo;
  762. End=
  763. PostCall=
  764. // thunk the returned INTDDEINFO @NL
  765. WOWASSERT(sizeof(CALLBACKSTATUS) == UserCallbackData.OutputLength); @NL
  766. WOWASSERT(sizeof(NT32INTDDEINFO) == ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput); @NL
  767. @ForceType(PostCall,(&IntDdeInfo),((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput,INTDDEINFO*,OUT);
  768. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput = sizeof(IntDdeInfo); @NL
  769. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput = &IntDdeInfo; @NL
  770. End=
  771. TemplateName=ClientCopyDDEOut1
  772. Locals=
  773. End=
  774. PostCall=
  775. @ThunkCallbackReturnType(IntDdeInfo,INTDDEINFO)
  776. End=
  777. TemplateName=ClientGetDDEHookData
  778. Locals=
  779. End=
  780. PostCall=
  781. @ThunkCallbackReturn(dmhd)
  782. End=
  783. TemplateName=ClientGetTextExtentPointW
  784. PreCall=
  785. End=
  786. PostCall=
  787. @ThunkCallbackReturnType(size,SIZE)
  788. End=
  789. TemplateName=fnOUTLPCOMBOBOXINFO
  790. Locals=
  791. COMBOBOXINFO ComboBoxInfo;
  792. End=
  793. PreCall=
  794. if (WOW64_ISPTR(pmsg)) { @NL
  795. ((NT32FNOUTLPCOMBOBOXINFOMSG *)(pmsgHost))->cbinfo.cbSize = sizeof (NT32COMBOBOXINFO); @NL
  796. } @NL
  797. End=
  798. PostCall=
  799. // thunk the returned FNOUTLPCOMBOBOXINFOMSG @NL
  800. WOWASSERT(sizeof(CALLBACKSTATUS) == UserCallbackData.OutputLength); @NL
  801. WOWASSERT(sizeof(NT32COMBOBOXINFO) == ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput); @NL
  802. @ForceType(PostCall,(&ComboBoxInfo),((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput,COMBOBOXINFO*,OUT);
  803. ComboBoxInfo.cbSize = sizeof (COMBOBOXINFO);
  804. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput = sizeof(COMBOBOXINFO); @NL
  805. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput = &ComboBoxInfo; @NL
  806. End=
  807. TemplateName=ClientGetMessageMPH
  808. Locals=
  809. PCALLBACKSTATUS CallbackStatus;
  810. MSG Msg;
  811. End=
  812. PreCall=
  813. End=
  814. PostCall=
  815. try { @NL
  816. if (WOW64_ISPTR (UserCallbackData.OutputBuffer)) { @NL
  817. CallbackStatus = (PCALLBACKSTATUS) UserCallbackData.OutputBuffer; @NL
  818. if (WOW64_ISPTR (CallbackStatus->pOutput)) { @NL
  819. Wow64ShallowThunkMSG32TO64(&Msg, (NT32MSG*)(CallbackStatus->pOutput));@NL
  820. CallbackStatus->pOutput = &Msg; @NL
  821. CallbackStatus->cbOutput = sizeof (MSG); @NL
  822. } @NL
  823. } @NL
  824. } except (EXCEPTION_EXECUTE_HANDLER) { @NL
  825. RetVal = GetExceptionCode (); @NL
  826. } @NL
  827. End=
  828. TemplateName=ClientPrinterThunk
  829. PreCall=
  830. // UNDONE @NL
  831. // This callback is for User mode printer drivers @NL
  832. // Need a plan for this @NL
  833. WOWASSERT(FALSE); @NL
  834. End=
  835. TemplateName=ClientImmLoadLayout
  836. Locals=
  837. IMEINFOEX iiex;
  838. End=
  839. PostCall=
  840. // thunk the returned INTDDEINFO @NL
  841. WOWASSERT(sizeof(CALLBACKSTATUS) == UserCallbackData.OutputLength); @NL
  842. WOWASSERT(sizeof(NT32IMEINFOEX) == ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput); @NL
  843. @ForceType(PostCall,(&iiex),((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput,IMEINFOEX*,OUT);
  844. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput = sizeof(iiex); @NL
  845. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput = &iiex; @NL
  846. End=
  847. TemplateName=fnIMECONTROL
  848. PreCall=
  849. @ThunkMessageXProc(FNIMECONTROLMSG)
  850. End=
  851. TemplateName=fnIMEREQUEST
  852. Locals=
  853. BYTE abBuffer[sizeof(LOGFONTW)];
  854. End=
  855. PreCall=
  856. @ThunkMessageXProc(FNIMEREQUESTMSG)
  857. End=
  858. PostCall=
  859. if (pmsg->wParam == IMR_COMPOSITIONFONT) {
  860. WOWASSERT(UserCallbackData.OutputLength == sizeof(CALLBACKSTATUS));
  861. if (pmsg->fAnsi) {
  862. WOWASSERT(((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput == sizeof(NT32LOGFONTA));
  863. @ForceType(PostCall, ((LOGFONTA*)abBuffer), ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput, LOGFONTA*,OUT);
  864. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput = sizeof(LOGFONTA);
  865. } else {
  866. WOWASSERT(((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput == sizeof(NT32LOGFONTW));
  867. @ForceType(PostCall, ((LOGFONTW*)abBuffer), ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput, LOGFONTW*,OUT);
  868. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->cbOutput = sizeof(LOGFONTW);
  869. }
  870. ((CALLBACKSTATUS*)UserCallbackData.OutputBuffer)->pOutput = abBuffer;
  871. }
  872. End=
  873. TemplateName=fnINOUTMENUGETOBJECT
  874. PreCall=
  875. @ThunkMessageXProc(FNINOUTMENUGETOBJECTMSG)
  876. End=
  877. PostCall=
  878. // pvObj is an IDropTarget COM interface pointer. See the docs for
  879. // WM_MENUGETOBJECT and the MENUGETOBJECTINFO struct... user32 sends
  880. // this message to apps then calls the interface pointer to notify it
  881. // of interesting events. Used for OLE drag&drop.
  882. @ThunkCallbackReturnType(mngoi.pvObj,PVOID)
  883. End=
  884. TemplateName=fnLOGONNOTIFY
  885. PreCall=
  886. @ThunkMessageXProc(FNLOGONNOTIFYMSG)
  887. End=
  888. TemplateName=ClientWOWGetProcModule
  889. PreCall=
  890. ((NT32CLIENTWOWGETPROCMODULEMSG*)pmsgHost)->pfn = NtWow64MapKernelClientFnToClientFn((PROC)pmsg->pfn); @NL
  891. End=
  892. [Code]
  893. TemplateName=ntcbc
  894. Begin=
  895. @NoFormat(
  896. /*
  897. * genthunk generated code: Do Not Modify
  898. * Thunks for win32k-to-user32 callback functions.
  899. *
  900. */
  901. #include "whwin32p.h"
  902. ASSERTNAME;
  903. #pragma warning(disable : 4311) //Disable pointer truncation warning
  904. #pragma warning(disable : 4020) //too many actual parameters(Wow64KiUserCallbackDispatcher)
  905. #pragma warning(disable : 4242) //truncation warning
  906. #pragma warning(disable : 4244) //truncation warning
  907. #if defined(WOW64DOPROFILE)
  908. #define APIPROFILE(apinum) (ptecbc[(apinum)].HitCount++)
  909. #else
  910. #define APIPROFILE(apinum)
  911. #endif
  912. )
  913. #if defined(WOW64DOPROFILE) @NL
  914. @NL
  915. WOW64SERVICE_PROFILE_TABLE_ELEMENT ptecbc[] = { @Indent( @NL
  916. @ApiList({L"@ApiName", 0, NULL, TRUE}, @NL)
  917. {NULL, 0, NULL, FALSE} // For debugging @NL
  918. )};@NL
  919. @NL
  920. @NL
  921. WOW64SERVICE_PROFILE_TABLE ptcbc = {L"NTCBC", L"Win32k Callback Thunks", ptecbc, (sizeof(ptecbc)/sizeof(WOW64SERVICE_PROFILE_TABLE_ELEMENT))-1}; @NL
  922. @NL
  923. #endif @NL
  924. @NoFormat(
  925. VOID
  926. FixupCaptureBuf64(
  927. PCAPTUREBUF pcb
  928. )
  929. /*
  930. * Converts offsets in a CAPTUREBUF into pointers
  931. */
  932. {
  933. DWORD i;
  934. LPDWORD lpdwOffset;
  935. PVOID *ppFixup;
  936. lpdwOffset = (LPDWORD)((PBYTE)pcb + pcb->offPointers);
  937. for (i = 0; i < pcb->cCapturedPointers; ++i, ++lpdwOffset) {
  938. ppFixup = (PVOID *)((PBYTE)pcb + *lpdwOffset);
  939. *ppFixup = (PBYTE)pcb + (LONG_PTR)*ppFixup;
  940. }
  941. // make sure that user32.dll doesn't attempt to
  942. // refixup the pointers
  943. pcb->cCapturedPointers = 0;
  944. }
  945. _int32
  946. NtWow64MapKernelClientFnToClientFn(
  947. PROC kproc
  948. );
  949. PROC
  950. NtWow64MapClientFnToKernelClientFn(
  951. PROC proc
  952. );
  953. )
  954. @Template(Callbacks)
  955. @NoFormat(
  956. //
  957. // This table is installed in the PEB64->KernelCallbackTable. 64-bit ntdll's
  958. // KiUserCallbackDispatcher calls through it, thinking it's calling
  959. // into user32.dll.
  960. //
  961. const PVOID Win32kCallbackTable[] = {
  962. @ApiList(@ListColwhcb@ApiName@ApiMore(,))
  963. };
  964. )
  965. End=