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.

797 lines
21 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. #include <wdbgexts.h>
  4. #include <stdlib.h>
  5. #include "rtkmext.h"
  6. #include "kdmacros.h"
  7. INT Item;
  8. HANDLE _hInstance;
  9. HANDLE _hAdditionalReference;
  10. HANDLE _hProcessHeap;
  11. int _Indent = 0;
  12. char IndentBuf[ 80 ]={"\0 "};
  13. BOOL
  14. dprint_enum_name
  15. (
  16. ULONG Value,
  17. PENUM_INFO pEnumInfo
  18. )
  19. {
  20. while ( pEnumInfo->pszDescription != NULL )
  21. {
  22. if ( pEnumInfo->Value == Value )
  23. {
  24. dprintf( "%.40s", pEnumInfo->pszDescription );
  25. return( TRUE );
  26. }
  27. pEnumInfo ++;
  28. }
  29. dprintf( "Unknown enumeration value." );
  30. return( FALSE );
  31. }
  32. BOOL
  33. dprint_flag_names
  34. (
  35. ULONG Value,
  36. PFLAG_INFO pFlagInfo
  37. )
  38. {
  39. BOOL bFoundOne = FALSE;
  40. while ( pFlagInfo->pszDescription != NULL )
  41. {
  42. if ( pFlagInfo->Value & Value )
  43. {
  44. if ( bFoundOne )
  45. {
  46. dprintf( " | " );
  47. }
  48. bFoundOne = TRUE;
  49. dprintf( "%.15s", pFlagInfo->pszDescription );
  50. }
  51. pFlagInfo ++;
  52. }
  53. return( bFoundOne );
  54. }
  55. VOID
  56. dprint_IP_address
  57. (
  58. IPAddr Address
  59. )
  60. {
  61. uchar IPAddrBuffer[(sizeof(IPAddr) * 4)];
  62. uint i;
  63. uint IPAddrCharCount;
  64. //
  65. // Convert the IP address into a string.
  66. //
  67. IPAddrCharCount = 0;
  68. for (i = 0; i < sizeof(IPAddr); i++) {
  69. uint CurrentByte;
  70. CurrentByte = Address & 0xff;
  71. if (CurrentByte > 99) {
  72. IPAddrBuffer[IPAddrCharCount++] = (CurrentByte / 100) + '0';
  73. CurrentByte %= 100;
  74. IPAddrBuffer[IPAddrCharCount++] = (CurrentByte / 10) + '0';
  75. CurrentByte %= 10;
  76. } else if (CurrentByte > 9) {
  77. IPAddrBuffer[IPAddrCharCount++] = (CurrentByte / 10) + '0';
  78. CurrentByte %= 10;
  79. }
  80. IPAddrBuffer[IPAddrCharCount++] = CurrentByte + '0';
  81. if (i != (sizeof(IPAddr) - 1))
  82. IPAddrBuffer[IPAddrCharCount++] = '.';
  83. Address >>= 8;
  84. }
  85. IPAddrBuffer[IPAddrCharCount] = '\0';
  86. dprintf( "%s", IPAddrBuffer );
  87. }
  88. #ifdef _obj
  89. # undef _obj
  90. # undef _objAddr
  91. # undef _objType
  92. #endif
  93. #define _obj IpsecGlobal
  94. #define _objAddr pIpsecGlobal
  95. #define _objType IPSEC_GLOBAL
  96. VOID
  97. Iglobal(DWORD opts, LPSTR args)
  98. {
  99. ULONG deviceToDump = 0;
  100. ULONG pDevice = 0;
  101. ULONG result;
  102. UCHAR cmdline[MAX_PATH]="0";
  103. UCHAR arg[MAX_PATH]="0";
  104. IPSEC_GLOBAL IpsecGlobal;
  105. PIPSEC_GLOBAL pIpsecGlobal;
  106. pDevice = GetExpression( "ipsec!g_ipsec" );
  107. if ( !pDevice ) {
  108. dprintf("Could not get g_ipsec, Try !reload\n");
  109. return;
  110. } else {
  111. if ( !ReadMemory( pDevice,
  112. &IpsecGlobal,
  113. sizeof(IPSEC_GLOBAL),
  114. &result )) {
  115. dprintf("%08lx: Could not read device context\n", pDevice);
  116. return;
  117. }
  118. }
  119. pIpsecGlobal = &IpsecGlobal;
  120. PrintBool(DriverUnloading);
  121. PrintBool(BoundToIP);
  122. PrintBool(SendBoundToIP);
  123. PrintULong(NumSends);
  124. PrintULong(NumThreads);
  125. PrintULong(NumWorkers);
  126. PrintULong(NumTimers);
  127. PrintLL(LarvalSAList);
  128. PrintLock(LarvalListLock);
  129. PrintLock(SADBLock.SpinLock);
  130. PrintULong(SADBLock.RefCount);
  131. PrintLock(SPIListLock.SpinLock);
  132. PrintULong(SPIListLock.RefCount);
  133. PrintLL(FilterList[INBOUND_TRANSPORT_FILTER]);
  134. PrintLL(FilterList[OUTBOUND_TRANSPORT_FILTER]);
  135. PrintLL(FilterList[INBOUND_TUNNEL_FILTER]);
  136. PrintLL(FilterList[OUTBOUND_TUNNEL_FILTER]);
  137. PrintULong(NumPolicies);
  138. PrintULong(NumTunnelFilters);
  139. PrintULong(NumMaskedFilters);
  140. PrintULong(NumOutboundSAs);
  141. PrintULong(NumMulticastFilters);
  142. PrintPtr(pSADb);
  143. PrintULong(NumSA);
  144. PrintULong(SAHashSize);
  145. PrintPtr(ppCache);
  146. PrintULong(CacheSize);
  147. PrintPtr(IPSecDevice);
  148. PrintPtr(IPSecDriverObject);
  149. PrintULong(EnableOffload);
  150. PrintULong(DefaultSAIdleTime);
  151. PrintULong(LogInterval);
  152. PrintULong(EventQueueSize);
  153. PrintULong(NoDefaultExempt);
  154. PrintULong(IPSecBufferedEvents);
  155. PrintPtr(IPSecLogMemory);
  156. PrintPtr(IPSecLogMemoryLoc);
  157. PrintPtr(IPSecLogMemoryEnd);
  158. PrintULong(OperationMode);
  159. return;
  160. }
  161. FLAG_INFO FlagsFilter[] =
  162. {
  163. { FILTER_FLAGS_PASS_THRU , "Pass Thru'" },
  164. { FILTER_FLAGS_DROP , "Drop" },
  165. { 0, NULL }
  166. };
  167. #ifdef _obj
  168. # undef _obj
  169. # undef _objAddr
  170. # undef _objType
  171. #endif
  172. #define _obj Filter
  173. #define _objAddr pFilter
  174. #define _objType FILTER
  175. VOID
  176. DumpFilter(PFILTER pFilter, FILTER Filter)
  177. {
  178. ULARGE_INTEGER uliSrcDstAddr;
  179. ULARGE_INTEGER uliSrcDstMask;
  180. ULARGE_INTEGER uliProtoSrcDstPort;
  181. uliSrcDstAddr = Filter.uliSrcDstAddr;
  182. uliSrcDstMask = Filter.uliSrcDstMask;
  183. uliProtoSrcDstPort = Filter.uliProtoSrcDstPort;
  184. dprintf("\n--------------------------- FILTER: %lx -------------------------------\n", pFilter);
  185. PrintLL(MaskedLinkage);
  186. PrintXULong(Signature);
  187. PrintFlags(Flags, FlagsFilter);
  188. PrintFieldName("SrcAddr");
  189. dprint_IP_address( SRC_ADDR );
  190. PrintNL();
  191. PrintFieldName("SrcMask");
  192. dprint_IP_address( SRC_MASK );
  193. PrintNL();
  194. PrintFieldName("DestAddr");
  195. dprint_IP_address( DEST_ADDR );
  196. PrintNL();
  197. PrintFieldName("DestMask");
  198. dprint_IP_address( DEST_MASK );
  199. PrintNL();
  200. PrintUShort(PROTO);
  201. PrintFieldName("SrcPort");
  202. dprintf("%-10hu%s", SRC_PORT, EOL);
  203. PrintFieldName("DestPort");
  204. dprintf("%-10hu%s", DEST_PORT, EOL);
  205. PrintIPAddress(TunnelAddr);
  206. PrintULong(SAChainSize);
  207. PrintULong(Index);
  208. PrintGUID(PolicyId);
  209. PrintGUID(FilterId);
  210. }
  211. VOID
  212. Imfl(DWORD opts, LPSTR args)
  213. {
  214. ULONG deviceToDump = 0;
  215. ULONG result;
  216. UCHAR cmdline[MAX_PATH]="0";
  217. UCHAR arg[MAX_PATH]="0";
  218. ULONG pDevice=0;
  219. IPSEC_GLOBAL IpsecGlobal;
  220. PFILTER pFilter;
  221. FILTER Filter;
  222. PLIST_ENTRY pEntry;
  223. LONG Index;
  224. pDevice = GetExpression( "ipsec!g_ipsec" );
  225. if ( !pDevice ) {
  226. dprintf("Could not get g_ipsec, Try !reload\n");
  227. return;
  228. } else {
  229. if ( !ReadMemory( pDevice,
  230. &IpsecGlobal,
  231. sizeof(IPSEC_GLOBAL),
  232. &result )) {
  233. dprintf("%08lx: Could not read device context\n", pDevice);
  234. return;
  235. }
  236. }
  237. for (Index = MIN_TRANSPORT_FILTER; Index <= MAX_TRANSPORT_FILTER; Index++) {
  238. pEntry = IpsecGlobal.FilterList[Index].Flink;
  239. while (pEntry != (PLIST_ENTRY)(pDevice + FIELD_OFFSET(IPSEC_GLOBAL, FilterList[Index]))) {
  240. pFilter = CONTAINING_RECORD(pEntry,
  241. FILTER,
  242. MaskedLinkage);
  243. if ( !ReadMemory( (ULONG)pFilter,
  244. &Filter,
  245. sizeof(Filter),
  246. &result )) {
  247. dprintf("%08lx: Could not read device context\n", pDevice);
  248. return;
  249. }
  250. DumpFilter(pFilter, Filter);
  251. pEntry = Filter.MaskedLinkage.Flink;
  252. }
  253. }
  254. return;
  255. }
  256. VOID
  257. Itfl(DWORD opts, LPSTR args)
  258. {
  259. ULONG deviceToDump = 0;
  260. ULONG result;
  261. UCHAR cmdline[MAX_PATH]="0";
  262. UCHAR arg[MAX_PATH]="0";
  263. ULONG pDevice=0;
  264. IPSEC_GLOBAL IpsecGlobal;
  265. PFILTER pFilter;
  266. FILTER Filter;
  267. PLIST_ENTRY pEntry;
  268. LONG Index;
  269. pDevice = GetExpression( "ipsec!g_ipsec" );
  270. if ( !pDevice ) {
  271. dprintf("Could not get g_ipsec, Try !reload\n");
  272. return;
  273. } else {
  274. if ( !ReadMemory( pDevice,
  275. &IpsecGlobal,
  276. sizeof(IPSEC_GLOBAL),
  277. &result )) {
  278. dprintf("%08lx: Could not read device context\n", pDevice);
  279. return;
  280. }
  281. }
  282. for (Index = MIN_TUNNEL_FILTER; Index <= MAX_TUNNEL_FILTER; Index++) {
  283. pEntry = IpsecGlobal.FilterList[Index].Flink;
  284. while (pEntry != (PLIST_ENTRY)(pDevice + FIELD_OFFSET(IPSEC_GLOBAL, FilterList[Index]))) {
  285. pFilter = CONTAINING_RECORD(pEntry,
  286. FILTER,
  287. MaskedLinkage);
  288. if ( !ReadMemory( (ULONG)pFilter,
  289. &Filter,
  290. sizeof(Filter),
  291. &result )) {
  292. dprintf("%08lx: Could not read device context\n", pDevice);
  293. return;
  294. }
  295. DumpFilter(pFilter, Filter);
  296. pEntry = Filter.MaskedLinkage.Flink;
  297. }
  298. }
  299. return;
  300. }
  301. FLAG_INFO FlagsSA[] =
  302. {
  303. { FLAGS_SA_INITIATOR , "Initiator" },
  304. { FLAGS_SA_OUTBOUND , "Outbound" },
  305. { FLAGS_SA_TUNNEL , "Tunnel" },
  306. { FLAGS_SA_REKEY , "Rekey" },
  307. { FLAGS_SA_MANUAL , "Manual" },
  308. { FLAGS_SA_MTU_BUMPED , "MTU_Bumped" },
  309. { FLAGS_SA_PENDING , "Pending" },
  310. { FLAGS_SA_TIMER_STARTED , "Timer_Started" },
  311. { FLAGS_SA_HW_PLUMBED , "HW_Plumbed" },
  312. { FLAGS_SA_HW_PLUMB_FAILED, "HW_Plumb_failed" },
  313. { FLAGS_SA_HW_CRYPTO_ONLY , "HW_Crpto_only" },
  314. { FLAGS_SA_REFERENCED , "SA_referenced" },
  315. { 0, NULL }
  316. };
  317. ENUM_INFO StateSA[] =
  318. {
  319. { STATE_SA_CREATED, "Created" },
  320. { STATE_SA_LARVAL, "Larval" },
  321. { STATE_SA_ACTIVE, "Active" },
  322. { STATE_SA_ZOMBIE, "Zombie" },
  323. { 0, NULL }
  324. };
  325. ENUM_INFO OperationSA[] =
  326. {
  327. { None, "None" },
  328. { Auth, "Auth" },
  329. { Encrypt,"Encrypt"},
  330. { Compress,"Compress"},
  331. { 0, NULL }
  332. };
  333. ENUM_INFO AHAlgo[] =
  334. {
  335. { IPSEC_AH_NONE, "IPSEC_AH_NONE"},
  336. { IPSEC_AH_MD5, "IPSEC_AH_MD5"},
  337. { IPSEC_AH_SHA, "IPSEC_AH_SHA"},
  338. { IPSEC_AH_MAX, "IPSEC_AH_MAX"},
  339. { 0, NULL }
  340. };
  341. ENUM_INFO ESPAlgo[] =
  342. {
  343. { IPSEC_ESP_NONE, "IPSEC_ESP_NONE"},
  344. { IPSEC_ESP_DES, "IPSEC_ESP_DES"},
  345. { IPSEC_ESP_DES_40, "IPSEC_ESP_DES_40"},
  346. { IPSEC_ESP_3_DES, "IPSEC_ESP_3_DES"},
  347. { IPSEC_ESP_MAX, "IPSEC_ESP_MAX"},
  348. { 0, NULL }
  349. };
  350. #ifdef _obj
  351. # undef _obj
  352. # undef _objAddr
  353. # undef _objType
  354. #endif
  355. #define _obj SA
  356. #define _objAddr pSA
  357. #define _objType SA_TABLE_ENTRY
  358. VOID
  359. DumpSA(PSA_TABLE_ENTRY pSA, SA_TABLE_ENTRY SA)
  360. {
  361. ULARGE_INTEGER uliSrcDstAddr;
  362. ULARGE_INTEGER uliSrcDstMask;
  363. ULARGE_INTEGER uliProtoSrcDstPort;
  364. LONG i;
  365. uliSrcDstAddr = SA.sa_uliSrcDstAddr;
  366. uliProtoSrcDstPort = SA.sa_uliProtoSrcDstPort;
  367. dprintf("\n---------------------- Security Association: %lx -----------------------\n", pSA);
  368. PrintLL(sa_SPILinkage);
  369. PrintLL(sa_FilterLinkage);
  370. PrintLL(sa_LarvalLinkage);
  371. PrintLL(sa_PendingLinkage);
  372. PrintXULong(sa_AssociatedSA);
  373. PrintXULong(sa_RekeyLarvalSA);
  374. PrintXULong(sa_RekeyOriginalSA);
  375. PrintXULong(sa_Filter);
  376. PrintXULong(sa_Signature);
  377. PrintULong(sa_Reference);
  378. PrintFlags(sa_Flags, FlagsSA);
  379. PrintEnum(sa_State, StateSA);
  380. PrintFieldName("SrcAddr");
  381. dprint_IP_address( SRC_ADDR );
  382. PrintNL();
  383. PrintFieldName("DestAddr");
  384. dprint_IP_address( DEST_ADDR );
  385. PrintNL();
  386. PrintUShort(SA_PROTO);
  387. PrintFieldName("SrcPort");
  388. dprintf("%-10hu%s", SA_SRC_PORT(&SA), EOL);
  389. PrintFieldName("DestPort");
  390. dprintf("%-10hu%s", SA_DEST_PORT(&SA), EOL);
  391. PrintIPAddress(sa_TunnelAddr);
  392. PrintXULong(sa_SPI);
  393. PrintULong(sa_NumOps);
  394. for (i=0; i<SA.sa_NumOps; i++) {
  395. PrintXULong(sa_OtherSPIs[i]);
  396. switch (SA.sa_Operation[i]) {
  397. case None:
  398. break;
  399. case Auth:
  400. PrintEnum(sa_Algorithm[i].integrityAlgo.algoIdentifier, AHAlgo);
  401. PrintFieldName("algoKey");
  402. dprintf("%lx %lx", SA.sa_Algorithm[i].integrityAlgo.algoKey, EOL);
  403. PrintNL();
  404. PrintULong(sa_Algorithm[i].integrityAlgo.algoKeylen);
  405. break;
  406. case Encrypt:
  407. PrintEnum(sa_Algorithm[i].integrityAlgo.algoIdentifier, AHAlgo);
  408. PrintFieldName("algoKey");
  409. dprintf("%lx %lx", SA.sa_Algorithm[i].integrityAlgo.algoKey, EOL);
  410. PrintNL();
  411. PrintULong(sa_Algorithm[i].integrityAlgo.algoKeylen);
  412. PrintEnum(sa_Algorithm[i].confAlgo.algoIdentifier, ESPAlgo);
  413. PrintFieldName("algoKey");
  414. dprintf("%lx %lx", SA.sa_Algorithm[i].confAlgo.algoKey, EOL);
  415. PrintNL();
  416. PrintULong(sa_Algorithm[i].confAlgo.algoKeylen);
  417. break;
  418. }
  419. }
  420. PrintULong(sa_TruncatedLen);
  421. PrintULong(sa_ReplayStartPoint);
  422. PrintULong(sa_ReplayLastSeq);
  423. PrintULong(sa_ReplayBitmap);
  424. PrintULong(sa_ReplaySendSeq);
  425. PrintULong(sa_ReplayLen);
  426. PrintULong(sa_BlockedDataLen);
  427. PrintXULong(sa_BlockedBuffer);
  428. PrintULong(sa_ExpiryTime);
  429. }
  430. VOID
  431. Isas(DWORD opts, LPSTR args)
  432. {
  433. ULONG deviceToDump = 0;
  434. ULONG result;
  435. ULONG pDevice=0;
  436. IPSEC_GLOBAL IpsecGlobal;
  437. PFILTER pFilter;
  438. FILTER Filter;
  439. PLIST_ENTRY pEntry;
  440. PLIST_ENTRY pEntry1;
  441. PSA_TABLE_ENTRY pSA;
  442. SA_TABLE_ENTRY SA;
  443. SA_TABLE_ENTRY NextSA;
  444. LONG Index, SAIndex;
  445. LIST_ENTRY * SAChain;
  446. pDevice = GetExpression( "ipsec!g_ipsec" );
  447. SAChain= malloc(256*sizeof(LIST_ENTRY)*sizeof(LIST_ENTRY));
  448. if (NULL==SAChain)
  449. {
  450. dprintf("Could not allocate memory resources\n");
  451. return;
  452. }
  453. if ( !pDevice ) {
  454. dprintf("Could not get g_ipsec, Try !reload\n");
  455. free(SAChain);
  456. return;
  457. } else {
  458. if ( !ReadMemory( pDevice,
  459. &IpsecGlobal,
  460. sizeof(IPSEC_GLOBAL),
  461. &result )) {
  462. dprintf("%08lx: Could not read device context\n", pDevice);
  463. free(SAChain);
  464. return;
  465. }
  466. }
  467. for (Index = MIN_TRANSPORT_FILTER; Index <= MAX_TRANSPORT_FILTER; Index++) {
  468. pEntry = IpsecGlobal.FilterList[Index].Flink;
  469. while (pEntry != (PLIST_ENTRY)(pDevice + FIELD_OFFSET(IPSEC_GLOBAL, FilterList[Index]))) {
  470. pFilter = CONTAINING_RECORD(pEntry,
  471. FILTER,
  472. MaskedLinkage);
  473. if ( !ReadMemory( (ULONG)pFilter,
  474. &Filter,
  475. sizeof(Filter),
  476. &result )) {
  477. dprintf("%08lx: Could not read filter context\n", pFilter);
  478. free(SAChain);
  479. return;
  480. }
  481. if ( !ReadMemory( (ULONG)pFilter + FIELD_OFFSET(FILTER, SAChain[0]),
  482. SAChain,
  483. Filter.SAChainSize * sizeof(LIST_ENTRY),
  484. &result )) {
  485. dprintf("%08lx: Could not read SAChain context\n", pFilter + FIELD_OFFSET(FILTER, SAChain[0]));
  486. free(SAChain);
  487. return;
  488. }
  489. DumpFilter(pFilter, Filter);
  490. for (SAIndex = 0; SAIndex < Filter.SAChainSize; SAIndex++) {
  491. pEntry1 = SAChain[SAIndex].Flink;
  492. while (pEntry1 != (PLIST_ENTRY)((PUCHAR)pFilter + FIELD_OFFSET(FILTER, SAChain[SAIndex]))) {
  493. pSA = CONTAINING_RECORD(pEntry1,
  494. SA_TABLE_ENTRY,
  495. sa_FilterLinkage);
  496. if ( !ReadMemory( (ULONG)pSA,
  497. &SA,
  498. sizeof(SA),
  499. &result )) {
  500. dprintf("%08lx: Could not read SA context\n", pSA);
  501. free(SAChain);
  502. return;
  503. }
  504. DumpSA(pSA, SA);
  505. pEntry1 = SA.sa_FilterLinkage.Flink;
  506. }
  507. }
  508. pEntry = Filter.MaskedLinkage.Flink;
  509. }
  510. }
  511. free(SAChain);
  512. return;
  513. }
  514. VOID
  515. Itsas(DWORD opts, LPSTR args)
  516. {
  517. ULONG deviceToDump = 0;
  518. ULONG result;
  519. ULONG pDevice=0;
  520. IPSEC_GLOBAL IpsecGlobal;
  521. PFILTER pFilter;
  522. FILTER Filter;
  523. PLIST_ENTRY pEntry;
  524. PLIST_ENTRY pEntry1;
  525. PSA_TABLE_ENTRY pSA;
  526. SA_TABLE_ENTRY SA;
  527. SA_TABLE_ENTRY NextSA;
  528. LONG Index, SAIndex;
  529. LIST_ENTRY * SAChain;
  530. pDevice = GetExpression( "ipsec!g_ipsec" );
  531. SAChain=malloc(256*sizeof(LIST_ENTRY)*sizeof(LIST_ENTRY));
  532. if (NULL==SAChain)
  533. {
  534. dprintf("Could not allocate memory resources\n");
  535. return;
  536. }
  537. if ( !pDevice ) {
  538. dprintf("Could not get g_ipsec, Try !reload\n");
  539. free(SAChain);
  540. return;
  541. } else {
  542. if ( !ReadMemory( pDevice,
  543. &IpsecGlobal,
  544. sizeof(IPSEC_GLOBAL),
  545. &result )) {
  546. dprintf("%08lx: Could not read device context\n", pDevice);
  547. free(SAChain);
  548. return;
  549. }
  550. }
  551. for (Index = MIN_TUNNEL_FILTER; Index <= MAX_TUNNEL_FILTER; Index++) {
  552. pEntry = IpsecGlobal.FilterList[Index].Flink;
  553. while (pEntry != (PLIST_ENTRY)(pDevice + FIELD_OFFSET(IPSEC_GLOBAL, FilterList[Index]))) {
  554. pFilter = CONTAINING_RECORD(pEntry,
  555. FILTER,
  556. MaskedLinkage);
  557. if ( !ReadMemory( (ULONG)pFilter,
  558. &Filter,
  559. sizeof(Filter),
  560. &result )) {
  561. dprintf("%08lx: Could not read filter context\n", pFilter);
  562. free(SAChain);
  563. return;
  564. }
  565. if ( !ReadMemory( (ULONG)pFilter + FIELD_OFFSET(FILTER, SAChain[0]),
  566. SAChain,
  567. Filter.SAChainSize * sizeof(LIST_ENTRY),
  568. &result )) {
  569. dprintf("%08lx: Could not read SAChain context\n", pFilter + FIELD_OFFSET(FILTER, SAChain[0]));
  570. free(SAChain);
  571. return;
  572. }
  573. DumpFilter(pFilter, Filter);
  574. for (SAIndex = 0; SAIndex < Filter.SAChainSize; SAIndex++) {
  575. pEntry1 = SAChain[SAIndex].Flink;
  576. while (pEntry1 != (PLIST_ENTRY)((PUCHAR)pFilter + FIELD_OFFSET(FILTER, SAChain[SAIndex]))) {
  577. pSA = CONTAINING_RECORD(pEntry1,
  578. SA_TABLE_ENTRY,
  579. sa_FilterLinkage);
  580. if ( !ReadMemory( (ULONG)pSA,
  581. &SA,
  582. sizeof(SA),
  583. &result )) {
  584. dprintf("%08lx: Could not read SA context\n", pSA);
  585. free(SAChain);
  586. return;
  587. }
  588. DumpSA(pSA, SA);
  589. pEntry1 = SA.sa_FilterLinkage.Flink;
  590. }
  591. }
  592. pEntry = Filter.MaskedLinkage.Flink;
  593. }
  594. }
  595. free(SAChain);
  596. return;
  597. }
  598. VOID
  599. Ilarvalsas(DWORD opts, LPSTR args)
  600. {
  601. ULONG deviceToDump = 0;
  602. ULONG result;
  603. ULONG pDevice=0;
  604. IPSEC_GLOBAL IpsecGlobal;
  605. PFILTER pFilter;
  606. FILTER Filter;
  607. PLIST_ENTRY pEntry;
  608. PLIST_ENTRY pEntry1;
  609. PSA_TABLE_ENTRY pSA;
  610. SA_TABLE_ENTRY SA;
  611. SA_TABLE_ENTRY NextSA;
  612. pDevice = GetExpression( "ipsec!g_ipsec" );
  613. if ( !pDevice ) {
  614. dprintf("Could not get g_ipsec, Try !reload\n");
  615. return;
  616. } else {
  617. if ( !ReadMemory( pDevice,
  618. &IpsecGlobal,
  619. sizeof(IPSEC_GLOBAL),
  620. &result )) {
  621. dprintf("%08lx: Could not read device context\n", pDevice);
  622. return;
  623. }
  624. }
  625. pEntry = IpsecGlobal.LarvalSAList.Flink;
  626. while (pEntry != (PLIST_ENTRY)(pDevice + FIELD_OFFSET(IPSEC_GLOBAL, LarvalSAList))) {
  627. pSA = CONTAINING_RECORD(pEntry,
  628. SA_TABLE_ENTRY,
  629. sa_LarvalLinkage);
  630. if ( !ReadMemory( (ULONG)pSA,
  631. &SA,
  632. sizeof(SA),
  633. &result )) {
  634. dprintf("%08lx: Could not read device context\n", pDevice);
  635. return;
  636. }
  637. DumpSA(pSA, SA);
  638. pEntry = SA.sa_LarvalLinkage.Flink;
  639. }
  640. return;
  641. }