summaryrefslogblamecommitdiffstats
path: root/private/ntos/dlc/kdexts/dlcx.c
blob: c4d29d4d553a7273f5f78cdf201fd9c122e12f7b (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551






























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                               
/*++

Copyright (c) 1993  Microsoft Corporation

Module Name:

    dlcx.c

Abstract:

    Contains kernel debugger extensions to help with DLC debugging

    Contents:
        help
        ac
        bc
        be
        bf
        bh
        bp
        ci
        cw
        dc
        de
        dx
        ep
        fc
        fl
        ll
        lt
        lx
        mdl
        mu
        pc
        pd
        ph
        png
        pnp
        pp
        pr
        pu
        px
        req
        tt

Author:

    Richard L Firth (rfirth) 20-Dec-1993

Environment:

    Kernel Debugger only

Revision History:

    20-Dec-1993 rfirth
        Created

--*/

#include <stdio.h>
#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>

#include <windows.h>
#include <imagehlp.h>
#include <wdbgexts.h>
#include <dlc.h>
#include <llc.h>

//
// macros
//

#define EMPTY_LIST(ptr, field, addr) \
    ((((ULONG)ptr->field.Flink - (ULONG)addr) == ((ULONG)&ptr->field.Flink - (ULONG)ptr)) ? "(empty)" : "")

#define CurPC dwCurrentPc
#define pArgStr args
#define lpReadVirtualMemRoutine lpReadProcessMemoryRoutine

//
// prototypes
//

VOID dump_close_wait_info(DWORD, PDLC_CLOSE_WAIT_INFO, BOOL);
VOID dump_gen_object(PLLC_GENERIC_OBJECT);
VOID dump_data_link(DWORD, BOOL);
VOID dump_memory_usage(DWORD, PMEMORY_USAGE, BOOL);
#if DBG
VOID dump_private_non_paged_pool(DWORD, PPRIVATE_NON_PAGED_POOL_HEAD);
#endif

LPSTR buffer_state$(BYTE);
LPSTR $lx_type(BYTE);
LPSTR $data_link_state(BYTE);
LPSTR $fc_state(USHORT);
LPSTR $dx_type(BYTE);
LPSTR $dx_state(BYTE);
LPSTR $address_translation(UINT);
LPSTR $frame_type(UINT);
LPSTR $object_id(UINT);

//
// globals
//

EXT_API_VERSION        ApiVersion = { 4, 0, EXT_API_VERSION_NUMBER, 0 };
WINDBG_EXTENSION_APIS  ExtensionApis;
PWINDBG_EXTENSION_APIS pExtApis = &ExtensionApis;
USHORT                 SavedMajorVersion;
USHORT                 SavedMinorVersion;

//
// functions
//



VOID
WinDbgExtensionDllInit(
    PWINDBG_EXTENSION_APIS lpExtensionApis,

    USHORT MajorVersion,
    USHORT MinorVersion
    )
{
    ExtensionApis = *lpExtensionApis;

    SavedMajorVersion = MajorVersion;
    SavedMinorVersion = MinorVersion;

    return;
}

VOID
CheckVersion(
    VOID
    )
{
    //
    // your check version code goes here
    //
}

LPEXT_API_VERSION
ExtensionApiVersion(
    VOID
    )
{
    return &ApiVersion;
}

DECLARE_API(help)
{

    dprintf("\n"
           "NT DLC Protocol Stack Kernel Debugger Extensions\n"
#if DBG
           "CHECKED build "
#else
           "FREE build "
#endif

#if defined(DLC_UNILOCK)
           "Uni-lock DLC "
#else
           "Multi-lock DLC "
#endif

#if defined(LOCK_CHECK)
           "LOCK_CHECK "
#endif
           "[" __TIME__ " " __DATE__ "]\n"
           "\n"
           );

    dprintf("\tac  - dump ADAPTER_CONTEXT\n"
           "\tbc  - dump BINDING_CONTEXT\n"
           "\tbe  - dump DLC_BUFFER_HEADER as FreeBuffer\n"
           "\tbf  - dump DLC_BUFFER_HEADER as FrameBuffer\n"
           "\tbh  - dump DLC_BUFFER_HEADER as Header\n"
           "\tbp  - dump DLC_BUFFER_POOL\n"
           "\tci  - dump DLC_COMPLETION_EVENT_INFO\n"
           "\tcw  - dump DLC_CLOSE_WAIT_INFO\n"
           "\tdc  - dump DLC_COMMAND\n"
           "\tde  - dump DLC_EVENT\n"
           "\tdx  - dump DLC_OBJECT\n"
           "\tep  - dump EVENT_PACKET\n"
           "\tfc  - dump FILE_CONTEXT\n"
           "\tfl  - dump DLC_RESET_LOCAL_BUSY_CMD\n"
           "\tll  - dump DATA_LINK\n"
           "\tlt  - dump LLC_TIMER\n"
           "\tlx  - dump LLC_OBJECT\n"
           "\tmdl - dump MDL\n"
           "\tmu  - dump MEMORY_USAGE\n"
           "\tpc  - dump LLC_PACKET Completion flavour\n"
           "\tpd  - dump LLC_PACKET XmitDix flavour\n"
           "\tph  - dump PACKET_HEAD\n"
           );
#if DBG
    dprintf("\tpng - dump PRIVATE_NON_PAGED_POOL_HEAD from GlobalList pointer\n"
           "\tpnp - dump PRIVATE_NON_PAGED_POOL_HEAD from PrivateList pointer\n"
           );
#endif
    dprintf("\tpp  - dump PACKET_POOL\n"
           "\tpr  - dump LLC_PACKET Response flavour\n"
           "\tpu  - dump LLC_PACKET XmitU flavour\n"
           "\tpx  - dump LLC_PACKET Xmit flavour\n"
           "\treq - dump DLC IOCTL code\n"
           "\ttt  - dump TIMER_TICK\n"
           "\n"
           );
}

DECLARE_API(ac)
{

    PADAPTER_CONTEXT pAdapter;
    ADAPTER_CONTEXT object;
    
    WCHAR name[128];
    BOOL ok;
    UINT i;
    BOOL haveOne;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    pAdapter = &object;

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        (DWORD)pAdapter->Name.Buffer,
        name,
        pAdapter->Name.Length * sizeof(name[0]),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy name locally\n");
        return;
    }

    dprintf("\n"
           "ADAPTER_CONTEXT structure at %#.8x:\n\n"
           "\t                     pNext 0x%08x\n"

#if !defined(DLC_UNILOCK)
           "\t              SendSpinLock 0x%08x, 0x%08x\n"
           "\t            ObjectDataBase 0x%08x, 0x%08x\n"
#endif
           "\t            pDirectStation 0x%08x\n"
           "\t                 pBindings 0x%08x\n"
           "\t         NdisBindingHandle 0x%08x\n",
           addr,
           pAdapter->pNext,

#if !defined(DLC_UNILOCK)
           pAdapter->SendSpinLock.SpinLock,
           pAdapter->SendSpinLock.OldIrql,
           pAdapter->ObjectDataBase.SpinLock,
           pAdapter->ObjectDataBase.OldIrql,
#endif
           pAdapter->pDirectStation,
           pAdapter->pBindings,
           pAdapter->NdisBindingHandle
           );

    dprintf("\t                 hLinkPool 0x%08x\n"
           "\t               hPacketPool 0x%08x\n"
           "\t           pNdisPacketPool 0x%08x\n"
           "\t           hNdisPacketPool 0x%08x\n"
           "\t hReceiveCompletionRequest 0x%08x\n"
           "\t             pResetPackets 0x%08x\n"
           "\t         MacReceiveContext 0x%08x\n"
           "\t                  pHeadBuf 0x%08x\n"
           "\t                 cbHeadBuf 0x%08x\n"
           "\t                  pLookBuf 0x%08x\n"
           "\t                 cbLookBuf 0x%08x\n"
           "\t              cbPacketSize 0x%08x\n"
           "\t                   Adapter DSAP=%02x SSAP=%02x NODE=%02x-%02x-%02x-%02x-%02x-%02x\n",
           pAdapter->hLinkPool,
           pAdapter->hPacketPool,
           pAdapter->pNdisPacketPool,
           pAdapter->hNdisPacketPool,
           pAdapter->hReceiveCompletionRequest,
           pAdapter->pResetPackets,
           pAdapter->MacReceiveContext,
           pAdapter->pHeadBuf,
           pAdapter->cbHeadBuf,
           pAdapter->pLookBuf,
           pAdapter->cbLookBuf,
           pAdapter->cbPacketSize,
           pAdapter->Adapter.Node.DestSap & 0xff,
           pAdapter->Adapter.Node.SrcSap & 0xff,
           pAdapter->Adapter.Node.auchAddress[0] & 0xff,
           pAdapter->Adapter.Node.auchAddress[1] & 0xff,
           pAdapter->Adapter.Node.auchAddress[2] & 0xff,
           pAdapter->Adapter.Node.auchAddress[3] & 0xff,
           pAdapter->Adapter.Node.auchAddress[4] & 0xff,
           pAdapter->Adapter.Node.auchAddress[5] & 0xff
           );

    dprintf("\t              MaxFrameSize %d\n"
           "\t                 LinkSpeed %d\n"
           "\t                NdisMedium %d\n"
           "\t          XidTestResponses %d\n"
           "\t               ObjectCount %d\n",
           pAdapter->MaxFrameSize,
           pAdapter->LinkSpeed,
           pAdapter->NdisMedium,
           pAdapter->XidTestResponses,
           pAdapter->ObjectCount
           );

    dprintf("\t                ConfigInfo:\n"
           "\t+          SwapAddressBits 0x%02x\n"
           "\t+                   UseDix 0x%02x\n"
           "\t+                T1TickOne 0x%02x\n"
           "\t+                T2TickOne 0x%02x\n"
           "\t+                TiTickOne 0x%02x\n"
           "\t+                T1TickTwo 0x%02x\n"
           "\t+                T2TickTwo 0x%02x\n"
           "\t+                TiTickTwo 0x%02x\n"
           "\t+     UseEthernetFrameSize 0x%02x\n",
           pAdapter->ConfigInfo.SwapAddressBits,
           pAdapter->ConfigInfo.UseDix,
           pAdapter->ConfigInfo.TimerTicks.T1TickOne,
           pAdapter->ConfigInfo.TimerTicks.T2TickOne,
           pAdapter->ConfigInfo.TimerTicks.TiTickOne,
           pAdapter->ConfigInfo.TimerTicks.T1TickTwo,
           pAdapter->ConfigInfo.TimerTicks.T2TickTwo,
           pAdapter->ConfigInfo.TimerTicks.TiTickTwo,
           pAdapter->ConfigInfo.UseEthernetFrameSize
           );

    dprintf("\t        ulBroadcastAddress 0x%08x\n"
           "\t        usBroadcastAddress 0x%04x\n"
           "\t BackgroundProcessRequests 0x%04x\n",
           pAdapter->ulBroadcastAddress,
           pAdapter->usBroadcastAddress,
           pAdapter->BackgroundProcessRequests
           );

    dprintf("\t               NodeAddress %02x-%02x-%02x-%02x-%02x-%02x\n"
           "\t          cbMaxFrameHeader 0x%04x\n"
           "\t          PermanentAddress %02x-%02x-%02x-%02x-%02x-%02x\n"
           "\t               OpenOptions 0x%04x\n"
           "\t    AddressTranslationMode 0x%04x [%s]\n"
           "\t                 FrameType 0x%04x [%s]\n"
           "\t                 usRcvMask 0x%04x\n",
           pAdapter->NodeAddress[0] & 0xff,
           pAdapter->NodeAddress[1] & 0xff,
           pAdapter->NodeAddress[2] & 0xff,
           pAdapter->NodeAddress[3] & 0xff,
           pAdapter->NodeAddress[4] & 0xff,
           pAdapter->NodeAddress[5] & 0xff,
           pAdapter->cbMaxFrameHeader,
           pAdapter->PermanentAddress[0] & 0xff,
           pAdapter->PermanentAddress[1] & 0xff,
           pAdapter->PermanentAddress[2] & 0xff,
           pAdapter->PermanentAddress[3] & 0xff,
           pAdapter->PermanentAddress[4] & 0xff,
           pAdapter->PermanentAddress[5] & 0xff,
           pAdapter->OpenOptions,
           pAdapter->AddressTranslationMode,
           $address_translation(pAdapter->AddressTranslationMode),
           pAdapter->FrameType,
           $frame_type(pAdapter->FrameType),
           pAdapter->usRcvMask
           );

    dprintf("\t              EthernetType 0x%04x\n"
           "\t        RcvLanHeaderLength 0x%04x\n"
           "\t              BindingCount %d\n"
           "\t      usHighFunctionalBits 0x%04x\n"
           "\tboolTranferDataNotComplete 0x%02x\n"
           "\t                   IsDirty 0x%02x\n"
           "\t           ResetInProgress 0x%02x\n"
           "\t                   Unused1 0x%02x\n"
           "\t             AdapterNumber 0x%02x\n"
           "\t               IsBroadcast 0x%02x\n"
           "\t       SendProcessIsActive 0x%02x\n"
           "\t      LlcPacketInSendQueue 0x%02x\n",
           pAdapter->EthernetType,
           pAdapter->RcvLanHeaderLength,
           pAdapter->BindingCount,
           pAdapter->usHighFunctionalBits,
           pAdapter->boolTranferDataNotComplete,
           pAdapter->IsDirty,
           pAdapter->ResetInProgress,
           pAdapter->Unused1,
           pAdapter->AdapterNumber,
           pAdapter->IsBroadcast,
           pAdapter->SendProcessIsActive,
           pAdapter->LlcPacketInSendQueue
           );

    dprintf("\t              NextSendTask 0x%08x, 0x%08x %s\n"
           "\t               QueueEvents 0x%08x, 0x%08x %s\n"
           "\t             QueueCommands 0x%08x, 0x%08x %s\n",
           pAdapter->NextSendTask.Flink,
           pAdapter->NextSendTask.Blink,
           EMPTY_LIST(pAdapter, NextSendTask, addr),
           pAdapter->QueueEvents.Flink,
           pAdapter->QueueEvents.Blink,
           EMPTY_LIST(pAdapter, QueueEvents, addr),
           pAdapter->QueueCommands.Flink,
           pAdapter->QueueCommands.Blink,
           EMPTY_LIST(pAdapter, QueueCommands, addr)
           );

    dprintf("\t                    QueueI:\n"
           "\t+                ListEntry 0x%08x, 0x%08x %s\n"
           "\t+                 ListHead 0x%08x, 0x%08x %s\n"
           "\t+                  pObject 0x%08x\n",
           pAdapter->QueueI.ListEntry.Flink,
           pAdapter->QueueI.ListEntry.Blink,
           EMPTY_LIST(pAdapter, QueueI.ListEntry, addr),
           pAdapter->QueueI.ListHead.Flink,
           pAdapter->QueueI.ListHead.Blink,
           EMPTY_LIST(pAdapter, QueueI.ListHead, addr),
           pAdapter->QueueI.pObject
           );

    dprintf("\t              QueueDirAndU:\n"
           "\t+                ListEntry 0x%08x, 0x%08x %s\n"
           "\t+                 ListHead 0x%08x, 0x%08x %s\n"
           "\t+                  pObject 0x%08x\n",
           pAdapter->QueueDirAndU.ListEntry.Flink,
           pAdapter->QueueDirAndU.ListEntry.Blink,
           EMPTY_LIST(pAdapter, QueueDirAndU.ListEntry, addr),
           pAdapter->QueueDirAndU.ListHead.Flink,
           pAdapter->QueueDirAndU.ListHead.Blink,
           EMPTY_LIST(pAdapter, QueueDirAndU.ListHead, addr),
           pAdapter->QueueDirAndU.pObject
           );

    dprintf("\t            QueueExpidited:\n"
           "\t+                ListEntry 0x%08x, 0x%08x %s\n"
           "\t+                 ListHead 0x%08x, 0x%08x %s\n"
           "\t+                  pObject 0x%08x\n",
           pAdapter->QueueExpidited.ListEntry.Flink,
           pAdapter->QueueExpidited.ListEntry.Blink,
           EMPTY_LIST(pAdapter, QueueExpidited.ListEntry, addr),
           pAdapter->QueueExpidited.ListHead.Flink,
           pAdapter->QueueExpidited.ListHead.Blink,
           EMPTY_LIST(pAdapter, QueueExpidited.ListHead, addr),
           pAdapter->QueueExpidited.pObject
           );

    dprintf("\t                      Name [0x%04x, 0x%04x] \"%ws\"\n",
           pAdapter->Name.Length,
           pAdapter->Name.MaximumLength,
           name
           );

    dprintf("\t               pTimerTicks 0x%08x\n"
           "\t           AsyncOpenStatus 0x%08x\n"
           "\t     AsyncCloseResetStatus 0x%08x\n"
           "\t        OpenCompleteStatus 0x%08x\n"
           "\t             LinkRcvStatus 0x%08x\n"
           "\t             NdisRcvStatus 0x%08x\n"
           "\t           OpenErrorStatus 0x%08x\n",
           pAdapter->pTimerTicks,
           pAdapter->AsyncOpenStatus,
           pAdapter->AsyncCloseResetStatus,
           pAdapter->OpenCompleteStatus,
           pAdapter->LinkRcvStatus,
           pAdapter->NdisRcvStatus,
           pAdapter->OpenErrorStatus
           );

    dprintf("\t                     Event:\n"
           "\t+                     Type 0x%04x\n"
           "\t+                     Size 0x%04x\n"
           "\t+              SignalState 0x%08x\n"
           "\t+             WaitListHead 0x%08x, 0x%08x %s\n",
           pAdapter->Event.Header.Type,
           pAdapter->Event.Header.Size,
           pAdapter->Event.Header.SignalState,
           pAdapter->Event.Header.WaitListHead.Flink,
           pAdapter->Event.Header.WaitListHead.Blink,
           EMPTY_LIST(pAdapter, Event.Header.WaitListHead, addr)
           );

    haveOne = FALSE;
    for (i = 0; i < 256; ++i) {
        if (pAdapter->apSapBindings[i]) {
            dprintf("\t                    SAP %02x %08x\n", i, pAdapter->apSapBindings[i]);
            haveOne = TRUE;
        }
    }
    if (!haveOne) {
        dprintf("\t                   NO SAPs\n");
    }

    haveOne = FALSE;
    for (i = 0; i < LINK_HASH_SIZE; ++i) {
        if (pAdapter->aLinkHash[i]) {
            dprintf("\t                      LINK %08x\n", pAdapter->aLinkHash[i]);
            haveOne = TRUE;
        }
    }
    if (!haveOne) {
        dprintf("\t                  NO LINKs\n");
    }

    haveOne = FALSE;
    for (i = 0; i < MAX_DIX_TABLE; ++i) {
        if (pAdapter->aDixStations[i]) {
            dprintf("\t               DIX Station %08x\n", pAdapter->aDixStations[i]);
        }
    }
    if (!haveOne) {
        dprintf("\t           NO DIX Stations\n");
    }
    dprintf("\t        TransferDataPacket:\n"
           "\t+                  private:\n"
           "\t++           PhysicalCount %d\n"
           "\t++             TotalLength %d\n"
           "\t++                    Head 0x%08x\n"
           "\t++                    Tail 0x%08x\n"
           "\t++                    Pool 0x%08x\n"
           "\t++                   Count %d\n"
           "\t++                   Flags 0x%08x\n"
           "\t++             ValidCounts 0x%02x\n"
           "\t+          auchMacReserved %02x %02x %02x %02x %02x %02x %02x %02x\n"
           "\t+                          %02x %02x %02x %02x %02x %02x %02x %02x\n"
           "\t+                  pPacket 0x%08x\n"
           "\n",
           pAdapter->TransferDataPacket.private.PhysicalCount,
           pAdapter->TransferDataPacket.private.TotalLength,
           pAdapter->TransferDataPacket.private.Head,
           pAdapter->TransferDataPacket.private.Tail,
           pAdapter->TransferDataPacket.private.Pool,
           pAdapter->TransferDataPacket.private.Count,
           pAdapter->TransferDataPacket.private.Flags,
           pAdapter->TransferDataPacket.private.ValidCounts,
           pAdapter->TransferDataPacket.auchMacReserved[0] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[1] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[2] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[3] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[4] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[5] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[6] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[7] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[8] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[9] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[10] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[11] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[12] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[13] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[14] & 0xff,
           pAdapter->TransferDataPacket.auchMacReserved[15] & 0xff,
           pAdapter->TransferDataPacket.pPacket
           );

	addr = (DWORD)pAdapter->pNext;
}

DECLARE_API(bc)
{

    PBINDING_CONTEXT p;
    BINDING_CONTEXT object;
    BOOL ok;
    DWORD i;
    DWORD maxFramingCacheCount;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "BINDING_CONTEXT structure at %#.8x:\n\n"
           "\t                     pNext 0x%08x\n"
           "\t           pAdapterContext 0x%08x\n"
           "\t            hClientContext 0x%08x\n"
           "\t         pfCommandComplete 0x%08x\n"
           "\t       pfReceiveIndication 0x%08x\n"
           "\t         pfEventIndication 0x%08x\n"
           "\t                Functional 0x%08x\n"
           "\t      ulFunctionalZeroBits 0x%08x\n",
           addr,
           p->pNext,
           p->pAdapterContext,
           p->hClientContext,
           p->pfCommandComplete,
           p->pfReceiveIndication,
           p->pfEventIndication,
           p->Functional,
           p->ulFunctionalZeroBits
           );

    dprintf("\t                  DlcTimer:\n"
           "\t+                    pNext 0x%08x\n"
           "\t+                    pPrev 0x%08x\n"
           "\t+               pTimerTick 0x%08x\n"
           "\t+           ExpirationTime 0x%08x\n"
           "\t+                 hContext 0x%08x\n",
           p->DlcTimer.pNext,
           p->DlcTimer.pPrev,
           p->DlcTimer.pTimerTick,
           p->DlcTimer.ExpirationTime,
           p->DlcTimer.hContext
           );

#if defined(LOCK_CHECK)
    dprintf("\t+                 Disabled 0x%08x\n",
           p->DlcTimer.Disabled
           );
#endif

    dprintf("\t                NdisMedium 0x%08x\n"
           "\t        AddressTranslation 0x%04x\n"
           "\t        usBroadcastAddress 0x%04x\n"
           "\t        ulBroadcastAddress 0x%08x\n"
           "\tInternalAddressTranslation 0x%04x [%s]\n"
           "\t              EthernetType 0x%04x\n"
           "\t    SwapCopiedLanAddresses 0x%02x\n",
           p->NdisMedium,
           p->AddressTranslation,
           p->usBroadcastAddress,
           p->ulBroadcastAddress,
           p->InternalAddressTranslation,
           $address_translation(p->InternalAddressTranslation),
           p->EthernetType,
           p->SwapCopiedLanAddresses
           );

    dprintf("\t        TransferDataPacket:\n"
           "\t+                  private:\n"
           "\t++           PhysicalCount %d\n"
           "\t++             TotalLength %d\n"
           "\t++                    Head 0x%08x\n"
           "\t++                    Tail 0x%08x\n"
           "\t++                    Pool 0x%08x\n"
           "\t++                   Count %d\n"
           "\t++                   Flags 0x%08x\n"
           "\t++             ValidCounts 0x%02x\n"
           "\t+          auchMacReserved %02x %02x %02x %02x %02x %02x %02x %02x\n"
           "\t+                          %02x %02x %02x %02x %02x %02x %02x %02x\n"
           "\t+                  pPacket 0x%08x\n",
           p->TransferDataPacket.private.PhysicalCount,
           p->TransferDataPacket.private.TotalLength,
           p->TransferDataPacket.private.Head,
           p->TransferDataPacket.private.Tail,
           p->TransferDataPacket.private.Pool,
           p->TransferDataPacket.private.Count,
           p->TransferDataPacket.private.Flags,
           p->TransferDataPacket.private.ValidCounts,
           p->TransferDataPacket.auchMacReserved[0] & 0xff,
           p->TransferDataPacket.auchMacReserved[1] & 0xff,
           p->TransferDataPacket.auchMacReserved[2] & 0xff,
           p->TransferDataPacket.auchMacReserved[3] & 0xff,
           p->TransferDataPacket.auchMacReserved[4] & 0xff,
           p->TransferDataPacket.auchMacReserved[5] & 0xff,
           p->TransferDataPacket.auchMacReserved[6] & 0xff,
           p->TransferDataPacket.auchMacReserved[7] & 0xff,
           p->TransferDataPacket.auchMacReserved[8] & 0xff,
           p->TransferDataPacket.auchMacReserved[9] & 0xff,
           p->TransferDataPacket.auchMacReserved[10] & 0xff,
           p->TransferDataPacket.auchMacReserved[11] & 0xff,
           p->TransferDataPacket.auchMacReserved[12] & 0xff,
           p->TransferDataPacket.auchMacReserved[13] & 0xff,
           p->TransferDataPacket.auchMacReserved[14] & 0xff,
           p->TransferDataPacket.auchMacReserved[15] & 0xff,
           p->TransferDataPacket.pPacket
           );

    dprintf("\tFramingDiscoveryCacheEntries %d\n",
           p->FramingDiscoveryCacheEntries
           );

    maxFramingCacheCount = p->FramingDiscoveryCacheEntries;
    if (maxFramingCacheCount > 64) {
        maxFramingCacheCount = 64;
    }
    for (i = 0; i < maxFramingCacheCount; ++i) {

        FRAMING_DISCOVERY_CACHE_ENTRY cacheEntry;

        ok = ExtensionApis.lpReadVirtualMemRoutine(
            (addr + sizeof(BINDING_CONTEXT) + i * sizeof(FRAMING_DISCOVERY_CACHE_ENTRY)),
            &cacheEntry,
            sizeof(cacheEntry),
            NULL
            );

        if (!ok) {
            dprintf("dlcx: error: can't copy cache object %d locally\n", i);
        } else {
            if (!cacheEntry.InUse) {
                continue;
            }
            dprintf("\t             CacheEntry % 2d:\n"
                   "\t               NodeAddress %02x-%02x-%02x-%02x-%02x-%02x\n"
                   "\t                     InUse %02x\n"
                   "\t               FramingType %02x\n"
                   "\t                 TimeStamp %08x.%08x\n",
                   i,
                   cacheEntry.NodeAddress.Bytes[0] & 0xff,
                   cacheEntry.NodeAddress.Bytes[1] & 0xff,
                   cacheEntry.NodeAddress.Bytes[2] & 0xff,
                   cacheEntry.NodeAddress.Bytes[3] & 0xff,
                   cacheEntry.NodeAddress.Bytes[4] & 0xff,
                   cacheEntry.NodeAddress.Bytes[5] & 0xff,
                   cacheEntry.InUse,
                   cacheEntry.FramingType,
                   cacheEntry.TimeStamp.HighPart,
                   cacheEntry.TimeStamp.LowPart
                   );
        }
    }
    dprintf("\n");

	addr = (DWORD)p->pNext;
}

