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
|
//+-------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1995
//
// File: dpsclsid.cxx
//
// Contents: Ole NTSD extension routines to dump the proxy/stub
// clsid cache
//
// Functions: psClsidHelp
// displayPsClsidTbl
//
//
// History: 06-01-95 BruceMa Created
//
//
//--------------------------------------------------------------------------
#include <ole2int.h>
#include <windows.h>
#include "ole.h"
#include "dshrdmem.h"
BOOL IsEqualCLSID(CLSID *pClsid1, CLSID *pClsid2);
void FormatCLSID(REFGUID rguid, LPSTR lpsz);
BOOL GetRegistryInterfaceName(REFIID iid, char *szValue, DWORD *pcbValue);
BOOL GetRegistryClsidKey(REFCLSID clsid, char *szKey,
char *szValue, DWORD *pcbValue);
//+-------------------------------------------------------------------------
//
// Function: psClsidHelp
//
// Synopsis: Display a menu for the command 'ps'
//
// Arguments: -
//
// Returns: -
//
// History: 07-Mar-95 BruceMa Created
//
//--------------------------------------------------------------------------
void psClsidHelp(PNTSD_EXTENSION_APIS lpExtensionApis)
{
Printf("ps - Display infomation for all IID's\n");
Printf("ps IID - Display infomation for IID\n");
}
//+-------------------------------------------------------------------------
//
// Function: displayPsClsidTbl
//
// Synopsis: Given an interface IID display the CLSID of the
// associated proxy/stub handler dll
//
// Arguments: [hProcess] - Handle of this process
// [lpExtensionApis] - Table of extension functions
// [lpFileExtTbl] - Address of file extensions table
// [pClsid] - Only for this clsid
//
// Returns: -
//
// History: 01-Jun-95 BruceMa Created
//
//--------------------------------------------------------------------------
void displayPsClsidTbl(HANDLE hProcess,
PNTSD_EXTENSION_APIS lpExtensionApis,
SDllShrdTbl *pShrdTbl,
IID *pIid)
{
SDllShrdTbl sDllTbl;
GUIDMAP sGuidMap;
GUIDPAIR *pGuidPair;
DWORDPAIR *pDwordPair;
IID iid = {0, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}};
char szClsid[CLSIDSTR_MAX];
char szName[129];
DWORD cbValue;
// Read the shared table locally
ReadMem(&sDllTbl, pShrdTbl, sizeof(SDllShrdTbl));
// Read the guid map locally
ReadMem(&sGuidMap, sDllTbl._PSClsidTbl._pGuidMap, sizeof(GUIDMAP));
// Allocate for the guid pair list
pGuidPair = (GUIDPAIR *) OleAlloc(sGuidMap.ulCntLong * sizeof(GUIDPAIR));
// Allocate for the dword pair list
pDwordPair = (DWORDPAIR *) OleAlloc(sGuidMap.ulCntShort *
sizeof(DWORDPAIR));
// Read the guid pair list
ReadMem(pGuidPair, sDllTbl._PSClsidTbl._pLongList -
(sGuidMap.ulCntLong - 1),
sGuidMap.ulCntLong * sizeof(GUIDPAIR));
// Read the dword pair list
ReadMem(pDwordPair, sDllTbl._PSClsidTbl._pShortList,
sGuidMap.ulCntShort * sizeof(DWORDPAIR));
// Are we looking for a specific IID?
if (pIid != NULL)
{
// Search the short list first
for (UINT cCnt = 0; cCnt < sGuidMap.ulCntShort; pDwordPair++, cCnt++)
{
if (pIid->Data1 == pDwordPair->dw1)
{
iid.Data1 = pIid->Data1;
// Fetch and print the interface name
cbValue = 64;
if(GetRegistryInterfaceName(iid, szName, &cbValue))
{
Printf("%s\t", szName);
}
else
{
Printf("-\t");
}
// The clsid
iid.Data1 = pDwordPair->dw2;
FormatCLSID(iid, szClsid);
Printf("%s\t", szClsid);
// Fetch and print the proxy/stub handler dll
cbValue = 128;
if (GetRegistryClsidKey(iid, "InprocServer32", szName,
&cbValue))
{
Printf("%s\n", szName);
}
else if(GetRegistryClsidKey(iid, "InprocServer", szName,
&cbValue))
{
Printf("%s(16)\n", szName);
}
else
{
Printf("-\n");
}
return;
}
}
// Search the long list next
for (cCnt = 0; cCnt < sGuidMap.ulCntLong; pGuidPair++, cCnt++)
{
if (IsEqualCLSID(pIid, &pGuidPair->guid1))
{
// Fetch and print the interface name
cbValue = 64;
if(GetRegistryInterfaceName(pGuidPair->guid1, szName,
&cbValue))
{
Printf("%s\t", szName);
}
else
{
Printf("-\t");
}
// The clsid
FormatCLSID(pGuidPair->guid2, szClsid);
Printf("%s\t", szClsid);
// Fetch and print the proxy/stub handler dll
cbValue = 128;
if (GetRegistryClsidKey(pGuidPair->guid2, "InprocServer32",
szName,
&cbValue))
{
Printf("%s\n", szName);
}
else if(GetRegistryClsidKey(pGuidPair->guid2, "InprocServer",
szName, &cbValue))
{
Printf("%s(16)\n", szName);
}
else
{
Printf("-\n");
}
return;
}
}
}
// Else dump everything
else
{
// Print header
Printf("where -. = '-0000-0000-C000-000000000046}'\n\n");
Printf(" IID interface clsid p/s dll\n");
Printf("----------- ------------------ ----------- ---------\n");
// Do over the short list
for (UINT cCnt = 0 ; cCnt < sGuidMap.ulCntShort; pDwordPair++, cCnt++)
{
// Print the IID
iid.Data1 = pDwordPair->dw1;
FormatCLSID(iid, szClsid);
if (lstrcmp(&szClsid[9], "-0000-0000-C000-000000000046}") == 0)
{
szClsid[9] = '\0';
Printf("%s-.", szClsid);
}
else
{
Printf("%s\n", szClsid);
}
// Fetch and print the interface name
cbValue = 64;
if(GetRegistryInterfaceName(iid, szName, &cbValue))
{
Printf(" %s", szName);
}
else
{
Printf(" -");
}
// Do some pretty printing alignment
for (UINT cCh = 24 - lstrlen(szName); cCh > 0; cCh--)
{
Printf(" ");
}
Printf(" ");
// The clsid
iid.Data1 = pDwordPair->dw2;
FormatCLSID(iid, szClsid);
if (lstrcmp(&szClsid[9], "-0000-0000-C000-000000000046}") == 0)
{
szClsid[9] = '\0';
Printf("%s-.\t", szClsid);
}
else
{
Printf("%s\t", szClsid);
}
// Fetch and print the proxy/stub handler dll
cbValue = 128;
if (GetRegistryClsidKey(iid, "InprocServer32", szName, &cbValue))
{
Printf("%s\n", szName);
}
else if(GetRegistryClsidKey(iid, "InprocServer", szName,
&cbValue))
{
Printf("%s(16)\n", szName);
}
else
{
Printf("-\n");
}
}
// Do over the long list
for (cCnt = 0; cCnt < sGuidMap.ulCntLong; pGuidPair++, cCnt++)
{
// Print the IID
FormatCLSID(pGuidPair->guid1, szClsid);
Printf("%s ", szClsid);
// Fetch and print the interface name
cbValue = 64;
if(GetRegistryInterfaceName(pGuidPair->guid1, szName, &cbValue))
{
Printf(" %s", szName);
}
else
{
Printf(" -");
}
// Do some pretty printing alignment
for (UINT cCh = 24 - lstrlen(szName); cCh > 0; cCh--)
{
Printf(" ");
}
Printf(" ");
// The clsid
FormatCLSID(pGuidPair->guid2, szClsid);
if (lstrcmp(&szClsid[9], "-0000-0000-C000-000000000046}") == 0)
{
szClsid[9] = '\0';
Printf("%s-.\t", szClsid);
}
else
{
Printf("%s\t", szClsid);
}
// Fetch and print the proxy/stub handler dll
cbValue = 128;
if (GetRegistryClsidKey(pGuidPair->guid2, "InprocServer32",
szName, &cbValue))
{
Printf("%s\n", szName);
}
else if(GetRegistryClsidKey(iid, "InprocServer32", szName,
&cbValue))
{
Printf("%s(16)\n", szName);
}
else
{
Printf("-\n");
}
}
}
// Release allocated resources
OleFree(pGuidPair);
OleFree(pDwordPair);
}
|