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.

1094 lines
26 KiB

  1. #include "precomp.h"
  2. //
  3. // The ExtensionApis is a mandatory global variable, which should
  4. // have this exact name. All definitions of callbacks to the windbg
  5. // are using this variable.
  6. //
  7. WINDBG_EXTENSION_APIS ExtensionApis;
  8. USHORT g_MajorVersion;
  9. USHORT g_MinorVersion;
  10. //
  11. // Prototypes
  12. //
  13. VOID
  14. PrintCf(
  15. PCF_BLOCK pCf
  16. );
  17. VOID
  18. PrintClient(
  19. PCLIENT_BLOCK pClient
  20. );
  21. VOID
  22. PrintBlob(
  23. PBLOB_BLOCK pBlob
  24. );
  25. VOID
  26. PrintPattern(
  27. PPATTERN_BLOCK pPattern
  28. );
  29. VOID
  30. PrintStat(
  31. PGPC_STAT pStat
  32. );
  33. BOOL
  34. GetDwordExpr(
  35. char* expr,
  36. DWORD* pdwAddress,
  37. DWORD* pValue
  38. );
  39. //
  40. // API's
  41. //
  42. LPEXT_API_VERSION
  43. ExtensionApiVersion(
  44. void
  45. )
  46. /*++
  47. Function Description:
  48. Windbg calls this function to match between the version of windbg and the
  49. extension. If the versions doesn't match, windbg will not load the extension.
  50. --*/
  51. {
  52. static EXT_API_VERSION ApiVersion =
  53. { 3, 5, EXT_API_VERSION_NUMBER, 0 };
  54. return &ApiVersion;
  55. }
  56. void
  57. WinDbgExtensionDllInit(
  58. PWINDBG_EXTENSION_APIS lpExtensionApis,
  59. USHORT MajorVersion,
  60. USHORT MinorVersion
  61. )
  62. /*++
  63. Function Description:
  64. When windbg loads the extension, it first call this function. You can
  65. perform various intialization here.
  66. Arguments:
  67. lpExtensionApis - A structure that contains the callbacks to functions that
  68. I can use to do standard operation. I must store this in a global
  69. variable called 'ExtensionApis'.
  70. MajorVersion - Indicates if target machine is running checked build or free.
  71. 0x0C - Checked build.
  72. 0x0F - Free build.
  73. MinorVersion - The Windows NT build number (for example, 1381 for NT4).
  74. --*/
  75. {
  76. ExtensionApis = *lpExtensionApis;
  77. g_MajorVersion = MajorVersion;
  78. g_MinorVersion = MinorVersion;
  79. }
  80. DECLARE_API( version )
  81. {
  82. #if DBG
  83. PCHAR DebuggerType = "Checked";
  84. #else
  85. PCHAR DebuggerType = "Free";
  86. #endif
  87. dprintf("KDGPC: %s Extension dll for Build %d debugging %s kernel for Build %d\n",
  88. DebuggerType,
  89. VER_PRODUCTBUILD,
  90. g_MajorVersion == 0x0c ? "Checked" : "Free",
  91. g_MinorVersion
  92. );
  93. }
  94. VOID
  95. CheckVersion(
  96. VOID
  97. )
  98. /*++
  99. Function Description:
  100. This function is called before every command. It gives the extension
  101. a chance to compare between the versions of the target and the extension.
  102. In this demo, I don't do much with that.
  103. --*/
  104. {
  105. #if DBG
  106. if ((g_MajorVersion != 0x0c) || (g_MinorVersion != VER_PRODUCTBUILD)) {
  107. dprintf("\r\n*** Extension DLL(%d Checked) does not match target system(%d %s)\r\n\r\n",
  108. (VER_PRODUCTBUILD, g_MinorVersion, g_MajorVersion==0x0f) ? "Free" : "Checked" );
  109. }
  110. #else
  111. // if ((g_MajorVersion != 0x0f) || (g_MinorVersion != VER_PRODUCTBUILD)) {
  112. // dprintf("\r\n*** Extension DLL(%d Free) does not match target system(%d %s)\r\n\r\n",
  113. // (VER_PRODUCTBUILD, g_MinorVersion, (g_MajorVersion==0x0f) ? "Free" : "Checked" );
  114. // }
  115. #endif
  116. }
  117. DECLARE_API( help )
  118. /*++
  119. Function Description:
  120. This is the implementation of the '!help' extension command. It lists
  121. all available command in this debugger extension.
  122. --*/
  123. {
  124. dprintf(
  125. "help - shows this list\n"
  126. "cf - print the CF list\n"
  127. "client [addr] - print the client block"
  128. "blob [addr] - print the blob list for the QoS CF, or the specified blob\n"
  129. "pattern [addr] - print the pattern block\n"
  130. "stat - print the statistics"
  131. );
  132. }
  133. DECLARE_API( cf )
  134. /*++
  135. Function Description:
  136. This function prints all the CF in the list. If args is specified, only that CF
  137. will be printed. Currently these are supported:
  138. 0 - for CF_QOS
  139. --*/
  140. {
  141. DWORD TargetGlobalData;
  142. GLOBAL_BLOCK LocalGlobalData;
  143. PLIST_ENTRY pHead, pEntry;
  144. DWORD TargetCf;
  145. CF_BLOCK LocalCf;
  146. ULONG result;
  147. ULONG CfIndex = (-1);
  148. char *lerr;
  149. TargetGlobalData = GetExpression( "MSGPC!glData" );
  150. if( !TargetGlobalData )
  151. {
  152. dprintf( "Can't find the address of 'glData'" );
  153. return;
  154. }
  155. //
  156. if ( !ReadMemory(
  157. TargetGlobalData,
  158. &LocalGlobalData,
  159. sizeof(LocalGlobalData),
  160. &result
  161. )) {
  162. dprintf( "Can't read memory from 0x%x", TargetGlobalData );
  163. return;
  164. }
  165. //
  166. //
  167. //
  168. if ( args )
  169. CfIndex = strtol( args, &lerr, 10 );
  170. pHead = (PLIST_ENTRY)((PUCHAR)TargetGlobalData + FIELD_OFFSET(GLOBAL_BLOCK, CfList));
  171. pEntry = LocalGlobalData.CfList.Flink;
  172. while ( pHead != pEntry ) {
  173. TargetCf = (DWORD)CONTAINING_RECORD( pEntry, CF_BLOCK, Linkage );
  174. if ( !ReadMemory( TargetCf,
  175. &LocalCf,
  176. sizeof(LocalCf),
  177. &result ) ) {
  178. dprintf( "Can't read memory from 0x%x", TargetCf );
  179. } else if ( CfIndex == (-1) || LocalCf.AssignedIndex == CfIndex ) {
  180. PrintCf( &LocalCf );
  181. }
  182. pEntry = LocalCf.Linkage.Flink;
  183. }
  184. }
  185. DECLARE_API( blob )
  186. /*++
  187. Function Description:
  188. This function prints all the blob in the QoS CF list.
  189. If args is specified it is used as the blob addr.
  190. --*/
  191. {
  192. DWORD TargetGlobalData;
  193. GLOBAL_BLOCK LocalGlobalData;
  194. PLIST_ENTRY pHead, pEntry;
  195. DWORD TargetCf;
  196. CF_BLOCK LocalCf;
  197. ULONG result;
  198. ULONG TargetBlob = 0;
  199. BLOB_BLOCK LocalBlob;
  200. char *lerr;
  201. if ( args )
  202. TargetBlob = GetExpression( args );
  203. if (TargetBlob) {
  204. if ( !ReadMemory( TargetBlob,
  205. &LocalBlob,
  206. sizeof(LocalBlob),
  207. &result ) ) {
  208. dprintf( "Can't read memory from 0x%x", TargetBlob );
  209. } else {
  210. PrintBlob( &LocalBlob );
  211. }
  212. return;
  213. }
  214. #if 0
  215. //
  216. // scan the blob list for the QoS CF
  217. //
  218. TargetGlobalData = GetExpression( "MSGPC!glData" );
  219. if( !TargetGlobalData )
  220. {
  221. dprintf( "Can't find the address of 'glData'" );
  222. return;
  223. }
  224. //
  225. if ( !ReadMemory(
  226. TargetGlobalData,
  227. &LocalGlobalData,
  228. sizeof(LocalGlobalData),
  229. &result
  230. )) {
  231. dprintf( "Can't read memory from 0x%x", TargetGlobalData );
  232. return;
  233. }
  234. //
  235. //
  236. //
  237. pHead = (PLIST_ENTRY)((PUCHAR)TargetGlobalData + FIELD_OFFSET(GLOBAL_BLOCK, CfList));
  238. pEntry = LocalGlobalData.CfList.Flink;
  239. while ( pHead != pEntry ) {
  240. TargetCf = (DWORD)CONTAINING_RECORD( pEntry, CF_BLOCK, Linkage );
  241. if ( !ReadMemory( TargetCf,
  242. &LocalCf,
  243. sizeof(LocalCf),
  244. &result ) ) {
  245. dprintf( "Can't read memory from 0x%x", TargetCf );
  246. } else if ( CfIndex == (-1) || LocalCf.AssignedIndex == CfIndex ) {
  247. PrintCf( &LocalCf );
  248. }
  249. pEntry = LocalCf.Linkage.Flink;
  250. }
  251. #endif
  252. }
  253. DECLARE_API( client )
  254. /*++
  255. Function Description:
  256. This function prints either the client addr or all the clients
  257. --*/
  258. {
  259. DWORD TargetGlobalData;
  260. GLOBAL_BLOCK LocalGlobalData;
  261. PLIST_ENTRY pHead, pEntry;
  262. PLIST_ENTRY pHead1, pEntry1;
  263. DWORD TargetCf;
  264. CF_BLOCK LocalCf;
  265. ULONG result;
  266. ULONG TargetClient = 0;
  267. CLIENT_BLOCK LocalClient;
  268. int i = 0;
  269. if ( args )
  270. TargetClient = GetExpression( args );
  271. if (TargetClient) {
  272. if ( !ReadMemory( TargetClient,
  273. &LocalClient,
  274. sizeof(LocalClient),
  275. &result ) ) {
  276. dprintf( "Can't read memory from 0x%x", TargetClient );
  277. } else {
  278. dprintf( "Client = 0x%X: ", TargetClient );
  279. PrintClient( &LocalClient );
  280. }
  281. return;
  282. }
  283. //
  284. // scan the client list for the QoS CF
  285. //
  286. TargetGlobalData = GetExpression( "MSGPC!glData" );
  287. if( !TargetGlobalData )
  288. {
  289. dprintf( "Can't find the address of 'glData'" );
  290. return;
  291. }
  292. //
  293. if ( !ReadMemory(
  294. TargetGlobalData,
  295. &LocalGlobalData,
  296. sizeof(LocalGlobalData),
  297. &result
  298. )) {
  299. dprintf( "Can't read memory from 0x%x", TargetGlobalData );
  300. return;
  301. }
  302. //
  303. //
  304. //
  305. pHead = (PLIST_ENTRY)((PUCHAR)TargetGlobalData + FIELD_OFFSET(GLOBAL_BLOCK, CfList));
  306. pEntry = LocalGlobalData.CfList.Flink;
  307. while ( pHead != pEntry ) {
  308. TargetCf = (DWORD)CONTAINING_RECORD( pEntry, CF_BLOCK, Linkage );
  309. if ( !ReadMemory( TargetCf,
  310. &LocalCf,
  311. sizeof(LocalCf),
  312. &result ) ) {
  313. dprintf( "Can't read memory from 0x%x", TargetCf );
  314. return;
  315. } else {
  316. dprintf( "\nClients for CF=%d\n", LocalCf.AssignedIndex );
  317. pHead1 = (PLIST_ENTRY)((PUCHAR)TargetCf + FIELD_OFFSET(CF_BLOCK, ClientList));
  318. pEntry1 = LocalCf.ClientList.Flink;
  319. while ( pHead1 != pEntry1 ) {
  320. TargetClient = (DWORD)CONTAINING_RECORD( pEntry1, CLIENT_BLOCK, ClientLinkage );
  321. if ( !ReadMemory( TargetClient,
  322. &LocalClient,
  323. sizeof(LocalClient),
  324. &result ) ) {
  325. dprintf( "Can't read memory from 0x%x", TargetClient );
  326. return;
  327. } else {
  328. dprintf( "Client [%d] = 0x%X: ", i++, TargetClient );
  329. PrintClient( &LocalClient );
  330. }
  331. pEntry1 = LocalClient.ClientLinkage.Flink;
  332. }
  333. }
  334. pEntry = LocalCf.Linkage.Flink;
  335. }
  336. }
  337. BOOL
  338. GetDwordExpr(
  339. char* expr,
  340. DWORD* pdwAddress,
  341. DWORD* pValue
  342. )
  343. /*++
  344. Function Description:
  345. This function gets as an argument a string which represent a DWORD
  346. variable. The funciton finds its address (if the symbols are loaded),
  347. and then grab the dword value from that address.
  348. Arguments:
  349. expr [in] - A null terminated string, represent the variable.
  350. pdwAddress [out, optional] - Optinally return the address of the variable.
  351. pValue [out] - returns the value of the DWORD variable.
  352. Return Value:
  353. true/false, if the function succeeded or failed.
  354. --*/
  355. {
  356. ULONG result;
  357. DWORD dwAddress;
  358. if( pdwAddress )
  359. *pdwAddress = 0;
  360. *pValue = 0;
  361. dwAddress = GetExpression( expr );
  362. if( !dwAddress )
  363. return FALSE;
  364. if( !ReadMemory( dwAddress, pValue, sizeof(DWORD), &result ) )
  365. return FALSE;
  366. if( pdwAddress )
  367. *pdwAddress = dwAddress;
  368. return TRUE;
  369. }
  370. VOID
  371. PrintCf(
  372. PCF_BLOCK pCf
  373. )
  374. /*++
  375. Function Description:
  376. This function gets as an argument a CF block pointer,
  377. and does a pretty print.
  378. Arguments:
  379. pCf - pointer to CF block
  380. Return Value:
  381. none
  382. --*/
  383. {
  384. int i;
  385. dprintf( " Linkage = { 0x%X, 0x%X }\n", pCf->Linkage.Flink, pCf->Linkage.Blink );
  386. dprintf( " ClientList = { 0x%X, 0x%X }\n",
  387. pCf->ClientList.Flink,
  388. pCf->ClientList.Blink );
  389. dprintf( " BlobList = { 0x%X, 0x%X }\n",
  390. pCf->BlobList.Flink,
  391. pCf->BlobList.Blink );
  392. dprintf( " NumberOfClients = %d\n", pCf->NumberOfClients );
  393. dprintf( " AssignedIndex = 0x%x\n", pCf->AssignedIndex );
  394. dprintf( " ClientIndexes = %d\n", pCf->ClientIndexes );
  395. dprintf( " MaxPriorities = %d\n", pCf->MaxPriorities );
  396. dprintf( " arpGenericDb = 0x%X\n", &pCf->arpGenericDb );
  397. for ( i = GPC_PROTOCOL_TEMPLATE_IP; i < GPC_PROTOCOL_TEMPLATE_MAX; i++ ) {
  398. dprintf( " [%d] = %d\n", i, (ULONG)pCf->arpGenericDb[i] );
  399. }
  400. }
  401. VOID
  402. PrintBlob(
  403. PBLOB_BLOCK pBlob
  404. )
  405. /*++
  406. Function Description:
  407. This function gets as an argument a BLOB block pointer,
  408. and does a pretty print.
  409. Arguments:
  410. pBlob - pointer to BLOB block
  411. Return Value:
  412. none
  413. --*/
  414. {
  415. int i;
  416. dprintf( " ObjectType = %d\n", pBlob->ObjectType );
  417. dprintf( " ClientLinkage = { 0x%X, 0x%X }\n",
  418. pBlob->ClientLinkage.Flink,
  419. pBlob->ClientLinkage.Blink );
  420. dprintf( " PatternList = { 0x%X, 0x%X }\n",
  421. pBlob->PatternList.Flink,
  422. pBlob->PatternList.Blink );
  423. dprintf( " CfLinkage = { 0x%X, 0x%X }\n",
  424. pBlob->CfLinkage.Flink,
  425. pBlob->CfLinkage.Blink );
  426. dprintf( " RefCount = %d\n", pBlob->RefCount );
  427. dprintf( " State = 0x%x\n", pBlob->State );
  428. dprintf( " arClientCtx[]:\n" );
  429. for ( i = 0; i < MAX_CLIENTS_CTX_PER_BLOB; i++ ) {
  430. dprintf( " [%d] = 0x%x\n", i, (ULONG)pBlob->arClientCtx[i] );
  431. }
  432. }
  433. VOID
  434. PrintClient(
  435. PCLIENT_BLOCK pClient
  436. )
  437. /*++
  438. Function Description:
  439. This function gets as an argument a CLIENT block pointer,
  440. and does a pretty print.
  441. Arguments:
  442. pClient - pointer to CLIENT block
  443. Return Value:
  444. none
  445. --*/
  446. {
  447. DWORD TargetCf;
  448. CF_BLOCK LocalCf;
  449. ULONG result;
  450. TargetCf = (DWORD)pClient->pCfBlock;
  451. if ( !ReadMemory( TargetCf,
  452. &LocalCf,
  453. sizeof(LocalCf),
  454. &result ) ) {
  455. dprintf( "Can't read memory from 0x%x", TargetCf );
  456. return;
  457. }
  458. if (pClient->Flags & GPC_FLAGS_USERMODE_CLIENT) {
  459. dprintf( " User Mode Client\n" );
  460. } else {
  461. if (GetExpression( "PSCHED!AddCfInfoNotify" ) == (DWORD)pClient->FuncList.ClAddCfInfoNotifyHandler
  462. && (LocalCf.AssignedIndex == GPC_CF_QOS || LocalCf.AssignedIndex == GPC_CF_CLASS_MAP)) {
  463. dprintf( " Probably PSCHED client\n" );
  464. } else if (GetExpression( "TCPIP!GPCcfInfoAddNotify" ) == (DWORD)pClient->FuncList.ClAddCfInfoNotifyHandler
  465. && (LocalCf.AssignedIndex == GPC_CF_QOS || LocalCf.AssignedIndex == GPC_CF_IPSEC)) {
  466. dprintf( " Probably TCPIP client\n" );
  467. } else if (GetExpression( "ATMARPC!AtmArpGpcAddCfInfoComplete" ) == (DWORD)pClient->FuncList.ClAddCfInfoNotifyHandler
  468. && (LocalCf.AssignedIndex == GPC_CF_QOS)) {
  469. dprintf( " Probably ATMARPC client\n" );
  470. } else if (0 == (DWORD)pClient->FuncList.ClAddCfInfoNotifyHandler
  471. && (LocalCf.AssignedIndex == GPC_CF_IPSEC)) {
  472. dprintf( " Probably IPSEC client\n" );
  473. } else {
  474. dprintf( " Unknown client\n" );
  475. }
  476. }
  477. dprintf( " ObjectType = %d\n", pClient->ObjectType );
  478. dprintf( " ClientLinkage = { 0x%X, 0x%X }\n",
  479. pClient->ClientLinkage.Flink,
  480. pClient->ClientLinkage.Blink );
  481. dprintf( " BlobList = { 0x%X, 0x%X }\n",
  482. pClient->BlobList.Flink,
  483. pClient->BlobList.Blink );
  484. dprintf( " Parrent CF = 0x%X\n", pClient->pCfBlock );
  485. dprintf( " Client Ctx = 0x%X\n", pClient->ClientCtx );
  486. dprintf( " AssignedIndex = %d\n", pClient->AssignedIndex );
  487. dprintf( " Flags = 0x%X %s %s \n",
  488. pClient->Flags,
  489. (pClient->Flags & GPC_FLAGS_USERMODE_CLIENT)?"UserMode":"" ,
  490. (pClient->Flags & GPC_FLAGS_FRAGMENT)?"Handle Fragments":""
  491. );
  492. dprintf( " State = %d\n", pClient->State );
  493. dprintf( " RefCount = %d\n", pClient->RefCount );
  494. dprintf( " File Object = 0x%X\n", pClient->pFileObject );
  495. dprintf( " Client Handle = %d\n", pClient->ClHandle );
  496. dprintf( " Client Handlers:\n" );
  497. dprintf( " Add Notify = 0x%X\n", pClient->FuncList.ClAddCfInfoCompleteHandler );
  498. dprintf( " Add Complete = 0x%X\n", pClient->FuncList.ClAddCfInfoNotifyHandler );
  499. dprintf( " Modify Notify = 0x%X\n", pClient->FuncList.ClModifyCfInfoCompleteHandler );
  500. dprintf( " Modify Complete = 0x%X\n", pClient->FuncList.ClModifyCfInfoNotifyHandler );
  501. dprintf( " Remove Notify = 0x%X\n", pClient->FuncList.ClRemoveCfInfoCompleteHandler );
  502. dprintf( " Remove Complete = 0x%X\n", pClient->FuncList.ClRemoveCfInfoNotifyHandler );
  503. dprintf( " Get CfInfo Name = 0x%X\n", pClient->FuncList.ClGetCfInfoName );
  504. }
  505. VOID
  506. PrintPattern(
  507. PPATTERN_BLOCK pPattern
  508. )
  509. /*++
  510. Function Description:
  511. This function gets as an argument a PATTERN block pointer,
  512. and does a pretty print.
  513. Arguments:
  514. pPattern - pointer to PATTERN block
  515. Return Value:
  516. none
  517. --*/
  518. {
  519. int i;
  520. dprintf( " ObjectType = %d\n", pPattern->ObjectType );
  521. dprintf( " BlobLinkage[]:\n" );
  522. for ( i = 0; i < GPC_CF_MAX; i++ ) {
  523. dprintf( " [%d] = {0x%X,0x%X}\n", i,
  524. pPattern->BlobLinkage[i].Flink,
  525. pPattern->BlobLinkage[i].Blink
  526. );
  527. }
  528. dprintf( " TimerLinkage = { 0x%X, 0x%X }\n",
  529. pPattern->TimerLinkage.Flink,
  530. pPattern->TimerLinkage.Blink );
  531. dprintf( " Owner client = 0x%X\n", pPattern->pClientBlock );
  532. dprintf( " Auto client = 0x%X\n", pPattern->pAutoClient );
  533. dprintf( " Classification block = 0x%X\n", pPattern->pClassificationBlock );
  534. dprintf( " Ref Count = %d\n", pPattern->RefCount );
  535. dprintf( " Client Ref Count = %d\n", pPattern->ClientRefCount );
  536. dprintf( " Flags = 0x%x %s %s \n", pPattern->Flags ,
  537. (pPattern->Flags & PATTERN_SPECIFIC)?"Specific":"",
  538. (pPattern->Flags & PATTERN_AUTO)?"Auto":""
  539. );
  540. dprintf( " Priority = %d\n", pPattern->Priority );
  541. dprintf( " Client handle = 0x%x\n", pPattern->ClHandle );
  542. dprintf( " Protocol = 0x%x\n", pPattern->ProtocolTemplate );
  543. }
  544. VOID
  545. PrintStat(
  546. PGPC_STAT pStat
  547. )
  548. /*++
  549. Function Description:
  550. Prints the GPC stat structure
  551. Arguments:
  552. pStat - pointer to GPC stat strucutre
  553. Return Value:
  554. none
  555. --*/
  556. {
  557. PPROTOCOL_STAT pProtocol;
  558. int i;
  559. dprintf( "Created CF = %d\n", pStat->CreatedCf );
  560. dprintf( "Deleted Cf = %d\n", pStat->DeletedCf );
  561. dprintf( "Rejected Cf = %d\n", pStat->RejectedCf );
  562. dprintf( "Current Cf = %d\n", pStat->CurrentCf );
  563. dprintf( "Inserted HF= %d\n", pStat->InsertedHF );
  564. dprintf( "Removed HF= %d\n", pStat->RemovedHF );
  565. for( i = 0; i < GPC_CF_MAX; i++) {
  566. dprintf( "CF[%d] info:\n", i);
  567. dprintf( " Created Blobs = %d\n", pStat->CfStat[i].CreatedBlobs );
  568. dprintf( " Modified Blobs = %d\n", pStat->CfStat[i].ModifiedBlobs );
  569. dprintf( " Deleted Blobs = %d\n", pStat->CfStat[i].DeletedBlobs );
  570. dprintf( " Rejected Blobs = %d\n", pStat->CfStat[i].RejectedBlobs );
  571. dprintf( " Current Blobs = %d\n", pStat->CfStat[i].CurrentBlobs );
  572. dprintf( " Deref Blobs to zero = %d\n", pStat->CfStat[i].DerefBlobs2Zero );
  573. dprintf( "\n" );
  574. }
  575. pProtocol = &pStat->ProtocolStat[GPC_PROTOCOL_TEMPLATE_IP];
  576. dprintf( "IP stats: Specific Patterns Generic Patterns Auto Patterns\n" );
  577. dprintf( " Created = %8d %8d %8d\n",
  578. pProtocol->CreatedSp, pProtocol->CreatedGp, pProtocol->CreatedAp );
  579. dprintf( " Deleted = %8d %8d %8d\n",
  580. pProtocol->DeletedSp, pProtocol->DeletedGp, pProtocol->DeletedAp );
  581. dprintf( " Rejected = %8d %8d %8d\n",
  582. pProtocol->RejectedSp, pProtocol->RejectedGp, pProtocol->RejectedAp );
  583. dprintf( " Current = %8d %8d %8d\n",
  584. pProtocol->CurrentSp, pProtocol->CurrentGp, pProtocol->CurrentAp );
  585. dprintf( "\n" );
  586. dprintf( " Classification Requests = %d\n", pProtocol->ClassificationRequests );
  587. dprintf( " Patterns Classified = %d\n", pProtocol->PatternsClassified );
  588. dprintf( " Packets Classified = %d\n", pProtocol->PacketsClassified );
  589. dprintf( "\n" );
  590. dprintf( " Deref Patterns to zero = %d\n", pProtocol->DerefPattern2Zero );
  591. dprintf( " First Frags Count = %d\n", pProtocol->FirstFragsCount );
  592. dprintf( " Last Frags Count = %d\n", pProtocol->LastFragsCount );
  593. dprintf( "\n" );
  594. dprintf( " Inserted PH= %d\n", pProtocol->InsertedPH );
  595. dprintf( " Removed PH= %d\n", pProtocol->RemovedPH );
  596. dprintf( " Inserted Rz= %d\n", pProtocol->InsertedRz );
  597. dprintf( " Removed Rz= %d\n", pProtocol->RemovedRz );
  598. dprintf( " Inserted CH= %d\n", pProtocol->InsertedCH );
  599. dprintf( " Removed CH= %d\n", pProtocol->RemovedCH );
  600. }
  601. DECLARE_API( pattern )
  602. /*++
  603. Function Description:
  604. This function prints all the pattern in the QoS CF list.
  605. If args is specified it is used as the blob addr.
  606. --*/
  607. {
  608. DWORD TargetGlobalData;
  609. GLOBAL_BLOCK LocalGlobalData;
  610. PLIST_ENTRY pHead, pEntry;
  611. DWORD TargetCf;
  612. CF_BLOCK LocalCf;
  613. ULONG result;
  614. ULONG TargetPattern = 0;
  615. PATTERN_BLOCK LocalPattern;
  616. char *lerr;
  617. if ( args )
  618. TargetPattern = GetExpression( args );
  619. if (TargetPattern) {
  620. if ( !ReadMemory( TargetPattern,
  621. &LocalPattern,
  622. sizeof(LocalPattern),
  623. &result ) ) {
  624. dprintf( "Can't read memory from 0x%x", TargetPattern );
  625. } else {
  626. PrintPattern( &LocalPattern );
  627. }
  628. return;
  629. }
  630. #if 0
  631. //
  632. // scan the blob list for the QoS CF
  633. //
  634. TargetGlobalData = GetExpression( "MSGPC!glData" );
  635. if( !TargetGlobalData )
  636. {
  637. dprintf( "Can't find the address of 'glData'" );
  638. return;
  639. }
  640. //
  641. if ( !ReadMemory(
  642. TargetGlobalData,
  643. &LocalGlobalData,
  644. sizeof(LocalGlobalData),
  645. &result
  646. )) {
  647. dprintf( "Can't read memory from 0x%x", TargetGlobalData );
  648. return;
  649. }
  650. //
  651. //
  652. //
  653. pHead = (PLIST_ENTRY)((PUCHAR)TargetGlobalData + FIELD_OFFSET(GLOBAL_BLOCK, CfList));
  654. pEntry = LocalGlobalData.CfList.Flink;
  655. while ( pHead != pEntry ) {
  656. TargetCf = (DWORD)CONTAINING_RECORD( pEntry, CF_BLOCK, Linkage );
  657. if ( !ReadMemory( TargetCf,
  658. &LocalCf,
  659. sizeof(LocalCf),
  660. &result ) ) {
  661. dprintf( "Can't read memory from 0x%x", TargetCf );
  662. } else if ( CfIndex == (-1) || LocalCf.AssignedIndex == CfIndex ) {
  663. PrintCf( &LocalCf );
  664. }
  665. pEntry = LocalCf.Linkage.Flink;
  666. }
  667. #endif
  668. }
  669. DECLARE_API( stat )
  670. /*++
  671. Function Description:
  672. This function prints all the stat structure
  673. --*/
  674. {
  675. DWORD TargetStat;
  676. GPC_STAT LocalStat;
  677. PLIST_ENTRY pHead, pEntry;
  678. DWORD TargetCf;
  679. CF_BLOCK LocalCf;
  680. ULONG result;
  681. TargetStat = GetExpression( "MSGPC!glStat" );
  682. if( !TargetStat )
  683. {
  684. dprintf( "Can't find the address of 'glStat'" );
  685. return;
  686. }
  687. if ( !ReadMemory( TargetStat,
  688. &LocalStat,
  689. sizeof(LocalStat),
  690. &result ) ) {
  691. dprintf( "Can't read memory from 0x%x", TargetStat );
  692. } else {
  693. PrintStat( &LocalStat );
  694. }
  695. }
  696. DECLARE_API( autopatterns )
  697. /*++
  698. Function Description:
  699. This function prints all the CF in the list. If args is specified, only that CF
  700. will be printed. Currently these are supported:
  701. 0 - for CF_QOS
  702. --*/
  703. {
  704. DWORD TargetGlobalData, TargetProtocolBlock;
  705. GLOBAL_BLOCK LocalGlobalData;
  706. PROTOCOL_BLOCK LocalProtocolBlock;
  707. PLIST_ENTRY pHead, pEntry;
  708. LIST_ENTRY listentry;
  709. DWORD TargetPattern;
  710. PATTERN_BLOCK LocalPattern;
  711. ULONG result;
  712. INT i, j;
  713. ULONG CfIndex = (-1);
  714. char *lerr;
  715. TargetGlobalData = GetExpression( "MSGPC!glData" );
  716. if( !TargetGlobalData )
  717. {
  718. dprintf( "Can't find the address of 'glData'" );
  719. return;
  720. }
  721. //
  722. if ( !ReadMemory(
  723. TargetGlobalData,
  724. &LocalGlobalData,
  725. sizeof(LocalGlobalData),
  726. &result
  727. )) {
  728. dprintf( "Can't read memory from 0x%x", TargetGlobalData );
  729. return;
  730. }
  731. //
  732. //
  733. //
  734. TargetProtocolBlock = (DWORD) LocalGlobalData.pProtocols;
  735. if ( !ReadMemory(
  736. TargetProtocolBlock,
  737. &LocalProtocolBlock,
  738. sizeof(LocalProtocolBlock),
  739. &result
  740. )) {
  741. dprintf( "Can't read memory from 0x%x", TargetProtocolBlock );
  742. return;
  743. }
  744. for (i = 0; i < NUMBER_OF_WHEELS; i++) {
  745. j = 0;
  746. pHead = (PLIST_ENTRY) ((DWORD)TargetProtocolBlock + (i * sizeof(listentry)));
  747. pEntry = LocalProtocolBlock.TimerPatternList[i].Flink;
  748. dprintf("Printing TimerWheel %d Head = %X and pEntry = %X ******************\n", i, pHead, pEntry);
  749. while ( (pHead != pEntry) && (j < 1000) ) {
  750. j++;
  751. TargetPattern = (DWORD)CONTAINING_RECORD( pEntry, PATTERN_BLOCK, TimerLinkage );
  752. if ( !ReadMemory( TargetPattern,
  753. &LocalPattern,
  754. sizeof(LocalPattern),
  755. &result ) ) {
  756. dprintf( "Can't read memory from 0x%x", TargetPattern );
  757. } else {
  758. dprintf("Pattern = %X and ClassificationBlock = %X\n", TargetPattern, LocalPattern.pClassificationBlock);
  759. // PrintPattern( &LocalPattern );
  760. }
  761. pEntry = LocalPattern.TimerLinkage.Flink;
  762. }
  763. }
  764. dprintf("Done printing all Timer Wheels\n");
  765. }