DECLARE_API(be)
{

    PDLC_BUFFER_HEADER pb;
    DLC_BUFFER_HEADER object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    pb = &object;

    dprintf("\n"
           "DLC_BUFFER_HEADER.FreeBuffer structure at %#.8x:\n\n"
           "\t                     pNext 0x%08x\n"
           "\t                     pPrev 0x%08x\n"
           "\t                   pParent 0x%08x\n"
           "\t                pNextChild 0x%08x\n"
           "\t            ReferenceCount %d\n"
           "\t                      Size %d\n"
           "\t                     Index %d\n"
           "\t               BufferState 0x%02x [%s]\n"
           "\t             FreeListIndex %d\n"
           "\t                      pMdl 0x%08x\n"
           "\n",
           addr,
           pb->FreeBuffer.pNext,
           pb->FreeBuffer.pPrev,
           pb->FreeBuffer.pParent,
           pb->FreeBuffer.pNextChild,
           pb->FreeBuffer.ReferenceCount,
           pb->FreeBuffer.Size & 0xff,
           pb->FreeBuffer.Index & 0xff,
           pb->FreeBuffer.BufferState & 0xff,
           buffer_state$((BYTE)(pb->FreeBuffer.BufferState & 0xff)),
           pb->FreeBuffer.FreeListIndex & 0xff,
           pb->FreeBuffer.pMdl
           );

	addr = (DWORD)pb->FreeBuffer.pNext;
}

DECLARE_API(bf)
{

    PDLC_BUFFER_HEADER pb;
    DLC_BUFFER_HEADER object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );
    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }
    pb = &object;
    dprintf("\n"
           "DLC_BUFFER_HEADER.FrameBuffer structure at %#.8x:\n\n"
           "\t                 pReserved 0x%08x\n"
           "\t                pNextFrame 0x%08x\n"
           "\t                   pParent 0x%08x\n"
           "\t                pNextChild 0x%08x\n"
           "\t            ReferenceCount %d\n"
           "\t                      Size %d\n"
           "\t                     Index %d\n"
           "\t               BufferState 0x%02x [%s]\n"
           "\t             FreeListIndex %d\n"
           "\t                      pMdl 0x%08x\n"
           "\t              pNextSegment 0x%08x\n"
           "\n",
           addr,
           pb->FrameBuffer.pReserved,
           pb->FrameBuffer.pNextFrame,
           pb->FrameBuffer.pParent,
           pb->FrameBuffer.pNextChild,
           pb->FrameBuffer.ReferenceCount,
           pb->FrameBuffer.Size & 0xff,
           pb->FrameBuffer.Index & 0xff,
           pb->FrameBuffer.BufferState & 0xff,
           buffer_state$((BYTE)(pb->FrameBuffer.BufferState & 0xff)),
           pb->FrameBuffer.FreeListIndex & 0xff,
           pb->FrameBuffer.pMdl,
           pb->FrameBuffer.pNextSegment
           );

	addr = (DWORD)pb->FrameBuffer.pNextFrame;
}

DECLARE_API(bh)
{

    PDLC_BUFFER_HEADER pb;
    DLC_BUFFER_HEADER object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );
    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }
    pb = &object;
    dprintf("\n"
           "DLC_BUFFER_HEADER.Header structure at %#.8x:\n\n"
           "\t               pNextHeader 0x%08x\n"
           "\t               pPrevHeader 0x%08x\n"
           "\t                pNextChild 0x%08x\n"
           "\t                  pLocalVa 0x%08x\n"
           "\t                 pGlobalVa 0x%08x\n"
           "\t              FreeSegments %d\n"
           "\t               SegmentsOut %d\n"
           "\t               BufferState 0x%02x [%s]\n"
           "\t                  Reserved 0x%02x\n"
           "\t                      pMdl 0x%08x\n"
           "\n",
           addr,
           pb->Header.pNextHeader,
           pb->Header.pPrevHeader,
           pb->Header.pNextChild,
           pb->Header.pLocalVa,
           pb->Header.pGlobalVa,
           pb->Header.FreeSegments & 0xff,
           pb->Header.SegmentsOut & 0xff,
           pb->Header.BufferState & 0xff,
           buffer_state$((BYTE)(pb->Header.BufferState & 0xff)),
           pb->Header.Reserved,
           pb->Header.pMdl
           );

	addr = (DWORD)pb->Header.pPrevHeader;
}

DECLARE_API(bp)
{

    PDLC_BUFFER_POOL pbp;
    DLC_BUFFER_POOL object;
    BOOL ok;
    DWORD maxIndex;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );
    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }
    pbp = &object;
    dprintf("\n"
           "DLC_BUFFER_POOL structure at %#.8x:\n\n"
           "\t                     pNext 0x%08x\n"
           "\t                  SpinLock 0x%08x\n"
           "\t            ReferenceCount %d\n"
           "\t                BaseOffset 0x%08x\n"
           "\t                 MaxOffset 0x%08x\n"
           "\t             MaxBufferSize %d\n"
           "\t            BufferPoolSize %d\n"
           "\t                 FreeSpace %d\n"
           "\t          UncommittedSpace %d\n"
           "\t               MissingSize %d\n"
           "\t              MaximumIndex %d\n"
           "\t               hHeaderPool 0x%08x\n"
           "\t               PageHeaders 0x%08x, 0x%08x %s\n"
           "\t        pUnlockedEntryList 0x%08x\n"
           "\t           4K FreeLists[0] 0x%08x, 0x%08x %s\n"
           "\t           2K          [1] 0x%08x, 0x%08x %s\n"
           "\t           1K          [2] 0x%08x, 0x%08x %s\n"
           "\t          512          [3] 0x%08x, 0x%08x %s\n"
           "\t          256          [4] 0x%08x, 0x%08x %s\n",
           addr,
           pbp->pNext,
           pbp->SpinLock,
           pbp->ReferenceCount,
           pbp->BaseOffset,
           pbp->MaxOffset,
           pbp->MaxBufferSize,
           pbp->BufferPoolSize,
           pbp->FreeSpace,
           pbp->UncommittedSpace,
           pbp->MissingSize,
           pbp->MaximumIndex,
           pbp->hHeaderPool,
           pbp->PageHeaders.Flink,
           pbp->PageHeaders.Blink,
           (((ULONG)pbp->PageHeaders.Flink - (ULONG)addr) == ((ULONG)&pbp->PageHeaders.Flink - (ULONG)pbp)) ? "(empty)" : "",
           pbp->pUnlockedEntryList,
           pbp->FreeLists[0].Flink,
           pbp->FreeLists[0].Blink,
           (((ULONG)pbp->FreeLists[0].Flink - (ULONG)addr) == ((ULONG)&pbp->FreeLists[0].Flink - (ULONG)pbp)) ? "(empty)" : "",
           pbp->FreeLists[1].Flink,
           pbp->FreeLists[1].Blink,
           (((ULONG)pbp->FreeLists[1].Flink - (ULONG)addr) == ((ULONG)&pbp->FreeLists[1].Flink - (ULONG)pbp)) ? "(empty)" : "",
           pbp->FreeLists[2].Flink,
           pbp->FreeLists[2].Blink,
           (((ULONG)pbp->FreeLists[2].Flink - (ULONG)addr) == ((ULONG)&pbp->FreeLists[2].Flink - (ULONG)pbp)) ? "(empty)" : "",
           pbp->FreeLists[3].Flink,
           pbp->FreeLists[3].Blink,
           (((ULONG)pbp->FreeLists[3].Flink - (ULONG)addr) == ((ULONG)&pbp->FreeLists[3].Flink - (ULONG)pbp)) ? "(empty)" : "",
           pbp->FreeLists[4].Flink,
           pbp->FreeLists[4].Blink,
           (((ULONG)pbp->FreeLists[4].Flink - (ULONG)addr) == ((ULONG)&pbp->FreeLists[4].Flink - (ULONG)pbp)) ? "(empty)" : ""
           );

    //
    // dump the array of pointers to buffer headers describing pages
    //

    if (maxIndex = pbp->MaximumIndex) {

        LPVOID ptr;
        DWORD i;

        addr = (DWORD)&((PDLC_BUFFER_POOL)addr)->BufferHeaders;
        for (i = 0; i <= maxIndex; ++i) {

            ok = ExtensionApis.lpReadVirtualMemRoutine(
                addr,
                &ptr,
                sizeof(ptr),
                NULL
                );
            if (!ok) {
                dprintf("dlcx: error: can't copy BufferHeader[%d]\n", i);
                break;
            }

            dprintf("\t          BufferHeaders[%d] 0x%08x\n", i, ptr);
            ++((PBYTE*)addr);
        }
    }
    dprintf("\n");

	addr = (DWORD)pbp->pNext;
}

DECLARE_API(ci)
{

    DLC_COMPLETION_EVENT_INFO object;
    PDLC_COMPLETION_EVENT_INFO p;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "DLC_COMPLETION_EVENT_INFO at %#.8x:\n\n"
           "\t                 LlcPacket:\n"
           "\t                     pNext 0x%08x\n"
           "\t                     pPrev 0x%08x\n"
           "\t            CompletionType 0x%02x [%s]\n"
           "\t               cbLlcHeader 0x%02x\n"
           "\t         InformationLength %d\n"
           "\t                  pBinding 0x%08x\n",
           addr,
           p->LlcPacket.pNext,
           p->LlcPacket.pPrev,
           p->LlcPacket.CompletionType,
           "",
           p->LlcPacket.cbLlcHeader,
           p->LlcPacket.InformationLength,
           p->LlcPacket.pBinding
           );

    dprintf("\t                    Status 0x%08x\n"
           "\t          CompletedCommand 0x%08x\n"
           "\t                pLlcObject 0x%08x\n"
           "\t             hClientHandle 0x%08x\n",
           p->LlcPacket.Data.Completion.Status,
           p->LlcPacket.Data.Completion.CompletedCommand,
           p->LlcPacket.Data.Completion.pLlcObject,
           p->LlcPacket.Data.Completion.hClientHandle
           );

    dprintf("\t               pCcbAddress 0x%08x\n"
           "\t           pReceiveBuffers 0x%08x\n"
           "\t     CommandCompletionFlag 0x%08x\n"
           "\t                  CcbCount 0x%04x\n"
           "\t                 StationId 0x%04x\n"
           "\n",
           p->pCcbAddress,
           p->pReceiveBuffers,
           p->CommandCompletionFlag,
           p->CcbCount,
           p->StationId
           );

	addr = (DWORD)p->LlcPacket.pNext;
}

DECLARE_API(cw)
{

    DLC_CLOSE_WAIT_INFO object;
    PDLC_CLOSE_WAIT_INFO p;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

	dump_close_wait_info(addr, p, TRUE);

    addr = (DWORD)p->pNext;
}

