Skip to content

Commit

Permalink
Update Burn to use pipeutil for low-level pipe operations
Browse files Browse the repository at this point in the history
  • Loading branch information
robmen committed Jan 12, 2024
1 parent 4e7b7c0 commit 8cfd711
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 328 deletions.
317 changes: 41 additions & 276 deletions src/burn/engine/burnpipe.cpp

Large diffs are not rendered by default.

11 changes: 1 addition & 10 deletions src/burn/engine/burnpipe.h
Expand Up @@ -25,15 +25,6 @@ typedef enum _BURN_PIPE_MESSAGE_TYPE : DWORD
BURN_PIPE_MESSAGE_TYPE_TERMINATE = 0xF0000003,
} BURN_PIPE_MESSAGE_TYPE;

typedef struct _BURN_PIPE_MESSAGE
{
DWORD dwMessage;
DWORD cbData;

BOOL fAllocatedData;
LPVOID pvData;
} BURN_PIPE_MESSAGE;

typedef struct _BURN_PIPE_RESULT
{
DWORD dwResult;
Expand All @@ -42,7 +33,7 @@ typedef struct _BURN_PIPE_RESULT


typedef HRESULT (*PFN_PIPE_MESSAGE_CALLBACK)(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
);
Expand Down
54 changes: 27 additions & 27 deletions src/burn/engine/elevation.cpp
Expand Up @@ -129,43 +129,43 @@ static HRESULT WaitForElevatedChildCacheThread(
__in DWORD dwExpectedExitCode
);
static HRESULT ProcessApplyInitializeMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
);
static HRESULT ProcessBurnCacheMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in LPVOID pvContext,
__out DWORD* pdwResult
);
static HRESULT ProcessGenericExecuteMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in LPVOID pvContext,
__out DWORD* pdwResult
);
static HRESULT ProcessMsiPackageMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
);
static HRESULT ProcessLaunchApprovedExeMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
);
static HRESULT ProcessProgressRoutineMessage(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in LPPROGRESS_ROUTINE pfnProgress,
__in LPVOID pvContext,
__out DWORD* pdwResult
);
static HRESULT ProcessElevatedChildMessage(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
);
static HRESULT ProcessElevatedChildCacheMessage(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
);
Expand Down Expand Up @@ -1739,7 +1739,7 @@ static HRESULT WaitForElevatedChildCacheThread(
}

