Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3218 lines
85 KiB

  1. /*++
  2. Copyright (c) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. dumpers.c
  5. Abstract:
  6. Dump routines for various structures.
  7. Author:
  8. Keith Moore (keithmo) 31-Jul-1998
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. //
  15. // Private constants.
  16. //
  17. #define MAX_NSGO_NAME_BUFFER 256
  18. #define MAX_URL_PREFIX_BUFFER 256
  19. #define MAX_RAW_VERB_BUFFER 16
  20. #define MAX_RAW_URL_BUFFER 256
  21. #define MAX_URL_BUFFER 256
  22. #define MAX_HEADER_BUFFER 256
  23. #define MAX_FILE_NAME_BUFFER 256
  24. //
  25. // Private prototypes.
  26. //
  27. BOOLEAN
  28. DumpUnknownHeadersCallback(
  29. IN PLIST_ENTRY RemoteListEntry,
  30. IN PVOID Context
  31. );
  32. BOOLEAN
  33. DumpUriEntryCallback(
  34. IN PLIST_ENTRY RemoteListEntry,
  35. IN PVOID Context
  36. );
  37. BOOLEAN
  38. DumpApoolCallback(
  39. IN PLIST_ENTRY RemoteListEntry,
  40. IN PVOID Context
  41. );
  42. #define ENDPOINT_GLOBAL_CALLBACK_CONTEXT_SIGNATURE ((ULONG) 'xGPE')
  43. typedef struct _ENDPOINT_GLOBAL_CALLBACK_CONTEXT
  44. {
  45. ULONG Signature;
  46. PSTR Prefix;
  47. ENDPOINT_CONNS Verbosity;
  48. } ENDPOINT_GLOBAL_CALLBACK_CONTEXT, *PENDPOINT_GLOBAL_CALLBACK_CONTEXT;
  49. BOOLEAN
  50. DumpEndpointCallback(
  51. IN PLIST_ENTRY RemoteListEntry,
  52. IN PVOID Context
  53. );
  54. BOOLEAN
  55. IrpListCallback(
  56. IN PLIST_ENTRY RemoteListEntry,
  57. IN PVOID Context
  58. );
  59. BOOLEAN
  60. ProcListCallback(
  61. IN PLIST_ENTRY RemoteListEntry,
  62. IN PVOID Context
  63. );
  64. BOOLEAN
  65. RequestListCallback(
  66. IN PLIST_ENTRY RemoteListEntry,
  67. IN PVOID Context
  68. );
  69. BOOLEAN
  70. DumpKQueueEntriesCallback(
  71. IN PLIST_ENTRY RemoteListEntry,
  72. IN PVOID Context
  73. );
  74. BOOLEAN
  75. FiltProcListCallback(
  76. IN PLIST_ENTRY RemoteListEntry,
  77. IN PVOID Context
  78. );
  79. BOOLEAN
  80. DumpUlActiveConnectionCallback(
  81. IN PLIST_ENTRY RemoteListEntry,
  82. IN PVOID Context
  83. );
  84. BOOLEAN
  85. DumpUlIdleConnectionCallback(
  86. IN PSINGLE_LIST_ENTRY RemoteSListEntry,
  87. IN PVOID Context
  88. );
  89. typedef struct _CONN_CALLBACK_CONTEXT
  90. {
  91. ULONG Signature;
  92. LONG Index;
  93. LONG SubIndex;
  94. ENDPOINT_CONNS Verbosity;
  95. PSTR Prefix;
  96. } CONN_CALLBACK_CONTEXT, *PCONN_CALLBACK_CONTEXT;
  97. #define CONN_CALLBACK_CONTEXT_SIGNATURE ((ULONG) 'xCcC')
  98. //
  99. // Private globals.
  100. //
  101. PSTR
  102. g_RequestHeaderIDs[] =
  103. {
  104. "CacheControl",
  105. "Connection",
  106. "Date",
  107. "KeepAlive",
  108. "Pragma",
  109. "Trailer",
  110. "TransferEncoding",
  111. "Upgrade",
  112. "Via",
  113. "Warning",
  114. "Allow",
  115. "ContentLength",
  116. "ContentType",
  117. "ContentEncoding",
  118. "ContentLanguage",
  119. "ContentLocation",
  120. "ContentMd5",
  121. "ContentRange",
  122. "Expires",
  123. "LastModified",
  124. "Accept",
  125. "AcceptCharset",
  126. "AcceptEncoding",
  127. "AcceptLanguage",
  128. "Authorization",
  129. "Cookie",
  130. "Expect",
  131. "From",
  132. "Host",
  133. "IfMatch",
  134. "IfModifiedSince",
  135. "IfNoneMatch",
  136. "IfRange",
  137. "IfUnmodifiedSince",
  138. "MaxForwards",
  139. "ProxyAuthorization",
  140. "Referer",
  141. "Range",
  142. "Te",
  143. "UserAgent"
  144. };
  145. PSTR
  146. g_ResponseHeaderIDs[] =
  147. {
  148. "CacheControl",
  149. "Connection",
  150. "Date",
  151. "KeepAlive",
  152. "Pragma",
  153. "Trailer",
  154. "TransferEncoding",
  155. "Upgrade",
  156. "Via",
  157. "Warning",
  158. "Allow",
  159. "ContentLength",
  160. "ContentType",
  161. "ContentEncoding",
  162. "ContentLanguage",
  163. "ContentLocation",
  164. "ContentMd5",
  165. "ContentRange",
  166. "Expires",
  167. "LastModified",
  168. "AcceptRanges",
  169. "Age",
  170. "Etag",
  171. "Location",
  172. "ProxyAuthenticate",
  173. "RetryAfter",
  174. "Server",
  175. "SetCookie",
  176. "Vary",
  177. "WwwAuthenticate"
  178. };
  179. VECTORMAP
  180. g_MdlFlagVector[] =
  181. {
  182. VECTORMAP_ENTRY( MDL_MAPPED_TO_SYSTEM_VA ),
  183. VECTORMAP_ENTRY( MDL_PAGES_LOCKED ),
  184. VECTORMAP_ENTRY( MDL_SOURCE_IS_NONPAGED_POOL),
  185. VECTORMAP_ENTRY( MDL_ALLOCATED_FIXED_SIZE ),
  186. VECTORMAP_ENTRY( MDL_PARTIAL ),
  187. VECTORMAP_ENTRY( MDL_PARTIAL_HAS_BEEN_MAPPED),
  188. VECTORMAP_ENTRY( MDL_IO_PAGE_READ ),
  189. VECTORMAP_ENTRY( MDL_WRITE_OPERATION ),
  190. VECTORMAP_ENTRY( MDL_PARENT_MAPPED_SYSTEM_VA),
  191. VECTORMAP_ENTRY( MDL_LOCK_HELD ),
  192. VECTORMAP_ENTRY( MDL_PHYSICAL_VIEW ),
  193. VECTORMAP_ENTRY( MDL_IO_SPACE ),
  194. VECTORMAP_ENTRY( MDL_NETWORK_HEADER ),
  195. VECTORMAP_ENTRY( MDL_MAPPING_CAN_FAIL ),
  196. VECTORMAP_ENTRY( MDL_ALLOCATED_MUST_SUCCEED ),
  197. VECTORMAP_END
  198. };
  199. //
  200. // Public functions.
  201. //
  202. // If you modify DumpUlConnection, you may need to modify DumpUlConnectionLite
  203. VOID
  204. DumpUlConnection(
  205. IN PSTR Prefix,
  206. IN PSTR CommandName,
  207. IN ULONG_PTR RemoteAddress,
  208. IN PUL_CONNECTION LocalConnection
  209. )
  210. {
  211. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  212. //
  213. // Dump it.
  214. //
  215. dprintf(
  216. "%s%sUL_CONNECTION @ %p\n"
  217. "%s Signature = %08lx (%s)\n"
  218. "%s ReferenceCount = %lu\n"
  219. "%s ConnectionFlags = %08lx\n"
  220. "%s AcceptPending = %ld\n"
  221. "%s AcceptComplete = %ld\n"
  222. "%s DisconnectPending = %ld\n"
  223. "%s DisconnectComplete = %ld\n"
  224. "%s AbortPending = %ld\n"
  225. "%s AbortComplete = %ld\n"
  226. "%s DisconnectIndicated = %ld\n"
  227. "%s AbortIndicated = %ld\n"
  228. "%s CleanupBegun = %ld\n"
  229. "%s FinalReferenceRemoved = %ld\n"
  230. #if REFERENCE_DEBUG
  231. "%s pTraceLog = %p\n"
  232. #endif // REFERENCE_DEBUG
  233. "%s IdleSListEntry @ %p (%p)\n"
  234. "%s ActiveListEntry @ %p (%p)\n"
  235. "%s ConnectionObject @ %p\n"
  236. "%s Handle = %p\n"
  237. "%s pFileObject = %p\n"
  238. "%s pDeviceObject = %p\n"
  239. "%s pConnectionContext = %p\n"
  240. "%s pOwningEndpoint = %p\n"
  241. "%s WorkItem @ %p\n"
  242. "%s LocalAddress = %x\n" // IPv6
  243. "%s LocalPort = %d\n"
  244. "%s RemoteAddress = %x\n" // IPv6
  245. "%s RemotePort = %d\n"
  246. "%s ConnectionId = %I64x\n"
  247. "%s pFilterChannel = %p\n"
  248. "%s ChannelEntry @ %p\n"
  249. "%s FilterConnState = %ld\n"
  250. "%s ConnectionDelivered = %ld\n"
  251. "\n",
  252. Prefix,
  253. CommandName,
  254. RemoteAddress,
  255. Prefix,
  256. LocalConnection->Signature,
  257. SignatureToString(
  258. LocalConnection->Signature,
  259. UL_CONNECTION_SIGNATURE,
  260. UL_CONNECTION_SIGNATURE_X,
  261. strSignature
  262. ),
  263. Prefix,
  264. LocalConnection->ReferenceCount,
  265. Prefix,
  266. LocalConnection->ConnectionFlags.Value,
  267. Prefix,
  268. LocalConnection->ConnectionFlags.AcceptPending,
  269. Prefix,
  270. LocalConnection->ConnectionFlags.AcceptComplete,
  271. Prefix,
  272. LocalConnection->ConnectionFlags.DisconnectPending,
  273. Prefix,
  274. LocalConnection->ConnectionFlags.DisconnectComplete,
  275. Prefix,
  276. LocalConnection->ConnectionFlags.AbortPending,
  277. Prefix,
  278. LocalConnection->ConnectionFlags.AbortComplete,
  279. Prefix,
  280. LocalConnection->ConnectionFlags.DisconnectIndicated,
  281. Prefix,
  282. LocalConnection->ConnectionFlags.AbortIndicated,
  283. Prefix,
  284. LocalConnection->ConnectionFlags.CleanupBegun,
  285. Prefix,
  286. LocalConnection->ConnectionFlags.FinalReferenceRemoved,
  287. #if REFERENCE_DEBUG
  288. Prefix,
  289. LocalConnection->pTraceLog,
  290. #endif // REFERENCE_DEBUG
  291. Prefix,
  292. REMOTE_OFFSET( RemoteAddress, UL_CONNECTION, IdleSListEntry ),
  293. LocalConnection->IdleSListEntry.Next,
  294. Prefix,
  295. REMOTE_OFFSET( RemoteAddress, UL_CONNECTION, ActiveListEntry ),
  296. LocalConnection->ActiveListEntry.Flink,
  297. Prefix,
  298. REMOTE_OFFSET( RemoteAddress, UL_CONNECTION, ConnectionObject ),
  299. Prefix,
  300. LocalConnection->ConnectionObject.Handle,
  301. Prefix,
  302. LocalConnection->ConnectionObject.pFileObject,
  303. Prefix,
  304. LocalConnection->ConnectionObject.pDeviceObject,
  305. Prefix,
  306. LocalConnection->pConnectionContext,
  307. Prefix,
  308. LocalConnection->pOwningEndpoint,
  309. Prefix,
  310. REMOTE_OFFSET( RemoteAddress, UL_CONNECTION, WorkItem ),
  311. Prefix,
  312. LocalConnection->LocalAddress,
  313. Prefix,
  314. LocalConnection->LocalPort,
  315. Prefix,
  316. LocalConnection->RemoteAddress,
  317. Prefix,
  318. LocalConnection->RemotePort,
  319. Prefix,
  320. LocalConnection->FilterInfo.ConnectionId,
  321. Prefix,
  322. LocalConnection->FilterInfo.pFilterChannel,
  323. Prefix,
  324. REMOTE_OFFSET( RemoteAddress, UL_CONNECTION, FilterInfo.ChannelEntry ),
  325. Prefix,
  326. (int) LocalConnection->FilterInfo.ConnState,
  327. Prefix,
  328. LocalConnection->FilterInfo.ConnectionDelivered
  329. );
  330. } // DumpUlConnection
  331. VOID
  332. DumpUlConnectionLite(
  333. IN PSTR Prefix,
  334. IN PSTR CommandName,
  335. IN ULONG_PTR RemoteAddress,
  336. IN PUL_CONNECTION LocalConnection
  337. )
  338. {
  339. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  340. //
  341. // Dump it.
  342. //
  343. dprintf(
  344. "%s%sUL_CONNECTION @ %p\n",
  345. Prefix,
  346. CommandName,
  347. RemoteAddress
  348. );
  349. if (LocalConnection->Signature != UL_CONNECTION_SIGNATURE)
  350. {
  351. dprintf(
  352. "%s Signature = %08lx (%s)\n",
  353. Prefix,
  354. LocalConnection->Signature,
  355. SignatureToString(
  356. LocalConnection->Signature,
  357. UL_CONNECTION_SIGNATURE,
  358. UL_CONNECTION_SIGNATURE_X,
  359. strSignature
  360. )
  361. );
  362. }
  363. dprintf(
  364. "%s ReferenceCount = %lu\n"
  365. "%s ConnectionFlags = %08lx\n",
  366. Prefix,
  367. LocalConnection->ReferenceCount,
  368. Prefix,
  369. LocalConnection->ConnectionFlags.Value
  370. );
  371. if (! HTTP_IS_NULL_ID(&LocalConnection->FilterInfo.ConnectionId))
  372. {
  373. dprintf(
  374. "%s ConnectionId = %I64x\n",
  375. Prefix,
  376. LocalConnection->FilterInfo.ConnectionId
  377. );
  378. }
  379. if (LocalConnection->ActiveListEntry.Flink != NULL)
  380. {
  381. dprintf(
  382. "%s ActiveListEntry @ %p (%p)\n",
  383. Prefix,
  384. REMOTE_OFFSET( RemoteAddress, UL_CONNECTION, ActiveListEntry ),
  385. LocalConnection->ActiveListEntry.Flink
  386. );
  387. }
  388. else
  389. {
  390. dprintf(
  391. "%s IdleSListEntry @ %p (%p)\n",
  392. Prefix,
  393. REMOTE_OFFSET( RemoteAddress, UL_CONNECTION, IdleSListEntry ),
  394. LocalConnection->IdleSListEntry.Next
  395. );
  396. }
  397. } // DumpUlConnectionLite
  398. VOID
  399. DumpHttpConnection(
  400. IN PSTR Prefix,
  401. IN PSTR CommandName,
  402. IN ULONG_PTR RemoteAddress,
  403. IN PUL_HTTP_CONNECTION LocalConnection
  404. )
  405. {
  406. CHAR resourceState[MAX_RESOURCE_STATE_LENGTH];
  407. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  408. //
  409. // Dump the easy parts.
  410. //
  411. dprintf(
  412. "%s%sUL_HTTP_CONNECTION @ %p\n"
  413. "%s Signature = %08lx (%s)\n"
  414. "%s ConnectionId = %I64x\n"
  415. "%s WorkItem @ %p\n"
  416. "%s RefCount = %lu\n"
  417. "%s NextRecvNumber = %lu\n"
  418. "%s NextBufferNumber = %lu\n"
  419. "%s NextBufferToParse = %lu\n"
  420. "%s pConnection = %p\n"
  421. "%s pRequest = %p\n"
  422. "%s Resource @ %p (%s)\n"
  423. "%s BufferHead @ %p%s\n"
  424. "%s BindingHead @ %p%s\n"
  425. "%s pCurrentBuffer = %p\n"
  426. "%s NeedMoreData = %lu\n"
  427. "%s UlconnDestroyed = %lu\n"
  428. "%s WaitingForResponse = %lu\n"
  429. "%s WaitForDisconnectHead @ %p\n"
  430. "%s DisconnectFlag = %s\n",
  431. Prefix,
  432. CommandName,
  433. RemoteAddress,
  434. Prefix,
  435. LocalConnection->Signature,
  436. SignatureToString(
  437. LocalConnection->Signature,
  438. UL_HTTP_CONNECTION_POOL_TAG,
  439. 0,
  440. strSignature
  441. ),
  442. Prefix,
  443. LocalConnection->ConnectionId,
  444. Prefix,
  445. REMOTE_OFFSET( RemoteAddress, UL_HTTP_CONNECTION, WorkItem ),
  446. Prefix,
  447. LocalConnection->RefCount,
  448. Prefix,
  449. LocalConnection->NextRecvNumber,
  450. Prefix,
  451. LocalConnection->NextBufferNumber,
  452. Prefix,
  453. LocalConnection->NextBufferToParse,
  454. Prefix,
  455. LocalConnection->pConnection,
  456. Prefix,
  457. LocalConnection->pRequest,
  458. Prefix,
  459. REMOTE_OFFSET( RemoteAddress, UL_HTTP_CONNECTION, Resource ),
  460. BuildResourceState( &LocalConnection->Resource, resourceState ),
  461. Prefix,
  462. REMOTE_OFFSET( RemoteAddress, UL_HTTP_CONNECTION, BufferHead ),
  463. IS_LIST_EMPTY(
  464. LocalConnection,
  465. RemoteAddress,
  466. UL_HTTP_CONNECTION,
  467. BufferHead,
  468. ) ? " (EMPTY)" : "",
  469. Prefix,
  470. REMOTE_OFFSET( RemoteAddress, UL_HTTP_CONNECTION, BindingHead ),
  471. IS_LIST_EMPTY(
  472. LocalConnection,
  473. RemoteAddress,
  474. UL_HTTP_CONNECTION,
  475. BindingHead,
  476. ) ? " (EMPTY)" : "",
  477. Prefix,
  478. LocalConnection->pCurrentBuffer,
  479. Prefix,
  480. LocalConnection->NeedMoreData,
  481. Prefix,
  482. LocalConnection->UlconnDestroyed,
  483. Prefix,
  484. LocalConnection->WaitingForResponse,
  485. Prefix,
  486. REMOTE_OFFSET( RemoteAddress, UL_HTTP_CONNECTION, WaitForDisconnectHead ),
  487. Prefix,
  488. LocalConnection->DisconnectFlag ? "TRUE" : "FALSE"
  489. );
  490. #if REFERENCE_DEBUG
  491. dprintf(
  492. "%s pTraceLog = %p\n",
  493. Prefix,
  494. LocalConnection->pTraceLog
  495. );
  496. #endif
  497. dprintf( "\n" );
  498. } // DumpHttpConnection
  499. VOID
  500. DumpHttpRequest(
  501. IN PSTR Prefix,
  502. IN PSTR CommandName,
  503. IN ULONG_PTR RemoteAddress,
  504. IN PUL_INTERNAL_REQUEST LocalRequest
  505. )
  506. {
  507. UCHAR rawVerbBuffer[MAX_RAW_VERB_BUFFER];
  508. UCHAR rawURLBuffer[MAX_RAW_URL_BUFFER];
  509. UCHAR urlBuffer[MAX_URL_BUFFER];
  510. CHAR resourceState[MAX_RESOURCE_STATE_LENGTH];
  511. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  512. ULONG i;
  513. //
  514. // Try to read the raw verb, raw url, and url buffers.
  515. //
  516. READ_REMOTE_STRING(
  517. rawVerbBuffer,
  518. sizeof(rawVerbBuffer),
  519. LocalRequest->pRawVerb,
  520. LocalRequest->RawVerbLength
  521. );
  522. READ_REMOTE_STRING(
  523. rawURLBuffer,
  524. sizeof(rawURLBuffer),
  525. LocalRequest->RawUrl.pUrl,
  526. LocalRequest->RawUrl.Length
  527. );
  528. READ_REMOTE_STRING(
  529. urlBuffer,
  530. sizeof(urlBuffer),
  531. LocalRequest->CookedUrl.pUrl,
  532. LocalRequest->CookedUrl.Length
  533. );
  534. //
  535. // Dump the easy parts.
  536. //
  537. dprintf(
  538. "%s%sHTTP_REQUEST @ %p\n"
  539. "%s Signature = %08lx (%s)\n"
  540. "%s RefCount = %lu\n"
  541. "%s RequestId = %I64x\n"
  542. "%s ConnectionId = %I64x\n"
  543. "%s pHttpConn = %p\n"
  544. "%s WorkItem @ %p\n"
  545. "%s AppPool.QueueState = %s\n"
  546. "%s AppPool.pProcess = %p\n"
  547. "%s AppPool.AppPoolEntry @ %p\n"
  548. "%s pConfigInfo = %p\n"
  549. "%s RecvNumber = %lu\n"
  550. "%s ParseState = %d (%s)\n"
  551. "%s ErrorCode = %lu\n"
  552. "%s TotalRequestSize = %lu\n"
  553. "%s UnknownHeaderCount = %lu\n"
  554. "%s Verb = %s\n",
  555. Prefix,
  556. CommandName,
  557. RemoteAddress,
  558. Prefix,
  559. LocalRequest->Signature,
  560. SignatureToString(
  561. LocalRequest->Signature,
  562. UL_INTERNAL_REQUEST_POOL_TAG,
  563. 0,
  564. strSignature
  565. ),
  566. Prefix,
  567. LocalRequest->RefCount,
  568. Prefix,
  569. LocalRequest->RequestId,
  570. Prefix,
  571. LocalRequest->ConnectionId,
  572. Prefix,
  573. LocalRequest->pHttpConn,
  574. Prefix,
  575. REMOTE_OFFSET( RemoteAddress, UL_INTERNAL_REQUEST, WorkItem ),
  576. Prefix,
  577. QueueStateToString( LocalRequest->AppPool.QueueState ),
  578. Prefix,
  579. LocalRequest->AppPool.pProcess,
  580. Prefix,
  581. REMOTE_OFFSET( RemoteAddress, UL_INTERNAL_REQUEST, AppPool.AppPoolEntry ),
  582. Prefix,
  583. &LocalRequest->ConfigInfo,
  584. Prefix,
  585. LocalRequest->RecvNumber,
  586. Prefix,
  587. LocalRequest->ParseState,
  588. ParseStateToString( LocalRequest->ParseState ),
  589. Prefix,
  590. LocalRequest->ErrorCode,
  591. Prefix,
  592. LocalRequest->TotalRequestSize,
  593. Prefix,
  594. LocalRequest->UnknownHeaderCount,
  595. Prefix,
  596. VerbToString( LocalRequest->Verb )
  597. );
  598. dprintf(
  599. "%s pRawVerb = %p (%s)\n"
  600. "%s RawVerbLength = %lu\n"
  601. "%s RawUrl.pUrl = %p (%s)\n"
  602. "%s RawUrl.pHost = %p\n"
  603. "%s RawUrl.pAbsPath = %p\n"
  604. "%s RawUrl.Length = %lu\n"
  605. "%s CookedUrl.pUrl = %p (%ws)\n"
  606. "%s CookedUrl.pHost = %p\n"
  607. "%s CookedUrl.pAbsPath = %p\n"
  608. "%s CookedUrl.pQueryString = %p\n"
  609. "%s CookedUrl.Length = %lu\n"
  610. "%s CookedUrl.Hash = %08lx\n"
  611. "%s Version = %s\n"
  612. "%s Headers @ %p\n"
  613. "%s UnknownHeaderList @ %p%s\n",
  614. Prefix,
  615. LocalRequest->pRawVerb,
  616. rawVerbBuffer,
  617. Prefix,
  618. LocalRequest->RawVerbLength,
  619. Prefix,
  620. LocalRequest->RawUrl.pUrl,
  621. rawURLBuffer,
  622. Prefix,
  623. LocalRequest->RawUrl.pHost,
  624. Prefix,
  625. LocalRequest->RawUrl.pAbsPath,
  626. Prefix,
  627. LocalRequest->RawUrl.Length,
  628. Prefix,
  629. LocalRequest->CookedUrl.pUrl,
  630. urlBuffer,
  631. Prefix,
  632. LocalRequest->CookedUrl.pHost,
  633. Prefix,
  634. LocalRequest->CookedUrl.pAbsPath,
  635. Prefix,
  636. LocalRequest->CookedUrl.pQueryString,
  637. Prefix,
  638. LocalRequest->CookedUrl.Length,
  639. Prefix,
  640. LocalRequest->CookedUrl.Hash,
  641. Prefix,
  642. VersionToString( LocalRequest->Version ),
  643. Prefix,
  644. REMOTE_OFFSET( RemoteAddress, UL_INTERNAL_REQUEST, Headers ),
  645. Prefix,
  646. REMOTE_OFFSET( RemoteAddress, UL_INTERNAL_REQUEST, UnknownHeaderList ),
  647. IS_LIST_EMPTY(
  648. LocalRequest,
  649. RemoteAddress,
  650. UL_INTERNAL_REQUEST,
  651. UnknownHeaderList
  652. ) ? " (EMPTY)" : ""
  653. );
  654. dprintf(
  655. "%s ContentLength = %I64u\n"
  656. "%s ChunkBytesToParse = %I64u\n"
  657. "%s ChunkBytesParsed = %I64u\n"
  658. "%s ChunkBytesToRead = %I64u\n"
  659. "%s ChunkBytesRead = %I64u\n"
  660. "%s Chunked = %lu\n"
  661. "%s ParsedFirstChunk = %lu\n"
  662. "%s SentResponse = %lu\n"
  663. "%s SentLast = %lu\n"
  664. "%s pHeaderBuffer = %p\n"
  665. "%s pLastHeaderBuffer = %p\n"
  666. "%s IrpHead @ %p%s\n"
  667. "%s pChunkBuffer = %p\n"
  668. "%s pChunkLocation = %p\n",
  669. Prefix,
  670. LocalRequest->ContentLength,
  671. Prefix,
  672. LocalRequest->ChunkBytesToParse,
  673. Prefix,
  674. LocalRequest->ChunkBytesParsed,
  675. Prefix,
  676. LocalRequest->ChunkBytesToRead,
  677. Prefix,
  678. LocalRequest->ChunkBytesRead,
  679. Prefix,
  680. LocalRequest->Chunked,
  681. Prefix,
  682. LocalRequest->ParsedFirstChunk,
  683. Prefix,
  684. LocalRequest->SentResponse,
  685. Prefix,
  686. LocalRequest->SentLast,
  687. Prefix,
  688. LocalRequest->pHeaderBuffer,
  689. Prefix,
  690. LocalRequest->pLastHeaderBuffer,
  691. Prefix,
  692. REMOTE_OFFSET( RemoteAddress, UL_INTERNAL_REQUEST, IrpHead ),
  693. IS_LIST_EMPTY(
  694. LocalRequest,
  695. RemoteAddress,
  696. UL_INTERNAL_REQUEST,
  697. IrpHead
  698. ) ? " (EMPTY)" : "",
  699. Prefix,
  700. LocalRequest->pChunkBuffer,
  701. Prefix,
  702. LocalRequest->pChunkLocation
  703. );
  704. #if REFERENCE_DEBUG
  705. dprintf(
  706. "%s pTraceLog = %p\n",
  707. Prefix,
  708. LocalRequest->pTraceLog
  709. );
  710. #endif
  711. //
  712. // Dump the known headers.
  713. //
  714. for (i = 0 ; i < HttpHeaderRequestMaximum ; i++)
  715. {
  716. if (LocalRequest->HeaderValid[i])
  717. {
  718. DumpHttpHeader(
  719. Prefix,
  720. "",
  721. (ULONG_PTR)REMOTE_OFFSET( RemoteAddress, UL_INTERNAL_REQUEST, Headers[i] ),
  722. &LocalRequest->Headers[i],
  723. i,
  724. g_RequestHeaderIDs
  725. );
  726. }
  727. }
  728. //
  729. // Dump the unknown headers.
  730. //
  731. EnumLinkedList(
  732. (PLIST_ENTRY)REMOTE_OFFSET( RemoteAddress, UL_INTERNAL_REQUEST, UnknownHeaderList ),
  733. &DumpUnknownHeadersCallback,
  734. Prefix
  735. );
  736. } // DumpHttpRequest
  737. VOID
  738. DumpHttpResponse(
  739. IN PSTR Prefix,
  740. IN PSTR CommandName,
  741. IN ULONG_PTR RemoteAddress,
  742. IN PUL_INTERNAL_RESPONSE LocalResponse
  743. )
  744. {
  745. ULONG i;
  746. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  747. //
  748. // Dump the easy parts.
  749. //
  750. dprintf(
  751. "%s%sUL_INTERNAL_RESPONSE @ %p\n"
  752. "%s Signature = %08lx (%s)\n"
  753. "%s ReferenceCount = %d\n"
  754. "%s CompleteIrpEarly = %d\n"
  755. "%s ContentLengthSpecified = %d\n"
  756. "%s ChunkedSpecified = %d\n"
  757. "%s StatusCode = %lu\n"
  758. "%s Verb = %s\n"
  759. "%s HeaderLength = %u\n"
  760. "%s pHeaders = %p\n"
  761. "%s AuxBufferLength = %u\n"
  762. "%s pAuxiliaryBuffer = %p\n"
  763. "%s MaxFileSystemStackSize = %d\n"
  764. "%s ResponseLength = %I64u\n"
  765. "%s ChunkCount = %d\n"
  766. "\n",
  767. Prefix,
  768. CommandName,
  769. RemoteAddress,
  770. Prefix,
  771. LocalResponse->Signature,
  772. SignatureToString(
  773. LocalResponse->Signature,
  774. UL_INTERNAL_RESPONSE_POOL_TAG,
  775. MAKE_FREE_TAG( UL_INTERNAL_RESPONSE_POOL_TAG ),
  776. strSignature
  777. ),
  778. Prefix,
  779. LocalResponse->ReferenceCount,
  780. Prefix,
  781. LocalResponse->CompleteIrpEarly,
  782. Prefix,
  783. LocalResponse->ContentLengthSpecified,
  784. Prefix,
  785. LocalResponse->ChunkedSpecified,
  786. Prefix,
  787. (ULONG)LocalResponse->StatusCode,
  788. Prefix,
  789. VerbToString( LocalResponse->Verb ),
  790. Prefix,
  791. LocalResponse->HeaderLength,
  792. Prefix,
  793. LocalResponse->pHeaders,
  794. Prefix,
  795. LocalResponse->AuxBufferLength,
  796. Prefix,
  797. LocalResponse->pAuxiliaryBuffer,
  798. Prefix,
  799. LocalResponse->MaxFileSystemStackSize,
  800. Prefix,
  801. LocalResponse->ResponseLength,
  802. Prefix,
  803. LocalResponse->ChunkCount
  804. );
  805. //
  806. // Dump the chunks
  807. //
  808. for (i = 0; i < LocalResponse->ChunkCount; i++) {
  809. UL_INTERNAL_DATA_CHUNK chunk;
  810. ULONG_PTR address;
  811. ULONG result;
  812. address = (ULONG_PTR)REMOTE_OFFSET(
  813. RemoteAddress,
  814. UL_INTERNAL_RESPONSE,
  815. pDataChunks
  816. ) + (i * sizeof(UL_INTERNAL_DATA_CHUNK));
  817. if (!ReadMemory(
  818. address,
  819. &chunk,
  820. sizeof(chunk),
  821. &result
  822. ))
  823. {
  824. dprintf(
  825. "%s: cannot read UL_INTERNAL_DATA_CHUNK @ %p\n",
  826. CommandName,
  827. address
  828. );
  829. break;
  830. }
  831. DumpDataChunk(
  832. " ",
  833. CommandName,
  834. address,
  835. &chunk
  836. );
  837. }
  838. } // DumpHttpResponse
  839. VOID
  840. DumpDataChunk(
  841. IN PSTR Prefix,
  842. IN PSTR CommandName,
  843. IN ULONG_PTR RemoteAddress,
  844. IN PUL_INTERNAL_DATA_CHUNK Chunk
  845. )
  846. {
  847. dprintf("%s%sUL_INTERNAL_DATA_CHUNK @ %p\n", Prefix, CommandName, RemoteAddress);
  848. switch (Chunk->ChunkType) {
  849. case HttpDataChunkFromMemory:
  850. dprintf(
  851. "%s ChunkType = HttpDataChunkFromMemory\n"
  852. "%s pMdl = %p\n"
  853. "%s pCopiedBuffer = %p\n"
  854. "%s pUserBuffer = %p\n"
  855. "%s BufferLength = %u\n",
  856. Prefix,
  857. Prefix,
  858. Chunk->FromMemory.pMdl,
  859. Prefix,
  860. Chunk->FromMemory.pCopiedBuffer,
  861. Prefix,
  862. Chunk->FromMemory.pUserBuffer,
  863. Prefix,
  864. Chunk->FromMemory.BufferLength
  865. );
  866. break;
  867. case HttpDataChunkFromFileName:
  868. dprintf(
  869. "%s ChunkType = HttpDataChunkFromFileName\n"
  870. "%s ByteRange = [offset %I64d, len %I64d]\n"
  871. "%s FileName = %ws\n"
  872. "%s pFileCacheEntry = %p\n",
  873. Prefix,
  874. Prefix,
  875. Chunk->FromFile.ByteRange.StartingOffset.QuadPart,
  876. Chunk->FromFile.ByteRange.Length.QuadPart,
  877. Prefix,
  878. Chunk->FromFile.FileName.Buffer,
  879. Prefix,
  880. Chunk->FromFile.pFileCacheEntry
  881. );
  882. break;
  883. case HttpDataChunkFromFileHandle:
  884. dprintf(
  885. "%s ChunkType = HttpDataChunkFromFileHandle\n"
  886. "%s ByteRange = [offset %I64d, len %I64d]\n"
  887. "%s FileHandle = %p\n"
  888. "%s pFileCacheEntry = %p\n",
  889. Prefix,
  890. Prefix,
  891. Chunk->FromFile.ByteRange.StartingOffset.QuadPart,
  892. Chunk->FromFile.ByteRange.Length.QuadPart,
  893. Prefix,
  894. Chunk->FromFile.FileHandle,
  895. Prefix,
  896. Chunk->FromFile.pFileCacheEntry
  897. );
  898. break;
  899. default:
  900. dprintf(
  901. "%s ChunkType = <Invalid>\n",
  902. Prefix
  903. );
  904. break;
  905. }
  906. } // DumpDataChunk
  907. VOID
  908. DumpReceiveBuffer(
  909. IN PSTR Prefix,
  910. IN PSTR CommandName,
  911. IN ULONG_PTR RemoteAddress,
  912. IN PUL_RECEIVE_BUFFER LocalBuffer
  913. )
  914. {
  915. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  916. dprintf(
  917. "%s%sUL_RECEIVE_BUFFER @ %p\n"
  918. "%s LookasideEntry @ %p\n"
  919. "%s Signature = %08lx (%s)\n"
  920. "%s pIrp = %p\n"
  921. "%s pMdl = %p\n"
  922. "%s pPartialMdl = %p\n"
  923. "%s pDataArea = %p\n"
  924. "%s pConnection = %p\n"
  925. "\n",
  926. Prefix,
  927. CommandName,
  928. RemoteAddress,
  929. Prefix,
  930. REMOTE_OFFSET( RemoteAddress, UL_RECEIVE_BUFFER, LookasideEntry ),
  931. Prefix,
  932. LocalBuffer->Signature,
  933. SignatureToString(
  934. LocalBuffer->Signature,
  935. UL_RECEIVE_BUFFER_SIGNATURE,
  936. UL_RECEIVE_BUFFER_SIGNATURE_X,
  937. strSignature
  938. ),
  939. Prefix,
  940. LocalBuffer->pIrp,
  941. Prefix,
  942. LocalBuffer->pMdl,
  943. Prefix,
  944. LocalBuffer->pPartialMdl,
  945. Prefix,
  946. LocalBuffer->pDataArea,
  947. Prefix,
  948. LocalBuffer->pConnectionContext
  949. );
  950. } // DumpReceiveBuffer
  951. VOID
  952. DumpRequestBuffer(
  953. IN PSTR Prefix,
  954. IN PSTR CommandName,
  955. IN ULONG_PTR RemoteAddress,
  956. IN PUL_REQUEST_BUFFER LocalBuffer
  957. )
  958. {
  959. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  960. dprintf(
  961. "%s%sUL_REQUEST_BUFFER @ %p\n"
  962. "%s Signature = %08lx (%s)\n"
  963. "%s ListEntry @ %p\n"
  964. "%s pConnection = %p\n"
  965. "%s WorkItem @ %p\n"
  966. "%s UsedBytes = %lu\n"
  967. "%s AllocBytes = %lu\n"
  968. "%s ParsedBytes = %lu\n"
  969. "%s BufferNumber = %lu\n"
  970. "%s JumboBuffer = %lu\n"
  971. "%s pBuffer @ %p\n"
  972. "\n",
  973. Prefix,
  974. CommandName,
  975. RemoteAddress,
  976. Prefix,
  977. LocalBuffer->Signature,
  978. SignatureToString(
  979. LocalBuffer->Signature,
  980. UL_REQUEST_BUFFER_POOL_TAG,
  981. MAKE_FREE_TAG( UL_REQUEST_BUFFER_POOL_TAG ),
  982. strSignature
  983. ),
  984. Prefix,
  985. REMOTE_OFFSET( RemoteAddress, UL_REQUEST_BUFFER, ListEntry ),
  986. Prefix,
  987. LocalBuffer->pConnection,
  988. Prefix,
  989. REMOTE_OFFSET( RemoteAddress, UL_REQUEST_BUFFER, WorkItem ),
  990. Prefix,
  991. LocalBuffer->UsedBytes,
  992. Prefix,
  993. LocalBuffer->AllocBytes,
  994. Prefix,
  995. LocalBuffer->ParsedBytes,
  996. Prefix,
  997. LocalBuffer->BufferNumber,
  998. Prefix,
  999. LocalBuffer->JumboBuffer,
  1000. Prefix,
  1001. REMOTE_OFFSET( RemoteAddress, UL_REQUEST_BUFFER, pBuffer )
  1002. );
  1003. } // DumpRequestBuffer
  1004. VOID
  1005. DumpUlEndpoint(
  1006. IN PSTR Prefix,
  1007. IN PSTR CommandName,
  1008. IN ULONG_PTR RemoteAddress,
  1009. IN PUL_ENDPOINT LocalEndpoint,
  1010. IN ENDPOINT_CONNS Verbosity
  1011. )
  1012. {
  1013. PTRANSPORT_ADDRESS pTransportAddress;
  1014. UCHAR addressBuffer[MAX_TRANSPORT_ADDRESS_LENGTH];
  1015. CHAR connectionRequestSymbol[MAX_SYMBOL_LENGTH];
  1016. CHAR connectionCompleteSymbol[MAX_SYMBOL_LENGTH];
  1017. CHAR connectionDisconnectSymbol[MAX_SYMBOL_LENGTH];
  1018. CHAR connectionDestroyedSymbol[MAX_SYMBOL_LENGTH];
  1019. CHAR dataReceiveSymbol[MAX_SYMBOL_LENGTH];
  1020. CHAR tmpSymbol[MAX_SYMBOL_LENGTH];
  1021. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  1022. ULONG offset;
  1023. ULONG result;
  1024. BOOLEAN NoActiveConns;
  1025. int i;
  1026. //
  1027. // Read the local address if it fits into our stack buffer.
  1028. //
  1029. pTransportAddress = NULL;
  1030. if (LocalEndpoint->LocalAddressLength <= sizeof(addressBuffer))
  1031. {
  1032. if (ReadMemory(
  1033. (ULONG_PTR)LocalEndpoint->pLocalAddress,
  1034. addressBuffer,
  1035. LocalEndpoint->LocalAddressLength,
  1036. &result
  1037. ))
  1038. {
  1039. pTransportAddress = (PTRANSPORT_ADDRESS)addressBuffer;
  1040. }
  1041. }
  1042. //
  1043. // Try to resolve the callback symbols.
  1044. //
  1045. BuildSymbol(
  1046. LocalEndpoint->pConnectionRequestHandler,
  1047. connectionRequestSymbol
  1048. );
  1049. BuildSymbol(
  1050. LocalEndpoint->pConnectionCompleteHandler,
  1051. connectionCompleteSymbol
  1052. );
  1053. BuildSymbol(
  1054. LocalEndpoint->pConnectionDisconnectHandler,
  1055. connectionDisconnectSymbol
  1056. );
  1057. BuildSymbol(
  1058. LocalEndpoint->pConnectionDestroyedHandler,
  1059. connectionDestroyedSymbol
  1060. );
  1061. BuildSymbol(
  1062. LocalEndpoint->pDataReceiveHandler,
  1063. dataReceiveSymbol
  1064. );
  1065. NoActiveConns = TRUE;
  1066. for (i = 0; i < DEFAULT_MAX_CONNECTION_ACTIVE_LISTS; ++i)
  1067. {
  1068. NoActiveConns &= IS_LIST_EMPTY(
  1069. LocalEndpoint,
  1070. RemoteAddress,
  1071. UL_ENDPOINT,
  1072. ActiveConnectionListHead[i]
  1073. );
  1074. }
  1075. //
  1076. // Dump it.
  1077. //
  1078. dprintf(
  1079. "%s%sUL_ENDPOINT @ %p\n"
  1080. "%s Signature = %08lx (%s)\n"
  1081. "%s ReferenceCount = %ld\n"
  1082. "%s UsageCount = %ld\n"
  1083. "%s GlobalEndpointListEntry @ %p%s\n"
  1084. "%s IdleConnectionSListHead @ %p (%hd entries)\n"
  1085. "%s ActiveConnectionListHead @ %p%s\n"
  1086. "%s EndpointSpinLock @ %p (%s)\n"
  1087. "%s AddressObject @ %p\n"
  1088. "%s Handle = %p\n"
  1089. "%s pFileObject = %p\n"
  1090. "%s pDeviceObject = %p\n",
  1091. Prefix,
  1092. CommandName,
  1093. RemoteAddress,
  1094. Prefix,
  1095. LocalEndpoint->Signature,
  1096. SignatureToString(
  1097. LocalEndpoint->Signature,
  1098. UL_ENDPOINT_SIGNATURE,
  1099. UL_ENDPOINT_SIGNATURE_X,
  1100. strSignature
  1101. ),
  1102. Prefix,
  1103. LocalEndpoint->ReferenceCount,
  1104. Prefix,
  1105. LocalEndpoint->UsageCount,
  1106. Prefix,
  1107. REMOTE_OFFSET( RemoteAddress, UL_ENDPOINT, GlobalEndpointListEntry ),
  1108. LocalEndpoint->GlobalEndpointListEntry.Flink == NULL
  1109. ? " (DISCONNECTED)"
  1110. : "",
  1111. Prefix,
  1112. REMOTE_OFFSET( RemoteAddress, UL_ENDPOINT, IdleConnectionSListHead ),
  1113. SLIST_HEADER_DEPTH(&LocalEndpoint->IdleConnectionSListHead),
  1114. Prefix,
  1115. REMOTE_OFFSET( RemoteAddress, UL_ENDPOINT, ActiveConnectionListHead ),
  1116. NoActiveConns ? " (EMPTY)" : "",
  1117. Prefix,
  1118. REMOTE_OFFSET( RemoteAddress, UL_ENDPOINT, EndpointSpinLock ),
  1119. GetSpinlockState( &LocalEndpoint->EndpointSpinLock ),
  1120. Prefix,
  1121. REMOTE_OFFSET( RemoteAddress, UL_ENDPOINT, AddressObject ),
  1122. Prefix,
  1123. LocalEndpoint->AddressObject.Handle,
  1124. Prefix,
  1125. LocalEndpoint->AddressObject.pFileObject,
  1126. Prefix,
  1127. LocalEndpoint->AddressObject.pDeviceObject
  1128. );
  1129. dprintf(
  1130. "%s pConnectionRequestHandler = %p %s\n"
  1131. "%s pConnectionCompleteHandler = %p %s\n"
  1132. "%s pConnectionDisconnectHandler = %p %s\n"
  1133. "%s pConnectionDestroyedHandler = %p %s\n"
  1134. "%s pDataReceiveHandler = %p %s\n"
  1135. "%s pListeningContext = %p\n"
  1136. "%s pLocalAddress = %p\n"
  1137. "%s LocalAddressLength = %lu\n",
  1138. Prefix,
  1139. LocalEndpoint->pConnectionRequestHandler,
  1140. connectionRequestSymbol,
  1141. Prefix,
  1142. LocalEndpoint->pConnectionCompleteHandler,
  1143. connectionCompleteSymbol,
  1144. Prefix,
  1145. LocalEndpoint->pConnectionDisconnectHandler,
  1146. connectionDisconnectSymbol,
  1147. Prefix,
  1148. LocalEndpoint->pConnectionDestroyedHandler,
  1149. connectionDestroyedSymbol,
  1150. Prefix,
  1151. LocalEndpoint->pDataReceiveHandler,
  1152. dataReceiveSymbol,
  1153. Prefix,
  1154. LocalEndpoint->pListeningContext,
  1155. Prefix,
  1156. LocalEndpoint->pLocalAddress,
  1157. Prefix,
  1158. LocalEndpoint->LocalAddressLength
  1159. );
  1160. if (pTransportAddress != NULL)
  1161. {
  1162. CHAR newPrefix[256];
  1163. sprintf( newPrefix, "%s ", Prefix );
  1164. DumpTransportAddress(
  1165. newPrefix,
  1166. pTransportAddress,
  1167. (ULONG_PTR)LocalEndpoint->pLocalAddress
  1168. );
  1169. }
  1170. dprintf(
  1171. #if ENABLE_OWNER_REF_TRACE
  1172. "%s pOwnerRefTraceLog = %p\n"
  1173. #endif
  1174. "%s WorkItem @ %p\n"
  1175. "%s EndpointSynch @ %p\n"
  1176. "%s ReplenishScheduled = %d\n"
  1177. "%s IdleConnections = %d\n"
  1178. "\n",
  1179. #if ENABLE_OWNER_REF_TRACE
  1180. Prefix,
  1181. LocalEndpoint->pOwnerRefTraceLog,
  1182. #endif
  1183. Prefix,
  1184. REMOTE_OFFSET( RemoteAddress, UL_ENDPOINT, WorkItem ),
  1185. Prefix,
  1186. REMOTE_OFFSET( RemoteAddress, UL_ENDPOINT, EndpointSynch ),
  1187. Prefix,
  1188. LocalEndpoint->EndpointSynch.ReplenishScheduled,
  1189. Prefix,
  1190. LocalEndpoint->EndpointSynch.IdleConnections
  1191. );
  1192. if (Verbosity != ENDPOINT_NO_CONNS)
  1193. {
  1194. CONN_CALLBACK_CONTEXT ConnContext;
  1195. ConnContext.Signature = CONN_CALLBACK_CONTEXT_SIGNATURE;
  1196. ConnContext.Index = 0;
  1197. ConnContext.SubIndex = 0;
  1198. ConnContext.Verbosity = Verbosity;
  1199. ConnContext.Prefix = "";
  1200. if (! NoActiveConns)
  1201. {
  1202. dprintf(
  1203. "\n"
  1204. "%s Active Connections\n",
  1205. Prefix);
  1206. for (i = 0; i < DEFAULT_MAX_CONNECTION_ACTIVE_LISTS; ++i)
  1207. {
  1208. if (! IS_LIST_EMPTY(LocalEndpoint,
  1209. RemoteAddress,
  1210. UL_ENDPOINT,
  1211. ActiveConnectionListHead[i]))
  1212. {
  1213. CHAR newPrefix[256];
  1214. sprintf( newPrefix, "%s %2d ", Prefix, i );
  1215. dprintf(
  1216. "\n"
  1217. "%s Active Connections[%d]\n",
  1218. Prefix);
  1219. ConnContext.Index = i;
  1220. ConnContext.SubIndex = 0;
  1221. ConnContext.Prefix = newPrefix;
  1222. EnumLinkedList(
  1223. (PLIST_ENTRY) REMOTE_OFFSET(RemoteAddress, UL_ENDPOINT,
  1224. ActiveConnectionListHead[i]),
  1225. &DumpUlActiveConnectionCallback,
  1226. &ConnContext
  1227. );
  1228. }
  1229. }
  1230. }
  1231. if (SLIST_HEADER_NEXT(&LocalEndpoint->IdleConnectionSListHead) != NULL)
  1232. {
  1233. dprintf(
  1234. "\n"
  1235. "%s Idle Connections, slist depth = %hd\n",
  1236. Prefix,
  1237. SLIST_HEADER_DEPTH(&LocalEndpoint->IdleConnectionSListHead)
  1238. );
  1239. ConnContext.Index = 0;
  1240. ConnContext.SubIndex = 0;
  1241. ConnContext.Prefix = Prefix;
  1242. EnumSList(
  1243. (PSLIST_HEADER) REMOTE_OFFSET(RemoteAddress, UL_ENDPOINT,
  1244. IdleConnectionSListHead),
  1245. &DumpUlIdleConnectionCallback,
  1246. &ConnContext
  1247. );
  1248. }
  1249. }
  1250. #ifdef _WIN64
  1251. else
  1252. {
  1253. dprintf("\n"
  1254. " Cannot enumerate Idle Connections SList on Win64 :-(\n");
  1255. }
  1256. #endif // _WIN64
  1257. } // DumpUlEndpoint
  1258. VOID
  1259. DumpAllEndpoints(
  1260. IN ENDPOINT_CONNS Verbosity
  1261. )
  1262. {
  1263. ULONG_PTR address = GetExpression("&http!g_TdiEndpointListHead");
  1264. ENDPOINT_GLOBAL_CALLBACK_CONTEXT Context;
  1265. if (!address) {
  1266. dprintf(
  1267. "!endp *: cannot find symbol for http!g_TdiEndpointListHead\n"
  1268. );
  1269. return;
  1270. }
  1271. Context.Signature = ENDPOINT_GLOBAL_CALLBACK_CONTEXT_SIGNATURE ;
  1272. Context.Verbosity = Verbosity;
  1273. Context.Prefix = "";
  1274. EnumLinkedList(
  1275. (PLIST_ENTRY) address,
  1276. &DumpEndpointCallback,
  1277. &Context
  1278. );
  1279. }
  1280. VOID
  1281. DumpUlRequest(
  1282. IN PSTR Prefix,
  1283. IN PSTR CommandName,
  1284. IN ULONG_PTR RemoteAddress,
  1285. IN PHTTP_REQUEST LocalRequest
  1286. )
  1287. {
  1288. UCHAR rawVerbBuffer[MAX_RAW_VERB_BUFFER];
  1289. UCHAR rawURLBuffer[MAX_RAW_URL_BUFFER];
  1290. UCHAR urlBuffer[MAX_URL_BUFFER];
  1291. //
  1292. // Try to read the raw verb, raw url, and url buffers.
  1293. //
  1294. READ_REMOTE_STRING(
  1295. rawVerbBuffer,
  1296. sizeof(rawVerbBuffer),
  1297. LocalRequest->pUnknownVerb,
  1298. LocalRequest->UnknownVerbLength
  1299. );
  1300. READ_REMOTE_STRING(
  1301. rawURLBuffer,
  1302. sizeof(rawURLBuffer),
  1303. LocalRequest->pRawUrl,
  1304. LocalRequest->RawUrlLength
  1305. );
  1306. READ_REMOTE_STRING(
  1307. urlBuffer,
  1308. sizeof(urlBuffer),
  1309. LocalRequest->CookedUrl.pFullUrl,
  1310. LocalRequest->CookedUrl.FullUrlLength
  1311. );
  1312. //
  1313. // Dump the easy parts.
  1314. //
  1315. dprintf(
  1316. "%s%sHTTP_REQUEST @ %p:\n"
  1317. "%s ConnectionId = %I64x\n"
  1318. "%s RequestId = %I64x\n"
  1319. "%s Verb = %s\n"
  1320. "%s VerbLength = %lu\n"
  1321. "%s VerbOffset = %p (%S)\n"
  1322. "%s RawUrlLength = %lu\n"
  1323. "%s RawUrlOffset = %p (%S)\n"
  1324. "%s UrlLength = %lu\n"
  1325. "%s UrlOffset = %p (%S)\n"
  1326. "%s UnknownHeaderCount = %lu\n"
  1327. "%s UnknownHeaderOffset = %p\n"
  1328. "%s EntityBodyLength = %lu\n"
  1329. "%s EntityBodyOffset = %p\n",
  1330. Prefix,
  1331. CommandName,
  1332. RemoteAddress,
  1333. Prefix,
  1334. LocalRequest->ConnectionId,
  1335. Prefix,
  1336. LocalRequest->RequestId,
  1337. Prefix,
  1338. VerbToString( LocalRequest->Verb ),
  1339. Prefix,
  1340. LocalRequest->UnknownVerbLength,
  1341. Prefix,
  1342. LocalRequest->pUnknownVerb,
  1343. rawVerbBuffer,
  1344. Prefix,
  1345. LocalRequest->RawUrlLength,
  1346. Prefix,
  1347. LocalRequest->pRawUrl,
  1348. rawURLBuffer,
  1349. Prefix,
  1350. LocalRequest->CookedUrl.FullUrlLength,
  1351. Prefix,
  1352. LocalRequest->CookedUrl.pFullUrl,
  1353. urlBuffer,
  1354. Prefix,
  1355. LocalRequest->Headers.UnknownHeaderCount,
  1356. Prefix,
  1357. LocalRequest->Headers.pUnknownHeaders,
  1358. Prefix,
  1359. LocalRequest->pEntityChunks->FromMemory.BufferLength,
  1360. Prefix,
  1361. LocalRequest->pEntityChunks->FromMemory.pBuffer
  1362. );
  1363. } // DumpUlRequest
  1364. VOID
  1365. DumpHttpHeader(
  1366. IN PSTR Prefix,
  1367. IN PSTR CommandName,
  1368. IN ULONG_PTR RemoteAddress,
  1369. IN PUL_HTTP_HEADER LocalHeader,
  1370. IN ULONG HeaderOrdinal,
  1371. IN PSTR *pHeaderIdMap
  1372. )
  1373. {
  1374. UCHAR headerBuffer[MAX_HEADER_BUFFER];
  1375. READ_REMOTE_STRING(
  1376. headerBuffer,
  1377. sizeof(headerBuffer),
  1378. LocalHeader->pHeader,
  1379. LocalHeader->HeaderLength
  1380. );
  1381. dprintf(
  1382. "%s%s UL_HTTP_HEADER[%lu] @ %p (%s):\n"
  1383. "%s HeaderLength = %lu\n"
  1384. "%s pHeader = %p (%s)\n"
  1385. "%s OurBuffer = %lu\n"
  1386. "%s Valid = %lu\n",
  1387. Prefix,
  1388. CommandName,
  1389. HeaderOrdinal,
  1390. RemoteAddress,
  1391. pHeaderIdMap[HeaderOrdinal],
  1392. Prefix,
  1393. LocalHeader->HeaderLength,
  1394. Prefix,
  1395. LocalHeader->pHeader,
  1396. headerBuffer,
  1397. Prefix,
  1398. LocalHeader->OurBuffer,
  1399. Prefix,
  1400. 1
  1401. );
  1402. } // DumpHttpHeader
  1403. VOID
  1404. DumpUnknownHeader(
  1405. IN PSTR Prefix,
  1406. IN PSTR CommandName,
  1407. IN ULONG_PTR RemoteAddress,
  1408. IN PUL_HTTP_UNKNOWN_HEADER LocalHeader
  1409. )
  1410. {
  1411. UCHAR headerName[MAX_HEADER_BUFFER];
  1412. UCHAR headerValue[MAX_HEADER_BUFFER];
  1413. READ_REMOTE_STRING(
  1414. headerName,
  1415. sizeof(headerName),
  1416. LocalHeader->pHeaderName,
  1417. LocalHeader->HeaderNameLength
  1418. );
  1419. READ_REMOTE_STRING(
  1420. headerValue,
  1421. sizeof(headerValue),
  1422. LocalHeader->HeaderValue.pHeader,
  1423. LocalHeader->HeaderValue.HeaderLength
  1424. );
  1425. dprintf(
  1426. "%s%s HTTP_UNKNOWN_HEADER @ %p:\n"
  1427. "%s List @ %p\n"
  1428. "%s HeaderNameLength = %lu\n"
  1429. "%s pHeaderName = %p (%s)\n"
  1430. "%s HeaderValue @ %p\n"
  1431. "%s HeaderLength = %lu\n"
  1432. "%s pHeader = %p (%s)\n"
  1433. "%s OurBuffer = %lu\n"
  1434. "%s Valid = %lu\n",
  1435. "%s ExternalAllocated = %lu\n",
  1436. Prefix,
  1437. CommandName,
  1438. RemoteAddress,
  1439. Prefix,
  1440. REMOTE_OFFSET( RemoteAddress, UL_HTTP_UNKNOWN_HEADER, List ),
  1441. Prefix,
  1442. LocalHeader->HeaderNameLength,
  1443. Prefix,
  1444. LocalHeader->pHeaderName,
  1445. headerName,
  1446. Prefix,
  1447. REMOTE_OFFSET( RemoteAddress, UL_HTTP_UNKNOWN_HEADER, HeaderValue ),
  1448. Prefix,
  1449. LocalHeader->HeaderValue.HeaderLength,
  1450. Prefix,
  1451. LocalHeader->HeaderValue.pHeader,
  1452. headerValue,
  1453. Prefix,
  1454. LocalHeader->HeaderValue.OurBuffer,
  1455. Prefix,
  1456. 1,
  1457. Prefix,
  1458. LocalHeader->HeaderValue.ExternalAllocated
  1459. );
  1460. } // DumpUnknownHeader
  1461. VOID
  1462. DumpFileCacheEntry(
  1463. IN PSTR Prefix,
  1464. IN PSTR CommandName,
  1465. IN ULONG_PTR RemoteAddress,
  1466. IN PUL_FILE_CACHE_ENTRY LocalFile
  1467. )
  1468. {
  1469. ULONG result;
  1470. ULONG_PTR offset;
  1471. ULONG nameLength;
  1472. WCHAR fileNameBuffer[MAX_PATH+1];
  1473. CHAR mdlReadSymbol[MAX_SYMBOL_LENGTH];
  1474. CHAR mdlReadCompleteSymbol[MAX_SYMBOL_LENGTH];
  1475. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  1476. nameLength = min( sizeof(fileNameBuffer), (ULONG)LocalFile->FileName.Length );
  1477. if (!ReadMemory(
  1478. (ULONG_PTR)LocalFile->FileName.Buffer,
  1479. fileNameBuffer,
  1480. nameLength,
  1481. &result
  1482. ))
  1483. {
  1484. nameLength = 0;
  1485. }
  1486. fileNameBuffer[nameLength / sizeof(WCHAR)] = L'\0';
  1487. GetSymbol(
  1488. LocalFile->pMdlRead,
  1489. mdlReadSymbol,
  1490. &offset
  1491. );
  1492. GetSymbol(
  1493. LocalFile->pMdlReadComplete,
  1494. mdlReadCompleteSymbol,
  1495. &offset
  1496. );
  1497. dprintf(
  1498. "%s%sUL_FILE_CACHE_ENTRY @ %p\n"
  1499. "%s Signature = %08lx (%s)\n"
  1500. "%s ReferenceCount = %lu\n"
  1501. "%s pFileObject = %p\n"
  1502. "%s pDeviceObject = %p\n"
  1503. "%s pMdlRead = %p %s\n"
  1504. "%s pMdlReadComplete = %p %s\n"
  1505. "%s FileName @ %p (%ws)\n"
  1506. "%s FileHandle = %p\n"
  1507. "%s WorkItem @ %p\n"
  1508. "%s FileInfo @ %p\n"
  1509. "%s AllocationSize = %I64u\n"
  1510. "%s EndOfFile = %I64u\n"
  1511. "%s NumberOfLinks = %lu\n"
  1512. "%s DeletePending = %lu\n"
  1513. "%s Directory = %lu\n",
  1514. Prefix,
  1515. CommandName,
  1516. RemoteAddress,
  1517. Prefix,
  1518. LocalFile->Signature,
  1519. SignatureToString(
  1520. LocalFile->Signature,
  1521. UL_FILE_CACHE_ENTRY_SIGNATURE,
  1522. UL_FILE_CACHE_ENTRY_SIGNATURE_X,
  1523. strSignature
  1524. ),
  1525. Prefix,
  1526. LocalFile->ReferenceCount,
  1527. Prefix,
  1528. LocalFile->pFileObject,
  1529. Prefix,
  1530. LocalFile->pDeviceObject,
  1531. Prefix,
  1532. LocalFile->pMdlRead,
  1533. mdlReadSymbol,
  1534. Prefix,
  1535. LocalFile->pMdlReadComplete,
  1536. mdlReadCompleteSymbol,
  1537. Prefix,
  1538. REMOTE_OFFSET( RemoteAddress, UL_FILE_CACHE_ENTRY, FileName ),
  1539. fileNameBuffer,
  1540. Prefix,
  1541. LocalFile->FileHandle,
  1542. Prefix,
  1543. REMOTE_OFFSET( RemoteAddress, UL_FILE_CACHE_ENTRY, WorkItem ),
  1544. Prefix,
  1545. REMOTE_OFFSET( RemoteAddress, UL_FILE_CACHE_ENTRY, FileInfo ),
  1546. Prefix,
  1547. LocalFile->FileInfo.AllocationSize.QuadPart,
  1548. Prefix,
  1549. LocalFile->FileInfo.EndOfFile.QuadPart,
  1550. Prefix,
  1551. LocalFile->FileInfo.NumberOfLinks,
  1552. Prefix,
  1553. (ULONG)LocalFile->FileInfo.DeletePending,
  1554. Prefix,
  1555. (ULONG)LocalFile->FileInfo.Directory
  1556. );
  1557. } // DumpFileCacheEntry
  1558. #if 0
  1559. // BUGBUG: GeorgeRe must fix
  1560. VOID
  1561. DumpUriEntry(
  1562. IN PSTR Prefix,
  1563. IN PSTR CommandName,
  1564. IN ULONG_PTR RemoteAddress,
  1565. IN PUL_URI_CACHE_ENTRY UriEntry
  1566. )
  1567. {
  1568. UCHAR urlBuffer[MAX_URL_BUFFER];
  1569. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  1570. READ_REMOTE_STRING(
  1571. urlBuffer,
  1572. sizeof(urlBuffer),
  1573. UriEntry->Uri.pUri,
  1574. UriEntry->Uri.Length
  1575. );
  1576. dprintf(
  1577. "%s%sUL_URI_CACHE_ENTRY @ %p\n"
  1578. "%s%S\n"
  1579. "%s\n"
  1580. "%s Signature = %08lx (%s)\n"
  1581. "%s BucketEntry @ %p\n"
  1582. "%s Flink = %p ( !ulkd.uri %p )\n"
  1583. "%s Blink = %p ( !ulkd.uri %p )\n"
  1584. "%s Uri @ %p\n"
  1585. "%s Hash = %08lx\n"
  1586. "%s Length = %lu\n"
  1587. "%s pUri = %p\n"
  1588. "%s ReferenceCount = %lu\n"
  1589. "%s HitCount = %lu\n"
  1590. "%s Zombie = %lu\n"
  1591. "%s Cached = %lu\n"
  1592. "%s ContentLengthSpecified = %lu\n"
  1593. "%s StatusCode = %u\n"
  1594. "%s Verb = %s\n"
  1595. "%s ScavengerTicks = %lu\n"
  1596. "%s CachePolicy @ %p\n"
  1597. "%s Policy = %s\n"
  1598. "%s SecondsToLive = %lu\n"
  1599. "%s ExpirationTime = %08x%08x\n"
  1600. "%s pConfigInfo = %p\n"
  1601. "%s pProcess = %p\n"
  1602. "%s HeaderLength = %lu\n"
  1603. "%s pHeaders = %p\n"
  1604. "%s ContentLength = %lu\n"
  1605. "%s pContent = %p\n"
  1606. "\n",
  1607. Prefix,
  1608. CommandName,
  1609. RemoteAddress,
  1610. Prefix,
  1611. urlBuffer,
  1612. Prefix,
  1613. Prefix,
  1614. UriEntry->Signature,
  1615. SignatureToString(
  1616. UriEntry->Signature,
  1617. UL_URI_CACHE_ENTRY_POOL_TAG,
  1618. MAKE_FREE_TAG(UL_URI_CACHE_ENTRY_POOL_TAG),
  1619. strSignature
  1620. ),
  1621. Prefix,
  1622. REMOTE_OFFSET( RemoteAddress, UL_URI_CACHE_ENTRY, BucketEntry ),
  1623. Prefix,
  1624. UriEntry->BucketEntry.Flink,
  1625. CONTAINING_RECORD(
  1626. UriEntry->BucketEntry.Flink,
  1627. UL_URI_CACHE_ENTRY,
  1628. BucketEntry
  1629. ),
  1630. Prefix,
  1631. UriEntry->BucketEntry.Blink,
  1632. CONTAINING_RECORD(
  1633. UriEntry->BucketEntry.Blink,
  1634. UL_URI_CACHE_ENTRY,
  1635. BucketEntry
  1636. ),
  1637. Prefix,
  1638. REMOTE_OFFSET( RemoteAddress, UL_URI_CACHE_ENTRY, Uri ),
  1639. Prefix,
  1640. UriEntry->Uri.Hash,
  1641. Prefix,
  1642. UriEntry->Uri.Length,
  1643. Prefix,
  1644. UriEntry->Uri.pUri,
  1645. Prefix,
  1646. UriEntry->ReferenceCount,
  1647. Prefix,
  1648. UriEntry->HitCount,
  1649. Prefix,
  1650. UriEntry->Zombie,
  1651. Prefix,
  1652. UriEntry->Cached,
  1653. Prefix,
  1654. UriEntry->ContentLengthSpecified,
  1655. Prefix,
  1656. (ULONG)UriEntry->StatusCode,
  1657. Prefix,
  1658. VerbToString( UriEntry->Verb ),
  1659. Prefix,
  1660. UriEntry->ScavengerTicks,
  1661. Prefix,
  1662. REMOTE_OFFSET( RemoteAddress, UL_URI_CACHE_ENTRY, CachePolicy ),
  1663. Prefix,
  1664. CachePolicyToString( UriEntry->CachePolicy.Policy ),
  1665. Prefix,
  1666. UriEntry->CachePolicy.SecondsToLive,
  1667. Prefix,
  1668. UriEntry->ExpirationTime.HighPart,
  1669. UriEntry->ExpirationTime.LowPart,
  1670. Prefix,
  1671. UriEntry->pConfigInfo,
  1672. Prefix,
  1673. UriEntry->pProcess,
  1674. Prefix,
  1675. UriEntry->HeaderLength,
  1676. Prefix,
  1677. UriEntry->pHeaders,
  1678. Prefix,
  1679. UriEntry->ContentLength,
  1680. Prefix,
  1681. UriEntry->pContent
  1682. );
  1683. } // DumpUriEntry
  1684. #endif
  1685. VOID
  1686. DumpAllUriEntries(
  1687. VOID
  1688. )
  1689. {
  1690. ULONG_PTR address = 0;
  1691. // UL_URI_CACHE_TABLE table;
  1692. ULONG_PTR dataAddress;
  1693. ULONG i;
  1694. dprintf("BUGBUG: GeorgeRe needs to fix DumpAllUriEntries!\n");
  1695. #if 0
  1696. //
  1697. // find table
  1698. //
  1699. address = GetExpression("&http!g_pUriCacheTable");
  1700. if (address) {
  1701. if (ReadMemory(
  1702. address,
  1703. &dataAddress,
  1704. sizeof(dataAddress),
  1705. NULL
  1706. ))
  1707. {
  1708. if (ReadMemory(
  1709. dataAddress,
  1710. &table,
  1711. sizeof(table),
  1712. NULL
  1713. ))
  1714. {
  1715. //
  1716. // dump live entries
  1717. //
  1718. dprintf("Live UL_URI_CACHE_ENTRIES\n\n");
  1719. for (i = 0; i < table.BucketCount; i++) {
  1720. EnumLinkedList(
  1721. ((PLIST_ENTRY)
  1722. REMOTE_OFFSET(
  1723. dataAddress,
  1724. UL_URI_CACHE_TABLE,
  1725. Buckets
  1726. )) + i,
  1727. &DumpUriEntryCallback,
  1728. "L "
  1729. );
  1730. }
  1731. } else {
  1732. dprintf(
  1733. "uri*: cannot read memory for http!g_pUriCacheTable = %p\n",
  1734. dataAddress
  1735. );
  1736. }
  1737. } else {
  1738. dprintf(
  1739. "uri*: cannot read memory for http!g_pUriCacheTable @ %p\n",
  1740. address
  1741. );
  1742. }
  1743. } else {
  1744. dprintf(
  1745. "uri*: cannot find symbol for http!g_pUriCacheTable\n"
  1746. );
  1747. }
  1748. //
  1749. // dump the zombie list
  1750. //
  1751. address = GetExpression("&http!g_ZombieListHead");
  1752. if (!address) {
  1753. dprintf(
  1754. "uri*: cannot find symbol for http!g_ZombieListHead\n"
  1755. );
  1756. return;
  1757. }
  1758. dprintf("Zombie UL_URI_CACHE_ENTRIES\n\n");
  1759. EnumLinkedList(
  1760. (PLIST_ENTRY) address,
  1761. &DumpUriEntryCallback,
  1762. "Z "
  1763. );
  1764. #endif
  1765. } // DumpAllUriEntries
  1766. VOID
  1767. DumpMdl(
  1768. IN PSTR Prefix,
  1769. IN PSTR CommandName,
  1770. IN ULONG_PTR RemoteAddress,
  1771. IN PMDL LocalMdl,
  1772. IN ULONG MaxBytesToDump
  1773. )
  1774. {
  1775. dprintf(
  1776. "%s%sMDL @ %p\n"
  1777. "%s Next = %p\n"
  1778. "%s Size = %04x\n"
  1779. "%s MdlFlags = %04x\n",
  1780. Prefix,
  1781. CommandName,
  1782. RemoteAddress,
  1783. Prefix,
  1784. LocalMdl->Next,
  1785. Prefix,
  1786. LocalMdl->Size,
  1787. Prefix,
  1788. LocalMdl->MdlFlags
  1789. );
  1790. DumpBitVector(
  1791. Prefix,
  1792. " ",
  1793. LocalMdl->MdlFlags,
  1794. g_MdlFlagVector
  1795. );
  1796. dprintf(
  1797. "%s Process = %p\n"
  1798. "%s MappedSystemVa = %p\n"
  1799. "%s StartVa = %p\n"
  1800. "%s ByteCount = %08lx\n"
  1801. "%s ByteOffset = %08lx\n",
  1802. Prefix,
  1803. LocalMdl->Process,
  1804. Prefix,
  1805. LocalMdl->MappedSystemVa,
  1806. Prefix,
  1807. LocalMdl->StartVa,
  1808. Prefix,
  1809. LocalMdl->ByteCount,
  1810. Prefix,
  1811. LocalMdl->ByteOffset
  1812. );
  1813. if (MaxBytesToDump > LocalMdl->ByteCount)
  1814. {
  1815. MaxBytesToDump = LocalMdl->ByteCount;
  1816. }
  1817. if (MaxBytesToDump > 0)
  1818. {
  1819. DumpRawData(
  1820. Prefix,
  1821. (ULONG_PTR)LocalMdl->MappedSystemVa,
  1822. MaxBytesToDump
  1823. );
  1824. }
  1825. } // DumpMdl
  1826. //
  1827. // Private functions.
  1828. //
  1829. BOOLEAN
  1830. DumpUnknownHeadersCallback(
  1831. IN PLIST_ENTRY RemoteListEntry,
  1832. IN PVOID Context
  1833. )
  1834. {
  1835. UL_HTTP_UNKNOWN_HEADER header;
  1836. UCHAR headerName[MAX_HEADER_BUFFER];
  1837. UCHAR headerValue[MAX_HEADER_BUFFER];
  1838. ULONG result;
  1839. ULONG_PTR address;
  1840. address = (ULONG_PTR)CONTAINING_RECORD(
  1841. RemoteListEntry,
  1842. UL_HTTP_UNKNOWN_HEADER,
  1843. List
  1844. );
  1845. if (!ReadMemory(
  1846. address,
  1847. &header,
  1848. sizeof(header),
  1849. &result
  1850. ))
  1851. {
  1852. return FALSE;
  1853. }
  1854. DumpUnknownHeader(
  1855. (PSTR) Context,
  1856. "",
  1857. address,
  1858. &header
  1859. );
  1860. return TRUE;
  1861. } // DumpUnknownHeadersCallback
  1862. VOID
  1863. DumpApoolObj(
  1864. IN PSTR Prefix,
  1865. IN PSTR CommandName,
  1866. IN ULONG_PTR RemoteAddress,
  1867. IN PUL_APP_POOL_OBJECT ApoolObj
  1868. )
  1869. {
  1870. UCHAR name[MAX_URL_BUFFER];
  1871. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  1872. READ_REMOTE_STRING(
  1873. name,
  1874. sizeof(name),
  1875. REMOTE_OFFSET( RemoteAddress, UL_APP_POOL_OBJECT, pName ),
  1876. ApoolObj->NameLength
  1877. );
  1878. dprintf(
  1879. "%s%sUL_APP_POOL_OBJECT @ %p\n"
  1880. "%s Signature = %08lx (%s)\n"
  1881. "%s RefCount = %d\n"
  1882. "%s ListEntry @ %p\n"
  1883. "%s Flink = %p ( !ulkd.apool %p )\n"
  1884. "%s Blink = %p ( !ulkd.apool %p )\n"
  1885. "%s pResource = %p\n"
  1886. "%s NewRequestQueue\n"
  1887. "%s RequestCount = %d\n"
  1888. "%s MaxRequests = %d\n"
  1889. "%s RequestHead @ %p\n"
  1890. "%s pDemandStartIrp = %p\n"
  1891. "%s pDemandStartProcess = %p\n"
  1892. "%s ProcessListHead @ %p\n"
  1893. "%s pSecurityDescriptor = %p\n"
  1894. "%s NameLength = %d\n"
  1895. "%s pName = %p ( %S )\n",
  1896. Prefix,
  1897. CommandName,
  1898. RemoteAddress,
  1899. Prefix,
  1900. ApoolObj->Signature,
  1901. SignatureToString(
  1902. ApoolObj->Signature,
  1903. UL_APP_POOL_OBJECT_POOL_TAG,
  1904. MAKE_FREE_TAG(UL_APP_POOL_OBJECT_POOL_TAG),
  1905. strSignature
  1906. ),
  1907. Prefix,
  1908. ApoolObj->RefCount,
  1909. Prefix,
  1910. REMOTE_OFFSET( RemoteAddress, UL_APP_POOL_OBJECT, ListEntry ),
  1911. Prefix,
  1912. ApoolObj->ListEntry.Flink,
  1913. CONTAINING_RECORD(
  1914. ApoolObj->ListEntry.Flink,
  1915. UL_APP_POOL_OBJECT,
  1916. ListEntry
  1917. ),
  1918. Prefix,
  1919. ApoolObj->ListEntry.Blink,
  1920. CONTAINING_RECORD(
  1921. ApoolObj->ListEntry.Blink,
  1922. UL_APP_POOL_OBJECT,
  1923. ListEntry
  1924. ),
  1925. Prefix,
  1926. ApoolObj->pResource,
  1927. Prefix,
  1928. Prefix,
  1929. ApoolObj->NewRequestQueue.RequestCount,
  1930. Prefix,
  1931. ApoolObj->NewRequestQueue.MaxRequests,
  1932. Prefix,
  1933. REMOTE_OFFSET( RemoteAddress, UL_APP_POOL_OBJECT, NewRequestQueue.RequestHead ),
  1934. Prefix,
  1935. ApoolObj->pDemandStartIrp,
  1936. Prefix,
  1937. ApoolObj->pDemandStartProcess,
  1938. Prefix,
  1939. REMOTE_OFFSET( RemoteAddress, UL_APP_POOL_OBJECT, ProcessListHead ),
  1940. Prefix,
  1941. ApoolObj->pSecurityDescriptor,
  1942. Prefix,
  1943. ApoolObj->NameLength,
  1944. Prefix,
  1945. REMOTE_OFFSET( RemoteAddress, UL_APP_POOL_OBJECT, pName ),
  1946. name
  1947. );
  1948. if (ApoolObj->ProcessListHead.Flink != (PLIST_ENTRY)REMOTE_OFFSET(
  1949. RemoteAddress,
  1950. UL_APP_POOL_OBJECT,
  1951. ProcessListHead
  1952. ))
  1953. {
  1954. dprintf("%s AP Process List:\n", Prefix);
  1955. EnumLinkedList(
  1956. (PLIST_ENTRY)REMOTE_OFFSET(
  1957. RemoteAddress,
  1958. UL_APP_POOL_OBJECT,
  1959. ProcessListHead
  1960. ),
  1961. &ProcListCallback,
  1962. Prefix
  1963. );
  1964. }
  1965. if (ApoolObj->NewRequestQueue.RequestHead.Flink != (PLIST_ENTRY)REMOTE_OFFSET(
  1966. RemoteAddress,
  1967. UL_APP_POOL_OBJECT,
  1968. NewRequestQueue.RequestHead
  1969. ))
  1970. {
  1971. dprintf("%s New Request List:\n", Prefix);
  1972. EnumLinkedList(
  1973. (PLIST_ENTRY)REMOTE_OFFSET(
  1974. RemoteAddress,
  1975. UL_APP_POOL_OBJECT,
  1976. NewRequestQueue.RequestHead
  1977. ),
  1978. &RequestListCallback,
  1979. Prefix
  1980. );
  1981. }
  1982. dprintf("\n");
  1983. } // DumpApoolObj
  1984. VOID
  1985. DumpAllApoolObjs(
  1986. VOID
  1987. )
  1988. {
  1989. ULONG_PTR address = 0;
  1990. address = GetExpression("&http!g_AppPoolListHead");
  1991. if (!address) {
  1992. dprintf(
  1993. "apool*: cannot find symbol for http!g_AppPoolListHead\n"
  1994. );
  1995. return;
  1996. }
  1997. EnumLinkedList(
  1998. (PLIST_ENTRY) address,
  1999. &DumpApoolCallback,
  2000. ""
  2001. );
  2002. }
  2003. VOID
  2004. DumpApoolProc(
  2005. IN PSTR Prefix,
  2006. IN PSTR CommandName,
  2007. IN ULONG_PTR RemoteAddress,
  2008. IN PUL_APP_POOL_PROCESS ApoolProc
  2009. )
  2010. {
  2011. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  2012. dprintf(
  2013. "%s%sUL_APP_POOL_PROCESS @ %p\n"
  2014. "%s Signature = %08lx (%s)\n"
  2015. "%s InCleanup = %d\n"
  2016. "%s ListEntry @ %p\n"
  2017. "%s Flink = %p ( !ulkd.proc %p )\n"
  2018. "%s Blink = %p ( !ulkd.proc %p )\n"
  2019. "%s pAppPool = %p\n"
  2020. "%s NewIrpHead @ %p\n"
  2021. "%s PendingRequestQueue\n"
  2022. "%s RequestCount = %d\n"
  2023. "%s MaxRequests = %d\n"
  2024. "%s RequestHead @ %p\n"
  2025. "%s pProcess = %p\n"
  2026. "%s WaitForDisconnectHead @ %p\n",
  2027. Prefix,
  2028. CommandName,
  2029. RemoteAddress,
  2030. Prefix,
  2031. ApoolProc->Signature,
  2032. SignatureToString(
  2033. ApoolProc->Signature,
  2034. UL_APP_POOL_PROCESS_POOL_TAG,
  2035. MAKE_FREE_TAG(UL_APP_POOL_PROCESS_POOL_TAG),
  2036. strSignature
  2037. ),
  2038. Prefix,
  2039. ApoolProc->InCleanup,
  2040. Prefix,
  2041. REMOTE_OFFSET( RemoteAddress, UL_APP_POOL_PROCESS, ListEntry ),
  2042. Prefix,
  2043. ApoolProc->ListEntry.Flink,
  2044. CONTAINING_RECORD(
  2045. ApoolProc->ListEntry.Flink,
  2046. UL_APP_POOL_PROCESS,
  2047. ListEntry
  2048. ),
  2049. Prefix,
  2050. ApoolProc->ListEntry.Blink,
  2051. CONTAINING_RECORD(
  2052. ApoolProc->ListEntry.Blink,
  2053. UL_APP_POOL_PROCESS,
  2054. ListEntry
  2055. ),
  2056. Prefix,
  2057. ApoolProc->pAppPool,
  2058. Prefix,
  2059. REMOTE_OFFSET( RemoteAddress, UL_APP_POOL_PROCESS, NewIrpHead ),
  2060. Prefix,
  2061. Prefix,
  2062. ApoolProc->PendingRequestQueue.RequestCount,
  2063. Prefix,
  2064. ApoolProc->PendingRequestQueue.MaxRequests,
  2065. Prefix,
  2066. REMOTE_OFFSET( RemoteAddress, UL_APP_POOL_PROCESS, PendingRequestQueue.RequestHead ),
  2067. Prefix,
  2068. ApoolProc->pProcess,
  2069. Prefix,
  2070. REMOTE_OFFSET( RemoteAddress, UL_APP_POOL_PROCESS, WaitForDisconnectHead )
  2071. );
  2072. //
  2073. // dump the IRP list
  2074. //
  2075. if (ApoolProc->NewIrpHead.Flink != (PLIST_ENTRY)REMOTE_OFFSET(
  2076. RemoteAddress,
  2077. UL_APP_POOL_PROCESS,
  2078. NewIrpHead
  2079. ))
  2080. {
  2081. dprintf("%s Irp List:\n", Prefix);
  2082. EnumLinkedList(
  2083. (PLIST_ENTRY) REMOTE_OFFSET(
  2084. RemoteAddress,
  2085. UL_APP_POOL_PROCESS,
  2086. NewIrpHead
  2087. ),
  2088. &IrpListCallback,
  2089. Prefix
  2090. );
  2091. }
  2092. //
  2093. // dump pending request list
  2094. //
  2095. if (ApoolProc->PendingRequestQueue.RequestHead.Flink != (PLIST_ENTRY)REMOTE_OFFSET(
  2096. RemoteAddress,
  2097. UL_APP_POOL_PROCESS,
  2098. PendingRequestQueue.RequestHead
  2099. ))
  2100. {
  2101. dprintf("%s Request List:\n", Prefix);
  2102. EnumLinkedList(
  2103. (PLIST_ENTRY) REMOTE_OFFSET(
  2104. RemoteAddress,
  2105. UL_APP_POOL_PROCESS,
  2106. PendingRequestQueue.RequestHead
  2107. ),
  2108. &RequestListCallback,
  2109. Prefix
  2110. );
  2111. }
  2112. dprintf("\n");
  2113. } // DumpApoolProc
  2114. VOID
  2115. DumpConfigGroup(
  2116. IN PSTR Prefix,
  2117. IN PSTR CommandName,
  2118. IN ULONG_PTR RemoteAddress,
  2119. IN PUL_CONFIG_GROUP_OBJECT Obj
  2120. )
  2121. {
  2122. CHAR temp[sizeof("1234567812345678")];
  2123. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  2124. dprintf(
  2125. "%s%sUL_CONFIG_GROUP_OBJECT @ %p\n"
  2126. "%s Signature = %x (%s)\n"
  2127. "%s RefCount = %d\n"
  2128. "%s ConfigGroupId = %I64x\n"
  2129. "%s ControlChannelEntry @ %p\n"
  2130. "%s pControlChannel = %p\n"
  2131. "%s UrlListHead @ %p\n",
  2132. Prefix,
  2133. CommandName,
  2134. RemoteAddress,
  2135. Prefix,
  2136. Obj->Signature,
  2137. SignatureToString(
  2138. Obj->Signature,
  2139. UL_CG_OBJECT_POOL_TAG,
  2140. MAKE_FREE_TAG(UL_CG_OBJECT_POOL_TAG),
  2141. strSignature
  2142. ),
  2143. Prefix,
  2144. Obj->RefCount,
  2145. Prefix,
  2146. Obj->ConfigGroupId,
  2147. Prefix,
  2148. REMOTE_OFFSET(RemoteAddress, UL_CONFIG_GROUP_OBJECT, ControlChannelEntry),
  2149. Prefix,
  2150. Obj->pControlChannel,
  2151. Prefix,
  2152. REMOTE_OFFSET(RemoteAddress, UL_CONFIG_GROUP_OBJECT, UrlListHead)
  2153. );
  2154. if (Obj->AppPoolFlags.Present) {
  2155. dprintf(
  2156. "%s pAppPool = %p\n",
  2157. Prefix,
  2158. Obj->pAppPool
  2159. );
  2160. } else {
  2161. dprintf(
  2162. "%s pAppPool (none)\n",
  2163. Prefix
  2164. );
  2165. }
  2166. dprintf(
  2167. "%s pAutoResponse = %p\n",
  2168. Prefix,
  2169. Obj->pAutoResponse
  2170. );
  2171. if (Obj->MaxBandwidth.Flags.Present) {
  2172. dprintf(
  2173. "%s MaxBandwidth = %d\n",
  2174. Prefix,
  2175. Obj->MaxBandwidth.MaxBandwidth
  2176. );
  2177. } else {
  2178. dprintf(
  2179. "%s MaxBandwidth (none)\n",
  2180. Prefix
  2181. );
  2182. }
  2183. if (Obj->MaxConnections.Flags.Present) {
  2184. dprintf(
  2185. "%s MaxConnections = %d\n",
  2186. Prefix,
  2187. Obj->MaxConnections.MaxConnections
  2188. );
  2189. } else {
  2190. dprintf(
  2191. "%s MaxConnections (none)\n",
  2192. Prefix
  2193. );
  2194. }
  2195. if (Obj->State.Flags.Present) {
  2196. dprintf(
  2197. "%s State = %s\n",
  2198. Prefix,
  2199. UlEnabledStateToString(Obj->State.State)
  2200. );
  2201. } else {
  2202. dprintf(
  2203. "%s State (none)\n",
  2204. Prefix
  2205. );
  2206. }
  2207. if (Obj->Security.Flags.Present) {
  2208. dprintf(
  2209. "%s Security.pSecurityDescriptor = %p\n",
  2210. Prefix,
  2211. Obj->Security.pSecurityDescriptor
  2212. );
  2213. if (Obj->Security.pSecurityDescriptor) {
  2214. sprintf(temp, "%p", Obj->Security.pSecurityDescriptor);
  2215. CallExtensionRoutine("sd", temp);
  2216. }
  2217. } else {
  2218. dprintf(
  2219. "%s Security (none)\n",
  2220. Prefix
  2221. );
  2222. }
  2223. }
  2224. VOID
  2225. DumpConfigTree(
  2226. IN PSTR Prefix,
  2227. IN PSTR CommandName,
  2228. IN ULONG_PTR RemoteAddress,
  2229. IN PUL_CG_URL_TREE_HEADER Tree
  2230. )
  2231. {
  2232. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  2233. dprintf(
  2234. "%s%sUL_CG_URL_TREE_HEADER @ %p\n"
  2235. "%s Signature = %x (%s)\n"
  2236. "%s AllocCount = %u\n"
  2237. "%s UsedCount = %u\n",
  2238. Prefix,
  2239. CommandName,
  2240. RemoteAddress,
  2241. Prefix,
  2242. Tree->Signature,
  2243. SignatureToString(
  2244. Tree->Signature,
  2245. UL_CG_TREE_HEADER_POOL_TAG,
  2246. MAKE_FREE_TAG(UL_CG_TREE_HEADER_POOL_TAG),
  2247. strSignature
  2248. ),
  2249. Prefix,
  2250. Tree->AllocCount,
  2251. Prefix,
  2252. Tree->UsedCount
  2253. );
  2254. }
  2255. VOID
  2256. DumpCgroupEntry(
  2257. IN PSTR Prefix,
  2258. IN PSTR CommandName,
  2259. IN ULONG_PTR RemoteAddress,
  2260. IN PUL_CG_URL_TREE_ENTRY Entry
  2261. )
  2262. {
  2263. UCHAR tokenBuffer[MAX_URL_BUFFER];
  2264. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  2265. dprintf(
  2266. "%s%sUL_CG_URL_TREE_ENTRY @ %p\n"
  2267. "%s Signature = %08lx (%s)\n"
  2268. "%s pParent = %p (cgentry)\n"
  2269. "%s pChildren = %p (cgtree)\n"
  2270. "%s TokenHash = 0x%08x\n"
  2271. "%s TokenLength = %d\n"
  2272. "%s FullUrl = %d\n",
  2273. Prefix,
  2274. CommandName,
  2275. RemoteAddress,
  2276. Prefix,
  2277. Entry->Signature,
  2278. SignatureToString(
  2279. Entry->Signature,
  2280. UL_CG_TREE_ENTRY_POOL_TAG,
  2281. MAKE_FREE_TAG(UL_CG_TREE_ENTRY_POOL_TAG),
  2282. strSignature
  2283. ),
  2284. Prefix,
  2285. Entry->pParent,
  2286. Prefix,
  2287. Entry->pChildren,
  2288. Prefix,
  2289. Entry->TokenHash,
  2290. Prefix,
  2291. Entry->TokenLength,
  2292. Prefix,
  2293. Entry->FullUrl
  2294. );
  2295. if (Entry->FullUrl) {
  2296. dprintf(
  2297. "%s UrlContext = %I64x\n"
  2298. "%s pConfigGroup = %p\n"
  2299. "%s ConfigGroupListEntry @ %p\n",
  2300. Prefix,
  2301. Entry->UrlContext,
  2302. Prefix,
  2303. Entry->pConfigGroup,
  2304. Prefix,
  2305. REMOTE_OFFSET(RemoteAddress, UL_CG_URL_TREE_ENTRY, ConfigGroupListEntry)
  2306. );
  2307. }
  2308. READ_REMOTE_STRING(
  2309. tokenBuffer,
  2310. sizeof(tokenBuffer),
  2311. REMOTE_OFFSET(RemoteAddress, UL_CG_URL_TREE_ENTRY, pToken),
  2312. Entry->TokenLength
  2313. );
  2314. dprintf(
  2315. "%s pToken = %ws\n"
  2316. "\n",
  2317. Prefix,
  2318. tokenBuffer
  2319. );
  2320. }
  2321. VOID
  2322. DumpCgroupHeader(
  2323. IN PSTR Prefix,
  2324. IN PSTR CommandName,
  2325. IN ULONG_PTR RemoteAddress,
  2326. IN PUL_CG_HEADER_ENTRY Entry
  2327. )
  2328. {
  2329. UL_CG_URL_TREE_ENTRY tentry;
  2330. ULONG result;
  2331. dprintf(
  2332. "%s%sUL_CG_HEADER_ENTRY @ %p\n"
  2333. "%s TokenHash = 0x%08x\n"
  2334. "%s pEntry = %p\n",
  2335. Prefix,
  2336. CommandName,
  2337. RemoteAddress,
  2338. Prefix,
  2339. Entry->TokenHash,
  2340. Prefix,
  2341. Entry->pEntry
  2342. );
  2343. if (!ReadMemory(
  2344. (ULONG_PTR)Entry->pEntry,
  2345. &tentry,
  2346. sizeof(tentry),
  2347. &result
  2348. ))
  2349. {
  2350. dprintf(
  2351. "%scouldn't read UL_CG_TREE_ENTRY @ %p\n",
  2352. CommandName,
  2353. Entry->pEntry
  2354. );
  2355. return;
  2356. }
  2357. DumpCgroupEntry(
  2358. Prefix,
  2359. CommandName,
  2360. (ULONG_PTR)Entry->pEntry,
  2361. &tentry
  2362. );
  2363. }
  2364. #if 0
  2365. BOOLEAN
  2366. DumpUriEntryCallback(
  2367. IN PLIST_ENTRY RemoteListEntry,
  2368. IN PVOID Context
  2369. )
  2370. {
  2371. UL_URI_CACHE_ENTRY entry;
  2372. ULONG_PTR address;
  2373. ULONG result;
  2374. address = (ULONG_PTR)CONTAINING_RECORD(
  2375. RemoteListEntry,
  2376. UL_URI_CACHE_ENTRY,
  2377. BucketEntry
  2378. );
  2379. if (!ReadMemory(
  2380. address,
  2381. &entry,
  2382. sizeof(entry),
  2383. &result
  2384. ))
  2385. {
  2386. return FALSE;
  2387. }
  2388. DumpUriEntry(
  2389. (PSTR) Context,
  2390. "uri*: ",
  2391. address,
  2392. &entry
  2393. );
  2394. return TRUE;
  2395. } // DumpUriEntryCallback
  2396. #endif
  2397. BOOLEAN
  2398. DumpApoolCallback(
  2399. IN PLIST_ENTRY RemoteListEntry,
  2400. IN PVOID Context
  2401. )
  2402. {
  2403. UL_APP_POOL_OBJECT obj;
  2404. ULONG_PTR address;
  2405. ULONG result;
  2406. address = (ULONG_PTR)CONTAINING_RECORD(
  2407. RemoteListEntry,
  2408. UL_APP_POOL_OBJECT,
  2409. ListEntry
  2410. );
  2411. if (!ReadMemory(
  2412. address,
  2413. &obj,
  2414. sizeof(obj),
  2415. &result
  2416. ))
  2417. {
  2418. return FALSE;
  2419. }
  2420. DumpApoolObj(
  2421. (PSTR) Context,
  2422. "apool*: ",
  2423. address,
  2424. &obj
  2425. );
  2426. return TRUE;
  2427. } // DumpApoolCallback
  2428. BOOLEAN
  2429. DumpEndpointCallback(
  2430. IN PLIST_ENTRY RemoteListEntry,
  2431. IN PVOID Context
  2432. )
  2433. {
  2434. UL_ENDPOINT endp;
  2435. ULONG_PTR address;
  2436. ULONG result;
  2437. PENDPOINT_GLOBAL_CALLBACK_CONTEXT pCtxt
  2438. = (PENDPOINT_GLOBAL_CALLBACK_CONTEXT) Context;
  2439. ASSERT(pCtxt->Signature == ENDPOINT_GLOBAL_CALLBACK_CONTEXT_SIGNATURE);
  2440. address = (ULONG_PTR)CONTAINING_RECORD(
  2441. RemoteListEntry,
  2442. UL_ENDPOINT,
  2443. GlobalEndpointListEntry
  2444. );
  2445. if (!ReadMemory(
  2446. address,
  2447. &endp,
  2448. sizeof(endp),
  2449. &result
  2450. ))
  2451. {
  2452. return FALSE;
  2453. }
  2454. DumpUlEndpoint(
  2455. pCtxt->Prefix,
  2456. "endp *: ",
  2457. address,
  2458. &endp,
  2459. pCtxt->Verbosity
  2460. );
  2461. return TRUE;
  2462. } // DumpEndpointCallback
  2463. BOOLEAN
  2464. ProcListCallback(
  2465. IN PLIST_ENTRY RemoteListEntry,
  2466. IN PVOID Context
  2467. )
  2468. {
  2469. ULONG_PTR address;
  2470. address = (ULONG_PTR)CONTAINING_RECORD(
  2471. RemoteListEntry,
  2472. UL_APP_POOL_PROCESS,
  2473. ListEntry
  2474. );
  2475. dprintf("%s %p\n", (PSTR) Context, address);
  2476. return TRUE;
  2477. } // ProcListCallback
  2478. BOOLEAN
  2479. IrpListCallback(
  2480. IN PLIST_ENTRY RemoteListEntry,
  2481. IN PVOID Context
  2482. )
  2483. {
  2484. ULONG_PTR address;
  2485. address = (ULONG_PTR)CONTAINING_RECORD(
  2486. RemoteListEntry,
  2487. IRP,
  2488. Tail.Overlay.ListEntry
  2489. );
  2490. dprintf("%s %p\n", (PSTR) Context, address);
  2491. return TRUE;
  2492. } // IrpListCallback
  2493. BOOLEAN
  2494. RequestListCallback(
  2495. IN PLIST_ENTRY RemoteListEntry,
  2496. IN PVOID Context
  2497. )
  2498. {
  2499. UL_INTERNAL_REQUEST request;
  2500. ULONG_PTR address;
  2501. ULONG result;
  2502. UCHAR urlBuffer[MAX_URL_BUFFER];
  2503. address = (ULONG_PTR)CONTAINING_RECORD(
  2504. RemoteListEntry,
  2505. UL_INTERNAL_REQUEST,
  2506. AppPool.AppPoolEntry
  2507. );
  2508. if (!ReadMemory(
  2509. address,
  2510. &request,
  2511. sizeof(request),
  2512. &result
  2513. ))
  2514. {
  2515. return FALSE;
  2516. }
  2517. READ_REMOTE_STRING(
  2518. urlBuffer,
  2519. sizeof(urlBuffer),
  2520. request.CookedUrl.pUrl,
  2521. request.CookedUrl.Length
  2522. );
  2523. dprintf(
  2524. "%s %p - %s %ws\n",
  2525. (PSTR) Context,
  2526. address,
  2527. VerbToString(request.Verb),
  2528. urlBuffer
  2529. );
  2530. return TRUE;
  2531. } // RequestListCallback
  2532. VOID
  2533. DumpKernelQueue(
  2534. IN PSTR Prefix,
  2535. IN PSTR CommandName,
  2536. IN ULONG_PTR RemoteAddress,
  2537. IN PKQUEUE LocalQueue,
  2538. IN ULONG Flags
  2539. )
  2540. {
  2541. dprintf(
  2542. "%s%sKQUEUE @ %p\n"
  2543. "%s Type = %02x\n"
  2544. "%s Absolute = %02x\n"
  2545. "%s Size = %02x\n"
  2546. "%s Inserted = %02x\n"
  2547. "%s SignalState = %ld\n"
  2548. "%s WaitListHead @ %p%s\n"
  2549. "%s EntryListHead @ %p%s\n"
  2550. "%s CurrentCount = %lu\n"
  2551. "%s MaximumCount = %lu\n"
  2552. "%s ThreadListHead @ %p%s\n",
  2553. Prefix,
  2554. CommandName,
  2555. RemoteAddress,
  2556. Prefix,
  2557. LocalQueue->Header.Type,
  2558. Prefix,
  2559. LocalQueue->Header.Absolute,
  2560. Prefix,
  2561. LocalQueue->Header.Size,
  2562. Prefix,
  2563. LocalQueue->Header.Inserted,
  2564. Prefix,
  2565. LocalQueue->Header.SignalState,
  2566. Prefix,
  2567. REMOTE_OFFSET( RemoteAddress, KQUEUE, Header.WaitListHead ),
  2568. IS_LIST_EMPTY(
  2569. LocalQueue,
  2570. RemoteAddress,
  2571. KQUEUE,
  2572. Header.WaitListHead
  2573. ) ? " (EMPTY)" : "",
  2574. Prefix,
  2575. REMOTE_OFFSET( RemoteAddress, KQUEUE, EntryListHead ),
  2576. IS_LIST_EMPTY(
  2577. LocalQueue,
  2578. RemoteAddress,
  2579. KQUEUE,
  2580. EntryListHead
  2581. ) ? " (EMPTY)" : "",
  2582. Prefix,
  2583. LocalQueue->CurrentCount,
  2584. Prefix,
  2585. LocalQueue->MaximumCount,
  2586. Prefix,
  2587. REMOTE_OFFSET( RemoteAddress, KQUEUE, ThreadListHead ),
  2588. IS_LIST_EMPTY(
  2589. LocalQueue,
  2590. RemoteAddress,
  2591. KQUEUE,
  2592. ThreadListHead
  2593. ) ? " (EMPTY)" : ""
  2594. );
  2595. if (Flags & 1)
  2596. {
  2597. EnumLinkedList(
  2598. (PLIST_ENTRY)REMOTE_OFFSET( RemoteAddress, KQUEUE, EntryListHead ),
  2599. &DumpKQueueEntriesCallback,
  2600. NULL
  2601. );
  2602. }
  2603. } // DumpKernelQueue
  2604. BOOLEAN
  2605. DumpKQueueEntriesCallback(
  2606. IN PLIST_ENTRY RemoteListEntry,
  2607. IN PVOID Context
  2608. )
  2609. {
  2610. ULONG_PTR address;
  2611. CHAR temp[sizeof("1234567812345678 f")];
  2612. address = (ULONG_PTR)CONTAINING_RECORD(
  2613. RemoteListEntry,
  2614. IRP,
  2615. Tail.Overlay.ListEntry
  2616. );
  2617. sprintf( temp, "%p f", address );
  2618. CallExtensionRoutine( "irp", temp );
  2619. return TRUE;
  2620. } // DumpKQueueEntriesCallback
  2621. VOID
  2622. DumpFilterChannel(
  2623. IN PSTR Prefix,
  2624. IN PSTR CommandName,
  2625. IN ULONG_PTR RemoteAddress,
  2626. IN PUL_FILTER_CHANNEL Filter,
  2627. IN ULONG Flags
  2628. )
  2629. {
  2630. UCHAR name[MAX_URL_BUFFER];
  2631. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  2632. READ_REMOTE_STRING(
  2633. name,
  2634. sizeof(name),
  2635. REMOTE_OFFSET( RemoteAddress, UL_FILTER_CHANNEL, pName ),
  2636. Filter->NameLength
  2637. );
  2638. dprintf(
  2639. "%s%sUL_FILTER_CHANNEL @ %p\n"
  2640. "%s Signature = %x (%s)\n"
  2641. "%s RefCount = %d\n"
  2642. "%s ListEntry @ %p\n"
  2643. "%s pDemandStartIrp = %p\n"
  2644. "%s pDemandStartProcess = %p\n"
  2645. "%s SpinLock @ %p (%s)\n"
  2646. "%s ProcessListHead @ %p%s\n"
  2647. "%s ConnectionListHead @ %p%s\n"
  2648. "%s pSecurityDescriptor = %p\n"
  2649. "%s NameLength = %d\n"
  2650. "%s pName = %p (%S)\n"
  2651. "\n",
  2652. Prefix,
  2653. CommandName,
  2654. RemoteAddress,
  2655. Prefix,
  2656. Filter->Signature,
  2657. SignatureToString(
  2658. Filter->Signature,
  2659. UL_FILTER_CHANNEL_POOL_TAG,
  2660. MAKE_FREE_TAG(UL_FILTER_CHANNEL_POOL_TAG),
  2661. strSignature
  2662. ),
  2663. Prefix,
  2664. Filter->RefCount,
  2665. Prefix,
  2666. REMOTE_OFFSET( RemoteAddress, UL_FILTER_CHANNEL, ListEntry ),
  2667. Prefix,
  2668. Filter->pDemandStartIrp,
  2669. Prefix,
  2670. Filter->pDemandStartProcess,
  2671. Prefix,
  2672. REMOTE_OFFSET( RemoteAddress, UL_FILTER_CHANNEL, SpinLock ),
  2673. GetSpinlockState( &Filter->SpinLock ),
  2674. Prefix,
  2675. REMOTE_OFFSET( RemoteAddress, UL_FILTER_CHANNEL, ProcessListHead ),
  2676. IS_LIST_EMPTY(
  2677. Filter,
  2678. RemoteAddress,
  2679. UL_FILTER_CHANNEL,
  2680. ProcessListHead
  2681. ) ? " (EMPTY)" : "",
  2682. Prefix,
  2683. REMOTE_OFFSET( RemoteAddress, UL_FILTER_CHANNEL, ConnectionListHead ),
  2684. IS_LIST_EMPTY(
  2685. Filter,
  2686. RemoteAddress,
  2687. UL_FILTER_CHANNEL,
  2688. ConnectionListHead
  2689. ) ? " (EMPTY)" : "",
  2690. Prefix,
  2691. Filter->pSecurityDescriptor,
  2692. Prefix,
  2693. Filter->NameLength,
  2694. Prefix,
  2695. Filter->pName,
  2696. name
  2697. );
  2698. if (Filter->ProcessListHead.Flink != (PLIST_ENTRY)REMOTE_OFFSET(
  2699. RemoteAddress,
  2700. UL_FILTER_CHANNEL,
  2701. ProcessListHead
  2702. ))
  2703. {
  2704. dprintf("%s Filter Process List:\n", Prefix);
  2705. EnumLinkedList(
  2706. (PLIST_ENTRY)REMOTE_OFFSET(
  2707. RemoteAddress,
  2708. UL_FILTER_CHANNEL,
  2709. ProcessListHead
  2710. ),
  2711. &FiltProcListCallback,
  2712. Prefix
  2713. );
  2714. }
  2715. dprintf("\n");
  2716. }
  2717. BOOLEAN
  2718. FiltProcListCallback(
  2719. IN PLIST_ENTRY RemoteListEntry,
  2720. IN PVOID Context
  2721. )
  2722. {
  2723. ULONG_PTR address;
  2724. address = (ULONG_PTR)CONTAINING_RECORD(
  2725. RemoteListEntry,
  2726. UL_FILTER_PROCESS,
  2727. ListEntry
  2728. );
  2729. dprintf("%s %p\n", (PSTR) Context, address);
  2730. return TRUE;
  2731. } // FiltProcListCallback
  2732. VOID
  2733. DumpFilterProc(
  2734. IN PSTR Prefix,
  2735. IN PSTR CommandName,
  2736. IN ULONG_PTR RemoteAddress,
  2737. IN PUL_FILTER_PROCESS Proc,
  2738. IN ULONG Flags
  2739. )
  2740. {
  2741. CHAR strSignature[MAX_SIGNATURE_LENGTH];
  2742. dprintf(
  2743. "%s%sUL_FILTER_PROCESS @ %p\n"
  2744. "%s Signature = %x (%s)\n"
  2745. "%s InCleanup = %ld\n"
  2746. "%s pFilterChannel = %p\n"
  2747. "%s ListEntry @ %p\n"
  2748. "%s ConnectionHead @ %p%s\n"
  2749. "%s IrpHead @ %p%s\n"
  2750. "%s pProcess = %p\n"
  2751. "\n",
  2752. Prefix,
  2753. CommandName,
  2754. RemoteAddress,
  2755. Prefix,
  2756. Proc->Signature,
  2757. SignatureToString(
  2758. Proc->Signature,
  2759. UL_FILTER_PROCESS_POOL_TAG,
  2760. MAKE_FREE_TAG(UL_FILTER_PROCESS_POOL_TAG),
  2761. strSignature
  2762. ),
  2763. Prefix,
  2764. Proc->InCleanup,
  2765. Prefix,
  2766. Proc->pFilterChannel,
  2767. Prefix,
  2768. REMOTE_OFFSET( RemoteAddress, UL_FILTER_PROCESS, ListEntry ),
  2769. Prefix,
  2770. REMOTE_OFFSET( RemoteAddress, UL_FILTER_PROCESS, ConnectionHead ),
  2771. IS_LIST_EMPTY(
  2772. Proc,
  2773. RemoteAddress,
  2774. UL_FILTER_PROCESS,
  2775. ConnectionHead
  2776. ) ? " (EMPTY)" : "",
  2777. Prefix,
  2778. REMOTE_OFFSET( RemoteAddress, UL_FILTER_PROCESS, IrpHead ),
  2779. IS_LIST_EMPTY(
  2780. Proc,
  2781. RemoteAddress,
  2782. UL_FILTER_PROCESS,
  2783. IrpHead
  2784. ) ? " (EMPTY)" : "",
  2785. Prefix,
  2786. Proc->pProcess
  2787. );
  2788. } // DumpFilterProc
  2789. BOOLEAN
  2790. DumpUlActiveConnectionCallback(
  2791. IN PLIST_ENTRY RemoteListEntry,
  2792. IN PVOID Context
  2793. )
  2794. {
  2795. ULONG_PTR address;
  2796. UL_CONNECTION connection;
  2797. ULONG result;
  2798. PCONN_CALLBACK_CONTEXT pConnContext = (PCONN_CALLBACK_CONTEXT) Context;
  2799. ASSERT(pConnContext->Signature == CONN_CALLBACK_CONTEXT_SIGNATURE);
  2800. address = (ULONG_PTR) CONTAINING_RECORD(
  2801. RemoteListEntry,
  2802. UL_CONNECTION,
  2803. ActiveListEntry // <--
  2804. );
  2805. if (!ReadMemory(
  2806. address,
  2807. &connection,
  2808. sizeof(connection),
  2809. &result
  2810. ))
  2811. {
  2812. return FALSE;
  2813. }
  2814. dprintf("active conn[%2d][%2d]: ",
  2815. pConnContext->Index, pConnContext->SubIndex++);
  2816. switch (pConnContext->Verbosity)
  2817. {
  2818. case ENDPOINT_BRIEF_CONNS:
  2819. DumpUlConnectionLite(
  2820. pConnContext->Prefix,
  2821. "",
  2822. address,
  2823. &connection
  2824. );
  2825. break;
  2826. case ENDPOINT_VERBOSE_CONNS:
  2827. DumpUlConnection(
  2828. pConnContext->Prefix,
  2829. "",
  2830. address,
  2831. &connection
  2832. );
  2833. break;
  2834. default:
  2835. ASSERT(! "Invalid ENDPOINT_CONNS");
  2836. }
  2837. return TRUE;
  2838. } // DumpUlActiveConnectionCallback
  2839. BOOLEAN
  2840. DumpUlIdleConnectionCallback(
  2841. IN PSINGLE_LIST_ENTRY RemoteSListEntry,
  2842. IN PVOID Context
  2843. )
  2844. {
  2845. ULONG_PTR address;
  2846. UL_CONNECTION connection;
  2847. ULONG result;
  2848. PCONN_CALLBACK_CONTEXT pConnContext = (PCONN_CALLBACK_CONTEXT) Context;
  2849. ASSERT(pConnContext->Signature == CONN_CALLBACK_CONTEXT_SIGNATURE);
  2850. address = (ULONG_PTR) CONTAINING_RECORD(
  2851. RemoteSListEntry,
  2852. UL_CONNECTION,
  2853. IdleSListEntry // <--
  2854. );
  2855. if (!ReadMemory(
  2856. address,
  2857. &connection,
  2858. sizeof(connection),
  2859. &result
  2860. ))
  2861. {
  2862. return FALSE;
  2863. }
  2864. dprintf("idle conn[%2d]: ", pConnContext->SubIndex++);
  2865. switch (pConnContext->Verbosity)
  2866. {
  2867. case ENDPOINT_BRIEF_CONNS:
  2868. DumpUlConnectionLite(
  2869. pConnContext->Prefix,
  2870. "",
  2871. address,
  2872. &connection
  2873. );
  2874. break;
  2875. case ENDPOINT_VERBOSE_CONNS:
  2876. DumpUlConnection(
  2877. pConnContext->Prefix,
  2878. "",
  2879. address,
  2880. &connection
  2881. );
  2882. break;
  2883. default:
  2884. ASSERT(! "Invalid ENDPOINT_CONNS");
  2885. }
  2886. return TRUE;
  2887. } // DumpUlIdleConnectionCallback