VOID dump_close_wait_info(DWORD addr, PDLC_CLOSE_WAIT_INFO p, BOOL DumpAll)
{

    char fname[128];
    DWORD off;

    ExtensionApis.lpGetSymbolRoutine(p->pfCloseComplete, fname, &off);
    if (DumpAll) {
        dprintf("\n"
               "DLC_CLOSE_WAIT_INFO at %#.8x:\n\n",
               addr
               );
    }
    dprintf("\t%c                    pNext 0x%08x\n"
           "\t%c                     pIrp 0x%08x\n"
           "\t%c                    Event 0x%08x\n"
           "\t%c          pfCloseComplete 0x%08x %s\n"
           "\t%c               pRcvFrames 0x%08x\n"
           "\t%c                 pCcbLink 0x%08x\n"
           "\t%c             pReadCommand 0x%08x\n"
           "\t%c              pRcvCommand 0x%08x\n"
           "\t%c          pCompletionInfo 0x%08x\n"
           "\t%c             CancelStatus 0x%08x\n"
           "\t%c                 CcbCount 0x%04x\n"
           "\t%c             CloseCounter 0x%04x\n"
           "\t%c            ChainCommands 0x%02x\n"
           "\t%c            CancelReceive 0x%02x\n"
           "\t%c           ClosingAdapter 0x%02x\n",
           DumpAll ? ' ' : '+',
           p->pNext,
           DumpAll ? ' ' : '+',
           p->pIrp,
           DumpAll ? ' ' : '+',
           p->Event,
           DumpAll ? ' ' : '+',
           p->pfCloseComplete,
           fname,
           DumpAll ? ' ' : '+',
           p->pRcvFrames,
           DumpAll ? ' ' : '+',
           p->pCcbLink,
           DumpAll ? ' ' : '+',
           p->pReadCommand,
           DumpAll ? ' ' : '+',
           p->pRcvCommand,
           DumpAll ? ' ' : '+',
           p->pCompletionInfo,
           DumpAll ? ' ' : '+',
           p->CancelStatus,
           DumpAll ? ' ' : '+',
           p->CcbCount,
           DumpAll ? ' ' : '+',
           p->CloseCounter,
           DumpAll ? ' ' : '+',
           p->ChainCommands,
           DumpAll ? ' ' : '+',
           p->CancelReceive,
           DumpAll ? ' ' : '+',
           p->ClosingAdapter
           );
    if (DumpAll) {
        dprintf("\n");
    }
}

DECLARE_API(dc)
{

    DLC_COMMAND object;
    PDLC_COMMAND p;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "DLC_COMMAND at %#.8x:\n\n"
           "\t                 LlcPacket:\n"
           "\t                     pNext 0x%08x\n"
           "\t                     pPrev 0x%08x\n"
           "\t            CompletionType 0x%02x [%s]\n"
           "\t               cbLlcHeader 0x%02x\n"
           "\t         InformationLength %d\n"
           "\t                  pBinding 0x%08x\n",
           addr,
           p->LlcPacket.pNext,
           p->LlcPacket.pPrev,
           p->LlcPacket.CompletionType,
           "",
           p->LlcPacket.cbLlcHeader,
           p->LlcPacket.InformationLength,
           p->LlcPacket.pBinding
           );

    dprintf("\t                    Status 0x%08x\n"
           "\t          CompletedCommand 0x%08x\n"
           "\t                pLlcObject 0x%08x\n"
           "\t             hClientHandle 0x%08x\n",
           p->LlcPacket.Data.Completion.Status,
           p->LlcPacket.Data.Completion.CompletedCommand,
           p->LlcPacket.Data.Completion.pLlcObject,
           p->LlcPacket.Data.Completion.hClientHandle
           );

    dprintf("\t                     Event 0x%08x\n"
           "\t                 StationId 0x%04x\n"
           "\t             StationIdMask 0x%04x\n"
           "\t               AbortHandle 0x%08x\n"
           "\t                      pIrp 0x%08x\n"
           "\t       pfCompletionHandler 0x%08x\n"
           "\n",
           p->Event,
           p->StationId,
           p->StationIdMask,
           p->AbortHandle,
           p->pIrp,
           p->Overlay.pfCompletionHandler
           );

	addr = (DWORD)p->LlcPacket.pNext;
}

DECLARE_API(de)
{

    DLC_EVENT object;
    PDLC_EVENT p;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "DLC_EVENT at %#.8x:\n\n"
           "\t                 LlcPacket:\n"
           "\t                     pNext 0x%08x\n"
           "\t                     pPrev 0x%08x\n"
           "\t            CompletionType 0x%02x [%s]\n"
           "\t               cbLlcHeader 0x%02x\n"
           "\t         InformationLength %d\n"
           "\t                  pBinding 0x%08x\n",
           addr,
           p->LlcPacket.pNext,
           p->LlcPacket.pPrev,
           p->LlcPacket.CompletionType,
           "",
           p->LlcPacket.cbLlcHeader,
           p->LlcPacket.InformationLength,
           p->LlcPacket.pBinding
           );

    dprintf("\t                    Status 0x%08x\n"
           "\t          CompletedCommand 0x%08x\n"
           "\t                pLlcObject 0x%08x\n"
           "\t             hClientHandle 0x%08x\n",
           p->LlcPacket.Data.Completion.Status,
           p->LlcPacket.Data.Completion.CompletedCommand,
           p->LlcPacket.Data.Completion.pLlcObject,
           p->LlcPacket.Data.Completion.hClientHandle
           );

    dprintf("\t                     Event 0x%08x\n"
           "\t                 StationId 0x%04x\n"
           "\t             StationIdMask 0x%04x\n"
           "\t              pOwnerObject 0x%08x\n"
           "\t         pEventInformation 0x%08x\n"
           "\t             SecondaryInfo 0x%08x\n"
           "\t            bFreeEventInfo 0x%02x\n"
           "\n",
           p->Event,
           p->StationId,
           p->Overlay.StationIdMask,
           p->pOwnerObject,
           p->pEventInformation,
           p->SecondaryInfo,
           p->bFreeEventInfo
           );

	addr = (DWORD)p->LlcPacket.pNext;
}

DECLARE_API(dx)
{

    DLC_OBJECT object;
    PDLC_OBJECT p;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "DLC_OBJECT at %#.8x:\n\n"
           "\t          pLinkStationList 0x%08x\n"
           "\t              pFileContext 0x%08x\n"
           "\t                 pRcvParms 0x%08x\n"
           "\t                hLlcObject 0x%08x\n"
           "\t             pReceiveEvent 0x%08x\n"
           "\t       pPrevXmitCcbAddress 0x%08x\n"
           "\t   pFirstChainedCcbAddress 0x%08x\n"
           "\t              pClosingInfo 0x%08x\n"
           "\t      CommittedBufferSpace 0x%08x\n"
           "\t      ChainedTransmitCount %d\n"
           "\t        PendingLlcRequests %d\n"
           "\t                 StationId 0x%04x\n"
           "\t                      Type 0x%02x [%s]\n"
           "\t               LinkAllCcbs 0x%02x\n"
           "\t                     State 0x%02x [%s]\n"
           "\t           LlcObjectExists 0x%02x\n"
           "\t         LlcReferenceCount %d\n",
           addr,
           p->pLinkStationList,
           p->pFileContext,
           p->pRcvParms,
           p->hLlcObject,
           p->pReceiveEvent,
           p->pPrevXmitCcbAddress,
           p->pFirstChainedCcbAddress,
           p->pClosingInfo,
           p->CommittedBufferSpace,
           p->ChainedTransmitCount,
           p->PendingLlcRequests,
           p->StationId,
           p->Type,
           $dx_type(p->Type),
           p->LinkAllCcbs,
           p->State,
           $dx_state(p->State),
           p->LlcObjectExists,
           p->LlcReferenceCount
           );

        switch (p->Type) {
        case DLC_SAP_OBJECT:
            dprintf("\t             DlcStatusFlag 0x%08x\n"
                   "\t      GlobalGroupSapHandle 0x%08x\n"
                   "\t        GroupSapHandleList 0x%08x\n"
                   "\t             GroupSapCount %d\n"
                   "\t           UserStatusValue 0x%04x\n"
                   "\t          LinkStationCount %d\n"
                   "\t           OptionsPriority 0x%02x\n"
                   "\t           MaxStationCount %d\n",
                   p->u.Sap.DlcStatusFlag,
                   p->u.Sap.GlobalGroupSapHandle,
                   p->u.Sap.GroupSapHandleList,
                   p->u.Sap.GroupSapCount,
                   p->u.Sap.UserStatusValue,
                   p->u.Sap.LinkStationCount,
                   p->u.Sap.OptionsPriority,
                   p->u.Sap.MaxStationCount
                   );
            break;

        case DLC_LINK_OBJECT:
            dprintf("\t                      pSap 0x%08x\n"
                   "\t              pStatusEvent 0x%08x\n"
                   "\t        MaxInfoFieldLength %d\n",
                   p->u.Link.pSap,
                   p->u.Link.pStatusEvent,
                   p->u.Link.MaxInfoFieldLength
                   );
            break;

        case DLC_DIRECT_OBJECT:
            dprintf("\t               OpenOptions 0x%04x\n"
                   "\t        ProtocolTypeOffset 0x%04x\n"
                   "\t          ProtocolTypeMask 0x%08x\n"
                   "\t         ProtocolTypeMatch 0x%08x\n",
                   p->u.Direct.OpenOptions,
                   p->u.Direct.ProtocolTypeOffset,
                   p->u.Direct.ProtocolTypeMask,
                   p->u.Direct.ProtocolTypeMatch
                   );
            break;
        }
    dprintf("\n");

	addr = 0;
}

DECLARE_API(ep)
{

    EVENT_PACKET object;
    PEVENT_PACKET p;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "EVENT_PACKET at %#.8x:\n\n"
           "\t                     pNext 0x%08x\n"
           "\t                     pPrev 0x%08x\n"
           "\t                  pBinding 0x%08x\n"
           "\t             hClientHandle 0x%08x\n"
           "\t         pEventInformation 0x%08x\n"
           "\t                     Event 0x%08x\n"
           "\t             SecondaryInfo 0x%08x\n"
           "\n",
           addr,
           p->pNext,
           p->pPrev,
           p->pBinding,
           p->hClientHandle,
           p->pEventInformation,
           p->Event,
           p->SecondaryInfo
           );

	addr = (DWORD)p->pNext;
}

DECLARE_API(fc)
{

    DLC_FILE_CONTEXT object;
    PDLC_FILE_CONTEXT p;
    BOOL ok;
    UINT i;
    BOOL firstTime;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );
    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "DLC_FILE_CONTEXT structure at %#.8x:\n\n",
           addr
           );

    dprintf("\t                      List 0x%08x\n",
           p->List
           );

#if !defined(DLC_UNILOCK)
    dprintf("\t                  SpinLock 0x%08x, 0x%08x\n",
           p->SpinLock.SpinLock,
           p->SpinLock.OldIrql
           );
