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
|
//+-------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1995
//
// File: drot.cxx
//
// Contents: Ole NTSD extension routines to display the ROT
//
// Functions: displayRot
//
//
// History: 06-01-95 BruceMa Created
// 06-26-95 BruceMa Add SCM ROT support
//
//
//--------------------------------------------------------------------------
#include <ole2int.h>
#include <windows.h>
#include "ole.h"
#include "drot.h"
void FormatCLSID(REFGUID rguid, LPSTR lpsz);
//+-------------------------------------------------------------------------
//
// Function: cliRotHelp
//
// Synopsis: Display a menu for the command 'rt'
//
// Arguments: -
//
// Returns: -
//
// History: 01-Jun-95 BruceMa Created
//
//--------------------------------------------------------------------------
void cliRotHelp(PNTSD_EXTENSION_APIS lpExtensionApis)
{
Printf("rt - Display the Running Object Table:\n");
Printf("Client side ROT\n");
Printf("sig\tcall?\t(scmLoc scmId)\thApt\n");
Printf("...\n\n");
Printf("Client side hint table\n");
Printf("<indices of set indicators>\n");
}
//+-------------------------------------------------------------------------
//
// Function: scmRotHelp
//
// Synopsis: Display a menu for the command 'rt'
//
// Arguments: -
//
// Returns: -
//
// History: 01-Jun-95 BruceMa Created
//
//--------------------------------------------------------------------------
void scmRotHelp(PNTSD_EXTENSION_APIS lpExtensionApis)
{
Printf("rt - Display the Running Object Table:\n");
Printf("Client side ROT\n");
Printf("sig\tcall?\t(scmLoc scmId)\thApt\n");
Printf("...\n\n");
Printf("Client side hint table\n");
Printf("<indices of set indicators>\n");
}
//+-------------------------------------------------------------------------
//
// Function: displayCliRot
//
// Synopsis: Formats and writes an ole processes' version of the
// ROT to the debug terminal
//
// Arguments: [hProcess] - Handle of this process
// [lpExtensionApis] - Table of extension functions
//
// Returns: -
//
// History: 01-Jun-95 BruceMa Created
//
//--------------------------------------------------------------------------
void displayCliRot(HANDLE hProcess, PNTSD_EXTENSION_APIS lpExtensionApis)
{
ULONG padr;
SRunningObjectTable *psRot;
SRunningObjectTable sRot;
SRotItem sRotItm;
SRotItem **ppsRotItm;
SRotItem *psRotItm;
int cSize;
// Read the CRunningObjectTable
padr = GetExpression("ole32!pRot");
ReadMem(&psRot, padr, sizeof(SRunningObjectTable *));
ReadMem(&sRot, psRot, sizeof(SRunningObjectTable));
// Read the array of pointers to ROT items
UINT ulSize = sRot._afvRotList.m_nSize * sizeof(SRotItem *);
ppsRotItm = (SRotItem **) OleAlloc(ulSize);
ReadMem(ppsRotItm, sRot._afvRotList.m_pData, ulSize);
// Display the ROT items in the table
Printf("Client side ROT\n");
for (cSize = 0; cSize < sRot._afvRotList.m_nSize; cSize++)
{
psRotItm = ppsRotItm[cSize];
if (psRotItm != NULL)
{
// Fetch the next ROT item
ReadMem(&sRotItm, psRotItm, sizeof(SRotItem));
// Display this ROT item
if (sRotItm._fDontCallApp)
{
Printf("%d\tTRUE\t(%x %x)\t%x\n",
sRotItm._wItemSig,
sRotItm._scmregkey.dwEntryLoc,
sRotItm._scmregkey.dwScmId,
sRotItm._hApt);
}
else
{
Printf("%d\tFALSE\t(%x %x)\t%x\n",
sRotItm._wItemSig,
sRotItm._scmregkey.dwEntryLoc,
sRotItm._scmregkey.dwScmId,
sRotItm._hApt);
}
}
}
// Display the client side ROT hint table
BYTE *pHint;
UINT k, l;
// Read the client side ROT hint table
pHint = (BYTE *) OleAlloc(SCM_HASH_SIZE * sizeof(DWORD));
ReadMem(pHint, sRot._crht._pbHintArray, SCM_HASH_SIZE * sizeof(BYTE));
// Display the client side hint table
Printf("\nClient side hint table\n");
for (l = 0, k = 0; k < SCM_HASH_SIZE; k++)
{
if (l == 16)
{
Printf("\n");
l = 0;
}
if (pHint[k])
{
Printf("%02d ", k);
l++;
}
}
if (l > 1)
{
Printf("\n");
}
// Delete resources
OleFree(ppsRotItm);
OleFree(pHint);
}
//+-------------------------------------------------------------------------
//
// Function: displayScmRot
//
// Synopsis: Formats and writes the full ROT to the debug terminal
//
// Arguments: [hProcess] - Handle of this process
// [lpExtensionApis] - Table of extension functions
//
// Returns: -
//
// History: 26-Jun-95 BruceMa Created
//
//--------------------------------------------------------------------------
void displayScmRot(HANDLE hProcess,
PNTSD_EXTENSION_APIS lpExtensionApis)
{
ULONG addr;
UINT cEnt;
char szClsid[CLSIDSTR_MAX];
SPerMachineROT sPerMachineRot;
SRotAcctEntry sRotAcctEntry;
SScmRot sScmRot;
SScmRotEntry **ppScmHashTbl;
SScmRotEntry *pScmRotEntry;
SScmRotEntry sScmRotEntry;
WCHAR wszSID[64];
char szSID[64];
MNKEQBUF *pMnkEqBfr;
IFData sIFData;
SYSTEMTIME sSystemTime;
// Get the address of the per machine ROT global
addr = GetExpression("scm!pPerMachineRot");
// Read the CPerMachineRot
ReadMem(&addr, addr, sizeof(ULONG));
ReadMem(&sPerMachineRot, addr, sizeof(SPerMachineROT));
// Read the first CRotAcctEntry
ReadMem(&sRotAcctEntry, sPerMachineRot._safvRotAcctTable.m_pData,
sizeof(SRotAcctEntry));
// Read the CScmRot table
ReadMem(&sScmRot, sRotAcctEntry.pscmrot, sizeof(SScmRot));
// Read the hash table of CScmRotEntry *'s
ppScmHashTbl = (SScmRotEntry **) OleAlloc(sScmRot._sht._ndwHashTableSize *
sizeof(SScmRotEntry *));
ReadMem(ppScmHashTbl, sScmRot._sht._apsheHashTable,
sScmRot._sht._ndwHashTableSize * sizeof(SScmRotEntry *));
// A header
ReadMem(wszSID, sRotAcctEntry.unicodestringSID, 64);
Unicode2Ansi(szSID, wszSID, 64);
szSID[32] = '\0';
Printf("\nSCM side ROT for SID %s\n\n", szSID);
// Do over entries in the hash table
for (cEnt = 0, pScmRotEntry = ppScmHashTbl[0];
cEnt < sScmRot._sht._ndwHashTableSize;
cEnt++, pScmRotEntry = ppScmHashTbl[cEnt])
{
// Only look at non-empty entries
while (pScmRotEntry)
{
// Read the CScmRotEntry
ReadMem(&sScmRotEntry, pScmRotEntry, sizeof(SScmRotEntry));
// Read the moniker comparison buffer
ULONG ulSize;
ReadMem(&ulSize, sScmRotEntry._pmkeqbufKey, sizeof(ULONG));
pMnkEqBfr = (MNKEQBUF *) OleAlloc(sizeof(ULONG) + ulSize);
ReadMem(pMnkEqBfr, sScmRotEntry._pmkeqbufKey,
sizeof(ULONG) + ulSize);
// Read the interface data buffer
ReadMem(&sIFData, sScmRotEntry._pifdObject,
sizeof(IFData));
// The registration Id
Printf("RegID: %x\n", sScmRotEntry._dwScmRotId);
// The moniker display name
Unicode2Ansi(szSID, pMnkEqBfr->_wszName, 64);
Printf("Display Name: %s\n", szSID);
// The last time changed
FileTimeToSystemTime(&sScmRotEntry._filetimeLastChange,
&sSystemTime);
Printf("Last Change: %2d:%02d:%02d %2d/%2d/%2d\n",
sSystemTime.wHour - 7,
sSystemTime.wMinute,
sSystemTime.wSecond,
sSystemTime.wMonth,
sSystemTime.wDay,
sSystemTime.wYear - 1900);
// The clsid of the moniker
FormatCLSID(pMnkEqBfr->_clsid, szClsid);
Printf("Moniker Type: %s\n", szClsid);
// The server unique id (from CoGetCurrentProcess())
Printf("Server ID: %d\n", sScmRotEntry._dwProcessID);
// The RPC end point
Unicode2Ansi(szSID, sIFData._wszEndPoint, 64);
Printf("Endpoint: %s\n", szSID);
// The object ID
FormatCLSID(sIFData._oid, szClsid);
Printf("Object OID: %s\n", szClsid);
// The IID of the object
FormatCLSID(sIFData._iid, szClsid);
Printf("Object IID: %s\n\n", szClsid);
// The hash table entry can be a list, i.e. a hash bucket, of
// ROT entries having the same hash value
pScmRotEntry = sScmRotEntry._sheNext;
// Release the moniker compare buffer
OleFree(pMnkEqBfr);
}
}
OleFree(ppScmHashTbl);
}
|