diff options
Diffstat (limited to 'src/burn/engine')
-rw-r--r-- | src/burn/engine/bundlepackageengine.cpp | 7 | ||||
-rw-r--r-- | src/burn/engine/embedded.cpp | 26 | ||||
-rw-r--r-- | src/burn/engine/embedded.h | 1 | ||||
-rw-r--r-- | src/burn/engine/exeengine.cpp | 3 | ||||
-rw-r--r-- | src/burn/engine/externalengine.cpp | 20 |
5 files changed, 36 insertions, 21 deletions
diff --git a/src/burn/engine/bundlepackageengine.cpp b/src/burn/engine/bundlepackageengine.cpp index 7ae12a1e..dafe1967 100644 --- a/src/burn/engine/bundlepackageengine.cpp +++ b/src/burn/engine/bundlepackageengine.cpp | |||
@@ -763,8 +763,7 @@ static HRESULT ExecuteBundle( | |||
763 | LPWSTR* argvArp = NULL; | 763 | LPWSTR* argvArp = NULL; |
764 | BOOL fRegistered = FALSE; | 764 | BOOL fRegistered = FALSE; |
765 | HANDLE hExecutableFile = INVALID_HANDLE_VALUE; | 765 | HANDLE hExecutableFile = INVALID_HANDLE_VALUE; |
766 | STARTUPINFOW si = { }; | 766 | BURN_PIPE_CONNECTION connection = { }; |
767 | PROCESS_INFORMATION pi = { }; | ||
768 | DWORD dwExitCode = 0; | 767 | DWORD dwExitCode = 0; |
769 | GENERIC_EXECUTE_MESSAGE message = { }; | 768 | GENERIC_EXECUTE_MESSAGE message = { }; |
770 | BURN_PAYLOAD* pPackagePayload = pPackage->payloads.rgItems[0].pPayload; | 769 | BURN_PAYLOAD* pPackagePayload = pPackage->payloads.rgItems[0].pPayload; |
@@ -1006,7 +1005,7 @@ static HRESULT ExecuteBundle( | |||
1006 | 1005 | ||
1007 | if (fRunEmbedded) | 1006 | if (fRunEmbedded) |
1008 | { | 1007 | { |
1009 | hr = EmbeddedRunBundle(sczExecutablePath, sczBaseCommand, sczUserArgs, pfnGenericMessageHandler, pvContext, &dwExitCode); | 1008 | hr = EmbeddedRunBundle(&connection, sczExecutablePath, sczBaseCommand, sczUserArgs, pfnGenericMessageHandler, pvContext, &dwExitCode); |
1010 | ExitOnFailure(hr, "Failed to run bundle as embedded from path: %ls", sczExecutablePath); | 1009 | ExitOnFailure(hr, "Failed to run bundle as embedded from path: %ls", sczExecutablePath); |
1011 | } | 1010 | } |
1012 | else | 1011 | else |
@@ -1033,8 +1032,6 @@ LExit: | |||
1033 | AppFreeCommandLineArgs(argvArp); | 1032 | AppFreeCommandLineArgs(argvArp); |
1034 | } | 1033 | } |
1035 | 1034 | ||
1036 | ReleaseHandle(pi.hThread); | ||
1037 | ReleaseHandle(pi.hProcess); | ||
1038 | ReleaseFileHandle(hExecutableFile); | 1035 | ReleaseFileHandle(hExecutableFile); |
1039 | 1036 | ||
1040 | // Best effort to clear the execute package cache folder and action variables. | 1037 | // Best effort to clear the execute package cache folder and action variables. |
diff --git a/src/burn/engine/embedded.cpp b/src/burn/engine/embedded.cpp index 4c3de98e..ac4c76d0 100644 --- a/src/burn/engine/embedded.cpp +++ b/src/burn/engine/embedded.cpp | |||
@@ -40,6 +40,7 @@ static HRESULT OnEmbeddedProgress( | |||
40 | 40 | ||
41 | *******************************************************************/ | 41 | *******************************************************************/ |
42 | extern "C" HRESULT EmbeddedRunBundle( | 42 | extern "C" HRESULT EmbeddedRunBundle( |
43 | __in BURN_PIPE_CONNECTION* pConnection, | ||
43 | __in_z LPCWSTR wzExecutablePath, | 44 | __in_z LPCWSTR wzExecutablePath, |
44 | __in_z LPWSTR sczBaseCommand, | 45 | __in_z LPWSTR sczBaseCommand, |
45 | __in_z_opt LPCWSTR wzUserArgs, | 46 | __in_z_opt LPCWSTR wzUserArgs, |
@@ -55,20 +56,19 @@ extern "C" HRESULT EmbeddedRunBundle( | |||
55 | PROCESS_INFORMATION pi = { }; | 56 | PROCESS_INFORMATION pi = { }; |
56 | BURN_PIPE_RESULT result = { }; | 57 | BURN_PIPE_RESULT result = { }; |
57 | 58 | ||
58 | BURN_PIPE_CONNECTION connection = { }; | 59 | PipeConnectionInitialize(pConnection); |
59 | PipeConnectionInitialize(&connection); | ||
60 | 60 | ||
61 | BURN_EMBEDDED_CALLBACK_CONTEXT context = { }; | 61 | BURN_EMBEDDED_CALLBACK_CONTEXT context = { }; |
62 | context.pfnGenericMessageHandler = pfnGenericMessageHandler; | 62 | context.pfnGenericMessageHandler = pfnGenericMessageHandler; |
63 | context.pvContext = pvContext; | 63 | context.pvContext = pvContext; |
64 | 64 | ||
65 | hr = PipeCreateNameAndSecret(&connection.sczName, &connection.sczSecret); | 65 | hr = PipeCreateNameAndSecret(&pConnection->sczName, &pConnection->sczSecret); |
66 | ExitOnFailure(hr, "Failed to create embedded pipe name and client token."); | 66 | ExitOnFailure(hr, "Failed to create embedded pipe name and client token."); |
67 | 67 | ||
68 | hr = PipeCreatePipes(&connection, FALSE, &hCreatedPipesEvent); | 68 | hr = PipeCreatePipes(pConnection, FALSE, &hCreatedPipesEvent); |
69 | ExitOnFailure(hr, "Failed to create embedded pipe."); | 69 | ExitOnFailure(hr, "Failed to create embedded pipe."); |
70 | 70 | ||
71 | hr = StrAllocFormatted(&sczCommand, L"%ls -%ls %ls %ls %u", sczBaseCommand, BURN_COMMANDLINE_SWITCH_EMBEDDED, connection.sczName, connection.sczSecret, dwCurrentProcessId); | 71 | hr = StrAllocFormatted(&sczCommand, L"%ls -%ls %ls %ls %u", sczBaseCommand, BURN_COMMANDLINE_SWITCH_EMBEDDED, pConnection->sczName, pConnection->sczSecret, dwCurrentProcessId); |
72 | ExitOnFailure(hr, "Failed to append embedded args."); | 72 | ExitOnFailure(hr, "Failed to append embedded args."); |
73 | 73 | ||
74 | // Always add user supplied arguments last. | 74 | // Always add user supplied arguments last. |
@@ -81,18 +81,18 @@ extern "C" HRESULT EmbeddedRunBundle( | |||
81 | hr = CoreCreateProcess(wzExecutablePath, sczCommand, TRUE, CREATE_NO_WINDOW, NULL, 0, &pi); | 81 | hr = CoreCreateProcess(wzExecutablePath, sczCommand, TRUE, CREATE_NO_WINDOW, NULL, 0, &pi); |
82 | ExitOnFailure(hr, "Failed to create embedded process at path: %ls", wzExecutablePath); | 82 | ExitOnFailure(hr, "Failed to create embedded process at path: %ls", wzExecutablePath); |
83 | 83 | ||
84 | connection.dwProcessId = ::GetProcessId(pi.hProcess); | 84 | pConnection->dwProcessId = ::GetProcessId(pi.hProcess); |
85 | connection.hProcess = pi.hProcess; | 85 | pConnection->hProcess = pi.hProcess; |
86 | pi.hProcess = NULL; | 86 | pi.hProcess = NULL; |
87 | 87 | ||
88 | hr = PipeWaitForChildConnect(&connection); | 88 | hr = PipeWaitForChildConnect(pConnection); |
89 | ExitOnFailure(hr, "Failed to wait for embedded process to connect to pipe."); | 89 | ExitOnFailure(hr, "Failed to wait for embedded process to connect to pipe."); |
90 | 90 | ||
91 | hr = PipePumpMessages(connection.hPipe, ProcessEmbeddedMessages, &context, &result); | 91 | hr = PipePumpMessages(pConnection->hPipe, ProcessEmbeddedMessages, &context, &result); |
92 | ExitOnFailure(hr, "Failed to process messages from embedded message."); | 92 | ExitOnFailure(hr, "Failed to process messages from embedded message."); |
93 | 93 | ||
94 | // Get the return code from the embedded process. | 94 | // Get the return code from the embedded process. |
95 | hr = CoreWaitForProcCompletion(connection.hProcess, INFINITE, pdwExitCode); | 95 | hr = CoreWaitForProcCompletion(pConnection->hProcess, INFINITE, pdwExitCode); |
96 | ExitOnFailure(hr, "Failed to wait for embedded executable: %ls", wzExecutablePath); | 96 | ExitOnFailure(hr, "Failed to wait for embedded executable: %ls", wzExecutablePath); |
97 | 97 | ||
98 | LExit: | 98 | LExit: |
@@ -101,7 +101,7 @@ LExit: | |||
101 | 101 | ||
102 | StrSecureZeroFreeString(sczCommand); | 102 | StrSecureZeroFreeString(sczCommand); |
103 | ReleaseHandle(hCreatedPipesEvent); | 103 | ReleaseHandle(hCreatedPipesEvent); |
104 | PipeConnectionUninitialize(&connection); | 104 | PipeConnectionUninitialize(pConnection); |
105 | 105 | ||
106 | return hr; | 106 | return hr; |
107 | } | 107 | } |
@@ -133,8 +133,8 @@ static HRESULT ProcessEmbeddedMessages( | |||
133 | break; | 133 | break; |
134 | 134 | ||
135 | default: | 135 | default: |
136 | hr = E_INVALIDARG; | 136 | LogStringLine(REPORT_DEBUG, "Unexpected embedded message received from child process, msg: %u", pMsg->dwMessage); |
137 | ExitOnRootFailure(hr, "Unexpected embedded message sent to child process, msg: %u", pMsg->dwMessage); | 137 | dwResult = (DWORD)E_NOTIMPL; |
138 | } | 138 | } |
139 | 139 | ||
140 | *pdwResult = dwResult; | 140 | *pdwResult = dwResult; |
diff --git a/src/burn/engine/embedded.h b/src/burn/engine/embedded.h index 905b227f..0a0a8fc2 100644 --- a/src/burn/engine/embedded.h +++ b/src/burn/engine/embedded.h | |||
@@ -15,6 +15,7 @@ typedef enum _BURN_EMBEDDED_MESSAGE_TYPE | |||
15 | 15 | ||
16 | 16 | ||
17 | HRESULT EmbeddedRunBundle( | 17 | HRESULT EmbeddedRunBundle( |
18 | __in BURN_PIPE_CONNECTION* pConnection, | ||
18 | __in_z LPCWSTR wzExecutablePath, | 19 | __in_z LPCWSTR wzExecutablePath, |
19 | __in_z LPWSTR sczBaseCommand, | 20 | __in_z LPWSTR sczBaseCommand, |
20 | __in_z_opt LPCWSTR wzUserArgs, | 21 | __in_z_opt LPCWSTR wzUserArgs, |
diff --git a/src/burn/engine/exeengine.cpp b/src/burn/engine/exeengine.cpp index 1168f5ea..ef0015ac 100644 --- a/src/burn/engine/exeengine.cpp +++ b/src/burn/engine/exeengine.cpp | |||
@@ -434,6 +434,7 @@ extern "C" HRESULT ExeEngineExecutePackage( | |||
434 | LPWSTR* argvArp = NULL; | 434 | LPWSTR* argvArp = NULL; |
435 | BOOTSTRAPPER_PACKAGE_STATE applyState = BOOTSTRAPPER_PACKAGE_STATE_UNKNOWN; | 435 | BOOTSTRAPPER_PACKAGE_STATE applyState = BOOTSTRAPPER_PACKAGE_STATE_UNKNOWN; |
436 | HANDLE hExecutableFile = INVALID_HANDLE_VALUE; | 436 | HANDLE hExecutableFile = INVALID_HANDLE_VALUE; |
437 | BURN_PIPE_CONNECTION connection = { }; | ||
437 | DWORD dwExitCode = 0; | 438 | DWORD dwExitCode = 0; |
438 | BURN_PACKAGE* pPackage = pExecuteAction->exePackage.pPackage; | 439 | BURN_PACKAGE* pPackage = pExecuteAction->exePackage.pPackage; |
439 | BURN_PAYLOAD* pPackagePayload = pPackage->payloads.rgItems[0].pPayload; | 440 | BURN_PAYLOAD* pPackagePayload = pPackage->payloads.rgItems[0].pPayload; |
@@ -633,7 +634,7 @@ extern "C" HRESULT ExeEngineExecutePackage( | |||
633 | 634 | ||
634 | if (!pPackage->Exe.fFireAndForget && BURN_EXE_PROTOCOL_TYPE_BURN == pPackage->Exe.protocol) | 635 | if (!pPackage->Exe.fFireAndForget && BURN_EXE_PROTOCOL_TYPE_BURN == pPackage->Exe.protocol) |
635 | { | 636 | { |
636 | hr = EmbeddedRunBundle(sczExecutablePath, sczBaseCommand, sczUserArgs, pfnGenericMessageHandler, pvContext, &dwExitCode); | 637 | hr = EmbeddedRunBundle(&connection, sczExecutablePath, sczBaseCommand, sczUserArgs, pfnGenericMessageHandler, pvContext, &dwExitCode); |
637 | ExitOnFailure(hr, "Failed to run exe with Burn protocol from path: %ls", sczExecutablePath); | 638 | ExitOnFailure(hr, "Failed to run exe with Burn protocol from path: %ls", sczExecutablePath); |
638 | } | 639 | } |
639 | else if (!pPackage->Exe.fFireAndForget && BURN_EXE_PROTOCOL_TYPE_NETFX4 == pPackage->Exe.protocol) | 640 | else if (!pPackage->Exe.fFireAndForget && BURN_EXE_PROTOCOL_TYPE_NETFX4 == pPackage->Exe.protocol) |
diff --git a/src/burn/engine/externalengine.cpp b/src/burn/engine/externalengine.cpp index abe9b8bc..16977395 100644 --- a/src/burn/engine/externalengine.cpp +++ b/src/burn/engine/externalengine.cpp | |||
@@ -8,6 +8,11 @@ static HRESULT CopyStringToExternal( | |||
8 | __in_z_opt LPWSTR wzBuffer, | 8 | __in_z_opt LPWSTR wzBuffer, |
9 | __inout SIZE_T* pcchBuffer | 9 | __inout SIZE_T* pcchBuffer |
10 | ); | 10 | ); |
11 | static HRESULT ProcessUnknownEmbeddedMessages( | ||
12 | __in BURN_PIPE_MESSAGE* /*pMsg*/, | ||
13 | __in_opt LPVOID /*pvContext*/, | ||
14 | __out DWORD* pdwResult | ||
15 | ); | ||
11 | 16 | ||
12 | // function definitions | 17 | // function definitions |
13 | 18 | ||
@@ -212,7 +217,7 @@ HRESULT ExternalEngineSendEmbeddedError( | |||
212 | hr = BuffWriteNumber(&pbData, &cbData, dwUIHint); | 217 | hr = BuffWriteNumber(&pbData, &cbData, dwUIHint); |
213 | ExitOnFailure(hr, "Failed to write UI hint to message buffer."); | 218 | ExitOnFailure(hr, "Failed to write UI hint to message buffer."); |
214 | 219 | ||
215 | hr = PipeSendMessage(pEngineState->embeddedConnection.hPipe, BURN_EMBEDDED_MESSAGE_TYPE_ERROR, pbData, cbData, NULL, NULL, &dwResult); | 220 | hr = PipeSendMessage(pEngineState->embeddedConnection.hPipe, BURN_EMBEDDED_MESSAGE_TYPE_ERROR, pbData, cbData, ProcessUnknownEmbeddedMessages, NULL, &dwResult); |
216 | ExitOnFailure(hr, "Failed to send embedded message over pipe."); | 221 | ExitOnFailure(hr, "Failed to send embedded message over pipe."); |
217 | 222 | ||
218 | *pnResult = static_cast<int>(dwResult); | 223 | *pnResult = static_cast<int>(dwResult); |
@@ -247,7 +252,7 @@ HRESULT ExternalEngineSendEmbeddedProgress( | |||
247 | hr = BuffWriteNumber(&pbData, &cbData, dwOverallProgressPercentage); | 252 | hr = BuffWriteNumber(&pbData, &cbData, dwOverallProgressPercentage); |
248 | ExitOnFailure(hr, "Failed to write overall progress percentage to message buffer."); | 253 | ExitOnFailure(hr, "Failed to write overall progress percentage to message buffer."); |
249 | 254 | ||
250 | hr = PipeSendMessage(pEngineState->embeddedConnection.hPipe, BURN_EMBEDDED_MESSAGE_TYPE_PROGRESS, pbData, cbData, NULL, NULL, &dwResult); | 255 | hr = PipeSendMessage(pEngineState->embeddedConnection.hPipe, BURN_EMBEDDED_MESSAGE_TYPE_PROGRESS, pbData, cbData, ProcessUnknownEmbeddedMessages, NULL, &dwResult); |
251 | ExitOnFailure(hr, "Failed to send embedded progress message over pipe."); | 256 | ExitOnFailure(hr, "Failed to send embedded progress message over pipe."); |
252 | 257 | ||
253 | *pnResult = static_cast<int>(dwResult); | 258 | *pnResult = static_cast<int>(dwResult); |
@@ -821,3 +826,14 @@ static HRESULT CopyStringToExternal( | |||
821 | 826 | ||
822 | return hr; | 827 | return hr; |
823 | } | 828 | } |
829 | |||
830 | static HRESULT ProcessUnknownEmbeddedMessages( | ||
831 | __in BURN_PIPE_MESSAGE* /*pMsg*/, | ||
832 | __in_opt LPVOID /*pvContext*/, | ||
833 | __out DWORD* pdwResult | ||
834 | ) | ||
835 | { | ||
836 | *pdwResult = (DWORD)E_NOTIMPL; | ||
837 | |||
838 | return S_OK; | ||
839 | } | ||