@joebigelow / wix / commits / 4f5de060

Process and return the failed version of reboot exit codes in Burn.

(ERROR_FAIL_REBOOT_REQUIRED and ERROR_FAIL_REBOOT_INITIATED) Fixes 6762

Sean Hall committed Aug 25, 2022 at 15:08 UTC 4f5de06073ad664f60ac775da5de8c0fa1de4923
12 files changed +92 -6
src/api/wix/WixToolset.Data/Symbols/WixBundlePackageExitCodeSymbol.cs
+2
@@ -36,6 +36,8 @@ namespace WixToolset.Data.Symbols
36 Error,
37 ScheduleReboot,
38 ForceReboot,
39 + ErrorScheduleReboot,
40 + ErrorForceReboot,
41 }
42
43 public class WixBundlePackageExitCodeSymbol : IntermediateSymbol
src/burn/engine/engine.cpp
+1 -1
@@ -294,7 +294,7 @@ LExit:
294 LogId(REPORT_STANDARD, MSG_RESTART_ABORTED, LoggingRelationTypeToString(engineState.command.relationType));
295
296 fRestart = FALSE;
297 - hr = HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED);
297 + hr = SUCCEEDED(hr) ? HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED) : HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_REQUIRED);
298 }
299
300 UninitializeEngineState(&engineState);
src/burn/engine/exeengine.cpp
+28
@@ -992,6 +992,16 @@ extern "C" HRESULT ExeEngineHandleExitCode(
992 {
993 typeCode = BURN_EXE_EXIT_CODE_TYPE_FORCE_REBOOT;
994 }
995 + else if (ERROR_FAIL_REBOOT_REQUIRED == dwExitCode ||
996 + HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_REQUIRED) == static_cast<HRESULT>(dwExitCode))
997 + {
998 + typeCode = BURN_EXE_EXIT_CODE_TYPE_ERROR_SCHEDULE_REBOOT;
999 + }
1000 + else if (ERROR_FAIL_REBOOT_INITIATED == dwExitCode ||
1001 + HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_INITIATED) == static_cast<HRESULT>(dwExitCode))
1002 + {
1003 + typeCode = BURN_EXE_EXIT_CODE_TYPE_ERROR_FORCE_REBOOT;
1004 + }
1005 else
1006 {
1007 typeCode = BURN_EXE_EXIT_CODE_TYPE_ERROR;
@@ -1024,6 +1034,24 @@ extern "C" HRESULT ExeEngineHandleExitCode(
1034 hr = S_OK;
1035 break;
1036
1037 + case BURN_EXE_EXIT_CODE_TYPE_ERROR_SCHEDULE_REBOOT:
1038 + *pRestart = BOOTSTRAPPER_APPLY_RESTART_REQUIRED;
1039 + hr = HRESULT_FROM_WIN32(dwExitCode);
1040 + if (SUCCEEDED(hr))
1041 + {
1042 + hr = HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_REQUIRED);
1043 + }
1044 + break;
1045 +
1046 + case BURN_EXE_EXIT_CODE_TYPE_ERROR_FORCE_REBOOT:
1047 + *pRestart = BOOTSTRAPPER_APPLY_RESTART_INITIATED;
1048 + hr = HRESULT_FROM_WIN32(dwExitCode);
1049 + if (SUCCEEDED(hr))
1050 + {
1051 + hr = HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_INITIATED);
1052 + }
1053 + break;
1054 +
1055 default:
1056 hr = E_UNEXPECTED;
1057 break;
src/burn/engine/logging.cpp
+4
@@ -545,6 +545,10 @@ extern "C" LPCSTR LoggingExitCodeTypeToString(
545 return "ScheduleReboot";
546 case BURN_EXE_EXIT_CODE_TYPE_FORCE_REBOOT:
547 return "ForceReboot";
548 + case BURN_EXE_EXIT_CODE_TYPE_ERROR_SCHEDULE_REBOOT:
549 + return "ErrorScheduleReboot";
550 + case BURN_EXE_EXIT_CODE_TYPE_ERROR_FORCE_REBOOT:
551 + return "ErrorForceReboot";
552 default:
553 return "Invalid";
554 }
src/burn/engine/package.h
+2
@@ -37,6 +37,8 @@ enum BURN_EXE_EXIT_CODE_TYPE
37 BURN_EXE_EXIT_CODE_TYPE_ERROR,
38 BURN_EXE_EXIT_CODE_TYPE_SCHEDULE_REBOOT,
39 BURN_EXE_EXIT_CODE_TYPE_FORCE_REBOOT,
40 + BURN_EXE_EXIT_CODE_TYPE_ERROR_SCHEDULE_REBOOT,
41 + BURN_EXE_EXIT_CODE_TYPE_ERROR_FORCE_REBOOT,
42 };
43
44 enum BURN_EXE_PROTOCOL_TYPE
src/burn/test/BurnUnitTest/ExitCodeTest.cpp
+20
@@ -82,16 +82,28 @@ static void LoadEngineState(
82 { (DWORD)HRESULT_FROM_WIN32(ERROR_SUCCESS_RESTART_REQUIRED), S_OK, BOOTSTRAPPER_APPLY_RESTART_REQUIRED, L"Standard" },
83 { ERROR_SUCCESS_REBOOT_INITIATED, S_OK, BOOTSTRAPPER_APPLY_RESTART_INITIATED, L"Standard" },
84 { (DWORD)HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_INITIATED), S_OK, BOOTSTRAPPER_APPLY_RESTART_INITIATED, L"Standard" },
85 + { ERROR_FAIL_REBOOT_REQUIRED, HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_REQUIRED), BOOTSTRAPPER_APPLY_RESTART_REQUIRED, L"Standard" },
86 + { (DWORD)HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_REQUIRED), HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_REQUIRED), BOOTSTRAPPER_APPLY_RESTART_REQUIRED, L"Standard" },
87 + { ERROR_FAIL_REBOOT_INITIATED, HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_INITIATED), BOOTSTRAPPER_APPLY_RESTART_INITIATED, L"Standard" },
88 + { (DWORD)HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_INITIATED), HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_INITIATED), BOOTSTRAPPER_APPLY_RESTART_INITIATED, L"Standard" },
89 { 0, E_FAIL, BOOTSTRAPPER_APPLY_RESTART_NONE, L"Custom" },
90 { 1, S_OK, BOOTSTRAPPER_APPLY_RESTART_NONE, L"Custom" },
91 { 3, S_OK, BOOTSTRAPPER_APPLY_RESTART_REQUIRED, L"Custom" },
92 { 4, S_OK, BOOTSTRAPPER_APPLY_RESTART_INITIATED, L"Custom" },
93 + { 5, HRESULT_FROM_WIN32(5), BOOTSTRAPPER_APPLY_RESTART_REQUIRED, L"Custom" },
94 + { (DWORD)HRESULT_FROM_WIN32(5), HRESULT_FROM_WIN32(5), BOOTSTRAPPER_APPLY_RESTART_REQUIRED, L"Custom" },
95 + { 6, HRESULT_FROM_WIN32(6), BOOTSTRAPPER_APPLY_RESTART_INITIATED, L"Custom" },
96 + { (DWORD)HRESULT_FROM_WIN32(6), HRESULT_FROM_WIN32(6), BOOTSTRAPPER_APPLY_RESTART_INITIATED, L"Custom" },
97 { ERROR_SUCCESS_REBOOT_REQUIRED, HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED), BOOTSTRAPPER_APPLY_RESTART_NONE, L"Custom" },
98 { (DWORD)HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED), HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED), BOOTSTRAPPER_APPLY_RESTART_NONE, L"Custom" },
99 { ERROR_SUCCESS_RESTART_REQUIRED, HRESULT_FROM_WIN32(ERROR_SUCCESS_RESTART_REQUIRED), BOOTSTRAPPER_APPLY_RESTART_NONE, L"Custom" },
100 { (DWORD)HRESULT_FROM_WIN32(ERROR_SUCCESS_RESTART_REQUIRED), HRESULT_FROM_WIN32(ERROR_SUCCESS_RESTART_REQUIRED), BOOTSTRAPPER_APPLY_RESTART_NONE, L"Custom" },
101 { ERROR_SUCCESS_REBOOT_INITIATED, HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_INITIATED), BOOTSTRAPPER_APPLY_RESTART_NONE, L"Custom" },
102 { (DWORD)HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_INITIATED), HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_INITIATED), BOOTSTRAPPER_APPLY_RESTART_NONE, L"Custom" },
103 + { ERROR_FAIL_REBOOT_REQUIRED, HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_REQUIRED), BOOTSTRAPPER_APPLY_RESTART_NONE, L"Custom" },
104 + { (DWORD)HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_REQUIRED), HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_REQUIRED), BOOTSTRAPPER_APPLY_RESTART_NONE, L"Custom" },
105 + { ERROR_FAIL_REBOOT_INITIATED, HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_INITIATED), BOOTSTRAPPER_APPLY_RESTART_NONE, L"Custom" },
106 + { (DWORD)HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_INITIATED), HRESULT_FROM_WIN32(ERROR_FAIL_REBOOT_INITIATED), BOOTSTRAPPER_APPLY_RESTART_NONE, L"Custom" },
107 };
108
109 engineState.sczBundleEngineWorkingPath = L"tests\\ignore\\this\\path\\to\\burn.exe";
@@ -321,12 +333,20 @@ static void LoadEngineState(
333 L" <ExitCode Code='0' Type='2' />"
334 L" <ExitCode Code='3' Type='3' />"
335 L" <ExitCode Code='4' Type='4' />"
336 + L" <ExitCode Code='5' Type='5' />"
337 + L" <ExitCode Code='-2147024891' Type='5' />"
338 + L" <ExitCode Code='6' Type='6' />"
339 + L" <ExitCode Code='-2147024890' Type='6' />"
340 L" <ExitCode Code='3010' Type='2' />"
341 L" <ExitCode Code='-2147021886' Type='2' />"
342 L" <ExitCode Code='3011' Type='2' />"
343 L" <ExitCode Code='-2147021885' Type='2' />"
344 L" <ExitCode Code='1641' Type='2' />"
345 L" <ExitCode Code='-2147023255' Type='2' />"
346 + L" <ExitCode Code='3017' Type='2' />"
347 + L" <ExitCode Code='-2147021879' Type='2' />"
348 + L" <ExitCode Code='3018' Type='2' />"
349 + L" <ExitCode Code='-2147021878' Type='2' />"
350 L" <ExitCode Code='*' Type='1' />"
351 L" <PayloadRef Id='test.exe' />"
352 L" </ExePackage>"
src/ext/Bal/wixiuiba/WixInternalUIBootstrapperApplication.cpp
+2 -2
@@ -391,11 +391,11 @@ private:
391
392 if (BOOTSTRAPPER_APPLY_RESTART_INITIATED == pThis->m_restartResult)
393 {
394 - dwQuit = ERROR_SUCCESS_REBOOT_INITIATED;
394 + dwQuit = SUCCEEDED(hr) ? ERROR_SUCCESS_REBOOT_INITIATED : ERROR_FAIL_REBOOT_INITIATED;
395 }
396 else if (BOOTSTRAPPER_APPLY_RESTART_REQUIRED == pThis->m_restartResult)
397 {
398 - dwQuit = ERROR_SUCCESS_REBOOT_REQUIRED;
398 + dwQuit = SUCCEEDED(hr) ? ERROR_SUCCESS_REBOOT_REQUIRED : ERROR_FAIL_REBOOT_REQUIRED;
399 }
400 else if (SEVERITY_ERROR == HRESULT_SEVERITY(hr) && FACILITY_WIN32 == HRESULT_FACILITY(hr))
401 {
src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
+2 -2
@@ -2684,11 +2684,11 @@ private:
2684
2685 if (BOOTSTRAPPER_APPLY_RESTART_INITIATED == pThis->m_restartResult)
2686 {
2687 - dwQuit = ERROR_SUCCESS_REBOOT_INITIATED;
2687 + dwQuit = SUCCEEDED(hr) ? ERROR_SUCCESS_REBOOT_INITIATED : ERROR_FAIL_REBOOT_INITIATED;
2688 }
2689 else if (BOOTSTRAPPER_APPLY_RESTART_REQUIRED == pThis->m_restartResult)
2690 {
2691 - dwQuit = ERROR_SUCCESS_REBOOT_REQUIRED;
2691 + dwQuit = SUCCEEDED(hr) ? ERROR_SUCCESS_REBOOT_REQUIRED : ERROR_FAIL_REBOOT_REQUIRED;
2692 }
2693 else if (SEVERITY_ERROR == HRESULT_SEVERITY(hr) && FACILITY_WIN32 == HRESULT_FACILITY(hr))
2694 {
src/libs/dutil/WixToolset.DUtil/wiutil.cpp
+8
@@ -1034,6 +1034,14 @@ static DWORD CheckForRestartErrorCode(
1034 *pRestart = WIU_RESTART_INITIATED;
1035 dwErrorCode = ERROR_SUCCESS;
1036 break;
1037 +
1038 + case ERROR_FAIL_REBOOT_REQUIRED:
1039 + *pRestart = WIU_RESTART_REQUIRED;
1040 + break;
1041 +
1042 + case ERROR_FAIL_REBOOT_INITIATED:
1043 + *pRestart = WIU_RESTART_INITIATED;
1044 + break;
1045 }
1046
1047 return dwErrorCode;
src/wix/WixToolset.Core/Compiler_Bundle.cs
+7 -1
@@ -1628,6 +1628,12 @@ namespace WixToolset.Core
1628 case "error":
1629 behavior = ExitCodeBehaviorType.Error;
1630 break;
1631 + case "errorForceReboot":
1632 + behavior = ExitCodeBehaviorType.ErrorForceReboot;
1633 + break;
1634 + case "errorScheduleReboot":
1635 + behavior = ExitCodeBehaviorType.ErrorScheduleReboot;
1636 + break;
1637 case "forceReboot":
1638 behavior = ExitCodeBehaviorType.ForceReboot;
1639 break;
@@ -1638,7 +1644,7 @@ namespace WixToolset.Core
1644 behavior = ExitCodeBehaviorType.Success;
1645 break;
1646 default:
1641 - this.Core.Write(ErrorMessages.IllegalAttributeValueWithLegalList(sourceLineNumbers, node.Name.LocalName, "Behavior", behaviorString, "success, error, scheduleReboot, forceReboot"));
1647 + this.Core.Write(ErrorMessages.IllegalAttributeValueWithLegalList(sourceLineNumbers, node.Name.LocalName, "Behavior", behaviorString, "success, error, scheduleReboot, forceReboot, errorScheduleReboot, errorForceReboot"));
1648 behavior = ExitCodeBehaviorType.Success; // set value to avoid ExpectedAttribute below.
1649 break;
1650 }
src/wix/test/WixToolsetTest.CoreIntegration/ExePackageFixture.cs
+8
@@ -93,12 +93,20 @@ namespace WixToolsetTest.CoreIntegration
93 "<ExitCode Code='0' Type='2' />" +
94 "<ExitCode Code='3' Type='3' />" +
95 "<ExitCode Code='4' Type='4' />" +
96 + "<ExitCode Code='5' Type='5' />" +
97 + "<ExitCode Code='-2147024891' Type='5' />" +
98 + "<ExitCode Code='6' Type='6' />" +
99 + "<ExitCode Code='-2147024890' Type='6' />" +
100 "<ExitCode Code='3010' Type='2' />" +
101 "<ExitCode Code='-2147021886' Type='2' />" +
102 "<ExitCode Code='3011' Type='2' />" +
103 "<ExitCode Code='-2147021885' Type='2' />" +
104 "<ExitCode Code='1641' Type='2' />" +
105 "<ExitCode Code='-2147023255' Type='2' />" +
106 + "<ExitCode Code='3017' Type='2' />" +
107 + "<ExitCode Code='-2147021879' Type='2' />" +
108 + "<ExitCode Code='3018' Type='2' />" +
109 + "<ExitCode Code='-2147021878' Type='2' />" +
110 "<ExitCode Code='-2147483647' Type='2' />" +
111 "<ExitCode Code='-2147483648' Type='2' />" +
112 "<ExitCode Code='*' Type='1' />" +
src/wix/test/WixToolsetTest.CoreIntegration/TestData/ExePackage/CustomExitCodes.wxs
+8
@@ -10,12 +10,20 @@
10 <ExitCode Value="0" Behavior="error" />
11 <ExitCode Value="3" Behavior="scheduleReboot" />
12 <ExitCode Value="4" Behavior="forceReboot" />
13 + <ExitCode Value="5" Behavior="errorScheduleReboot" />
14 + <ExitCode Value="-2147024891" Behavior="errorScheduleReboot" />
15 + <ExitCode Value="6" Behavior="errorForceReboot" />
16 + <ExitCode Value="-2147024890" Behavior="errorForceReboot" />
17 <ExitCode Value="3010" Behavior="error" />
18 <ExitCode Value="-2147021886" Behavior="error" />
19 <ExitCode Value="3011" Behavior="error" />
20 <ExitCode Value="-2147021885" Behavior="error" />
21 <ExitCode Value="1641" Behavior="error" />
22 <ExitCode Value="-2147023255" Behavior="error" />
23 + <ExitCode Value="3017" Behavior="error" />
24 + <ExitCode Value="-2147021879" Behavior="error" />
25 + <ExitCode Value="3018" Behavior="error" />
26 + <ExitCode Value="-2147021878" Behavior="error" />
27 <ExitCode Value="-2147483647" Behavior="error" />
28 <ExitCode Value="-2147483648" Behavior="error" />
29 <ExitCode Behavior="success" />