aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-02-24 17:02:31 -0600
committerSean Hall <r.sean.hall@gmail.com>2021-03-02 15:47:43 -0600
commitb5c4d92528dd088d0065c634eb1a353c424a4441 (patch)
tree428d6caf8bd414f0735b5fbc28b1add950324d15
parenta98115d996d65834e7c8d593c10d2cfa66096ccd (diff)
downloadwix-b5c4d92528dd088d0065c634eb1a353c424a4441.tar.gz
wix-b5c4d92528dd088d0065c634eb1a353c424a4441.tar.bz2
wix-b5c4d92528dd088d0065c634eb1a353c424a4441.zip
Always remove all dependencies the bundle could have registered.
#6297
-rw-r--r--src/engine/apply.cpp2
-rw-r--r--src/engine/dependency.cpp17
-rw-r--r--src/engine/dependency.h3
-rw-r--r--src/engine/elevation.cpp6
-rw-r--r--src/engine/registration.cpp3
-rw-r--r--src/engine/registration.h1
-rw-r--r--src/test/BurnUnitTest/RegistrationTest.cpp18
7 files changed, 37 insertions, 13 deletions
diff --git a/src/engine/apply.cpp b/src/engine/apply.cpp
index 44ff9429..f57a56fe 100644
--- a/src/engine/apply.cpp
+++ b/src/engine/apply.cpp
@@ -435,7 +435,7 @@ extern "C" HRESULT ApplyUnregister(
435 } 435 }
436 else 436 else
437 { 437 {
438 hr = RegistrationSessionEnd(&pEngineState->registration, resumeMode, restart, pEngineState->plan.dependencyRegistrationAction); 438 hr = RegistrationSessionEnd(&pEngineState->registration, &pEngineState->packages, resumeMode, restart, pEngineState->plan.dependencyRegistrationAction);
439 ExitOnFailure(hr, "Failed to end session in per-user process."); 439 ExitOnFailure(hr, "Failed to end session in per-user process.");
440 } 440 }
441 441
diff --git a/src/engine/dependency.cpp b/src/engine/dependency.cpp
index 3d978740..4833de94 100644
--- a/src/engine/dependency.cpp
+++ b/src/engine/dependency.cpp
@@ -680,10 +680,12 @@ LExit:
680} 680}
681 681
682extern "C" void DependencyUnregisterBundle( 682extern "C" void DependencyUnregisterBundle(
683 __in const BURN_REGISTRATION* pRegistration 683 __in const BURN_REGISTRATION* pRegistration,
684 __in const BURN_PACKAGES* pPackages
684 ) 685 )
685{ 686{
686 HRESULT hr = S_OK; 687 HRESULT hr = S_OK;
688 LPCWSTR wzDependentProviderKey = pRegistration->sczId;
687 689
688 // Remove the bundle provider key. 690 // Remove the bundle provider key.
689 hr = DepUnregisterDependency(pRegistration->hkRoot, pRegistration->sczProviderKey); 691 hr = DepUnregisterDependency(pRegistration->hkRoot, pRegistration->sczProviderKey);
@@ -695,6 +697,19 @@ extern "C" void DependencyUnregisterBundle(
695 { 697 {
696 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_BUNDLE_UNREGISTERED_FAILED, pRegistration->sczProviderKey, hr); 698 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_BUNDLE_UNREGISTERED_FAILED, pRegistration->sczProviderKey, hr);
697 } 699 }
700
701 // Best effort to make sure this bundle is not registered as a dependent for anything.
702 for (DWORD i = 0; i < pPackages->cPackages; ++i)
703 {
704 const BURN_PACKAGE* pPackage = pPackages->rgPackages + i;
705 UnregisterPackageDependency(pPackage->fPerMachine, pPackage, wzDependentProviderKey);
706 }
707
708 for (DWORD i = 0; i < pRegistration->relatedBundles.cRelatedBundles; ++i)
709 {
710 const BURN_PACKAGE* pPackage = &pRegistration->relatedBundles.rgRelatedBundles[i].package;
711 UnregisterPackageDependency(pPackage->fPerMachine, pPackage, wzDependentProviderKey);
712 }
698} 713}
699 714
700// internal functions 715// internal functions
diff --git a/src/engine/dependency.h b/src/engine/dependency.h
index 5390bede..efb9f2f2 100644
--- a/src/engine/dependency.h
+++ b/src/engine/dependency.h
@@ -169,7 +169,8 @@ HRESULT DependencyProcessDependentRegistration(
169 Note: Does not check for existing dependents before removing the key. 169 Note: Does not check for existing dependents before removing the key.
170*********************************************************************/ 170*********************************************************************/
171void DependencyUnregisterBundle( 171void DependencyUnregisterBundle(
172 __in const BURN_REGISTRATION* pRegistration 172 __in const BURN_REGISTRATION* pRegistration,
173 __in const BURN_PACKAGES* pPackages
173 ); 174 );
174 175
175#if defined(__cplusplus) 176#if defined(__cplusplus)
diff --git a/src/engine/elevation.cpp b/src/engine/elevation.cpp
index c9ed9810..7c5dae4b 100644
--- a/src/engine/elevation.cpp
+++ b/src/engine/elevation.cpp
@@ -154,6 +154,7 @@ static HRESULT OnSessionResume(
154 __in DWORD cbData 154 __in DWORD cbData
155 ); 155 );
156static HRESULT OnSessionEnd( 156static HRESULT OnSessionEnd(
157 __in BURN_PACKAGES* pPackages,
157 __in BURN_REGISTRATION* pRegistration, 158 __in BURN_REGISTRATION* pRegistration,
158 __in BYTE* pbData, 159 __in BYTE* pbData,
159 __in DWORD cbData 160 __in DWORD cbData
@@ -1637,7 +1638,7 @@ static HRESULT ProcessElevatedChildMessage(
1637 break; 1638 break;
1638 1639
1639 case BURN_ELEVATION_MESSAGE_TYPE_SESSION_END: 1640 case BURN_ELEVATION_MESSAGE_TYPE_SESSION_END:
1640 hrResult = OnSessionEnd(pContext->pRegistration, (BYTE*)pMsg->pvData, pMsg->cbData); 1641 hrResult = OnSessionEnd(pContext->pPackages, pContext->pRegistration, (BYTE*)pMsg->pvData, pMsg->cbData);
1641 break; 1642 break;
1642 1643
1643 case BURN_ELEVATION_MESSAGE_TYPE_SAVE_STATE: 1644 case BURN_ELEVATION_MESSAGE_TYPE_SAVE_STATE:
@@ -1954,6 +1955,7 @@ LExit:
1954} 1955}
1955 1956
1956static HRESULT OnSessionEnd( 1957static HRESULT OnSessionEnd(
1958 __in BURN_PACKAGES* pPackages,
1957 __in BURN_REGISTRATION* pRegistration, 1959 __in BURN_REGISTRATION* pRegistration,
1958 __in BYTE* pbData, 1960 __in BYTE* pbData,
1959 __in DWORD cbData 1961 __in DWORD cbData
@@ -1976,7 +1978,7 @@ static HRESULT OnSessionEnd(
1976 ExitOnFailure(hr, "Failed to read dependency registration action."); 1978 ExitOnFailure(hr, "Failed to read dependency registration action.");
1977 1979
1978 // suspend session in per-machine process 1980 // suspend session in per-machine process
1979 hr = RegistrationSessionEnd(pRegistration, (BURN_RESUME_MODE)dwResumeMode, (BOOTSTRAPPER_APPLY_RESTART)dwRestart, (BURN_DEPENDENCY_REGISTRATION_ACTION)dwDependencyRegistrationAction); 1981 hr = RegistrationSessionEnd(pRegistration, pPackages, (BURN_RESUME_MODE)dwResumeMode, (BOOTSTRAPPER_APPLY_RESTART)dwRestart, (BURN_DEPENDENCY_REGISTRATION_ACTION)dwDependencyRegistrationAction);
1980 ExitOnFailure(hr, "Failed to suspend registration session."); 1982 ExitOnFailure(hr, "Failed to suspend registration session.");
1981 1983
1982LExit: 1984LExit:
diff --git a/src/engine/registration.cpp b/src/engine/registration.cpp
index 9c821422..dc4b88bf 100644
--- a/src/engine/registration.cpp
+++ b/src/engine/registration.cpp
@@ -869,6 +869,7 @@ LExit:
869 *******************************************************************/ 869 *******************************************************************/
870extern "C" HRESULT RegistrationSessionEnd( 870extern "C" HRESULT RegistrationSessionEnd(
871 __in BURN_REGISTRATION* pRegistration, 871 __in BURN_REGISTRATION* pRegistration,
872 __in BURN_PACKAGES* pPackages,
872 __in BURN_RESUME_MODE resumeMode, 873 __in BURN_RESUME_MODE resumeMode,
873 __in BOOTSTRAPPER_APPLY_RESTART restart, 874 __in BOOTSTRAPPER_APPLY_RESTART restart,
874 __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction 875 __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction
@@ -912,7 +913,7 @@ extern "C" HRESULT RegistrationSessionEnd(
912 BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER == dependencyRegistrationAction) 913 BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER == dependencyRegistrationAction)
913 { 914 {
914 // Remove the bundle dependency key. 915 // Remove the bundle dependency key.
915 DependencyUnregisterBundle(pRegistration); 916 DependencyUnregisterBundle(pRegistration, pPackages);
916 } 917 }
917 918
918 // Delete update registration key. 919 // Delete update registration key.
diff --git a/src/engine/registration.h b/src/engine/registration.h
index 56bcb1f0..4aca5a05 100644
--- a/src/engine/registration.h
+++ b/src/engine/registration.h
@@ -196,6 +196,7 @@ HRESULT RegistrationSessionResume(
196 ); 196 );
197HRESULT RegistrationSessionEnd( 197HRESULT RegistrationSessionEnd(
198 __in BURN_REGISTRATION* pRegistration, 198 __in BURN_REGISTRATION* pRegistration,
199 __in BURN_PACKAGES* pPackages,
199 __in BURN_RESUME_MODE resumeMode, 200 __in BURN_RESUME_MODE resumeMode,
200 __in BOOTSTRAPPER_APPLY_RESTART restart, 201 __in BOOTSTRAPPER_APPLY_RESTART restart,
201 __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction 202 __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction
diff --git a/src/test/BurnUnitTest/RegistrationTest.cpp b/src/test/BurnUnitTest/RegistrationTest.cpp
index 9c7bf4ce..1687385b 100644
--- a/src/test/BurnUnitTest/RegistrationTest.cpp
+++ b/src/test/BurnUnitTest/RegistrationTest.cpp
@@ -71,6 +71,7 @@ namespace Bootstrapper
71 BOOTSTRAPPER_COMMAND command = { }; 71 BOOTSTRAPPER_COMMAND command = { };
72 BURN_REGISTRATION registration = { }; 72 BURN_REGISTRATION registration = { };
73 BURN_LOGGING logging = { }; 73 BURN_LOGGING logging = { };
74 BURN_PACKAGES packages = { };
74 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}")); 75 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"));
75 try 76 try
76 { 77 {
@@ -121,7 +122,7 @@ namespace Bootstrapper
121 Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)(Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"), nullptr))); 122 Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)(Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"), nullptr)));
122 123
123 // end session 124 // end session
124 hr = RegistrationSessionEnd(&registration, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER); 125 hr = RegistrationSessionEnd(&registration, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER);
125 TestThrowOnFailure(hr, L"Failed to unregister bundle."); 126 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
126 127
127 // verify that registration was removed 128 // verify that registration was removed
@@ -159,6 +160,7 @@ namespace Bootstrapper
159 BOOTSTRAPPER_COMMAND command = { }; 160 BOOTSTRAPPER_COMMAND command = { };
160 BURN_REGISTRATION registration = { }; 161 BURN_REGISTRATION registration = { };
161 BURN_LOGGING logging = { }; 162 BURN_LOGGING logging = { };
163 BURN_PACKAGES packages = { };
162 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}")); 164 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"));
163 try 165 try
164 { 166 {
@@ -210,7 +212,7 @@ namespace Bootstrapper
210 Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"), nullptr)); 212 Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"), nullptr));
211 213
212 // complete registration 214 // complete registration
213 hr = RegistrationSessionEnd(&registration, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER); 215 hr = RegistrationSessionEnd(&registration, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER);
214 TestThrowOnFailure(hr, L"Failed to unregister bundle."); 216 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
215 217
216 // verify that registration was updated 218 // verify that registration was updated
@@ -232,7 +234,7 @@ namespace Bootstrapper
232 Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"), nullptr)); 234 Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"), nullptr));
233 235
234 // delete registration 236 // delete registration
235 hr = RegistrationSessionEnd(&registration, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER); 237 hr = RegistrationSessionEnd(&registration, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER);
236 TestThrowOnFailure(hr, L"Failed to unregister bundle."); 238 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
237 239
238 // verify that registration was removed 240 // verify that registration was removed
@@ -269,6 +271,7 @@ namespace Bootstrapper
269 BOOTSTRAPPER_COMMAND command = { }; 271 BOOTSTRAPPER_COMMAND command = { };
270 BURN_REGISTRATION registration = { }; 272 BURN_REGISTRATION registration = { };
271 BURN_LOGGING logging = { }; 273 BURN_LOGGING logging = { };
274 BURN_PACKAGES packages = { };
272 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}")); 275 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"));
273 try 276 try
274 { 277 {
@@ -322,7 +325,7 @@ namespace Bootstrapper
322 Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"), nullptr)); 325 Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"), nullptr));
323 326
324 // finish registration 327 // finish registration
325 hr = RegistrationSessionEnd(&registration, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER); 328 hr = RegistrationSessionEnd(&registration, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER);
326 TestThrowOnFailure(hr, L"Failed to register bundle."); 329 TestThrowOnFailure(hr, L"Failed to register bundle.");
327 330
328 // verify that registration was updated 331 // verify that registration was updated
@@ -355,7 +358,7 @@ namespace Bootstrapper
355 Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"), nullptr)); 358 Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"), nullptr));
356 359
357 // delete registration 360 // delete registration
358 hr = RegistrationSessionEnd(&registration, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER); 361 hr = RegistrationSessionEnd(&registration, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER);
359 TestThrowOnFailure(hr, L"Failed to unregister bundle."); 362 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
360 363
361 // verify that registration was removed 364 // verify that registration was removed
@@ -392,6 +395,7 @@ namespace Bootstrapper
392 BOOTSTRAPPER_COMMAND command = { }; 395 BOOTSTRAPPER_COMMAND command = { };
393 BURN_REGISTRATION registration = { }; 396 BURN_REGISTRATION registration = { };
394 BURN_LOGGING logging = { }; 397 BURN_LOGGING logging = { };
398 BURN_PACKAGES packages = { };
395 BYTE rgbData[256] = { }; 399 BYTE rgbData[256] = { };
396 BOOTSTRAPPER_RESUME_TYPE resumeType = BOOTSTRAPPER_RESUME_TYPE_NONE; 400 BOOTSTRAPPER_RESUME_TYPE resumeType = BOOTSTRAPPER_RESUME_TYPE_NONE;
397 BYTE* pbBuffer = NULL; 401 BYTE* pbBuffer = NULL;
@@ -459,7 +463,7 @@ namespace Bootstrapper
459 Assert::Equal((int)BOOTSTRAPPER_RESUME_TYPE_INTERRUPTED, (int)resumeType); 463 Assert::Equal((int)BOOTSTRAPPER_RESUME_TYPE_INTERRUPTED, (int)resumeType);
460 464
461 // suspend session 465 // suspend session
462 hr = RegistrationSessionEnd(&registration, BURN_RESUME_MODE_SUSPEND, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER); 466 hr = RegistrationSessionEnd(&registration, &packages, BURN_RESUME_MODE_SUSPEND, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER);
463 TestThrowOnFailure(hr, L"Failed to suspend session."); 467 TestThrowOnFailure(hr, L"Failed to suspend session.");
464 468
465 // verify that run key was removed 469 // verify that run key was removed
@@ -486,7 +490,7 @@ namespace Bootstrapper
486 Assert::NotEqual((Object^)nullptr, Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"), nullptr)); 490 Assert::NotEqual((Object^)nullptr, Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(L"{D54F896D-1952-43e6-9C67-B5652240618C}"), nullptr));
487 491
488 // end session 492 // end session
489 hr = RegistrationSessionEnd(&registration, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER); 493 hr = RegistrationSessionEnd(&registration, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER);
490 TestThrowOnFailure(hr, L"Failed to unregister bundle."); 494 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
491 495
492 // read resume type after session 496 // read resume type after session