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.

248 lines
9.3 KiB

  1. #include <wmiexts.h>
  2. #include <malloc.h>
  3. #include <wbemint.h>
  4. #ifdef SetContext
  5. #undef SetContext
  6. #endif
  7. #ifdef GetContext
  8. #undef GetContext
  9. #endif
  10. #ifdef GetExpression
  11. #undef GetExpression
  12. #endif
  13. #include <utilfun.h>
  14. #define COREPROX_POLARITY
  15. #include <esssink.h>
  16. #include <ess.h>
  17. #include <nsrep.h>
  18. #include <equeue.h>
  19. DWORD
  20. CallBackEssNamespace(void * pKey, void * pValue)
  21. {
  22. WCHAR pName[MAX_PATH+1];
  23. pName[MAX_PATH] = 0;
  24. if (pKey && ReadMemory((ULONG_PTR)pKey,pName,MAX_PATH*sizeof(WCHAR),NULL))
  25. {
  26. dprintf(" %S\n",pName);
  27. }
  28. DEFINE_CPP_VAR(CEssNamespace,varCEssNamespace);
  29. CEssNamespace * pEssNameSpace = GET_CPP_VAR_PTR(CEssNamespace,varCEssNamespace);
  30. if (pValue && ReadMemory((ULONG_PTR)pValue,pEssNameSpace,sizeof(CEssNamespace),NULL))
  31. {
  32. dprintf(" %p\n",pValue);
  33. dprintf(" m_csLevel2: owner %x event %x\n",pEssNameSpace->m_csLevel2.m_dwThreadId,pEssNameSpace->m_csLevel2.m_hEvent);
  34. dprintf(" m_aDeferredEvents size %x %p\n",pEssNameSpace->m_aDeferredEvents.m_Array.m_nSize,pEssNameSpace->m_aDeferredEvents.m_Array.m_pArray);
  35. dprintf(" m_wszName %p\n",pEssNameSpace->m_wszName);
  36. dprintf(" m_pProviderFactory %p\n",pEssNameSpace->m_pProviderFactory);
  37. dprintf(" m_pCoreSvc %p\n",pEssNameSpace->m_pCoreSvc);
  38. dprintf(" m_pFullSvc %p\n",pEssNameSpace->m_pFullSvc);
  39. dprintf(" m_pInternalCoreSvc %p\n",pEssNameSpace->m_pInternalCoreSvc);
  40. dprintf(" m_pInternalFullSvc %p\n",pEssNameSpace->m_pInternalFullSvc);
  41. //
  42. CBindingTable * pBinding = &pEssNameSpace->m_Bindings;
  43. dprintf(" m_Binding\n");
  44. dprintf(" wbemess!CEventFilter\n");
  45. _Map * pMapF = (_Map *)((BYTE*)pValue+FIELD_OFFSET(CEssNamespace,m_Bindings)+FIELD_OFFSET(CBindingTable,m_apFilters)+FIELD_OFFSET(CSortedRefedKeyedPointerArray<CEventFilter>,m_t));
  46. //&pBinding->m_apFilters.m_t;
  47. PrintMapCB(pMapF,TRUE,CallBackObj);
  48. dprintf(" wbemess!CEventConsumer\n");
  49. _Map * pMapC = (_Map *)((BYTE*)pValue+FIELD_OFFSET(CEssNamespace,m_Bindings)+FIELD_OFFSET(CBindingTable,m_apConsumers)+FIELD_OFFSET(CSortedRefedKeyedPointerArray<CEventConsumer>,m_t));
  50. PrintMapCB(pMapC,TRUE,CallBackObj);
  51. DWORD NumEl = pEssNameSpace->m_ConsumerProviderCache.m_apRecords.m_Array.m_nSize;
  52. VOID * pVoid = pEssNameSpace->m_ConsumerProviderCache.m_apRecords.m_Array.m_pArray;
  53. VOID **ppPointers = (VOID **)_alloca(NumEl * sizeof(VOID *));
  54. dprintf(" wbemess!CConsumerProviderCache %x - %p\n",NumEl,pVoid);
  55. if (ReadMemory((ULONG_PTR)pVoid,ppPointers,NumEl * sizeof(VOID *),NULL))
  56. {
  57. for (DWORD i=0;i<NumEl;i++)
  58. {
  59. dprintf(" %x - %p\n",i,ppPointers[i]);
  60. }
  61. }
  62. dprintf(" ----------------------- End of Namespace\n");
  63. }
  64. return 0;
  65. }
  66. //
  67. // prototype declaration
  68. //
  69. void DumpRecord(ULONG_PTR pRecord_OOP,
  70. HANDLE hSourceProcess,
  71. pfnDumpRequest DumpRequest);
  72. DWORD DumpCExecRequest(ULONG_PTR pExecReq_OOP)
  73. {
  74. DEFINE_CPP_VAR(CEventQueue::CDeliverRequest,varCExecRequest);
  75. CEventQueue::CDeliverRequest * pExecReq = GET_CPP_VAR_PTR(CEventQueue::CDeliverRequest,varCExecRequest);
  76. ReadMemory((ULONG_PTR)pExecReq_OOP,pExecReq,sizeof(CEventQueue::CDeliverRequest),NULL);
  77. GetVTable((MEMORY_ADDRESS)pExecReq_OOP);
  78. dprintf(" %p m_hWhenDone\n",pExecReq->m_hWhenDone); // Ptr32 to Void
  79. dprintf(" %p m_pNext\n",pExecReq->m_pNext); // Ptr32 CCoreExecReq
  80. dprintf(" %08x m_lPriority\n",pExecReq->m_lPriority); // Int 4B
  81. dprintf(" %d m_fOk\n",pExecReq->m_fOk); // Char
  82. dprintf(" %p m_pConsumer ",pExecReq->m_pConsumer); // Ptr32 _IWmiCoreHandle
  83. if (pExecReq->m_pConsumer){
  84. GetVTable((MEMORY_ADDRESS)pExecReq->m_pConsumer);
  85. }
  86. return 0;
  87. }
  88. void
  89. Print_CEventQueue(ULONG_PTR pEventQueue_OOP, HANDLE hCurrentProcess)
  90. {
  91. DEFINE_CPP_VAR(CEventQueue,varCEventQueue);
  92. CEventQueue * pEventQueue = GET_CPP_VAR_PTR(CEventQueue,varCEventQueue);
  93. if (ReadMemory(pEventQueue_OOP,pEventQueue,sizeof(CEventQueue),NULL))
  94. {
  95. dprintf(" CEventQueue @ %p\n",pEventQueue);
  96. //m_aThreads : CFlexArray
  97. dprintf(" elems %d pointer %p\n",pEventQueue->m_aThreads.m_nSize,pEventQueue->m_aThreads.m_pArray);
  98. CExecQueue::CThreadRecord ** pRecord_OOP = (CExecQueue::CThreadRecord **)_alloca(sizeof(void*)*pEventQueue->m_aThreads.m_nSize);
  99. if (ReadMemory((ULONG_PTR)pEventQueue->m_aThreads.m_pArray,pRecord_OOP,sizeof(void*)*pEventQueue->m_aThreads.m_nSize,0))
  100. {
  101. DWORD i;
  102. for (i=0;i<pEventQueue->m_aThreads.m_nSize;i++)
  103. {
  104. dprintf(" -- CThreadRecord %d\n",i);
  105. DumpRecord((ULONG_PTR)pRecord_OOP[i],
  106. hCurrentProcess,
  107. DumpCExecRequest);
  108. }
  109. }
  110. dprintf(" m_pHead %p\n",pEventQueue->m_pHead);
  111. dprintf(" m_pTail %p\n",pEventQueue->m_pTail);
  112. // here code for the list
  113. CEventQueue::CDeliverRequest * pReq = (CEventQueue::CDeliverRequest *)pEventQueue->m_pHead;
  114. DWORD i = 0;
  115. while (pReq)
  116. {
  117. dprintf(" ---- list - %d\n",i++);
  118. DEFINE_CPP_VAR(CEventQueue::CDeliverRequest,MyAsyncReq);
  119. CEventQueue::CDeliverRequest * pReqHERE = GET_CPP_VAR_PTR(CEventQueue::CDeliverRequest,MyAsyncReq);
  120. ReadMemory((ULONG_PTR)pReq,pReqHERE,sizeof(CEventQueue::CDeliverRequest),NULL);
  121. //dprintf(" %p %p\n",pReq,pReqHERE->m_pNext);
  122. DumpCExecRequest((ULONG_PTR)pReq);
  123. if (pReq == pEventQueue->m_pTail)
  124. break;
  125. pReq = (CEventQueue::CDeliverRequest *)pReqHERE->m_pNext;
  126. if (CheckControlC())
  127. break;
  128. }
  129. //
  130. dprintf(" m_lNumThreads %d \n",pEventQueue->m_lNumThreads);
  131. dprintf(" m_lNumIdle %d\n",pEventQueue->m_lNumIdle);
  132. dprintf(" m_lNumRequests %d\n",pEventQueue->m_lNumRequests);
  133. dprintf(" m_lMaxThreads %d\n",pEventQueue->m_lMaxThreads);
  134. dprintf(" m_lHiPriBound %d\n",pEventQueue->m_lHiPriBound);
  135. dprintf(" m_lHiPriMaxThreads %d\n",pEventQueue->m_lHiPriMaxThreads);
  136. dprintf(" m_lStartSlowdownCount %d\n",pEventQueue->m_lStartSlowdownCount);
  137. dprintf(" m_lAbsoluteLimitCount %d\n",pEventQueue->m_lAbsoluteLimitCount);
  138. dprintf(" m_lOneSecondDelayCount %d\n",pEventQueue->m_lOneSecondDelayCount);
  139. dprintf(" m_dblAlpha %f\n",pEventQueue->m_dblAlpha);
  140. dprintf(" m_dblBeta %f\n",pEventQueue->m_dblBeta);
  141. dprintf(" m_dwTimeout %x\n",pEventQueue->m_dwTimeout);
  142. dprintf(" m_pEss %p\n",pEventQueue->m_pEss);
  143. }
  144. else
  145. {
  146. dprintf("RM %p\n",pEventQueue_OOP);
  147. }
  148. }
  149. DECLARE_API(ess)
  150. {
  151. INIT_API();
  152. ULONG_PTR Addr = (ExtensionApis.lpGetExpressionRoutine)("wbemcore!g_pESS");
  153. VOID * pVoid= NULL;
  154. if (!Addr)
  155. {
  156. pVoid = (VOID *)(ExtensionApis.lpGetExpressionRoutine)(args);
  157. }
  158. if (Addr || pVoid)
  159. {
  160. if (Addr)
  161. ReadMemory(Addr,&pVoid,sizeof(pVoid),NULL);
  162. DEFINE_CPP_VAR(CEssObjectSink::XNewESS,varImp);
  163. CEssObjectSink::XNewESS * pImp = GET_CPP_VAR_PTR(CEssObjectSink::XNewESS,varImp);
  164. if (ReadMemory((ULONG_PTR)pVoid,pImp,sizeof(CEssObjectSink::XNewESS),NULL))
  165. {
  166. dprintf(" CEssObjectSink %p\n",pImp->m_pObject);
  167. DEFINE_CPP_VAR(CEssObjectSink,varCEssObjectSink);
  168. CEssObjectSink * pEssSink = GET_CPP_VAR_PTR(CEssObjectSink,varCEssObjectSink);
  169. if (ReadMemory((ULONG_PTR)pImp->m_pObject,pEssSink,sizeof(CEssObjectSink),NULL))
  170. {
  171. Print_CEventQueue((ULONG_PTR)pEssSink->m_pEss+FIELD_OFFSET(CEss,m_Queue),hCurrentProcess);
  172. dprintf(" m_pEss %p\n",pEssSink->m_pEss);
  173. dprintf(" m_bShutdown %08x\n",pEssSink->m_bShutdown);
  174. dprintf(" m_pCoreServices %p\n",pEssSink->m_pCoreServices);
  175. // CEss;
  176. DEFINE_CPP_VAR(CEss,varCEss);
  177. CEss * pEss = GET_CPP_VAR_PTR(CEss,varCEss);
  178. if (ReadMemory((ULONG_PTR)pEssSink->m_pEss,pEss,sizeof(CEss),NULL))
  179. {
  180. _Map * pMap = (_Map *)((BYTE *)pEssSink->m_pEss + FIELD_OFFSET(CEss,m_mapNamespaces));
  181. PrintMapCB(pMap,TRUE,CallBackEssNamespace);
  182. }
  183. else
  184. {
  185. dprintf("RM %p err %d\n",pEssSink->m_pEss,GetLastError());
  186. }
  187. }
  188. else
  189. {
  190. dprintf("RM %p err %d\n",pImp->m_pObject,GetLastError());
  191. }
  192. }
  193. else
  194. {
  195. dprintf("RM %p err %d\n",Addr,GetLastError());
  196. }
  197. }
  198. else
  199. {
  200. dprintf("invalid address %s\n",args);
  201. }
  202. }