Windows NT 4.0 source code leak
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.

2221 lines
46 KiB

4 years ago
  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. #define MAX_SYMBOL_LENGTH 128
  19. #define ACTUAL_ADDRESS(a,s,f) \
  20. ( (DWORD)(a) + ( (PUCHAR)(&(s)->f) - (PUCHAR)(s) ) )
  21. #define IS_LIST_EMPTY(a,s,f) \
  22. ( (DWORD)(s)->f.Flink == ACTUAL_ADDRESS(a,s,f) )
  23. //
  24. // Private globals.
  25. //
  26. PSTR WeekdayNames[] =
  27. {
  28. "Sunday",
  29. "Monday",
  30. "Tuesday",
  31. "Wednesday",
  32. "Thursday",
  33. "Friday",
  34. "Saturday"
  35. };
  36. PSTR MonthNames[] =
  37. {
  38. "",
  39. "January",
  40. "February",
  41. "March",
  42. "April",
  43. "May",
  44. "June",
  45. "July",
  46. "August",
  47. "September",
  48. "October",
  49. "November",
  50. "December"
  51. };
  52. //
  53. // Private prototypes.
  54. //
  55. PSTR
  56. StructureTypeToString(
  57. USHORT Type
  58. );
  59. PSTR
  60. BooleanToString(
  61. BOOLEAN Flag
  62. );
  63. PSTR
  64. EndpointStateToString(
  65. UCHAR State
  66. );
  67. PSTR
  68. EndpointTypeToString(
  69. AFD_ENDPOINT_TYPE Type
  70. );
  71. PSTR
  72. ConnectionStateToString(
  73. USHORT State
  74. );
  75. PSTR
  76. SystemTimeToString(
  77. LONGLONG Value
  78. );
  79. PSTR
  80. GroupTypeToString(
  81. AFD_GROUP_TYPE GroupType
  82. );
  83. VOID
  84. DumpReferenceDebug(
  85. PAFD_REFERENCE_DEBUG ReferenceDebug,
  86. ULONG CurrentSlot
  87. );
  88. BOOL
  89. IsTransmitIrpBusy(
  90. PIRP Irp
  91. );
  92. //
  93. // Public functions.
  94. //
  95. VOID
  96. DumpAfdEndpoint(
  97. PAFD_ENDPOINT Endpoint,
  98. DWORD ActualAddress
  99. )
  100. /*++
  101. Routine Description:
  102. Dumps the specified AFD_ENDPOINT structure.
  103. Arguments:
  104. Endpoint - Points to the AFD_ENDPOINT to dump.
  105. ActualAddress - The actual address where the structure resides on the
  106. debugee.
  107. Return Value:
  108. None.
  109. --*/
  110. {
  111. AFD_TRANSPORT_INFO transportInfo;
  112. UNICODE_STRING unicodeString;
  113. WCHAR buffer[MAX_PATH];
  114. UCHAR address[MAX_TRANSPORT_ADDR];
  115. ULONG result;
  116. dprintf(
  117. "AFD_ENDPOINT @ %08lx:\n",
  118. ActualAddress
  119. );
  120. dprintf(
  121. " Type = %04X (%s)\n",
  122. Endpoint->Type,
  123. StructureTypeToString( Endpoint->Type )
  124. );
  125. dprintf(
  126. " ReferenceCount = %d\n",
  127. Endpoint->ReferenceCount
  128. );
  129. dprintf(
  130. " State = %02X (%s)\n",
  131. Endpoint->State,
  132. EndpointStateToString( Endpoint->State )
  133. );
  134. dprintf(
  135. " NonBlocking = %s\n",
  136. BooleanToString( Endpoint->NonBlocking )
  137. );
  138. dprintf(
  139. " InLine = %s\n",
  140. BooleanToString( Endpoint->InLine )
  141. );
  142. dprintf(
  143. " TdiBufferring = %s\n",
  144. BooleanToString( Endpoint->TdiBufferring )
  145. );
  146. dprintf(
  147. " TransportInfo = %08lx\n",
  148. Endpoint->TransportInfo
  149. );
  150. if( ReadMemory(
  151. (DWORD)Endpoint->TransportInfo,
  152. &transportInfo,
  153. sizeof(transportInfo),
  154. &result
  155. ) &&
  156. ReadMemory(
  157. (DWORD)transportInfo.TransportDeviceName.Buffer,
  158. buffer,
  159. sizeof(buffer),
  160. &result
  161. ) ) {
  162. unicodeString = transportInfo.TransportDeviceName;
  163. unicodeString.Buffer = buffer;
  164. dprintf(
  165. " TransportDeviceName = %wZ\n",
  166. &unicodeString
  167. );
  168. }
  169. dprintf(
  170. " EndpointType = %08lx (%s)\n",
  171. Endpoint->EndpointType,
  172. EndpointTypeToString( Endpoint->EndpointType )
  173. );
  174. dprintf(
  175. " AddressHandle = %08lx\n",
  176. Endpoint->AddressHandle
  177. );
  178. dprintf(
  179. " AddressFileObject = %08lx\n",
  180. Endpoint->AddressFileObject
  181. );
  182. switch( Endpoint->Type ) {
  183. case AfdBlockTypeVcConnecting :
  184. dprintf(
  185. " Connection = %08lx\n",
  186. Endpoint->Common.VcConnecting.Connection
  187. );
  188. dprintf(
  189. " ConnectStatus = %08lx\n",
  190. Endpoint->Common.VcConnecting.ConnectStatus
  191. );
  192. dprintf(
  193. " ListenEndpoint = %08lx\n",
  194. Endpoint->Common.VcConnecting.ListenEndpoint
  195. );
  196. break;
  197. case AfdBlockTypeVcListening :
  198. if( IS_LIST_EMPTY(
  199. ActualAddress,
  200. Endpoint,
  201. Common.VcListening.FreeConnectionListHead ) ) {
  202. dprintf(
  203. " FreeConnectionListHead = EMPTY\n"
  204. );
  205. } else {
  206. dprintf(
  207. " FreeConnectionListHead @ %08lx\n",
  208. ACTUAL_ADDRESS(
  209. ActualAddress,
  210. Endpoint,
  211. Common.VcListening.FreeConnectionListHead
  212. )
  213. );
  214. }
  215. if( IS_LIST_EMPTY(
  216. ActualAddress,
  217. Endpoint,
  218. Common.VcListening.UnacceptedConnectionListHead ) ) {
  219. dprintf(
  220. " UnacceptedConnectionListHead = EMPTY\n"
  221. );
  222. } else {
  223. dprintf(
  224. " UnacceptedConnectionListHead @ %08lx\n",
  225. ACTUAL_ADDRESS(
  226. ActualAddress,
  227. Endpoint,
  228. Common.VcListening.UnacceptedConnectionListHead
  229. )
  230. );
  231. }
  232. if( IS_LIST_EMPTY(
  233. ActualAddress,
  234. Endpoint,
  235. Common.VcListening.ReturnedConnectionListHead ) ) {
  236. dprintf(
  237. " ReturnedConnectionListHead = EMPTY\n"
  238. );
  239. } else {
  240. dprintf(
  241. " ReturnedConnectionListHead @ %08lx\n",
  242. ACTUAL_ADDRESS(
  243. ActualAddress,
  244. Endpoint,
  245. Common.VcListening.ReturnedConnectionListHead
  246. )
  247. );
  248. }
  249. if( IS_LIST_EMPTY(
  250. ActualAddress,
  251. Endpoint,
  252. Common.VcListening.ListeningIrpListHead ) ) {
  253. dprintf(
  254. " ListeningIrpListHead = EMPTY\n"
  255. );
  256. } else {
  257. dprintf(
  258. " ListeningIrpListHead @ %08lx\n",
  259. ACTUAL_ADDRESS(
  260. ActualAddress,
  261. Endpoint,
  262. Common.VcListening.ListeningIrpListHead
  263. )
  264. );
  265. }
  266. dprintf(
  267. " FailedConnectionAdds = %08lx\n",
  268. Endpoint->Common.VcListening.FailedConnectionAdds
  269. );
  270. break;
  271. case AfdBlockTypeDatagram :
  272. dprintf(
  273. " RemoteAddress = %08lx\n",
  274. Endpoint->Common.Datagram.RemoteAddress
  275. );
  276. dprintf(
  277. " RemoteAddressLength = %08lx\n",
  278. Endpoint->Common.Datagram.RemoteAddressLength
  279. );
  280. if( IS_LIST_EMPTY(
  281. ActualAddress,
  282. Endpoint,
  283. Common.Datagram.ReceiveIrpListHead ) ) {
  284. dprintf(
  285. " ReceiveIrpListHead = EMPTY\n"
  286. );
  287. } else {
  288. dprintf(
  289. " ReceiveIrpListHead @ %08lx\n",
  290. ACTUAL_ADDRESS(
  291. ActualAddress,
  292. Endpoint,
  293. Common.Datagram.ReceiveIrpListHead
  294. )
  295. );
  296. }
  297. if( IS_LIST_EMPTY(
  298. ActualAddress,
  299. Endpoint,
  300. Common.Datagram.PeekIrpListHead ) ) {
  301. dprintf(
  302. " PeekIrpListHead = EMPTY\n"
  303. );
  304. } else {
  305. dprintf(
  306. " PeekIrpListHead @ %08lx\n",
  307. ACTUAL_ADDRESS(
  308. ActualAddress,
  309. Endpoint,
  310. Common.Datagram.PeekIrpListHead
  311. )
  312. );
  313. }
  314. if( IS_LIST_EMPTY(
  315. ActualAddress,
  316. Endpoint,
  317. Common.Datagram.ReceiveBufferListHead ) ) {
  318. dprintf(
  319. " ReceiveBufferListHead = EMPTY\n"
  320. );
  321. } else {
  322. dprintf(
  323. " ReceiveBufferListHead @ %08lx\n",
  324. ACTUAL_ADDRESS(
  325. ActualAddress,
  326. Endpoint,
  327. Common.Datagram.ReceiveBufferListHead
  328. )
  329. );
  330. }
  331. dprintf(
  332. " BufferredDatagramBytes = %08lx\n",
  333. Endpoint->BufferredDatagramBytes
  334. );
  335. dprintf(
  336. " BufferredDatagramCount = %04X\n",
  337. Endpoint->BufferredDatagramCount
  338. );
  339. dprintf(
  340. " MaxBufferredReceiveBytes = %08lx\n",
  341. Endpoint->Common.Datagram.MaxBufferredReceiveBytes
  342. );
  343. dprintf(
  344. " MaxBufferredSendBytes = %08lx\n",
  345. Endpoint->Common.Datagram.MaxBufferredSendBytes
  346. );
  347. dprintf(
  348. " MaxBufferredReceiveCount = %04X\n",
  349. Endpoint->Common.Datagram.MaxBufferredReceiveCount
  350. );
  351. dprintf(
  352. " MaxBufferredSendCount = %04X\n",
  353. Endpoint->Common.Datagram.MaxBufferredSendCount
  354. );
  355. dprintf(
  356. " CircularQueueing = %s\n",
  357. BooleanToString( Endpoint->Common.Datagram.CircularQueueing )
  358. );
  359. break;
  360. }
  361. dprintf(
  362. " DisconnectMode = %08lx\n",
  363. Endpoint->DisconnectMode
  364. );
  365. dprintf(
  366. " OutstandingIrpCount = %08lx\n",
  367. Endpoint->OutstandingIrpCount
  368. );
  369. dprintf(
  370. " LocalAddress = %08lx\n",
  371. Endpoint->LocalAddress
  372. );
  373. dprintf(
  374. " LocalAddressLength = %08lx\n",
  375. Endpoint->LocalAddressLength
  376. );
  377. if( Endpoint->LocalAddressLength <= sizeof(address) &&
  378. Endpoint->LocalAddress != NULL ) {
  379. if( ReadMemory(
  380. (DWORD)Endpoint->LocalAddress,
  381. address,
  382. sizeof(address),
  383. &result
  384. ) ) {
  385. DumpTransportAddress(
  386. " ",
  387. (PTRANSPORT_ADDRESS)address,
  388. (DWORD)Endpoint->LocalAddress
  389. );
  390. }
  391. }
  392. dprintf(
  393. " Context = %08lx\n",
  394. Endpoint->Context
  395. );
  396. dprintf(
  397. " ContextLength = %08lx\n",
  398. Endpoint->ContextLength
  399. );
  400. dprintf(
  401. " OwningProcess = %08lx\n",
  402. Endpoint->OwningProcess
  403. );
  404. dprintf(
  405. " ConnectDataBuffers = %08lx\n",
  406. Endpoint->ConnectDataBuffers
  407. );
  408. dprintf(
  409. " TransmitIrp = %08lx\n",
  410. Endpoint->TransmitIrp
  411. );
  412. dprintf(
  413. " TransmitInfo = %08lx\n",
  414. Endpoint->TransmitInfo
  415. );
  416. dprintf(
  417. " AddressDeviceObject = %08lx\n",
  418. Endpoint->AddressDeviceObject
  419. );
  420. dprintf(
  421. " ConnectOutstanding = %s\n",
  422. BooleanToString( Endpoint->ConnectOutstanding )
  423. );
  424. dprintf(
  425. " SendDisconnected = %s\n",
  426. BooleanToString( Endpoint->SendDisconnected )
  427. );
  428. dprintf(
  429. " EndpointCleanedUp = %s\n",
  430. BooleanToString( Endpoint->EndpointCleanedUp )
  431. );
  432. dprintf(
  433. " TdiMessageMode = %s\n",
  434. BooleanToString( Endpoint->TdiMessageMode )
  435. );
  436. #if !defined(NT351)
  437. dprintf(
  438. " EventObject = %08lx\n",
  439. Endpoint->EventObject
  440. );
  441. dprintf(
  442. " EventsEnabled = %08lx\n",
  443. Endpoint->EventsEnabled
  444. );
  445. dprintf(
  446. " EventsDisabled = %08lx\n",
  447. Endpoint->EventsDisabled
  448. );
  449. dprintf(
  450. " EventsActive = %08lx\n",
  451. Endpoint->EventsActive
  452. );
  453. dprintf(
  454. " EventStatus = %08lx\n",
  455. ACTUAL_ADDRESS( ActualAddress, Endpoint, EventStatus[0] )
  456. );
  457. dprintf(
  458. " GroupID = %08lx\n",
  459. Endpoint->GroupID
  460. );
  461. dprintf(
  462. " GroupType = %s\n",
  463. GroupTypeToString( Endpoint->GroupType )
  464. );
  465. #endif
  466. if( IsCheckedAfd ) {
  467. dprintf(
  468. " ReferenceDebug = %08lx\n",
  469. Endpoint->ReferenceDebug
  470. );
  471. dprintf(
  472. " CurrentReferenceSlot = %lu\n",
  473. Endpoint->CurrentReferenceSlot % MAX_REFERENCE
  474. );
  475. }
  476. dprintf( "\n" );
  477. } // DumpAfdEndpoint
  478. VOID
  479. DumpAfdConnection(
  480. PAFD_CONNECTION Connection,
  481. DWORD ActualAddress
  482. )
  483. /*++
  484. Routine Description:
  485. Dumps the specified AFD_CONNECTION structures.
  486. Arguments:
  487. Connection - Points to the AFD_CONNECTION structure to dump.
  488. ActualAddress - The actual address where the structure resides on the
  489. debugee.
  490. Return Value:
  491. None.
  492. --*/
  493. {
  494. UCHAR address[MAX_TRANSPORT_ADDR];
  495. ULONG result;
  496. dprintf(
  497. "AFD_CONNECTION @ %08lx:\n",
  498. ActualAddress
  499. );
  500. dprintf(
  501. " Type = %04X (%s)\n",
  502. Connection->Type,
  503. StructureTypeToString( Connection->Type )
  504. );
  505. dprintf(
  506. " ReferenceCount = %d\n",
  507. Connection->ReferenceCount
  508. );
  509. dprintf(
  510. " State = %08X (%s)\n",
  511. Connection->State,
  512. ConnectionStateToString( Connection->State )
  513. );
  514. dprintf(
  515. " Handle = %08lx\n",
  516. Connection->Handle
  517. );
  518. dprintf(
  519. " FileObject = %08lx\n",
  520. Connection->FileObject
  521. );
  522. dprintf(
  523. " ConnectTime = %s\n",
  524. SystemTimeToString( Connection->ConnectTime )
  525. );
  526. if( Connection->TdiBufferring )
  527. {
  528. dprintf(
  529. " ReceiveBytesIndicated = %s\n",
  530. LongLongToString( Connection->Common.Bufferring.ReceiveBytesIndicated.QuadPart )
  531. );
  532. dprintf(
  533. " ReceiveBytesTaken = %s\n",
  534. LongLongToString( Connection->Common.Bufferring.ReceiveBytesTaken.QuadPart )
  535. );
  536. dprintf(
  537. " ReceiveBytesOutstanding = %s\n",
  538. LongLongToString( Connection->Common.Bufferring.ReceiveBytesOutstanding.QuadPart )
  539. );
  540. dprintf(
  541. " ReceiveExpeditedBytesIndicated = %s\n",
  542. LongLongToString( Connection->Common.Bufferring.ReceiveExpeditedBytesIndicated.QuadPart )
  543. );
  544. dprintf(
  545. " ReceiveExpeditedBytesTaken = %s\n",
  546. LongLongToString( Connection->Common.Bufferring.ReceiveExpeditedBytesTaken.QuadPart )
  547. );
  548. dprintf(
  549. " ReceiveExpeditedBytesOutstanding = %s\n",
  550. LongLongToString( Connection->Common.Bufferring.ReceiveExpeditedBytesOutstanding.QuadPart )
  551. );
  552. dprintf(
  553. " NonBlockingSendPossible = %s\n",
  554. BooleanToString( Connection->Common.Bufferring.NonBlockingSendPossible )
  555. );
  556. dprintf(
  557. " ZeroByteReceiveIndicated = %s\n",
  558. BooleanToString( Connection->Common.Bufferring.ZeroByteReceiveIndicated )
  559. );
  560. }
  561. else
  562. {
  563. if( IS_LIST_EMPTY(
  564. ActualAddress,
  565. Connection,
  566. Common.NonBufferring.ReceiveIrpListHead ) ) {
  567. dprintf(
  568. " ReceiveIrpListHead = EMPTY\n"
  569. );
  570. } else {
  571. dprintf(
  572. " ReceiveIrpListHead @ %08lx\n",
  573. ACTUAL_ADDRESS(
  574. ActualAddress,
  575. Connection,
  576. Common.NonBufferring.ReceiveIrpListHead
  577. )
  578. );
  579. }
  580. if( IS_LIST_EMPTY(
  581. ActualAddress,
  582. Connection,
  583. Common.NonBufferring.ReceiveBufferListHead ) ) {
  584. dprintf(
  585. " ReceiveBufferListHead = EMPTY\n"
  586. );
  587. } else {
  588. dprintf(
  589. " ReceiveBufferListHead @ %08lx\n",
  590. ACTUAL_ADDRESS(
  591. ActualAddress,
  592. Connection,
  593. Common.NonBufferring.ReceiveBufferListHead
  594. )
  595. );
  596. }
  597. if( IS_LIST_EMPTY(
  598. ActualAddress,
  599. Connection,
  600. Common.NonBufferring.SendIrpListHead ) ) {
  601. dprintf(
  602. " SendIrpListHead = EMPTY\n"
  603. );
  604. } else {
  605. dprintf(
  606. " SendIrpListHead @ %08lx\n",
  607. ACTUAL_ADDRESS(
  608. ActualAddress,
  609. Connection,
  610. Common.NonBufferring.SendIrpListHead
  611. )
  612. );
  613. }
  614. dprintf(
  615. " BufferredReceiveBytes = %lu\n",
  616. Connection->Common.NonBufferring.BufferredReceiveBytes
  617. );
  618. dprintf(
  619. " BufferredExpeditedBytes = %lu\n",
  620. Connection->Common.NonBufferring.BufferredExpeditedBytes
  621. );
  622. dprintf(
  623. " BufferredReceiveCount = %u\n",
  624. Connection->Common.NonBufferring.BufferredReceiveCount
  625. );
  626. dprintf(
  627. " BufferredExpeditedCount = %u\n",
  628. Connection->Common.NonBufferring.BufferredExpeditedCount
  629. );
  630. dprintf(
  631. " ReceiveBytesInTransport = %lu\n",
  632. Connection->Common.NonBufferring.ReceiveBytesInTransport
  633. );
  634. dprintf(
  635. " BufferredSendBytes = %lu\n",
  636. Connection->Common.NonBufferring.BufferredSendBytes
  637. );
  638. dprintf(
  639. " ReceiveCountInTransport = %u\n",
  640. Connection->Common.NonBufferring.ReceiveCountInTransport
  641. );
  642. dprintf(
  643. " BufferredSendCount = %u\n",
  644. Connection->Common.NonBufferring.BufferredSendCount
  645. );
  646. dprintf(
  647. " DisconnectIrp = %08lx\n",
  648. Connection->Common.NonBufferring.DisconnectIrp
  649. );
  650. }
  651. dprintf(
  652. " Endpoint = %08lx\n",
  653. Connection->Endpoint
  654. );
  655. dprintf(
  656. " MaxBufferredReceiveBytes = %lu\n",
  657. Connection->MaxBufferredReceiveBytes
  658. );
  659. dprintf(
  660. " MaxBufferredSendBytes = %lu\n",
  661. Connection->MaxBufferredSendBytes
  662. );
  663. dprintf(
  664. " MaxBufferredReceiveCount = %u\n",
  665. Connection->MaxBufferredReceiveCount
  666. );
  667. dprintf(
  668. " MaxBufferredSendCount = %u\n",
  669. Connection->MaxBufferredSendCount
  670. );
  671. dprintf(
  672. " ConnectDataBuffers = %08lx\n",
  673. Connection->ConnectDataBuffers
  674. );
  675. dprintf(
  676. " OwningProcess = %08lx\n",
  677. Connection->OwningProcess
  678. );
  679. dprintf(
  680. " DeviceObject = %08lx\n",
  681. Connection->DeviceObject
  682. );
  683. dprintf(
  684. " RemoteAddress = %08lx\n",
  685. Connection->RemoteAddress
  686. );
  687. dprintf(
  688. " RemoteAddressLength = %lu\n",
  689. Connection->RemoteAddressLength
  690. );
  691. if( Connection->RemoteAddressLength <= sizeof(address) &&
  692. Connection->RemoteAddress != NULL ) {
  693. if( ReadMemory(
  694. (DWORD)Connection->RemoteAddress,
  695. address,
  696. sizeof(address),
  697. &result
  698. ) ) {
  699. DumpTransportAddress(
  700. " ",
  701. (PTRANSPORT_ADDRESS)address,
  702. (DWORD)Connection->RemoteAddress
  703. );
  704. }
  705. }
  706. dprintf(
  707. " DisconnectIndicated = %s\n",
  708. BooleanToString( Connection->DisconnectIndicated )
  709. );
  710. dprintf(
  711. " AbortIndicated = %s\n",
  712. BooleanToString( Connection->AbortIndicated )
  713. );
  714. dprintf(
  715. " TdiBufferring = %s\n",
  716. BooleanToString( Connection->TdiBufferring )
  717. );
  718. dprintf(
  719. " ConnectedReferenceAdded = %s\n",
  720. BooleanToString( Connection->ConnectedReferenceAdded )
  721. );
  722. dprintf(
  723. " SpecialCondition = %s\n",
  724. BooleanToString( Connection->SpecialCondition )
  725. );
  726. dprintf(
  727. " CleanupBegun = %s\n",
  728. BooleanToString( Connection->CleanupBegun )
  729. );
  730. dprintf(
  731. " ClosePendedTransmit = %s\n",
  732. BooleanToString( Connection->ClosePendedTransmit )
  733. );
  734. if( IsCheckedAfd ) {
  735. dprintf(
  736. " CurrentReferenceSlot = %lu\n",
  737. Connection->CurrentReferenceSlot % MAX_REFERENCE
  738. );
  739. dprintf(
  740. " ReferenceDebug = %08lx\n",
  741. ACTUAL_ADDRESS(
  742. ActualAddress,
  743. Connection,
  744. ReferenceDebug
  745. )
  746. );
  747. }
  748. dprintf( "\n" );
  749. } // DumpAfdConnection
  750. VOID
  751. DumpAfdConnectionReferenceDebug(
  752. PAFD_REFERENCE_DEBUG ReferenceDebug,
  753. DWORD ActualAddress
  754. )
  755. /*++
  756. Routine Description:
  757. Dumps the AFD_REFERENCE_DEBUG structures associated with an
  758. AFD_CONNECTION object.
  759. Arguments:
  760. ReferenceDebug - Points to an array of AFD_REFERENCE_DEBUG structures.
  761. There are assumed to be MAX_REFERENCE entries in this array.
  762. ActualAddress - The actual address where the array resides on the
  763. debugee.
  764. Return Value:
  765. None.
  766. --*/
  767. {
  768. ULONG i;
  769. ULONG result;
  770. LPSTR fileName;
  771. CHAR filePath[MAX_PATH];
  772. CHAR action[16];
  773. dprintf(
  774. "AFD_REFERENCE_DEBUG @ %08lx\n",
  775. ActualAddress
  776. );
  777. for( i = 0 ; i < MAX_REFERENCE ; i++, ReferenceDebug++ ) {
  778. if( CheckControlC() ) {
  779. break;
  780. }
  781. if( ReferenceDebug->Info1 == NULL &&
  782. ReferenceDebug->Info2 == NULL &&
  783. ReferenceDebug->Action == 0 &&
  784. ReferenceDebug->NewCount == 0 ) {
  785. break;
  786. }
  787. if( ReferenceDebug->Action == 0 ||
  788. ReferenceDebug->Action == 1 ||
  789. ReferenceDebug->Action == (ULONG)-1L ) {
  790. sprintf(
  791. action,
  792. "%ld",
  793. ReferenceDebug->Action
  794. );
  795. } else {
  796. sprintf(
  797. action,
  798. "%08lx",
  799. ReferenceDebug->Action
  800. );
  801. }
  802. switch( (DWORD)ReferenceDebug->Info1 ) {
  803. case 0xafdafd02 :
  804. dprintf(
  805. " %3lu: Buffered Send, IRP @ %08lx [%s] -> %lu\n",
  806. i,
  807. ReferenceDebug->Info2,
  808. action,
  809. ReferenceDebug->NewCount
  810. );
  811. break;
  812. case 0xafdafd03 :
  813. dprintf(
  814. " %3lu: Nonbuffered Send, IRP @ %08lx [%s] -> %lu\n",
  815. i,
  816. ReferenceDebug->Info2,
  817. action,
  818. ReferenceDebug->NewCount
  819. );
  820. break;
  821. case 0xafd11100 :
  822. case 0xafd11101 :
  823. dprintf(
  824. " %3lu: AfdRestartSend (%08lx), IRP @ %08lx [%s] -> %lu\n",
  825. i,
  826. ReferenceDebug->Info1,
  827. ReferenceDebug->Info2,
  828. action,
  829. ReferenceDebug->NewCount
  830. );
  831. break;
  832. case 0xafd11102 :
  833. case 0xafd11103 :
  834. case 0xafd11104 :
  835. case 0xafd11105 :
  836. dprintf(
  837. " %3lu: AfdRestartBufferSend (%08lx), IRP @ %08lx [%s] -> %lu\n",
  838. i,
  839. ReferenceDebug->Info1,
  840. ReferenceDebug->Info2,
  841. action,
  842. ReferenceDebug->NewCount
  843. );
  844. break;
  845. case 0 :
  846. if( ReferenceDebug->Info2 == NULL ) {
  847. dprintf(
  848. " %3lu: AfdDeleteConnectedReference (%08lx)\n",
  849. i,
  850. ReferenceDebug->Action
  851. );
  852. break;
  853. } else {
  854. //
  855. // Fall through to default case.
  856. //
  857. }
  858. default :
  859. if( ReadMemory(
  860. (DWORD)ReferenceDebug->Info1,
  861. filePath,
  862. sizeof(filePath),
  863. &result
  864. ) ) {
  865. fileName = strrchr( filePath, '\\' );
  866. if( fileName != NULL ) {
  867. fileName++;
  868. } else {
  869. fileName = filePath;
  870. }
  871. } else {
  872. sprintf(
  873. filePath,
  874. "%08lx",
  875. ReferenceDebug->Info1
  876. );
  877. fileName = filePath;
  878. }
  879. dprintf(
  880. " %3lu: %s:%lu [%s] -> %lu\n",
  881. i,
  882. fileName,
  883. ReferenceDebug->Info2,
  884. action,
  885. ReferenceDebug->NewCount
  886. );
  887. break;
  888. }
  889. }
  890. } // DumpAfdConnectionReferenceDebug
  891. VOID
  892. DumpAfdEndpointReferenceDebug(
  893. PAFD_REFERENCE_DEBUG ReferenceDebug,
  894. DWORD ActualAddress
  895. )
  896. /*++
  897. Routine Description:
  898. Dumps the AFD_REFERENCE_DEBUG structures associated with an
  899. AFD_ENDPOINT object.
  900. Arguments:
  901. ReferenceDebug - Points to an array of AFD_REFERENCE_DEBUG structures.
  902. There are assumed to be MAX_REFERENCE entries in this array.
  903. ActualAddress - The actual address where the array resides on the
  904. debugee.
  905. Return Value:
  906. None.
  907. --*/
  908. {
  909. ULONG i;
  910. ULONG result;
  911. LPSTR fileName;
  912. CHAR filePath[MAX_PATH];
  913. CHAR action[16];
  914. dprintf(
  915. "AFD_REFERENCE_DEBUG @ %08lx\n",
  916. ActualAddress
  917. );
  918. for( i = 0 ; i < MAX_REFERENCE ; i++, ReferenceDebug++ ) {
  919. if( CheckControlC() ) {
  920. break;
  921. }
  922. if( ReferenceDebug->Info1 == NULL &&
  923. ReferenceDebug->Info2 == NULL &&
  924. ReferenceDebug->Action == 0 &&
  925. ReferenceDebug->NewCount == 0 ) {
  926. break;
  927. }
  928. if( ReferenceDebug->Action == 0 ||
  929. ReferenceDebug->Action == 1 ||
  930. ReferenceDebug->Action == (ULONG)-1L ) {
  931. sprintf(
  932. action,
  933. "%ld",
  934. ReferenceDebug->Action
  935. );
  936. } else {
  937. sprintf(
  938. action,
  939. "%08lx",
  940. ReferenceDebug->Action
  941. );
  942. }
  943. if( ReadMemory(
  944. (DWORD)ReferenceDebug->Info1,
  945. filePath,
  946. sizeof(filePath),
  947. &result
  948. ) ) {
  949. fileName = strrchr( filePath, '\\' );
  950. if( fileName != NULL ) {
  951. fileName++;
  952. } else {
  953. fileName = filePath;
  954. }
  955. } else {
  956. sprintf(
  957. filePath,
  958. "%08lx",
  959. ReferenceDebug->Info1
  960. );
  961. fileName = filePath;
  962. }
  963. dprintf(
  964. " %3lu: %s:%lu [%s] -> %ld\n",
  965. i,
  966. fileName,
  967. ReferenceDebug->Info2,
  968. action,
  969. ReferenceDebug->NewCount
  970. );
  971. }
  972. } // DumpAfdEndpointReferenceDebug
  973. #if GLOBAL_REFERENCE_DEBUG
  974. BOOL
  975. DumpAfdGlobalReferenceDebug(
  976. PAFD_GLOBAL_REFERENCE_DEBUG ReferenceDebug,
  977. DWORD ActualAddress,
  978. DWORD CurrentSlot,
  979. DWORD StartingSlot,
  980. DWORD NumEntries,
  981. DWORD CompareAddress
  982. )
  983. /*++
  984. Routine Description:
  985. Dumps the AFD_GLOBAL_REFERENCE_DEBUG structures.
  986. Arguments:
  987. ReferenceDebug - Points to an array of AFD_GLOBAL_REFERENCE_DEBUG
  988. structures. There are assumed to be MAX_GLOBAL_REFERENCE entries
  989. in this array.
  990. ActualAddress - The actual address where the array resides on the
  991. debugee.
  992. CurrentSlot - The last slot used.
  993. CompareAddress - If zero, then dump all records. Otherwise, only dump
  994. those records with a matching connection pointer.
  995. Return Value:
  996. None.
  997. --*/
  998. {
  999. ULONG result;
  1000. LPSTR fileName;
  1001. CHAR decoration;
  1002. CHAR filePath[MAX_PATH];
  1003. CHAR action[16];
  1004. BOOL foundEnd = FALSE;
  1005. ULONG lowTick;
  1006. if( StartingSlot == 0 ) {
  1007. dprintf(
  1008. "AFD_GLOBAL_REFERENCE_DEBUG @ %08lx, Current Slot = %lu\n",
  1009. ActualAddress,
  1010. CurrentSlot
  1011. );
  1012. }
  1013. for( ; NumEntries > 0 ; NumEntries--, StartingSlot++, ReferenceDebug++ ) {
  1014. if( CheckControlC() ) {
  1015. foundEnd = TRUE;
  1016. break;
  1017. }
  1018. if( ReferenceDebug->Info1 == NULL &&
  1019. ReferenceDebug->Info2 == NULL &&
  1020. ReferenceDebug->Action == 0 &&
  1021. ReferenceDebug->NewCount == 0 &&
  1022. ReferenceDebug->Connection == NULL ) {
  1023. foundEnd = TRUE;
  1024. break;
  1025. }
  1026. if( CompareAddress != 0 &&
  1027. ReferenceDebug->Connection != (PVOID)CompareAddress ) {
  1028. continue;
  1029. }
  1030. if( ReferenceDebug->Action == 0 ||
  1031. ReferenceDebug->Action == 1 ||
  1032. ReferenceDebug->Action == (ULONG)-1L ) {
  1033. sprintf(
  1034. action,
  1035. "%ld",
  1036. ReferenceDebug->Action
  1037. );
  1038. } else {
  1039. sprintf(
  1040. action,
  1041. "%08lx",
  1042. ReferenceDebug->Action
  1043. );
  1044. }
  1045. decoration = ( StartingSlot == CurrentSlot ) ? '>' : ' ';
  1046. lowTick = ReferenceDebug->TickCounter.LowPart;
  1047. switch( (DWORD)ReferenceDebug->Info1 ) {
  1048. case 0xafdafd02 :
  1049. dprintf(
  1050. "%c %3lu: %08lx (%8lu) Buffered Send, IRP @ %08lx [%s] -> %lu\n",
  1051. decoration,
  1052. StartingSlot,
  1053. ReferenceDebug->Connection,
  1054. lowTick,
  1055. ReferenceDebug->Info2,
  1056. action,
  1057. ReferenceDebug->NewCount
  1058. );
  1059. break;
  1060. case 0xafdafd03 :
  1061. dprintf(
  1062. "%c %3lu: %08lx (%8lu) Nonbuffered Send, IRP @ %08lx [%s] -> %lu\n",
  1063. decoration,
  1064. StartingSlot,
  1065. ReferenceDebug->Connection,
  1066. lowTick,
  1067. ReferenceDebug->Info2,
  1068. action,
  1069. ReferenceDebug->NewCount
  1070. );
  1071. break;
  1072. case 0xafd11100 :
  1073. case 0xafd11101 :
  1074. dprintf(
  1075. "%c %3lu: %08lx (%8lu) AfdRestartSend (%08lx), IRP @ %08lx [%s] -> %lu\n",
  1076. decoration,
  1077. StartingSlot,
  1078. ReferenceDebug->Connection,
  1079. lowTick,
  1080. ReferenceDebug->Info1,
  1081. ReferenceDebug->Info2,
  1082. action,
  1083. ReferenceDebug->NewCount
  1084. );
  1085. break;
  1086. case 0xafd11102 :
  1087. case 0xafd11103 :
  1088. case 0xafd11104 :
  1089. case 0xafd11105 :
  1090. dprintf(
  1091. "%c %3lu: %08lx (%8lu) AfdRestartBufferSend (%08lx), IRP @ %08lx [%s] -> %lu\n",
  1092. decoration,
  1093. StartingSlot,
  1094. ReferenceDebug->Connection,
  1095. lowTick,
  1096. ReferenceDebug->Info1,
  1097. ReferenceDebug->Info2,
  1098. action,
  1099. ReferenceDebug->NewCount
  1100. );
  1101. break;
  1102. case 0 :
  1103. if( ReferenceDebug->Info2 == NULL ) {
  1104. dprintf(
  1105. "%c %3lu: %08lx (%8lu) AfdDeleteConnectedReference (%08lx)\n",
  1106. decoration,
  1107. StartingSlot,
  1108. ReferenceDebug->Connection,
  1109. lowTick,
  1110. ReferenceDebug->Action
  1111. );
  1112. break;
  1113. } else {
  1114. //
  1115. // Fall through to default case.
  1116. //
  1117. }
  1118. default :
  1119. if( ReadMemory(
  1120. (DWORD)ReferenceDebug->Info1,
  1121. filePath,
  1122. sizeof(filePath),
  1123. &result
  1124. ) ) {
  1125. fileName = strrchr( filePath, '\\' );
  1126. if( fileName != NULL ) {
  1127. fileName++;
  1128. } else {
  1129. fileName = filePath;
  1130. }
  1131. } else {
  1132. sprintf(
  1133. filePath,
  1134. "%08lx",
  1135. ReferenceDebug->Info1
  1136. );
  1137. fileName = filePath;
  1138. }
  1139. dprintf(
  1140. "%c %3lu: %08lx (%8lu) %s:%lu [%s] -> %lu\n",
  1141. decoration,
  1142. StartingSlot,
  1143. ReferenceDebug->Connection,
  1144. lowTick,
  1145. fileName,
  1146. ReferenceDebug->Info2,
  1147. action,
  1148. ReferenceDebug->NewCount
  1149. );
  1150. break;
  1151. }
  1152. }
  1153. return foundEnd;
  1154. } // DumpAfdGlobalReferenceDebug
  1155. #endif
  1156. VOID
  1157. DumpAfdTransmitInfo(
  1158. PAFD_TRANSMIT_FILE_INFO_INTERNAL TransmitInfo,
  1159. DWORD ActualAddress
  1160. )
  1161. {
  1162. dprintf(
  1163. "AFD_TRANSMIT_FILE_INFO_INTERNAL @ %08lx\n",
  1164. ActualAddress
  1165. );
  1166. dprintf(
  1167. " Offset = %s\n",
  1168. LongLongToString( TransmitInfo->Offset )
  1169. );
  1170. dprintf(
  1171. " FileWriteLength = %s\n",
  1172. LongLongToString( TransmitInfo->FileWriteLength )
  1173. );
  1174. dprintf(
  1175. " SendPacketLength = %08lx\n",
  1176. TransmitInfo->SendPacketLength
  1177. );
  1178. dprintf(
  1179. " FileHandle = %08lx\n",
  1180. TransmitInfo->FileHandle
  1181. );
  1182. dprintf(
  1183. " Head = %08lx\n",
  1184. TransmitInfo->Head
  1185. );
  1186. dprintf(
  1187. " HeadLength = %08lx\n",
  1188. TransmitInfo->HeadLength
  1189. );
  1190. dprintf(
  1191. " Tail = %08lx\n",
  1192. TransmitInfo->Tail
  1193. );
  1194. dprintf(
  1195. " TailLength = %08lx\n",
  1196. TransmitInfo->TailLength
  1197. );
  1198. dprintf(
  1199. " Flags = %08lx\n",
  1200. TransmitInfo->Flags
  1201. );
  1202. dprintf(
  1203. " _Dummy = %08lx\n",
  1204. TransmitInfo->_Dummy
  1205. );
  1206. dprintf(
  1207. " TotalBytesToSend = %s\n",
  1208. LongLongToString( TransmitInfo->TotalBytesToSend )
  1209. );
  1210. dprintf(
  1211. " BytesRead = %s\n",
  1212. LongLongToString( TransmitInfo->BytesRead )
  1213. );
  1214. dprintf(
  1215. " BytesSent = %s\n",
  1216. LongLongToString( TransmitInfo->BytesSent )
  1217. );
  1218. dprintf(
  1219. " FileObject = %08lx\n",
  1220. TransmitInfo->FileObject
  1221. );
  1222. dprintf(
  1223. " DeviceObject = %08lx\n",
  1224. TransmitInfo->DeviceObject
  1225. );
  1226. dprintf(
  1227. " TdiFileObject = %08lx\n",
  1228. TransmitInfo->TdiFileObject
  1229. );
  1230. dprintf(
  1231. " TdiDeviceObject = %08lx\n",
  1232. TransmitInfo->TdiDeviceObject
  1233. );
  1234. dprintf(
  1235. " TransmitIrp = %08lx\n",
  1236. TransmitInfo->TransmitIrp
  1237. );
  1238. dprintf(
  1239. " Endpoint = %08lx\n",
  1240. TransmitInfo->Endpoint
  1241. );
  1242. dprintf(
  1243. " FileMdl = %08lx\n",
  1244. TransmitInfo->FileMdl
  1245. );
  1246. dprintf(
  1247. " HeadMdl = %08lx\n",
  1248. TransmitInfo->HeadMdl
  1249. );
  1250. dprintf(
  1251. " TailMdl = %08lx\n",
  1252. TransmitInfo->TailMdl
  1253. );
  1254. dprintf(
  1255. " FirstFileMdlAfterHead = %08lx\n",
  1256. TransmitInfo->FirstFileMdlAfterHead
  1257. );
  1258. dprintf(
  1259. " LastFileMdlBeforeTail = %08lx\n",
  1260. TransmitInfo->LastFileMdlBeforeTail
  1261. );
  1262. dprintf(
  1263. " IrpUsedTOSendTail = %08lx\n",
  1264. TransmitInfo->IrpUsedToSendTail
  1265. );
  1266. dprintf(
  1267. " FileMdlLength = %08lx\n",
  1268. TransmitInfo->FileMdlLength
  1269. );
  1270. dprintf(
  1271. " ReadPending = %s\n",
  1272. BooleanToString( TransmitInfo->ReadPending )
  1273. );
  1274. dprintf(
  1275. " CompletionPending = %s\n",
  1276. BooleanToString( TransmitInfo->CompletionPending )
  1277. );
  1278. dprintf(
  1279. " NeedToSendHead = %s\n",
  1280. BooleanToString( TransmitInfo->NeedToSendHead )
  1281. );
  1282. dprintf(
  1283. " Queued = %s\n",
  1284. BooleanToString( TransmitInfo->Queued )
  1285. );
  1286. dprintf(
  1287. " Read.Irp = %08lx%s\n",
  1288. TransmitInfo->Read.Irp,
  1289. IsTransmitIrpBusy( TransmitInfo->Read.Irp )
  1290. ? " (BUSY)"
  1291. : ""
  1292. );
  1293. dprintf(
  1294. " Read.AfdBuffer = %08lx\n",
  1295. TransmitInfo->Read.AfdBuffer
  1296. );
  1297. dprintf(
  1298. " Read.Length = %08lx\n",
  1299. TransmitInfo->Read.Length
  1300. );
  1301. dprintf(
  1302. " Send1.Irp = %08lx%s\n",
  1303. TransmitInfo->Send1.Irp,
  1304. IsTransmitIrpBusy( TransmitInfo->Send1.Irp )
  1305. ? " (BUSY)"
  1306. : ""
  1307. );
  1308. dprintf(
  1309. " Send1.AfdBuffer = %08lx\n",
  1310. TransmitInfo->Send1.AfdBuffer
  1311. );
  1312. dprintf(
  1313. " Send1.Length = %08lx\n",
  1314. TransmitInfo->Send1.Length
  1315. );
  1316. dprintf(
  1317. " Send2.Irp = %08lx%s\n",
  1318. TransmitInfo->Send2.Irp,
  1319. IsTransmitIrpBusy( TransmitInfo->Send2.Irp )
  1320. ? " (BUSY)"
  1321. : ""
  1322. );
  1323. dprintf(
  1324. " Send2.AfdBuffer = %08lx\n",
  1325. TransmitInfo->Send2.AfdBuffer
  1326. );
  1327. dprintf(
  1328. " Send2.Length = %08lx\n",
  1329. TransmitInfo->Send2.Length
  1330. );
  1331. dprintf( "\n" );
  1332. } // DumpAfdTransmitInfo
  1333. VOID
  1334. DumpAfdBuffer(
  1335. PAFD_BUFFER Buffer,
  1336. DWORD ActualAddress
  1337. )
  1338. {
  1339. dprintf(
  1340. "AFD_BUFFER @ %08lx\n",
  1341. ActualAddress
  1342. );
  1343. dprintf(
  1344. " BufferListHead = %08lx\n",
  1345. Buffer->BufferListHead
  1346. );
  1347. dprintf(
  1348. " NextBuffer = %08lx\n",
  1349. Buffer->NextBuffer
  1350. );
  1351. dprintf(
  1352. " Buffer = %08lx\n",
  1353. Buffer->Buffer
  1354. );
  1355. dprintf(
  1356. " BufferLength = %08lx\n",
  1357. Buffer->BufferLength
  1358. );
  1359. dprintf(
  1360. " DataLength = %08lx\n",
  1361. Buffer->DataLength
  1362. );
  1363. dprintf(
  1364. " DataOffset = %08lx\n",
  1365. Buffer->DataOffset
  1366. );
  1367. dprintf(
  1368. " Irp = %08lx\n",
  1369. Buffer->Irp
  1370. );
  1371. dprintf(
  1372. " Mdl = %08lx\n",
  1373. Buffer->Mdl
  1374. );
  1375. dprintf(
  1376. " Context = %08lx\n",
  1377. Buffer->Context
  1378. );
  1379. dprintf(
  1380. " SourceAddress = %08lx\n",
  1381. Buffer->SourceAddress
  1382. );
  1383. dprintf(
  1384. " SourceAddressLength = %08lx\n",
  1385. Buffer->SourceAddressLength
  1386. );
  1387. dprintf(
  1388. " FileObject = %08lx\n",
  1389. Buffer->FileObject
  1390. );
  1391. dprintf(
  1392. " AllocatedAddressLength = %04X\n",
  1393. Buffer->AllocatedAddressLength
  1394. );
  1395. dprintf(
  1396. " ExpeditedData = %s\n",
  1397. BooleanToString( Buffer->ExpeditedData )
  1398. );
  1399. dprintf(
  1400. " PartialMessage = %s\n",
  1401. BooleanToString( Buffer->PartialMessage )
  1402. );
  1403. #if DBG
  1404. if( IsCheckedAfd ) {
  1405. dprintf(
  1406. " TotalChainLength = %08lx\n",
  1407. Buffer->TotalChainLength
  1408. );
  1409. }
  1410. #endif
  1411. dprintf( "\n" );
  1412. } // DumpAfdBuffer
  1413. //
  1414. // Private functions.
  1415. //
  1416. PSTR
  1417. StructureTypeToString(
  1418. USHORT Type
  1419. )
  1420. /*++
  1421. Routine Description:
  1422. Maps an AFD structure type to a displayable string.
  1423. Arguments:
  1424. Type - The AFD structure type to map.
  1425. Return Value:
  1426. PSTR - Points to the displayable form of the structure type.
  1427. --*/
  1428. {
  1429. switch( Type ) {
  1430. case AfdBlockTypeEndpoint :
  1431. return "Endpoint";
  1432. case AfdBlockTypeVcConnecting :
  1433. return "VcConnecting";
  1434. case AfdBlockTypeVcListening :
  1435. return "VcListening";
  1436. case AfdBlockTypeDatagram :
  1437. return "Datagram";
  1438. case AfdBlockTypeConnection :
  1439. return "Connection";
  1440. #if !defined(NT351)
  1441. case AfdBlockTypeHelper :
  1442. return "Helper";
  1443. #endif
  1444. }
  1445. return "INVALID";
  1446. } // StructureTypeToString
  1447. PSTR
  1448. BooleanToString(
  1449. BOOLEAN Flag
  1450. )
  1451. /*++
  1452. Routine Description:
  1453. Maps a BOOELEAN to a displayable form.
  1454. Arguments:
  1455. Flag - The BOOLEAN to map.
  1456. Return Value:
  1457. PSTR - Points to the displayable form of the BOOLEAN.
  1458. --*/
  1459. {
  1460. return Flag ? "TRUE" : "FALSE";
  1461. } // BooleanToString
  1462. PSTR
  1463. EndpointStateToString(
  1464. UCHAR State
  1465. )
  1466. /*++
  1467. Routine Description:
  1468. Maps an AFD endpoint state to a displayable string.
  1469. Arguments:
  1470. State - The AFD endpoint state to map.
  1471. Return Value:
  1472. PSTR - Points to the displayable form of the AFD endpoint state.
  1473. --*/
  1474. {
  1475. switch( State ) {
  1476. case AfdEndpointStateOpen :
  1477. return "Open";
  1478. case AfdEndpointStateBound :
  1479. return "Bound";
  1480. case AfdEndpointStateListening :
  1481. return "Listening";
  1482. case AfdEndpointStateConnected :
  1483. return "Connected";
  1484. case AfdEndpointStateCleanup :
  1485. return "Cleanup";
  1486. case AfdEndpointStateClosing :
  1487. return "Closing";
  1488. case AfdEndpointStateTransmitClosing :
  1489. return "Transmit Closing";
  1490. #if !defined(NT351)
  1491. case AfdEndpointStateInvalid :
  1492. return "Invalid";
  1493. #endif
  1494. }
  1495. return "INVALID";
  1496. } // EndpointStateToString
  1497. PSTR
  1498. EndpointTypeToString(
  1499. AFD_ENDPOINT_TYPE Type
  1500. )
  1501. /*++
  1502. Routine Description:
  1503. Maps an AFD_ENDPOINT_TYPE to a displayable string.
  1504. Arguments:
  1505. Type - The AFD_ENDPOINT_TYPE to map.
  1506. Return Value:
  1507. PSTR - Points to the displayable form of the AFD_ENDPOINT_TYPE.
  1508. --*/
  1509. {
  1510. switch( Type ) {
  1511. case AfdEndpointTypeStream :
  1512. return "Stream";
  1513. case AfdEndpointTypeDatagram :
  1514. return "Datagram";
  1515. case AfdEndpointTypeRaw :
  1516. return "Raw";
  1517. case AfdEndpointTypeSequencedPacket :
  1518. return "SequencedPacket";
  1519. case AfdEndpointTypeReliableMessage :
  1520. return "ReliableMessage";
  1521. case AfdEndpointTypeUnknown :
  1522. return "Unknown";
  1523. }
  1524. return "INVALID";
  1525. } // EndpointTypeToString
  1526. PSTR
  1527. ConnectionStateToString(
  1528. USHORT State
  1529. )
  1530. /*++
  1531. Routine Description:
  1532. Maps an AFD connection state to a displayable string.
  1533. Arguments:
  1534. State - The AFD connection state to map.
  1535. Return Value:
  1536. PSTR - Points to the displayable form of the AFD connection state.
  1537. --*/
  1538. {
  1539. switch( State ) {
  1540. case AfdConnectionStateFree :
  1541. return "Free";
  1542. case AfdConnectionStateUnaccepted :
  1543. return "Unaccepted";
  1544. case AfdConnectionStateReturned :
  1545. return "Returned";
  1546. case AfdConnectionStateConnected :
  1547. return "Connected";
  1548. case AfdConnectionStateClosing :
  1549. return "Closing";
  1550. }
  1551. return "INVALID";
  1552. } // ConnectionStateToString
  1553. PSTR
  1554. SystemTimeToString(
  1555. LONGLONG Value
  1556. )
  1557. /*++
  1558. Routine Description:
  1559. Maps a LONGLONG representing system time to a displayable string.
  1560. Arguments:
  1561. Value - The LONGLONG time to map.
  1562. Return Value:
  1563. PSTR - Points to the displayable form of the system time.
  1564. Notes:
  1565. This routine is NOT multithread safe!
  1566. --*/
  1567. {
  1568. static char buffer[64];
  1569. NTSTATUS status;
  1570. LARGE_INTEGER systemTime;
  1571. LARGE_INTEGER localTime;
  1572. TIME_FIELDS timeFields;
  1573. systemTime.QuadPart = Value;
  1574. status = RtlSystemTimeToLocalTime( &systemTime, &localTime );
  1575. if( !NT_SUCCESS(status) ) {
  1576. return LongLongToString( Value );
  1577. }
  1578. RtlTimeToTimeFields( &localTime, &timeFields );
  1579. sprintf(
  1580. buffer,
  1581. "%s %s %2d %4d %02d:%02d:%02d.%03d",
  1582. WeekdayNames[timeFields.Weekday],
  1583. MonthNames[timeFields.Month],
  1584. timeFields.Day,
  1585. timeFields.Year,
  1586. timeFields.Hour,
  1587. timeFields.Minute,
  1588. timeFields.Second,
  1589. timeFields.Milliseconds
  1590. );
  1591. return buffer;
  1592. } // SystemTimeToString
  1593. BOOL
  1594. IsTransmitIrpBusy(
  1595. PIRP Irp
  1596. )
  1597. {
  1598. IRP localIrp;
  1599. ULONG result;
  1600. if( Irp == NULL ) {
  1601. return FALSE;
  1602. }
  1603. if( !ReadMemory(
  1604. (DWORD)Irp,
  1605. &localIrp,
  1606. sizeof(localIrp),
  1607. &result
  1608. ) ) {
  1609. return FALSE;
  1610. }
  1611. return localIrp.UserIosb != 0;
  1612. } // IsTransmitIrpBusy
  1613. PSTR
  1614. GroupTypeToString(
  1615. AFD_GROUP_TYPE GroupType
  1616. )
  1617. /*++
  1618. Routine Description:
  1619. Maps an AFD_GROUP_TYPE to a displayable string.
  1620. Arguments:
  1621. GroupType - The AFD_GROUP_TYPE to map.
  1622. Return Value:
  1623. PSTR - Points to the displayable form of the AFD_GROUP_TYPE.
  1624. --*/
  1625. {
  1626. switch( GroupType ) {
  1627. case GroupTypeNeither :
  1628. return "Neither";
  1629. case GroupTypeConstrained :
  1630. return "Constrained";
  1631. case GroupTypeUnconstrained :
  1632. return "Unconstrained";
  1633. }
  1634. return "INVALID";
  1635. } // GroupTypeToString