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.

334 lines
9.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995
  5. //
  6. // File: dpsclsid.cxx
  7. //
  8. // Contents: Ole NTSD extension routines to dump the proxy/stub
  9. // clsid cache
  10. //
  11. // Functions: psClsidHelp
  12. // displayPsClsidTbl
  13. //
  14. //
  15. // History: 06-01-95 BruceMa Created
  16. //
  17. //
  18. //--------------------------------------------------------------------------
  19. #include <ole2int.h>
  20. #include <windows.h>
  21. #include "ole.h"
  22. #include "dshrdmem.h"
  23. BOOL IsEqualCLSID(CLSID *pClsid1, CLSID *pClsid2);
  24. void FormatCLSID(REFGUID rguid, LPSTR lpsz);
  25. BOOL GetRegistryInterfaceName(REFIID iid, char *szValue, DWORD *pcbValue);
  26. BOOL GetRegistryClsidKey(REFCLSID clsid, char *szKey,
  27. char *szValue, DWORD *pcbValue);
  28. //+-------------------------------------------------------------------------
  29. //
  30. // Function: psClsidHelp
  31. //
  32. // Synopsis: Display a menu for the command 'ps'
  33. //
  34. // Arguments: -
  35. //
  36. // Returns: -
  37. //
  38. // History: 07-Mar-95 BruceMa Created
  39. //
  40. //--------------------------------------------------------------------------
  41. void psClsidHelp(PNTSD_EXTENSION_APIS lpExtensionApis)
  42. {
  43. Printf("ps - Display infomation for all IID's\n");
  44. Printf("ps IID - Display infomation for IID\n");
  45. }
  46. //+-------------------------------------------------------------------------
  47. //
  48. // Function: displayPsClsidTbl
  49. //
  50. // Synopsis: Given an interface IID display the CLSID of the
  51. // associated proxy/stub handler dll
  52. //
  53. // Arguments: [hProcess] - Handle of this process
  54. // [lpExtensionApis] - Table of extension functions
  55. // [lpFileExtTbl] - Address of file extensions table
  56. // [pClsid] - Only for this clsid
  57. //
  58. // Returns: -
  59. //
  60. // History: 01-Jun-95 BruceMa Created
  61. //
  62. //--------------------------------------------------------------------------
  63. void displayPsClsidTbl(HANDLE hProcess,
  64. PNTSD_EXTENSION_APIS lpExtensionApis,
  65. SDllShrdTbl *pShrdTbl,
  66. IID *pIid)
  67. {
  68. SDllShrdTbl sDllTbl;
  69. GUIDMAP sGuidMap;
  70. GUIDPAIR *pGuidPair;
  71. DWORDPAIR *pDwordPair;
  72. IID iid = {0, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}};
  73. char szClsid[CLSIDSTR_MAX];
  74. char szName[129];
  75. DWORD cbValue;
  76. // Read the shared table locally
  77. ReadMem(&sDllTbl, pShrdTbl, sizeof(SDllShrdTbl));
  78. // Read the guid map locally
  79. ReadMem(&sGuidMap, sDllTbl._PSClsidTbl._pGuidMap, sizeof(GUIDMAP));
  80. // Allocate for the guid pair list
  81. pGuidPair = (GUIDPAIR *) OleAlloc(sGuidMap.ulCntLong * sizeof(GUIDPAIR));
  82. // Allocate for the dword pair list
  83. pDwordPair = (DWORDPAIR *) OleAlloc(sGuidMap.ulCntShort *
  84. sizeof(DWORDPAIR));
  85. // Read the guid pair list
  86. ReadMem(pGuidPair, sDllTbl._PSClsidTbl._pLongList -
  87. (sGuidMap.ulCntLong - 1),
  88. sGuidMap.ulCntLong * sizeof(GUIDPAIR));
  89. // Read the dword pair list
  90. ReadMem(pDwordPair, sDllTbl._PSClsidTbl._pShortList,
  91. sGuidMap.ulCntShort * sizeof(DWORDPAIR));
  92. // Are we looking for a specific IID?
  93. if (pIid != NULL)
  94. {
  95. // Search the short list first
  96. for (UINT cCnt = 0; cCnt < sGuidMap.ulCntShort; pDwordPair++, cCnt++)
  97. {
  98. if (pIid->Data1 == pDwordPair->dw1)
  99. {
  100. iid.Data1 = pIid->Data1;
  101. // Fetch and print the interface name
  102. cbValue = 64;
  103. if(GetRegistryInterfaceName(iid, szName, &cbValue))
  104. {
  105. Printf("%s\t", szName);
  106. }
  107. else
  108. {
  109. Printf("-\t");
  110. }
  111. // The clsid
  112. iid.Data1 = pDwordPair->dw2;
  113. FormatCLSID(iid, szClsid);
  114. Printf("%s\t", szClsid);
  115. // Fetch and print the proxy/stub handler dll
  116. cbValue = 128;
  117. if (GetRegistryClsidKey(iid, "InprocServer32", szName,
  118. &cbValue))
  119. {
  120. Printf("%s\n", szName);
  121. }
  122. else if(GetRegistryClsidKey(iid, "InprocServer", szName,
  123. &cbValue))
  124. {
  125. Printf("%s(16)\n", szName);
  126. }
  127. else
  128. {
  129. Printf("-\n");
  130. }
  131. return;
  132. }
  133. }
  134. // Search the long list next
  135. for (cCnt = 0; cCnt < sGuidMap.ulCntLong; pGuidPair++, cCnt++)
  136. {
  137. if (IsEqualCLSID(pIid, &pGuidPair->guid1))
  138. {
  139. // Fetch and print the interface name
  140. cbValue = 64;
  141. if(GetRegistryInterfaceName(pGuidPair->guid1, szName,
  142. &cbValue))
  143. {
  144. Printf("%s\t", szName);
  145. }
  146. else
  147. {
  148. Printf("-\t");
  149. }
  150. // The clsid
  151. FormatCLSID(pGuidPair->guid2, szClsid);
  152. Printf("%s\t", szClsid);
  153. // Fetch and print the proxy/stub handler dll
  154. cbValue = 128;
  155. if (GetRegistryClsidKey(pGuidPair->guid2, "InprocServer32",
  156. szName,
  157. &cbValue))
  158. {
  159. Printf("%s\n", szName);
  160. }
  161. else if(GetRegistryClsidKey(pGuidPair->guid2, "InprocServer",
  162. szName, &cbValue))
  163. {
  164. Printf("%s(16)\n", szName);
  165. }
  166. else
  167. {
  168. Printf("-\n");
  169. }
  170. return;
  171. }
  172. }
  173. }
  174. // Else dump everything
  175. else
  176. {
  177. // Print header
  178. Printf("where -. = '-0000-0000-C000-000000000046}'\n\n");
  179. Printf(" IID interface clsid p/s dll\n");
  180. Printf("----------- ------------------ ----------- ---------\n");
  181. // Do over the short list
  182. for (UINT cCnt = 0 ; cCnt < sGuidMap.ulCntShort; pDwordPair++, cCnt++)
  183. {
  184. // Print the IID
  185. iid.Data1 = pDwordPair->dw1;
  186. FormatCLSID(iid, szClsid);
  187. if (lstrcmp(&szClsid[9], "-0000-0000-C000-000000000046}") == 0)
  188. {
  189. szClsid[9] = '\0';
  190. Printf("%s-.", szClsid);
  191. }
  192. else
  193. {
  194. Printf("%s\n", szClsid);
  195. }
  196. // Fetch and print the interface name
  197. cbValue = 64;
  198. if(GetRegistryInterfaceName(iid, szName, &cbValue))
  199. {
  200. Printf(" %s", szName);
  201. }
  202. else
  203. {
  204. Printf(" -");
  205. }
  206. // Do some pretty printing alignment
  207. for (UINT cCh = 24 - lstrlen(szName); cCh > 0; cCh--)
  208. {
  209. Printf(" ");
  210. }
  211. Printf(" ");
  212. // The clsid
  213. iid.Data1 = pDwordPair->dw2;
  214. FormatCLSID(iid, szClsid);
  215. if (lstrcmp(&szClsid[9], "-0000-0000-C000-000000000046}") == 0)
  216. {
  217. szClsid[9] = '\0';
  218. Printf("%s-.\t", szClsid);
  219. }
  220. else
  221. {
  222. Printf("%s\t", szClsid);
  223. }
  224. // Fetch and print the proxy/stub handler dll
  225. cbValue = 128;
  226. if (GetRegistryClsidKey(iid, "InprocServer32", szName, &cbValue))
  227. {
  228. Printf("%s\n", szName);
  229. }
  230. else if(GetRegistryClsidKey(iid, "InprocServer", szName,
  231. &cbValue))
  232. {
  233. Printf("%s(16)\n", szName);
  234. }
  235. else
  236. {
  237. Printf("-\n");
  238. }
  239. }
  240. // Do over the long list
  241. for (cCnt = 0; cCnt < sGuidMap.ulCntLong; pGuidPair++, cCnt++)
  242. {
  243. // Print the IID
  244. FormatCLSID(pGuidPair->guid1, szClsid);
  245. Printf("%s ", szClsid);
  246. // Fetch and print the interface name
  247. cbValue = 64;
  248. if(GetRegistryInterfaceName(pGuidPair->guid1, szName, &cbValue))
  249. {
  250. Printf(" %s", szName);
  251. }
  252. else
  253. {
  254. Printf(" -");
  255. }
  256. // Do some pretty printing alignment
  257. for (UINT cCh = 24 - lstrlen(szName); cCh > 0; cCh--)
  258. {
  259. Printf(" ");
  260. }
  261. Printf(" ");
  262. // The clsid
  263. FormatCLSID(pGuidPair->guid2, szClsid);
  264. if (lstrcmp(&szClsid[9], "-0000-0000-C000-000000000046}") == 0)
  265. {
  266. szClsid[9] = '\0';
  267. Printf("%s-.\t", szClsid);
  268. }
  269. else
  270. {
  271. Printf("%s\t", szClsid);
  272. }
  273. // Fetch and print the proxy/stub handler dll
  274. cbValue = 128;
  275. if (GetRegistryClsidKey(pGuidPair->guid2, "InprocServer32",
  276. szName, &cbValue))
  277. {
  278. Printf("%s\n", szName);
  279. }
  280. else if(GetRegistryClsidKey(iid, "InprocServer32", szName,
  281. &cbValue))
  282. {
  283. Printf("%s(16)\n", szName);
  284. }
  285. else
  286. {
  287. Printf("-\n");
  288. }
  289. }
  290. }
  291. // Release allocated resources
  292. OleFree(pGuidPair);
  293. OleFree(pDwordPair);
  294. }