aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine/registration.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-05-13 20:46:08 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-05-19 12:15:13 -0500
commit2c085b3aa89150fff9a0ea6df2cde0ce56e3066d (patch)
treed5c1cfb9e6fa1cc1270c813d28a6ca3ee4f84b0b /src/burn/engine/registration.cpp
parentf88ffc7f5c1710b5e106d7e6aea7f1e32fb15dfe (diff)
downloadwix-2c085b3aa89150fff9a0ea6df2cde0ce56e3066d.tar.gz
wix-2c085b3aa89150fff9a0ea6df2cde0ce56e3066d.tar.bz2
wix-2c085b3aa89150fff9a0ea6df2cde0ce56e3066d.zip
Add InProgressDisplayName for bundles.
#6296
Diffstat (limited to 'src/burn/engine/registration.cpp')
-rw-r--r--src/burn/engine/registration.cpp140
1 files changed, 105 insertions, 35 deletions
diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp
index 5b246112..eed1fee2 100644
--- a/src/burn/engine/registration.cpp
+++ b/src/burn/engine/registration.cpp
@@ -46,12 +46,23 @@ static HRESULT SetPaths(
46static HRESULT GetBundleManufacturer( 46static HRESULT GetBundleManufacturer(
47 __in BURN_REGISTRATION* pRegistration, 47 __in BURN_REGISTRATION* pRegistration,
48 __in BURN_VARIABLES* pVariables, 48 __in BURN_VARIABLES* pVariables,
49 __out LPWSTR* psczBundleManufacturer 49 __out_z LPWSTR* psczBundleManufacturer
50 );
51static HRESULT GetBundleInProgressName(
52 __in BURN_REGISTRATION* pRegistration,
53 __in BURN_VARIABLES* pVariables,
54 __out_z LPWSTR* psczBundleName
50 ); 55 );
51static HRESULT GetBundleName( 56static HRESULT GetBundleName(
52 __in BURN_REGISTRATION* pRegistration, 57 __in BURN_REGISTRATION* pRegistration,
53 __in BURN_VARIABLES* pVariables, 58 __in BURN_VARIABLES* pVariables,
54 __out LPWSTR* psczBundleName 59 __out_z LPWSTR* psczBundleName
60 );
61static HRESULT EnsureRegistrationVariable(
62 __in BURN_VARIABLES* pVariables,
63 __in_z LPCWSTR wzVariable,
64 __in_z LPCWSTR wzDefaultValue,
65 __out_z LPWSTR* psczValue
55 ); 66 );
56static HRESULT UpdateResumeMode( 67static HRESULT UpdateResumeMode(
57 __in BURN_REGISTRATION* pRegistration, 68 __in BURN_REGISTRATION* pRegistration,
@@ -91,7 +102,8 @@ static HRESULT RegWriteStringVariable(
91static HRESULT UpdateBundleNameRegistration( 102static HRESULT UpdateBundleNameRegistration(
92 __in BURN_REGISTRATION* pRegistration, 103 __in BURN_REGISTRATION* pRegistration,
93 __in BURN_VARIABLES* pVariables, 104 __in BURN_VARIABLES* pVariables,
94 __in HKEY hkRegistration 105 __in HKEY hkRegistration,
106 __in BOOL fInProgressRegistration
95 ); 107 );
96static BOOL IsWuRebootPending(); 108static BOOL IsWuRebootPending();
97static BOOL IsBundleRebootPending( 109static BOOL IsBundleRebootPending(
@@ -176,6 +188,13 @@ extern "C" HRESULT RegistrationParseFromXml(
176 ExitOnFailure(hr, "Failed to get @DisplayName."); 188 ExitOnFailure(hr, "Failed to get @DisplayName.");
177 } 189 }
178 190
191 // @InProgressDisplayName
192 hr = XmlGetAttributeEx(pixnArpNode, L"InProgressDisplayName", &pRegistration->sczInProgressDisplayName);
193 if (E_NOTFOUND != hr)
194 {
195 ExitOnFailure(hr, "Failed to get @InProgressDisplayName.");
196 }
197
179 // @DisplayVersion 198 // @DisplayVersion
180 hr = XmlGetAttributeEx(pixnArpNode, L"DisplayVersion", &pRegistration->sczDisplayVersion); 199 hr = XmlGetAttributeEx(pixnArpNode, L"DisplayVersion", &pRegistration->sczDisplayVersion);
181 if (E_NOTFOUND != hr) 200 if (E_NOTFOUND != hr)
@@ -372,6 +391,7 @@ extern "C" void RegistrationUninitialize(
372 ReleaseStr(pRegistration->sczStateFile); 391 ReleaseStr(pRegistration->sczStateFile);
373 392
374 ReleaseStr(pRegistration->sczDisplayName); 393 ReleaseStr(pRegistration->sczDisplayName);
394 ReleaseStr(pRegistration->sczInProgressDisplayName);
375 ReleaseStr(pRegistration->sczDisplayVersion); 395 ReleaseStr(pRegistration->sczDisplayVersion);
376 ReleaseStr(pRegistration->sczPublisher); 396 ReleaseStr(pRegistration->sczPublisher);
377 ReleaseStr(pRegistration->sczHelpLink); 397 ReleaseStr(pRegistration->sczHelpLink);
@@ -421,8 +441,7 @@ extern "C" HRESULT RegistrationSetVariables(
421 ) 441 )
422{ 442{
423 HRESULT hr = S_OK; 443 HRESULT hr = S_OK;
424 LPWSTR sczBundleManufacturer = NULL; 444 LPWSTR scz = NULL;
425 LPWSTR sczBundleName = NULL;
426 445
427 if (pRegistration->fInstalled) 446 if (pRegistration->fInstalled)
428 { 447 {
@@ -431,10 +450,13 @@ extern "C" HRESULT RegistrationSetVariables(
431 } 450 }
432 451
433 // Ensure the registration bundle name is updated. 452 // Ensure the registration bundle name is updated.
434 hr = GetBundleName(pRegistration, pVariables, &sczBundleName); 453 hr = GetBundleInProgressName(pRegistration, pVariables, &scz);
435 ExitOnFailure(hr, "Failed to initialize bundle name."); 454 ExitOnFailure(hr, "Failed to initialize bundle name.");
436 455
437 hr = GetBundleManufacturer(pRegistration, pVariables, &sczBundleName); 456 hr = GetBundleName(pRegistration, pVariables, &scz);
457 ExitOnFailure(hr, "Failed to initialize bundle name.");
458
459 hr = GetBundleManufacturer(pRegistration, pVariables, &scz);
438 ExitOnFailure(hr, "Failed to initialize bundle manufacturer."); 460 ExitOnFailure(hr, "Failed to initialize bundle manufacturer.");
439 461
440 if (pRegistration->sczActiveParent && *pRegistration->sczActiveParent) 462 if (pRegistration->sczActiveParent && *pRegistration->sczActiveParent)
@@ -456,8 +478,7 @@ extern "C" HRESULT RegistrationSetVariables(
456 ExitOnFailure(hr, "Failed to overwrite the bundle reboot-pending built-in variable."); 478 ExitOnFailure(hr, "Failed to overwrite the bundle reboot-pending built-in variable.");
457 479
458LExit: 480LExit:
459 ReleaseStr(sczBundleManufacturer); 481 ReleaseStr(scz);
460 ReleaseStr(sczBundleName);
461 482
462 return hr; 483 return hr;
463} 484}
@@ -595,7 +616,8 @@ extern "C" HRESULT RegistrationSessionBegin(
595 __in BURN_VARIABLES* pVariables, 616 __in BURN_VARIABLES* pVariables,
596 __in DWORD dwRegistrationOptions, 617 __in DWORD dwRegistrationOptions,
597 __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction, 618 __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction,
598 __in DWORD64 qwEstimatedSize 619 __in DWORD64 qwEstimatedSize,
620 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType
599 ) 621 )
600{ 622{
601 HRESULT hr = S_OK; 623 HRESULT hr = S_OK;
@@ -603,6 +625,8 @@ extern "C" HRESULT RegistrationSessionBegin(
603 HKEY hkRegistration = NULL; 625 HKEY hkRegistration = NULL;
604 LPWSTR sczPublisher = NULL; 626 LPWSTR sczPublisher = NULL;
605 627
628 AssertSz(BOOTSTRAPPER_REGISTRATION_TYPE_NONE != registrationType, "Registration type can't be NONE");
629
606 LogId(REPORT_VERBOSE, MSG_SESSION_BEGIN, pRegistration->sczRegistrationKey, dwRegistrationOptions, LoggingBoolToString(pRegistration->fDisableResume)); 630 LogId(REPORT_VERBOSE, MSG_SESSION_BEGIN, pRegistration->sczRegistrationKey, dwRegistrationOptions, LoggingBoolToString(pRegistration->fDisableResume));
607 631
608 // Cache bundle executable. 632 // Cache bundle executable.
@@ -668,7 +692,7 @@ extern "C" HRESULT RegistrationSessionBegin(
668 ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_DISPLAY_ICON); 692 ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_DISPLAY_ICON);
669 693
670 // update display name 694 // update display name
671 hr = UpdateBundleNameRegistration(pRegistration, pVariables, hkRegistration); 695 hr = UpdateBundleNameRegistration(pRegistration, pVariables, hkRegistration, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS == registrationType);
672 ExitOnFailure(hr, "Failed to update name and publisher."); 696 ExitOnFailure(hr, "Failed to update name and publisher.");
673 697
674 // DisplayVersion: provided by UI 698 // DisplayVersion: provided by UI
@@ -841,12 +865,15 @@ LExit:
841*******************************************************************/ 865*******************************************************************/
842extern "C" HRESULT RegistrationSessionResume( 866extern "C" HRESULT RegistrationSessionResume(
843 __in BURN_REGISTRATION* pRegistration, 867 __in BURN_REGISTRATION* pRegistration,
844 __in BURN_VARIABLES* pVariables 868 __in BURN_VARIABLES* pVariables,
869 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType
845 ) 870 )
846{ 871{
847 HRESULT hr = S_OK; 872 HRESULT hr = S_OK;
848 HKEY hkRegistration = NULL; 873 HKEY hkRegistration = NULL;
849 874
875 AssertSz(BOOTSTRAPPER_REGISTRATION_TYPE_NONE != registrationType, "Registration type can't be NONE");
876
850 // open registration key 877 // open registration key
851 hr = RegOpen(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_WRITE, &hkRegistration); 878 hr = RegOpen(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_WRITE, &hkRegistration);
852 ExitOnFailure(hr, "Failed to open registration key."); 879 ExitOnFailure(hr, "Failed to open registration key.");
@@ -856,7 +883,7 @@ extern "C" HRESULT RegistrationSessionResume(
856 ExitOnFailure(hr, "Failed to update resume mode."); 883 ExitOnFailure(hr, "Failed to update resume mode.");
857 884
858 // update display name 885 // update display name
859 hr = UpdateBundleNameRegistration(pRegistration, pVariables, hkRegistration); 886 hr = UpdateBundleNameRegistration(pRegistration, pVariables, hkRegistration, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS == registrationType);
860 ExitOnFailure(hr, "Failed to update name and publisher."); 887 ExitOnFailure(hr, "Failed to update name and publisher.");
861 888
862LExit: 889LExit:
@@ -876,7 +903,8 @@ extern "C" HRESULT RegistrationSessionEnd(
876 __in BURN_PACKAGES* pPackages, 903 __in BURN_PACKAGES* pPackages,
877 __in BURN_RESUME_MODE resumeMode, 904 __in BURN_RESUME_MODE resumeMode,
878 __in BOOTSTRAPPER_APPLY_RESTART restart, 905 __in BOOTSTRAPPER_APPLY_RESTART restart,
879 __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction 906 __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction,
907 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType
880 ) 908 )
881{ 909{
882 HRESULT hr = S_OK; 910 HRESULT hr = S_OK;
@@ -884,8 +912,6 @@ extern "C" HRESULT RegistrationSessionEnd(
884 HKEY hkRebootRequired = NULL; 912 HKEY hkRebootRequired = NULL;
885 HKEY hkRegistration = NULL; 913 HKEY hkRegistration = NULL;
886 914
887 LogId(REPORT_STANDARD, MSG_SESSION_END, pRegistration->sczRegistrationKey, LoggingResumeModeToString(resumeMode), LoggingRestartToString(restart), LoggingBoolToString(pRegistration->fDisableResume));
888
889 // If a restart is required for any reason, write a volatile registry key to track of 915 // If a restart is required for any reason, write a volatile registry key to track of
890 // of that fact until the reboot has taken place. 916 // of that fact until the reboot has taken place.
891 if (BOOTSTRAPPER_APPLY_RESTART_NONE != restart) 917 if (BOOTSTRAPPER_APPLY_RESTART_NONE != restart)
@@ -910,6 +936,8 @@ extern "C" HRESULT RegistrationSessionEnd(
910 // If no resume mode, then remove the bundle registration. 936 // If no resume mode, then remove the bundle registration.
911 if (BURN_RESUME_MODE_NONE == resumeMode) 937 if (BURN_RESUME_MODE_NONE == resumeMode)
912 { 938 {
939 AssertSz(BOOTSTRAPPER_REGISTRATION_TYPE_NONE == registrationType, "Registration type must be NONE if resume mode is NONE");
940
913 // If we just registered the bundle dependency but something went wrong and caused us to not 941 // If we just registered the bundle dependency but something went wrong and caused us to not
914 // keep the bundle registration (like rollback) or we are supposed to unregister the bundle 942 // keep the bundle registration (like rollback) or we are supposed to unregister the bundle
915 // dependency when unregistering the bundle, do so. 943 // dependency when unregistering the bundle, do so.
@@ -939,9 +967,15 @@ extern "C" HRESULT RegistrationSessionEnd(
939 } 967 }
940 else // the mode needs to be updated so open the registration key. 968 else // the mode needs to be updated so open the registration key.
941 { 969 {
970 AssertSz(BOOTSTRAPPER_REGISTRATION_TYPE_NONE != registrationType, "Registration type must not be NONE if resume mode is not NONE");
971
942 // Open registration key. 972 // Open registration key.
943 hr = RegOpen(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_WRITE, &hkRegistration); 973 hr = RegOpen(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_WRITE, &hkRegistration);
944 ExitOnFailure(hr, "Failed to open registration key."); 974 ExitOnFailure(hr, "Failed to open registration key.");
975
976 // update display name
977 hr = UpdateBundleNameRegistration(pRegistration, pVariables, hkRegistration, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS == registrationType);
978 ExitOnFailure(hr, "Failed to update name and publisher.");
945 } 979 }
946 980
947 // Update resume mode. 981 // Update resume mode.
@@ -1133,44 +1167,69 @@ LExit:
1133static HRESULT GetBundleManufacturer( 1167static HRESULT GetBundleManufacturer(
1134 __in BURN_REGISTRATION* pRegistration, 1168 __in BURN_REGISTRATION* pRegistration,
1135 __in BURN_VARIABLES* pVariables, 1169 __in BURN_VARIABLES* pVariables,
1136 __out LPWSTR* psczBundleManufacturer 1170 __out_z LPWSTR* psczBundleManufacturer
1137 ) 1171 )
1138{ 1172{
1139 HRESULT hr = S_OK; 1173 HRESULT hr = S_OK;
1140 LPCWSTR wzPublisher = pRegistration->sczPublisher ? pRegistration->sczPublisher : L""; 1174 LPCWSTR wzPublisher = pRegistration->sczPublisher ? pRegistration->sczPublisher : L"";
1141 1175
1142 hr = VariableGetString(pVariables, BURN_BUNDLE_MANUFACTURER, psczBundleManufacturer); 1176 hr = EnsureRegistrationVariable(pVariables, BURN_BUNDLE_MANUFACTURER, wzPublisher, psczBundleManufacturer);
1143 if (E_NOTFOUND == hr)
1144 {
1145 hr = VariableSetString(pVariables, BURN_BUNDLE_MANUFACTURER, wzPublisher, FALSE, FALSE);
1146 ExitOnFailure(hr, "Failed to set bundle manufacturer.");
1147
1148 hr = StrAllocString(psczBundleManufacturer, wzPublisher, 0);
1149 }
1150 ExitOnFailure(hr, "Failed to get bundle manufacturer."); 1177 ExitOnFailure(hr, "Failed to get bundle manufacturer.");
1151 1178
1152LExit: 1179LExit:
1153 return hr; 1180 return hr;
1154} 1181}
1155 1182
1183static HRESULT GetBundleInProgressName(
1184 __in BURN_REGISTRATION* pRegistration,
1185 __in BURN_VARIABLES* pVariables,
1186 __out_z LPWSTR* psczInProgressBundleName
1187 )
1188{
1189 HRESULT hr = S_OK;
1190 LPCWSTR wzInProgressDisplayName = pRegistration->sczInProgressDisplayName ? pRegistration->sczInProgressDisplayName : L"";
1191
1192 hr = EnsureRegistrationVariable(pVariables, BURN_BUNDLE_INPROGRESS_NAME, wzInProgressDisplayName, psczInProgressBundleName);
1193 ExitOnFailure(hr, "Failed to ensure in-progress bundle name.");
1194
1195LExit:
1196 return hr;
1197}
1198
1156static HRESULT GetBundleName( 1199static HRESULT GetBundleName(
1157 __in BURN_REGISTRATION* pRegistration, 1200 __in BURN_REGISTRATION* pRegistration,
1158 __in BURN_VARIABLES* pVariables, 1201 __in BURN_VARIABLES* pVariables,
1159 __out LPWSTR* psczBundleName 1202 __out_z LPWSTR* psczBundleName
1160 ) 1203 )
1161{ 1204{
1162 HRESULT hr = S_OK; 1205 HRESULT hr = S_OK;
1163 LPCWSTR wzDisplayName = pRegistration->sczDisplayName ? pRegistration->sczDisplayName : L""; 1206 LPCWSTR wzDisplayName = pRegistration->sczDisplayName ? pRegistration->sczDisplayName : L"";
1164 1207
1165 hr = VariableGetString(pVariables, BURN_BUNDLE_NAME, psczBundleName); 1208 hr = EnsureRegistrationVariable(pVariables, BURN_BUNDLE_NAME, wzDisplayName, psczBundleName);
1209 ExitOnFailure(hr, "Failed to ensure bundle name.");
1210
1211LExit:
1212 return hr;
1213}
1214
1215static HRESULT EnsureRegistrationVariable(
1216 __in BURN_VARIABLES* pVariables,
1217 __in_z LPCWSTR wzVariable,
1218 __in_z LPCWSTR wzDefaultValue,
1219 __out_z LPWSTR* psczValue
1220 )
1221{
1222 HRESULT hr = S_OK;
1223
1224 hr = VariableGetString(pVariables, wzVariable, psczValue);
1166 if (E_NOTFOUND == hr) 1225 if (E_NOTFOUND == hr)
1167 { 1226 {
1168 hr = VariableSetString(pVariables, BURN_BUNDLE_NAME, wzDisplayName, FALSE, FALSE); 1227 hr = VariableSetString(pVariables, wzVariable, wzDefaultValue, FALSE, FALSE);
1169 ExitOnFailure(hr, "Failed to set bundle name."); 1228 ExitOnFailure(hr, "Failed to set registration variable.");
1170 1229
1171 hr = StrAllocString(psczBundleName, wzDisplayName, 0); 1230 hr = StrAllocString(psczValue, wzDefaultValue, 0);
1172 } 1231 }
1173 ExitOnFailure(hr, "Failed to get bundle name."); 1232 ExitOnFailure(hr, "Failed to get registration variable.");
1174 1233
1175LExit: 1234LExit:
1176 return hr; 1235 return hr;
@@ -1584,15 +1643,26 @@ LExit:
1584static HRESULT UpdateBundleNameRegistration( 1643static HRESULT UpdateBundleNameRegistration(
1585 __in BURN_REGISTRATION* pRegistration, 1644 __in BURN_REGISTRATION* pRegistration,
1586 __in BURN_VARIABLES* pVariables, 1645 __in BURN_VARIABLES* pVariables,
1587 __in HKEY hkRegistration 1646 __in HKEY hkRegistration,
1647 __in BOOL fInProgressRegistration
1588 ) 1648 )
1589{ 1649{
1590 HRESULT hr = S_OK; 1650 HRESULT hr = S_OK;
1591 LPWSTR sczDisplayName = NULL; 1651 LPWSTR sczDisplayName = NULL;
1592 1652
1593 // DisplayName: provided by UI 1653 if (fInProgressRegistration)
1594 hr = GetBundleName(pRegistration, pVariables, &sczDisplayName); 1654 {
1595 hr = RegWriteString(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_DISPLAY_NAME, SUCCEEDED(hr) ? sczDisplayName : pRegistration->sczDisplayName); 1655 hr = GetBundleInProgressName(pRegistration, pVariables, &sczDisplayName);
1656 ExitOnFailure(hr, "Failed to get bundle in-progress name.");
1657 }
1658
1659 if (!sczDisplayName || !*sczDisplayName)
1660 {
1661 hr = GetBundleName(pRegistration, pVariables, &sczDisplayName);
1662 ExitOnFailure(hr, "Failed to get bundle name.");
1663 }
1664
1665 hr = RegWriteString(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_DISPLAY_NAME, sczDisplayName);
1596 ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_DISPLAY_NAME); 1666 ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_DISPLAY_NAME);
1597 1667
1598LExit: 1668LExit: