diff options
Diffstat (limited to 'src/engine/elevation.cpp')
| -rw-r--r-- | src/engine/elevation.cpp | 136 |
1 files changed, 135 insertions, 1 deletions
diff --git a/src/engine/elevation.cpp b/src/engine/elevation.cpp index d37907cf..2dd61a81 100644 --- a/src/engine/elevation.cpp +++ b/src/engine/elevation.cpp | |||
| @@ -16,6 +16,7 @@ typedef enum _BURN_ELEVATION_MESSAGE_TYPE | |||
| 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_LAYOUT_BUNDLE, |
| 18 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_OR_LAYOUT_CONTAINER_OR_PAYLOAD, | 18 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_OR_LAYOUT_CONTAINER_OR_PAYLOAD, |
| 19 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_CONTAINER_OR_PAYLOAD, | ||
| 19 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP, | 20 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP, |
| 20 | BURN_ELEVATION_MESSAGE_TYPE_PROCESS_DEPENDENT_REGISTRATION, | 21 | BURN_ELEVATION_MESSAGE_TYPE_PROCESS_DEPENDENT_REGISTRATION, |
| 21 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE, | 22 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE, |
| @@ -176,6 +177,13 @@ static HRESULT OnCacheOrLayoutContainerOrPayload( | |||
| 176 | __in BYTE* pbData, | 177 | __in BYTE* pbData, |
| 177 | __in DWORD cbData | 178 | __in DWORD cbData |
| 178 | ); | 179 | ); |
| 180 | static HRESULT OnCacheVerifyContainerOrPayload( | ||
| 181 | __in BURN_CONTAINERS* pContainers, | ||
| 182 | __in BURN_PACKAGES* pPackages, | ||
| 183 | __in BURN_PAYLOADS* pPayloads, | ||
| 184 | __in BYTE* pbData, | ||
| 185 | __in DWORD cbData | ||
| 186 | ); | ||
| 179 | static void OnCacheCleanup( | 187 | static void OnCacheCleanup( |
| 180 | __in_z LPCWSTR wzBundleId | 188 | __in_z LPCWSTR wzBundleId |
| 181 | ); | 189 | ); |
| @@ -657,6 +665,44 @@ LExit: | |||
| 657 | return hr; | 665 | return hr; |
| 658 | } | 666 | } |
| 659 | 667 | ||
| 668 | extern "C" HRESULT ElevationCacheVerifyContainerOrPayload( | ||
| 669 | __in HANDLE hPipe, | ||
| 670 | __in_opt BURN_CONTAINER* pContainer, | ||
| 671 | __in_opt BURN_PACKAGE* pPackage, | ||
| 672 | __in_opt BURN_PAYLOAD* pPayload, | ||
| 673 | __in_z_opt LPCWSTR wzLayoutDirectory | ||
| 674 | ) | ||
| 675 | { | ||
| 676 | HRESULT hr = S_OK; | ||
| 677 | BYTE* pbData = NULL; | ||
| 678 | SIZE_T cbData = 0; | ||
| 679 | DWORD dwResult = 0; | ||
| 680 | |||
| 681 | // serialize message data | ||
| 682 | hr = BuffWriteString(&pbData, &cbData, pContainer ? pContainer->sczId : NULL); | ||
| 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."); | ||
| 687 | |||
| 688 | hr = BuffWriteString(&pbData, &cbData, pPayload ? pPayload->sczKey : NULL); | ||
| 689 | ExitOnFailure(hr, "Failed to write payload id to message buffer."); | ||
| 690 | |||
| 691 | hr = BuffWriteString(&pbData, &cbData, wzLayoutDirectory); | ||
| 692 | ExitOnFailure(hr, "Failed to write layout directory to message buffer."); | ||
| 693 | |||
| 694 | // send message | ||
| 695 | hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_CONTAINER_OR_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."); | ||
| 697 | |||
| 698 | hr = (HRESULT)dwResult; | ||
| 699 | |||
| 700 | LExit: | ||
| 701 | ReleaseBuffer(pbData); | ||
| 702 | |||
| 703 | return hr; | ||
| 704 | } | ||
| 705 | |||
| 660 | /******************************************************************* | 706 | /******************************************************************* |
| 661 | ElevationCacheCleanup - | 707 | ElevationCacheCleanup - |
| 662 | 708 | ||
| @@ -1724,6 +1770,10 @@ static HRESULT ProcessElevatedChildCacheMessage( | |||
| 1724 | hrResult = OnCacheOrLayoutContainerOrPayload(pContext->pContainers, pContext->pPackages, pContext->pPayloads, (BYTE*)pMsg->pvData, pMsg->cbData); | 1770 | hrResult = OnCacheOrLayoutContainerOrPayload(pContext->pContainers, pContext->pPackages, pContext->pPayloads, (BYTE*)pMsg->pvData, pMsg->cbData); |
| 1725 | break; | 1771 | break; |
| 1726 | 1772 | ||
| 1773 | case BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_CONTAINER_OR_PAYLOAD: | ||
| 1774 | hrResult = OnCacheVerifyContainerOrPayload(pContext->pContainers, pContext->pPackages, pContext->pPayloads, (BYTE*)pMsg->pvData, pMsg->cbData); | ||
| 1775 | break; | ||
| 1776 | |||
| 1727 | case BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP: | 1777 | case BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP: |
| 1728 | OnCacheCleanup(pContext->pRegistration->sczId); | 1778 | OnCacheCleanup(pContext->pRegistration->sczId); |
| 1729 | hrResult = S_OK; | 1779 | hrResult = S_OK; |
| @@ -2062,7 +2112,7 @@ static HRESULT OnCacheOrLayoutContainerOrPayload( | |||
| 2062 | 2112 | ||
| 2063 | // Deserialize message data. | 2113 | // Deserialize message data. |
| 2064 | hr = BuffReadString(pbData, cbData, &iData, &scz); | 2114 | hr = BuffReadString(pbData, cbData, &iData, &scz); |
| 2065 | ExitOnFailure(hr, "Failed to read package id."); | 2115 | ExitOnFailure(hr, "Failed to read container id."); |
| 2066 | 2116 | ||
| 2067 | if (scz && *scz) | 2117 | if (scz && *scz) |
| 2068 | { | 2118 | { |
| @@ -2135,6 +2185,90 @@ LExit: | |||
| 2135 | return hr; | 2185 | return hr; |
| 2136 | } | 2186 | } |
| 2137 | 2187 | ||
| 2188 | static HRESULT OnCacheVerifyContainerOrPayload( | ||
| 2189 | __in BURN_CONTAINERS* pContainers, | ||
| 2190 | __in BURN_PACKAGES* pPackages, | ||
| 2191 | __in BURN_PAYLOADS* pPayloads, | ||
| 2192 | __in BYTE* pbData, | ||
| 2193 | __in DWORD cbData | ||
| 2194 | ) | ||
| 2195 | { | ||
| 2196 | HRESULT hr = S_OK; | ||
| 2197 | SIZE_T iData = 0; | ||
| 2198 | LPWSTR scz = NULL; | ||
| 2199 | BURN_CONTAINER* pContainer = NULL; | ||
| 2200 | BURN_PACKAGE* pPackage = NULL; | ||
| 2201 | BURN_PAYLOAD* pPayload = NULL; | ||
| 2202 | LPWSTR sczCacheDirectory = NULL; | ||
| 2203 | |||
| 2204 | // Deserialize message data. | ||
| 2205 | 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."); | ||
| 2216 | |||
| 2217 | if (scz && *scz) | ||
| 2218 | { | ||
| 2219 | hr = PackageFindById(pPackages, scz, &pPackage); | ||
| 2220 | ExitOnFailure(hr, "Failed to find package: %ls", scz); | ||
| 2221 | } | ||
| 2222 | |||
| 2223 | hr = BuffReadString(pbData, cbData, &iData, &scz); | ||
| 2224 | ExitOnFailure(hr, "Failed to read payload id."); | ||
| 2225 | |||
| 2226 | if (scz && *scz) | ||
| 2227 | { | ||
| 2228 | hr = PayloadFindById(pPayloads, scz, &pPayload); | ||
| 2229 | ExitOnFailure(hr, "Failed to find payload: %ls", scz); | ||
| 2230 | } | ||
| 2231 | |||
| 2232 | hr = BuffReadString(pbData, cbData, &iData, &sczCacheDirectory); | ||
| 2233 | ExitOnFailure(hr, "Failed to read layout directory."); | ||
| 2234 | |||
| 2235 | if (!sczCacheDirectory || !*sczCacheDirectory) | ||
| 2236 | { | ||
| 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); | ||
| 2244 | 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 | |||
| 2252 | hr = CacheVerifyContainer(pContainer, sczCacheDirectory); | ||
| 2253 | } | ||
| 2254 | else if (pPayload) | ||
| 2255 | { | ||
| 2256 | hr = CacheVerifyPayload(pPayload, sczCacheDirectory); | ||
| 2257 | } | ||
| 2258 | else | ||
| 2259 | { | ||
| 2260 | hr = E_INVALIDARG; | ||
| 2261 | ExitOnRootFailure(hr, "Invalid data passed to cache or layout payload."); | ||
| 2262 | } | ||
| 2263 | // Nothing should be logged on failure. | ||
| 2264 | |||
| 2265 | LExit: | ||
| 2266 | ReleaseStr(sczCacheDirectory); | ||
| 2267 | ReleaseStr(scz); | ||
| 2268 | |||
| 2269 | return hr; | ||
| 2270 | } | ||
| 2271 | |||
| 2138 | static void OnCacheCleanup( | 2272 | static void OnCacheCleanup( |
| 2139 | __in_z LPCWSTR wzBundleId | 2273 | __in_z LPCWSTR wzBundleId |
| 2140 | ) | 2274 | ) |