#endif

    dprintf("\t               hBufferPool 0x%08x\n"
           "\t       hExternalBufferPool 0x%08x\n"
           "\t               hPacketPool 0x%08x\n"
           "\t          hLinkStationPool 0x%08x\n"
           "\t           pBindingContext 0x%08x\n"
           "\t          AdapterCheckFlag 0x%08x\n"
           "\t         NetworkStatusFlag 0x%08x\n"
           "\t               PcErrorFlag 0x%08x\n"
           "\t          SystemActionFlag 0x%08x\n",
           p->hBufferPool,
           p->hExternalBufferPool,
           p->hPacketPool,
           p->hLinkStationPool,
           p->pBindingContext,
           p->AdapterCheckFlag,
           p->NetworkStatusFlag,
           p->PcErrorFlag,
           p->SystemActionFlag
           );

    dprintf("\t                EventQueue 0x%08x, 0x%08x %s\n"
           "\t              CommandQueue 0x%08x, 0x%08x %s\n"
           "\t              ReceiveQueue 0x%08x, 0x%08x %s\n"
           "\t          FlowControlQueue 0x%08x, 0x%08x %s\n"
           "\t               pTimerQueue 0x%08x\n"
           "\t       pSecurityDescriptor 0x%08x\n"
           "\t                FileObject 0x%08x\n"
           "\t      WaitingTransmitCount %d\n"
           "\t          ActualNdisMedium 0x%08x\n",
           p->EventQueue.Flink,
           p->EventQueue.Blink,
           (p->EventQueue.Flink == &((PDLC_FILE_CONTEXT)addr)->EventQueue) ? "(empty)" : "",
           p->CommandQueue.Flink,
           p->CommandQueue.Blink,
           (p->CommandQueue.Flink == &((PDLC_FILE_CONTEXT)addr)->CommandQueue) ? "(empty)" : "",
           p->ReceiveQueue.Flink,
           p->ReceiveQueue.Blink,
           (p->ReceiveQueue.Flink == &((PDLC_FILE_CONTEXT)addr)->ReceiveQueue) ? "(empty)" : "",
           p->FlowControlQueue.Flink,
           p->FlowControlQueue.Blink,
           (p->FlowControlQueue.Flink == &((PDLC_FILE_CONTEXT)addr)->FlowControlQueue) ? "(empty)" : "",
           p->pTimerQueue,
           p->pSecurityDescriptor,
           p->FileObject,
           p->WaitingTransmitCount,
           p->ActualNdisMedium
           );

    dprintf("\t            ReferenceCount %d\n"
           "\t  BufferPoolReferenceCount %d\n"
           "\t          TimerTickCounter %d\n"
           "\t            DlcObjectCount %d\n"
           "\t                     State 0x%04x [%s]\n"
           "\t            MaxFrameLength %d\n"
           "\t             AdapterNumber 0x%02x\n"
           "\t          LinkStationCount %d\n",
           p->ReferenceCount,
           p->BufferPoolReferenceCount,
           p->TimerTickCounter,
           p->DlcObjectCount,
           p->State,
           $fc_state(p->State),
           p->MaxFrameLength,
           p->AdapterNumber,
           p->LinkStationCount
           );

    dprintf("\t           SapStationTable ");
    firstTime = TRUE;
    for (i = 0; i < MAX_SAP_STATIONS; ++i) {
        if (p->SapStationTable[i]) {
            if (!firstTime) {
                dprintf("\t                           ");
            }
            firstTime = FALSE;
            dprintf("SAP  0x%02x Object = 0x%08x\n", i * 2, p->SapStationTable[i]);
        }
    }
    if (firstTime) {
        dprintf("\n");
    }

    dprintf("\t          LinkStationTable ");
    firstTime = TRUE;
    for (i = 0; i < MAX_LINK_STATIONS; ++i) {
        if (p->LinkStationTable[i]) {
            if (!firstTime) {
                dprintf("\t                           ");
            }
            firstTime = FALSE;
            dprintf("LINK 0x%02x Object = 0x%08x\n", i + 1, p->LinkStationTable[i]);
        }
    }
    if (firstTime) {
        dprintf("\n");
    }

    firstTime = TRUE;
    for (i = 0; i < ADAPTER_ERROR_COUNTERS; ++i) {
        if (firstTime) {
            dprintf("\t         NdisErrorCounters 0x%08x\n", p->NdisErrorCounters[i]);
            firstTime = FALSE;
        } else {
            dprintf("\t                           0x%08x\n", p->NdisErrorCounters[i]);
        }
    }

    dprintf("\t             ClosingPacket:\n");
    dump_close_wait_info(addr, &p->ClosingPacket, FALSE);

#if DBG
    dprintf("\t               MemoryUsage:\n");
    dump_memory_usage(addr, &p->MemoryUsage, FALSE);
#endif

    dprintf("\n");

	addr = (DWORD)p->List.Next;
}

DECLARE_API(fl)
{

    DLC_RESET_LOCAL_BUSY_CMD object;
    PDLC_RESET_LOCAL_BUSY_CMD p;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );
    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "DLC_RESET_LOCAL_BUSY_CMD structure at %#.8x:\n\n"
           "\t                      List 0x%08x, 0x%08x %s\n"
           "\t       RequiredBufferSpace 0x%08x\n"
           "\t                 StationId 0x%04x\n"
           "\n",
           addr,
           p->List.Flink,
           p->List.Blink,
           EMPTY_LIST(p, List, addr),
           p->RequiredBufferSpace,
           p->StationId
           );

	addr = (DWORD)p->List.Flink;
}

DECLARE_API(ll)
{

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;


    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    dump_data_link(addr, TRUE);

	addr = 0;
}

DECLARE_API(lt)
{

    PLLC_TIMER p;
    LLC_TIMER object;
    BOOL ok;

	static DWORD addr = (DWORD)0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "LLC_TIMER structure at %#.8x:\n\n"
           "\t                     pNext 0x%08x\n"
           "\t                     pPrev 0x%08x\n"
           "\t                pTimerTick 0x%08x\n"
           "\t            ExpirationTime 0x%08x\n"
           "\t                  hContext 0x%08x\n"
#if defined(LOCK_CHECK)
           "\t                  Disabled 0x%08x\n"
#endif
           "\n",
           addr,
           p->pNext,
           p->pPrev,
           p->pTimerTick,
           p->ExpirationTime,
           p->hContext

#if defined(LOCK_CHECK)
           ,
           p->Disabled
#endif
           );

	addr = (DWORD)p->pNext;
}

DECLARE_API(lx)
{

    PLLC_OBJECT p;
    LLC_OBJECT object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "LLC_OBJECT structure at %#.8x:\n"
           "\n",
           addr
           );

    dump_gen_object(&p->Gen);

    switch (p->Gen.ObjectType) {
    case LLC_SAP_OBJECT:
        dprintf("\t                 SourceSap 0x%04x\n"
               "\t               OpenOptions 0x%04x\n"
               "\t                Statistics:\n"
               "\t+        FramesTransmitted %u\n"
               "\t+           FramesReceived %u\n"
               "\t+     FramesDiscardedNoRcv %u\n"
               "\t+          DataLostCounter %u\n"
               "\t         DefaultParameters:\n"
               "\t+                  TimerT1 %d\n"
               "\t+                  TimerT2 %d\n"
               "\t+                  TimerTi %d\n"
               "\t+                   MaxOut %d\n"
               "\t+                    MaxIn %d\n"
               "\t+          MaxOutIncrement %d\n"
               "\t+            MaxRetryCount %d\n"
               "\t+  TokenRingAccessPriority 0x%02x\n"
               "\t+      MaxInformationField %d\n"
               "\t           FlowControlLock 0x%08x, 0x%08x\n"
               "\t              pActiveLinks 0x%08x\n",
               p->Sap.SourceSap,
               p->Sap.OpenOptions,
               p->Sap.Statistics.FramesTransmitted,
               p->Sap.Statistics.FramesReceived,
               p->Sap.Statistics.FramesDiscardedNoRcv,
               p->Sap.Statistics.DataLostCounter,
               p->Sap.DefaultParameters.TimerT1,
               p->Sap.DefaultParameters.TimerT2,
               p->Sap.DefaultParameters.TimerTi,
               p->Sap.DefaultParameters.MaxOut,
               p->Sap.DefaultParameters.MaxIn,
               p->Sap.DefaultParameters.MaxOutIncrement,
               p->Sap.DefaultParameters.MaxRetryCount,
               p->Sap.DefaultParameters.TokenRingAccessPriority,
               p->Sap.DefaultParameters.MaxInformationField,
               p->Sap.FlowControlLock.SpinLock,
               p->Sap.FlowControlLock.OldIrql,
               p->Sap.pActiveLinks
               );
        break;

    case LLC_GROUP_SAP_OBJECT:
    case LLC_DIX_OBJECT:
    case LLC_DIRECT_OBJECT:
        dprintf("\t             ObjectAddress 0x%04x\n"
               "\t               OpenOptions 0x%04x\n"
               "\t                Statistics:\n"
               "\t+        FramesTransmitted %u\n"
               "\t+           FramesReceived %u\n"
               "\t+     FramesDiscardedNoRcv %u\n"
               "\t+          DataLostCounter %u\n",
               p->Group.ObjectAddress,
               p->Group.OpenOptions,
               p->Group.Statistics.FramesTransmitted,
               p->Group.Statistics.FramesReceived,
               p->Group.Statistics.FramesDiscardedNoRcv,
               p->Group.Statistics.DataLostCounter
               );
        break;

    case LLC_LINK_OBJECT:
        dump_data_link(addr, FALSE);
        break;
    }
    dprintf("\n");

	addr = 0;
}

DECLARE_API(mdl)
{

    PMDL p;
    MDL object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "MDL structure at %#.8x:\n\n"
           "\t                      Next 0x%08x\n"
           "\t                      Size 0x%04x\n"
           "\t                  MdlFlags 0x%04x\n"
           "\t                   Process 0x%08x\n"
           "\t            MappedSystemVa 0x%08x\n"
           "\t                   StartVa 0x%08x\n"
           "\t                 ByteCount 0x%08x\n"
           "\t                ByteOffset 0x%08x\n"
           "\n",
           addr,
           p->Next,
           p->Size & 0xffff,
           p->MdlFlags & 0xffff,
           p->Process,
           p->MappedSystemVa,
           p->StartVa,
           p->ByteCount,
           p->ByteOffset
           );

	addr = (DWORD)p->Next;
}

DECLARE_API(mu)
{

    PMEMORY_USAGE p;
    MEMORY_USAGE object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dump_memory_usage(addr, p, TRUE);

	addr = (DWORD)p->List;
}

DECLARE_API(pc)
{

    PLLC_PACKET p;
    LLC_PACKET object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "LLC_PACKET (Completion) structure at %#.8x:\n\n"
           "\t                     pNext 0x%08x\n"
           "\t                     pPrev 0x%08x\n"
           "\t            CompletionType 0x%02x\n"
           "\t               cbLlcHeader 0x%02x\n"
           "\t         InformationLength 0x%04x\n"
           "\t                  pBinding 0x%08x\n"
           "\t                    Status 0x%08x\n"
           "\t          CompletedCommand 0x%08x\n"
           "\t                pLlcObject 0x%08x\n"
           "\t             hClientHandle 0x%08x\n"
           "\n",
           addr,
           p->pNext,
           p->pPrev,
           p->CompletionType & 0xff,
           p->cbLlcHeader & 0xff,
           p->InformationLength & 0xffff,
           p->pBinding,
           p->Data.Completion.Status,
           p->Data.Completion.CompletedCommand,
           p->Data.Completion.pLlcObject,
           p->Data.Completion.hClientHandle
           );

	addr = (DWORD)p->pNext;
}

DECLARE_API(pd)
{

    PLLC_PACKET p;
    LLC_PACKET object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "LLC_PACKET (XmitDix) structure at %#.8x:\n\n"
           "\t                     pNext 0x%08x\n"
           "\t                     pPrev 0x%08x\n"
           "\t            CompletionType 0x%02x\n"
           "\t               cbLlcHeader 0x%02x\n"
           "\t         InformationLength 0x%04x\n"
           "\t                  pBinding 0x%08x\n"
           "\t                pLanHeader 0x%08x\n"
           "\t           TranslationType 0x%02x\n"
           "\t      EthernetTypeHighByte 0x%02x\n"
           "\t       EthernetTypeLowByte 0x%02x\n"
           "\t                   Padding 0x%02x\n"
           "\t                pLlcObject 0x%08x\n"
           "\t                      pMdl 0x%08x\n"
           "\n",
           addr,
           p->pNext,
           p->pPrev,
           p->CompletionType & 0xff,
           p->cbLlcHeader & 0xff,
           p->InformationLength & 0xffff,
           p->pBinding,
           p->Data.XmitDix.pLanHeader,
           p->Data.XmitDix.TranslationType,
           p->Data.XmitDix.EthernetTypeHighByte,
           p->Data.XmitDix.EthernetTypeLowByte,
           p->Data.XmitDix.Padding,
           p->Data.XmitDix.pLlcObject,
           p->Data.XmitDix.pMdl
           );

	addr = (DWORD)p->pNext;
}

DECLARE_API(ph)
{

    PPACKET_HEAD p;
    PACKET_HEAD object;
    BOOL ok;
    char place[128];
    DWORD off;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "PACKET_HEAD structure at %#.8x:\n"
           "\n"
           "\t                      List 0x%08x\n"
           "\t                     Flags 0x%08x\n",
           addr,
           p->List,
           p->Flags
           );

