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
|
/*++
Copyright (c) 1994 Microsoft Corporation
Module Name:
pointer.cxx
Abstract:
Author:
David Kays (dkays) August 1 1994
Revision History:
ryszardk Sept 15, 94 full pointers, interface pointers.
--*/
#include <sysinc.h>
#include <rpc.h>
#include <rpcndr.h>
#include <ntsdexts.h>
#include <ntdbg.h>
#include "ndrtypes.h"
#include "ndrp.h"
#include "bufout.hxx"
char * PointerNames[] =
{
"Ref",
"Unique",
"Object",
"Full"
};
unsigned long
POINTER::OutputPointerItself(
uchar PointerType )
{
unsigned long PointerValue;
if ( PointerType != FC_RP )
{
if ( OffsetToWireId == -1 )
{
Buffer->Align( 0x3 );
Buffer->Read( (char *) &PointerValue, 4 );
}
else
{
Buffer->Read( (char *) &PointerValue, 4, OffsetToWireId );
}
}
PrintIndent();
Print( "%s pointer <id=%d>", PointerNames[ PointerType - FC_RP ], MyId );
if ( PointerType != FC_RP )
Print( " <wire ref=0x%x>", PointerValue );
Print( "\n" );
return( PointerValue );
}
void
POINTER::Output()
{
uchar Format[4];
unsigned long PointerValue;
NDR * Ndr;
uchar ReferentType;
if ( fOutputLimitReached )
return;
//
// Get the pointer's description.
//
FormatString->Read( FormatOffset, Format, 4 );
PointerValue = OutputPointerItself( Format[0] );
IndentInc();
if ( (Format[0] != FC_RP) && (PointerValue == 0) )
{
PrintIndent();
Print( "NULL\n" );
IndentDec();
return;
}
if ( Format[0] == FC_FP )
{
// We use wire id as the dictionary key for full pointers,
// instead of offset used for structs etc.
if ( FullPointerDict->IsInDictionary( PointerValue ) )
{
PrintIndent();
Print( "This pointer done\n");
IndentDec();
return;
}
else
FullPointerDict->Register( PointerValue, this );
}
if ( SIMPLE_POINTER(Format[1]) )
{
Ndr = Create( FormatOffset + 2, this );
}
else
{
FormatOffset += 2;
FormatOffset += *((signed short *)&Format[2]);
FormatString->Read( FormatOffset, &ReferentType, 1 );
Ndr = Create( ReferentType,
FormatOffset,
this );
}
Ndr->Output();
IndentDec();
delete Ndr;
}
uchar
POINTER::GetPointerFC()
{
uchar FC;
FormatString->Read( FormatOffset, & FC, 1);
return( FC );
}
void
IF_POINTER::Output()
/*++
For the contant pointers the NDR representation is equivalent to:
struct
{
long size;
[size_is(size)] byte data[];
}
For the variable pointers the NDR representation is equivalent to:
struct
{
long size;
[size_is(size)] byte data[];
}
Note:
GUUD,
This is going to change when Shannon changes the engine to:
struct
{
GUID uuid;
long size;
[size_is(size)] byte data[];
}
--*/
{
uchar Format[ 4 ], GUID [ 16 ];
unsigned long Size, SizeAgain;
if ( fOutputLimitReached )
return;
// See where the GUID comes from.
FormatString->Read( FormatOffset, Format, 2 );
if ( Format[1] == FC_CONSTANT_IID )
{
Print( "Interface pointer with constant IID\n" );
FormatString->Read( FormatOffset + 2, GUID, 16 );
}
else
{
Print( "Interface pointer with variable IID\n" );
// Skip the description of [iid_is()] attribute.
// Read the GUID from the buffer.
FormatString->Read( FormatOffset, Format, 4 );
Buffer->Read( (char *)GUID, 16 );
}
IndentInc();
Print( "GUID is %08x-%04x-%04x-",
GET_ULONG( GUID ),
GET_USHORT( GUID + 4),
GET_USHORT( GUID + 6) );
Print( "%02x%02x-",
(unsigned char)GUID[ 8 ],
(unsigned char)GUID[ 9 ] );
for (int i = 0; i < 6; i++)
Print( "%02x", (unsigned char)GUID[ 10 + i ] );
Print( "\n" );
// Now the open array.
// Read the conformant size for the open array.
Buffer->Align( 3 );
Buffer->Read( (char *)&Size, sizeof(long) );
Print( "Data size is %ld", Size );
// Skip the size field of the struct.
Buffer->Read( (char *)&SizeAgain, sizeof(long) );
if ( SizeAgain != Size)
Print( " SizeAgain = %ld ???", SizeAgain );
if ( Size )
{
char * pBuffer = new char[ Size ];
Buffer->Read( pBuffer, Size );
for (uint j = 0; j < Size; j++ )
{
if ( (j % 16) == 0 )
{
Print( "\n" );
PrintIndent();
}
Print(" %02x", (unsigned char)pBuffer[j] );
}
delete pBuffer;
}
Print( "\n" );
IndentDec();
}
|