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.

298 lines
6.9 KiB

  1. /*++
  2. Copyright (c) 2001-2001 Microsoft Corporation
  3. Module Name:
  4. provutil.cpp
  5. Revision History:
  6. ivanbrug jan 2001 created
  7. --*/
  8. #include <wmiexts.h>
  9. #include <utilfun.h>
  10. #include <malloc.h>
  11. #include <wbemint.h>
  12. #ifdef SetContext
  13. #undef SetContext
  14. #endif
  15. #include <ProvSubS.h>
  16. //#include <provregdecoupled.h>
  17. //#include <provdcaggr.h>
  18. typedef ULONG_PTR CServerObject_DecoupledClientRegistration_Element;
  19. typedef ULONG_PTR CDecoupledAggregator_IWbemProvider;
  20. #include <provfact.h>
  21. //
  22. //
  23. // Dump the Provider cache
  24. //
  25. typedef WCHAR * WmiKey;
  26. typedef void * WmiElement;
  27. typedef WmiAvlTree<WmiKey,WmiElement>::WmiAvlNode Node;
  28. /*
  29. class Node {
  30. public:
  31. VOID * m_Key;
  32. Node * m_Left;
  33. Node * m_Right;
  34. Node * m_Parent;
  35. int m_Status;
  36. VOID * m_Element;
  37. };
  38. */
  39. class NodeBind;
  40. VOID DumpTreeBind(NodeBind * pNode_OOP,DWORD * pCount,BOOL * pbStop);
  41. VOID
  42. DumpTree(Node * pNode_OOP,DWORD * pCount,BOOL * pbStop)
  43. {
  44. if (!pNode_OOP)
  45. return;
  46. if (CheckControlC())
  47. {
  48. if(pbStop)
  49. *pbStop = TRUE;
  50. }
  51. if (pbStop)
  52. {
  53. if (*pbStop)
  54. return;
  55. }
  56. DEFINE_CPP_VAR(Node,MyNode);
  57. WCHAR pBuff[MAX_PATH+1];
  58. Node * pNode = GET_CPP_VAR_PTR(Node,MyNode);
  59. BOOL bRet;
  60. bRet = ReadMemory((ULONG_PTR)pNode_OOP,pNode,sizeof(Node),NULL);
  61. if (bRet)
  62. {
  63. DumpTree(pNode->m_Left,pCount,pbStop);
  64. //dprintf("--------\n");
  65. if (pCount) {
  66. *pCount++;
  67. };
  68. dprintf(" (L %p R %p P %p) %p\n",
  69. //pNode->m_Key,
  70. pNode->m_Left,
  71. pNode->m_Right,
  72. pNode->m_Parent,
  73. pNode->m_State);
  74. if (pNode->m_Key)
  75. {
  76. ReadMemory((ULONG_PTR)pNode->m_Key,pBuff,MAX_PATH*sizeof(WCHAR),NULL);
  77. pBuff[MAX_PATH] = 0;
  78. dprintf(" %S\n",pBuff);
  79. }
  80. dprintf(" - %p real %p\n",pNode->m_Element,((ULONG_PTR *)pNode->m_Element-4));
  81. if (pNode->m_Element)
  82. {
  83. GetVTable((MEMORY_ADDRESS)(pNode->m_Element));
  84. //
  85. // attention to the vtable trick !!!!
  86. //
  87. DEFINE_CPP_VAR(CServerObject_BindingFactory,MyFactory);
  88. CServerObject_BindingFactory * pBindF = GET_CPP_VAR_PTR(CServerObject_BindingFactory,MyFactory);
  89. BOOL bRet;
  90. bRet = ReadMemory((ULONG_PTR)((ULONG_PTR *)pNode->m_Element-4),pBindF,sizeof(CServerObject_BindingFactory),NULL);
  91. if (bRet)
  92. {
  93. DumpTreeBind((NodeBind *)pBindF->m_Cache.m_Root,pCount,pbStop);
  94. }
  95. }
  96. DumpTree(pNode->m_Right,pCount,pbStop);
  97. }
  98. }
  99. DECLARE_API(pc)
  100. {
  101. INIT_API();
  102. ULONG_PTR Addr = GetExpression("wbemcore!CCoreServices__m_pProvSS");
  103. if (Addr)
  104. {
  105. CServerObject_ProviderSubSystem * pProvSS_OOP = NULL;
  106. ReadMemory(Addr,&pProvSS_OOP,sizeof(void *),NULL);
  107. if (pProvSS_OOP)
  108. {
  109. dprintf("pProvSS %p\n",pProvSS_OOP);
  110. BOOL bRet;
  111. DEFINE_CPP_VAR(CServerObject_ProviderSubSystem,MyProvSS);
  112. CServerObject_ProviderSubSystem * pProvSS = GET_CPP_VAR_PTR(CServerObject_ProviderSubSystem,MyProvSS);
  113. bRet = ReadMemory((ULONG_PTR)pProvSS_OOP,pProvSS,sizeof(CServerObject_ProviderSubSystem),NULL);
  114. if (bRet)
  115. {
  116. DEFINE_CPP_VAR(CWbemGlobal_IWmiFactoryController_Cache,MyCacheNode);
  117. CWbemGlobal_IWmiFactoryController_Cache * pNodeCache = NULL; //GET_CPP_VAR_PTR(CWbemGlobal_IWmiFactoryController_Cache CacheNode,MyCacheNode);
  118. pNodeCache = &pProvSS->m_Cache;
  119. //dprintf(" root %p\n",pNodeCache->m_Root);
  120. DWORD Count = 0;
  121. BOOL bStop = FALSE;
  122. DumpTree((Node *)pNodeCache->m_Root,&Count,&bStop);
  123. //dprintf("traversed %d nodes\n",Count);
  124. }
  125. }
  126. }
  127. else
  128. {
  129. dprintf("invalid address %s\n",args);
  130. }
  131. }
  132. //
  133. //
  134. // CServerObject_BindingFactory
  135. //
  136. //////////////
  137. class NodeBind
  138. {
  139. public:
  140. ProviderCacheKey m_Key;
  141. NodeBind * m_Left;
  142. NodeBind * m_Right;
  143. NodeBind * m_Parent;
  144. int m_State;
  145. //WmiCacheController<ProviderCacheKey>::WmiCacheElement
  146. void * m_Element;
  147. };
  148. VOID
  149. DumpTreeBind(NodeBind * pNode_OOP,DWORD * pCount,BOOL * pbStop)
  150. {
  151. //dprintf("%p ????\n",pNode_OOP);
  152. if (!pNode_OOP)
  153. return;
  154. if (CheckControlC())
  155. {
  156. if(pbStop)
  157. *pbStop = TRUE;
  158. }
  159. if (pbStop)
  160. {
  161. if (*pbStop)
  162. return;
  163. }
  164. DEFINE_CPP_VAR(NodeBind,MyNode);
  165. static WCHAR pBuff[MAX_PATH+1];
  166. NodeBind * pNode = GET_CPP_VAR_PTR(NodeBind,MyNode);
  167. BOOL bRet;
  168. bRet = ReadMemory((ULONG_PTR)pNode_OOP,pNode,sizeof(NodeBind),NULL);
  169. if (bRet)
  170. {
  171. DumpTreeBind(pNode->m_Left,pCount,pbStop);
  172. //dprintf("--------\n");
  173. if (pCount) {
  174. *pCount++;
  175. };
  176. dprintf(" - (L %p R %p P %p) %p\n",
  177. pNode->m_Left,
  178. pNode->m_Right,
  179. pNode->m_Parent,
  180. pNode->m_State);
  181. if (pNode->m_Key.m_Provider)
  182. {
  183. ReadMemory((ULONG_PTR)pNode->m_Key.m_Provider,pBuff,MAX_PATH*sizeof(WCHAR),NULL);
  184. pBuff[MAX_PATH] = 0;
  185. dprintf(" Provider: %S\n",pBuff);
  186. }
  187. else
  188. {
  189. dprintf(" Provider: %p\n",0);
  190. }
  191. dprintf(" Hosting : %08x\n",pNode->m_Key.m_Hosting);
  192. if (pNode->m_Key.m_Group)
  193. {
  194. ReadMemory((ULONG_PTR)pNode->m_Key.m_Group,pBuff,MAX_PATH*sizeof(WCHAR),NULL);
  195. pBuff[MAX_PATH] = 0;
  196. dprintf(" Group : %S\n",pBuff);
  197. }
  198. else
  199. {
  200. dprintf(" Group : %p\n",0);
  201. }
  202. dprintf(" - %p\n",pNode->m_Element);
  203. if (pNode->m_Element)
  204. {
  205. GetVTable((MEMORY_ADDRESS)(pNode->m_Element));
  206. }
  207. DumpTreeBind(pNode->m_Right,pCount,pbStop);
  208. }
  209. }
  210. DECLARE_API(pf)
  211. {
  212. INIT_API();
  213. ULONG_PTR Addr = GetExpression(args);
  214. if (Addr)
  215. {
  216. DEFINE_CPP_VAR(CServerObject_BindingFactory,MyFactory);
  217. CServerObject_BindingFactory * pBindF = GET_CPP_VAR_PTR(CServerObject_BindingFactory,MyFactory);
  218. BOOL bRet;
  219. bRet = ReadMemory(Addr,pBindF,sizeof(CServerObject_BindingFactory),NULL);
  220. if (bRet)
  221. {
  222. dprintf(" root %p\n",pBindF->m_Cache.m_Root);
  223. DWORD Count = 0;
  224. BOOL bStop = FALSE;
  225. DumpTreeBind((NodeBind *)pBindF->m_Cache.m_Root,&Count,&bStop);
  226. }
  227. }
  228. else
  229. {
  230. dprintf("invalid address %s\n",args);
  231. }
  232. }