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.

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