Source code of Windows XP (NT5)
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.

370 lines
11 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995
  5. //
  6. // File: dclscach.cxx
  7. //
  8. // Contents: Ole NTSD extension routines to display the class cache in
  9. // the scm
  10. //
  11. // Functions: displayClassCache
  12. //
  13. //
  14. // History: 06-01-95 BruceMa Created
  15. //
  16. //
  17. //--------------------------------------------------------------------------
  18. #include <ole2int.h>
  19. #include <windows.h>
  20. #include "ole.h"
  21. #include "dclscach.h"
  22. void FormatCLSID(REFGUID rguid, LPSTR lpsz);
  23. //+-------------------------------------------------------------------------
  24. //
  25. // Function: classCacheHelp
  26. //
  27. // Synopsis: Prints a short help menu for !ole.cc
  28. //
  29. // Arguments: [lpExtensionApis] - Table of extension functions
  30. //
  31. // Returns: -
  32. //
  33. // History: 27-Jun-95 BruceMa Created
  34. //
  35. //--------------------------------------------------------------------------
  36. void classCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis)
  37. {
  38. Printf("cc - Display class cache info\n");
  39. Printf("local-server-path[(16)] clsid debug? [handler]\n");
  40. Printf(" hRpc hWnd flags PSID desktop\n");
  41. Printf(" ...\n");
  42. }
  43. //+-------------------------------------------------------------------------
  44. //
  45. // Function: displayClassCache
  46. //
  47. // Synopsis: Displays the retail scm class cache
  48. //
  49. // Arguments: [hProcess] - Handle of this process
  50. // [lpExtensionApis] - Table of extension functions
  51. //
  52. // Returns: -
  53. //
  54. // History: 27-Jun-95 BruceMa Created
  55. //
  56. //--------------------------------------------------------------------------
  57. void displayClassCache(HANDLE hProcess,
  58. PNTSD_EXTENSION_APIS lpExtensionApis)
  59. {
  60. ULONG addr;
  61. SClassCacheList sClassCacheList;
  62. SSkipListEntry sSkipListEntry;
  63. SClassData sClassData;
  64. SLocalServer sLocalServer;
  65. SStringID sStringId;
  66. WCHAR *pwszUni;
  67. WCHAR wszUni[128];
  68. char szAnsi[128];
  69. SArrayFValue sArrayFValue;
  70. SSrvRegistration *pSrvReg;
  71. // Read the class cache
  72. addr = GetExpression("scm!g_pcllClassCache");
  73. ReadMem(&addr, addr, sizeof(ULONG));
  74. ReadMem(&sClassCacheList, addr, sizeof(SClassCacheList));
  75. // Read the initial skiplist entry
  76. ReadMem(&sSkipListEntry, sClassCacheList._pSkipList,
  77. sizeof(SSkipListEntry));
  78. // Do over skiplist entries
  79. do
  80. {
  81. // Just in case
  82. if (CheckControlC())
  83. {
  84. return;
  85. }
  86. // Read the next skiplist entry
  87. ReadMem(&sSkipListEntry, sSkipListEntry._apBaseForward,
  88. sizeof(SSkipListEntry));
  89. // Read the CClassData structure
  90. ReadMem(&sClassData, sSkipListEntry._pvEntry, sizeof(SClassData));
  91. // Read the CLocalServer structure
  92. ReadMem(&sLocalServer, sClassData._slocalsrv, sizeof(SLocalServer));
  93. // Print the path
  94. pwszUni = (WCHAR *) OleAlloc(sLocalServer._stringId._cPath *
  95. sizeof(WCHAR));
  96. ReadMem(pwszUni, sLocalServer._stringId._pwszPath,
  97. sLocalServer._stringId._cPath * sizeof(WCHAR));
  98. Unicode2Ansi(szAnsi, pwszUni, sLocalServer._stringId._cPath *
  99. sizeof(WCHAR));
  100. if (sClassData._fLocalServer16)
  101. {
  102. Printf("%s(16) ", szAnsi);
  103. }
  104. else
  105. {
  106. Printf("%s ", szAnsi);
  107. }
  108. OleFree(pwszUni);
  109. // Print the clsid
  110. FormatCLSID(sClassData._clsid, szAnsi);
  111. Printf("%s ", szAnsi);
  112. // Whether activated under a debugger
  113. if (sClassData._fDebug)
  114. {
  115. Printf("*Debug*");
  116. }
  117. // Any specified handler
  118. if (sClassData._shandlr)
  119. {
  120. ReadMem(&sStringId, sClassData._shandlr, sizeof(SStringID));
  121. // Print the path
  122. pwszUni = (WCHAR *) OleAlloc(sStringId._cPath * sizeof(WCHAR));
  123. ReadMem(pwszUni, sStringId._pwszPath,
  124. sStringId._cPath * sizeof(WCHAR));
  125. Unicode2Ansi(szAnsi, pwszUni, sStringId._cPath *
  126. sizeof(WCHAR));
  127. if (sClassData._fInprocHandler16)
  128. {
  129. Printf("%s(16) ", szAnsi);
  130. }
  131. else
  132. {
  133. Printf("%s ", szAnsi);
  134. }
  135. OleFree(pwszUni);
  136. }
  137. // Close the print line
  138. Printf("\n");
  139. // Read the endpoint registration array base
  140. ReadMem(&sArrayFValue, sClassData._pssrvreg, sizeof(SArrayFValue));
  141. // Read the array of endpoint registrations
  142. pSrvReg = (SSrvRegistration *) OleAlloc(sArrayFValue.m_nSize *
  143. sizeof(SSrvRegistration));
  144. ReadMem(pSrvReg, sArrayFValue.m_pData,
  145. sArrayFValue.m_nSize * sizeof(SSrvRegistration));
  146. // Do over the RPC endpoints registered for this server
  147. for (int cReg = 0; cReg < sArrayFValue.m_nSize; cReg++)
  148. {
  149. // Only look at non-empty binding handles
  150. if (pSrvReg[cReg]._hRpc)
  151. {
  152. // The RPC binding handle
  153. Printf(" %x ", pSrvReg[cReg]._hRpc);
  154. // The window handle
  155. Printf("%x ", pSrvReg[cReg]._ulWnd);
  156. // Flags
  157. Printf("%x ", pSrvReg[cReg]._dwFlags);
  158. // Security Id
  159. Printf("%x ", pSrvReg[cReg]._psid);
  160. // The desktop
  161. UINT cb = 0;
  162. // We have to read memory one WCHAR at a time because any
  163. // av prevents any reading
  164. do
  165. {
  166. ReadMem(&wszUni[cb], &pSrvReg[cReg]._lpDesktop[cb],
  167. sizeof(WCHAR));
  168. cb++;
  169. } until_(wszUni[cb - 1] == L'\0');
  170. Unicode2Ansi(szAnsi, wszUni, cb);
  171. Printf("%s\n\n", szAnsi);
  172. }
  173. }
  174. } until_(sSkipListEntry._apBaseForward == sClassCacheList._pSkipList);
  175. }
  176. //+-------------------------------------------------------------------------
  177. //
  178. // Function: displayClassCacheCk
  179. //
  180. // Synopsis: Displays the checked scm class cache
  181. //
  182. // Arguments: [hProcess] - Handle of this process
  183. // [lpExtensionApis] - Table of extension functions
  184. //
  185. // Returns: -
  186. //
  187. // History: 27-Jun-95 BruceMa Created
  188. //
  189. // Notes: This was necessary because certain of the class cache
  190. // structures different depending on retail vs. checked
  191. //
  192. //--------------------------------------------------------------------------
  193. void displayClassCacheCk(HANDLE hProcess,
  194. PNTSD_EXTENSION_APIS lpExtensionApis)
  195. {
  196. ULONG addr;
  197. SClassCacheList sClassCacheList;
  198. SSkipListEntry sSkipListEntry;
  199. SClassDataCk sClassData;
  200. SLocalServerCk sLocalServer;
  201. SStringIDCk sStringId;
  202. WCHAR *pwszUni;
  203. WCHAR wszUni[128];
  204. char szAnsi[128];
  205. SArrayFValue sArrayFValue;
  206. SSrvRegistration *pSrvReg;
  207. // Read the class cache
  208. addr = GetExpression("scm!g_pcllClassCache");
  209. ReadMem(&addr, addr, sizeof(ULONG));
  210. ReadMem(&sClassCacheList, addr, sizeof(SClassCacheList));
  211. // Read the initial skiplist entry
  212. ReadMem(&sSkipListEntry, sClassCacheList._pSkipList,
  213. sizeof(SSkipListEntry));
  214. // Do over skiplist entries
  215. do
  216. {
  217. // Just in case
  218. if (CheckControlC())
  219. {
  220. return;
  221. }
  222. // Read the next skiplist entry
  223. ReadMem(&sSkipListEntry, sSkipListEntry._apBaseForward,
  224. sizeof(SSkipListEntry));
  225. // Read the CClassData structure
  226. ReadMem(&sClassData, sSkipListEntry._pvEntry, sizeof(SClassDataCk));
  227. // Read the CLocalServer structure
  228. ReadMem(&sLocalServer, sClassData._slocalsrv, sizeof(SLocalServerCk));
  229. // Print the path
  230. pwszUni = (WCHAR *) OleAlloc(sLocalServer._stringId._cPath *
  231. sizeof(WCHAR));
  232. ReadMem(pwszUni, sLocalServer._stringId._pwszPath,
  233. sLocalServer._stringId._cPath * sizeof(WCHAR));
  234. Unicode2Ansi(szAnsi, pwszUni, sLocalServer._stringId._cPath *
  235. sizeof(WCHAR));
  236. if (sClassData._fLocalServer16)
  237. {
  238. Printf("%s(16) ", szAnsi);
  239. }
  240. else
  241. {
  242. Printf("%s ", szAnsi);
  243. }
  244. OleFree(pwszUni);
  245. // Print the clsid
  246. FormatCLSID(sClassData._clsid, szAnsi);
  247. Printf("%s ", szAnsi);
  248. // Whether activated under a debugger
  249. if (sClassData._fDebug)
  250. {
  251. Printf("*Debug*");
  252. }
  253. // Any specified handler
  254. if (sClassData._shandlr)
  255. {
  256. ReadMem(&sStringId, sClassData._shandlr, sizeof(SStringIDCk));
  257. // Print the path
  258. pwszUni = (WCHAR *) OleAlloc(sStringId._cPath * sizeof(WCHAR));
  259. ReadMem(pwszUni, sStringId._pwszPath,
  260. sStringId._cPath * sizeof(WCHAR));
  261. Unicode2Ansi(szAnsi, pwszUni, sStringId._cPath *
  262. sizeof(WCHAR));
  263. if (sClassData._fInprocHandler16)
  264. {
  265. Printf("%s(16) ", szAnsi);
  266. }
  267. else
  268. {
  269. Printf("%s ", szAnsi);
  270. }
  271. OleFree(pwszUni);
  272. }
  273. // Close the print line
  274. Printf("\n");
  275. // Read the endpoint registration array base
  276. ReadMem(&sArrayFValue, sClassData._pssrvreg, sizeof(SArrayFValue));
  277. // Read the array of endpoint registrations
  278. pSrvReg = (SSrvRegistration *) OleAlloc(sArrayFValue.m_nSize *
  279. sizeof(SSrvRegistration));
  280. ReadMem(pSrvReg, sArrayFValue.m_pData,
  281. sArrayFValue.m_nSize * sizeof(SSrvRegistration));
  282. // Do over the RPC endpoints registered for this server
  283. for (int cReg = 0; cReg < sArrayFValue.m_nSize; cReg++)
  284. {
  285. // Only look at non-empty binding handles
  286. if (pSrvReg[cReg]._hRpc)
  287. {
  288. // The RPC binding handle
  289. Printf(" %x ", pSrvReg[cReg]._hRpc);
  290. // The window handle
  291. Printf("%x ", pSrvReg[cReg]._ulWnd);
  292. // Flags
  293. Printf("%x ", pSrvReg[cReg]._dwFlags);
  294. // Security Id
  295. Printf("%x ", pSrvReg[cReg]._psid);
  296. // The desktop
  297. UINT cb = 0;
  298. // We have to read memory one WCHAR at a time because any
  299. // av prevents any reading
  300. do
  301. {
  302. ReadMem(&wszUni[cb], &pSrvReg[cReg]._lpDesktop[cb],
  303. sizeof(WCHAR));
  304. cb++;
  305. } until_(wszUni[cb - 1] == L'\0');
  306. Unicode2Ansi(szAnsi, wszUni, cb);
  307. Printf("%s\n\n", szAnsi);
  308. }
  309. }
  310. } until_(sSkipListEntry._apBaseForward == sClassCacheList._pSkipList);
  311. }