diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-04-22 16:56:21 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-04-23 15:40:21 -0500 |
commit | a981e29d7a3df566754356c3fe1eb938a5cac4c1 (patch) | |
tree | 9d2b2abac872ae3c4917003812951e68b72e7163 /src/burn/engine/registration.cpp | |
parent | 72e20f682c0d64102e86439ba5527dd0d71932ae (diff) | |
download | wix-a981e29d7a3df566754356c3fe1eb938a5cac4c1.tar.gz wix-a981e29d7a3df566754356c3fe1eb938a5cac4c1.tar.bz2 wix-a981e29d7a3df566754356c3fe1eb938a5cac4c1.zip |
Make the estimated size in ARP a little more accurate.
Fixes 4039
Diffstat (limited to 'src/burn/engine/registration.cpp')
-rw-r--r-- | src/burn/engine/registration.cpp | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp index 0ffbc89e..9953be83 100644 --- a/src/burn/engine/registration.cpp +++ b/src/burn/engine/registration.cpp | |||
@@ -102,6 +102,10 @@ static HRESULT UpdateBundleNameRegistration( | |||
102 | __in HKEY hkRegistration, | 102 | __in HKEY hkRegistration, |
103 | __in BOOL fInProgressRegistration | 103 | __in BOOL fInProgressRegistration |
104 | ); | 104 | ); |
105 | static HRESULT UpdateEstimatedSize( | ||
106 | __in HKEY hkRegistration, | ||
107 | __in DWORD64 qwEstimatedSize | ||
108 | ); | ||
105 | static BOOL IsWuRebootPending(); | 109 | static BOOL IsWuRebootPending(); |
106 | static BOOL IsRegistryRebootPending(); | 110 | static BOOL IsRegistryRebootPending(); |
107 | 111 | ||
@@ -600,8 +604,8 @@ extern "C" HRESULT RegistrationSessionBegin( | |||
600 | ) | 604 | ) |
601 | { | 605 | { |
602 | HRESULT hr = S_OK; | 606 | HRESULT hr = S_OK; |
603 | DWORD dwSize = 0; | ||
604 | HKEY hkRegistration = NULL; | 607 | HKEY hkRegistration = NULL; |
608 | BOOL fCreated = FALSE; | ||
605 | LPWSTR sczPublisher = NULL; | 609 | LPWSTR sczPublisher = NULL; |
606 | 610 | ||
607 | AssertSz(BOOTSTRAPPER_REGISTRATION_TYPE_NONE != registrationType, "Registration type can't be NONE"); | 611 | AssertSz(BOOTSTRAPPER_REGISTRATION_TYPE_NONE != registrationType, "Registration type can't be NONE"); |
@@ -620,7 +624,7 @@ extern "C" HRESULT RegistrationSessionBegin( | |||
620 | } | 624 | } |
621 | 625 | ||
622 | // create registration key | 626 | // create registration key |
623 | hr = RegCreate(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_WRITE, &hkRegistration); | 627 | hr = RegCreateEx(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_WRITE, REG_KEY_DEFAULT, FALSE, NULL, &hkRegistration, &fCreated); |
624 | ExitOnFailure(hr, "Failed to create registration key."); | 628 | ExitOnFailure(hr, "Failed to create registration key."); |
625 | 629 | ||
626 | // Write any ARP values and software tags. | 630 | // Write any ARP values and software tags. |
@@ -797,22 +801,12 @@ extern "C" HRESULT RegistrationSessionBegin( | |||
797 | ExitOnFailure(hr, "Failed to write update registration."); | 801 | ExitOnFailure(hr, "Failed to write update registration."); |
798 | } | 802 | } |
799 | 803 | ||
800 | // Update estimated size. | 804 | // Only set estimated size here for the first time. |
801 | qwEstimatedSize /= 1024; // Convert bytes to KB | 805 | // It will always get updated at the end of the session. |
802 | if (0 < qwEstimatedSize) | 806 | if (fCreated) |
803 | { | 807 | { |
804 | if (DWORD_MAX < qwEstimatedSize) | 808 | hr = UpdateEstimatedSize(hkRegistration, qwEstimatedSize); |
805 | { | 809 | ExitOnFailure(hr, "Failed to update estimated size."); |
806 | // ARP doesn't support QWORDs here | ||
807 | dwSize = DWORD_MAX; | ||
808 | } | ||
809 | else | ||
810 | { | ||
811 | dwSize = static_cast<DWORD>(qwEstimatedSize); | ||
812 | } | ||
813 | |||
814 | hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_ESTIMATED_SIZE, dwSize); | ||
815 | ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_ESTIMATED_SIZE); | ||
816 | } | 810 | } |
817 | 811 | ||
818 | // Register the bundle dependency key. | 812 | // Register the bundle dependency key. |
@@ -879,6 +873,7 @@ extern "C" HRESULT RegistrationSessionEnd( | |||
879 | __in BURN_PACKAGES* pPackages, | 873 | __in BURN_PACKAGES* pPackages, |
880 | __in BURN_RESUME_MODE resumeMode, | 874 | __in BURN_RESUME_MODE resumeMode, |
881 | __in BOOTSTRAPPER_APPLY_RESTART restart, | 875 | __in BOOTSTRAPPER_APPLY_RESTART restart, |
876 | __in DWORD64 qwEstimatedSize, | ||
882 | __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType | 877 | __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType |
883 | ) | 878 | ) |
884 | { | 879 | { |
@@ -921,6 +916,9 @@ extern "C" HRESULT RegistrationSessionEnd( | |||
921 | // update display name | 916 | // update display name |
922 | hr = UpdateBundleNameRegistration(pRegistration, pVariables, hkRegistration, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS == registrationType); | 917 | hr = UpdateBundleNameRegistration(pRegistration, pVariables, hkRegistration, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS == registrationType); |
923 | ExitOnFailure(hr, "Failed to update name and publisher."); | 918 | ExitOnFailure(hr, "Failed to update name and publisher."); |
919 | |||
920 | hr = UpdateEstimatedSize(hkRegistration, qwEstimatedSize); | ||
921 | ExitOnFailure(hr, "Failed to update estimated size."); | ||
924 | } | 922 | } |
925 | 923 | ||
926 | // Update resume mode. | 924 | // Update resume mode. |
@@ -1604,6 +1602,35 @@ LExit: | |||
1604 | return hr; | 1602 | return hr; |
1605 | } | 1603 | } |
1606 | 1604 | ||
1605 | static HRESULT UpdateEstimatedSize( | ||
1606 | __in HKEY hkRegistration, | ||
1607 | __in DWORD64 qwEstimatedSize | ||
1608 | ) | ||
1609 | { | ||
1610 | HRESULT hr = S_OK; | ||
1611 | DWORD dwSize = 0; | ||
1612 | |||
1613 | qwEstimatedSize /= 1024; // Convert bytes to KB | ||
1614 | if (0 < qwEstimatedSize) | ||
1615 | { | ||
1616 | if (DWORD_MAX < qwEstimatedSize) | ||
1617 | { | ||
1618 | // ARP doesn't support QWORDs here | ||
1619 | dwSize = DWORD_MAX; | ||
1620 | } | ||
1621 | else | ||
1622 | { | ||
1623 | dwSize = static_cast<DWORD>(qwEstimatedSize); | ||
1624 | } | ||
1625 | |||
1626 | hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_ESTIMATED_SIZE, dwSize); | ||
1627 | ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_ESTIMATED_SIZE); | ||
1628 | } | ||
1629 | |||
1630 | LExit: | ||
1631 | return hr; | ||
1632 | } | ||
1633 | |||
1607 | static BOOL IsWuRebootPending() | 1634 | static BOOL IsWuRebootPending() |
1608 | { | 1635 | { |
1609 | HRESULT hr = S_OK; | 1636 | HRESULT hr = S_OK; |