#if DBG
    dprintf("\t                 Signature 0x%08x\n"
           "\t               pPacketPool 0x%08x\n",
           p->Signature,
           p->pPacketPool
           );
    dprintf("\t     Alloc: CallersAddress 0x%08x", p->CallersAddress_A);
    if (p->CallersAddress_A) {
        place[0] = 0;
        off = 0;
        ExtensionApis.lpGetSymbolRoutine(p->CallersAddress_A, place, &off);
        if (place[0]) {
            dprintf(" %s", place);
            if (off) {
                dprintf("+%#x", off);
            }
        }
    }
    dprintf("\n"
           "\t     Alloc:  CallersCaller 0x%08x", p->CallersCaller_A);
    if (p->CallersCaller_A) {
        place[0] = 0;
        off = 0;
        ExtensionApis.lpGetSymbolRoutine(p->CallersCaller_A, place, &off);
        if (place[0]) {
            dprintf(" %s", place);
            if (off) {
                dprintf("+%#x", off);
            }
        }
    }
    dprintf("\n"
           "\t     Free:  CallersAddress 0x%08x", p->CallersAddress_D);
    if (p->CallersAddress_D) {
        place[0] = 0;
        off = 0;
        ExtensionApis.lpGetSymbolRoutine(p->CallersAddress_D, place, &off);
        if (place[0]) {
            dprintf(" %s", place);
            if (off) {
                dprintf("+%#x", off);
            }
        }
    }
    dprintf("\n"
           "\t     Free:   CallersCaller 0x%08x", p->CallersCaller_D);
    if (p->CallersCaller_D) {
        place[0] = 0;
        off = 0;
        ExtensionApis.lpGetSymbolRoutine(p->CallersCaller_D, place, &off);
        if (place[0]) {
            dprintf(" %s", place);
            if (off) {
                dprintf("+%#x", off);
            }
        }
    }
#endif

    dprintf("\n");

	addr = 0;
}

DECLARE_API(png)
{

#if DBG

    PPRIVATE_NON_PAGED_POOL_HEAD p;
    PRIVATE_NON_PAGED_POOL_HEAD object;
    DWORD adjustedAddr;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    adjustedAddr = addr - (DWORD)&((PPRIVATE_NON_PAGED_POOL_HEAD)0)->GlobalList;
    ok = ExtensionApis.lpReadVirtualMemRoutine(
        adjustedAddr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dump_private_non_paged_pool(adjustedAddr, p);

	addr = 0;

#else

    dprintf("error: png: only active on DEBUG build of DLC.SYS/DLCX.DLL\n");

#endif

}

DECLARE_API(pnp)
     {

#if DBG

    PPRIVATE_NON_PAGED_POOL_HEAD p;
    PRIVATE_NON_PAGED_POOL_HEAD object;
    BOOL ok;
    DWORD adjustedAddr;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    adjustedAddr = addr - (DWORD)&((PPRIVATE_NON_PAGED_POOL_HEAD)0)->PrivateList;
    ok = ExtensionApis.lpReadVirtualMemRoutine(
        adjustedAddr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dump_private_non_paged_pool(adjustedAddr, p);

	addr = 0;

#else

    dprintf("error: pnp: only active on DEBUG build of DLC.SYS/DLCX.DLL\n");

#endif

}

#if DBG

VOID dump_private_non_paged_pool(DWORD adjustedAddr, PPRIVATE_NON_PAGED_POOL_HEAD p) {

    DWORD off;
    char place[128];

    dprintf("\n"
           "PRIVATE_NON_PAGED_POOL_HEAD at %#.8x:\n\n"
           "\t                      Size %d\n"
           "\t              OriginalSize %d\n"
           "\t                     Flags 0x%08x\n"
           "\t                 Signature 0x%08x\n"
           "\t                GlobalList 0x%08x, 0x%08x %s\n"
           "\t               PrivateList 0x%08x, 0x%08x %s\n",
           adjustedAddr,
           p->Size,
           p->OriginalSize,
           p->Flags,
           p->Signature,
           p->GlobalList.Flink,
           p->GlobalList.Blink,
           EMPTY_LIST(p, GlobalList, adjustedAddr),
           p->PrivateList.Flink,
           p->PrivateList.Blink,
           EMPTY_LIST(p, PrivateList, adjustedAddr)
           );

    dprintf("\t                  Stack[0] 0x%08x", p->Stack[0]);
    if (p->Stack[0]) {
        place[0] = 0;
        off = 0;
        ExtensionApis.lpGetSymbolRoutine(p->Stack[0], place, &off);
        if (place[0]) {
            dprintf(" %s", place);
            if (off) {
                dprintf("+%#x", off);
            }
        }
    }
    dprintf("\n");

    dprintf("\t                       [1] 0x%08x", p->Stack[1]);
    if (p->Stack[1]) {
        place[0] = 0;
        off = 0;
        ExtensionApis.lpGetSymbolRoutine(p->Stack[1], place, &off);
        if (place[0]) {
            dprintf(" %s", place);
            if (off) {
                dprintf("+%#x", off);
            }
        }
    }
    dprintf("\n");

    dprintf("\t                       [2] 0x%08x", p->Stack[2]);
    if (p->Stack[2]) {
        place[0] = 0;
        off = 0;
        ExtensionApis.lpGetSymbolRoutine(p->Stack[2], place, &off);
        if (place[0]) {
            dprintf(" %s", place);
            if (off) {
                dprintf("+%#x", off);
            }
        }
    }
    dprintf("\n");

    dprintf("\t                       [3] 0x%08x", p->Stack[3]);
    if (p->Stack[3]) {
        place[0] = 0;
        off = 0;
        ExtensionApis.lpGetSymbolRoutine(p->Stack[3], place, &off);
        if (place[0]) {
            dprintf(" %s", place);
            if (off) {
                dprintf("+%#x", off);
            }
        }
    }
    dprintf("\n\n");
}

#endif

DECLARE_API(pp)
     {

    PPACKET_POOL p;
    PACKET_POOL object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "PACKET_POOL structure at %#.8x:\n\n"
           "\t                  FreeList 0x%08x\n"
           "\t                  BusyList 0x%08x\n"
           "\t                  PoolLock 0x%08x\n"
           "\t                PacketSize 0x%08x\n",
           addr,
           p->FreeList,
           p->BusyList,
           p->PoolLock,
           p->PacketSize
           );

#if DBG
    dprintf("\t                 Signature 0x%08x\n"
           "\t                    Viable 0x%08x\n"
           "\t       OriginalPacketCount %d\n"
           "\t        CurrentPacketCount %d\n"
           "\t               Allocations %d\n"
           "\t                     Frees %d\n"
           "\t             NoneFreeCount %d\n"
           "\t                  MaxInUse %d\n"
           "\t                ClashCount %d\n"
           "\t                     Flags 0x%08x\n"
           "\t           ObjectSignature 0x%08x\n"
           "\t              pMemoryUsage 0x%08x\n"
           "\t               MemoryUsage:\n",
           p->Signature,
           p->Viable,
           p->OriginalPacketCount,
           p->CurrentPacketCount,
           p->Allocations,
           p->Frees,
           p->NoneFreeCount,
           p->MaxInUse,
           p->ClashCount,
           p->Flags,
           p->ObjectSignature,
           p->pMemoryUsage
           );
    dump_memory_usage(addr, &p->MemoryUsage, FALSE);
    dprintf("\t                 FreeCount %d\n"
           "\t                 BusyCount %d\n"
           "\t                      Pad1 0x%08x\n"
           "\t                      Pad2 0x%08x\n",
           p->FreeCount,
           p->BusyCount,
           p->Pad1,
           p->Pad2
           );
#endif

    dprintf("\n");

	addr = 0;
}

DECLARE_API(pr)
{

    PLLC_PACKET p;
    LLC_PACKET object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "LLC_PACKET (Response) structure at %#.8x:\n\n"
           "\t                     pNext 0x%08x\n"
           "\t                     pPrev 0x%08x\n"
           "\t            CompletionType 0x%02x\n"
           "\t               cbLlcHeader 0x%02x\n"
           "\t         InformationLength 0x%04x\n"
           "\t                  pBinding 0x%08x\n"
           "\t                pLanHeader 0x%08x\n"
           "\t           TranslationType 0x%02x\n"
           "\t                      Dsap 0x%02x\n"
           "\t                      Ssap 0x%02x\n"
           "\t                   Command 0x%02x\n"
           "\t                      Info %02x %02x %02x %02x %02x %02x %02x %02x\n"
           "\n",
           addr,
           p->pNext,
           p->pPrev,
           p->CompletionType & 0xff,
           p->cbLlcHeader & 0xff,
           p->InformationLength & 0xffff,
           p->pBinding,
           p->Data.Response.pLanHeader,
           p->Data.Response.TranslationType,
           p->Data.Response.Dsap,
           p->Data.Response.Ssap,
           p->Data.Response.Command,
           p->Data.Response.Info.Padding[0],
           p->Data.Response.Info.Padding[1],
           p->Data.Response.Info.Padding[2],
           p->Data.Response.Info.Padding[3],
           p->Data.Response.Info.Padding[4],
           p->Data.Response.Info.Padding[5],
           p->Data.Response.Info.Padding[6],
           p->Data.Response.Info.Padding[7]
           );

	addr = (DWORD)p->pNext;
}

DECLARE_API(pu)
{

    PLLC_PACKET p;
    LLC_PACKET object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "LLC_PACKET (XmitU) structure at %#.8x:\n\n"
           "\t                     pNext 0x%08x\n"
           "\t                     pPrev 0x%08x\n"
           "\t            CompletionType 0x%02x\n"
           "\t               cbLlcHeader 0x%02x\n"
           "\t         InformationLength 0x%04x\n"
           "\t                  pBinding 0x%08x\n"
           "\t                pLanHeader 0x%08x\n"
           "\t           TranslationType 0x%02x\n"
           "\t                      Dsap 0x%02x\n"
           "\t                      Ssap 0x%02x\n"
           "\t                   Command 0x%02x\n"
           "\t                pLlcObject 0x%08x\n"
           "\t                      pMdl 0x%08x\n"
           "\n",
           addr,
           p->pNext,
           p->pPrev,
           p->CompletionType & 0xff,
           p->cbLlcHeader & 0xff,
           p->InformationLength & 0xffff,
           p->pBinding,
           p->Data.XmitU.pLanHeader,
           p->Data.XmitU.TranslationType,
           p->Data.XmitU.Dsap,
           p->Data.XmitU.Ssap,
           p->Data.XmitU.Command,
           p->Data.XmitU.pLlcObject,
           p->Data.XmitU.pMdl
           );

	addr = (DWORD)p->pNext;
}

DECLARE_API(px)
{

    PLLC_PACKET p;
    LLC_PACKET object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "LLC_PACKET (Xmit) structure at %#.8x:\n\n"
           "\t                     pNext 0x%08x\n"
           "\t                     pPrev 0x%08x\n"
           "\t            CompletionType 0x%02x\n"
           "\t               cbLlcHeader 0x%02x\n"
           "\t         InformationLength 0x%04x\n"
           "\t                  pBinding 0x%08x\n"
           "\t                pLanHeader 0x%08x\n"
           "\t                 LlcHeader %02x %02x %02x %02x\n"
           "\t                pLlcObject 0x%08x\n"
           "\t                      pMdl 0x%08x\n"
           "\n",
           addr,
           p->pNext,
           p->pPrev,
           p->CompletionType & 0xff,
           p->cbLlcHeader & 0xff,
           p->InformationLength & 0xffff,
           p->pBinding,
           p->Data.Xmit.pLanHeader,
           p->Data.Xmit.LlcHeader.auchRawBytes[0],
           p->Data.Xmit.LlcHeader.auchRawBytes[1],
           p->Data.Xmit.LlcHeader.auchRawBytes[2],
           p->Data.Xmit.LlcHeader.auchRawBytes[3],
           p->Data.Xmit.pLlcObject,
           p->Data.Xmit.pMdl
           );

	addr = (DWORD)p->pNext;
}

