summaryrefslogtreecommitdiffstats
path: root/private/ole32/olethunk/tools/infolvl/infolvl.cxx
blob: bd9bd79ed37bed9e6af50e12ad315a6ee208bab8 (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>


typedef struct _InfoLevelRecord
{
	char *pszInfoLevel;
	char *pszSectionName;
	char *pszDescription;
} InfoLevelRecord;

InfoLevelRecord ilrArray[] =
{
	{ "cairole", "Cairole Infolevels","Compobj layer" },
	{ "DD", "Cairole Infolevels","Drag & Drop" },
	{ "heap", "Cairole Infolevels","Heap trace output" },
	{ "hk", "Cairole Infolevels","Hook layer" },
	{ "intr","Cairole Infolevels","1.0/2.0 interop layer" },
	{ "le", "Cairole Infolevels", "Linking and embedding" },
	{ "mnk", "Cairole Infolevels", "Moniker tracing" },
	{ "msf", "Cairole Infolevels", "Upper layer storage" },
	{ "ol", "Cairole Infolevels", "Lower layer storage" },
	{ "ref", "Cairole Infolevels", "CSafeRef class (Cairo)" },
	{ "scm", "Cairole Infolevels", "OLE service" },
	{ "Stack", "Cairole Infolevels", "Stack switching (Win95)" },
	{ "StackOn", "Cairole Infolevels", "Stack switching enable (boolean,Win95)" },
	{ "prop", "Cairole Infolevels", "Storage property interfaces" },
	{ "api", "Cairole Infolevels","CompApi trace" },
	{ "breakoninit", "Olethk32","Break on initialization (boolean)" },
	{ "InfoLevel", "Olethk32","16/32 thunk layer (32-bit side)" },
	{ "ole2", "Olethk16","16/32 thunk layer: ole2.dll" },
	{ "stg",  "Olethk16","16/32 thunk layer: storage.dll" },
	{ "comp", "Olethk16","16/32 thunk layer: compobj.dll" },
	{ NULL, NULL }
};

typedef struct _AttrRecord
{
	char *pszAttr;
	char *pszSectionName;
	char *pszDescription;
} AttrRecord;

AttrRecord arArray[] =
{
	{ "DebugScreen", "Cairole Infolevels","Debugger Screen (Yes|No)" },
	{ "LogFile", "Cairole Infolevels","LogFile (\"<name>\"|\"\")" },
        { NULL, NULL}
};

char * LookupILSection (char * pszInfoLevel)
{
	InfoLevelRecord *pr;
	for ( pr = ilrArray ; pr->pszInfoLevel != NULL ; pr++)
	{
		if (_stricmp(pr->pszInfoLevel,pszInfoLevel) == 0)
		{
			break;
		}

	}
	return pr->pszSectionName;
}

void DumpInfoLevelRecords()
{
	InfoLevelRecord *pr;
	
	printf("%20s %-12s Currently\n","Section Name","Name");

	for ( pr = ilrArray ; pr->pszInfoLevel != NULL ; pr++)
	{
		printf("%20s %-12s (%08x) %s\n",
		       pr->pszSectionName,
		       pr->pszInfoLevel,
		       GetProfileInt(pr->pszSectionName,pr->pszInfoLevel,0),
		       pr->pszDescription);

	}

}

char * LookupASection (char * pszAttr)
{
	AttrRecord *pr;
	for ( pr = arArray ; pr->pszAttr != NULL ; pr++)
	{
		if (stricmp(pr->pszAttr,pszAttr) == 0)
		{
			break;
		}

	}
	return pr->pszSectionName;
}

void DumpAttrRecords()
{
	AttrRecord *pr;
        char buffer[256];
	
	printf("%20s %-12s Currently\n","Section Name","Name");

	for ( pr = arArray ; pr->pszAttr != NULL ; pr++)
	{
                GetProfileString(pr->pszSectionName,pr->pszAttr, "", buffer, sizeof(buffer));
		printf("%20s %-12s (%s) %s\n",
		       pr->pszSectionName,
		       pr->pszAttr,
		       buffer,
		       pr->pszDescription);

	}

}

void Usage(char *pszProgName)
{
	printf("Usage:\n\t%s <infolevel name> 0x<hexvalue>\tOR\n\t%s <attribute> <value>\n", pszProgName, pszProgName);
	printf("\nKnown infolevels are as follows\n\n");
	DumpInfoLevelRecords();
	printf("\nKnown attributes are as follows\n\n");
	DumpAttrRecords();
}

void _cdecl main(int argc, char *argv[])
{
	//
	// The command line specifies the infolevel, followed by the
	// value. There are a known set of infolevels.
	//
	//
	if (argc != 3)
	{
		Usage(argv[0]);
		return;
	}

	char *pszSectionName = LookupILSection(argv[1]);

        if (pszSectionName == NULL)
        {
                pszSectionName = LookupASection(argv[1]);
        }

	if (pszSectionName == NULL)
	{
		printf("Don't recognize %s as an infolevel or attribute\n",argv[1]);
		Usage(argv[0]);
		return;
	}

	if(!WriteProfileString(pszSectionName,argv[1],argv[2]))
	{
		printf("Error: WriteProfileString returns false\n");
		printf("GetLastError returns %x\n",GetLastError());
	}
}