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.

142 lines
4.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995
  5. //
  6. // File: dtreatas.cxx
  7. //
  8. // Contents: Ole NTSD extension routines to display a dll/class cache
  9. //
  10. // Functions: displayTreatAsCache
  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 "dtreatas.h"
  21. extern BOOL fInScm;
  22. void FormatCLSID(REFGUID rguid, LPSTR lpsz);
  23. BOOL IsEqualCLSID(CLSID *pClsid1, CLSID *pClsid2);
  24. //+-------------------------------------------------------------------------
  25. //
  26. // Function: treatAsCacheHelp
  27. //
  28. // Synopsis: Display a menu for the command 'ds'
  29. //
  30. // Arguments: -
  31. //
  32. // Returns: -
  33. //
  34. // History: 07-Mar-95 BruceMa Created
  35. //
  36. //--------------------------------------------------------------------------
  37. void treatAsCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis)
  38. {
  39. Printf("ta - Display entire TreatAs class cache:\n");
  40. Printf("ta clsid - Display Treat As class for clsid (if any)\n");
  41. }
  42. //+-------------------------------------------------------------------------
  43. //
  44. // Function: displayTreatAsCache
  45. //
  46. // Synopsis: Formats and writes all or part of the TreatAs class cache
  47. //
  48. // Arguments: [hProcess] - Handle of this process
  49. // [lpExtensionApis] - Table of extension functions
  50. // [REFCLSID] - If not CLSID_NULL only for this clsid
  51. //
  52. // Returns: -
  53. //
  54. // History: 07-Mar-95 BruceMa Created
  55. //
  56. //--------------------------------------------------------------------------
  57. void displayTreatAsCache(HANDLE hProcess,
  58. PNTSD_EXTENSION_APIS lpExtensionApis,
  59. CLSID *clsid)
  60. {
  61. ULONG pAdr;
  62. BOOL fRetail;
  63. ULONG gptrtlstTreatClasses;
  64. ULONG pTreatAs;
  65. STreatList sTreatList;
  66. STreatEntry *pTreatEntry;
  67. BOOL fInit = TRUE;
  68. char szClsid[CLSIDSTR_MAX];
  69. // Determine if this is checked or retail ole
  70. if (fInScm)
  71. {
  72. pAdr = GetExpression("scm!_CairoleInfoLevel");
  73. }
  74. else
  75. {
  76. pAdr = GetExpression("ole32!_CairoleInfoLevel");
  77. }
  78. fRetail = pAdr == NULL ? TRUE : FALSE;
  79. // Read the pointer to the TreatAs class cache
  80. gptrtlstTreatClasses = GetExpression("ole32!gptrtlstTreatClasses");
  81. ReadMem(&pTreatAs, gptrtlstTreatClasses, sizeof(ULONG));
  82. if (pTreatAs == NULL)
  83. {
  84. return;
  85. }
  86. // Read the TreatAs cache header
  87. ReadMem(&sTreatList, pTreatAs, sizeof(STreatList));
  88. Printf(" clsid is treated as clsid\n");
  89. Printf("-------------------------------------- --------------------------------------\n");
  90. if (sTreatList._centries > 0)
  91. {
  92. // Read the array of entries
  93. pTreatEntry = (STreatEntry *) OleAlloc(sTreatList._centries *
  94. sizeof(STreatEntry));
  95. ReadMem(pTreatEntry, sTreatList._array.m_pData,
  96. sTreatList._centries * sizeof(STreatEntry));
  97. for (DWORD i = 0; i < sTreatList._centries; i++)
  98. {
  99. // Display the clsid and the TreatAs clsid
  100. if (clsid == NULL)
  101. {
  102. FormatCLSID(pTreatEntry[i]._clsid, szClsid);
  103. Printf("%s ", szClsid);
  104. FormatCLSID(pTreatEntry[i]._treatAsClsid, szClsid);
  105. Printf("%s\n", szClsid);
  106. }
  107. // We are looking for a particular clsid
  108. else if (IsEqualCLSID(clsid, &pTreatEntry[i]._clsid))
  109. {
  110. FormatCLSID(pTreatEntry[i]._clsid, szClsid);
  111. Printf("%s ", szClsid);
  112. FormatCLSID(pTreatEntry[i]._treatAsClsid, szClsid);
  113. Printf("%s\n", szClsid);
  114. return;
  115. }
  116. }
  117. }
  118. }
  119.