diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-04-16 13:40:25 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-04-19 23:12:55 -0500 |
| commit | cc240536956e3ef6981599dfff05aa5628e910ac (patch) | |
| tree | 4f601e0f9d30ddb51dc449b3f0593574f8ce3e8a /src/engine/elevation.cpp | |
| parent | b1d1e523f5cdadce0cbf105179b33c014d5ec9eb (diff) | |
| download | wix-cc240536956e3ef6981599dfff05aa5628e910ac.tar.gz wix-cc240536956e3ef6981599dfff05aa5628e910ac.tar.bz2 wix-cc240536956e3ef6981599dfff05aa5628e910ac.zip | |
Perform all layout operations in the BA process.
Diffstat (limited to 'src/engine/elevation.cpp')
| -rw-r--r-- | src/engine/elevation.cpp | 214 |
1 files changed, 29 insertions, 185 deletions
diff --git a/src/engine/elevation.cpp b/src/engine/elevation.cpp index 2dd61a81..502c5462 100644 --- a/src/engine/elevation.cpp +++ b/src/engine/elevation.cpp | |||
| @@ -14,9 +14,8 @@ typedef enum _BURN_ELEVATION_MESSAGE_TYPE | |||
| 14 | BURN_ELEVATION_MESSAGE_TYPE_SESSION_RESUME, | 14 | BURN_ELEVATION_MESSAGE_TYPE_SESSION_RESUME, |
| 15 | BURN_ELEVATION_MESSAGE_TYPE_SESSION_END, | 15 | BURN_ELEVATION_MESSAGE_TYPE_SESSION_END, |
| 16 | BURN_ELEVATION_MESSAGE_TYPE_SAVE_STATE, | 16 | BURN_ELEVATION_MESSAGE_TYPE_SAVE_STATE, |
| 17 | BURN_ELEVATION_MESSAGE_TYPE_LAYOUT_BUNDLE, | 17 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_COMPLETE_PAYLOAD, |
| 18 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_OR_LAYOUT_CONTAINER_OR_PAYLOAD, | 18 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_PAYLOAD, |
| 19 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_CONTAINER_OR_PAYLOAD, | ||
| 20 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP, | 19 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP, |
| 21 | BURN_ELEVATION_MESSAGE_TYPE_PROCESS_DEPENDENT_REGISTRATION, | 20 | BURN_ELEVATION_MESSAGE_TYPE_PROCESS_DEPENDENT_REGISTRATION, |
| 22 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE, | 21 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE, |
| @@ -165,20 +164,13 @@ static HRESULT OnSaveState( | |||
| 165 | __in BYTE* pbData, | 164 | __in BYTE* pbData, |
| 166 | __in DWORD cbData | 165 | __in DWORD cbData |
| 167 | ); | 166 | ); |
| 168 | static HRESULT OnLayoutBundle( | 167 | static HRESULT OnCacheCompletePayload( |
| 169 | __in_z LPCWSTR wzExecutableName, | ||
| 170 | __in BYTE* pbData, | ||
| 171 | __in DWORD cbData | ||
| 172 | ); | ||
| 173 | static HRESULT OnCacheOrLayoutContainerOrPayload( | ||
| 174 | __in BURN_CONTAINERS* pContainers, | ||
| 175 | __in BURN_PACKAGES* pPackages, | 168 | __in BURN_PACKAGES* pPackages, |
| 176 | __in BURN_PAYLOADS* pPayloads, | 169 | __in BURN_PAYLOADS* pPayloads, |
| 177 | __in BYTE* pbData, | 170 | __in BYTE* pbData, |
| 178 | __in DWORD cbData | 171 | __in DWORD cbData |
| 179 | ); | 172 | ); |
| 180 | static HRESULT OnCacheVerifyContainerOrPayload( | 173 | static HRESULT OnCacheVerifyPayload( |
| 181 | __in BURN_CONTAINERS* pContainers, | ||
| 182 | __in BURN_PACKAGES* pPackages, | 174 | __in BURN_PACKAGES* pPackages, |
| 183 | __in BURN_PAYLOADS* pPayloads, | 175 | __in BURN_PAYLOADS* pPayloads, |
| 184 | __in BYTE* pbData, | 176 | __in BYTE* pbData, |
| @@ -582,49 +574,13 @@ LExit: | |||
| 582 | } | 574 | } |
| 583 | 575 | ||
| 584 | /******************************************************************* | 576 | /******************************************************************* |
| 585 | ElevationLayoutBundle - | 577 | ElevationCacheCompletePayload - |
| 586 | 578 | ||
| 587 | *******************************************************************/ | 579 | *******************************************************************/ |
| 588 | extern "C" HRESULT ElevationLayoutBundle( | 580 | extern "C" HRESULT ElevationCacheCompletePayload( |
| 589 | __in HANDLE hPipe, | 581 | __in HANDLE hPipe, |
| 590 | __in_z LPCWSTR wzLayoutDirectory, | 582 | __in BURN_PACKAGE* pPackage, |
| 591 | __in_z LPCWSTR wzUnverifiedPath | 583 | __in BURN_PAYLOAD* pPayload, |
| 592 | ) | ||
| 593 | { | ||
| 594 | HRESULT hr = S_OK; | ||
| 595 | BYTE* pbData = NULL; | ||
| 596 | SIZE_T cbData = 0; | ||
| 597 | DWORD dwResult = 0; | ||
| 598 | |||
| 599 | // serialize message data | ||
| 600 | hr = BuffWriteString(&pbData, &cbData, wzLayoutDirectory); | ||
| 601 | ExitOnFailure(hr, "Failed to write layout directory to message buffer."); | ||
| 602 | |||
| 603 | hr = BuffWriteString(&pbData, &cbData, wzUnverifiedPath); | ||
| 604 | ExitOnFailure(hr, "Failed to write payload unverified path to message buffer."); | ||
| 605 | |||
| 606 | // send message | ||
| 607 | hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_LAYOUT_BUNDLE, pbData, cbData, NULL, NULL, &dwResult); | ||
| 608 | ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_LAYOUT_BUNDLE message to per-machine process."); | ||
| 609 | |||
| 610 | hr = (HRESULT)dwResult; | ||
| 611 | |||
| 612 | LExit: | ||
| 613 | ReleaseBuffer(pbData); | ||
| 614 | |||
| 615 | return hr; | ||
| 616 | } | ||
| 617 | |||
| 618 | /******************************************************************* | ||
| 619 | ElevationCacheOrLayoutPayload - | ||
| 620 | |||
| 621 | *******************************************************************/ | ||
| 622 | extern "C" HRESULT ElevationCacheOrLayoutContainerOrPayload( | ||
| 623 | __in HANDLE hPipe, | ||
| 624 | __in_opt BURN_CONTAINER* pContainer, | ||
| 625 | __in_opt BURN_PACKAGE* pPackage, | ||
| 626 | __in_opt BURN_PAYLOAD* pPayload, | ||
| 627 | __in_z_opt LPCWSTR wzLayoutDirectory, | ||
| 628 | __in_z LPCWSTR wzUnverifiedPath, | 584 | __in_z LPCWSTR wzUnverifiedPath, |
| 629 | __in BOOL fMove | 585 | __in BOOL fMove |
| 630 | ) | 586 | ) |
| @@ -635,18 +591,12 @@ extern "C" HRESULT ElevationCacheOrLayoutContainerOrPayload( | |||
| 635 | DWORD dwResult = 0; | 591 | DWORD dwResult = 0; |
| 636 | 592 | ||
| 637 | // serialize message data | 593 | // serialize message data |
| 638 | hr = BuffWriteString(&pbData, &cbData, pContainer ? pContainer->sczId : NULL); | 594 | hr = BuffWriteString(&pbData, &cbData, pPackage->sczId); |
| 639 | ExitOnFailure(hr, "Failed to write container id to message buffer."); | ||
| 640 | |||
| 641 | hr = BuffWriteString(&pbData, &cbData, pPackage ? pPackage->sczId : NULL); | ||
| 642 | ExitOnFailure(hr, "Failed to write package id to message buffer."); | 595 | ExitOnFailure(hr, "Failed to write package id to message buffer."); |
| 643 | 596 | ||
| 644 | hr = BuffWriteString(&pbData, &cbData, pPayload ? pPayload->sczKey : NULL); | 597 | hr = BuffWriteString(&pbData, &cbData, pPayload->sczKey); |
| 645 | ExitOnFailure(hr, "Failed to write payload id to message buffer."); | 598 | ExitOnFailure(hr, "Failed to write payload id to message buffer."); |
| 646 | 599 | ||
| 647 | hr = BuffWriteString(&pbData, &cbData, wzLayoutDirectory); | ||
| 648 | ExitOnFailure(hr, "Failed to write layout directory to message buffer."); | ||
| 649 | |||
| 650 | hr = BuffWriteString(&pbData, &cbData, wzUnverifiedPath); | 600 | hr = BuffWriteString(&pbData, &cbData, wzUnverifiedPath); |
| 651 | ExitOnFailure(hr, "Failed to write unverified path to message buffer."); | 601 | ExitOnFailure(hr, "Failed to write unverified path to message buffer."); |
| 652 | 602 | ||
| @@ -654,8 +604,8 @@ extern "C" HRESULT ElevationCacheOrLayoutContainerOrPayload( | |||
| 654 | ExitOnFailure(hr, "Failed to write move flag to message buffer."); | 604 | ExitOnFailure(hr, "Failed to write move flag to message buffer."); |
| 655 | 605 | ||
| 656 | // send message | 606 | // send message |
| 657 | hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_CACHE_OR_LAYOUT_CONTAINER_OR_PAYLOAD, pbData, cbData, NULL, NULL, &dwResult); | 607 | hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_CACHE_COMPLETE_PAYLOAD, pbData, cbData, NULL, NULL, &dwResult); |
| 658 | ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_CACHE_OR_LAYOUT_CONTAINER_OR_PAYLOAD message to per-machine process."); | 608 | ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_CACHE_COMPLETE_PAYLOAD message to per-machine process."); |
| 659 | 609 | ||
| 660 | hr = (HRESULT)dwResult; | 610 | hr = (HRESULT)dwResult; |
| 661 | 611 | ||
| @@ -665,12 +615,10 @@ LExit: | |||
| 665 | return hr; | 615 | return hr; |
| 666 | } | 616 | } |
| 667 | 617 | ||
| 668 | extern "C" HRESULT ElevationCacheVerifyContainerOrPayload( | 618 | extern "C" HRESULT ElevationCacheVerifyPayload( |
| 669 | __in HANDLE hPipe, | 619 | __in HANDLE hPipe, |
| 670 | __in_opt BURN_CONTAINER* pContainer, | 620 | __in BURN_PACKAGE* pPackage, |
| 671 | __in_opt BURN_PACKAGE* pPackage, | 621 | __in BURN_PAYLOAD* pPayload |
| 672 | __in_opt BURN_PAYLOAD* pPayload, | ||
| 673 | __in_z_opt LPCWSTR wzLayoutDirectory | ||
| 674 | ) | 622 | ) |
| 675 | { | 623 | { |
| 676 | HRESULT hr = S_OK; | 624 | HRESULT hr = S_OK; |
| @@ -679,21 +627,15 @@ extern "C" HRESULT ElevationCacheVerifyContainerOrPayload( | |||
| 679 | DWORD dwResult = 0; | 627 | DWORD dwResult = 0; |
| 680 | 628 | ||
| 681 | // serialize message data | 629 | // serialize message data |
| 682 | hr = BuffWriteString(&pbData, &cbData, pContainer ? pContainer->sczId : NULL); | 630 | hr = BuffWriteString(&pbData, &cbData, pPackage->sczId); |
| 683 | ExitOnFailure(hr, "Failed to write container id to message buffer."); | ||
| 684 | |||
| 685 | hr = BuffWriteString(&pbData, &cbData, pPackage ? pPackage->sczId : NULL); | ||
| 686 | ExitOnFailure(hr, "Failed to write package id to message buffer."); | 631 | ExitOnFailure(hr, "Failed to write package id to message buffer."); |
| 687 | 632 | ||
| 688 | hr = BuffWriteString(&pbData, &cbData, pPayload ? pPayload->sczKey : NULL); | 633 | hr = BuffWriteString(&pbData, &cbData, pPayload->sczKey); |
| 689 | ExitOnFailure(hr, "Failed to write payload id to message buffer."); | 634 | ExitOnFailure(hr, "Failed to write payload id to message buffer."); |
| 690 | 635 | ||
| 691 | hr = BuffWriteString(&pbData, &cbData, wzLayoutDirectory); | ||
| 692 | ExitOnFailure(hr, "Failed to write layout directory to message buffer."); | ||
| 693 | |||
| 694 | // send message | 636 | // send message |
| 695 | hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_CONTAINER_OR_PAYLOAD, pbData, cbData, NULL, NULL, &dwResult); | 637 | hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_PAYLOAD, pbData, cbData, NULL, NULL, &dwResult); |
| 696 | ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_CONTAINER_OR_PAYLOAD message to per-machine process."); | 638 | ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_PAYLOAD message to per-machine process."); |
| 697 | 639 | ||
| 698 | hr = (HRESULT)dwResult; | 640 | hr = (HRESULT)dwResult; |
| 699 | 641 | ||
| @@ -1762,16 +1704,12 @@ static HRESULT ProcessElevatedChildCacheMessage( | |||
| 1762 | 1704 | ||
| 1763 | switch (pMsg->dwMessage) | 1705 | switch (pMsg->dwMessage) |
| 1764 | { | 1706 | { |
| 1765 | case BURN_ELEVATION_MESSAGE_TYPE_LAYOUT_BUNDLE: | 1707 | case BURN_ELEVATION_MESSAGE_TYPE_CACHE_COMPLETE_PAYLOAD: |
| 1766 | hrResult = OnLayoutBundle(pContext->pRegistration->sczExecutableName, (BYTE*)pMsg->pvData, pMsg->cbData); | 1708 | hrResult = OnCacheCompletePayload(pContext->pPackages, pContext->pPayloads, (BYTE*)pMsg->pvData, pMsg->cbData); |
| 1767 | break; | ||
| 1768 | |||
| 1769 | case BURN_ELEVATION_MESSAGE_TYPE_CACHE_OR_LAYOUT_CONTAINER_OR_PAYLOAD: | ||
| 1770 | hrResult = OnCacheOrLayoutContainerOrPayload(pContext->pContainers, pContext->pPackages, pContext->pPayloads, (BYTE*)pMsg->pvData, pMsg->cbData); | ||
| 1771 | break; | 1709 | break; |
| 1772 | 1710 | ||
| 1773 | case BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_CONTAINER_OR_PAYLOAD: | 1711 | case BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_PAYLOAD: |
| 1774 | hrResult = OnCacheVerifyContainerOrPayload(pContext->pContainers, pContext->pPackages, pContext->pPayloads, (BYTE*)pMsg->pvData, pMsg->cbData); | 1712 | hrResult = OnCacheVerifyPayload(pContext->pPackages, pContext->pPayloads, (BYTE*)pMsg->pvData, pMsg->cbData); |
| 1775 | break; | 1713 | break; |
| 1776 | 1714 | ||
| 1777 | case BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP: | 1715 | case BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP: |
| @@ -2063,37 +2001,7 @@ LExit: | |||
| 2063 | return hr; | 2001 | return hr; |
| 2064 | } | 2002 | } |
| 2065 | 2003 | ||
| 2066 | static HRESULT OnLayoutBundle( | 2004 | static HRESULT OnCacheCompletePayload( |
| 2067 | __in_z LPCWSTR wzExecutableName, | ||
| 2068 | __in BYTE* pbData, | ||
| 2069 | __in DWORD cbData | ||
| 2070 | ) | ||
| 2071 | { | ||
| 2072 | HRESULT hr = S_OK; | ||
| 2073 | SIZE_T iData = 0; | ||
| 2074 | LPWSTR sczLayoutDirectory = NULL; | ||
| 2075 | LPWSTR sczUnverifiedPath = NULL; | ||
| 2076 | |||
| 2077 | // Deserialize message data. | ||
| 2078 | hr = BuffReadString(pbData, cbData, &iData, &sczLayoutDirectory); | ||
| 2079 | ExitOnFailure(hr, "Failed to read layout directory."); | ||
| 2080 | |||
| 2081 | hr = BuffReadString(pbData, cbData, &iData, &sczUnverifiedPath); | ||
| 2082 | ExitOnFailure(hr, "Failed to read unverified bundle path."); | ||
| 2083 | |||
| 2084 | // Layout the bundle. | ||
| 2085 | hr = CacheLayoutBundle(wzExecutableName, sczLayoutDirectory, sczUnverifiedPath); | ||
| 2086 | ExitOnFailure(hr, "Failed to layout bundle from: %ls", sczUnverifiedPath); | ||
| 2087 | |||
| 2088 | LExit: | ||
| 2089 | ReleaseStr(sczUnverifiedPath); | ||
| 2090 | ReleaseStr(sczLayoutDirectory); | ||
| 2091 | |||
| 2092 | return hr; | ||
| 2093 | } | ||
| 2094 | |||
| 2095 | static HRESULT OnCacheOrLayoutContainerOrPayload( | ||
| 2096 | __in BURN_CONTAINERS* pContainers, | ||
| 2097 | __in BURN_PACKAGES* pPackages, | 2005 | __in BURN_PACKAGES* pPackages, |
| 2098 | __in BURN_PAYLOADS* pPayloads, | 2006 | __in BURN_PAYLOADS* pPayloads, |
| 2099 | __in BYTE* pbData, | 2007 | __in BYTE* pbData, |
| @@ -2103,24 +2011,13 @@ static HRESULT OnCacheOrLayoutContainerOrPayload( | |||
| 2103 | HRESULT hr = S_OK; | 2011 | HRESULT hr = S_OK; |
| 2104 | SIZE_T iData = 0; | 2012 | SIZE_T iData = 0; |
| 2105 | LPWSTR scz = NULL; | 2013 | LPWSTR scz = NULL; |
| 2106 | BURN_CONTAINER* pContainer = NULL; | ||
| 2107 | BURN_PACKAGE* pPackage = NULL; | 2014 | BURN_PACKAGE* pPackage = NULL; |
| 2108 | BURN_PAYLOAD* pPayload = NULL; | 2015 | BURN_PAYLOAD* pPayload = NULL; |
| 2109 | LPWSTR sczLayoutDirectory = NULL; | ||
| 2110 | LPWSTR sczUnverifiedPath = NULL; | 2016 | LPWSTR sczUnverifiedPath = NULL; |
| 2111 | BOOL fMove = FALSE; | 2017 | BOOL fMove = FALSE; |
| 2112 | 2018 | ||
| 2113 | // Deserialize message data. | 2019 | // Deserialize message data. |
| 2114 | hr = BuffReadString(pbData, cbData, &iData, &scz); | 2020 | hr = BuffReadString(pbData, cbData, &iData, &scz); |
| 2115 | ExitOnFailure(hr, "Failed to read container id."); | ||
| 2116 | |||
| 2117 | if (scz && *scz) | ||
| 2118 | { | ||
| 2119 | hr = ContainerFindById(pContainers, scz, &pContainer); | ||
| 2120 | ExitOnFailure(hr, "Failed to find container: %ls", scz); | ||
| 2121 | } | ||
| 2122 | |||
| 2123 | hr = BuffReadString(pbData, cbData, &iData, &scz); | ||
| 2124 | ExitOnFailure(hr, "Failed to read package id."); | 2021 | ExitOnFailure(hr, "Failed to read package id."); |
| 2125 | 2022 | ||
| 2126 | if (scz && *scz) | 2023 | if (scz && *scz) |
| @@ -2138,55 +2035,31 @@ static HRESULT OnCacheOrLayoutContainerOrPayload( | |||
| 2138 | ExitOnFailure(hr, "Failed to find payload: %ls", scz); | 2035 | ExitOnFailure(hr, "Failed to find payload: %ls", scz); |
| 2139 | } | 2036 | } |
| 2140 | 2037 | ||
| 2141 | hr = BuffReadString(pbData, cbData, &iData, &sczLayoutDirectory); | ||
| 2142 | ExitOnFailure(hr, "Failed to read layout directory."); | ||
| 2143 | |||
| 2144 | hr = BuffReadString(pbData, cbData, &iData, &sczUnverifiedPath); | 2038 | hr = BuffReadString(pbData, cbData, &iData, &sczUnverifiedPath); |
| 2145 | ExitOnFailure(hr, "Failed to read unverified path."); | 2039 | ExitOnFailure(hr, "Failed to read unverified path."); |
| 2146 | 2040 | ||
| 2147 | hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&fMove); | 2041 | hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&fMove); |
| 2148 | ExitOnFailure(hr, "Failed to read move flag."); | 2042 | ExitOnFailure(hr, "Failed to read move flag."); |
| 2149 | 2043 | ||
| 2150 | // Layout payload. | 2044 | if (pPackage && pPayload) // complete payload. |
| 2151 | if (sczLayoutDirectory && *sczLayoutDirectory) | ||
| 2152 | { | 2045 | { |
| 2153 | if (pContainer) | ||
| 2154 | { | ||
| 2155 | Assert(!pPackage); | ||
| 2156 | Assert(!pPayload); | ||
| 2157 | |||
| 2158 | hr = CacheLayoutContainer(pContainer, sczLayoutDirectory, sczUnverifiedPath, fMove); | ||
| 2159 | ExitOnFailure(hr, "Failed to layout container from: %ls to %ls", sczUnverifiedPath, sczLayoutDirectory); | ||
| 2160 | } | ||
| 2161 | else | ||
| 2162 | { | ||
| 2163 | hr = CacheLayoutPayload(pPayload, sczLayoutDirectory, sczUnverifiedPath, fMove); | ||
| 2164 | ExitOnFailure(hr, "Failed to layout payload from: %ls to %ls", sczUnverifiedPath, sczLayoutDirectory); | ||
| 2165 | } | ||
| 2166 | } | ||
| 2167 | else if (pPackage) // complete payload. | ||
| 2168 | { | ||
| 2169 | Assert(!pContainer); | ||
| 2170 | |||
| 2171 | hr = CacheCompletePayload(pPackage->fPerMachine, pPayload, pPackage->sczCacheId, sczUnverifiedPath, fMove); | 2046 | hr = CacheCompletePayload(pPackage->fPerMachine, pPayload, pPackage->sczCacheId, sczUnverifiedPath, fMove); |
| 2172 | ExitOnFailure(hr, "Failed to cache payload: %ls", pPayload->sczKey); | 2047 | ExitOnFailure(hr, "Failed to cache payload: %ls", pPayload->sczKey); |
| 2173 | } | 2048 | } |
| 2174 | else | 2049 | else |
| 2175 | { | 2050 | { |
| 2176 | hr = E_INVALIDARG; | 2051 | hr = E_INVALIDARG; |
| 2177 | ExitOnRootFailure(hr, "Invalid data passed to cache or layout payload."); | 2052 | ExitOnRootFailure(hr, "Invalid data passed to cache complete payload."); |
| 2178 | } | 2053 | } |
| 2179 | 2054 | ||
| 2180 | LExit: | 2055 | LExit: |
| 2181 | ReleaseStr(sczUnverifiedPath); | 2056 | ReleaseStr(sczUnverifiedPath); |
| 2182 | ReleaseStr(sczLayoutDirectory); | ||
| 2183 | ReleaseStr(scz); | 2057 | ReleaseStr(scz); |
| 2184 | 2058 | ||
| 2185 | return hr; | 2059 | return hr; |
| 2186 | } | 2060 | } |
| 2187 | 2061 | ||
| 2188 | static HRESULT OnCacheVerifyContainerOrPayload( | 2062 | static HRESULT OnCacheVerifyPayload( |
| 2189 | __in BURN_CONTAINERS* pContainers, | ||
| 2190 | __in BURN_PACKAGES* pPackages, | 2063 | __in BURN_PACKAGES* pPackages, |
| 2191 | __in BURN_PAYLOADS* pPayloads, | 2064 | __in BURN_PAYLOADS* pPayloads, |
| 2192 | __in BYTE* pbData, | 2065 | __in BYTE* pbData, |
| @@ -2196,22 +2069,12 @@ static HRESULT OnCacheVerifyContainerOrPayload( | |||
| 2196 | HRESULT hr = S_OK; | 2069 | HRESULT hr = S_OK; |
| 2197 | SIZE_T iData = 0; | 2070 | SIZE_T iData = 0; |
| 2198 | LPWSTR scz = NULL; | 2071 | LPWSTR scz = NULL; |
| 2199 | BURN_CONTAINER* pContainer = NULL; | ||
| 2200 | BURN_PACKAGE* pPackage = NULL; | 2072 | BURN_PACKAGE* pPackage = NULL; |
| 2201 | BURN_PAYLOAD* pPayload = NULL; | 2073 | BURN_PAYLOAD* pPayload = NULL; |
| 2202 | LPWSTR sczCacheDirectory = NULL; | 2074 | LPWSTR sczCacheDirectory = NULL; |
| 2203 | 2075 | ||
| 2204 | // Deserialize message data. | 2076 | // Deserialize message data. |
| 2205 | hr = BuffReadString(pbData, cbData, &iData, &scz); | 2077 | hr = BuffReadString(pbData, cbData, &iData, &scz); |
| 2206 | ExitOnFailure(hr, "Failed to read container id."); | ||
| 2207 | |||
| 2208 | if (scz && *scz) | ||
| 2209 | { | ||
| 2210 | hr = ContainerFindById(pContainers, scz, &pContainer); | ||
| 2211 | ExitOnFailure(hr, "Failed to find container: %ls", scz); | ||
| 2212 | } | ||
| 2213 | |||
| 2214 | hr = BuffReadString(pbData, cbData, &iData, &scz); | ||
| 2215 | ExitOnFailure(hr, "Failed to read package id."); | 2078 | ExitOnFailure(hr, "Failed to read package id."); |
| 2216 | 2079 | ||
| 2217 | if (scz && *scz) | 2080 | if (scz && *scz) |
| @@ -2229,36 +2092,17 @@ static HRESULT OnCacheVerifyContainerOrPayload( | |||
| 2229 | ExitOnFailure(hr, "Failed to find payload: %ls", scz); | 2092 | ExitOnFailure(hr, "Failed to find payload: %ls", scz); |
| 2230 | } | 2093 | } |
| 2231 | 2094 | ||
| 2232 | hr = BuffReadString(pbData, cbData, &iData, &sczCacheDirectory); | 2095 | if (pPackage && pPayload) |
| 2233 | ExitOnFailure(hr, "Failed to read layout directory."); | ||
| 2234 | |||
| 2235 | if (!sczCacheDirectory || !*sczCacheDirectory) | ||
| 2236 | { | 2096 | { |
| 2237 | if (!pPackage) | ||
| 2238 | { | ||
| 2239 | hr = E_INVALIDARG; | ||
| 2240 | ExitOnRootFailure(hr, "Invalid data passed to cache verify payload."); | ||
| 2241 | } | ||
| 2242 | |||
| 2243 | hr = CacheGetCompletedPath(TRUE, pPackage->sczCacheId, &sczCacheDirectory); | 2097 | hr = CacheGetCompletedPath(TRUE, pPackage->sczCacheId, &sczCacheDirectory); |
| 2244 | ExitOnFailure(hr, "Failed to get cached path for package with cache id: %ls", pPackage->sczCacheId); | 2098 | ExitOnFailure(hr, "Failed to get cached path for package with cache id: %ls", pPackage->sczCacheId); |
| 2245 | } | ||
| 2246 | |||
| 2247 | if (pContainer) | ||
| 2248 | { | ||
| 2249 | Assert(!pPackage); | ||
| 2250 | Assert(!pPayload); | ||
| 2251 | 2099 | ||
| 2252 | hr = CacheVerifyContainer(pContainer, sczCacheDirectory); | ||
| 2253 | } | ||
| 2254 | else if (pPayload) | ||
| 2255 | { | ||
| 2256 | hr = CacheVerifyPayload(pPayload, sczCacheDirectory); | 2100 | hr = CacheVerifyPayload(pPayload, sczCacheDirectory); |
| 2257 | } | 2101 | } |
| 2258 | else | 2102 | else |
| 2259 | { | 2103 | { |
| 2260 | hr = E_INVALIDARG; | 2104 | hr = E_INVALIDARG; |
| 2261 | ExitOnRootFailure(hr, "Invalid data passed to cache or layout payload."); | 2105 | ExitOnRootFailure(hr, "Invalid data passed to cache verify payload."); |
| 2262 | } | 2106 | } |
| 2263 | // Nothing should be logged on failure. | 2107 | // Nothing should be logged on failure. |
| 2264 | 2108 | ||
