From 5a6c681b28c953d809292b4b85c80af300d7902f Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 5 Mar 2022 15:27:42 -0600 Subject: Ensure WixBundleInstalled and RebootPending are set in elevated engine. --- src/burn/engine/core.cpp | 12 ------------ src/burn/engine/elevation.cpp | 7 ++++++- src/burn/engine/registration.cpp | 8 +++++++- src/burn/engine/variable.cpp | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp index ca4d607b..43f79133 100644 --- a/src/burn/engine/core.cpp +++ b/src/burn/engine/core.cpp @@ -264,10 +264,6 @@ extern "C" HRESULT CoreQueryRegistration( SIZE_T cbBuffer = 0; SIZE_T iBuffer = 0; - // Detect if bundle is already installed. - hr = RegistrationDetectInstalled(&pEngineState->registration); - ExitOnFailure(hr, "Failed to detect bundle install state."); - // detect resume type hr = RegistrationDetectResumeType(&pEngineState->registration, &pEngineState->command.resumeType); ExitOnFailure(hr, "Failed to detect resume type."); @@ -315,14 +311,6 @@ extern "C" HRESULT CoreDetect( DetectReset(&pEngineState->registration, &pEngineState->packages); PlanReset(&pEngineState->plan, &pEngineState->containers, &pEngineState->packages, &pEngineState->layoutPayloads); - // Detect if bundle installed state has changed since start up. - // This only happens if Apply() changed the state of bundle (installed, in progress, or uninstalled). - // In that case, Detect() can be used here to reset the installed state. - // Of course, there's also cases outside of this bundle's control, - // like other processes messing with its registration. - hr = RegistrationDetectInstalled(&pEngineState->registration); - ExitOnFailure(hr, "Failed to detect bundle install state."); - hr = RegistrationSetDynamicVariables(&pEngineState->registration, &pEngineState->variables); ExitOnFailure(hr, "Failed to reset the dynamic registration variables during detect."); diff --git a/src/burn/engine/elevation.cpp b/src/burn/engine/elevation.cpp index d12a151a..e479b6c0 100644 --- a/src/burn/engine/elevation.cpp +++ b/src/burn/engine/elevation.cpp @@ -178,6 +178,7 @@ static HRESULT OnApplyInitialize( ); static HRESULT ElevatedProcessDetect( __in BURN_REGISTRATION* pRegistration, + __in BURN_VARIABLES* pVariables, __in BURN_PACKAGES* pPackages ); static HRESULT OnApplyUninitialize( @@ -2245,7 +2246,7 @@ static HRESULT OnApplyInitialize( ExitOnFailure(hr, "Failed to acquire lock due to setup in other session."); // Detect. - hr = ElevatedProcessDetect(pRegistration, pPackages); + hr = ElevatedProcessDetect(pRegistration, pVariables, pPackages); ExitOnFailure(hr, "Failed to run detection in elevated process."); // Attempt to pause AU with best effort. @@ -2331,6 +2332,7 @@ LExit: static HRESULT ElevatedProcessDetect( __in BURN_REGISTRATION* pRegistration, + __in BURN_VARIABLES* pVariables, __in BURN_PACKAGES* pPackages ) { @@ -2338,6 +2340,9 @@ static HRESULT ElevatedProcessDetect( DetectReset(pRegistration, pPackages); + hr = RegistrationSetDynamicVariables(pRegistration, pVariables); + ExitOnFailure(hr, "Failed to reset the dynamic registration variables during elevated detect."); + hr = RelatedBundlesInitializeForScope(TRUE, pRegistration, &pRegistration->relatedBundles); ExitOnFailure(hr, "Failed to initialize per-machine related bundles."); diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp index fcefe5e0..545c390b 100644 --- a/src/burn/engine/registration.cpp +++ b/src/burn/engine/registration.cpp @@ -484,7 +484,13 @@ extern "C" HRESULT RegistrationSetDynamicVariables( ) { HRESULT hr = S_OK; - LONGLONG llInstalled = BOOTSTRAPPER_REGISTRATION_TYPE_FULL == pRegistration->detectedRegistrationType ? 1 : 0; + LONGLONG llInstalled = 0; + + // Detect if bundle is already installed. + hr = RegistrationDetectInstalled(pRegistration); + ExitOnFailure(hr, "Failed to detect bundle install state."); + + llInstalled = BOOTSTRAPPER_REGISTRATION_TYPE_FULL == pRegistration->detectedRegistrationType ? 1 : 0; hr = VariableSetNumeric(pVariables, BURN_BUNDLE_INSTALLED, llInstalled, TRUE); ExitOnFailure(hr, "Failed to set the bundle installed built-in variable."); diff --git a/src/burn/engine/variable.cpp b/src/burn/engine/variable.cpp index 5d92590c..ae06c1d5 100644 --- a/src/burn/engine/variable.cpp +++ b/src/burn/engine/variable.cpp @@ -271,7 +271,7 @@ extern "C" HRESULT VariableInitialize( {BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, InitializeVariableString, NULL, FALSE, TRUE}, {BURN_BUNDLE_EXECUTE_PACKAGE_ACTION, InitializeVariableString, NULL, FALSE, TRUE}, {BURN_BUNDLE_FORCED_RESTART_PACKAGE, InitializeVariableString, NULL, TRUE, TRUE}, - {BURN_BUNDLE_INSTALLED, InitializeVariableNumeric, 0, FALSE, TRUE}, + {BURN_BUNDLE_INSTALLED, InitializeVariableNumeric, 0}, {BURN_BUNDLE_ELEVATED, InitializeVariableNumeric, 0, FALSE, TRUE}, {BURN_BUNDLE_ACTIVE_PARENT, InitializeVariableString, NULL, FALSE, TRUE}, {BURN_BUNDLE_PROVIDER_KEY, InitializeVariableString, (DWORD_PTR)L"", FALSE, TRUE}, -- cgit v1.2.3-55-g6feb