DECLARE_API(req)
     {

    DWORD val = ExtensionApis.lpGetExpressionRoutine(pArgStr);
    LPSTR str;

    switch (val) {
    case IOCTL_DLC_READ:
        str = "READ";
        break;

    case IOCTL_DLC_RECEIVE:
        str = "RECEIVE";
        break;

    case IOCTL_DLC_TRANSMIT:
        str = "TRANSMIT";
        break;

    case IOCTL_DLC_BUFFER_FREE:
        str = "BUFFER.FREE";
        break;

    case IOCTL_DLC_BUFFER_GET:
        str = "BUFFER.GET";
        break;

    case IOCTL_DLC_BUFFER_CREATE:
        str = "BUFFER.CREATE";
        break;

    case IOCTL_DLC_SET_EXCEPTION_FLAGS:
        str = "DIR.SET.EXCEPTION.FLAGS";
        break;

    case IOCTL_DLC_CLOSE_STATION:
        str = "DLC.CLOSE.STATION";
        break;

    case IOCTL_DLC_CONNECT_STATION:
        str = "DLC.CONNECT.STATION";
        break;

    case IOCTL_DLC_FLOW_CONTROL:
        str = "DLC.FLOW.CONTROL";
        break;

    case IOCTL_DLC_OPEN_STATION:
        str = "DLC.OPEN.STATION";
        break;

    case IOCTL_DLC_RESET:
        str = "DLC.RESET";
        break;

    case IOCTL_DLC_READ_CANCEL:
        str = "READ.CANCEL";
        break;

    case IOCTL_DLC_RECEIVE_CANCEL:
        str = "RECEIVE.CANCEL";
        break;

    case IOCTL_DLC_QUERY_INFORMATION:
        str = "DlcQueryInformation";
        break;

    case IOCTL_DLC_SET_INFORMATION:
        str = "DlcSetInformation";
        break;

    case IOCTL_DLC_TIMER_CANCEL:
        str = "DIR.TIMER.CANCEL";
        break;

    case IOCTL_DLC_TIMER_CANCEL_GROUP:
        str = "DIR.TIMER.CANCEL.GROUP";
        break;

    case IOCTL_DLC_TIMER_SET:
        str = "DIR.TIMER.SET";
        break;

    case IOCTL_DLC_OPEN_SAP:
        str = "DLC.OPEN.SAP";
        break;

    case IOCTL_DLC_CLOSE_SAP:
        str = "DLC.CLOSE.SAP";
        break;

    case IOCTL_DLC_OPEN_DIRECT:
        str = "DIR.OPEN.DIRECT";
        break;

    case IOCTL_DLC_CLOSE_DIRECT:
        str = "DIR.CLOSE.DIRECT";
        break;

    case IOCTL_DLC_OPEN_ADAPTER:
        str = "DIR.OPEN.ADAPTER";
        break;

    case IOCTL_DLC_CLOSE_ADAPTER:
        str = "DIR.CLOSE.ADAPTER";
        break;

    case IOCTL_DLC_REALLOCTE_STATION:
        str = "DLC.REALLOCATE";
        break;

    case IOCTL_DLC_READ2:
        str = "READ2";
        break;

    case IOCTL_DLC_RECEIVE2:
        str = "RECEIVE2";
        break;

    case IOCTL_DLC_TRANSMIT2:
        str = "TRANSMIT2";
        break;

    case IOCTL_DLC_COMPLETE_COMMAND:
        str = "DlcCompleteCommand";
        break;

    default:
        str = "*** UNKNOWN IOCTL CODE ***";
        break;
    }

    dprintf("DLC IoCtl code %x = %s\n", val, str);

}

DECLARE_API(tt)
{

    PTIMER_TICK p;
    TIMER_TICK object;
    BOOL ok;

	static DWORD addr = 0;
	addr = *pArgStr ? ExtensionApis.lpGetExpressionRoutine(pArgStr) : addr;

    if (!addr) {
        dprintf("dlcx: error: address expression (0)\n");
        return;
    }

    ok = ExtensionApis.lpReadVirtualMemRoutine(
        addr,
        &object,
        sizeof(object),
        NULL
        );

    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object;

    dprintf("\n"
           "TIMER_TICK structure at %#.8x:\n\n"
           "\t                     pNext 0x%08x\n"
//           "\t                     pPrev 0x%08x\n"
           "\t                    pFront 0x%08x\n"
//           "\t                 pSpinLock 0x%08x\n"
           "\t                 DeltaTime 0x%08x\n"
           "\t                     Input 0x%04x\n"
           "\t            ReferenceCount 0x%04x\n"
           "\n",
           addr,
           p->pNext,
//           p->pPrev,
           p->pFront,
//           p->pSpinLock,
           p->DeltaTime,
           p->Input,
           p->ReferenceCount
           );

	addr = (DWORD)p->pNext;
}

VOID dump_gen_object(PLLC_GENERIC_OBJECT p) {


    dprintf("\t                       Gen:\n"
           "\t+                    pNext 0x%08x\n"
           "\t+               ObjectType 0x%02x [%s]\n"
           "\t+             EthernetType 0x%02x\n"
           "\t+               usReserved 0x%04x\n"
           "\t+          pAdapterContext 0x%08x\n"
           "\t+              pLlcBinding 0x%08x\n"
           "\t+            hClientHandle 0x%08x\n"
           "\t+       pCompletionPackets 0x%08x\n"
           "\t+           ReferenceCount %d\n",
           p->pNext,
           p->ObjectType,
           $lx_type(p->ObjectType),
           p->EthernetType,
           p->usReserved,
           p->pAdapterContext,
           p->pLlcBinding,
           p->hClientHandle,
           p->pCompletionPackets,
           p->ReferenceCount
           );
}

VOID dump_data_link(DWORD addr, BOOL DumpAll) {

    PDATA_LINK p;
    DATA_LINK object[2];    // use 2 DATA_LINKs so we get the MAC addr overflow
    BOOL ok;
    int i;
    int macAddrLength;
    int macAddrLengthArray[3] = {32, 6, 0};

    //
    // just in case we can't read the arbitrary 32 bytes of MAC address, try
    // the more usual 6 bytes. If that doesn't work, ignore the MAC address
    //

    for (i = 0; i < 3; ++i) {

        macAddrLength = macAddrLengthArray[i];

        ok = ExtensionApis.lpReadVirtualMemRoutine(
            addr,
            &object[0],
            sizeof(DATA_LINK) + macAddrLength,    // for MAC addr
            NULL
            );

        if (ok) {
            break;
        }
    }
    if (!ok) {
        dprintf("dlcx: error: can't copy object locally\n");
        return;
    }

    p = &object[0];
    if (DumpAll) {
        dprintf("\n"
               "DATA_LINK structure at %#.8x:\n"
               "\n",
               addr
               );
        dump_gen_object(&p->Gen);
    }

    dprintf("\t                     Is_Ct 0x%04x\n"
           "\t                     Ia_Ct 0x%04x\n"
           "\t                     State 0x%02x [%s]\n"
           "\t                     Ir_Ct 0x%02x\n"
           "\t                        Vs 0x%02x\n"
           "\t                        Vr 0x%02x\n"
           "\t                        Pf 0x%02x\n"
           "\t                        Va 0x%02x\n"
           "\t                        Vp 0x%02x\n"
           "\t                        Vb 0x%02x\n"
           "\t                        Vc 0x%02x\n"
           "\t                        Vi 0x%02x\n"
           "\t                   TimerT1 0x%02x\n"
           "\t                   TimerT2 0x%02x\n"
           "\t                   TimerTi 0x%02x\n"
           "\t                    MaxOut 0x%02x\n"
           "\t                        RW 0x%02x\n"
           "\t                        Nw 0x%02x\n"
           "\t                        N2 0x%02x\n"
           "\t                AccessPrty 0x%02x\n"
           "\t                 MaxIField 0x%04x\n"
           "\t                        Ww 0x%02x\n"
           "\t                        N3 0x%02x\n"
           "\t                      P_Ct 0x%02x\n"
           "\t                        Nr 0x%02x\n",
           p->Is_Ct,
           p->Ia_Ct,
           p->State,
           $data_link_state(p->State),
           p->Ir_Ct,
           p->Vs,
           p->Vr,
           p->Pf,
           p->Va,
           p->Vp,
           p->Vb,
           p->Vc,
           p->Vi,
           p->TimerT1,
           p->TimerT2,
           p->TimerTi,
           p->MaxOut,
           p->RW,
           p->Nw,
           p->N2,
           p->AccessPrty,
           p->MaxIField,
           p->Ww,
           p->N3,
           p->P_Ct,
           p->Nr
           );

    dprintf("\tLastTimeWhenCmdPollWasSent 0x%04x\n"
           "\t       AverageResponseTime 0x%04x\n"
           "\t         cbLanHeaderLength 0x%02x\n"
           "\t         VrDuringLocalBusy 0x%02x\n"
           "\t                     Flags 0x%02x\n"
           "\t                        TW 0x%02x\n"
           "\t       FullWindowTransmits 0x%04x\n"
           "\t               T1_Timeouts 0x%02x\n"
           "\t                RemoteOpen 0x%02x\n",
           p->LastTimeWhenCmdPollWasSent,
           p->AverageResponseTime,
           p->cbLanHeaderLength,
           p->VrDuringLocalBusy,
           p->Flags,
           p->TW,
           p->FullWindowTransmits,
           p->T1_Timeouts,
           p->RemoteOpen
           );

    dprintf("\t                        T1:\n"
           "\t+                    pNext 0x%08x\n"
           "\t+                    pPrev 0x%08x\n"
           "\t+               pTimerTick 0x%08x\n"
           "\t+           ExpirationTime 0x%08x\n"
           "\t+                 hContext 0x%08x\n",
           p->T1.pNext,
           p->T1.pPrev,
           p->T1.pTimerTick,
           p->T1.ExpirationTime,
           p->T1.hContext
           );

#if defined(LOCK_CHECK)
    dprintf("\t+                 Disabled 0x%08x\n",
           p->T1.Disabled
           );
#endif

    dprintf("\t                        T2:\n"
           "\t+                    pNext 0x%08x\n"
           "\t+                    pPrev 0x%08x\n"
           "\t+               pTimerTick 0x%08x\n"
           "\t+           ExpirationTime 0x%08x\n"
           "\t+                 hContext 0x%08x\n",
           p->T2.pNext,
           p->T2.pPrev,
           p->T2.pTimerTick,
           p->T2.ExpirationTime,
           p->T2.hContext
           );

#if defined(LOCK_CHECK)
    dprintf("\t+                 Disabled 0x%08x\n",
           p->T2.Disabled
           );
#endif

    dprintf("\t                        Ti:\n"
           "\t+                    pNext 0x%08x\n"
           "\t+                    pPrev 0x%08x\n"
           "\t+               pTimerTick 0x%08x\n"
           "\t+           ExpirationTime 0x%08x\n"
           "\t+                 hContext 0x%08x\n",
           p->Ti.pNext,
           p->Ti.pPrev,
           p->Ti.pTimerTick,
           p->Ti.ExpirationTime,
           p->Ti.hContext
           );

#if defined(LOCK_CHECK)
    dprintf("\t+                 Disabled 0x%08x\n",
           p->Ti.Disabled
           );
#endif

    dprintf("\t                 SendQueue:\n"
           "\t+                ListEntry 0x%08x 0x%08x\n"
           "\t+                 ListHead 0x%08x 0x%08x\n"
           "\t+                  pObject 0x%08x\n"
           "\t                 SentQueue 0x%08x 0x%08x\n"
           "\t                 pNextNode 0x%08x\n"
           "\t                  LinkAddr DSAP=%02x SSAP=%02x NODE=%02x-%02x-%02x-%02x-%02x-%02x\n"
           "\t                      pSap 0x%08x\n",
           p->SendQueue.ListEntry.Flink,
           p->SendQueue.ListEntry.Blink,
           p->SendQueue.ListHead.Flink,
           p->SendQueue.ListHead.Blink,
           p->SendQueue.pObject,
           p->SentQueue.Flink,
           p->SentQueue.Blink,
           p->pNextNode,
           p->LinkAddr.Node.DestSap,
           p->LinkAddr.Node.SrcSap,
           p->LinkAddr.Node.auchAddress[0] & 0xff,
           p->LinkAddr.Node.auchAddress[1] & 0xff,
           p->LinkAddr.Node.auchAddress[2] & 0xff,
           p->LinkAddr.Node.auchAddress[3] & 0xff,
           p->LinkAddr.Node.auchAddress[4] & 0xff,
           p->LinkAddr.Node.auchAddress[5] & 0xff,
           p->pSap
           );

    dprintf("\t                 DlcStatus:\n"
           "\t+               StatusCode 0x%04x\n"
           "\t+                 FrmrData:\n"
           "\t++                 Command 0x%02x\n"
           "\t++                    Ctrl 0x%02x\n"
           "\t++                      Vs 0x%02x\n"
           "\t++                      Vr 0x%02x\n"
           "\t++                  Reason 0x%02x\n"
           "\t+        uchAccessPriority 0x%02x\n"
           "\t+           auchRemoteNode %02x-%02x-%02x-%02x-%02x-%02x\n"
           "\t+             uchRemoteSap 0x%02x\n"
           "\t+              uchLocalSap 0x%02x\n"
           "\t+          hLlcLinkStation 0x%08x\n",
           p->DlcStatus.StatusCode,
           p->DlcStatus.FrmrData.Command,
           p->DlcStatus.FrmrData.Ctrl,
           p->DlcStatus.FrmrData.Vs,
           p->DlcStatus.FrmrData.Vr,
           p->DlcStatus.FrmrData.Reason,
           p->DlcStatus.uchAccessPriority,
           p->DlcStatus.auchRemoteNode[0] & 0xff,
           p->DlcStatus.auchRemoteNode[1] & 0xff,
           p->DlcStatus.auchRemoteNode[2] & 0xff,
           p->DlcStatus.auchRemoteNode[3] & 0xff,
           p->DlcStatus.auchRemoteNode[4] & 0xff,
           p->DlcStatus.auchRemoteNode[5] & 0xff,
           p->DlcStatus.uchRemoteSap,
           p->DlcStatus.uchLocalSap,
           p->DlcStatus.hLlcLinkStation
           );

    dprintf("\t                Statistics:\n"
           "\t+      I_FramesTransmitted %u\n"
           "\t+         I_FramesReceived %u\n"
           "\t+     I_FrameReceiveErrors %u\n"
           "\t+I_FrameTransmissionErrors %u\n"
           "\t+       T1_ExpirationCount %u\n"
           "\t         LastCmdOrRespSent 0x%02x\n"
           "\t     LastCmdOrRespReceived 0x%02x\n"
           "\t                      Dsap 0x%02x\n"
           "\t                      Ssap 0x%02x\n"
           "\t          BufferCommitment 0x%08x\n"
           "\t               FramingType %d [%s]\n",
           p->Statistics.I_FramesTransmitted,
           p->Statistics.I_FramesReceived,
           p->Statistics.I_FrameReceiveErrors,
           p->Statistics.I_FrameTransmissionErrors,
           p->Statistics.T1_ExpirationCount,
           p->LastCmdOrRespSent,
           p->LastCmdOrRespReceived,
           p->Dsap,
           p->Ssap,
           p->BufferCommitment,
           p->FramingType,
           $address_translation(p->FramingType)
           );
    if (macAddrLength) {
        dprintf("\t             auchLanHeader ");
        for (i = 0; i < macAddrLength; ++i) {
            dprintf("%02x ", p->auchLanHeader[i]);
            if (i && !((i + 1) % 8)) {
                dprintf("\n\t                           ");
            }
        }
        dprintf("\n");
    }
    dprintf("\n");
}