static HRESULT ProcessApplyInitializeMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
)
Expand All @@ -1752,7 +1752,7 @@ static HRESULT ProcessApplyInitializeMessages(
HRESULT hrBA = S_OK;

// Process the message.
switch (pMsg->dwMessage)
switch (pMsg->dwMessageType)
{
case BURN_ELEVATION_MESSAGE_TYPE_APPLY_INITIALIZE_PAUSE_AU_BEGIN:
pContext->fPauseCompleteNeeded = TRUE;
Expand Down Expand Up @@ -1801,7 +1801,7 @@ static HRESULT ProcessApplyInitializeMessages(
}

static HRESULT ProcessBurnCacheMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in LPVOID pvContext,
__out DWORD* pdwResult
)
Expand All @@ -1813,7 +1813,7 @@ static HRESULT ProcessBurnCacheMessages(
BOOL fProgressRoutine = FALSE;

// Process the message.
switch (pMsg->dwMessage)
switch (pMsg->dwMessageType)
{
case BURN_ELEVATION_MESSAGE_TYPE_BURN_CACHE_BEGIN:
// read message parameters
Expand Down Expand Up @@ -1872,7 +1872,7 @@ static HRESULT ProcessBurnCacheMessages(
}

static HRESULT ProcessGenericExecuteMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in LPVOID pvContext,
__out DWORD* pdwResult
)
Expand All @@ -1885,7 +1885,7 @@ static HRESULT ProcessGenericExecuteMessages(
LPWSTR* rgwzFiles = NULL;
GENERIC_EXECUTE_MESSAGE message = { };

if (BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE == pMsg->dwMessage)
if (BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE == pMsg->dwMessageType)
{
hr = ProcessExecuteActionCompleteMessage((BYTE*)pMsg->pvData, pMsg->cbData, &pContext->restart, pdwResult);
ExitOnFailure(hr, "Failed to process BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE message.");
Expand All @@ -1897,7 +1897,7 @@ static HRESULT ProcessGenericExecuteMessages(
ExitOnFailure(hr, "Failed to allowed results.");

// Process the message.
switch (pMsg->dwMessage)
switch (pMsg->dwMessageType)
{
case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_PROGRESS:
message.type = GENERIC_EXECUTE_MESSAGE_PROGRESS;
Expand Down Expand Up @@ -1979,7 +1979,7 @@ static HRESULT ProcessGenericExecuteMessages(
}

static HRESULT ProcessMsiPackageMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
)
Expand All @@ -1993,7 +1993,7 @@ static HRESULT ProcessMsiPackageMessages(
LPWSTR sczMessage = NULL;
BOOL fRestartManager = FALSE;

if (BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE == pMsg->dwMessage)
if (BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE == pMsg->dwMessageType)
{
hr = ProcessExecuteActionCompleteMessage((BYTE*)pMsg->pvData, pMsg->cbData, &pContext->restart, pdwResult);
ExitOnFailure(hr, "Failed to process BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_ACTION_COMPLETE message.");
Expand Down Expand Up @@ -2024,7 +2024,7 @@ static HRESULT ProcessMsiPackageMessages(
ExitOnFailure(hr, "Failed to read UI flags.");

// Process the rest of the message.
switch (pMsg->dwMessage)
switch (pMsg->dwMessageType)
{
case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_PROGRESS:
// read message parameters
Expand Down Expand Up @@ -2093,7 +2093,7 @@ static HRESULT ProcessMsiPackageMessages(
}

static HRESULT ProcessLaunchApprovedExeMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
)
Expand All @@ -2104,7 +2104,7 @@ static HRESULT ProcessLaunchApprovedExeMessages(
DWORD dwProcessId = 0;

// Process the message.
switch (pMsg->dwMessage)
switch (pMsg->dwMessageType)
{
case BURN_ELEVATION_MESSAGE_TYPE_LAUNCH_APPROVED_EXE_PROCESSID:
// read message parameters
Expand All @@ -2126,7 +2126,7 @@ static HRESULT ProcessLaunchApprovedExeMessages(
}

static HRESULT ProcessProgressRoutineMessage(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in LPPROGRESS_ROUTINE pfnProgress,
__in LPVOID pvContext,
__out DWORD* pdwResult
Expand Down Expand Up @@ -2156,7 +2156,7 @@ static HRESULT ProcessProgressRoutineMessage(
}

static HRESULT ProcessElevatedChildMessage(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
)
Expand All @@ -2167,7 +2167,7 @@ static HRESULT ProcessElevatedChildMessage(
BOOTSTRAPPER_APPLY_RESTART restart = BOOTSTRAPPER_APPLY_RESTART_NONE;
BOOL fSendRestart = FALSE;

switch (pMsg->dwMessage)
switch (pMsg->dwMessageType)
{
case BURN_ELEVATION_MESSAGE_TYPE_BEGIN_MSI_TRANSACTION:
hrResult = OnMsiBeginTransaction(pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData);
Expand Down Expand Up @@ -2263,7 +2263,7 @@ static HRESULT ProcessElevatedChildMessage(
break;

default:
ExitWithRootFailure(hr, E_INVALIDARG, "Unexpected elevated message sent to child process, msg: %u", pMsg->dwMessage);
ExitWithRootFailure(hr, E_INVALIDARG, "Unexpected elevated message sent to child process, msg: %u", pMsg->dwMessageType);
}

if (fSendRestart)
Expand All @@ -2279,7 +2279,7 @@ static HRESULT ProcessElevatedChildMessage(
}

static HRESULT ProcessElevatedChildCacheMessage(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
)
Expand All @@ -2288,7 +2288,7 @@ static HRESULT ProcessElevatedChildCacheMessage(
BURN_ELEVATION_CHILD_MESSAGE_CONTEXT* pContext = static_cast<BURN_ELEVATION_CHILD_MESSAGE_CONTEXT*>(pvContext);
HRESULT hrResult = S_OK;

switch (pMsg->dwMessage)
switch (pMsg->dwMessageType)
{
case BURN_ELEVATION_MESSAGE_TYPE_CACHE_PREPARE_PACKAGE:
hrResult = OnCachePreparePackage(pContext->pCache, pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData);
Expand All @@ -2313,7 +2313,7 @@ static HRESULT ProcessElevatedChildCacheMessage(

default:
hr = E_INVALIDARG;
ExitOnRootFailure(hr, "Unexpected elevated cache message sent to child process, msg: %u", pMsg->dwMessage);
ExitOnRootFailure(hr, "Unexpected elevated cache message sent to child process, msg: %u", pMsg->dwMessageType);
}

*pdwResult = (DWORD)hrResult;
Expand Down
10 changes: 5 additions & 5 deletions src/burn/engine/embedded.cpp
Expand Up @@ -14,7 +14,7 @@ struct BURN_EMBEDDED_CALLBACK_CONTEXT
// internal function declarations

static HRESULT ProcessEmbeddedMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
);
Expand All @@ -36,7 +36,7 @@ static HRESULT OnEmbeddedProgress(
// function definitions

/*******************************************************************
EmbeddedRunBundle -
EmbeddedRunBundle -
*******************************************************************/
extern "C" HRESULT EmbeddedRunBundle(
Expand Down Expand Up @@ -108,7 +108,7 @@ extern "C" HRESULT EmbeddedRunBundle(
// internal function definitions

static HRESULT ProcessEmbeddedMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
)
Expand All @@ -118,7 +118,7 @@ static HRESULT ProcessEmbeddedMessages(
DWORD dwResult = 0;

// Process the message.
switch (pMsg->dwMessage)
switch (pMsg->dwMessageType)
{
case BURN_EMBEDDED_MESSAGE_TYPE_ERROR:
hr = OnEmbeddedErrorMessage(pContext->pfnGenericMessageHandler, pContext->pvContext, static_cast<BYTE*>(pMsg->pvData), pMsg->cbData, &dwResult);
Expand All @@ -131,7 +131,7 @@ static HRESULT ProcessEmbeddedMessages(
break;

default:
LogStringLine(REPORT_DEBUG, "Unexpected embedded message received from child process, msg: %u", pMsg->dwMessage);
LogStringLine(REPORT_DEBUG, "Unexpected embedded message received from child process, msg: %u", pMsg->dwMessageType);
dwResult = (DWORD)E_NOTIMPL;
}

Expand Down
4 changes: 2 additions & 2 deletions src/burn/engine/externalengine.cpp
Expand Up @@ -9,7 +9,7 @@ static HRESULT CopyStringToExternal(
__inout SIZE_T* pcchBuffer
);
static HRESULT ProcessUnknownEmbeddedMessages(
__in BURN_PIPE_MESSAGE* /*pMsg*/,
__in PIPE_MESSAGE* /*pMsg*/,
__in_opt LPVOID /*pvContext*/,
__out DWORD* pdwResult
);
Expand Down Expand Up @@ -877,7 +877,7 @@ static HRESULT CopyStringToExternal(
}

static HRESULT ProcessUnknownEmbeddedMessages(
__in BURN_PIPE_MESSAGE* /*pMsg*/,
__in PIPE_MESSAGE* /*pMsg*/,
__in_opt LPVOID /*pvContext*/,
__out DWORD* pdwResult
)
Expand Down
1 change: 1 addition & 0 deletions src/burn/engine/precomp.h
Expand Up @@ -38,6 +38,7 @@
#include <memutil.h>
#include <osutil.h>
#include <pathutil.h>
#include <pipeutil.h>
#include <polcutil.h>
#include <procutil.h>
#include <queutil.h>
Expand Down
16 changes: 8 additions & 8 deletions src/burn/test/BurnUnitTest/ElevationTest.cpp
Expand Up @@ -16,12 +16,12 @@ static DWORD CALLBACK ElevateTest_ThreadProc(
__in LPVOID lpThreadParameter
);
static HRESULT ProcessParentMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
);
static HRESULT ProcessChildMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
);
Expand Down Expand Up @@ -155,7 +155,7 @@ static DWORD CALLBACK ElevateTest_ThreadProc(
}

static HRESULT ProcessParentMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID /*pvContext*/,
__out DWORD* pdwResult
)
Expand All @@ -164,7 +164,7 @@ static HRESULT ProcessParentMessages(
HRESULT hrResult = E_INVALIDDATA;

// Process the message.
switch (pMsg->dwMessage)
switch (pMsg->dwMessageType)
{
case TEST_CHILD_SENT_MESSAGE_ID:
if (sizeof(TEST_MESSAGE_DATA) == pMsg->cbData && 0 == memcmp(TEST_MESSAGE_DATA, pMsg->pvData, sizeof(TEST_MESSAGE_DATA)))
Expand All @@ -175,7 +175,7 @@ static HRESULT ProcessParentMessages(

default:
hr = E_INVALIDARG;
ExitOnRootFailure(hr, "Unexpected elevated message sent to parent process, msg: %u", pMsg->dwMessage);
ExitOnRootFailure(hr, "Unexpected elevated message sent to parent process, msg: %u", pMsg->dwMessageType);
}

*pdwResult = static_cast<DWORD>(hrResult);
Expand All @@ -185,7 +185,7 @@ static HRESULT ProcessParentMessages(
}

static HRESULT ProcessChildMessages(
__in BURN_PIPE_MESSAGE* pMsg,
__in PIPE_MESSAGE* pMsg,
__in_opt LPVOID pvContext,
__out DWORD* pdwResult
)
Expand All @@ -195,7 +195,7 @@ static HRESULT ProcessChildMessages(
DWORD dwResult = 0;

// Process the message.
switch (pMsg->dwMessage)
switch (pMsg->dwMessageType)
{
case TEST_PARENT_SENT_MESSAGE_ID:
// send test message
Expand All @@ -205,7 +205,7 @@ static HRESULT ProcessChildMessages(

default:
hr = E_INVALIDARG;
ExitOnRootFailure(hr, "Unexpected elevated message sent to child process, msg: %u", pMsg->dwMessage);
ExitOnRootFailure(hr, "Unexpected elevated message sent to child process, msg: %u", pMsg->dwMessageType);
}

*pdwResult = dwResult;
Expand Down
1 change: 1 addition & 0 deletions src/burn/test/BurnUnitTest/precomp.h
Expand Up @@ -24,6 +24,7 @@
#include <logutil.h>
#include <memutil.h>
#include <pathutil.h>
#include <pipeutil.h>
#include <polcutil.h>
#include <regutil.h>
#include <resrutil.h>
Expand Down

0 comments on commit 8cfd711

Please sign in to comment.