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.

981 lines
30 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: debug.c
  3. *
  4. * This file is for debugging tools and extensions.
  5. *
  6. * Created: 22-Dec-1991
  7. * Author: John Colleran
  8. *
  9. * Copyright (c) 1990 Microsoft Corporation
  10. \**************************************************************************/
  11. #if defined(_X86_)
  12. #define FASTCALL __fastcall
  13. #else
  14. #define FASTCALL
  15. #endif
  16. #include <nt.h>
  17. #include <ntrtl.h>
  18. #include <nturtl.h>
  19. #include <stddef.h>
  20. #include <windows.h>
  21. #include <winspool.h>
  22. #include <limits.h>
  23. #include <string.h>
  24. #include <nlsconv.h>
  25. #include <wingdip.h>
  26. #include "winddi.h"
  27. #include "firewall.h"
  28. #include "ntgdistr.h"
  29. #include "ntgdi.h"
  30. #include "xfflags.h"
  31. #include "hmgshare.h"
  32. #include "local.h"
  33. #include "metarec.h"
  34. #include "mfrec16.h"
  35. #include "metadef.h"
  36. #include "font.h"
  37. #include <excpt.h>
  38. #include <ntstatus.h>
  39. #include <wdbgexts.h>
  40. #include <ntsdexts.h>
  41. #define NOEXTAPI
  42. #include <dbgext.h>
  43. #include <ntcsrmsg.h>
  44. /**************************************************************************\
  45. *
  46. \**************************************************************************/
  47. typedef struct _FLAGDEF {
  48. char *psz; // description
  49. FLONG fl; // flag
  50. } FLAGDEF;
  51. FLAGDEF afdLDC_FL[] = {
  52. { "LDC_SAP_CALLBACK ", LDC_SAP_CALLBACK },
  53. { "LDC_DOC_STARTED ", LDC_DOC_STARTED },
  54. { "LDC_PAGE_STARTED ", LDC_PAGE_STARTED },
  55. { "LDC_CALL_STARTPAGE ", LDC_CALL_STARTPAGE },
  56. { "LDC_NEXTBAND ", LDC_NEXTBAND },
  57. { "LDC_EMPTYBAND ", LDC_EMPTYBAND },
  58. { "LDC_META_ARCDIR_CLOCKWISE ", LDC_META_ARCDIR_CLOCKWISE },
  59. { "LDC_FONT_CHANGE ", LDC_FONT_CHANGE },
  60. { "LDC_DOC_CANCELLED ", LDC_DOC_CANCELLED },
  61. { "LDC_META_PRINT ", LDC_META_PRINT },
  62. { "LDC_PRINT_DIRECT ", LDC_PRINT_DIRECT },
  63. { "LDC_BANDING ", LDC_BANDING },
  64. { "LDC_DOWNLOAD_FONTS ", LDC_DOWNLOAD_FONTS },
  65. { "LDC_RESETDC_CALLED ", LDC_RESETDC_CALLED },
  66. { "LDC_FORCE_MAPPING ", LDC_FORCE_MAPPING },
  67. { "LDC_INFO ", LDC_INFO },
  68. { "NULL ", 0 },
  69. };
  70. FLAGDEF afdDirty[] = {
  71. { "DIRTY_FILL ", DIRTY_FILL },
  72. { "DIRTY_LINE ", DIRTY_LINE },
  73. { "DIRTY_TEXT ", DIRTY_TEXT },
  74. { "DIRTY_BACKGROUND ", DIRTY_BACKGROUND },
  75. { "DIRTY_CHARSET ", DIRTY_CHARSET },
  76. { "SLOW_WIDTHS ", SLOW_WIDTHS },
  77. { "DC_CACHED_TM_VALID ", DC_CACHED_TM_VALID },
  78. { "DISPLAY_DC ", DISPLAY_DC },
  79. { "DIRTY_PTLCURRENT ", DIRTY_PTLCURRENT },
  80. { "DIRTY_PTFXCURRENT ", DIRTY_PTFXCURRENT },
  81. { "DIRTY_STYLESTATE ", DIRTY_STYLESTATE },
  82. { "DC_PLAYMETAFILE ", DC_PLAYMETAFILE },
  83. { "DC_BRUSH_DIRTY ", DC_BRUSH_DIRTY },
  84. { "DC_DIBSECTION ", DC_DIBSECTION },
  85. { "DC_LAST_CLIPRGN_VALID ", DC_LAST_CLIPRGN_VALID },
  86. { 0, 0 }
  87. };
  88. FLAGDEF afdIcmMode[] = {
  89. { "ICM_ON ", ICM_ON },
  90. { "ICM_OFF ", ICM_OFF },
  91. { 0, 0 }
  92. };
  93. FLAGDEF afdBrushAttr[] = {
  94. { "ATTR_CACHED ", ATTR_CACHED },
  95. { "ATTR_TO_BE_DELETED ", ATTR_TO_BE_DELETED },
  96. { "ATTR_NEW_COLOR ", ATTR_NEW_COLOR },
  97. { "ATTR_CANT_SELECT ", ATTR_CANT_SELECT },
  98. { 0, 0 }
  99. };
  100. #define PRINT_FLAGS(ulIn,sSpace,afd) \
  101. { \
  102. ULONG ul = ulIn; \
  103. FLAGDEF *pfd; \
  104. \
  105. for (pfd=afd; pfd->psz; pfd++) \
  106. if (ul & pfd->fl) \
  107. Print(" %s%s\n",sSpace, pfd->psz); \
  108. }
  109. char *pszMapMode(long l)
  110. {
  111. char *psz;
  112. switch (l) {
  113. case MM_TEXT : psz = "MM_TEXT" ; break;
  114. case MM_LOMETRIC : psz = "MM_LOMETRIC" ; break;
  115. case MM_HIMETRIC : psz = "MM_HIMETRIC" ; break;
  116. case MM_LOENGLISH : psz = "MM_LOENGLISH" ; break;
  117. case MM_HIENGLISH : psz = "MM_HIENGLISH" ; break;
  118. case MM_TWIPS : psz = "MM_TWIPS" ; break;
  119. case MM_ISOTROPIC : psz = "MM_ISOTROPIC" ; break;
  120. case MM_ANISOTROPIC: psz = "MM_ANISOTROPIC"; break;
  121. default : psz = "MM_?" ; break;
  122. }
  123. return( psz );
  124. }
  125. char *pszBkMode(long l)
  126. {
  127. char *psz;
  128. switch (l)
  129. {
  130. case TRANSPARENT: psz = "TRANSPARENT"; break;
  131. case OPAQUE : psz = "OPAQUE" ; break;
  132. default : psz = "BKMODE_?" ; break;
  133. }
  134. return( psz );
  135. }
  136. char *pszObjType(HOBJ h)
  137. {
  138. char *psz;
  139. switch (LO_TYPE(h))
  140. {
  141. case LO_BRUSH_TYPE : psz = "BRUSH "; break;
  142. case LO_DC_TYPE : psz = "DC "; break;
  143. case LO_BITMAP_TYPE : psz = "BITMAP "; break;
  144. case LO_PALETTE_TYPE : psz = "PALETTE "; break;
  145. case LO_FONT_TYPE : psz = "FONT "; break;
  146. case LO_REGION_TYPE : psz = "REGION "; break;
  147. case LO_CLIENTOBJ_TYPE : psz = "CLIENTOBJ "; break;
  148. case LO_ALTDC_TYPE : psz = "ALTDC "; break;
  149. case LO_PEN_TYPE : psz = "PEN "; break;
  150. case LO_EXTPEN_TYPE : psz = "EXTPEN "; break;
  151. case LO_DIBSECTION_TYPE: psz = "DIBSECTION"; break;
  152. case LO_METAFILE16_TYPE: psz = "METAFILE16"; break;
  153. case LO_METAFILE_TYPE : psz = "METAFILE "; break;
  154. case LO_METADC16_TYPE : psz = "METADC16 "; break;
  155. default:
  156. switch (GRE_TYPE(h))
  157. {
  158. case DEF_TYPE : psz = "DEF "; break;
  159. case DC_TYPE : psz = "DC "; break;
  160. case DD_DIRECTDRAW_TYPE: psz = "DD_DIRECTDRAW"; break;
  161. case DD_SURFACE_TYPE : psz = "DD_SURFACE "; break;
  162. case RGN_TYPE : psz = "RGN "; break;
  163. case SURF_TYPE : psz = "SURF "; break;
  164. case CLIENTOBJ_TYPE : psz = "CLIENTOBJ "; break;
  165. case PATH_TYPE : psz = "PATH "; break;
  166. case PAL_TYPE : psz = "PAL "; break;
  167. case ICMLCS_TYPE : psz = "ICMLCS "; break;
  168. case LFONT_TYPE : psz = "LFONT "; break;
  169. case RFONT_TYPE : psz = "RFONT "; break;
  170. case PFE_TYPE : psz = "PFE "; break;
  171. case PFT_TYPE : psz = "PFT "; break;
  172. case ICMCXF_TYPE : psz = "ICMCXF "; break;
  173. case ICMDLL_TYPE : psz = "ICMDLL "; break;
  174. case BRUSH_TYPE : psz = "BRUSH "; break;
  175. case PFF_TYPE : psz = "PFF "; break;
  176. case CACHE_TYPE : psz = "CACHE "; break;
  177. case SPACE_TYPE : psz = "SPACE "; break;
  178. case META_TYPE : psz = "META "; break;
  179. case EFSTATE_TYPE : psz = "EFSTATE "; break;
  180. case BMFD_TYPE : psz = "BMFD "; break;
  181. case VTFD_TYPE : psz = "VTFD "; break;
  182. case TTFD_TYPE : psz = "TTFD "; break;
  183. case RC_TYPE : psz = "RC "; break;
  184. case TEMP_TYPE : psz = "TEMP "; break;
  185. case DRVOBJ_TYPE : psz = "DRVOBJ "; break;
  186. case DCIOBJ_TYPE : psz = "DCIOBJ "; break;
  187. case SPOOL_TYPE : psz = "SPOOL "; break;
  188. default : psz = "unknown "; break;
  189. }
  190. }
  191. return( psz );
  192. }
  193. /******************************Public*Routine******************************\
  194. *
  195. * History:
  196. * 03-Nov-1993 -by- Eric Kutter [erick]
  197. * Wrote it.
  198. \**************************************************************************/
  199. char *gaszHelpCli[] = {
  200. "=======================================================================\n"
  201. ,"GDIEXTS client debugger extentions:\n"
  202. ,"-----------------------------------------------------------------------\n"
  203. ,"dh [object handle] -- dump HMGR entry of handle\n"
  204. ,"ddc [DC handle] -- dump DC obj (ddc -? for more info)\n"
  205. ,"hbr [brush handle] -- dump DC brush object\n"
  206. ,"dcfont -- dumps all logfont/cfontsinfo\n"
  207. ,"dcache -- dump client side object cache info\n"
  208. ,"\n"
  209. ,"use gdikdx.dll extensions for kernel debuging\n"
  210. ,"=======================================================================\n"
  211. ,NULL
  212. };
  213. VOID
  214. help(
  215. HANDLE hCurrentProcess,
  216. HANDLE hCurrentThread,
  217. DWORD dwCurrentPc,
  218. PWINDBG_EXTENSION_APIS lpExtensionApis,
  219. LPSTR lpArgumentString
  220. )
  221. {
  222. PNTSD_OUTPUT_ROUTINE Print;
  223. char **ppsz = gaszHelpCli;
  224. // Avoid warnings.
  225. hCurrentProcess = hCurrentProcess;
  226. hCurrentThread = hCurrentThread;
  227. dwCurrentPc = dwCurrentPc;
  228. lpArgumentString = lpArgumentString;
  229. Print = lpExtensionApis->lpOutputRoutine;
  230. // The help info is formatted as a doubly NULL-terminated array of strings.
  231. // So, until we hit the NULL, print each string.
  232. while (*ppsz)
  233. Print(*ppsz++);
  234. }
  235. /******************************Public*Routine******************************\
  236. * dumphandle
  237. *
  238. * Dumps the contents of a GDI client handle
  239. *
  240. * History:
  241. * 23-Dec-1991 -by- John Colleran
  242. * Wrote it.
  243. \**************************************************************************/
  244. void dh(
  245. HANDLE hCurrentProcess,
  246. HANDLE hCurrentThread,
  247. DWORD dwCurrentPc,
  248. PWINDBG_EXTENSION_APIS lpExtensionApis,
  249. LPSTR lpArgumentString)
  250. {
  251. PNTSD_OUTPUT_ROUTINE Print;
  252. PNTSD_GET_EXPRESSION EvalExpression;
  253. PNTSD_GET_SYMBOL GetSymbol;
  254. PENTRY pent;
  255. DWORD ho;
  256. ENTRY ent; // copy of handle entry
  257. ULONG ulTemp;
  258. // eliminate warnings
  259. hCurrentThread = hCurrentThread;
  260. dwCurrentPc = dwCurrentPc;
  261. lpArgumentString = lpArgumentString;
  262. // set up function pointers
  263. Print = lpExtensionApis->lpOutputRoutine;
  264. EvalExpression = lpExtensionApis->lpGetExpressionRoutine;
  265. GetSymbol = lpExtensionApis->lpGetSymbolRoutine;
  266. // do some real work
  267. ho = (ULONG)EvalExpression(lpArgumentString);
  268. GetValue(pent,"&gdi32!pGdiSharedHandleTable");
  269. pent += HANDLE_TO_INDEX(ho);
  270. move(ent,pent);
  271. // just incase they just gave us the index
  272. ho = MAKE_HMGR_HANDLE(HANDLE_TO_INDEX(ho),ent.FullUnique);
  273. // Print the entry.
  274. Print("--------------------------------------------------\n");
  275. Print("Entry from ghmgr for handle 0x%08lx, pent = %lx\n", ho,pent);
  276. Print(" objt = 0x%x, %s\n" , ent.Objt,pszObjType(ho));
  277. Print(" puser = 0x%x\n" , ent.pUser);
  278. Print(" ObjectOwner = 0x%08lx\n" , ent.ObjectOwner.ulObj);
  279. Print(" pidOwner = 0x%x\n" , ent.ObjectOwner.Share.Pid);
  280. Print(" usUnique = 0x%hx\n" , ent.FullUnique);
  281. Print(" pobj krnl = 0x%08lx\n" , ent.einfo.pobj);
  282. Print(" ShareCount = 0x%x\n" , ent.ObjectOwner.Share.Count);
  283. Print(" lock = %s\n" , ent.ObjectOwner.Share.Lock ? "LOCKED" : "UNLOCKED");
  284. Print(" fsHmgr = 0x%hx\n" , ent.Flags);
  285. Print("--------------------------------------------------\n");
  286. }
  287. /******************************Public*Routine******************************\
  288. * dcfonts
  289. *
  290. * Dumps the contents of a GDI client handle
  291. *
  292. * History:
  293. * 23-Dec-1991 -by- John Colleran
  294. * Wrote it.
  295. \**************************************************************************/
  296. void dcfont(
  297. HANDLE hCurrentProcess,
  298. HANDLE hCurrentThread,
  299. DWORD dwCurrentPc,
  300. PWINDBG_EXTENSION_APIS lpExtensionApis,
  301. LPSTR lpArgumentString)
  302. {
  303. PNTSD_OUTPUT_ROUTINE Print;
  304. PNTSD_GET_EXPRESSION EvalExpression;
  305. PNTSD_GET_SYMBOL GetSymbol;
  306. int i;
  307. PENTRY pent;
  308. ENTRY ent;
  309. ULONG pid;
  310. ULONG h;
  311. ULONG ho;
  312. // eliminate warnings
  313. hCurrentThread = hCurrentThread;
  314. dwCurrentPc = dwCurrentPc;
  315. lpArgumentString = lpArgumentString;
  316. // set up function pointers
  317. Print = lpExtensionApis->lpOutputRoutine;
  318. EvalExpression = lpExtensionApis->lpGetExpressionRoutine;
  319. GetSymbol = lpExtensionApis->lpGetSymbolRoutine;
  320. // do some real work
  321. GetValue(pent,"&gdi32!pGdiSharedHandleTable");
  322. GetValue(pid,"&gdi32!gW32PID");
  323. ho = (ULONG)EvalExpression(lpArgumentString);
  324. i = 0;
  325. if (ho)
  326. i = HANDLE_TO_INDEX(ho);
  327. Print("pent = %lx, pid = %lx, lf type = %lx\n",pent,pid,LFONT_TYPE);
  328. for (;i < 1000/*MAX_HANDLE_COUNT*/; ++i)
  329. {
  330. move(ent,pent+i);
  331. if ((ent.Objt == LFONT_TYPE) &&
  332. ((ent.ObjectOwner.Share.Pid == pid) || ho))
  333. {
  334. LOCALFONT lf;
  335. h = MAKE_HMGR_HANDLE(i,ent.FullUnique);
  336. Print("\n");
  337. Print("%3lx: h = %lx, puser = %lx, owner = %lx\n",i,h,ent.pUser,ent.ObjectOwner.Share.Pid);
  338. if (ent.pUser)
  339. {
  340. CFONT cf;
  341. PCFONT pcf;
  342. move(lf,ent.pUser);
  343. for (pcf = lf.pcf; pcf; pcf = cf.pcfNext)
  344. {
  345. move(cf,pcf);
  346. Print(" pcf = 0x%lx, fl = 0x%lx, lHeight = %d\n",
  347. pcf,cf.fl,cf.lHeight);
  348. Print(" efm11 = 0x%08lx, efm22 = 0x%08lx, hdc = 0x%08lx\n",
  349. lEfToF(cf.efM11),lEfToF(cf.efM22),cf.hdc);
  350. }
  351. }
  352. }
  353. if (ho)
  354. break;
  355. }
  356. }
  357. /******************************Public*Routine******************************\
  358. *
  359. * History:
  360. * 10-Apr-1993 -by- Eric Kutter [erick]
  361. * Wrote it.
  362. \**************************************************************************/
  363. void ddc(
  364. HANDLE hCurrentProcess,
  365. HANDLE hCurrentThread,
  366. DWORD dwCurrentPc,
  367. PWINDBG_EXTENSION_APIS lpExtensionApis,
  368. LPSTR lpArgumentString)
  369. {
  370. PNTSD_OUTPUT_ROUTINE Print;
  371. PNTSD_GET_EXPRESSION EvalExpression;
  372. PNTSD_GET_SYMBOL GetSymbol;
  373. PENTRY pent;
  374. DWORD ho;
  375. ENTRY ent; // copy of handle entry
  376. ULONG ulTemp;
  377. BOOL bVerbose = FALSE;
  378. BOOL bLDC = FALSE;
  379. // eliminate warnings
  380. hCurrentThread = hCurrentThread;
  381. dwCurrentPc = dwCurrentPc;
  382. lpArgumentString = lpArgumentString;
  383. // set up function pointers
  384. Print = lpExtensionApis->lpOutputRoutine;
  385. EvalExpression = lpExtensionApis->lpGetExpressionRoutine;
  386. GetSymbol = lpExtensionApis->lpGetSymbolRoutine;
  387. if (*lpArgumentString == '-')
  388. {
  389. char chOpt;
  390. do {
  391. chOpt = *(++lpArgumentString);
  392. switch (chOpt) {
  393. case 'v':
  394. case 'V':
  395. bVerbose = TRUE;
  396. break;
  397. case 'L':
  398. case 'l':
  399. bLDC = TRUE;
  400. break;
  401. }
  402. } while ((chOpt != ' ') && (chOpt != '\0'));
  403. }
  404. // do some real work
  405. ho = (ULONG)EvalExpression(lpArgumentString);
  406. GetValue(pent,"&gdi32!pGdiSharedHandleTable");
  407. pent += HANDLE_TO_INDEX(ho);
  408. move(ent,pent);
  409. // now get the dcAttr
  410. Print("DC dump for handle %lx, pUser = %lx\n",ho,ent.pUser);
  411. if (ent.pUser != NULL)
  412. {
  413. DC_ATTR dca;
  414. move(dca,ent.pUser);
  415. Print(" objt = 0x%x\n" , ent.Objt);
  416. Print(" pldc = 0x%x\n" , dca.pvLDC);
  417. Print(" ulDirty_ = 0x%08x\n" , dca.ulDirty_);
  418. PRINT_FLAGS(dca.ulDirty_," ",afdDirty);
  419. Print(" hbrush = 0x%08x\n" , dca.hbrush);
  420. Print(" hpen = 0x%08x\n" , dca.hpen);
  421. Print(" hfont = 0x%08x\n" , dca.hlfntNew);
  422. Print(" bkColor = 0x%x, (0x%x)\n", dca.crBackgroundClr,dca.ulBackgroundClr);
  423. Print(" foreColor = 0x%x, (0x%x)\n", dca.crForegroundClr,dca.ulForegroundClr);
  424. Print(" lIcmMode = 0x%08lx\n" ,dca.lIcmMode);
  425. PRINT_FLAGS(dca.lIcmMode," ",afdIcmMode);
  426. Print(" hcmXform = 0x%08lx\n" ,dca.hcmXform);
  427. Print(" hColorSpace = 0x%08lx\n" ,dca.hColorSpace);
  428. Print(" pProfile = 0x%08lx\n" ,dca.pProfile);
  429. Print(" hProfile = 0x%08lx\n" ,dca.hProfile);
  430. Print(" IcmBrush = 0x%08lx\n" ,dca.IcmBrushColor);
  431. Print(" IcmPen = 0x%08lx\n" ,dca.IcmPenColor);
  432. if (bVerbose)
  433. {
  434. ULONG ul;
  435. PSZ psz;
  436. // REGION
  437. Print(" REGION\n");
  438. if (dca.VisRectRegion.AttrFlags & ATTR_RGN_VALID)
  439. {
  440. switch (dca.VisRectRegion.Flags)
  441. {
  442. case NULLREGION:
  443. Print(" NULLREGION\n");
  444. break;
  445. SIMPLEREGION;
  446. Print(" SIMPLEREGION, 1rect\n");
  447. Print(" AttrFlags = 0x%x,%s\n",
  448. dca.VisRectRegion.AttrFlags,
  449. (dca.VisRectRegion.AttrFlags & ATTR_RGN_DIRTY) ? "DIRTY" : "CLEAN");
  450. Print(" RECT = 0x%x, 0x%x, 0x%x, 0x%x\n",
  451. dca.VisRectRegion.Rect.left,
  452. dca.VisRectRegion.Rect.top,
  453. dca.VisRectRegion.Rect.right,
  454. dca.VisRectRegion.Rect.bottom);
  455. break;
  456. case COMPLEXREGION:
  457. Print(" COMPLEXREGION\n");
  458. break;
  459. default:
  460. Print(" ERROR in region\n");
  461. break;
  462. }
  463. }
  464. else
  465. {
  466. Print(" invalid cached region\n");
  467. }
  468. Print(" Other attributes\n");
  469. Print(" BkMode = 0x%x, (0x%x)\n", dca.lBkMode,dca.jBkMode);
  470. Print(" FillMode = 0x%x, (0x%x)\n", dca.lFillMode,dca.jFillMode);
  471. Print(" StretchMode = 0x%x, (0x%x)\n", dca.lStretchBltMode,dca.jStretchBltMode);
  472. Print(" PtlCurrent(L)= 0x%x,0x%x\n" , dca.ptlCurrent.x,dca.ptlCurrent.y);
  473. Print(" PtlCurrent(D)= 0x%x,0x%x\n" , dca.ptfxCurrent.x,dca.ptfxCurrent.y);
  474. Print(" ROP2 = 0x%x\n" , dca.jROP2);
  475. Print(" GraphicsMode = 0x%x\n" , dca.iGraphicsMode);
  476. Print(" Text attributes\n");
  477. Print(" code page = 0x%x\n" , dca.iCS_CP);
  478. Print(" flTextAlign = 0x%x\n" , dca.flTextAlign);
  479. Print(" lTextAlign = 0x%x\n" , dca.lTextAlign );
  480. Print(" lTextExtra = 0x%x\n" , dca.lTextExtra );
  481. Print(" lRelAbs = 0x%x\n" , dca.lRelAbs );
  482. Print(" lBreakExtra = 0x%x\n" , dca.lBreakExtra);
  483. Print(" cBreak = 0x%x\n" , dca.cBreak );
  484. Print(" XFORMS\n");
  485. Print(" flXform = 0x%08lx\n", dca.flXform);
  486. Print(" Map Mode = %ld, %s\n", dca.iMapMode, pszMapMode(dca.iMapMode));
  487. Print(" Window Org = (%8ld, %8ld)\n", dca.ptlWindowOrg.x,
  488. dca.ptlWindowOrg.y);
  489. Print(" Window Ext = (%8ld, %8ld)\n", dca.szlWindowExt.cx,
  490. dca.szlWindowExt.cy);
  491. Print(" Viewport Org = (%8ld, %8ld)\n", dca.ptlViewportOrg.x,
  492. dca.ptlViewportOrg.y);
  493. Print(" Viewport Ext = (%8ld, %8ld)\n", dca.szlViewportExt.cx,
  494. dca.szlViewportExt.cy);
  495. Print(" Virtual Pix = (%8ld, %8ld)\n", dca.szlVirtualDevicePixel.cx,
  496. dca.szlVirtualDevicePixel.cy);
  497. Print(" Virtual mm = (%8ld, %8ld)\n", dca.szlVirtualDeviceMm.cx,
  498. dca.szlVirtualDeviceMm.cy);
  499. Print("\tMatrix\n");
  500. Print("\t\tM11 = 0x%08lx\n", lEfToF(dca.mxWtoD.efM11));
  501. Print("\t\tM12 = 0x%08lx\n", lEfToF(dca.mxWtoD.efM12));
  502. Print("\t\tM21 = 0x%08lx\n", lEfToF(dca.mxWtoD.efM21));
  503. Print("\t\tM22 = 0x%08lx\n", lEfToF(dca.mxWtoD.efM22));
  504. Print("\t\tDx = 0x%08lx\n", lEfToF(dca.mxWtoD.efDx));
  505. Print("\t\tDy = 0x%08lx\n", lEfToF(dca.mxWtoD.efDy));
  506. Print("\t\tFDx = 0x%08lx\n", dca.mxWtoD.fxDx);
  507. Print("\t\tFDy = 0x%08lx\n", dca.mxWtoD.fxDy);
  508. }
  509. if (bLDC && dca.pvLDC)
  510. {
  511. LDC ldc;
  512. move(ldc,dca.pvLDC);
  513. Print(" LDC\n");
  514. Print(" hdc = 0x%08x\n" , ldc.hdc);
  515. Print(" fl = 0x%x\n" , ldc.fl);
  516. PRINT_FLAGS(ldc.fl," ",afdLDC_FL);
  517. Print(" iType = 0x%x, %s\n" , ldc.iType, ldc.iType == LO_DC ? "LO_DC" : "LO_METADC");
  518. Print(" PMDC = 0x%x\n" , ldc.pvPMDC);
  519. Print(" pwszPort = %ws\n" , ldc.pwszPort ? ldc.pwszPort : L"NULL");
  520. Print(" pfnAbort = 0x%08x\n" , ldc.pfnAbort);
  521. Print(" hSpooler = 0x%x\n" , ldc.hSpooler);
  522. Print(" pdm = 0x%x\n" , ldc.pDevMode);
  523. Print(" pdm.devname = %ws\n" , ldc.pDevMode ? ldc.pDevMode->dmDeviceName : L"NULL");
  524. }
  525. }
  526. }
  527. /******************************Public*Routine******************************\
  528. *
  529. * History:
  530. * 10-Apr-1993 -by- Eric Kutter [erick]
  531. * Wrote it.
  532. \**************************************************************************/
  533. void hbrush(
  534. HANDLE hCurrentProcess,
  535. HANDLE hCurrentThread,
  536. DWORD dwCurrentPc,
  537. PWINDBG_EXTENSION_APIS lpExtensionApis,
  538. LPSTR lpArgumentString)
  539. {
  540. PNTSD_OUTPUT_ROUTINE Print;
  541. PNTSD_GET_EXPRESSION EvalExpression;
  542. PNTSD_GET_SYMBOL GetSymbol;
  543. PENTRY pent;
  544. DWORD ho;
  545. ENTRY ent; // copy of handle entry
  546. ULONG ulTemp;
  547. BOOL bVerbose = FALSE;
  548. BOOL bLDC = FALSE;
  549. // eliminate warnings
  550. hCurrentThread = hCurrentThread;
  551. dwCurrentPc = dwCurrentPc;
  552. lpArgumentString = lpArgumentString;
  553. // set up function pointers
  554. Print = lpExtensionApis->lpOutputRoutine;
  555. EvalExpression = lpExtensionApis->lpGetExpressionRoutine;
  556. GetSymbol = lpExtensionApis->lpGetSymbolRoutine;
  557. if (*lpArgumentString == '-')
  558. {
  559. char chOpt;
  560. do {
  561. chOpt = *(++lpArgumentString);
  562. switch (chOpt) {
  563. case 'v':
  564. case 'V':
  565. bVerbose = TRUE;
  566. break;
  567. case 'L':
  568. case 'l':
  569. bLDC = TRUE;
  570. break;
  571. }
  572. } while ((chOpt != ' ') && (chOpt != '\0'));
  573. }
  574. // do some real work
  575. ho = (ULONG)EvalExpression(lpArgumentString);
  576. GetValue(pent,"&gdi32!pGdiSharedHandleTable");
  577. pent += HANDLE_TO_INDEX(ho);
  578. move(ent,pent);
  579. // now get the dcAttr
  580. Print("BRUSH dump for handle %lx, pUser = %lx\n",ho,ent.pUser);
  581. if (ent.pUser != NULL)
  582. {
  583. BRUSHATTR bra;
  584. move(bra,ent.pUser);
  585. Print(" objt = 0x%x\n" , ent.Objt);
  586. Print(" AttrFlags = 0x%x, (0x%x)\n", bra.AttrFlags);
  587. PRINT_FLAGS(bra.AttrFlags," ",afdBrushAttr);
  588. Print(" lbColor = 0x%x, (0x%x)\n", bra.lbColor);
  589. }
  590. }
  591. void dcache(
  592. HANDLE hCurrentProcess,
  593. HANDLE hCurrentThread,
  594. DWORD dwCurrentPc,
  595. PWINDBG_EXTENSION_APIS lpExtensionApis,
  596. LPSTR lpArgumentString)
  597. {
  598. PNTSD_OUTPUT_ROUTINE Print;
  599. PNTSD_GET_EXPRESSION EvalExpression;
  600. PNTSD_GET_SYMBOL GetSymbol;
  601. PCFONT pcf;
  602. CFONT cf;
  603. int i;
  604. PGDI_SHARED_MEMORY pshare;
  605. // eliminate warnings
  606. hCurrentThread = hCurrentThread;
  607. dwCurrentPc = dwCurrentPc;
  608. lpArgumentString = lpArgumentString;
  609. // set up function pointers
  610. Print = lpExtensionApis->lpOutputRoutine;
  611. EvalExpression = lpExtensionApis->lpGetExpressionRoutine;
  612. GetSymbol = lpExtensionApis->lpGetSymbolRoutine;
  613. // do some real work
  614. GetValue(pshare,"&gdi32!pGdiSharedMemory");
  615. pcf = pshare->acfPublic;
  616. Print("Public CFONT Table, %lx\n",pcf);
  617. for (i = 0; i < MAX_PUBLIC_CFONT; ++i)
  618. {
  619. move(cf,pcf);
  620. if (cf.hf)
  621. {
  622. Print("%2d: hf = 0x%lx, pcf = 0x%lx, fl = 0x%lx, lHeight = %d\n",
  623. i,cf.hf,pcf,cf.fl,cf.lHeight);
  624. }
  625. cf.hf = 0;
  626. pcf++;
  627. }
  628. }
  629. #if 0
  630. /******************************Public*Routine******************************\
  631. *
  632. * History:
  633. * 10-Apr-1993 -by- Eric Kutter [erick]
  634. * Wrote it.
  635. \**************************************************************************/
  636. void clidumphmgr(
  637. HANDLE hCurrentProcess,
  638. HANDLE hCurrentThread,
  639. DWORD dwCurrentPc,
  640. PWINDBG_EXTENSION_APIS lpExtensionApis,
  641. LPSTR lpArgumentString)
  642. {
  643. PNTSD_OUTPUT_ROUTINE Print;
  644. PNTSD_GET_EXPRESSION EvalExpression;
  645. PNTSD_GET_SYMBOL GetSymbol;
  646. LHE lhe;
  647. LHE *pLocalTable;
  648. ULONG aulCount[LO_LAST];
  649. int i;
  650. int c;
  651. for (i = 0; i < LO_LAST; ++i)
  652. aulCount[i] = 0;
  653. // eliminate warnings
  654. hCurrentThread = hCurrentThread;
  655. dwCurrentPc = dwCurrentPc;
  656. lpArgumentString = lpArgumentString;
  657. // set up function pointers
  658. Print = lpExtensionApis->lpOutputRoutine;
  659. EvalExpression = lpExtensionApis->lpGetExpressionRoutine;
  660. GetSymbol = lpExtensionApis->lpGetSymbolRoutine;
  661. GetValue(c,"&gdi32!cLheCommitted");
  662. Print("cLheCommitted = %ld\n",c);
  663. GetValue(pLocalTable,"&gdi32!pLocalTable");
  664. for (i = 0; i < (int)c; ++i)
  665. {
  666. int iType;
  667. move(lhe,(pLocalTable+i));
  668. iType = lhe.iType & 0x0f;
  669. if (iType < LO_LAST)
  670. aulCount[iType]++;
  671. else
  672. Print("Invalid handle %lx, type = %ld\n",i,lhe.iType);
  673. }
  674. for (i = 0; i < LO_LAST; ++i)
  675. Print("\t%s - %ld\n",aszType[i],aulCount[i]);
  676. return;
  677. }
  678. void clidumpcache(
  679. HANDLE hCurrentProcess,
  680. HANDLE hCurrentThread,
  681. DWORD dwCurrentPc,
  682. PWINDBG_EXTENSION_APIS lpExtensionApis,
  683. LPSTR lpArgumentString)
  684. {
  685. PNTSD_OUTPUT_ROUTINE Print;
  686. PNTSD_GET_EXPRESSION EvalExpression;
  687. PNTSD_GET_SYMBOL GetSymbol;
  688. LDC ldc;
  689. HCACHE hc;
  690. PVOID apv[CACHESIZE];
  691. int i;
  692. BOOL b;
  693. PVOID pv;
  694. PLDC *gapldc;
  695. PHCACHE gaphcBrushes;
  696. PHCACHE gaphcFonts;
  697. // eliminate warnings
  698. hCurrentThread = hCurrentThread;
  699. dwCurrentPc = dwCurrentPc;
  700. lpArgumentString = lpArgumentString;
  701. // set up function pointers
  702. Print = lpExtensionApis->lpOutputRoutine;
  703. EvalExpression = lpExtensionApis->lpGetExpressionRoutine;
  704. GetSymbol = lpExtensionApis->lpGetSymbolRoutine;
  705. // do the dc's
  706. Print("Cached objects - bucket: client handle, client handle, ...\n");
  707. Print("Cached DC's\n");
  708. GetAddress(gapldc,"gdi32!gapldc");
  709. move(apv,gapldc);
  710. for (i = 0; i < CACHESIZE; ++i)
  711. {
  712. b = FALSE;
  713. if (apv[i])
  714. {
  715. if (!b)
  716. {
  717. Print("\t%d: ",i);
  718. b = TRUE;
  719. }
  720. for (pv = apv[i]; pv; pv = ldc.pldcNext)
  721. {
  722. move(ldc,pv);
  723. Print("%x, ",ldc.lhdc);
  724. }
  725. }
  726. if (b)
  727. Print("\n");
  728. }
  729. // do the brushes
  730. Print("Cached Brushes\n");
  731. GetAddress(gaphcBrushes,"gdi32!gaphcBrushes");
  732. move(apv,gaphcBrushes);
  733. for (i = 0; i < CACHESIZE; ++i)
  734. {
  735. b = FALSE;
  736. if (apv[i])
  737. {
  738. if (!b)
  739. {
  740. Print("\t%d: ",i);
  741. b = TRUE;
  742. }
  743. for (pv = apv[i]; pv; pv = hc.phcNext)
  744. {
  745. move(hc,pv);
  746. Print("%x, ",hc.hLocal);
  747. }
  748. }
  749. if (b)
  750. Print("\n");
  751. }
  752. // do the fonts
  753. Print("Cached Fonts\n");
  754. GetAddress(gaphcFonts,"gdi32!gaphcFonts");
  755. move(apv,gaphcFonts);
  756. for (i = 0; i < CACHESIZE; ++i)
  757. {
  758. b = FALSE;
  759. if (apv[i])
  760. {
  761. if (!b)
  762. {
  763. Print("\t%d: ",i);
  764. b = TRUE;
  765. }
  766. for (pv = apv[i]; pv; pv = hc.phcNext)
  767. {
  768. move(hc,pv);
  769. Print("%x, ",hc.hLocal);
  770. }
  771. }
  772. if (b)
  773. Print("\n");
  774. }
  775. return;
  776. }
  777. #endif