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
|
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
#include "precomp.h"
static HRESULT ParseFromXml(
__in IXMLDOMDocument* pixdDocument,
__in BURN_ENGINE_STATE* pEngineState
);
#if DEBUG
static void ValidateHarvestingAttributes(
__in IXMLDOMDocument* pixdDocument
);
#endif
// function definitions
extern "C" HRESULT ManifestLoadXmlFromFile(
__in LPCWSTR wzPath,
__in BURN_ENGINE_STATE* pEngineState
)
{
HRESULT hr = S_OK;
IXMLDOMDocument* pixdDocument = NULL;
// load xml document
hr = XmlLoadDocumentFromFile(wzPath, &pixdDocument);
ExitOnFailure(hr, "Failed to load manifest as XML document.");
hr = ParseFromXml(pixdDocument, pEngineState);
LExit:
ReleaseObject(pixdDocument);
return hr;
}
extern "C" HRESULT ManifestLoadXmlFromBuffer(
__in_bcount(cbBuffer) BYTE* pbBuffer,
__in SIZE_T cbBuffer,
__in BURN_ENGINE_STATE* pEngineState
)
{
HRESULT hr = S_OK;
IXMLDOMDocument* pixdDocument = NULL;
// load xml document
hr = XmlLoadDocumentFromBuffer(pbBuffer, cbBuffer, &pixdDocument);
ExitOnFailure(hr, "Failed to load manifest as XML document.");
#if DEBUG
ValidateHarvestingAttributes(pixdDocument);
#endif
hr = ParseFromXml(pixdDocument, pEngineState);
LExit:
ReleaseObject(pixdDocument);
return hr;
}
static HRESULT ParseFromXml(
__in IXMLDOMDocument* pixdDocument,
__in BURN_ENGINE_STATE* pEngineState
)
{
HRESULT hr = S_OK;
IXMLDOMElement* pixeBundle = NULL;
IXMLDOMNode* pixnChain = NULL;
// get bundle element
hr = pixdDocument->get_documentElement(&pixeBundle);
ExitOnFailure(hr, "Failed to get bundle element.");
hr = LoggingParseFromXml(&pEngineState->log, pixeBundle);
ExitOnFailure(hr, "Failed to parse logging.");
// get the chain element
hr = XmlSelectSingleNode(pixeBundle, L"Chain", &pixnChain);
ExitOnFailure(hr, "Failed to get chain element.");
if (S_OK == hr)
{
// parse disable rollback
hr = XmlGetYesNoAttribute(pixnChain, L"DisableRollback", &pEngineState->fDisableRollback);
if (E_NOTFOUND != hr)
{
ExitOnFailure(hr, "Failed to get Chain/@DisableRollback");
}
// parse disable system restore
hr = XmlGetYesNoAttribute(pixnChain, L"DisableSystemRestore", &pEngineState->internalCommand.fDisableSystemRestore);
if (E_NOTFOUND != hr)
{
ExitOnFailure(hr, "Failed to get Chain/@DisableSystemRestore");
}
// parse parallel cache
hr = XmlGetYesNoAttribute(pixnChain, L"ParallelCache", &pEngineState->fParallelCacheAndExecute);
if (E_NOTFOUND != hr)
{
ExitOnFailure(hr, "Failed to get Chain/@ParallelCache");
}
}
// parse built-in condition
hr = ConditionGlobalParseFromXml(&pEngineState->condition, pixeBundle);
ExitOnFailure(hr, "Failed to parse global condition.");
// parse variables
hr = VariablesParseFromXml(&pEngineState->variables, pixeBundle);
ExitOnFailure(hr, "Failed to parse variables.");
// parse user experience
hr = BootstrapperApplicationParseFromXml(&pEngineState->userExperience, pixeBundle);
ExitOnFailure(hr, "Failed to parse bootstrapper application.");
// parse extensions
hr = BurnExtensionParseFromXml(&pEngineState->extensions, &pEngineState->userExperience.payloads, pixeBundle);
ExitOnFailure(hr, "Failed to parse extensions.");
// parse searches
hr = SearchesParseFromXml(&pEngineState->searches, &pEngineState->extensions, pixeBundle);
ExitOnFailure(hr, "Failed to parse searches.");
// parse registration
hr = RegistrationParseFromXml(&pEngineState->registration, &pEngineState->cache, pixeBundle);
ExitOnFailure(hr, "Failed to parse registration.");
// parse update
hr = UpdateParseFromXml(&pEngineState->update, pixeBundle);
ExitOnFailure(hr, "Failed to parse update.");
// parse containers
hr = ContainersParseFromXml(&pEngineState->containers, pixeBundle);
ExitOnFailure(hr, "Failed to parse containers.");
// parse payloads
hr = PayloadsParseFromXml(&pEngineState->payloads, &pEngineState->containers, &pEngineState->layoutPayloads, pixeBundle);
ExitOnFailure(hr, "Failed to parse payloads.");
// parse packages
hr = PackagesParseFromXml(&pEngineState->packages, &pEngineState->payloads, pixeBundle);
ExitOnFailure(hr, "Failed to parse packages.");
// parse approved exes for elevation
hr = ApprovedExesParseFromXml(&pEngineState->approvedExes, pixeBundle);
ExitOnFailure(hr, "Failed to parse approved exes.");
LExit:
ReleaseObject(pixnChain);
ReleaseObject(pixeBundle);
return hr;
}
#if DEBUG
static void ValidateHarvestingAttributes(
__in IXMLDOMDocument* pixdDocument
)
{
HRESULT hr = S_OK;
IXMLDOMElement* pixeBundle = NULL;
LPWSTR sczEngineVersion = NULL;
DWORD dwProtocolVersion = 0;
BOOL fWin64 = FALSE;
hr = pixdDocument->get_documentElement(&pixeBundle);
ExitOnFailure(hr, "Failed to get document element.");
hr = XmlGetAttributeEx(pixeBundle, L"EngineVersion", &sczEngineVersion);
ExitOnRequiredXmlQueryFailure(hr, "Failed to get BurnManifest/@EngineVersion attribute.");
hr = XmlGetAttributeUInt32(pixeBundle, L"ProtocolVersion", &dwProtocolVersion);
ExitOnRequiredXmlQueryFailure(hr, "Failed to get BurnManifest/@ProtocolVersion attribute.");
hr = XmlGetYesNoAttribute(pixeBundle, L"Win64", &fWin64);
ExitOnRequiredXmlQueryFailure(hr, "Failed to get BurnManifest/@Win64 attribute.");
Assert(CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, sczEngineVersion, -1, wzVerMajorMinorBuild, -1));
Assert(BURN_PROTOCOL_VERSION == dwProtocolVersion);
#if !defined(_WIN64)
Assert(!fWin64);
#else
Assert(fWin64);
#endif
LExit:
AssertSz(SUCCEEDED(hr), "Failed to get harvesting attributes.");
ReleaseStr(sczEngineVersion);
ReleaseObject(pixeBundle);
}
#endif
|