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.

335 lines
10 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. ddiexts.cxx
  5. Abstract:
  6. This file contains the DDI related extensions.
  7. Author:
  8. Jason Hartman (JasonHa) 2000-11-01
  9. Environment:
  10. User Mode
  11. --*/
  12. #include "precomp.hxx"
  13. /******************************Public*Routine******************************\
  14. * BLENDOBJ
  15. *
  16. \**************************************************************************/
  17. DECLARE_API( blendobj )
  18. {
  19. return ExtDumpType(Client, "blendobj", "BLENDOBJ", args);
  20. }
  21. /******************************Public*Routine******************************\
  22. * BRUSHOBJ
  23. *
  24. \**************************************************************************/
  25. DECLARE_API( brushobj )
  26. {
  27. return ExtDumpType(Client, "brushobj", "BRUSHOBJ", args);
  28. }
  29. /******************************Public*Routine******************************\
  30. * CLIPOBJ
  31. *
  32. \**************************************************************************/
  33. DECLARE_API( clipobj )
  34. {
  35. return ExtDumpType(Client, "clipobj", "CLIPOBJ", args);
  36. }
  37. /******************************Public*Routine******************************\
  38. * LINEATTRS
  39. *
  40. \**************************************************************************/
  41. DECLARE_API( lineattrs )
  42. {
  43. HRESULT hr = S_OK;
  44. OutputControl OutCtl(Client);
  45. DEBUG_VALUE Offset;
  46. BEGIN_API( lineattrs );
  47. while (isspace(*args)) args++;
  48. if (*args == '-' ||
  49. (hr = OutCtl.Evaluate(args, DEBUG_VALUE_INT64, &Offset, NULL)) != S_OK ||
  50. Offset.I64 == 0)
  51. {
  52. if (hr != S_OK)
  53. {
  54. OutCtl.OutErr("Evaluate '%s' returned %s.\n",
  55. args,
  56. pszHRESULT(hr));
  57. }
  58. OutCtl.Output("Usage: lineattrs [-?] <LINEATTRS Addr>\n");
  59. }
  60. else
  61. {
  62. OutputFilter OutFilter(Client);
  63. OutputState OutState(Client, FALSE);
  64. if (hr == S_OK &&
  65. (hr = OutState.Setup(0, &OutFilter)) == S_OK &&
  66. (hr = OutCtl.SetControl(DEBUG_OUTCTL_THIS_CLIENT |
  67. DEBUG_OUTCTL_NOT_LOGGED |
  68. DEBUG_OUTCTL_OVERRIDE_MASK,
  69. OutState.Client)) == S_OK)
  70. {
  71. hr = DumpType(Client,
  72. "_LINEATTRS",
  73. Offset.I64,
  74. DEBUG_OUTTYPE_DEFAULT,
  75. &OutCtl);
  76. OutCtl.SetControl(DEBUG_OUTCTL_AMBIENT, Client);
  77. if (hr == S_OK)
  78. {
  79. // Determine if FLOAT_LONG unions contain
  80. // FLOATL's or LONG's.
  81. if (OutFilter.Query("LA_GEOMETRIC") == S_OK)
  82. {
  83. OutFilter.Skip(OUTFILTER_QUERY_EVERY_LINE |
  84. OUTFILTER_QUERY_WHOLE_WORD,
  85. "l");
  86. }
  87. else
  88. {
  89. OutFilter.Skip(OUTFILTER_QUERY_EVERY_LINE |
  90. OUTFILTER_QUERY_WHOLE_WORD,
  91. "e");
  92. }
  93. OutFilter.OutputText();
  94. }
  95. else
  96. {
  97. OutCtl.OutErr("Type Dump for LINEATTRS returned %s.\n", pszHRESULT(hr));
  98. }
  99. }
  100. else
  101. {
  102. OutCtl.OutErr("Type Dump setup for LINEATTRS returned %s.\n", pszHRESULT(hr));
  103. }
  104. }
  105. return hr;
  106. }
  107. /******************************Public*Routine******************************\
  108. * PATHOBJ
  109. *
  110. \**************************************************************************/
  111. DECLARE_API( pathobj )
  112. {
  113. return ExtDumpType(Client, "pathobj", "PATHOBJ", args);
  114. }
  115. /******************************Public*Routine******************************\
  116. * SURFOBJ
  117. *
  118. \**************************************************************************/
  119. DECLARE_API( surfobj )
  120. {
  121. BEGIN_API( surfobj );
  122. HRESULT hr = S_OK;
  123. DEBUG_VALUE Arg;
  124. DEBUG_VALUE Offset;
  125. TypeOutputParser TypeParser(Client);
  126. OutputState OutState(Client);
  127. OutputControl OutCtl(Client);
  128. while (isspace(*args)) args++;
  129. if (*args == '-' ||
  130. (hr = Evaluate(Client, args, DEBUG_VALUE_INT64, 0, &Arg, NULL)) != S_OK ||
  131. Arg.I64 == 0)
  132. {
  133. OutCtl.Output("Usage: surfobj [-?] <HSURF | SURFOBJ Addr>\n");
  134. }
  135. else if ((hr = OutState.Setup(0, &TypeParser)) == S_OK)
  136. {
  137. ULONG64 SurfAddr;
  138. ULONG64 SurfObjAddr = 0;
  139. DEBUG_VALUE SurfObjHandle;
  140. BOOL SurfObjHandleChecked = FALSE;
  141. hr = GetObjectAddress(Client, Arg.I64, &SurfAddr, SURF_TYPE, TRUE, TRUE);
  142. if (hr != S_OK || SurfAddr == 0)
  143. {
  144. // Invalid handle try argument as a SURFOBJ address
  145. SurfObjAddr = Arg.I64;
  146. // Try to read hsurf from SURFOBJ
  147. if ((hr = OutState.OutputTypeVirtual(SurfObjAddr, GDIType(_SURFOBJ), 0)) != S_OK ||
  148. (hr = TypeParser.Get(&SurfObjHandle, "hsurf", DEBUG_VALUE_INT64)) != S_OK)
  149. {
  150. OutCtl.OutErr("Unable to get contents of SURFOBJ's handle\n");
  151. OutCtl.OutErr(" (Type Read returned %s)\n", pszHRESULT(hr));
  152. OutCtl.OutErr(" 0x%p is neither an HSURF nor valid SURFOBJ address\n", Arg.I64);
  153. }
  154. }
  155. if (hr == S_OK)
  156. {
  157. PDEBUG_SYMBOLS Symbols;
  158. ULONG64 SurfModule = 0;
  159. ULONG SurfTypeId = 0;
  160. ULONG BaseObjTypeId = 0;
  161. ULONG SurfObjOffset = 0;
  162. if ((hr = Client->QueryInterface(__uuidof(IDebugSymbols),
  163. (void **)&Symbols)) == S_OK)
  164. {
  165. // Try to read SURFOBJ offset from SURFACE type, but
  166. // if that fails assume it is directly after BASEOBJECT.
  167. if ((hr = GetTypeId(Client, "SURFACE", &SurfTypeId, &SurfModule)) != S_OK ||
  168. (hr = Symbols->GetFieldOffset(SurfModule, SurfTypeId, "so", &SurfObjOffset)) != S_OK)
  169. {
  170. if ((hr = Symbols->GetTypeId(Type_Module.Base, "_BASEOBJECT", &BaseObjTypeId)) == S_OK)
  171. {
  172. hr = Symbols->GetTypeSize(Type_Module.Base, BaseObjTypeId, &SurfObjOffset);
  173. }
  174. }
  175. Symbols->Release();
  176. }
  177. if (SurfObjAddr != 0)
  178. {
  179. // If we were given a address, check hsurf validity.
  180. // hsurf value (SurfObjHandle) is retrieved above.
  181. hr = GetObjectAddress(Client, SurfObjHandle.I64, &SurfAddr,
  182. SURF_TYPE, TRUE, FALSE);
  183. if (hr != S_OK || SurfAddr == 0)
  184. {
  185. OutCtl.OutWarn(" SURFOBJ's hsurf is not valid.\n");
  186. }
  187. else if (SurfObjOffset != 0 &&
  188. SurfObjAddr != SurfAddr + SurfObjOffset)
  189. {
  190. OutCtl.OutWarn(" SURFOBJ's hsurf may not be valid.\n");
  191. }
  192. else
  193. {
  194. ULONG64 SurfaceHandle;
  195. hr = GetObjectHandle(Client, SurfAddr, &SurfaceHandle, FALSE);
  196. if (hr != S_OK)
  197. {
  198. OutCtl.OutErr("Unable to get contents of surface handle\n");
  199. OutCtl.OutErr(" (Type Read returned %s)\n", pszHRESULT(hr));
  200. }
  201. else if (SurfaceHandle != SurfObjHandle.I64)
  202. {
  203. OutCtl.OutWarn(" Surface has an invalid handle.\n");
  204. }
  205. }
  206. }
  207. else
  208. {
  209. // If we were given a handle,
  210. // compute SURFOBJ address.
  211. if (SurfObjOffset != 0)
  212. {
  213. SurfObjAddr = SurfAddr + SurfObjOffset;
  214. // Try to read hsurf from SURFOBJ
  215. if ((hr = OutState.OutputTypeVirtual(SurfObjAddr, GDIType(_SURFOBJ), 0)) != S_OK ||
  216. (hr = TypeParser.Get(&SurfObjHandle, "hsurf", DEBUG_VALUE_INT64)) != S_OK)
  217. {
  218. OutCtl.OutErr("Unable to get contents of SURFOBJ's handle\n");
  219. OutCtl.OutErr(" (Type Read returned %s)\n", pszHRESULT(hr));
  220. }
  221. else if (SurfObjHandle.I64 != Arg.I64)
  222. {
  223. OutCtl.OutWarn(" SURFOBJ's hsurf is not valid.\n");
  224. }
  225. }
  226. }
  227. if (SurfObjAddr != 0)
  228. {
  229. hr = DumpType(Client, "_SURFOBJ", SurfObjAddr);
  230. if (hr != S_OK)
  231. {
  232. OutCtl.OutErr("Type Dump for %s returned %s.\n", GDIType(_SURFOBJ), pszHRESULT(hr));
  233. }
  234. }
  235. }
  236. }
  237. else
  238. {
  239. OutCtl.OutErr("Couldn't setup type reader, %s.\n", pszHRESULT(hr));
  240. }
  241. return hr;
  242. }
  243. /******************************Public*Routine******************************\
  244. * WNDOBJ
  245. *
  246. \**************************************************************************/
  247. DECLARE_API( wndobj )
  248. {
  249. return ExtDumpType(Client, "wndobj", "WNDOBJ", args);
  250. }
  251. /******************************Public*Routine******************************\
  252. * XLATEOBJ
  253. *
  254. \**************************************************************************/
  255. DECLARE_API( xlateobj )
  256. {
  257. return ExtDumpType(Client, "xlateobj", "XLATEOBJ", args);
  258. }
  259. /******************************Public*Routine******************************\
  260. * DEVMODEA
  261. *
  262. \**************************************************************************/
  263. DECLARE_API( devmodea )
  264. {
  265. return ExtDumpType(Client, "devmodea", "_devicemodeA", args);
  266. }
  267. /******************************Public*Routine******************************\
  268. * DEVMODEW
  269. *
  270. \**************************************************************************/
  271. DECLARE_API( devmodew )
  272. {
  273. return ExtDumpType(Client, "devmodeW", "_devicemodeW", args);
  274. }