summaryrefslogtreecommitdiffstats
path: root/private/sdktools/instaler/showinst.c
blob: 9cba9b2b31ee2806625e602e403f0eb9e20b8227 (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
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
/*++

Copyright (c) 1992  Microsoft Corporation

Module Name:

    showinst.c

Abstract:

    This program displays the contents of an Installation Modification Log file
    created by the INSTALER program

Author:

    Steve Wood (stevewo) 15-Jan-1996

Revision History:

--*/

#include "instutil.h"
#include "iml.h"

BOOLEAN DisplayContentsOfTextFiles;

int
ProcessShowIml(
    PINSTALLATION_MODIFICATION_LOGFILE pIml
    );

int
_CRTAPI1
main(
    int argc,
    char *argv[]
    )
{
    int Result;
    char *s;
    PWSTR pw;
    PINSTALLATION_MODIFICATION_LOGFILE pIml;

    InitCommonCode( "SHOWINST",
                    "[-c]",
                    "-c specifies to display the contents of text files\n"
                  );
    DisplayContentsOfTextFiles = FALSE;
    while (--argc) {
        s = *++argv;
        if (*s == '-' || *s == '/') {
            while (*++s) {
                switch( tolower( *s ) ) {
                    case 'c':
                        DisplayContentsOfTextFiles = TRUE;
                        break;
                    default:
                        CommonSwitchProcessing( &argc, &argv, *s );
                        break;
                    }
                }
            }
        else
        if (!CommonArgProcessing( &argc, &argv )) {
            Usage( "Arguments not supported - '%s'", (ULONG)s );
            }
        }

    if (ImlPath == NULL) {
        Usage( "Must specify an installation name as first argument", 0 );
        }

    if (!SetCurrentDirectory( InstalerDirectory )) {
        FatalError( "Unable to change to '%ws' directory (%u)",
                    (ULONG)InstalerDirectory,
                    GetLastError()
                  );
        }

    pIml = LoadIml( ImlPath );
    if (pIml == NULL) {
        FatalError( "Unable to open '%ws' (%u)",
                    (ULONG)ImlPath,
                    GetLastError()
                  );
        }
    Result = ProcessShowIml( pIml );

    CloseIml( pIml );
    exit( Result );
    return Result;
}

int
ProcessShowIml(
    PINSTALLATION_MODIFICATION_LOGFILE pIml
    )
{
    PIML_FILE_RECORD pFile;
    PIML_FILE_RECORD_CONTENTS pOldFile;
    PIML_FILE_RECORD_CONTENTS pNewFile;
    PIML_KEY_RECORD pKey;
    PIML_VALUE_RECORD pValue;
    PIML_VALUE_RECORD_CONTENTS pOldValue;
    PIML_VALUE_RECORD_CONTENTS pNewValue;
    PIML_INI_RECORD pIni;
    PIML_INISECTION_RECORD pSection;
    PIML_INIVARIABLE_RECORD pVariable;
    BOOLEAN FileNameShown;
    BOOLEAN SectionNameShown;

    if (pIml->NumberOfFileRecords > 0) {
        printf( "File Modifications:\n" );
        pFile = MP( PIML_FILE_RECORD, pIml, pIml->FileRecords );
        while (pFile != NULL) {
            pOldFile = MP( PIML_FILE_RECORD_CONTENTS, pIml, pFile->OldFile );
            pNewFile = MP( PIML_FILE_RECORD_CONTENTS, pIml, pFile->NewFile );
            printf( "    %ws - ", MP( PWSTR, pIml, pFile->Name ) );
            switch( pFile->Action ) {
                case CreateNewFile:
                    printf( "created\n" );
                    break;

                case ModifyOldFile:
                    printf( "overwritten\n" );
                    if (pOldFile != NULL) {
                        printf( "        Old size is %u bytes\n", pOldFile->FileSize );
                        }
                    break;

                case DeleteOldFile:
                    printf( "deleted\n" );
                    if (pOldFile != NULL) {
                        printf( "        Old size is %u bytes\n", pOldFile->FileSize );
                        }
                    break;

                case ModifyFileDateTime:
                    printf( "date/time modified\n" );
                    break;

                case ModifyFileAttributes:
                    printf( "attributes modified\n" );
                    break;
                }

            pFile = MP( PIML_FILE_RECORD, pIml, pFile->Next );
            }

        printf( "\n" );
        }

    if (pIml->NumberOfKeyRecords > 0) {
        printf( "Registry Modifications:\n" );
        pKey = MP( PIML_KEY_RECORD, pIml, pIml->KeyRecords );
        while (pKey != NULL) {
            printf( "    %ws - ", MP( PWSTR, pIml, pKey->Name ) );
            switch( pKey->Action ) {
                case CreateNewKey:
                    printf( "created\n" );
                    break;

                case DeleteOldKey:
                    printf( "deleted\n" );
                    break;


                case ModifyKeyValues:
                    printf( "modified\n" );
                    break;

                }

            pValue = MP( PIML_VALUE_RECORD, pIml, pKey->Values );
            while (pValue != NULL) {
                pOldValue = MP( PIML_VALUE_RECORD_CONTENTS, pIml, pValue->OldValue );
                pNewValue = MP( PIML_VALUE_RECORD_CONTENTS, pIml, pValue->NewValue );
                printf( "        %ws - ", MP( PWSTR, pIml, pValue->Name ) );
                if (pValue->Action != DeleteOldValue) {
                    printf( "%s [%x]",
                            FormatEnumType( 0, ValueDataTypeNames, pNewValue->Type, FALSE ),
                            pNewValue->Length
                          );
                    if (pNewValue->Type == REG_SZ ||
                        pNewValue->Type == REG_EXPAND_SZ
                       ) {
                        printf( " '%ws'", MP( PWSTR, pIml, pNewValue->Data ) );
                        }
                    else
                    if (pNewValue->Type == REG_DWORD) {
                        printf( " 0x%x", *MP( PULONG, pIml, pNewValue->Data ) );
                        }
                    }

                if (pValue->Action == CreateNewValue) {
                    printf( " (created)\n" );
                    }
                else  {
                    if (pValue->Action == DeleteOldValue) {
                        printf( " (deleted" );
                        }
                    else {
                        printf( " (modified" );
                        }

                    printf( " - was %s [%x]",
                            FormatEnumType( 0, ValueDataTypeNames, pOldValue->Type, FALSE ),
                            pOldValue->Length
                          );
                    if (pOldValue->Type == REG_SZ ||
                        pOldValue->Type == REG_EXPAND_SZ
                       ) {
                        printf( " '%ws'", MP( PWSTR, pIml, pOldValue->Data ) );
                        }
                    else
                    if (pOldValue->Type == REG_DWORD) {
                        printf( " 0x%x", *MP( PULONG, pIml, pOldValue->Data ) );
                        }

                    printf( " )\n" );
                    }

                pValue = MP( PIML_VALUE_RECORD, pIml, pValue->Next );
                }

            pKey = MP( PIML_KEY_RECORD, pIml, pKey->Next );
            }

        printf( "\n" );
        }

    if (pIml->NumberOfIniRecords > 0) {
        printf( ".INI File modifications:\n" );
        pIni = MP( PIML_INI_RECORD, pIml, pIml->IniRecords );
        while (pIni != NULL) {
            FileNameShown = FALSE;
            pSection = MP( PIML_INISECTION_RECORD, pIml, pIni->Sections );
            while (pSection != NULL) {
                SectionNameShown = FALSE;
                pVariable = MP( PIML_INIVARIABLE_RECORD, pIml, pSection->Variables );
                while (pVariable != NULL) {
                    if (!FileNameShown) {
                        printf( "%ws", MP( PWSTR, pIml, pIni->Name ) );
                        if (pIni->Action == CreateNewIniFile) {
                            printf( " (created)" );
                            }
                        printf( "\n" );
                        FileNameShown = TRUE;
                        }

                    if (!SectionNameShown) {
                        printf( "    [%ws]", MP( PWSTR, pIml, pSection->Name ) );
                        if (pSection->Action == CreateNewSection) {
                            printf( " (created)" );
                            }
                        else
                        if (pSection->Action == DeleteOldSection) {
                            printf( " (deleted)" );
                            }
                        printf( "\n" );

                        SectionNameShown = TRUE;
                        }

                    printf( "        %ws = ", MP( PWSTR, pIml, pVariable->Name ) );
                    if (pVariable->Action == CreateNewVariable) {
                        printf( "'%ws' (created)\n", MP( PWSTR, pIml, pVariable->NewValue ) );
                        }
                    else
                    if (pVariable->Action == DeleteOldVariable) {
                        printf( " (deleted - was '%ws')\n", MP( PWSTR, pIml, pVariable->OldValue ) );
                        }
                    else {
                        printf( "'%ws' (modified - was '%ws')\n",
                                MP( PWSTR, pIml, pVariable->NewValue ),
                                MP( PWSTR, pIml, pVariable->OldValue )
                              );
                        }

                    pVariable = MP( PIML_INIVARIABLE_RECORD, pIml, pVariable->Next );
                    }

                pSection = MP( PIML_INISECTION_RECORD, pIml, pSection->Next );
                }

            if (FileNameShown) {
                printf( "\n" );
                }

            pIni = MP( PIML_INI_RECORD, pIml, pIni->Next );
            }
        }

    return 0;
}