@joebigelow / wix-1 / commits / 5a6c681b

Ensure WixBundleInstalled and RebootPending are set in elevated engine.

Sean Hall committed Mar 5, 2022 at 15:27 UTC 5a6c681b28c953d809292b4b85c80af300d7902f
4 files changed +14 -15
src/burn/engine/core.cpp
-12
@@ -264,10 +264,6 @@ extern "C" HRESULT CoreQueryRegistration(
264 SIZE_T cbBuffer = 0;
265 SIZE_T iBuffer = 0;
266
267 - // Detect if bundle is already installed.
268 - hr = RegistrationDetectInstalled(&pEngineState->registration);
269 - ExitOnFailure(hr, "Failed to detect bundle install state.");
270 -
267 // detect resume type
268 hr = RegistrationDetectResumeType(&pEngineState->registration, &pEngineState->command.resumeType);
269 ExitOnFailure(hr, "Failed to detect resume type.");
@@ -315,14 +311,6 @@ extern "C" HRESULT CoreDetect(
311 DetectReset(&pEngineState->registration, &pEngineState->packages);
312 PlanReset(&pEngineState->plan, &pEngineState->containers, &pEngineState->packages, &pEngineState->layoutPayloads);
313
318 - // Detect if bundle installed state has changed since start up.
319 - // This only happens if Apply() changed the state of bundle (installed, in progress, or uninstalled).
320 - // In that case, Detect() can be used here to reset the installed state.
321 - // Of course, there's also cases outside of this bundle's control,
322 - // like other processes messing with its registration.
323 - hr = RegistrationDetectInstalled(&pEngineState->registration);
324 - ExitOnFailure(hr, "Failed to detect bundle install state.");
325 -
314 hr = RegistrationSetDynamicVariables(&pEngineState->registration, &pEngineState->variables);
315 ExitOnFailure(hr, "Failed to reset the dynamic registration variables during detect.");
316
src/burn/engine/elevation.cpp
+6 -1
@@ -178,6 +178,7 @@ static HRESULT OnApplyInitialize(
178 );
179 static HRESULT ElevatedProcessDetect(
180 __in BURN_REGISTRATION* pRegistration,
181 + __in BURN_VARIABLES* pVariables,
182 __in BURN_PACKAGES* pPackages
183 );
184 static HRESULT OnApplyUninitialize(
@@ -2245,7 +2246,7 @@ static HRESULT OnApplyInitialize(
2246 ExitOnFailure(hr, "Failed to acquire lock due to setup in other session.");
2247
2248 // Detect.
2248 - hr = ElevatedProcessDetect(pRegistration, pPackages);
2249 + hr = ElevatedProcessDetect(pRegistration, pVariables, pPackages);
2250 ExitOnFailure(hr, "Failed to run detection in elevated process.");
2251
2252 // Attempt to pause AU with best effort.
@@ -2331,6 +2332,7 @@ LExit:
2332
2333 static HRESULT ElevatedProcessDetect(
2334 __in BURN_REGISTRATION* pRegistration,
2335 + __in BURN_VARIABLES* pVariables,
2336 __in BURN_PACKAGES* pPackages
2337 )
2338 {
@@ -2338,6 +2340,9 @@ static HRESULT ElevatedProcessDetect(
2340
2341 DetectReset(pRegistration, pPackages);
2342
2343 + hr = RegistrationSetDynamicVariables(pRegistration, pVariables);
2344 + ExitOnFailure(hr, "Failed to reset the dynamic registration variables during elevated detect.");
2345 +
2346 hr = RelatedBundlesInitializeForScope(TRUE, pRegistration, &pRegistration->relatedBundles);
2347 ExitOnFailure(hr, "Failed to initialize per-machine related bundles.");
2348
src/burn/engine/registration.cpp
+7 -1
@@ -484,7 +484,13 @@ extern "C" HRESULT RegistrationSetDynamicVariables(
484 )
485 {
486 HRESULT hr = S_OK;
487 - LONGLONG llInstalled = BOOTSTRAPPER_REGISTRATION_TYPE_FULL == pRegistration->detectedRegistrationType ? 1 : 0;
487 + LONGLONG llInstalled = 0;
488 +
489 + // Detect if bundle is already installed.
490 + hr = RegistrationDetectInstalled(pRegistration);
491 + ExitOnFailure(hr, "Failed to detect bundle install state.");
492 +
493 + llInstalled = BOOTSTRAPPER_REGISTRATION_TYPE_FULL == pRegistration->detectedRegistrationType ? 1 : 0;
494
495 hr = VariableSetNumeric(pVariables, BURN_BUNDLE_INSTALLED, llInstalled, TRUE);
496 ExitOnFailure(hr, "Failed to set the bundle installed built-in variable.");
src/burn/engine/variable.cpp
+1 -1
@@ -271,7 +271,7 @@ extern "C" HRESULT VariableInitialize(
271 {BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, InitializeVariableString, NULL, FALSE, TRUE},
272 {BURN_BUNDLE_EXECUTE_PACKAGE_ACTION, InitializeVariableString, NULL, FALSE, TRUE},
273 {BURN_BUNDLE_FORCED_RESTART_PACKAGE, InitializeVariableString, NULL, TRUE, TRUE},
274 - {BURN_BUNDLE_INSTALLED, InitializeVariableNumeric, 0, FALSE, TRUE},
274 + {BURN_BUNDLE_INSTALLED, InitializeVariableNumeric, 0},
275 {BURN_BUNDLE_ELEVATED, InitializeVariableNumeric, 0, FALSE, TRUE},
276 {BURN_BUNDLE_ACTIVE_PARENT, InitializeVariableString, NULL, FALSE, TRUE},
277 {BURN_BUNDLE_PROVIDER_KEY, InitializeVariableString, (DWORD_PTR)L"", FALSE, TRUE},