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.

232 lines
6.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995
  5. //
  6. // File: ddllcach.cxx
  7. //
  8. // Contents: Ole NTSD extension routines to display a dll/class cache
  9. //
  10. // Functions: displayDllCache
  11. //
  12. //
  13. // History: 06-01-95 BruceMa Created
  14. //
  15. //
  16. //--------------------------------------------------------------------------
  17. #include <ole2int.h>
  18. #include <windows.h>
  19. #include "ole.h"
  20. #include "ddllcach.h"
  21. void FormatCLSID(REFGUID rguid, LPSTR lpsz);
  22. //+-------------------------------------------------------------------------
  23. //
  24. // Function: dllCacheHelp
  25. //
  26. // Synopsis: Display a menu for the command 'ds'
  27. //
  28. // Arguments: -
  29. //
  30. // Returns: -
  31. //
  32. // History: 07-Mar-95 BruceMa Created
  33. //
  34. //--------------------------------------------------------------------------
  35. void dllCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis)
  36. {
  37. Printf("\nds - Display entire Inproc Server dll/class cache:\n");
  38. Printf("dh - Display entire Inproc Handler dll/class cache:\n\n");
  39. Printf("Dll's\n");
  40. Printf("-----\n");
  41. Printf("path hModule DllGetClassObject() DllCanUnloadNow() apt ... apt \n");
  42. Printf(" CLSID\n");
  43. Printf(" ...\n");
  44. Printf("...\n\n");
  45. Printf("LocalServers\n");
  46. Printf("------------\n");
  47. Printf("CLSID IUnknown* [M|S|MS] reg_key reg_@_scm\n");
  48. Printf("...\n\n");
  49. }
  50. //+-------------------------------------------------------------------------
  51. //
  52. // Function: displayDllCache
  53. //
  54. // Synopsis: Formats and writes a dll/class cache structure to the
  55. // debugger terminal
  56. //
  57. // Arguments: [hProcess] - Handle of this process
  58. // [lpExtensionApis] - Table of extension functions
  59. //
  60. // Returns: -
  61. //
  62. // History: 07-Mar-95 BruceMa Created
  63. //
  64. //--------------------------------------------------------------------------
  65. void displayDllCache(HANDLE hProcess,
  66. PNTSD_EXTENSION_APIS lpExtensionApis,
  67. SDllCache *pDllCache)
  68. {
  69. SDllPathEntry *pDllPathEntries;
  70. SClassEntry *pClassEntries;
  71. DWORD cbSize;
  72. // dbt("pDllCache", pDllCache, sizeof(SDllCache));
  73. // Fetch the array of dll path entries
  74. cbSize = sizeof(SDllPathEntry) * pDllCache->_cDllPathEntries;
  75. pDllPathEntries = (SDllPathEntry *) OleAlloc(cbSize);
  76. ReadMem(pDllPathEntries, pDllCache->_pDllPathEntries, cbSize);
  77. // dbt("pDllPathEntries", pDllPathEntries, cbSize);
  78. // Fetch the array of class entries
  79. cbSize = sizeof(SClassEntry) * pDllCache->_cClassEntries;
  80. pClassEntries = (SClassEntry *) OleAlloc(cbSize);
  81. ReadMem(pClassEntries, pDllCache->_pClassEntries, cbSize);
  82. // dbt("pClassEntries", pClassEntries, cbSize);
  83. // We do the dll's first
  84. Printf("Dll's:\n-----\n");
  85. // Do over the registered dll's
  86. for (DWORD dwDll = pDllCache->_nDllPathEntryInUse; dwDll != NONE;
  87. dwDll = pDllPathEntries[dwDll]._dwNext)
  88. {
  89. // Fetch the dll path
  90. WCHAR wszPath[MAX_PATH + 1];
  91. CHAR szPath[2 * MAX_PATH + 1];
  92. // We don't know the length of the path, so read one WCHAR
  93. // at a time
  94. INT k = -1;
  95. do
  96. {
  97. k++;
  98. ReadMem(&wszPath[k], &pDllPathEntries[dwDll]._pwszPath[k],
  99. sizeof(WCHAR));
  100. } until_(wszPath[k] == L'\0');
  101. Unicode2Ansi(szPath, wszPath, 2 * MAX_PATH + 1);
  102. // Fetch the apartment entries for this dll path entry
  103. SDllAptEntry *pAptEntries;
  104. cbSize = sizeof(SDllAptEntry) * pDllPathEntries[dwDll]._cAptEntries;
  105. pAptEntries = (SDllAptEntry *) OleAlloc(cbSize);
  106. ReadMem(pAptEntries, pDllPathEntries[dwDll]._pAptEntries,
  107. cbSize);
  108. // dbt("pAptEntries", pAptEntries, cbSize);
  109. // Display path
  110. Printf("%s ", szPath);
  111. // Display hModule and DllGetClassObject and DllCanUnloadNow entry
  112. // points
  113. Printf("%08x %08x %08x ",
  114. pAptEntries[pDllPathEntries[dwDll]._nAptInUse]._hDll,
  115. pDllPathEntries[dwDll]._pfnGetClassObject,
  116. pDllPathEntries[dwDll]._pfnDllCanUnload);
  117. // Display apartment id's
  118. for (DWORD dwApt = pDllPathEntries[dwDll]._nAptInUse; dwApt != NONE;
  119. dwApt = pAptEntries[dwApt]._dwNext)
  120. {
  121. Printf("%x ", pAptEntries[dwApt]._hApt);
  122. }
  123. Printf("\n");
  124. // Do over CLSID's for this dll
  125. for (DWORD dwCls = pDllPathEntries[dwDll]._dw1stClass; dwCls != NONE;
  126. dwCls = pClassEntries[dwCls]._dwNextDllCls)
  127. {
  128. // Display the CLSID
  129. CHAR szClsid[CLSIDSTR_MAX];
  130. FormatCLSID(pClassEntries[dwCls]._clsid, szClsid);
  131. Printf(" %s \n", szClsid);
  132. }
  133. // Release the apartment entries for this dll
  134. OleFree(pAptEntries);
  135. Printf("\n");
  136. }
  137. // Release the array of dll path entries
  138. OleFree(pDllPathEntries);
  139. // Then we do the local servers
  140. Printf("Local Servers:\n----------\n");
  141. // Do over the locally registerd local servers
  142. for (DWORD dwCls = pDllCache->_nClassEntryInUse; dwCls != NONE;
  143. dwCls = pClassEntries[dwCls]._dwNext)
  144. {
  145. // Skip class entries associated with dll's
  146. if (pClassEntries[dwCls]._dwDllEnt == NONE)
  147. {
  148. // Display the CLSID
  149. CHAR szClsid[CLSIDSTR_MAX];
  150. FormatCLSID(pClassEntries[dwCls]._clsid, szClsid);
  151. Printf(" %s ", szClsid);
  152. // The class factory punk
  153. Printf("%08x ", pClassEntries[dwCls]._pUnk);
  154. // The flags
  155. if (pClassEntries[dwCls]._dwFlags == REGCLS_SINGLEUSE)
  156. {
  157. Printf("S ");
  158. }
  159. else if (pClassEntries[dwCls]._dwFlags == REGCLS_MULTIPLEUSE)
  160. {
  161. Printf("M ");
  162. }
  163. else if (pClassEntries[dwCls]._dwFlags == REGCLS_MULTI_SEPARATE)
  164. {
  165. Printf("MS ");
  166. }
  167. // The registration key given to the user
  168. Printf("%08x ", pClassEntries[dwCls]._dwReg);
  169. // The registration key at the scm
  170. Printf("%08x ", pClassEntries[dwCls]._dwScmReg);
  171. // Whether this is an AtBits server
  172. if (pClassEntries[dwCls]._fAtBits)
  173. {
  174. Printf("AtBits\n");
  175. }
  176. else
  177. {
  178. Printf("\n");
  179. }
  180. }
  181. }
  182. Printf("\n");
  183. // Release the array of class entries
  184. OleFree(pClassEntries);
  185. }