summaryrefslogtreecommitdiffstats
path: root/private/ntos/afd/afdkd/addr.c
blob: 61f9f3aea58831b2654c570751136663cf562c5d (plain) (blame)
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
/*++

Copyright (c) 1992  Microsoft Corporation

Module Name:

    addr.c

Abstract:

    Implements the addr command.

Author:

    Keith Moore (keithmo) 19-Apr-1995

Environment:

    User Mode.

Revision History:

--*/


#include "afdkdp.h"
#pragma hdrstop


//
// Public functions.
//

DECLARE_API( addr )

/*++

Routine Description:

    Dumps the TRANSPORT_ADDRESS structure at the specified address.

Arguments:

    None.

Return Value:

    None.

--*/

{

    DWORD address = 0;
    ULONG result;
    UCHAR transportAddress[MAX_TRANSPORT_ADDR];
    PTA_IP_ADDRESS ipAddress = (PTA_IP_ADDRESS)transportAddress;

    //
    // Snag the address from the command line.
    //

    sscanf( args, "%lx", &address );

    if( address == 0 ) {

        dprintf( "use: addr address\n" );
        return;

    }

    //
    // Assume the address is 22 bytes long (the same size as
    // a TA_IP_ADDRESS structure).  After we perform this initial
    // read, we can examine the structure to determine its actual
    // size.  If it's really larger than 22 bytes, we'll reread
    // the entire address structure.
    //

    if( !ReadMemory(
            address,
            transportAddress,
            sizeof(TA_IP_ADDRESS),
            &result
            ) ) {

        dprintf(
            "addr: cannot read TRANSPORT_ADDRESS @ %08lx\n",
            address
            );

        return;

    }

    if( ipAddress->TAAddressCount != 1 ) {

        dprintf(
            "addr: invalid TRANSPORT_ADDRESS @ %08lx\n",
            address
            );

        return;

    }

    if( ipAddress->Address[0].AddressLength > sizeof(TDI_ADDRESS_IP) ) {

        //
        // It's a big one.
        //

        if( !ReadMemory(
                address,
                transportAddress,
                ipAddress->Address[0].AddressLength +
                    ( sizeof(TA_IP_ADDRESS) - sizeof(TDI_ADDRESS_IP) ),
                &result
                ) ) {

            dprintf(
                "addr: cannot read TRANSPORT_ADDRESS @ %08lx\n",
                address
                );

            return;

        }

    }

    DumpTransportAddress(
        "",
        (PTRANSPORT_ADDRESS)transportAddress,
        address
        );

}   // addr