diff options
Diffstat (limited to 'src/api/burn/balutil/BalBootstrapperEngine.cpp')
-rw-r--r-- | src/api/burn/balutil/BalBootstrapperEngine.cpp | 1148 |
1 files changed, 1035 insertions, 113 deletions
diff --git a/src/api/burn/balutil/BalBootstrapperEngine.cpp b/src/api/burn/balutil/BalBootstrapperEngine.cpp index be53c6b9..b924906e 100644 --- a/src/api/burn/balutil/BalBootstrapperEngine.cpp +++ b/src/api/burn/balutil/BalBootstrapperEngine.cpp | |||
@@ -2,7 +2,6 @@ | |||
2 | 2 | ||
3 | #include "precomp.h" | 3 | #include "precomp.h" |
4 | 4 | ||
5 | |||
6 | class CBalBootstrapperEngine : public IBootstrapperEngine | 5 | class CBalBootstrapperEngine : public IBootstrapperEngine |
7 | { | 6 | { |
8 | public: // IUnknown | 7 | public: // IUnknown |
@@ -64,18 +63,44 @@ public: // IBootstrapperEngine | |||
64 | HRESULT hr = S_OK; | 63 | HRESULT hr = S_OK; |
65 | BAENGINE_GETPACKAGECOUNT_ARGS args = { }; | 64 | BAENGINE_GETPACKAGECOUNT_ARGS args = { }; |
66 | BAENGINE_GETPACKAGECOUNT_RESULTS results = { }; | 65 | BAENGINE_GETPACKAGECOUNT_RESULTS results = { }; |
66 | BUFF_BUFFER bufferArgs = { }; | ||
67 | BUFF_BUFFER bufferResults = { }; | ||
68 | PIPE_RPC_RESULT rpc = { }; | ||
69 | SIZE_T iBuffer = 0; | ||
67 | 70 | ||
68 | ExitOnNull(pcPackages, hr, E_INVALIDARG, "pcPackages is required"); | 71 | ExitOnNull(pcPackages, hr, E_INVALIDARG, "pcPackages is required"); |
69 | 72 | ||
70 | args.cbSize = sizeof(args); | 73 | // Init send structs. |
74 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
75 | |||
76 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
77 | |||
78 | // Send args. | ||
79 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
80 | ExitOnFailure(hr, "Failed to write API version of GetPackageCount args."); | ||
81 | |||
82 | // Send results. | ||
83 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
84 | ExitOnFailure(hr, "Failed to write API version of GetPackageCount results."); | ||
85 | |||
86 | // Get results. | ||
87 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT, &bufferArgs, &bufferResults, &rpc); | ||
88 | ExitOnFailure(hr, "BA GetPackageCount failed."); | ||
71 | 89 | ||
72 | results.cbSize = sizeof(results); | 90 | // Read results. |
91 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); | ||
92 | ExitOnFailure(hr, "Failed to read value length from GetPackageCount results."); | ||
73 | 93 | ||
74 | hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT, &args, &results, m_pvBAEngineProcContext); | 94 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, (DWORD*)&results.cPackages); |
95 | ExitOnFailure(hr, "Failed to read value length from GetPackageCount results."); | ||
75 | 96 | ||
76 | *pcPackages = results.cPackages; | 97 | *pcPackages = results.cPackages; |
77 | 98 | ||
78 | LExit: | 99 | LExit: |
100 | PipeFreeRpcResult(&rpc); | ||
101 | ReleaseBuffer(bufferResults); | ||
102 | ReleaseBuffer(bufferArgs); | ||
103 | |||
79 | return hr; | 104 | return hr; |
80 | } | 105 | } |
81 | 106 | ||
@@ -87,20 +112,50 @@ public: // IBootstrapperEngine | |||
87 | HRESULT hr = S_OK; | 112 | HRESULT hr = S_OK; |
88 | BAENGINE_GETVARIABLENUMERIC_ARGS args = { }; | 113 | BAENGINE_GETVARIABLENUMERIC_ARGS args = { }; |
89 | BAENGINE_GETVARIABLENUMERIC_RESULTS results = { }; | 114 | BAENGINE_GETVARIABLENUMERIC_RESULTS results = { }; |
115 | BUFF_BUFFER bufferArgs = { }; | ||
116 | BUFF_BUFFER bufferResults = { }; | ||
117 | PIPE_RPC_RESULT rpc = { }; | ||
118 | SIZE_T iBuffer = 0; | ||
119 | LPWSTR sczValue = NULL; | ||
90 | 120 | ||
91 | ExitOnNull(pllValue, hr, E_INVALIDARG, "pllValue is required"); | 121 | ExitOnNull(pllValue, hr, E_INVALIDARG, "pllValue is required"); |
92 | 122 | ||
93 | args.cbSize = sizeof(args); | 123 | // Init send structs. |
124 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
94 | args.wzVariable = wzVariable; | 125 | args.wzVariable = wzVariable; |
95 | 126 | ||
96 | results.cbSize = sizeof(results); | 127 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
128 | |||
129 | // Send args. | ||
130 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
131 | ExitOnFailure(hr, "Failed to write API version of GetVariableNumeric args."); | ||
132 | |||
133 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); | ||
134 | ExitOnFailure(hr, "Failed to write variable name of GetVariableNumeric args."); | ||
135 | |||
136 | // Send results. | ||
137 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
138 | ExitOnFailure(hr, "Failed to write API version of GetVariableNumeric results."); | ||
97 | 139 | ||
98 | hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC, &args, &results, m_pvBAEngineProcContext); | 140 | // Get results. |
141 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC, &bufferArgs, &bufferResults, &rpc); | ||
142 | ExitOnFailure(hr, "BA GetVariableNumeric failed."); | ||
143 | |||
144 | // Read results. | ||
145 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); | ||
146 | ExitOnFailure(hr, "Failed to read value length from GetVariableNumeric results."); | ||
147 | |||
148 | hr = BuffReadNumber64(rpc.pbData, rpc.cbData, &iBuffer, (DWORD64*)&results.llValue); | ||
149 | ExitOnFailure(hr, "Failed to read value length from GetVariableNumeric results."); | ||
99 | 150 | ||
100 | *pllValue = results.llValue; | 151 | *pllValue = results.llValue; |
101 | 152 | ||
102 | LExit: | 153 | LExit: |
103 | SecureZeroMemory(&results, sizeof(results)); | 154 | ReleaseStr(sczValue); |
155 | PipeFreeRpcResult(&rpc); | ||
156 | ReleaseBuffer(bufferResults); | ||
157 | ReleaseBuffer(bufferArgs); | ||
158 | |||
104 | return hr; | 159 | return hr; |
105 | } | 160 | } |
106 | 161 | ||
@@ -113,21 +168,69 @@ public: // IBootstrapperEngine | |||
113 | HRESULT hr = S_OK; | 168 | HRESULT hr = S_OK; |
114 | BAENGINE_GETVARIABLESTRING_ARGS args = { }; | 169 | BAENGINE_GETVARIABLESTRING_ARGS args = { }; |
115 | BAENGINE_GETVARIABLESTRING_RESULTS results = { }; | 170 | BAENGINE_GETVARIABLESTRING_RESULTS results = { }; |
171 | BUFF_BUFFER bufferArgs = { }; | ||
172 | BUFF_BUFFER bufferResults = { }; | ||
173 | PIPE_RPC_RESULT rpc = { }; | ||
174 | SIZE_T iBuffer = 0; | ||
175 | LPWSTR sczValue = NULL; | ||
116 | 176 | ||
117 | ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); | 177 | ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); |
118 | 178 | ||
119 | args.cbSize = sizeof(args); | 179 | // Init send structs. |
180 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
120 | args.wzVariable = wzVariable; | 181 | args.wzVariable = wzVariable; |
121 | 182 | ||
122 | results.cbSize = sizeof(results); | 183 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
123 | results.wzValue = wzValue; | 184 | results.cchValue = static_cast<DWORD>(*pcchValue); |
124 | results.cchValue = *pcchValue; | 185 | |
186 | // Send args. | ||
187 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
188 | ExitOnFailure(hr, "Failed to write API version of GetVariableString args."); | ||
189 | |||
190 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); | ||
191 | ExitOnFailure(hr, "Failed to write variable name of GetVariableString args."); | ||
192 | |||
193 | // Send results. | ||
194 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
195 | ExitOnFailure(hr, "Failed to write API version of GetVariableString results."); | ||
196 | |||
197 | hr = BuffWriteNumberToBuffer(&bufferResults, results.cchValue); | ||
198 | ExitOnFailure(hr, "Failed to write API version of GetVariableString results value."); | ||
199 | |||
200 | // Get results. | ||
201 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING, &bufferArgs, &bufferResults, &rpc); | ||
202 | ExitOnFailure(hr, "BA GetVariableString failed."); | ||
203 | |||
204 | // Read results. | ||
205 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); | ||
206 | ExitOnFailure(hr, "Failed to read value length from GetVariableString results."); | ||
125 | 207 | ||
126 | hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING, &args, &results, m_pvBAEngineProcContext); | 208 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cchValue); |
209 | ExitOnFailure(hr, "Failed to read value length from GetVariableString results."); | ||
210 | |||
211 | hr = BuffReadString(rpc.pbData, rpc.cbData, &iBuffer, &sczValue); | ||
212 | ExitOnFailure(hr, "Failed to read value from GetVariableString results."); | ||
213 | |||
214 | results.wzValue = sczValue; | ||
215 | |||
216 | if (wzValue) | ||
217 | { | ||
218 | hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue); | ||
219 | } | ||
220 | else if (results.cchValue) | ||
221 | { | ||
222 | hr = E_MOREDATA; | ||
223 | } | ||
127 | 224 | ||
128 | *pcchValue = results.cchValue; | 225 | *pcchValue = results.cchValue; |
226 | ExitOnFailure(hr, "Failed to copy value from GetVariableString results."); | ||
129 | 227 | ||
130 | LExit: | 228 | LExit: |
229 | ReleaseStr(sczValue); | ||
230 | PipeFreeRpcResult(&rpc); | ||
231 | ReleaseBuffer(bufferResults); | ||
232 | ReleaseBuffer(bufferArgs); | ||
233 | |||
131 | return hr; | 234 | return hr; |
132 | } | 235 | } |
133 | 236 | ||
@@ -140,21 +243,70 @@ public: // IBootstrapperEngine | |||
140 | HRESULT hr = S_OK; | 243 | HRESULT hr = S_OK; |
141 | BAENGINE_GETVARIABLEVERSION_ARGS args = { }; | 244 | BAENGINE_GETVARIABLEVERSION_ARGS args = { }; |
142 | BAENGINE_GETVARIABLEVERSION_RESULTS results = { }; | 245 | BAENGINE_GETVARIABLEVERSION_RESULTS results = { }; |
246 | BUFF_BUFFER bufferArgs = { }; | ||
247 | BUFF_BUFFER bufferResults = { }; | ||
248 | PIPE_RPC_RESULT rpc = { }; | ||
249 | SIZE_T iBuffer = 0; | ||
250 | LPWSTR sczValue = NULL; | ||
143 | 251 | ||
144 | ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); | 252 | ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); |
145 | 253 | ||
146 | args.cbSize = sizeof(args); | 254 | // Init send structs. |
255 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
147 | args.wzVariable = wzVariable; | 256 | args.wzVariable = wzVariable; |
148 | 257 | ||
149 | results.cbSize = sizeof(results); | 258 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
150 | results.wzValue = wzValue; | 259 | hr = DutilSizetToDword(*pcchValue, &results.cchValue); |
151 | results.cchValue = *pcchValue; | 260 | ExitOnFailure(hr, "Failed to convert pcchValue to DWORD."); |
261 | |||
262 | // Send args. | ||
263 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
264 | ExitOnFailure(hr, "Failed to write API version of GetVariableVersion args."); | ||
152 | 265 | ||
153 | hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext); | 266 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); |
267 | ExitOnFailure(hr, "Failed to write variable name of GetVariableVersion args."); | ||
268 | |||
269 | // Send results. | ||
270 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
271 | ExitOnFailure(hr, "Failed to write API version of GetVariableVersion results."); | ||
272 | |||
273 | hr = BuffWriteNumberToBuffer(&bufferResults, results.cchValue); | ||
274 | ExitOnFailure(hr, "Failed to write API version of GetVariableVersion results value."); | ||
275 | |||
276 | // Get results. | ||
277 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, &bufferArgs, &bufferResults, &rpc); | ||
278 | ExitOnFailure(hr, "BA GetVariableVersion failed."); | ||
279 | |||
280 | // Read results. | ||
281 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); | ||
282 | ExitOnFailure(hr, "Failed to read value length from GetVariableVersion results."); | ||
283 | |||
284 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cchValue); | ||
285 | ExitOnFailure(hr, "Failed to read value length from GetVariableVersion results."); | ||
286 | |||
287 | hr = BuffReadString(rpc.pbData, rpc.cbData, &iBuffer, &sczValue); | ||
288 | ExitOnFailure(hr, "Failed to read value from GetVariableVersion results."); | ||
289 | |||
290 | results.wzValue = sczValue; | ||
291 | |||
292 | if (wzValue) | ||
293 | { | ||
294 | hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue); | ||
295 | } | ||
296 | else if (results.cchValue) | ||
297 | { | ||
298 | hr = E_MOREDATA; | ||
299 | } | ||
154 | 300 | ||
155 | *pcchValue = results.cchValue; | 301 | *pcchValue = results.cchValue; |
302 | ExitOnFailure(hr, "Failed to copy value from GetVariableVersion results."); | ||
156 | 303 | ||
157 | LExit: | 304 | LExit: |
305 | ReleaseStr(sczValue); | ||
306 | PipeFreeRpcResult(&rpc); | ||
307 | ReleaseBuffer(bufferResults); | ||
308 | ReleaseBuffer(bufferArgs); | ||
309 | |||
158 | return hr; | 310 | return hr; |
159 | } | 311 | } |
160 | 312 | ||
@@ -168,21 +320,74 @@ public: // IBootstrapperEngine | |||
168 | HRESULT hr = S_OK; | 320 | HRESULT hr = S_OK; |
169 | BAENGINE_GETRELATEDBUNDLEVARIABLE_ARGS args = { }; | 321 | BAENGINE_GETRELATEDBUNDLEVARIABLE_ARGS args = { }; |
170 | BAENGINE_GETRELATEDBUNDLEVARIABLE_RESULTS results = { }; | 322 | BAENGINE_GETRELATEDBUNDLEVARIABLE_RESULTS results = { }; |
323 | BUFF_BUFFER bufferArgs = { }; | ||
324 | BUFF_BUFFER bufferResults = { }; | ||
325 | PIPE_RPC_RESULT rpc = { }; | ||
326 | SIZE_T iBuffer = 0; | ||
327 | LPWSTR sczValue = NULL; | ||
171 | 328 | ||
172 | ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); | 329 | ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); |
173 | 330 | ||
174 | args.cbSize = sizeof(args); | 331 | // Init send structs. |
332 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
175 | args.wzBundleId = wzBundleId; | 333 | args.wzBundleId = wzBundleId; |
176 | args.wzVariable = wzVariable; | 334 | args.wzVariable = wzVariable; |
177 | 335 | ||
178 | results.cbSize = sizeof(results); | 336 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
179 | results.wzValue = wzValue; | 337 | hr = DutilSizetToDword(*pcchValue, &results.cchValue); |
180 | results.cchValue = *pcchValue; | 338 | ExitOnFailure(hr, "Failed to convert pcchValue to DWORD."); |
339 | |||
340 | // Send args. | ||
341 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
342 | ExitOnFailure(hr, "Failed to write API version of GetRelatedBundleVariable args."); | ||
343 | |||
344 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleId); | ||
345 | ExitOnFailure(hr, "Failed to write bundle id of GetRelatedBundleVariable args."); | ||
346 | |||
347 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); | ||
348 | ExitOnFailure(hr, "Failed to write variable name of GetRelatedBundleVariable args."); | ||
349 | |||
350 | // Send results. | ||
351 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
352 | ExitOnFailure(hr, "Failed to write API version of GetRelatedBundleVariable results."); | ||
353 | |||
354 | hr = BuffWriteNumberToBuffer(&bufferResults, results.cchValue); | ||
355 | ExitOnFailure(hr, "Failed to write API version of GetRelatedBundleVariable results value."); | ||
181 | 356 | ||
182 | hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE, &args, &results, m_pvBAEngineProcContext); | 357 | // Get results. |
358 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE, &bufferArgs, &bufferResults, &rpc); | ||
359 | ExitOnFailure(hr, "BA GetRelatedBundleVariable failed."); | ||
360 | |||
361 | // Read results. | ||
362 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); | ||
363 | ExitOnFailure(hr, "Failed to read value length from GetRelatedBundleVariable results."); | ||
364 | |||
365 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cchValue); | ||
366 | ExitOnFailure(hr, "Failed to read value length from GetRelatedBundleVariable results."); | ||
367 | |||
368 | hr = BuffReadString(rpc.pbData, rpc.cbData, &iBuffer, &sczValue); | ||
369 | ExitOnFailure(hr, "Failed to read value from GetRelatedBundleVariable results."); | ||
370 | |||
371 | results.wzValue = sczValue; | ||
372 | |||
373 | if (wzValue) | ||
374 | { | ||
375 | hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue); | ||
376 | } | ||
377 | else if (results.cchValue) | ||
378 | { | ||
379 | hr = E_MOREDATA; | ||
380 | } | ||
183 | 381 | ||
184 | *pcchValue = results.cchValue; | 382 | *pcchValue = results.cchValue; |
383 | ExitOnFailure(hr, "Failed to copy value from GetRelatedBundleVariable results."); | ||
384 | |||
185 | LExit: | 385 | LExit: |
386 | ReleaseStr(sczValue); | ||
387 | PipeFreeRpcResult(&rpc); | ||
388 | ReleaseBuffer(bufferResults); | ||
389 | ReleaseBuffer(bufferArgs); | ||
390 | |||
186 | return hr; | 391 | return hr; |
187 | } | 392 | } |
188 | 393 | ||
@@ -195,21 +400,70 @@ public: // IBootstrapperEngine | |||
195 | HRESULT hr = S_OK; | 400 | HRESULT hr = S_OK; |
196 | BAENGINE_FORMATSTRING_ARGS args = { }; | 401 | BAENGINE_FORMATSTRING_ARGS args = { }; |
197 | BAENGINE_FORMATSTRING_RESULTS results = { }; | 402 | BAENGINE_FORMATSTRING_RESULTS results = { }; |
403 | BUFF_BUFFER bufferArgs = { }; | ||
404 | BUFF_BUFFER bufferResults = { }; | ||
405 | PIPE_RPC_RESULT rpc = { }; | ||
406 | SIZE_T iBuffer = 0; | ||
407 | LPWSTR sczOut = NULL; | ||
198 | 408 | ||
199 | ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); | 409 | ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); |
200 | 410 | ||
201 | args.cbSize = sizeof(args); | 411 | // Init send structs. |
412 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
202 | args.wzIn = wzIn; | 413 | args.wzIn = wzIn; |
203 | 414 | ||
204 | results.cbSize = sizeof(results); | 415 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
205 | results.wzOut = wzOut; | 416 | hr = DutilSizetToDword(*pcchOut, &results.cchOut); |
206 | results.cchOut = *pcchOut; | 417 | ExitOnFailure(hr, "Failed to convert pcchOut to DWORD."); |
418 | |||
419 | // Send args. | ||
420 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
421 | ExitOnFailure(hr, "Failed to write API version of FormatString args."); | ||
422 | |||
423 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzIn); | ||
424 | ExitOnFailure(hr, "Failed to write string to format of FormatString args."); | ||
425 | |||
426 | // Send results. | ||
427 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
428 | ExitOnFailure(hr, "Failed to write API version of FormatString results."); | ||
429 | |||
430 | hr = BuffWriteNumberToBuffer(&bufferResults, results.cchOut); | ||
431 | ExitOnFailure(hr, "Failed to write format string maximum size of FormatString results value."); | ||
432 | |||
433 | // Get results. | ||
434 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING, &bufferArgs, &bufferResults, &rpc); | ||
435 | ExitOnFailure(hr, "BA FormatString failed."); | ||
436 | |||
437 | // Read results. | ||
438 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); | ||
439 | ExitOnFailure(hr, "Failed to read size from FormatString results."); | ||
440 | |||
441 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cchOut); | ||
442 | ExitOnFailure(hr, "Failed to read formatted string length from FormatString results."); | ||
207 | 443 | ||
208 | hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING, &args, &results, m_pvBAEngineProcContext); | 444 | hr = BuffReadString(rpc.pbData, rpc.cbData, &iBuffer, &sczOut); |
445 | ExitOnFailure(hr, "Failed to read formatted string from FormatString results."); | ||
446 | |||
447 | results.wzOut = sczOut; | ||
448 | |||
449 | if (wzOut) | ||
450 | { | ||
451 | hr = ::StringCchCopyW(wzOut, *pcchOut, results.wzOut); | ||
452 | } | ||
453 | else if (results.cchOut) | ||
454 | { | ||
455 | hr = E_MOREDATA; | ||
456 | } | ||
209 | 457 | ||
210 | *pcchOut = results.cchOut; | 458 | *pcchOut = results.cchOut; |
459 | ExitOnFailure(hr, "Failed to copy formatted string from FormatString results."); | ||
211 | 460 | ||
212 | LExit: | 461 | LExit: |
462 | ReleaseStr(sczOut); | ||
463 | PipeFreeRpcResult(&rpc); | ||
464 | ReleaseBuffer(bufferResults); | ||
465 | ReleaseBuffer(bufferArgs); | ||
466 | |||
213 | return hr; | 467 | return hr; |
214 | } | 468 | } |
215 | 469 | ||
@@ -222,21 +476,70 @@ public: // IBootstrapperEngine | |||
222 | HRESULT hr = S_OK; | 476 | HRESULT hr = S_OK; |
223 | BAENGINE_ESCAPESTRING_ARGS args = { }; | 477 | BAENGINE_ESCAPESTRING_ARGS args = { }; |
224 | BAENGINE_ESCAPESTRING_RESULTS results = { }; | 478 | BAENGINE_ESCAPESTRING_RESULTS results = { }; |
479 | BUFF_BUFFER bufferArgs = { }; | ||
480 | BUFF_BUFFER bufferResults = { }; | ||
481 | PIPE_RPC_RESULT rpc = { }; | ||
482 | SIZE_T iBuffer = 0; | ||
483 | LPWSTR sczOut = NULL; | ||
225 | 484 | ||
226 | ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); | 485 | ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); |
227 | 486 | ||
228 | args.cbSize = sizeof(args); | 487 | // Init send structs. |
488 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
229 | args.wzIn = wzIn; | 489 | args.wzIn = wzIn; |
230 | 490 | ||
231 | results.cbSize = sizeof(results); | 491 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
232 | results.wzOut = wzOut; | 492 | hr = DutilSizetToDword(*pcchOut, &results.cchOut); |
233 | results.cchOut = *pcchOut; | 493 | ExitOnFailure(hr, "Failed to convert pcchOut to DWORD."); |
494 | |||
495 | // Send args. | ||
496 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
497 | ExitOnFailure(hr, "Failed to write API version of EscapeString args."); | ||
234 | 498 | ||
235 | hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING, &args, &results, m_pvBAEngineProcContext); | 499 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzIn); |
500 | ExitOnFailure(hr, "Failed to write string to escape of EscapeString args."); | ||
501 | |||
502 | // Send results. | ||
503 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
504 | ExitOnFailure(hr, "Failed to write API version of EscapeString results."); | ||
505 | |||
506 | hr = BuffWriteNumberToBuffer(&bufferResults, results.cchOut); | ||
507 | ExitOnFailure(hr, "Failed to write escape string maximum size of EscapeString results value."); | ||
508 | |||
509 | // Get results. | ||
510 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING, &bufferArgs, &bufferResults, &rpc); | ||
511 | ExitOnFailure(hr, "BA EscapeString failed."); | ||
512 | |||
513 | // Read results. | ||
514 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); | ||
515 | ExitOnFailure(hr, "Failed to read size from EscapeString results."); | ||
516 | |||
517 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cchOut); | ||
518 | ExitOnFailure(hr, "Failed to read escaped string length from EscapeString results."); | ||
519 | |||
520 | hr = BuffReadString(rpc.pbData, rpc.cbData, &iBuffer, &sczOut); | ||
521 | ExitOnFailure(hr, "Failed to read escaped string from EscapeString results."); | ||
522 | |||
523 | results.wzOut = sczOut; | ||
524 | |||
525 | if (wzOut) | ||
526 | { | ||
527 | hr = ::StringCchCopyW(wzOut, *pcchOut, results.wzOut); | ||
528 | } | ||
529 | else if (results.cchOut) | ||
530 | { | ||
531 | hr = E_MOREDATA; | ||
532 | } | ||
236 | 533 | ||
237 | *pcchOut = results.cchOut; | 534 | *pcchOut = results.cchOut; |
535 | ExitOnFailure(hr, "Failed to copy escaped string from EscapeString results."); | ||
238 | 536 | ||
239 | LExit: | 537 | LExit: |
538 | ReleaseStr(sczOut); | ||
539 | PipeFreeRpcResult(&rpc); | ||
540 | ReleaseBuffer(bufferResults); | ||
541 | ReleaseBuffer(bufferArgs); | ||
542 | |||
240 | return hr; | 543 | return hr; |
241 | } | 544 | } |
242 | 545 | ||
@@ -248,19 +551,56 @@ public: // IBootstrapperEngine | |||
248 | HRESULT hr = S_OK; | 551 | HRESULT hr = S_OK; |
249 | BAENGINE_EVALUATECONDITION_ARGS args = { }; | 552 | BAENGINE_EVALUATECONDITION_ARGS args = { }; |
250 | BAENGINE_EVALUATECONDITION_RESULTS results = { }; | 553 | BAENGINE_EVALUATECONDITION_RESULTS results = { }; |
554 | BUFF_BUFFER bufferArgs = { }; | ||
555 | BUFF_BUFFER bufferResults = { }; | ||
556 | PIPE_RPC_RESULT rpc = { }; | ||
557 | SIZE_T iBuffer = 0; | ||
251 | 558 | ||
559 | ExitOnNull(wzCondition, hr, E_INVALIDARG, "wzCondition is required"); | ||
252 | ExitOnNull(pf, hr, E_INVALIDARG, "pf is required"); | 560 | ExitOnNull(pf, hr, E_INVALIDARG, "pf is required"); |
253 | 561 | ||
254 | args.cbSize = sizeof(args); | 562 | // Empty condition evaluates to true. |
563 | if (!*wzCondition) | ||
564 | { | ||
565 | *pf = TRUE; | ||
566 | ExitFunction(); | ||
567 | } | ||
568 | |||
569 | // Init send structs. | ||
570 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
255 | args.wzCondition = wzCondition; | 571 | args.wzCondition = wzCondition; |
256 | 572 | ||
257 | results.cbSize = sizeof(results); | 573 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
574 | |||
575 | // Send args. | ||
576 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
577 | ExitOnFailure(hr, "Failed to write API version of EvaluateCondition args."); | ||
578 | |||
579 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzCondition); | ||
580 | ExitOnFailure(hr, "Failed to write condition of EvaluateCondition args."); | ||
258 | 581 | ||
259 | hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION, &args, &results, m_pvBAEngineProcContext); | 582 | // Send results. |
583 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
584 | ExitOnFailure(hr, "Failed to write API version of EvaluateCondition results."); | ||
585 | |||
586 | // Get results. | ||
587 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION, &bufferArgs, &bufferResults, &rpc); | ||
588 | ExitOnFailure(hr, "BA EvaluateCondition failed."); | ||
589 | |||
590 | // Read results. | ||
591 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); | ||
592 | ExitOnFailure(hr, "Failed to read size from EvaluateCondition results."); | ||
593 | |||
594 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast<DWORD*>(&results.f)); | ||
595 | ExitOnFailure(hr, "Failed to read result from EvaluateCondition results."); | ||
260 | 596 | ||
261 | *pf = results.f; | 597 | *pf = results.f; |
262 | 598 | ||
263 | LExit: | 599 | LExit: |
600 | PipeFreeRpcResult(&rpc); | ||
601 | ReleaseBuffer(bufferResults); | ||
602 | ReleaseBuffer(bufferArgs); | ||
603 | |||
264 | return hr; | 604 | return hr; |
265 | } | 605 | } |
266 | 606 | ||
@@ -269,16 +609,44 @@ public: // IBootstrapperEngine | |||
269 | __in_z LPCWSTR wzMessage | 609 | __in_z LPCWSTR wzMessage |
270 | ) | 610 | ) |
271 | { | 611 | { |
612 | HRESULT hr = S_OK; | ||
272 | BAENGINE_LOG_ARGS args = { }; | 613 | BAENGINE_LOG_ARGS args = { }; |
273 | BAENGINE_LOG_RESULTS results = { }; | 614 | BAENGINE_LOG_RESULTS results = { }; |
615 | BUFF_BUFFER bufferArgs = { }; | ||
616 | BUFF_BUFFER bufferResults = { }; | ||
617 | PIPE_RPC_RESULT rpc = { }; | ||
274 | 618 | ||
275 | args.cbSize = sizeof(args); | 619 | // Init send structs. |
620 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
276 | args.level = level; | 621 | args.level = level; |
277 | args.wzMessage = wzMessage; | 622 | args.wzMessage = wzMessage; |
278 | 623 | ||
279 | results.cbSize = sizeof(results); | 624 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
625 | |||
626 | // Send args. | ||
627 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
628 | ExitOnFailure(hr, "Failed to write API version of Log args."); | ||
629 | |||
630 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.level); | ||
631 | ExitOnFailure(hr, "Failed to write level of Log args."); | ||
632 | |||
633 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzMessage); | ||
634 | ExitOnFailure(hr, "Failed to write message of Log args."); | ||
635 | |||
636 | // Send results. | ||
637 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
638 | ExitOnFailure(hr, "Failed to write API version of Log results."); | ||
280 | 639 | ||
281 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LOG, &args, &results, m_pvBAEngineProcContext); | 640 | // Get results. |
641 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_LOG, &bufferArgs, &bufferResults, &rpc); | ||
642 | ExitOnFailure(hr, "BA Log failed."); | ||
643 | |||
644 | LExit: | ||
645 | PipeFreeRpcResult(&rpc); | ||
646 | ReleaseBuffer(bufferResults); | ||
647 | ReleaseBuffer(bufferArgs); | ||
648 | |||
649 | return hr; | ||
282 | } | 650 | } |
283 | 651 | ||
284 | virtual STDMETHODIMP SendEmbeddedError( | 652 | virtual STDMETHODIMP SendEmbeddedError( |
@@ -291,21 +659,56 @@ public: // IBootstrapperEngine | |||
291 | HRESULT hr = S_OK; | 659 | HRESULT hr = S_OK; |
292 | BAENGINE_SENDEMBEDDEDERROR_ARGS args = { }; | 660 | BAENGINE_SENDEMBEDDEDERROR_ARGS args = { }; |
293 | BAENGINE_SENDEMBEDDEDERROR_RESULTS results = { }; | 661 | BAENGINE_SENDEMBEDDEDERROR_RESULTS results = { }; |
662 | BUFF_BUFFER bufferArgs = { }; | ||
663 | BUFF_BUFFER bufferResults = { }; | ||
664 | PIPE_RPC_RESULT rpc = { }; | ||
665 | SIZE_T iBuffer = 0; | ||
294 | 666 | ||
295 | ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); | 667 | ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); |
296 | 668 | ||
297 | args.cbSize = sizeof(args); | 669 | // Init send structs. |
670 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
298 | args.dwErrorCode = dwErrorCode; | 671 | args.dwErrorCode = dwErrorCode; |
299 | args.wzMessage = wzMessage; | 672 | args.wzMessage = wzMessage; |
300 | args.dwUIHint = dwUIHint; | 673 | args.dwUIHint = dwUIHint; |
301 | 674 | ||
302 | results.cbSize = sizeof(results); | 675 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
676 | |||
677 | // Send args. | ||
678 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
679 | ExitOnFailure(hr, "Failed to write API version of SendEmbeddedError args."); | ||
680 | |||
681 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwErrorCode); | ||
682 | ExitOnFailure(hr, "Failed to write error code of SendEmbeddedError args."); | ||
683 | |||
684 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzMessage); | ||
685 | ExitOnFailure(hr, "Failed to write message of SendEmbeddedError args."); | ||
686 | |||
687 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwUIHint); | ||
688 | ExitOnFailure(hr, "Failed to write UI hint of SendEmbeddedError args."); | ||
689 | |||
690 | // Send results. | ||
691 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
692 | ExitOnFailure(hr, "Failed to write API version of SendEmbeddedError results."); | ||
303 | 693 | ||
304 | hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR, &args, &results, m_pvBAEngineProcContext); | 694 | // Get results. |
695 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR, &bufferArgs, &bufferResults, &rpc); | ||
696 | ExitOnFailure(hr, "BA SendEmbeddedError failed."); | ||
697 | |||
698 | // Read results. | ||
699 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); | ||
700 | ExitOnFailure(hr, "Failed to read size from SendEmbeddedError results."); | ||
701 | |||
702 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast<DWORD*>(&results.nResult)); | ||
703 | ExitOnFailure(hr, "Failed to read result from SendEmbeddedError results."); | ||
305 | 704 | ||
306 | *pnResult = results.nResult; | 705 | *pnResult = results.nResult; |
307 | 706 | ||
308 | LExit: | 707 | LExit: |
708 | PipeFreeRpcResult(&rpc); | ||
709 | ReleaseBuffer(bufferResults); | ||
710 | ReleaseBuffer(bufferArgs); | ||
711 | |||
309 | return hr; | 712 | return hr; |
310 | } | 713 | } |
311 | 714 | ||
@@ -318,20 +721,52 @@ public: // IBootstrapperEngine | |||
318 | HRESULT hr = S_OK; | 721 | HRESULT hr = S_OK; |
319 | BAENGINE_SENDEMBEDDEDPROGRESS_ARGS args = { }; | 722 | BAENGINE_SENDEMBEDDEDPROGRESS_ARGS args = { }; |
320 | BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS results = { }; | 723 | BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS results = { }; |
724 | BUFF_BUFFER bufferArgs = { }; | ||
725 | BUFF_BUFFER bufferResults = { }; | ||
726 | PIPE_RPC_RESULT rpc = { }; | ||
727 | SIZE_T iBuffer = 0; | ||
321 | 728 | ||
322 | ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); | 729 | ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); |
323 | 730 | ||
324 | args.cbSize = sizeof(args); | 731 | // Init send structs. |
732 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
325 | args.dwProgressPercentage = dwProgressPercentage; | 733 | args.dwProgressPercentage = dwProgressPercentage; |
326 | args.dwOverallProgressPercentage = dwOverallProgressPercentage; | 734 | args.dwOverallProgressPercentage = dwOverallProgressPercentage; |
327 | 735 | ||
328 | results.cbSize = sizeof(results); | 736 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
737 | |||
738 | // Send args. | ||
739 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
740 | ExitOnFailure(hr, "Failed to write API version of SendEmbeddedProgress args."); | ||
741 | |||
742 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwProgressPercentage); | ||
743 | ExitOnFailure(hr, "Failed to write progress of SendEmbeddedProgress args."); | ||
744 | |||
745 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwOverallProgressPercentage); | ||
746 | ExitOnFailure(hr, "Failed to write overall progress of SendEmbeddedProgress args."); | ||
747 | |||
748 | // Send results. | ||
749 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
750 | ExitOnFailure(hr, "Failed to write API version of SendEmbeddedProgress results."); | ||
751 | |||
752 | // Get results. | ||
753 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS, &bufferArgs, &bufferResults, &rpc); | ||
754 | ExitOnFailure(hr, "BA SendEmbeddedProgress failed."); | ||
755 | |||
756 | // Read results. | ||
757 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); | ||
758 | ExitOnFailure(hr, "Failed to read size from SendEmbeddedProgress results."); | ||
329 | 759 | ||
330 | hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS, &args, &results, m_pvBAEngineProcContext); | 760 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast<DWORD*>(&results.nResult)); |
761 | ExitOnFailure(hr, "Failed to read result from SendEmbeddedProgress results."); | ||
331 | 762 | ||
332 | *pnResult = results.nResult; | 763 | *pnResult = results.nResult; |
333 | 764 | ||
334 | LExit: | 765 | LExit: |
766 | PipeFreeRpcResult(&rpc); | ||
767 | ReleaseBuffer(bufferResults); | ||
768 | ReleaseBuffer(bufferArgs); | ||
769 | |||
335 | return hr; | 770 | return hr; |
336 | } | 771 | } |
337 | 772 | ||
@@ -340,22 +775,67 @@ public: // IBootstrapperEngine | |||
340 | __in_z_opt LPCWSTR wzDownloadSource, | 775 | __in_z_opt LPCWSTR wzDownloadSource, |
341 | __in DWORD64 qwSize, | 776 | __in DWORD64 qwSize, |
342 | __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, | 777 | __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, |
343 | __in_z_opt LPCWSTR wzHash | 778 | __in_z_opt LPCWSTR wzHash, |
779 | __in_z_opt LPCWSTR wzUpdatePackageId | ||
344 | ) | 780 | ) |
345 | { | 781 | { |
782 | HRESULT hr = S_OK; | ||
346 | BAENGINE_SETUPDATE_ARGS args = { }; | 783 | BAENGINE_SETUPDATE_ARGS args = { }; |
347 | BAENGINE_SETUPDATE_RESULTS results = { }; | 784 | BAENGINE_SETUPDATE_RESULTS results = { }; |
785 | BUFF_BUFFER bufferArgs = { }; | ||
786 | BUFF_BUFFER bufferResults = { }; | ||
787 | PIPE_RPC_RESULT rpc = { }; | ||
348 | 788 | ||
349 | args.cbSize = sizeof(args); | 789 | // Init send structs. |
790 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
350 | args.wzLocalSource = wzLocalSource; | 791 | args.wzLocalSource = wzLocalSource; |
351 | args.wzDownloadSource = wzDownloadSource; | 792 | args.wzDownloadSource = wzDownloadSource; |
352 | args.qwSize = qwSize; | 793 | args.qwSize = qwSize; |
353 | args.hashType = hashType; | 794 | args.hashType = hashType; |
354 | args.wzHash = wzHash; | 795 | args.wzHash = wzHash; |
796 | args.wzUpdatePackageId = wzUpdatePackageId; | ||
797 | |||
798 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
799 | |||
800 | // Send args. | ||
801 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
802 | ExitOnFailure(hr, "Failed to write API version of SetUpdate args."); | ||
803 | |||
804 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzLocalSource); | ||
805 | ExitOnFailure(hr, "Failed to write local source of SetUpdate args."); | ||
806 | |||
807 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzDownloadSource); | ||
808 | ExitOnFailure(hr, "Failed to write download source of SetUpdate args."); | ||
809 | |||
810 | hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.qwSize); | ||
811 | ExitOnFailure(hr, "Failed to write udpate size of SetUpdate args."); | ||
812 | |||
813 | hr = BuffWriteNumberToBuffer(&bufferArgs, static_cast<DWORD>(args.hashType)); | ||
814 | ExitOnFailure(hr, "Failed to write hash type of SetUpdate args."); | ||
815 | |||
816 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzHash); | ||
817 | ExitOnFailure(hr, "Failed to write hash of SetUpdate args."); | ||
355 | 818 | ||
356 | results.cbSize = sizeof(results); | 819 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzHash); |
820 | ExitOnFailure(hr, "Failed to write hash of SetUpdate args."); | ||
357 | 821 | ||
358 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE, &args, &results, m_pvBAEngineProcContext); | 822 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUpdatePackageId); |
823 | ExitOnFailure(hr, "Failed to write update package id to SetUpdate args."); | ||
824 | |||
825 | // Send results. | ||
826 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
827 | ExitOnFailure(hr, "Failed to write API version of SetUpdate results."); | ||
828 | |||
829 | // Get results. | ||
830 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE, &bufferArgs, &bufferResults, &rpc); | ||
831 | ExitOnFailure(hr, "BA SetUpdate failed."); | ||
832 | |||
833 | LExit: | ||
834 | PipeFreeRpcResult(&rpc); | ||
835 | ReleaseBuffer(bufferResults); | ||
836 | ReleaseBuffer(bufferArgs); | ||
837 | |||
838 | return hr; | ||
359 | } | 839 | } |
360 | 840 | ||
361 | virtual STDMETHODIMP SetLocalSource( | 841 | virtual STDMETHODIMP SetLocalSource( |
@@ -364,17 +844,48 @@ public: // IBootstrapperEngine | |||
364 | __in_z LPCWSTR wzPath | 844 | __in_z LPCWSTR wzPath |
365 | ) | 845 | ) |
366 | { | 846 | { |
847 | HRESULT hr = S_OK; | ||
367 | BAENGINE_SETLOCALSOURCE_ARGS args = { }; | 848 | BAENGINE_SETLOCALSOURCE_ARGS args = { }; |
368 | BAENGINE_SETLOCALSOURCE_RESULTS results = { }; | 849 | BAENGINE_SETLOCALSOURCE_RESULTS results = { }; |
850 | BUFF_BUFFER bufferArgs = { }; | ||
851 | BUFF_BUFFER bufferResults = { }; | ||
852 | PIPE_RPC_RESULT rpc = { }; | ||
369 | 853 | ||
370 | args.cbSize = sizeof(args); | 854 | // Init send structs. |
855 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
371 | args.wzPackageOrContainerId = wzPackageOrContainerId; | 856 | args.wzPackageOrContainerId = wzPackageOrContainerId; |
372 | args.wzPayloadId = wzPayloadId; | 857 | args.wzPayloadId = wzPayloadId; |
373 | args.wzPath = wzPath; | 858 | args.wzPath = wzPath; |
374 | 859 | ||
375 | results.cbSize = sizeof(results); | 860 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
861 | |||
862 | // Send args. | ||
863 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
864 | ExitOnFailure(hr, "Failed to write API version of SetLocalSource args."); | ||
865 | |||
866 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); | ||
867 | ExitOnFailure(hr, "Failed to write package or container id of SetLocalSource args."); | ||
376 | 868 | ||
377 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE, &args, &results, m_pvBAEngineProcContext); | 869 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); |
870 | ExitOnFailure(hr, "Failed to write payload id of SetLocalSource args."); | ||
871 | |||
872 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPath); | ||
873 | ExitOnFailure(hr, "Failed to write path of SetLocalSource args."); | ||
874 | |||
875 | // Send results. | ||
876 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
877 | ExitOnFailure(hr, "Failed to write API version of SetLocalSource results."); | ||
878 | |||
879 | // Get results. | ||
880 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE, &bufferArgs, &bufferResults, &rpc); | ||
881 | ExitOnFailure(hr, "BA SetLocalSource failed."); | ||
882 | |||
883 | LExit: | ||
884 | PipeFreeRpcResult(&rpc); | ||
885 | ReleaseBuffer(bufferResults); | ||
886 | ReleaseBuffer(bufferArgs); | ||
887 | |||
888 | return hr; | ||
378 | } | 889 | } |
379 | 890 | ||
380 | virtual STDMETHODIMP SetDownloadSource( | 891 | virtual STDMETHODIMP SetDownloadSource( |
@@ -382,22 +893,64 @@ public: // IBootstrapperEngine | |||
382 | __in_z_opt LPCWSTR wzPayloadId, | 893 | __in_z_opt LPCWSTR wzPayloadId, |
383 | __in_z LPCWSTR wzUrl, | 894 | __in_z LPCWSTR wzUrl, |
384 | __in_z_opt LPCWSTR wzUser, | 895 | __in_z_opt LPCWSTR wzUser, |
385 | __in_z_opt LPCWSTR wzPassword | 896 | __in_z_opt LPCWSTR wzPassword, |
897 | __in_z_opt LPCWSTR wzAuthorizationHeader | ||
386 | ) | 898 | ) |
387 | { | 899 | { |
900 | HRESULT hr = S_OK; | ||
388 | BAENGINE_SETDOWNLOADSOURCE_ARGS args = { }; | 901 | BAENGINE_SETDOWNLOADSOURCE_ARGS args = { }; |
389 | BAENGINE_SETDOWNLOADSOURCE_RESULTS results = { }; | 902 | BAENGINE_SETDOWNLOADSOURCE_RESULTS results = { }; |
903 | BUFF_BUFFER bufferArgs = { }; | ||
904 | BUFF_BUFFER bufferResults = { }; | ||
905 | PIPE_RPC_RESULT rpc = { }; | ||
390 | 906 | ||
391 | args.cbSize = sizeof(args); | 907 | // Init send structs. |
908 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
392 | args.wzPackageOrContainerId = wzPackageOrContainerId; | 909 | args.wzPackageOrContainerId = wzPackageOrContainerId; |
393 | args.wzPayloadId = wzPayloadId; | 910 | args.wzPayloadId = wzPayloadId; |
394 | args.wzUrl = wzUrl; | 911 | args.wzUrl = wzUrl; |
395 | args.wzUser = wzUser; | 912 | args.wzUser = wzUser; |
396 | args.wzPassword = wzPassword; | 913 | args.wzPassword = wzPassword; |
914 | args.wzAuthorizationHeader = wzAuthorizationHeader; | ||
397 | 915 | ||
398 | results.cbSize = sizeof(results); | 916 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
399 | 917 | ||
400 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE, &args, &results, m_pvBAEngineProcContext); | 918 | // Send args. |
919 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
920 | ExitOnFailure(hr, "Failed to write API version of SetDownloadSource args."); | ||
921 | |||
922 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); | ||
923 | ExitOnFailure(hr, "Failed to write package or container id of SetDownloadSource args."); | ||
924 | |||
925 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); | ||
926 | ExitOnFailure(hr, "Failed to write payload id of SetDownloadSource args."); | ||
927 | |||
928 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUrl); | ||
929 | ExitOnFailure(hr, "Failed to write url of SetDownloadSource args."); | ||
930 | |||
931 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUser); | ||
932 | ExitOnFailure(hr, "Failed to write user of SetDownloadSource args."); | ||
933 | |||
934 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPassword); | ||
935 | ExitOnFailure(hr, "Failed to write password of SetDownloadSource args."); | ||
936 | |||
937 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzAuthorizationHeader); | ||
938 | ExitOnFailure(hr, "Failed to write authorization header of SetDownloadSource args."); | ||
939 | |||
940 | // Send results. | ||
941 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
942 | ExitOnFailure(hr, "Failed to write API version of SetDownloadSource results."); | ||
943 | |||
944 | // Get results. | ||
945 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE, &bufferArgs, &bufferResults, &rpc); | ||
946 | ExitOnFailure(hr, "BA SetDownloadSource failed."); | ||
947 | |||
948 | LExit: | ||
949 | PipeFreeRpcResult(&rpc); | ||
950 | ReleaseBuffer(bufferResults); | ||
951 | ReleaseBuffer(bufferArgs); | ||
952 | |||
953 | return hr; | ||
401 | } | 954 | } |
402 | 955 | ||
403 | virtual STDMETHODIMP SetVariableNumeric( | 956 | virtual STDMETHODIMP SetVariableNumeric( |
@@ -405,16 +958,44 @@ public: // IBootstrapperEngine | |||
405 | __in LONGLONG llValue | 958 | __in LONGLONG llValue |
406 | ) | 959 | ) |
407 | { | 960 | { |
961 | HRESULT hr = S_OK; | ||
408 | BAENGINE_SETVARIABLENUMERIC_ARGS args = { }; | 962 | BAENGINE_SETVARIABLENUMERIC_ARGS args = { }; |
409 | BAENGINE_SETVARIABLENUMERIC_RESULTS results = { }; | 963 | BAENGINE_SETVARIABLENUMERIC_RESULTS results = { }; |
964 | BUFF_BUFFER bufferArgs = { }; | ||
965 | BUFF_BUFFER bufferResults = { }; | ||
966 | PIPE_RPC_RESULT rpc = { }; | ||
410 | 967 | ||
411 | args.cbSize = sizeof(args); | 968 | // Init send structs. |
969 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
412 | args.wzVariable = wzVariable; | 970 | args.wzVariable = wzVariable; |
413 | args.llValue = llValue; | 971 | args.llValue = llValue; |
414 | 972 | ||
415 | results.cbSize = sizeof(results); | 973 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
974 | |||
975 | // Send args. | ||
976 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
977 | ExitOnFailure(hr, "Failed to write API version of SetVariableNumeric args."); | ||
978 | |||
979 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); | ||
980 | ExitOnFailure(hr, "Failed to write variable of SetVariableNumeric args."); | ||
981 | |||
982 | hr = BuffWriteNumber64ToBuffer(&bufferArgs, static_cast<DWORD64>(args.llValue)); | ||
983 | ExitOnFailure(hr, "Failed to write value of SetVariableNumeric args."); | ||
984 | |||
985 | // Send results. | ||
986 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
987 | ExitOnFailure(hr, "Failed to write API version of SetVariableNumeric results."); | ||
988 | |||
989 | // Get results. | ||
990 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC, &bufferArgs, &bufferResults, &rpc); | ||
991 | ExitOnFailure(hr, "BA SetVariableNumeric failed."); | ||
416 | 992 | ||
417 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC, &args, &results, m_pvBAEngineProcContext); | 993 | LExit: |
994 | PipeFreeRpcResult(&rpc); | ||
995 | ReleaseBuffer(bufferResults); | ||
996 | ReleaseBuffer(bufferArgs); | ||
997 | |||
998 | return hr; | ||
418 | } | 999 | } |
419 | 1000 | ||
420 | virtual STDMETHODIMP SetVariableString( | 1001 | virtual STDMETHODIMP SetVariableString( |
@@ -423,17 +1004,48 @@ public: // IBootstrapperEngine | |||
423 | __in BOOL fFormatted | 1004 | __in BOOL fFormatted |
424 | ) | 1005 | ) |
425 | { | 1006 | { |
1007 | HRESULT hr = S_OK; | ||
426 | BAENGINE_SETVARIABLESTRING_ARGS args = { }; | 1008 | BAENGINE_SETVARIABLESTRING_ARGS args = { }; |
427 | BAENGINE_SETVARIABLESTRING_RESULTS results = { }; | 1009 | BAENGINE_SETVARIABLESTRING_RESULTS results = { }; |
1010 | BUFF_BUFFER bufferArgs = { }; | ||
1011 | BUFF_BUFFER bufferResults = { }; | ||
1012 | PIPE_RPC_RESULT rpc = { }; | ||
428 | 1013 | ||
429 | args.cbSize = sizeof(args); | 1014 | // Init send structs. |
1015 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
430 | args.wzVariable = wzVariable; | 1016 | args.wzVariable = wzVariable; |
431 | args.wzValue = wzValue; | 1017 | args.wzValue = wzValue; |
432 | args.fFormatted = fFormatted; | 1018 | args.fFormatted = fFormatted; |
433 | 1019 | ||
434 | results.cbSize = sizeof(results); | 1020 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
1021 | |||
1022 | // Send args. | ||
1023 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
1024 | ExitOnFailure(hr, "Failed to write API version of SetVariableString args."); | ||
1025 | |||
1026 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); | ||
1027 | ExitOnFailure(hr, "Failed to write variable of SetVariableString args."); | ||
1028 | |||
1029 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzValue); | ||
1030 | ExitOnFailure(hr, "Failed to write value of SetVariableString args."); | ||
1031 | |||
1032 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.fFormatted); | ||
1033 | ExitOnFailure(hr, "Failed to write formatted flag of SetVariableString args."); | ||
1034 | |||
1035 | // Send results. | ||
1036 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
1037 | ExitOnFailure(hr, "Failed to write API version of SetVariableString results."); | ||
435 | 1038 | ||
436 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING, &args, &results, m_pvBAEngineProcContext); | 1039 | // Get results. |
1040 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING, &bufferArgs, &bufferResults, &rpc); | ||
1041 | ExitOnFailure(hr, "BA SetVariableString failed."); | ||
1042 | |||
1043 | LExit: | ||
1044 | PipeFreeRpcResult(&rpc); | ||
1045 | ReleaseBuffer(bufferResults); | ||
1046 | ReleaseBuffer(bufferArgs); | ||
1047 | |||
1048 | return hr; | ||
437 | } | 1049 | } |
438 | 1050 | ||
439 | virtual STDMETHODIMP SetVariableVersion( | 1051 | virtual STDMETHODIMP SetVariableVersion( |
@@ -441,103 +1053,278 @@ public: // IBootstrapperEngine | |||
441 | __in_z_opt LPCWSTR wzValue | 1053 | __in_z_opt LPCWSTR wzValue |
442 | ) | 1054 | ) |
443 | { | 1055 | { |
1056 | HRESULT hr = S_OK; | ||
444 | BAENGINE_SETVARIABLEVERSION_ARGS args = { }; | 1057 | BAENGINE_SETVARIABLEVERSION_ARGS args = { }; |
445 | BAENGINE_SETVARIABLEVERSION_RESULTS results = { }; | 1058 | BAENGINE_SETVARIABLEVERSION_RESULTS results = { }; |
1059 | BUFF_BUFFER bufferArgs = { }; | ||
1060 | BUFF_BUFFER bufferResults = { }; | ||
1061 | PIPE_RPC_RESULT rpc = { }; | ||
446 | 1062 | ||
447 | args.cbSize = sizeof(args); | 1063 | // Init send structs. |
1064 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
448 | args.wzVariable = wzVariable; | 1065 | args.wzVariable = wzVariable; |
449 | args.wzValue = wzValue; | 1066 | args.wzValue = wzValue; |
450 | 1067 | ||
451 | results.cbSize = sizeof(results); | 1068 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
1069 | |||
1070 | // Send args. | ||
1071 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
1072 | ExitOnFailure(hr, "Failed to write API version of SetVariableVersion args."); | ||
1073 | |||
1074 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); | ||
1075 | ExitOnFailure(hr, "Failed to write variable of SetVariableVersion args."); | ||
1076 | |||
1077 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzValue); | ||
1078 | ExitOnFailure(hr, "Failed to write value of SetVariableVersion args."); | ||
1079 | |||
1080 | // Send results. | ||
1081 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
1082 | ExitOnFailure(hr, "Failed to write API version of SetVariableVersion results."); | ||
452 | 1083 | ||
453 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext); | 1084 | // Get results. |
1085 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION, &bufferArgs, &bufferResults, &rpc); | ||
1086 | ExitOnFailure(hr, "BA SetVariableVersion failed."); | ||
1087 | |||
1088 | LExit: | ||
1089 | PipeFreeRpcResult(&rpc); | ||
1090 | ReleaseBuffer(bufferResults); | ||
1091 | ReleaseBuffer(bufferArgs); | ||
1092 | |||
1093 | return hr; | ||
454 | } | 1094 | } |
455 | 1095 | ||
456 | virtual STDMETHODIMP CloseSplashScreen() | 1096 | virtual STDMETHODIMP CloseSplashScreen() |
457 | { | 1097 | { |
1098 | HRESULT hr = S_OK; | ||
458 | BAENGINE_CLOSESPLASHSCREEN_ARGS args = { }; | 1099 | BAENGINE_CLOSESPLASHSCREEN_ARGS args = { }; |
459 | BAENGINE_CLOSESPLASHSCREEN_RESULTS results = { }; | 1100 | BAENGINE_CLOSESPLASHSCREEN_RESULTS results = { }; |
1101 | BUFF_BUFFER bufferArgs = { }; | ||
1102 | BUFF_BUFFER bufferResults = { }; | ||
1103 | PIPE_RPC_RESULT rpc = { }; | ||
1104 | |||
1105 | // Init send structs. | ||
1106 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
1107 | |||
1108 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
1109 | |||
1110 | // Send args. | ||
1111 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
1112 | ExitOnFailure(hr, "Failed to write API version of CloseSplashScreen args."); | ||
1113 | |||
1114 | // Send results. | ||
1115 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
1116 | ExitOnFailure(hr, "Failed to write API version of CloseSplashScreen results."); | ||
460 | 1117 | ||
461 | args.cbSize = sizeof(args); | 1118 | // Get results. |
1119 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN, &bufferArgs, &bufferResults, &rpc); | ||
1120 | ExitOnFailure(hr, "BA CloseSplashScreen failed."); | ||
462 | 1121 | ||
463 | results.cbSize = sizeof(results); | 1122 | LExit: |
1123 | PipeFreeRpcResult(&rpc); | ||
1124 | ReleaseBuffer(bufferResults); | ||
1125 | ReleaseBuffer(bufferArgs); | ||
464 | 1126 | ||
465 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN, &args, &results, m_pvBAEngineProcContext); | 1127 | return hr; |
466 | } | 1128 | } |
467 | 1129 | ||
468 | virtual STDMETHODIMP Detect( | 1130 | virtual STDMETHODIMP Detect( |
469 | __in_opt HWND hwndParent | 1131 | __in_opt HWND hwndParent |
470 | ) | 1132 | ) |
471 | { | 1133 | { |
1134 | HRESULT hr = S_OK; | ||
472 | BAENGINE_DETECT_ARGS args = { }; | 1135 | BAENGINE_DETECT_ARGS args = { }; |
473 | BAENGINE_DETECT_RESULTS results = { }; | 1136 | BAENGINE_DETECT_RESULTS results = { }; |
1137 | BUFF_BUFFER bufferArgs = { }; | ||
1138 | BUFF_BUFFER bufferResults = { }; | ||
1139 | PIPE_RPC_RESULT rpc = { }; | ||
1140 | |||
1141 | // Init send structs. | ||
1142 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
1143 | args.hwndParent = reinterpret_cast<DWORD64>(hwndParent); | ||
1144 | |||
1145 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
474 | 1146 | ||
475 | args.cbSize = sizeof(args); | 1147 | // Send args. |
476 | args.hwndParent = hwndParent; | 1148 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); |
1149 | ExitOnFailure(hr, "Failed to write API version of Detect args."); | ||
477 | 1150 | ||
478 | results.cbSize = sizeof(results); | 1151 | hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.hwndParent); |
1152 | ExitOnFailure(hr, "Failed to write parent window of Detect args."); | ||
1153 | |||
1154 | // Send results. | ||
1155 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
1156 | ExitOnFailure(hr, "Failed to write API version of Detect results."); | ||
1157 | |||
1158 | // Get results. | ||
1159 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_DETECT, &bufferArgs, &bufferResults, &rpc); | ||
1160 | ExitOnFailure(hr, "BA Detect failed."); | ||
1161 | |||
1162 | LExit: | ||
1163 | PipeFreeRpcResult(&rpc); | ||
1164 | ReleaseBuffer(bufferResults); | ||
1165 | ReleaseBuffer(bufferArgs); | ||
479 | 1166 | ||
480 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_DETECT, &args, &results, m_pvBAEngineProcContext); | 1167 | return hr; |
481 | } | 1168 | } |
482 | 1169 | ||
483 | virtual STDMETHODIMP Plan( | 1170 | virtual STDMETHODIMP Plan( |
484 | __in BOOTSTRAPPER_ACTION action | 1171 | __in BOOTSTRAPPER_ACTION action |
485 | ) | 1172 | ) |
486 | { | 1173 | { |
1174 | HRESULT hr = S_OK; | ||
487 | BAENGINE_PLAN_ARGS args = { }; | 1175 | BAENGINE_PLAN_ARGS args = { }; |
488 | BAENGINE_PLAN_RESULTS results = { }; | 1176 | BAENGINE_PLAN_RESULTS results = { }; |
1177 | BUFF_BUFFER bufferArgs = { }; | ||
1178 | BUFF_BUFFER bufferResults = { }; | ||
1179 | PIPE_RPC_RESULT rpc = { }; | ||
489 | 1180 | ||
490 | args.cbSize = sizeof(args); | 1181 | // Init send structs. |
1182 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
491 | args.action = action; | 1183 | args.action = action; |
492 | 1184 | ||
493 | results.cbSize = sizeof(results); | 1185 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
1186 | |||
1187 | // Send args. | ||
1188 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
1189 | ExitOnFailure(hr, "Failed to write API version of Plan args."); | ||
1190 | |||
1191 | hr = BuffWriteNumberToBuffer(&bufferArgs, static_cast<DWORD>(args.action)); | ||
1192 | ExitOnFailure(hr, "Failed to write parent window of Plan args."); | ||
1193 | |||
1194 | // Send results. | ||
1195 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
1196 | ExitOnFailure(hr, "Failed to write API version of Plan results."); | ||
494 | 1197 | ||
495 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_PLAN, &args, &results, m_pvBAEngineProcContext); | 1198 | // Get results. |
1199 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_PLAN, &bufferArgs, &bufferResults, &rpc); | ||
1200 | ExitOnFailure(hr, "BA Plan failed."); | ||
1201 | |||
1202 | LExit: | ||
1203 | PipeFreeRpcResult(&rpc); | ||
1204 | ReleaseBuffer(bufferResults); | ||
1205 | ReleaseBuffer(bufferArgs); | ||
1206 | |||
1207 | return hr; | ||
496 | } | 1208 | } |
497 | 1209 | ||
498 | virtual STDMETHODIMP Elevate( | 1210 | virtual STDMETHODIMP Elevate( |
499 | __in_opt HWND hwndParent | 1211 | __in_opt HWND hwndParent |
500 | ) | 1212 | ) |
501 | { | 1213 | { |
1214 | HRESULT hr = S_OK; | ||
502 | BAENGINE_ELEVATE_ARGS args = { }; | 1215 | BAENGINE_ELEVATE_ARGS args = { }; |
503 | BAENGINE_ELEVATE_RESULTS results = { }; | 1216 | BAENGINE_ELEVATE_RESULTS results = { }; |
1217 | BUFF_BUFFER bufferArgs = { }; | ||
1218 | BUFF_BUFFER bufferResults = { }; | ||
1219 | PIPE_RPC_RESULT rpc = { }; | ||
1220 | |||
1221 | // Init send structs. | ||
1222 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
1223 | args.hwndParent = reinterpret_cast<DWORD64>(hwndParent); | ||
1224 | |||
1225 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
1226 | |||
1227 | // Send args. | ||
1228 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
1229 | ExitOnFailure(hr, "Failed to write API version of Elevate args."); | ||
504 | 1230 | ||
505 | args.cbSize = sizeof(args); | 1231 | hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.hwndParent); |
506 | args.hwndParent = hwndParent; | 1232 | ExitOnFailure(hr, "Failed to write parent window of Elevate args."); |
507 | 1233 | ||
508 | results.cbSize = sizeof(results); | 1234 | // Send results. |
1235 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
1236 | ExitOnFailure(hr, "Failed to write API version of Elevate results."); | ||
509 | 1237 | ||
510 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE, &args, &results, m_pvBAEngineProcContext); | 1238 | // Get results. |
1239 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE, &bufferArgs, &bufferResults, &rpc); | ||
1240 | ExitOnFailure(hr, "BA Elevate failed."); | ||
1241 | |||
1242 | LExit: | ||
1243 | PipeFreeRpcResult(&rpc); | ||
1244 | ReleaseBuffer(bufferResults); | ||
1245 | ReleaseBuffer(bufferArgs); | ||
1246 | |||
1247 | return hr; | ||
511 | } | 1248 | } |
512 | 1249 | ||
513 | virtual STDMETHODIMP Apply( | 1250 | virtual STDMETHODIMP Apply( |
514 | __in HWND hwndParent | 1251 | __in HWND hwndParent |
515 | ) | 1252 | ) |
516 | { | 1253 | { |
1254 | HRESULT hr = S_OK; | ||
517 | BAENGINE_APPLY_ARGS args = { }; | 1255 | BAENGINE_APPLY_ARGS args = { }; |
518 | BAENGINE_APPLY_RESULTS results = { }; | 1256 | BAENGINE_APPLY_RESULTS results = { }; |
1257 | BUFF_BUFFER bufferArgs = { }; | ||
1258 | BUFF_BUFFER bufferResults = { }; | ||
1259 | PIPE_RPC_RESULT rpc = { }; | ||
1260 | |||
1261 | // Init send structs. | ||
1262 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
1263 | args.hwndParent = reinterpret_cast<DWORD64>(hwndParent); | ||
1264 | |||
1265 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
1266 | |||
1267 | // Send args. | ||
1268 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
1269 | ExitOnFailure(hr, "Failed to write API version of Apply args."); | ||
1270 | |||
1271 | hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.hwndParent); | ||
1272 | ExitOnFailure(hr, "Failed to write parent window of Apply args."); | ||
519 | 1273 | ||
520 | args.cbSize = sizeof(args); | 1274 | // Send results. |
521 | args.hwndParent = hwndParent; | 1275 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); |
1276 | ExitOnFailure(hr, "Failed to write API version of Apply results."); | ||
522 | 1277 | ||
523 | results.cbSize = sizeof(results); | 1278 | // Get results. |
1279 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, &bufferArgs, &bufferResults, &rpc); | ||
1280 | ExitOnFailure(hr, "BA Apply failed."); | ||
524 | 1281 | ||
525 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, &args, &results, m_pvBAEngineProcContext); | 1282 | LExit: |
1283 | PipeFreeRpcResult(&rpc); | ||
1284 | ReleaseBuffer(bufferResults); | ||
1285 | ReleaseBuffer(bufferArgs); | ||
1286 | |||
1287 | return hr; | ||
526 | } | 1288 | } |
527 | 1289 | ||
528 | virtual STDMETHODIMP Quit( | 1290 | virtual STDMETHODIMP Quit( |
529 | __in DWORD dwExitCode | 1291 | __in DWORD dwExitCode |
530 | ) | 1292 | ) |
531 | { | 1293 | { |
1294 | HRESULT hr = S_OK; | ||
532 | BAENGINE_QUIT_ARGS args = { }; | 1295 | BAENGINE_QUIT_ARGS args = { }; |
533 | BAENGINE_QUIT_RESULTS results = { }; | 1296 | BAENGINE_QUIT_RESULTS results = { }; |
1297 | BUFF_BUFFER bufferArgs = { }; | ||
1298 | BUFF_BUFFER bufferResults = { }; | ||
1299 | PIPE_RPC_RESULT rpc = { }; | ||
534 | 1300 | ||
535 | args.cbSize = sizeof(args); | 1301 | // Init send structs. |
1302 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
536 | args.dwExitCode = dwExitCode; | 1303 | args.dwExitCode = dwExitCode; |
537 | 1304 | ||
538 | results.cbSize = sizeof(results); | 1305 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
539 | 1306 | ||
540 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, &args, &results, m_pvBAEngineProcContext); | 1307 | // Send args. |
1308 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
1309 | ExitOnFailure(hr, "Failed to write API version of Quit args."); | ||
1310 | |||
1311 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwExitCode); | ||
1312 | ExitOnFailure(hr, "Failed to write exit code of Quit args."); | ||
1313 | |||
1314 | // Send results. | ||
1315 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
1316 | ExitOnFailure(hr, "Failed to write API version of Quit results."); | ||
1317 | |||
1318 | // Get results. | ||
1319 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, &bufferArgs, &bufferResults, &rpc); | ||
1320 | ExitOnFailure(hr, "BA Quit failed."); | ||
1321 | |||
1322 | LExit: | ||
1323 | PipeFreeRpcResult(&rpc); | ||
1324 | ReleaseBuffer(bufferResults); | ||
1325 | ReleaseBuffer(bufferArgs); | ||
1326 | |||
1327 | return hr; | ||
541 | } | 1328 | } |
542 | 1329 | ||
543 | virtual STDMETHODIMP LaunchApprovedExe( | 1330 | virtual STDMETHODIMP LaunchApprovedExe( |
@@ -547,33 +1334,101 @@ public: // IBootstrapperEngine | |||
547 | __in DWORD dwWaitForInputIdleTimeout | 1334 | __in DWORD dwWaitForInputIdleTimeout |
548 | ) | 1335 | ) |
549 | { | 1336 | { |
1337 | HRESULT hr = S_OK; | ||
550 | BAENGINE_LAUNCHAPPROVEDEXE_ARGS args = { }; | 1338 | BAENGINE_LAUNCHAPPROVEDEXE_ARGS args = { }; |
551 | BAENGINE_LAUNCHAPPROVEDEXE_RESULTS results = { }; | 1339 | BAENGINE_LAUNCHAPPROVEDEXE_RESULTS results = { }; |
1340 | BUFF_BUFFER bufferArgs = { }; | ||
1341 | BUFF_BUFFER bufferResults = { }; | ||
1342 | PIPE_RPC_RESULT rpc = { }; | ||
1343 | |||
1344 | ExitOnNull(wzApprovedExeForElevationId, hr, E_INVALIDARG, "wzApprovedExeForElevationId is required"); | ||
552 | 1345 | ||
553 | args.cbSize = sizeof(args); | 1346 | // Init send structs. |
554 | args.hwndParent = hwndParent; | 1347 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
1348 | args.hwndParent = reinterpret_cast<DWORD64>(hwndParent); | ||
555 | args.wzApprovedExeForElevationId = wzApprovedExeForElevationId; | 1349 | args.wzApprovedExeForElevationId = wzApprovedExeForElevationId; |
556 | args.wzArguments = wzArguments; | 1350 | args.wzArguments = wzArguments; |
557 | args.dwWaitForInputIdleTimeout = dwWaitForInputIdleTimeout; | 1351 | args.dwWaitForInputIdleTimeout = dwWaitForInputIdleTimeout; |
558 | 1352 | ||
559 | results.cbSize = sizeof(results); | 1353 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
560 | 1354 | ||
561 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, &args, &results, m_pvBAEngineProcContext); | 1355 | // Send args. |
1356 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
1357 | ExitOnFailure(hr, "Failed to write API version of LaunchApprovedExe args."); | ||
1358 | |||
1359 | hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.hwndParent); | ||
1360 | ExitOnFailure(hr, "Failed to write parent window of LaunchApprovedExe args."); | ||
1361 | |||
1362 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzApprovedExeForElevationId); | ||
1363 | ExitOnFailure(hr, "Failed to write approved exe elevation id of LaunchApprovedExe args."); | ||
1364 | |||
1365 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzArguments); | ||
1366 | ExitOnFailure(hr, "Failed to write arguments of LaunchApprovedExe args."); | ||
1367 | |||
1368 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwWaitForInputIdleTimeout); | ||
1369 | ExitOnFailure(hr, "Failed to write wait for idle input timeout of LaunchApprovedExe args."); | ||
1370 | |||
1371 | // Send results. | ||
1372 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
1373 | ExitOnFailure(hr, "Failed to write API version of LaunchApprovedExe results."); | ||
1374 | |||
1375 | // Get results. | ||
1376 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, &bufferArgs, &bufferResults, &rpc); | ||
1377 | ExitOnFailure(hr, "BA LaunchApprovedExe failed."); | ||
1378 | |||
1379 | LExit: | ||
1380 | PipeFreeRpcResult(&rpc); | ||
1381 | ReleaseBuffer(bufferResults); | ||
1382 | ReleaseBuffer(bufferArgs); | ||
1383 | |||
1384 | return hr; | ||
562 | } | 1385 | } |
563 | 1386 | ||
564 | virtual STDMETHODIMP SetUpdateSource( | 1387 | virtual STDMETHODIMP SetUpdateSource( |
565 | __in_z LPCWSTR wzUrl | 1388 | __in_z LPCWSTR wzUrl, |
1389 | __in_z_opt LPCWSTR wzAuthorizationHeader | ||
566 | ) | 1390 | ) |
567 | { | 1391 | { |
1392 | HRESULT hr = S_OK; | ||
568 | BAENGINE_SETUPDATESOURCE_ARGS args = { }; | 1393 | BAENGINE_SETUPDATESOURCE_ARGS args = { }; |
569 | BAENGINE_SETUPDATESOURCE_RESULTS results = { }; | 1394 | BAENGINE_SETUPDATESOURCE_RESULTS results = { }; |
1395 | BUFF_BUFFER bufferArgs = { }; | ||
1396 | BUFF_BUFFER bufferResults = { }; | ||
1397 | PIPE_RPC_RESULT rpc = { }; | ||
1398 | |||
1399 | ExitOnNull(wzUrl, hr, E_INVALIDARG, "wzUrl is required"); | ||
570 | 1400 | ||
571 | args.cbSize = sizeof(args); | 1401 | // Init send structs. |
1402 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
572 | args.wzUrl = wzUrl; | 1403 | args.wzUrl = wzUrl; |
1404 | args.wzAuthorizationHeader = wzAuthorizationHeader; | ||
1405 | |||
1406 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
1407 | |||
1408 | // Send args. | ||
1409 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
1410 | ExitOnFailure(hr, "Failed to write API version of SetUpdateSource args."); | ||
1411 | |||
1412 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUrl); | ||
1413 | ExitOnFailure(hr, "Failed to write url of SetUpdateSource args."); | ||
1414 | |||
1415 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzAuthorizationHeader); | ||
1416 | ExitOnFailure(hr, "Failed to write authorization header of SetUpdateSource args."); | ||
573 | 1417 | ||
574 | results.cbSize = sizeof(results); | 1418 | // Send results. |
1419 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
1420 | ExitOnFailure(hr, "Failed to write API version of SetUpdateSource results."); | ||
575 | 1421 | ||
576 | return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE, &args, &results, m_pvBAEngineProcContext); | 1422 | // Get results. |
1423 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE, &bufferArgs, &bufferResults, &rpc); | ||
1424 | ExitOnFailure(hr, "BA SetUpdateSource failed."); | ||
1425 | |||
1426 | LExit: | ||
1427 | PipeFreeRpcResult(&rpc); | ||
1428 | ReleaseBuffer(bufferResults); | ||
1429 | ReleaseBuffer(bufferArgs); | ||
1430 | |||
1431 | return hr; | ||
577 | } | 1432 | } |
578 | 1433 | ||
579 | virtual STDMETHODIMP CompareVersions( | 1434 | virtual STDMETHODIMP CompareVersions( |
@@ -585,66 +1440,133 @@ public: // IBootstrapperEngine | |||
585 | HRESULT hr = S_OK; | 1440 | HRESULT hr = S_OK; |
586 | BAENGINE_COMPAREVERSIONS_ARGS args = { }; | 1441 | BAENGINE_COMPAREVERSIONS_ARGS args = { }; |
587 | BAENGINE_COMPAREVERSIONS_RESULTS results = { }; | 1442 | BAENGINE_COMPAREVERSIONS_RESULTS results = { }; |
1443 | BUFF_BUFFER bufferArgs = { }; | ||
1444 | BUFF_BUFFER bufferResults = { }; | ||
1445 | PIPE_RPC_RESULT rpc = { }; | ||
1446 | SIZE_T iBuffer = 0; | ||
588 | 1447 | ||
589 | ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); | 1448 | ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); |
590 | 1449 | ||
591 | args.cbSize = sizeof(args); | 1450 | // Init send structs. |
1451 | args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; | ||
592 | args.wzVersion1 = wzVersion1; | 1452 | args.wzVersion1 = wzVersion1; |
593 | args.wzVersion2 = wzVersion2; | 1453 | args.wzVersion2 = wzVersion2; |
594 | 1454 | ||
595 | results.cbSize = sizeof(results); | 1455 | results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; |
1456 | |||
1457 | // Send args. | ||
1458 | hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); | ||
1459 | ExitOnFailure(hr, "Failed to write API version of CompareVersions args."); | ||
1460 | |||
1461 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVersion1); | ||
1462 | ExitOnFailure(hr, "Failed to write first input of CompareVersions args."); | ||
1463 | |||
1464 | hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVersion2); | ||
1465 | ExitOnFailure(hr, "Failed to write second input of CompareVersions args."); | ||
1466 | |||
1467 | // Send results. | ||
1468 | hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); | ||
1469 | ExitOnFailure(hr, "Failed to write API version of CompareVersions results."); | ||
1470 | |||
1471 | // Get results. | ||
1472 | hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS, &bufferArgs, &bufferResults, &rpc); | ||
1473 | ExitOnFailure(hr, "BA CompareVersions failed."); | ||
596 | 1474 | ||
597 | hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS, &args, &results, m_pvBAEngineProcContext); | 1475 | // Read results. |
1476 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); | ||
1477 | ExitOnFailure(hr, "Failed to read size from CompareVersions results."); | ||
1478 | |||
1479 | hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast<DWORD*>(&results.nResult)); | ||
1480 | ExitOnFailure(hr, "Failed to read result from CompareVersions results."); | ||
598 | 1481 | ||
599 | *pnResult = results.nResult; | 1482 | *pnResult = results.nResult; |
600 | 1483 | ||
601 | LExit: | 1484 | LExit: |
1485 | PipeFreeRpcResult(&rpc); | ||
1486 | ReleaseBuffer(bufferResults); | ||
1487 | ReleaseBuffer(bufferArgs); | ||
1488 | |||
602 | return hr; | 1489 | return hr; |
603 | } | 1490 | } |
604 | 1491 | ||
605 | public: | 1492 | private: |
606 | HRESULT Init() | 1493 | HRESULT SendRequest( |
1494 | __in DWORD dwMessageType, | ||
1495 | __in BUFF_BUFFER* pBufferArgs, | ||
1496 | __in BUFF_BUFFER* pBufferResults, | ||
1497 | __in PIPE_RPC_RESULT* pRpc | ||
1498 | ) | ||
607 | { | 1499 | { |
608 | return ::CoCreateFreeThreadedMarshaler(this, &m_pFreeThreadedMarshaler); | 1500 | HRESULT hr = S_OK; |
1501 | BUFF_BUFFER buffer = { }; | ||
1502 | |||
1503 | hr = CombineArgsAndResults(pBufferArgs, pBufferResults, &buffer); | ||
1504 | if (SUCCEEDED(hr)) | ||
1505 | { | ||
1506 | hr = PipeRpcRequest(&m_hRpcPipe, dwMessageType, buffer.pbData, buffer.cbData, pRpc); | ||
1507 | } | ||
1508 | |||
1509 | ReleaseBuffer(buffer); | ||
1510 | return hr; | ||
609 | } | 1511 | } |
610 | 1512 | ||
1513 | HRESULT CombineArgsAndResults( | ||
1514 | __in BUFF_BUFFER* pBufferArgs, | ||
1515 | __in BUFF_BUFFER* pBufferResults, | ||
1516 | __in BUFF_BUFFER* pBufferCombined | ||
1517 | ) | ||
1518 | { | ||
1519 | HRESULT hr = S_OK; | ||
1520 | |||
1521 | // Write args to buffer. | ||
1522 | hr = BuffWriteStreamToBuffer(pBufferCombined, pBufferArgs->pbData, pBufferArgs->cbData); | ||
1523 | ExitOnFailure(hr, "Failed to write args buffer."); | ||
1524 | |||
1525 | // Write results to buffer. | ||
1526 | hr = BuffWriteStreamToBuffer(pBufferCombined, pBufferResults->pbData, pBufferResults->cbData); | ||
1527 | ExitOnFailure(hr, "Failed to write results buffer."); | ||
1528 | |||
1529 | LExit: | ||
1530 | return hr; | ||
1531 | } | ||
1532 | |||
1533 | public: | ||
611 | CBalBootstrapperEngine( | 1534 | CBalBootstrapperEngine( |
612 | __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc, | 1535 | __in HANDLE hPipe, |
613 | __in_opt LPVOID pvBAEngineProcContext | 1536 | __out HRESULT* phr |
614 | ) | 1537 | ) |
615 | { | 1538 | { |
616 | m_cReferences = 1; | 1539 | m_cReferences = 1; |
617 | m_pfnBAEngineProc = pfnBAEngineProc; | 1540 | |
618 | m_pvBAEngineProcContext = pvBAEngineProcContext; | 1541 | PipeRpcInitialize(&m_hRpcPipe, hPipe, FALSE); |
619 | m_pFreeThreadedMarshaler = NULL; | 1542 | |
1543 | *phr = ::CoCreateFreeThreadedMarshaler(this, &m_pFreeThreadedMarshaler); | ||
620 | } | 1544 | } |
621 | 1545 | ||
622 | ~CBalBootstrapperEngine() | 1546 | ~CBalBootstrapperEngine() |
623 | { | 1547 | { |
1548 | PipeRpcUninitiailize(&m_hRpcPipe); | ||
624 | ReleaseObject(m_pFreeThreadedMarshaler); | 1549 | ReleaseObject(m_pFreeThreadedMarshaler); |
625 | } | 1550 | } |
626 | 1551 | ||
627 | private: | 1552 | private: |
628 | long m_cReferences; | 1553 | long m_cReferences; |
629 | PFN_BOOTSTRAPPER_ENGINE_PROC m_pfnBAEngineProc; | 1554 | PIPE_RPC_HANDLE m_hRpcPipe; |
630 | LPVOID m_pvBAEngineProcContext; | ||
631 | IUnknown* m_pFreeThreadedMarshaler; | 1555 | IUnknown* m_pFreeThreadedMarshaler; |
632 | }; | 1556 | }; |
633 | 1557 | ||
1558 | |||
634 | HRESULT BalBootstrapperEngineCreate( | 1559 | HRESULT BalBootstrapperEngineCreate( |
635 | __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc, | 1560 | __in HANDLE hPipe, |
636 | __in_opt LPVOID pvBAEngineProcContext, | ||
637 | __out IBootstrapperEngine** ppBootstrapperEngine | 1561 | __out IBootstrapperEngine** ppBootstrapperEngine |
638 | ) | 1562 | ) |
639 | { | 1563 | { |
640 | HRESULT hr = S_OK; | 1564 | HRESULT hr = S_OK; |
641 | CBalBootstrapperEngine* pBootstrapperEngine = NULL; | 1565 | CBalBootstrapperEngine* pBootstrapperEngine = NULL; |
642 | 1566 | ||
643 | pBootstrapperEngine = new CBalBootstrapperEngine(pfnBAEngineProc, pvBAEngineProcContext); | 1567 | pBootstrapperEngine = new CBalBootstrapperEngine(hPipe, &hr); |
644 | ExitOnNull(pBootstrapperEngine, hr, E_OUTOFMEMORY, "Failed to allocate new BalBootstrapperEngine object."); | 1568 | ExitOnNull(pBootstrapperEngine, hr, E_OUTOFMEMORY, "Failed to allocate new BalBootstrapperEngine object."); |
645 | 1569 | ExitOnFailure(hr, "Failed to initialize BalBootstrapperEngine."); | |
646 | hr = pBootstrapperEngine->Init(); | ||
647 | ExitOnFailure(hr, "Failed to initialize CBalBootstrapperEngine."); | ||
648 | 1570 | ||
649 | hr = pBootstrapperEngine->QueryInterface(IID_PPV_ARGS(ppBootstrapperEngine)); | 1571 | hr = pBootstrapperEngine->QueryInterface(IID_PPV_ARGS(ppBootstrapperEngine)); |
650 | ExitOnFailure(hr, "Failed to QI for IBootstrapperEngine from BalBootstrapperEngine object."); | 1572 | ExitOnFailure(hr, "Failed to QI for IBootstrapperEngine from BalBootstrapperEngine object."); |