diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-03-04 17:55:17 -0600 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-03-05 16:22:04 -0600 |
commit | e027c6c571a4bc8c818244e2b0c5015eb4ef3110 (patch) | |
tree | 8149aa491766bfe8a883f921831a52133abceea5 /src/burn/engine/registration.cpp | |
parent | baf09c19c5a0f0d3f9533f9084f094066c1be7d9 (diff) | |
download | wix-e027c6c571a4bc8c818244e2b0c5015eb4ef3110.tar.gz wix-e027c6c571a4bc8c818244e2b0c5015eb4ef3110.tar.bz2 wix-e027c6c571a4bc8c818244e2b0c5015eb4ef3110.zip |
Change ARP property Installed to 0 when registrationType is InProgress.
Being registered in ARP and "installed" were always separate concepts, and some things like fEligibleForCleanup were looking at the wrong thing. This also allows the BA to tell the difference.
Diffstat (limited to 'src/burn/engine/registration.cpp')
-rw-r--r-- | src/burn/engine/registration.cpp | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp index a1b1b607..fcefe5e0 100644 --- a/src/burn/engine/registration.cpp +++ b/src/burn/engine/registration.cpp | |||
@@ -69,6 +69,7 @@ static HRESULT UpdateResumeMode( | |||
69 | __in BURN_REGISTRATION* pRegistration, | 69 | __in BURN_REGISTRATION* pRegistration, |
70 | __in HKEY hkRegistration, | 70 | __in HKEY hkRegistration, |
71 | __in BURN_RESUME_MODE resumeMode, | 71 | __in BURN_RESUME_MODE resumeMode, |
72 | __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType, | ||
72 | __in BOOL fRestartInitiated | 73 | __in BOOL fRestartInitiated |
73 | ); | 74 | ); |
74 | static HRESULT ParseRelatedCodes( | 75 | static HRESULT ParseRelatedCodes( |
@@ -444,11 +445,8 @@ extern "C" HRESULT RegistrationSetVariables( | |||
444 | HRESULT hr = S_OK; | 445 | HRESULT hr = S_OK; |
445 | LPWSTR scz = NULL; | 446 | LPWSTR scz = NULL; |
446 | 447 | ||
447 | if (pRegistration->fInstalled) | 448 | hr = RegistrationSetDynamicVariables(pRegistration, pVariables); |
448 | { | 449 | ExitOnFailure(hr, "Failed to set the dynamic registration variables."); |
449 | hr = VariableSetNumeric(pVariables, BURN_BUNDLE_INSTALLED, 1, TRUE); | ||
450 | ExitOnFailure(hr, "Failed to set the bundle installed built-in variable."); | ||
451 | } | ||
452 | 450 | ||
453 | // Ensure the registration bundle name is updated. | 451 | // Ensure the registration bundle name is updated. |
454 | hr = GetBundleInProgressName(pRegistration, pVariables, &scz); | 452 | hr = GetBundleInProgressName(pRegistration, pVariables, &scz); |
@@ -469,12 +467,32 @@ extern "C" HRESULT RegistrationSetVariables( | |||
469 | hr = VariableSetVersion(pVariables, BURN_BUNDLE_VERSION, pRegistration->pVersion, TRUE); | 467 | hr = VariableSetVersion(pVariables, BURN_BUNDLE_VERSION, pRegistration->pVersion, TRUE); |
470 | ExitOnFailure(hr, "Failed to overwrite the bundle version built-in variable."); | 468 | ExitOnFailure(hr, "Failed to overwrite the bundle version built-in variable."); |
471 | 469 | ||
470 | LExit: | ||
471 | ReleaseStr(scz); | ||
472 | |||
473 | return hr; | ||
474 | } | ||
475 | |||
476 | /******************************************************************* | ||
477 | RegistrationSetDynamicVariables - Initializes bundle variables that | ||
478 | map to registration entities that can change during execution. | ||
479 | |||
480 | *******************************************************************/ | ||
481 | extern "C" HRESULT RegistrationSetDynamicVariables( | ||
482 | __in BURN_REGISTRATION* pRegistration, | ||
483 | __in BURN_VARIABLES* pVariables | ||
484 | ) | ||
485 | { | ||
486 | HRESULT hr = S_OK; | ||
487 | LONGLONG llInstalled = BOOTSTRAPPER_REGISTRATION_TYPE_FULL == pRegistration->detectedRegistrationType ? 1 : 0; | ||
488 | |||
489 | hr = VariableSetNumeric(pVariables, BURN_BUNDLE_INSTALLED, llInstalled, TRUE); | ||
490 | ExitOnFailure(hr, "Failed to set the bundle installed built-in variable."); | ||
491 | |||
472 | hr = VariableSetNumeric(pVariables, BURN_REBOOT_PENDING, IsWuRebootPending() || IsRegistryRebootPending(), TRUE); | 492 | hr = VariableSetNumeric(pVariables, BURN_REBOOT_PENDING, IsWuRebootPending() || IsRegistryRebootPending(), TRUE); |
473 | ExitOnFailure(hr, "Failed to overwrite the bundle reboot-pending built-in variable."); | 493 | ExitOnFailure(hr, "Failed to overwrite the bundle reboot-pending built-in variable."); |
474 | 494 | ||
475 | LExit: | 495 | LExit: |
476 | ReleaseStr(scz); | ||
477 | |||
478 | return hr; | 496 | return hr; |
479 | } | 497 | } |
480 | 498 | ||
@@ -487,12 +505,15 @@ extern "C" HRESULT RegistrationDetectInstalled( | |||
487 | DWORD dwInstalled = 0; | 505 | DWORD dwInstalled = 0; |
488 | 506 | ||
489 | pRegistration->fCached = FileExistsEx(pRegistration->sczCacheExecutablePath, NULL); | 507 | pRegistration->fCached = FileExistsEx(pRegistration->sczCacheExecutablePath, NULL); |
508 | pRegistration->detectedRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE; | ||
490 | 509 | ||
491 | // open registration key | 510 | // open registration key |
492 | hr = RegOpen(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_QUERY_VALUE, &hkRegistration); | 511 | hr = RegOpen(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_QUERY_VALUE, &hkRegistration); |
493 | if (SUCCEEDED(hr)) | 512 | if (SUCCEEDED(hr)) |
494 | { | 513 | { |
495 | hr = RegReadNumber(hkRegistration, REGISTRY_BUNDLE_INSTALLED, &dwInstalled); | 514 | hr = RegReadNumber(hkRegistration, REGISTRY_BUNDLE_INSTALLED, &dwInstalled); |
515 | |||
516 | pRegistration->detectedRegistrationType = (1 == dwInstalled) ? BOOTSTRAPPER_REGISTRATION_TYPE_FULL : BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS; | ||
496 | } | 517 | } |
497 | 518 | ||
498 | // Not finding the key or value is okay. | 519 | // Not finding the key or value is okay. |
@@ -501,8 +522,6 @@ extern "C" HRESULT RegistrationDetectInstalled( | |||
501 | hr = S_OK; | 522 | hr = S_OK; |
502 | } | 523 | } |
503 | 524 | ||
504 | pRegistration->fInstalled = (1 == dwInstalled); | ||
505 | |||
506 | ReleaseRegKey(hkRegistration); | 525 | ReleaseRegKey(hkRegistration); |
507 | return hr; | 526 | return hr; |
508 | } | 527 | } |
@@ -833,7 +852,7 @@ extern "C" HRESULT RegistrationSessionBegin( | |||
833 | } | 852 | } |
834 | 853 | ||
835 | // update resume mode | 854 | // update resume mode |
836 | hr = UpdateResumeMode(pRegistration, hkRegistration, BURN_RESUME_MODE_ACTIVE, FALSE); | 855 | hr = UpdateResumeMode(pRegistration, hkRegistration, BURN_RESUME_MODE_ACTIVE, registrationType, FALSE); |
837 | ExitOnFailure(hr, "Failed to update resume mode."); | 856 | ExitOnFailure(hr, "Failed to update resume mode."); |
838 | 857 | ||
839 | LExit: | 858 | LExit: |
@@ -864,7 +883,7 @@ extern "C" HRESULT RegistrationSessionResume( | |||
864 | ExitOnFailure(hr, "Failed to open registration key."); | 883 | ExitOnFailure(hr, "Failed to open registration key."); |
865 | 884 | ||
866 | // update resume mode | 885 | // update resume mode |
867 | hr = UpdateResumeMode(pRegistration, hkRegistration, BURN_RESUME_MODE_ACTIVE, FALSE); | 886 | hr = UpdateResumeMode(pRegistration, hkRegistration, BURN_RESUME_MODE_ACTIVE, registrationType, FALSE); |
868 | ExitOnFailure(hr, "Failed to update resume mode."); | 887 | ExitOnFailure(hr, "Failed to update resume mode."); |
869 | 888 | ||
870 | // update display name | 889 | // update display name |
@@ -934,7 +953,7 @@ extern "C" HRESULT RegistrationSessionEnd( | |||
934 | } | 953 | } |
935 | 954 | ||
936 | // Update resume mode. | 955 | // Update resume mode. |
937 | hr = UpdateResumeMode(pRegistration, hkRegistration, resumeMode, BOOTSTRAPPER_APPLY_RESTART_INITIATED == restart); | 956 | hr = UpdateResumeMode(pRegistration, hkRegistration, resumeMode, registrationType, BOOTSTRAPPER_APPLY_RESTART_INITIATED == restart); |
938 | ExitOnFailure(hr, "Failed to update resume mode."); | 957 | ExitOnFailure(hr, "Failed to update resume mode."); |
939 | 958 | ||
940 | LExit: | 959 | LExit: |
@@ -1271,6 +1290,7 @@ static HRESULT UpdateResumeMode( | |||
1271 | __in BURN_REGISTRATION* pRegistration, | 1290 | __in BURN_REGISTRATION* pRegistration, |
1272 | __in HKEY hkRegistration, | 1291 | __in HKEY hkRegistration, |
1273 | __in BURN_RESUME_MODE resumeMode, | 1292 | __in BURN_RESUME_MODE resumeMode, |
1293 | __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType, | ||
1274 | __in BOOL fRestartInitiated | 1294 | __in BOOL fRestartInitiated |
1275 | ) | 1295 | ) |
1276 | { | 1296 | { |
@@ -1289,16 +1309,9 @@ static HRESULT UpdateResumeMode( | |||
1289 | hr = RegWriteNumber(hkRegistration, L"Resume", (DWORD)resumeMode); | 1309 | hr = RegWriteNumber(hkRegistration, L"Resume", (DWORD)resumeMode); |
1290 | ExitOnFailure(hr, "Failed to write Resume value."); | 1310 | ExitOnFailure(hr, "Failed to write Resume value."); |
1291 | 1311 | ||
1292 | // Write the Installed value *only* when the mode is ARP. This will tell us | 1312 | // Write Installed value. |
1293 | // that the bundle considers itself "installed" on the machine. Note that we | 1313 | hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_INSTALLED, BOOTSTRAPPER_REGISTRATION_TYPE_FULL == registrationType ? 1 : 0); |
1294 | // never change the value to "0" after that. The bundle will be considered | 1314 | ExitOnFailure(hr, "Failed to write Installed value."); |
1295 | // "uninstalled" when all of the registration is removed. | ||
1296 | if (BURN_RESUME_MODE_ARP == resumeMode) | ||
1297 | { | ||
1298 | // Write Installed value. | ||
1299 | hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_INSTALLED, 1); | ||
1300 | ExitOnFailure(hr, "Failed to write Installed value."); | ||
1301 | } | ||
1302 | } | 1315 | } |
1303 | 1316 | ||
1304 | // If the engine is active write the run key so we resume if there is an unexpected | 1317 | // If the engine is active write the run key so we resume if there is an unexpected |