VOID dump_memory_usage(DWORD addr, PMEMORY_USAGE p, BOOL DumpAll) {
    if (DumpAll) {
        dprintf("\n"
               "MEMORY_USAGE structure at 0x%08x\n"
               "\n",
               addr
               );
    }
    dprintf("\t%c                     List 0x%08x\n"
           "\t%c                 SpinLock 0x%08x\n"
           "\t%c                    Owner 0x%08x\n"
           "\t%c            OwnerObjectId 0x%08x [%s]\n"
           "\t%c            OwnerInstance %d\n"
           "\t%c    NonPagedPoolAllocated %d\n"
           "\t%c            AllocateCount %d\n"
           "\t%c                FreeCount %d\n"
           "\t%c              PrivateList 0x%08x, 0x%08x %s\n"
           "\t%c                   Unused 0x%08x 0x%08x\n",
           DumpAll ? ' ' : '+',
           p->List,
           DumpAll ? ' ' : '+',
           p->SpinLock,
           DumpAll ? ' ' : '+',
           p->Owner,
           DumpAll ? ' ' : '+',
           p->OwnerObjectId,
           $object_id(p->OwnerObjectId),
           DumpAll ? ' ' : '+',
           p->OwnerInstance,
           DumpAll ? ' ' : '+',
           p->NonPagedPoolAllocated,
           DumpAll ? ' ' : '+',
           p->AllocateCount,
           DumpAll ? ' ' : '+',
           p->FreeCount,
           DumpAll ? ' ' : '+',
           p->PrivateList.Flink,
           p->PrivateList.Blink,
           EMPTY_LIST(p, PrivateList, addr),
           DumpAll ? ' ' : '+',
           p->Unused[0],
           p->Unused[1]
           );
    if (DumpAll) {
        dprintf("\n");
    }
}

LPSTR buffer_state$(BYTE state) {

    static char buf[256];
    BYTE comb;
    LPSTR str;
    LPSTR bp = buf;
    BOOL first = TRUE;

    buf[0] = 0;
    for (comb = 1; comb; comb <<= 1) {
        switch (state & comb) {
        case 0: str = NULL; break;
        case BUF_READY: str = "BUF_READY"; break;
        case BUF_USER: str = "BUF_USER"; break;
        case BUF_LOCKED: str = "BUF_LOCKED"; break;
        case BUF_RCV_PENDING: str = "BUF_RCV_PENDING"; break;
        case DEALLOCATE_AFTER_USE: str = "DEALLOCATE_AFTER_USE"; break;
        default: str = "UNKNOWN %02x"; break;
        }
        if (str) {
            if (!first) {
                bp += sprintf(bp, " ");
            } else {
                first = FALSE;
            }
            bp += sprintf(bp, str, state & comb);
        }
    }
    return buf;
}

LPSTR $lx_type(BYTE type) {
    switch (type) {
    case LLC_DIRECT_OBJECT:
        return "DIRECT";

    case LLC_SAP_OBJECT:
        return "SAP";

    case LLC_GROUP_SAP_OBJECT:
        return "GROUP SAP";

    case LLC_LINK_OBJECT:
        return "LINK";

    case LLC_DIX_OBJECT:
        return "DIX";
    }
    return "*** UNKNOWN ***";
}

LPSTR $data_link_state(BYTE state) {
    switch (state) {
    case LINK_CLOSED:
        return "LINK_CLOSED";

    case DISCONNECTED:
        return "DISCONNECTED";

    case LINK_OPENING:
        return "LINK_OPENING";

    case DISCONNECTING:
        return "DISCONNECTING";

    case FRMR_SENT:
        return "FRMR_SENT";

    case LINK_OPENED:
        return "LINK_OPENED";

    case LOCAL_BUSY:
        return "LOCAL_BUSY";

    case REJECTION:
        return "REJECTION";

    case CHECKPOINTING:
        return "CHECKPOINTING";

    case CHKP_LOCAL_BUSY:
        return "CHKP_LOCAL_BUSY";

    case CHKP_REJECT:
        return "CHKP_REJECT";

    case RESETTING:
        return "RESETTING";

    case REMOTE_BUSY:
        return "REMOTE_BUSY";

    case LOCAL_REMOTE_BUSY:
        return "LOCAL_REMOTE_BUSY";

    case REJECT_LOCAL_BUSY:
        return "REJECT_LOCAL_BUSY";

    case REJECT_REMOTE_BUSY:
        return "REJECT_REMOTE_BUSY";

    case CHKP_REJECT_LOCAL_BUSY:
        return "CHKP_REJECT_LOCAL_BUSY";

    case CHKP_CLEARING:
        return "CHKP_CLEARING";

    case CHKP_REJECT_CLEARING:
        return "CHKP_REJECT_CLEARING";

    case REJECT_LOCAL_REMOTE_BUSY:
        return "REJECT_LOCAL_REMOTE_BUSY";

    case FRMR_RECEIVED:
        return "FRMR_RECEIVED";
    }
    return "*** UNKNOWN ***";
}

LPSTR $fc_state(USHORT state) {
    switch (state) {
    case DLC_FILE_CONTEXT_OPEN:
        return "DLC_FILE_CONTEXT_OPEN";

    case DLC_FILE_CONTEXT_CLOSE_PENDING:
        return "DLC_FILE_CONTEXT_CLOSE_PENDING";

    case DLC_FILE_CONTEXT_CLOSED:
        return "DLC_FILE_CONTEXT_CLOSED";
    }
    return "*** UNKNOWN STATE ***";
}

LPSTR $dx_type(BYTE type) {
    switch (type) {
    case DLC_ADAPTER_OBJECT:
        return "DLC_ADAPTER_OBJECT";

    case DLC_SAP_OBJECT:
        return "DLC_SAP_OBJECT";

    case DLC_LINK_OBJECT:
        return "DLC_LINK_OBJECT";

    case DLC_DIRECT_OBJECT:
        return "DLC_DIRECT_OBJECT";
    }
    return "*** UNKNOWN TYPE ***";
}

LPSTR $dx_state(BYTE state) {
    switch (state) {
    case DLC_OBJECT_OPEN:
        return "DLC_OBJECT_OPEN";

    case DLC_OBJECT_CLOSING:
        return "DLC_OBJECT_CLOSING";

    case DLC_OBJECT_CLOSED:
        return "DLC_OBJECT_CLOSED";

    case DLC_OBJECT_INVALID_TYPE:
        return "DLC_OBJECT_INVALID_TYPE";
    }
    return "*** UNKNOWN STATE ***";
}

LPSTR $address_translation(UINT trans) {
    switch (trans) {
    case LLC_SEND_UNSPECIFIED:
        return "LLC_SEND_UNSPECIFIED";

    case LLC_SEND_802_5_TO_802_3:
        return "LLC_SEND_802_5_TO_802_3";

    case LLC_SEND_802_5_TO_DIX:
        return "LLC_SEND_802_5_TO_DIX";

    case LLC_SEND_802_5_TO_802_5:
        return "LLC_SEND_802_5_TO_802_5";

    case LLC_SEND_802_5_TO_FDDI:
        return "LLC_SEND_802_5_TO_FDDI";

    case LLC_SEND_DIX_TO_DIX:
        return "LLC_SEND_DIX_TO_DIX";

    case LLC_SEND_802_3_TO_802_3:
        return "LLC_SEND_802_3_TO_802_3";

    case LLC_SEND_802_3_TO_DIX:
        return "LLC_SEND_802_3_TO_DIX";

    case LLC_SEND_802_3_TO_802_5:
        return "LLC_SEND_802_3_TO_802_5";

    case LLC_SEND_UNMODIFIED:
        return "LLC_SEND_UNMODIFIED";

    case LLC_SEND_FDDI_TO_FDDI:
        return "LLC_SEND_FDDI_TO_FDDI";

    case LLC_SEND_FDDI_TO_802_5:
        return "LLC_SEND_FDDI_TO_802_5";

    case LLC_SEND_FDDI_TO_802_3:
        return "LLC_SEND_FDDI_TO_802_3";
    }
    return "*** UNKNOWN ADDRESS TRANSLATION ***";
}

LPSTR $frame_type(UINT type) {
    if (type >= LLC_FIRST_ETHERNET_TYPE) {
        return "LLC_FIRST_ETHERNET_TYPE";
    }
    switch (type) {
    case LLC_DIRECT_TRANSMIT:
        return "LLC_DIRECT_TRANSMIT";

    case LLC_DIRECT_MAC:
        return "LLC_DIRECT_MAC";

    case LLC_I_FRAME:
        return "LLC_I_FRAME";

    case LLC_UI_FRAME:
        return "LLC_UI_FRAME";

    case LLC_XID_COMMAND_POLL:
        return "LLC_XID_COMMAND_POLL";

    case LLC_XID_COMMAND_NOT_POLL:
        return "LLC_XID_COMMAND_NOT_POLL";

    case LLC_XID_RESPONSE_FINAL:
        return "LLC_XID_RESPONSE_FINAL";

    case LLC_XID_RESPONSE_NOT_FINAL:
        return "LLC_XID_RESPONSE_NOT_FINAL";

    case LLC_TEST_RESPONSE_FINAL:
        return "LLC_TEST_RESPONSE_FINAL";

    case LLC_TEST_RESPONSE_NOT_FINAL:
        return "LLC_TEST_RESPONSE_NOT_FINAL";

    case LLC_DIRECT_8022:
        return "LLC_DIRECT_8022";

    case LLC_TEST_COMMAND_POLL:
        return "LLC_TEST_COMMAND_POLL";

    case LLC_DIRECT_ETHERNET_TYPE:
        return "LLC_DIRECT_ETHERNET_TYPE";

    case LLC_LAST_FRAME_TYPE:
        return "LLC_LAST_FRAME_TYPE";
    }
    return "*** UNKNOWN FRAME TYPE ***";
}

LPSTR $object_id(UINT id) {
    switch (id) {
    case DlcDriverObject:
        return "DlcDriverObject";

    case FileContextObject:
        return "FileContextObject";

    case AdapterContextObject:
        return "AdapterContextObject";

    case BindingContextObject:
        return "BindingContextObject";

    case DlcSapObject:
        return "DlcSapObject";

    case DlcGroupSapObject:
        return "DlcGroupSapObject";

    case DlcLinkObject:
        return "DlcLinkObject";

    case DlcDixObject:
        return "DlcDixObject";

    case LlcDataLinkObject:
        return "LlcDataLinkObject";

    case LLcDirectObject:
        return "LLcDirectObject";

    case LlcSapObject:
        return "LlcSapObject";

    case LlcGroupSapObject:
        return "LlcGroupSapObject";

    case DlcBufferPoolObject:
        return "DlcBufferPoolObject";

    case DlcLinkPoolObject:
        return "DlcLinkPoolObject";

    case DlcPacketPoolObject:
        return "DlcPacketPoolObject";

    case LlcLinkPoolObject:
        return "LlcLinkPoolObject";

    case LlcPacketPoolObject:
        return "LlcPacketPoolObject";
    }
    return "*** UNKNOWN OBJECT TYPE ***";
}