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.

1519 lines
47 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: dcexts.cxx
  3. *
  4. * Copyright (c) 2000 Microsoft Corporation
  5. *
  6. \**************************************************************************/
  7. #include "precomp.hxx"
  8. // class DC
  9. #define GetDCField(field) \
  10. GetDCSubField(#field, field)
  11. #define GetDCSubField(field,local) \
  12. GetFieldData(offDC, GDIType(DC), field, sizeof(local), &local)
  13. #define GetDCOffset(field) \
  14. GetFieldOffset(GDIType(DC), #field, &offset)
  15. #define GetDCFieldAndOffset(field) \
  16. do { \
  17. GetDCField(field); \
  18. GetDCOffset(field); \
  19. } while (0)
  20. // _DC_ATTR
  21. #define GetDCATTRField(field) \
  22. GetDCATTRSubField(#field, field)
  23. #define GetDCATTRSubField(field,local) \
  24. GetFieldData(offDCATTR, GDIType(_DC_ATTR), field, sizeof(local), &local)
  25. #define GetDCATTROffset(field) \
  26. GetFieldOffset(GDIType(_DC_ATTR), #field, &offset)
  27. #define GetDCATTRFieldAndOffset(field) \
  28. do { \
  29. GetDCATTRField(field); \
  30. GetDCATTROffset(field); \
  31. } while (0)
  32. // DCLEVEL
  33. #define GetDCLEVELField(field) \
  34. GetDCLEVELSubField(#field, field)
  35. #define GetDCLEVELSubField(field,local) \
  36. GetFieldData(offDCLEVEL, GDIType(DCLEVEL), field, sizeof(local), &local)
  37. #define GetDCLEVELOffset(field) \
  38. GetFieldOffset(GDIType(DCLEVEL), #field, &offset)
  39. #define GetDCLEVELFieldAndOffset(field) \
  40. do { \
  41. GetDCLEVELField(field); \
  42. GetDCLEVELOffset(field); \
  43. } while (0)
  44. /******************************Public*Routine******************************\
  45. *
  46. * Routine Name:
  47. *
  48. * vDumpDCGeneral
  49. *
  50. \**************************************************************************/
  51. void vDumpDCgeneral(ULONG64 offDC)
  52. {
  53. #define DPRINTDCPP(aa,bb) \
  54. DPRINTPP(aa,bb,offDC)
  55. #define DPRINTDCPX(aa,bb) \
  56. DPRINTPX(aa,bb,offDC)
  57. #define DPRINTDCPS(bb) \
  58. DPRINTPS(bb,offDC)
  59. #define GetERECTLvalues { \
  60. GetFieldData(percl, "ERECTL", "left", sizeof(left), &left); \
  61. GetFieldData(percl, "ERECTL", "top", sizeof(top), &top); \
  62. GetFieldData(percl, "ERECTL", "right", sizeof(right), &right); \
  63. GetFieldData(percl, "ERECTL", "bottom", sizeof(bottom), &bottom); \
  64. }
  65. ULONG64 ppdev_, dhpdev_;
  66. ULONG64 hdcNext_, hdcPrev_;
  67. ULONG64 prgnAPI_, prgnVis_, prgnRao_;
  68. ULONG64 psurfInfo_, pDCAttr, ebrushobj;
  69. ULONG64 hlfntCur_, prfnt_, pPFFList;
  70. ULONG64 percl;
  71. SHORT ipfdDevMax_;
  72. FSHORT fs_;
  73. POINTL ptlFillOrigin_;
  74. FLONG flGraphicsCaps_,flSimulationFlags_;
  75. LONG lEscapement_, left, right, top, bottom;
  76. ULONG ulCopyCount_, offset;
  77. DCTYPE dctp_;
  78. FLAGDEF *pfd;
  79. GetDCFieldAndOffset(ppdev_);
  80. DPRINTDCPP( ppdev_, "ppdev_ " );
  81. GetDCFieldAndOffset(dhpdev_);
  82. DPRINTDCPP( dhpdev_, "dhpdev_ " );
  83. GetDCFieldAndOffset(flGraphicsCaps_);
  84. DPRINTDCPX( flGraphicsCaps_, "flGraphicsCaps_ " );
  85. for (pfd = afdGInfo; pfd->psz; pfd++)
  86. if (pfd->fl & flGraphicsCaps_) {
  87. dprintf("\t\t\t\t%s\n", pfd->psz);
  88. flGraphicsCaps_ &= ~pfd->fl;
  89. }
  90. if (flGraphicsCaps_) dprintf(" \t\t\t%-#x BAD FLAGS\n", flGraphicsCaps_);
  91. GetDCFieldAndOffset(hdcNext_);
  92. DPRINTDCPP( hdcNext_, "hdcNext_ " );
  93. GetDCFieldAndOffset(hdcPrev_);
  94. DPRINTDCPP( hdcPrev_, "hdcPrev_ " );
  95. GetDCOffset(erclClip_);
  96. percl = offDC + offset;
  97. GetERECTLvalues;
  98. DPRINTDCPS( "erclClip " );
  99. dprintf("%d %d %d %d\n", left, top, right, bottom );
  100. GetDCOffset(erclWindow_);
  101. percl = offDC + offset;
  102. GetERECTLvalues;
  103. DPRINTDCPS( "erclWindow " );
  104. dprintf("%d %d %d %d\n", left, top, right, bottom );
  105. GetDCOffset(erclBounds_);
  106. percl = offDC + offset;
  107. GetERECTLvalues;
  108. DPRINTDCPS( "erclBounds_ " );
  109. dprintf("%d %d %d %d\n", left, top, right, bottom );
  110. GetDCOffset(erclBoundsApp_);
  111. percl = offDC + offset;
  112. GetERECTLvalues;
  113. DPRINTDCPS( "erclBoundsApp_ " );
  114. dprintf("%d %d %d %d\n", left, top, right, bottom);
  115. GetDCFieldAndOffset(prgnAPI_);
  116. DPRINTDCPP( prgnAPI_, "prgnAPI_ " );
  117. GetDCFieldAndOffset(prgnVis_);
  118. DPRINTDCPP( prgnVis_, "prgnVis_ " );
  119. GetDCFieldAndOffset(prgnRao_);
  120. DPRINTDCPP( prgnRao_, "prgnRao_ " );
  121. GetDCFieldAndOffset(ipfdDevMax_);
  122. DPRINTDCPS( "ipfdDevMax_\n" );
  123. GetDCFieldAndOffset(ptlFillOrigin_);
  124. DPRINTDCPS( "ptlFillOrigin " );
  125. dprintf("%d %d\n", ptlFillOrigin_.x, ptlFillOrigin_.y);
  126. GetDCOffset(eboFill_);
  127. ebrushobj = offDC + offset;
  128. DPRINTDCPS("eboFill_\n");
  129. GetDCOffset(eboLine_);
  130. ebrushobj = offDC + offset;
  131. DPRINTDCPS("eboLine_\n");
  132. GetDCOffset(eboText_);
  133. ebrushobj = offDC + offset;
  134. DPRINTDCPS("eboText_\n");
  135. GetDCOffset(eboBackground_);
  136. ebrushobj = offDC + offset;
  137. DPRINTDCPS("eboBackground_\n");
  138. GetDCFieldAndOffset(hlfntCur_);
  139. DPRINTDCPP( hlfntCur_, "hlfntCur_ " );
  140. GetDCFieldAndOffset(flSimulationFlags_);
  141. DPRINTDCPX( flSimulationFlags_, "flSimulationFlags_ " );
  142. for (pfd = afdTSIM; pfd->psz; pfd++)
  143. if (pfd->fl & flSimulationFlags_) {
  144. dprintf(" \t\t\t\t%s\n", pfd->psz);
  145. flSimulationFlags_ &= ~pfd->fl;
  146. }
  147. if (flSimulationFlags_) dprintf(" \t\t\t%-#x BAD FLAGS\n", flSimulationFlags_);
  148. GetDCFieldAndOffset(lEscapement_);
  149. DPRINTDCPS("lEscapement_ " );
  150. dprintf( "%d\n", lEscapement_ );
  151. GetDCFieldAndOffset(prfnt_);
  152. DPRINTDCPP( prfnt_, "prfnt_ " );
  153. GetDCFieldAndOffset(pPFFList);
  154. DPRINTDCPP( pPFFList, "pPFFList " );
  155. GetDCOffset(co_);
  156. DPRINTDCPS("co_ " );
  157. dprintf("!gdikdx.dco %p\n", offDC + offset);
  158. GetDCFieldAndOffset(pDCAttr);
  159. DPRINTDCPP( pDCAttr, "pDCAttr " );
  160. GetDCOffset(dcattr);
  161. DPRINTDCPS( "dcattr " );
  162. dprintf("!gdikdx.dca %p\n", offDC + offset);
  163. GetDCOffset(dclevel);
  164. DPRINTDCPS( "dclevel " );
  165. dprintf("!gdikdx.dcl %p\n", offDC + offset);
  166. GetDCFieldAndOffset(ulCopyCount_);
  167. DPRINTDCPS( "ulCopyCount_ " );
  168. dprintf("%u\n" , ulCopyCount_);
  169. GetDCFieldAndOffset(psurfInfo_);
  170. DPRINTDCPP( psurfInfo_, "pSurfInfo " );
  171. GetDCFieldAndOffset(dctp_);
  172. DPRINTDCPS( "dctp_ " );
  173. dprintf("%d %s\n", dctp_, pszDCTYPE(dctp_));
  174. GetDCFieldAndOffset(fs_);
  175. DPRINTDCPX( fs_, "fs_ " );
  176. for (pfd = afdDCfs; pfd->psz; pfd++)
  177. if (pfd->fl & fs_) {
  178. dprintf("\t\t\t\t%s\n", pfd->psz);
  179. fs_ &= ~pfd->fl;
  180. }
  181. if (fs_)
  182. dprintf(" \t\t\t%-#x BAD FLAGS\n", fs_);
  183. dprintf("\n");
  184. #undef GetERECTLvalues
  185. return;
  186. }
  187. /******************************Public*Routine******************************\
  188. *
  189. * Routine Name:
  190. *
  191. * vDumpDC_ATTR
  192. *
  193. \**************************************************************************/
  194. void vDumpDC_ATTR(ULONG64 offDCATTR)
  195. {
  196. #define DPRINTDCATTRPP(aa,bb) \
  197. DPRINTPP(aa,bb,offDCATTR)
  198. #define DPRINTDCATTRPX(aa,bb) \
  199. DPRINTPX(aa,bb,offDCATTR)
  200. #define DPRINTDCATTRPS(bb) \
  201. DPRINTPS(bb,offDCATTR)
  202. #define DPRINTDCATTRPD(aa,bb) \
  203. DPRINTPD(aa,bb,offDCATTR)
  204. ULONG64 pvLDC, hbrush, hcmXform, hColorSpace, hlfntNew, pvisrectrgn;
  205. ULONG ulDirty_, offset, Flags;
  206. DWORD crBackgroundClr, crForegroundClr, iCS_CP, IcmBrushColor, IcmPenColor, dwLayout;
  207. ULONG ulBackgroundClr, ulForegroundClr;
  208. LONG lIcmMode,lBkMode, lFillMode, lStretchBltMode, lTextAlign, lTextExtra, lRelAbs, lBreakExtra, cBreak, lWindowOrgx;
  209. FLONG flTextAlign, flFontMapper, flXform;
  210. BYTE jROP2, jBkMode, jFillMode, jStretchBltMode;
  211. POINTL ptlCurrent, ptfxCurrent, ptlWindowOrg, ptlViewportOrg, ptlBrushOrigin;
  212. SIZEL szlWindowExt, szlViewportExt, szlVirtualDevicePixel,szlVirtualDeviceMm;
  213. int iGraphicsMode;
  214. INT iMapMode;
  215. LONG left, top, right, bottom;
  216. FLAGDEF *pfd;
  217. char ach[128], *psz = ach;
  218. if (offDCATTR)
  219. {
  220. dprintf("\nDC_ATTR\n address\n -------\n");
  221. GetDCATTRFieldAndOffset(pvLDC);
  222. DPRINTDCATTRPP(pvLDC, " pvLDC ");
  223. GetDCATTRFieldAndOffset(ulDirty_);
  224. dprintf("[%x]", offDCATTR + offset);
  225. dprintf(" ulDirty_ %-#x\n",ulDirty_);
  226. for (pfd=afdDirty; pfd->psz; pfd++)
  227. if (ulDirty_ & pfd->fl) {
  228. dprintf("\t\t\t\t%s\n", pfd->psz);
  229. ulDirty_ &= ~pfd->fl;
  230. }
  231. if (ulDirty_)
  232. dprintf("\t\t\t\t? %-#x\tBAD FLAGS\n", ulDirty_);
  233. //
  234. // hbrush
  235. //
  236. GetDCATTRFieldAndOffset(hbrush);
  237. DPRINTDCATTRPP(hbrush, "hbrush ");
  238. GetDCATTRFieldAndOffset(crBackgroundClr);
  239. DPRINTDCATTRPX(crBackgroundClr, "crBackgroundClr ");
  240. GetDCATTRFieldAndOffset(ulBackgroundClr);
  241. DPRINTDCATTRPX(ulBackgroundClr, "ulBackgroundClr ");
  242. GetDCATTRFieldAndOffset(crForegroundClr);
  243. DPRINTDCATTRPX(crForegroundClr, "crForegroundClr ");
  244. GetDCATTRFieldAndOffset(ulForegroundClr);
  245. DPRINTDCATTRPX(ulForegroundClr, "ulForegroundClr ");
  246. GetDCATTRFieldAndOffset(iCS_CP);
  247. DPRINTDCATTRPX(iCS_CP, "iCS_CP ");
  248. GetDCATTRFieldAndOffset(iGraphicsMode);
  249. dprintf("[%p] iGraphicsMode %d= %s\n",
  250. offDCATTR + offset, iGraphicsMode, pszGraphicsMode(iGraphicsMode));
  251. GetDCATTRFieldAndOffset(jROP2);
  252. dprintf("[%p] jROP2 %d= %s\n",
  253. offDCATTR + offset, jROP2, pszROP2(jROP2));
  254. GetDCATTRFieldAndOffset(jBkMode);
  255. dprintf("[%p] jBkMode %d= %s\n",
  256. offDCATTR + offset, jBkMode, pszBkMode(jBkMode));
  257. // jFillMode
  258. GetDCATTRFieldAndOffset(jFillMode);
  259. switch (jFillMode) {
  260. case ALTERNATE: psz = "ALTERNATE"; break;
  261. case WINDING : psz = "WINDING" ; break;
  262. default : psz = "?FILLMODE"; break;
  263. }
  264. dprintf("[%p] jFillMode %d = %s\n", offDCATTR + offset, jFillMode, psz);
  265. // jStretchBltMode
  266. GetDCATTRFieldAndOffset(jStretchBltMode);
  267. switch (jStretchBltMode) {
  268. case BLACKONWHITE: psz = "BLACKONWHITE"; break;
  269. case WHITEONBLACK: psz = "WHITEONBLACK"; break;
  270. case COLORONCOLOR: psz = "COLORONCOLOR"; break;
  271. case HALFTONE : psz = "HALFTONE" ; break;
  272. default : psz = "?STRETCHMODE"; break;
  273. }
  274. dprintf("[%p] jStretchBltMode %d = %s\n", offDCATTR + offset, jStretchBltMode, psz);
  275. //
  276. // ICM
  277. //
  278. GetDCATTRFieldAndOffset(lIcmMode);
  279. DPRINTDCATTRPX(lIcmMode, "lIcmMode ");
  280. GetDCATTRFieldAndOffset(hcmXform);
  281. DPRINTDCATTRPP(hcmXform, "hcmXform ");
  282. GetDCATTRFieldAndOffset(hColorSpace);
  283. DPRINTDCATTRPP(hColorSpace, "hColorSpace ");
  284. GetDCATTRFieldAndOffset(IcmBrushColor);
  285. DPRINTDCATTRPX(IcmBrushColor, "IcmBrushColor ");
  286. GetDCATTRFieldAndOffset(IcmPenColor);
  287. DPRINTDCATTRPX(IcmPenColor, "IcmPenColor ");
  288. GetDCATTRFieldAndOffset(ptlCurrent);
  289. dprintf("[%p] ptlCurrent %d %d\n", offDCATTR + offset, ptlCurrent.x, ptlCurrent.y);
  290. GetDCATTRFieldAndOffset(ptfxCurrent);
  291. dprintf("[%p] ptfxCurrent %-#x %-#x\n", offDCATTR + offset, ptfxCurrent.x, ptfxCurrent.y);
  292. GetDCATTRFieldAndOffset(lBkMode);
  293. dprintf("[%p] lBkMode %d = %s\n",
  294. offDCATTR + offset, lBkMode, pszBkMode(lBkMode));
  295. GetDCATTRFieldAndOffset(lFillMode);
  296. switch (lFillMode) {
  297. case ALTERNATE: psz = "ALTERNATE"; break;
  298. case WINDING : psz = "WINDING" ; break;
  299. default : psz = "?" ; break;
  300. }
  301. dprintf("[%p] lFillMode %d = %s\n", offDCATTR + offset, lFillMode, psz);
  302. GetDCATTRFieldAndOffset(lStretchBltMode);
  303. switch (lStretchBltMode) {
  304. case BLACKONWHITE: psz = "BLACKONWHITE"; break;
  305. case WHITEONBLACK: psz = "WHITEONBLACK"; break;
  306. case COLORONCOLOR: psz = "COLORONCOLOR"; break;
  307. case HALFTONE : psz = "HALFTONE" ; break;
  308. default : psz = "?" ; break;
  309. }
  310. dprintf("[%p] lStretchBltMode %d = %s\n", offDCATTR + offset, lStretchBltMode, psz);
  311. GetDCATTRFieldAndOffset(flTextAlign);
  312. DPRINTDCATTRPS("flTextAlign ");
  313. dprintf("%-#x = %s | %s | %s\n", flTextAlign, pszTA_U(flTextAlign), pszTA_H(flTextAlign), pszTA_V(flTextAlign));
  314. GetDCATTRFieldAndOffset(lTextAlign);
  315. DPRINTDCATTRPS("lTextAlign ");
  316. dprintf("%-#x = %s | %s | %s\n", lTextAlign, pszTA_U(lTextAlign), pszTA_H(lTextAlign), pszTA_V(lTextAlign));
  317. GetDCATTRFieldAndOffset(lTextExtra);
  318. DPRINTDCATTRPD(lTextExtra, "lTextExtra ");
  319. GetDCATTRFieldAndOffset(lRelAbs);
  320. DPRINTDCATTRPD(lRelAbs, "lRelAbs ");
  321. GetDCATTRFieldAndOffset(lBreakExtra);
  322. DPRINTDCATTRPD(lBreakExtra, "lBreakExtra ");
  323. GetDCATTRFieldAndOffset(cBreak);
  324. DPRINTDCATTRPD(cBreak, "cBreak ");
  325. GetDCATTRFieldAndOffset(hlfntNew);
  326. DPRINTDCATTRPP(hlfntNew, "hlfntNew ");
  327. GetDCATTRFieldAndOffset(iMapMode);
  328. DPRINTDCATTRPX(iMapMode,"iMapMode ");
  329. dprintf("\t\t\t\t%s\n",pszMapMode(iMapMode));
  330. GetDCATTRFieldAndOffset(flFontMapper);
  331. DPRINTDCATTRPX(flFontMapper, "flFontMapper ");
  332. GetDCATTRFieldAndOffset(dwLayout);
  333. DPRINTDCATTRPD(dwLayout, "dwLayout ");
  334. GetDCATTRFieldAndOffset(lWindowOrgx);
  335. DPRINTDCATTRPD(lWindowOrgx, "lWindowOrgx ");
  336. GetDCATTRFieldAndOffset(ptlWindowOrg);
  337. dprintf("[%p] ptlWindowOrg %d %d\n",
  338. offDCATTR + offset, ptlWindowOrg.x, ptlWindowOrg.y);
  339. GetDCATTRFieldAndOffset(szlWindowExt);
  340. dprintf("[%p] szlWindowExt %d %d\n",
  341. offDCATTR + offset, szlWindowExt.cx, szlWindowExt.cy);
  342. GetDCATTRFieldAndOffset(ptlViewportOrg);
  343. dprintf("[%p] ptlViewportOrg %d %d\n",
  344. offDCATTR + offset, ptlViewportOrg.x, ptlViewportOrg.y);
  345. GetDCATTRFieldAndOffset(szlViewportExt);
  346. dprintf("[%p] szlViewportExt %d %d\n",
  347. offDCATTR + offset, szlViewportExt.cx, szlViewportExt.cy);
  348. GetDCATTRFieldAndOffset(flXform);
  349. DPRINTDCATTRPX(flXform, "flXform ");
  350. for (pfd = afdflx; pfd->psz; pfd++) {
  351. if (flXform & pfd->fl) {
  352. dprintf("\t\t\t\t%s\n", pfd->psz);
  353. flXform &= ~pfd->fl;
  354. }
  355. }
  356. if (flXform)
  357. dprintf("\t\t\t\t%-#x bad flags\n", flXform);
  358. GetDCATTROffset(mxWtoD);
  359. dprintf("[%p] mxWorldToDevice !gdikdx.mx %p\n", offDCATTR + offset, offDCATTR + offset);
  360. GetDCATTROffset(mxDtoW);
  361. dprintf("[%p] mxDeviceToWorld !gdikdx.mx %p\n", offDCATTR + offset, offDCATTR + offset);
  362. GetDCATTROffset(mxWtoP);
  363. dprintf("[%p] mxWorldToPage !gdikdx.mx %p\n", offDCATTR + offset, offDCATTR + offset);
  364. GetDCATTRFieldAndOffset(szlVirtualDevicePixel);
  365. dprintf("[%p] szlVirtualDevicePixel %d %d\n",
  366. offDCATTR + offset, szlVirtualDevicePixel.cx, szlVirtualDevicePixel.cy);
  367. GetDCATTRFieldAndOffset(szlVirtualDeviceMm);
  368. dprintf("[%p] szlVirtualDeviceMm %d %d\n",
  369. offDCATTR + offset, szlVirtualDeviceMm.cx, szlVirtualDeviceMm.cy);
  370. GetDCATTRFieldAndOffset(ptlBrushOrigin);
  371. dprintf("[%p] ptlBrushOrigin\t %d %d\n",
  372. offDCATTR + offset, ptlBrushOrigin.x, ptlBrushOrigin.y);
  373. GetDCATTROffset(VisRectRegion);
  374. pvisrectrgn = offDCATTR + offset;
  375. dprintf("[%p] VisRectRegion", pvisrectrgn);
  376. GetFieldData(pvisrectrgn, "_RGNATTR", "Flags", sizeof(Flags), &Flags);
  377. if (Flags & ATTR_RGN_VALID)
  378. {
  379. GetFieldData(pvisrectrgn, "_RGNATTR", "Rect.left", sizeof(left), &left);
  380. GetFieldData(pvisrectrgn, "_RGNATTR", "Rect.top", sizeof(top), &top);
  381. GetFieldData(pvisrectrgn, "_RGNATTR", "Rect.right", sizeof(right), &right);
  382. GetFieldData(pvisrectrgn, "_RGNATTR", "Rect.bottom", sizeof(bottom), &bottom);
  383. dprintf(" %d %d %d %d", left, top, right, bottom);
  384. }
  385. else
  386. dprintf(" INVALID");
  387. dprintf("\n");
  388. }
  389. else
  390. dprintf("Address of _DC_ATTR is NULL.\n");
  391. return;
  392. }
  393. /******************************Public*Routine******************************\
  394. *
  395. * Routine Name:
  396. *
  397. * vDumpDCLEVEL
  398. *
  399. * Routine Description:
  400. *
  401. * Arguments:
  402. *
  403. * Return Value:
  404. *
  405. \**************************************************************************/
  406. void vDumpDCLEVEL(ULONG64 offDCLEVEL)
  407. {
  408. #define DPRINTDCLEVELPP(aa,bb) \
  409. DPRINTPP(aa,bb,offDCLEVEL)
  410. #define DPRINTDCLEVELPX(aa,bb) \
  411. DPRINTPX(aa,bb,offDCLEVEL)
  412. #define DPRINTDCLEVELPS(bb) \
  413. DPRINTPS(bb,offDCLEVEL)
  414. #define DPRINTDCLEVELPD(aa,bb) \
  415. DPRINTPD(aa,bb,offDCLEVEL)
  416. ULONG64 pSurface, hpal, ppal, hdcSave, pbrFill, pbrLine, hpath, pColorSpace;
  417. ULONG64 prgnClip, prgnMeta;
  418. ULONG64 pfield;
  419. FLONG flPath, flFontState, fl, flbrush;
  420. LONG lSaveDepth, lIcmMode;
  421. SIZEL sizl;
  422. ULONG offset;
  423. FLAGDEF *pfd;
  424. dprintf("\nDCLEVEL @ %p\n address\n -------\n", offDCLEVEL);
  425. GetDCLEVELFieldAndOffset(pSurface);
  426. DPRINTDCLEVELPP( pSurface, "pSurface " );
  427. GetDCLEVELFieldAndOffset(hpal);
  428. DPRINTDCLEVELPP( hpal, "hpal " );
  429. GetDCLEVELFieldAndOffset(ppal);
  430. DPRINTDCLEVELPP( ppal, "ppal " );
  431. GetDCLEVELFieldAndOffset(sizl);
  432. DPRINTDCLEVELPS("sizl " );
  433. dprintf("%d %d\n", sizl.cx, sizl.cy);
  434. GetDCLEVELFieldAndOffset(lSaveDepth);
  435. DPRINTDCLEVELPX(lSaveDepth, "lSaveDepth ");
  436. GetDCLEVELFieldAndOffset(hdcSave);
  437. DPRINTDCLEVELPP( hdcSave, "hdcSave " );
  438. GetDCLEVELFieldAndOffset(pbrFill);
  439. DPRINTDCLEVELPP( pbrFill, "pbrFill " );
  440. GetDCLEVELFieldAndOffset(pbrLine);
  441. DPRINTDCLEVELPP( pbrLine, "pbrLine " );
  442. GetDCLEVELFieldAndOffset(hpath);
  443. DPRINTDCLEVELPP( hpath, "hpath " );
  444. GetDCLEVELFieldAndOffset(pColorSpace);
  445. DPRINTDCLEVELPP( pColorSpace, "pColorSpace " );
  446. GetDCLEVELFieldAndOffset(lIcmMode);
  447. DPRINTDCLEVELPP( lIcmMode, "lIcmMode " );
  448. // flPath
  449. GetDCLEVELFieldAndOffset(flPath);
  450. DPRINTDCLEVELPP( flPath, "flPath " );
  451. for (pfd = afdDCPATH; pfd->psz; pfd++)
  452. if (flPath & pfd->fl) {
  453. dprintf("\t\t\t\t%s\n", pfd->psz);
  454. flPath &= ~pfd->fl;
  455. }
  456. if (flPath)
  457. dprintf("\t\t\t\t%-#x bad flags\n", flPath);
  458. // laPath
  459. GetDCLEVELOffset(laPath);
  460. pfield = offDCLEVEL + offset;
  461. DPRINTDCLEVELPS("laPath ");
  462. dprintf("!gdikdx.la %p\n", pfield);
  463. GetDCLEVELFieldAndOffset(prgnClip);
  464. DPRINTDCLEVELPP( prgnClip, "prgnClip " );
  465. GetDCLEVELFieldAndOffset(prgnMeta);
  466. DPRINTDCLEVELPP( prgnMeta, "prgnMeta " );
  467. // ca
  468. GetDCLEVELOffset(ca);
  469. pfield = offDCLEVEL + offset;
  470. dprintf("[%p] ca !gdikdx.ca %p\n", pfield, pfield);
  471. // flFontState
  472. GetDCLEVELFieldAndOffset(flFontState);
  473. DPRINTDCLEVELPS("flFontState ");
  474. if (!flFontState)
  475. dprintf("0\n");
  476. else
  477. {
  478. for (pfd = afdFS2; pfd->psz; pfd++) {
  479. if (flFontState & pfd->fl) {
  480. dprintf("\t\t\t\t%s\n", pfd->psz);
  481. flFontState &= ~pfd->fl;
  482. }
  483. }
  484. if (flFontState)
  485. dprintf("\t\t\t\t%-#x bad flags\n", flFontState);
  486. }
  487. GetDCLEVELOffset(ufi);
  488. pfield = offDCLEVEL + offset;
  489. DPRINTDCLEVELPS("ufi");
  490. dprintf("\n");
  491. GetDCLEVELFieldAndOffset(fl);
  492. DPRINTDCLEVELPX( fl, "fl " );
  493. if (fl == DC_FL_PAL_BACK)
  494. dprintf("\t\t\t\t\tDC_FL_PAL_BACK\n");
  495. else if (fl != 0)
  496. dprintf("\t\t\t\tbad flags\n");
  497. GetDCLEVELFieldAndOffset(flbrush);
  498. DPRINTDCLEVELPX( flbrush, "flbrush " );
  499. GetDCLEVELOffset(mxWorldToDevice);
  500. DPRINTDCLEVELPS("mxWorldToDevice\t !gdikdx.mx ");
  501. dprintf("%p\n", offDCLEVEL + offset);
  502. GetDCLEVELOffset(mxDeviceToWorld);
  503. DPRINTDCLEVELPS("mxDeviceToWorld\t !gdikdx.mx ");
  504. dprintf("%p\n", offDCLEVEL + offset);
  505. GetDCLEVELOffset(mxWorldToPage);
  506. DPRINTDCLEVELPS("mxWorldToPage\t !gdikdx.mx ");
  507. dprintf("%p\n", offDCLEVEL + offset);
  508. dprintf("\n");
  509. return;
  510. /* #define M3(aa,bb) \
  511. dprintf("[%x] %s%-#x\n", &(pdclSrc->##aa), (bb), pdcl->##aa)
  512. #define M2(aa,bb) \
  513. dprintf("[%x] %s", &(pdclSrc->##aa), (bb))
  514. FLAGDEF *pfd;
  515. FLONG fl;
  516. LONG l;
  517. CHAR ach[128], *psz;
  518. GetDCLEVELFieldAndOffset(efM11PtoD);
  519. sprintEFLOAT( ach, pdcl->efM11PtoD );
  520. M2( efM11PtoD, "efM11PtoD ");
  521. dprintf("%s\n", ach);
  522. sprintEFLOAT( ach, pdcl->efM22PtoD );
  523. M2( efM22PtoD, "efM22PtoD ");
  524. dprintf("%s\n", ach);
  525. sprintEFLOAT( ach, pdcl->efDxPtoD );
  526. M2( efDxPtoD, "efDxPtoD ");
  527. dprintf("%s\n", ach);
  528. sprintEFLOAT( ach, pdcl->efDyPtoD );
  529. M2( efDyPtoD, "efDyPtoD ");
  530. dprintf("%s\n", ach);
  531. sprintEFLOAT( ach, pdcl->efM11_TWIPS );
  532. M2( efM11_TWIPS,"efM11_TWIPS ");
  533. dprintf("%s\n", ach);
  534. sprintEFLOAT( ach, pdcl->efM22_TWIPS );
  535. M2( efM22_TWIPS,"efM22_TWIPS ");
  536. dprintf("%s\n", ach);
  537. sprintEFLOAT( ach, pdcl->efPr11 );
  538. M2( efPr11, "efPr11 ");
  539. dprintf("%s\n", ach);
  540. sprintEFLOAT( ach, pdcl->efPr22 );
  541. M2( efPr22, "efPr22 ");
  542. dprintf("%s\n", ach);
  543. #undef M2
  544. #undef M3
  545. */
  546. }
  547. /******************************Public*Routine******************************\
  548. *
  549. * Routine Name:
  550. *
  551. * vDumpDCFontInfo
  552. *
  553. \**************************************************************************/
  554. void vDumpDCFontInfo(ULONG64 offDC)
  555. {
  556. ULONG64 prfnt_, hlfntCur_, pDCAttr, offDCLEVEL;
  557. FLONG flFontState, fl, flFontMapper, flXform;
  558. INT iMapMode;
  559. ULONG offset;
  560. FLAGDEF *pfd;
  561. dprintf("\n");
  562. GetDCFieldAndOffset(prfnt_);
  563. dprintf("[%p] prfnt_ %p\t(!gdikdx.fo -f %p)\n",
  564. offDC + offset, prfnt_, prfnt_);
  565. GetDCFieldAndOffset(hlfntCur_);
  566. dprintf("[%p] hlfntCur_ %p", offDC + offset, hlfntCur_);
  567. if (hlfntCur_)
  568. vDumpHFONT(hlfntCur_);
  569. else
  570. dprintf("\n");
  571. GetDCField(pDCAttr);
  572. if (pDCAttr)
  573. {
  574. ULONG64 offDCATTR, hlfntNew;
  575. int iGraphicsMode;
  576. LONG lBkMode, lTextAlign, lTextExtra, lBreakExtra, cBreak;
  577. offDCATTR = pDCAttr;
  578. GetDCATTRFieldAndOffset(hlfntNew);
  579. dprintf("[%p] hlfntNew %p", offDCATTR + offset, hlfntNew);
  580. if (hlfntNew != hlfntCur_)
  581. vDumpHFONT(hlfntNew);
  582. else
  583. dprintf(" (same as hlfntCur_)\n");
  584. // iGraphicsMode
  585. GetDCATTRFieldAndOffset(iGraphicsMode);
  586. dprintf("[%p] iGraphicsMode %d = %s\n",
  587. offDCATTR + offset,
  588. iGraphicsMode,
  589. pszGraphicsMode(iGraphicsMode)
  590. );
  591. // lBkMode
  592. GetDCATTRFieldAndOffset(lBkMode);
  593. dprintf("[%p] lBkMode %d = %s\n",
  594. offDCATTR + offset, lBkMode, pszBkMode(lBkMode));
  595. // lTextAlign
  596. GetDCATTRFieldAndOffset(lTextAlign);
  597. dprintf("[%p] lTextAlign %d =",
  598. offDCATTR + offset, lTextAlign);
  599. dprintf(" %s | %s | %s\n",
  600. pszTA_U(lTextAlign),
  601. pszTA_H(lTextAlign),pszTA_V(lTextAlign));
  602. GetDCATTRFieldAndOffset(lTextExtra);
  603. dprintf("[%p] lTextExtra %d\n",
  604. offDCATTR + offset, lTextExtra);
  605. GetDCATTRFieldAndOffset(lBreakExtra);
  606. dprintf("[%p] lBreakExtra %d\n",
  607. offDCATTR + offset, lBreakExtra);
  608. GetDCATTRFieldAndOffset(cBreak);
  609. dprintf("[%p] cBreak %d\n",
  610. offDCATTR + offset, cBreak);
  611. GetDCATTRFieldAndOffset(flFontMapper);
  612. dprintf("[%p] flFontMapper %-#x",
  613. offDCATTR + offset, flFontMapper);
  614. if (flFontMapper == ASPECT_FILTERING)
  615. dprintf(" = ASPECT_FILTERING");
  616. else if (flFontMapper != 0)
  617. dprintf(" = ?");
  618. dprintf("\n");
  619. GetDCATTRFieldAndOffset(iMapMode);
  620. dprintf("[%p] iMapMode %d = %s\n",
  621. offDCATTR + offset,
  622. iMapMode,
  623. pszMapMode(iMapMode)
  624. );
  625. GetDCATTRFieldAndOffset(flXform);
  626. dprintf("[%p] flXform %-#x\n", offDCATTR + offset, flXform);
  627. for (pfd = afdflx; pfd->psz; pfd++)
  628. if (flXform & pfd->fl) dprintf("\t\t\t\t%s\n", pfd->psz);
  629. }
  630. else
  631. dprintf("pdc->pDCAttr == 0\n");
  632. GetDCOffset(dclevel);
  633. offDCLEVEL= offDC + offset;
  634. GetDCLEVELField(flFontState);
  635. dprintf("[%p] flFontState %-#x", offDCLEVEL, flFontState);
  636. for (pfd = afdDCFS; pfd->psz; pfd++) {
  637. if (pfd->fl & flFontState) {
  638. dprintf(" = %s", pfd->psz);
  639. }
  640. }
  641. dprintf("\n");
  642. GetDCLEVELOffset(mxWorldToDevice);
  643. dprintf("[%p] mxWorldToDevice\n", offDCLEVEL + offset);
  644. dprintf("\n");
  645. return;
  646. }
  647. /******************************Public*Routine******************************\
  648. *
  649. * Routine Name:
  650. *
  651. * dca
  652. *
  653. \**************************************************************************/
  654. DECLARE_API( dca )
  655. {
  656. PARSE_POINTER(dca_help);
  657. vDumpDC_ATTR(arg);
  658. EXIT_API(S_OK);
  659. dca_help:
  660. dprintf("Usage: dca [-?] DC_ATTR pointer\n");
  661. EXIT_API(S_OK);
  662. }
  663. /******************************Public*Routine******************************\
  664. *
  665. * Routine Name:
  666. *
  667. * dcl
  668. *
  669. \**************************************************************************/
  670. DECLARE_API( dcl )
  671. {
  672. PARSE_POINTER(dcl_help);
  673. vDumpDCLEVEL(arg);
  674. EXIT_API(S_OK);
  675. dcl_help:
  676. dprintf("Usage: dcl [-?] DCLEVEL pointer\n");
  677. EXIT_API(S_OK);
  678. }
  679. /******************************Public*Routine******************************\
  680. *
  681. * Routine Name:
  682. *
  683. * hdc
  684. *
  685. \**************************************************************************/
  686. DECLARE_API( hdc )
  687. {
  688. HRESULT hr;
  689. ULONG64 addrDC;
  690. BOOL General =FALSE;
  691. BOOL DCLevel =FALSE;
  692. BOOL DCAttr =FALSE;
  693. BOOL FontInfo=FALSE;
  694. PARSE_POINTER(hdc_help);
  695. hr = GetObjectAddress(Client,arg,&addrDC,DC_TYPE,TRUE,TRUE);
  696. if(ntok<2) {
  697. General=TRUE;
  698. } else {
  699. if(parse_iFindSwitch(tokens, ntok, 'g')!=-1) {General=TRUE;}
  700. if(parse_iFindSwitch(tokens, ntok, 'l')!=-1) {DCLevel=TRUE;}
  701. if(parse_iFindSwitch(tokens, ntok, 't')!=-1) {DCAttr=TRUE;}
  702. if(parse_iFindSwitch(tokens, ntok, 'f')!=-1) {FontInfo=TRUE;}
  703. }
  704. if(!(General||DCLevel||DCAttr||FontInfo)) {General=TRUE;}
  705. if (hr == S_OK && addrDC)
  706. {
  707. dprintf("\nDC @ 0x%p\n address\n -------\n", addrDC);
  708. // general info
  709. if (General)
  710. vDumpDCgeneral(addrDC);
  711. // dcattr
  712. if (DCAttr)
  713. {
  714. ULONG64 addrDCAttr;
  715. ULONG error;
  716. if (error = GetFieldData(addrDC, GDIType(DC), "pDCAttr", sizeof(addrDCAttr), &addrDCAttr))
  717. {
  718. dprintf("Unable to get pDCAttr\n");
  719. dprintf(" (GetFieldData returned %s)\n", pszWinDbgError(error));
  720. }
  721. else
  722. {
  723. vDumpDC_ATTR(addrDCAttr);
  724. }
  725. }
  726. // dclevel
  727. if (DCLevel)
  728. {
  729. ULONG offDCLevel;
  730. GetFieldOffset(GDIType(DC), "dclevel", &offDCLevel);
  731. vDumpDCLEVEL(addrDC + offDCLevel);
  732. }
  733. // font information
  734. if (FontInfo)
  735. vDumpDCFontInfo(addrDC);
  736. }
  737. EXIT_API(S_OK);
  738. hdc_help:
  739. dprintf("Usage: hdc [-?] [-g] [-l] [-t] [-f] handle\n"
  740. " -? help\n"
  741. " -g general\n"
  742. " -l dclevel\n"
  743. " -t dcattr\n"
  744. " -f font information\n");
  745. EXIT_API(S_OK);
  746. }
  747. /**************************************************************************\
  748. * DC (ddc) Fields
  749. \**************************************************************************/
  750. PCSTR DCAttribFields[] = {
  751. "dcattr.*", // "dcattr.ptlBrushOrigin",
  752. "pDCAttr",
  753. // Extended
  754. "ptlFillOrigin_",
  755. NULL
  756. };
  757. PCSTR DCDrawFields[] = {
  758. "pDCAttr",
  759. "dclevel.hpath",
  760. "dclevel.flPath",
  761. // Extended
  762. "dclevel.laPath",
  763. NULL
  764. };
  765. PCSTR DCFontFields[] = {
  766. "prfnt_",
  767. "pDCAttr",
  768. NULL
  769. };
  770. PCSTR DCGeneralFields[] = {
  771. "hHmgr",
  772. "pDCAttr",
  773. "dclevel.",
  774. "dclevel.pSurface",
  775. "dctp_",
  776. "prgnVis_",
  777. "dclevel.prgnClip",
  778. "dclevel.prgnMeta",
  779. "prgnAPI_",
  780. "prgnRao_",
  781. "dclevel.sizl",
  782. "erclClip_",
  783. "eptlOrigin_",
  784. "erclWindow_",
  785. "erclBounds_",
  786. // Extended
  787. "fs_",
  788. "dhpdev_",
  789. "ppdev_",
  790. "hsemDcDevLock_",
  791. "flGraphicsCaps_",
  792. "flGraphicsCaps2_",
  793. "hdcPrev_",
  794. "hdcNext_",
  795. "hlfntCur_",
  796. "prfnt_",
  797. NULL
  798. };
  799. PCSTR DCLevelFields[] = {
  800. "dclevel.*",
  801. NULL
  802. };
  803. PCSTR DCSavedFields[] = {
  804. "dclevel.hdcSave",
  805. "dclevel.lSaveDepth",
  806. // Extended
  807. "dclevel.hpal",
  808. "dclevel.ppal",
  809. "pDCAttr", //dprintf("\thlfntNew = 0x%08lx\n", pdcattr->hlfntNew);
  810. "dclevel.flFontState", //afdDCFS
  811. "fs_", // afdDCFS
  812. NULL
  813. };
  814. PCSTR DCTextFields[] = {
  815. "pDCAttr",
  816. NULL
  817. };
  818. PCSTR DCXformFields[] = {
  819. "dclevel.mxWorldToDevice.",
  820. "dclevel.mxDeviceToWorld.",
  821. "dclevel.mxWorldToPage.",
  822. // Extended
  823. "dclevel.mxWorldToDevice",
  824. NULL
  825. };
  826. /******************************Public*Routine******************************\
  827. * DC (ddc)
  828. *
  829. * Debugger extension to dump a DC.
  830. *
  831. * History:
  832. * 10-Jul-1991 -by- Gilman Wong [gilmanw]
  833. * Wrote it.
  834. *
  835. * 21-Feb-1995 -by- Lingyun Wang [lingyunw]
  836. * Made it to work in the kernel.
  837. *
  838. * 22-Dec-2000 -by- Jason Hartman [jasonha]
  839. * Rewrote for type knowledgable debugger.
  840. *
  841. \**************************************************************************/
  842. DECLARE_API( ddc )
  843. {
  844. BEGIN_API( ddc );
  845. HRESULT hr = S_OK;
  846. ULONG64 DCAddr;
  847. DEBUG_VALUE Arg;
  848. ULONG64 Module;
  849. ULONG TypeId;
  850. OutputControl OutCtl(Client);
  851. BOOL BadSwitch = FALSE;
  852. BOOL DumpAll = FALSE;
  853. BOOL bAttrib = FALSE;
  854. BOOL bDraw = FALSE;
  855. BOOL bExtend = FALSE;
  856. BOOL bFont = FALSE;
  857. BOOL bGeneral= FALSE;
  858. BOOL bLevel = FALSE;
  859. BOOL bSaved = FALSE;
  860. BOOL bText = FALSE;
  861. BOOL bXform = FALSE;
  862. while (!BadSwitch)
  863. {
  864. while (isspace(*args)) args++;
  865. if (*args != '-') break;
  866. args++;
  867. BadSwitch = (*args == '\0' || isspace(*args));
  868. while (*args != '\0' && !isspace(*args))
  869. {
  870. switch (tolower(*args))
  871. {
  872. case 'a': bAttrib = TRUE; break;
  873. case 'd': bDraw = TRUE; break;
  874. case 'e': bExtend = TRUE; break;
  875. case 'f': bFont = TRUE; break;
  876. case 'g': bGeneral = TRUE; break;
  877. case 'l': bLevel = TRUE; break;
  878. case 's': bSaved = TRUE; break;
  879. case 't': bText = TRUE; break;
  880. case 'v': DumpAll = TRUE; break;
  881. case 'x': bXform = TRUE; break;
  882. default:
  883. BadSwitch = TRUE;
  884. break;
  885. }
  886. if (BadSwitch) break;
  887. args++;
  888. }
  889. }
  890. if (BadSwitch)
  891. {
  892. OutCtl.Output("Usage: hdc [-?adefgstvx] <HDC | DC Addr>\n"
  893. "\n"
  894. "a - DC_ATTR\n"
  895. "d - Drawing attributes\n"
  896. "e - Extended info\n"
  897. "f - Font data\n\n"
  898. "g - General data (default)\n"
  899. "l - DCLEVEL\n"
  900. "s - Saved data\n"
  901. "t - Text attributes\n"
  902. "v - Verbose mode (print everything)\n"
  903. "x - Transform data\n");
  904. return S_OK;
  905. }
  906. hr = GetTypeId(Client, "DC", &TypeId, &Module);
  907. if (hr != S_OK)
  908. {
  909. OutCtl.OutErr("Error getting type info for %s (%s).\n",
  910. GDIType(DC), pszHRESULT(hr));
  911. }
  912. else if ((hr = Evaluate(Client, args, DEBUG_VALUE_INT64, 0, &Arg, NULL)) != S_OK ||
  913. Arg.I64 == 0)
  914. {
  915. if (hr == S_OK)
  916. {
  917. OutCtl.Output("Expression %s evalated to zero.\n", args);
  918. }
  919. else
  920. {
  921. OutCtl.OutErr("Evaluate(%s) returned %s.\n", args, pszHRESULT(hr));
  922. }
  923. }
  924. else
  925. {
  926. hr = GetObjectAddress(Client, Arg.I64, &DCAddr, DC_TYPE, TRUE, TRUE);
  927. if (hr != S_OK || DCAddr == 0)
  928. {
  929. DEBUG_VALUE ObjHandle;
  930. TypeOutputParser TypeParser(Client);
  931. OutputState OutState(Client);
  932. ULONG64 DCAddrFromHmgr;
  933. DCAddr = Arg.I64;
  934. if ((hr = OutState.Setup(0, &TypeParser)) != S_OK ||
  935. (hr = OutState.OutputTypeVirtual(DCAddr, Module, TypeId, 0)) != S_OK ||
  936. (hr = TypeParser.Get(&ObjHandle, "hHmgr", DEBUG_VALUE_INT64)) != S_OK)
  937. {
  938. OutCtl.OutErr("Unable to get contents of DC::hHmgr\n");
  939. OutCtl.OutErr(" (Type Read returned %s)\n", pszHRESULT(hr));
  940. OutCtl.OutErr(" 0x%p is neither an HDC nor valid DC address\n", Arg.I64);
  941. }
  942. else
  943. {
  944. if (GetObjectAddress(Client, ObjHandle.I64, &DCAddrFromHmgr,
  945. DC_TYPE, TRUE, FALSE) == S_OK &&
  946. DCAddrFromHmgr != DCAddr)
  947. {
  948. OutCtl.OutWarn("\tNote: DC may not be valid.\n"
  949. "\t It does not have a valid handle manager entry.\n");
  950. }
  951. }
  952. }
  953. //
  954. // If nothing was specified, dump main section
  955. //
  956. if (!(bAttrib || bDraw || bFont || bSaved || bText || bXform))
  957. {
  958. bGeneral = TRUE;
  959. }
  960. if (hr == S_OK)
  961. {
  962. TypeOutputDumper TypeReader(Client, &OutCtl);
  963. if (DumpAll)
  964. {
  965. TypeReader.ExcludeMarked();
  966. // Don't recurse for big sub structures
  967. TypeReader.MarkField("dclevel.*");
  968. TypeReader.MarkField("dcattr.*");
  969. TypeReader.MarkField("co_.*");
  970. TypeReader.MarkField("eboFill_.*");
  971. TypeReader.MarkField("eboLine_.*");
  972. TypeReader.MarkField("eboText_.*");
  973. TypeReader.MarkField("eboBackground_.*");
  974. }
  975. else
  976. {
  977. TypeReader.IncludeMarked();
  978. if (bAttrib)
  979. {
  980. TypeReader.MarkFields(DCAttribFields, bExtend ? -1 : 2);
  981. }
  982. if (bDraw)
  983. {
  984. TypeReader.MarkFields(DCDrawFields, bExtend ? -1 : 3);
  985. }
  986. if (bFont)
  987. {
  988. TypeReader.MarkFields(DCFontFields);
  989. }
  990. if (bGeneral)
  991. {
  992. TypeReader.MarkFields(DCGeneralFields, bExtend ? -1 : 14);
  993. }
  994. if (bLevel)
  995. {
  996. TypeReader.MarkFields(DCLevelFields);
  997. }
  998. if (bSaved)
  999. {
  1000. TypeReader.MarkFields(DCSavedFields, bExtend ? -1 : 2);
  1001. }
  1002. if (bText)
  1003. {
  1004. TypeReader.MarkFields(DCTextFields);
  1005. }
  1006. if (bXform)
  1007. {
  1008. TypeReader.MarkFields(DCXformFields, bExtend ? -1 : 3);
  1009. }
  1010. }
  1011. OutCtl.Output(" DC @ 0x%p:\n", DCAddr);
  1012. hr = TypeReader.OutputVirtual(Module, TypeId, DCAddr);
  1013. if (hr != S_OK)
  1014. {
  1015. OutCtl.OutErr("Type Dump for DC returned %s.\n", pszHRESULT(hr));
  1016. }
  1017. }
  1018. }
  1019. return hr;
  1020. }
  1021. /******************************Public*Routine******************************\
  1022. * DCLIST
  1023. *
  1024. * List DC and brief info
  1025. *
  1026. \**************************************************************************/
  1027. PCSTR DCListFields[] = {
  1028. "hHmgr",
  1029. "dhpdev_",
  1030. "ppdev_",
  1031. "dclevel.pSurface",
  1032. NULL
  1033. };
  1034. DECLARE_API( dclist )
  1035. {
  1036. BEGIN_API( dclist );
  1037. HRESULT hr;
  1038. HRESULT hrMask;
  1039. ULONG64 index;
  1040. ULONG64 gcMaxHmgr;
  1041. ULONG64 DCAddr;
  1042. BOOL BadSwitch = FALSE;
  1043. BOOL DumpBaseObject = FALSE;
  1044. BOOL DumpUserFields = FALSE;
  1045. OutputControl OutCtl(Client);
  1046. while (isspace(*args)) args++;
  1047. while (!BadSwitch)
  1048. {
  1049. while (isspace(*args)) args++;
  1050. if (*args != '-') break;
  1051. args++;
  1052. BadSwitch = (*args == '\0' || isspace(*args));
  1053. while (*args != '\0' && !isspace(*args))
  1054. {
  1055. switch (*args)
  1056. {
  1057. case 'b': DumpBaseObject = TRUE; break;
  1058. default:
  1059. BadSwitch = TRUE;
  1060. break;
  1061. }
  1062. if (BadSwitch) break;
  1063. args++;
  1064. }
  1065. }
  1066. if (BadSwitch)
  1067. {
  1068. if (*args == '?')
  1069. {
  1070. OutCtl.Output("Lists all DCs and a few basic members.\n"
  1071. "\n");
  1072. }
  1073. OutCtl.Output("Usage: dclist [-?b] [<Member List>]\n"
  1074. "\n"
  1075. " b - Dump BASEOBJECT information\n"
  1076. "\n"
  1077. " Member List - Space seperated list of other SURFACE members\n"
  1078. " to be included in the dump\n");
  1079. return S_OK;
  1080. }
  1081. if ((hr = GetMaxHandles(Client, &gcMaxHmgr)) != S_OK)
  1082. {
  1083. OutCtl.OutErr("Unable to get sizeof GDI handle table. HRESULT %s\n", pszHRESULT(hr));
  1084. return hr;
  1085. }
  1086. gcMaxHmgr = (ULONG64)(ULONG)gcMaxHmgr;
  1087. OutCtl.Output("Searching 0x%I64x handle entries for DCs.\n", gcMaxHmgr);
  1088. OutputFilter OutFilter(Client);
  1089. OutputState OutState(Client, FALSE);
  1090. OutputControl OutCtlToFilter;
  1091. ULONG64 Module;
  1092. ULONG TypeId;
  1093. ULONG OutputMask;
  1094. if ((hr = OutState.Setup(DEBUG_OUTPUT_NORMAL, &OutFilter)) == S_OK &&
  1095. (hr = OutCtlToFilter.SetControl(DEBUG_OUTCTL_THIS_CLIENT |
  1096. DEBUG_OUTCTL_NOT_LOGGED,
  1097. OutState.Client)) == S_OK &&
  1098. (hr = GetTypeId(Client, "DC", &TypeId, &Module)) == S_OK)
  1099. {
  1100. TypeOutputDumper TypeReader(OutState.Client, &OutCtlToFilter);
  1101. TypeReader.SelectMarks(1);
  1102. TypeReader.IncludeMarked();
  1103. if (DumpBaseObject) TypeReader.MarkFields(BaseObjectFields);
  1104. // Add user specified fields to dump list
  1105. PSTR MemberList = NULL;
  1106. CHAR *pBOF = (CHAR *)args;
  1107. if (iscsymf(*pBOF))
  1108. {
  1109. MemberList = (PSTR) HeapAlloc(GetProcessHeap(), 0, strlen(pBOF)+1);
  1110. if (MemberList != NULL)
  1111. {
  1112. strcpy(MemberList, pBOF);
  1113. pBOF = MemberList;
  1114. DumpUserFields = TRUE;
  1115. while (iscsymf(*pBOF))
  1116. {
  1117. CHAR *pEOF = pBOF;
  1118. CHAR EOFChar;
  1119. // Get member
  1120. do {
  1121. pEOF++;
  1122. } while (iscsym(*pEOF) || *pEOF == '.' || *pEOF == '*');
  1123. EOFChar = *pEOF;
  1124. *pEOF = '\0';
  1125. TypeReader.MarkField(pBOF);
  1126. // Advance to next
  1127. if (EOFChar != '\0')
  1128. {
  1129. do
  1130. {
  1131. pEOF++;
  1132. } while (isspace(*pEOF));
  1133. }
  1134. pBOF = pEOF;
  1135. }
  1136. }
  1137. else
  1138. {
  1139. OutCtl.OutErr("Error: Couldn't allocate memory for Member List.\n");
  1140. hr = E_OUTOFMEMORY;
  1141. }
  1142. }
  1143. if (hr == S_OK && *pBOF != '\0')
  1144. {
  1145. OutCtl.OutErr("Error: \"%s\" is not a valid member list.\n", pBOF);
  1146. hr = E_INVALIDARG;
  1147. }
  1148. if (hr == S_OK)
  1149. {
  1150. // Setup default dump specifications
  1151. TypeReader.SelectMarks(0);
  1152. TypeReader.IncludeMarked();
  1153. TypeReader.MarkFields(DCListFields);
  1154. OutFilter.Replace(OUTFILTER_REPLACE_THIS, "hHmgr ", NULL);
  1155. OutFilter.Replace(OUTFILTER_REPLACE_THIS, "DC_TYPE : ", NULL);
  1156. OutFilter.Replace(OUTFILTER_REPLACE_THIS, " dhpdev_ ", NULL);
  1157. OutFilter.Replace(OUTFILTER_REPLACE_THIS, " ppdev_ ", NULL);
  1158. OutFilter.Replace(OUTFILTER_REPLACE_THIS, " dclevel DCLEVEL ", NULL);
  1159. OutFilter.Replace(OUTFILTER_REPLACE_THIS, " pSurface ", NULL);
  1160. OutFilter.Replace(OUTFILTER_REPLACE_THIS, "(null)", "(null) ");
  1161. OutCtl.Output(" &DC HDC dhpdev_ ppdev_ pSurface");
  1162. if (DumpBaseObject) OutCtl.Output(" \tBASEOBJECT");
  1163. if (DumpUserFields) OutCtl.Output(" %s", args);
  1164. OutCtl.Output("\n");
  1165. for (index = 0;
  1166. index < gcMaxHmgr;
  1167. index++)
  1168. {
  1169. if (OutCtl.GetInterrupt() == S_OK)
  1170. {
  1171. OutCtl.OutWarn("User aborted search:\n"
  1172. " 0x%I64x entries were checked.\n"
  1173. " 0x%I64x entries remain.\n",
  1174. index, gcMaxHmgr - index);
  1175. break;
  1176. }
  1177. // Turn off error and verbose messages for this call to
  1178. // GetObjectAddress since it will spew for non-DCs.
  1179. if ((hrMask = Client->GetOutputMask(&OutputMask)) == S_OK &&
  1180. OutputMask & (DEBUG_OUTPUT_ERROR | DEBUG_OUTPUT_VERBOSE))
  1181. {
  1182. hrMask = Client->SetOutputMask(OutputMask & ~(DEBUG_OUTPUT_ERROR | DEBUG_OUTPUT_VERBOSE));
  1183. }
  1184. hr = GetObjectAddress(Client, index, &DCAddr, DC_TYPE, FALSE, FALSE);
  1185. // Restore mask
  1186. if (hrMask == S_OK &&
  1187. OutputMask & (DEBUG_OUTPUT_ERROR | DEBUG_OUTPUT_VERBOSE))
  1188. {
  1189. Client->SetOutputMask(OutputMask);
  1190. }
  1191. if (hr != S_OK || DCAddr == 0) continue;
  1192. OutCtl.Output(" 0x%p ", DCAddr);
  1193. OutFilter.DiscardOutput();
  1194. hr = TypeReader.OutputVirtual(Module, TypeId, DCAddr,
  1195. DEBUG_OUTTYPE_NO_OFFSET |
  1196. DEBUG_OUTTYPE_COMPACT_OUTPUT);
  1197. if (hr == S_OK)
  1198. {
  1199. if (DumpBaseObject || DumpUserFields)
  1200. {
  1201. OutCtlToFilter.Output(" \t");
  1202. TypeReader.SelectMarks(1);
  1203. TypeReader.OutputVirtual(Module, TypeId, DCAddr,
  1204. DEBUG_OUTTYPE_NO_OFFSET |
  1205. DEBUG_OUTTYPE_COMPACT_OUTPUT);
  1206. TypeReader.SelectMarks(0);
  1207. }
  1208. OutFilter.OutputText(&OutCtl, DEBUG_OUTPUT_NORMAL);
  1209. OutCtl.Output("\n");
  1210. }
  1211. else
  1212. {
  1213. OutCtl.Output("0x????%4.4I64x ** failed to read DC **\n", index);
  1214. }
  1215. }
  1216. }
  1217. if (MemberList != NULL)
  1218. {
  1219. HeapFree(GetProcessHeap(), 0, MemberList);
  1220. }
  1221. }
  1222. else
  1223. {
  1224. OutCtl.OutErr(" Output state/control setup returned %s.\n",
  1225. pszHRESULT(hr));
  1226. }
  1227. return S_OK;
  1228. }