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.

596 lines
11 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: thunk.c
  3. *
  4. * This module exists solely for testing, to make it is easy to instrument
  5. * all the driver's Drv calls.
  6. *
  7. * Note that most of this stuff will only be compiled in a checked (debug)
  8. * build.
  9. *
  10. * Copyright (c) 1993-1994 Microsoft Corporation
  11. \**************************************************************************/
  12. #include "precomp.h"
  13. ////////////////////////////////////////////////////////////////////////////
  14. #if DBG
  15. // This entire module is only enabled for Checked builds
  16. #define SYNCH_ENTER() 0 // do nothing
  17. #define SYNCH_LEAVE() 0 // do nothing
  18. ////////////////////////////////////////////////////////////////////////////
  19. BOOL gbNull = FALSE; // Set to TRUE with the debugger to test the speed
  20. // of NT with an inifinitely fast display driver
  21. // (actually, almost infinitely fast since we're
  22. // not hooking all the calls we could be)
  23. DHPDEV DbgEnablePDEV(
  24. DEVMODEW* pDevmode,
  25. PWSTR pwszLogAddress,
  26. ULONG cPatterns,
  27. HSURF* ahsurfPatterns,
  28. ULONG cjGdiInfo,
  29. ULONG* pGdiInfo,
  30. ULONG cjDevInfo,
  31. DEVINFO* pDevInfo,
  32. HDEV hdev,
  33. PWSTR pwszDeviceName,
  34. HANDLE hDriver)
  35. {
  36. DHPDEV bRet;
  37. SYNCH_ENTER();
  38. DISPDBG((5, "DrvEnablePDEV"));
  39. bRet = DrvEnablePDEV(
  40. pDevmode,
  41. pwszLogAddress,
  42. cPatterns,
  43. ahsurfPatterns,
  44. cjGdiInfo,
  45. pGdiInfo,
  46. cjDevInfo,
  47. pDevInfo,
  48. hdev,
  49. pwszDeviceName,
  50. hDriver);
  51. DISPDBG((6, "DrvEnablePDEV done"));
  52. SYNCH_LEAVE();
  53. return(bRet);
  54. }
  55. VOID DbgCompletePDEV(
  56. DHPDEV dhpdev,
  57. HDEV hdev)
  58. {
  59. SYNCH_ENTER();
  60. DISPDBG((5, "DrvCompletePDEV"));
  61. DrvCompletePDEV(
  62. dhpdev,
  63. hdev);
  64. DISPDBG((6, "DrvCompletePDEV done"));
  65. SYNCH_LEAVE();
  66. }
  67. VOID DbgDisablePDEV(DHPDEV dhpdev)
  68. {
  69. SYNCH_ENTER();
  70. DISPDBG((5, "DrvDisable"));
  71. DrvDisablePDEV(dhpdev);
  72. DISPDBG((6, "DrvDisable done"));
  73. SYNCH_LEAVE();
  74. }
  75. HSURF DbgEnableSurface(DHPDEV dhpdev)
  76. {
  77. HSURF h;
  78. SYNCH_ENTER();
  79. DISPDBG((5, "DrvEnableSurface"));
  80. h = DrvEnableSurface(dhpdev);
  81. DISPDBG((6, "DrvEnableSurface done"));
  82. SYNCH_LEAVE();
  83. return(h);
  84. }
  85. VOID DbgDisableSurface(DHPDEV dhpdev)
  86. {
  87. SYNCH_ENTER();
  88. DISPDBG((5, "DrvDisableSurface"));
  89. DrvDisableSurface(dhpdev);
  90. DISPDBG((6, "DrvDisableSurface done"));
  91. SYNCH_LEAVE();
  92. }
  93. BOOL DbgAssertMode(
  94. DHPDEV dhpdev,
  95. BOOL bEnable)
  96. {
  97. BOOL b;
  98. SYNCH_ENTER();
  99. DISPDBG((5, "DrvAssertMode"));
  100. b = DrvAssertMode(dhpdev,bEnable);
  101. DISPDBG((6, "DrvAssertMode done"));
  102. SYNCH_LEAVE();
  103. return b;
  104. }
  105. //
  106. // We do not SYNCH_ENTER since we have not initalized the driver.
  107. // We just want to get the list of modes from the miniport.
  108. //
  109. ULONG DbgGetModes(
  110. HANDLE hDriver,
  111. ULONG cjSize,
  112. DEVMODEW* pdm)
  113. {
  114. ULONG u;
  115. DISPDBG((5, "DrvGetModes"));
  116. u = DrvGetModes(
  117. hDriver,
  118. cjSize,
  119. pdm);
  120. DISPDBG((6, "DrvGetModes done"));
  121. return(u);
  122. }
  123. VOID DbgMovePointer(SURFOBJ *pso,LONG x,LONG y,RECTL *prcl)
  124. {
  125. if (gbNull)
  126. return;
  127. SYNCH_ENTER();
  128. DISPDBG((5, "DrvMovePointer"));
  129. DrvMovePointer(pso,x,y,prcl);
  130. DISPDBG((6, "DrvMovePointer done"));
  131. SYNCH_LEAVE();
  132. }
  133. ULONG DbgSetPointerShape(
  134. SURFOBJ* pso,
  135. SURFOBJ* psoMask,
  136. SURFOBJ* psoColor,
  137. XLATEOBJ* pxlo,
  138. LONG xHot,
  139. LONG yHot,
  140. LONG x,
  141. LONG y,
  142. RECTL* prcl,
  143. FLONG fl)
  144. {
  145. ULONG u;
  146. if (gbNull)
  147. return(SPS_ACCEPT_NOEXCLUDE);
  148. SYNCH_ENTER();
  149. DISPDBG((5, "DrvSetPointerShape"));
  150. u = DrvSetPointerShape(
  151. pso,
  152. psoMask,
  153. psoColor,
  154. pxlo,
  155. xHot,
  156. yHot,
  157. x,
  158. y,
  159. prcl,
  160. fl);
  161. DISPDBG((6, "DrvSetPointerShape done"));
  162. SYNCH_LEAVE();
  163. return(u);
  164. }
  165. ULONG DbgDitherColor(
  166. DHPDEV dhpdev,
  167. ULONG iMode,
  168. ULONG rgb,
  169. ULONG* pul)
  170. {
  171. ULONG u;
  172. if (gbNull)
  173. return(DCR_DRIVER);
  174. //
  175. // No need to Synchronize Dither color.
  176. //
  177. DISPDBG((5, "DrvDitherColor"));
  178. u = DrvDitherColor(
  179. dhpdev,
  180. iMode,
  181. rgb,
  182. pul);
  183. DISPDBG((6, "DrvDitherColor done"));
  184. return(u);
  185. }
  186. BOOL DbgSetPalette(
  187. DHPDEV dhpdev,
  188. PALOBJ* ppalo,
  189. FLONG fl,
  190. ULONG iStart,
  191. ULONG cColors)
  192. {
  193. BOOL u;
  194. if (gbNull)
  195. return(TRUE);
  196. SYNCH_ENTER();
  197. DISPDBG((5, "DrvSetPalette"));
  198. u = DrvSetPalette(
  199. dhpdev,
  200. ppalo,
  201. fl,
  202. iStart,
  203. cColors);
  204. DISPDBG((6, "DrvSetPalette done"));
  205. SYNCH_LEAVE();
  206. return(u);
  207. }
  208. BOOL DbgCopyBits(
  209. SURFOBJ* psoDst,
  210. SURFOBJ* psoSrc,
  211. CLIPOBJ* pco,
  212. XLATEOBJ* pxlo,
  213. RECTL* prclDst,
  214. POINTL* pptlSrc)
  215. {
  216. BOOL u;
  217. if (gbNull)
  218. return(TRUE);
  219. SYNCH_ENTER();
  220. DISPDBG((5, "DrvCopyBits"));
  221. u = DrvCopyBits(
  222. psoDst,
  223. psoSrc,
  224. pco,
  225. pxlo,
  226. prclDst,
  227. pptlSrc);
  228. DISPDBG((6, "DrvCopyBits done"));
  229. SYNCH_LEAVE();
  230. return(u);
  231. }
  232. BOOL DbgBitBlt(
  233. SURFOBJ* psoDst,
  234. SURFOBJ* psoSrc,
  235. SURFOBJ* psoMask,
  236. CLIPOBJ* pco,
  237. XLATEOBJ* pxlo,
  238. RECTL* prclDst,
  239. POINTL* pptlSrc,
  240. POINTL* pptlMask,
  241. BRUSHOBJ* pbo,
  242. POINTL* pptlBrush,
  243. ROP4 rop4)
  244. {
  245. BOOL u;
  246. if (gbNull)
  247. return(TRUE);
  248. SYNCH_ENTER();
  249. DISPDBG((5, "DrvBitBlt"));
  250. u = DrvBitBlt(
  251. psoDst,
  252. psoSrc,
  253. psoMask,
  254. pco,
  255. pxlo,
  256. prclDst,
  257. pptlSrc,
  258. pptlMask,
  259. pbo,
  260. pptlBrush,
  261. rop4);
  262. DISPDBG((6, "DrvBitBlt done"));
  263. SYNCH_LEAVE();
  264. return(u);
  265. }
  266. BOOL DbgTextOut(
  267. SURFOBJ* pso,
  268. STROBJ* pstro,
  269. FONTOBJ* pfo,
  270. CLIPOBJ* pco,
  271. RECTL* prclExtra,
  272. RECTL* prclOpaque,
  273. BRUSHOBJ* pboFore,
  274. BRUSHOBJ* pboOpaque,
  275. POINTL* pptlOrg,
  276. MIX mix)
  277. {
  278. BOOL u;
  279. if (gbNull)
  280. return(TRUE);
  281. SYNCH_ENTER();
  282. DISPDBG((5, "DrvTextOut"));
  283. u = DrvTextOut(
  284. pso,
  285. pstro,
  286. pfo,
  287. pco,
  288. prclExtra,
  289. prclOpaque,
  290. pboFore,
  291. pboOpaque,
  292. pptlOrg,
  293. mix);
  294. DISPDBG((6, "DrvTextOut done"));
  295. SYNCH_LEAVE();
  296. return(u);
  297. }
  298. BOOL DbgStrokePath(
  299. SURFOBJ* pso,
  300. PATHOBJ* ppo,
  301. CLIPOBJ* pco,
  302. XFORMOBJ* pxo,
  303. BRUSHOBJ* pbo,
  304. POINTL* pptlBrushOrg,
  305. LINEATTRS* plineattrs,
  306. MIX mix)
  307. {
  308. BOOL u;
  309. if (gbNull)
  310. return(TRUE);
  311. SYNCH_ENTER();
  312. DISPDBG((5, "DrvStrokePath"));
  313. u = DrvStrokePath(
  314. pso,
  315. ppo,
  316. pco,
  317. pxo,
  318. pbo,
  319. pptlBrushOrg,
  320. plineattrs,
  321. mix);
  322. DISPDBG((6, "DrvStrokePath done"));
  323. SYNCH_LEAVE();
  324. return(u);
  325. }
  326. BOOL DbgFillPath(
  327. SURFOBJ* pso,
  328. PATHOBJ* ppo,
  329. CLIPOBJ* pco,
  330. BRUSHOBJ* pbo,
  331. POINTL* pptlBrushOrg,
  332. MIX mix,
  333. FLONG flOptions)
  334. {
  335. BOOL u;
  336. if (gbNull)
  337. return(TRUE);
  338. SYNCH_ENTER();
  339. DISPDBG((5, "DrvFillPath"));
  340. u = DrvFillPath(pso,
  341. ppo,
  342. pco,
  343. pbo,
  344. pptlBrushOrg,
  345. mix,
  346. flOptions);
  347. DISPDBG((6, "DrvFillPath done"));
  348. SYNCH_LEAVE();
  349. return(u);
  350. }
  351. BOOL DbgPaint(
  352. SURFOBJ* pso,
  353. CLIPOBJ* pco,
  354. BRUSHOBJ* pbo,
  355. POINTL* pptlBrushOrg,
  356. MIX mix)
  357. {
  358. BOOL u;
  359. if (gbNull)
  360. return(TRUE);
  361. SYNCH_ENTER();
  362. DISPDBG((5, "DrvPaint"));
  363. u = DrvPaint(
  364. pso,
  365. pco,
  366. pbo,
  367. pptlBrushOrg,
  368. mix);
  369. DISPDBG((6, "DrvPaint done"));
  370. SYNCH_LEAVE();
  371. return(u);
  372. }
  373. BOOL DbgRealizeBrush(
  374. BRUSHOBJ* pbo,
  375. SURFOBJ* psoTarget,
  376. SURFOBJ* psoPattern,
  377. SURFOBJ* psoMask,
  378. XLATEOBJ* pxlo,
  379. ULONG iHatch)
  380. {
  381. BOOL u;
  382. // Note: The only time DrvRealizeBrush is called by GDI is when we've
  383. // called BRUSHOBJ_pvGetRbrush in the middle of a DrvBitBlt
  384. // call, and GDI had to call us back. Since we're still in the
  385. // middle of DrvBitBlt, synchronization has already taken care of.
  386. // For the same reason, this will never be called when 'gbNull'
  387. // is TRUE, so it doesn't even make sense to check gbNull...
  388. DISPDBG((5, "DrvRealizeBrush"));
  389. u = DrvRealizeBrush(
  390. pbo,
  391. psoTarget,
  392. psoPattern,
  393. psoMask,
  394. pxlo,
  395. iHatch);
  396. DISPDBG((6, "DrvRealizeBrush done"));
  397. return(u);
  398. }
  399. VOID DbgDestroyFont(FONTOBJ *pfo)
  400. {
  401. // Note: GDI synchronizes DrvDestroyFont only with other font calls.
  402. // Calls such as DrvBitBlt may be going on at the same time
  403. // as this call, but calls such as DrvTextOut are guaranteed
  404. // not to happen at the same time.
  405. DISPDBG((5, "DrvDestroyFont"));
  406. DrvDestroyFont(pfo);
  407. DISPDBG((6, "DrvDestroyFont done"));
  408. }
  409. HBITMAP DbgCreateDeviceBitmap(DHPDEV dhpdev, SIZEL sizl, ULONG iFormat)
  410. {
  411. HBITMAP hbm;
  412. if (gbNull) // I would pretend to have created a
  413. return(FALSE); // bitmap when gbNull is set, by we
  414. // would need some code to back this
  415. // up so that the system wouldn't
  416. // crash...
  417. SYNCH_ENTER();
  418. DISPDBG((5, "DrvCreateDeviceBitmap"));
  419. hbm = DrvCreateDeviceBitmap(dhpdev, sizl, iFormat);
  420. DISPDBG((6, "DrvCreateDeviceBitmap done"));
  421. SYNCH_LEAVE();
  422. return(hbm);
  423. }
  424. VOID DbgDeleteDeviceBitmap(DHSURF dhsurf)
  425. {
  426. SYNCH_ENTER();
  427. DISPDBG((5, "DrvDeleteDeviceBitmap"));
  428. DrvDeleteDeviceBitmap(dhsurf);
  429. DISPDBG((6, "DrvDeleteDeviceBitmap done"));
  430. SYNCH_LEAVE();
  431. }
  432. BOOL DbgStretchBlt(
  433. SURFOBJ* psoDst,
  434. SURFOBJ* psoSrc,
  435. SURFOBJ* psoMask,
  436. CLIPOBJ* pco,
  437. XLATEOBJ* pxlo,
  438. COLORADJUSTMENT* pca,
  439. POINTL* pptlHTOrg,
  440. RECTL* prclDst,
  441. RECTL* prclSrc,
  442. POINTL* pptlMask,
  443. ULONG iMode)
  444. {
  445. BOOL u;
  446. if (gbNull)
  447. return(TRUE);
  448. SYNCH_ENTER();
  449. DISPDBG((5, "DrvStretchBlt"));
  450. #if SYNCHRONIZEACCESS_WORKS
  451. {
  452. // Our DrvStretchBlt routine calls back to EngStretchBlt, which
  453. // calls back to our DrvCopyBits routine -- so we have to be
  454. // re-entrant for synchronization...
  455. SYNCH_LEAVE();
  456. }
  457. #endif // SYNCHRONIZEACCESS_WORKS
  458. u = DrvStretchBlt(psoDst, psoSrc, psoMask, pco, pxlo, pca, pptlHTOrg,
  459. prclDst, prclSrc, pptlMask, iMode);
  460. #if SYNCHRONIZEACCESS_WORKS
  461. {
  462. SYNCH_ENTER();
  463. }
  464. #endif // SYNCHRONIZEACCESS_WORKS
  465. DISPDBG((6, "DrvStretchBlt done"));
  466. SYNCH_LEAVE();
  467. return(u);
  468. }
  469. #endif