aboutsummaryrefslogtreecommitdiff
path: root/src/burn
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2024-01-11 00:00:27 -0800
committerRob Mensching <rob@firegiant.com>2024-01-11 18:24:06 -0800
commit8cfd711f775e8501836162538998b5b6d8efbf89 (patch)
tree3083faee64b5be16062a93ed4e4b6668fc4f64c8 /src/burn
parent4e7b7c0059d76498d1c24f348dbf6d5799203fe0 (diff)
downloadwix-8cfd711f775e8501836162538998b5b6d8efbf89.tar.gz
wix-8cfd711f775e8501836162538998b5b6d8efbf89.tar.bz2
wix-8cfd711f775e8501836162538998b5b6d8efbf89.zip
Update Burn to use pipeutil for low-level pipe operations
Diffstat (limited to 'src/burn')
-rw-r--r--src/burn/engine/burnpipe.cpp317
-rw-r--r--src/burn/engine/burnpipe.h11
-rw-r--r--src/burn/engine/elevation.cpp54
-rw-r--r--src/burn/engine/embedded.cpp10
-rw-r--r--src/burn/engine/externalengine.cpp4
-rw-r--r--src/burn/engine/precomp.h1
-rw-r--r--src/burn/test/BurnUnitTest/ElevationTest.cpp16
-rw-r--r--src/burn/test/BurnUnitTest/precomp.h1
8 files changed, 86 insertions, 328 deletions
diff --git a/src/burn/engine/burnpipe.cpp b/src/burn/engine/burnpipe.cpp
index 5003622c..297dc77a 100644
--- a/src/burn/engine/burnpipe.cpp
+++ b/src/burn/engine/burnpipe.cpp
@@ -2,34 +2,9 @@
2 2
3#include "precomp.h" 3#include "precomp.h"
4 4
5static const DWORD PIPE_64KB = 64 * 1024; 5static const LPCWSTR CACHE_PIPE_NAME_FORMAT_STRING = L"%ls.Cache";
6static const DWORD PIPE_WAIT_FOR_CONNECTION = 100; // wait a 10th of a second, 6static const LPCWSTR LOGGING_PIPE_NAME_FORMAT_STRING = L"%ls.Log";
7static const DWORD PIPE_RETRY_FOR_CONNECTION = 1800; // for up to 3 minutes.
8 7
9static const LPCWSTR PIPE_NAME_FORMAT_STRING = L"\\\\.\\pipe\\%ls";
10static const LPCWSTR CACHE_PIPE_NAME_FORMAT_STRING = L"\\\\.\\pipe\\%ls.Cache";
11static const LPCWSTR LOGGING_PIPE_NAME_FORMAT_STRING = L"\\\\.\\pipe\\%ls.Log";
12
13static HRESULT AllocatePipeMessage(
14 __in DWORD dwMessage,
15 __in_bcount_opt(cbData) LPVOID pvData,
16 __in SIZE_T cbData,
17 __out_bcount(cb) LPVOID* ppvMessage,
18 __out SIZE_T* pcbMessage
19 );
20static void FreePipeMessage(
21 __in BURN_PIPE_MESSAGE *pMsg
22 );
23static HRESULT WritePipeMessage(
24 __in HANDLE hPipe,
25 __in DWORD dwMessage,
26 __in_bcount_opt(cbData) LPVOID pvData,
27 __in SIZE_T cbData
28 );
29static HRESULT GetPipeMessage(
30 __in HANDLE hPipe,
31 __in BURN_PIPE_MESSAGE* pMsg
32 );
33static HRESULT ChildPipeConnected( 8static HRESULT ChildPipeConnected(
34 __in HANDLE hPipe, 9 __in HANDLE hPipe,
35 __in_z LPCWSTR wzSecret, 10 __in_z LPCWSTR wzSecret,
@@ -37,7 +12,6 @@ static HRESULT ChildPipeConnected(
37 ); 12 );
38 13
39 14
40
41/******************************************************************* 15/*******************************************************************
42 PipeConnectionInitialize - initialize pipe connection data. 16 PipeConnectionInitialize - initialize pipe connection data.
43 17
@@ -60,9 +34,9 @@ void PipeConnectionUninitialize(
60 __in BURN_PIPE_CONNECTION* pConnection 34 __in BURN_PIPE_CONNECTION* pConnection
61 ) 35 )
62{ 36{
63 ReleaseFileHandle(pConnection->hLoggingPipe); 37 ReleasePipeHandle(pConnection->hLoggingPipe);
64 ReleaseFileHandle(pConnection->hCachePipe); 38 ReleasePipeHandle(pConnection->hCachePipe);
65 ReleaseFileHandle(pConnection->hPipe); 39 ReleasePipeHandle(pConnection->hPipe);
66 ReleaseHandle(pConnection->hProcess); 40 ReleaseHandle(pConnection->hProcess);
67 ReleaseStr(pConnection->sczSecret); 41 ReleaseStr(pConnection->sczSecret);
68 ReleaseStr(pConnection->sczName); 42 ReleaseStr(pConnection->sczName);
@@ -71,7 +45,7 @@ void PipeConnectionUninitialize(
71} 45}
72 46
73/******************************************************************* 47/*******************************************************************
74 PipeSendMessage - 48 PipeSendMessage -
75 49
76*******************************************************************/ 50*******************************************************************/
77extern "C" HRESULT PipeSendMessage( 51extern "C" HRESULT PipeSendMessage(
@@ -87,7 +61,7 @@ extern "C" HRESULT PipeSendMessage(
87 HRESULT hr = S_OK; 61 HRESULT hr = S_OK;
88 BURN_PIPE_RESULT result = { }; 62 BURN_PIPE_RESULT result = { };
89 63
90 hr = WritePipeMessage(hPipe, dwMessage, pvData, cbData); 64 hr = PipeWriteMessage(hPipe, dwMessage, pvData, cbData);
91 ExitOnFailure(hr, "Failed to write send message to pipe."); 65 ExitOnFailure(hr, "Failed to write send message to pipe.");
92 66
93 hr = PipePumpMessages(hPipe, pfnCallback, pvContext, &result); 67 hr = PipePumpMessages(hPipe, pfnCallback, pvContext, &result);
@@ -100,7 +74,7 @@ LExit:
100} 74}
101 75
102/******************************************************************* 76/*******************************************************************
103 PipePumpMessages - 77 PipePumpMessages -
104 78
105*******************************************************************/ 79*******************************************************************/
106extern "C" HRESULT PipePumpMessages( 80extern "C" HRESULT PipePumpMessages(
@@ -111,15 +85,15 @@ extern "C" HRESULT PipePumpMessages(
111 ) 85 )
112{ 86{
113 HRESULT hr = S_OK; 87 HRESULT hr = S_OK;
114 BURN_PIPE_MESSAGE msg = { }; 88 PIPE_MESSAGE msg = { };
115 SIZE_T iData = 0; 89 SIZE_T iData = 0;
116 LPSTR sczMessage = NULL; 90 LPSTR sczMessage = NULL;
117 DWORD dwResult = 0; 91 DWORD dwResult = 0;
118 92
119 // Pump messages from child process. 93 // Pump messages from child process.
120 while (S_OK == (hr = GetPipeMessage(hPipe, &msg))) 94 while (S_OK == (hr = PipeReadMessage(hPipe, &msg)))
121 { 95 {
122 switch (msg.dwMessage) 96 switch (msg.dwMessageType)
123 { 97 {
124 case BURN_PIPE_MESSAGE_TYPE_LOG: 98 case BURN_PIPE_MESSAGE_TYPE_LOG:
125 iData = 0; 99 iData = 0;
@@ -166,15 +140,15 @@ extern "C" HRESULT PipePumpMessages(
166 { 140 {
167 hr = E_INVALIDARG; 141 hr = E_INVALIDARG;
168 } 142 }
169 ExitOnFailure(hr, "Failed to process message: %u", msg.dwMessage); 143 ExitOnFailure(hr, "Failed to process message: %u", msg.dwMessageType);
170 break; 144 break;
171 } 145 }
172 146
173 // post result 147 // post result
174 hr = WritePipeMessage(hPipe, static_cast<DWORD>(BURN_PIPE_MESSAGE_TYPE_COMPLETE), &dwResult, sizeof(dwResult)); 148 hr = PipeWriteMessage(hPipe, static_cast<DWORD>(BURN_PIPE_MESSAGE_TYPE_COMPLETE), &dwResult, sizeof(dwResult));
175 ExitOnFailure(hr, "Failed to post result to child process."); 149 ExitOnFailure(hr, "Failed to post result to child process.");
176 150
177 FreePipeMessage(&msg); 151 ReleasePipeMessage(&msg);
178 } 152 }
179 ExitOnFailure(hr, "Failed to get message over pipe"); 153 ExitOnFailure(hr, "Failed to get message over pipe");
180 154
@@ -185,13 +159,13 @@ extern "C" HRESULT PipePumpMessages(
185 159
186LExit: 160LExit:
187 ReleaseStr(sczMessage); 161 ReleaseStr(sczMessage);
188 FreePipeMessage(&msg); 162 ReleasePipeMessage(&msg);
189 163
190 return hr; 164 return hr;
191} 165}
192 166
193/******************************************************************* 167/*******************************************************************
194 PipeCreateNameAndSecret - 168 PipeCreateNameAndSecret -
195 169
196*******************************************************************/ 170*******************************************************************/
197extern "C" HRESULT PipeCreateNameAndSecret( 171extern "C" HRESULT PipeCreateNameAndSecret(
@@ -247,7 +221,7 @@ extern "C" HRESULT PipeCreatePipes(
247 HRESULT hr = S_OK; 221 HRESULT hr = S_OK;
248 PSECURITY_DESCRIPTOR psd = NULL; 222 PSECURITY_DESCRIPTOR psd = NULL;
249 SECURITY_ATTRIBUTES sa = { }; 223 SECURITY_ATTRIBUTES sa = { };
250 LPWSTR sczFullPipeName = NULL; 224 LPWSTR sczPipeName = NULL;
251 HANDLE hPipe = INVALID_HANDLE_VALUE; 225 HANDLE hPipe = INVALID_HANDLE_VALUE;
252 HANDLE hCachePipe = INVALID_HANDLE_VALUE; 226 HANDLE hCachePipe = INVALID_HANDLE_VALUE;
253 HANDLE hLoggingPipe = INVALID_HANDLE_VALUE; 227 HANDLE hLoggingPipe = INVALID_HANDLE_VALUE;
@@ -269,37 +243,24 @@ extern "C" HRESULT PipeCreatePipes(
269 } 243 }
270 244
271 // Create the pipe. 245 // Create the pipe.
272 hr = StrAllocFormatted(&sczFullPipeName, PIPE_NAME_FORMAT_STRING, pConnection->sczName); 246 hr = PipeCreate(pConnection->sczName, psd ? &sa : NULL, &hPipe);
273 ExitOnFailure(hr, "Failed to allocate full name of pipe: %ls", pConnection->sczName); 247 ExitOnFailure(hr, "Failed to create pipe: %ls", pConnection->sczName);
274
275 // TODO: consider using overlapped IO to do waits on the pipe and still be able to cancel and such.
276 hPipe = ::CreateNamedPipeW(sczFullPipeName, PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1, PIPE_64KB, PIPE_64KB, 1, psd ? &sa : NULL);
277 if (INVALID_HANDLE_VALUE == hPipe)
278 {
279 ExitWithLastError(hr, "Failed to create pipe: %ls", sczFullPipeName);
280 }
281 248
282 if (fCompanion) 249 if (fCompanion)
283 { 250 {
284 // Create the cache pipe. 251 // Create the cache pipe.
285 hr = StrAllocFormatted(&sczFullPipeName, CACHE_PIPE_NAME_FORMAT_STRING, pConnection->sczName); 252 hr = StrAllocFormatted(&sczPipeName, CACHE_PIPE_NAME_FORMAT_STRING, pConnection->sczName);
286 ExitOnFailure(hr, "Failed to allocate full name of cache pipe: %ls", pConnection->sczName); 253 ExitOnFailure(hr, "Failed to allocate full name of cache pipe: %ls", pConnection->sczName);
287 254
288 hCachePipe = ::CreateNamedPipeW(sczFullPipeName, PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1, PIPE_64KB, PIPE_64KB, 1, NULL); 255 hr = PipeCreate(sczPipeName, NULL, &hCachePipe);
289 if (INVALID_HANDLE_VALUE == hCachePipe) 256 ExitOnFailure(hr, "Failed to create cache pipe: %ls", sczPipeName);
290 {
291 ExitWithLastError(hr, "Failed to create cache pipe: %ls", sczFullPipeName);
292 }
293 257
294 // Create the logging pipe. 258 // Create the logging pipe.
295 hr = StrAllocFormatted(&sczFullPipeName, LOGGING_PIPE_NAME_FORMAT_STRING, pConnection->sczName); 259 hr = StrAllocFormatted(&sczPipeName, LOGGING_PIPE_NAME_FORMAT_STRING, pConnection->sczName);
296 ExitOnFailure(hr, "Failed to allocate full name of logging pipe: %ls", pConnection->sczName); 260 ExitOnFailure(hr, "Failed to allocate full name of logging pipe: %ls", pConnection->sczName);
297 261
298 hLoggingPipe = ::CreateNamedPipeW(sczFullPipeName, PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1, PIPE_64KB, PIPE_64KB, 1, NULL); 262 hr = PipeCreate(sczPipeName, NULL, &hLoggingPipe);
299 if (INVALID_HANDLE_VALUE == hLoggingPipe) 263 ExitOnFailure(hr, "Failed to create logging pipe: %ls", sczPipeName);
300 {
301 ExitWithLastError(hr, "Failed to create logging pipe: %ls", sczFullPipeName);
302 }
303 } 264 }
304 265
305 pConnection->hLoggingPipe = hLoggingPipe; 266 pConnection->hLoggingPipe = hLoggingPipe;
@@ -312,10 +273,10 @@ extern "C" HRESULT PipeCreatePipes(
312 hPipe = INVALID_HANDLE_VALUE; 273 hPipe = INVALID_HANDLE_VALUE;
313 274
314LExit: 275LExit:
315 ReleaseFileHandle(hLoggingPipe); 276 ReleasePipeHandle(hLoggingPipe);
316 ReleaseFileHandle(hCachePipe); 277 ReleasePipeHandle(hCachePipe);
317 ReleaseFileHandle(hPipe); 278 ReleasePipeHandle(hPipe);
318 ReleaseStr(sczFullPipeName); 279 ReleaseStr(sczPipeName);
319 280
320 if (psd) 281 if (psd)
321 { 282 {
@@ -326,7 +287,7 @@ LExit:
326} 287}
327 288
328/******************************************************************* 289/*******************************************************************
329 PipeWaitForChildConnect - 290 PipeWaitForChildConnect -
330 291
331*******************************************************************/ 292*******************************************************************/
332extern "C" HRESULT PipeWaitForChildConnect( 293extern "C" HRESULT PipeWaitForChildConnect(
@@ -343,58 +304,10 @@ extern "C" HRESULT PipeWaitForChildConnect(
343 for (DWORD i = 0; i < countof(hPipes) && INVALID_HANDLE_VALUE != hPipes[i]; ++i) 304 for (DWORD i = 0; i < countof(hPipes) && INVALID_HANDLE_VALUE != hPipes[i]; ++i)
344 { 305 {
345 HANDLE hPipe = hPipes[i]; 306 HANDLE hPipe = hPipes[i];
346 DWORD dwPipeState = PIPE_READMODE_BYTE | PIPE_NOWAIT;
347 307
348 // Temporarily make the pipe non-blocking so we will not get stuck in ::ConnectNamedPipe() forever 308 hr = PipeServerWaitForClientConnect(hPipe);
349 // if the child decides not to show up.
350 if (!::SetNamedPipeHandleState(hPipe, &dwPipeState, NULL, NULL))
351 {
352 ExitWithLastError(hr, "Failed to set pipe to non-blocking.");
353 }
354
355 // Loop for a while waiting for a connection from child process.
356 DWORD cRetry = 0;
357 do
358 {
359 if (!::ConnectNamedPipe(hPipe, NULL))
360 {
361 DWORD er = ::GetLastError();
362 if (ERROR_PIPE_CONNECTED == er)
363 {
364 hr = S_OK;
365 break;
366 }
367 else if (ERROR_PIPE_LISTENING == er)
368 {
369 if (cRetry < PIPE_RETRY_FOR_CONNECTION)
370 {
371 hr = HRESULT_FROM_WIN32(er);
372 }
373 else
374 {
375 hr = HRESULT_FROM_WIN32(ERROR_TIMEOUT);
376 break;
377 }
378
379 ++cRetry;
380 ::Sleep(PIPE_WAIT_FOR_CONNECTION);
381 }
382 else
383 {
384 hr = HRESULT_FROM_WIN32(er);
385 break;
386 }
387 }
388 } while (HRESULT_FROM_WIN32(ERROR_PIPE_LISTENING) == hr);
389 ExitOnRootFailure(hr, "Failed to wait for child to connect to pipe."); 309 ExitOnRootFailure(hr, "Failed to wait for child to connect to pipe.");
390 310
391 // Put the pipe back in blocking mode.
392 dwPipeState = PIPE_READMODE_BYTE | PIPE_WAIT;
393 if (!::SetNamedPipeHandleState(hPipe, &dwPipeState, NULL, NULL))
394 {
395 ExitWithLastError(hr, "Failed to reset pipe to blocking.");
396 }
397
398 // Prove we are the one that created the elevated process by passing the secret. 311 // Prove we are the one that created the elevated process by passing the secret.
399 hr = FileWriteHandle(hPipe, reinterpret_cast<LPCBYTE>(&cbSecret), sizeof(cbSecret)); 312 hr = FileWriteHandle(hPipe, reinterpret_cast<LPCBYTE>(&cbSecret), sizeof(cbSecret));
400 ExitOnFailure(hr, "Failed to write secret length to pipe."); 313 ExitOnFailure(hr, "Failed to write secret length to pipe.");
@@ -422,7 +335,7 @@ LExit:
422} 335}
423 336
424/******************************************************************* 337/*******************************************************************
425 PipeTerminateLoggingPipe - 338 PipeTerminateLoggingPipe -
426 339
427*******************************************************************/ 340*******************************************************************/
428extern "C" HRESULT PipeTerminateLoggingPipe( 341extern "C" HRESULT PipeTerminateLoggingPipe(
@@ -438,7 +351,7 @@ extern "C" HRESULT PipeTerminateLoggingPipe(
438 hr = BuffWriteNumber(&pbData, &cbData, dwParentExitCode); 351 hr = BuffWriteNumber(&pbData, &cbData, dwParentExitCode);
439 ExitOnFailure(hr, "Failed to write exit code to message buffer."); 352 ExitOnFailure(hr, "Failed to write exit code to message buffer.");
440 353
441 hr = WritePipeMessage(hLoggingPipe, static_cast<DWORD>(BURN_PIPE_MESSAGE_TYPE_COMPLETE), pbData, cbData); 354 hr = PipeWriteMessage(hLoggingPipe, static_cast<DWORD>(BURN_PIPE_MESSAGE_TYPE_COMPLETE), pbData, cbData);
442 ExitOnFailure(hr, "Failed to post complete message to logging pipe."); 355 ExitOnFailure(hr, "Failed to post complete message to logging pipe.");
443 356
444LExit: 357LExit:
@@ -448,7 +361,7 @@ LExit:
448} 361}
449 362
450/******************************************************************* 363/*******************************************************************
451 PipeTerminateChildProcess - 364 PipeTerminateChildProcess -
452 365
453*******************************************************************/ 366*******************************************************************/
454extern "C" HRESULT PipeTerminateChildProcess( 367extern "C" HRESULT PipeTerminateChildProcess(
@@ -472,11 +385,11 @@ extern "C" HRESULT PipeTerminateChildProcess(
472 // Send the messages. 385 // Send the messages.
473 if (INVALID_HANDLE_VALUE != pConnection->hCachePipe) 386 if (INVALID_HANDLE_VALUE != pConnection->hCachePipe)
474 { 387 {
475 hr = WritePipeMessage(pConnection->hCachePipe, static_cast<DWORD>(BURN_PIPE_MESSAGE_TYPE_TERMINATE), pbData, cbData); 388 hr = PipeWriteMessage(pConnection->hCachePipe, static_cast<DWORD>(BURN_PIPE_MESSAGE_TYPE_TERMINATE), pbData, cbData);
476 ExitOnFailure(hr, "Failed to post terminate message to child process cache thread."); 389 ExitOnFailure(hr, "Failed to post terminate message to child process cache thread.");
477 } 390 }
478 391
479 hr = WritePipeMessage(pConnection->hPipe, static_cast<DWORD>(BURN_PIPE_MESSAGE_TYPE_TERMINATE), pbData, cbData); 392 hr = PipeWriteMessage(pConnection->hPipe, static_cast<DWORD>(BURN_PIPE_MESSAGE_TYPE_TERMINATE), pbData, cbData);
480 ExitOnFailure(hr, "Failed to post terminate message to child process."); 393 ExitOnFailure(hr, "Failed to post terminate message to child process.");
481 394
482 // If we were able to get a handle to the other process, wait for it to exit. 395 // If we were able to get a handle to the other process, wait for it to exit.
@@ -532,28 +445,7 @@ extern "C" HRESULT PipeChildConnect(
532 LPWSTR sczPipeName = NULL; 445 LPWSTR sczPipeName = NULL;
533 446
534 // Try to connect to the parent. 447 // Try to connect to the parent.
535 hr = StrAllocFormatted(&sczPipeName, PIPE_NAME_FORMAT_STRING, pConnection->sczName); 448 hr = PipeClientConnect(pConnection->sczName, &pConnection->hPipe);
536 ExitOnFailure(hr, "Failed to allocate name of parent pipe.");
537
538 hr = E_UNEXPECTED;
539 for (DWORD cRetry = 0; FAILED(hr) && cRetry < PIPE_RETRY_FOR_CONNECTION; ++cRetry)
540 {
541 pConnection->hPipe = ::CreateFileW(sczPipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
542 if (INVALID_HANDLE_VALUE == pConnection->hPipe)
543 {
544 hr = HRESULT_FROM_WIN32(::GetLastError());
545 if (E_FILENOTFOUND == hr) // if the pipe isn't created, call it a timeout waiting on the parent.
546 {
547 hr = HRESULT_FROM_WIN32(ERROR_TIMEOUT);
548 }
549
550 ::Sleep(PIPE_WAIT_FOR_CONNECTION);
551 }
552 else // we have a connection, go with it.
553 {
554 hr = S_OK;
555 }
556 }
557 ExitOnRootFailure(hr, "Failed to open parent pipe: %ls", sczPipeName) 449 ExitOnRootFailure(hr, "Failed to open parent pipe: %ls", sczPipeName)
558 450
559 // Verify the parent and notify it that the child connected. 451 // Verify the parent and notify it that the child connected.
@@ -566,11 +458,8 @@ extern "C" HRESULT PipeChildConnect(
566 hr = StrAllocFormatted(&sczPipeName, CACHE_PIPE_NAME_FORMAT_STRING, pConnection->sczName); 458 hr = StrAllocFormatted(&sczPipeName, CACHE_PIPE_NAME_FORMAT_STRING, pConnection->sczName);
567 ExitOnFailure(hr, "Failed to allocate name of parent cache pipe."); 459 ExitOnFailure(hr, "Failed to allocate name of parent cache pipe.");
568 460
569 pConnection->hCachePipe = ::CreateFileW(sczPipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); 461 hr = PipeClientConnect(sczPipeName, &pConnection->hCachePipe);
570 if (INVALID_HANDLE_VALUE == pConnection->hCachePipe) 462 ExitOnFailure(hr, "Failed to open parent cache pipe: %ls", sczPipeName)
571 {
572 ExitWithLastError(hr, "Failed to open parent cache pipe: %ls", sczPipeName)
573 }
574 463
575 // Verify the parent and notify it that the child connected. 464 // Verify the parent and notify it that the child connected.
576 hr = ChildPipeConnected(pConnection->hCachePipe, pConnection->sczSecret, &pConnection->dwProcessId); 465 hr = ChildPipeConnected(pConnection->hCachePipe, pConnection->sczSecret, &pConnection->dwProcessId);
@@ -580,11 +469,8 @@ extern "C" HRESULT PipeChildConnect(
580 hr = StrAllocFormatted(&sczPipeName, LOGGING_PIPE_NAME_FORMAT_STRING, pConnection->sczName); 469 hr = StrAllocFormatted(&sczPipeName, LOGGING_PIPE_NAME_FORMAT_STRING, pConnection->sczName);
581 ExitOnFailure(hr, "Failed to allocate name of parent logging pipe."); 470 ExitOnFailure(hr, "Failed to allocate name of parent logging pipe.");
582 471
583 pConnection->hLoggingPipe = ::CreateFileW(sczPipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); 472 hr = PipeClientConnect(sczPipeName, &pConnection->hLoggingPipe);
584 if (INVALID_HANDLE_VALUE == pConnection->hLoggingPipe) 473 ExitOnFailure(hr, "Failed to open parent cache pipe: %ls", sczPipeName)
585 {
586 ExitWithLastError(hr, "Failed to open parent logging pipe: %ls", sczPipeName)
587 }
588 474
589 // Verify the parent and notify it that the child connected. 475 // Verify the parent and notify it that the child connected.
590 hr = ChildPipeConnected(pConnection->hLoggingPipe, pConnection->sczSecret, &pConnection->dwProcessId); 476 hr = ChildPipeConnected(pConnection->hLoggingPipe, pConnection->sczSecret, &pConnection->dwProcessId);
@@ -600,127 +486,6 @@ LExit:
600 return hr; 486 return hr;
601} 487}
602 488
603
604static HRESULT AllocatePipeMessage(
605 __in DWORD dwMessage,
606 __in_bcount_opt(cbData) LPVOID pvData,
607 __in SIZE_T cbData,
608 __out_bcount(cb) LPVOID* ppvMessage,
609 __out SIZE_T* pcbMessage
610 )
611{
612 HRESULT hr = S_OK;
613 LPVOID pv = NULL;
614 size_t cb = 0;
615 DWORD dwcbData = 0;
616
617 // If no data was provided, ensure the count of bytes is zero.
618 if (!pvData)
619 {
620 cbData = 0;
621 }
622 else if (MAXDWORD < cbData)
623 {
624 ExitWithRootFailure(hr, E_INVALIDDATA, "Pipe message is too large.");
625 }
626
627 hr = ::SizeTAdd(sizeof(dwMessage) + sizeof(dwcbData), cbData, &cb);
628 ExitOnRootFailure(hr, "Failed to calculate total pipe message size");
629
630 dwcbData = (DWORD)cbData;
631
632 // Allocate the message.
633 pv = MemAlloc(cb, FALSE);
634 ExitOnNull(pv, hr, E_OUTOFMEMORY, "Failed to allocate memory for message.");
635
636 memcpy_s(pv, cb, &dwMessage, sizeof(dwMessage));
637 memcpy_s(static_cast<BYTE*>(pv) + sizeof(dwMessage), cb - sizeof(dwMessage), &dwcbData, sizeof(dwcbData));
638 if (dwcbData)
639 {
640 memcpy_s(static_cast<BYTE*>(pv) + sizeof(dwMessage) + sizeof(dwcbData), cb - sizeof(dwMessage) - sizeof(dwcbData), pvData, dwcbData);
641 }
642
643 *pcbMessage = cb;
644 *ppvMessage = pv;
645 pv = NULL;
646
647LExit:
648 ReleaseMem(pv);
649 return hr;
650}
651
652static void FreePipeMessage(
653 __in BURN_PIPE_MESSAGE *pMsg
654 )
655{
656 if (pMsg->fAllocatedData)
657 {
658 ReleaseNullMem(pMsg->pvData);
659 pMsg->fAllocatedData = FALSE;
660 }
661}
662
663static HRESULT WritePipeMessage(
664 __in HANDLE hPipe,
665 __in DWORD dwMessage,
666 __in_bcount_opt(cbData) LPVOID pvData,
667 __in SIZE_T cbData
668 )
669{
670 HRESULT hr = S_OK;
671 LPVOID pv = NULL;
672 SIZE_T cb = 0;
673
674 hr = AllocatePipeMessage(dwMessage, pvData, cbData, &pv, &cb);
675 ExitOnFailure(hr, "Failed to allocate message to write.");
676
677 // Write the message.
678 hr = FileWriteHandle(hPipe, reinterpret_cast<LPCBYTE>(pv), cb);
679 ExitOnFailure(hr, "Failed to write message type to pipe.");
680
681LExit:
682 ReleaseMem(pv);
683 return hr;
684}
685
686static HRESULT GetPipeMessage(
687 __in HANDLE hPipe,
688 __in BURN_PIPE_MESSAGE* pMsg
689 )
690{
691 HRESULT hr = S_OK;
692 BYTE pbMessageAndByteCount[sizeof(DWORD) + sizeof(DWORD)] = { };
693
694 hr = FileReadHandle(hPipe, pbMessageAndByteCount, sizeof(pbMessageAndByteCount));
695 if (HRESULT_FROM_WIN32(ERROR_BROKEN_PIPE) == hr)
696 {
697 memset(pbMessageAndByteCount, 0, sizeof(pbMessageAndByteCount));
698 hr = S_FALSE;
699 }
700 ExitOnFailure(hr, "Failed to read message from pipe.");
701
702 pMsg->dwMessage = *(DWORD*)(pbMessageAndByteCount);
703 pMsg->cbData = *(DWORD*)(pbMessageAndByteCount + sizeof(DWORD));
704 if (pMsg->cbData)
705 {
706 pMsg->pvData = MemAlloc(pMsg->cbData, FALSE);
707 ExitOnNull(pMsg->pvData, hr, E_OUTOFMEMORY, "Failed to allocate data for message.");
708
709 hr = FileReadHandle(hPipe, reinterpret_cast<LPBYTE>(pMsg->pvData), pMsg->cbData);
710 ExitOnFailure(hr, "Failed to read data for message.");
711
712 pMsg->fAllocatedData = TRUE;
713 }
714
715LExit:
716 if (!pMsg->fAllocatedData && pMsg->pvData)
717 {
718 MemFree(pMsg->pvData);
719 }
720
721 return hr;
722}
723
724static HRESULT ChildPipeConnected( 489static HRESULT ChildPipeConnected(
725 __in HANDLE hPipe, 490 __in HANDLE hPipe,
726 __in_z LPCWSTR wzSecret, 491 __in_z LPCWSTR wzSecret,
diff --git a/src/burn/engine/burnpipe.h b/src/burn/engine/burnpipe.h
index 6571c0e2..c878ad94 100644
--- a/src/burn/engine/burnpipe.h
+++ b/src/burn/engine/burnpipe.h
@@ -25,15 +25,6 @@ typedef enum _BURN_PIPE_MESSAGE_TYPE : DWORD
25 BURN_PIPE_MESSAGE_TYPE_TERMINATE = 0xF0000003, 25 BURN_PIPE_MESSAGE_TYPE_TERMINATE = 0xF0000003,
26} BURN_PIPE_MESSAGE_TYPE; 26} BURN_PIPE_MESSAGE_TYPE;
27 27
28typedef struct _BURN_PIPE_MESSAGE
29{
30 DWORD dwMessage;
31 DWORD cbData;
32
33 BOOL fAllocatedData;
34 LPVOID pvData;
35} BURN_PIPE_MESSAGE;
36
37typedef struct _BURN_PIPE_RESULT 28typedef struct _BURN_PIPE_RESULT
38{ 29{
39 DWORD dwResult; 30 DWORD dwResult;
@@ -42,7 +33,7 @@ typedef struct _BURN_PIPE_RESULT
42 33
43 34
44typedef HRESULT (*PFN_PIPE_MESSAGE_CALLBACK)( 35typedef HRESULT (*PFN_PIPE_MESSAGE_CALLBACK)(
45 __in BURN_PIPE_MESSAGE* pMsg, 36 __in PIPE_MESSAGE* pMsg,
46 __in_opt LPVOID pvContext, 37 __in_opt LPVOID pvContext,
47 __out DWORD* pdwResult 38 __out DWORD* pdwResult
48 ); 39 );
diff --git a/src/burn/engine/elevation.cpp b/src/burn/engine/elevation.cpp
index 63a76c2c..10ae74a4 100644
--- a/src/burn/engine/elevation.cpp
+++ b/src/burn/engine/elevation.cpp
@@ -129,43 +129,43 @@ static HRESULT WaitForElevatedChildCacheThread(
129 __in DWORD dwExpectedExitCode 129 __in DWORD dwExpectedExitCode
130 ); 130 );
131static HRESULT ProcessApplyInitializeMessages( 131static HRESULT ProcessApplyInitializeMessages(
132 __in BURN_PIPE_MESSAGE* pMsg, 132 __in PIPE_MESSAGE* pMsg,
133 __in_opt LPVOID pvContext, 133 __in_opt LPVOID pvContext,
134 __out DWORD* pdwResult 134 __out DWORD* pdwResult
135 ); 135 );
136static HRESULT ProcessBurnCacheMessages( 136static HRESULT ProcessBurnCacheMessages(
137 __in BURN_PIPE_MESSAGE* pMsg, 137 __in PIPE_MESSAGE* pMsg,
138 __in LPVOID pvContext, 138 __in LPVOID pvContext,
139 __out DWORD* pdwResult 139 __out DWORD* pdwResult
140 ); 140 );
141static HRESULT ProcessGenericExecuteMessages( 141static HRESULT ProcessGenericExecuteMessages(
142 __in BURN_PIPE_MESSAGE* pMsg, 142 __in PIPE_MESSAGE* pMsg,
143 __in LPVOID pvContext, 143 __in LPVOID pvContext,
144 __out DWORD* pdwResult 144 __out DWORD* pdwResult
145 ); 145 );
146static HRESULT ProcessMsiPackageMessages( 146static HRESULT ProcessMsiPackageMessages(
147 __in BURN_PIPE_MESSAGE* pMsg, 147 __in PIPE_MESSAGE* pMsg,
148 __in_opt LPVOID pvContext, 148 __in_opt LPVOID pvContext,
149 __out DWORD* pdwResult 149 __out DWORD* pdwResult
150 ); 150 );
151static HRESULT ProcessLaunchApprovedExeMessages( 151static HRESULT ProcessLaunchApprovedExeMessages(
152 __in BURN_PIPE_MESSAGE* pMsg, 152 __in PIPE_MESSAGE* pMsg,
153 __in_opt LPVOID pvContext, 153 __in_opt LPVOID pvContext,
154 __out DWORD* pdwResult 154 __out DWORD* pdwResult
155 ); 155 );
156static HRESULT ProcessProgressRoutineMessage( 156static HRESULT ProcessProgressRoutineMessage(
157 __in BURN_PIPE_MESSAGE* pMsg, 157 __in PIPE_MESSAGE* pMsg,
158 __in LPPROGRESS_ROUTINE pfnProgress, 158 __in LPPROGRESS_ROUTINE pfnProgress,
159 __in LPVOID pvContext, 159 __in LPVOID pvContext,
160 __out DWORD* pdwResult 160 __out DWORD* pdwResult
161 ); 161 );
162static HRESULT ProcessElevatedChildMessage( 162static HRESULT ProcessElevatedChildMessage(
163 __in BURN_PIPE_MESSAGE* pMsg, 163 __in PIPE_MESSAGE* pMsg,
164 __in_opt LPVOID pvContext, 164 __in_opt LPVOID pvContext,
165 __out DWORD* pdwResult 165 __out DWORD* pdwResult
166 ); 166 );
167static HRESULT ProcessElevatedChildCacheMessage( 167static HRESULT ProcessElevatedChildCacheMessage(
168 __in BURN_PIPE_MESSAGE* pMsg, 168 __in PIPE_MESSAGE* pMsg,
169 __in_opt LPVOID pvContext, 169 __in_opt LPVOID pvContext,
170 __out DWORD* pdwResult 170 __out DWORD* pdwResult
171 ); 171 );
@@ -1739,7 +1739,7 @@ LExit:
1739} 1739}
1740 1740
1741static HRESULT ProcessApplyInitializeMessages( 1741static HRESULT ProcessApplyInitializeMessages(
1742 __in BURN_PIPE_MESSAGE* pMsg, 1742 __in PIPE_MESSAGE* pMsg,
1743 __in_opt LPVOID pvContext, 1743 __in_opt LPVOID pvContext,
1744 __out DWORD* pdwResult 1744 __out DWORD* pdwResult
1745 ) 1745 )
@@ -1752,7 +1752,7 @@ static HRESULT ProcessApplyInitializeMessages(
1752 HRESULT hrBA = S_OK; 1752 HRESULT hrBA = S_OK;
1753 1753
1754 // Process the message. 1754 // Process the message.
1755 switch (pMsg->dwMessage) 1755 switch (pMsg->dwMessageType)
1756 { 1756 {
1757 case BURN_ELEVATION_MESSAGE_TYPE_APPLY_INITIALIZE_PAUSE_AU_BEGIN: 1757 case BURN_ELEVATION_MESSAGE_TYPE_APPLY_INITIALIZE_PAUSE_AU_BEGIN:
1758 pContext->fPauseCompleteNeeded = TRUE; 1758 pContext->fPauseCompleteNeeded = TRUE;
@@ -1801,7 +1801,7 @@ LExit:
1801} 1801}
1802 1802
1803static HRESULT ProcessBurnCacheMessages( 1803static HRESULT ProcessBurnCacheMessages(
1804 __in BURN_PIPE_MESSAGE* pMsg, 1804 __in PIPE_MESSAGE* pMsg,
1805 __in LPVOID pvContext, 1805 __in LPVOID pvContext,
1806 __out DWORD* pdwResult 1806 __out DWORD* pdwResult
1807 ) 1807 )
@@ -1813,7 +1813,7 @@ static HRESULT ProcessBurnCacheMessages(
1813 BOOL fProgressRoutine = FALSE; 1813 BOOL fProgressRoutine = FALSE;
1814 1814
1815 // Process the message. 1815 // Process the message.
1816 switch (pMsg->dwMessage) 1816 switch (pMsg->dwMessageType)
1817 { 1817 {
1818 case BURN_ELEVATION_MESSAGE_TYPE_BURN_CACHE_BEGIN: 1818 case BURN_ELEVATION_MESSAGE_TYPE_BURN_CACHE_BEGIN:
1819 // read message parameters 1819 // read message parameters
@@ -1872,7 +1872,7 @@ LExit:
1872} 1872}
1873 1873
1874static HRESULT ProcessGenericExecuteMessages( 1874static HRESULT ProcessGenericExecuteMessages(
1875 __in BURN_PIPE_MESSAGE* pMsg, 1875 __in PIPE_MESSAGE* pMsg,
1876 __in LPVOID pvContext, 1876 __in LPVOID pvContext,
1877 __out DWORD* pdwResult 1877 __out DWORD* pdwResult
1878 ) 1878 )
@@ -1885,7 +1885,7 @@ static HRESULT ProcessGenericExecuteMessages(
1885 LPWSTR* rgwzFiles = NULL; 1885 LPWSTR* rgwzFiles = NULL;
1886 GENERIC_EXECUTE_MESSAGE message = { }; 1886 GENERIC_EXECUTE_MESSAGE message = { };
1887 1887
1888 if (BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE == pMsg->dwMessage) 1888 if (BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE == pMsg->dwMessageType)
1889 { 1889 {
1890 hr = ProcessExecuteActionCompleteMessage((BYTE*)pMsg->pvData, pMsg->cbData, &pContext->restart, pdwResult); 1890 hr = ProcessExecuteActionCompleteMessage((BYTE*)pMsg->pvData, pMsg->cbData, &pContext->restart, pdwResult);
1891 ExitOnFailure(hr, "Failed to process BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE message."); 1891 ExitOnFailure(hr, "Failed to process BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE message.");
@@ -1897,7 +1897,7 @@ static HRESULT ProcessGenericExecuteMessages(
1897 ExitOnFailure(hr, "Failed to allowed results."); 1897 ExitOnFailure(hr, "Failed to allowed results.");
1898 1898
1899 // Process the message. 1899 // Process the message.
1900 switch (pMsg->dwMessage) 1900 switch (pMsg->dwMessageType)
1901 { 1901 {
1902 case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_PROGRESS: 1902 case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_PROGRESS:
1903 message.type = GENERIC_EXECUTE_MESSAGE_PROGRESS; 1903 message.type = GENERIC_EXECUTE_MESSAGE_PROGRESS;
@@ -1979,7 +1979,7 @@ LExit:
1979} 1979}
1980 1980
1981static HRESULT ProcessMsiPackageMessages( 1981static HRESULT ProcessMsiPackageMessages(
1982 __in BURN_PIPE_MESSAGE* pMsg, 1982 __in PIPE_MESSAGE* pMsg,
1983 __in_opt LPVOID pvContext, 1983 __in_opt LPVOID pvContext,
1984 __out DWORD* pdwResult 1984 __out DWORD* pdwResult
1985 ) 1985 )
@@ -1993,7 +1993,7 @@ static HRESULT ProcessMsiPackageMessages(
1993 LPWSTR sczMessage = NULL; 1993 LPWSTR sczMessage = NULL;
1994 BOOL fRestartManager = FALSE; 1994 BOOL fRestartManager = FALSE;
1995 1995
1996 if (BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE == pMsg->dwMessage) 1996 if (BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE == pMsg->dwMessageType)
1997 { 1997 {
1998 hr = ProcessExecuteActionCompleteMessage((BYTE*)pMsg->pvData, pMsg->cbData, &pContext->restart, pdwResult); 1998 hr = ProcessExecuteActionCompleteMessage((BYTE*)pMsg->pvData, pMsg->cbData, &pContext->restart, pdwResult);
1999 ExitOnFailure(hr, "Failed to process BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE message."); 1999 ExitOnFailure(hr, "Failed to process BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE message.");
@@ -2024,7 +2024,7 @@ static HRESULT ProcessMsiPackageMessages(
2024 ExitOnFailure(hr, "Failed to read UI flags."); 2024 ExitOnFailure(hr, "Failed to read UI flags.");
2025 2025
2026 // Process the rest of the message. 2026 // Process the rest of the message.
2027 switch (pMsg->dwMessage) 2027 switch (pMsg->dwMessageType)
2028 { 2028 {
2029 case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_PROGRESS: 2029 case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_PROGRESS:
2030 // read message parameters 2030 // read message parameters
@@ -2093,7 +2093,7 @@ LExit:
2093} 2093}
2094 2094
2095static HRESULT ProcessLaunchApprovedExeMessages( 2095static HRESULT ProcessLaunchApprovedExeMessages(
2096 __in BURN_PIPE_MESSAGE* pMsg, 2096 __in PIPE_MESSAGE* pMsg,
2097 __in_opt LPVOID pvContext, 2097 __in_opt LPVOID pvContext,
2098 __out DWORD* pdwResult 2098 __out DWORD* pdwResult
2099 ) 2099 )
@@ -2104,7 +2104,7 @@ static HRESULT ProcessLaunchApprovedExeMessages(
2104 DWORD dwProcessId = 0; 2104 DWORD dwProcessId = 0;
2105 2105
2106 // Process the message. 2106 // Process the message.
2107 switch (pMsg->dwMessage) 2107 switch (pMsg->dwMessageType)
2108 { 2108 {
2109 case BURN_ELEVATION_MESSAGE_TYPE_LAUNCH_APPROVED_EXE_PROCESSID: 2109 case BURN_ELEVATION_MESSAGE_TYPE_LAUNCH_APPROVED_EXE_PROCESSID:
2110 // read message parameters 2110 // read message parameters
@@ -2126,7 +2126,7 @@ LExit:
2126} 2126}
2127 2127
2128static HRESULT ProcessProgressRoutineMessage( 2128static HRESULT ProcessProgressRoutineMessage(
2129 __in BURN_PIPE_MESSAGE* pMsg, 2129 __in PIPE_MESSAGE* pMsg,
2130 __in LPPROGRESS_ROUTINE pfnProgress, 2130 __in LPPROGRESS_ROUTINE pfnProgress,
2131 __in LPVOID pvContext, 2131 __in LPVOID pvContext,
2132 __out DWORD* pdwResult 2132 __out DWORD* pdwResult
@@ -2156,7 +2156,7 @@ LExit:
2156} 2156}
2157 2157
2158static HRESULT ProcessElevatedChildMessage( 2158static HRESULT ProcessElevatedChildMessage(
2159 __in BURN_PIPE_MESSAGE* pMsg, 2159 __in PIPE_MESSAGE* pMsg,
2160 __in_opt LPVOID pvContext, 2160 __in_opt LPVOID pvContext,
2161 __out DWORD* pdwResult 2161 __out DWORD* pdwResult
2162 ) 2162 )
@@ -2167,7 +2167,7 @@ static HRESULT ProcessElevatedChildMessage(
2167 BOOTSTRAPPER_APPLY_RESTART restart = BOOTSTRAPPER_APPLY_RESTART_NONE; 2167 BOOTSTRAPPER_APPLY_RESTART restart = BOOTSTRAPPER_APPLY_RESTART_NONE;
2168 BOOL fSendRestart = FALSE; 2168 BOOL fSendRestart = FALSE;
2169 2169
2170 switch (pMsg->dwMessage) 2170 switch (pMsg->dwMessageType)
2171 { 2171 {
2172 case BURN_ELEVATION_MESSAGE_TYPE_BEGIN_MSI_TRANSACTION: 2172 case BURN_ELEVATION_MESSAGE_TYPE_BEGIN_MSI_TRANSACTION:
2173 hrResult = OnMsiBeginTransaction(pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData); 2173 hrResult = OnMsiBeginTransaction(pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData);
@@ -2263,7 +2263,7 @@ static HRESULT ProcessElevatedChildMessage(
2263 break; 2263 break;
2264 2264
2265 default: 2265 default:
2266 ExitWithRootFailure(hr, E_INVALIDARG, "Unexpected elevated message sent to child process, msg: %u", pMsg->dwMessage); 2266 ExitWithRootFailure(hr, E_INVALIDARG, "Unexpected elevated message sent to child process, msg: %u", pMsg->dwMessageType);
2267 } 2267 }
2268 2268
2269 if (fSendRestart) 2269 if (fSendRestart)
@@ -2279,7 +2279,7 @@ LExit:
2279} 2279}
2280 2280
2281static HRESULT ProcessElevatedChildCacheMessage( 2281static HRESULT ProcessElevatedChildCacheMessage(
2282 __in BURN_PIPE_MESSAGE* pMsg, 2282 __in PIPE_MESSAGE* pMsg,
2283 __in_opt LPVOID pvContext, 2283 __in_opt LPVOID pvContext,
2284 __out DWORD* pdwResult 2284 __out DWORD* pdwResult
2285 ) 2285 )
@@ -2288,7 +2288,7 @@ static HRESULT ProcessElevatedChildCacheMessage(
2288 BURN_ELEVATION_CHILD_MESSAGE_CONTEXT* pContext = static_cast<BURN_ELEVATION_CHILD_MESSAGE_CONTEXT*>(pvContext); 2288 BURN_ELEVATION_CHILD_MESSAGE_CONTEXT* pContext = static_cast<BURN_ELEVATION_CHILD_MESSAGE_CONTEXT*>(pvContext);
2289 HRESULT hrResult = S_OK; 2289 HRESULT hrResult = S_OK;
2290 2290
2291 switch (pMsg->dwMessage) 2291 switch (pMsg->dwMessageType)
2292 { 2292 {
2293 case BURN_ELEVATION_MESSAGE_TYPE_CACHE_PREPARE_PACKAGE: 2293 case BURN_ELEVATION_MESSAGE_TYPE_CACHE_PREPARE_PACKAGE:
2294 hrResult = OnCachePreparePackage(pContext->pCache, pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData); 2294 hrResult = OnCachePreparePackage(pContext->pCache, pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData);
@@ -2313,7 +2313,7 @@ static HRESULT ProcessElevatedChildCacheMessage(
2313 2313
2314 default: 2314 default:
2315 hr = E_INVALIDARG; 2315 hr = E_INVALIDARG;
2316 ExitOnRootFailure(hr, "Unexpected elevated cache message sent to child process, msg: %u", pMsg->dwMessage); 2316 ExitOnRootFailure(hr, "Unexpected elevated cache message sent to child process, msg: %u", pMsg->dwMessageType);
2317 } 2317 }
2318 2318
2319 *pdwResult = (DWORD)hrResult; 2319 *pdwResult = (DWORD)hrResult;
diff --git a/src/burn/engine/embedded.cpp b/src/burn/engine/embedded.cpp
index b9335cdf..1e0759d1 100644
--- a/src/burn/engine/embedded.cpp
+++ b/src/burn/engine/embedded.cpp
@@ -14,7 +14,7 @@ struct BURN_EMBEDDED_CALLBACK_CONTEXT
14// internal function declarations 14// internal function declarations
15 15
16static HRESULT ProcessEmbeddedMessages( 16static HRESULT ProcessEmbeddedMessages(
17 __in BURN_PIPE_MESSAGE* pMsg, 17 __in PIPE_MESSAGE* pMsg,
18 __in_opt LPVOID pvContext, 18 __in_opt LPVOID pvContext,
19 __out DWORD* pdwResult 19 __out DWORD* pdwResult
20 ); 20 );
@@ -36,7 +36,7 @@ static HRESULT OnEmbeddedProgress(
36// function definitions 36// function definitions
37 37
38/******************************************************************* 38/*******************************************************************
39 EmbeddedRunBundle - 39 EmbeddedRunBundle -
40 40
41*******************************************************************/ 41*******************************************************************/
42extern "C" HRESULT EmbeddedRunBundle( 42extern "C" HRESULT EmbeddedRunBundle(
@@ -108,7 +108,7 @@ LExit:
108// internal function definitions 108// internal function definitions
109 109
110static HRESULT ProcessEmbeddedMessages( 110static HRESULT ProcessEmbeddedMessages(
111 __in BURN_PIPE_MESSAGE* pMsg, 111 __in PIPE_MESSAGE* pMsg,
112 __in_opt LPVOID pvContext, 112 __in_opt LPVOID pvContext,
113 __out DWORD* pdwResult 113 __out DWORD* pdwResult
114 ) 114 )
@@ -118,7 +118,7 @@ static HRESULT ProcessEmbeddedMessages(
118 DWORD dwResult = 0; 118 DWORD dwResult = 0;
119 119
120 // Process the message. 120 // Process the message.
121 switch (pMsg->dwMessage) 121 switch (pMsg->dwMessageType)
122 { 122 {
123 case BURN_EMBEDDED_MESSAGE_TYPE_ERROR: 123 case BURN_EMBEDDED_MESSAGE_TYPE_ERROR:
124 hr = OnEmbeddedErrorMessage(pContext->pfnGenericMessageHandler, pContext->pvContext, static_cast<BYTE*>(pMsg->pvData), pMsg->cbData, &dwResult); 124 hr = OnEmbeddedErrorMessage(pContext->pfnGenericMessageHandler, pContext->pvContext, static_cast<BYTE*>(pMsg->pvData), pMsg->cbData, &dwResult);
@@ -131,7 +131,7 @@ static HRESULT ProcessEmbeddedMessages(
131 break; 131 break;
132 132
133 default: 133 default:
134 LogStringLine(REPORT_DEBUG, "Unexpected embedded message received from child process, msg: %u", pMsg->dwMessage); 134 LogStringLine(REPORT_DEBUG, "Unexpected embedded message received from child process, msg: %u", pMsg->dwMessageType);
135 dwResult = (DWORD)E_NOTIMPL; 135 dwResult = (DWORD)E_NOTIMPL;
136 } 136 }
137 137
diff --git a/src/burn/engine/externalengine.cpp b/src/burn/engine/externalengine.cpp
index c38d8fc3..77af79ce 100644
--- a/src/burn/engine/externalengine.cpp
+++ b/src/burn/engine/externalengine.cpp
@@ -9,7 +9,7 @@ static HRESULT CopyStringToExternal(
9 __inout SIZE_T* pcchBuffer 9 __inout SIZE_T* pcchBuffer
10 ); 10 );
11static HRESULT ProcessUnknownEmbeddedMessages( 11static HRESULT ProcessUnknownEmbeddedMessages(
12 __in BURN_PIPE_MESSAGE* /*pMsg*/, 12 __in PIPE_MESSAGE* /*pMsg*/,
13 __in_opt LPVOID /*pvContext*/, 13 __in_opt LPVOID /*pvContext*/,
14 __out DWORD* pdwResult 14 __out DWORD* pdwResult
15 ); 15 );
@@ -877,7 +877,7 @@ static HRESULT CopyStringToExternal(
877} 877}
878 878
879static HRESULT ProcessUnknownEmbeddedMessages( 879static HRESULT ProcessUnknownEmbeddedMessages(
880 __in BURN_PIPE_MESSAGE* /*pMsg*/, 880 __in PIPE_MESSAGE* /*pMsg*/,
881 __in_opt LPVOID /*pvContext*/, 881 __in_opt LPVOID /*pvContext*/,
882 __out DWORD* pdwResult 882 __out DWORD* pdwResult
883 ) 883 )
diff --git a/src/burn/engine/precomp.h b/src/burn/engine/precomp.h
index d9a98f07..50df77ca 100644
--- a/src/burn/engine/precomp.h
+++ b/src/burn/engine/precomp.h
@@ -38,6 +38,7 @@
38#include <memutil.h> 38#include <memutil.h>
39#include <osutil.h> 39#include <osutil.h>
40#include <pathutil.h> 40#include <pathutil.h>
41#include <pipeutil.h>
41#include <polcutil.h> 42#include <polcutil.h>
42#include <procutil.h> 43#include <procutil.h>
43#include <queutil.h> 44#include <queutil.h>
diff --git a/src/burn/test/BurnUnitTest/ElevationTest.cpp b/src/burn/test/BurnUnitTest/ElevationTest.cpp
index 713d9e07..857873b6 100644
--- a/src/burn/test/BurnUnitTest/ElevationTest.cpp
+++ b/src/burn/test/BurnUnitTest/ElevationTest.cpp
@@ -16,12 +16,12 @@ static DWORD CALLBACK ElevateTest_ThreadProc(
16 __in LPVOID lpThreadParameter 16 __in LPVOID lpThreadParameter
17 ); 17 );
18static HRESULT ProcessParentMessages( 18static HRESULT ProcessParentMessages(
19 __in BURN_PIPE_MESSAGE* pMsg, 19 __in PIPE_MESSAGE* pMsg,
20 __in_opt LPVOID pvContext, 20 __in_opt LPVOID pvContext,
21 __out DWORD* pdwResult 21 __out DWORD* pdwResult
22 ); 22 );
23static HRESULT ProcessChildMessages( 23static HRESULT ProcessChildMessages(
24 __in BURN_PIPE_MESSAGE* pMsg, 24 __in PIPE_MESSAGE* pMsg,
25 __in_opt LPVOID pvContext, 25 __in_opt LPVOID pvContext,
26 __out DWORD* pdwResult 26 __out DWORD* pdwResult
27 ); 27 );
@@ -155,7 +155,7 @@ LExit:
155} 155}
156 156
157static HRESULT ProcessParentMessages( 157static HRESULT ProcessParentMessages(
158 __in BURN_PIPE_MESSAGE* pMsg, 158 __in PIPE_MESSAGE* pMsg,
159 __in_opt LPVOID /*pvContext*/, 159 __in_opt LPVOID /*pvContext*/,
160 __out DWORD* pdwResult 160 __out DWORD* pdwResult
161 ) 161 )
@@ -164,7 +164,7 @@ static HRESULT ProcessParentMessages(
164 HRESULT hrResult = E_INVALIDDATA; 164 HRESULT hrResult = E_INVALIDDATA;
165 165
166 // Process the message. 166 // Process the message.
167 switch (pMsg->dwMessage) 167 switch (pMsg->dwMessageType)
168 { 168 {
169 case TEST_CHILD_SENT_MESSAGE_ID: 169 case TEST_CHILD_SENT_MESSAGE_ID:
170 if (sizeof(TEST_MESSAGE_DATA) == pMsg->cbData && 0 == memcmp(TEST_MESSAGE_DATA, pMsg->pvData, sizeof(TEST_MESSAGE_DATA))) 170 if (sizeof(TEST_MESSAGE_DATA) == pMsg->cbData && 0 == memcmp(TEST_MESSAGE_DATA, pMsg->pvData, sizeof(TEST_MESSAGE_DATA)))
@@ -175,7 +175,7 @@ static HRESULT ProcessParentMessages(
175 175
176 default: 176 default:
177 hr = E_INVALIDARG; 177 hr = E_INVALIDARG;
178 ExitOnRootFailure(hr, "Unexpected elevated message sent to parent process, msg: %u", pMsg->dwMessage); 178 ExitOnRootFailure(hr, "Unexpected elevated message sent to parent process, msg: %u", pMsg->dwMessageType);
179 } 179 }
180 180
181 *pdwResult = static_cast<DWORD>(hrResult); 181 *pdwResult = static_cast<DWORD>(hrResult);
@@ -185,7 +185,7 @@ LExit:
185} 185}
186 186
187static HRESULT ProcessChildMessages( 187static HRESULT ProcessChildMessages(
188 __in BURN_PIPE_MESSAGE* pMsg, 188 __in PIPE_MESSAGE* pMsg,
189 __in_opt LPVOID pvContext, 189 __in_opt LPVOID pvContext,
190 __out DWORD* pdwResult 190 __out DWORD* pdwResult
191 ) 191 )
@@ -195,7 +195,7 @@ static HRESULT ProcessChildMessages(
195 DWORD dwResult = 0; 195 DWORD dwResult = 0;
196 196
197 // Process the message. 197 // Process the message.
198 switch (pMsg->dwMessage) 198 switch (pMsg->dwMessageType)
199 { 199 {
200 case TEST_PARENT_SENT_MESSAGE_ID: 200 case TEST_PARENT_SENT_MESSAGE_ID:
201 // send test message 201 // send test message
@@ -205,7 +205,7 @@ static HRESULT ProcessChildMessages(
205 205
206 default: 206 default:
207 hr = E_INVALIDARG; 207 hr = E_INVALIDARG;
208 ExitOnRootFailure(hr, "Unexpected elevated message sent to child process, msg: %u", pMsg->dwMessage); 208 ExitOnRootFailure(hr, "Unexpected elevated message sent to child process, msg: %u", pMsg->dwMessageType);
209 } 209 }
210 210
211 *pdwResult = dwResult; 211 *pdwResult = dwResult;
diff --git a/src/burn/test/BurnUnitTest/precomp.h b/src/burn/test/BurnUnitTest/precomp.h
index 1aa18204..33ca6d5f 100644
--- a/src/burn/test/BurnUnitTest/precomp.h
+++ b/src/burn/test/BurnUnitTest/precomp.h
@@ -24,6 +24,7 @@
24#include <logutil.h> 24#include <logutil.h>
25#include <memutil.h> 25#include <memutil.h>
26#include <pathutil.h> 26#include <pathutil.h>
27#include <pipeutil.h>
27#include <polcutil.h> 28#include <polcutil.h>
28#include <regutil.h> 29#include <regutil.h>
29#include <resrutil.h> 30#include <resrutil.h>