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.

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