From 807e888699cb5bb7aa8445024c7d455927c5bc07 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sun, 3 Mar 2024 17:27:36 -0800 Subject: [PATCH] Send args and results as combined buffer in pipe RPC message --- .../burn/balutil/BalBootstrapperEngine.cpp | 641 ++-- src/api/burn/balutil/balinfo.cpp | 2 +- src/api/burn/balutil/msg.cpp | 1966 ++++++------ src/burn/engine/bacallback.cpp | 2739 ++++++++--------- src/burn/engine/baengine.cpp | 647 ++-- src/libs/dutil/WixToolset.DUtil/buffutil.cpp | 61 +- .../dutil/WixToolset.DUtil/inc/buffutil.h | 9 - 7 files changed, 2808 insertions(+), 3257 deletions(-) diff --git a/src/api/burn/balutil/BalBootstrapperEngine.cpp b/src/api/burn/balutil/BalBootstrapperEngine.cpp index 479d253ae..a6a5a869e 100644 --- a/src/api/burn/balutil/BalBootstrapperEngine.cpp +++ b/src/api/burn/balutil/BalBootstrapperEngine.cpp @@ -63,7 +63,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_GETPACKAGECOUNT_ARGS args = { }; BAENGINE_GETPACKAGECOUNT_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; @@ -75,21 +76,15 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of GetPackageCount args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to GetPackageCount args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of GetPackageCount results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to GetPackageCount results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA GetPackageCount failed."); // Read results. @@ -103,7 +98,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -116,7 +112,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_GETVARIABLENUMERIC_ARGS args = { }; BAENGINE_GETVARIABLENUMERIC_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; LPWSTR sczValue = NULL; @@ -130,24 +127,18 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of GetVariableNumeric args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVariable); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); ExitOnFailure(hr, "Failed to write variable name of GetVariableNumeric args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to GetVariableNumeric args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of GetVariableNumeric results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to GetVariableNumeric results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA GetVariableNumeric failed."); // Read results. @@ -162,7 +153,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine LExit: ReleaseStr(sczValue); PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -176,7 +168,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_GETVARIABLESTRING_ARGS args = { }; BAENGINE_GETVARIABLESTRING_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; LPWSTR sczValue = NULL; @@ -191,27 +184,21 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cchValue = static_cast(*pcchValue); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of GetVariableString args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVariable); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); ExitOnFailure(hr, "Failed to write variable name of GetVariableString args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to GetVariableString args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of GetVariableString results."); - hr = BuffWriteNumberToBuffer(&buffer, results.cchValue); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cchValue); ExitOnFailure(hr, "Failed to write size of GetVariableString results value."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to GetVariableString results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA GetVariableString failed."); // Read results. @@ -241,7 +228,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine LExit: ReleaseStr(sczValue); PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -255,7 +243,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_GETVARIABLEVERSION_ARGS args = { }; BAENGINE_GETVARIABLEVERSION_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; LPWSTR sczValue = NULL; @@ -271,27 +260,21 @@ class CBalBootstrapperEngine : public IBootstrapperEngine ExitOnFailure(hr, "Failed to convert pcchValue to DWORD."); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of GetVariableVersion args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVariable); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); ExitOnFailure(hr, "Failed to write variable name of GetVariableVersion args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to GetVariableVersion args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of GetVariableVersion results."); - hr = BuffWriteNumberToBuffer(&buffer, results.cchValue); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cchValue); ExitOnFailure(hr, "Failed to write size of GetVariableVersion results value."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to GetVariableVersion results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA GetVariableVersion failed."); // Read results. @@ -321,7 +304,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine LExit: ReleaseStr(sczValue); PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -336,7 +320,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_GETRELATEDBUNDLEVARIABLE_ARGS args = { }; BAENGINE_GETRELATEDBUNDLEVARIABLE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; LPWSTR sczValue = NULL; @@ -353,30 +338,24 @@ class CBalBootstrapperEngine : public IBootstrapperEngine ExitOnFailure(hr, "Failed to convert pcchValue to DWORD."); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of GetRelatedBundleVariable args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzBundleId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleId); ExitOnFailure(hr, "Failed to write bundle id of GetRelatedBundleVariable args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVariable); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); ExitOnFailure(hr, "Failed to write variable name of GetRelatedBundleVariable args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to GetRelatedBundleVariable args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of GetRelatedBundleVariable results."); - hr = BuffWriteNumberToBuffer(&buffer, results.cchValue); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cchValue); ExitOnFailure(hr, "Failed to write size of GetRelatedBundleVariable results value."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to GetRelatedBundleVariable results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA GetRelatedBundleVariable failed."); // Read results. @@ -406,7 +385,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine LExit: ReleaseStr(sczValue); PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -420,7 +400,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_FORMATSTRING_ARGS args = { }; BAENGINE_FORMATSTRING_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; LPWSTR sczOut = NULL; @@ -436,27 +417,21 @@ class CBalBootstrapperEngine : public IBootstrapperEngine ExitOnFailure(hr, "Failed to convert pcchOut to DWORD."); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of FormatString args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzIn); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzIn); ExitOnFailure(hr, "Failed to write string to format of FormatString args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to FormatString args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of FormatString results."); - hr = BuffWriteNumberToBuffer(&buffer, results.cchOut); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cchOut); ExitOnFailure(hr, "Failed to write format string maximum size of FormatString results value."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to FormatString results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA FormatString failed."); // Read results. @@ -486,7 +461,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine LExit: ReleaseStr(sczOut); PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -500,7 +476,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_ESCAPESTRING_ARGS args = { }; BAENGINE_ESCAPESTRING_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; LPWSTR sczOut = NULL; @@ -516,27 +493,21 @@ class CBalBootstrapperEngine : public IBootstrapperEngine ExitOnFailure(hr, "Failed to convert pcchOut to DWORD."); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of EscapeString args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzIn); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzIn); ExitOnFailure(hr, "Failed to write string to escape of EscapeString args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to EscapeString args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of EscapeString results."); - hr = BuffWriteNumberToBuffer(&buffer, results.cchOut); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cchOut); ExitOnFailure(hr, "Failed to write escape string maximum size of EscapeString results value."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to EscapeString results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA EscapeString failed."); // Read results. @@ -566,7 +537,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine LExit: ReleaseStr(sczOut); PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -579,7 +551,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_EVALUATECONDITION_ARGS args = { }; BAENGINE_EVALUATECONDITION_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; @@ -600,24 +573,18 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of EvaluateCondition args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzCondition); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzCondition); ExitOnFailure(hr, "Failed to write condition of EvaluateCondition args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to EvaluateCondition args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of EvaluateCondition results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to EvaluateCondition results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA EvaluateCondition failed."); // Read results. @@ -631,7 +598,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -644,7 +612,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_LOG_ARGS args = { }; BAENGINE_LOG_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; // Init send structs. @@ -655,32 +624,27 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of Log args."); - hr = BuffWriteNumberToBuffer(&buffer, args.level); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.level); ExitOnFailure(hr, "Failed to write level of Log args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzMessage); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzMessage); ExitOnFailure(hr, "Failed to write message of Log args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to Log args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of Log results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to Log results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_LOG, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_LOG, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA Log failed."); LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -695,7 +659,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_SENDEMBEDDEDERROR_ARGS args = { }; BAENGINE_SENDEMBEDDEDERROR_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; @@ -710,30 +675,24 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of SendEmbeddedError args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwErrorCode); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwErrorCode); ExitOnFailure(hr, "Failed to write error code of SendEmbeddedError args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzMessage); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzMessage); ExitOnFailure(hr, "Failed to write message of SendEmbeddedError args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwUIHint); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwUIHint); ExitOnFailure(hr, "Failed to write UI hint of SendEmbeddedError args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to SendEmbeddedError args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of SendEmbeddedError results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to SendEmbeddedError results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA SendEmbeddedError failed."); // Read results. @@ -747,7 +706,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -761,7 +721,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_SENDEMBEDDEDPROGRESS_ARGS args = { }; BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; @@ -775,27 +736,21 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of SendEmbeddedProgress args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwProgressPercentage); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwProgressPercentage); ExitOnFailure(hr, "Failed to write progress of SendEmbeddedProgress args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwOverallProgressPercentage); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwOverallProgressPercentage); ExitOnFailure(hr, "Failed to write overall progress of SendEmbeddedProgress args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to SendEmbeddedProgress args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of SendEmbeddedProgress results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to SendEmbeddedProgress results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA SendEmbeddedProgress failed."); // Read results. @@ -809,7 +764,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -826,7 +782,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_SETUPDATE_ARGS args = { }; BAENGINE_SETUPDATE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; // Init send structs. @@ -841,47 +798,42 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of SetUpdate args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzLocalSource); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzLocalSource); ExitOnFailure(hr, "Failed to write local source of SetUpdate args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzDownloadSource); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzDownloadSource); ExitOnFailure(hr, "Failed to write download source of SetUpdate args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.qwSize); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.qwSize); ExitOnFailure(hr, "Failed to write udpate size of SetUpdate args."); - hr = BuffWriteNumberToBuffer(&buffer, static_cast(args.hashType)); + hr = BuffWriteNumberToBuffer(&bufferArgs, static_cast(args.hashType)); ExitOnFailure(hr, "Failed to write hash type of SetUpdate args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzHash); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzHash); ExitOnFailure(hr, "Failed to write hash of SetUpdate args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzHash); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzHash); ExitOnFailure(hr, "Failed to write hash of SetUpdate args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzUpdatePackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUpdatePackageId); ExitOnFailure(hr, "Failed to write update package id to SetUpdate args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetLocalSource args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of SetUpdate results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetUpdate results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA SetUpdate failed."); LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -895,7 +847,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_SETLOCALSOURCE_ARGS args = { }; BAENGINE_SETLOCALSOURCE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; // Init send structs. @@ -907,35 +860,30 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of SetLocalSource args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageOrContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); ExitOnFailure(hr, "Failed to write package or container id of SetLocalSource args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of SetLocalSource args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPath); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPath); ExitOnFailure(hr, "Failed to write path of SetLocalSource args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetLocalSource args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of SetLocalSource results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetLocalSource results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA SetLocalSource failed."); LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -952,7 +900,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_SETDOWNLOADSOURCE_ARGS args = { }; BAENGINE_SETDOWNLOADSOURCE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; // Init send structs. @@ -967,44 +916,39 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of SetDownloadSource args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageOrContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); ExitOnFailure(hr, "Failed to write package or container id of SetDownloadSource args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of SetDownloadSource args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzUrl); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUrl); ExitOnFailure(hr, "Failed to write url of SetDownloadSource args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzUser); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUser); ExitOnFailure(hr, "Failed to write user of SetDownloadSource args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPassword); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPassword); ExitOnFailure(hr, "Failed to write password of SetDownloadSource args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzAuthorizationHeader); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzAuthorizationHeader); ExitOnFailure(hr, "Failed to write authorization header of SetDownloadSource args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetDownloadSource args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of SetDownloadSource results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetDownloadSource results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA SetDownloadSource failed."); LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1017,7 +961,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_SETVARIABLENUMERIC_ARGS args = { }; BAENGINE_SETVARIABLENUMERIC_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; // Init send structs. @@ -1028,32 +973,27 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of SetVariableNumeric args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVariable); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); ExitOnFailure(hr, "Failed to write variable of SetVariableNumeric args."); - hr = BuffWriteNumber64ToBuffer(&buffer, static_cast(args.llValue)); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, static_cast(args.llValue)); ExitOnFailure(hr, "Failed to write value of SetVariableNumeric args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetVariableNumeric args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of SetVariableNumeric results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetVariableNumeric results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA SetVariableNumeric failed."); LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1067,7 +1007,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_SETVARIABLESTRING_ARGS args = { }; BAENGINE_SETVARIABLESTRING_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; // Init send structs. @@ -1079,35 +1020,30 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of SetVariableString args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVariable); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); ExitOnFailure(hr, "Failed to write variable of SetVariableString args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzValue); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzValue); ExitOnFailure(hr, "Failed to write value of SetVariableString args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fFormatted); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fFormatted); ExitOnFailure(hr, "Failed to write formatted flag of SetVariableString args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetVariableString args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of SetVariableString results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetVariableString results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA SetVariableString failed."); LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1120,7 +1056,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_SETVARIABLEVERSION_ARGS args = { }; BAENGINE_SETVARIABLEVERSION_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; // Init send structs. @@ -1131,32 +1068,27 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of SetVariableVersion args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVariable); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); ExitOnFailure(hr, "Failed to write variable of SetVariableVersion args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzValue); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzValue); ExitOnFailure(hr, "Failed to write value of SetVariableVersion args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetVariableVersion args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of SetVariableVersion results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetVariableVersion results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA SetVariableVersion failed."); LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1166,7 +1098,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_CLOSESPLASHSCREEN_ARGS args = { }; BAENGINE_CLOSESPLASHSCREEN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; // Init send structs. @@ -1175,26 +1108,21 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of CloseSplashScreen args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to CloseSplashScreen args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of CloseSplashScreen results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to CloseSplashScreen results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA CloseSplashScreen failed."); LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1206,8 +1134,9 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_DETECT_ARGS args = { }; BAENGINE_DETECT_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init send structs. args.cbSize = sizeof(args); @@ -1216,29 +1145,24 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of Detect args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.hwndParent); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.hwndParent); ExitOnFailure(hr, "Failed to write parent window of Detect args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to Detect args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of Detect results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to Detect results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_DETECT, buffer.pbData, buffer.cbData, &result); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_DETECT, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA Detect failed."); LExit: - PipeFreeRpcResult(&result); - ReleaseNullBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1250,8 +1174,9 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_PLAN_ARGS args = { }; BAENGINE_PLAN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init send structs. args.cbSize = sizeof(args); @@ -1260,29 +1185,24 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of Plan args."); - hr = BuffWriteNumberToBuffer(&buffer, static_cast(args.action)); + hr = BuffWriteNumberToBuffer(&bufferArgs, static_cast(args.action)); ExitOnFailure(hr, "Failed to write parent window of Plan args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetVariableVersion args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of Plan results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetVariableVersion results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_PLAN, buffer.pbData, buffer.cbData, &result); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_PLAN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA Plan failed."); LExit: - PipeFreeRpcResult(&result); - ReleaseNullBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1294,8 +1214,9 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_ELEVATE_ARGS args = { }; BAENGINE_ELEVATE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init send structs. args.cbSize = sizeof(args); @@ -1304,29 +1225,24 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of Elevate args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.hwndParent); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.hwndParent); ExitOnFailure(hr, "Failed to write parent window of Elevate args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to Elevate args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of Elevate results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to Elevate results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE, buffer.pbData, buffer.cbData, &result); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA Elevate failed."); LExit: - PipeFreeRpcResult(&result); - ReleaseNullBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1338,8 +1254,9 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_APPLY_ARGS args = { }; BAENGINE_APPLY_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init send structs. args.cbSize = sizeof(args); @@ -1348,29 +1265,24 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of Apply args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.hwndParent); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.hwndParent); ExitOnFailure(hr, "Failed to write parent window of Apply args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to Apply args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of Apply results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to Apply results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, buffer.pbData, buffer.cbData, &result); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA Apply failed."); LExit: - PipeFreeRpcResult(&result); - ReleaseNullBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1382,8 +1294,9 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_QUIT_ARGS args = { }; BAENGINE_QUIT_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init send structs. args.cbSize = sizeof(args); @@ -1392,29 +1305,24 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of Quit args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwExitCode); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwExitCode); ExitOnFailure(hr, "Failed to write exit code of Quit args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to Quit args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of Quit results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to Quit results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, buffer.pbData, buffer.cbData, &result); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA Quit failed."); LExit: - PipeFreeRpcResult(&result); - ReleaseNullBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1429,7 +1337,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_LAUNCHAPPROVEDEXE_ARGS args = { }; BAENGINE_LAUNCHAPPROVEDEXE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; ExitOnNull(wzApprovedExeForElevationId, hr, E_INVALIDARG, "wzApprovedExeForElevationId is required"); @@ -1444,38 +1353,33 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of LaunchApprovedExe args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.hwndParent); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.hwndParent); ExitOnFailure(hr, "Failed to write parent window of LaunchApprovedExe args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzApprovedExeForElevationId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzApprovedExeForElevationId); ExitOnFailure(hr, "Failed to write approved exe elevation id of LaunchApprovedExe args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzArguments); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzArguments); ExitOnFailure(hr, "Failed to write arguments of LaunchApprovedExe args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwWaitForInputIdleTimeout); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwWaitForInputIdleTimeout); ExitOnFailure(hr, "Failed to write wait for idle input timeout of LaunchApprovedExe args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to LaunchApprovedExe args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of LaunchApprovedExe results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to LaunchApprovedExe results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA LaunchApprovedExe failed."); LExit: - ReleaseNullBuffer(buffer); PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1488,7 +1392,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_SETUPDATESOURCE_ARGS args = { }; BAENGINE_SETUPDATESOURCE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; ExitOnNull(wzUrl, hr, E_INVALIDARG, "wzUrl is required"); @@ -1501,32 +1406,27 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of SetUpdateSource args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzUrl); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUrl); ExitOnFailure(hr, "Failed to write url of SetUpdateSource args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzAuthorizationHeader); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzAuthorizationHeader); ExitOnFailure(hr, "Failed to write authorization header of SetUpdateSource args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetUpdateSource args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of SetUpdateSource results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to SetUpdateSource results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA SetUpdateSource failed."); LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1540,7 +1440,8 @@ class CBalBootstrapperEngine : public IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_COMPAREVERSIONS_ARGS args = { }; BAENGINE_COMPAREVERSIONS_RESULTS results = { }; - BUFF_BUFFER buffer = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; @@ -1554,27 +1455,21 @@ class CBalBootstrapperEngine : public IBootstrapperEngine results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of CompareVersions args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVersion1); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVersion1); ExitOnFailure(hr, "Failed to write first input of CompareVersions args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVersion2); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVersion2); ExitOnFailure(hr, "Failed to write second input of CompareVersions args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to CompareVersions args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of CompareVersions results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to CompareVersions results."); - // Get results. - hr = PipeRpcRequest(&m_hRpcPipe, BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS, buffer.pbData, buffer.cbData, &rpc); + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA CompareVersions failed."); // Read results. @@ -1588,8 +1483,50 @@ class CBalBootstrapperEngine : public IBootstrapperEngine LExit: PipeFreeRpcResult(&rpc); - ReleaseNullBuffer(buffer); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; + } + +private: + HRESULT SendRequest( + __in DWORD dwMessageType, + __in BUFF_BUFFER* pBufferArgs, + __in BUFF_BUFFER* pBufferResults, + __in PIPE_RPC_RESULT* pRpc + ) + { + HRESULT hr = S_OK; + BUFF_BUFFER buffer = { }; + hr = CombineArgsAndResults(pBufferArgs, pBufferResults, &buffer); + if (SUCCEEDED(hr)) + { + hr = PipeRpcRequest(&m_hRpcPipe, dwMessageType, buffer.pbData, buffer.cbData, pRpc); + } + + ReleaseBuffer(buffer); + return hr; + } + + HRESULT CombineArgsAndResults( + __in BUFF_BUFFER* pBufferArgs, + __in BUFF_BUFFER* pBufferResults, + __in BUFF_BUFFER* pBufferCombined + ) + { + HRESULT hr = S_OK; + + // Write args to buffer. + hr = BuffWriteStreamToBuffer(pBufferCombined, pBufferArgs->pbData, pBufferArgs->cbData); + ExitOnFailure(hr, "Failed to write args buffer."); + + // Write results to buffer. + hr = BuffWriteStreamToBuffer(pBufferCombined, pBufferResults->pbData, pBufferResults->cbData); + ExitOnFailure(hr, "Failed to write results buffer."); + + LExit: return hr; } diff --git a/src/api/burn/balutil/balinfo.cpp b/src/api/burn/balutil/balinfo.cpp index 1ce10f529..6f609a400 100644 --- a/src/api/burn/balutil/balinfo.cpp +++ b/src/api/burn/balutil/balinfo.cpp @@ -355,7 +355,7 @@ DAPI_(HRESULT) BalSetOverridableVariablesFromEngine( LPCWSTR wzVariableValue = pCommand->rgVariableValues[i]; hr = DictGetValue(pOverridableVariables->sdVariables, wzVariableName, reinterpret_cast(&pOverridableVariable)); - if (E_NOTFOUND == hr) + if (E_NOTFOUND == hr || E_INVALIDARG == hr) { BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Ignoring attempt to set non-overridable variable: '%ls'.", wzVariableName); hr = S_OK; diff --git a/src/api/burn/balutil/msg.cpp b/src/api/burn/balutil/msg.cpp index 91cb3e28d..dee46b3ae 100644 --- a/src/api/burn/balutil/msg.cpp +++ b/src/api/burn/balutil/msg.cpp @@ -4,7 +4,8 @@ static HRESULT OnApplyBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -13,17 +14,14 @@ static HRESULT OnApplyBegin( BA_ONAPPLYBEGIN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnApplyBegin args."); - hr = BuffReaderReadNumber(pReader, &args.dwPhaseCount); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwPhaseCount); ExitOnFailure(hr, "Failed to read phase count of OnApplyBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnApplyBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnApplyBegin results."); // Callback. @@ -50,7 +48,8 @@ static HRESULT OnApplyBegin( static HRESULT OnApplyComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -59,26 +58,23 @@ static HRESULT OnApplyComplete( BA_ONAPPLYCOMPLETE_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnApplyComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnApplyComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.restart)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.restart)); ExitOnFailure(hr, "Failed to read restart of OnApplyComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnApplyComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnApplyComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnApplyComplete results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnApplyComplete results."); // Callback. @@ -105,7 +101,8 @@ static HRESULT OnApplyComplete( static HRESULT OnApplyDowngrade( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -114,20 +111,17 @@ static HRESULT OnApplyDowngrade( BA_ONAPPLYDOWNGRADE_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnApplyDowngrade args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrRecommended)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrRecommended)); ExitOnFailure(hr, "Failed to read recommended of OnApplyDowngrade args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnApplyDowngrade args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnApplyDowngrade results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.hrStatus)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnApplyDowngrade results."); // Callback. @@ -154,7 +148,8 @@ static HRESULT OnApplyDowngrade( static HRESULT OnBeginMsiTransactionBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -164,19 +159,16 @@ static HRESULT OnBeginMsiTransactionBegin( LPWSTR sczTransactionId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnBeginMsiTransactionBegin args."); - hr = BuffReaderReadString(pReader, &sczTransactionId); + hr = BuffReaderReadString(pReaderArgs, &sczTransactionId); ExitOnFailure(hr, "Failed to read recommended of OnBeginMsiTransactionBegin args."); args.wzTransactionId = sczTransactionId; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnBeginMsiTransactionBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnBeginMsiTransactionBegin results."); // Callback. @@ -204,7 +196,8 @@ static HRESULT OnBeginMsiTransactionBegin( static HRESULT OnBeginMsiTransactionComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -214,22 +207,19 @@ static HRESULT OnBeginMsiTransactionComplete( LPWSTR sczTransactionId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnBeginMsiTransactionComplete args."); - hr = BuffReaderReadString(pReader, &sczTransactionId); + hr = BuffReaderReadString(pReaderArgs, &sczTransactionId); ExitOnFailure(hr, "Failed to read transaction id of OnBeginMsiTransactionComplete args."); args.wzTransactionId = sczTransactionId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnBeginMsiTransactionComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnBeginMsiTransactionComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnBeginMsiTransactionComplete results."); // Callback. @@ -254,7 +244,8 @@ static HRESULT OnBeginMsiTransactionComplete( static HRESULT OnCacheAcquireBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -268,45 +259,42 @@ static HRESULT OnCacheAcquireBegin( LPWSTR sczPayloadContainerId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheAcquireBegin args."); - hr = BuffReaderReadString(pReader, &sczPackageOrContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); ExitOnFailure(hr, "Failed to read package or container id of OnCacheAcquireBegin args."); args.wzPackageOrContainerId = sczPackageOrContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCacheAcquireBegin args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderReadString(pReader, &sczSource); + hr = BuffReaderReadString(pReaderArgs, &sczSource); ExitOnFailure(hr, "Failed to read source of OnCacheAcquireBegin args."); args.wzSource = sczSource; - hr = BuffReaderReadString(pReader, &sczDownloadUrl); + hr = BuffReaderReadString(pReaderArgs, &sczDownloadUrl); ExitOnFailure(hr, "Failed to read download url of OnCacheAcquireBegin args."); args.wzDownloadUrl = sczDownloadUrl; - hr = BuffReaderReadString(pReader, &sczPayloadContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadContainerId); ExitOnFailure(hr, "Failed to read payload container id of OnCacheAcquireBegin args."); args.wzPayloadContainerId = sczPayloadContainerId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnCacheAcquireBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCacheAcquireBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheAcquireBegin results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnCacheAcquireBegin results."); // Callback. @@ -341,7 +329,8 @@ static HRESULT OnCacheAcquireBegin( static HRESULT OnCacheAcquireComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -352,33 +341,30 @@ static HRESULT OnCacheAcquireComplete( LPWSTR sczPayloadId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheAcquireComplete args."); - hr = BuffReaderReadString(pReader, &sczPackageOrContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); ExitOnFailure(hr, "Failed to read package or container id of OnCacheAcquireComplete args."); args.wzPackageOrContainerId = sczPackageOrContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCacheAcquireComplete args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnCacheAcquireComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnCacheAcquireComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCacheAcquireComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheAcquireComplete results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnCacheAcquireComplete results."); // Callback. @@ -407,7 +393,8 @@ static HRESULT OnCacheAcquireComplete( static HRESULT OnCacheAcquireProgress( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -418,33 +405,30 @@ static HRESULT OnCacheAcquireProgress( LPWSTR sczPayloadId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheAcquireProgress args."); - hr = BuffReaderReadString(pReader, &sczPackageOrContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); ExitOnFailure(hr, "Failed to read package or container id of OnCacheAcquireProgress args."); args.wzPackageOrContainerId = sczPackageOrContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCacheAcquireProgress args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderReadNumber64(pReader, &args.dw64Progress); + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Progress); ExitOnFailure(hr, "Failed to read progress of OnCacheAcquireProgress args."); - hr = BuffReaderReadNumber64(pReader, &args.dw64Total); + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Total); ExitOnFailure(hr, "Failed to read total progress of OnCacheAcquireProgress args."); - hr = BuffReaderReadNumber(pReader, &args.dwOverallPercentage); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage); ExitOnFailure(hr, "Failed to read overall percentage of OnCacheAcquireProgress args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCacheAcquireProgress args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheAcquireProgress results."); // Callback. @@ -473,7 +457,8 @@ static HRESULT OnCacheAcquireProgress( static HRESULT OnCacheAcquireResolving( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -488,20 +473,20 @@ static HRESULT OnCacheAcquireResolving( LPWSTR sczPayloadContainerId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheAcquireResolving args."); - hr = BuffReaderReadString(pReader, &sczPackageOrContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); ExitOnFailure(hr, "Failed to read package or container id of OnCacheAcquireResolving args."); args.wzPackageOrContainerId = sczPackageOrContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCacheAcquireResolving args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderReadNumber(pReader, &cSearchPaths); + hr = BuffReaderReadNumber(pReaderArgs, &cSearchPaths); ExitOnFailure(hr, "Failed to read overall percentage of OnCacheAcquireResolving args."); if (cSearchPaths) @@ -511,7 +496,7 @@ static HRESULT OnCacheAcquireResolving( for (DWORD i = 0; i < cSearchPaths; ++i) { - hr = BuffReaderReadString(pReader, &rgsczSearchPaths[i]); + hr = BuffReaderReadString(pReaderArgs, &rgsczSearchPaths[i]); ExitOnFailure(hr, "Failed to read search path[%u] of OnCacheAcquireResolving args.", i); } } @@ -519,34 +504,31 @@ static HRESULT OnCacheAcquireResolving( args.cSearchPaths = cSearchPaths; args.rgSearchPaths = const_cast(rgsczSearchPaths); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fFoundLocal)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fFoundLocal)); ExitOnFailure(hr, "Failed to read found local of OnCacheAcquireResolving args."); - hr = BuffReaderReadNumber(pReader, &args.dwRecommendedSearchPath); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwRecommendedSearchPath); ExitOnFailure(hr, "Failed to read recommended search path of OnCacheAcquireResolving args."); - hr = BuffReaderReadString(pReader, &sczDownloadUrl); + hr = BuffReaderReadString(pReaderArgs, &sczDownloadUrl); ExitOnFailure(hr, "Failed to read download url of OnCacheAcquireResolving args."); - hr = BuffReaderReadString(pReader, &sczPayloadContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadContainerId); ExitOnFailure(hr, "Failed to read payload container id of OnCacheAcquireResolving args."); args.wzPayloadContainerId = sczPayloadContainerId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); ExitOnFailure(hr, "Failed to read recommendedation of OnCacheAcquireResolving args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCacheAcquireResolving args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheAcquireResolving results."); - hr = BuffReaderReadNumber(pReader, &results.dwChosenSearchPath); + hr = BuffReaderReadNumber(pReaderResults, &results.dwChosenSearchPath); ExitOnFailure(hr, "Failed to read chosen search path of OnCacheAcquireResolving results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnCacheAcquireResolving results."); // Callback. @@ -590,7 +572,8 @@ static HRESULT OnCacheAcquireResolving( static HRESULT OnCacheBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -599,14 +582,11 @@ static HRESULT OnCacheBegin( BA_ONCACHEBEGIN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCacheBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheBegin results."); // Callback. @@ -633,7 +613,8 @@ static HRESULT OnCacheBegin( static HRESULT OnCacheComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -642,17 +623,14 @@ static HRESULT OnCacheComplete( BA_ONCACHECOMPLETE_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnCacheComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCacheComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheComplete results."); // Callback. @@ -676,7 +654,8 @@ static HRESULT OnCacheComplete( static HRESULT OnCacheContainerOrPayloadVerifyBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -687,24 +666,21 @@ static HRESULT OnCacheContainerOrPayloadVerifyBegin( LPWSTR sczPayloadId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheContainerOrPayloadVerifyBegin args."); - hr = BuffReaderReadString(pReader, &sczPackageOrContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); ExitOnFailure(hr, "Failed to read package or container id of OnCacheContainerOrPayloadVerifyBegin args."); args.wzPackageOrContainerId = sczPackageOrContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCacheContainerOrPayloadVerifyBegin args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCacheContainerOrPayloadVerifyBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheContainerOrPayloadVerifyBegin results."); // Callback. @@ -733,7 +709,8 @@ static HRESULT OnCacheContainerOrPayloadVerifyBegin( static HRESULT OnCacheContainerOrPayloadVerifyComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -744,27 +721,24 @@ static HRESULT OnCacheContainerOrPayloadVerifyComplete( LPWSTR sczPayloadId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheContainerOrPayloadVerifyComplete args."); - hr = BuffReaderReadString(pReader, &sczPackageOrContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); ExitOnFailure(hr, "Failed to read package or container id of OnCacheContainerOrPayloadVerifyComplete args."); args.wzPackageOrContainerId = sczPackageOrContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCacheContainerOrPayloadVerifyComplete args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnCacheContainerOrPayloadVerifyComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCacheContainerOrPayloadVerifyComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheContainerOrPayloadVerifyComplete results."); // Callback. @@ -790,7 +764,8 @@ static HRESULT OnCacheContainerOrPayloadVerifyComplete( static HRESULT OnCacheContainerOrPayloadVerifyProgress( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -801,33 +776,30 @@ static HRESULT OnCacheContainerOrPayloadVerifyProgress( LPWSTR sczPayloadId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheContainerOrPayloadVerifyProgress args."); - hr = BuffReaderReadString(pReader, &sczPackageOrContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); ExitOnFailure(hr, "Failed to read package or container id of OnCacheContainerOrPayloadVerifyProgress args."); args.wzPackageOrContainerId = sczPackageOrContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCacheContainerOrPayloadVerifyProgress args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderReadNumber64(pReader, &args.dw64Progress); + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Progress); ExitOnFailure(hr, "Failed to read progress of OnCacheContainerOrPayloadVerifyProgress args."); - hr = BuffReaderReadNumber64(pReader, &args.dw64Total); + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Total); ExitOnFailure(hr, "Failed to read total progress of OnCacheContainerOrPayloadVerifyProgress args."); - hr = BuffReaderReadNumber(pReader, &args.dwOverallPercentage); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage); ExitOnFailure(hr, "Failed to read overall percentage of OnCacheContainerOrPayloadVerifyProgress args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCacheContainerOrPayloadVerifyProgress args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheContainerOrPayloadVerifyProgress results."); // Callback. @@ -856,7 +828,8 @@ static HRESULT OnCacheContainerOrPayloadVerifyProgress( static HRESULT OnCachePackageBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -866,28 +839,25 @@ static HRESULT OnCachePackageBegin( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePackageBegin args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnCachePackageBegin args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, &args.cCachePayloads); + hr = BuffReaderReadNumber(pReaderArgs, &args.cCachePayloads); ExitOnFailure(hr, "Failed to read count of cached payloads of OnCachePackageBegin args."); - hr = BuffReaderReadNumber64(pReader, &args.dw64PackageCacheSize); + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64PackageCacheSize); ExitOnFailure(hr, "Failed to read package cache size of OnCachePackageBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fVital)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fVital)); ExitOnFailure(hr, "Failed to read vital of OnCachePackageBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCachePackageBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePackageBegin results."); // Callback. @@ -915,7 +885,8 @@ static HRESULT OnCachePackageBegin( static HRESULT OnCachePackageComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -925,28 +896,25 @@ static HRESULT OnCachePackageComplete( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePackageComplete args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnCachePackageComplete args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnCachePackageComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnCachePackageComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCachePackageComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePackageComplete results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnCachePackageComplete results."); // Callback. @@ -974,7 +942,8 @@ static HRESULT OnCachePackageComplete( static HRESULT OnCachePackageNonVitalValidationFailure( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -984,28 +953,25 @@ static HRESULT OnCachePackageNonVitalValidationFailure( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePackageNonVitalValidationFailure args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnCachePackageNonVitalValidationFailure args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnCachePackageNonVitalValidationFailure args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnCachePackageNonVitalValidationFailure args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCachePackageNonVitalValidationFailure args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePackageNonVitalValidationFailure results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnCachePackageNonVitalValidationFailure results."); // Callback. @@ -1033,7 +999,8 @@ static HRESULT OnCachePackageNonVitalValidationFailure( static HRESULT OnCachePayloadExtractBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1044,24 +1011,21 @@ static HRESULT OnCachePayloadExtractBegin( LPWSTR sczPayloadId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePayloadExtractBegin args."); - hr = BuffReaderReadString(pReader, &sczContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczContainerId); ExitOnFailure(hr, "Failed to read container id of OnCachePayloadExtractBegin args."); args.wzContainerId = sczContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCachePayloadExtractBegin args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCachePayloadExtractBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePayloadExtractBegin results."); // Callback. @@ -1090,7 +1054,8 @@ static HRESULT OnCachePayloadExtractBegin( static HRESULT OnCachePayloadExtractComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1101,27 +1066,24 @@ static HRESULT OnCachePayloadExtractComplete( LPWSTR sczPayloadId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePayloadExtractComplete args."); - hr = BuffReaderReadString(pReader, &sczContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczContainerId); ExitOnFailure(hr, "Failed to read container id of OnCachePayloadExtractComplete args."); args.wzContainerId = sczContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCachePayloadExtractComplete args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnCachePayloadExtractComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCachePayloadExtractComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePayloadExtractComplete results."); // Callback. @@ -1147,7 +1109,8 @@ static HRESULT OnCachePayloadExtractComplete( static HRESULT OnCachePayloadExtractProgress( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1158,33 +1121,30 @@ static HRESULT OnCachePayloadExtractProgress( LPWSTR sczPayloadId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePayloadExtractProgress args."); - hr = BuffReaderReadString(pReader, &sczContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczContainerId); ExitOnFailure(hr, "Failed to read container id of OnCachePayloadExtractProgress args."); args.wzContainerId = sczContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCachePayloadExtractProgress args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderReadNumber64(pReader, &args.dw64Progress); + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Progress); ExitOnFailure(hr, "Failed to read progress of OnCachePayloadExtractProgress args."); - hr = BuffReaderReadNumber64(pReader, &args.dw64Total); + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Total); ExitOnFailure(hr, "Failed to read total progress of OnCachePayloadExtractProgress args."); - hr = BuffReaderReadNumber(pReader, &args.dwOverallPercentage); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage); ExitOnFailure(hr, "Failed to read overall percentage of OnCachePayloadExtractProgress args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCachePayloadExtractProgress args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePayloadExtractProgress results."); // Callback. @@ -1213,7 +1173,8 @@ static HRESULT OnCachePayloadExtractProgress( static HRESULT OnCacheVerifyBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1224,24 +1185,21 @@ static HRESULT OnCacheVerifyBegin( LPWSTR sczPayloadId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheVerifyBegin args."); - hr = BuffReaderReadString(pReader, &sczPackageOrContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); ExitOnFailure(hr, "Failed to read package or container id of OnCacheVerifyBegin args."); args.wzPackageOrContainerId = sczPackageOrContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCacheVerifyBegin args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCacheVerifyBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheVerifyBegin results."); // Callback. @@ -1270,7 +1228,8 @@ static HRESULT OnCacheVerifyBegin( static HRESULT OnCacheVerifyComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1281,33 +1240,30 @@ static HRESULT OnCacheVerifyComplete( LPWSTR sczPayloadId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheVerifyComplete args."); - hr = BuffReaderReadString(pReader, &sczPackageOrContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); ExitOnFailure(hr, "Failed to read package or container id of OnCacheVerifyComplete args."); args.wzPackageOrContainerId = sczPackageOrContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCacheVerifyComplete args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnCacheVerifyComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnCacheVerifyComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCacheVerifyComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheVerifyComplete results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read size of OnCacheVerifyComplete results."); // Callback. @@ -1336,7 +1292,8 @@ static HRESULT OnCacheVerifyComplete( static HRESULT OnCacheVerifyProgress( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1347,36 +1304,33 @@ static HRESULT OnCacheVerifyProgress( LPWSTR sczPayloadId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheVerifyProgress args."); - hr = BuffReaderReadString(pReader, &sczPackageOrContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); ExitOnFailure(hr, "Failed to read package or container id of OnCacheVerifyProgress args."); args.wzPackageOrContainerId = sczPackageOrContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of OnCacheVerifyProgress args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderReadNumber64(pReader, &args.dw64Progress); + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Progress); ExitOnFailure(hr, "Failed to read progress of OnCacheVerifyProgress args."); - hr = BuffReaderReadNumber64(pReader, &args.dw64Total); + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Total); ExitOnFailure(hr, "Failed to read total progress of OnCacheVerifyProgress args."); - hr = BuffReaderReadNumber(pReader, &args.dwOverallPercentage); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage); ExitOnFailure(hr, "Failed to read overall percentage of OnCacheVerifyProgress args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.verifyStep)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.verifyStep)); ExitOnFailure(hr, "Failed to read verify step of OnCacheVerifyProgress args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCacheVerifyProgress args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheVerifyProgress results."); // Callback. @@ -1405,7 +1359,8 @@ static HRESULT OnCacheVerifyProgress( static HRESULT OnCommitMsiTransactionBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1415,19 +1370,16 @@ static HRESULT OnCommitMsiTransactionBegin( LPWSTR sczTransactionId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCommitMsiTransactionBegin args."); - hr = BuffReaderReadString(pReader, &sczTransactionId); + hr = BuffReaderReadString(pReaderArgs, &sczTransactionId); ExitOnFailure(hr, "Failed to read transaction id of OnCommitMsiTransactionBegin args."); args.wzTransactionId = sczTransactionId; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCommitMsiTransactionBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCommitMsiTransactionBegin results."); // Callback. @@ -1455,7 +1407,8 @@ static HRESULT OnCommitMsiTransactionBegin( static HRESULT OnCommitMsiTransactionComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1465,31 +1418,28 @@ static HRESULT OnCommitMsiTransactionComplete( LPWSTR sczTransactionId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCommitMsiTransactionComplete args."); - hr = BuffReaderReadString(pReader, &sczTransactionId); + hr = BuffReaderReadString(pReaderArgs, &sczTransactionId); ExitOnFailure(hr, "Failed to read transaction id of OnCommitMsiTransactionComplete args."); args.wzTransactionId = sczTransactionId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnCommitMsiTransactionComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.restart)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.restart)); ExitOnFailure(hr, "Failed to read restart of OnCommitMsiTransactionComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnCommitMsiTransactionComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCommitMsiTransactionComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCommitMsiTransactionComplete results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnCommitMsiTransactionComplete results."); // Callback. @@ -1518,7 +1468,8 @@ static HRESULT OnCommitMsiTransactionComplete( static HRESULT OnCreate( __in IBootstrapperApplication* pApplication, __in IBootstrapperEngine* pEngine, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1532,60 +1483,57 @@ static HRESULT OnCreate( DWORD64 dw64 = 0; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnCreate args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.command.cbSize)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.cbSize)); ExitOnFailure(hr, "Failed to read size of OnCreate args command."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.command.action)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.action)); ExitOnFailure(hr, "Failed to read action of OnCreate args command."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.command.display)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.display)); ExitOnFailure(hr, "Failed to read action of OnCreate args command."); - hr = BuffReaderReadString(pReader, &sczCommandLine); + hr = BuffReaderReadString(pReaderArgs, &sczCommandLine); ExitOnFailure(hr, "Failed to read command-line of OnCreate args command."); args.command.wzCommandLine = sczCommandLine; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.command.nCmdShow)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.nCmdShow)); ExitOnFailure(hr, "Failed to read show command of OnCreate args command."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.command.resumeType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.resumeType)); ExitOnFailure(hr, "Failed to read resume type of OnCreate args command."); - hr = BuffReaderReadNumber64(pReader, &dw64); + hr = BuffReaderReadNumber64(pReaderArgs, &dw64); ExitOnFailure(hr, "Failed to read splash screen handle of OnCreate args command."); args.command.hwndSplashScreen = reinterpret_cast(dw64); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.command.relationType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.relationType)); ExitOnFailure(hr, "Failed to read relation type of OnCreate args command."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.command.fPassthrough)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.fPassthrough)); ExitOnFailure(hr, "Failed to read passthrough of OnCreate args command."); - hr = BuffReaderReadString(pReader, &sczLayoutDirectory); + hr = BuffReaderReadString(pReaderArgs, &sczLayoutDirectory); ExitOnFailure(hr, "Failed to read command-line of OnCreate args command."); args.command.wzLayoutDirectory = sczLayoutDirectory; - hr = BuffReaderReadString(pReader, &sczBootstrapperWorkingFolder); + hr = BuffReaderReadString(pReaderArgs, &sczBootstrapperWorkingFolder); ExitOnFailure(hr, "Failed to read command-line of OnCreate args command."); args.command.wzBootstrapperWorkingFolder = sczBootstrapperWorkingFolder; - hr = BuffReaderReadString(pReader, &sczBootstrapperApplicationDataPath); + hr = BuffReaderReadString(pReaderArgs, &sczBootstrapperApplicationDataPath); ExitOnFailure(hr, "Failed to read command-line of OnCreate args command."); args.command.wzBootstrapperApplicationDataPath = sczBootstrapperApplicationDataPath; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnCreate args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCreate results."); // Callback. @@ -1614,7 +1562,8 @@ static HRESULT OnCreate( static HRESULT OnDestroy( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1623,17 +1572,14 @@ static HRESULT OnDestroy( BA_ONDESTROY_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDestroy args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fReload)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fReload)); ExitOnFailure(hr, "Failed to read reload of OnDestroy args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDestroy args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDestroy results."); // Callback. @@ -1657,7 +1603,8 @@ static HRESULT OnDestroy( static HRESULT OnDetectBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1666,24 +1613,21 @@ static HRESULT OnDetectBegin( BA_ONDETECTBEGIN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.registrationType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.registrationType)); ExitOnFailure(hr, "Failed to read registration type of OnDetectBegin args."); - hr = BuffReaderReadNumber(pReader, &args.cPackages); + hr = BuffReaderReadNumber(pReaderArgs, &args.cPackages); ExitOnFailure(hr, "Failed to read package count of OnDetectBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fCached)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fCached)); ExitOnFailure(hr, "Failed to read cached of OnDetectBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectBegin results."); // Callback. @@ -1710,7 +1654,8 @@ static HRESULT OnDetectBegin( static HRESULT OnDetectCompatibleMsiPackage( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1722,29 +1667,26 @@ static HRESULT OnDetectCompatibleMsiPackage( LPWSTR sczCompatiblePackageVersion = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectCompatibleMsiPackage args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnDetectCompatibleMsiPackage args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadString(pReader, &sczCompatiblePackageId); + hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageId); ExitOnFailure(hr, "Failed to read compatible package id of OnDetectCompatibleMsiPackage args."); args.wzCompatiblePackageId = sczCompatiblePackageId; - hr = BuffReaderReadString(pReader, &sczCompatiblePackageVersion); + hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageVersion); ExitOnFailure(hr, "Failed to read compatible package version of OnDetectCompatibleMsiPackage args."); args.wzCompatiblePackageVersion = sczCompatiblePackageVersion; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectCompatibleMsiPackage args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectCompatibleMsiPackage results."); // Callback. @@ -1774,7 +1716,8 @@ static HRESULT OnDetectCompatibleMsiPackage( static HRESULT OnDetectComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1783,20 +1726,17 @@ static HRESULT OnDetectComplete( BA_ONDETECTCOMPLETE_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnDetectComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fEligibleForCleanup)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fEligibleForCleanup)); ExitOnFailure(hr, "Failed to read eligible for cleanup of OnDetectComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectComplete results."); // Callback. @@ -1820,7 +1760,8 @@ static HRESULT OnDetectComplete( static HRESULT OnDetectForwardCompatibleBundle( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1832,38 +1773,35 @@ static HRESULT OnDetectForwardCompatibleBundle( LPWSTR sczVersion = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectForwardCompatibleBundle args."); - hr = BuffReaderReadString(pReader, &sczBundleId); + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); ExitOnFailure(hr, "Failed to read bundle id of OnDetectForwardCompatibleBundle args."); args.wzBundleId = sczBundleId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.relationType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.relationType)); ExitOnFailure(hr, "Failed to read relation type of OnDetectForwardCompatibleBundle args."); - hr = BuffReaderReadString(pReader, &sczBundleTag); + hr = BuffReaderReadString(pReaderArgs, &sczBundleTag); ExitOnFailure(hr, "Failed to read bundle tag of OnDetectForwardCompatibleBundle args."); args.wzBundleTag = sczBundleTag; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fPerMachine)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPerMachine)); ExitOnFailure(hr, "Failed to read per-machine of OnDetectForwardCompatibleBundle args."); - hr = BuffReaderReadString(pReader, &sczVersion); + hr = BuffReaderReadString(pReaderArgs, &sczVersion); ExitOnFailure(hr, "Failed to read version of OnDetectForwardCompatibleBundle args."); args.wzVersion = sczVersion; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fMissingFromCache)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fMissingFromCache)); ExitOnFailure(hr, "Failed to read missing from cache of OnDetectForwardCompatibleBundle args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectForwardCompatibleBundle args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectForwardCompatibleBundle results."); // Callback. @@ -1893,7 +1831,8 @@ static HRESULT OnDetectForwardCompatibleBundle( static HRESULT OnDetectMsiFeature( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1904,27 +1843,24 @@ static HRESULT OnDetectMsiFeature( LPWSTR sczFeatureId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectMsiFeature args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnDetectMsiFeature args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadString(pReader, &sczFeatureId); + hr = BuffReaderReadString(pReaderArgs, &sczFeatureId); ExitOnFailure(hr, "Failed to read feature id of OnDetectMsiFeature args."); args.wzFeatureId = sczFeatureId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.state)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.state)); ExitOnFailure(hr, "Failed to read state of OnDetectMsiFeature args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectMsiFeature args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectMsiFeature results."); // Callback. @@ -1953,7 +1889,8 @@ static HRESULT OnDetectMsiFeature( static HRESULT OnDetectPackageBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1963,19 +1900,16 @@ static HRESULT OnDetectPackageBegin( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectPackageBegin args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnDetectPackageBegin args."); args.wzPackageId = sczPackageId; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectPackageBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectPackageBegin results."); // Callback. @@ -2003,7 +1937,8 @@ static HRESULT OnDetectPackageBegin( static HRESULT OnDetectPackageComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2013,28 +1948,25 @@ static HRESULT OnDetectPackageComplete( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectPackageComplete args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnDetectPackageComplete args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnDetectPackageComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.state)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.state)); ExitOnFailure(hr, "Failed to read state of OnDetectPackageComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fCached)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fCached)); ExitOnFailure(hr, "Failed to read cached of OnDetectPackageComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectPackageComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectPackageComplete results."); // Callback. @@ -2059,7 +1991,8 @@ static HRESULT OnDetectPackageComplete( static HRESULT OnDetectRelatedBundle( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2071,38 +2004,35 @@ static HRESULT OnDetectRelatedBundle( LPWSTR sczVersion = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectRelatedBundle args."); - hr = BuffReaderReadString(pReader, &sczBundleId); + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); ExitOnFailure(hr, "Failed to read bundle id of OnDetectRelatedBundle args."); args.wzBundleId = sczBundleId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.relationType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.relationType)); ExitOnFailure(hr, "Failed to read relation type of OnDetectRelatedBundle args."); - hr = BuffReaderReadString(pReader, &sczBundleTag); + hr = BuffReaderReadString(pReaderArgs, &sczBundleTag); ExitOnFailure(hr, "Failed to read bundle tag of OnDetectRelatedBundle args."); args.wzBundleTag = sczBundleTag; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fPerMachine)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPerMachine)); ExitOnFailure(hr, "Failed to read per-machine of OnDetectRelatedBundle args."); - hr = BuffReaderReadString(pReader, &sczVersion); + hr = BuffReaderReadString(pReaderArgs, &sczVersion); ExitOnFailure(hr, "Failed to read version of OnDetectRelatedBundle args."); args.wzVersion = sczVersion; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fMissingFromCache)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fMissingFromCache)); ExitOnFailure(hr, "Failed to read missing from cache of OnDetectRelatedBundle args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectRelatedBundle args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectRelatedBundle results."); // Callback. @@ -2132,7 +2062,8 @@ static HRESULT OnDetectRelatedBundle( static HRESULT OnDetectRelatedBundlePackage( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2144,35 +2075,32 @@ static HRESULT OnDetectRelatedBundlePackage( LPWSTR sczVersion = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectRelatedBundlePackage args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnDetectRelatedBundlePackage args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadString(pReader, &sczBundleId); + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); ExitOnFailure(hr, "Failed to read bundle id of OnDetectRelatedBundlePackage args."); args.wzBundleId = sczBundleId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.relationType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.relationType)); ExitOnFailure(hr, "Failed to read relation type of OnDetectRelatedBundlePackage args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fPerMachine)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPerMachine)); ExitOnFailure(hr, "Failed to read per-machine of OnDetectRelatedBundlePackage args."); - hr = BuffReaderReadString(pReader, &sczVersion); + hr = BuffReaderReadString(pReaderArgs, &sczVersion); ExitOnFailure(hr, "Failed to read version of OnDetectRelatedBundlePackage args."); args.wzVersion = sczVersion; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectRelatedBundlePackage args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectRelatedBundlePackage results."); // Callback. @@ -2202,7 +2130,8 @@ static HRESULT OnDetectRelatedBundlePackage( static HRESULT OnDetectRelatedMsiPackage( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2215,40 +2144,37 @@ static HRESULT OnDetectRelatedMsiPackage( LPWSTR sczVersion = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectRelatedMsiPackage args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnDetectRelatedMsiPackage args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadString(pReader, &sczUpgradeCode); + hr = BuffReaderReadString(pReaderArgs, &sczUpgradeCode); ExitOnFailure(hr, "Failed to read upgrade code of OnDetectRelatedMsiPackage args."); args.wzUpgradeCode = sczUpgradeCode; - hr = BuffReaderReadString(pReader, &sczProductCode); + hr = BuffReaderReadString(pReaderArgs, &sczProductCode); ExitOnFailure(hr, "Failed to read product code of OnDetectRelatedMsiPackage args."); args.wzProductCode = sczProductCode; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fPerMachine)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPerMachine)); ExitOnFailure(hr, "Failed to read per-machine of OnDetectRelatedMsiPackage args."); - hr = BuffReaderReadString(pReader, &sczVersion); + hr = BuffReaderReadString(pReaderArgs, &sczVersion); ExitOnFailure(hr, "Failed to read version of OnDetectRelatedMsiPackage args."); args.wzVersion = sczVersion; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.operation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.operation)); ExitOnFailure(hr, "Failed to read per-machine of OnDetectRelatedMsiPackage args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectRelatedMsiPackage args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectRelatedMsiPackage results."); // Callback. @@ -2279,7 +2205,8 @@ static HRESULT OnDetectRelatedMsiPackage( static HRESULT OnDetectPatchTarget( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2290,27 +2217,24 @@ static HRESULT OnDetectPatchTarget( LPWSTR sczProductCode = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectPatchTarget args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnDetectPatchTarget args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadString(pReader, &sczProductCode); + hr = BuffReaderReadString(pReaderArgs, &sczProductCode); ExitOnFailure(hr, "Failed to read product code of OnDetectPatchTarget args."); args.wzProductCode = sczProductCode; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.patchState)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.patchState)); ExitOnFailure(hr, "Failed to read patch state of OnDetectPatchTarget args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectPatchTarget args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectPatchTarget results."); // Callback. @@ -2339,7 +2263,8 @@ static HRESULT OnDetectPatchTarget( static HRESULT OnDetectUpdate( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2355,58 +2280,55 @@ static HRESULT OnDetectUpdate( LPWSTR sczContent = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectUpdate args."); - hr = BuffReaderReadString(pReader, &sczUpdateLocation); + hr = BuffReaderReadString(pReaderArgs, &sczUpdateLocation); ExitOnFailure(hr, "Failed to read update location of OnDetectUpdate args."); args.wzUpdateLocation = sczUpdateLocation; - hr = BuffReaderReadNumber64(pReader, &args.dw64Size); + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Size); ExitOnFailure(hr, "Failed to read update size of OnDetectUpdate args."); - hr = BuffReaderReadString(pReader, &sczHash); + hr = BuffReaderReadString(pReaderArgs, &sczHash); ExitOnFailure(hr, "Failed to read hash of OnDetectUpdate args."); args.wzHash = sczHash; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hashAlgorithm)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hashAlgorithm)); ExitOnFailure(hr, "Failed to read hash algorithm of OnDetectUpdate args."); - hr = BuffReaderReadString(pReader, &sczVersion); + hr = BuffReaderReadString(pReaderArgs, &sczVersion); ExitOnFailure(hr, "Failed to read version of OnDetectUpdate args."); args.wzVersion = sczVersion; - hr = BuffReaderReadString(pReader, &sczTitle); + hr = BuffReaderReadString(pReaderArgs, &sczTitle); ExitOnFailure(hr, "Failed to read title of OnDetectUpdate args."); args.wzTitle = sczTitle; - hr = BuffReaderReadString(pReader, &sczSummary); + hr = BuffReaderReadString(pReaderArgs, &sczSummary); ExitOnFailure(hr, "Failed to read summary of OnDetectUpdate args."); args.wzSummary = sczSummary; - hr = BuffReaderReadString(pReader, &sczContentType); + hr = BuffReaderReadString(pReaderArgs, &sczContentType); ExitOnFailure(hr, "Failed to read content type of OnDetectUpdate args."); args.wzContentType = sczContentType; - hr = BuffReaderReadString(pReader, &sczContent); + hr = BuffReaderReadString(pReaderArgs, &sczContent); ExitOnFailure(hr, "Failed to read content of OnDetectUpdate args."); args.wzContent = sczContent; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectUpdate args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectUpdate results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.fStopProcessingUpdates)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fStopProcessingUpdates)); ExitOnFailure(hr, "Failed to read stop processing updates of OnDetectUpdate results."); // Callback. @@ -2443,7 +2365,8 @@ static HRESULT OnDetectUpdate( static HRESULT OnDetectUpdateBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2453,22 +2376,19 @@ static HRESULT OnDetectUpdateBegin( LPWSTR sczUpdateLocation = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectUpdateBegin args."); - hr = BuffReaderReadString(pReader, &sczUpdateLocation); + hr = BuffReaderReadString(pReaderArgs, &sczUpdateLocation); ExitOnFailure(hr, "Failed to read update location of OnDetectUpdateBegin args."); args.wzUpdateLocation = sczUpdateLocation; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectUpdateBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectUpdateBegin results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.fSkip)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fSkip)); ExitOnFailure(hr, "Failed to read skip of OnDetectUpdateBegin results."); // Callback. @@ -2500,7 +2420,8 @@ static HRESULT OnDetectUpdateBegin( static HRESULT OnDetectUpdateComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2510,20 +2431,17 @@ static HRESULT OnDetectUpdateComplete( LPWSTR sczUpdateLocation = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectUpdateComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnDetectUpdateComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnDetectUpdateComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectUpdateComplete results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.fIgnoreError)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fIgnoreError)); ExitOnFailure(hr, "Failed to read ignore error of OnDetectUpdateComplete results."); // Callback. @@ -2551,7 +2469,8 @@ static HRESULT OnDetectUpdateComplete( static HRESULT OnElevateBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2560,14 +2479,11 @@ static HRESULT OnElevateBegin( BA_ONELEVATEBEGIN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnElevateBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnElevateBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnElevateBegin results."); // Callback. @@ -2594,7 +2510,8 @@ static HRESULT OnElevateBegin( static HRESULT OnElevateComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2603,17 +2520,14 @@ static HRESULT OnElevateComplete( BA_ONELEVATECOMPLETE_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnElevateComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnElevateComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnElevateComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnElevateComplete results."); // Callback. @@ -2637,7 +2551,8 @@ static HRESULT OnElevateComplete( static HRESULT OnError( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2650,29 +2565,29 @@ static HRESULT OnError( LPWSTR* rgsczData = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnError args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.errorType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.errorType)); ExitOnFailure(hr, "Failed to read error type of OnError args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnError args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, &args.dwCode); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwCode); ExitOnFailure(hr, "Failed to read code of OnError args."); - hr = BuffReaderReadString(pReader, &sczError); + hr = BuffReaderReadString(pReaderArgs, &sczError); ExitOnFailure(hr, "Failed to read error of OnError args."); args.wzError = sczError; - hr = BuffReaderReadNumber(pReader, &args.dwUIHint); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwUIHint); ExitOnFailure(hr, "Failed to read UI hint of OnError args."); - hr = BuffReaderReadNumber(pReader, &cData); + hr = BuffReaderReadNumber(pReaderArgs, &cData); ExitOnFailure(hr, "Failed to read count of data of OnError args."); if (cData) @@ -2682,7 +2597,7 @@ static HRESULT OnError( for (DWORD i = 0; i < cData; ++i) { - hr = BuffReaderReadString(pReader, &rgsczData[i]); + hr = BuffReaderReadString(pReaderArgs, &rgsczData[i]); ExitOnFailure(hr, "Failed to read search path[%u] of OnError args.", i); } } @@ -2690,17 +2605,14 @@ static HRESULT OnError( args.cData = cData; args.rgwzData = const_cast(rgsczData); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.nRecommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.nRecommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnError args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnError args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnError results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.nResult)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.nResult)); ExitOnFailure(hr, "Failed to read cancel of OnError results."); // Callback. @@ -2735,7 +2647,8 @@ static HRESULT OnError( static HRESULT OnExecuteBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2744,17 +2657,14 @@ static HRESULT OnExecuteBegin( BA_ONEXECUTEBEGIN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteBegin args."); - hr = BuffReaderReadNumber(pReader, &args.cExecutingPackages); + hr = BuffReaderReadNumber(pReaderArgs, &args.cExecutingPackages); ExitOnFailure(hr, "Failed to executing packages of OnExecuteBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnExecuteBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteBegin results."); // Callback. @@ -2782,7 +2692,8 @@ static HRESULT OnExecuteBegin( static HRESULT OnExecuteComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2791,17 +2702,14 @@ static HRESULT OnExecuteComplete( BA_ONEXECUTECOMPLETE_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to status of OnExecuteComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnExecuteComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteComplete results."); // Callback. @@ -2825,7 +2733,8 @@ static HRESULT OnExecuteComplete( static HRESULT OnExecuteFilesInUse( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2837,15 +2746,15 @@ static HRESULT OnExecuteFilesInUse( LPWSTR* rgsczFiles = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteFilesInUse args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnExecuteFilesInUse args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, &cFiles); + hr = BuffReaderReadNumber(pReaderArgs, &cFiles); ExitOnFailure(hr, "Failed to read count of files of OnExecuteFilesInUse args."); if (cFiles) @@ -2855,7 +2764,7 @@ static HRESULT OnExecuteFilesInUse( for (DWORD i = 0; i < cFiles; ++i) { - hr = BuffReaderReadString(pReader, &rgsczFiles[i]); + hr = BuffReaderReadString(pReaderArgs, &rgsczFiles[i]); ExitOnFailure(hr, "Failed to read file[%u] of OnExecuteFilesInUse args.", i); } } @@ -2863,20 +2772,17 @@ static HRESULT OnExecuteFilesInUse( args.cFiles = cFiles; args.rgwzFiles = const_cast(rgsczFiles); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.nRecommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.nRecommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnExecuteFilesInUse args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.source)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.source)); ExitOnFailure(hr, "Failed to read source of OnExecuteFilesInUse args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnExecuteFilesInUse args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteFilesInUse results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.nResult)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.nResult)); ExitOnFailure(hr, "Failed to read result of OnExecuteFilesInUse results."); // Callback. @@ -2910,7 +2816,8 @@ static HRESULT OnExecuteFilesInUse( static HRESULT OnExecuteMsiMessage( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -2923,26 +2830,26 @@ static HRESULT OnExecuteMsiMessage( LPWSTR* rgsczData = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteMsiMessage args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnExecuteMsiMessage args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.messageType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.messageType)); ExitOnFailure(hr, "Failed to read messageType of OnExecuteMsiMessage args."); - hr = BuffReaderReadNumber(pReader, &args.dwUIHint); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwUIHint); ExitOnFailure(hr, "Failed to read UI hint of OnExecuteMsiMessage args."); - hr = BuffReaderReadString(pReader, &sczMessage); + hr = BuffReaderReadString(pReaderArgs, &sczMessage); ExitOnFailure(hr, "Failed to read message of OnExecuteMsiMessage args."); args.wzMessage = sczMessage; - hr = BuffReaderReadNumber(pReader, &cData); + hr = BuffReaderReadNumber(pReaderArgs, &cData); ExitOnFailure(hr, "Failed to read count of files of OnExecuteMsiMessage args."); if (cData) @@ -2952,7 +2859,7 @@ static HRESULT OnExecuteMsiMessage( for (DWORD i = 0; i < cData; ++i) { - hr = BuffReaderReadString(pReader, &rgsczData[i]); + hr = BuffReaderReadString(pReaderArgs, &rgsczData[i]); ExitOnFailure(hr, "Failed to read data[%u] of OnExecuteMsiMessage args.", i); } } @@ -2960,17 +2867,14 @@ static HRESULT OnExecuteMsiMessage( args.cData = cData; args.rgwzData = const_cast(rgsczData); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.nRecommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.nRecommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnExecuteMsiMessage args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnExecuteMsiMessage args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteMsiMessage results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.nResult)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.nResult)); ExitOnFailure(hr, "Failed to read result of OnExecuteMsiMessage results."); // Callback. @@ -3005,7 +2909,8 @@ static HRESULT OnExecuteMsiMessage( static HRESULT OnExecutePackageBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3015,31 +2920,28 @@ static HRESULT OnExecutePackageBegin( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecutePackageBegin args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnExecutePackageBegin args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fExecute)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fExecute)); ExitOnFailure(hr, "Failed to read execute of OnExecutePackageBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.action)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.action)); ExitOnFailure(hr, "Failed to read action of OnExecutePackageBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.uiLevel)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.uiLevel)); ExitOnFailure(hr, "Failed to read UI level of OnExecutePackageBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fDisableExternalUiHandler)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fDisableExternalUiHandler)); ExitOnFailure(hr, "Failed to read disable external UI handler of OnExecutePackageBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnExecutePackageBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecutePackageBegin results."); // Callback. @@ -3067,7 +2969,8 @@ static HRESULT OnExecutePackageBegin( static HRESULT OnExecutePackageComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3077,31 +2980,28 @@ static HRESULT OnExecutePackageComplete( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecutePackageComplete args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnExecutePackageComplete args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnExecutePackageComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.restart)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.restart)); ExitOnFailure(hr, "Failed to read restart of OnExecutePackageComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnExecutePackageComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnExecutePackageComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecutePackageComplete results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnExecutePackageComplete results."); // Callback. @@ -3129,7 +3029,8 @@ static HRESULT OnExecutePackageComplete( static HRESULT OnExecutePatchTarget( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3140,24 +3041,22 @@ static HRESULT OnExecutePatchTarget( LPWSTR sczTargetProductCode = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecutePatchTarget args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnExecutePatchTarget args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadString(pReader, &sczTargetProductCode); + hr = BuffReaderReadString(pReaderArgs, &sczTargetProductCode); ExitOnFailure(hr, "Failed to read target product code of OnExecutePatchTarget args."); args.wzTargetProductCode = sczTargetProductCode; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnExecutePatchTarget args size does not match expected size."); // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecutePatchTarget results."); // Callback. @@ -3186,7 +3085,8 @@ static HRESULT OnExecutePatchTarget( static HRESULT OnExecuteProcessCancel( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3196,28 +3096,25 @@ static HRESULT OnExecuteProcessCancel( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteProcessCancel args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnExecuteProcessCancel args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, &args.dwProcessId); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwProcessId); ExitOnFailure(hr, "Failed to read process id of OnExecuteProcessCancel args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnExecuteProcessCancel args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnExecuteProcessCancel args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteProcessCancel results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnExecuteProcessCancel results."); // Callback. @@ -3245,7 +3142,8 @@ static HRESULT OnExecuteProcessCancel( static HRESULT OnExecuteProgress( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3255,25 +3153,22 @@ static HRESULT OnExecuteProgress( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteProgress args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnExecuteProgress args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, &args.dwProgressPercentage); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwProgressPercentage); ExitOnFailure(hr, "Failed to read progress of OnExecuteProgress args."); - hr = BuffReaderReadNumber(pReader, &args.dwOverallPercentage); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage); ExitOnFailure(hr, "Failed to read overall progress of OnExecuteProgress args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnExecuteProgress args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteProgress results."); // Callback. @@ -3301,7 +3196,8 @@ static HRESULT OnExecuteProgress( static HRESULT OnLaunchApprovedExeBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3310,14 +3206,11 @@ static HRESULT OnLaunchApprovedExeBegin( BA_ONLAUNCHAPPROVEDEXEBEGIN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnLaunchApprovedExeBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnLaunchApprovedExeBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnLaunchApprovedExeBegin results."); // Callback. @@ -3344,7 +3237,8 @@ static HRESULT OnLaunchApprovedExeBegin( static HRESULT OnLaunchApprovedExeComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3353,20 +3247,17 @@ static HRESULT OnLaunchApprovedExeComplete( BA_ONLAUNCHAPPROVEDEXECOMPLETE_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnLaunchApprovedExeComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnLaunchApprovedExeComplete args."); - hr = BuffReaderReadNumber(pReader, &args.dwProcessId); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwProcessId); ExitOnFailure(hr, "Failed to read process id of OnLaunchApprovedExeComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnLaunchApprovedExeComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnLaunchApprovedExeComplete results."); // Callback. @@ -3390,7 +3281,8 @@ static HRESULT OnLaunchApprovedExeComplete( static HRESULT OnPauseAutomaticUpdatesBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3399,14 +3291,11 @@ static HRESULT OnPauseAutomaticUpdatesBegin( BA_ONPAUSEAUTOMATICUPDATESBEGIN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPauseAutomaticUpdatesBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPauseAutomaticUpdatesBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPauseAutomaticUpdatesBegin results."); // Callback. @@ -3430,7 +3319,8 @@ static HRESULT OnPauseAutomaticUpdatesBegin( static HRESULT OnPauseAutomaticUpdatesComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3439,17 +3329,14 @@ static HRESULT OnPauseAutomaticUpdatesComplete( BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPauseAutomaticUpdatesComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnPauseAutomaticUpdatesComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPauseAutomaticUpdatesComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPauseAutomaticUpdatesComplete results."); // Callback. @@ -3473,7 +3360,8 @@ static HRESULT OnPauseAutomaticUpdatesComplete( static HRESULT OnPlanBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3482,17 +3370,14 @@ static HRESULT OnPlanBegin( BA_ONPLANBEGIN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanBegin args."); - hr = BuffReaderReadNumber(pReader, &args.cPackages); + hr = BuffReaderReadNumber(pReaderArgs, &args.cPackages); ExitOnFailure(hr, "Failed to read count of packages of OnPlanBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanBegin results."); // Callback. @@ -3519,7 +3404,8 @@ static HRESULT OnPlanBegin( static HRESULT OnPlanCompatibleMsiPackageBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3531,35 +3417,32 @@ static HRESULT OnPlanCompatibleMsiPackageBegin( LPWSTR sczCompatiblePackageVersion = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanCompatibleMsiPackageBegin args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnPlanCompatibleMsiPackageBegin args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadString(pReader, &sczCompatiblePackageId); + hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageId); ExitOnFailure(hr, "Failed to read compatible package id of OnPlanCompatibleMsiPackageBegin args."); args.wzCompatiblePackageId = sczCompatiblePackageId; - hr = BuffReaderReadString(pReader, &sczCompatiblePackageVersion); + hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageVersion); ExitOnFailure(hr, "Failed to read compatible package version of OnPlanCompatibleMsiPackageBegin args."); args.wzCompatiblePackageVersion = sczCompatiblePackageVersion; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fRecommendedRemove)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fRecommendedRemove)); ExitOnFailure(hr, "Failed to read recommend remove of OnPlanCompatibleMsiPackageBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanCompatibleMsiPackageBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanCompatibleMsiPackageBegin results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.fRequestRemove)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fRequestRemove)); ExitOnFailure(hr, "Failed to read request remove of OnPlanCompatibleMsiPackageBegin results."); // Callback. @@ -3593,7 +3476,8 @@ static HRESULT OnPlanCompatibleMsiPackageBegin( static HRESULT OnPlanCompatibleMsiPackageComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3604,30 +3488,27 @@ static HRESULT OnPlanCompatibleMsiPackageComplete( LPWSTR sczCompatiblePackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanCompatibleMsiPackageComplete args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnPlanCompatibleMsiPackageComplete args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadString(pReader, &sczCompatiblePackageId); + hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageId); ExitOnFailure(hr, "Failed to read compatible package id of OnPlanCompatibleMsiPackageComplete args."); args.wzCompatiblePackageId = sczCompatiblePackageId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnPlanCompatibleMsiPackageComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fRequestedRemove)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fRequestedRemove)); ExitOnFailure(hr, "Failed to read requested remove of OnPlanCompatibleMsiPackageComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanCompatibleMsiPackageComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanCompatibleMsiPackageComplete results."); // Callback. @@ -3655,7 +3536,8 @@ static HRESULT OnPlanCompatibleMsiPackageComplete( static HRESULT OnPlanMsiFeature( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3666,30 +3548,27 @@ static HRESULT OnPlanMsiFeature( LPWSTR sczFeatureId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanMsiFeature args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnPlanMsiFeature args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadString(pReader, &sczFeatureId); + hr = BuffReaderReadString(pReaderArgs, &sczFeatureId); ExitOnFailure(hr, "Failed to read feature id of OnPlanMsiFeature args."); args.wzFeatureId = sczFeatureId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendedState)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedState)); ExitOnFailure(hr, "Failed to read recommended state of OnPlanMsiFeature args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanMsiFeature args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanMsiFeature results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.requestedState)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedState)); ExitOnFailure(hr, "Failed to read requested state of OnPlanMsiFeature results."); // Callback. @@ -3722,7 +3601,8 @@ static HRESULT OnPlanMsiFeature( static HRESULT OnPlanComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3731,17 +3611,14 @@ static HRESULT OnPlanComplete( BA_ONPLANCOMPLETE_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnPlanComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanComplete results."); // Callback. @@ -3765,7 +3642,8 @@ static HRESULT OnPlanComplete( static HRESULT OnPlanForwardCompatibleBundle( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3777,41 +3655,38 @@ static HRESULT OnPlanForwardCompatibleBundle( LPWSTR sczVersion = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanForwardCompatibleBundle args."); - hr = BuffReaderReadString(pReader, &sczBundleId); + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); ExitOnFailure(hr, "Failed to read bundle id of OnPlanForwardCompatibleBundle args."); args.wzBundleId = sczBundleId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.relationType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.relationType)); ExitOnFailure(hr, "Failed to read relation type of OnPlanForwardCompatibleBundle args."); - hr = BuffReaderReadString(pReader, &sczBundleTag); + hr = BuffReaderReadString(pReaderArgs, &sczBundleTag); ExitOnFailure(hr, "Failed to read bundle tag of OnPlanForwardCompatibleBundle args."); args.wzBundleTag = sczBundleTag; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fPerMachine)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPerMachine)); ExitOnFailure(hr, "Failed to read per-machine of OnPlanForwardCompatibleBundle args."); - hr = BuffReaderReadString(pReader, &sczVersion); + hr = BuffReaderReadString(pReaderArgs, &sczVersion); ExitOnFailure(hr, "Failed to read version of OnPlanForwardCompatibleBundle args."); args.wzVersion = sczVersion; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fRecommendedIgnoreBundle)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fRecommendedIgnoreBundle)); ExitOnFailure(hr, "Failed to read recommended ignore bundle of OnPlanForwardCompatibleBundle args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanForwardCompatibleBundle args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanForwardCompatibleBundle results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.fIgnoreBundle)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fIgnoreBundle)); ExitOnFailure(hr, "Failed to read requested ignore bundle of OnPlanForwardCompatibleBundle results."); // Callback. @@ -3844,7 +3719,8 @@ static HRESULT OnPlanForwardCompatibleBundle( static HRESULT OnPlanMsiPackage( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3854,40 +3730,37 @@ static HRESULT OnPlanMsiPackage( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanMsiPackage args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnPlanMsiPackage args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fExecute)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fExecute)); ExitOnFailure(hr, "Failed to read execute of OnPlanMsiPackage args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.action)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.action)); ExitOnFailure(hr, "Failed to read action of OnPlanMsiPackage args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendedFileVersioning)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedFileVersioning)); ExitOnFailure(hr, "Failed to read recommended file versioning of OnPlanMsiPackage args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanMsiPackage args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanMsiPackage results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.actionMsiProperty)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.actionMsiProperty)); ExitOnFailure(hr, "Failed to read action msi property of OnPlanMsiPackage results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.uiLevel)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.uiLevel)); ExitOnFailure(hr, "Failed to read UI level of OnPlanMsiPackage results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.fDisableExternalUiHandler)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fDisableExternalUiHandler)); ExitOnFailure(hr, "Failed to read disable external UI handler of OnPlanMsiPackage results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.fileVersioning)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fileVersioning)); ExitOnFailure(hr, "Failed to read file versioning of OnPlanMsiPackage results."); // Callback. @@ -3927,7 +3800,8 @@ static HRESULT OnPlanMsiPackage( static HRESULT OnPlannedCompatiblePackage( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3938,27 +3812,24 @@ static HRESULT OnPlannedCompatiblePackage( LPWSTR sczCompatiblePackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlannedCompatiblePackage args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnPlannedCompatiblePackage args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadString(pReader, &sczCompatiblePackageId); + hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageId); ExitOnFailure(hr, "Failed to read compatible package id of OnPlannedCompatiblePackage args."); args.wzCompatiblePackageId = sczCompatiblePackageId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fRemove)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fRemove)); ExitOnFailure(hr, "Failed to read remove of OnPlannedCompatiblePackage args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlannedCompatiblePackage args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlannedCompatiblePackage results."); // Callback. @@ -3984,7 +3855,8 @@ static HRESULT OnPlannedCompatiblePackage( static HRESULT OnPlannedPackage( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -3994,31 +3866,28 @@ static HRESULT OnPlannedPackage( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlannedPackage args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnPlannedPackage args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.execute)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.execute)); ExitOnFailure(hr, "Failed to read execute of OnPlannedPackage args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.rollback)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.rollback)); ExitOnFailure(hr, "Failed to read rollback of OnPlannedPackage args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fPlannedCache)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPlannedCache)); ExitOnFailure(hr, "Failed to read planned cache of OnPlannedPackage args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fPlannedUncache)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPlannedUncache)); ExitOnFailure(hr, "Failed to read planned uncache of OnPlannedPackage args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlannedPackage args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlannedPackage results."); // Callback. @@ -4043,7 +3912,8 @@ static HRESULT OnPlannedPackage( static HRESULT OnPlanPackageBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4053,43 +3923,40 @@ static HRESULT OnPlanPackageBegin( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanPackageBegin args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnPlanPackageBegin args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.state)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.state)); ExitOnFailure(hr, "Failed to read state of OnPlanPackageBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fCached)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fCached)); ExitOnFailure(hr, "Failed to read cached of OnPlanPackageBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.installCondition)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.installCondition)); ExitOnFailure(hr, "Failed to read install condition of OnPlanPackageBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.repairCondition)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.repairCondition)); ExitOnFailure(hr, "Failed to read repair condition of OnPlanPackageBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendedState)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedState)); ExitOnFailure(hr, "Failed to read recommended state of OnPlanPackageBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendedCacheType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedCacheType)); ExitOnFailure(hr, "Failed to read recommended cache type of OnPlanPackageBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanPackageBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanPackageBegin results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.requestedState)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedState)); ExitOnFailure(hr, "Failed to read requested state of OnPlanPackageBegin results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.requestedCacheType)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedCacheType)); ExitOnFailure(hr, "Failed to read requested cache type of OnPlanPackageBegin results."); // Callback. @@ -4123,7 +3990,8 @@ static HRESULT OnPlanPackageBegin( static HRESULT OnPlanPackageComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4133,25 +4001,22 @@ static HRESULT OnPlanPackageComplete( LPWSTR sczPackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanPackageComplete args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnPlanPackageComplete args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnPlanPackageComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.requested)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.requested)); ExitOnFailure(hr, "Failed to read requested of OnPlanPackageComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanPackageComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanPackageComplete results."); // Callback. @@ -4176,7 +4041,8 @@ static HRESULT OnPlanPackageComplete( static HRESULT OnPlanRelatedBundle( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4186,25 +4052,22 @@ static HRESULT OnPlanRelatedBundle( LPWSTR sczBundleId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanRelatedBundle args."); - hr = BuffReaderReadString(pReader, &sczBundleId); + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); ExitOnFailure(hr, "Failed to read package id of OnPlanRelatedBundle args."); args.wzBundleId = sczBundleId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendedState)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedState)); ExitOnFailure(hr, "Failed to read recommended state of OnPlanRelatedBundle args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanRelatedBundle args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanRelatedBundle results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.requestedState)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedState)); ExitOnFailure(hr, "Failed to read requested state of OnPlanRelatedBundle results."); // Callback. @@ -4235,7 +4098,8 @@ static HRESULT OnPlanRelatedBundle( static HRESULT OnPlanRelatedBundleType( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4245,25 +4109,22 @@ static HRESULT OnPlanRelatedBundleType( LPWSTR sczBundleId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanRelatedBundleType args."); - hr = BuffReaderReadString(pReader, &sczBundleId); + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); ExitOnFailure(hr, "Failed to read package id of OnPlanRelatedBundleType args."); args.wzBundleId = sczBundleId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendedType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedType)); ExitOnFailure(hr, "Failed to read recommended type of OnPlanRelatedBundleType args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanRelatedBundleType args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanRelatedBundleType results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.requestedType)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedType)); ExitOnFailure(hr, "Failed to read requested type of OnPlanRelatedBundleType results."); // Callback. @@ -4294,7 +4155,8 @@ static HRESULT OnPlanRelatedBundleType( static HRESULT OnPlanRestoreRelatedBundle( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4304,25 +4166,22 @@ static HRESULT OnPlanRestoreRelatedBundle( LPWSTR sczBundleId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanRestoreRelatedBundle args."); - hr = BuffReaderReadString(pReader, &sczBundleId); + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); ExitOnFailure(hr, "Failed to read package id of OnPlanRestoreRelatedBundle args."); args.wzBundleId = sczBundleId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendedState)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedState)); ExitOnFailure(hr, "Failed to read recommended state of OnPlanRestoreRelatedBundle args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanRestoreRelatedBundle args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanRestoreRelatedBundle results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.requestedState)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedState)); ExitOnFailure(hr, "Failed to read requested state of OnPlanRestoreRelatedBundle results."); // Callback. @@ -4353,7 +4212,8 @@ static HRESULT OnPlanRestoreRelatedBundle( static HRESULT OnPlanRollbackBoundary( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4363,25 +4223,22 @@ static HRESULT OnPlanRollbackBoundary( LPWSTR sczRollbackBoundaryId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanRollbackBoundary args."); - hr = BuffReaderReadString(pReader, &sczRollbackBoundaryId); + hr = BuffReaderReadString(pReaderArgs, &sczRollbackBoundaryId); ExitOnFailure(hr, "Failed to read rollback boundary id of OnPlanRollbackBoundary args."); args.wzRollbackBoundaryId = sczRollbackBoundaryId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fRecommendedTransaction)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fRecommendedTransaction)); ExitOnFailure(hr, "Failed to read recommended transaction of OnPlanRollbackBoundary args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanRollbackBoundary args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanRollbackBoundary results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.fTransaction)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fTransaction)); ExitOnFailure(hr, "Failed to read transaction of OnPlanRollbackBoundary results."); // Callback. @@ -4412,7 +4269,8 @@ static HRESULT OnPlanRollbackBoundary( static HRESULT OnPlanPatchTarget( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4423,30 +4281,27 @@ static HRESULT OnPlanPatchTarget( LPWSTR sczProductCode = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanPatchTarget args."); - hr = BuffReaderReadString(pReader, &sczPackageId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); ExitOnFailure(hr, "Failed to read package id of OnPlanPatchTarget args."); args.wzPackageId = sczPackageId; - hr = BuffReaderReadString(pReader, &sczProductCode); + hr = BuffReaderReadString(pReaderArgs, &sczProductCode); ExitOnFailure(hr, "Failed to read product code of OnPlanPatchTarget args."); args.wzProductCode = sczProductCode; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendedState)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedState)); ExitOnFailure(hr, "Failed to read recommended state transaction of OnPlanPatchTarget args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnPlanPatchTarget args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanPatchTarget results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.requestedState)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedState)); ExitOnFailure(hr, "Failed to read requested state of OnPlanPatchTarget results."); // Callback. @@ -4478,7 +4333,8 @@ static HRESULT OnPlanPatchTarget( static HRESULT OnProgress( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4487,20 +4343,17 @@ static HRESULT OnProgress( BA_ONPROGRESS_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnProgress args."); - hr = BuffReaderReadNumber(pReader, &args.dwProgressPercentage); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwProgressPercentage); ExitOnFailure(hr, "Failed to read progress of OnProgress args."); - hr = BuffReaderReadNumber(pReader, &args.dwOverallPercentage); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage); ExitOnFailure(hr, "Failed to read overall progress of OnProgress args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnProgress args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnProgress results."); // Callback. @@ -4527,7 +4380,8 @@ static HRESULT OnProgress( static HRESULT OnRegisterBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4536,20 +4390,17 @@ static HRESULT OnRegisterBegin( BA_ONREGISTERBEGIN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnRegisterBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendedRegistrationType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedRegistrationType)); ExitOnFailure(hr, "Failed to read recommended registration type of OnRegisterBegin args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnRegisterBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnRegisterBegin results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.registrationType)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.registrationType)); ExitOnFailure(hr, "Failed to read registration type of OnRegisterBegin results."); // Callback. @@ -4579,7 +4430,8 @@ static HRESULT OnRegisterBegin( static HRESULT OnRegisterComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4588,17 +4440,14 @@ static HRESULT OnRegisterComplete( BA_ONREGISTERCOMPLETE_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnRegisterComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnRegisterComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnRegisterComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnRegisterComplete results."); // Callback. @@ -4622,7 +4471,8 @@ static HRESULT OnRegisterComplete( static HRESULT OnRollbackMsiTransactionBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4632,19 +4482,16 @@ static HRESULT OnRollbackMsiTransactionBegin( LPWSTR sczTransactionId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnRollbackMsiTransactionBegin args."); - hr = BuffReaderReadString(pReader, &sczTransactionId); + hr = BuffReaderReadString(pReaderArgs, &sczTransactionId); ExitOnFailure(hr, "Failed to read transaction id of OnRollbackMsiTransactionBegin args."); args.wzTransactionId = sczTransactionId; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnRollbackMsiTransactionBegin args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnRollbackMsiTransactionBegin results."); // Callback. @@ -4669,7 +4516,8 @@ static HRESULT OnRollbackMsiTransactionBegin( static HRESULT OnRollbackMsiTransactionComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4679,31 +4527,28 @@ static HRESULT OnRollbackMsiTransactionComplete( LPWSTR sczTransactionId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnRollbackMsiTransactionComplete args."); - hr = BuffReaderReadString(pReader, &sczTransactionId); + hr = BuffReaderReadString(pReaderArgs, &sczTransactionId); ExitOnFailure(hr, "Failed to read transaction id of OnRollbackMsiTransactionComplete args."); args.wzTransactionId = sczTransactionId; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnRollbackMsiTransactionComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.restart)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.restart)); ExitOnFailure(hr, "Failed to read restart of OnRollbackMsiTransactionComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendation)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); ExitOnFailure(hr, "Failed to read recommendation of OnRollbackMsiTransactionComplete args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnRollbackMsiTransactionComplete args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnRollbackMsiTransactionComplete results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnRollbackMsiTransactionComplete results."); // Callback. @@ -4731,7 +4576,8 @@ static HRESULT OnRollbackMsiTransactionComplete( static HRESULT OnShutdown( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4740,17 +4586,14 @@ static HRESULT OnShutdown( BA_ONSHUTDOWN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnShutdown args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnShutdown args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnShutdown results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnShutdown results."); // Callback. @@ -4777,7 +4620,8 @@ static HRESULT OnShutdown( static HRESULT OnStartup( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4786,14 +4630,11 @@ static HRESULT OnStartup( BA_ONSTARTUP_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnStartup args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - BalExitOnRootFailure(hr, "OnStartup args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnStartup results."); // Callback. @@ -4817,7 +4658,8 @@ static HRESULT OnStartup( static HRESULT OnSystemRestorePointBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4826,11 +4668,11 @@ static HRESULT OnSystemRestorePointBegin( BA_ONSYSTEMRESTOREPOINTBEGIN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnSystemRestorePointBegin args."); // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnSystemRestorePointBegin results."); // Callback. @@ -4854,7 +4696,8 @@ static HRESULT OnSystemRestorePointBegin( static HRESULT OnSystemRestorePointComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4863,14 +4706,14 @@ static HRESULT OnSystemRestorePointComplete( BA_ONSYSTEMRESTOREPOINTCOMPLETE_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnSystemRestorePointComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnSystemRestorePointComplete args."); // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnSystemRestorePointComplete results."); // Callback. @@ -4894,7 +4737,8 @@ static HRESULT OnSystemRestorePointComplete( static HRESULT OnUnregisterBegin( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4903,17 +4747,17 @@ static HRESULT OnUnregisterBegin( BA_ONUNREGISTERBEGIN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnUnregisterBegin args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.recommendedRegistrationType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedRegistrationType)); ExitOnFailure(hr, "Failed to read recommended registration type of OnUnregisterBegin args."); // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnUnregisterBegin results."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.registrationType)); + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.registrationType)); ExitOnFailure(hr, "Failed to read registration type of OnUnregisterBegin results."); // Callback. @@ -4940,7 +4784,8 @@ static HRESULT OnUnregisterBegin( static HRESULT OnUnregisterComplete( __in IBootstrapperApplication* pApplication, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -4949,14 +4794,14 @@ static HRESULT OnUnregisterComplete( BA_ONUNREGISTERCOMPLETE_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of OnUnregisterComplete args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hrStatus)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); ExitOnFailure(hr, "Failed to read status of OnUnregisterComplete args."); // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnUnregisterComplete results."); // Callback. @@ -4978,6 +4823,40 @@ static HRESULT OnUnregisterComplete( return hr; } +static HRESULT ParseArgsAndResults( + __in_bcount(cbData) LPCBYTE pbData, + __in SIZE_T cbData, + __in BUFF_READER* pBufferArgs, + __in BUFF_READER* pBufferResults +) +{ + HRESULT hr = S_OK; + SIZE_T iData = 0; + DWORD dw = 0; + + // Get the args reader size and point to the data just after the size. + hr = BuffReadNumber(pbData, cbData, &iData, &dw); + ExitOnFailure(hr, "Failed to parse size of args"); + + pBufferArgs->pbData = pbData + iData; + pBufferArgs->cbData = dw; + pBufferArgs->iBuffer = 0; + + // Get the results reader size and point to the data just after the size. + hr = ::SIZETAdd(iData, dw, &iData); + ExitOnFailure(hr, "Failed to advance index beyond args"); + + hr = BuffReadNumber(pbData, cbData, &iData, &dw); + ExitOnFailure(hr, "Failed to parse size of results"); + + pBufferResults->pbData = pbData + iData; + pBufferResults->cbData = dw; + pBufferResults->iBuffer = 0; + +LExit: + return hr; +} + static HRESULT ProcessMessage( __in PIPE_RPC_HANDLE* phRpcPipe, __in IBootstrapperApplication* pApplication, @@ -4988,358 +4867,363 @@ static HRESULT ProcessMessage( ) { HRESULT hr = S_OK; - BUFF_READER reader = { pbData, cbData, 0 }; - BUFF_BUFFER buffer = { }; + BUFF_READER readerArgs = { }; + BUFF_READER readerResults = { }; + BUFF_BUFFER bufferResponse = { }; - switch (messageType) + hr = ParseArgsAndResults(pbData, cbData, &readerArgs, &readerResults); + if (SUCCEEDED(hr)) { - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCREATE: - hr = OnCreate(pApplication, pEngine, &reader, &buffer); - break; + switch (messageType) + { + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCREATE: + hr = OnCreate(pApplication, pEngine, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDESTROY: - hr = OnDestroy(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDESTROY: + hr = OnDestroy(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP: - hr = OnStartup(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP: + hr = OnStartup(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN: - hr = OnShutdown(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN: + hr = OnShutdown(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN: - hr = OnDetectBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN: + hr = OnDetectBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE: - hr = OnDetectComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE: + hr = OnDetectComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE: - hr = OnDetectForwardCompatibleBundle(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE: + hr = OnDetectForwardCompatibleBundle(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE: - hr = OnDetectMsiFeature(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE: + hr = OnDetectMsiFeature(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE: - hr = OnDetectRelatedBundle(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE: + hr = OnDetectRelatedBundle(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN: - hr = OnDetectPackageBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN: + hr = OnDetectPackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE: - hr = OnDetectPackageComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE: + hr = OnDetectPackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE: - hr = OnDetectRelatedMsiPackage(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE: + hr = OnDetectRelatedMsiPackage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET: - hr = OnDetectPatchTarget(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET: + hr = OnDetectPatchTarget(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN: - hr = OnDetectUpdateBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN: + hr = OnDetectUpdateBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE: - hr = OnDetectUpdate(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE: + hr = OnDetectUpdate(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE: - hr = OnDetectUpdateComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE: + hr = OnDetectUpdateComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN: - hr = OnPlanBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN: + hr = OnPlanBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE: - hr = OnPlanComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE: + hr = OnPlanComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE: - hr = OnPlanMsiFeature(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE: + hr = OnPlanMsiFeature(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN: - hr = OnPlanPackageBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN: + hr = OnPlanPackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE: - hr = OnPlanPackageComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE: + hr = OnPlanPackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET: - hr = OnPlanPatchTarget(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET: + hr = OnPlanPatchTarget(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE: - hr = OnPlanRelatedBundle(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE: + hr = OnPlanRelatedBundle(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN: - hr = OnApplyBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN: + hr = OnApplyBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN: - hr = OnElevateBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN: + hr = OnElevateBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE: - hr = OnElevateComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE: + hr = OnElevateComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS: - hr = OnProgress(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS: + hr = OnProgress(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR: - hr = OnError(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR: + hr = OnError(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN: - hr = OnRegisterBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN: + hr = OnRegisterBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE: - hr = OnRegisterComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE: + hr = OnRegisterComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN: - hr = OnCacheBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN: + hr = OnCacheBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN: - hr = OnCachePackageBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN: + hr = OnCachePackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN: - hr = OnCacheAcquireBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN: + hr = OnCacheAcquireBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS: - hr = OnCacheAcquireProgress(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS: + hr = OnCacheAcquireProgress(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING: - hr = OnCacheAcquireResolving(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING: + hr = OnCacheAcquireResolving(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE: - hr = OnCacheAcquireComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE: + hr = OnCacheAcquireComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN: - hr = OnCacheVerifyBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN: + hr = OnCacheVerifyBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE: - hr = OnCacheVerifyComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE: + hr = OnCacheVerifyComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE: - hr = OnCachePackageComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE: + hr = OnCachePackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE: - hr = OnCacheComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE: + hr = OnCacheComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN: - hr = OnExecuteBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN: + hr = OnExecuteBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN: - hr = OnExecutePackageBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN: + hr = OnExecutePackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET: - hr = OnExecutePatchTarget(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET: + hr = OnExecutePatchTarget(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS: - hr = OnExecuteProgress(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS: + hr = OnExecuteProgress(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE: - hr = OnExecuteMsiMessage(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE: + hr = OnExecuteMsiMessage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE: - hr = OnExecuteFilesInUse(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE: + hr = OnExecuteFilesInUse(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE: - hr = OnExecutePackageComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE: + hr = OnExecutePackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE: - hr = OnExecuteComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE: + hr = OnExecuteComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN: - hr = OnUnregisterBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN: + hr = OnUnregisterBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE: - hr = OnUnregisterComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE: + hr = OnUnregisterComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE: - hr = OnApplyComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE: + hr = OnApplyComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN: - hr = OnLaunchApprovedExeBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN: + hr = OnLaunchApprovedExeBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE: - hr = OnLaunchApprovedExeComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE: + hr = OnLaunchApprovedExeComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE: - hr = OnPlanMsiPackage(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE: + hr = OnPlanMsiPackage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN: - hr = OnBeginMsiTransactionBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN: + hr = OnBeginMsiTransactionBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE: - hr = OnBeginMsiTransactionComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE: + hr = OnBeginMsiTransactionComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN: - hr = OnCommitMsiTransactionBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN: + hr = OnCommitMsiTransactionBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE: - hr = OnCommitMsiTransactionComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE: + hr = OnCommitMsiTransactionComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN: - hr = OnRollbackMsiTransactionBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN: + hr = OnRollbackMsiTransactionBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE: - hr = OnRollbackMsiTransactionComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE: + hr = OnRollbackMsiTransactionComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN: - hr = OnPauseAutomaticUpdatesBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN: + hr = OnPauseAutomaticUpdatesBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE: - hr = OnPauseAutomaticUpdatesComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE: + hr = OnPauseAutomaticUpdatesComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN: - hr = OnSystemRestorePointBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN: + hr = OnSystemRestorePointBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE: - hr = OnSystemRestorePointComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE: + hr = OnSystemRestorePointComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE: - hr = OnPlannedPackage(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE: + hr = OnPlannedPackage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE: - hr = OnPlanForwardCompatibleBundle(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE: + hr = OnPlanForwardCompatibleBundle(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS: - hr = OnCacheVerifyProgress(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS: + hr = OnCacheVerifyProgress(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN: - hr = OnCacheContainerOrPayloadVerifyBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN: + hr = OnCacheContainerOrPayloadVerifyBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE: - hr = OnCacheContainerOrPayloadVerifyComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE: + hr = OnCacheContainerOrPayloadVerifyComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS: - hr = OnCacheContainerOrPayloadVerifyProgress(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS: + hr = OnCacheContainerOrPayloadVerifyProgress(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN: - hr = OnCachePayloadExtractBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN: + hr = OnCachePayloadExtractBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE: - hr = OnCachePayloadExtractComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE: + hr = OnCachePayloadExtractComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS: - hr = OnCachePayloadExtractProgress(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS: + hr = OnCachePayloadExtractProgress(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY: - hr = OnPlanRollbackBoundary(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY: + hr = OnPlanRollbackBoundary(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE: - hr = OnDetectCompatibleMsiPackage(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE: + hr = OnDetectCompatibleMsiPackage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN: - hr = OnPlanCompatibleMsiPackageBegin(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN: + hr = OnPlanCompatibleMsiPackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE: - hr = OnPlanCompatibleMsiPackageComplete(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE: + hr = OnPlanCompatibleMsiPackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE: - hr = OnPlannedCompatiblePackage(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE: + hr = OnPlannedCompatiblePackage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE: - hr = OnPlanRestoreRelatedBundle(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE: + hr = OnPlanRestoreRelatedBundle(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE: - hr = OnPlanRelatedBundleType(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE: + hr = OnPlanRelatedBundleType(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE: - hr = OnApplyDowngrade(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE: + hr = OnApplyDowngrade(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL: - hr = OnExecuteProcessCancel(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL: + hr = OnExecuteProcessCancel(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE: - hr = OnDetectRelatedBundlePackage(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE: + hr = OnDetectRelatedBundlePackage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE: - hr = OnCachePackageNonVitalValidationFailure(pApplication, &reader, &buffer); - break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE: + hr = OnCachePackageNonVitalValidationFailure(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; - default: - hr = E_NOTIMPL; - break; - // BalExitWithRootFailure(hr, E_NOTIMPL, "Unknown message type %d sent to bootstrapper application.", messageType) + default: + hr = E_NOTIMPL; + break; + // BalExitWithRootFailure(hr, E_NOTIMPL, "Unknown message type %d sent to bootstrapper application.", messageType) + } } - hr = PipeRpcResponse(phRpcPipe, messageType, hr, buffer.pbData, buffer.cbData); + hr = PipeRpcResponse(phRpcPipe, messageType, hr, bufferResponse.pbData, bufferResponse.cbData); BalExitOnFailure(hr, "Failed to send bootstrapper application callback result to engine."); LExit: - ReleaseBuffer(buffer); + ReleaseBuffer(bufferResponse); return hr; } diff --git a/src/burn/engine/bacallback.cpp b/src/burn/engine/bacallback.cpp index e8e654622..8993e0209 100644 --- a/src/burn/engine/bacallback.cpp +++ b/src/burn/engine/bacallback.cpp @@ -14,15 +14,22 @@ static HRESULT FilterExecuteResult( static HRESULT SendBAMessage( __in BURN_USER_EXPERIENCE* pUserExperience, __in BOOTSTRAPPER_APPLICATION_MESSAGE message, - __in BUFF_BUFFER* pBuffer, + __in BUFF_BUFFER* pBufferArgs, + __in BUFF_BUFFER* pBufferResults, __in PIPE_RPC_RESULT* pResult ); static HRESULT SendBAMessageFromInactiveEngine( __in BURN_USER_EXPERIENCE* pUserExperience, __in BOOTSTRAPPER_APPLICATION_MESSAGE message, - __in BUFF_BUFFER* pBuffer, + __in BUFF_BUFFER* pBufferArgs, + __in BUFF_BUFFER* pBufferResults, __in PIPE_RPC_RESULT* pResult ); +static HRESULT CombineArgsAndResults( + __in BUFF_BUFFER* pBufferArgs, + __in BUFF_BUFFER* pBufferResults, + __in BUFF_BUFFER* pBufferCombined + ); // function definitions @@ -34,8 +41,9 @@ EXTERN_C HRESULT BACallbackOnApplyBegin( HRESULT hr = S_OK; BA_ONAPPLYBEGIN_ARGS args = { }; BA_ONAPPLYBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -45,24 +53,18 @@ EXTERN_C HRESULT BACallbackOnApplyBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnApplyBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwPhaseCount); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwPhaseCount); ExitOnFailure(hr, "Failed to write phase count of OnApplyBegin args command."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnApplyBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnApplyBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnApplyBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnApplyBegin failed."); if (S_FALSE == hr) @@ -71,10 +73,10 @@ EXTERN_C HRESULT BACallbackOnApplyBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnApplyBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnApplyBegin result."); if (results.fCancel) @@ -83,8 +85,9 @@ EXTERN_C HRESULT BACallbackOnApplyBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -99,8 +102,9 @@ EXTERN_C HRESULT BACallbackOnApplyComplete( HRESULT hr = S_OK; BA_ONAPPLYCOMPLETE_ARGS args = { }; BA_ONAPPLYCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -113,33 +117,27 @@ EXTERN_C HRESULT BACallbackOnApplyComplete( results.action = *pAction; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnApplyComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnApplyComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.restart); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.restart); ExitOnFailure(hr, "Failed to write restart of OnApplyComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendation); ExitOnFailure(hr, "Failed to write recommended action of OnApplyComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnApplyComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnApplyComplete results."); - hr = BuffWriteNumberToBuffer(&buffer, results.action); + hr = BuffWriteNumberToBuffer(&bufferResults, results.action); ExitOnFailure(hr, "Failed to write default action of OnApplyComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnApplyComplete results."); - // Callback. - hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE, &buffer, &result); + hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnApplyComplete failed."); if (S_FALSE == hr) @@ -148,17 +146,18 @@ EXTERN_C HRESULT BACallbackOnApplyComplete( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnApplyComplete result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.action)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnApplyComplete result."); *pAction = results.action; LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -171,8 +170,9 @@ EXTERN_C HRESULT BACallbackOnApplyDowngrade( HRESULT hr = S_OK; BA_ONAPPLYDOWNGRADE_ARGS args = { }; BA_ONAPPLYDOWNGRADE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -183,27 +183,21 @@ EXTERN_C HRESULT BACallbackOnApplyDowngrade( results.hrStatus = *phrStatus; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnApplyDowngrade args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrRecommended); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrRecommended); ExitOnFailure(hr, "Failed to write recommended status of OnApplyDowngrade args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnApplyDowngrade args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnApplyDowngrade results."); - hr = BuffWriteNumberToBuffer(&buffer, results.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferResults, results.hrStatus); ExitOnFailure(hr, "Failed to write default action of OnApplyDowngrade results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnApplyDowngrade results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnApplyDowngrade failed."); if (S_FALSE == hr) @@ -212,17 +206,18 @@ EXTERN_C HRESULT BACallbackOnApplyDowngrade( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnApplyDowngrade result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.hrStatus)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.hrStatus)); ExitOnFailure(hr, "Failed to read action of OnApplyDowngrade result."); *phrStatus = results.hrStatus; LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -235,8 +230,9 @@ EXTERN_C HRESULT BACallbackOnBeginMsiTransactionBegin( HRESULT hr = S_OK; BA_ONBEGINMSITRANSACTIONBEGIN_ARGS args = { }; BA_ONBEGINMSITRANSACTIONBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -246,24 +242,18 @@ EXTERN_C HRESULT BACallbackOnBeginMsiTransactionBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnBeginMsiTransactionBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzTransactionId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzTransactionId); ExitOnFailure(hr, "Failed to write recommended status of OnBeginMsiTransactionBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnBeginMsiTransactionBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnBeginMsiTransactionBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnBeginMsiTransactionBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnBeginMsiTransactionBegin failed."); if (S_FALSE == hr) @@ -272,10 +262,10 @@ EXTERN_C HRESULT BACallbackOnBeginMsiTransactionBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnBeginMsiTransactionBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read action of OnBeginMsiTransactionBegin result."); if (results.fCancel) @@ -284,8 +274,9 @@ EXTERN_C HRESULT BACallbackOnBeginMsiTransactionBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -299,8 +290,9 @@ EXTERN_C HRESULT BACallbackOnBeginMsiTransactionComplete( HRESULT hr = S_OK; BA_ONBEGINMSITRANSACTIONCOMPLETE_ARGS args = { }; BA_ONBEGINMSITRANSACTIONCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -310,27 +302,21 @@ EXTERN_C HRESULT BACallbackOnBeginMsiTransactionComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnBeginMsiTransactionComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzTransactionId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzTransactionId); ExitOnFailure(hr, "Failed to write recommended status of OnBeginMsiTransactionComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnBeginMsiTransactionComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnBeginMsiTransactionComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnBeginMsiTransactionComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnBeginMsiTransactionComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnBeginMsiTransactionComplete failed."); if (S_FALSE == hr) @@ -339,8 +325,9 @@ EXTERN_C HRESULT BACallbackOnBeginMsiTransactionComplete( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -358,8 +345,9 @@ EXTERN_C HRESULT BACallbackOnCacheAcquireBegin( HRESULT hr = S_OK; BA_ONCACHEACQUIREBEGIN_ARGS args = { }; BA_ONCACHEACQUIREBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; *pCacheOperation = BOOTSTRAPPER_CACHE_OPERATION_NONE; @@ -377,42 +365,36 @@ EXTERN_C HRESULT BACallbackOnCacheAcquireBegin( results.action = *pCacheOperation; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheAcquireBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageOrContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); ExitOnFailure(hr, "Failed to write package or container of OnCacheAcquireBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCacheAcquireBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzSource); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzSource); ExitOnFailure(hr, "Failed to write source of OnCacheAcquireBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzDownloadUrl); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzDownloadUrl); ExitOnFailure(hr, "Failed to write download url of OnCacheAcquireBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadContainerId); ExitOnFailure(hr, "Failed to write payload container id of OnCacheAcquireBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendation); ExitOnFailure(hr, "Failed to write recommendation of OnCacheAcquireBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheAcquireBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheAcquireBegin results."); - hr = BuffWriteNumberToBuffer(&buffer, results.action); + hr = BuffWriteNumberToBuffer(&bufferResults, results.action); ExitOnFailure(hr, "Failed to write action of OnCacheAcquireBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheAcquireBegin results."); - // Callback. - hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, &buffer, &result); + hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCacheAcquireBegin failed."); if (S_FALSE == hr) @@ -421,13 +403,13 @@ EXTERN_C HRESULT BACallbackOnCacheAcquireBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheAcquireBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnCacheAcquireBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.action)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnCacheAcquireBegin result."); if (results.fCancel) @@ -447,8 +429,9 @@ EXTERN_C HRESULT BACallbackOnCacheAcquireBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -464,8 +447,9 @@ EXTERN_C HRESULT BACallbackOnCacheAcquireComplete( HRESULT hr = S_OK; BA_ONCACHEACQUIRECOMPLETE_ARGS args = { }; BA_ONCACHEACQUIRECOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -479,36 +463,30 @@ EXTERN_C HRESULT BACallbackOnCacheAcquireComplete( results.action = args.recommendation; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheAcquireComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageOrContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); ExitOnFailure(hr, "Failed to write package or container of OnCacheAcquireComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCacheAcquireComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnCacheAcquireComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendation); ExitOnFailure(hr, "Failed to write recommendation of OnCacheAcquireComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheAcquireComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheAcquireComplete results."); - hr = BuffWriteNumberToBuffer(&buffer, results.action); + hr = BuffWriteNumberToBuffer(&bufferResults, results.action); ExitOnFailure(hr, "Failed to write action of OnCacheAcquireComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheAcquireComplete results."); - // Callback. - hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, &buffer, &result); + hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCacheAcquireComplete failed."); if (S_FALSE == hr) @@ -517,10 +495,10 @@ EXTERN_C HRESULT BACallbackOnCacheAcquireComplete( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheAcquireComplete result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.action)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnCacheAcquireComplete result."); if (FAILED(hrStatus)) @@ -529,8 +507,9 @@ EXTERN_C HRESULT BACallbackOnCacheAcquireComplete( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -547,8 +526,9 @@ EXTERN_C BAAPI BACallbackOnCacheAcquireProgress( HRESULT hr = S_OK; BA_ONCACHEACQUIREPROGRESS_ARGS args = { }; BA_ONCACHEACQUIREPROGRESS_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -562,36 +542,30 @@ EXTERN_C BAAPI BACallbackOnCacheAcquireProgress( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheAcquireProgress args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageOrContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); ExitOnFailure(hr, "Failed to write package or container of OnCacheAcquireProgress args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCacheAcquireProgress args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.dw64Progress); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.dw64Progress); ExitOnFailure(hr, "Failed to write progress of OnCacheAcquireProgress args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.dw64Total); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.dw64Total); ExitOnFailure(hr, "Failed to write total progress of OnCacheAcquireProgress args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwOverallPercentage); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwOverallPercentage); ExitOnFailure(hr, "Failed to write overall percentage of OnCacheAcquireProgress args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheAcquireProgress args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheAcquireProgress results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheAcquireProgress results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCacheAcquireProgress failed."); if (S_FALSE == hr) @@ -600,10 +574,10 @@ EXTERN_C BAAPI BACallbackOnCacheAcquireProgress( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheAcquireProgress result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnCacheAcquireProgress result."); if (results.fCancel) @@ -612,8 +586,9 @@ EXTERN_C BAAPI BACallbackOnCacheAcquireProgress( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -634,8 +609,9 @@ EXTERN_C HRESULT BACallbackOnCacheAcquireResolving( HRESULT hr = S_OK; BA_ONCACHEACQUIRERESOLVING_ARGS args = { }; BA_ONCACHEACQUIRERESOLVING_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -654,57 +630,51 @@ EXTERN_C HRESULT BACallbackOnCacheAcquireResolving( results.action = *pCacheOperation; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheAcquireResolving args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageOrContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); ExitOnFailure(hr, "Failed to write package or container of OnCacheAcquireResolving args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCacheAcquireResolving args."); - hr = BuffWriteNumberToBuffer(&buffer, args.cSearchPaths); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cSearchPaths); ExitOnFailure(hr, "Failed to write count of search paths of OnCacheAcquireResolving args."); for (DWORD i = 0; i < args.cSearchPaths; ++i) { - hr = BuffWriteStringToBuffer(&buffer, args.rgSearchPaths[i]); + hr = BuffWriteStringToBuffer(&bufferArgs, args.rgSearchPaths[i]); ExitOnFailure(hr, "Failed to write search path[%u] of OnCacheAcquireResolving args.", i); } - hr = BuffWriteNumberToBuffer(&buffer, args.fFoundLocal); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fFoundLocal); ExitOnFailure(hr, "Failed to write found local of OnCacheAcquireResolving args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwRecommendedSearchPath); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwRecommendedSearchPath); ExitOnFailure(hr, "Failed to write recommended search path of OnCacheAcquireResolving args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzDownloadUrl); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzDownloadUrl); ExitOnFailure(hr, "Failed to write download url of OnCacheAcquireResolving args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadContainerId); ExitOnFailure(hr, "Failed to write payload container id of OnCacheAcquireResolving args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendation); ExitOnFailure(hr, "Failed to write recommendation of OnCacheAcquireResolving args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheAcquireResolving args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheAcquireResolving results."); - hr = BuffWriteNumberToBuffer(&buffer, results.dwChosenSearchPath); + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwChosenSearchPath); ExitOnFailure(hr, "Failed to write chose search path of OnCacheAcquireResolving results."); - hr = BuffWriteNumberToBuffer(&buffer, results.action); + hr = BuffWriteNumberToBuffer(&bufferResults, results.action); ExitOnFailure(hr, "Failed to write action of OnCacheAcquireResolving results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheAcquireResolving results."); - // Callback. - hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING, &buffer, &result); + hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCacheAcquireResolving failed."); if (S_FALSE == hr) @@ -713,16 +683,16 @@ EXTERN_C HRESULT BACallbackOnCacheAcquireResolving( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheAcquireResolving result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.dwChosenSearchPath); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwChosenSearchPath); ExitOnFailure(hr, "Failed to read chosen search path of OnCacheAcquireResolving result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.action)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnCacheAcquireResolving result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnCacheAcquireResolving result."); if (results.fCancel) @@ -747,8 +717,9 @@ EXTERN_C HRESULT BACallbackOnCacheAcquireResolving( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -760,8 +731,9 @@ EXTERN_C HRESULT BACallbackOnCacheBegin( HRESULT hr = S_OK; BA_ONCACHEBEGIN_ARGS args = { }; BA_ONCACHEBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -770,21 +742,15 @@ EXTERN_C HRESULT BACallbackOnCacheBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCacheBegin failed."); if (S_FALSE == hr) @@ -793,10 +759,10 @@ EXTERN_C HRESULT BACallbackOnCacheBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnCacheBegin result."); if (results.fCancel) @@ -805,8 +771,9 @@ EXTERN_C HRESULT BACallbackOnCacheBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -819,8 +786,9 @@ EXTERN_C HRESULT BACallbackOnCacheComplete( HRESULT hr = S_OK; BA_ONCACHECOMPLETE_ARGS args = { }; BA_ONCACHECOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -829,24 +797,18 @@ EXTERN_C HRESULT BACallbackOnCacheComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnCacheComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCacheComplete failed."); if (S_FALSE == hr) @@ -855,8 +817,9 @@ EXTERN_C HRESULT BACallbackOnCacheComplete( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -870,8 +833,9 @@ EXTERN_C BAAPI BACallbackOnCacheContainerOrPayloadVerifyBegin( HRESULT hr = S_OK; BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_ARGS args = { }; BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -882,27 +846,21 @@ EXTERN_C BAAPI BACallbackOnCacheContainerOrPayloadVerifyBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheContainerOrPayloadVerifyBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageOrContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); ExitOnFailure(hr, "Failed to write package or container id of OnCacheContainerOrPayloadVerifyBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCacheContainerOrPayloadVerifyBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheContainerOrPayloadVerifyBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheContainerOrPayloadVerifyBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheContainerOrPayloadVerifyBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCacheContainerOrPayloadVerifyBegin failed."); if (S_FALSE == hr) @@ -911,10 +869,10 @@ EXTERN_C BAAPI BACallbackOnCacheContainerOrPayloadVerifyBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheContainerOrPayloadVerifyBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnCacheContainerOrPayloadVerifyBegin result."); if (results.fCancel) @@ -923,8 +881,9 @@ EXTERN_C BAAPI BACallbackOnCacheContainerOrPayloadVerifyBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -939,8 +898,9 @@ EXTERN_C HRESULT BACallbackOnCacheContainerOrPayloadVerifyComplete( HRESULT hr = S_OK; BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_ARGS args = { }; BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -951,30 +911,24 @@ EXTERN_C HRESULT BACallbackOnCacheContainerOrPayloadVerifyComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheContainerOrPayloadVerifyComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageOrContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); ExitOnFailure(hr, "Failed to write package or container id of OnCacheContainerOrPayloadVerifyComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCacheContainerOrPayloadVerifyComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnCacheContainerOrPayloadVerifyComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheContainerOrPayloadVerifyComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheContainerOrPayloadVerifyComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheContainerOrPayloadVerifyComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCacheContainerOrPayloadVerifyComplete failed."); if (S_FALSE == hr) @@ -983,8 +937,9 @@ EXTERN_C HRESULT BACallbackOnCacheContainerOrPayloadVerifyComplete( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1001,8 +956,9 @@ EXTERN_C HRESULT BACallbackOnCacheContainerOrPayloadVerifyProgress( HRESULT hr = S_OK; BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_ARGS args = { }; BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -1016,36 +972,30 @@ EXTERN_C HRESULT BACallbackOnCacheContainerOrPayloadVerifyProgress( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheContainerOrPayloadVerifyProgress args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageOrContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); ExitOnFailure(hr, "Failed to write package or container id of OnCacheContainerOrPayloadVerifyProgress args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCacheContainerOrPayloadVerifyProgress args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.dw64Progress); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.dw64Progress); ExitOnFailure(hr, "Failed to write progress of OnCacheContainerOrPayloadVerifyProgress args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.dw64Total); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.dw64Total); ExitOnFailure(hr, "Failed to write total progress of OnCacheContainerOrPayloadVerifyProgress args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwOverallPercentage); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwOverallPercentage); ExitOnFailure(hr, "Failed to write overall percentage of OnCacheContainerOrPayloadVerifyProgress args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheContainerOrPayloadVerifyProgress args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheContainerOrPayloadVerifyProgress results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheContainerOrPayloadVerifyProgress results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCacheContainerOrPayloadVerifyProgress failed."); if (S_FALSE == hr) @@ -1054,10 +1004,10 @@ EXTERN_C HRESULT BACallbackOnCacheContainerOrPayloadVerifyProgress( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheContainerOrPayloadVerifyProgress result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnCacheContainerOrPayloadVerifyProgress result."); if (results.fCancel) @@ -1066,8 +1016,9 @@ EXTERN_C HRESULT BACallbackOnCacheContainerOrPayloadVerifyProgress( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1083,8 +1034,9 @@ EXTERN_C HRESULT BACallbackOnCachePackageBegin( HRESULT hr = S_OK; BA_ONCACHEPACKAGEBEGIN_ARGS args = { }; BA_ONCACHEPACKAGEBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -1097,33 +1049,27 @@ EXTERN_C HRESULT BACallbackOnCachePackageBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePackageBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnCachePackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.cCachePayloads); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cCachePayloads); ExitOnFailure(hr, "Failed to write count of cached payloads of OnCachePackageBegin args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.dw64PackageCacheSize); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.dw64PackageCacheSize); ExitOnFailure(hr, "Failed to write package cache size of OnCachePackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fVital); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fVital); ExitOnFailure(hr, "Failed to write vital of OnCachePackageBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCachePackageBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePackageBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCachePackageBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCachePackageBegin failed."); if (S_FALSE == hr) @@ -1132,10 +1078,10 @@ EXTERN_C HRESULT BACallbackOnCachePackageBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePackageBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnCachePackageBegin result."); if (results.fCancel) @@ -1144,8 +1090,9 @@ EXTERN_C HRESULT BACallbackOnCachePackageBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1160,8 +1107,9 @@ EXTERN_C HRESULT BACallbackOnCachePackageComplete( HRESULT hr = S_OK; BA_ONCACHEPACKAGECOMPLETE_ARGS args = { }; BA_ONCACHEPACKAGECOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -1174,33 +1122,27 @@ EXTERN_C HRESULT BACallbackOnCachePackageComplete( results.action = *pAction; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePackageComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnCachePackageComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnCachePackageComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendation); ExitOnFailure(hr, "Failed to write recommendation of OnCachePackageComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCachePackageComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePackageComplete results."); - hr = BuffWriteNumberToBuffer(&buffer, results.action); + hr = BuffWriteNumberToBuffer(&bufferResults, results.action); ExitOnFailure(hr, "Failed to write action of OnCachePackageComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCachePackageComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCachePackageComplete failed."); if (S_FALSE == hr) @@ -1209,10 +1151,10 @@ EXTERN_C HRESULT BACallbackOnCachePackageComplete( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePackageComplete result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.action)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read cancel of OnCachePackageComplete result."); if (FAILED(hrStatus)) @@ -1221,8 +1163,9 @@ EXTERN_C HRESULT BACallbackOnCachePackageComplete( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1237,8 +1180,9 @@ EXTERN_C HRESULT BACallbackOnCachePackageNonVitalValidationFailure( HRESULT hr = S_OK; BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_ARGS args = { }; BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -1251,33 +1195,27 @@ EXTERN_C HRESULT BACallbackOnCachePackageNonVitalValidationFailure( results.action = *pAction; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePackageNonVitalValidationFailure args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnCachePackageNonVitalValidationFailure args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnCachePackageNonVitalValidationFailure args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendation); ExitOnFailure(hr, "Failed to write recommendation of OnCachePackageNonVitalValidationFailure args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCachePackageNonVitalValidationFailure args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePackageNonVitalValidationFailure results."); - hr = BuffWriteNumberToBuffer(&buffer, results.action); + hr = BuffWriteNumberToBuffer(&bufferResults, results.action); ExitOnFailure(hr, "Failed to write size of OnCachePackageNonVitalValidationFailure results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCachePackageNonVitalValidationFailure results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCachePackageNonVitalValidationFailure failed."); if (S_FALSE == hr) @@ -1286,10 +1224,10 @@ EXTERN_C HRESULT BACallbackOnCachePackageNonVitalValidationFailure( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePackageNonVitalValidationFailure result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.action)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read cancel of OnCachePackageNonVitalValidationFailure result."); switch (results.action) @@ -1301,8 +1239,9 @@ EXTERN_C HRESULT BACallbackOnCachePackageNonVitalValidationFailure( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1316,8 +1255,9 @@ EXTERN_C HRESULT BACallbackOnCachePayloadExtractBegin( HRESULT hr = S_OK; BA_ONCACHEPAYLOADEXTRACTBEGIN_ARGS args = { }; BA_ONCACHEPAYLOADEXTRACTBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -1328,27 +1268,21 @@ EXTERN_C HRESULT BACallbackOnCachePayloadExtractBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePayloadExtractBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzContainerId); ExitOnFailure(hr, "Failed to write container id of OnCachePayloadExtractBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCachePayloadExtractBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCachePayloadExtractBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePayloadExtractBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCachePayloadExtractBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCachePayloadExtractBegin failed."); if (S_FALSE == hr) @@ -1357,10 +1291,10 @@ EXTERN_C HRESULT BACallbackOnCachePayloadExtractBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePayloadExtractBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnCachePayloadExtractBegin result."); if (results.fCancel) @@ -1369,8 +1303,9 @@ EXTERN_C HRESULT BACallbackOnCachePayloadExtractBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1385,8 +1320,9 @@ EXTERN_C HRESULT BACallbackOnCachePayloadExtractComplete( HRESULT hr = S_OK; BA_ONCACHEPAYLOADEXTRACTCOMPLETE_ARGS args = { }; BA_ONCACHEPAYLOADEXTRACTCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -1397,30 +1333,24 @@ EXTERN_C HRESULT BACallbackOnCachePayloadExtractComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePayloadExtractComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzContainerId); ExitOnFailure(hr, "Failed to write container id of OnCachePayloadExtractComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCachePayloadExtractComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnCachePayloadExtractComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCachePayloadExtractComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePayloadExtractComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCachePayloadExtractComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCachePayloadExtractComplete failed."); if (S_FALSE == hr) @@ -1429,8 +1359,9 @@ EXTERN_C HRESULT BACallbackOnCachePayloadExtractComplete( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1447,8 +1378,9 @@ EXTERN_C HRESULT BACallbackOnCachePayloadExtractProgress( HRESULT hr = S_OK; BA_ONCACHEPAYLOADEXTRACTPROGRESS_ARGS args = { }; BA_ONCACHEPAYLOADEXTRACTPROGRESS_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -1462,36 +1394,30 @@ EXTERN_C HRESULT BACallbackOnCachePayloadExtractProgress( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePayloadExtractProgress args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzContainerId); ExitOnFailure(hr, "Failed to write container id of OnCachePayloadExtractProgress args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCachePayloadExtractProgress args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.dw64Progress); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.dw64Progress); ExitOnFailure(hr, "Failed to write progress of OnCachePayloadExtractProgress args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.dw64Total); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.dw64Total); ExitOnFailure(hr, "Failed to write total progress of OnCachePayloadExtractProgress args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwOverallPercentage); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwOverallPercentage); ExitOnFailure(hr, "Failed to write overall percentage of OnCachePayloadExtractProgress args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCachePayloadExtractProgress args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePayloadExtractProgress results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCachePayloadExtractProgress results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCachePayloadExtractProgress failed."); if (S_FALSE == hr) @@ -1500,10 +1426,10 @@ EXTERN_C HRESULT BACallbackOnCachePayloadExtractProgress( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePayloadExtractProgress result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnCachePayloadExtractProgress result."); if (results.fCancel) @@ -1512,8 +1438,9 @@ EXTERN_C HRESULT BACallbackOnCachePayloadExtractProgress( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1527,8 +1454,9 @@ EXTERN_C HRESULT BACallbackOnCacheVerifyBegin( HRESULT hr = S_OK; BA_ONCACHEVERIFYBEGIN_ARGS args = { }; BA_ONCACHEVERIFYBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -1539,27 +1467,21 @@ EXTERN_C HRESULT BACallbackOnCacheVerifyBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheVerifyBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageOrContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); ExitOnFailure(hr, "Failed to write package or container id of OnCacheVerifyBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCacheVerifyBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheVerifyBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheVerifyBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheVerifyBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCacheVerifyBegin failed."); if (S_FALSE == hr) @@ -1568,10 +1490,10 @@ EXTERN_C HRESULT BACallbackOnCacheVerifyBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheVerifyBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnCacheVerifyBegin result."); if (results.fCancel) @@ -1580,8 +1502,9 @@ EXTERN_C HRESULT BACallbackOnCacheVerifyBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1597,8 +1520,9 @@ EXTERN_C HRESULT BACallbackOnCacheVerifyComplete( HRESULT hr = S_OK; BA_ONCACHEVERIFYCOMPLETE_ARGS args = { }; BA_ONCACHEVERIFYCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -1612,36 +1536,30 @@ EXTERN_C HRESULT BACallbackOnCacheVerifyComplete( results.action = *pAction; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheVerifyComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageOrContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); ExitOnFailure(hr, "Failed to write package or container id of OnCacheVerifyComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCacheVerifyComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnCacheVerifyComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendation); ExitOnFailure(hr, "Failed to write recommendation of OnCacheVerifyComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheVerifyComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheVerifyComplete results."); - hr = BuffWriteNumberToBuffer(&buffer, results.action); + hr = BuffWriteNumberToBuffer(&bufferResults, results.action); ExitOnFailure(hr, "Failed to write action of OnCacheVerifyComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheVerifyComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCacheVerifyComplete failed."); if (S_FALSE == hr) @@ -1650,10 +1568,10 @@ EXTERN_C HRESULT BACallbackOnCacheVerifyComplete( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheVerifyComplete result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.action)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnCacheVerifyComplete result."); if (FAILED(hrStatus)) @@ -1662,8 +1580,9 @@ EXTERN_C HRESULT BACallbackOnCacheVerifyComplete( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1681,8 +1600,9 @@ EXTERN_C HRESULT BACallbackOnCacheVerifyProgress( HRESULT hr = S_OK; BA_ONCACHEVERIFYPROGRESS_ARGS args = { }; BA_ONCACHEVERIFYPROGRESS_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -1697,39 +1617,33 @@ EXTERN_C HRESULT BACallbackOnCacheVerifyProgress( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheVerifyProgress args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageOrContainerId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); ExitOnFailure(hr, "Failed to write package or container id of OnCacheVerifyProgress args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPayloadId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); ExitOnFailure(hr, "Failed to write payload id of OnCacheVerifyProgress args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.dw64Progress); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.dw64Progress); ExitOnFailure(hr, "Failed to write progress of OnCacheVerifyProgress args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.dw64Total); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.dw64Total); ExitOnFailure(hr, "Failed to write total progress of OnCacheVerifyProgress args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwOverallPercentage); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwOverallPercentage); ExitOnFailure(hr, "Failed to write overall percentage of OnCacheVerifyProgress args."); - hr = BuffWriteNumberToBuffer(&buffer, args.verifyStep); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.verifyStep); ExitOnFailure(hr, "Failed to write verify step of OnCacheVerifyProgress args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheVerifyProgress args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCacheVerifyProgress results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCacheVerifyProgress results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCacheVerifyProgress failed."); if (S_FALSE == hr) @@ -1738,10 +1652,10 @@ EXTERN_C HRESULT BACallbackOnCacheVerifyProgress( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCacheVerifyProgress result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnCacheVerifyProgress result."); if (results.fCancel) @@ -1750,8 +1664,9 @@ EXTERN_C HRESULT BACallbackOnCacheVerifyProgress( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1764,8 +1679,9 @@ EXTERN_C HRESULT BACallbackOnCommitMsiTransactionBegin( HRESULT hr = S_OK; BA_ONCOMMITMSITRANSACTIONBEGIN_ARGS args = { }; BA_ONCOMMITMSITRANSACTIONBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -1775,24 +1691,18 @@ EXTERN_C HRESULT BACallbackOnCommitMsiTransactionBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCommitMsiTransactionBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzTransactionId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzTransactionId); ExitOnFailure(hr, "Failed to write transaction id of OnCommitMsiTransactionBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCommitMsiTransactionBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCommitMsiTransactionBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCommitMsiTransactionBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCommitMsiTransactionBegin failed."); if (S_FALSE == hr) @@ -1801,10 +1711,10 @@ EXTERN_C HRESULT BACallbackOnCommitMsiTransactionBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCommitMsiTransactionBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnCommitMsiTransactionBegin result."); if (results.fCancel) @@ -1813,8 +1723,9 @@ EXTERN_C HRESULT BACallbackOnCommitMsiTransactionBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1830,8 +1741,9 @@ EXTERN_C HRESULT BACallbackOnCommitMsiTransactionComplete( HRESULT hr = S_OK; BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS args = { }; BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -1845,36 +1757,30 @@ EXTERN_C HRESULT BACallbackOnCommitMsiTransactionComplete( results.action = *pAction; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCommitMsiTransactionComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzTransactionId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzTransactionId); ExitOnFailure(hr, "Failed to write transaction id of OnCommitMsiTransactionComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnCommitMsiTransactionComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.restart); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.restart); ExitOnFailure(hr, "Failed to write restart of OnCommitMsiTransactionComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendation); ExitOnFailure(hr, "Failed to write recommendation of OnCommitMsiTransactionComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCommitMsiTransactionComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCommitMsiTransactionComplete results."); - hr = BuffWriteNumberToBuffer(&buffer, results.action); + hr = BuffWriteNumberToBuffer(&bufferResults, results.action); ExitOnFailure(hr, "Failed to write size of OnCommitMsiTransactionComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCommitMsiTransactionComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCommitMsiTransactionComplete failed."); if (S_FALSE == hr) @@ -1883,17 +1789,18 @@ EXTERN_C HRESULT BACallbackOnCommitMsiTransactionComplete( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCommitMsiTransactionComplete result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.action)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnCommitMsiTransactionComplete result."); *pAction = results.action; LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1906,8 +1813,9 @@ EXTERN_C HRESULT BACallbackOnCreate( HRESULT hr = S_OK; BA_ONCREATE_ARGS args = { }; BA_ONCREATE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -1915,57 +1823,51 @@ EXTERN_C HRESULT BACallbackOnCreate( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnCreate args."); - hr = BuffWriteNumberToBuffer(&buffer, pCommand->cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, pCommand->cbSize); ExitOnFailure(hr, "Failed to write size of OnCreate args command."); - hr = BuffWriteNumberToBuffer(&buffer, pCommand->action); + hr = BuffWriteNumberToBuffer(&bufferArgs, pCommand->action); ExitOnFailure(hr, "Failed to write action of OnCreate args command."); - hr = BuffWriteNumberToBuffer(&buffer, pCommand->display); + hr = BuffWriteNumberToBuffer(&bufferArgs, pCommand->display); ExitOnFailure(hr, "Failed to write display of OnCreate args command."); - hr = BuffWriteStringToBuffer(&buffer, pCommand->wzCommandLine); + hr = BuffWriteStringToBuffer(&bufferArgs, pCommand->wzCommandLine); ExitOnFailure(hr, "Failed to write command-line of OnCreate args command."); - hr = BuffWriteNumberToBuffer(&buffer, pCommand->nCmdShow); + hr = BuffWriteNumberToBuffer(&bufferArgs, pCommand->nCmdShow); ExitOnFailure(hr, "Failed to write show command of OnCreate args command."); - hr = BuffWriteNumberToBuffer(&buffer, pCommand->resumeType); + hr = BuffWriteNumberToBuffer(&bufferArgs, pCommand->resumeType); ExitOnFailure(hr, "Failed to write resume type of OnCreate args command."); - hr = BuffWriteNumber64ToBuffer(&buffer, reinterpret_cast(pCommand->hwndSplashScreen)); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, reinterpret_cast(pCommand->hwndSplashScreen)); ExitOnFailure(hr, "Failed to write splash screen handle of OnCreate args command."); - hr = BuffWriteNumberToBuffer(&buffer, pCommand->relationType); + hr = BuffWriteNumberToBuffer(&bufferArgs, pCommand->relationType); ExitOnFailure(hr, "Failed to write relation type of OnCreate args command."); - hr = BuffWriteNumberToBuffer(&buffer, pCommand->fPassthrough); + hr = BuffWriteNumberToBuffer(&bufferArgs, pCommand->fPassthrough); ExitOnFailure(hr, "Failed to write passthrough of OnCreate args command."); - hr = BuffWriteStringToBuffer(&buffer, pCommand->wzLayoutDirectory); + hr = BuffWriteStringToBuffer(&bufferArgs, pCommand->wzLayoutDirectory); ExitOnFailure(hr, "Failed to write layout directory of OnCreate args command."); - hr = BuffWriteStringToBuffer(&buffer, pCommand->wzBootstrapperWorkingFolder); + hr = BuffWriteStringToBuffer(&bufferArgs, pCommand->wzBootstrapperWorkingFolder); ExitOnFailure(hr, "Failed to write working folder of OnCreate args command."); - hr = BuffWriteStringToBuffer(&buffer, pCommand->wzBootstrapperApplicationDataPath); + hr = BuffWriteStringToBuffer(&bufferArgs, pCommand->wzBootstrapperApplicationDataPath); ExitOnFailure(hr, "Failed to write application data path of OnCreate args command."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCreate args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCreate results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnCreate results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCREATE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCREATE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnCreate failed."); if (S_FALSE == hr) @@ -1974,8 +1876,9 @@ EXTERN_C HRESULT BACallbackOnCreate( } LExit: - PipeFreeRpcResult(&result); - ReleaseNullBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -1988,8 +1891,9 @@ EXTERN_C HRESULT BACallbackOnDestroy( HRESULT hr = S_OK; BA_ONDESTROY_ARGS args = { }; BA_ONDESTROY_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -1998,24 +1902,18 @@ EXTERN_C HRESULT BACallbackOnDestroy( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDestroy args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fReload); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fReload); ExitOnFailure(hr, "Failed to write reload of OnDestroy args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDestroy args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDestroy results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDestroy results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDESTROY, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDESTROY, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDestroy failed."); if (S_FALSE == hr) @@ -2024,8 +1922,9 @@ EXTERN_C HRESULT BACallbackOnDestroy( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2040,8 +1939,9 @@ EXTERN_C HRESULT BACallbackOnDetectBegin( HRESULT hr = S_OK; BA_ONDETECTBEGIN_ARGS args = { }; BA_ONDETECTBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -2053,30 +1953,24 @@ EXTERN_C HRESULT BACallbackOnDetectBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.registrationType); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.registrationType); ExitOnFailure(hr, "Failed to write restart of OnDetectBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.cPackages); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cPackages); ExitOnFailure(hr, "Failed to write package count of OnDetectBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fCached); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fCached); ExitOnFailure(hr, "Failed to write cached of OnDetectBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectBegin failed."); if (S_FALSE == hr) @@ -2085,10 +1979,10 @@ EXTERN_C HRESULT BACallbackOnDetectBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnDetectBegin result."); if (results.fCancel) @@ -2097,8 +1991,9 @@ EXTERN_C HRESULT BACallbackOnDetectBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2113,8 +2008,9 @@ EXTERN_C HRESULT BACallbackOnDetectCompatibleMsiPackage( HRESULT hr = S_OK; BA_ONDETECTCOMPATIBLEMSIPACKAGE_ARGS args = { }; BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -2126,30 +2022,24 @@ EXTERN_C HRESULT BACallbackOnDetectCompatibleMsiPackage( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectCompatibleMsiPackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnDetectCompatibleMsiPackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzCompatiblePackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzCompatiblePackageId); ExitOnFailure(hr, "Failed to write compatible package id of OnDetectCompatibleMsiPackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzCompatiblePackageVersion); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzCompatiblePackageVersion); ExitOnFailure(hr, "Failed to write compatible package version of OnDetectCompatibleMsiPackage args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectCompatibleMsiPackage args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectCompatibleMsiPackage results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectCompatibleMsiPackage results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectCompatibleMsiPackage failed."); if (S_FALSE == hr) @@ -2158,10 +2048,10 @@ EXTERN_C HRESULT BACallbackOnDetectCompatibleMsiPackage( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectCompatibleMsiPackage result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnDetectCompatibleMsiPackage result."); if (results.fCancel) @@ -2170,8 +2060,9 @@ EXTERN_C HRESULT BACallbackOnDetectCompatibleMsiPackage( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2185,8 +2076,9 @@ EXTERN_C HRESULT BACallbackOnDetectComplete( HRESULT hr = S_OK; BA_ONDETECTCOMPLETE_ARGS args = { }; BA_ONDETECTCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -2196,27 +2088,21 @@ EXTERN_C HRESULT BACallbackOnDetectComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnDetectComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fEligibleForCleanup); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fEligibleForCleanup); ExitOnFailure(hr, "Failed to write eligible for cleanup of OnDetectComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectComplete results."); - // Callback. - hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE, &buffer, &result); + hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectComplete failed."); if (S_FALSE == hr) @@ -2225,8 +2111,9 @@ EXTERN_C HRESULT BACallbackOnDetectComplete( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2244,8 +2131,9 @@ EXTERN_C HRESULT BACallbackOnDetectForwardCompatibleBundle( HRESULT hr = S_OK; BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS args = { }; BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -2260,39 +2148,33 @@ EXTERN_C HRESULT BACallbackOnDetectForwardCompatibleBundle( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectForwardCompatibleBundle args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzBundleId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleId); ExitOnFailure(hr, "Failed to write bundle id of OnDetectForwardCompatibleBundle args."); - hr = BuffWriteNumberToBuffer(&buffer, args.relationType); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.relationType); ExitOnFailure(hr, "Failed to write relation type of OnDetectForwardCompatibleBundle args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzBundleTag); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleTag); ExitOnFailure(hr, "Failed to write bundle tag of OnDetectForwardCompatibleBundle args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fPerMachine); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fPerMachine); ExitOnFailure(hr, "Failed to write per-machine of OnDetectForwardCompatibleBundle args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVersion); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVersion); ExitOnFailure(hr, "Failed to write version of OnDetectForwardCompatibleBundle args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fMissingFromCache); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fMissingFromCache); ExitOnFailure(hr, "Failed to write missing from cache of OnDetectForwardCompatibleBundle args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectForwardCompatibleBundle args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectForwardCompatibleBundle results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectForwardCompatibleBundle results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectForwardCompatibleBundle failed."); if (S_FALSE == hr) @@ -2301,10 +2183,10 @@ EXTERN_C HRESULT BACallbackOnDetectForwardCompatibleBundle( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectForwardCompatibleBundle result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnDetectForwardCompatibleBundle result."); if (results.fCancel) @@ -2313,8 +2195,9 @@ EXTERN_C HRESULT BACallbackOnDetectForwardCompatibleBundle( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2329,8 +2212,9 @@ EXTERN_C HRESULT BACallbackOnDetectMsiFeature( HRESULT hr = S_OK; BA_ONDETECTMSIFEATURE_ARGS args = { }; BA_ONDETECTMSIFEATURE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -2342,30 +2226,24 @@ EXTERN_C HRESULT BACallbackOnDetectMsiFeature( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectMsiFeature args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnDetectMsiFeature args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzFeatureId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzFeatureId); ExitOnFailure(hr, "Failed to write feature id of OnDetectMsiFeature args."); - hr = BuffWriteNumberToBuffer(&buffer, args.state); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.state); ExitOnFailure(hr, "Failed to write state of OnDetectMsiFeature args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectMsiFeature args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectMsiFeature results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectMsiFeature results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectMsiFeature failed."); if (S_FALSE == hr) @@ -2374,10 +2252,10 @@ EXTERN_C HRESULT BACallbackOnDetectMsiFeature( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectMsiFeature result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnDetectMsiFeature result."); if (results.fCancel) @@ -2386,8 +2264,9 @@ EXTERN_C HRESULT BACallbackOnDetectMsiFeature( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2400,8 +2279,9 @@ EXTERN_C HRESULT BACallbackOnDetectPackageBegin( HRESULT hr = S_OK; BA_ONDETECTPACKAGEBEGIN_ARGS args = { }; BA_ONDETECTPACKAGEBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -2411,24 +2291,18 @@ EXTERN_C HRESULT BACallbackOnDetectPackageBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectPackageBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnDetectPackageBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectPackageBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectPackageBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectPackageBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectPackageBegin failed."); if (S_FALSE == hr) @@ -2437,10 +2311,10 @@ EXTERN_C HRESULT BACallbackOnDetectPackageBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectPackageBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnDetectPackageBegin result."); if (results.fCancel) @@ -2449,8 +2323,9 @@ EXTERN_C HRESULT BACallbackOnDetectPackageBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2466,8 +2341,9 @@ EXTERN_C HRESULT BACallbackOnDetectPackageComplete( HRESULT hr = S_OK; BA_ONDETECTPACKAGECOMPLETE_ARGS args = { }; BA_ONDETECTPACKAGECOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -2479,33 +2355,27 @@ EXTERN_C HRESULT BACallbackOnDetectPackageComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectPackageComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnDetectPackageComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnDetectPackageComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.state); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.state); ExitOnFailure(hr, "Failed to write state of OnDetectPackageComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fCached); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fCached); ExitOnFailure(hr, "Failed to write cached of OnDetectPackageComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectPackageComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectPackageComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectPackageComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectPackageComplete failed."); if (S_FALSE == hr) @@ -2514,8 +2384,9 @@ EXTERN_C HRESULT BACallbackOnDetectPackageComplete( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2533,8 +2404,9 @@ EXTERN_C HRESULT BACallbackOnDetectRelatedBundle( HRESULT hr = S_OK; BA_ONDETECTRELATEDBUNDLE_ARGS args = { }; BA_ONDETECTRELATEDBUNDLE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -2549,39 +2421,33 @@ EXTERN_C HRESULT BACallbackOnDetectRelatedBundle( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectRelatedBundle args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzBundleId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleId); ExitOnFailure(hr, "Failed to write bundle id of OnDetectRelatedBundle args."); - hr = BuffWriteNumberToBuffer(&buffer, args.relationType); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.relationType); ExitOnFailure(hr, "Failed to write relation type of OnDetectRelatedBundle args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzBundleTag); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleTag); ExitOnFailure(hr, "Failed to write bundle tag of OnDetectRelatedBundle args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fPerMachine); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fPerMachine); ExitOnFailure(hr, "Failed to write per-machine of OnDetectRelatedBundle args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVersion); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVersion); ExitOnFailure(hr, "Failed to write version of OnDetectRelatedBundle args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fMissingFromCache); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fMissingFromCache); ExitOnFailure(hr, "Failed to write cached of OnDetectRelatedBundle args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectRelatedBundle args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectRelatedBundle results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectRelatedBundle results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectRelatedBundle failed."); if (S_FALSE == hr) @@ -2590,10 +2456,10 @@ EXTERN_C HRESULT BACallbackOnDetectRelatedBundle( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectRelatedBundle result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnDetectRelatedBundle result."); if (results.fCancel) @@ -2602,8 +2468,9 @@ EXTERN_C HRESULT BACallbackOnDetectRelatedBundle( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2620,8 +2487,9 @@ EXTERN_C HRESULT BACallbackOnDetectRelatedBundlePackage( HRESULT hr = S_OK; BA_ONDETECTRELATEDBUNDLEPACKAGE_ARGS args = { }; BA_ONDETECTRELATEDBUNDLEPACKAGE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -2635,36 +2503,30 @@ EXTERN_C HRESULT BACallbackOnDetectRelatedBundlePackage( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectRelatedBundlePackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnDetectRelatedBundlePackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzBundleId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleId); ExitOnFailure(hr, "Failed to write bundle id of OnDetectRelatedBundlePackage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.relationType); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.relationType); ExitOnFailure(hr, "Failed to write relation type of OnDetectRelatedBundlePackage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fPerMachine); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fPerMachine); ExitOnFailure(hr, "Failed to write per-machine of OnDetectRelatedBundlePackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVersion); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVersion); ExitOnFailure(hr, "Failed to write version of OnDetectRelatedBundlePackage args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectRelatedBundlePackage args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectRelatedBundlePackage results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectRelatedBundlePackage results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectRelatedBundlePackage failed."); if (S_FALSE == hr) @@ -2673,10 +2535,10 @@ EXTERN_C HRESULT BACallbackOnDetectRelatedBundlePackage( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectRelatedBundlePackage result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnDetectRelatedBundlePackage result."); if (results.fCancel) @@ -2685,8 +2547,9 @@ EXTERN_C HRESULT BACallbackOnDetectRelatedBundlePackage( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2704,8 +2567,9 @@ EXTERN_C HRESULT BACallbackOnDetectRelatedMsiPackage( HRESULT hr = S_OK; BA_ONDETECTRELATEDMSIPACKAGE_ARGS args = { }; BA_ONDETECTRELATEDMSIPACKAGE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -2720,39 +2584,33 @@ EXTERN_C HRESULT BACallbackOnDetectRelatedMsiPackage( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectRelatedMsiPackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnDetectRelatedMsiPackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzUpgradeCode); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUpgradeCode); ExitOnFailure(hr, "Failed to write upgrade code of OnDetectRelatedMsiPackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzProductCode); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzProductCode); ExitOnFailure(hr, "Failed to write product code of OnDetectRelatedMsiPackage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fPerMachine); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fPerMachine); ExitOnFailure(hr, "Failed to write per-machine of OnDetectRelatedMsiPackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVersion); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVersion); ExitOnFailure(hr, "Failed to write version of OnDetectRelatedMsiPackage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.operation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.operation); ExitOnFailure(hr, "Failed to write operation OnDetectRelatedMsiPackage args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectRelatedMsiPackage args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectRelatedMsiPackage results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectRelatedMsiPackage results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectRelatedMsiPackage failed."); if (S_FALSE == hr) @@ -2761,10 +2619,10 @@ EXTERN_C HRESULT BACallbackOnDetectRelatedMsiPackage( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectRelatedMsiPackage result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnDetectRelatedMsiPackage result."); if (results.fCancel) @@ -2773,8 +2631,9 @@ EXTERN_C HRESULT BACallbackOnDetectRelatedMsiPackage( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2789,8 +2648,9 @@ EXTERN_C HRESULT BACallbackOnDetectPatchTarget( HRESULT hr = S_OK; BA_ONDETECTPATCHTARGET_ARGS args = { }; BA_ONDETECTPATCHTARGET_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -2802,30 +2662,24 @@ EXTERN_C HRESULT BACallbackOnDetectPatchTarget( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectPatchTarget args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnDetectPatchTarget args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzProductCode); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzProductCode); ExitOnFailure(hr, "Failed to write product code of OnDetectPatchTarget args."); - hr = BuffWriteNumberToBuffer(&buffer, args.patchState); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.patchState); ExitOnFailure(hr, "Failed to write patch state OnDetectPatchTarget args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectPatchTarget args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectPatchTarget results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectPatchTarget results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectPatchTarget failed."); if (S_FALSE == hr) @@ -2834,10 +2688,10 @@ EXTERN_C HRESULT BACallbackOnDetectPatchTarget( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectPatchTarget result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnDetectPatchTarget result."); if (results.fCancel) @@ -2846,8 +2700,9 @@ EXTERN_C HRESULT BACallbackOnDetectPatchTarget( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2869,8 +2724,9 @@ EXTERN_C HRESULT BACallbackOnDetectUpdate( HRESULT hr = S_OK; BA_ONDETECTUPDATE_ARGS args = { }; BA_ONDETECTUPDATE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -2889,51 +2745,45 @@ EXTERN_C HRESULT BACallbackOnDetectUpdate( results.fStopProcessingUpdates = *pfStopProcessingUpdates; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectUpdate args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzUpdateLocation); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUpdateLocation); ExitOnFailure(hr, "Failed to write update location of OnDetectUpdate args."); - hr = BuffWriteNumber64ToBuffer(&buffer, args.dw64Size); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.dw64Size); ExitOnFailure(hr, "Failed to write update size OnDetectUpdate args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzHash); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzHash); ExitOnFailure(hr, "Failed to write hash of OnDetectUpdate args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hashAlgorithm); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hashAlgorithm); ExitOnFailure(hr, "Failed to write hash algorithm OnDetectUpdate args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVersion); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVersion); ExitOnFailure(hr, "Failed to write version of OnDetectUpdate args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzTitle); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzTitle); ExitOnFailure(hr, "Failed to write title of OnDetectUpdate args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzSummary); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzSummary); ExitOnFailure(hr, "Failed to write summary of OnDetectUpdate args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzContentType); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzContentType); ExitOnFailure(hr, "Failed to write content type of OnDetectUpdate args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzContent); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzContent); ExitOnFailure(hr, "Failed to write content of OnDetectUpdate args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectUpdate args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectUpdate results."); - hr = BuffWriteNumberToBuffer(&buffer, results.fStopProcessingUpdates); + hr = BuffWriteNumberToBuffer(&bufferResults, results.fStopProcessingUpdates); ExitOnFailure(hr, "Failed to write stop processing updates of OnDetectUpdate results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectUpdate results."); - // Callback. - hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, &buffer, &result); + hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectUpdate failed."); if (S_FALSE == hr) @@ -2942,13 +2792,13 @@ EXTERN_C HRESULT BACallbackOnDetectUpdate( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectUpdate result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnDetectUpdate result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fStopProcessingUpdates)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fStopProcessingUpdates)); ExitOnFailure(hr, "Failed to read stop processing updates of OnDetectUpdate result."); if (results.fCancel) @@ -2959,8 +2809,9 @@ EXTERN_C HRESULT BACallbackOnDetectUpdate( *pfStopProcessingUpdates = results.fStopProcessingUpdates; LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -2974,8 +2825,9 @@ EXTERN_C HRESULT BACallbackOnDetectUpdateBegin( HRESULT hr = S_OK; BA_ONDETECTUPDATEBEGIN_ARGS args = { }; BA_ONDETECTUPDATEBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -2986,27 +2838,21 @@ EXTERN_C HRESULT BACallbackOnDetectUpdateBegin( results.fSkip = *pfSkip; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectUpdateBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzUpdateLocation); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUpdateLocation); ExitOnFailure(hr, "Failed to write update location of OnDetectUpdateBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectUpdateBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectUpdateBegin results."); - hr = BuffWriteNumberToBuffer(&buffer, results.fSkip); + hr = BuffWriteNumberToBuffer(&bufferResults, results.fSkip); ExitOnFailure(hr, "Failed to write skip of OnDetectUpdateBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectUpdateBegin results."); - // Callback. - hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, &buffer, &result); + hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectUpdateBegin failed."); if (S_FALSE == hr) @@ -3015,13 +2861,13 @@ EXTERN_C HRESULT BACallbackOnDetectUpdateBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectUpdateBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnDetectUpdateBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fSkip)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fSkip)); ExitOnFailure(hr, "Failed to read cancel of OnDetectUpdateBegin result."); if (results.fCancel) @@ -3032,8 +2878,9 @@ EXTERN_C HRESULT BACallbackOnDetectUpdateBegin( *pfSkip = results.fSkip; LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3047,8 +2894,9 @@ EXTERN_C HRESULT BACallbackOnDetectUpdateComplete( HRESULT hr = S_OK; BA_ONDETECTUPDATECOMPLETE_ARGS args = { }; BA_ONDETECTUPDATECOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -3059,27 +2907,21 @@ EXTERN_C HRESULT BACallbackOnDetectUpdateComplete( results.fIgnoreError = *pfIgnoreError; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectUpdateComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnDetectUpdateComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectUpdateComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnDetectUpdateComplete results."); - hr = BuffWriteNumberToBuffer(&buffer, results.fIgnoreError); + hr = BuffWriteNumberToBuffer(&bufferResults, results.fIgnoreError); ExitOnFailure(hr, "Failed to write ignore error of OnDetectUpdateComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnDetectUpdateComplete results."); - // Callback. - hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE, &buffer, &result); + hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnDetectUpdateComplete failed."); if (S_FALSE == hr) @@ -3088,10 +2930,10 @@ EXTERN_C HRESULT BACallbackOnDetectUpdateComplete( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnDetectUpdateComplete result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fIgnoreError)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fIgnoreError)); ExitOnFailure(hr, "Failed to read ignore error of OnDetectUpdateComplete result."); if (FAILED(hrStatus)) @@ -3100,8 +2942,9 @@ EXTERN_C HRESULT BACallbackOnDetectUpdateComplete( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3113,8 +2956,9 @@ EXTERN_C HRESULT BACallbackOnElevateBegin( HRESULT hr = S_OK; BA_ONELEVATEBEGIN_ARGS args = { }; BA_ONELEVATEBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -3123,21 +2967,15 @@ EXTERN_C HRESULT BACallbackOnElevateBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnElevateBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnElevateBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnElevateBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnElevateBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnElevateBegin failed."); if (S_FALSE == hr) @@ -3146,10 +2984,10 @@ EXTERN_C HRESULT BACallbackOnElevateBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnElevateBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnElevateBegin result."); if (results.fCancel) @@ -3158,8 +2996,9 @@ EXTERN_C HRESULT BACallbackOnElevateBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3172,8 +3011,9 @@ EXTERN_C HRESULT BACallbackOnElevateComplete( HRESULT hr = S_OK; BA_ONELEVATECOMPLETE_ARGS args = { }; BA_ONELEVATECOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -3182,24 +3022,18 @@ EXTERN_C HRESULT BACallbackOnElevateComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnElevateComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnElevateComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnElevateComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnElevateComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnElevateComplete results."); - // Callback. - hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE, &buffer, &result); + hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnElevateComplete failed."); if (S_FALSE == hr) @@ -3208,8 +3042,9 @@ EXTERN_C HRESULT BACallbackOnElevateComplete( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3229,8 +3064,9 @@ EXTERN_C HRESULT BACallbackOnError( HRESULT hr = S_OK; BA_ONERROR_ARGS args = { }; BA_ONERROR_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -3248,51 +3084,45 @@ EXTERN_C HRESULT BACallbackOnError( results.nResult = *pnResult; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnError args."); - hr = BuffWriteNumberToBuffer(&buffer, args.errorType); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.errorType); ExitOnFailure(hr, "Failed to write error type OnError args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnError args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwCode); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwCode); ExitOnFailure(hr, "Failed to write code OnError args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzError); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzError); ExitOnFailure(hr, "Failed to write error of OnError args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwUIHint); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwUIHint); ExitOnFailure(hr, "Failed to write UI hint OnError args."); - hr = BuffWriteNumberToBuffer(&buffer, args.cData); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cData); ExitOnFailure(hr, "Failed to write count of data of OnError args."); for (DWORD i = 0; i < args.cData; ++i) { - hr = BuffWriteStringToBuffer(&buffer, args.rgwzData[i]); + hr = BuffWriteStringToBuffer(&bufferArgs, args.rgwzData[i]); ExitOnFailure(hr, "Failed to write data[%u] of OnError args.", i); } - hr = BuffWriteNumberToBuffer(&buffer, args.nRecommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.nRecommendation); ExitOnFailure(hr, "Failed to write recommendation of OnError args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnError args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnError results."); - hr = BuffWriteNumberToBuffer(&buffer, results.nResult); + hr = BuffWriteNumberToBuffer(&bufferResults, results.nResult); ExitOnFailure(hr, "Failed to write result of OnError results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnError results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnError failed."); if (S_FALSE == hr) @@ -3301,17 +3131,18 @@ EXTERN_C HRESULT BACallbackOnError( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnError result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.nResult)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.nResult)); ExitOnFailure(hr, "Failed to read result of OnError result."); *pnResult = results.nResult; LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3324,8 +3155,9 @@ EXTERN_C HRESULT BACallbackOnExecuteBegin( HRESULT hr = S_OK; BA_ONEXECUTEBEGIN_ARGS args = { }; BA_ONEXECUTEBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -3335,24 +3167,18 @@ EXTERN_C HRESULT BACallbackOnExecuteBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecuteBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.cExecutingPackages); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cExecutingPackages); ExitOnFailure(hr, "Failed to write executing packages OnExecuteBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecuteBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecuteBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecuteBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnExecuteBegin failed."); if (S_FALSE == hr) @@ -3361,10 +3187,10 @@ EXTERN_C HRESULT BACallbackOnExecuteBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnExecuteBegin result."); if (results.fCancel) @@ -3373,8 +3199,9 @@ EXTERN_C HRESULT BACallbackOnExecuteBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3387,8 +3214,9 @@ EXTERN_C HRESULT BACallbackOnExecuteComplete( HRESULT hr = S_OK; BA_ONEXECUTECOMPLETE_ARGS args = { }; BA_ONEXECUTECOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -3397,24 +3225,18 @@ EXTERN_C HRESULT BACallbackOnExecuteComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecuteComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status OnExecuteComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecuteComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecuteComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecuteComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnExecuteComplete failed."); if (S_FALSE == hr) @@ -3423,8 +3245,9 @@ EXTERN_C HRESULT BACallbackOnExecuteComplete( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3441,8 +3264,9 @@ EXTERN_C HRESULT BACallbackOnExecuteFilesInUse( HRESULT hr = S_OK; BA_ONEXECUTEFILESINUSE_ARGS args = { }; BA_ONEXECUTEFILESINUSE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -3457,42 +3281,36 @@ EXTERN_C HRESULT BACallbackOnExecuteFilesInUse( results.nResult = *pnResult; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecuteFilesInUse args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnExecuteFilesInUse args."); - hr = BuffWriteNumberToBuffer(&buffer, args.cFiles); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cFiles); ExitOnFailure(hr, "Failed to write count of files of OnExecuteFilesInUse args."); for (DWORD i = 0; i < args.cFiles; ++i) { - hr = BuffWriteStringToBuffer(&buffer, args.rgwzFiles[i]); + hr = BuffWriteStringToBuffer(&bufferArgs, args.rgwzFiles[i]); ExitOnFailure(hr, "Failed to write file[%u] of OnExecuteFilesInUse args.", i); } - hr = BuffWriteNumberToBuffer(&buffer, args.nRecommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.nRecommendation); ExitOnFailure(hr, "Failed to write recommendation of OnExecuteFilesInUse args."); - hr = BuffWriteNumberToBuffer(&buffer, args.source); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.source); ExitOnFailure(hr, "Failed to write source of OnExecuteFilesInUse args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecuteFilesInUse args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecuteFilesInUse results."); - hr = BuffWriteNumberToBuffer(&buffer, results.nResult); + hr = BuffWriteNumberToBuffer(&bufferResults, results.nResult); ExitOnFailure(hr, "Failed to write result of OnExecuteFilesInUse results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecuteFilesInUse results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnExecuteFilesInUse failed."); if (S_FALSE == hr) @@ -3501,17 +3319,18 @@ EXTERN_C HRESULT BACallbackOnExecuteFilesInUse( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteFilesInUse result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.nResult)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.nResult)); ExitOnFailure(hr, "Failed to read result of OnExecuteFilesInUse result."); *pnResult = results.nResult; LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3530,8 +3349,9 @@ EXTERN_C HRESULT BACallbackOnExecuteMsiMessage( HRESULT hr = S_OK; BA_ONEXECUTEMSIMESSAGE_ARGS args = { }; BA_ONEXECUTEMSIMESSAGE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -3548,48 +3368,42 @@ EXTERN_C HRESULT BACallbackOnExecuteMsiMessage( results.nResult = *pnResult; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecuteMsiMessage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnExecuteMsiMessage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.messageType); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.messageType); ExitOnFailure(hr, "Failed to write message type OnExecuteMsiMessage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwUIHint); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwUIHint); ExitOnFailure(hr, "Failed to write UI hint OnExecuteMsiMessage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzMessage); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzMessage); ExitOnFailure(hr, "Failed to write message of OnExecuteMsiMessage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.cData); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cData); ExitOnFailure(hr, "Failed to write count of data of OnExecuteMsiMessage args."); for (DWORD i = 0; i < args.cData; ++i) { - hr = BuffWriteStringToBuffer(&buffer, args.rgwzData[i]); + hr = BuffWriteStringToBuffer(&bufferArgs, args.rgwzData[i]); ExitOnFailure(hr, "Failed to write data[%u] of OnExecuteMsiMessage args.", i); } - hr = BuffWriteNumberToBuffer(&buffer, args.nRecommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.nRecommendation); ExitOnFailure(hr, "Failed to write recommendation of OnExecuteMsiMessage args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecuteMsiMessage args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecuteMsiMessage results."); - hr = BuffWriteNumberToBuffer(&buffer, results.nResult); + hr = BuffWriteNumberToBuffer(&bufferResults, results.nResult); ExitOnFailure(hr, "Failed to write result of OnExecuteMsiMessage results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecuteMsiMessage results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnExecuteMsiMessage failed."); if (S_FALSE == hr) @@ -3598,17 +3412,18 @@ EXTERN_C HRESULT BACallbackOnExecuteMsiMessage( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteMsiMessage result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.nResult)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.nResult)); ExitOnFailure(hr, "Failed to read cancel of OnExecuteMsiMessage result."); *pnResult = results.nResult; LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3625,8 +3440,9 @@ EXTERN_C HRESULT BACallbackOnExecutePackageBegin( HRESULT hr = S_OK; BA_ONEXECUTEPACKAGEBEGIN_ARGS args = { }; BA_ONEXECUTEPACKAGEBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -3640,36 +3456,30 @@ EXTERN_C HRESULT BACallbackOnExecutePackageBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecutePackageBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnExecutePackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fExecute); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fExecute); ExitOnFailure(hr, "Failed to write execute OnExecutePackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.action); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.action); ExitOnFailure(hr, "Failed to write action OnExecutePackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.uiLevel); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.uiLevel); ExitOnFailure(hr, "Failed to write UI level of OnExecutePackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fDisableExternalUiHandler); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fDisableExternalUiHandler); ExitOnFailure(hr, "Failed to write disable external UI handler of OnExecutePackageBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecutePackageBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecutePackageBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecutePackageBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnExecutePackageBegin failed."); if (S_FALSE == hr) @@ -3678,10 +3488,10 @@ EXTERN_C HRESULT BACallbackOnExecutePackageBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecutePackageBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnExecutePackageBegin result."); if (results.fCancel) @@ -3690,8 +3500,9 @@ EXTERN_C HRESULT BACallbackOnExecutePackageBegin( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3707,8 +3518,9 @@ EXTERN_C HRESULT BACallbackOnExecutePackageComplete( HRESULT hr = S_OK; BA_ONEXECUTEPACKAGECOMPLETE_ARGS args = { }; BA_ONEXECUTEPACKAGECOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -3722,36 +3534,30 @@ EXTERN_C HRESULT BACallbackOnExecutePackageComplete( results.action = *pAction; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecutePackageComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnExecutePackageComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnExecutePackageComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.restart); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.restart); ExitOnFailure(hr, "Failed to write restart of OnExecutePackageComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendation); ExitOnFailure(hr, "Failed to write recommendation of OnExecutePackageComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecutePackageComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecutePackageComplete results."); - hr = BuffWriteNumberToBuffer(&buffer, results.action); + hr = BuffWriteNumberToBuffer(&bufferResults, results.action); ExitOnFailure(hr, "Failed to write action of OnExecutePackageComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecutePackageComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnExecutePackageComplete failed."); if (S_FALSE == hr) @@ -3760,17 +3566,18 @@ EXTERN_C HRESULT BACallbackOnExecutePackageComplete( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecutePackageComplete result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.action)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnExecutePackageComplete result."); *pAction = results.action; LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3784,8 +3591,9 @@ EXTERN_C HRESULT BACallbackOnExecutePatchTarget( HRESULT hr = S_OK; BA_ONEXECUTEPATCHTARGET_ARGS args = { }; BA_ONEXECUTEPATCHTARGET_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -3796,27 +3604,21 @@ EXTERN_C HRESULT BACallbackOnExecutePatchTarget( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecutePatchTarget args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnExecutePatchTarget args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzTargetProductCode); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzTargetProductCode); ExitOnFailure(hr, "Failed to write target product code of OnExecutePatchTarget args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecutePatchTarget args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecutePatchTarget results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecutePatchTarget results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnExecutePatchTarget failed."); if (S_FALSE == hr) @@ -3825,10 +3627,10 @@ EXTERN_C HRESULT BACallbackOnExecutePatchTarget( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecutePatchTarget result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnExecutePatchTarget result."); if (results.fCancel) @@ -3837,8 +3639,9 @@ EXTERN_C HRESULT BACallbackOnExecutePatchTarget( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3853,8 +3656,9 @@ EXTERN_C HRESULT BACallbackOnExecuteProcessCancel( HRESULT hr = S_OK; BA_ONEXECUTEPROCESSCANCEL_ARGS args = { }; BA_ONEXECUTEPROCESSCANCEL_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -3867,33 +3671,27 @@ EXTERN_C HRESULT BACallbackOnExecuteProcessCancel( results.action = *pAction; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecuteProcessCancel args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnExecuteProcessCancel args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwProcessId); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwProcessId); ExitOnFailure(hr, "Failed to write process id of OnExecuteProcessCancel args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendation); ExitOnFailure(hr, "Failed to write recommendation of OnExecuteProcessCancel args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecuteProcessCancel args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecuteProcessCancel results."); - hr = BuffWriteNumberToBuffer(&buffer, results.action); + hr = BuffWriteNumberToBuffer(&bufferResults, results.action); ExitOnFailure(hr, "Failed to write action of OnExecuteProcessCancel results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecuteProcessCancel results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnExecuteProcessCancel failed."); if (S_FALSE == hr) @@ -3902,17 +3700,18 @@ EXTERN_C HRESULT BACallbackOnExecuteProcessCancel( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteProcessCancel result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.action)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read action of OnExecuteProcessCancel result."); *pAction = results.action; LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -3928,8 +3727,9 @@ EXTERN_C HRESULT BACallbackOnExecuteProgress( HRESULT hr = S_OK; BA_ONEXECUTEPROGRESS_ARGS args = { }; BA_ONEXECUTEPROGRESS_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -3941,30 +3741,24 @@ EXTERN_C HRESULT BACallbackOnExecuteProgress( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecuteProgress args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnExecuteProgress args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwProgressPercentage); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwProgressPercentage); ExitOnFailure(hr, "Failed to write progress of OnExecuteProgress args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwOverallPercentage); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwOverallPercentage); ExitOnFailure(hr, "Failed to write overall progress of OnExecuteProgress args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecuteProgress args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnExecuteProgress results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnExecuteProgress results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnExecuteProgress failed."); if (S_FALSE == hr) @@ -3973,10 +3767,10 @@ EXTERN_C HRESULT BACallbackOnExecuteProgress( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnExecuteProgress result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnExecuteProgress result."); LExit: @@ -3992,6 +3786,11 @@ EXTERN_C HRESULT BACallbackOnExecuteProgress( { *pnResult = IDNOACTION; } + + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4002,8 +3801,9 @@ EXTERN_C HRESULT BACallbackOnLaunchApprovedExeBegin( HRESULT hr = S_OK; BA_ONLAUNCHAPPROVEDEXEBEGIN_ARGS args = { }; BA_ONLAUNCHAPPROVEDEXEBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -4012,21 +3812,15 @@ EXTERN_C HRESULT BACallbackOnLaunchApprovedExeBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnLaunchApprovedExeBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnLaunchApprovedExeBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnLaunchApprovedExeBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnLaunchApprovedExeBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnLaunchApprovedExeBegin failed."); if (S_FALSE == hr) @@ -4035,10 +3829,10 @@ EXTERN_C HRESULT BACallbackOnLaunchApprovedExeBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnLaunchApprovedExeBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnLaunchApprovedExeBegin result."); if (results.fCancel) @@ -4047,6 +3841,10 @@ EXTERN_C HRESULT BACallbackOnLaunchApprovedExeBegin( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4059,8 +3857,9 @@ EXTERN_C HRESULT BACallbackOnLaunchApprovedExeComplete( HRESULT hr = S_OK; BA_ONLAUNCHAPPROVEDEXECOMPLETE_ARGS args = { }; BA_ONLAUNCHAPPROVEDEXECOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -4070,27 +3869,21 @@ EXTERN_C HRESULT BACallbackOnLaunchApprovedExeComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnLaunchApprovedExeComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnLaunchApprovedExeComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwProcessId); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwProcessId); ExitOnFailure(hr, "Failed to write process id of OnLaunchApprovedExeComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnLaunchApprovedExeComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnLaunchApprovedExeComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnLaunchApprovedExeComplete results."); - // Callback. - hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, &buffer, &result); + hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnLaunchApprovedExeComplete failed."); if (S_FALSE == hr) @@ -4099,6 +3892,10 @@ EXTERN_C HRESULT BACallbackOnLaunchApprovedExeComplete( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4109,8 +3906,9 @@ EXTERN_C HRESULT BACallbackOnPauseAUBegin( HRESULT hr = S_OK; BA_ONPAUSEAUTOMATICUPDATESBEGIN_ARGS args = { }; BA_ONPAUSEAUTOMATICUPDATESBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -4118,21 +3916,15 @@ EXTERN_C HRESULT BACallbackOnPauseAUBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPauseAUBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPauseAUBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPauseAUBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPauseAUBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPauseAUBegin failed."); if (S_FALSE == hr) @@ -4141,6 +3933,10 @@ EXTERN_C HRESULT BACallbackOnPauseAUBegin( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4152,8 +3948,9 @@ EXTERN_C HRESULT BACallbackOnPauseAUComplete( HRESULT hr = S_OK; BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_ARGS args = { }; BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -4162,24 +3959,18 @@ EXTERN_C HRESULT BACallbackOnPauseAUComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPauseAUComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnPauseAUComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPauseAUComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPauseAUComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPauseAUComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPauseAUComplete failed."); if (S_FALSE == hr) @@ -4188,6 +3979,10 @@ EXTERN_C HRESULT BACallbackOnPauseAUComplete( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4199,8 +3994,9 @@ EXTERN_C HRESULT BACallbackOnPlanBegin( HRESULT hr = S_OK; BA_ONPLANBEGIN_ARGS args = { }; BA_ONPLANBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -4210,24 +4006,18 @@ EXTERN_C HRESULT BACallbackOnPlanBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.cPackages); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cPackages); ExitOnFailure(hr, "Failed to write count of packages of OnPlanBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanBegin failed."); if (S_FALSE == hr) @@ -4236,10 +4026,10 @@ EXTERN_C HRESULT BACallbackOnPlanBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnPlanBegin result."); if (results.fCancel) @@ -4248,6 +4038,10 @@ EXTERN_C HRESULT BACallbackOnPlanBegin( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4262,8 +4056,9 @@ EXTERN_C HRESULT BACallbackOnPlanCompatibleMsiPackageBegin( HRESULT hr = S_OK; BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_ARGS args = { }; BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -4277,36 +4072,30 @@ EXTERN_C HRESULT BACallbackOnPlanCompatibleMsiPackageBegin( results.fRequestRemove = *pfRequested; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanCompatibleMsiPackageBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnPlanCompatibleMsiPackageBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzCompatiblePackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzCompatiblePackageId); ExitOnFailure(hr, "Failed to write compatible package id of OnPlanCompatibleMsiPackageBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzCompatiblePackageVersion); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzCompatiblePackageVersion); ExitOnFailure(hr, "Failed to write compatible package version of OnPlanCompatibleMsiPackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fRecommendedRemove); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fRecommendedRemove); ExitOnFailure(hr, "Failed to write recommend remove of OnPlanCompatibleMsiPackageBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanCompatibleMsiPackageBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanCompatibleMsiPackageBegin results."); - hr = BuffWriteNumberToBuffer(&buffer, results.fRequestRemove); + hr = BuffWriteNumberToBuffer(&bufferResults, results.fRequestRemove); ExitOnFailure(hr, "Failed to write request remove of OnPlanCompatibleMsiPackageBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanCompatibleMsiPackageBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanCompatibleMsiPackageBegin failed."); if (S_FALSE == hr) @@ -4315,13 +4104,13 @@ EXTERN_C HRESULT BACallbackOnPlanCompatibleMsiPackageBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanCompatibleMsiPackageBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnPlanCompatibleMsiPackageBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fRequestRemove)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fRequestRemove)); ExitOnFailure(hr, "Failed to read requested remove of OnPlanCompatibleMsiPackageBegin result."); if (results.fCancel) @@ -4332,6 +4121,10 @@ EXTERN_C HRESULT BACallbackOnPlanCompatibleMsiPackageBegin( *pfRequested = results.fRequestRemove; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4346,8 +4139,9 @@ EXTERN_C HRESULT BACallbackOnPlanCompatibleMsiPackageComplete( HRESULT hr = S_OK; BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_ARGS args = { }; BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -4359,33 +4153,27 @@ EXTERN_C HRESULT BACallbackOnPlanCompatibleMsiPackageComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanCompatibleMsiPackageComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnPlanCompatibleMsiPackageComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzCompatiblePackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzCompatiblePackageId); ExitOnFailure(hr, "Failed to write compatible package id of OnPlanCompatibleMsiPackageComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnPlanCompatibleMsiPackageComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fRequestedRemove); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fRequestedRemove); ExitOnFailure(hr, "Failed to write requested remove of OnPlanCompatibleMsiPackageComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanCompatibleMsiPackageComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanCompatibleMsiPackageComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanCompatibleMsiPackageComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanCompatibleMsiPackageComplete failed."); if (S_FALSE == hr) @@ -4394,6 +4182,10 @@ EXTERN_C HRESULT BACallbackOnPlanCompatibleMsiPackageComplete( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4407,8 +4199,9 @@ EXTERN_C HRESULT BACallbackOnPlanMsiFeature( HRESULT hr = S_OK; BA_ONPLANMSIFEATURE_ARGS args = { }; BA_ONPLANMSIFEATURE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -4421,33 +4214,27 @@ EXTERN_C HRESULT BACallbackOnPlanMsiFeature( results.requestedState = *pRequestedState; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanMsiFeature args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnPlanMsiFeature args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzFeatureId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzFeatureId); ExitOnFailure(hr, "Failed to write feature id of OnPlanMsiFeature args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendedState); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendedState); ExitOnFailure(hr, "Failed to write recommended state of OnPlanMsiFeature args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanMsiFeature args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanMsiFeature results."); - hr = BuffWriteNumberToBuffer(&buffer, results.requestedState); + hr = BuffWriteNumberToBuffer(&bufferResults, results.requestedState); ExitOnFailure(hr, "Failed to write requested state of OnPlanMsiFeature results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanMsiFeature results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanMsiFeature failed."); if (S_FALSE == hr) @@ -4456,13 +4243,13 @@ EXTERN_C HRESULT BACallbackOnPlanMsiFeature( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanMsiFeature result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.requestedState)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.requestedState)); ExitOnFailure(hr, "Failed to read requested state of OnPlanMsiFeature result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnPlanMsiFeature result."); if (results.fCancel) @@ -4473,6 +4260,10 @@ EXTERN_C HRESULT BACallbackOnPlanMsiFeature( *pRequestedState = results.requestedState; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4484,8 +4275,9 @@ EXTERN_C HRESULT BACallbackOnPlanComplete( HRESULT hr = S_OK; BA_ONPLANCOMPLETE_ARGS args = { }; BA_ONPLANCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -4494,24 +4286,18 @@ EXTERN_C HRESULT BACallbackOnPlanComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnPlanComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanComplete results."); - // Callback. - hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE, &buffer, &result); + hr = SendBAMessageFromInactiveEngine(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanComplete failed."); if (S_FALSE == hr) @@ -4520,6 +4306,10 @@ EXTERN_C HRESULT BACallbackOnPlanComplete( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4536,8 +4326,9 @@ EXTERN_C HRESULT BACallbackOnPlanForwardCompatibleBundle( HRESULT hr = S_OK; BA_ONPLANFORWARDCOMPATIBLEBUNDLE_ARGS args = { }; BA_ONPLANFORWARDCOMPATIBLEBUNDLE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -4553,42 +4344,36 @@ EXTERN_C HRESULT BACallbackOnPlanForwardCompatibleBundle( results.fIgnoreBundle = *pfIgnoreBundle; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanForwardCompatibleBundle args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzBundleId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleId); ExitOnFailure(hr, "Failed to write bundle id of OnPlanForwardCompatibleBundle args."); - hr = BuffWriteNumberToBuffer(&buffer, args.relationType); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.relationType); ExitOnFailure(hr, "Failed to write relation type of OnPlanForwardCompatibleBundle args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzBundleTag); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleTag); ExitOnFailure(hr, "Failed to write bundle tag of OnPlanForwardCompatibleBundle args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fPerMachine); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fPerMachine); ExitOnFailure(hr, "Failed to write per-machine of OnPlanForwardCompatibleBundle args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzVersion); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVersion); ExitOnFailure(hr, "Failed to write version of OnPlanForwardCompatibleBundle args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fRecommendedIgnoreBundle); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fRecommendedIgnoreBundle); ExitOnFailure(hr, "Failed to write recommended ignore bundle of OnPlanForwardCompatibleBundle args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanForwardCompatibleBundle args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanForwardCompatibleBundle results."); - hr = BuffWriteNumberToBuffer(&buffer, results.fIgnoreBundle); + hr = BuffWriteNumberToBuffer(&bufferResults, results.fIgnoreBundle); ExitOnFailure(hr, "Failed to write ignore bundle of OnPlanForwardCompatibleBundle results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanForwardCompatibleBundle results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanForwardCompatibleBundle failed."); if (S_FALSE == hr) @@ -4597,13 +4382,13 @@ EXTERN_C HRESULT BACallbackOnPlanForwardCompatibleBundle( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanForwardCompatibleBundle result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnPlanForwardCompatibleBundle result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fIgnoreBundle)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fIgnoreBundle)); ExitOnFailure(hr, "Failed to read ignore bundle of OnPlanForwardCompatibleBundle result."); if (results.fCancel) @@ -4614,6 +4399,10 @@ EXTERN_C HRESULT BACallbackOnPlanForwardCompatibleBundle( *pfIgnoreBundle = results.fIgnoreBundle; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4631,8 +4420,9 @@ EXTERN_C HRESULT BACallbackOnPlanMsiPackage( HRESULT hr = S_OK; BA_ONPLANMSIPACKAGE_ARGS args = { }; BA_ONPLANMSIPACKAGE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -4649,45 +4439,39 @@ EXTERN_C HRESULT BACallbackOnPlanMsiPackage( results.fileVersioning = args.recommendedFileVersioning; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanMsiPackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnPlanMsiPackage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fExecute); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fExecute); ExitOnFailure(hr, "Failed to write execute of OnPlanMsiPackage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.action); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.action); ExitOnFailure(hr, "Failed to write action of OnPlanMsiPackage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendedFileVersioning); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendedFileVersioning); ExitOnFailure(hr, "Failed to write recommended file versioning of OnPlanMsiPackage args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanMsiPackage args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanMsiPackage results."); - hr = BuffWriteNumberToBuffer(&buffer, results.actionMsiProperty); + hr = BuffWriteNumberToBuffer(&bufferResults, results.actionMsiProperty); ExitOnFailure(hr, "Failed to write action msi property of OnPlanMsiPackage results."); - hr = BuffWriteNumberToBuffer(&buffer, results.uiLevel); + hr = BuffWriteNumberToBuffer(&bufferResults, results.uiLevel); ExitOnFailure(hr, "Failed to write UI level of OnPlanMsiPackage results."); - hr = BuffWriteNumberToBuffer(&buffer, results.fDisableExternalUiHandler); + hr = BuffWriteNumberToBuffer(&bufferResults, results.fDisableExternalUiHandler); ExitOnFailure(hr, "Failed to write disable external UI handler of OnPlanMsiPackage results."); - hr = BuffWriteNumberToBuffer(&buffer, results.fileVersioning); + hr = BuffWriteNumberToBuffer(&bufferResults, results.fileVersioning); ExitOnFailure(hr, "Failed to write file versioning of OnPlanMsiPackage results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanMsiPackage results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanMsiPackage failed."); if (S_FALSE == hr) @@ -4696,22 +4480,22 @@ EXTERN_C HRESULT BACallbackOnPlanMsiPackage( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanMsiPackage result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnPlanMsiPackage result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.actionMsiProperty)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.actionMsiProperty)); ExitOnFailure(hr, "Failed to read action MSI property of OnPlanMsiPackage result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.uiLevel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.uiLevel)); ExitOnFailure(hr, "Failed to read UI level of OnPlanMsiPackage result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fDisableExternalUiHandler)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fDisableExternalUiHandler)); ExitOnFailure(hr, "Failed to read disable external UI handler of OnPlanMsiPackage result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fileVersioning)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fileVersioning)); ExitOnFailure(hr, "Failed to read file versioning of OnPlanMsiPackage result."); if (results.fCancel) @@ -4725,6 +4509,10 @@ EXTERN_C HRESULT BACallbackOnPlanMsiPackage( *pFileVersioning = results.fileVersioning; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4738,8 +4526,9 @@ EXTERN_C HRESULT BACallbackOnPlannedCompatiblePackage( HRESULT hr = S_OK; BA_ONPLANNEDCOMPATIBLEPACKAGE_ARGS args = { }; BA_ONPLANNEDCOMPATIBLEPACKAGE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -4750,30 +4539,24 @@ EXTERN_C HRESULT BACallbackOnPlannedCompatiblePackage( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlannedCompatiblePackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnPlannedCompatiblePackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzCompatiblePackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzCompatiblePackageId); ExitOnFailure(hr, "Failed to write compatible package id of OnPlannedCompatiblePackage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fRemove); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fRemove); ExitOnFailure(hr, "Failed to write remove of OnPlannedCompatiblePackage args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlannedCompatiblePackage args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlannedCompatiblePackage results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlannedCompatiblePackage results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlannedCompatiblePackage failed."); if (S_FALSE == hr) @@ -4782,6 +4565,10 @@ EXTERN_C HRESULT BACallbackOnPlannedCompatiblePackage( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4797,8 +4584,9 @@ EXTERN_C HRESULT BACallbackOnPlannedPackage( HRESULT hr = S_OK; BA_ONPLANNEDPACKAGE_ARGS args = { }; BA_ONPLANNEDPACKAGE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -4811,36 +4599,30 @@ EXTERN_C HRESULT BACallbackOnPlannedPackage( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlannedPackage args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnPlannedPackage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.execute); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.execute); ExitOnFailure(hr, "Failed to write execute of OnPlannedPackage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.rollback); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.rollback); ExitOnFailure(hr, "Failed to write rollback of OnPlannedPackage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fPlannedCache); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fPlannedCache); ExitOnFailure(hr, "Failed to write planned cache of OnPlannedPackage args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fPlannedUncache); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fPlannedUncache); ExitOnFailure(hr, "Failed to write planned uncache of OnPlannedPackage args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlannedPackage args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlannedPackage results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlannedPackage results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlannedPackage failed."); if (S_FALSE == hr) @@ -4849,6 +4631,10 @@ EXTERN_C HRESULT BACallbackOnPlannedPackage( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4866,8 +4652,9 @@ EXTERN_C HRESULT BACallbackOnPlanPackageBegin( HRESULT hr = S_OK; BA_ONPLANPACKAGEBEGIN_ARGS args = { }; BA_ONPLANPACKAGEBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -4885,48 +4672,42 @@ EXTERN_C HRESULT BACallbackOnPlanPackageBegin( results.requestedCacheType = *pRequestedCacheType; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanPackageBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnPlanPackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.state); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.state); ExitOnFailure(hr, "Failed to write state of OnPlanPackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fCached); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fCached); ExitOnFailure(hr, "Failed to write cached of OnPlanPackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.installCondition); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.installCondition); ExitOnFailure(hr, "Failed to write install condition of OnPlanPackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.repairCondition); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.repairCondition); ExitOnFailure(hr, "Failed to write repair condition of OnPlanPackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendedState); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendedState); ExitOnFailure(hr, "Failed to write recommended state of OnPlanPackageBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendedCacheType); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendedCacheType); ExitOnFailure(hr, "Failed to write recommended cache type of OnPlanPackageBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanPackageBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanPackageBegin results."); - hr = BuffWriteNumberToBuffer(&buffer, results.requestedState); + hr = BuffWriteNumberToBuffer(&bufferResults, results.requestedState); ExitOnFailure(hr, "Failed to write requested state of OnPlanPackageBegin results."); - hr = BuffWriteNumberToBuffer(&buffer, results.requestedCacheType); + hr = BuffWriteNumberToBuffer(&bufferResults, results.requestedCacheType); ExitOnFailure(hr, "Failed to write requested cache type of OnPlanPackageBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanPackageBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanPackageBegin failed."); if (S_FALSE == hr) @@ -4935,16 +4716,16 @@ EXTERN_C HRESULT BACallbackOnPlanPackageBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanPackageBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnPlanPackageBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.requestedState)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.requestedState)); ExitOnFailure(hr, "Failed to read requested state of OnPlanPackageBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.requestedCacheType)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.requestedCacheType)); ExitOnFailure(hr, "Failed to read requested cache type of OnPlanPackageBegin result."); if (results.fCancel) @@ -4960,6 +4741,10 @@ EXTERN_C HRESULT BACallbackOnPlanPackageBegin( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -4973,8 +4758,9 @@ EXTERN_C HRESULT BACallbackOnPlanPackageComplete( HRESULT hr = S_OK; BA_ONPLANPACKAGECOMPLETE_ARGS args = { }; BA_ONPLANPACKAGECOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -4985,30 +4771,24 @@ EXTERN_C HRESULT BACallbackOnPlanPackageComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanPackageComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnPlanPackageComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnPlanPackageComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.requested); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.requested); ExitOnFailure(hr, "Failed to write requested of OnPlanPackageComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanPackageComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanPackageComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanPackageComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanPackageComplete failed."); if (S_FALSE == hr) @@ -5017,6 +4797,10 @@ EXTERN_C HRESULT BACallbackOnPlanPackageComplete( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5029,8 +4813,9 @@ EXTERN_C HRESULT BACallbackOnPlanRelatedBundle( HRESULT hr = S_OK; BA_ONPLANRELATEDBUNDLE_ARGS args = { }; BA_ONPLANRELATEDBUNDLE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -5042,30 +4827,24 @@ EXTERN_C HRESULT BACallbackOnPlanRelatedBundle( results.requestedState = *pRequestedState; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanRelatedBundle args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzBundleId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleId); ExitOnFailure(hr, "Failed to write bundle id of OnPlanRelatedBundle args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendedState); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendedState); ExitOnFailure(hr, "Failed to write recommended state of OnPlanRelatedBundle args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanRelatedBundle args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanRelatedBundle results."); - hr = BuffWriteNumberToBuffer(&buffer, results.requestedState); + hr = BuffWriteNumberToBuffer(&bufferResults, results.requestedState); ExitOnFailure(hr, "Failed to write requested state of OnPlanRelatedBundle results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanRelatedBundle results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanRelatedBundle failed."); if (S_FALSE == hr) @@ -5074,13 +4853,13 @@ EXTERN_C HRESULT BACallbackOnPlanRelatedBundle( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanRelatedBundle result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnPlanRelatedBundle result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.requestedState)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.requestedState)); ExitOnFailure(hr, "Failed to read requested state of OnPlanRelatedBundle result."); if (results.fCancel) @@ -5091,6 +4870,10 @@ EXTERN_C HRESULT BACallbackOnPlanRelatedBundle( *pRequestedState = results.requestedState; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5103,8 +4886,9 @@ EXTERN_C HRESULT BACallbackOnPlanRelatedBundleType( HRESULT hr = S_OK; BA_ONPLANRELATEDBUNDLETYPE_ARGS args = { }; BA_ONPLANRELATEDBUNDLETYPE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -5116,30 +4900,24 @@ EXTERN_C HRESULT BACallbackOnPlanRelatedBundleType( results.requestedType = *pRequestedType; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanRelatedBundleType args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzBundleId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleId); ExitOnFailure(hr, "Failed to write bundle id of OnPlanRelatedBundleType args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendedType); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendedType); ExitOnFailure(hr, "Failed to write recommended type of OnPlanRelatedBundleType args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanRelatedBundleType args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanRelatedBundleType results."); - hr = BuffWriteNumberToBuffer(&buffer, results.requestedType); + hr = BuffWriteNumberToBuffer(&bufferResults, results.requestedType); ExitOnFailure(hr, "Failed to write requested type of OnPlanRelatedBundleType results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanRelatedBundleType results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanRelatedBundleType failed."); if (S_FALSE == hr) @@ -5148,13 +4926,13 @@ EXTERN_C HRESULT BACallbackOnPlanRelatedBundleType( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanRelatedBundleType result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnPlanRelatedBundleType result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.requestedType)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.requestedType)); ExitOnFailure(hr, "Failed to read requested type of OnPlanRelatedBundleType result."); if (results.fCancel) @@ -5165,6 +4943,10 @@ EXTERN_C HRESULT BACallbackOnPlanRelatedBundleType( *pRequestedType = results.requestedType; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5177,8 +4959,9 @@ EXTERN_C HRESULT BACallbackOnPlanRestoreRelatedBundle( HRESULT hr = S_OK; BA_ONPLANRESTORERELATEDBUNDLE_ARGS args = { }; BA_ONPLANRESTORERELATEDBUNDLE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -5190,30 +4973,24 @@ EXTERN_C HRESULT BACallbackOnPlanRestoreRelatedBundle( results.requestedState = *pRequestedState; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanRestoreRelatedBundle args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzBundleId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleId); ExitOnFailure(hr, "Failed to write bundle id of OnPlanRestoreRelatedBundle args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendedState); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendedState); ExitOnFailure(hr, "Failed to write recommended state of OnPlanRestoreRelatedBundle args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanRestoreRelatedBundle args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanRestoreRelatedBundle results."); - hr = BuffWriteNumberToBuffer(&buffer, results.requestedState); + hr = BuffWriteNumberToBuffer(&bufferResults, results.requestedState); ExitOnFailure(hr, "Failed to write requested state of OnPlanRestoreRelatedBundle results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanRestoreRelatedBundle results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanRestoreRelatedBundle failed."); if (S_FALSE == hr) @@ -5222,13 +4999,13 @@ EXTERN_C HRESULT BACallbackOnPlanRestoreRelatedBundle( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanRestoreRelatedBundle result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnPlanRestoreRelatedBundle result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.requestedState)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.requestedState)); ExitOnFailure(hr, "Failed to read requested state of OnPlanRestoreRelatedBundle result."); if (results.fCancel) @@ -5239,6 +5016,10 @@ EXTERN_C HRESULT BACallbackOnPlanRestoreRelatedBundle( *pRequestedState = results.requestedState; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5251,8 +5032,9 @@ EXTERN_C HRESULT BACallbackOnPlanRollbackBoundary( HRESULT hr = S_OK; BA_ONPLANROLLBACKBOUNDARY_ARGS args = { }; BA_ONPLANROLLBACKBOUNDARY_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -5264,30 +5046,24 @@ EXTERN_C HRESULT BACallbackOnPlanRollbackBoundary( results.fTransaction = *pfTransaction; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanRollbackBoundary args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzRollbackBoundaryId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzRollbackBoundaryId); ExitOnFailure(hr, "Failed to write rollback boundary id of OnPlanRollbackBoundary args."); - hr = BuffWriteNumberToBuffer(&buffer, args.fRecommendedTransaction); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fRecommendedTransaction); ExitOnFailure(hr, "Failed to write recommended transaction of OnPlanRollbackBoundary args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanRollbackBoundary args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanRollbackBoundary results."); - hr = BuffWriteNumberToBuffer(&buffer, results.fTransaction); + hr = BuffWriteNumberToBuffer(&bufferResults, results.fTransaction); ExitOnFailure(hr, "Failed to write transaction of OnPlanRollbackBoundary results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanRollbackBoundary results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanRollbackBoundary failed."); if (S_FALSE == hr) @@ -5296,13 +5072,13 @@ EXTERN_C HRESULT BACallbackOnPlanRollbackBoundary( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanRollbackBoundary result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fTransaction)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fTransaction)); ExitOnFailure(hr, "Failed to read transaction of OnPlanRollbackBoundary result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnPlanRollbackBoundary result."); if (results.fCancel) @@ -5313,6 +5089,10 @@ EXTERN_C HRESULT BACallbackOnPlanRollbackBoundary( *pfTransaction = results.fTransaction; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5326,8 +5106,9 @@ EXTERN_C HRESULT BACallbackOnPlanPatchTarget( HRESULT hr = S_OK; BA_ONPLANPATCHTARGET_ARGS args = { }; BA_ONPLANPATCHTARGET_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -5340,33 +5121,27 @@ EXTERN_C HRESULT BACallbackOnPlanPatchTarget( results.requestedState = *pRequestedState; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanPatchTarget args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzPackageId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageId); ExitOnFailure(hr, "Failed to write package id of OnPlanPatchTarget args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzProductCode); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzProductCode); ExitOnFailure(hr, "Failed to write product code of OnPlanPatchTarget args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendedState); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendedState); ExitOnFailure(hr, "Failed to write recommended state of OnPlanPatchTarget args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanPatchTarget args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnPlanPatchTarget results."); - hr = BuffWriteNumberToBuffer(&buffer, results.requestedState); + hr = BuffWriteNumberToBuffer(&bufferResults, results.requestedState); ExitOnFailure(hr, "Failed to write requested state of OnPlanPatchTarget results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnPlanPatchTarget results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnPlanPatchTarget failed."); if (S_FALSE == hr) @@ -5375,13 +5150,13 @@ EXTERN_C HRESULT BACallbackOnPlanPatchTarget( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnPlanPatchTarget result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnPlanPatchTarget result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.requestedState)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.requestedState)); ExitOnFailure(hr, "Failed to read requrested state of OnPlanPatchTarget result."); if (results.fCancel) @@ -5392,6 +5167,10 @@ EXTERN_C HRESULT BACallbackOnPlanPatchTarget( *pRequestedState = results.requestedState; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5405,8 +5184,9 @@ EXTERN_C HRESULT BACallbackOnProgress( HRESULT hr = S_OK; BA_ONPROGRESS_ARGS args = { }; BA_ONPROGRESS_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -5417,27 +5197,21 @@ EXTERN_C HRESULT BACallbackOnProgress( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnProgress args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwProgressPercentage); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwProgressPercentage); ExitOnFailure(hr, "Failed to write progress of OnProgress args."); - hr = BuffWriteNumberToBuffer(&buffer, args.dwOverallPercentage); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwOverallPercentage); ExitOnFailure(hr, "Failed to write overall progress of OnProgress args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnProgress args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnProgress results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnProgress results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnProgress failed."); if (S_FALSE == hr) @@ -5446,17 +5220,18 @@ EXTERN_C HRESULT BACallbackOnProgress( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnProgress result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnProgress result."); LExit: hr = FilterExecuteResult(pUserExperience, hr, fRollback, results.fCancel, L"OnProgress"); - PipeFreeRpcResult(&result); - ReleaseNullBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -5469,8 +5244,9 @@ EXTERN_C HRESULT BACallbackOnRegisterBegin( HRESULT hr = S_OK; BA_ONREGISTERBEGIN_ARGS args = { }; BA_ONREGISTERBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -5481,27 +5257,21 @@ EXTERN_C HRESULT BACallbackOnRegisterBegin( results.registrationType = *pRegistrationType; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnRegisterBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendedRegistrationType); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendedRegistrationType); ExitOnFailure(hr, "Failed to write recommended registration type of OnRegisterBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnRegisterBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnRegisterBegin results."); - hr = BuffWriteNumberToBuffer(&buffer, results.registrationType); + hr = BuffWriteNumberToBuffer(&bufferResults, results.registrationType); ExitOnFailure(hr, "Failed to write registration type of OnRegisterBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnRegisterBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnRegisterBegin failed."); if (S_FALSE == hr) @@ -5510,13 +5280,13 @@ EXTERN_C HRESULT BACallbackOnRegisterBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnRegisterBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.fCancel)); ExitOnFailure(hr, "Failed to read cancel of OnRegisterBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.registrationType)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.registrationType)); ExitOnFailure(hr, "Failed to read registration type of OnRegisterBegin result."); if (results.fCancel) @@ -5529,6 +5299,10 @@ EXTERN_C HRESULT BACallbackOnRegisterBegin( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5540,8 +5314,9 @@ EXTERN_C HRESULT BACallbackOnRegisterComplete( HRESULT hr = S_OK; BA_ONREGISTERCOMPLETE_ARGS args = { }; BA_ONREGISTERCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -5550,24 +5325,18 @@ EXTERN_C HRESULT BACallbackOnRegisterComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnRegisterComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status type of OnRegisterComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnRegisterComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnRegisterComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnRegisterComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnRegisterComplete failed."); if (S_FALSE == hr) @@ -5576,6 +5345,10 @@ EXTERN_C HRESULT BACallbackOnRegisterComplete( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5587,8 +5360,9 @@ EXTERN_C HRESULT BACallbackOnRollbackMsiTransactionBegin( HRESULT hr = S_OK; BA_ONROLLBACKMSITRANSACTIONBEGIN_ARGS args = { }; BA_ONROLLBACKMSITRANSACTIONBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -5597,24 +5371,18 @@ EXTERN_C HRESULT BACallbackOnRollbackMsiTransactionBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnRollbackMsiTransactionBegin args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzTransactionId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzTransactionId); ExitOnFailure(hr, "Failed to write transaction id of OnRollbackMsiTransactionBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnRollbackMsiTransactionBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnRollbackMsiTransactionBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnRollbackMsiTransactionBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnRollbackMsiTransactionBegin failed."); if (S_FALSE == hr) @@ -5623,6 +5391,10 @@ EXTERN_C HRESULT BACallbackOnRollbackMsiTransactionBegin( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5637,8 +5409,9 @@ EXTERN_C HRESULT BACallbackOnRollbackMsiTransactionComplete( HRESULT hr = S_OK; BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS args = { }; BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -5652,36 +5425,30 @@ EXTERN_C HRESULT BACallbackOnRollbackMsiTransactionComplete( results.action = *pAction; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnRollbackMsiTransactionComplete args."); - hr = BuffWriteStringToBuffer(&buffer, args.wzTransactionId); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzTransactionId); ExitOnFailure(hr, "Failed to write transaction id of OnRollbackMsiTransactionComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status type of OnRollbackMsiTransactionComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.restart); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.restart); ExitOnFailure(hr, "Failed to write restart of OnRollbackMsiTransactionComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendation); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendation); ExitOnFailure(hr, "Failed to write recommedation of OnRollbackMsiTransactionComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnRollbackMsiTransactionComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnRollbackMsiTransactionComplete results."); - hr = BuffWriteNumberToBuffer(&buffer, results.action); + hr = BuffWriteNumberToBuffer(&bufferResults, results.action); ExitOnFailure(hr, "Failed to write action of OnRollbackMsiTransactionComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnRollbackMsiTransactionComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnRollbackMsiTransactionComplete failed."); if (S_FALSE == hr) @@ -5690,15 +5457,19 @@ EXTERN_C HRESULT BACallbackOnRollbackMsiTransactionComplete( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnRollbackMsiTransactionComplete result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.action)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read cancel of OnRollbackMsiTransactionComplete result."); *pAction = results.action; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5710,8 +5481,9 @@ EXTERN_C HRESULT BACallbackOnShutdown( HRESULT hr = S_OK; BA_ONSHUTDOWN_ARGS args = { sizeof(args) }; BA_ONSHUTDOWN_RESULTS results = { sizeof(results) }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -5721,24 +5493,18 @@ EXTERN_C HRESULT BACallbackOnShutdown( results.action = *pAction; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnShutdown args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnShutdown args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnShutdown results."); - hr = BuffWriteNumberToBuffer(&buffer, results.action); + hr = BuffWriteNumberToBuffer(&bufferResults, results.action); ExitOnFailure(hr, "Failed to write action of OnShutdown results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnShutdown results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnShutdown failed."); if (S_FALSE == hr) @@ -5747,17 +5513,18 @@ EXTERN_C HRESULT BACallbackOnShutdown( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnShutdown result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.action)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.action)); ExitOnFailure(hr, "Failed to read result action of OnShutdown result."); *pAction = results.action; LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -5769,8 +5536,9 @@ EXTERN_C HRESULT BACallbackOnStartup( HRESULT hr = S_OK; BA_ONSTARTUP_ARGS args = { }; BA_ONSTARTUP_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -5778,21 +5546,15 @@ EXTERN_C HRESULT BACallbackOnStartup( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnStartup args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnStartup args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnStartup results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnStartup results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnStartup failed."); if (S_FALSE == hr) @@ -5801,8 +5563,9 @@ EXTERN_C HRESULT BACallbackOnStartup( } LExit: - PipeFreeRpcResult(&result); - ReleaseBuffer(buffer); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); return hr; } @@ -5814,8 +5577,9 @@ EXTERN_C HRESULT BACallbackOnSystemRestorePointBegin( HRESULT hr = S_OK; BA_ONSYSTEMRESTOREPOINTBEGIN_ARGS args = { }; BA_ONSYSTEMRESTOREPOINTBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -5823,21 +5587,15 @@ EXTERN_C HRESULT BACallbackOnSystemRestorePointBegin( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnSystemRestorePointBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnSystemRestorePointBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnSystemRestorePointBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnSystemRestorePointBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnSystemRestorePointBegin failed."); if (S_FALSE == hr) @@ -5846,6 +5604,10 @@ EXTERN_C HRESULT BACallbackOnSystemRestorePointBegin( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5857,8 +5619,9 @@ EXTERN_C HRESULT BACallbackOnSystemRestorePointComplete( HRESULT hr = S_OK; BA_ONSYSTEMRESTOREPOINTCOMPLETE_ARGS args = { }; BA_ONSYSTEMRESTOREPOINTCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -5867,24 +5630,18 @@ EXTERN_C HRESULT BACallbackOnSystemRestorePointComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnSystemRestorePointComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnSystemRestorePointComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnSystemRestorePointComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnSystemRestorePointComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnSystemRestorePointComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnSystemRestorePointComplete failed."); if (S_FALSE == hr) @@ -5893,6 +5650,10 @@ EXTERN_C HRESULT BACallbackOnSystemRestorePointComplete( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5904,8 +5665,9 @@ EXTERN_C HRESULT BACallbackOnUnregisterBegin( HRESULT hr = S_OK; BA_ONUNREGISTERBEGIN_ARGS args = { }; BA_ONUNREGISTERBEGIN_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; SIZE_T iBuffer = 0; // Init structs. @@ -5916,27 +5678,21 @@ EXTERN_C HRESULT BACallbackOnUnregisterBegin( results.registrationType = *pRegistrationType; // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnUnregisterBegin args."); - hr = BuffWriteNumberToBuffer(&buffer, args.recommendedRegistrationType); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.recommendedRegistrationType); ExitOnFailure(hr, "Failed to write recommended registration type of OnUnregisterBegin args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnUnregisterBegin args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnUnregisterBegin results."); - hr = BuffWriteNumberToBuffer(&buffer, results.registrationType); + hr = BuffWriteNumberToBuffer(&bufferResults, results.registrationType); ExitOnFailure(hr, "Failed to write registration type of OnUnregisterBegin results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnUnregisterBegin results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnUnregisterBegin failed."); if (S_FALSE == hr) @@ -5945,10 +5701,10 @@ EXTERN_C HRESULT BACallbackOnUnregisterBegin( } // Read results. - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, &results.cbSize); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnUnregisterBegin result."); - hr = BuffReadNumber(result.pbData, result.cbData, &iBuffer, reinterpret_cast(&results.registrationType)); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.registrationType)); ExitOnFailure(hr, "Failed to read registration type of OnUnregisterBegin result."); if (BOOTSTRAPPER_REGISTRATION_TYPE_NONE < results.registrationType && BOOTSTRAPPER_REGISTRATION_TYPE_FULL >= results.registrationType) @@ -5957,6 +5713,10 @@ EXTERN_C HRESULT BACallbackOnUnregisterBegin( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -5968,8 +5728,9 @@ EXTERN_C HRESULT BACallbackOnUnregisterComplete( HRESULT hr = S_OK; BA_ONUNREGISTERCOMPLETE_ARGS args = { }; BA_ONUNREGISTERCOMPLETE_RESULTS results = { }; - BUFF_BUFFER buffer = { }; - PIPE_RPC_RESULT result = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; // Init structs. args.cbSize = sizeof(args); @@ -5978,24 +5739,18 @@ EXTERN_C HRESULT BACallbackOnUnregisterComplete( results.cbSize = sizeof(results); // Send args. - hr = BuffWriteNumberToBuffer(&buffer, args.cbSize); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.cbSize); ExitOnFailure(hr, "Failed to write size of OnUnregisterComplete args."); - hr = BuffWriteNumberToBuffer(&buffer, args.hrStatus); + hr = BuffWriteNumberToBuffer(&bufferArgs, args.hrStatus); ExitOnFailure(hr, "Failed to write status of OnUnregisterComplete args."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnUnregisterComplete args."); - // Send results. - hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); + hr = BuffWriteNumberToBuffer(&bufferResults, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnUnregisterComplete results."); - hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); - ExitOnFailure(hr, "Failed to add padding to OnUnregisterComplete results."); - // Callback. - hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE, &buffer, &result); + hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE, &bufferArgs, &bufferResults, &rpc); ExitOnFailure(hr, "BA OnUnregisterComplete failed."); if (S_FALSE == hr) @@ -6004,6 +5759,10 @@ EXTERN_C HRESULT BACallbackOnUnregisterComplete( } LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -6054,38 +5813,53 @@ static HRESULT FilterExecuteResult( static HRESULT SendBAMessage( __in BURN_USER_EXPERIENCE* pUserExperience, __in BOOTSTRAPPER_APPLICATION_MESSAGE message, - __in BUFF_BUFFER* pBuffer, + __in BUFF_BUFFER* pBufferArgs, + __in BUFF_BUFFER* pBufferResults, __in PIPE_RPC_RESULT* pResult ) { HRESULT hr = S_OK; + BUFF_BUFFER buffer = { }; if (PipeRpcInitialized(&pUserExperience->hBARpcPipe)) { - hr = PipeRpcRequest(&pUserExperience->hBARpcPipe, message, pBuffer->pbData, pBuffer->cbData, pResult); + // Send the combined counted args and results buffer to the BA. + hr = CombineArgsAndResults(pBufferArgs, pBufferResults, &buffer); + if (SUCCEEDED(hr)) + { + hr = PipeRpcRequest(&pUserExperience->hBARpcPipe, message, buffer.pbData, buffer.cbData, pResult); + } } else { hr = S_FALSE; } + ReleaseBuffer(buffer); return hr; } static HRESULT SendBAMessageFromInactiveEngine( - __in BURN_USER_EXPERIENCE* pUserExperience, - __in BOOTSTRAPPER_APPLICATION_MESSAGE message, - __in BUFF_BUFFER* pBuffer, - __in PIPE_RPC_RESULT* pResult + __in BURN_USER_EXPERIENCE* pUserExperience, + __in BOOTSTRAPPER_APPLICATION_MESSAGE message, + __in BUFF_BUFFER* pBufferArgs, + __in BUFF_BUFFER* pBufferResults, + __in PIPE_RPC_RESULT* pResult ) { HRESULT hr = S_OK; + BUFF_BUFFER buffer = { }; if (PipeRpcInitialized(&pUserExperience->hBARpcPipe)) { BootstrapperApplicationDeactivateEngine(pUserExperience); - hr = PipeRpcRequest(&pUserExperience->hBARpcPipe, message, pBuffer->pbData, pBuffer->cbData, pResult); + // Send the combined counted args and results buffer to the BA. + hr = CombineArgsAndResults(pBufferArgs, pBufferResults, &buffer); + if (SUCCEEDED(hr)) + { + hr = PipeRpcRequest(&pUserExperience->hBARpcPipe, message, buffer.pbData, buffer.cbData, pResult); + } BootstrapperApplicationActivateEngine(pUserExperience); } @@ -6094,5 +5868,26 @@ static HRESULT SendBAMessageFromInactiveEngine( hr = S_FALSE; } + ReleaseBuffer(buffer); + return hr; +} + +static HRESULT CombineArgsAndResults( + __in BUFF_BUFFER* pBufferArgs, + __in BUFF_BUFFER* pBufferResults, + __in BUFF_BUFFER* pBufferCombined + ) +{ + HRESULT hr = S_OK; + + // Write args to buffer. + hr = BuffWriteStreamToBuffer(pBufferCombined, pBufferArgs->pbData, pBufferArgs->cbData); + ExitOnFailure(hr, "Failed to write args buffer."); + + // Write results to buffer. + hr = BuffWriteStreamToBuffer(pBufferCombined, pBufferResults->pbData, pBufferResults->cbData); + ExitOnFailure(hr, "Failed to write results buffer."); + +LExit: return hr; } diff --git a/src/burn/engine/baengine.cpp b/src/burn/engine/baengine.cpp index 36af681a2..78c4cd506 100644 --- a/src/burn/engine/baengine.cpp +++ b/src/burn/engine/baengine.cpp @@ -133,7 +133,8 @@ static void CALLBACK FreeQueueItem( static HRESULT BAEngineGetPackageCount( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -142,17 +143,14 @@ static HRESULT BAEngineGetPackageCount( BAENGINE_GETPACKAGECOUNT_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineGetPackageCount args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineGetPackageCount args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineGetPackageCount results."); - // Get results. + // Execute. ExternalEngineGetPackageCount(pContext->pEngineState, &results.cPackages); // Write results. @@ -168,7 +166,8 @@ static HRESULT BAEngineGetPackageCount( static HRESULT BAEngineGetVariableNumeric( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -178,22 +177,19 @@ static HRESULT BAEngineGetVariableNumeric( LPWSTR sczVariable = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineGetVariableNumeric args."); - hr = BuffReaderReadString(pReader, &sczVariable); + hr = BuffReaderReadString(pReaderArgs, &sczVariable); ExitOnFailure(hr, "Failed to read variable name of BAEngineGetVariableNumeric args."); args.wzVariable = sczVariable; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineGetVariableNumeric args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineGetVariableNumeric results."); - // Get results. + // Execute. hr = ExternalEngineGetVariableNumeric(pContext->pEngineState, args.wzVariable, &results.llValue); // Write results. @@ -210,7 +206,8 @@ static HRESULT BAEngineGetVariableNumeric( static HRESULT BAEngineGetVariableString( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -222,27 +219,24 @@ static HRESULT BAEngineGetVariableString( DWORD cchValue = 0; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineGetVariableString args."); - hr = BuffReaderReadString(pReader, &sczVariable); + hr = BuffReaderReadString(pReaderArgs, &sczVariable); ExitOnFailure(hr, "Failed to read variable name of BAEngineGetVariableString args."); args.wzVariable = sczVariable; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineGetVariableString args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineGetVariableString results."); - hr = BuffReaderReadNumber(pReader, &cchValue); + hr = BuffReaderReadNumber(pReaderResults, &cchValue); ExitOnFailure(hr, "Failed to read size of BAEngineGetVariableString results."); results.cchValue = cchValue; - // Get results. + // Execute. hr = VariableGetString(&pContext->pEngineState->variables, args.wzVariable, &sczValue); if (E_NOTFOUND == hr) { @@ -272,7 +266,8 @@ static HRESULT BAEngineGetVariableString( static HRESULT BAEngineGetVariableVersion( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -284,27 +279,24 @@ static HRESULT BAEngineGetVariableVersion( DWORD cchValue = 0; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineGetVariableVersion args."); - hr = BuffReaderReadString(pReader, &sczVariable); + hr = BuffReaderReadString(pReaderArgs, &sczVariable); ExitOnFailure(hr, "Failed to read variable name of BAEngineGetVariableVersion args."); args.wzVariable = sczVariable; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineGetVariableVersion args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineGetVariableVersion results."); - hr = BuffReaderReadNumber(pReader, &cchValue); + hr = BuffReaderReadNumber(pReaderResults, &cchValue); ExitOnFailure(hr, "Failed to read size of BAEngineGetVariableVersion results."); results.cchValue = cchValue; - // Get results. + // Execute. hr = VariableGetVersion(&pContext->pEngineState->variables, args.wzVariable, &pVersion); ExitOnFailure(hr, "Failed to get version variable: %ls", sczVariable); @@ -330,7 +322,8 @@ static HRESULT BAEngineGetVariableVersion( static HRESULT BAEngineGetRelatedBundleVariable( __in BAENGINE_CONTEXT* /* pContext */, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -342,29 +335,26 @@ static HRESULT BAEngineGetRelatedBundleVariable( LPWSTR sczValue = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineGetRelatedBundleVariable args."); - hr = BuffReaderReadString(pReader, &sczBundleId); + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); ExitOnFailure(hr, "Failed to read bundle id of BAEngineGetRelatedBundleVariable args."); - hr = BuffReaderReadString(pReader, &sczVariable); + hr = BuffReaderReadString(pReaderArgs, &sczVariable); ExitOnFailure(hr, "Failed to read variable name of BAEngineGetRelatedBundleVariable args."); args.wzBundleId = sczBundleId; args.wzVariable = sczVariable; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineGetRelatedBundleVariable args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineGetRelatedBundleVariable results."); - hr = BuffReaderReadNumber(pReader, &results.cchValue); // ignored, overwritten below. + hr = BuffReaderReadNumber(pReaderResults, &results.cchValue); // ignored, overwritten below. ExitOnFailure(hr, "Failed to read size of BAEngineGetRelatedBundleVariable results."); - // Get results. + // Execute. hr = BundleGetBundleVariable(args.wzBundleId, args.wzVariable, &sczValue); ExitOnFailure(hr, "Failed to get related bundle variable: %ls", sczVariable); @@ -391,7 +381,8 @@ static HRESULT BAEngineGetRelatedBundleVariable( static HRESULT BAEngineFormatString( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -403,25 +394,22 @@ static HRESULT BAEngineFormatString( SIZE_T cchOut = 0; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineFormatString args."); - hr = BuffReaderReadString(pReader, &sczIn); + hr = BuffReaderReadString(pReaderArgs, &sczIn); ExitOnFailure(hr, "Failed to read string to format of BAEngineFormatString args."); args.wzIn = sczIn; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineFormatString args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineFormatString results."); - hr = BuffReaderReadNumber(pReader, &results.cchOut); // ignored, overwritten below. + hr = BuffReaderReadNumber(pReaderResults, &results.cchOut); // ignored, overwritten below. ExitOnFailure(hr, "Failed to read allowed length of formatted string of BAEngineFormatString results."); - // Get results. + // Execute. hr = VariableFormatString(&pContext->pEngineState->variables, args.wzIn, &sczOut, &cchOut); ExitOnFailure(hr, "Failed to format string"); @@ -447,7 +435,8 @@ static HRESULT BAEngineFormatString( static HRESULT BAEngineEscapeString( __in BAENGINE_CONTEXT* /* pContext */, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -458,25 +447,22 @@ static HRESULT BAEngineEscapeString( LPWSTR sczOut = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineEscapeString args."); - hr = BuffReaderReadString(pReader, &sczIn); + hr = BuffReaderReadString(pReaderArgs, &sczIn); ExitOnFailure(hr, "Failed to read string to escape of BAEngineEscapeString args."); args.wzIn = sczIn; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineEscapeString args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineEscapeString results."); - hr = BuffReaderReadNumber(pReader, &results.cchOut); // ignored, overwritten below. + hr = BuffReaderReadNumber(pReaderResults, &results.cchOut); // ignored, overwritten below. ExitOnFailure(hr, "Failed to read allowed length of escaped string of BAEngineEscapeString results."); - // Get results. + // Execute. hr = VariableEscapeString(args.wzIn, &sczOut); ExitOnFailure(hr, "Failed to format string"); @@ -502,7 +488,8 @@ static HRESULT BAEngineEscapeString( static HRESULT BAEngineEvaluateCondition( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -512,22 +499,19 @@ static HRESULT BAEngineEvaluateCondition( LPWSTR sczCondition = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineEvaluateCondition args."); - hr = BuffReaderReadString(pReader, &sczCondition); + hr = BuffReaderReadString(pReaderArgs, &sczCondition); ExitOnFailure(hr, "Failed to read condition of BAEngineEvaluateCondition args."); args.wzCondition = sczCondition; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineEvaluateCondition args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineEvaluateCondition results."); - // Get results. + // Execute. hr = ConditionEvaluate(&pContext->pEngineState->variables, args.wzCondition, &results.f); ExitOnFailure(hr, "Failed to evalute condition."); @@ -545,7 +529,8 @@ static HRESULT BAEngineEvaluateCondition( } static HRESULT BAEngineLog( - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -556,13 +541,13 @@ static HRESULT BAEngineLog( REPORT_LEVEL rl = REPORT_NONE; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineLog args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.level)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.level)); ExitOnFailure(hr, "Failed to read size of BAEngineLog args."); - hr = BuffReaderReadString(pReader, &sczMessage); + hr = BuffReaderReadString(pReaderArgs, &sczMessage); ExitOnFailure(hr, "Failed to read variable name of BAEngineLog args."); switch (args.level) @@ -589,14 +574,11 @@ static HRESULT BAEngineLog( args.wzMessage = sczMessage; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnFailure(hr, "Failed to skip extra data of BAEngineLog args."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineLog results."); - // Get results. + // Execute. hr = ExternalEngineLog(rl, args.wzMessage); ExitOnFailure(hr, "Failed to log BA message."); @@ -611,7 +593,8 @@ static HRESULT BAEngineLog( static HRESULT BAEngineSendEmbeddedError( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -621,28 +604,25 @@ static HRESULT BAEngineSendEmbeddedError( LPWSTR sczMessage = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSendEmbeddedError args."); - hr = BuffReaderReadNumber(pReader, &args.dwErrorCode); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwErrorCode); ExitOnFailure(hr, "Failed to read error code of BAEngineSendEmbeddedError args."); - hr = BuffReaderReadString(pReader, &sczMessage); + hr = BuffReaderReadString(pReaderArgs, &sczMessage); ExitOnFailure(hr, "Failed to read condition of BAEngineSendEmbeddedError args."); args.wzMessage = sczMessage; - hr = BuffReaderReadNumber(pReader, &args.dwUIHint); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwUIHint); ExitOnFailure(hr, "Failed to read UI hint of BAEngineSendEmbeddedError args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineSendEmbeddedError args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSendEmbeddedError results."); - // Get results. + // Execute. hr = ExternalEngineSendEmbeddedError(pContext->pEngineState, args.dwErrorCode, args.wzMessage, args.dwUIHint, &results.nResult); ExitOnFailure(hr, "Failed to send embedded error."); @@ -660,7 +640,8 @@ static HRESULT BAEngineSendEmbeddedError( static HRESULT BAEngineSendEmbeddedProgress( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -669,23 +650,20 @@ static HRESULT BAEngineSendEmbeddedProgress( BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSendEmbeddedProgress args."); - hr = BuffReaderReadNumber(pReader, &args.dwProgressPercentage); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwProgressPercentage); ExitOnFailure(hr, "Failed to read progress of BAEngineSendEmbeddedProgress args."); - hr = BuffReaderReadNumber(pReader, &args.dwOverallProgressPercentage); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallProgressPercentage); ExitOnFailure(hr, "Failed to read overall progress of BAEngineSendEmbeddedProgress args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineSendEmbeddedProgress args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSendEmbeddedProgress results."); - // Get results. + // Execute. hr = ExternalEngineSendEmbeddedProgress(pContext->pEngineState, args.dwProgressPercentage, args.dwOverallProgressPercentage, &results.nResult); ExitOnFailure(hr, "Failed to send embedded error."); @@ -702,7 +680,8 @@ static HRESULT BAEngineSendEmbeddedProgress( static HRESULT BAEngineSetUpdate( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -715,43 +694,40 @@ static HRESULT BAEngineSetUpdate( LPWSTR sczUpdatePackageId = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetUpdate args."); - hr = BuffReaderReadString(pReader, &sczLocalSource); + hr = BuffReaderReadString(pReaderArgs, &sczLocalSource); ExitOnFailure(hr, "Failed to read local source of BAEngineSetUpdate args."); args.wzLocalSource = sczLocalSource; - hr = BuffReaderReadString(pReader, &sczDownloadSource); + hr = BuffReaderReadString(pReaderArgs, &sczDownloadSource); ExitOnFailure(hr, "Failed to read download source of BAEngineSetUpdate args."); args.wzDownloadSource = sczDownloadSource; - hr = BuffReaderReadNumber64(pReader, &args.qwSize); + hr = BuffReaderReadNumber64(pReaderArgs, &args.qwSize); ExitOnFailure(hr, "Failed to read update size of BAEngineSetUpdate args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.hashType)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hashType)); ExitOnFailure(hr, "Failed to read hash type of BAEngineSetUpdate args."); - hr = BuffReaderReadString(pReader, &sczHash); + hr = BuffReaderReadString(pReaderArgs, &sczHash); ExitOnFailure(hr, "Failed to read hash of BAEngineSetUpdate args."); args.wzHash = sczHash; - hr = BuffReaderReadString(pReader, &sczUpdatePackageId); + hr = BuffReaderReadString(pReaderArgs, &sczUpdatePackageId); ExitOnFailure(hr, "Failed to read update package id of BAEngineSetUpdate args."); args.wzUpdatePackageId = sczUpdatePackageId; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineSetUpdate args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetUpdate results."); - // Get results. + // Execute. hr = ExternalEngineSetUpdate(pContext->pEngineState, args.wzLocalSource, args.wzDownloadSource, args.qwSize, args.hashType, args.wzHash, args.wzUpdatePackageId); ExitOnFailure(hr, "Failed to set update."); @@ -769,7 +745,8 @@ static HRESULT BAEngineSetUpdate( static HRESULT BAEngineSetLocalSource( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -781,32 +758,29 @@ static HRESULT BAEngineSetLocalSource( LPWSTR sczPath = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetLocalSource args."); - hr = BuffReaderReadString(pReader, &sczPackageOrContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); ExitOnFailure(hr, "Failed to read package or container id of BAEngineSetLocalSource args."); args.wzPackageOrContainerId = sczPackageOrContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of BAEngineSetLocalSource args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderReadString(pReader, &sczPath); + hr = BuffReaderReadString(pReaderArgs, &sczPath); ExitOnFailure(hr, "Failed to read path of BAEngineSetLocalSource args."); args.wzPath = sczPath; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineSetLocalSource args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetLocalSource results."); - // Get results. + // Execute. hr = ExternalEngineSetLocalSource(pContext->pEngineState, args.wzPackageOrContainerId, args.wzPayloadId, args.wzPath); ExitOnFailure(hr, "Failed to set local source."); @@ -823,7 +797,8 @@ static HRESULT BAEngineSetLocalSource( static HRESULT BAEngineSetDownloadSource( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -838,47 +813,44 @@ static HRESULT BAEngineSetDownloadSource( LPWSTR sczAuthorizationHeader = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetDownloadSource args."); - hr = BuffReaderReadString(pReader, &sczPackageOrContainerId); + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); ExitOnFailure(hr, "Failed to read package or container id of BAEngineSetDownloadSource args."); args.wzPackageOrContainerId = sczPackageOrContainerId; - hr = BuffReaderReadString(pReader, &sczPayloadId); + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); ExitOnFailure(hr, "Failed to read payload id of BAEngineSetDownloadSource args."); args.wzPayloadId = sczPayloadId; - hr = BuffReaderReadString(pReader, &sczUrl); + hr = BuffReaderReadString(pReaderArgs, &sczUrl); ExitOnFailure(hr, "Failed to read url of BAEngineSetDownloadSource args."); args.wzUrl = sczUrl; - hr = BuffReaderReadString(pReader, &sczUser); + hr = BuffReaderReadString(pReaderArgs, &sczUser); ExitOnFailure(hr, "Failed to read user of BAEngineSetDownloadSource args."); args.wzUser = sczUser; - hr = BuffReaderReadString(pReader, &sczPassword); + hr = BuffReaderReadString(pReaderArgs, &sczPassword); ExitOnFailure(hr, "Failed to read password of BAEngineSetDownloadSource args."); args.wzPassword = sczPassword; - hr = BuffReaderReadString(pReader, &sczAuthorizationHeader); + hr = BuffReaderReadString(pReaderArgs, &sczAuthorizationHeader); ExitOnFailure(hr, "Failed to read authorization header of BAEngineSetDownloadSource args."); args.wzAuthorizationHeader = sczAuthorizationHeader; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineSetDownloadSource args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetDownloadSource results."); - // Get results. + // Execute. hr = ExternalEngineSetDownloadSource(pContext->pEngineState, args.wzPackageOrContainerId, args.wzPayloadId, args.wzUrl, args.wzUser, args.wzPassword, args.wzAuthorizationHeader); ExitOnFailure(hr, "Failed to set download source."); @@ -899,7 +871,8 @@ static HRESULT BAEngineSetDownloadSource( static HRESULT BAEngineSetVariableNumeric( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -909,25 +882,22 @@ static HRESULT BAEngineSetVariableNumeric( LPWSTR sczVariable = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetVariableNumeric args."); - hr = BuffReaderReadString(pReader, &sczVariable); + hr = BuffReaderReadString(pReaderArgs, &sczVariable); ExitOnFailure(hr, "Failed to read variable of BAEngineSetVariableNumeric args."); args.wzVariable = sczVariable; - hr = BuffReaderReadNumber64(pReader, reinterpret_cast(&args.llValue)); + hr = BuffReaderReadNumber64(pReaderArgs, reinterpret_cast(&args.llValue)); ExitOnFailure(hr, "Failed to read formatted flag of BAEngineSetVariableNumeric results."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineSetVariableNumeric args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetVariableNumeric results."); - // Get results. + // Execute. hr = ExternalEngineSetVariableNumeric(pContext->pEngineState, args.wzVariable, args.llValue); ExitOnFailure(hr, "Failed to set numeric variable."); @@ -942,7 +912,8 @@ static HRESULT BAEngineSetVariableNumeric( static HRESULT BAEngineSetVariableString( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -953,30 +924,27 @@ static HRESULT BAEngineSetVariableString( LPWSTR sczValue = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetVariableString args."); - hr = BuffReaderReadString(pReader, &sczVariable); + hr = BuffReaderReadString(pReaderArgs, &sczVariable); ExitOnFailure(hr, "Failed to read variable of BAEngineSetVariableString args."); args.wzVariable = sczVariable; - hr = BuffReaderReadString(pReader, &sczValue); + hr = BuffReaderReadString(pReaderArgs, &sczValue); ExitOnFailure(hr, "Failed to read value of BAEngineSetVariableString args."); args.wzValue = sczValue; - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.fFormatted)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fFormatted)); ExitOnFailure(hr, "Failed to read formatted flag of BAEngineSetVariableString results."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineSetVariableString args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetVariableString results."); - // Get results. + // Execute. hr = ExternalEngineSetVariableString(pContext->pEngineState, args.wzVariable, args.wzValue, args.fFormatted); ExitOnFailure(hr, "Failed to set string variable."); @@ -992,7 +960,8 @@ static HRESULT BAEngineSetVariableString( static HRESULT BAEngineSetVariableVersion( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1003,27 +972,24 @@ static HRESULT BAEngineSetVariableVersion( LPWSTR sczValue = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetVariableVersion args."); - hr = BuffReaderReadString(pReader, &sczVariable); + hr = BuffReaderReadString(pReaderArgs, &sczVariable); ExitOnFailure(hr, "Failed to read variable of BAEngineSetVariableVersion args."); args.wzVariable = sczVariable; - hr = BuffReaderReadString(pReader, &sczValue); + hr = BuffReaderReadString(pReaderArgs, &sczValue); ExitOnFailure(hr, "Failed to read value of BAEngineSetVariableVersion args."); args.wzValue = sczValue; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineSetVariableVersion args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetVariableVersion results."); - // Get results. + // Execute. hr = ExternalEngineSetVariableVersion(pContext->pEngineState, args.wzVariable, args.wzValue); ExitOnFailure(hr, "Failed to set variable version."); @@ -1039,7 +1005,8 @@ static HRESULT BAEngineSetVariableVersion( static HRESULT BAEngineCloseSplashScreen( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1048,17 +1015,14 @@ static HRESULT BAEngineCloseSplashScreen( BAENGINE_CLOSESPLASHSCREEN_RESULTS results = { }; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineCloseSplashScreen args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineCloseSplashScreen args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineCloseSplashScreen results."); - // Get results. + // Execute. ExternalEngineCloseSplashScreen(pContext->pEngineState); // Write results. @@ -1071,7 +1035,8 @@ static HRESULT BAEngineCloseSplashScreen( static HRESULT BAEngineCompareVersions( __in BAENGINE_CONTEXT* /* pContext */, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1082,27 +1047,24 @@ static HRESULT BAEngineCompareVersions( LPWSTR sczVersion2 = NULL; // Read args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineCompareVersions args."); - hr = BuffReaderReadString(pReader, &sczVersion1); + hr = BuffReaderReadString(pReaderArgs, &sczVersion1); ExitOnFailure(hr, "Failed to read first input of BAEngineCompareVersions args."); args.wzVersion1 = sczVersion1; - hr = BuffReaderReadString(pReader, &sczVersion2); + hr = BuffReaderReadString(pReaderArgs, &sczVersion2); ExitOnFailure(hr, "Failed to read second input of BAEngineCompareVersions args."); args.wzVersion2 = sczVersion2; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineCompareVersions args size does not match expected size."); - // Read results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineCompareVersions results."); - // Get results. + // Execute. hr = ExternalEngineCompareVersions(args.wzVersion1, args.wzVersion2, &results.nResult); ExitOnFailure(hr, "Failed to compare versions."); @@ -1122,7 +1084,8 @@ static HRESULT BAEngineCompareVersions( static HRESULT BAEngineDetect( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1130,18 +1093,15 @@ static HRESULT BAEngineDetect( BAENGINE_DETECT_ARGS args = { }; BAENGINE_DETECT_RESULTS results = { }; - // Unpack args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineDetect args."); - hr = BuffReaderReadNumber64(pReader, &args.hwndParent); + hr = BuffReaderReadNumber64(pReaderArgs, &args.hwndParent); ExitOnFailure(hr, "Failed to read parent window of BAEngineDetect args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineDetect args size does not match expected size."); - - // Unpack results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineDetect results."); // Execute. @@ -1158,7 +1118,8 @@ static HRESULT BAEngineDetect( static HRESULT BAEnginePlan( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1166,18 +1127,15 @@ static HRESULT BAEnginePlan( BAENGINE_PLAN_ARGS args = { }; BAENGINE_PLAN_RESULTS results = { }; - // Unpack args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEnginePlan args."); - hr = BuffReaderReadNumber(pReader, reinterpret_cast(&args.action)); + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.action)); ExitOnFailure(hr, "Failed to read plan action of BAEnginePlan args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEnginePlan args size does not match expected size."); - - // Unpack results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEnginePlan results."); // Execute. @@ -1194,7 +1152,8 @@ static HRESULT BAEnginePlan( static HRESULT BAEngineElevate( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1202,18 +1161,15 @@ static HRESULT BAEngineElevate( BAENGINE_ELEVATE_ARGS args = { }; BAENGINE_ELEVATE_RESULTS results = { }; - // Unpack args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineElevate args."); - hr = BuffReaderReadNumber64(pReader, &args.hwndParent); + hr = BuffReaderReadNumber64(pReaderArgs, &args.hwndParent); ExitOnFailure(hr, "Failed to read parent window of BAEngineElevate args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineElevate args size does not match expected size."); - - // Unpack results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineElevate results."); // Execute. @@ -1230,7 +1186,8 @@ static HRESULT BAEngineElevate( static HRESULT BAEngineApply( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1238,18 +1195,15 @@ static HRESULT BAEngineApply( BAENGINE_APPLY_ARGS args = { }; BAENGINE_APPLY_RESULTS results = { }; - // Unpack args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineApply args."); - hr = BuffReaderReadNumber64(pReader, &args.hwndParent); + hr = BuffReaderReadNumber64(pReaderArgs, &args.hwndParent); ExitOnFailure(hr, "Failed to read parent window of BAEngineApply args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineApply args size does not match expected size."); - - // Unpack results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineApply results."); // Execute. @@ -1266,7 +1220,8 @@ static HRESULT BAEngineApply( static HRESULT BAEngineQuit( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1274,18 +1229,15 @@ static HRESULT BAEngineQuit( BAENGINE_QUIT_ARGS args = { }; BAENGINE_QUIT_RESULTS results = { }; - // Unpack args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineQuit args."); - hr = BuffReaderReadNumber(pReader, &args.dwExitCode); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwExitCode); ExitOnFailure(hr, "Failed to read size of BAEngineQuit args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineQuit args size does not match expected size."); - - // Unpack results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineQuit results."); // Execute. @@ -1302,7 +1254,8 @@ static HRESULT BAEngineQuit( static HRESULT BAEngineLaunchApprovedExe( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1312,31 +1265,28 @@ static HRESULT BAEngineLaunchApprovedExe( LPWSTR sczApprovedExeForElevationId = NULL; LPWSTR sczArguments = NULL; - // Unpack args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineLaunchApprovedExe args."); - hr = BuffReaderReadNumber64(pReader, &args.hwndParent); + hr = BuffReaderReadNumber64(pReaderArgs, &args.hwndParent); ExitOnFailure(hr, "Failed to read parent window of BAEngineLaunchApprovedExe args."); - hr = BuffReaderReadString(pReader, &sczApprovedExeForElevationId); + hr = BuffReaderReadString(pReaderArgs, &sczApprovedExeForElevationId); ExitOnFailure(hr, "Failed to read approved exe elevation id of BAEngineLaunchApprovedExe args."); args.wzApprovedExeForElevationId = sczApprovedExeForElevationId; - hr = BuffReaderReadString(pReader, &sczArguments); + hr = BuffReaderReadString(pReaderArgs, &sczArguments); ExitOnFailure(hr, "Failed to read arguments of BAEngineLaunchApprovedExe args."); args.wzArguments = sczArguments; - hr = BuffReaderReadNumber(pReader, &args.dwWaitForInputIdleTimeout); + hr = BuffReaderReadNumber(pReaderArgs, &args.dwWaitForInputIdleTimeout); ExitOnFailure(hr, "Failed to read wait for idle input timeout of BAEngineLaunchApprovedExe args."); - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineLaunchApprovedExe args size does not match expected size."); - - // Unpack results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineLaunchApprovedExe results."); // Execute. @@ -1355,7 +1305,8 @@ static HRESULT BAEngineLaunchApprovedExe( static HRESULT BAEngineSetUpdateSource( __in BAENGINE_CONTEXT* pContext, - __in BUFF_READER* pReader, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, __in BUFF_BUFFER* pBuffer ) { @@ -1365,25 +1316,22 @@ static HRESULT BAEngineSetUpdateSource( LPWSTR sczUrl = NULL; LPWSTR sczAuthorizationHeader = NULL; - // Unpack args. - hr = BuffReaderReadNumber(pReader, &args.cbSize); + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetUpdateSource args."); - hr = BuffReaderReadString(pReader, &sczUrl); + hr = BuffReaderReadString(pReaderArgs, &sczUrl); ExitOnFailure(hr, "Failed to read url of BAEngineSetUpdateSource args."); args.wzUrl = sczUrl; - hr = BuffReaderReadString(pReader, &sczAuthorizationHeader); + hr = BuffReaderReadString(pReaderArgs, &sczAuthorizationHeader); ExitOnFailure(hr, "Failed to read authorization header of BAEngineSetUpdateSource args."); args.wzAuthorizationHeader = sczAuthorizationHeader; - hr = BuffReaderSkipExtraData(pReader, sizeof(args), args.cbSize); - ExitOnRootFailure(hr, "BAEngineSetUpdateSource args size does not match expected size."); - - // Unpack results. - hr = BuffReaderReadNumber(pReader, &results.cbSize); + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.cbSize); ExitOnFailure(hr, "Failed to read size of BAEngineSetUpdateSource results."); // Execute. @@ -1401,6 +1349,40 @@ static HRESULT BAEngineSetUpdateSource( return hr; } +static HRESULT ParseArgsAndResults( + __in_bcount(cbData) LPCBYTE pbData, + __in SIZE_T cbData, + __in BUFF_READER* pBufferArgs, + __in BUFF_READER* pBufferResults +) +{ + HRESULT hr = S_OK; + SIZE_T iData = 0; + DWORD dw = 0; + + // Get the args reader size and point to the data just after the size. + hr = BuffReadNumber(pbData, cbData, &iData, &dw); + ExitOnFailure(hr, "Failed to parse size of args"); + + pBufferArgs->pbData = pbData + iData; + pBufferArgs->cbData = dw; + pBufferArgs->iBuffer = 0; + + // Get the results reader size and point to the data just after the size. + hr = ::SIZETAdd(iData, dw, &iData); + ExitOnFailure(hr, "Failed to advance index beyond args"); + + hr = BuffReadNumber(pbData, cbData, &iData, &dw); + ExitOnFailure(hr, "Failed to parse size of results"); + + pBufferResults->pbData = pbData + iData; + pBufferResults->cbData = dw; + pBufferResults->iBuffer = 0; + +LExit: + return hr; +} + HRESULT WINAPI EngineForApplicationProc( __in BAENGINE_CONTEXT* pContext, __in BOOTSTRAPPER_ENGINE_MESSAGE message, @@ -1409,99 +1391,104 @@ HRESULT WINAPI EngineForApplicationProc( ) { HRESULT hr = S_OK; - BUFF_READER reader = { pbData, cbData, 0 }; - BUFF_BUFFER buffer = { }; + BUFF_READER readerArgs = { }; + BUFF_READER readerResults = { }; + BUFF_BUFFER bufferResponse = { }; - switch (message) + hr = ParseArgsAndResults(pbData, cbData, &readerArgs, &readerResults); + if (SUCCEEDED(hr)) { - case BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT: - hr = BAEngineGetPackageCount(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC: - hr = BAEngineGetVariableNumeric(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING: - hr = BAEngineGetVariableString(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION: - hr = BAEngineGetVariableVersion(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING: - hr = BAEngineFormatString(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING: - hr = BAEngineEscapeString(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION: - hr = BAEngineEvaluateCondition(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_LOG: - hr = BAEngineLog(&reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR: - hr = BAEngineSendEmbeddedError(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS: - hr = BAEngineSendEmbeddedProgress(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE: - hr = BAEngineSetUpdate(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE: - hr = BAEngineSetLocalSource(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE: - hr = BAEngineSetDownloadSource(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC: - hr = BAEngineSetVariableNumeric(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING: - hr = BAEngineSetVariableString(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION: - hr = BAEngineSetVariableVersion(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN: - hr = BAEngineCloseSplashScreen(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_DETECT: - hr = BAEngineDetect(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_PLAN: - hr = BAEnginePlan(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE: - hr = BAEngineElevate(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_APPLY: - hr = BAEngineApply(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_QUIT: - hr = BAEngineQuit(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE: - hr = BAEngineLaunchApprovedExe(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE: - hr = BAEngineSetUpdateSource(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS: - hr = BAEngineCompareVersions(pContext, &reader, &buffer); - break; - case BOOTSTRAPPER_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE: - hr = BAEngineGetRelatedBundleVariable(pContext, &reader, &buffer); - break; - default: - hr = E_NOTIMPL; - break; + switch (message) + { + case BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT: + hr = BAEngineGetPackageCount(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC: + hr = BAEngineGetVariableNumeric(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING: + hr = BAEngineGetVariableString(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION: + hr = BAEngineGetVariableVersion(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING: + hr = BAEngineFormatString(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING: + hr = BAEngineEscapeString(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION: + hr = BAEngineEvaluateCondition(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_LOG: + hr = BAEngineLog(&readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR: + hr = BAEngineSendEmbeddedError(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS: + hr = BAEngineSendEmbeddedProgress(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE: + hr = BAEngineSetUpdate(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE: + hr = BAEngineSetLocalSource(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE: + hr = BAEngineSetDownloadSource(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC: + hr = BAEngineSetVariableNumeric(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING: + hr = BAEngineSetVariableString(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION: + hr = BAEngineSetVariableVersion(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN: + hr = BAEngineCloseSplashScreen(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_DETECT: + hr = BAEngineDetect(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_PLAN: + hr = BAEnginePlan(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE: + hr = BAEngineElevate(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_APPLY: + hr = BAEngineApply(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_QUIT: + hr = BAEngineQuit(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE: + hr = BAEngineLaunchApprovedExe(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE: + hr = BAEngineSetUpdateSource(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS: + hr = BAEngineCompareVersions(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE: + hr = BAEngineGetRelatedBundleVariable(pContext, &readerArgs, &readerResults, &bufferResponse); + break; + default: + hr = E_NOTIMPL; + break; + } } - hr = PipeRpcResponse(&pContext->hRpcPipe, message, hr, buffer.pbData, buffer.cbData); + hr = PipeRpcResponse(&pContext->hRpcPipe, message, hr, bufferResponse.pbData, bufferResponse.cbData); ExitOnFailure(hr, "Failed to send engine result to bootstrapper application."); LExit: - ReleaseBuffer(buffer); + ReleaseBuffer(bufferResponse); return hr; } diff --git a/src/libs/dutil/WixToolset.DUtil/buffutil.cpp b/src/libs/dutil/WixToolset.DUtil/buffutil.cpp index 4bf639d1f..270bfc858 100644 --- a/src/libs/dutil/WixToolset.DUtil/buffutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/buffutil.cpp @@ -309,25 +309,6 @@ extern "C" HRESULT BuffReadStream( return hr; } -extern "C" HRESULT BuffSkipExtraData( - __in SIZE_T cbExpectedSize, - __in SIZE_T cbActualSize, - __inout SIZE_T* piBuffer - ) -{ - HRESULT hr = S_OK; - - if (cbActualSize < cbExpectedSize) - { - hr = E_INVALIDARG; - } - else if (cbActualSize > *piBuffer) // skip any extra data. - { - *piBuffer = cbActualSize; - } - - return hr; -} // Buffer Reader read functions @@ -371,14 +352,6 @@ extern "C" HRESULT BuffReaderReadStringAnsi( return BuffReadStringAnsi(pReader->pbData, pReader->cbData, &pReader->iBuffer, pscz); } -HRESULT BuffReaderSkipExtraData( - __in BUFF_READER* pReader, - __in SIZE_T cbExpectedSize, - __in SIZE_T cbActualSize - ) -{ - return BuffSkipExtraData(cbExpectedSize, cbActualSize, &pReader->iBuffer); -} // Buffer write functions @@ -588,14 +561,17 @@ extern "C" HRESULT BuffWriteStream( *reinterpret_cast(*ppbBuffer + *piBuffer) = cb; *piBuffer += sizeof(DWORD); - // copy data to buffer - err = memcpy_s(*ppbBuffer + *piBuffer, cbStream, pbStream, cbStream); - if (err) + if (cbStream) { - BuffExitOnRootFailure(hr = E_INVALIDARG, "Failed to write stream to buffer, error: %d", err); - } + // copy data to buffer + err = memcpy_s(*ppbBuffer + *piBuffer, cbStream, pbStream, cbStream); + if (err) + { + BuffExitOnRootFailure(hr = E_INVALIDARG, "Failed to write stream to buffer, error: %d", err); + } - *piBuffer += cbStream; + *piBuffer += cbStream; + } LExit: return hr; @@ -603,25 +579,6 @@ extern "C" HRESULT BuffWriteStream( // Buffer-based write functions -extern "C" HRESULT BuffEnsurePaddingInBuffer( - __in BUFF_BUFFER* pBuffer, - __in DWORD cb - ) -{ - HRESULT hr = S_OK; - - if (pBuffer->cbData < cb) - { - hr = EnsureBufferSize(&pBuffer->pbData, cb); - BuffExitOnFailure(hr, "Failed to ensure padding in buffer."); - - pBuffer->cbData = cb; - } - -LExit: - return hr; -} - extern "C" HRESULT BuffWriteNumberToBuffer( __in BUFF_BUFFER* pBuffer, __out DWORD dw diff --git a/src/libs/dutil/WixToolset.DUtil/inc/buffutil.h b/src/libs/dutil/WixToolset.DUtil/inc/buffutil.h index d213bc618..116b67bd2 100644 --- a/src/libs/dutil/WixToolset.DUtil/inc/buffutil.h +++ b/src/libs/dutil/WixToolset.DUtil/inc/buffutil.h @@ -110,11 +110,6 @@ HRESULT BuffReaderReadStream( __deref_inout_bcount(*pcbStream) BYTE** ppbStream, __out SIZE_T* pcbStream ); -HRESULT BuffReaderSkipExtraData( - __in BUFF_READER* pReader, - __in SIZE_T cbExpectedSize, - __in SIZE_T cbActualSize - ); HRESULT BuffWriteNumber( __deref_inout_bcount(*piBuffer) BYTE** ppbBuffer, @@ -148,10 +143,6 @@ HRESULT BuffWriteStream( __in SIZE_T cbStream ); -HRESULT BuffEnsurePaddingInBuffer( - __in BUFF_BUFFER* pBuffer, - __in DWORD cb - ); HRESULT BuffWriteNumberToBuffer( __in BUFF_BUFFER* pBuffer, __in DWORD dw