summaryrefslogtreecommitdiffstats
path: root/private/ole32/dbgexts/dtreatas.cxx
blob: e9c76a80b2548cd66fd9fcabf856ad126e13cc81 (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
140
141
142
//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (C) Microsoft Corporation, 1995
//
//  File:       dtreatas.cxx
//
//  Contents:   Ole NTSD extension routines to display a dll/class cache
//
//  Functions:  displayTreatAsCache
//
//
//  History:    06-01-95 BruceMa    Created
//
//
//--------------------------------------------------------------------------


#include <ole2int.h>
#include <windows.h>
#include "ole.h"
#include "dtreatas.h"


extern BOOL fInScm;


void FormatCLSID(REFGUID rguid, LPSTR lpsz);
BOOL IsEqualCLSID(CLSID *pClsid1, CLSID *pClsid2);




//+-------------------------------------------------------------------------
//
//  Function:   treatAsCacheHelp
//
//  Synopsis:   Display a menu for the command 'ds'
//
//  Arguments:  -
//
//  Returns:    -
//
//  History:    07-Mar-95   BruceMa    Created
//
//--------------------------------------------------------------------------
void treatAsCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis)
{
    Printf("ta         - Display entire TreatAs class cache:\n");
    Printf("ta clsid   - Display Treat As class for clsid (if any)\n");
}






//+-------------------------------------------------------------------------
//
//  Function:   displayTreatAsCache
//
//  Synopsis:   Formats and writes all or part of the TreatAs class cache
//
//  Arguments:  [hProcess]        -       Handle of this process
//              [lpExtensionApis] -       Table of extension functions
//              [REFCLSID]        -       If not CLSID_NULL only for this clsid
//
//  Returns:    -
//
//  History:    07-Mar-95   BruceMa    Created
//
//--------------------------------------------------------------------------
void displayTreatAsCache(HANDLE hProcess,
                         PNTSD_EXTENSION_APIS lpExtensionApis,
                         CLSID *clsid)
{
    ULONG          pAdr;
    BOOL           fRetail;
    ULONG          gptrtlstTreatClasses;
    ULONG          pTreatAs;
    STreatList     sTreatList;
    STreatEntry    *pTreatEntry;
    BOOL           fInit = TRUE;
    char           szClsid[CLSIDSTR_MAX];

    // Determine if this is checked or retail ole
    if (fInScm)
    {
        pAdr = GetExpression("scm!_CairoleInfoLevel");
    }
    else
    {
        pAdr = GetExpression("ole32!_CairoleInfoLevel");
    }
    fRetail = pAdr == NULL ? TRUE : FALSE;

    // Read the pointer to the TreatAs class cache
    gptrtlstTreatClasses = GetExpression("ole32!gptrtlstTreatClasses");
    ReadMem(&pTreatAs, gptrtlstTreatClasses, sizeof(ULONG));
    if (pTreatAs == NULL)
    {
        return;
    }

    // Read the TreatAs cache header
    ReadMem(&sTreatList, pTreatAs, sizeof(STreatList));

    Printf("                clsid                         is treated as clsid\n");
    Printf("-------------------------------------- --------------------------------------\n");

    if (sTreatList._centries > 0)
    {
        // Read the array of entries
        pTreatEntry = (STreatEntry *) OleAlloc(sTreatList._centries *
                                               sizeof(STreatEntry));
        ReadMem(pTreatEntry, sTreatList._array.m_pData,
                sTreatList._centries * sizeof(STreatEntry));

        for (DWORD i = 0; i < sTreatList._centries; i++)
        {
            // Display the clsid and the TreatAs clsid
            if (clsid == NULL)
            {
                FormatCLSID(pTreatEntry[i]._clsid, szClsid);
                Printf("%s ", szClsid);
                FormatCLSID(pTreatEntry[i]._treatAsClsid, szClsid);
                Printf("%s\n", szClsid);
            }

            // We are looking for a particular clsid
            else if (IsEqualCLSID(clsid, &pTreatEntry[i]._clsid))
            {
                FormatCLSID(pTreatEntry[i]._clsid, szClsid);
                Printf("%s ", szClsid);
                FormatCLSID(pTreatEntry[i]._treatAsClsid, szClsid);
                Printf("%s\n", szClsid);
                return;
            }
        }
    }
}