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.

5042 lines
148 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. afdutil.c
  5. Abstract:
  6. Utility functions for dumping various AFD structures.
  7. Author:
  8. Keith Moore (keithmo) 19-Apr-1995
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "afdkdp.h"
  14. #pragma hdrstop
  15. //
  16. // Private constants.
  17. //
  18. //
  19. // Private globals.
  20. //
  21. PSTR WeekdayNames[] =
  22. {
  23. "Sun",
  24. "Mon",
  25. "Tue",
  26. "Wed",
  27. "Thu",
  28. "Fri",
  29. "Sat"
  30. };
  31. PSTR MonthNames[] =
  32. {
  33. "",
  34. "Jan",
  35. "Feb",
  36. "Mar",
  37. "Apr",
  38. "May",
  39. "Jun",
  40. "Jul",
  41. "Aug",
  42. "Sep",
  43. "Oct",
  44. "Nov",
  45. "Dec"
  46. };
  47. //
  48. // Private prototypes.
  49. //
  50. PSTR
  51. StructureTypeToString(
  52. USHORT Type
  53. );
  54. PSTR
  55. StructureTypeToStringBrief (
  56. USHORT Type
  57. );
  58. PSTR
  59. BooleanToString(
  60. BOOLEAN Flag
  61. );
  62. PSTR
  63. EndpointStateToString(
  64. UCHAR State
  65. );
  66. PSTR
  67. EndpointStateToStringBrief(
  68. UCHAR State
  69. );
  70. PSTR
  71. EndpointStateFlagsToString(
  72. );
  73. PSTR
  74. EndpointTypeToString(
  75. ULONG TypeFlags
  76. );
  77. PSTR
  78. ConnectionStateToString(
  79. USHORT State
  80. );
  81. PSTR
  82. ConnectionStateToStringBrief(
  83. USHORT State
  84. );
  85. PSTR
  86. ConnectionStateFlagsToString(
  87. );
  88. PSTR
  89. TranfileFlagsToString(
  90. VOID
  91. );
  92. PSTR
  93. TPacketsFlagsToStringNet(
  94. ULONG Flags,
  95. ULONG StateFlags
  96. );
  97. PSTR
  98. TPacketsFlagsToStringXp(
  99. ULONG Flags,
  100. ULONG StateFlags
  101. );
  102. VOID
  103. DumpAfdTPacketsInfoNet(
  104. ULONG64 ActualAddress
  105. );
  106. VOID
  107. DumpAfdTPacketsInfoBriefNet (
  108. ULONG64 ActualAddress
  109. );
  110. VOID
  111. DumpAfdTPacketsInfoXp(
  112. ULONG64 ActualAddress
  113. );
  114. VOID
  115. DumpAfdTPacketsInfoBriefXp (
  116. ULONG64 ActualAddress
  117. );
  118. PSTR
  119. BufferFlagsToString(
  120. );
  121. PSTR
  122. SystemTimeToString(
  123. LONGLONG Value
  124. );
  125. PSTR
  126. GroupTypeToString(
  127. AFD_GROUP_TYPE GroupType
  128. );
  129. VOID
  130. DumpReferenceDebug(
  131. PAFD_REFERENCE_DEBUG ReferenceDebug,
  132. ULONG CurrentSlot
  133. );
  134. BOOL
  135. IsTransmitIrpBusy(
  136. PIRP Irp
  137. );
  138. PSTR
  139. TdiServiceFlagsToStringBrief(
  140. ULONG Flags
  141. );
  142. //
  143. // Public functions.
  144. //
  145. VOID
  146. DumpAfdEndpoint(
  147. ULONG64 ActualAddress
  148. )
  149. /*++
  150. Routine Description:
  151. Dumps the specified AFD_ENDPOINT structure.
  152. Arguments:
  153. ActualAddress - The actual address where the structure resides on the
  154. debugee.
  155. Return Value:
  156. None.
  157. --*/
  158. {
  159. ULONG64 address;
  160. ULONG length;
  161. UCHAR transportAddress[MAX_TRANSPORT_ADDR];
  162. ULONG64 irp, process, pid, tinfo;
  163. ULONG result;
  164. PAFDKD_TRANSPORT_INFO transportInfo = NULL;
  165. USHORT type;
  166. UCHAR state;
  167. LONG stateChangeInProgress;
  168. ULONG stateFlags, tdiFlags;
  169. ULONG EventStatus[AFD_NUM_POLL_EVENTS];
  170. dprintf(
  171. "\nAFD_ENDPOINT @ %p:\n",
  172. ActualAddress
  173. );
  174. dprintf(
  175. " ReferenceCount = %ld\n",
  176. (ULONG)ReadField(ReferenceCount)
  177. );
  178. type=(USHORT)ReadField (Type);
  179. dprintf(
  180. " Type = %04X (%s)\n",
  181. type,
  182. StructureTypeToString( type )
  183. );
  184. state=(UCHAR)ReadField (State);
  185. dprintf(
  186. " State = %02X (%s)\n",
  187. state,
  188. EndpointStateToString(state)
  189. );
  190. if ((stateChangeInProgress=(ULONG)ReadField (StateChangeInProgress))!=0) {
  191. dprintf(
  192. " State changing to = %02X (%s)\n",
  193. stateChangeInProgress,
  194. EndpointStateToString( (UCHAR)stateChangeInProgress )
  195. );
  196. }
  197. tdiFlags=(ULONG)ReadField (TdiServiceFlags);
  198. dprintf(
  199. " TdiTransportFlags = %08lx (",
  200. tdiFlags
  201. );
  202. if (TDI_SERVICE_ORDERLY_RELEASE & tdiFlags)
  203. dprintf (" OrdRel");
  204. if (TDI_SERVICE_DELAYED_ACCEPTANCE & tdiFlags)
  205. dprintf (" DelAcc");
  206. if (TDI_SERVICE_EXPEDITED_DATA & tdiFlags)
  207. dprintf (" Expd");
  208. if (TDI_SERVICE_INTERNAL_BUFFERING & tdiFlags)
  209. dprintf (" Buff");
  210. if (TDI_SERVICE_MESSAGE_MODE & tdiFlags)
  211. dprintf (" Msg");
  212. if (TDI_SERVICE_DGRAM_CONNECTION & tdiFlags)
  213. dprintf (" DgramCon");
  214. if (TDI_SERVICE_FORCE_ACCESS_CHECK & tdiFlags)
  215. dprintf (" AccChk");
  216. if (TDI_SERVICE_SEND_AND_DISCONNECT & tdiFlags)
  217. dprintf (" S&D");
  218. if (TDI_SERVICE_DIRECT_ACCEPT & tdiFlags)
  219. dprintf (" DirAcc");
  220. if (TDI_SERVICE_ACCEPT_LOCAL_ADDR & tdiFlags)
  221. dprintf (" AccLAd");
  222. dprintf (" )\n");
  223. dprintf(
  224. " StateFlags = %08X (",
  225. stateFlags = (ULONG)ReadField (EndpointStateFlags)
  226. );
  227. if (ReadField (Listening))
  228. dprintf (" Listn");
  229. if (ReadField (DelayedAcceptance))
  230. dprintf (" DelAcc");
  231. if (ReadField (NonBlocking))
  232. dprintf (" NBlock");
  233. if (ReadField (InLine))
  234. dprintf (" InLine");
  235. if (ReadField (EndpointCleanedUp))
  236. dprintf (" Clnd-up");
  237. if (ReadField (PollCalled))
  238. dprintf (" Polled");
  239. if (ReadField (RoutingQueryReferenced))
  240. dprintf (" RtQ");
  241. if (SavedMinorVersion>=2246) {
  242. if (ReadField (RoutingQueryIPv6))
  243. dprintf (" RtQ6");
  244. }
  245. if (ReadField (DisableFastIoSend))
  246. dprintf (" -FastSnd");
  247. if (ReadField (EnableSendEvent))
  248. dprintf (" +SndEvt");
  249. if (ReadField (DisableFastIoRecv))
  250. dprintf (" -FastRcv");
  251. dprintf (" )\n");
  252. dprintf(
  253. " TransportInfo = %p\n",
  254. address = ReadField (TransportInfo)
  255. );
  256. if (address!=0) {
  257. PLIST_ENTRY listEntry;
  258. listEntry = TransportInfoList.Flink;
  259. while (listEntry!=&TransportInfoList) {
  260. transportInfo = CONTAINING_RECORD (listEntry, AFDKD_TRANSPORT_INFO, Link);
  261. if (transportInfo->ActualAddress==address)
  262. break;
  263. listEntry = listEntry->Flink;
  264. }
  265. if (listEntry==&TransportInfoList) {
  266. transportInfo = ReadTransportInfo (address);
  267. if (transportInfo!=NULL) {
  268. InsertHeadList (&TransportInfoList, &transportInfo->Link);
  269. }
  270. }
  271. if (transportInfo!=NULL) {
  272. dprintf(
  273. " TransportDeviceName = %ls\n",
  274. transportInfo->DeviceName
  275. );
  276. }
  277. }
  278. dprintf(
  279. " AddressHandle = %p\n",
  280. ReadField (AddressHandle)
  281. );
  282. dprintf(
  283. " AddressFileObject = %p\n",
  284. ReadField (AddressFileObject)
  285. );
  286. dprintf(
  287. " AddressDeviceObject = %p\n",
  288. ReadField (AddressDeviceObject)
  289. );
  290. dprintf(
  291. " AdminAccessGranted = %s\n",
  292. BooleanToString( (BOOLEAN)ReadField (AdminAccessGranted))
  293. );
  294. switch( type ) {
  295. case AfdBlockTypeVcConnecting :
  296. address = ReadField (Common.VirtualCircuit.Connection);
  297. dprintf(
  298. " Connection = %p",
  299. address!=0
  300. ? address
  301. : (((state==AfdEndpointStateClosing ||
  302. state==AfdEndpointStateTransmitClosing) &&
  303. ((address = ReadField (WorkItem.Context))!=0))
  304. ? address
  305. : 0)
  306. );
  307. if (address!=0) {
  308. ULONG64 connAddr = address;
  309. if (GetFieldValue (connAddr,
  310. "AFD!AFD_CONNECTION",
  311. "RemoteAddress",
  312. address)==0 &&
  313. address!=0 &&
  314. GetFieldValue (connAddr,
  315. "AFD!AFD_CONNECTION",
  316. "RemoteAddressLength",
  317. length)==0 &&
  318. length!=0 ) {
  319. if (ReadMemory (address,
  320. transportAddress,
  321. length<sizeof (transportAddress)
  322. ? length
  323. : sizeof (transportAddress),
  324. &length)) {
  325. dprintf (" (to %s)", TransportAddressToString (
  326. (PTRANSPORT_ADDRESS)transportAddress, address));
  327. }
  328. else {
  329. dprintf (" (Could not read transport address @ %p)", address);
  330. }
  331. }
  332. else if (state==AfdEndpointStateConnected ||
  333. state==AfdEndpointStateTransmitClosing) {
  334. ULONG64 contextAddr;
  335. //
  336. // Attempt to read user mode data stored as the context
  337. //
  338. result = GetRemoteAddressFromContext (ActualAddress,
  339. transportAddress,
  340. sizeof (transportAddress),
  341. &contextAddr);
  342. if (result==0) {
  343. dprintf (" (to %s)", TransportAddressToString (
  344. (PTRANSPORT_ADDRESS)transportAddress, contextAddr));
  345. }
  346. else if ((result==MEMORY_READ_ERROR) &&
  347. (transportInfo!=NULL) &&
  348. (_wcsicmp (transportInfo->DeviceName, L"\\Device\\TCP")==0)) {
  349. ULONG64 tdiFile;
  350. if ((result=GetFieldValue (connAddr,
  351. "AFD!AFD_CONNECTION",
  352. "FileObject",
  353. tdiFile))==0 &&
  354. (result=GetRemoteAddressFromTcp (tdiFile,
  355. transportAddress,
  356. sizeof (transportAddress)))==0) {
  357. dprintf (" (to %s)", TransportAddressToString (
  358. (PTRANSPORT_ADDRESS)transportAddress, contextAddr));
  359. }
  360. else {
  361. dprintf (" (Could not read transport address from endpoint context @%p (err: %ld) and TCP (err: %ld))",
  362. contextAddr, MEMORY_READ_ERROR, result);
  363. }
  364. }
  365. else {
  366. dprintf (" (Could not read transport address from endpoint context @ %p (err: %ld))", contextAddr, result);
  367. }
  368. }
  369. }
  370. dprintf("\n");
  371. dprintf(
  372. " ListenEndpoint = %p\n",
  373. ReadField (Common.VirtualCircuit.ListenEndpoint)
  374. );
  375. dprintf(
  376. " ConnectDataBuffers = %p\n",
  377. ReadField (Common.VirtualCircuit.ConnectDataBuffers)
  378. );
  379. break;
  380. case AfdBlockTypeVcBoth :
  381. dprintf(
  382. " Connection = %p",
  383. address=ReadField (Common.VirtualCircuit.Connection)
  384. );
  385. if (address!=0) {
  386. ULONG64 connAddr = address;
  387. if (GetFieldValue (connAddr,
  388. "AFD!AFD_CONNECTION",
  389. "RemoteAddress",
  390. address)==0 &&
  391. address!=0 &&
  392. GetFieldValue (connAddr,
  393. "AFD!AFD_CONNECTION",
  394. "RemoteAddressLength",
  395. length)==0 &&
  396. length!=0 ) {
  397. if (ReadMemory (address,
  398. transportAddress,
  399. length<sizeof (transportAddress)
  400. ? length
  401. : sizeof (transportAddress),
  402. &length)) {
  403. dprintf (" (to %s)", TransportAddressToString (
  404. (PTRANSPORT_ADDRESS)transportAddress, address));
  405. }
  406. else {
  407. dprintf (" (Could not read transport address @ %p)", address);
  408. }
  409. }
  410. else if (state==AfdEndpointStateConnected ||
  411. state==AfdEndpointStateTransmitClosing) {
  412. ULONG64 contextAddr;
  413. //
  414. // Attempt to read user mode data stored as the context
  415. //
  416. result = GetRemoteAddressFromContext (ActualAddress,
  417. transportAddress,
  418. sizeof (transportAddress),
  419. &contextAddr);
  420. if (result==0) {
  421. dprintf (" (to %s)", TransportAddressToString (
  422. (PTRANSPORT_ADDRESS)transportAddress, contextAddr));
  423. }
  424. else if ((result==MEMORY_READ_ERROR) &&
  425. (transportInfo!=NULL) &&
  426. (_wcsicmp (transportInfo->DeviceName, L"\\Device\\TCP")==0)) {
  427. ULONG64 tdiFile;
  428. if ((result=GetFieldValue (connAddr,
  429. "AFD!AFD_CONNECTION",
  430. "FileObject",
  431. tdiFile))==0 &&
  432. (result=GetRemoteAddressFromTcp (tdiFile,
  433. transportAddress,
  434. sizeof (transportAddress)))==0) {
  435. dprintf (" (to %s)", TransportAddressToString (
  436. (PTRANSPORT_ADDRESS)transportAddress, contextAddr));
  437. }
  438. else {
  439. dprintf (" (Could not read transport address from endpoint context @%p (err: %ld) and TCP (err: %ld))",
  440. contextAddr, MEMORY_READ_ERROR, result);
  441. }
  442. }
  443. else {
  444. dprintf (" (Could not read transport address from endpoint context @ %p)", contextAddr);
  445. }
  446. }
  447. }
  448. dprintf ("\n");
  449. dprintf(
  450. " ConnectDataBuffers = %p\n",
  451. ReadField (Common.VirtualCircuit.ConnectDataBuffers)
  452. );
  453. // Skip through to listening endpoint
  454. case AfdBlockTypeVcListening :
  455. if (ReadField(DelayedAcceptance)) {
  456. dprintf(
  457. " ListenConnectionListHead @ %s\n",
  458. LIST_TO_STRING(
  459. ActualAddress+ListenConnListOffset
  460. )
  461. );
  462. }
  463. else {
  464. dprintf(
  465. " FreeConnectionListHead @ %p(%d)\n",
  466. ActualAddress + FreeConnListOffset,
  467. (USHORT)ReadField (Common.VirtualCircuit.Listening.FreeConnectionListHead.Depth)
  468. );
  469. dprintf(
  470. " AcceptExIrpListHead @ %p(%d)\n",
  471. ActualAddress + PreaccConnListOffset,
  472. (USHORT)ReadField (Common.VirtualCircuit.Listening.PreacceptedConnectionsListHead.Depth)
  473. );
  474. }
  475. dprintf(
  476. " UnacceptedConnectionListHead %s\n",
  477. LIST_TO_STRING(
  478. ActualAddress + UnacceptedConnListOffset)
  479. );
  480. dprintf(
  481. " ReturnedConnectionListHead %s\n",
  482. LIST_TO_STRING(
  483. ActualAddress + ReturnedConnListOffset)
  484. );
  485. dprintf(
  486. " ListeningIrpListHead %s\n",
  487. LIST_TO_STRING(
  488. ActualAddress + ListenIrpListOffset)
  489. );
  490. dprintf(
  491. " FailedConnectionAdds = %ld\n",
  492. (LONG)ReadField (Common.VirtualCircuit.Listening.FailedConnectionAdds)
  493. );
  494. dprintf(
  495. " TdiAcceptPendingCount = %ld\n",
  496. (LONG)ReadField (Common.VirtualCircuit.Listening.TdiAcceptPendingCount)
  497. );
  498. dprintf(
  499. " MaxCachedConnections = %ld\n",
  500. (USHORT)ReadField (Common.VirtualCircuit.Listening.MaxExtraConnections)
  501. );
  502. dprintf(
  503. " ConnectionSequenceNumber = %ld\n",
  504. (LONG)ReadField (Common.VirtualCircuit.ListeningSequence)
  505. );
  506. dprintf(
  507. " BacklogReplenishActive = %s\n",
  508. BooleanToString (
  509. (BOOLEAN)ReadField (Common.VirtualCircuit.Listening.BacklogReplenishActive))
  510. );
  511. dprintf(
  512. " EnableDynamicBacklog = %s\n",
  513. BooleanToString (
  514. (BOOLEAN)(LONG)ReadField (Common.VirtualCircuit.Listening.EnableDynamicBacklog))
  515. );
  516. break;
  517. case AfdBlockTypeDatagram :
  518. dprintf(
  519. " RemoteAddress = %p\n",
  520. address = ReadField (Common.Datagram.RemoteAddress)
  521. );
  522. dprintf(
  523. " RemoteAddressLength = %lu\n",
  524. length=(ULONG)ReadField (Common.Datagram.RemoteAddressLength)
  525. );
  526. if( address!=0 ) {
  527. if (ReadMemory (address,
  528. transportAddress,
  529. length<sizeof (transportAddress)
  530. ? length
  531. : sizeof (transportAddress),
  532. &length)) {
  533. DumpTransportAddress(
  534. " ",
  535. (PTRANSPORT_ADDRESS)transportAddress,
  536. address
  537. );
  538. }
  539. else {
  540. dprintf ("\nDumpAfdEndpoint: Could not read transport address @ %p\n", address);
  541. }
  542. }
  543. dprintf(
  544. " ReceiveIrpListHead %s\n",
  545. LIST_TO_STRING(
  546. ActualAddress + DatagramRecvListOffset)
  547. );
  548. dprintf(
  549. " PeekIrpListHead %s\n",
  550. LIST_TO_STRING(
  551. ActualAddress + DatagramPeekListOffset)
  552. );
  553. dprintf(
  554. " ReceiveBufferListHead %s\n",
  555. LIST_TO_STRING(
  556. ActualAddress + DatagramBufferListOffset)
  557. );
  558. dprintf(
  559. " BufferredReceiveBytes = %08lx\n",
  560. (ULONG)ReadField (Common.Datagram.BufferredReceiveBytes)
  561. );
  562. dprintf(
  563. " BufferredReceiveCount = %04X\n",
  564. (ULONG)ReadField (Common.Datagram.BufferredReceiveCount)
  565. );
  566. dprintf(
  567. " MaxBufferredReceiveBytes = %08lx\n",
  568. (ULONG)ReadField (Common.Datagram.MaxBufferredReceiveBytes)
  569. );
  570. dprintf(
  571. " BufferredSendBytes = %08lx\n",
  572. (ULONG)ReadField (Common.Datagram.BufferredSendBytes)
  573. );
  574. dprintf(
  575. " MaxBufferredSendBytes = %08lx\n",
  576. (ULONG)ReadField (Common.Datagram.MaxBufferredSendBytes)
  577. );
  578. dprintf(
  579. " CircularQueueing = %s\n",
  580. BooleanToString(
  581. (BOOLEAN)ReadField (Common.Datagram.CircularQueueing ))
  582. );
  583. dprintf(
  584. " HalfConnect = %s\n",
  585. BooleanToString(
  586. (BOOLEAN)ReadField (Common.Datagram.HalfConnect))
  587. );
  588. if (SavedMinorVersion>=2466) {
  589. dprintf(
  590. " PacketsDropped due to %s%s%s%s\n",
  591. ReadField (Common.Datagram.AddressDrop)
  592. ? "source address, "
  593. : "",
  594. ReadField (Common.Datagram.ResourceDrop)
  595. ? "out of memory, "
  596. : "",
  597. ReadField (Common.Datagram.BufferDrop)
  598. ? "SO_RCVBUF setting, "
  599. : "",
  600. ReadField (Common.Datagram.ErrorDrop)
  601. ? "transport error"
  602. : ""
  603. );
  604. }
  605. break;
  606. case AfdBlockTypeSanEndpoint :
  607. dprintf(
  608. " HelperEndpoint = %p\n",
  609. ReadField (Common.SanEndp.SanHlpr)
  610. );
  611. dprintf(
  612. " FileObject = %p\n",
  613. ReadField (Common.SanEndp.FileObject)
  614. );
  615. dprintf(
  616. " Switch/Saved Context = %p (length: %d)\n",
  617. ReadField (Common.SanEndp.SwitchContext),
  618. (ULONG)ReadField (Common.SanEndp.SavedContextLength)
  619. );
  620. dprintf(
  621. " Local Context = %p\n",
  622. ReadField (Common.SanEndp.LocalContext)
  623. );
  624. dprintf(
  625. " Select Events Active = %lx\n",
  626. (ULONG)ReadField (Common.SanEndp.SelectEventsActive)
  627. );
  628. dprintf(
  629. " Request IrpList %s\n",
  630. LIST_TO_STRING(
  631. ActualAddress + SanIrpListOffset)
  632. );
  633. dprintf(
  634. " Request ID = %d\n",
  635. (ULONG)ReadField (Common.SanEndp.RequestId)
  636. );
  637. dprintf(
  638. " CtxTransferStatus = %lx%s\n",
  639. (ULONG)ReadField (Common.SanEndp.CtxTransferStatus),
  640. ReadField (Common.SanEndp.ImplicitDup) ? " (implicit)" : ""
  641. );
  642. if (state==AfdEndpointStateConnected ||
  643. state==AfdEndpointStateTransmitClosing) {
  644. ULONG64 contextAddr;
  645. //
  646. // Attempt to read user mode data stored as the context
  647. //
  648. result = GetRemoteAddressFromContext (ActualAddress,
  649. transportAddress,
  650. sizeof (transportAddress),
  651. &contextAddr);
  652. if (result==0) {
  653. dprintf (" Connected to = %s\n",
  654. TransportAddressToString (
  655. (PTRANSPORT_ADDRESS)transportAddress,
  656. contextAddr));
  657. }
  658. else {
  659. dprintf ("DumAfdEndpoint: Could not read transport address from endpoint context @ %p\n", contextAddr);
  660. }
  661. }
  662. break;
  663. case AfdBlockTypeSanHelper :
  664. dprintf(
  665. " IoCompletionPort = %p\n",
  666. ReadField (Common.SanHlpr.IoCompletionPort)
  667. );
  668. dprintf(
  669. " IoCompletionEvent = %p\n",
  670. ReadField (Common.SanHlpr.IoCompletionEvent)
  671. );
  672. dprintf(
  673. " Provider list sequence = %d\n",
  674. (LONG)ReadField (Common.SanHlpr.Plsn)
  675. );
  676. if (SavedMinorVersion>=3549) {
  677. result = (LONG)ReadField (Common.SanHlpr.PendingRequests);
  678. dprintf(
  679. " Pending requests = %d%s\n",
  680. result >> 1,
  681. (result & 1) ? " (cleaned-up)" : ""
  682. );
  683. }
  684. break;
  685. }
  686. dprintf(
  687. " DisconnectMode = %08lx\n",
  688. (ULONG)ReadField (DisconnectMode)
  689. );
  690. dprintf(
  691. " OutstandingIrpCount = %08lx\n",
  692. (ULONG)ReadField (OutstandingIrpCount)
  693. );
  694. dprintf(
  695. " LocalAddress = %p\n",
  696. address = ReadField (LocalAddress)
  697. );
  698. dprintf(
  699. " LocalAddressLength = %08lx\n",
  700. length = (ULONG)ReadField (LocalAddressLength)
  701. );
  702. if (address!=0) {
  703. if (ReadMemory (address,
  704. transportAddress,
  705. length<sizeof (transportAddress)
  706. ? length
  707. : sizeof (transportAddress),
  708. &length)) {
  709. DumpTransportAddress(
  710. " ",
  711. (PTRANSPORT_ADDRESS)transportAddress,
  712. address
  713. );
  714. }
  715. else {
  716. dprintf ("\nDumpAfdEndpoint: Could not read transport address @ %p\n", address);
  717. }
  718. }
  719. dprintf(
  720. " Context = %p\n",
  721. ReadField (Context)
  722. );
  723. dprintf(
  724. " ContextLength = %08lx\n",
  725. (ULONG)ReadField (ContextLength)
  726. );
  727. if (SavedMinorVersion>=2419) {
  728. process = ReadField (OwningProcess);
  729. }
  730. else {
  731. process = ReadField (ProcessCharge.Process);
  732. }
  733. if (GetFieldValue (
  734. process,
  735. "NT!_EPROCESS",
  736. "UniqueProcessId",
  737. pid)!=0) {
  738. pid = 0;
  739. }
  740. dprintf(
  741. " OwningProcess = %p (0x%lx)\n",
  742. process, (ULONG)pid
  743. );
  744. if (SavedMinorVersion>=2219) {
  745. irp = ReadField (Irp);
  746. if (irp!=0) {
  747. if (state==AfdEndpointStateConnected ||
  748. state==AfdEndpointStateTransmitClosing) {
  749. ULONG64 tpInfo;
  750. dprintf(
  751. " Transmit Irp = %p",
  752. irp);
  753. result = GetFieldValue (
  754. irp,
  755. "NT!_IRP",
  756. "AssociatedIrp.SystemBuffer",
  757. tpInfo);
  758. if (result==0) {
  759. dprintf (" (TPInfo @ %p)\n", tpInfo);
  760. }
  761. else {
  762. dprintf ("\nDumpAfdEndpoint: Could not read Irp's system buffer, err: %d\n",
  763. result);
  764. }
  765. }
  766. else if (state==AfdEndpointStateOpen) {
  767. dprintf(
  768. " Super Accept Irp = %p\n",
  769. irp
  770. );
  771. }
  772. }
  773. }
  774. else {
  775. tinfo=ReadField (TransmitInfo);
  776. if (tinfo!=0) {
  777. dprintf(
  778. " TransmitInfo = %p\n",
  779. tinfo
  780. );
  781. }
  782. }
  783. dprintf(
  784. " RoutingNotificationList %s\n",
  785. LIST_TO_STRING(
  786. ActualAddress + RoutingNotifyListOffset)
  787. );
  788. dprintf(
  789. " RequestList %s\n",
  790. LIST_TO_STRING(
  791. ActualAddress + RequestListOffset)
  792. );
  793. dprintf(
  794. " EventObject = %p\n",
  795. ReadField (EventObject)
  796. );
  797. dprintf(
  798. " EventsEnabled = %08lx\n",
  799. (ULONG)ReadField (EventsEnabled)
  800. );
  801. dprintf(
  802. " EventsActive = %08lx\n",
  803. (ULONG)ReadField (EventsActive)
  804. );
  805. dprintf(
  806. " EventStatus (non-zero only) =");
  807. ReadMemory (ActualAddress+EventStatusOffset,
  808. EventStatus,
  809. sizeof (EventStatus),
  810. &length);
  811. if (EventStatus[AFD_POLL_RECEIVE_BIT]!=0) {
  812. dprintf (" recv:%lx", EventStatus[AFD_POLL_RECEIVE_BIT]);
  813. }
  814. if (EventStatus[AFD_POLL_RECEIVE_EXPEDITED_BIT]!=0) {
  815. dprintf (" rcv exp:%lx", EventStatus[AFD_POLL_RECEIVE_EXPEDITED_BIT]);
  816. }
  817. if (EventStatus[AFD_POLL_SEND_BIT]!=0) {
  818. dprintf (" send:%lx", EventStatus[AFD_POLL_SEND_BIT]);
  819. }
  820. if (EventStatus[AFD_POLL_DISCONNECT_BIT]!=0) {
  821. dprintf (" disc:%lx", EventStatus[AFD_POLL_DISCONNECT_BIT]);
  822. }
  823. if (EventStatus[AFD_POLL_ABORT_BIT]!=0) {
  824. dprintf (" abort:%lx", EventStatus[AFD_POLL_ABORT_BIT]);
  825. }
  826. if (EventStatus[AFD_POLL_LOCAL_CLOSE_BIT]!=0) {
  827. dprintf (" close:%lx", EventStatus[AFD_POLL_LOCAL_CLOSE_BIT]);
  828. }
  829. if (EventStatus[AFD_POLL_CONNECT_BIT]!=0) {
  830. dprintf (" connect:%lx", EventStatus[AFD_POLL_CONNECT_BIT]);
  831. }
  832. if (EventStatus[AFD_POLL_ACCEPT_BIT]!=0) {
  833. dprintf (" accept:%lx", EventStatus[AFD_POLL_ACCEPT_BIT]);
  834. }
  835. if (EventStatus[AFD_POLL_CONNECT_FAIL_BIT]!=0) {
  836. dprintf (" con fail:%lx", EventStatus[AFD_POLL_CONNECT_FAIL_BIT]);
  837. }
  838. if (EventStatus[AFD_POLL_QOS_BIT]!=0) {
  839. dprintf (" qos:%lx", EventStatus[AFD_POLL_QOS_BIT]);
  840. }
  841. if (EventStatus[AFD_POLL_GROUP_QOS_BIT]!=0) {
  842. dprintf (" gqos:%lx", EventStatus[AFD_POLL_GROUP_QOS_BIT]);
  843. }
  844. if (EventStatus[AFD_POLL_ROUTING_IF_CHANGE_BIT]!=0) {
  845. dprintf (" route chng:%lx", EventStatus[AFD_POLL_ROUTING_IF_CHANGE_BIT]);
  846. }
  847. if (EventStatus[AFD_POLL_ADDRESS_LIST_CHANGE_BIT]!=0) {
  848. dprintf (" addr chng:%lx", EventStatus[AFD_POLL_ADDRESS_LIST_CHANGE_BIT]);
  849. }
  850. dprintf ("\n");
  851. dprintf(
  852. " GroupID = %08lx\n",
  853. (ULONG)ReadField (GroupID)
  854. );
  855. dprintf(
  856. " GroupType = %s\n",
  857. GroupTypeToString( (ULONG)ReadField (GroupType) )
  858. );
  859. if( IsReferenceDebug ) {
  860. dprintf(
  861. " ReferenceDebug = %p\n",
  862. ActualAddress + EndpRefOffset
  863. );
  864. if (SavedMinorVersion>=3554) {
  865. ULONGLONG refCount;
  866. refCount = ReadField (CurrentReferenceSlot);
  867. if (SystemTime.QuadPart!=0) {
  868. dprintf(
  869. " CurrentReferenceSlot = %lu (@ %s)\n",
  870. (ULONG)refCount & AFD_REF_MASK,
  871. SystemTimeToString (
  872. (((ReadField (CurrentTimeHigh)<<32) +
  873. (refCount&(~AFD_REF_MASK)))<<(13-AFD_REF_SHIFT)) +
  874. SystemTime.QuadPart -
  875. InterruptTime.QuadPart)
  876. );
  877. }
  878. else {
  879. dprintf(
  880. " CurrentReferenceSlot = %lu (@ %I64u ms since boot)\n",
  881. (ULONG)refCount & AFD_REF_MASK,
  882. (((ReadField (CurrentTimeHigh)<<32) +
  883. (refCount&(~AFD_REF_MASK)))<<(13-AFD_REF_SHIFT))/(10*1000)
  884. );
  885. }
  886. }
  887. else {
  888. dprintf(
  889. " CurrentReferenceSlot = %lu\n",
  890. (ULONG)ReadField (CurrentReferenceSlot) & AFD_REF_MASK
  891. );
  892. }
  893. }
  894. dprintf( "\n" );
  895. } // DumpAfdEndpoint
  896. VOID
  897. DumpAfdEndpointBrief (
  898. ULONG64 ActualAddress
  899. )
  900. /*++
  901. Routine Description:
  902. Dumps the specified AFD_ENDPOINT structure in short format.
  903. Endpoint Typ State Flags Transport Port Counts Evt Pid Con/RAdr
  904. xxxxxxxx xxx xxx xxxxxxxxxxxx xxxxxxxx xxxxx xx xx xx xx xxx xxxx xxxxxxxx
  905. Endpoint Typ State Flags Transport Port Counts Evt Pid Con/RemAddr
  906. xxxxxxxxxxx xxx xxx xxxxxxxxxxxx xxxxxxxx xxxxx xx xx xx xx xxx xxxx xxxxxxxxxxx
  907. Arguments:
  908. ActualAddress - The actual address where the structure resides on the
  909. debugee.
  910. Return Value:
  911. None.
  912. --*/
  913. {
  914. CHAR ctrs[40];
  915. LPSTR port;
  916. UCHAR transportAddress[MAX_TRANSPORT_ADDR];
  917. UCHAR remoteAddress[MAX_ADDRESS_STRING];
  918. PUCHAR raddr;
  919. PAFDKD_TRANSPORT_INFO transportInfo = NULL;
  920. ULONG64 address, trInfoAddr, localAddr, sanSvcHlpr=0;
  921. ULONG length;
  922. ULONG64 process, pid;
  923. USHORT type;
  924. UCHAR state;
  925. type = (USHORT)ReadField (Type);
  926. state = (UCHAR)ReadField (State);
  927. if ((trInfoAddr=ReadField (TransportInfo))!=0) {
  928. PLIST_ENTRY listEntry;
  929. listEntry = TransportInfoList.Flink;
  930. while (listEntry!=&TransportInfoList) {
  931. transportInfo = CONTAINING_RECORD (listEntry, AFDKD_TRANSPORT_INFO, Link);
  932. if (transportInfo->ActualAddress==trInfoAddr)
  933. break;
  934. listEntry = listEntry->Flink;
  935. }
  936. if (listEntry==&TransportInfoList) {
  937. transportInfo = ReadTransportInfo (trInfoAddr);
  938. if (transportInfo!=NULL) {
  939. InsertHeadList (&TransportInfoList, &transportInfo->Link);
  940. }
  941. }
  942. }
  943. raddr = remoteAddress;
  944. switch (type) {
  945. case AfdBlockTypeDatagram :
  946. _snprintf (ctrs, sizeof (ctrs)-1, "%5.5x %5.5x",
  947. (ULONG)ReadField (Common.Datagram.BufferredSendBytes),
  948. (ULONG)ReadField (Common.Datagram.BufferredReceiveBytes)
  949. );
  950. ctrs[sizeof(ctrs)-1]=0;
  951. address = ReadField (Common.Datagram.RemoteAddress);
  952. length = (ULONG)ReadField (Common.Datagram.RemoteAddressLength);
  953. _snprintf (remoteAddress, sizeof (remoteAddress)-1,
  954. IsPtr64 () ? "%011.011I64X" : "%008.008I64X",
  955. DISP_PTR(address));
  956. remoteAddress[sizeof(remoteAddress)-1]=0;
  957. if (Options & AFDKD_RADDR_DISPLAY) {
  958. if (address!=0 && length!=0) {
  959. if (ReadMemory (address,
  960. transportAddress,
  961. length<sizeof (transportAddress)
  962. ? length
  963. : sizeof (transportAddress),
  964. &length)) {
  965. raddr = TransportAddressToString(
  966. (PTRANSPORT_ADDRESS)transportAddress,
  967. address
  968. );
  969. }
  970. else {
  971. _snprintf (remoteAddress, sizeof (remoteAddress)-1,
  972. "Read error @%I64X",
  973. IsPtr64 () ? address : (address & 0xFFFFFFFF));
  974. remoteAddress[sizeof(remoteAddress)-1]=0;
  975. }
  976. }
  977. else
  978. raddr = "";
  979. }
  980. break;
  981. case AfdBlockTypeVcConnecting:
  982. address = ReadField (Common.VirtualCircuit.Connection);
  983. address =
  984. address!=0
  985. ? address
  986. : (((state==AfdEndpointStateClosing ||
  987. state==AfdEndpointStateTransmitClosing) &&
  988. ((address = ReadField (WorkItem.Context))!=0))
  989. ? address
  990. : 0);
  991. _snprintf (remoteAddress, sizeof (remoteAddress)-1,
  992. IsPtr64 () ? "%011.011I64X" : "%008.008I64X",
  993. DISP_PTR(address));
  994. remoteAddress[sizeof(remoteAddress)-1]=0;
  995. if (address!=0) {
  996. AFD_CONNECTION_STATE_FLAGS flags;
  997. ULONG sndB = 0, rcvB = 0;
  998. if (GetFieldValue (address,
  999. "AFD!AFD_CONNECTION",
  1000. "ConnectionStateFlags",
  1001. flags)==0) {
  1002. if (flags.TdiBufferring) {
  1003. ULONGLONG taken, there;
  1004. GetFieldValue (address,
  1005. "AFD!AFD_CONNECTION",
  1006. "Common.Bufferring.ReceiveBytesIndicated.QuadPart",
  1007. taken);
  1008. GetFieldValue (address,
  1009. "AFD!AFD_CONNECTION",
  1010. "Common.Bufferring.ReceiveBytesTaken.QuadPart",
  1011. there);
  1012. sndB = 0;
  1013. rcvB = (ULONG)(taken-there);
  1014. }
  1015. else {
  1016. GetFieldValue (address,
  1017. "AFD!AFD_CONNECTION",
  1018. "Common.NonBufferring.BufferredReceiveBytes",
  1019. rcvB);
  1020. GetFieldValue (address,
  1021. "AFD!AFD_CONNECTION",
  1022. "Common.NonBufferring.BufferredSendBytes",
  1023. sndB);
  1024. }
  1025. _snprintf (ctrs, sizeof (ctrs)-1, "%5.5x %5.5x", sndB, rcvB);
  1026. ctrs[sizeof(ctrs)-1]=0;
  1027. if (Options & AFDKD_RADDR_DISPLAY) {
  1028. ULONG64 connAddr = address;
  1029. if (GetFieldValue (connAddr,
  1030. "AFD!AFD_CONNECTION",
  1031. "RemoteAddress",
  1032. address)==0 &&
  1033. address!=0 &&
  1034. GetFieldValue (connAddr,
  1035. "AFD!AFD_CONNECTION",
  1036. "RemoteAddressLength",
  1037. length)==0 &&
  1038. length!=0 ) {
  1039. if (ReadMemory (address,
  1040. transportAddress,
  1041. length<sizeof (transportAddress)
  1042. ? length
  1043. : sizeof (transportAddress),
  1044. &length)) {
  1045. raddr = TransportAddressToString(
  1046. (PTRANSPORT_ADDRESS)transportAddress,
  1047. address
  1048. );
  1049. }
  1050. else {
  1051. _snprintf (remoteAddress, sizeof (remoteAddress)-1,
  1052. "Read error @%I64X",
  1053. IsPtr64 () ? address : (address & 0xFFFFFFFF));
  1054. remoteAddress[sizeof(remoteAddress)-1]=0;
  1055. }
  1056. }
  1057. else if (state==AfdEndpointStateConnected ||
  1058. state==AfdEndpointStateTransmitClosing) {
  1059. ULONG result;
  1060. ULONG64 contextAddr;
  1061. //
  1062. // Attempt to read user mode data stored as the context
  1063. //
  1064. result = GetRemoteAddressFromContext (ActualAddress,
  1065. transportAddress,
  1066. sizeof (transportAddress),
  1067. &contextAddr);
  1068. if (result==0) {
  1069. raddr = TransportAddressToString(
  1070. (PTRANSPORT_ADDRESS)transportAddress,
  1071. contextAddr
  1072. );
  1073. }
  1074. else if ((result==MEMORY_READ_ERROR) &&
  1075. (transportInfo!=NULL) &&
  1076. (_wcsicmp (transportInfo->DeviceName, L"\\Device\\TCP")==0)) {
  1077. ULONG64 tdiFile;
  1078. if ((result=GetFieldValue (connAddr,
  1079. "AFD!AFD_CONNECTION",
  1080. "FileObject",
  1081. tdiFile)==0) &&
  1082. (result=GetRemoteAddressFromTcp (tdiFile,
  1083. transportAddress,
  1084. sizeof (transportAddress)))==0) {
  1085. raddr = TransportAddressToString (
  1086. (PTRANSPORT_ADDRESS)transportAddress, contextAddr);
  1087. }
  1088. else {
  1089. _snprintf (remoteAddress, sizeof (remoteAddress)-1,
  1090. "Read error %ld @ %I64X", result,
  1091. IsPtr64 () ? contextAddr : (contextAddr & 0xFFFFFFFF));
  1092. remoteAddress[sizeof(remoteAddress)-1]=0;;
  1093. }
  1094. }
  1095. else {
  1096. _snprintf (remoteAddress, sizeof (remoteAddress)-1,
  1097. "Read error %ld @ %I64X", result,
  1098. IsPtr64 () ? contextAddr : (contextAddr & 0xFFFFFFFF));
  1099. remoteAddress[sizeof(remoteAddress)-1]=0;
  1100. }
  1101. }
  1102. }
  1103. }
  1104. else {
  1105. _snprintf (ctrs, sizeof (ctrs)-1, "Read error!");
  1106. ctrs[sizeof(ctrs)-1]=0;
  1107. }
  1108. }
  1109. else {
  1110. _snprintf (ctrs, sizeof (ctrs)-1, " ");
  1111. ctrs[sizeof(ctrs)-1]=0;
  1112. }
  1113. break;
  1114. case AfdBlockTypeVcListening:
  1115. case AfdBlockTypeVcBoth:
  1116. _snprintf (remoteAddress, sizeof (remoteAddress)-1,
  1117. "mc:%1.1x,fd:%1.1x",
  1118. (USHORT)ReadField (Common.VirtualCircuit.Listening.MaxExtraConnections),
  1119. (LONG)ReadField (Common.VirtualCircuit.Listening.FailedConnectionAdds));
  1120. remoteAddress[sizeof(remoteAddress)-1]=0;
  1121. raddr = remoteAddress;
  1122. if (ReadField (DelayedAcceptance)) {
  1123. if (Options & AFDKD_LIST_COUNT) {
  1124. _snprintf (ctrs, sizeof (ctrs)-1, "%2.2x %2.2x %2.2x %2.2x",
  1125. CountListEntries (ActualAddress+ListenConnListOffset),
  1126. CountListEntries (ActualAddress+ListenIrpListOffset),
  1127. (LONG)ReadField(Common.VirtualCircuit.Listening.TdiAcceptPendingCount),
  1128. CountListEntries (ActualAddress+UnacceptedConnListOffset));
  1129. ctrs[sizeof(ctrs)-1]=0;
  1130. }
  1131. else {
  1132. _snprintf (ctrs, sizeof (ctrs)-1, "%2.2s %2.2s %2.2x %2.2s",
  1133. ListCountEstimate (ActualAddress+ListenConnListOffset),
  1134. ListCountEstimate (ActualAddress+ListenIrpListOffset),
  1135. (LONG)ReadField(Common.VirtualCircuit.Listening.TdiAcceptPendingCount),
  1136. ListCountEstimate (ActualAddress+UnacceptedConnListOffset));
  1137. ctrs[sizeof(ctrs)-1]=0;
  1138. }
  1139. }
  1140. else {
  1141. if (Options & AFDKD_LIST_COUNT) {
  1142. _snprintf (ctrs, sizeof (ctrs)-1, "%2.2x %2.2x %2.2x %2.2x",
  1143. (USHORT)ReadField (Common.VirtualCircuit.Listening.FreeConnectionListHead.Depth),
  1144. (USHORT)ReadField (Common.VirtualCircuit.Listening.PreacceptedConnectionsListHead.Depth),
  1145. (LONG)ReadField(Common.VirtualCircuit.Listening.TdiAcceptPendingCount),
  1146. CountListEntries (ActualAddress+UnacceptedConnListOffset));
  1147. ctrs[sizeof(ctrs)-1]=0;
  1148. }
  1149. else {
  1150. _snprintf (ctrs, sizeof (ctrs)-1, "%2.2x %2.2x %2.2x %2.2s",
  1151. (USHORT)ReadField (Common.VirtualCircuit.Listening.FreeConnectionListHead.Depth),
  1152. (USHORT)ReadField (Common.VirtualCircuit.Listening.PreacceptedConnectionsListHead.Depth),
  1153. (LONG)ReadField(Common.VirtualCircuit.Listening.TdiAcceptPendingCount),
  1154. ListCountEstimate (ActualAddress+UnacceptedConnListOffset));
  1155. ctrs[sizeof(ctrs)-1]=0;
  1156. }
  1157. }
  1158. break;
  1159. case AfdBlockTypeSanEndpoint:
  1160. if (Options & AFDKD_RADDR_DISPLAY) {
  1161. ULONG result;
  1162. ULONG64 contextAddr;
  1163. //
  1164. // Attempt to read user mode data stored as the context
  1165. //
  1166. result = GetRemoteAddressFromContext (ActualAddress,
  1167. transportAddress,
  1168. sizeof (transportAddress),
  1169. &contextAddr);
  1170. if (result==0) {
  1171. raddr = TransportAddressToString(
  1172. (PTRANSPORT_ADDRESS)transportAddress,
  1173. contextAddr
  1174. );
  1175. }
  1176. else {
  1177. _snprintf (remoteAddress, sizeof (remoteAddress)-1,
  1178. "Read error %ld @ %I64X", result,
  1179. IsPtr64 () ? contextAddr : (contextAddr & 0xFFFFFFFF));
  1180. remoteAddress[sizeof(remoteAddress)-1]=0;
  1181. }
  1182. }
  1183. else {
  1184. _snprintf (remoteAddress, sizeof (remoteAddress)-1,
  1185. IsPtr64 () ? "H:%011.011I64X" : "H:%008.008I64X",
  1186. DISP_PTR (ReadField (Common.SanEndp.SanHlpr)));
  1187. remoteAddress[sizeof(remoteAddress)-1]=0;
  1188. }
  1189. _snprintf (ctrs, sizeof (ctrs)-1, "%5.5x %5.5x",
  1190. (ULONG)ReadField (Common.SanEndp.RequestId),
  1191. (ULONG)ReadField (Common.SanEndp.SelectEventsActive));
  1192. ctrs[sizeof(ctrs)-1]=0;
  1193. break;
  1194. case AfdBlockTypeSanHelper:
  1195. {
  1196. ULONG64 cPort, depth;
  1197. cPort = ReadField (Common.SanHlpr.IoCompletionPort);
  1198. GetFieldValue (0, "AFD!AfdSanServiceHelper", NULL, sanSvcHlpr);
  1199. GetFieldValue (cPort, "NT!DISPATCHER_HEADER", "SignalState", depth);
  1200. _snprintf (remoteAddress, sizeof (remoteAddress)-1,
  1201. IsPtr64 () ? "C:%011.011I64X(%d)" : "C:%008.008I64X(%d)",
  1202. DISP_PTR (cPort), (ULONG)depth);
  1203. remoteAddress[sizeof(remoteAddress)-1]=0;
  1204. _snprintf (ctrs, sizeof (ctrs)-1, "%5.5x %5.5x",
  1205. (ULONG)ReadField (Common.SanEndp.Plsn),
  1206. (ULONG)ReadField (Common.SanEndp.PendingRequests));
  1207. ctrs[sizeof(ctrs)-1]=0;
  1208. }
  1209. break;
  1210. case AfdBlockTypeEndpoint:
  1211. default:
  1212. raddr = "";
  1213. _snprintf (ctrs, sizeof (ctrs)-1, " ");
  1214. ctrs[sizeof(ctrs)-1]=0;
  1215. break;
  1216. }
  1217. port = " ";
  1218. if ((localAddr=ReadField(LocalAddress))!=0) {
  1219. length = (ULONG)ReadField (LocalAddressLength);
  1220. if (ReadMemory (localAddr,
  1221. transportAddress,
  1222. length<sizeof (transportAddress)
  1223. ? length
  1224. : sizeof (transportAddress),
  1225. &length)) {
  1226. port = TransportPortToString(
  1227. (PTRANSPORT_ADDRESS)transportAddress,
  1228. localAddr
  1229. );
  1230. }
  1231. else {
  1232. port = "error";
  1233. }
  1234. }
  1235. if (SavedMinorVersion>=2419) {
  1236. process = ReadField (OwningProcess);
  1237. }
  1238. else {
  1239. process = ReadField (ProcessCharge.Process);
  1240. }
  1241. if (GetFieldValue (
  1242. process,
  1243. "NT!_EPROCESS",
  1244. "UniqueProcessId",
  1245. pid)!=0) {
  1246. pid = 0;
  1247. }
  1248. /* Endpoint Typ Sta StFl Tr.Inf Lport ctrs Events PID Con/Raddr*/
  1249. dprintf (
  1250. IsPtr64 ()
  1251. ? "\n%011.011p %3s %3s %12s %-9.9ls %5.5s %11s %3.3lx %4.4x %s"
  1252. : "\n%008.008p %3s %3s %12s %-9.9ls %5.5s %11s %3.3lx %4.4x %s",
  1253. DISP_PTR(ActualAddress),
  1254. StructureTypeToStringBrief (type),
  1255. EndpointStateToStringBrief (state),
  1256. EndpointStateFlagsToString (),
  1257. transportInfo
  1258. ? &transportInfo->DeviceName[sizeof("\\Device\\")-1]
  1259. : (ActualAddress==sanSvcHlpr ? L"SVCHLPR" : L""),
  1260. port,
  1261. ctrs,
  1262. (ULONG)ReadField (EventsActive),
  1263. (ULONG)pid,
  1264. raddr
  1265. );
  1266. }
  1267. VOID
  1268. DumpAfdConnection(
  1269. ULONG64 ActualAddress
  1270. )
  1271. /*++
  1272. Routine Description:
  1273. Dumps the specified AFD_CONNECTION structures.
  1274. Arguments:
  1275. Connection - Points to the AFD_CONNECTION structure to dump.
  1276. ActualAddress - The actual address where the structure resides on the
  1277. debugee.
  1278. Return Value:
  1279. None.
  1280. --*/
  1281. {
  1282. ULONG64 address, endpAddr, fileObject, process, pid;
  1283. ULONG length;
  1284. UCHAR transportAddress[MAX_TRANSPORT_ADDR];
  1285. USHORT type, state;
  1286. BOOLEAN tdiBuf;
  1287. dprintf(
  1288. "\nAFD_CONNECTION @ %p:\n",
  1289. ActualAddress
  1290. );
  1291. type = (USHORT)ReadField (Type);
  1292. dprintf(
  1293. " Type = %04X (%s)\n",
  1294. type,
  1295. StructureTypeToString( type )
  1296. );
  1297. dprintf(
  1298. " ReferenceCount = %ld\n",
  1299. (LONG)ReadField (ReferenceCount)
  1300. );
  1301. state = (USHORT)ReadField (State);
  1302. dprintf(
  1303. " State = %08X (%s)\n",
  1304. state,
  1305. ConnectionStateToString( state )
  1306. );
  1307. dprintf(
  1308. " StateFlags = %08X (",
  1309. (ULONG)ReadField (ConnectionStateFlags)
  1310. );
  1311. tdiBuf = (ReadField (TdiBufferring)!=0);
  1312. if (tdiBuf)
  1313. dprintf (" Buf");
  1314. if (SavedMinorVersion>=3549) {
  1315. if (ReadField (Aborted)) {
  1316. dprintf (" Abort%s%s",
  1317. ReadField (AbortIndicated) ? "-ind" : "",
  1318. ReadField (AbortFailed) ? "-fail" : "");
  1319. }
  1320. }
  1321. else {
  1322. if (ReadField (AbortedIndicated)) {
  1323. dprintf (" AbortInd");
  1324. }
  1325. }
  1326. if (ReadField (DisconnectIndicated))
  1327. dprintf (" DscnInd");
  1328. if (ReadField (ConnectedReferenceAdded))
  1329. dprintf (" +CRef");
  1330. if (ReadField (SpecialCondition))
  1331. dprintf (" Special");
  1332. if (ReadField (CleanupBegun))
  1333. dprintf (" ClnBegun");
  1334. if (ReadField (ClosePendedTransmit))
  1335. dprintf (" ClosingTranFile");
  1336. if (ReadField (OnLRList))
  1337. dprintf (" LRList");
  1338. if (ReadField (SanConnection))
  1339. dprintf (" SAN");
  1340. dprintf (" )\n");
  1341. dprintf(
  1342. " Handle = %p\n",
  1343. ReadField (Handle)
  1344. );
  1345. dprintf(
  1346. " FileObject = %p\n",
  1347. fileObject=ReadField (FileObject)
  1348. );
  1349. if (state==AfdConnectionStateConnected) {
  1350. ULONGLONG connectTime;
  1351. connectTime = ReadField (ConnectTime);
  1352. if (SystemTime.QuadPart!=0) {
  1353. dprintf(
  1354. " ConnectTime = %s\n",
  1355. SystemTimeToString(
  1356. connectTime-
  1357. InterruptTime.QuadPart+
  1358. SystemTime.QuadPart));
  1359. dprintf(
  1360. " (now: %s)\n",
  1361. SystemTimeToString (SystemTime.QuadPart)
  1362. );
  1363. }
  1364. else {
  1365. dprintf(
  1366. " ConnectTime = %I64x (nsec since boot)\n",
  1367. connectTime
  1368. );
  1369. }
  1370. }
  1371. else {
  1372. dprintf(
  1373. " Accept/Listen Irp = %p\n",
  1374. ReadField (AcceptIrp)
  1375. );
  1376. }
  1377. if( tdiBuf ) {
  1378. dprintf(
  1379. " ReceiveBytesIndicated = %I64d\n",
  1380. ReadField( Common.Bufferring.ReceiveBytesIndicated.QuadPart )
  1381. );
  1382. dprintf(
  1383. " ReceiveBytesTaken = %I64d\n",
  1384. ReadField ( Common.Bufferring.ReceiveBytesTaken.QuadPart )
  1385. );
  1386. dprintf(
  1387. " ReceiveBytesOutstanding = %I64d\n",
  1388. ReadField( Common.Bufferring.ReceiveBytesOutstanding.QuadPart )
  1389. );
  1390. dprintf(
  1391. " ReceiveExpeditedBytesIndicated = %I64d\n",
  1392. ReadField( Common.Bufferring.ReceiveExpeditedBytesIndicated.QuadPart )
  1393. );
  1394. dprintf(
  1395. " ReceiveExpeditedBytesTaken = %I64d\n",
  1396. ReadField( Common.Bufferring.ReceiveExpeditedBytesTaken.QuadPart )
  1397. );
  1398. dprintf(
  1399. " ReceiveExpeditedBytesOutstanding = %I64d\n",
  1400. ReadField( Common.Bufferring.ReceiveExpeditedBytesOutstanding.QuadPart )
  1401. );
  1402. dprintf(
  1403. " NonBlockingSendPossible = %s\n",
  1404. BooleanToString( (BOOLEAN)ReadField (Common.Bufferring.NonBlockingSendPossible) )
  1405. );
  1406. dprintf(
  1407. " ZeroByteReceiveIndicated = %s\n",
  1408. BooleanToString( (BOOLEAN)ReadField (Common.Bufferring.ZeroByteReceiveIndicated) )
  1409. );
  1410. }
  1411. else {
  1412. dprintf(
  1413. " ReceiveIrpListHead %s\n",
  1414. LIST_TO_STRING(
  1415. ActualAddress + ConnectionRecvListOffset)
  1416. );
  1417. dprintf(
  1418. " ReceiveBufferListHead %s\n",
  1419. LIST_TO_STRING(
  1420. ActualAddress + ConnectionBufferListOffset)
  1421. );
  1422. dprintf(
  1423. " SendIrpListHead %s\n",
  1424. LIST_TO_STRING(
  1425. ActualAddress + ConnectionSendListOffset)
  1426. );
  1427. dprintf(
  1428. " BufferredReceiveBytes = %lu\n",
  1429. (ULONG)ReadField (Common.NonBufferring.BufferredReceiveBytes)
  1430. );
  1431. dprintf(
  1432. " BufferredExpeditedBytes = %lu\n",
  1433. (ULONG)ReadField (Common.NonBufferring.BufferredExpeditedBytes)
  1434. );
  1435. dprintf(
  1436. " BufferredReceiveCount = %u\n",
  1437. (USHORT)ReadField (Common.NonBufferring.BufferredReceiveCount)
  1438. );
  1439. dprintf(
  1440. " BufferredExpeditedCount = %u\n",
  1441. (USHORT)ReadField (Common.NonBufferring.BufferredExpeditedCount)
  1442. );
  1443. dprintf(
  1444. " ReceiveBytesInTransport = %lu\n",
  1445. (ULONG)ReadField (Common.NonBufferring.ReceiveBytesInTransport)
  1446. );
  1447. dprintf(
  1448. " BufferredSendBytes = %lu\n",
  1449. (ULONG)ReadField (Common.NonBufferring.BufferredSendBytes)
  1450. );
  1451. dprintf(
  1452. " BufferredSendCount = %u\n",
  1453. (USHORT)ReadField (Common.NonBufferring.BufferredSendCount)
  1454. );
  1455. dprintf(
  1456. " DisconnectIrp = %p\n",
  1457. ReadField (Common.NonBufferring.DisconnectIrp)
  1458. );
  1459. if (IsCheckedAfd ) {
  1460. dprintf(
  1461. " ReceiveIrpsInTransport = %ld\n",
  1462. (ULONG)ReadField (Common.NonBufferring.ReceiveIrpsInTransport)
  1463. );
  1464. }
  1465. }
  1466. dprintf(
  1467. " Endpoint = %p\n",
  1468. endpAddr = ReadField (Endpoint)
  1469. );
  1470. dprintf(
  1471. " MaxBufferredReceiveBytes = %lu\n",
  1472. (ULONG)ReadField (MaxBufferredReceiveBytes)
  1473. );
  1474. dprintf(
  1475. " MaxBufferredSendBytes = %lu\n",
  1476. (ULONG)ReadField (MaxBufferredSendBytes)
  1477. );
  1478. dprintf(
  1479. " ConnectDataBuffers = %p\n",
  1480. ReadField (ConnectDataBuffers)
  1481. );
  1482. if (SavedMinorVersion>=2419) {
  1483. process = ReadField (OwningProcess);
  1484. }
  1485. else {
  1486. process = ReadField (ProcessCharge.Process);
  1487. }
  1488. if (GetFieldValue (
  1489. process,
  1490. "NT!_EPROCESS",
  1491. "UniqueProcessId",
  1492. pid)!=0) {
  1493. pid = 0;
  1494. }
  1495. dprintf(
  1496. " OwningProcess = %p (0x%lx)\n",
  1497. process, (ULONG)pid
  1498. );
  1499. dprintf(
  1500. " DeviceObject = %p\n",
  1501. ReadField (DeviceObject)
  1502. );
  1503. dprintf(
  1504. " RemoteAddress = %p\n",
  1505. address = ReadField (RemoteAddress)
  1506. );
  1507. length = (USHORT)ReadField (RemoteAddressLength);
  1508. dprintf(
  1509. " RemoteAddressLength = %lu\n",
  1510. length
  1511. );
  1512. if( address != 0 ) {
  1513. if (ReadMemory (address,
  1514. transportAddress,
  1515. length<sizeof (transportAddress)
  1516. ? length
  1517. : sizeof (transportAddress),
  1518. &length)) {
  1519. DumpTransportAddress(
  1520. " ",
  1521. (PTRANSPORT_ADDRESS)transportAddress,
  1522. address
  1523. );
  1524. }
  1525. else {
  1526. dprintf ("\nDumpAfdConnection: Could not read transport address @ %p\n", address);
  1527. }
  1528. }
  1529. else if ((state==AfdConnectionStateConnected) && (endpAddr!=0)) {
  1530. ULONG result;
  1531. ULONG64 contextAddr;
  1532. //
  1533. // Attempt to read user mode data stored as the context
  1534. //
  1535. result = GetRemoteAddressFromContext (endpAddr,
  1536. transportAddress,
  1537. sizeof (transportAddress),
  1538. &contextAddr);
  1539. if (result==0) {
  1540. DumpTransportAddress(
  1541. " ",
  1542. (PTRANSPORT_ADDRESS)transportAddress,
  1543. contextAddr
  1544. );
  1545. }
  1546. else if (GetFieldValue (endpAddr, "AFD!AFD_ENDPOINT",
  1547. "TransportInfo", address)==0
  1548. && address!=0) {
  1549. PLIST_ENTRY listEntry;
  1550. PAFDKD_TRANSPORT_INFO transportInfo = NULL;
  1551. listEntry = TransportInfoList.Flink;
  1552. while (listEntry!=&TransportInfoList) {
  1553. transportInfo = CONTAINING_RECORD (listEntry, AFDKD_TRANSPORT_INFO, Link);
  1554. if (transportInfo->ActualAddress==address)
  1555. break;
  1556. listEntry = listEntry->Flink;
  1557. }
  1558. if (listEntry==&TransportInfoList) {
  1559. transportInfo = ReadTransportInfo (address);
  1560. if (transportInfo!=NULL) {
  1561. InsertHeadList (&TransportInfoList, &transportInfo->Link);
  1562. }
  1563. }
  1564. if (transportInfo!=NULL &&
  1565. (_wcsicmp (transportInfo->DeviceName, L"\\Device\\TCP")==0)) {
  1566. if ((result=GetRemoteAddressFromTcp (fileObject,
  1567. transportAddress,
  1568. sizeof (transportAddress)))==0) {
  1569. DumpTransportAddress(
  1570. " ",
  1571. (PTRANSPORT_ADDRESS)transportAddress,
  1572. fileObject
  1573. );
  1574. }
  1575. else {
  1576. dprintf ("\nDumpAfdConnection: Could not get remote address from tcp file @ %p err: %ld)!\n",
  1577. fileObject, result);
  1578. }
  1579. }
  1580. }
  1581. if (result!=0) {
  1582. dprintf ("\nDumpAfdConnection: Could not read address info from endpoint context @ %p err: %ld)!\n",
  1583. contextAddr, result);
  1584. }
  1585. }
  1586. if( IsReferenceDebug ) {
  1587. dprintf(
  1588. " ReferenceDebug = %p\n",
  1589. ActualAddress + ConnRefOffset
  1590. );
  1591. if (SavedMinorVersion>=3554) {
  1592. ULONGLONG refCount;
  1593. refCount = ReadField (CurrentReferenceSlot);
  1594. if (SystemTime.QuadPart!=0) {
  1595. dprintf(
  1596. " CurrentReferenceSlot = %lu (@ %s)\n",
  1597. (ULONG)refCount & AFD_REF_MASK,
  1598. SystemTimeToString (
  1599. (((ReadField (CurrentTimeHigh)<<32) +
  1600. (refCount&(~AFD_REF_MASK)))<<(13-AFD_REF_SHIFT))+
  1601. SystemTime.QuadPart -
  1602. InterruptTime.QuadPart)
  1603. );
  1604. }
  1605. else {
  1606. dprintf(
  1607. " CurrentReferenceSlot = %lu (@ %I64u ms since boot)\n",
  1608. (ULONG)refCount & AFD_REF_MASK,
  1609. (((ReadField (CurrentTimeHigh)<<32) +
  1610. (refCount&(~AFD_REF_MASK)))<<(13-AFD_REF_SHIFT))/(10*1000)
  1611. );
  1612. }
  1613. }
  1614. else {
  1615. dprintf(
  1616. " CurrentReferenceSlot = %lu\n",
  1617. (ULONG)ReadField (CurrentReferenceSlot) & AFD_REF_MASK
  1618. );
  1619. }
  1620. }
  1621. #ifdef _AFD_VERIFY_DATA_
  1622. dprintf(
  1623. " VerifySequenceNumber = %lx\n",
  1624. (LONG)ReadField (VerifySequenceNumber)
  1625. );
  1626. #endif
  1627. dprintf( "\n" );
  1628. } // DumpAfdConnection
  1629. VOID
  1630. DumpAfdConnectionBrief(
  1631. ULONG64 ActualAddress
  1632. )
  1633. /*++
  1634. Routine Description:
  1635. Dumps the specified AFD_CONNECTION structure in short format.
  1636. Connectn Stat Flags SndB-cnt RcvB-cnt Pid Endpoint Remote Address"
  1637. xxxxxxxx xxx xxxxxxx xxxxx-xx xxxxx-xx xxxx xxxxxxxx xxxxxxxxxxxxxx"
  1638. Connection Stat Flags SndB-cnt RcvB-cnt Pid Endpoint Remote Address"
  1639. xxxxxxxxxxx xxx xxxxxxx xxxxx-xx xxxxx-xx xxxx xxxxxxxxxxx xxxxxxxxxxxxxx
  1640. Arguments:
  1641. ActualAddress - The actual address where the structure resides on the
  1642. debugee.
  1643. Return Value:
  1644. None.
  1645. --*/
  1646. {
  1647. CHAR transportAddress[MAX_TRANSPORT_ADDR];
  1648. ULONG64 address, endpAddr, pid, process;
  1649. ULONG length;
  1650. LPSTR raddr;
  1651. USHORT type, state;
  1652. BOOLEAN tdiBuf;
  1653. type = (USHORT)ReadField (Type);
  1654. state = (USHORT)ReadField (State);
  1655. endpAddr = ReadField (Endpoint);
  1656. address = ReadField (RemoteAddress);
  1657. length = (ULONG)ReadField (RemoteAddressLength);
  1658. tdiBuf = ReadField (TdiBufferring)!=0;
  1659. if( address != 0 ) {
  1660. if (ReadMemory (address,
  1661. transportAddress,
  1662. length<sizeof (transportAddress)
  1663. ? length
  1664. : sizeof (transportAddress),
  1665. &length)) {
  1666. raddr = TransportAddressToString(
  1667. (PTRANSPORT_ADDRESS)transportAddress,
  1668. address
  1669. );
  1670. }
  1671. else {
  1672. _snprintf (transportAddress, sizeof (transportAddress)-1,
  1673. "Read error @%I64X",
  1674. IsPtr64 () ? address : (address & 0xFFFFFFFF));
  1675. transportAddress[sizeof(transportAddress)-1]=0;
  1676. raddr = transportAddress;
  1677. }
  1678. }
  1679. else if ((state==AfdConnectionStateConnected) && (endpAddr!=0)) {
  1680. ULONG result;
  1681. ULONG64 contextAddr;
  1682. //
  1683. // Attempt to read user mode data stored as the context
  1684. //
  1685. result = GetRemoteAddressFromContext (endpAddr,
  1686. transportAddress,
  1687. sizeof (transportAddress),
  1688. &contextAddr);
  1689. if (result==0) {
  1690. raddr = TransportAddressToString(
  1691. (PTRANSPORT_ADDRESS)transportAddress,
  1692. contextAddr
  1693. );
  1694. }
  1695. else if (GetFieldValue (endpAddr, "AFD!AFD_ENDPOINT",
  1696. "TransportInfo", address)==0
  1697. && address!=0) {
  1698. PLIST_ENTRY listEntry;
  1699. PAFDKD_TRANSPORT_INFO transportInfo = NULL;
  1700. listEntry = TransportInfoList.Flink;
  1701. while (listEntry!=&TransportInfoList) {
  1702. transportInfo = CONTAINING_RECORD (listEntry, AFDKD_TRANSPORT_INFO, Link);
  1703. if (transportInfo->ActualAddress==address)
  1704. break;
  1705. listEntry = listEntry->Flink;
  1706. }
  1707. if (listEntry==&TransportInfoList) {
  1708. transportInfo = ReadTransportInfo (address);
  1709. if (transportInfo!=NULL) {
  1710. InsertHeadList (&TransportInfoList, &transportInfo->Link);
  1711. }
  1712. }
  1713. if (transportInfo!=NULL &&
  1714. (_wcsicmp (transportInfo->DeviceName, L"\\Device\\TCP")==0)) {
  1715. ULONG64 fileObject = ReadField (FileObject);
  1716. if ((result=GetRemoteAddressFromTcp (fileObject,
  1717. transportAddress,
  1718. sizeof (transportAddress)))==0) {
  1719. raddr = TransportAddressToString(
  1720. (PTRANSPORT_ADDRESS)transportAddress,
  1721. fileObject
  1722. );
  1723. }
  1724. else {
  1725. contextAddr = fileObject;
  1726. }
  1727. }
  1728. }
  1729. if (result!=0) {
  1730. _snprintf (transportAddress, sizeof (transportAddress)-1,
  1731. "Read error %ld @ %I64X", result,
  1732. IsPtr64 () ? contextAddr : (contextAddr & 0xFFFFFFFF));
  1733. transportAddress[sizeof(transportAddress)-1]=0;
  1734. raddr = transportAddress;
  1735. }
  1736. }
  1737. else {
  1738. raddr = "";
  1739. }
  1740. if (SavedMinorVersion>=2419) {
  1741. process = ReadField (OwningProcess);
  1742. }
  1743. else {
  1744. process = ReadField (ProcessCharge.Process);
  1745. }
  1746. if (GetFieldValue (
  1747. process,
  1748. "NT!_EPROCESS",
  1749. "UniqueProcessId",
  1750. pid)!=0) {
  1751. pid = 0;
  1752. }
  1753. // Connection Sta Flg SndB RcvB Pid Endpoint RemA
  1754. dprintf (
  1755. IsPtr64 ()
  1756. ? "\n%011.011p %3s %7s %5.5x-%2.2x %5.5x-%2.2x %4.4x %011.011p %-s"
  1757. : "\n%008.008p %3s %7s %5.5x-%2.2x %5.5x-%2.2x %4.4x %008.008p %-s",
  1758. DISP_PTR(ActualAddress),
  1759. ConnectionStateToStringBrief (state),
  1760. ConnectionStateFlagsToString (),
  1761. tdiBuf
  1762. ? (ULONG)0
  1763. : (ULONG)ReadField (Common.NonBufferring.BufferredSendBytes),
  1764. tdiBuf
  1765. ? (ULONG)0
  1766. : (ULONG)ReadField (Common.NonBufferring.BufferredSendCount),
  1767. tdiBuf
  1768. ? (ULONG)(ReadField (Common.Bufferring.ReceiveBytesIndicated.QuadPart)
  1769. - ReadField (Common.Bufferring.ReceiveBytesTaken.QuadPart))
  1770. : (ULONG)(ReadField (Common.NonBufferring.BufferredReceiveBytes)
  1771. + ReadField (Common.NonBufferring.ReceiveBytesInTransport)),
  1772. tdiBuf
  1773. ? 0
  1774. : (ULONG)ReadField (Common.NonBufferring.BufferredReceiveCount),
  1775. (ULONG)pid,
  1776. DISP_PTR(endpAddr),
  1777. raddr
  1778. );
  1779. }
  1780. VOID
  1781. DumpAfdReferenceDebug(
  1782. ULONG64 ActualAddress,
  1783. LONGLONG Idx
  1784. )
  1785. /*++
  1786. Routine Description:
  1787. Dumps the AFD_REFERENCE_DEBUG structures associated with an
  1788. AFD_CONNECTION object.
  1789. Arguments:
  1790. ReferenceDebug - Points to an array of AFD_REFERENCE_DEBUG structures.
  1791. There are assumed to be AFD_MAX_REF entries in this array.
  1792. ActualAddress - The actual address where the array resides on the
  1793. debugee.
  1794. Return Value:
  1795. None.
  1796. --*/
  1797. {
  1798. ULONG i;
  1799. ULONG result;
  1800. CHAR filePath[MAX_PATH];
  1801. CHAR message[256];
  1802. ULONG64 format;
  1803. ULONG64 address;
  1804. ULONG64 locationTable;
  1805. LONG64 timeLast;
  1806. ULONG newCount;
  1807. ULONG locationId;
  1808. ULONGLONG timeExp;
  1809. ULONGLONG timeDif;
  1810. ULONGLONG tickCount;
  1811. ULONG param;
  1812. ULONGLONG quadPart;
  1813. if (RefDebugSize==0) {
  1814. dprintf ("\nDumpAfdReferenceDebug: sizeof(AFD!AFD_REFERENCE_DEBUG) is 0!!!\n");
  1815. return;
  1816. }
  1817. result = ReadPtr (GetExpression ("AFD!AfdLocationTable"),
  1818. &locationTable);
  1819. if (result!=0) {
  1820. dprintf("\nDumpAfdReferenceDebug: Could not read afd!AfdLocationTable, err: %ld\n", result);
  1821. return;
  1822. }
  1823. if (SavedMinorVersion>=3554) {
  1824. if (SystemTime.QuadPart!=0) {
  1825. dprintf(
  1826. "AFD_REFERENCE_DEBUG @ %p (current time: %s)\n",
  1827. ActualAddress,
  1828. SystemTimeToString(SystemTime.QuadPart)
  1829. );
  1830. }
  1831. else {
  1832. dprintf(
  1833. "AFD_REFERENCE_DEBUG @ %p\n",
  1834. ActualAddress
  1835. );
  1836. }
  1837. }
  1838. else {
  1839. dprintf(
  1840. "AFD_REFERENCE_DEBUG @ %p (current time: %I64d (%I64d) ms)\n",
  1841. ActualAddress,
  1842. ((LONGLONG)TickCount*TicksToMs)>>24,
  1843. ((LONGLONG)(USHORT)TickCount*TicksToMs)>>24
  1844. );
  1845. }
  1846. timeLast = Idx>>AFD_REF_SHIFT;
  1847. if (SavedMinorVersion>=3554)
  1848. Idx = (Idx-1) & AFD_REF_MASK;
  1849. else
  1850. Idx &= AFD_REF_MASK;
  1851. for( i = 0 ; i < AFD_MAX_REF ; i++, Idx=(Idx-1)&AFD_REF_MASK ) {
  1852. if( CheckControlC() ) {
  1853. break;
  1854. }
  1855. result = (ULONG)InitTypeRead (ActualAddress+Idx*sizeof (AFD_REFERENCE_DEBUG),
  1856. AFD!AFD_REFERENCE_DEBUG);
  1857. if (result!=0) {
  1858. dprintf ("\nDumpAfdReferenceDebug: Could not read AFD_REFERENCE_DEBUG @ %p(%ld), err: %ld\n",
  1859. ActualAddress+Idx*sizeof (AFD_REFERENCE_DEBUG), Idx, result);
  1860. return;
  1861. }
  1862. quadPart = ReadField (QuadPart);
  1863. if( quadPart==0) {
  1864. continue;
  1865. }
  1866. newCount = (ULONG)ReadField (NewCount);
  1867. locationId = (ULONG)ReadField (LocationId);
  1868. param = (ULONG)ReadField (Param);
  1869. if (SavedMinorVersion>=3554) {
  1870. timeExp = ReadField (TimeExp);
  1871. timeDif = ReadField (TimeDif);
  1872. }
  1873. else {
  1874. tickCount = ReadField (TickCount);
  1875. }
  1876. if (GetFieldValue (locationTable+RefDebugSize*(locationId-1),
  1877. "AFD!AFD_REFERENCE_LOCATION",
  1878. "Format",
  1879. format)==0 &&
  1880. GetFieldValue (locationTable+RefDebugSize*(locationId-1),
  1881. "AFD!AFD_REFERENCE_LOCATION",
  1882. "Address",
  1883. address)==0 &&
  1884. (ReadMemory (format,
  1885. filePath,
  1886. sizeof (filePath),
  1887. &result) ||
  1888. (result>0 && filePath[result-1]==0))) {
  1889. CHAR *fileName;
  1890. fileName = strrchr (filePath, '\\');
  1891. if (fileName!=NULL) {
  1892. fileName += 1;
  1893. }
  1894. else {
  1895. fileName = filePath;
  1896. }
  1897. _snprintf (message, sizeof (message)-1, fileName, param);
  1898. message[sizeof(message)-1]=0;
  1899. }
  1900. else {
  1901. _snprintf (message, sizeof (message)-1, "%lx %lx",
  1902. locationId,
  1903. param);
  1904. message[sizeof(message)-1]=0;
  1905. }
  1906. if (SavedMinorVersion>=3554) {
  1907. if (SystemTime.QuadPart!=0) {
  1908. dprintf (" %3lu %s -> %ld @ %s\n",
  1909. (ULONG)Idx, message, newCount,
  1910. SystemTimeToString(
  1911. (timeLast<<13)+
  1912. SystemTime.QuadPart -
  1913. InterruptTime.QuadPart
  1914. )
  1915. );
  1916. }
  1917. else {
  1918. dprintf (" %3lu %s -> %ld @ %I64u ms since boot\n",
  1919. (ULONG)Idx, message, newCount,
  1920. (timeLast<<13)/(10*1000)
  1921. );
  1922. }
  1923. timeLast -= timeDif<<(timeExp*AFD_TIME_EXP_SHIFT);
  1924. }
  1925. else {
  1926. dprintf (" %3lu %s -> %ld @ %u %s\n",
  1927. (ULONG)Idx, message, newCount,
  1928. (TicksToMs!=0)
  1929. ? (ULONG)((tickCount*TicksToMs)>>24)
  1930. : (ULONG)tickCount,
  1931. (TicksToMs!=0) ? "ms" : ""
  1932. );
  1933. }
  1934. }
  1935. } // DumpAfdReferenceDebug
  1936. #if GLOBAL_REFERENCE_DEBUG
  1937. BOOL
  1938. DumpAfdGlobalReferenceDebug(
  1939. PAFD_GLOBAL_REFERENCE_DEBUG ReferenceDebug,
  1940. ULONG64 ActualAddress,
  1941. DWORD CurrentSlot,
  1942. DWORD StartingSlot,
  1943. DWORD NumEntries,
  1944. ULONG64 CompareAddress
  1945. )
  1946. /*++
  1947. Routine Description:
  1948. Dumps the AFD_GLOBAL_REFERENCE_DEBUG structures.
  1949. Arguments:
  1950. ReferenceDebug - Points to an array of AFD_GLOBAL_REFERENCE_DEBUG
  1951. structures. There are assumed to be MAX_GLOBAL_REFERENCE entries
  1952. in this array.
  1953. ActualAddress - The actual address where the array resides on the
  1954. debugee.
  1955. CurrentSlot - The last slot used.
  1956. CompareAddress - If zero, then dump all records. Otherwise, only dump
  1957. those records with a matching connection pointer.
  1958. Return Value:
  1959. None.
  1960. --*/
  1961. {
  1962. ULONG result;
  1963. LPSTR fileName;
  1964. CHAR decoration;
  1965. CHAR filePath[MAX_PATH];
  1966. CHAR action[16];
  1967. BOOL foundEnd = FALSE;
  1968. ULONG lowTick;
  1969. if( StartingSlot == 0 ) {
  1970. dprintf(
  1971. "AFD_GLOBAL_REFERENCE_DEBUG @ %p, Current Slot = %lu\n",
  1972. ActualAddress,
  1973. CurrentSlot
  1974. );
  1975. }
  1976. for( ; NumEntries > 0 ; NumEntries--, StartingSlot++, ReferenceDebug++ ) {
  1977. if( CheckControlC() ) {
  1978. foundEnd = TRUE;
  1979. break;
  1980. }
  1981. if( ReferenceDebug->Info1 == NULL &&
  1982. ReferenceDebug->Info2 == NULL &&
  1983. ReferenceDebug->Action == 0 &&
  1984. ReferenceDebug->NewCount == 0 &&
  1985. ReferenceDebug->Connection == NULL ) {
  1986. foundEnd = TRUE;
  1987. break;
  1988. }
  1989. if( CompareAddress != 0 &&
  1990. ReferenceDebug->Connection != (PVOID)CompareAddress ) {
  1991. continue;
  1992. }
  1993. if( ReferenceDebug->Action == 0 ||
  1994. ReferenceDebug->Action == 1 ||
  1995. ReferenceDebug->Action == (ULONG64)-1L ) {
  1996. _snprintf(
  1997. action, sizeof (action),
  1998. "%ld",
  1999. PtrToUlong(ReferenceDebug->Action)
  2000. );
  2001. action[sizeof(action)-1]=0;
  2002. } else {
  2003. _snprintf(
  2004. action, sizeof (action),
  2005. "%p",
  2006. ReferenceDebug->Action
  2007. );
  2008. action[sizeof(action)-1]=0;
  2009. }
  2010. decoration = ( StartingSlot == CurrentSlot ) ? '>' : ' ';
  2011. lowTick = ReferenceDebug->TickCounter.LowPart;
  2012. switch( (ULONG64)ReferenceDebug->Info1 ) {
  2013. case 0xafdafd02 :
  2014. dprintf(
  2015. "%c %3lu: %p (%8lu) Buffered Send, IRP @ %plx [%s] -> %lu\n",
  2016. decoration,
  2017. StartingSlot,
  2018. (ULONG64)ReferenceDebug->Connection,
  2019. lowTick,
  2020. (ULONG64)ReferenceDebug->Info2,
  2021. action,
  2022. ReferenceDebug->NewCount
  2023. );
  2024. break;
  2025. case 0xafdafd03 :
  2026. dprintf(
  2027. "%c %3lu: %p (%8lu) Nonbuffered Send, IRP @ %p [%s] -> %lu\n",
  2028. decoration,
  2029. StartingSlot,
  2030. (ULONG64)ReferenceDebug->Connection,
  2031. lowTick,
  2032. (ULONG64)ReferenceDebug->Info2,
  2033. action,
  2034. ReferenceDebug->NewCount
  2035. );
  2036. break;
  2037. case 0xafd11100 :
  2038. case 0xafd11101 :
  2039. dprintf(
  2040. "%c %3lu: %p (%8lu) AfdRestartSend (%p), IRP @ %p [%s] -> %lu\n",
  2041. decoration,
  2042. StartingSlot,
  2043. (ULONG64)ReferenceDebug->Connection,
  2044. lowTick,
  2045. (ULONG64)ReferenceDebug->Info1,
  2046. (ULONG64)ReferenceDebug->Info2,
  2047. action,
  2048. ReferenceDebug->NewCount
  2049. );
  2050. break;
  2051. case 0xafd11102 :
  2052. case 0xafd11103 :
  2053. case 0xafd11104 :
  2054. case 0xafd11105 :
  2055. dprintf(
  2056. "%c %3lu: %p (%8lu) AfdRestartBufferSend (%p), IRP @ %p [%s] -> %lu\n",
  2057. decoration,
  2058. StartingSlot,
  2059. (ULONG64)ReferenceDebug->Connection,
  2060. lowTick,
  2061. (ULONG64)ReferenceDebug->Info1,
  2062. (ULONG64)ReferenceDebug->Info2,
  2063. action,
  2064. ReferenceDebug->NewCount
  2065. );
  2066. break;
  2067. case 0 :
  2068. if( ReferenceDebug->Info2 == NULL ) {
  2069. dprintf(
  2070. "%c %3lu: %p (%8lu) AfdDeleteConnectedReference (%p)\n",
  2071. decoration,
  2072. StartingSlot,
  2073. (ULONG64)ReferenceDebug->Connection,
  2074. lowTick,
  2075. (ULONG64)ReferenceDebug->Action
  2076. );
  2077. break;
  2078. } else {
  2079. //
  2080. // Fall through to default case.
  2081. //
  2082. }
  2083. default :
  2084. if( ReadMemory(
  2085. (ULONG64)ReferenceDebug->Info1,
  2086. filePath,
  2087. sizeof(filePath),
  2088. &result
  2089. ) ) {
  2090. fileName = strrchr( filePath, '\\' );
  2091. if( fileName != NULL ) {
  2092. fileName++;
  2093. } else {
  2094. fileName = filePath;
  2095. }
  2096. } else {
  2097. _snprintf(
  2098. filePath, sizeof (filePath),
  2099. "%p",
  2100. ReferenceDebug->Info1
  2101. );
  2102. filePath[sizeof(filePath)-1]=0;
  2103. fileName = filePath;
  2104. }
  2105. dprintf(
  2106. "%c %3lu: %p (%8lu) %s:%lu [%s] -> %lu\n",
  2107. decoration,
  2108. StartingSlot,
  2109. (ULONG64)ReferenceDebug->Connection,
  2110. lowTick,
  2111. fileName,
  2112. PtrToUlong (ReferenceDebug->Info2),
  2113. action,
  2114. ReferenceDebug->NewCount
  2115. );
  2116. break;
  2117. }
  2118. }
  2119. return foundEnd;
  2120. } // DumpAfdGlobalReferenceDebug
  2121. #endif
  2122. VOID
  2123. DumpAfdTransmitInfo(
  2124. ULONG64 ActualAddress
  2125. )
  2126. {
  2127. dprintf(
  2128. "\nAFD_TRANSMIT_FILE_INFO_INTERNAL @ %p\n",
  2129. ActualAddress
  2130. );
  2131. dprintf(
  2132. " Endpoint = %p\n",
  2133. ReadField (Endpoint)
  2134. );
  2135. dprintf(
  2136. " ReferenceCount = %ld\n",
  2137. (ULONG)ReadField (ReferenceCount)
  2138. );
  2139. dprintf(
  2140. " Flags = %08lx\n",
  2141. (ULONG)ReadField (Flags)
  2142. );
  2143. dprintf(
  2144. " WorkerScheduled = %s\n",
  2145. BooleanToString( ReadField (WorkerScheduled)!=0 )
  2146. );
  2147. dprintf(
  2148. " AbortPending = %s\n",
  2149. BooleanToString( ReadField (AbortPending)!=0 )
  2150. );
  2151. dprintf(
  2152. " NeedSendHead = %s\n",
  2153. BooleanToString( ReadField (NeedSendHead)!=0 )
  2154. );
  2155. dprintf(
  2156. " ReuseInProgress = %s\n",
  2157. BooleanToString( ReadField (ReuseInProgress)!=0 )
  2158. );
  2159. dprintf(
  2160. " SendAndDisconnect = %s\n",
  2161. BooleanToString( ReadField (SendAndDisconnect)!=0 )
  2162. );
  2163. dprintf(
  2164. " SendPacketLength = %08lx\n",
  2165. (ULONG)ReadField (SendPacketLength)
  2166. );
  2167. dprintf(
  2168. " FileReadOffset = %I64x\n",
  2169. ReadField (FileReadOffset)
  2170. );
  2171. dprintf(
  2172. " FileReadEnd = %I64x\n",
  2173. ReadField (FileReadEnd)
  2174. );
  2175. dprintf(
  2176. " FsFileObject = %p\n",
  2177. ReadField (FsFileObject)
  2178. );
  2179. dprintf(
  2180. " FsDeviceObject = %p\n",
  2181. ReadField (FsDeviceObject)
  2182. );
  2183. dprintf(
  2184. " TdiFileObject = %p\n",
  2185. ReadField (TdiFileObject)
  2186. );
  2187. dprintf(
  2188. " TdiDeviceObject = %p\n",
  2189. ReadField (TdiDeviceObject)
  2190. );
  2191. dprintf(
  2192. " TransmitIrp = %p\n",
  2193. ReadField (TransmitIrp)
  2194. );
  2195. dprintf(
  2196. " SendIrp1 = %p%s\n",
  2197. ReadField (SendIrp1),
  2198. ReadField (Irp1Done)
  2199. ? " (DONE)"
  2200. : ""
  2201. );
  2202. dprintf(
  2203. " SendIrp2 = %p%s\n",
  2204. ReadField (SendIrp2),
  2205. ReadField (Irp2Done)
  2206. ? " (DONE)"
  2207. : ""
  2208. );
  2209. dprintf(
  2210. " ReadIrp = %p%s\n",
  2211. ReadField (ReadIrp),
  2212. ReadField (IrpRDone)
  2213. ? " (DONE)"
  2214. : ""
  2215. );
  2216. dprintf(
  2217. " HeadMdl = %p\n",
  2218. ReadField (HeadMdl)
  2219. );
  2220. dprintf(
  2221. " TailMdl = %p\n",
  2222. ReadField (TailMdl)
  2223. );
  2224. dprintf(
  2225. " PreTailMdl = %p\n",
  2226. ReadField (PreTailMdl)
  2227. );
  2228. dprintf(
  2229. " WithTailMdl = %p\n",
  2230. ReadField (WithTailMdl)
  2231. );
  2232. dprintf(
  2233. " LastFileMdl/Buffer = %p\n",
  2234. ReadField (LastFileMdl)
  2235. );
  2236. if( IsReferenceDebug ) {
  2237. dprintf(
  2238. " ReferenceDebug = %p\n",
  2239. ActualAddress+TPackRefOffset
  2240. );
  2241. dprintf(
  2242. " CurrentReferenceSlot = %lu\n",
  2243. (ULONG)ReadField (CurrentReferenceSlot) & AFD_REF_MASK
  2244. );
  2245. }
  2246. dprintf( "\n" );
  2247. } // DumpAfdTransmitInfo
  2248. VOID
  2249. DumpAfdTransmitInfoBrief (
  2250. ULONG64 ActualAddress
  2251. )
  2252. /*
  2253. "TranInfo I R P S Endpoint Flags Cur.Read Read\n"
  2254. "Address Transmit Send1 Send2 Read Address Offset End \n"
  2255. */
  2256. {
  2257. dprintf ("\n%p %p %p %p %p %p %s %8.8lx %8.8lx",
  2258. ActualAddress,
  2259. ReadField (TransmitIrp),
  2260. ReadField (SendIrp1),
  2261. ReadField (SendIrp2),
  2262. ReadField (ReadIrp),
  2263. ReadField (Endpoint),
  2264. TranfileFlagsToString (),
  2265. (ULONG)ReadField (FileReadOffset),
  2266. (ULONG)ReadField (FileReadEnd));
  2267. } // DumpAfdTransmitInfoBrief
  2268. VOID
  2269. DumpAfdTPacketsInfo(
  2270. ULONG64 ActualAddress
  2271. )
  2272. {
  2273. if (SavedMinorVersion>=3549) {
  2274. DumpAfdTPacketsInfoNet (ActualAddress);
  2275. }
  2276. else {
  2277. DumpAfdTPacketsInfoXp (ActualAddress);
  2278. }
  2279. }
  2280. VOID
  2281. DumpAfdTPacketsInfoBrief(
  2282. ULONG64 ActualAddress
  2283. )
  2284. {
  2285. if (SavedMinorVersion>=3549) {
  2286. DumpAfdTPacketsInfoBriefNet (ActualAddress);
  2287. }
  2288. else {
  2289. DumpAfdTPacketsInfoBriefXp (ActualAddress);
  2290. }
  2291. }
  2292. VOID
  2293. DumpAfdTPacketsInfoNet(
  2294. ULONG64 ActualAddress
  2295. )
  2296. {
  2297. ULONG64 fileAddr, endpAddr, tpInfoAddr, irpSpAddr;
  2298. ULONG64 i;
  2299. ULONG Flags, StateFlags, NumSendIrps, RefCount;
  2300. ULONG result;
  2301. irpSpAddr = ReadField (Tail.Overlay.CurrentStackLocation);
  2302. tpInfoAddr = ReadField (AssociatedIrp.SystemBuffer);
  2303. if ( (result=GetFieldValue (ActualAddress+DriverContextOffset,
  2304. "AFD!AFD_TPACKETS_IRP_CTX",
  2305. "Flags",
  2306. Flags)) !=0 ||
  2307. (result=GetFieldValue (ActualAddress+DriverContextOffset,
  2308. "AFD!AFD_TPACKETS_IRP_CTX",
  2309. "StateFlags",
  2310. StateFlags)) !=0 ||
  2311. (result=GetFieldValue (ActualAddress+DriverContextOffset,
  2312. "AFD!AFD_TPACKETS_IRP_CTX",
  2313. "ReferenceCount",
  2314. RefCount)) !=0 ) {
  2315. dprintf(
  2316. "\ntran: Could not read AFD_TPACKETS_IRP_CTX @ %p, err:%d\n",
  2317. ActualAddress+DriverContextOffset, result
  2318. );
  2319. return;
  2320. }
  2321. if ( (result = GetFieldValue (irpSpAddr,
  2322. "NT!_IO_STACK_LOCATION",
  2323. "FileObject",
  2324. fileAddr)) !=0 ) {
  2325. dprintf(
  2326. "\ntran: Could not read IO_STACK_LOCATION @ %p for IRP @ %p, err:%d\n",
  2327. irpSpAddr, ActualAddress, result
  2328. );
  2329. return;
  2330. }
  2331. result = GetFieldValue (fileAddr,
  2332. "NT!_FILE_OBJECT",
  2333. "FsContext",
  2334. endpAddr);
  2335. if (result!=0) {
  2336. dprintf(
  2337. "\ntran: Could not read FsContext of FILE_OBJECT @ %p for IRP @ %p, err:%d\n",
  2338. fileAddr, ActualAddress, result
  2339. );
  2340. return;
  2341. }
  2342. dprintf(
  2343. "\nAFD_TRANSMIT_FILE_INFO_INTERNAL @ %p\n",
  2344. tpInfoAddr
  2345. );
  2346. dprintf(
  2347. " Endpoint = %p\n",
  2348. endpAddr
  2349. );
  2350. dprintf(
  2351. " TransmitIrp = %p (%d more irp(s) pending)\n",
  2352. ActualAddress,
  2353. CountListEntries (ActualAddress+DriverContextOffset));
  2354. dprintf(
  2355. " ReferenceCount = %ld\n",
  2356. RefCount
  2357. );
  2358. dprintf(
  2359. " Flags = %08lx (",
  2360. Flags
  2361. );
  2362. if (Flags & AFD_TF_WRITE_BEHIND)
  2363. dprintf ("WrB ");
  2364. if (Flags & AFD_TF_DISCONNECT)
  2365. dprintf ("Dsc ");
  2366. if (Flags & AFD_TF_REUSE_SOCKET)
  2367. dprintf ("Reu ");
  2368. if (Flags & AFD_TF_USE_SYSTEM_THREAD)
  2369. dprintf ("Sys ");
  2370. if (Flags & AFD_TF_USE_KERNEL_APC)
  2371. dprintf ("Apc ");
  2372. dprintf (")\n");
  2373. dprintf(
  2374. " StateFlags = %08lx (",
  2375. StateFlags
  2376. );
  2377. if (StateFlags & AFD_TP_ABORT_PENDING)
  2378. dprintf ("Abrt ");
  2379. if (StateFlags & AFD_TP_WORKER_SCHEDULED)
  2380. dprintf ("WrkS ");
  2381. if (StateFlags & AFD_TP_SENDS_POSTED)
  2382. dprintf ("Post ");
  2383. if (StateFlags & AFD_TP_QUEUED)
  2384. dprintf ("Qued ");
  2385. if (StateFlags & AFD_TP_SEND)
  2386. dprintf ("Send ");
  2387. if (StateFlags & AFD_TP_AFD_SEND)
  2388. dprintf ("AfdS ");
  2389. if (StateFlags & AFD_TP_SEND_AND_DISCONNECT)
  2390. dprintf ("S&D ");
  2391. if (tpInfoAddr==-1) {
  2392. dprintf(
  2393. "Reusing)\n"
  2394. );
  2395. }
  2396. else if (tpInfoAddr!=0) {
  2397. result = (ULONG)InitTypeRead (tpInfoAddr, AFD!AFD_TPACKETS_INFO_INTERNAL);
  2398. if (result!=0) {
  2399. dprintf(
  2400. "\ntran: Could not read AFD_TPACKETS_INFO_INTERNAL @ %p, err:%d\n",
  2401. tpInfoAddr, result
  2402. );
  2403. return;
  2404. }
  2405. if (ReadField(PdNeedsPps))
  2406. dprintf ("Pps ");
  2407. if (ReadField(ArrayAllocated))
  2408. dprintf ("Alloc ");
  2409. dprintf (")\n");
  2410. dprintf(
  2411. " SendPacketLength = %08lx\n",
  2412. (ULONG)ReadField (SendPacketLength)
  2413. );
  2414. dprintf(
  2415. " PdLength = %08lx\n",
  2416. (ULONG)ReadField (PdLength)
  2417. );
  2418. dprintf(
  2419. " NextElement = %d\n",
  2420. (ULONG)ReadField (NextElement)
  2421. );
  2422. dprintf(
  2423. " ElementCount = %d\n",
  2424. (ULONG)ReadField (ElementCount)
  2425. );
  2426. dprintf(
  2427. " ElementArray = %p\n",
  2428. ReadField (ElementArray)
  2429. );
  2430. dprintf(
  2431. " RemainingPkts = %p\n",
  2432. ReadField (RemainingPkts)
  2433. );
  2434. dprintf(
  2435. " HeadPd = %p\n",
  2436. ReadField (HeadPd)
  2437. );
  2438. dprintf(
  2439. " TailPd = %p\n",
  2440. ReadField (TailPd)
  2441. );
  2442. dprintf(
  2443. " HeadMdl = %p\n",
  2444. ReadField (HeadMdl)
  2445. );
  2446. dprintf(
  2447. " TailMdl = %p\n",
  2448. ReadField (TailMdl)
  2449. );
  2450. dprintf(
  2451. " TdiFileObject = %p\n",
  2452. ReadField (TdiFileObject)
  2453. );
  2454. dprintf(
  2455. " TdiDeviceObject = %p\n",
  2456. ReadField (TdiDeviceObject)
  2457. );
  2458. dprintf(
  2459. " NumSendIrps = %08lx\n",
  2460. NumSendIrps = (LONG)ReadField (NumSendIrps)
  2461. );
  2462. for (i=0; i<NumSendIrps && i<AFD_TP_MAX_SEND_IRPS; i++) {
  2463. CHAR fieldName[16];
  2464. if (CheckControlC ())
  2465. break;
  2466. _snprintf (fieldName, sizeof (fieldName)-1, "SendIrp[%1d]",i);
  2467. fieldName[sizeof(fieldName)-1]=0;
  2468. dprintf(
  2469. " %s = %p%s\n",
  2470. fieldName,
  2471. GetShortField (0, fieldName, 0),
  2472. StateFlags & AFD_TP_SEND_BUSY(i)
  2473. ? " (BUSY)"
  2474. : ""
  2475. );
  2476. }
  2477. dprintf(
  2478. " ReadIrp = %p%s\n",
  2479. ReadField (ReadIrp),
  2480. StateFlags & AFD_TP_READ_BUSY
  2481. ? " (BUSY)"
  2482. : ""
  2483. );
  2484. if( IsReferenceDebug ) {
  2485. dprintf(
  2486. " ReferenceDebug = %p\n",
  2487. tpInfoAddr + TPackRefOffset
  2488. );
  2489. if (SavedMinorVersion>=3554) {
  2490. ULONGLONG refCount;
  2491. refCount = ReadField (CurrentReferenceSlot);
  2492. if (SystemTime.QuadPart!=0) {
  2493. dprintf(
  2494. " CurrentReferenceSlot = %lu (@ %s)\n",
  2495. (ULONG)refCount & AFD_REF_MASK,
  2496. SystemTimeToString (
  2497. (((ReadField (CurrentTimeHigh)<<32) +
  2498. (refCount&(~AFD_REF_MASK)))<<(13-AFD_REF_SHIFT))+
  2499. SystemTime.QuadPart -
  2500. InterruptTime.QuadPart
  2501. )
  2502. );
  2503. }
  2504. else {
  2505. dprintf(
  2506. " CurrentReferenceSlot = %lu (@ %I64u ms since boot)\n",
  2507. (ULONG)refCount & AFD_REF_MASK,
  2508. (((ReadField (CurrentTimeHigh)<<32) +
  2509. (refCount&(~AFD_REF_MASK)))<<(13-AFD_REF_SHIFT))/(10*1000)
  2510. );
  2511. }
  2512. }
  2513. else {
  2514. dprintf(
  2515. " CurrentReferenceSlot = %lu\n",
  2516. (ULONG)ReadField (CurrentReferenceSlot) & AFD_REF_MASK
  2517. );
  2518. }
  2519. }
  2520. }
  2521. dprintf( "\n" );
  2522. } // DumpAfdTPacketsInfoNet
  2523. VOID
  2524. DumpAfdTPacketsInfoBriefNet (
  2525. ULONG64 ActualAddress
  2526. )
  2527. /*
  2528. TPackets I R P S Endpoint Flags Next Elmt Mo
  2529. Address Transmit Send Read Address App | State Elmt Cnt. re
  2530. xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxx xxxxxxxxxxxxxxc xxxx xxxx xx
  2531. TPackets I R P S Endpoint Flags Next Elmt Mo
  2532. Address Transmit S1 Read Address App | State Elmt Cnt. re
  2533. xxxxxxxxxxx xxxxxxxxxxx xxx xxxxxxxxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxx xxxx xxxx xx
  2534. */
  2535. {
  2536. ULONG64 fileAddr, endpAddr, tpInfoAddr, irpSpAddr;
  2537. ULONG Flags, StateFlags;
  2538. ULONG result;
  2539. tpInfoAddr = ReadField (AssociatedIrp.SystemBuffer);
  2540. irpSpAddr = ReadField (Tail.Overlay.CurrentStackLocation);
  2541. if ( (result=GetFieldValue (ActualAddress+DriverContextOffset,
  2542. "AFD!AFD_TPACKETS_IRP_CTX",
  2543. "Flags",
  2544. Flags))!=0 ||
  2545. (result=GetFieldValue (ActualAddress+DriverContextOffset,
  2546. "AFD!AFD_TPACKETS_IRP_CTX",
  2547. "StateFlags",
  2548. StateFlags))!=0 ) {
  2549. dprintf(
  2550. "\ntran: Could not read AFD_TPACKETS_IRP_CTX @ %p, err:%d\n",
  2551. ActualAddress+DriverContextOffset, result
  2552. );
  2553. return;
  2554. }
  2555. if ( (result = GetFieldValue (irpSpAddr,
  2556. "NT!_IO_STACK_LOCATION",
  2557. "FileObject",
  2558. fileAddr))!=0 ) {
  2559. dprintf(
  2560. "\ntran: Could not read IO_STACK_LOCATION @ %p for IRP @ %p, err:%d\n",
  2561. irpSpAddr, ActualAddress, result
  2562. );
  2563. return;
  2564. }
  2565. result = GetFieldValue (fileAddr,
  2566. "NT!_FILE_OBJECT",
  2567. "FsContext",
  2568. endpAddr);
  2569. if (result!=0) {
  2570. dprintf(
  2571. "\ntran: Could not read FsContext of FILE_OBJECT @ %p for IRP @ %p, err:%d\n",
  2572. fileAddr, ActualAddress, result
  2573. );
  2574. return;
  2575. }
  2576. if (tpInfoAddr!=0 && tpInfoAddr!=-1 ) {
  2577. result = (ULONG)InitTypeRead (tpInfoAddr, AFD!AFD_TPACKETS_INFO_INTERNAL);
  2578. if (result!=0) {
  2579. dprintf(
  2580. "\ntran: Could not read AFD_TPACKETS_INFO_INTERNAL @ %p, err:%d\n",
  2581. tpInfoAddr, result
  2582. );
  2583. return;
  2584. }
  2585. dprintf (
  2586. IsPtr64()
  2587. ? "\n%011.011p %011.011p %03.03p %011.011p %011.011p %s %4ld %4ld %2ld"
  2588. : "\n%008.008p %008.008p %08.08p %008.008p %008.008p %s %4ld %4ld %2ld",
  2589. DISP_PTR(tpInfoAddr),
  2590. DISP_PTR(ActualAddress),
  2591. IsPtr64()
  2592. ? DISP_PTR((tpInfoAddr+SendIrpArrayOffset)&0xFFF)
  2593. : DISP_PTR(tpInfoAddr+SendIrpArrayOffset),
  2594. DISP_PTR(ReadField (ReadIrp)),
  2595. DISP_PTR(endpAddr),
  2596. TPacketsFlagsToStringNet (Flags, StateFlags),
  2597. (ULONG)ReadField (NextElement),
  2598. (ULONG)ReadField (ElementCount),
  2599. CountListEntries (ActualAddress+DriverContextOffset)
  2600. );
  2601. }
  2602. else {
  2603. CHAR *str;
  2604. if (tpInfoAddr==0) {
  2605. if (StateFlags & AFD_TP_SEND) {
  2606. if (StateFlags & AFD_TP_AFD_SEND) {
  2607. str = "Buffered send";
  2608. }
  2609. else {
  2610. str = "Direct send";
  2611. }
  2612. }
  2613. else {
  2614. str = "Disconnect";
  2615. }
  2616. }
  2617. else {
  2618. str = "Reusing";
  2619. }
  2620. dprintf (
  2621. IsPtr64()
  2622. ? "\n%011.011p %011.011p %-15.15s %011.011p %s %4ld %4ld %2ld"
  2623. : "\n%008.008p %008.008p %-17.17s %008.008p %s %4ld %4ld %2ld",
  2624. DISP_PTR(tpInfoAddr),
  2625. DISP_PTR(ActualAddress),
  2626. str,
  2627. DISP_PTR(endpAddr),
  2628. TPacketsFlagsToStringNet (Flags, StateFlags),
  2629. 0,
  2630. 0,
  2631. CountListEntries (ActualAddress+DriverContextOffset)
  2632. );
  2633. }
  2634. } // DumpAfdTPacketsInfoBriefNet
  2635. VOID
  2636. DumpAfdTPacketsInfoXp(
  2637. ULONG64 ActualAddress
  2638. )
  2639. {
  2640. ULONG64 fileAddr, endpAddr, tpInfoAddr, irpSpAddr;
  2641. ULONG64 i;
  2642. ULONG Flags, StateFlags, NumSendIrps, RefCount;
  2643. ULONG result;
  2644. irpSpAddr = ReadField (Tail.Overlay.CurrentStackLocation);
  2645. tpInfoAddr = ReadField (AssociatedIrp.SystemBuffer);
  2646. if ( (result=GetFieldValue (ActualAddress+DriverContextOffset,
  2647. "AFD!AFD_TPACKETS_IRP_CTX",
  2648. "StateFlags",
  2649. StateFlags)) !=0 ||
  2650. (result=GetFieldValue (ActualAddress+DriverContextOffset,
  2651. "AFD!AFD_TPACKETS_IRP_CTX",
  2652. "ReferenceCount",
  2653. RefCount)) !=0 ) {
  2654. dprintf(
  2655. "\ntran: Could not read AFD_TPACKETS_IRP_CTX @ %p, err:%d\n",
  2656. ActualAddress+DriverContextOffset, result
  2657. );
  2658. return;
  2659. }
  2660. if ( (result = GetFieldValue (irpSpAddr,
  2661. "NT!_IO_STACK_LOCATION",
  2662. "FileObject",
  2663. fileAddr)) !=0 ) {
  2664. dprintf(
  2665. "\ntran: Could not read IO_STACK_LOCATION @ %p for IRP @ %p, err:%d\n",
  2666. irpSpAddr, ActualAddress, result
  2667. );
  2668. return;
  2669. }
  2670. if ( (result = GetFieldValue (irpSpAddr,
  2671. "NT!_IO_STACK_LOCATION",
  2672. "Parameters.DeviceIoControl.IoControlCode",
  2673. Flags)) !=0 ) {
  2674. dprintf(
  2675. "\ntran: Could not read IO_STACK_LOCATION @ %p for IRP @ %p, err:%d\n",
  2676. irpSpAddr, ActualAddress, result
  2677. );
  2678. return;
  2679. }
  2680. result = GetFieldValue (fileAddr,
  2681. "NT!_FILE_OBJECT",
  2682. "FsContext",
  2683. endpAddr);
  2684. if (result!=0) {
  2685. dprintf(
  2686. "\ntran: Could not read FsContext of FILE_OBJECT @ %p for IRP @ %p, err:%d\n",
  2687. fileAddr, ActualAddress, result
  2688. );
  2689. return;
  2690. }
  2691. dprintf(
  2692. "\nAFD_TRANSMIT_FILE_INFO_INTERNAL @ %p\n",
  2693. tpInfoAddr
  2694. );
  2695. dprintf(
  2696. " Endpoint = %p\n",
  2697. endpAddr
  2698. );
  2699. dprintf(
  2700. " TransmitIrp = %p (%d more irp(s) pending)\n",
  2701. ActualAddress,
  2702. CountListEntries (ActualAddress+DriverContextOffset));
  2703. dprintf(
  2704. " ReferenceCount = %ld\n",
  2705. RefCount
  2706. );
  2707. dprintf(
  2708. " Flags = %08lx (",
  2709. Flags
  2710. );
  2711. if (Flags & AFD_TF_WRITE_BEHIND)
  2712. dprintf ("WrB ");
  2713. if (Flags & AFD_TF_DISCONNECT)
  2714. dprintf ("Dsc ");
  2715. if (Flags & AFD_TF_REUSE_SOCKET)
  2716. dprintf ("Reu ");
  2717. if (Flags & AFD_TF_USE_SYSTEM_THREAD)
  2718. dprintf ("Sys ");
  2719. if (Flags & AFD_TF_USE_KERNEL_APC)
  2720. dprintf ("Apc ");
  2721. dprintf (")\n");
  2722. dprintf(
  2723. " StateFlags = %08lx (",
  2724. StateFlags
  2725. );
  2726. if (StateFlags & AFD_TP_ABORT_PENDING)
  2727. dprintf ("Abrt ");
  2728. #define AFD_TP_WORKER_SCHEDULED_XP 0x00000010
  2729. if (StateFlags & AFD_TP_WORKER_SCHEDULED_XP)
  2730. dprintf ("WrkS ");
  2731. #define AFD_TP_SEND_AND_DISCONNECT_XP 0x00000100
  2732. if (StateFlags & AFD_TP_SEND_AND_DISCONNECT_XP)
  2733. dprintf ("S&D ");
  2734. if (tpInfoAddr==-1) {
  2735. dprintf(
  2736. "Reusing)\n"
  2737. );
  2738. }
  2739. else if (tpInfoAddr!=0) {
  2740. result = (ULONG)InitTypeRead (tpInfoAddr, AFD!AFD_TPACKETS_INFO_INTERNAL);
  2741. if (result!=0) {
  2742. dprintf(
  2743. "\ntran: Could not read AFD_TPACKETS_INFO_INTERNAL @ %p, err:%d\n",
  2744. tpInfoAddr, result
  2745. );
  2746. return;
  2747. }
  2748. if (ReadField(PdNeedsPps))
  2749. dprintf ("Pps ");
  2750. if (ReadField(ArrayAllocated))
  2751. dprintf ("Alloc ");
  2752. dprintf (")\n");
  2753. dprintf(
  2754. " SendPacketLength = %08lx\n",
  2755. (ULONG)ReadField (SendPacketLength)
  2756. );
  2757. dprintf(
  2758. " PdLength = %08lx\n",
  2759. (ULONG)ReadField (PdLength)
  2760. );
  2761. dprintf(
  2762. " NextElement = %d\n",
  2763. (ULONG)ReadField (NextElement)
  2764. );
  2765. dprintf(
  2766. " ElementCount = %d\n",
  2767. (ULONG)ReadField (ElementCount)
  2768. );
  2769. dprintf(
  2770. " ElementArray = %p\n",
  2771. ReadField (ElementArray)
  2772. );
  2773. dprintf(
  2774. " RemainingPkts = %p\n",
  2775. ReadField (RemainingPkts)
  2776. );
  2777. dprintf(
  2778. " HeadPd = %p\n",
  2779. ReadField (HeadPd)
  2780. );
  2781. dprintf(
  2782. " TailPd = %p\n",
  2783. ReadField (TailPd)
  2784. );
  2785. dprintf(
  2786. " HeadMdl = %p\n",
  2787. ReadField (HeadMdl)
  2788. );
  2789. dprintf(
  2790. " TailMdl = %p\n",
  2791. ReadField (TailMdl)
  2792. );
  2793. dprintf(
  2794. " TdiFileObject = %p\n",
  2795. ReadField (TdiFileObject)
  2796. );
  2797. dprintf(
  2798. " TdiDeviceObject = %p\n",
  2799. ReadField (TdiDeviceObject)
  2800. );
  2801. dprintf(
  2802. " NumSendIrps = %08lx\n",
  2803. NumSendIrps = (LONG)ReadField (NumSendIrps)
  2804. );
  2805. for (i=0; i<NumSendIrps && i<AFD_TP_MAX_SEND_IRPS; i++) {
  2806. CHAR fieldName[16];
  2807. if (CheckControlC ())
  2808. break;
  2809. _snprintf (fieldName, sizeof (fieldName)-1, "SendIrp[%1d]",i);
  2810. fieldName[sizeof(fieldName)-1]=0;
  2811. dprintf(
  2812. " %s = %p%s\n",
  2813. fieldName,
  2814. GetShortField (0, fieldName, 0),
  2815. StateFlags & AFD_TP_SEND_BUSY(i)
  2816. ? " (BUSY)"
  2817. : ""
  2818. );
  2819. }
  2820. dprintf(
  2821. " ReadIrp = %p%s\n",
  2822. ReadField (ReadIrp),
  2823. StateFlags & AFD_TP_READ_BUSY
  2824. ? " (BUSY)"
  2825. : ""
  2826. );
  2827. if( IsReferenceDebug ) {
  2828. dprintf(
  2829. " ReferenceDebug = %p\n",
  2830. tpInfoAddr + TPackRefOffset
  2831. );
  2832. if (SavedMinorVersion>=3554) {
  2833. ULONGLONG refCount;
  2834. refCount = ReadField (CurrentReferenceSlot);
  2835. if (SystemTime.QuadPart!=0) {
  2836. dprintf(
  2837. " CurrentReferenceSlot = %lu (@ %s)\n",
  2838. (ULONG)refCount & AFD_REF_MASK,
  2839. SystemTimeToString (
  2840. (((ReadField (CurrentTimeHigh)<<32) +
  2841. (refCount&(~AFD_REF_MASK)))<<(13-AFD_REF_SHIFT))+
  2842. SystemTime.QuadPart -
  2843. InterruptTime.QuadPart
  2844. )
  2845. );
  2846. }
  2847. else {
  2848. dprintf(
  2849. " CurrentReferenceSlot = %lu (@ %I64u ms since boot)\n",
  2850. (ULONG)refCount & AFD_REF_MASK,
  2851. (((ReadField (CurrentTimeHigh)<<32) +
  2852. (refCount&(~AFD_REF_MASK)))<<(13-AFD_REF_SHIFT))/(10*1000)
  2853. );
  2854. }
  2855. }
  2856. else {
  2857. dprintf(
  2858. " CurrentReferenceSlot = %lu\n",
  2859. (ULONG)ReadField (CurrentReferenceSlot) & AFD_REF_MASK
  2860. );
  2861. }
  2862. }
  2863. }
  2864. dprintf( "\n" );
  2865. } // DumpAfdTPacketsInfoXp
  2866. VOID
  2867. DumpAfdTPacketsInfoBriefXp (
  2868. ULONG64 ActualAddress
  2869. )
  2870. /*
  2871. TPackets I R P S Endpoint Flags Next Elmt Mo
  2872. Address Transmit Send Read Address App | State Elmt Cnt. re
  2873. xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxx xxxxxxxxxxxxxxc xxxx xxxx xx
  2874. TPackets I R P S Endpoint Flags Next Elmt Mo
  2875. Address Transmit S1 Read Address App | State Elmt Cnt. re
  2876. xxxxxxxxxxx xxxxxxxxxxx xxx xxxxxxxxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxx xxxx xxxx xx
  2877. */
  2878. {
  2879. ULONG64 fileAddr, endpAddr, tpInfoAddr, irpSpAddr;
  2880. ULONG Flags, StateFlags;
  2881. ULONG result;
  2882. tpInfoAddr = ReadField (AssociatedIrp.SystemBuffer);
  2883. irpSpAddr = ReadField (Tail.Overlay.CurrentStackLocation);
  2884. if ( (result=GetFieldValue (ActualAddress+DriverContextOffset,
  2885. "AFD!AFD_TPACKETS_IRP_CTX",
  2886. "StateFlags",
  2887. StateFlags))!=0 ) {
  2888. dprintf(
  2889. "\ntran: Could not read AFD_TPACKETS_IRP_CTX @ %p, err:%d\n",
  2890. ActualAddress+DriverContextOffset, result
  2891. );
  2892. return;
  2893. }
  2894. if ( (result = GetFieldValue (irpSpAddr,
  2895. "NT!_IO_STACK_LOCATION",
  2896. "FileObject",
  2897. fileAddr))!=0 ) {
  2898. dprintf(
  2899. "\ntran: Could not read IO_STACK_LOCATION @ %p for IRP @ %p, err:%d\n",
  2900. irpSpAddr, ActualAddress, result
  2901. );
  2902. return;
  2903. }
  2904. if ( (result = GetFieldValue (irpSpAddr,
  2905. "NT!_IO_STACK_LOCATION",
  2906. "Parameters.DeviceIoControl.IoControlCode",
  2907. Flags)) !=0 ) {
  2908. dprintf(
  2909. "\ntran: Could not read IO_STACK_LOCATION @ %p for IRP @ %p, err:%d\n",
  2910. irpSpAddr, ActualAddress, result
  2911. );
  2912. return;
  2913. }
  2914. result = GetFieldValue (fileAddr,
  2915. "NT!_FILE_OBJECT",
  2916. "FsContext",
  2917. endpAddr);
  2918. if (result!=0) {
  2919. dprintf(
  2920. "\ntran: Could not read FsContext of FILE_OBJECT @ %p for IRP @ %p, err:%d\n",
  2921. fileAddr, ActualAddress, result
  2922. );
  2923. return;
  2924. }
  2925. if (tpInfoAddr!=0 && tpInfoAddr!=-1 ) {
  2926. result = (ULONG)InitTypeRead (tpInfoAddr, AFD!AFD_TPACKETS_INFO_INTERNAL);
  2927. if (result!=0) {
  2928. dprintf(
  2929. "\ntran: Could not read AFD_TPACKETS_INFO_INTERNAL @ %p, err:%d\n",
  2930. tpInfoAddr, result
  2931. );
  2932. return;
  2933. }
  2934. dprintf (
  2935. IsPtr64()
  2936. ? "\n%011.011p %011.011p %03.03p %011.011p %011.011p %s %4ld %4ld %2ld"
  2937. : "\n%008.008p %008.008p %08.08p %008.008p %008.008p %s %4ld %4ld %2ld",
  2938. DISP_PTR(tpInfoAddr),
  2939. DISP_PTR(ActualAddress),
  2940. IsPtr64()
  2941. ? DISP_PTR((tpInfoAddr+SendIrpArrayOffset)&0xFFF)
  2942. : DISP_PTR(tpInfoAddr+SendIrpArrayOffset),
  2943. DISP_PTR(ReadField (ReadIrp)),
  2944. DISP_PTR(endpAddr),
  2945. TPacketsFlagsToStringXp (Flags, StateFlags),
  2946. (ULONG)ReadField (NextElement),
  2947. (ULONG)ReadField (ElementCount),
  2948. CountListEntries (ActualAddress+DriverContextOffset)
  2949. );
  2950. }
  2951. else {
  2952. CHAR *str;
  2953. if (tpInfoAddr==0) {
  2954. str = "Disconnect";
  2955. }
  2956. else {
  2957. str = "Reusing";
  2958. }
  2959. dprintf (
  2960. IsPtr64()
  2961. ? "\n%011.011p %011.011p %-15.15s %011.011p %s %4ld %4ld %2ld"
  2962. : "\n%008.008p %008.008p %-17.17s %008.008p %s %4ld %4ld %2l",
  2963. DISP_PTR(tpInfoAddr),
  2964. DISP_PTR(ActualAddress),
  2965. str,
  2966. DISP_PTR(endpAddr),
  2967. TPacketsFlagsToStringXp (Flags, StateFlags),
  2968. 0,
  2969. 0,
  2970. CountListEntries (ActualAddress+DriverContextOffset)
  2971. );
  2972. }
  2973. } // DumpAfdTPacketsInfoBrief
  2974. VOID
  2975. DumpAfdBuffer(
  2976. ULONG64 ActualAddress
  2977. )
  2978. {
  2979. ULONG result;
  2980. ULONG length;
  2981. ULONG64 mdl,irp,buf;
  2982. dprintf(
  2983. "AFD_BUFFER @ %p\n",
  2984. ActualAddress
  2985. );
  2986. dprintf(
  2987. " BufferLength = %08lx\n",
  2988. length=(ULONG)ReadField (BufferLength)
  2989. );
  2990. dprintf(
  2991. " DataLength = %08lx\n",
  2992. (ULONG)ReadField (DataLength)
  2993. );
  2994. dprintf(
  2995. " DataOffset = %08lx\n",
  2996. (ULONG)ReadField (DataOffset)
  2997. );
  2998. dprintf(
  2999. " Context/Status = %p/%lx\n",
  3000. ReadField (Context), (ULONG)ReadField(Status)
  3001. );
  3002. dprintf(
  3003. " Mdl = %p\n",
  3004. mdl=ReadField (Mdl)
  3005. );
  3006. dprintf(
  3007. " RemoteAddress = %p\n",
  3008. ReadField (TdiInfo.RemoteAddress)
  3009. );
  3010. dprintf(
  3011. " RemoteAddressLength = %lu\n",
  3012. (ULONG)ReadField (TdiInfo.RemoteAddressLength)
  3013. );
  3014. dprintf(
  3015. " AllocatedAddressLength = %04X\n",
  3016. (USHORT)ReadField (AllocatedAddressLength)
  3017. );
  3018. dprintf(
  3019. " Flags = %04X (",
  3020. (USHORT)ReadField(Flags)
  3021. );
  3022. if (ReadField (ExpeditedData))
  3023. dprintf (" Exp");
  3024. if (ReadField (PartialMessage))
  3025. dprintf (" Partial");
  3026. if (ReadField (Lookaside))
  3027. dprintf (" Lookaside");
  3028. if (ReadField (NdisPacket))
  3029. dprintf (" Packet");
  3030. dprintf (" )\n");
  3031. if (length!=AFD_DEFAULT_TAG_BUFFER_SIZE) {
  3032. result = (ULONG)InitTypeRead (ActualAddress, AFD!AFD_BUFFER);
  3033. if (result!=0) {
  3034. dprintf ("\nDumpAfdBuffer: Could not read AFD_BUFFER @p, err: %ld\n",
  3035. ActualAddress, result);
  3036. return ;
  3037. }
  3038. dprintf(
  3039. " Buffer = %p\n",
  3040. buf=ReadField (Buffer)
  3041. );
  3042. dprintf(
  3043. " Irp = %p\n",
  3044. irp = ReadField (Irp)
  3045. );
  3046. if (SavedMinorVersion>=2267) {
  3047. dprintf(
  3048. " Placement ="
  3049. );
  3050. switch (ReadField (Placement)) {
  3051. case AFD_PLACEMENT_HDR:
  3052. dprintf (" Header-first\n");
  3053. buf = ActualAddress;
  3054. break;
  3055. case AFD_PLACEMENT_IRP:
  3056. dprintf (" Irp-first\n");
  3057. buf = irp;
  3058. break;
  3059. case AFD_PLACEMENT_MDL:
  3060. dprintf (" Mdl-first\n");
  3061. buf = mdl;
  3062. break;
  3063. case AFD_PLACEMENT_BUFFER:
  3064. dprintf (" Buffer-first\n");
  3065. // buf = buf;
  3066. break;
  3067. }
  3068. if (SavedMinorVersion>=2414) {
  3069. if (ReadField (AlignmentAdjusted)) {
  3070. ULONG64 adj;
  3071. if (ReadPointer (buf - (IsPtr64 () ? 8 : 4), &adj)) {
  3072. dprintf(
  3073. " AlignmentAdjustment = %p\n",
  3074. adj
  3075. );
  3076. }
  3077. else {
  3078. dprintf(
  3079. " Could not read alignment adjustment below %p\n",
  3080. buf);
  3081. }
  3082. }
  3083. }
  3084. }
  3085. }
  3086. dprintf( "\n" );
  3087. } // DumpAfdBuffer
  3088. VOID
  3089. DumpAfdBufferBrief(
  3090. ULONG64 ActualAddress
  3091. )
  3092. {
  3093. ULONG length;
  3094. LPSTR raddr;
  3095. UCHAR transportAddress[MAX_TRANSPORT_ADDR];
  3096. ULONG64 address;
  3097. address = ReadField (TdiInfo.RemoteAddress);
  3098. length = (ULONG)ReadField (TdiInfo.RemoteAddressLength);
  3099. if( address != 0 && length != 0) {
  3100. if (ReadMemory (address,
  3101. transportAddress,
  3102. length<sizeof (transportAddress)
  3103. ? length
  3104. : sizeof (transportAddress),
  3105. &length)) {
  3106. raddr = TransportAddressToString(
  3107. (PTRANSPORT_ADDRESS)transportAddress,
  3108. address
  3109. );
  3110. }
  3111. else {
  3112. raddr = "Read error!";
  3113. }
  3114. }
  3115. else {
  3116. raddr = "";
  3117. }
  3118. dprintf (/* Buffer Size Length Offst Context Mdl|IRP Flags Rem Addr*/
  3119. IsPtr64 ()
  3120. ? "\n%011.011p %4.4x %4.4x %4.4x %011.011p %011.011p %6s %-32.32s"
  3121. : "\n%008.008p %4.4x %4.4x %4.4x %008.008p %008.008p %6s %-32.32s",
  3122. DISP_PTR(ActualAddress),
  3123. length = (ULONG)ReadField (BufferLength),
  3124. (ULONG)ReadField (DataLength),
  3125. (ULONG)ReadField (DataOffset),
  3126. DISP_PTR(ReadField (Context)),
  3127. length==0 ? DISP_PTR(ReadField (Mdl)) : DISP_PTR(ReadField (Irp)),
  3128. BufferFlagsToString (),
  3129. raddr
  3130. );
  3131. } // DumpAfdBufferBrief
  3132. ULONG
  3133. DumpAfdPollEndpointInfo (
  3134. PFIELD_INFO pField,
  3135. PVOID UserContext
  3136. )
  3137. {
  3138. ULONG64 file, endp, hndl;
  3139. ULONG evts;
  3140. ULONG err;
  3141. if ((err=GetFieldValue (pField->address,
  3142. "AFD!AFD_POLL_ENDPOINT_INFO",
  3143. "FileObject",
  3144. file))==0 &&
  3145. (err=GetFieldValue (pField->address,
  3146. "AFD!AFD_POLL_ENDPOINT_INFO",
  3147. "Endpoint",
  3148. endp))==0 &&
  3149. (err=GetFieldValue (pField->address,
  3150. "AFD!AFD_POLL_ENDPOINT_INFO",
  3151. "Handle",
  3152. hndl))==0 &&
  3153. (err=GetFieldValue (pField->address,
  3154. "AFD!AFD_POLL_ENDPOINT_INFO",
  3155. "PollEvents",
  3156. evts))==0) {
  3157. dprintf (" %-16p %-16p %-8x %s%s%s%s%s%s%s%s%s%s%s%s%s\n",
  3158. file, endp, (ULONG)hndl,
  3159. (evts & AFD_POLL_RECEIVE) ? "rcv " : "",
  3160. (evts & AFD_POLL_RECEIVE_EXPEDITED) ? "rce " : "",
  3161. (evts & AFD_POLL_SEND) ? "snd " : "",
  3162. (evts & AFD_POLL_DISCONNECT) ? "dsc " : "",
  3163. (evts & AFD_POLL_ABORT) ? "abrt " : "",
  3164. (evts & AFD_POLL_LOCAL_CLOSE) ? "cls " : "",
  3165. (evts & AFD_POLL_CONNECT) ? "con " : "",
  3166. (evts & AFD_POLL_ACCEPT) ? "acc " : "",
  3167. (evts & AFD_POLL_CONNECT_FAIL) ? "cnf " : "",
  3168. (evts & AFD_POLL_QOS) ? "qos " : "",
  3169. (evts & AFD_POLL_GROUP_QOS) ? "gqs " : "",
  3170. (evts & AFD_POLL_ROUTING_IF_CHANGE) ? "rif " : "",
  3171. (evts & AFD_POLL_ADDRESS_LIST_CHANGE) ? "adr " : "");
  3172. }
  3173. else {
  3174. dprintf (" Failed to read endpoint info @ %p, err: %ld\n",
  3175. pField->address, err);
  3176. }
  3177. return err;
  3178. }
  3179. VOID
  3180. DumpAfdPollInfo (
  3181. ULONG64 ActualAddress
  3182. )
  3183. {
  3184. ULONG numEndpoints, err;
  3185. ULONG64 irp,thread,pid,tid;
  3186. dprintf ("\nAFD_POLL_INFO_INTERNAL @ %p\n", ActualAddress);
  3187. dprintf(
  3188. " NumberOfEndpoints = %08lx\n",
  3189. numEndpoints=(ULONG)ReadField (NumberOfEndpoints)
  3190. );
  3191. dprintf(
  3192. " Irp = %p\n",
  3193. irp=ReadField (Irp)
  3194. );
  3195. if ((err=GetFieldValue (irp, "NT!_IRP", "Tail.Overlay.Thread", thread))==0 &&
  3196. (err=GetFieldValue (thread, "NT!_ETHREAD", "Cid.UniqueProcess", pid))==0 &&
  3197. (err=GetFieldValue (thread, "NT!_ETHREAD", "Cid.UniqueThread", tid))==0 ){
  3198. dprintf(
  3199. " Thread = %p (%lx.%lx)\n",
  3200. thread, (ULONG)pid, (ULONG)tid);
  3201. }
  3202. else {
  3203. dprintf(
  3204. " Could not get thread(tid/pid) from irp, err: %ld\n", err);
  3205. }
  3206. if (ReadField (TimerStarted)) {
  3207. if (SystemTime.QuadPart!=0 ) {
  3208. dprintf(
  3209. " Expires @ %s (cur %s)\n",
  3210. SystemTimeToString (ReadField (Timer.DueTime.QuadPart)-
  3211. InterruptTime.QuadPart+
  3212. SystemTime.QuadPart),
  3213. SystemTimeToString (SystemTime.QuadPart));
  3214. }
  3215. else {
  3216. dprintf(
  3217. " Expires @ %I64x\n",
  3218. ReadField (Timer.DueTime.QuadPart));
  3219. }
  3220. }
  3221. dprintf(
  3222. " Flags : %s%s%s\n",
  3223. ReadField (Unique) ? "Unique " : "",
  3224. ReadField (TimerStarted) ? "TimerStarted " : "",
  3225. ReadField (SanPoll) ? "SanPoll " : ""
  3226. );
  3227. if (numEndpoints>0) {
  3228. FIELD_INFO flds = {
  3229. NULL,
  3230. NULL,
  3231. numEndpoints,
  3232. 0,
  3233. 0,
  3234. DumpAfdPollEndpointInfo};
  3235. SYM_DUMP_PARAM sym = {
  3236. sizeof (SYM_DUMP_PARAM),
  3237. "AFD!AFD_POLL_ENDPOINT_INFO",
  3238. DBG_DUMP_NO_PRINT | DBG_DUMP_ARRAY,
  3239. ActualAddress+PollEndpointInfoOffset,
  3240. &flds,
  3241. NULL,
  3242. NULL,
  3243. 0,
  3244. NULL
  3245. };
  3246. dprintf ( " File Object Endpoint Handle Events\n");
  3247. Ioctl(IG_DUMP_SYMBOL_INFO, &sym, sym.size);
  3248. }
  3249. }
  3250. VOID
  3251. DumpAfdPollInfoBrief (
  3252. ULONG64 ActualAddress
  3253. )
  3254. {
  3255. ULONG64 irp, thread=0, pid=0, tid=0;
  3256. BOOLEAN timerStarted, unique, san;
  3257. CHAR dueTime[16];
  3258. irp = ReadField (Irp);
  3259. GetFieldValue (irp, "NT!_IRP", "Tail.Overlay.Thread", thread);
  3260. GetFieldValue (thread, "NT!_ETHREAD", "Cid.UniqueProcess", pid);
  3261. GetFieldValue (thread, "NT!_ETHREAD", "Cid.UniqueThread", tid);
  3262. timerStarted = ReadField (TimerStarted)!=0;
  3263. unique = ReadField (Unique)!=0;
  3264. san = ReadField (SanPoll)!=0;
  3265. if (timerStarted) {
  3266. TIME_FIELDS timeFields;
  3267. LARGE_INTEGER diff;
  3268. diff.QuadPart = ReadField (Timer.DueTime.QuadPart)-InterruptTime.QuadPart;
  3269. RtlTimeToElapsedTimeFields( &diff, &timeFields );
  3270. _snprintf (dueTime, sizeof (dueTime)-1, "%2d:%2.2d:%2.2d.%3.3d",
  3271. timeFields.Day*24+timeFields.Hour,
  3272. timeFields.Minute,
  3273. timeFields.Second,
  3274. timeFields.Milliseconds);
  3275. dueTime[sizeof(dueTime)-1]=0;
  3276. }
  3277. else {
  3278. _snprintf (dueTime, sizeof (dueTime)-1, "NEVER ");
  3279. dueTime[sizeof(dueTime)-1]=0;
  3280. }
  3281. dprintf (//PollInfo IRP Thread (pid.tid) Expr Flags Hdls Array
  3282. IsPtr64 ()
  3283. ? "\n%011.011p %011.011p %011.011p %4.4x.%4.4x %12s %1s%1s%1s %4.4x %011.011p"
  3284. : "\n%008.008p %008.008p %008.008p %4.4x.%4.4x %12s %1s%1s%1s %4.4x %008.008p",
  3285. DISP_PTR(ActualAddress),
  3286. DISP_PTR(irp),
  3287. DISP_PTR(thread),
  3288. (ULONG)pid,
  3289. (ULONG)tid,
  3290. dueTime,
  3291. timerStarted ? "T" : " ",
  3292. unique ? "U" : " ",
  3293. san ? "S" : " ",
  3294. (ULONG)ReadField (NumberOfEndpoints),
  3295. DISP_PTR (ActualAddress+PollEndpointInfoOffset));
  3296. }
  3297. ULONG
  3298. GetRemoteAddressFromContext (
  3299. ULONG64 EndpAddr,
  3300. PVOID AddressBuffer,
  3301. SIZE_T AddressBufferLength,
  3302. ULONG64 *ContextAddr
  3303. )
  3304. {
  3305. ULONG64 context;
  3306. ULONG result, contextLength;
  3307. ULONG addressOffset=0, addressLength=0;
  3308. PTRANSPORT_ADDRESS TaAddress = (PTRANSPORT_ADDRESS)AddressBuffer;
  3309. ULONG maxAddressLength = (ULONG)(AddressBufferLength -
  3310. FIELD_OFFSET (TRANSPORT_ADDRESS, Address[0].AddressType));
  3311. *ContextAddr = 0;
  3312. if ((result=GetFieldValue (EndpAddr,
  3313. "AFD!AFD_ENDPOINT",
  3314. "Context",
  3315. context))==0 &&
  3316. context!=0 &&
  3317. (result=GetFieldValue (EndpAddr,
  3318. "AFD!AFD_ENDPOINT",
  3319. "ContextLength",
  3320. contextLength))==0 &&
  3321. contextLength!=0) {
  3322. //
  3323. // Hard-coded layout of SOCK_SHARED_INFO structure in
  3324. // msafd. It would be better to get it from type info,
  3325. // but msafd/mswsock symbols are not easy to load in kernel
  3326. // mode.
  3327. //
  3328. #define SOCK_SHARED_INFO_LL_OFF 0x10 // Offset of LocalAddressLength field
  3329. #define SOCK_SHARED_INFO_RL_OFF 0x14 // Offset of RemoteAddressLength field
  3330. #define SOCK_SHARED_INFO_SIZE 0x78 // Total size of the structure.
  3331. #define SOCK_SHARED_INFO_SIZE_OLD 0x68 // Size before GUID was added.
  3332. ULONG ll, rl, res;
  3333. *ContextAddr = context;
  3334. if (ReadMemory (context+SOCK_SHARED_INFO_LL_OFF, &ll, sizeof (ll), &res) &&
  3335. ReadMemory (context+SOCK_SHARED_INFO_RL_OFF, &rl, sizeof (rl), &res)) {
  3336. addressLength = rl;
  3337. if (SavedMinorVersion>=3628) {
  3338. addressOffset = SOCK_SHARED_INFO_SIZE +
  3339. ALIGN_UP_A(sizeof (ULONG), 8) +
  3340. ALIGN_UP_A(ll, 8);
  3341. }
  3342. else if (SavedMinorVersion>=2219) {
  3343. addressOffset = SOCK_SHARED_INFO_SIZE_OLD +
  3344. ALIGN_UP_A(sizeof (ULONG), 8) +
  3345. ALIGN_UP_A(ll, 8);
  3346. }
  3347. else {
  3348. addressOffset = SOCK_SHARED_INFO_SIZE_OLD +
  3349. sizeof (ULONG) +
  3350. ll;
  3351. }
  3352. }
  3353. else
  3354. return result;
  3355. if (contextLength>=(addressOffset+addressLength) &&
  3356. ReadMemory (context+addressOffset,
  3357. &TaAddress->Address[0].AddressType,
  3358. addressLength<maxAddressLength
  3359. ? addressLength
  3360. : maxAddressLength,
  3361. &res)) {
  3362. *ContextAddr += addressOffset;
  3363. TaAddress->TAAddressCount = 1;
  3364. TaAddress->Address[0].AddressLength = (USHORT)addressLength;
  3365. return 0;
  3366. }
  3367. else
  3368. result = MEMORY_READ_ERROR;
  3369. }
  3370. return result;
  3371. }
  3372. //
  3373. // Private functions.
  3374. //
  3375. PSTR
  3376. StructureTypeToString(
  3377. USHORT Type
  3378. )
  3379. /*++
  3380. Routine Description:
  3381. Maps an AFD structure type to a displayable string.
  3382. Arguments:
  3383. Type - The AFD structure type to map.
  3384. Return Value:
  3385. PSTR - Points to the displayable form of the structure type.
  3386. --*/
  3387. {
  3388. switch( Type ) {
  3389. case AfdBlockTypeEndpoint :
  3390. return "Endpoint";
  3391. case AfdBlockTypeVcConnecting :
  3392. return "VcConnecting";
  3393. case AfdBlockTypeVcListening :
  3394. return "VcListening";
  3395. case AfdBlockTypeDatagram :
  3396. return "Datagram";
  3397. case AfdBlockTypeConnection :
  3398. return "Connection";
  3399. case AfdBlockTypeHelper :
  3400. return "Helper";
  3401. case AfdBlockTypeVcBoth:
  3402. return "Listening Root";
  3403. case AfdBlockTypeSanEndpoint:
  3404. return "San Endpoint";
  3405. case AfdBlockTypeSanHelper:
  3406. return "San Helper";
  3407. }
  3408. return "INVALID";
  3409. } // StructureTypeToString
  3410. PSTR
  3411. StructureTypeToStringBrief (
  3412. USHORT Type
  3413. )
  3414. /*++
  3415. Routine Description:
  3416. Maps an AFD structure type to a displayable string.
  3417. Arguments:
  3418. Type - The AFD structure type to map.
  3419. Return Value:
  3420. PSTR - Points to the displayable form of the structure type.
  3421. --*/
  3422. {
  3423. switch( Type ) {
  3424. case AfdBlockTypeEndpoint :
  3425. return "Enp";
  3426. case AfdBlockTypeVcConnecting :
  3427. return "Vc ";
  3428. case AfdBlockTypeVcListening :
  3429. return "Lsn";
  3430. case AfdBlockTypeDatagram :
  3431. return "Dg ";
  3432. case AfdBlockTypeConnection :
  3433. return "Con";
  3434. case AfdBlockTypeHelper :
  3435. return "Hlp";
  3436. case AfdBlockTypeVcBoth:
  3437. return "Rot";
  3438. case AfdBlockTypeSanEndpoint:
  3439. return "SaE";
  3440. case AfdBlockTypeSanHelper:
  3441. return "SaH";
  3442. }
  3443. return "???";
  3444. } // StructureTypeToString
  3445. PSTR
  3446. BooleanToString(
  3447. BOOLEAN Flag
  3448. )
  3449. /*++
  3450. Routine Description:
  3451. Maps a BOOELEAN to a displayable form.
  3452. Arguments:
  3453. Flag - The BOOLEAN to map.
  3454. Return Value:
  3455. PSTR - Points to the displayable form of the BOOLEAN.
  3456. --*/
  3457. {
  3458. return Flag ? "TRUE" : "FALSE";
  3459. } // BooleanToString
  3460. PSTR
  3461. EndpointStateToString(
  3462. UCHAR State
  3463. )
  3464. /*++
  3465. Routine Description:
  3466. Maps an AFD endpoint state to a displayable string.
  3467. Arguments:
  3468. State - The AFD endpoint state to map.
  3469. Return Value:
  3470. PSTR - Points to the displayable form of the AFD endpoint state.
  3471. --*/
  3472. {
  3473. switch( State ) {
  3474. case AfdEndpointStateOpen :
  3475. return "Open";
  3476. case AfdEndpointStateBound :
  3477. return "Bound";
  3478. case AfdEndpointStateConnected :
  3479. return "Connected";
  3480. case AfdEndpointStateCleanup :
  3481. return "Cleanup";
  3482. case AfdEndpointStateClosing :
  3483. return "Closing";
  3484. case AfdEndpointStateTransmitClosing :
  3485. return "Transmit Closing";
  3486. case AfdEndpointStateInvalid :
  3487. return "Invalid";
  3488. }
  3489. return "INVALID";
  3490. } // EndpointStateToString
  3491. PSTR
  3492. EndpointStateToStringBrief(
  3493. UCHAR State
  3494. )
  3495. /*++
  3496. Routine Description:
  3497. Maps an AFD endpoint state to a displayable string.
  3498. Arguments:
  3499. State - The AFD endpoint state to map.
  3500. Return Value:
  3501. PSTR - Points to the displayable form of the AFD endpoint state.
  3502. --*/
  3503. {
  3504. switch( State ) {
  3505. case AfdEndpointStateOpen :
  3506. return "Opn";
  3507. case AfdEndpointStateBound :
  3508. return "Bnd";
  3509. case AfdEndpointStateConnected :
  3510. return "Con";
  3511. case AfdEndpointStateCleanup :
  3512. return "Cln";
  3513. case AfdEndpointStateClosing :
  3514. return "Cls";
  3515. case AfdEndpointStateTransmitClosing :
  3516. return "TrC";
  3517. case AfdEndpointStateInvalid :
  3518. return "Inv";
  3519. }
  3520. return "???";
  3521. } // EndpointStateToString
  3522. PSTR
  3523. EndpointStateFlagsToString(
  3524. )
  3525. /*++
  3526. Routine Description:
  3527. Maps an AFD endpoint state flags to a displayable string.
  3528. Arguments:
  3529. Endpoint - The AFD endpoint which state flags to map.
  3530. Return Value:
  3531. PSTR - Points to the displayable form of the AFD endpoint state flags.
  3532. --*/
  3533. {
  3534. static CHAR buffer[13];
  3535. buffer[0] = ReadField (NonBlocking) ? 'N' : ' ';
  3536. buffer[1] = ReadField (InLine) ? 'I' : ' ';
  3537. buffer[2] = ReadField (EndpointCleanedUp) ? 'E' : ' ';
  3538. buffer[3] = ReadField (PollCalled) ? 'P' : ' ';
  3539. buffer[4] = ReadField (RoutingQueryReferenced) ? 'Q' : ' ';
  3540. buffer[5] = ReadField (DisableFastIoSend) ? 'S' : ' ';
  3541. buffer[6] = ReadField (DisableFastIoRecv) ? 'R' : ' ';
  3542. buffer[7] = ReadField (AdminAccessGranted) ? 'A' : ' ';
  3543. switch (ReadField (DisconnectMode)) {
  3544. case 0:
  3545. buffer[8] = ' ';
  3546. break;
  3547. case 1:
  3548. buffer[8] = 's';
  3549. break;
  3550. case 2:
  3551. buffer[8] = 'r';
  3552. break;
  3553. case 3:
  3554. buffer[8] = 'b';
  3555. break;
  3556. case 7:
  3557. buffer[8] = 'a';
  3558. break;
  3559. default:
  3560. buffer[8] = '?';
  3561. break;
  3562. }
  3563. switch (ReadField (Type)) {
  3564. case AfdBlockTypeDatagram:
  3565. buffer[9] = ReadField (Common.Datagram.CircularQueueing) ? 'C' : ' ';
  3566. buffer[10] = ReadField (Common.Datagram.HalfConnect) ? 'H' : ' ';
  3567. if (SavedMinorVersion>=2466) {
  3568. buffer[11] = '0' + (CHAR)
  3569. ((ReadField (Common.Datagram.AddressDrop) <<0)+
  3570. (ReadField (Common.Datagram.ResourceDrop)<<1)+
  3571. (ReadField (Common.Datagram.BufferDrop) <<2)+
  3572. (ReadField (Common.Datagram.ErrorDrop) <<3));
  3573. }
  3574. else {
  3575. buffer[11] = ' ';
  3576. }
  3577. break;
  3578. case AfdBlockTypeSanEndpoint: {
  3579. NTSTATUS status = (NTSTATUS)ReadField (Common.SanEndp.CtxTransferStatus);
  3580. switch (status) {
  3581. case STATUS_PENDING:
  3582. buffer[9] = 'p';
  3583. break;
  3584. case STATUS_MORE_PROCESSING_REQUIRED:
  3585. buffer[9] = 'm';
  3586. break;
  3587. default:
  3588. if (NT_SUCCESS (status)) {
  3589. buffer[9] = ' ';
  3590. }
  3591. else {
  3592. buffer[9] = 'f';
  3593. }
  3594. break;
  3595. }
  3596. buffer[10] = ReadField (Common.SanEndp.ImplicitDup) ? 'i' : ' ';
  3597. buffer[11] = ' ';
  3598. break;
  3599. }
  3600. default:
  3601. buffer[9] = ReadField (Listening) ? 'L' : ' ';
  3602. buffer[10] = ' ';
  3603. buffer[11] = ' ';
  3604. break;
  3605. }
  3606. buffer[12] = 0;
  3607. return buffer;
  3608. }
  3609. PSTR
  3610. EndpointTypeToString(
  3611. ULONG TypeFlags
  3612. )
  3613. /*++
  3614. Routine Description:
  3615. Maps an AFD_ENDPOINT_TYPE to a displayable string.
  3616. Arguments:
  3617. Type - The AFD_ENDPOINT_TYPE to map.
  3618. Return Value:
  3619. PSTR - Points to the displayable form of the AFD_ENDPOINT_TYPE.
  3620. --*/
  3621. {
  3622. switch( TypeFlags ) {
  3623. case AfdEndpointTypeStream :
  3624. return "Stream";
  3625. case AfdEndpointTypeDatagram :
  3626. return "Datagram";
  3627. case AfdEndpointTypeRaw :
  3628. return "Raw";
  3629. case AfdEndpointTypeSequencedPacket :
  3630. return "SequencedPacket";
  3631. default:
  3632. if (TypeFlags&(~AFD_ENDPOINT_VALID_FLAGS))
  3633. return "INVALID";
  3634. else {
  3635. static CHAR buffer[64];
  3636. INT n = 0;
  3637. buffer[0] = 0;
  3638. if (TypeFlags & AFD_ENDPOINT_FLAG_CONNECTIONLESS)
  3639. n += _snprintf (&buffer[n], sizeof (buffer)-1-n, "con-less ");
  3640. if (TypeFlags & AFD_ENDPOINT_FLAG_MESSAGEMODE)
  3641. n += _snprintf (&buffer[n], sizeof (buffer)-1-n, "msg ");
  3642. if (TypeFlags & AFD_ENDPOINT_FLAG_RAW)
  3643. n += _snprintf (&buffer[n], sizeof (buffer)-1-n, "raw ");
  3644. if (TypeFlags & AFD_ENDPOINT_FLAG_MULTIPOINT)
  3645. n += _snprintf (&buffer[n], sizeof (buffer)-1-n, "m-point ");
  3646. if (TypeFlags & AFD_ENDPOINT_FLAG_CROOT)
  3647. n += _snprintf (&buffer[n], sizeof (buffer)-1-n, "croot ");
  3648. if (TypeFlags & AFD_ENDPOINT_FLAG_DROOT)
  3649. n += _snprintf (&buffer[n], sizeof (buffer)-1-n, "droot ");
  3650. buffer[sizeof(buffer)-1]=0;
  3651. return buffer;
  3652. }
  3653. }
  3654. } // EndpointTypeToString
  3655. PSTR
  3656. ConnectionStateToString(
  3657. USHORT State
  3658. )
  3659. /*++
  3660. Routine Description:
  3661. Maps an AFD connection state to a displayable string.
  3662. Arguments:
  3663. State - The AFD connection state to map.
  3664. Return Value:
  3665. PSTR - Points to the displayable form of the AFD connection state.
  3666. --*/
  3667. {
  3668. switch( State ) {
  3669. case AfdConnectionStateFree :
  3670. return "Free";
  3671. case AfdConnectionStateUnaccepted :
  3672. return "Unaccepted";
  3673. case AfdConnectionStateReturned :
  3674. return "Returned";
  3675. case AfdConnectionStateConnected :
  3676. return "Connected";
  3677. case AfdConnectionStateClosing :
  3678. return "Closing";
  3679. }
  3680. return "INVALID";
  3681. } // ConnectionStateToString
  3682. PSTR
  3683. ConnectionStateToStringBrief(
  3684. USHORT State
  3685. )
  3686. /*++
  3687. Routine Description:
  3688. Maps an AFD connection state to a displayable string.
  3689. Arguments:
  3690. State - The AFD connection state to map.
  3691. Return Value:
  3692. PSTR - Points to the displayable form of the AFD connection state.
  3693. --*/
  3694. {
  3695. switch( State ) {
  3696. case AfdConnectionStateFree :
  3697. return "Fre";
  3698. case AfdConnectionStateUnaccepted :
  3699. return "UnA";
  3700. case AfdConnectionStateReturned :
  3701. return "Rtn";
  3702. case AfdConnectionStateConnected :
  3703. return "Con";
  3704. case AfdConnectionStateClosing :
  3705. return "Cls";
  3706. }
  3707. return "???";
  3708. } // ConnectionStateToStringBrief
  3709. PSTR
  3710. ConnectionStateFlagsToString(
  3711. )
  3712. /*++
  3713. Routine Description:
  3714. Maps an AFD connection state flags to a displayable string.
  3715. Arguments:
  3716. Connection - The AFD connection which state flags to map.
  3717. Return Value:
  3718. PSTR - Points to the displayable form of the AFD connection state flags.
  3719. --*/
  3720. {
  3721. static CHAR buffer[8];
  3722. if (SavedMinorVersion>=3549) {
  3723. buffer[0] = ReadField (Aborted) ? 'A' : ' ';
  3724. if (ReadField (AbortIndicated)) {
  3725. buffer[0] = 'a';
  3726. }
  3727. else if (ReadField (AbortFailed)) {
  3728. buffer[0] = 'f';
  3729. }
  3730. }
  3731. else {
  3732. buffer[0] = ReadField (AbortedIndicated) ? 'A' : ' ';
  3733. }
  3734. buffer[1] = ReadField (DisconnectIndicated) ? 'D' : ' ';
  3735. buffer[2] = ReadField (ConnectedReferenceAdded) ? 'R' : ' ';
  3736. buffer[3] = ReadField (SpecialCondition) ? 'S' : ' ';
  3737. buffer[4] = ReadField (CleanupBegun) ? 'C' : ' ';
  3738. buffer[5] = ReadField (ClosePendedTransmit) ? 'T' : ' ';
  3739. buffer[6] = ReadField (OnLRList) ? 'L' : ' ';
  3740. buffer[7] = 0;
  3741. return buffer;
  3742. }
  3743. PSTR
  3744. TranfileFlagsToString(
  3745. VOID
  3746. )
  3747. /*++
  3748. Routine Description:
  3749. Maps an AFD transmit file info flags to a displayable string.
  3750. Arguments:
  3751. TransmitInfo - The AFD transmit file info which flags to map.
  3752. Return Value:
  3753. PSTR - Points to the displayable form of the AFD transmit file info flags.
  3754. --*/
  3755. {
  3756. static CHAR buffer[9];
  3757. buffer[0] = (ReadField (AbortPending)) ? 'A' : ' ';
  3758. buffer[1] = (ReadField (WorkerScheduled)) ? 'W' : ' ';
  3759. buffer[2] = (ReadField (NeedSendHead)) ? 'H' : ' ';
  3760. buffer[3] = (ReadField (ReuseInProgress)) ? 'R' : ' ';
  3761. buffer[4] = (ReadField (SendAndDisconnect)) ? 'S' : ' ';
  3762. buffer[5] = (ReadField (Irp1Done)) ? '1' : ' ';
  3763. buffer[6] = (ReadField (Irp2Done)) ? '2' : ' ';
  3764. buffer[7] = (ReadField (IrpRDone)) ? '3' : ' ';
  3765. buffer[8] = 0;
  3766. return buffer;
  3767. }
  3768. PSTR
  3769. TPacketsFlagsToStringNet(
  3770. ULONG Flags,
  3771. ULONG StateFlags
  3772. )
  3773. /*++
  3774. Routine Description:
  3775. Maps an AFD transmit file info flags to a displayable string.
  3776. Arguments:
  3777. TransmitInfo - The AFD transmit file info which flags to map.
  3778. Return Value:
  3779. PSTR - Points to the displayable form of the AFD transmit file info flags.
  3780. --*/
  3781. {
  3782. static CHAR buffer[20];
  3783. buffer[0] = (Flags & AFD_TF_WRITE_BEHIND) ? 'b' : ' ';
  3784. buffer[1] = (Flags & AFD_TF_DISCONNECT) ? 'd' : ' ';
  3785. buffer[2] = (Flags & AFD_TF_REUSE_SOCKET) ? 'r' : ' ';
  3786. buffer[3] = (Flags & AFD_TF_USE_SYSTEM_THREAD) ? 's' : 'a';
  3787. buffer[4] = '|';
  3788. buffer[5] = (StateFlags & AFD_TP_ABORT_PENDING) ? 'A' : ' ';
  3789. buffer[6] = (StateFlags & AFD_TP_WORKER_SCHEDULED) ? 'W' : ' ';
  3790. buffer[7] = (StateFlags & AFD_TP_SENDS_POSTED) ? 'S' : ' ';
  3791. buffer[8] = (StateFlags & AFD_TP_QUEUED) ? 'Q' : ' ';
  3792. buffer[9] = (StateFlags & AFD_TP_READ_BUSY) ? '0' : ' ';
  3793. buffer[10] = (StateFlags & AFD_TP_SEND_BUSY(0)) ? '1' : ' ';
  3794. buffer[11] = (StateFlags & AFD_TP_SEND_BUSY(1)) ? '2' : ' ';
  3795. buffer[12] = (StateFlags & AFD_TP_SEND_BUSY(2)) ? '3' : ' ';
  3796. buffer[13] = (StateFlags & AFD_TP_SEND_BUSY(3)) ? '4' : ' ';
  3797. buffer[14] = (StateFlags & AFD_TP_SEND_BUSY(4)) ? '5' : ' ';
  3798. buffer[15] = (StateFlags & AFD_TP_SEND_BUSY(5)) ? '6' : ' ';
  3799. buffer[16] = (StateFlags & AFD_TP_SEND_BUSY(6)) ? '7' : ' ';
  3800. buffer[17] = (StateFlags & AFD_TP_SEND_BUSY(7)) ? '8' : ' ';
  3801. buffer[18] = (StateFlags & AFD_TP_SEND_AND_DISCONNECT) ? '&' : ' ';
  3802. buffer[19] = 0;
  3803. return buffer;
  3804. }
  3805. PSTR
  3806. TPacketsFlagsToStringXp(
  3807. ULONG Flags,
  3808. ULONG StateFlags
  3809. )
  3810. /*++
  3811. Routine Description:
  3812. Maps an AFD transmit file info flags to a displayable string.
  3813. Arguments:
  3814. TransmitInfo - The AFD transmit file info which flags to map.
  3815. Return Value:
  3816. PSTR - Points to the displayable form of the AFD transmit file info flags.
  3817. --*/
  3818. {
  3819. static CHAR buffer[20];
  3820. buffer[0] = (Flags & AFD_TF_WRITE_BEHIND) ? 'b' : ' ';
  3821. buffer[1] = (Flags & AFD_TF_DISCONNECT) ? 'd' : ' ';
  3822. buffer[2] = (Flags & AFD_TF_REUSE_SOCKET) ? 'r' : ' ';
  3823. buffer[3] = (Flags & AFD_TF_USE_SYSTEM_THREAD) ? 's' : 'a';
  3824. buffer[4] = '|';
  3825. buffer[5] = (StateFlags & AFD_TP_ABORT_PENDING) ? 'A' : ' ';
  3826. buffer[6] = (StateFlags & AFD_TP_WORKER_SCHEDULED_XP) ? 'W' : ' ';
  3827. buffer[7] = ' ';
  3828. buffer[8] = ' ';
  3829. buffer[9] = (StateFlags & AFD_TP_READ_BUSY) ? '0' : ' ';
  3830. buffer[10] = (StateFlags & AFD_TP_SEND_BUSY(0)) ? '1' : ' ';
  3831. buffer[11] = (StateFlags & AFD_TP_SEND_BUSY(1)) ? '2' : ' ';
  3832. buffer[12] = (StateFlags & AFD_TP_SEND_BUSY(2)) ? '3' : ' ';
  3833. buffer[13] = (StateFlags & AFD_TP_SEND_BUSY(3)) ? '4' : ' ';
  3834. buffer[14] = (StateFlags & AFD_TP_SEND_BUSY(4)) ? '5' : ' ';
  3835. buffer[15] = (StateFlags & AFD_TP_SEND_BUSY(5)) ? '6' : ' ';
  3836. buffer[16] = (StateFlags & AFD_TP_SEND_BUSY(6)) ? '7' : ' ';
  3837. buffer[17] = (StateFlags & AFD_TP_SEND_BUSY(7)) ? '8' : ' ';
  3838. buffer[18] = (StateFlags & AFD_TP_SEND_AND_DISCONNECT_XP) ? '&' : ' ';
  3839. buffer[19] = 0;
  3840. return buffer;
  3841. }
  3842. PSTR
  3843. BufferFlagsToString(
  3844. )
  3845. /*++
  3846. Routine Description:
  3847. Maps an AFD buffer flags to a displayable string.
  3848. Arguments:
  3849. TransmitInfo - The AFD buffer which flags to map.
  3850. Return Value:
  3851. PSTR - Points to the displayable form of the AFD buffer flags.
  3852. --*/
  3853. {
  3854. static CHAR buffer[7];
  3855. buffer[0] = (ReadField (ExpeditedData)) ? 'E' : ' ';
  3856. buffer[1] = (ReadField (PartialMessage)) ? 'P' : ' ';
  3857. buffer[2] = (ReadField (Lookaside)) ? 'L' : ' ';
  3858. buffer[3] = (ReadField (NdisPacket)) ? 'N' : ' ';
  3859. if (SavedMinorVersion>=2267) {
  3860. UCHAR placement = (UCHAR)ReadField (Placement);
  3861. switch (placement) {
  3862. case AFD_PLACEMENT_HDR:
  3863. buffer[4] = 'h';
  3864. break;
  3865. case AFD_PLACEMENT_IRP:
  3866. buffer[4] = 'i';
  3867. break;
  3868. case AFD_PLACEMENT_MDL:
  3869. buffer[4] = 'm';
  3870. break;
  3871. case AFD_PLACEMENT_BUFFER:
  3872. buffer[4] = 'b';
  3873. break;
  3874. }
  3875. if (SavedMinorVersion>=2414) {
  3876. buffer[5] = ReadField (AlignmentAdjusted) ? 'A' : ' ';
  3877. }
  3878. else
  3879. buffer[5] = ' ';
  3880. }
  3881. else {
  3882. buffer[4] = ' ';
  3883. buffer[5] = ' ';
  3884. }
  3885. buffer[6] = 0;
  3886. return buffer;
  3887. }
  3888. PSTR
  3889. SystemTimeToString(
  3890. LONGLONG Value
  3891. )
  3892. /*++
  3893. Routine Description:
  3894. Maps a LONGLONG representing system time to a displayable string.
  3895. Arguments:
  3896. Value - The LONGLONG time to map.
  3897. Return Value:
  3898. PSTR - Points to the displayable form of the system time.
  3899. Notes:
  3900. This routine is NOT multithread safe!
  3901. --*/
  3902. {
  3903. static char buffer[64];
  3904. NTSTATUS status;
  3905. LARGE_INTEGER systemTime;
  3906. LARGE_INTEGER localTime;
  3907. TIME_FIELDS timeFields;
  3908. systemTime.QuadPart = Value;
  3909. status = RtlSystemTimeToLocalTime( &systemTime, &localTime );
  3910. if( !NT_SUCCESS(status) ) {
  3911. _snprintf(buffer, sizeof (buffer)-1, "%I64x", Value);
  3912. buffer[sizeof(buffer)-1]=0;
  3913. return buffer;
  3914. }
  3915. RtlTimeToTimeFields( &localTime, &timeFields );
  3916. _snprintf(
  3917. buffer, sizeof (buffer)-1,
  3918. "%s %s %2d %4d %02d:%02d:%02d.%03d",
  3919. WeekdayNames[timeFields.Weekday],
  3920. MonthNames[timeFields.Month],
  3921. timeFields.Day,
  3922. timeFields.Year,
  3923. timeFields.Hour,
  3924. timeFields.Minute,
  3925. timeFields.Second,
  3926. timeFields.Milliseconds
  3927. );
  3928. buffer[sizeof(buffer)-1]=0;
  3929. return buffer;
  3930. } // SystemTimeToString
  3931. PSTR
  3932. GroupTypeToString(
  3933. AFD_GROUP_TYPE GroupType
  3934. )
  3935. /*++
  3936. Routine Description:
  3937. Maps an AFD_GROUP_TYPE to a displayable string.
  3938. Arguments:
  3939. GroupType - The AFD_GROUP_TYPE to map.
  3940. Return Value:
  3941. PSTR - Points to the displayable form of the AFD_GROUP_TYPE.
  3942. --*/
  3943. {
  3944. switch( GroupType ) {
  3945. case GroupTypeNeither :
  3946. return "Neither";
  3947. case GroupTypeConstrained :
  3948. return "Constrained";
  3949. case GroupTypeUnconstrained :
  3950. return "Unconstrained";
  3951. }
  3952. return "INVALID";
  3953. } // GroupTypeToString
  3954. PSTR
  3955. ListToString (
  3956. ULONG64 ListHead
  3957. )
  3958. {
  3959. static CHAR buffer[32];
  3960. INT count = CountListEntries (ListHead);
  3961. if (count==0) {
  3962. _snprintf (buffer, sizeof (buffer)-1, "= EMPTY");
  3963. }
  3964. else {
  3965. if (IsPtr64()) {
  3966. _snprintf (buffer, sizeof (buffer)-1, "@ %I64X (%d)", ListHead, count);
  3967. }
  3968. else {
  3969. _snprintf (buffer, sizeof (buffer)-1, "@ %X (%d)", (ULONG)ListHead, count);
  3970. }
  3971. }
  3972. buffer[sizeof(buffer)-1]=0;
  3973. return buffer;
  3974. }
  3975. PAFDKD_TRANSPORT_INFO
  3976. ReadTransportInfo (
  3977. ULONG64 ActualAddress
  3978. )
  3979. {
  3980. ULONG result, length;
  3981. PAFDKD_TRANSPORT_INFO transportInfo;
  3982. ULONG64 buffer;
  3983. if( GetFieldValue(
  3984. ActualAddress,
  3985. "AFD!AFD_TRANSPORT_INFO",
  3986. "TransportDeviceName.Length",
  3987. length
  3988. )!=0 ||
  3989. GetFieldValue(
  3990. ActualAddress,
  3991. "AFD!AFD_TRANSPORT_INFO",
  3992. "TransportDeviceName.Buffer",
  3993. buffer
  3994. )!=0) {
  3995. dprintf(
  3996. "\nReadTransportInfo: Could not read AFD_TRANSPORT_INFO @ %p\n",
  3997. ActualAddress
  3998. );
  3999. return NULL;
  4000. }
  4001. if (length < sizeof (L"\\Device\\")-2) {
  4002. dprintf(
  4003. "\nReadTransportInfo: transport info (@%p) device name length (%ld) is less than sizeof (L'\\Device\\')-2\n",
  4004. ActualAddress,
  4005. length
  4006. );
  4007. return NULL;
  4008. }
  4009. transportInfo = RtlAllocateHeap (RtlProcessHeap (),
  4010. 0,
  4011. FIELD_OFFSET (AFDKD_TRANSPORT_INFO,
  4012. DeviceName[length/2+1]));
  4013. if (transportInfo==NULL) {
  4014. dprintf(
  4015. "\nReadTransportInfo: Could not allocate space for transport info.\n"
  4016. );
  4017. return NULL;
  4018. }
  4019. transportInfo->ActualAddress = ActualAddress;
  4020. if (GetFieldValue (
  4021. ActualAddress,
  4022. "AFD!AFD_TRANSPORT_INFO",
  4023. "ReferenceCount",
  4024. transportInfo->ReferenceCount)!=0 ||
  4025. GetFieldValue (
  4026. ActualAddress,
  4027. "AFD!AFD_TRANSPORT_INFO",
  4028. "InfoValid",
  4029. transportInfo->InfoValid)!=0 ||
  4030. GetFieldValue (
  4031. ActualAddress,
  4032. "AFD!AFD_TRANSPORT_INFO",
  4033. "ProviderInfo",
  4034. transportInfo->ProviderInfo)!=0 ||
  4035. !ReadMemory(
  4036. buffer,
  4037. &transportInfo->DeviceName,
  4038. length,
  4039. &result
  4040. )) {
  4041. dprintf(
  4042. "\nReadTransportInfo: Could not read AFD_TRANSPORT_INFO @ %p\n",
  4043. ActualAddress
  4044. );
  4045. RtlFreeHeap (RtlProcessHeap (), 0, transportInfo);
  4046. return NULL;
  4047. }
  4048. transportInfo->DeviceName[length/2] = 0;
  4049. return transportInfo;
  4050. }
  4051. VOID
  4052. DumpTransportInfo (
  4053. PAFDKD_TRANSPORT_INFO TransportInfo
  4054. )
  4055. {
  4056. dprintf ("\nTransport Info @ %p\n", TransportInfo->ActualAddress);
  4057. dprintf (" TransportDeviceName = %ls\n",
  4058. TransportInfo->DeviceName);
  4059. dprintf (" ReferenceCount = %ld\n",
  4060. TransportInfo->ReferenceCount);
  4061. if (TransportInfo->InfoValid) {
  4062. dprintf (" ProviderInfo:\n");
  4063. dprintf (" Version = %8.8lx\n",
  4064. TransportInfo->ProviderInfo.Version);
  4065. dprintf (" MaxSendSize = %ld\n",
  4066. TransportInfo->ProviderInfo.MaxSendSize);
  4067. dprintf (" MaxConnectionUserData = %ld\n",
  4068. TransportInfo->ProviderInfo.MaxConnectionUserData);
  4069. dprintf (" MaxDatagramSize = %ld\n",
  4070. TransportInfo->ProviderInfo.MaxDatagramSize);
  4071. dprintf (" ServiceFlags = %lx (",
  4072. TransportInfo->ProviderInfo.ServiceFlags);
  4073. if (TDI_SERVICE_ORDERLY_RELEASE & TransportInfo->ProviderInfo.ServiceFlags)
  4074. dprintf (" OrdRel");
  4075. if (TDI_SERVICE_DELAYED_ACCEPTANCE & TransportInfo->ProviderInfo.ServiceFlags)
  4076. dprintf (" DelAcc");
  4077. if (TDI_SERVICE_EXPEDITED_DATA & TransportInfo->ProviderInfo.ServiceFlags)
  4078. dprintf (" Expd");
  4079. if (TDI_SERVICE_INTERNAL_BUFFERING & TransportInfo->ProviderInfo.ServiceFlags)
  4080. dprintf (" Buff");
  4081. if (TDI_SERVICE_MESSAGE_MODE & TransportInfo->ProviderInfo.ServiceFlags)
  4082. dprintf (" Msg");
  4083. if (TDI_SERVICE_DGRAM_CONNECTION & TransportInfo->ProviderInfo.ServiceFlags)
  4084. dprintf (" DgramCon");
  4085. if (TDI_SERVICE_FORCE_ACCESS_CHECK & TransportInfo->ProviderInfo.ServiceFlags)
  4086. dprintf (" AccChk");
  4087. if (TDI_SERVICE_SEND_AND_DISCONNECT & TransportInfo->ProviderInfo.ServiceFlags)
  4088. dprintf (" S&D");
  4089. if (TDI_SERVICE_DIRECT_ACCEPT & TransportInfo->ProviderInfo.ServiceFlags)
  4090. dprintf (" DirAcc");
  4091. if (TDI_SERVICE_ACCEPT_LOCAL_ADDR & TransportInfo->ProviderInfo.ServiceFlags)
  4092. dprintf (" AcLoAd");
  4093. dprintf (" )\n");
  4094. dprintf (" MinimumLookaheadData = %ld\n",
  4095. TransportInfo->ProviderInfo.MinimumLookaheadData);
  4096. dprintf (" MaximumLookaheadData = %ld\n",
  4097. TransportInfo->ProviderInfo.MaximumLookaheadData);
  4098. dprintf (" NumberOfResources = %ld\n",
  4099. TransportInfo->ProviderInfo.NumberOfResources);
  4100. dprintf (" StartTime = %s\n",
  4101. SystemTimeToString(TransportInfo->ProviderInfo.StartTime.QuadPart));
  4102. }
  4103. }
  4104. VOID
  4105. DumpTransportInfoBrief (
  4106. PAFDKD_TRANSPORT_INFO TransportInfo
  4107. )
  4108. {
  4109. dprintf (//PollInfo IRP Thread (pid.tid) Expr Flags Hdls Array
  4110. IsPtr64 ()
  4111. ? "\n%011.011p %-30.30ls %4.4x %3.3x %8.8x %5.5x %5.5x %s"
  4112. : "\n%008.008p %-30.30ls %4.4x %3.3x %8.8x %5.5x %5.5x %s",
  4113. DISP_PTR(TransportInfo->ActualAddress),
  4114. &TransportInfo->DeviceName[sizeof ("\\device\\")-1],
  4115. TransportInfo->ReferenceCount,
  4116. TransportInfo->ProviderInfo.Version,
  4117. TransportInfo->ProviderInfo.MaxSendSize,
  4118. TransportInfo->ProviderInfo.MaxDatagramSize,
  4119. TransportInfo->ProviderInfo.ServiceFlags,
  4120. TdiServiceFlagsToStringBrief (TransportInfo->ProviderInfo.ServiceFlags));
  4121. }
  4122. PSTR
  4123. TdiServiceFlagsToStringBrief(
  4124. ULONG Flags
  4125. )
  4126. /*++
  4127. Routine Description:
  4128. Maps an TDI service flags to a displayable string.
  4129. Arguments:
  4130. Flags - flags to map
  4131. Return Value:
  4132. PSTR - Points to the displayable form of the TDI service flags.
  4133. --*/
  4134. {
  4135. static CHAR buffer[10];
  4136. buffer[0] = (TDI_SERVICE_ORDERLY_RELEASE & Flags) ? 'O' : ' ',
  4137. buffer[1] = (TDI_SERVICE_DELAYED_ACCEPTANCE & Flags) ? 'D' : ' ',
  4138. buffer[2] = (TDI_SERVICE_EXPEDITED_DATA & Flags) ? 'E' : ' ',
  4139. buffer[3] = (TDI_SERVICE_INTERNAL_BUFFERING & Flags) ? 'B' : ' ',
  4140. buffer[4] = (TDI_SERVICE_MESSAGE_MODE & Flags) ? 'M' : ' ',
  4141. buffer[5] = (TDI_SERVICE_DGRAM_CONNECTION & Flags) ? 'G' : ' ',
  4142. buffer[6] = (TDI_SERVICE_FORCE_ACCESS_CHECK & Flags) ? 'A' : ' ',
  4143. buffer[7] = (TDI_SERVICE_SEND_AND_DISCONNECT & Flags) ? '&' : ' ',
  4144. buffer[8] = (TDI_SERVICE_DIRECT_ACCEPT & Flags) ? 'R' : ' ',
  4145. buffer[9] = 0;
  4146. return buffer;
  4147. }
  4148. INT
  4149. CountListEntries (
  4150. ULONG64 ListHeadAddress
  4151. )
  4152. {
  4153. ULONG64 ptr, Next=ListHeadAddress;
  4154. INT count = 0;
  4155. Next = ListHeadAddress;
  4156. while (ReadPtr (Next, &ptr)==0 && ptr!=0 && ptr!=ListHeadAddress) {
  4157. if (CheckControlC()) {
  4158. return -1;
  4159. }
  4160. count += 1;
  4161. Next = ptr;
  4162. }
  4163. return count;
  4164. }
  4165. PSTR
  4166. ListCountEstimate (
  4167. ULONG64 ListHeadAddress
  4168. )
  4169. {
  4170. ULONG64 next, prev;
  4171. if (ReadPtr (ListHeadAddress, &next)!=0) {
  4172. return "Er";
  4173. }
  4174. else if (next==ListHeadAddress) {
  4175. return " 0";
  4176. }
  4177. else if (ReadPtr (ListHeadAddress+(IsPtr64 () ? 8 : 4), &prev)!=0) {
  4178. return "Er";
  4179. }
  4180. else if (prev==next) {
  4181. return " 1";
  4182. }
  4183. else {
  4184. return ">1";
  4185. }
  4186. }