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.

896 lines
30 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: ddexts.cxx
  3. *
  4. * Copyright (c) 2000 Microsoft Corporation
  5. *
  6. \**************************************************************************/
  7. #include "precomp.hxx"
  8. /******************************Public*Routine******************************\
  9. * vPrintDDSURFACE
  10. *
  11. * Print out DirectDraw surface contents.
  12. *
  13. * History:
  14. * Apr-09-1996 -by- J. Andrew Goossen andrewgo
  15. * Wrote it.
  16. \**************************************************************************/
  17. #define DDSURFACE_LOCKS 0x00000001
  18. #define DDSURFACE_PUBLIC 0x00000002
  19. #define DDSURFACE_PRIVATE 0x00000004
  20. #define DDSURFACE_DDNEXT 0x00000008
  21. #if ENABLE_OLD_EXTS // DOES NOT SUPPORT API64
  22. VOID
  23. vPrintDDSURFACE(
  24. VOID * pvServer,
  25. FLONG fl
  26. )
  27. {
  28. char eSurface[sizeof(EDD_SURFACE)];
  29. char AttachList[sizeof(DD_ATTACHLIST)];
  30. EDD_SURFACE *peSurface;
  31. ULONG ul;
  32. FLAGDEF *pfd;
  33. PDD_ATTACHLIST pAttach;
  34. Next_Surface:
  35. move2(eSurface, pvServer, sizeof(EDD_SURFACE));
  36. dprintf("EDD_SURFACE structure at 0x%p:\n", pvServer);
  37. peSurface = (EDD_SURFACE *)eSurface;
  38. if (fl & DDSURFACE_PUBLIC)
  39. {
  40. dprintf("--------------------------------------------------\n");
  41. dprintf("PDD_SURFACE_GLOBAL lpGbl 0x%lx\n", peSurface->lpGbl);
  42. dprintf("PDD_SURFACE_MORE lpMore 0x%lx\n", peSurface->lpSurfMore);
  43. ul = peSurface->dwFlags;
  44. dprintf("DWORD dwFlags 0x%lx\n", ul);
  45. //CHECKLOOP
  46. for (pfd = afdDDRAWISURF; pfd->psz; pfd++)
  47. if (ul & pfd->fl)
  48. dprintf("\t\t\t\t%s\n", pfd->psz);
  49. ul = peSurface->ddsCaps.dwCaps;
  50. dprintf("DWORD ddsCaps.dwCaps 0x%lx\n", ul);
  51. //CHECKLOOP
  52. for (pfd = afdDDSCAPS; pfd->psz; pfd++)
  53. if (ul & pfd->fl)
  54. dprintf("\t\t\t\t%s\n", pfd->psz);
  55. ul = peSurface->ddsCapsEx.dwCaps2;
  56. dprintf("DWORD ddsCapsEx.dwCaps2 0x%lx\n", ul);
  57. //CHECKLOOP
  58. for (pfd = afdDDSCAPS2; pfd->psz; pfd++)
  59. if (ul & pfd->fl)
  60. dprintf("\t\t\t\t%s\n", pfd->psz);
  61. dprintf("DWORD dwSurfaceHandle 0x%lx\n", peSurface->dwSurfaceHandle);
  62. dprintf("DDCOLORKEY ddckCKSrcBlt/Overlay 0x%lx:0x%lx\n", peSurface->ddckCKSrcOverlay.dwColorSpaceHighValue,
  63. peSurface->ddckCKSrcOverlay.dwColorSpaceLowValue);
  64. dprintf("DDCOLORKEY ddckCKDestBlt/Overlay 0x%lx:0x%lx\n", peSurface->ddckCKDestOverlay.dwColorSpaceHighValue,
  65. peSurface->ddckCKDestOverlay.dwColorSpaceLowValue);
  66. dprintf("PDD_ATTACHLIST lpAttachList 0x%lx\n", peSurface->lpAttachList);
  67. //CHECKLOOP
  68. for (pAttach = peSurface->lpAttachList;
  69. pAttach != NULL;
  70. pAttach = pAttach->lpLink)
  71. {
  72. move2(AttachList, pAttach, sizeof(DD_ATTACHLIST));
  73. pAttach = (PDD_ATTACHLIST) AttachList;
  74. dprintf(" EDD_SURFACE*\t\t\t0x%lx\n", pedFromLp(pAttach->lpAttached));
  75. if (pAttach->lpLink == pAttach)
  76. {
  77. dprintf(" !!! Endless lpAttachList loop\n");
  78. break;
  79. }
  80. if (CheckControlC())
  81. return;
  82. }
  83. dprintf("PDD_ATTACHLIST lpAttachListFrom 0x%lx\n", peSurface->lpAttachListFrom);
  84. //CHECKLOOP
  85. for (pAttach = peSurface->lpAttachListFrom;
  86. pAttach != NULL;
  87. pAttach = pAttach->lpLink)
  88. {
  89. move2(AttachList, pAttach, sizeof(DD_ATTACHLIST));
  90. pAttach = (PDD_ATTACHLIST) AttachList;
  91. dprintf(" EDD_SURFACE*\t\t\t0x%lx\n", pedFromLp(pAttach->lpAttached));
  92. if (pAttach->lpLink == pAttach)
  93. {
  94. dprintf(" !!! Endless lpAttachListFrom loop\n");
  95. break;
  96. }
  97. if (CheckControlC())
  98. return;
  99. }
  100. dprintf("DWORD dwMipMapCount 0x%lx\n", peSurface->dwMipMapCount);
  101. dprintf("EDD_VIDEOPORT* peVideoPort 0x%lx\n",
  102. peSurface->lpVideoPort != NULL ? pedFromLp(peSurface->lpVideoPort) : 0);
  103. dprintf("HBITMAP hbmGdi 0x%lx\n", peSurface->hbmGdi);
  104. dprintf("DWORD dwOverlayFlags 0x%lx\n", peSurface->dwOverlayFlags);
  105. dprintf("DWORD dwBlockSizeX 0x%lx\n", peSurface->dwBlockSizeX);
  106. dprintf("DWORD dwBlockSizeY 0x%lx\n", peSurface->dwBlockSizeY);
  107. dprintf("FLATPTR fpVidMem 0x%lx\n", peSurface->fpVidMem);
  108. dprintf("LONG lPitch 0x%lx\n", peSurface->lPitch);
  109. dprintf("LONG xHint 0x%lx\n", peSurface->xHint);
  110. dprintf("LONG yHint 0x%lx\n", peSurface->yHint);
  111. dprintf("DWORD wWidth 0x%lx\n", peSurface->wWidth);
  112. dprintf("DWORD wHeight 0x%lx\n", peSurface->wHeight);
  113. dprintf("DWORD (global) dwReserved1 0x%lx\n", peSurface->DD_SURFACE_GLOBAL::dwReserved1);
  114. dprintf("DWORD (local) dwReserved1 0x%lx\n", peSurface->DD_SURFACE_LOCAL::dwReserved1);
  115. dprintf("DDPIXELFORMAT ddpfSurface\n");
  116. dprintf(" DWORD dwSize (should be 0x20) 0x%lx\n", peSurface->ddpfSurface.dwSize);
  117. ul = peSurface->ddpfSurface.dwFlags;
  118. dprintf(" DWORD dwFlags 0x%lx\n", ul);
  119. //CHECKLOOP
  120. for (pfd = afdDDPIXELFORMAT; pfd->psz; pfd++)
  121. if (ul & pfd->fl)
  122. dprintf("\t\t\t\t%s\n", pfd->psz);
  123. dprintf(" DWORD dwFourCC 0x%lx\n", peSurface->ddpfSurface.dwFourCC);
  124. dprintf(" DWORD dwRGB/YUV/ZBuffer/AlphaBitCount 0x%lx\n", peSurface->ddpfSurface.dwRGBBitCount);
  125. dprintf(" DWORD dwRBitMask/dwYBitMask 0x%lx\n", peSurface->ddpfSurface.dwRBitMask);
  126. dprintf(" DWORD dwGBitMask/dwUBitMask 0x%lx\n", peSurface->ddpfSurface.dwGBitMask);
  127. dprintf(" DWORD dwBBitMask/dwVBitMask 0x%lx\n", peSurface->ddpfSurface.dwBBitMask);
  128. dprintf(" DWORD dwRGB/YUVAlphaBitMask 0x%lx\n", peSurface->ddpfSurface.dwRGBAlphaBitMask);
  129. }
  130. if (fl & DDSURFACE_PRIVATE)
  131. {
  132. dprintf("--------------------------------------------------\n");
  133. dprintf("EDD_SURFACE* peSurface_DdNext 0x%lx\n", peSurface->peSurface_DdNext);
  134. dprintf("EDD_SURFACE* peSurface_LockNext 0x%lx\n", peSurface->peSurface_PrimaryLockNext);
  135. dprintf("EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal 0x%lx\n", peSurface->peDirectDrawGlobal);
  136. dprintf("EDD_DIRECTDRAW_LOCAL* peDirectDrawLocal 0x%lx\n", peSurface->peDirectDrawLocal);
  137. ul = peSurface->fl;
  138. dprintf("FLONG fl 0x%lx\n", ul);
  139. //CHECKLOOP
  140. for (pfd = afdDDSURFACEFL; pfd->psz; pfd++)
  141. if (ul & pfd->fl)
  142. dprintf("\t\t\t\t%s\n", pfd->psz);
  143. dprintf("ULONG iVisRgnUniqueness 0x%lx\n", peSurface->iVisRgnUniqueness);
  144. dprintf("BOOL bLost %s\n",
  145. peSurface->bLost ? "TRUE" : "FALSE");
  146. dprintf("HANDLE hSecure 0x%lx\n", peSurface->hSecure);
  147. dprintf("ERECTL rclLock: (%li, %li, %li, %li)\n",
  148. peSurface->rclLock.left, peSurface->rclLock.top,
  149. peSurface->rclLock.right, peSurface->rclLock.bottom);
  150. }
  151. if (fl & DDSURFACE_LOCKS)
  152. {
  153. dprintf("--------------------------------------------------\n");
  154. dprintf("ULONG cLocks 0x%lx\n", peSurface->cLocks);
  155. dprintf("HDC hdc 0x%lx\n", peSurface->hdc);
  156. }
  157. if (fl & DDSURFACE_DDNEXT)
  158. {
  159. if (CheckControlC())
  160. return;
  161. pvServer = peSurface->peSurface_DdNext;
  162. if (pvServer != NULL)
  163. goto Next_Surface;
  164. }
  165. }
  166. #endif // DOES NOT SUPPORT API64
  167. /******************************Public*Routine******************************\
  168. * DECLARE_API( dddsurface )
  169. *
  170. * Dumps a DirectDraw surface structure.
  171. *
  172. \**************************************************************************/
  173. DECLARE_API( dddsurface )
  174. {
  175. dprintf("Extension 'dddsurface' is not converted.\n");
  176. #if ENABLE_OLD_EXTS // DOES NOT SUPPORT API64
  177. FLONG fl = 0;
  178. ULONG_PTR ddsurface;
  179. PARSE_ARGUMENTS(dddsurface_help);
  180. if(ntok<1) { goto dddsurface_help; }
  181. if(parse_iFindSwitch(tokens, ntok, 'h')!=-1) { goto dddsurface_help; }
  182. if(parse_iFindSwitch(tokens, ntok, 'a')!=-1) {
  183. fl |= (DDSURFACE_PRIVATE | DDSURFACE_PUBLIC | DDSURFACE_LOCKS);
  184. }
  185. if(parse_iFindSwitch(tokens, ntok, 'r')!=-1) { fl |= DDSURFACE_PRIVATE; }
  186. if(parse_iFindSwitch(tokens, ntok, 'u')!=-1) { fl |= DDSURFACE_PUBLIC; }
  187. if(parse_iFindSwitch(tokens, ntok, 'l')!=-1) { fl |= DDSURFACE_LOCKS; }
  188. if(parse_iFindSwitch(tokens, ntok, 'n')!=-1) { fl |= DDSURFACE_DDNEXT; }
  189. tok_pos = parse_FindNonSwitch(tokens, ntok);
  190. if(tok_pos==-1) { goto dddsurface_help; }
  191. ddsurface = GetExpression(tokens[tok_pos]);
  192. if (fl == 0) {
  193. fl |= (DDSURFACE_PRIVATE | DDSURFACE_PUBLIC | DDSURFACE_LOCKS);
  194. }
  195. vPrintDDSURFACE((PVOID)ddsurface, fl);
  196. return;
  197. dddsurface_help:
  198. dprintf("Usage: dddsurface [-?haruln] ddsurface");
  199. dprintf(" a - all info\n");
  200. dprintf(" r - private info\n");
  201. dprintf(" u - public info\n");
  202. dprintf(" l - locks\n");
  203. dprintf(" n - all surfaces in DdNext link\n");
  204. #endif // DOES NOT SUPPORT API64
  205. EXIT_API(S_OK);
  206. }
  207. /******************************Public*Routine******************************\
  208. * vPrintDDLOCAL
  209. *
  210. * Print out DirectDraw local object contents.
  211. *
  212. * History:
  213. * Apr-09-1996 -by- J. Andrew Goossen andrewgo
  214. * Wrote it.
  215. \**************************************************************************/
  216. #if ENABLE_OLD_EXTS // DOES NOT SUPPORT API64
  217. VOID
  218. vPrintDDLOCAL(
  219. VOID * pvServer,
  220. FLONG fl
  221. )
  222. {
  223. char pbr[sizeof(EDD_DIRECTDRAW_LOCAL)];
  224. EDD_DIRECTDRAW_LOCAL * peDirectDrawLocal;
  225. move2(pbr, pvServer, sizeof(EDD_DIRECTDRAW_LOCAL));
  226. dprintf("EDD_DIRECTDRAW_LOCAL structure at 0x%p:\n",pvServer);
  227. peDirectDrawLocal = (EDD_DIRECTDRAW_LOCAL *)pbr;
  228. dprintf("--------------------------------------------------\n");
  229. dprintf("FLATPTR fpProcess 0x%lx\n", peDirectDrawLocal->fpProcess);
  230. dprintf("--------------------------------------------------\n");
  231. dprintf("EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal 0x%lx\n", peDirectDrawLocal->peDirectDrawGlobal);
  232. dprintf("EDD_SURFACE* peSurface_DdList 0x%lx\n", peDirectDrawLocal->peSurface_DdList);
  233. dprintf("EDD_DIRECTDRAW_LOCAL* peDirectDrawLocalNext 0x%lx\n", peDirectDrawLocal->peDirectDrawLocalNext);
  234. dprintf("FLONG fl 0x%lx\n", peDirectDrawLocal->fl);
  235. dprintf("HANDLE UniqueProcess 0x%lx\n", peDirectDrawLocal->UniqueProcess);
  236. dprintf("PEPROCESS Process 0x%lx\n", peDirectDrawLocal->Process);
  237. }
  238. #endif // DOES NOT SUPPORT API64
  239. /******************************Public*Routine******************************\
  240. * DECLARE_API( dddlocal )
  241. *
  242. \**************************************************************************/
  243. DECLARE_API( dddlocal )
  244. {
  245. dprintf("Extension 'dddlocal' is not converted.\n");
  246. #if ENABLE_OLD_EXTS // DOES NOT SUPPORT API64
  247. FLONG fl = 0;
  248. ULONG_PTR ddlocal;
  249. PARSE_ARGUMENTS(dddlocal_help);
  250. if(ntok<1) { goto dddlocal_help; }
  251. if(parse_iFindSwitch(tokens, ntok, 'h')!=-1) { goto dddlocal_help; }
  252. if(parse_iFindSwitch(tokens, ntok, 'a')!=-1) { fl |= 0; }
  253. tok_pos = parse_FindNonSwitch(tokens, ntok);
  254. if(tok_pos==-1) { goto dddlocal_help; }
  255. ddlocal = GetExpression(tokens[tok_pos]);
  256. vPrintDDLOCAL((PVOID)ddlocal, fl);
  257. return;
  258. dddlocal_help:
  259. dprintf("dddlocal [-?] [-h] [-a]\n\n");
  260. dprintf(" a - all info\n");
  261. #endif // DOES NOT SUPPORT API64
  262. EXIT_API(S_OK);
  263. }
  264. /******************************Public*Routine******************************\
  265. * vPrintDDGLOBAL
  266. *
  267. * Print out DirectDraw global object contents.
  268. *
  269. * History:
  270. * Apr-09-1996 -by- J. Andrew Goossen andrewgo
  271. * Wrote it.
  272. \**************************************************************************/
  273. #if ENABLE_OLD_EXTS // DOES NOT SUPPORT API64
  274. VOID
  275. vPrintDDGLOBAL(
  276. VOID * pvServer,
  277. FLONG fl
  278. )
  279. {
  280. char pbr[sizeof(EDD_DIRECTDRAW_GLOBAL) + 100];
  281. EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal;
  282. move2(pbr, pvServer, sizeof(EDD_DIRECTDRAW_GLOBAL));
  283. dprintf("EDD_DIRECTDRAW_GLOBAL structure at 0x%p:\n", pvServer);
  284. peDirectDrawGlobal = (EDD_DIRECTDRAW_GLOBAL *)pbr;
  285. dprintf("--------------------------------------------------\n");
  286. dprintf("VOID* dhpdev 0x%lx\n", peDirectDrawGlobal->dhpdev);
  287. dprintf("DWORD dwReserved1 0x%lx\n", peDirectDrawGlobal->dwReserved1);
  288. dprintf("DWORD dwReserved2 0x%lx\n", peDirectDrawGlobal->dwReserved2);
  289. dprintf("EDD_DIRECTDRAW_LOCAL* peDirectDrawLocalList 0x%lx\n", peDirectDrawGlobal->peDirectDrawLocalList);
  290. dprintf("EDD_SURFACE* peSurface_LockList 0x%lx\n", peDirectDrawGlobal->peSurface_PrimaryLockList);
  291. dprintf("FLONG fl 0x%lx\n", peDirectDrawGlobal->fl);
  292. dprintf("ULONG cSurfaceLocks 0x%lx\n", peDirectDrawGlobal->cSurfaceLocks);
  293. dprintf("ULONG cSurfaceAliasedLocks 0x%lx\n", peDirectDrawGlobal->cSurfaceAliasedLocks);
  294. dprintf("PKEVENT pAssertModeEvent 0x%lx\n", peDirectDrawGlobal->pAssertModeEvent);
  295. dprintf("LONGLONG llAssertModeTimeout 0x%lx\n", (DWORD) peDirectDrawGlobal->llAssertModeTimeout);
  296. dprintf("EDD_SURFACE* peSurfaceCurrent 0x%lx\n", peDirectDrawGlobal->peSurfaceCurrent);
  297. dprintf("EDD_SURFACE* peSurfacePrimary 0x%lx\n", peDirectDrawGlobal->peSurfacePrimary);
  298. dprintf("BOOL bSuspended 0x%lx\n", peDirectDrawGlobal->bSuspended);
  299. dprintf("HDEV hdev 0x%lx\n", peDirectDrawGlobal->hdev);
  300. dprintf("LONG cDriverReferences 0x%lx\n", peDirectDrawGlobal->cDriverReferences);
  301. dprintf("DWORD dwNumHeaps 0x%lx\n", peDirectDrawGlobal->dwNumHeaps);
  302. dprintf("VIDEOMEMORY* pvmList 0x%lx\n", peDirectDrawGlobal->pvmList);
  303. dprintf("DWORD dwNumFourCC 0x%lx\n", peDirectDrawGlobal->dwNumFourCC);
  304. dprintf("DWORD* pdwFourCC 0x%lx\n", peDirectDrawGlobal->pdwFourCC);
  305. dprintf("DD_HALINFO HalInfo\n");
  306. dprintf("DD_CALLBACKS CallBacks\n");
  307. dprintf("DD_SURFACECALLBACKS SurfaceCallBacks\n");
  308. dprintf("DD_PALETTECALLBACKS PaletteCallBacks\n");
  309. dprintf("RECTL rclBounds (%ld, %ld), (%ld, %ld)\n",
  310. peDirectDrawGlobal->rclBounds.left, peDirectDrawGlobal->rclBounds.top,
  311. peDirectDrawGlobal->rclBounds.right, peDirectDrawGlobal->rclBounds.bottom);
  312. }
  313. #endif // DOES NOT SUPPORT API64
  314. /******************************Public*Routine******************************\
  315. * DECLARE_API( dddglobal )
  316. *
  317. \**************************************************************************/
  318. DECLARE_API( dddglobal )
  319. {
  320. dprintf("Extension 'dddglobal' is not converted.\n");
  321. #if ENABLE_OLD_EXTS // DOES NOT SUPPORT API64
  322. FLONG fl = 0;
  323. ULONG_PTR ddglobal;
  324. PARSE_ARGUMENTS(dddglobal_help);
  325. if(ntok<1) { goto dddglobal_help; }
  326. if(parse_iFindSwitch(tokens, ntok, 'h')!=-1) { goto dddglobal_help; }
  327. if(parse_iFindSwitch(tokens, ntok, 'a')!=-1) { fl |= 0; }
  328. tok_pos = parse_FindNonSwitch(tokens, ntok);
  329. if(tok_pos==-1) { goto dddglobal_help; }
  330. ddglobal = GetExpression(tokens[tok_pos]);
  331. vPrintDDGLOBAL((PVOID)ddglobal, fl);
  332. return;
  333. dddglobal_help:
  334. dprintf("dddglobal [-?] [-h] [-a]\n\n");
  335. dprintf(" a - all info\n");
  336. #endif // DOES NOT SUPPORT API64
  337. EXIT_API(S_OK);
  338. }
  339. char *pszDdTypes[] = {
  340. "DD_DEF_TYPE ",
  341. "DD_DIRECTDRAW_TYPE",
  342. "DD_SURFACE_TYPE ",
  343. "D3D_HANDLE_TYPE ",
  344. "DD_VIDEOPORT_TYPE ",
  345. "DD_MOTIONCOMP_TYPE",
  346. "TOTALS ",
  347. "DEF "
  348. };
  349. #define DD_TOTAL_TYPE (DD_MAX_TYPE+1)
  350. /******************************Public*Routine******************************\
  351. * DECLARE_API( dumpdd )
  352. *
  353. * Dumps the count of handles in DdHmgr for each object type.
  354. *
  355. * History:
  356. * 30-Apr-1999 -by- Lindsay Steventon [linstev]
  357. * Wrote it.
  358. \**************************************************************************/
  359. DECLARE_API( dumpdd )
  360. {
  361. dprintf("Extension 'dumpdd' is not converted.\n");
  362. #if ENABLE_OLD_EXTS // DOES NOT SUPPORT API64
  363. PENTRY pent;
  364. ULONG gcMaxHmgr;
  365. ULONG gcSizeHmgr;
  366. ULONG ulLoop; // loop variable
  367. ULONG objt;
  368. ULONG pulCount[DD_MAX_TYPE + 2];
  369. ULONG cUnknown = 0;
  370. ULONG cUnknownSize = 0;
  371. ULONG cUnused = 0;
  372. ENTRY entry;
  373. ULONG HmgCurrentNumberOfObjects[DD_MAX_TYPE + 2] = {0};
  374. ULONG HmgMaximumNumberOfObjects[DD_MAX_TYPE + 2] = {0};
  375. ULONG HmgNumberOfObjectsAllocated[DD_MAX_TYPE + 2] = {0};
  376. ULONG HmgCurrentNumberOfHandles[DD_MAX_TYPE + 2] = {0};
  377. ULONG HmgMaximumNumberOfHandles[DD_MAX_TYPE + 2] = {0};
  378. ULONG HmgNumberOfHandlesAllocated[DD_MAX_TYPE + 2] = {0};
  379. PARSE_ARGUMENTS(dumpdd_help);
  380. // Get the pointers and counts from win32k
  381. GetValue (pent, "win32k!gpentDdHmgr");
  382. GetValue (gcMaxHmgr, "win32k!gcMaxDdHmgr");
  383. GetValue (gcSizeHmgr, "win32k!gcSizeDdHmgr");
  384. dprintf("Max handles out so far %lu\n", gcMaxHmgr - DD_HMGR_HANDLE_BASE);
  385. if (pent == NULL || gcMaxHmgr == 0)
  386. {
  387. dprintf("terminating: pent = %lx, gcMaxDdHmgr = %lx\n",pent,gcMaxHmgr);
  388. return;
  389. }
  390. // Print out the amount reserved and committed, note we assume a 4K page size
  391. dprintf("Total allocated for DdHmgr %lu (%d handles)\n", gcSizeHmgr * sizeof(ENTRY), gcSizeHmgr);
  392. //CHECKLOOP
  393. for (ulLoop = 0; ulLoop <= DD_TOTAL_TYPE; ulLoop++)
  394. {
  395. pulCount[ulLoop] = 0;
  396. }
  397. //CHECKLOOP
  398. for (ulLoop = DD_HMGR_HANDLE_BASE; ulLoop < gcMaxHmgr; ulLoop++)
  399. {
  400. move (entry, &(pent[ulLoop]));
  401. objt = (ULONG) entry.Objt;
  402. if (objt == DD_DEF_TYPE)
  403. {
  404. cUnused++;
  405. }
  406. if (objt > DD_MAX_TYPE)
  407. {
  408. cUnknown++;
  409. }
  410. else
  411. {
  412. pulCount[objt]++;
  413. }
  414. if (CheckControlC())
  415. return;
  416. }
  417. dprintf("ulLoop=%d, gcMaxDdHmgr=%d\n", ulLoop, gcMaxHmgr);
  418. dprintf("%8s%17s\n","TYPE","Current");
  419. // init the totals
  420. pulCount[DD_TOTAL_TYPE] = 0;
  421. HmgMaximumNumberOfHandles[DD_TOTAL_TYPE] = 0;
  422. // now go through printing each line and accumulating totals
  423. for (ulLoop = 0; ulLoop <= DD_MAX_TYPE; ulLoop++)
  424. {
  425. dprintf("%s%4lu\n",
  426. pszDdTypes[ulLoop],
  427. pulCount[ulLoop]);
  428. if (ulLoop != DD_DEF_TYPE)
  429. {
  430. pulCount[DD_TOTAL_TYPE] += pulCount[ulLoop];
  431. }
  432. if (CheckControlC())
  433. return;
  434. }
  435. dprintf("%s%4lu\n", pszDdTypes[DD_TOTAL_TYPE],
  436. pulCount[DD_TOTAL_TYPE]);
  437. dprintf ("\ncUnused objects %lu\n", cUnused);
  438. dprintf("cUnknown objects %lu\n",cUnknown);
  439. return;
  440. dumpdd_help:
  441. dprintf("Usage: dumpdd [-?]\n");
  442. dprintf("dumpdd displays the amount of each type of object in the ddraw handle manager\n");
  443. dprintf("-? produces this help\ndumpdd ignores all other arguments\n");
  444. #endif // DOES NOT SUPPORT API64
  445. EXIT_API(S_OK);
  446. }
  447. char *pszDdTypes2[] = {
  448. "DEF",
  449. "DDRAW",
  450. "SURF",
  451. "D3DH",
  452. "VPE",
  453. "MOCOMP"
  454. };
  455. /******************************Public*Routine******************************\
  456. * DECLARE_API( dumpddobj )
  457. *
  458. * History:
  459. * 30-Apr-1999 -by- Lindsay Steventon [linstev]
  460. * Wrote it.
  461. \**************************************************************************/
  462. DECLARE_API( dumpddobj )
  463. {
  464. dprintf("Extension 'dumpddobj' is not converted.\n");
  465. #if ENABLE_OLD_EXTS // DOES NOT SUPPORT API64
  466. PENTRY pent;
  467. ULONG gcMaxHmgr;
  468. ULONG ulLoop;
  469. ENTRY entry;
  470. LONG Pid = PID_ALL;
  471. LONG Type = TYPE_ALL;
  472. BOOL bCheckLock = FALSE;
  473. BOOL bSummary = FALSE;
  474. int i;
  475. PARSE_ARGUMENTS(dumpddobj_help);
  476. if(ntok<1) {
  477. goto dumpddobj_help;
  478. }
  479. //find valid tokens - ignore the rest
  480. bCheckLock = (parse_iFindSwitch(tokens, ntok, 'l') >= 0);
  481. bSummary = (parse_iFindSwitch(tokens, ntok, 's') >= 0);
  482. tok_pos = parse_iFindSwitch(tokens, ntok, 'p');
  483. if(tok_pos>=0) {
  484. tok_pos++;
  485. if((tok_pos+1)>=ntok) {
  486. goto dumpddobj_help; //-p requires a pid and it can't be the last arg
  487. }
  488. Pid = (LONG)GetExpression(tokens[tok_pos]);
  489. }
  490. //find first non-switch token not preceeded by a -p
  491. tok_pos = -1;
  492. do {
  493. tok_pos = parse_FindNonSwitch(tokens, ntok, tok_pos+1);
  494. } while ( (tok_pos!=-1)&&(parse_iIsSwitch(tokens, tok_pos-1, 'p')));
  495. if(tok_pos==-1) {
  496. goto dumpddobj_help;
  497. }
  498. //CHECKLOOP
  499. for (Type = 0; Type <= DD_MAX_TYPE; ++Type) {
  500. if(parse_iIsToken(tokens, tok_pos, pszDdTypes2[Type])) {
  501. break;
  502. }
  503. }
  504. if (Type > DD_MAX_TYPE) {
  505. goto dumpddobj_help;
  506. }
  507. //
  508. // Get the pointers and counts from win32k
  509. //
  510. GetValue(pent, "win32k!gpentDdHmgr");
  511. GetValue(gcMaxHmgr, "win32k!gcMaxDdHmgr");
  512. if (pent == NULL || gcMaxHmgr == 0)
  513. {
  514. dprintf("terminating: pent = %lx, gcMaxDdHmgr = %lx\n",pent,gcMaxHmgr);
  515. return;
  516. }
  517. //
  518. // dprintf out the amount reserved and committed, note we assume a 4K page size
  519. //
  520. dprintf("object list for %s type objects",Type == TYPE_ALL ? "ALL" : pszDdTypes2[Type]);
  521. if (Pid == PID_ALL)
  522. {
  523. dprintf(" owned by ALL PIDs\n");
  524. }
  525. else
  526. {
  527. dprintf(" owned by PID 0x%lx\n",Pid);
  528. }
  529. if(!bSummary) {
  530. dprintf("%4s, %8s, %6s, %6s, %4s, %8s, %8s, %6s, %6s, %8s,%9s\n",
  531. "I","handle","Lock","sCount","pid","pv","objt","unique","Flags","pUser","Tlock");
  532. dprintf("--------------------------------------------------------------------------------------------\n");
  533. }
  534. {
  535. LONG ObjCount = 0;
  536. LONG ObjArray[DD_MAX_TYPE+1];
  537. for(i=0;i<=DD_MAX_TYPE;i++) {
  538. ObjArray[i]=0;
  539. }
  540. //CHECKLOOP
  541. for (ulLoop = 0; ulLoop < gcMaxHmgr; ulLoop++)
  542. {
  543. LONG objt;
  544. LONG ThisPid;
  545. move(entry, &(pent[ulLoop]));
  546. objt = entry.Objt;
  547. ThisPid = OBJECTOWNER_PID(entry.ObjectOwner);
  548. if (
  549. ((objt == Type) || (Type == TYPE_ALL)) &&
  550. ((ThisPid == Pid) || (Pid == PID_ALL)) &&
  551. ((!bCheckLock) || (entry.ObjectOwner.Share.Lock))
  552. )
  553. {
  554. ObjCount++;
  555. if (!bSummary)
  556. {
  557. BASEOBJECT baseObj;
  558. move(baseObj, entry.einfo.pobj);
  559. dprintf("%4lx, %8lx, %6lx, %6lx, %4lx, %8lx, %8s, %6lx, %6lx, %08x, %08lx\n",
  560. ulLoop,
  561. DD_MAKE_HMGR_HANDLE(ulLoop,entry.FullUnique),
  562. (entry.ObjectOwner.Share.Lock != 0),
  563. baseObj.ulShareCount,
  564. OBJECTOWNER_PID(entry.ObjectOwner),
  565. entry.einfo,
  566. pszDdTypes2[entry.Objt],
  567. entry.FullUnique,
  568. entry.Flags,
  569. entry.pUser,
  570. entry.pUser);
  571. }
  572. else
  573. {
  574. ObjArray[entry.Objt]++;
  575. }
  576. }
  577. if (CheckControlC())
  578. return;
  579. }
  580. if(bSummary && (Type==TYPE_ALL)) {
  581. for(i=0;i<=DD_MAX_TYPE; i++) {
  582. if(ObjArray[i]>0) {
  583. dprintf("%s\t%ld\n", pszDdTypes2[i], ObjArray[i]);
  584. }
  585. }
  586. }
  587. dprintf("Total objects = %li\n",ObjCount);
  588. }
  589. return;
  590. dumpddobj_help:
  591. dprintf("Usage: dumpddobj [-?] [-p pid] [-l] [-s] object_type\n");
  592. dprintf("-l check lock\n");
  593. dprintf("-s summary\n");
  594. dprintf("\nThe -s option combined with the DEF object type will produce"
  595. " a list of the totals for each object type\n");
  596. dprintf("\nValid object_type values are:\n");
  597. for(i=0;i<=DD_MAX_TYPE;i++) {
  598. dprintf("%s\n", pszDdTypes2[i]);
  599. }
  600. #endif // DOES NOT SUPPORT API64
  601. EXIT_API(S_OK);
  602. }
  603. /******************************Public*Routine******************************\
  604. * DECLARE_API( dddh )
  605. *
  606. * Debugger extension to dump a handle.
  607. *
  608. * History:
  609. * 30-Apr-1999 -by- Lindsay Steventon [linstev]
  610. * Wrote it.
  611. \**************************************************************************/
  612. DECLARE_API( dddh )
  613. {
  614. dprintf("Extension 'dddh' is not converted.\n");
  615. #if ENABLE_OLD_EXTS // DOES NOT SUPPORT API64
  616. HOBJ ho; // dump this handle
  617. PENTRY pent; // base address of hmgr entries
  618. ENTRY ent; // copy of handle entry
  619. BASEOBJECT obj;
  620. ULONG ulTemp;
  621. int iRet;
  622. PARSE_POINTER(dddh_help);
  623. ho = (HOBJ)arg;
  624. // Get argument (handle to dump).
  625. dprintf("--------------------------------------------------\n");
  626. dprintf("Entry from ghmgr for handle 0x%08lx:\n", ho );
  627. // Dereference the handle via the engine's handle manager.
  628. GetAddress(pent, "win32k!gpentDdHmgr");
  629. dprintf("&pent = %lx\n",pent);
  630. GetValue(pent, "win32k!gpentDdHmgr");
  631. dprintf("pent = %lx\n",pent);
  632. iRet = move(ent, &(pent[DdHmgIfromH((ULONG_PTR) ho)]));
  633. dprintf("move() = %lx\n",iRet);
  634. // dprintf the entry.
  635. BASEOBJECT baseObj;
  636. move(baseObj, ent.einfo.pobj);
  637. dprintf(" pobj/hfree = 0x%08lx\n" , ent.einfo.pobj);
  638. dprintf(" ObjectOwner = 0x%08lx\n" , ent.ObjectOwner.ulObj);
  639. dprintf(" pidOwner = 0x%x\n" , OBJECTOWNER_PID(ent.ObjectOwner));
  640. dprintf(" ShareCount = 0x%x\n" , baseObj.ulShareCount);
  641. dprintf(" lock = %s\n" , ent.ObjectOwner.Share.Lock ? "LOCKED" : "UNLOCKED");
  642. dprintf(" puser = 0x%x\n" , ent.pUser);
  643. dprintf(" objt = 0x%hx\n" , ent.Objt);
  644. dprintf(" usUnique = 0x%hx\n" , ent.FullUnique);
  645. dprintf(" fsHmgr = 0x%hx\n" , ent.Flags);
  646. // If it has an object we get the lock counts and tid owner.
  647. if (ent.Objt != DD_DEF_TYPE)
  648. {
  649. if (ent.einfo.pobj != NULL)
  650. {
  651. move(obj,ent.einfo.pobj);
  652. dprintf(" hHmgr = 0x%08lx\n" , obj.hHmgr);
  653. dprintf(" cExcluLock = 0x%08lx\n" , obj.cExclusiveLock);
  654. dprintf(" tid = 0x%08lx\n" , obj.Tid);
  655. }
  656. else
  657. {
  658. dprintf("It has a NULL pointer\n");
  659. }
  660. }
  661. ulTemp = (ULONG) ent.Objt;
  662. switch(ulTemp)
  663. {
  664. case DD_DEF_TYPE:
  665. dprintf("This is DD_DEF_TYPE\n");
  666. break;
  667. case DD_DIRECTDRAW_TYPE:
  668. dprintf("This is DD_DIRECTDRAW_TYPE\n");
  669. break;
  670. case DD_SURFACE_TYPE:
  671. dprintf("This is DD_SURFACE_TYPE\n");
  672. break;
  673. case D3D_HANDLE_TYPE:
  674. dprintf("This is D3D_HANDLE_TYPE\n");
  675. break;
  676. case DD_VIDEOPORT_TYPE:
  677. dprintf("This is DD_VIDEOPORT_TYPE\n");
  678. break;
  679. case DD_MOTIONCOMP_TYPE:
  680. dprintf("This is DD_MOTIONCOMP_TYPE\n");
  681. break;
  682. default:
  683. dprintf("This is of unknown type - an error\n");
  684. }
  685. dprintf("--------------------------------------------------\n");
  686. return;
  687. dddh_help:
  688. dprintf("Usage: dddh [-?] object_handle\n");
  689. dprintf("-? displays this help\n");
  690. dprintf("object_handle must be in hexadecimal\n");
  691. #endif // DOES NOT SUPPORT API64
  692. EXIT_API(S_OK);
  693. }
  694. /******************************Public*Routine******************************\
  695. * DECLARE_API( dddht )
  696. *
  697. * Debugger extension to dump a handle type.
  698. *
  699. * History:
  700. * 21-Feb-1995 -by- Lingyun Wang [lingyunw]
  701. * Wrote it.
  702. \**************************************************************************/
  703. DECLARE_API( dddht )
  704. {
  705. dprintf("Extension 'dddht' is not converted.\n");
  706. #if ENABLE_OLD_EXTS // DOES NOT SUPPORT API64
  707. DWORD dwHandle;
  708. PARSE_POINTER(dddht_help);
  709. dwHandle = (DWORD)arg;
  710. // Get argument (handle to dump).
  711. dprintf("Handle: %lx\n",dwHandle);
  712. dprintf("\tIndex | UNIQUE | SRV TYPE\n");
  713. dprintf("\t %.4x | %.2x | %.6s (%2x)\n",
  714. DdHmgIfromH(dwHandle),
  715. (dwHandle & DD_UNIQUE_MASK) >> DD_UNIQUE_SHIFT,
  716. pszDdTypes[DdHmgObjtype(dwHandle)], DdHmgObjtype(dwHandle));
  717. return;
  718. dddht_help:
  719. dprintf("Usage: dddht [-?] object_handle\n");
  720. dprintf("-? displays this help\n");
  721. dprintf("object_handle must be in hexadecimal\n");
  722. #endif // DOES NOT SUPPORT API64
  723. EXIT_API(S_OK);
  724. }