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.

931 lines
26 KiB

  1. ; Copyright (c) Microsoft Corporation. All rights reserved.
  2. [Macros]
  3. ; Generate the prolog stuff for a thunked API.
  4. ; pBaseArgs is a 64-bit pointer pointing at the 32-bit
  5. ; arguments on the 32-bit stack (fetched from EDX when
  6. ; the syscall was executed).
  7. MacroName=ApiProlog
  8. Begin=
  9. // @NL
  10. // @ApiName - @ApiNum @NL
  11. // @NL
  12. @ApiFnRet @ApiFnMod @NL
  13. wh@ApiName(PULONG pBaseArgs) { @NL
  14. PULONG pBaseArgsCopy = pBaseArgs; // prevent unreferenced formal parameter errors @NL
  15. @IfArgs(@ArgList(@ListCol@ArgMod @ArgHostType @ArgNameHost = *(@ArgHostType *)&pBaseArgs[@ArgOff];
  16. ))
  17. End=
  18. MacroName=DeclareIndex
  19. NumArgs=0
  20. Begin=
  21. int @ArgValue_Index;@NL
  22. End=
  23. MacroName=ElementCopy
  24. NumArgs=1
  25. Begin=
  26. for(@ArgValue_Index = 0; @ArgValue_Index < @ArrayElements; @ArgValue_Index++) {@NL
  27. @Indent(
  28. @MArg(1)
  29. )
  30. } @NL
  31. End=
  32. MacroName=StdH2NCopy
  33. NumArgs=0
  34. Begin=
  35. @ArgName = @IfNotIsBitfield(@UnalignedTag64)(@ArgType)(UlongToPtr(@ArgHostName));@NL
  36. End=
  37. MacroName=StdH2NCopyOrg
  38. NumArgs=0
  39. Begin=
  40. @ArgName = @IfNotIsBitfield(@UnalignedTag64)(@ArgType)(@ArgHostName);@NL
  41. End=
  42. MacroName=StdAEH2NCopy
  43. NumArgs=0
  44. Begin=
  45. @ArgName[@ArgValue_Index] = (@ArgType)@ArgHostName[@ArgValue_Index]; @NL
  46. End=
  47. MacroName=StdN2HCopy
  48. NumArgs=0
  49. Begin=
  50. @ArgHostName = @IfNotIsBitfield((@ArgHostType))@ArgName; @NL
  51. End=
  52. MacroName=StdAEN2HCopy
  53. NumArgs=0
  54. Begin=
  55. @ArgHostName[@ArgValue_Index] = (@ArgHostType)@ArgName[@ArgValue_Index]; @NL
  56. End=
  57. MacroName=StructLocal
  58. NumArgs=0
  59. Begin=
  60. @IfPtrDep(
  61. @IfIsArray(
  62. // Note: @ArgName(@ArgType) is pointer dependent and is an array. @NL
  63. // Note: Declaring array index. @NL
  64. @DeclareIndex
  65. )
  66. @IfNotIsArray(
  67. // Note: @ArgName(@ArgType) is a pointer dependent struct. @NL
  68. )
  69. @MemberTypes(Locals,.)
  70. )
  71. @IfNotPtrDep(
  72. // Note: @ArgName(@ArgType) is a non pointer dependent struct. @NL
  73. @MemberTypes(Locals,.)
  74. )
  75. End=
  76. MacroName=StructIN
  77. NumArgs=0
  78. Begin=
  79. @IfPtrDep(
  80. @IfNotIsArray(
  81. // Note: @ArgName(@ArgType) is pointer dependent and is not an array. @NL
  82. @MemberTypes(PreCall,.)
  83. )
  84. @IfIsArray(
  85. // Note: @ArgName(@ArgType) is pointer dependent and is an array. @NL
  86. #error Error: don't know how to thunk an array of ptr dep structures. @NL
  87. )
  88. )
  89. @IfNotPtrDep(
  90. @IfIsArray(
  91. // Note: @ArgName(@ArgType) is not pointer dependent and is and array. @NL
  92. RtlCopyMemory(@ArgName, @ArgHostName, sizeof(@ArgType) * @ArrayElements);@NL
  93. )
  94. @IfNotIsArray(
  95. // Note: ArgName(ArgType) is not pointer dependent and is not an array. @NL
  96. RtlCopyMemory(&(@ArgName), &(@ArgHostName), sizeof(@ArgType));@NL
  97. )
  98. )
  99. End=
  100. MacroName=StructOUT
  101. NumArgs=0
  102. Begin=
  103. @IfIsMember(
  104. @IfPtrDep(
  105. @IfNotIsArray(
  106. // Note: @ArgName(@ArgType) is pointer dependent and is not an array.@NL
  107. @MemberTypes(PostCall,.)
  108. )
  109. @IfIsArray(
  110. // Note: @ArgName(@ArgType) is pointer dependent and is an array. @NL
  111. { @NL
  112. @ArgType *___ptr = (@ArgType *)@ArgName; @NL
  113. @ArgHostType *___hostptr = (@ArgHostType*)@ArgHostName; @NL
  114. while (___ptr < ((@ArgType *)(sizeof(@ArgName) + (PBYTE)@ArgName))) { @NL
  115. @ForceType(PostCall, ___ptr, ___hostptr, @ArgType *,OUT);
  116. ___ptr++; @NL
  117. ___hostptr++; @NL
  118. } @NL
  119. } @NL
  120. )
  121. )
  122. @IfNotPtrDep(
  123. @IfIsArray(
  124. // Note: @ArgName(@ArgType) is not pointer dependent and is an array. @NL
  125. RtlCopyMemory(@ArgHostName, @ArgName, sizeof(@ArgType) * @ArrayElements); @NL
  126. )
  127. @IfNotIsArray(
  128. // Note: @ArgName(@ArgType) is not pointer dependent and is not an array. @NL
  129. RtlCopyMemory(&(@ArgHostName), &(@ArgName), sizeof(@ArgType));@NL
  130. )
  131. )
  132. )
  133. End=
  134. MacroName=StructPtrLocal
  135. NumArgs=0
  136. Begin=
  137. @IfPointerToPtrDep(
  138. @IfIsArray(
  139. // Note: @ArgName(@ArgType) is an array of pointers to a pointer dependent structure. @NL
  140. @DeclareIndex
  141. BYTE @ArgValCopy[sizeof(*@ArgName)]; @NL
  142. @MemberTypes(Locals)
  143. )
  144. @IfNotIsArray(
  145. BYTE @ArgValCopy[sizeof(*@ArgName)]; // Note: a pointer to a pointer dependent structure. @NL
  146. @MemberTypes(Locals)
  147. )
  148. )
  149. @IfNotPointerToPtrDep(
  150. // Note: @ArgName(@ArgType) is a pointer to structure that is not pointer dependent - nothing to do. @NL
  151. )
  152. End=
  153. MacroName=StructPtrIN
  154. NumArgs=0
  155. Begin=
  156. @IfPointerToPtrDep(
  157. @IfIsArray(
  158. // Note: @ArgName(@ArgType) is an array of pointers to pointer dependent structures. @NL
  159. #error Error: don't know how to thunk an array of pointers to ptr dep. @NL
  160. )
  161. @IfNotIsArray(
  162. // Note: @ArgName(@ArgType) is a pointer to a pointer dependent structure. @NL
  163. if (WOW64_ISPTR(@ArgHostName)) { @NL
  164. try { @NL
  165. @Indent(
  166. @ArgName = (@ArgType)@ArgValCopy; @NL
  167. @MemberTypes(PreCall)
  168. )
  169. } except (EXCEPTION_EXECUTE_HANDLER) { @NL
  170. #if defined _NTBASE_API_ @NL
  171. return GetExceptionCode(); @NL
  172. #elif defined _WIN32_API_ @NL
  173. return 0; @NL
  174. #endif @NL
  175. } @NL
  176. } @NL
  177. else { @NL
  178. @Indent(
  179. @ArgName = (@ArgType)@ArgHostName; @NL
  180. )
  181. } @NL
  182. )
  183. )
  184. @IfNotPointerToPtrDep(
  185. @IfIsArray(
  186. // Note: @ArgName(@ArgType) is an array of pointers to non pointer dependent structures. @NL
  187. @ElementCopy(StdAEN2HCopy)
  188. )
  189. @IfNotIsArray(
  190. // Note: @ArgName(@ArgType) is pointer to a non pointer dependent structure. @NL
  191. @StdH2NCopy
  192. )
  193. )
  194. End=
  195. MacroName=StructPtrOUTInit
  196. NumArgs=0
  197. Begin=
  198. @IfPointerToPtrDep(
  199. @IfIsArray(
  200. // Note: @ArgName(@ArgType) is an array of pointers to pointer dependent structures. @NL
  201. #error Error: don't know how to thunk an array of pointers to ptr dep. @NL
  202. )
  203. @IfNotIsArray(
  204. try { @NL
  205. // Note: @ArgName(@ArgType) is a pointer to a pointer dependent structure. @NL
  206. @ArgName = WOW64_ISPTR(@ArgHostName) ? (@ArgType)@ArgValCopy : (@ArgType)@ArgHostName; @NL
  207. } except (EXCEPTION_EXECUTE_HANDLER) { @NL
  208. #if defined _NTBASE_API_ @NL
  209. return GetExceptionCode(); @NL
  210. #elif defined _WIN32_API_ @NL
  211. return 0; @NL
  212. #endif @NL
  213. } @NL
  214. )
  215. )
  216. @IfNotPointerToPtrDep(
  217. @IfIsArray(
  218. // Note: @ArgName(@ArgType) is an array of pointers to non pointer dependent structures. @NL
  219. @ElementCopy(StdAEN2HCopy)
  220. )
  221. @IfNotIsArray(
  222. // Note: @ArgName(@ArgType) is pointer to a non pointer dependent structure. @NL
  223. @StdH2NCopy
  224. )
  225. )
  226. End=
  227. MacroName=StructPtrOUT
  228. NumArgs=0
  229. Begin=
  230. @IfPointerToPtrDep(
  231. @IfIsArray(
  232. // Note: @ArgName(@ArgType) is a array of pointers to a pointer dependent structure. @NL
  233. #error Error: don't know how to thunk an array of pointers to ptr dep@NL
  234. )
  235. @IfNotIsArray(
  236. // Note: @ArgName(@ArgType) is a pointer to a pointer dependent structure. @NL
  237. if (WOW64_ISPTR(@ArgHostName)) { @NL
  238. try { @NL
  239. @Indent(
  240. @MemberTypes(PostCall)
  241. )
  242. } except (EXCEPTION_EXECUTE_HANDLER) { @NL
  243. #if defined _NTBASE_API_ @NL
  244. return GetExceptionCode(); @NL
  245. #elif defined _WIN32_API_ @NL
  246. return 0; @NL
  247. #endif @NL
  248. } @NL
  249. } @NL
  250. )
  251. )
  252. @IfNotPointerToPtrDep(
  253. @IfIsMember(
  254. // Note: @ArgName(@ArgType) is a member of a structure. Copying. @NL
  255. @IfIsArray(
  256. RtlCopyMemory(@ArgHostName, @ArgName, sizeof(@ArgType) * @ArrayElements); @NL
  257. )
  258. @IfNotIsArray(
  259. @StdN2HCopy
  260. )
  261. @NL
  262. )
  263. @IfNotIsMember(
  264. // Note: @ArgName(@ArgType) is a pointer to a non pointer dependent type. @NL
  265. // Note: Type is not a member of a structure. Nothing to do. @NL
  266. )
  267. )
  268. End=
  269. MacroName=PointerLocal
  270. NumArgs=0
  271. Begin=
  272. @IfPointerToPtrDep(
  273. // Note: @ArgName(@ArgType) is a pointer to a pointer dependent type. @NL
  274. BYTE @ArgValCopy[sizeof(*@ArgName)];@NL
  275. )
  276. @IfNotPointerToPtrDep(
  277. @IfIsArray(
  278. // Note: @ArgName(@ArgTypes) is an array of pointers to a non pointer dependent type. @NL
  279. @DeclareIndex
  280. )
  281. @IfNotIsArray(
  282. // Note: @ArgName(@ArgType) is a pointer to a non pointer dependent type - Nothing to do. @NL
  283. )
  284. )
  285. End=
  286. MacroName=PointerIN
  287. NumArgs=0
  288. Begin=
  289. @IfPointerToPtrDep(
  290. @IfIsArray(
  291. // Note: @ArgName(@ArgType) is an array of pointers to pointer dependent types. @NL
  292. #error Error: don't know how to thunk an array of pointers to ptr dep. @NL
  293. )
  294. @IfNotIsArray(
  295. // Note: @ArgName(@ArgType) is a pointer to a pointer dependent type. @NL
  296. if (WOW64_ISPTR(@ArgHostName)) { @NL
  297. try { @NL
  298. @Indent(
  299. @IfInt64DepUnion(
  300. //Special Case union having LARGE_INTEGER member @NL
  301. @ArgName = (@ArgType)@ArgValCopy; @NL
  302. *(LONG *)((PBYTE)@ArgValCopy) = *(LONG *)((PBYTE)@ArgHostName); @NL
  303. *(LONG *)(4+(PBYTE)@ArgValCopy) = *(LONG *)(4+(PBYTE)@ArgHostName); @NL
  304. )
  305. @IfNotInt64DepUnion(
  306. @ArgName = (@ArgType)@ArgValCopy; @NL
  307. *((@ArgType)@ArgValCopy) = (@ArgTypeInd)UlongToPtr (*((@ArgHostTypeInd *)@ArgHostName)); @NL
  308. )
  309. )
  310. } except (EXCEPTION_EXECUTE_HANDLER) { @NL
  311. #if defined _NTBASE_API_ @NL
  312. return GetExceptionCode(); @NL
  313. #elif defined _WIN32_API_ @NL
  314. return 0; @NL
  315. #endif @NL
  316. } @NL
  317. } @NL
  318. else { @NL
  319. @Indent(
  320. @ArgName = (@ArgType)@ArgHostName; @NL
  321. )
  322. } @NL
  323. )
  324. )
  325. @IfNotPointerToPtrDep(
  326. @IfIsArray(
  327. // Note: @ArgName(@ArgType) is an array of pointers to a non pointer dependent type.@NL
  328. @ElementCopy(@StdAEH2NCopy)
  329. )
  330. @IfNotIsArray(
  331. // Note: @ArgName(@ArgType) is a pointer to a non pointer dependent type.@NL
  332. @StdH2NCopy
  333. )
  334. )
  335. End=
  336. MacroName=PointerOUTInit
  337. NumArgs=0
  338. Begin=
  339. @IfPointerToPtrDep(
  340. @IfIsArray(
  341. // Note: @ArgName(@ArgType) is an array of pointers to a pointer dependent type. @NL
  342. #error Error: don't know how to thunk an array of pointers to ptr dep @NL
  343. )
  344. @IfNotIsArray(
  345. // Note: @ArgName(@ArgType) is a pointer to a pointer dependent type. @NL
  346. try { @NL
  347. @ArgName = WOW64_ISPTR(@ArgHostName) ? (@ArgType)@ArgValCopy : (@ArgType)@ArgHostName; @NL
  348. } except (EXCEPTION_EXECUTE_HANDLER) { @NL
  349. #if defined _NTBASE_API_ @NL
  350. return GetExceptionCode(); @NL
  351. #elif defined _WIN32_API_ @NL
  352. return 0; @NL
  353. #endif @NL
  354. } @NL
  355. )
  356. )
  357. @IfNotPointerToPtrDep(
  358. // Note: @ArgName(@ArgType) is a pointer to a non pointer dependent type. @NL
  359. @StdH2NCopy
  360. )
  361. End=
  362. MacroName=PointerOUT
  363. NumArgs=0
  364. Begin=
  365. @IfPointerToPtrDep(
  366. @IfIsArray(
  367. // Note: @ArgName(@ArgType) is an array of pointers to a pointer dependent type. @NL
  368. #error Error: don't know how to thunk an array of pointers to ptr dep @NL
  369. )
  370. @IfNotIsArray(
  371. // Note: @ArgName(@ArgType) is a pointer to a pointer dependent type. @NL
  372. if (WOW64_ISPTR(@ArgHostName)) { @NL
  373. try { @NL
  374. @Indent(
  375. @IfInt64DepUnion(
  376. //8byte long integer @NL
  377. *(LONG *)(PBYTE)@ArgHostName = *(LONG *)(PBYTE)@ArgName; @NL
  378. *(LONG *)(4+(PBYTE)@ArgHostName) = *(LONG *)(4+(PBYTE)@ArgName); @NL
  379. )
  380. @IfNotInt64DepUnion(
  381. *((@ArgHostTypeInd *)@ArgHostName) = *(@ArgHostTypeInd *)((@ArgType)@ArgName);@NL
  382. )
  383. )
  384. } except (EXCEPTION_EXECUTE_HANDLER) { @NL
  385. #if defined _NTBASE_API_ @NL
  386. return GetExceptionCode(); @NL
  387. #elif defined _WIN32_API_ @NL
  388. return 0; @NL
  389. #endif @NL
  390. } @NL
  391. } @NL
  392. )
  393. )
  394. @IfNotPointerToPtrDep(
  395. @IfIsMember(
  396. // Note: @ArgName(@ArgType) is a member of a structure. Copying. @NL
  397. @IfIsArray(
  398. @ElementCopy(@StdAEN2HCopy)
  399. )
  400. @IfNotIsArray(
  401. @StdN2HCopy
  402. )
  403. @NL
  404. )
  405. @IfNotIsMember(
  406. // Note: @ArgName(@ArgType) is a pointer to a non pointer dependent type - Nothing to do. @NL
  407. )
  408. )
  409. End=
  410. MacroName=GenericPtrAllocSize
  411. Begin=
  412. @IfPointerToPtrDep(
  413. AllocSize += LENGTH + sizeof(@ArgTypeInd) - sizeof(@ArgHostTypeInd); @NL
  414. )
  415. @IfNotPointerToPtrDep(
  416. // Note: Type is not pointer dependent. @NL
  417. // Note: Signal code to pass the pointer along. @NL
  418. AllocSize = 0; @NL
  419. )
  420. End=
  421. MacroName=TypeStructPtrINLocal
  422. Begin=
  423. @StructPtrLocal
  424. End=
  425. MacroName=TypeStructPtrINPreCall
  426. Begin=
  427. @StructPtrIN
  428. End=
  429. MacroName=TypeStructPtrINPostCall
  430. Begin=
  431. End=
  432. MacroName=TypeStructPtrOUTLocal
  433. Begin=
  434. @StructPtrLocal
  435. End=
  436. MacroName=TypeStructPtrOUTPreCall
  437. Begin=
  438. @StructPtrOUTInit
  439. End=
  440. MacroName=TypeStructPtrOUTPostCall
  441. Begin=
  442. @StructPtrOUT
  443. End=
  444. MacroName=TypeStructPtrINOUTLocal
  445. Begin=
  446. @StructPtrLocal
  447. End=
  448. MacroName=TypeStructPtrINOUTPreCall
  449. Begin=
  450. @StructPtrIN
  451. End=
  452. MacroName=TypeStructPtrINOUTPostCall
  453. Begin=
  454. @StructPtrOUT
  455. End=
  456. MacroName=TypeStructPtrNONELocal
  457. Begin=
  458. @TypeStructPtrINOUTLocal
  459. End=
  460. MacroName=TypeStructPtrNONEPreCall
  461. Begin=
  462. @TypeStructPtrINOUTPreCall
  463. End=
  464. MacroName=TypeStructPtrNONEPostCall
  465. Begin=
  466. @TypeStructPtrINOUTPostCall
  467. End=
  468. MacroName=DbgNonPtrDepCases
  469. NumArgs=1
  470. Begin=
  471. switch(@MArg(1)) { @Indent( @NL
  472. @ForCase(case @CArg(1): @NL)
  473. @Indent(
  474. break; @NL
  475. )
  476. default: @Indent( @NL
  477. LOGPRINT((ERRORLOG, "@ApiName: Called with unsupported class.\n"));
  478. WOWASSERT(FALSE); @NL
  479. return STATUS_NOT_IMPLEMENTED; @NL
  480. )
  481. )} @NL
  482. End=
  483. MacroName=GenProfileSubTable
  484. NumArgs=0
  485. Begin=
  486. @NL
  487. #if defined WOW64DOPROFILE @NL
  488. WOW64SERVICE_PROFILE_TABLE_ELEMENT @ApiNameProfileSublistElements[] = { @Indent( @NL
  489. @ForCase({L"@CArg(1)", 0, NULL, TRUE}, @NL)
  490. {NULL, 0, NULL, FALSE} // For Debugging @NL
  491. )}; @NL
  492. @NL
  493. WOW64SERVICE_PROFILE_TABLE @ApiNameProfileSublist = { @Indent( @NL
  494. NULL,NULL,@ApiNameProfileSublistElements,
  495. (sizeof(@ApiNameProfileSublistElements)/sizeof(WOW64SERVICE_PROFILE_TABLE_ELEMENT))-1
  496. )};@NL
  497. @NL
  498. #if defined @ApiName_PROFILE_SUBLIST @NL
  499. #undef @ApiName_PROFILE_SUBLIST @NL
  500. #endif @NL
  501. #define @ApiName_PROFILE_SUBLIST &@ApiNameProfileSublist @NL
  502. #endif
  503. @NL
  504. End=
  505. MacroName=GenDebugNonPtrDepCases
  506. NumArgs=2
  507. Begin=
  508. @NL
  509. @IfApiCode(Header)
  510. @NL
  511. @GenProfileSubTable
  512. @NL
  513. @ForCase(
  514. @ApiFnRet @NL
  515. wh@ApiName_@CArg(1)(@ArgList(@ListCol@ArgMod @ArgType @IfArgs(@ArgName)@ArgMore(,))) { @Indent( @NL
  516. @IfApiRet(@ApiFnRet RetVal); @NL
  517. #if defined WOW64DOPROFILE @NL
  518. @ApiNameProfileSublistElements[@CNumber].HitCount++; @NL
  519. #endif @NL
  520. @CallApi(@MArg(1), RetVal)
  521. return @IfApiRet(RetVal); @NL
  522. )} @NL
  523. @NL
  524. )
  525. @ApiProlog
  526. // @NL
  527. // Begin: IfApiCode(ApiEntry) @NL
  528. @IfApiCode(ApiEntry)
  529. @NL
  530. @Indent(
  531. @IfApiRet(@ApiFnRet RetVal;) @NL
  532. @NL
  533. // @NL
  534. // Begin: ApiLocals @NL
  535. @ApiLocals
  536. @NL
  537. // @NL
  538. // Begin: Types(Locals) @NL
  539. @Types(Locals)
  540. @NL
  541. // @NL
  542. // Begin: IfApiCode(Locals) @NL
  543. @IfApiCode(Locals)
  544. @NL
  545. APIPROFILE(@ApiNum); @NL
  546. // @NL
  547. //Begin: Types(PreCall) @NL
  548. @Types(PreCall)
  549. @NL
  550. // @NL
  551. // Begin: IfApiCode(PreCall) @NL
  552. @IfApiCode(PreCall)
  553. @NL
  554. // @NL
  555. // Begin: CallApi(MArg(1), RetVal) @NL
  556. switch(@MArg(2)) { @Indent( @NL
  557. @ForCase(
  558. case @CArg(1): @Indent( @NL
  559. @CallApi(wh@ApiName_@CArg(1),RetVal)
  560. break; @NL
  561. ))
  562. default: @Indent( @NL
  563. LOGPRINT((ERRORLOG, "@ApiName: Called with unsupported class %x.\n", @MArg(2)));
  564. WOWASSERT(FALSE); @NL
  565. return STATUS_NOT_IMPLEMENTED; @NL
  566. )
  567. )} @NL
  568. @NL
  569. // @NL
  570. // Begin: Types(PostCall) @NL
  571. @Types(PostCall)
  572. @NL
  573. // @NL
  574. // Begin: ApiCode(PostCall) @NL
  575. @IfApiCode(PostCall)
  576. @NL
  577. // @NL
  578. // Begin: ApiEpilog @NL
  579. @ApiEpilog
  580. @NL
  581. )
  582. // @NL
  583. // Begin: IfApiCode(ApiExit) @NL
  584. @IfApiCode(ApiExit)
  585. @NL
  586. //
  587. // Begin: ApiExit @NL
  588. @ApiExit
  589. @NL
  590. End=
  591. MacroName=GenQuerySetDispatch
  592. NumArgs=2
  593. Begin=
  594. //Switch on the subapi. @NL
  595. switch(@MArg(2)) { @Indent(@NL
  596. // @NL
  597. // Begin Ptr dependent cases. @NL
  598. @ForCase(
  599. case @CArg(1): @Indent( @NL
  600. @If(@CArgExist(2))(
  601. //Handle Automatically generated cases. @NL
  602. #if defined WOW64DOPROFILE @NL
  603. @ApiNameProfileSublistElements[@CNumber].HitCount++; @NL
  604. #endif @NL
  605. @CallApi(wh@ApiName_@CArg(1), RetVal)
  606. break; @NL
  607. )@Else(
  608. //Handle Special cases. @NL
  609. #if defined WOW64DOPROFILE @NL
  610. @ApiNameProfileSublistElements[@CNumber].HitCount++; @NL
  611. #endif @NL
  612. @CallApi(wh@ApiName_Special@MArg(1)Case, RetVal)
  613. break; @NL
  614. )
  615. )
  616. )
  617. default: @Indent( @NL
  618. LOGPRINT((ERRORLOG, "@ApiName: called with unsupported class : %lx\n", @MArg(2))); @NL
  619. WOWASSERT(FALSE); @NL
  620. return STATUS_NOT_IMPLEMENTED; @NL
  621. break; @NL
  622. )@NL
  623. )} @NL
  624. End=
  625. ;
  626. ; Macro Args:
  627. ; 1. Api to call.
  628. ; 2. SwitchParam.
  629. ; 3. DataParam.
  630. ; 4. LengthParam.
  631. ; Case Args:
  632. ; 1. Case for switch
  633. ; 2. Datatype(Optional, If absent indicates a custom thunk)
  634. MacroName=GenSetThunk
  635. NumArgs=4
  636. Begin=
  637. // @NL
  638. // Begin: IfApiCode(Header) @NL
  639. @NL
  640. @NL
  641. @IfApiCode(Header)
  642. @NL
  643. @GenProfileSubTable
  644. @NL
  645. #define SETLENGTH @MArg(4) @NL
  646. @NL
  647. // Special Set Case for @ApiName @NL
  648. @ApiFnRet @NL
  649. wh@ApiName_SpecialSetCase(@ArgList(@ListCol@ArgMod @ArgType @IfArgs(@ArgName)@ArgMore(,))) { @Indent( @NL
  650. @IfApiRet(@ApiFnRet RetVal = STATUS_UNSUCCESSFUL); @NL
  651. ULONG @MArg(4)Host = @MArg(4); @NL
  652. NT32PVOID @MArg(3)Host = (NT32PVOID)@MArg(3); @NL
  653. // @NL
  654. // Begin: IfApiCode(SpecialSetCase) @NL
  655. @NL
  656. switch(@MArg(2)) { @Indent( @NL
  657. @IfApiCode(SpecialSetCase)
  658. )} @NL
  659. return @IfApiRet(RetVal); @NL
  660. )} @NL
  661. @NL
  662. @ForCase(@If(@CArgExist(2))(
  663. @ApiFnRet @NL
  664. wh@ApiName_@CArg(1)(@ArgList(@ListCol@ArgMod @ArgType @IfArgs(@ArgName)@ArgMore(,))) { @Indent( @NL
  665. @IfApiRet(@ApiFnRet RetVal); @NL
  666. @If(@IsPointerToPtrDep(@CArg(2)))(
  667. ULONG @MArg(4)Host = @MArg(4); @NL
  668. NT32PVOID @MArg(3)Host = (NT32PVOID)@MArg(3); @NL
  669. @Types(Locals,@MArg(3),@CArg(2))
  670. // By default: set the length to be 64bit size of the type. @NL
  671. @MArg(4) = sizeof(*((@CArg(2))(@MArg(3)))); @NL
  672. @Types(PreCall,@MArg(3),@CArg(2))
  673. @CallApi(@MArg(1), RetVal)
  674. @Types(PostCall,@MArg(3),@CArg(2))
  675. )@Else(
  676. @CallApi(@MArg(1), RetVal)
  677. )
  678. return @IfApiRet(RetVal); @NL
  679. )} @NL
  680. @NL
  681. ))
  682. @NL
  683. @ApiProlog
  684. // @NL
  685. // Begin: IfApiCode(ApiEntry) @NL
  686. @IfApiCode(ApiEntry)
  687. @NL
  688. @Indent(
  689. NTSTATUS RetVal; @NL
  690. @NL
  691. // @NL
  692. // Begin: ApiLocals @NL
  693. @ApiLocals
  694. @NL
  695. // @NL
  696. // Begin: Types(Locals) @NL
  697. @Types(Locals)
  698. @NL
  699. // @NL
  700. // Begin: IfApiCode(Locals) @NL
  701. @IfApiCode(Locals)
  702. @NL
  703. APIPROFILE(@ApiNum); @NL
  704. @NL
  705. // @NL
  706. //Begin: Types(PreCall) @NL
  707. @Types(PreCall)
  708. @NL
  709. // @NL
  710. // Begin: IfApiCode(PreCall) @NL
  711. @IfApiCode(PreCall)
  712. @NL
  713. @GenQuerySetDispatch(Set,@MArg(2))
  714. // @NL
  715. // Begin: Types(PostCall) @NL
  716. @Types(PostCall)
  717. @NL
  718. // @NL
  719. // Begin: ApiCode(PostCall) @NL
  720. @IfApiCode(PostCall)
  721. @NL
  722. @NL
  723. // @NL
  724. // Begin: ApiEpilog @NL
  725. @ApiEpilog
  726. @NL
  727. )
  728. // @NL
  729. // Begin: IfApiCode(ApiExit) @NL
  730. @IfApiCode(ApiExit)
  731. #undef SETLENGTH @NL
  732. }@NL
  733. @NL
  734. End=
  735. ;
  736. ; Macro Args:
  737. ; 1. Api to call.
  738. ; 2. SwitchParam.
  739. ; 3. DataParam.
  740. ; 4. LengthParam.
  741. ; 5. ReturnLengthParam
  742. ; 6. ReturnLengthType (without pointer decorator)
  743. ; Case Args:
  744. ; 1. Case for switch
  745. ; 2. Datatype
  746. MacroName=GenQueryThunk
  747. NumArgs=6
  748. Begin=
  749. // @NL
  750. // Begin: IfApiCode(Header) @NL
  751. @NL
  752. @NL
  753. @IfApiCode(Header)
  754. @NL
  755. @GenProfileSubTable
  756. @NL
  757. #define LENGTH @MArg(4) @NL
  758. @NL
  759. // Special Query Case for @ApiName @NL
  760. @ApiFnRet @NL
  761. wh@ApiName_SpecialQueryCase(@ArgList(@ListCol@ArgMod @ArgType @IfArgs(@ArgName)@ArgMore(,))) { @Indent( @NL
  762. @IfApiRet(@ApiFnRet RetVal = STATUS_UNSUCCESSFUL); @NL
  763. ULONG @MArg(4)Host = @MArg(4); @NL
  764. PVOID @MArg(3)Host = @MArg(3); @NL
  765. NT32P@MArg(6) @MArg(5)Host = (NT32P@MArg(6))@MArg(5); @NL
  766. // @NL
  767. // Begin: IfApiCode(SpecialQueryCase) @NL
  768. @NL
  769. switch(@MArg(2)) { @Indent( @NL
  770. @IfApiCode(SpecialQueryCase)
  771. )} @NL
  772. return @IfApiRet(RetVal); @NL
  773. )} @NL
  774. @NL
  775. @ForCase(@If(@CArgExist(2))(
  776. @ApiFnRet @NL
  777. wh@ApiName_@CArg(1)(@ArgList(@ListCol@ArgMod @ArgType @IfArgs(@ArgName)@ArgMore(,))) { @Indent( @NL
  778. @IfApiRet(@ApiFnRet RetVal); @NL
  779. @If(@IsPointerToPtrDep(@CArg(2)))(
  780. ULONG @MArg(4)Host = @MArg(4); @NL
  781. PVOID @MArg(3)Host = @MArg(3); @NL
  782. NT32P@MArg(6) @MArg(5)Host = (NT32P@MArg(6))@MArg(5); @NL
  783. SIZE_T RetInfoLen = 0; @NL
  784. SIZE_T AllocSize = 0; @NL
  785. SIZE_T OldLength = 0; @NL
  786. PVOID @MArg(3)Copy = NULL;@NL
  787. @MArg(6) ApiReturnLength; @NL
  788. P@MArg(6) pApiReturnLengthOld; @NL
  789. @Types(AllocSize,@MArg(3),@CArg(2))
  790. if (WOW64_ISPTR(@MArg(3))) { @NL
  791. @MArg(3) = @MArg(3)Copy = Wow64AllocateTemp(AllocSize); @NL
  792. } else { @NL
  793. @MArg(3)Copy = @MArg(3);
  794. } @NL
  795. pApiReturnLengthOld = ReturnLength;@NL
  796. ReturnLength = &ApiReturnLength;@NL
  797. OldLength = LENGTH; @NL
  798. LENGTH = (NT32SIZE_T)AllocSize; @NL
  799. @CallApi(@MArg(1), RetVal)
  800. if (NT_ERROR(RetVal)) { @NL @Indent(
  801. WriteReturnLength(pApiReturnLengthOld, ApiReturnLength); @NL
  802. return RetVal; @NL
  803. )}@NL
  804. try { @NL
  805. @Types(RetSize,@MArg(3),@CArg(2))
  806. if (RetInfoLen > OldLength) { @NL @Indent(
  807. return STATUS_INFO_LENGTH_MISMATCH; @NL
  808. )}@NL
  809. @Types(PostCall,@MArg(3),@CArg(2))
  810. } except (EXCEPTION_EXECUTE_HANDLER) { @NL
  811. return GetExceptionCode (); @NL
  812. } @NL
  813. WriteReturnLength(pApiReturnLengthOld, RetInfoLen); @NL
  814. )@Else(
  815. @CallApi(@MArg(1), RetVal)
  816. )
  817. return @IfApiRet(RetVal); @NL
  818. )} @NL
  819. @NL
  820. ))
  821. @NL
  822. @ApiProlog
  823. // @NL
  824. // Begin: IfApiCode(ApiEntry) @NL
  825. @IfApiCode(ApiEntry)
  826. @NL
  827. @Indent(
  828. @IfApiRet(@ApiFnRet RetVal;) @NL
  829. @NL
  830. // @NL
  831. // Begin: ApiLocals @NL
  832. @ApiLocals
  833. @NL
  834. // @NL
  835. // Begin: Types(Locals) @NL
  836. @Types(Locals)
  837. @NL
  838. // @NL
  839. // Begin: IfApiCode(Locals) @NL
  840. @IfApiCode(Locals)
  841. @NL
  842. APIPROFILE(@ApiNum); @NL
  843. @NL
  844. // @NL
  845. //Begin: Types(PreCall) @NL
  846. @Types(PreCall)
  847. @NL
  848. // @NL
  849. // Begin: IfApiCode(PreCall) @NL
  850. @IfApiCode(PreCall)
  851. @NL
  852. @GenQuerySetDispatch(Query,@MArg(2))
  853. // @NL
  854. // Begin: Types(PostCall) @NL
  855. @Types(PostCall)
  856. @NL
  857. // @NL
  858. // Begin: ApiCode(PostCall) @NL
  859. @IfApiCode(PostCall)
  860. @NL
  861. @NL
  862. // @NL
  863. // Begin: ApiEpilog @NL
  864. @ApiEpilog
  865. @NL
  866. )
  867. // @NL
  868. // Begin: IfApiCode(ApiExit) @NL
  869. @IfApiCode(ApiExit)
  870. #undef LENGTH @NL
  871. }@NL
  872. @NL
  873. End=