Skip to content

Commit

Permalink
Let the child bundle know whether the parent can receive custom messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nirbar committed May 13, 2024
1 parent 3d0c6a9 commit 5769145
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/burn/engine/EngineForApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,12 @@ class CEngineForApplication : public IBootstrapperEngine, public IMarshal
if (BURN_MODE_EMBEDDED != m_pEngineState->mode)
{
hr = HRESULT_FROM_WIN32(ERROR_INVALID_STATE);
ExitOnRootFailure(hr, "Application requested to send embedded progress message when not in embedded mode.");
ExitOnRootFailure(hr, "Application requested to send embedded custom message when not in embedded mode.");
}
if ((m_pEngineState->embeddedConnection.dwCapabilities & BURN_PIPE_CAPABILITIES_CUSTOM_MESSAGE) != BURN_PIPE_CAPABILITIES_CUSTOM_MESSAGE)
{
hr = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
ExitOnRootFailure(hr, "Parent engine does not support receiving embedded custom messages.");
}

hr = BuffWriteNumber(&pbData, &cbData, dwCode);
Expand All @@ -394,7 +399,7 @@ class CEngineForApplication : public IBootstrapperEngine, public IMarshal
ExitOnFailure(hr, "Failed to write text to message buffer.");

hr = PipeSendMessage(m_pEngineState->embeddedConnection.hPipe, BURN_EMBEDDED_MESSAGE_TYPE_CUSTOM, pbData, cbData, NULL, NULL, &dwResult);
ExitOnFailure(hr, "Failed to send embedded progress message over pipe.");
ExitOnFailure(hr, "Failed to send embedded custom message over pipe.");

*pnResult = static_cast<int>(dwResult);

Expand Down
11 changes: 11 additions & 0 deletions src/burn/engine/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,17 @@ static HRESULT ParseCommandLine(

i += 2;
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_EMBEDDED_CAPABILITIES, -1))
{
if (i + 1 >= argc)
{
ExitOnRootFailure(hr = E_INVALIDARG, "Must specify the embedded capabilities.");
}
++i;

hr = StrStringToUInt32(argv[i], 0, reinterpret_cast<UINT*>(&pEmbeddedConnection->dwCapabilities));
ExitOnFailure(hr, "Failed to parse parent pipe capabilities.");
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_RELATED_DETECT, -1))
{
pCommand->relationType = BOOTSTRAPPER_RELATION_DETECT;
Expand Down
1 change: 1 addition & 0 deletions src/burn/engine/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const LPCWSTR BURN_COMMANDLINE_SWITCH_PARENT_NONE = L"parent:none";
const LPCWSTR BURN_COMMANDLINE_SWITCH_CLEAN_ROOM = L"burn.clean.room";
const LPCWSTR BURN_COMMANDLINE_SWITCH_ELEVATED = L"burn.elevated";
const LPCWSTR BURN_COMMANDLINE_SWITCH_EMBEDDED = L"burn.embedded";
const LPCWSTR BURN_COMMANDLINE_SWITCH_EMBEDDED_CAPABILITIES = L"burn.embedded.capabilities";
const LPCWSTR BURN_COMMANDLINE_SWITCH_RUNONCE = L"burn.runonce";
const LPCWSTR BURN_COMMANDLINE_SWITCH_LOG_APPEND = L"burn.log.append";
const LPCWSTR BURN_COMMANDLINE_SWITCH_RELATED_DETECT = L"burn.related.detect";
Expand Down
2 changes: 1 addition & 1 deletion src/burn/engine/embedded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extern "C" HRESULT EmbeddedRunBundle(
hr = PipeCreatePipes(&connection, FALSE, &hCreatedPipesEvent);
ExitOnFailure(hr, "Failed to create embedded pipe.");

hr = StrAllocFormattedSecure(&sczCommand, L"%ls -%ls %ls %ls %u", wzArguments, BURN_COMMANDLINE_SWITCH_EMBEDDED, connection.sczName, connection.sczSecret, dwCurrentProcessId);
hr = StrAllocFormattedSecure(&sczCommand, L"%ls -%ls %ls %ls %u -%ls %u", wzArguments, BURN_COMMANDLINE_SWITCH_EMBEDDED, connection.sczName, connection.sczSecret, dwCurrentProcessId, BURN_COMMANDLINE_SWITCH_EMBEDDED_CAPABILITIES, BURN_PIPE_CAPABILITIES_ALL);
ExitOnFailure(hr, "Failed to allocate embedded command.");

if (!::CreateProcessW(wzExecutablePath, sczCommand, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
Expand Down
11 changes: 11 additions & 0 deletions src/burn/engine/pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@
extern "C" {
#endif


enum BURN_PIPE_CAPABILITIES
{
BURN_PIPE_CAPABILITIES_NONE = 0,
BURN_PIPE_CAPABILITIES_CUSTOM_MESSAGE = 1,

// All the capabilities that this engine supports, used when creating capabilities command line for the embedded bundle
BURN_PIPE_CAPABILITIES_ALL = BURN_PIPE_CAPABILITIES_CUSTOM_MESSAGE,
};

typedef struct _BURN_PIPE_CONNECTION
{
LPWSTR sczName;
LPWSTR sczSecret;
DWORD dwProcessId;
DWORD dwCapabilities; // Capabilities of the engine that created the pipe

HANDLE hProcess;
HANDLE hPipe;
Expand Down
3 changes: 3 additions & 0 deletions src/ext/BalExtension/mba/core/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ public int SendEmbeddedProgress(int progressPercentage, int overallPercentage)
/// </summary>
/// <param name="code">Custom message code.</param>
/// <param name="message">Optional text.</param>
/// <exception cref="System.NotSupportedException">
/// Thrown when the parent burn engine does not support receiving custom messages
/// </exception>
public int SendEmbeddedCustomMessage(int code, string message)
{
int result = 0;
Expand Down

0 comments on commit 5769145

Please sign in to comment.