Leaked source code of windows server 2003
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.

710 lines
25 KiB

  1. #include <wmiexts.h>
  2. #include <oleauto.h> // for BSTR definition
  3. #include <malloc.h>
  4. #include <helper.h>
  5. #include <autoptr.h>
  6. #include "utilfun.h"
  7. #ifndef COREPROX_POLARITY
  8. #define COREPROX_POLARITY
  9. #endif
  10. #include <wbemint.h>
  11. #include <var.h>
  12. typedef void IWbemCallSecurity;
  13. #ifndef INTERNAL
  14. #define INTERNAL
  15. #endif
  16. #ifndef ADDREF
  17. #define ADDREF
  18. #endif
  19. #ifndef READONLY
  20. #define READONLY
  21. #endif
  22. #ifdef GetContext
  23. #undef GetContext
  24. #endif
  25. #include <coreq.h>
  26. #include <wbemq.h>
  27. typedef void IWmiDbSession;
  28. typedef void IWmiDbController;
  29. typedef void IWmiDbHandle;
  30. typedef void CWbemObject;
  31. typedef void CWbemClass;
  32. typedef void CWbemInstance;
  33. class CWbemNamespace;
  34. typedef void * PF_FilterForwarder;
  35. #define ReleaseIfNotNULL
  36. class CAsyncReq;
  37. class ParsedObjectPath;
  38. class CWmiMerger;
  39. #include <winntsec.h>
  40. #include <wstring.h>
  41. #include <sinks.h>
  42. #include <dynasty.h>
  43. #include <ql.h>
  44. #include <wbemname.h>
  45. #include <wmitask.h>
  46. class CAsyncReq : public CWbemRequest
  47. {
  48. protected:
  49. CStdSink *m_pHandler;
  50. long m_lRequestHandle;
  51. };
  52. class CAsyncServiceQueue : public CWbemQueue{
  53. };
  54. /*
  55. class CFlexArray {
  56. private:
  57. DWORD m_nSize;
  58. DWORD m_nExtent;
  59. DWORD m_nGrowByPercent;
  60. void * m_pArray;
  61. }
  62. */
  63. /*
  64. typedef
  65. enum tag_WMI_TASK_TYPE
  66. { WMICORE_TASK_NULL = 0,
  67. WMICORE_TASK_GET_OBJECT = 1,
  68. WMICORE_TASK_GET_INSTANCE = 2,
  69. WMICORE_TASK_PUT_INSTANCE = 3,
  70. WMICORE_TASK_DELETE_INSTANCE = 4,
  71. WMICORE_TASK_ENUM_INSTANCES = 5,
  72. WMICORE_TASK_GET_CLASS = 6,
  73. WMICORE_TASK_PUT_CLASS = 7,
  74. WMICORE_TASK_DELETE_CLASS = 8,
  75. WMICORE_TASK_ENUM_CLASSES = 9,
  76. WMICORE_TASK_EXEC_QUERY = 10,
  77. WMICORE_TASK_EXEC_METHOD = 11,
  78. WMICORE_TASK_OPEN = 12,
  79. WMICORE_TASK_OPEN_SCOPE = 13,
  80. WMICORE_TASK_OPEN_NAMESPACE = 14,
  81. WMICORE_TASK_OPEN_COLLECTION = 15,
  82. WMICORE_TASK_ADD = 16,
  83. WMICORE_TASK_REMOVE = 17,
  84. WMICORE_TASK_REFRESH_OBJECT = 18,
  85. WMICORE_TASK_RENAME_OBJECT = 19,
  86. WMICORE_TASK_ATOMIC_DYN_INST_GET = 20,
  87. WMICORE_TASK_ATOMIC_DYN_INST_ENUM = 21,
  88. WMICORE_TASK_ATOMIC_DYN_INST_QUERY = 22,
  89. WMICORE_TASK_ATOMIC_DYN_INST_PUT = 23,
  90. WMICORE_TASK_DYN_CLASS_ENUM = 24,
  91. WMICORE_TASK_EXEC_NOTIFICATION_QUERY = 25,
  92. WMICORE_TASK_TYPE_SYNC = 0x1000000,
  93. WMICORE_TASK_TYPE_SEMISYNC = 0x2000000,
  94. WMICORE_TASK_TYPE_ASYNC = 0x4000000,
  95. WMICORE_TASK_TYPE_PRIMARY = 0x10000000,
  96. WMICORE_TASK_TYPE_SUBTASK = 0x20000000,
  97. WMICORE_TASK_TYPE_DEPENDENT = 0x40000000
  98. } WMI_TASK_TYPE;
  99. typedef
  100. enum tag_WMICORE_TASK_STATUS
  101. { WMICORE_TASK_STATUS_NEW = 1,
  102. WMICORE_TASK_STATUS_VALIDATED = WMICORE_TASK_STATUS_NEW + 1,
  103. WMICORE_TASK_STATUS_SUSPENDED = WMICORE_TASK_STATUS_VALIDATED + 1,
  104. WMICORE_TASK_STATUS_EXECUTING = WMICORE_TASK_STATUS_SUSPENDED + 1,
  105. WMICORE_TASK_STATUS_WAITING_ON_SUBTASKS = WMICORE_TASK_STATUS_EXECUTING + 1,
  106. WMICORE_TASK_STATUS_TIMED_OUT = WMICORE_TASK_STATUS_WAITING_ON_SUBTASKS + 1,
  107. WMICORE_TASK_STATUS_CORE_COMPLETED = WMICORE_TASK_STATUS_TIMED_OUT + 1,
  108. WMICORE_TASK_STATUS_CLIENT_COMPLETED = WMICORE_TASK_STATUS_CORE_COMPLETED + 1,
  109. WMICORE_TASK_STATUS_CANCELLED = WMICORE_TASK_STATUS_CLIENT_COMPLETED + 1,
  110. WMICORE_TASK_STATUS_FAILED = WMICORE_TASK_STATUS_CANCELLED + 1
  111. } WMICORE_TASK_STATUS;
  112. */
  113. //typedef void CWbemNamespace;
  114. char * GetTaskStatus(DWORD TaskStatus)
  115. {
  116. char * p = "<unk>";
  117. switch(TaskStatus)
  118. {
  119. case WMICORE_TASK_STATUS_NEW: p = "WMICORE_TASK_STATUS_NEW"; break;
  120. case WMICORE_TASK_STATUS_VALIDATED: p = "WMICORE_TASK_STATUS_VALIDATED"; break;
  121. case WMICORE_TASK_STATUS_SUSPENDED: p = "WMICORE_TASK_STATUS_SUSPENDED"; break;
  122. case WMICORE_TASK_STATUS_EXECUTING: p = "WMICORE_TASK_STATUS_EXECUTING"; break;
  123. case WMICORE_TASK_STATUS_WAITING_ON_SUBTASKS: p = "WMICORE_TASK_STATUS_WAITING_ON_SUBTASKS"; break;
  124. case WMICORE_TASK_STATUS_TIMED_OUT: p = "WMICORE_TASK_STATUS_TIMED_OUT"; break;
  125. case WMICORE_TASK_STATUS_CORE_COMPLETED: p = "WMICORE_TASK_STATUS_CORE_COMPLETED"; break;
  126. case WMICORE_TASK_STATUS_CLIENT_COMPLETED: p = "WMICORE_TASK_STATUS_CLIENT_COMPLETED"; break;
  127. case WMICORE_TASK_STATUS_CANCELLED: p = "WMICORE_TASK_STATUS_CANCELLED"; break;
  128. case WMICORE_TASK_STATUS_FAILED: p = "WMICORE_TASK_STATUS_FAILED";
  129. break;
  130. };
  131. return p;
  132. }
  133. char * GetTaskType(DWORD TaskType)
  134. {
  135. char * p = "<unk>";
  136. switch(TaskType & 0xFF)
  137. {
  138. case WMICORE_TASK_NULL: p = "WMICORE_TASK_NULL"; break;
  139. case WMICORE_TASK_GET_OBJECT: p = "WMICORE_TASK_GET_OBJECT"; break;
  140. case WMICORE_TASK_GET_INSTANCE: p = "WMICORE_TASK_GET_INSTANCE"; break;
  141. case WMICORE_TASK_PUT_INSTANCE: p = "WMICORE_TASK_PUT_INSTANCE"; break;
  142. case WMICORE_TASK_DELETE_INSTANCE: p = "WMICORE_TASK_DELETE_INSTANCE"; break;
  143. case WMICORE_TASK_ENUM_INSTANCES: p = "WMICORE_TASK_ENUM_INSTANCES"; break;
  144. case WMICORE_TASK_GET_CLASS: p = "WMICORE_TASK_GET_CLASS"; break;
  145. case WMICORE_TASK_PUT_CLASS: p = "WMICORE_TASK_PUT_CLASS"; break;
  146. case WMICORE_TASK_DELETE_CLASS: p = "WMICORE_TASK_DELETE_CLASS"; break;
  147. case WMICORE_TASK_ENUM_CLASSES: p = "WMICORE_TASK_ENUM_CLASSES"; break;
  148. case WMICORE_TASK_EXEC_QUERY: p = "WMICORE_TASK_EXEC_QUERY"; break;
  149. case WMICORE_TASK_EXEC_METHOD: p = "WMICORE_TASK_EXEC_METHOD"; break;
  150. case WMICORE_TASK_OPEN: p = "WMICORE_TASK_OPEN"; break;
  151. case WMICORE_TASK_OPEN_SCOPE: p = "WMICORE_TASK_OPEN_SCOPE"; break;
  152. case WMICORE_TASK_OPEN_NAMESPACE: p = "WMICORE_TASK_OPEN_NAMESPACE"; break;
  153. case WMICORE_TASK_EXEC_NOTIFICATION_QUERY: p = "WMICORE_TASK_EXEC_NOTIFICATION_QUERY"; break;
  154. }
  155. return p;
  156. }
  157. char * GetOpType(DWORD TaskType)
  158. {
  159. if (TaskType & WMICORE_TASK_TYPE_SYNC)
  160. return " WMICORE_TASK_TYPE_SYNC";
  161. if (TaskType & WMICORE_TASK_TYPE_SEMISYNC)
  162. return " WMICORE_TASK_TYPE_SEMISYNC";
  163. if (TaskType & WMICORE_TASK_TYPE_ASYNC)
  164. return " WMICORE_TASK_TYPE_ASYNC";
  165. if (TaskType & WMICORE_TASK_TYPE_PRIMARY)
  166. return " WMICORE_TASK_TYPE_PRIMARY";
  167. if (TaskType & WMICORE_TASK_TYPE_DEPENDENT)
  168. return " WMICORE_TASK_TYPE_DEPENDENT";
  169. return "<unk>";
  170. }
  171. void DumpCWmiTask(CWmiTask * pTask_OOP)
  172. {
  173. DEFINE_CPP_VAR(CWmiTask, MyWmiTask);
  174. if (ReadMemory((ULONG_PTR)pTask_OOP,&MyWmiTask,sizeof(MyWmiTask),0))
  175. {
  176. CWmiTask * pWmiTask = (CWmiTask *)&MyWmiTask;
  177. dprintf(" m_uRefCount %d\n",pWmiTask->m_uRefCount); //: 0x3
  178. dprintf(" m_uTaskType %s %s\n",GetTaskType(pWmiTask->m_uTaskType),GetOpType(pWmiTask->m_uTaskType)); //: 0x11000005
  179. dprintf(" m_uTaskStatus %s\n",GetTaskStatus(pWmiTask->m_uTaskStatus)); //: 0x0
  180. dprintf(" m_uTaskId %p\n",pWmiTask->m_uTaskId); //: 0x17f
  181. dprintf(" m_pAsyncClientSink %p\n",pWmiTask->m_pAsyncClientSink); //: (null)
  182. dprintf(" m_pReqSink %p\n",pWmiTask->m_pReqSink); //: 0x06e0cc80
  183. //dprintf(" m_pWorkingFnz %p\n",pWmiTask->m_pWorkingFnz); //: 0x01395ed8
  184. //dprintf(" m_pUser %p\n",pWmiTask->m_pUser); //: (null)
  185. //dprintf(" m_pSec %p\n",pWmiTask->m_pSec); //: (null)
  186. dprintf(" m_pAsyncClientSink %p\n",pWmiTask->m_pAsyncClientSink); //: (null)
  187. dprintf(" m_pNs %p\n",pWmiTask->m_pNs); //: 0x0131a198
  188. DWORD i;
  189. VOID ** ppPointers = (VOID **)_alloca(max(pWmiTask->m_aTaskProviders.m_nSize,pWmiTask->m_aArbitratees.m_nSize));
  190. dprintf(" m_aTaskProviders: size %x p %p\n",
  191. pWmiTask->m_aTaskProviders.m_nSize,
  192. pWmiTask->m_aTaskProviders.m_pArray);
  193. if (pWmiTask->m_aTaskProviders.m_nSize)
  194. {
  195. if (ReadMemory((ULONG_PTR)pWmiTask->m_aTaskProviders.m_pArray,ppPointers,sizeof(void *)*pWmiTask->m_aTaskProviders.m_nSize,NULL))
  196. {
  197. for(i=0;i<pWmiTask->m_aTaskProviders.m_nSize;i++)
  198. {
  199. dprintf(" %p - %x\n",ppPointers[i],i);
  200. GetVTable((MEMORY_ADDRESS)ppPointers[i]);
  201. }
  202. }
  203. }
  204. dprintf(" m_aArbitratees: size %x p %p\n",
  205. pWmiTask->m_aArbitratees.m_nSize,
  206. pWmiTask->m_aArbitratees.m_pArray);
  207. if (pWmiTask->m_aArbitratees.m_nSize)
  208. {
  209. if (ReadMemory((ULONG_PTR)pWmiTask->m_aArbitratees.m_pArray,ppPointers,sizeof(void *)*pWmiTask->m_aArbitratees.m_nSize,NULL))
  210. {
  211. for(i=0;i<pWmiTask->m_aArbitratees.m_nSize;i++)
  212. {
  213. dprintf(" %p - %x\n",ppPointers[i],i);
  214. GetVTable((MEMORY_ADDRESS)ppPointers[i]);
  215. }
  216. }
  217. }
  218. }
  219. else
  220. {
  221. dprintf("RM %p\n",pTask_OOP);
  222. }
  223. }
  224. DWORD DumpCAsyncReq(ULONG_PTR pAsyncReq_OOP)
  225. {
  226. DEFINE_CPP_VAR(CAsyncReq,MyCAsyncReq);
  227. if (ReadMemory((ULONG_PTR)pAsyncReq_OOP,&MyCAsyncReq,sizeof(CAsyncReq),NULL))
  228. {
  229. CAsyncReq * pAsyncReq = (CAsyncReq *)&MyCAsyncReq;
  230. GetVTable((MEMORY_ADDRESS)pAsyncReq_OOP);
  231. dprintf(" %p m_hWhenDone\n",pAsyncReq->m_hWhenDone); // Ptr32 to Void
  232. dprintf(" %p m_pNext\n",pAsyncReq->m_pNext); // Ptr32 CCoreExecReq
  233. dprintf(" %08x m_lPriority\n",pAsyncReq->m_lPriority); // Int 4B
  234. dprintf(" %d m_fOk\n",pAsyncReq->m_fOk); // Char
  235. dprintf(" %p m_phTask ",pAsyncReq->m_phTask); // Ptr32 _IWmiCoreHandle
  236. if (pAsyncReq->m_phTask){
  237. DumpCWmiTask((CWmiTask *)pAsyncReq->m_phTask);
  238. }
  239. dprintf(" %p m_pContext\n",pAsyncReq->m_pContext); // Ptr32 IWbemContext
  240. dprintf(" %p m_pCA\n",pAsyncReq->m_pCA); // Ptr32 IWbemCausalityAccess
  241. dprintf(" %p m_pCallSec\n",pAsyncReq->m_pCallSec); // Ptr32 IWbemCallSecurity
  242. dprintf(" %p m_pHandler ",pAsyncReq->m_pHandler); // Ptr32 CStdSink
  243. //GetVTable(pAsyncReq->m_pHandler);
  244. dprintf(" %08x m_lRequestHandle\n",pAsyncReq->m_lRequestHandle); // Int 4B
  245. }
  246. else
  247. {
  248. dprintf("RM %p\n",pAsyncReq_OOP);
  249. }
  250. return 0;
  251. }
  252. DWORD EnumListNamespaces(VOID * pStructure_OOP,
  253. VOID * pLocalStructure)
  254. {
  255. /*
  256. DEFINE_CPP_VAR(CWbemNamespace, MyWbemNamespace);
  257. ReadMemory((ULONG_PTR)pNamespace_OOP,&MyWbemNamespace,sizeof(CWbemNamespace),0);
  258. */
  259. dprintf(" - CWbemNamespace @ %p\n",pStructure_OOP);
  260. CWbemNamespace * pName = (CWbemNamespace *)pLocalStructure;
  261. dprintf(" m_bShutDown %d\n",pName->m_bShutDown);
  262. dprintf(" Status %d\n",pName->Status);
  263. dprintf(" m_uSecondaryRefCount %d\n",pName->m_uSecondaryRefCount);
  264. //
  265. WCHAR pBuff[MAX_PATH];
  266. ReadMemory((ULONG_PTR)pName->m_pThisNamespace,pBuff,sizeof(pBuff),0);
  267. pBuff[MAX_PATH-1] = 0; // in any case
  268. dprintf(" m_pThisNamespace %S\n",pBuff);
  269. dprintf(" m_pProvFact %p\n",pName->m_pProvFact);
  270. dprintf(" m_pCoreSvc %p\n",pName->m_pCoreSvc);
  271. dprintf(" m_bRepositOnly %d\n",pName->m_bRepositOnly);
  272. dprintf(" m_pRefreshingSvc %p\n",pName->m_pRefreshingSvc);
  273. dprintf(" m_bESS %d\n",pName->m_bESS);
  274. return 0;
  275. }
  276. void GetThreadInfo(HANDLE hThread,HANDLE hSourceProcess)
  277. {
  278. HANDLE hThreadThisProc;
  279. if (DuplicateHandle(hSourceProcess,
  280. hThread,
  281. GetCurrentProcess(),
  282. &hThreadThisProc,
  283. 0,
  284. FALSE,
  285. DUPLICATE_SAME_ACCESS))
  286. {
  287. NTSTATUS Status;
  288. ULONG Long;
  289. THREAD_BASIC_INFORMATION TBasicInfo;
  290. Status = NtQueryInformationThread(hThreadThisProc,
  291. ThreadBasicInformation,
  292. &TBasicInfo,
  293. sizeof(TBasicInfo),
  294. &Long);
  295. if ( Status == 0 )
  296. {
  297. dprintf(" %p %x.%x\n",TBasicInfo.TebBaseAddress,TBasicInfo.ClientId.UniqueProcess,TBasicInfo.ClientId.UniqueThread);
  298. }
  299. else
  300. {
  301. dprintf(" NTSTATUS %08x\n",Status);
  302. }
  303. CloseHandle(hThreadThisProc);
  304. }
  305. else
  306. {
  307. dprintf("DuplicateHandle %d\n",GetLastError());
  308. }
  309. }
  310. void DumpRecord(ULONG_PTR pRecord_OOP,
  311. HANDLE hSourceProcess,
  312. pfnDumpRequest DumpRequest)
  313. {
  314. DEFINE_CPP_VAR(CCoreQueue::CThreadRecord,MyThreadRecord);
  315. if (ReadMemory((ULONG_PTR)pRecord_OOP,&MyThreadRecord,sizeof(CCoreQueue::CThreadRecord),NULL))
  316. {
  317. CCoreQueue::CThreadRecord * pRecord = (CCoreQueue::CThreadRecord *)&MyThreadRecord;
  318. //dprintf(" %p m_pQueue\n",pRecord->m_pQueue); //: Ptr32 CCoreQueue
  319. dprintf(" %p m_pCurrentRequest",pRecord->m_pCurrentRequest);// : Ptr32 CCoreExecReq
  320. dprintf(" %d m_bReady",pRecord->m_bReady); //: Int 4B
  321. dprintf(" %d m_bExitNow",pRecord->m_bExitNow); //: Int 4B
  322. dprintf(" %p m_hThread",pRecord->m_hThread); //: Ptr32 to Void
  323. dprintf(" %p m_hAttention\n",pRecord->m_hAttention); //: Ptr32 to Void
  324. GetThreadInfo(pRecord->m_hThread,hSourceProcess);
  325. if (pRecord->m_pCurrentRequest)
  326. {
  327. //DumpCAsyncReq((CAsyncReq *)pRecord->m_pCurrentRequest);
  328. if (DumpRequest)
  329. DumpRequest((ULONG_PTR)pRecord->m_pCurrentRequest);
  330. }
  331. }
  332. else
  333. {
  334. dprintf("RM %p\n",pRecord_OOP);
  335. }
  336. }
  337. DECLARE_API( q )
  338. {
  339. INIT_API();
  340. ULONG_PTR Addr = GetExpression("wbemcore!g_pAsyncSvcQueue");
  341. if (Addr)
  342. {
  343. CAsyncServiceQueue * pAsyncQueue = NULL;
  344. if (ReadMemory(Addr,&pAsyncQueue,sizeof(CAsyncServiceQueue *),0))
  345. {
  346. dprintf("CAsyncServiceQueue %p\n",pAsyncQueue);
  347. DEFINE_CPP_VAR(CAsyncServiceQueue,MyAsyncServiceQueue);
  348. if (ReadMemory((ULONG_PTR)pAsyncQueue,&MyAsyncServiceQueue,sizeof(CAsyncServiceQueue),NULL))
  349. {
  350. pAsyncQueue = (CAsyncServiceQueue *)&MyAsyncServiceQueue;
  351. //m_aThreads : CFlexArray
  352. dprintf(" elems %d pointer %p\n",pAsyncQueue->m_aThreads.m_nSize,pAsyncQueue->m_aThreads.m_pArray);
  353. CCoreQueue::CThreadRecord ** pRecord_OOP = (CCoreQueue::CThreadRecord **)_alloca(sizeof(void*)*pAsyncQueue->m_aThreads.m_nSize);
  354. if (ReadMemory((ULONG_PTR)pAsyncQueue->m_aThreads.m_pArray,pRecord_OOP,sizeof(void*)*pAsyncQueue->m_aThreads.m_nSize,0))
  355. {
  356. DWORD i;
  357. for (i=0;i<pAsyncQueue->m_aThreads.m_nSize;i++)
  358. {
  359. dprintf(" -- CThreadRecord %p - %d\n",pRecord_OOP[i],i);
  360. DumpRecord((ULONG_PTR)pRecord_OOP[i],hCurrentProcess,DumpCAsyncReq);
  361. }
  362. }
  363. else
  364. {
  365. dprintf("RM %p\n",pRecord_OOP);
  366. }
  367. dprintf(" m_pHead %p\n",pAsyncQueue->m_pHead);
  368. dprintf(" m_pTail %p\n",pAsyncQueue->m_pTail);
  369. // here code for the list
  370. CCoreExecReq * pReq = pAsyncQueue->m_pHead;
  371. DWORD i = 0;
  372. while (pReq)
  373. {
  374. dprintf(" ---- list - %d\n",i++);
  375. DEFINE_CPP_VAR(CCoreExecReq,MyAsyncReq);
  376. CCoreExecReq * pReqHERE = GET_CPP_VAR_PTR(CCoreExecReq,MyAsyncReq);
  377. if (ReadMemory((ULONG_PTR)pReq,pReqHERE,sizeof(CCoreExecReq),NULL))
  378. {
  379. //dprintf(" %p %p\n",pReq,pReqHERE->m_pNext);
  380. DumpCAsyncReq((ULONG_PTR)pReq);
  381. }
  382. else
  383. {
  384. dprintf("RM %p\n",pReq);
  385. break;
  386. }
  387. if (pReq == pAsyncQueue->m_pTail)
  388. break;
  389. pReq = pReqHERE->m_pNext;
  390. if (CheckControlC())
  391. break;
  392. }
  393. //
  394. dprintf(" m_lNumThreads %d \n",pAsyncQueue->m_lNumThreads);
  395. dprintf(" m_lNumIdle %d\n",pAsyncQueue->m_lNumIdle);
  396. dprintf(" m_lNumRequests %d\n",pAsyncQueue->m_lNumRequests);
  397. dprintf(" m_lMaxThreads %d\n",pAsyncQueue->m_lMaxThreads);
  398. dprintf(" m_lHiPriBound %d\n",pAsyncQueue->m_lHiPriBound);
  399. dprintf(" m_lHiPriMaxThreads %d\n",pAsyncQueue->m_lHiPriMaxThreads);
  400. dprintf(" m_lStartSlowdownCount %d\n",pAsyncQueue->m_lStartSlowdownCount);
  401. dprintf(" m_lAbsoluteLimitCount %d\n",pAsyncQueue->m_lAbsoluteLimitCount);
  402. dprintf(" m_lOneSecondDelayCount %d\n",pAsyncQueue->m_lOneSecondDelayCount);
  403. dprintf(" m_dblAlpha %f\n",pAsyncQueue->m_dblAlpha);
  404. dprintf(" m_dblBeta %f\n",pAsyncQueue->m_dblBeta);
  405. dprintf(" m_dwTimeout %x\n",pAsyncQueue->m_dwTimeout);
  406. // m_dwOverflowTimeout
  407. // m_lChildPenalty
  408. // m_lSiblingPenalty
  409. // m_lPassingPenalty
  410. }
  411. else
  412. {
  413. dprintf("RM %p\n",pAsyncQueue);
  414. }
  415. }
  416. else
  417. {
  418. dprintf("RM %p\n",Addr);
  419. }
  420. }
  421. else
  422. {
  423. dprintf("unable to resolve wbemcore!g_pAsyncSvcQueue");
  424. }
  425. }
  426. #include <wmiarbitrator.h>
  427. void Dump_CWmiFinalizer()
  428. {
  429. DWORD Val;
  430. ULONG_PTR pAddr;
  431. pAddr = GetExpression("wbemcore!s_Finalizer_ObjectCount");
  432. ReadMemory(pAddr,&Val,sizeof(DWORD),NULL);
  433. dprintf(" s_Finalizer_ObjectCount = %d\n",Val);
  434. pAddr = GetExpression("wbemcore!s_FinalizerCallResult_ObjectCount");
  435. ReadMemory(pAddr,&Val,sizeof(DWORD),NULL);
  436. dprintf(" s_FinalizerCallResult_ObjectCount = %d\n",Val);
  437. pAddr = GetExpression("wbemcore!s_FinalizerEnum_ObjectCount");
  438. ReadMemory(pAddr,&Val,sizeof(DWORD),NULL);
  439. dprintf(" s_FinalizerEnum_ObjectCount = %d\n",Val);
  440. pAddr = GetExpression("wbemcore!s_FinalizerEnumSink_ObjectCount");
  441. ReadMemory(pAddr,&Val,sizeof(DWORD),NULL);
  442. dprintf(" s_FinalizerEnumSink_ObjectCount = %d\n",Val);
  443. pAddr = GetExpression("wbemcore!s_FinalizerInBoundSink_ObjectCount");
  444. ReadMemory(pAddr,&Val,sizeof(DWORD),NULL);
  445. dprintf(" s_FinalizerInBoundSink_ObjectCount = %d\n\n",Val);
  446. }
  447. void
  448. DumpCProvSink(CProviderSink * pProvSink)
  449. {
  450. dprintf(" Total Indicates = %d\n", pProvSink->m_lIndicateCount);
  451. WCHAR pString[MAX_PATH+1];
  452. pString[MAX_PATH] = 0;
  453. if (ReadMemory((ULONG_PTR)pProvSink->m_pszDebugInfo,pString,MAX_PATH*sizeof(WCHAR),NULL))
  454. {
  455. dprintf(" Debug Info = %S\n",pString);
  456. }
  457. dprintf(" SetStatus called? %d\n", pProvSink->m_bDone);
  458. dprintf(" hRes = 0x%x\n", pProvSink->m_hRes);
  459. dprintf(" m_pNextSink = %p\n", pProvSink->m_pNextSink);
  460. }
  461. DECLARE_API( arb )
  462. {
  463. INIT_API();
  464. CWmiArbitrator * pArbit_OOP = NULL;
  465. ULONG_PTR Addr = GetExpression(args);
  466. if (NULL == Addr)
  467. {
  468. Addr = GetExpression("wbemcore!CWmiArbitrator__m_pArb");
  469. if (Addr)
  470. {
  471. if (ReadMemory(Addr,&pArbit_OOP,sizeof(CWmiArbitrator *),0))
  472. {
  473. }
  474. else
  475. {
  476. dprintf("RM %p\n",Addr);
  477. }
  478. }
  479. else
  480. {
  481. dprintf("unable to resolve wbemcore!CWmiArbitrator__m_pArb\n");
  482. }
  483. }
  484. else
  485. pArbit_OOP = (CWmiArbitrator *)Addr;
  486. if (pArbit_OOP)
  487. {
  488. DWORD Val;
  489. ULONG_PTR pAddr;
  490. pAddr = GetExpression("wbemcore!g_nSinkCount");
  491. ReadMemory(pAddr,&Val,sizeof(DWORD),NULL);
  492. dprintf("Total sinks active = %d\n",Val);
  493. pAddr = GetExpression("wbemcore!g_nStdSinkCount");
  494. ReadMemory(pAddr,&Val,sizeof(DWORD),NULL);
  495. dprintf("Total std sink objects = %d\n",Val);
  496. pAddr = GetExpression("wbemcore!g_nSynchronousSinkCount");
  497. ReadMemory(pAddr,&Val,sizeof(DWORD),NULL);
  498. dprintf("Total Sync sink objects = %d\n",Val);
  499. pAddr = GetExpression("wbemcore!g_nProviderSinkCount");
  500. ReadMemory(pAddr,&Val,sizeof(DWORD),NULL);
  501. dprintf("Total Prov sink objects = %d\n",Val);
  502. pAddr = GetExpression("wbemcore!g_lCoreThreads");
  503. ReadMemory(pAddr,&Val,sizeof(DWORD),NULL);
  504. dprintf("Total Core Threads = %d\n",Val);
  505. pAddr = GetExpression("fastprox!g_lDebugObjCount");
  506. ReadMemory(pAddr,&Val,sizeof(DWORD),NULL);
  507. dprintf("Total Obj-QualSets = %d\n",Val);
  508. Dump_CWmiFinalizer();
  509. DEFINE_CPP_VAR(CWmiArbitrator,varWmiArbitrator);
  510. CWmiArbitrator * pArbit = GET_CPP_VAR_PTR(CWmiArbitrator,varWmiArbitrator);
  511. dprintf("CWmiArbitrator %p\n",pArbit_OOP);
  512. if (ReadMemory((ULONG_PTR)pArbit_OOP,pArbit,sizeof(CWmiArbitrator),NULL))
  513. {
  514. dprintf(" m_lRefCount %d\n",pArbit->m_lRefCount);
  515. dprintf(" m_uTotalTasks %d\n",pArbit->m_uTotalTasks);
  516. dprintf(" m_uTotalPrimaryTasks %d\n",pArbit->m_uTotalPrimaryTasks);
  517. DWORD dwTot = pArbit->m_aTasks.m_nSize*sizeof(void*);
  518. void ** pMem = new void *[dwTot];
  519. DWORD i;
  520. dprintf(" m_aTasks P %p S %x\n",pArbit->m_aTasks.m_pArray,pArbit->m_aTasks.m_nSize);
  521. if (ReadMemory((ULONG_PTR)pArbit->m_aTasks.m_pArray,pMem,dwTot,0))
  522. {
  523. for (i=0;i<pArbit->m_aTasks.m_nSize;i++)
  524. {
  525. dprintf(" - CWmiTask %d - %p\n",i,pMem[i]);
  526. if (pMem[i])
  527. {
  528. DumpCWmiTask((CWmiTask *)pMem[i]);
  529. }
  530. else
  531. {
  532. dprintf(" <NULL>\n");
  533. }
  534. }
  535. }
  536. else
  537. {
  538. dprintf("RM %p\n",pArbit->m_aTasks.m_pArray);
  539. }
  540. delete [] pMem;
  541. //m_aNamespaces
  542. /*
  543. DWORD dwTot2 = pArbit->m_aNamespaces.m_nSize*sizeof(void*);
  544. void ** pMem2 = new void *[dwTot2];
  545. dprintf(" m_aNamespaces P %p S %x\n",pArbit->m_aNamespaces.m_pArray,pArbit->m_aNamespaces.m_nSize);
  546. if (ReadMemory((ULONG_PTR)pArbit->m_aNamespaces.m_pArray,pMem2,dwTot2,0))
  547. {
  548. for (i=0;i<pArbit->m_aNamespaces.m_nSize;i++)
  549. {
  550. dprintf(" - CWbemNamespace %d - %p\n",i,pMem2[i]);
  551. if (pMem2[i])
  552. {
  553. DumpCWbemNamespace((CWbemNamespace *)pMem2[i]);
  554. }
  555. }
  556. }
  557. else
  558. {
  559. dprintf("RM %p\n",pArbit->m_aNamespaces.m_pArray);
  560. }
  561. delete [] pMem2;
  562. */
  563. ULONG_PTR pListHead_oop = (ULONG_PTR)pArbit_OOP + FIELD_OFFSET(CWmiArbitrator,m_NameSpaceList);
  564. EnumLinkedListCB((LIST_ENTRY *)pListHead_oop,
  565. sizeof(CWmiArbitrator),
  566. FIELD_OFFSET(CWbemNamespace,m_EntryArb),
  567. EnumListNamespaces);
  568. }
  569. else
  570. {
  571. dprintf("RM %p\n",pArbit_OOP);
  572. }
  573. }
  574. //g_aProviderSinks
  575. DEFINE_CPP_VAR(CFlexArray,varCFlexArray);
  576. CFlexArray * pFlexArray = GET_CPP_VAR_PTR(CFlexArray,varCFlexArray);
  577. Addr = GetExpression("wbemcore!g_aProviderSinks");
  578. if (Addr)
  579. {
  580. if (ReadMemory(Addr,pFlexArray,sizeof(CFlexArray),NULL))
  581. {
  582. VOID ** ppPointers = (VOID **)_alloca(pFlexArray->m_nSize*sizeof(void *));
  583. if (ReadMemory((ULONG_PTR)pFlexArray->m_pArray,ppPointers,pFlexArray->m_nSize*sizeof(void *),NULL))
  584. {
  585. for(DWORD i =0 ;i<pFlexArray->m_nSize;i++)
  586. {
  587. dprintf(" - CProviderSink %d - %p\n",i,ppPointers[i]);
  588. GetVTable((MEMORY_ADDRESS)ppPointers[i]);
  589. DEFINE_CPP_VAR(CProviderSink,varCProviderSink);
  590. CProviderSink * pProvSink = GET_CPP_VAR_PTR(CProviderSink,varCProviderSink);
  591. if (ppPointers[i] && ReadMemory((ULONG_PTR)ppPointers[i],pProvSink,sizeof(CProviderSink),NULL))
  592. {
  593. DumpCProvSink(pProvSink);
  594. }
  595. else
  596. {
  597. dprintf("RM %p\n",ppPointers[i]);
  598. }
  599. }
  600. }
  601. }
  602. }
  603. }