Skip to content

Commit

Permalink
Ensure WixBundleInstalled and RebootPending are set in elevated engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
rseanhall committed Mar 5, 2022
1 parent 3ac19da commit 6a90b64
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
12 changes: 0 additions & 12 deletions src/burn/engine/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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.");

Expand Down
7 changes: 6 additions & 1 deletion src/burn/engine/elevation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -2331,13 +2332,17 @@ static HRESULT OnApplyInitialize(

static HRESULT ElevatedProcessDetect(
__in BURN_REGISTRATION* pRegistration,
__in BURN_VARIABLES* pVariables,
__in BURN_PACKAGES* pPackages
)
{
HRESULT hr = S_OK;

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.");

Expand Down
8 changes: 7 additions & 1 deletion src/burn/engine/registration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down

0 comments on commit 6a90b64

Please sign in to comment.