diff options
Diffstat (limited to 'src/burn/engine/elevation.cpp')
-rw-r--r-- | src/burn/engine/elevation.cpp | 166 |
1 files changed, 139 insertions, 27 deletions
diff --git a/src/burn/engine/elevation.cpp b/src/burn/engine/elevation.cpp index 6c4a775f..355b4a34 100644 --- a/src/burn/engine/elevation.cpp +++ b/src/burn/engine/elevation.cpp | |||
@@ -19,6 +19,7 @@ typedef enum _BURN_ELEVATION_MESSAGE_TYPE | |||
19 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_PAYLOAD, | 19 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_PAYLOAD, |
20 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP, | 20 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP, |
21 | BURN_ELEVATION_MESSAGE_TYPE_PROCESS_DEPENDENT_REGISTRATION, | 21 | BURN_ELEVATION_MESSAGE_TYPE_PROCESS_DEPENDENT_REGISTRATION, |
22 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_RELATED_BUNDLE, | ||
22 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE, | 23 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE, |
23 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_MSI_PACKAGE, | 24 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_MSI_PACKAGE, |
24 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_MSP_PACKAGE, | 25 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_MSP_PACKAGE, |
@@ -230,11 +231,18 @@ static HRESULT OnProcessDependentRegistration( | |||
230 | __in BYTE* pbData, | 231 | __in BYTE* pbData, |
231 | __in SIZE_T cbData | 232 | __in SIZE_T cbData |
232 | ); | 233 | ); |
234 | static HRESULT OnExecuteRelatedBundle( | ||
235 | __in HANDLE hPipe, | ||
236 | __in BURN_CACHE* pCache, | ||
237 | __in BURN_RELATED_BUNDLES* pRelatedBundles, | ||
238 | __in BURN_VARIABLES* pVariables, | ||
239 | __in BYTE* pbData, | ||
240 | __in SIZE_T cbData | ||
241 | ); | ||
233 | static HRESULT OnExecuteExePackage( | 242 | static HRESULT OnExecuteExePackage( |
234 | __in HANDLE hPipe, | 243 | __in HANDLE hPipe, |
235 | __in BURN_CACHE* pCache, | 244 | __in BURN_CACHE* pCache, |
236 | __in BURN_PACKAGES* pPackages, | 245 | __in BURN_PACKAGES* pPackages, |
237 | __in BURN_RELATED_BUNDLES* pRelatedBundles, | ||
238 | __in BURN_VARIABLES* pVariables, | 246 | __in BURN_VARIABLES* pVariables, |
239 | __in BYTE* pbData, | 247 | __in BYTE* pbData, |
240 | __in SIZE_T cbData | 248 | __in SIZE_T cbData |
@@ -818,10 +826,10 @@ LExit: | |||
818 | } | 826 | } |
819 | 827 | ||
820 | /******************************************************************* | 828 | /******************************************************************* |
821 | ElevationExecuteExePackage - | 829 | ElevationExecuteRelatedBundle - |
822 | 830 | ||
823 | *******************************************************************/ | 831 | *******************************************************************/ |
824 | extern "C" HRESULT ElevationExecuteExePackage( | 832 | extern "C" HRESULT ElevationExecuteRelatedBundle( |
825 | __in HANDLE hPipe, | 833 | __in HANDLE hPipe, |
826 | __in BURN_EXECUTE_ACTION* pExecuteAction, | 834 | __in BURN_EXECUTE_ACTION* pExecuteAction, |
827 | __in BURN_VARIABLES* pVariables, | 835 | __in BURN_VARIABLES* pVariables, |
@@ -838,22 +846,22 @@ extern "C" HRESULT ElevationExecuteExePackage( | |||
838 | DWORD dwResult = 0; | 846 | DWORD dwResult = 0; |
839 | 847 | ||
840 | // serialize message data | 848 | // serialize message data |
841 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->exePackage.pPackage->sczId); | 849 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->relatedBundle.pRelatedBundle->package.sczId); |
842 | ExitOnFailure(hr, "Failed to write package id to message buffer."); | 850 | ExitOnFailure(hr, "Failed to write package id to message buffer."); |
843 | 851 | ||
844 | hr = BuffWriteNumber(&pbData, &cbData, (DWORD)pExecuteAction->exePackage.action); | 852 | hr = BuffWriteNumber(&pbData, &cbData, (DWORD)pExecuteAction->relatedBundle.action); |
845 | ExitOnFailure(hr, "Failed to write action to message buffer."); | 853 | ExitOnFailure(hr, "Failed to write action to message buffer."); |
846 | 854 | ||
847 | hr = BuffWriteNumber(&pbData, &cbData, fRollback); | 855 | hr = BuffWriteNumber(&pbData, &cbData, fRollback); |
848 | ExitOnFailure(hr, "Failed to write rollback."); | 856 | ExitOnFailure(hr, "Failed to write rollback."); |
849 | 857 | ||
850 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->exePackage.sczIgnoreDependencies); | 858 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->relatedBundle.sczIgnoreDependencies); |
851 | ExitOnFailure(hr, "Failed to write the list of dependencies to ignore to the message buffer."); | 859 | ExitOnFailure(hr, "Failed to write the list of dependencies to ignore to the message buffer."); |
852 | 860 | ||
853 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->exePackage.sczAncestors); | 861 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->relatedBundle.sczAncestors); |
854 | ExitOnFailure(hr, "Failed to write the list of ancestors to the message buffer."); | 862 | ExitOnFailure(hr, "Failed to write the list of ancestors to the message buffer."); |
855 | 863 | ||
856 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->exePackage.sczEngineWorkingDirectory); | 864 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->relatedBundle.sczEngineWorkingDirectory); |
857 | ExitOnFailure(hr, "Failed to write the custom working directory to the message buffer."); | 865 | ExitOnFailure(hr, "Failed to write the custom working directory to the message buffer."); |
858 | 866 | ||
859 | hr = VariableSerialize(pVariables, FALSE, &pbData, &cbData); | 867 | hr = VariableSerialize(pVariables, FALSE, &pbData, &cbData); |
@@ -863,6 +871,54 @@ extern "C" HRESULT ElevationExecuteExePackage( | |||
863 | context.pfnGenericMessageHandler = pfnGenericMessageHandler; | 871 | context.pfnGenericMessageHandler = pfnGenericMessageHandler; |
864 | context.pvContext = pvContext; | 872 | context.pvContext = pvContext; |
865 | 873 | ||
874 | hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_RELATED_BUNDLE, pbData, cbData, ProcessGenericExecuteMessages, &context, &dwResult); | ||
875 | ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_RELATED_BUNDLE message to per-machine process."); | ||
876 | |||
877 | hr = ProcessResult(dwResult, pRestart); | ||
878 | |||
879 | LExit: | ||
880 | ReleaseBuffer(pbData); | ||
881 | |||
882 | return hr; | ||
883 | } | ||
884 | |||
885 | /******************************************************************* | ||
886 | ElevationExecuteExePackage - | ||
887 | |||
888 | *******************************************************************/ | ||
889 | extern "C" HRESULT ElevationExecuteExePackage( | ||
890 | __in HANDLE hPipe, | ||
891 | __in BURN_EXECUTE_ACTION* pExecuteAction, | ||
892 | __in BURN_VARIABLES* pVariables, | ||
893 | __in BOOL fRollback, | ||
894 | __in PFN_GENERICMESSAGEHANDLER pfnGenericMessageHandler, | ||
895 | __in LPVOID pvContext, | ||
896 | __out BOOTSTRAPPER_APPLY_RESTART* pRestart | ||
897 | ) | ||
898 | { | ||
899 | HRESULT hr = S_OK; | ||
900 | BYTE* pbData = NULL; | ||
901 | SIZE_T cbData = 0; | ||
902 | BURN_ELEVATION_GENERIC_MESSAGE_CONTEXT context = { }; | ||
903 | DWORD dwResult = 0; | ||
904 | |||
905 | // serialize message data | ||
906 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->exePackage.pPackage->sczId); | ||
907 | ExitOnFailure(hr, "Failed to write package id to message buffer."); | ||
908 | |||
909 | hr = BuffWriteNumber(&pbData, &cbData, (DWORD)pExecuteAction->exePackage.action); | ||
910 | ExitOnFailure(hr, "Failed to write action to message buffer."); | ||
911 | |||
912 | hr = BuffWriteNumber(&pbData, &cbData, fRollback); | ||
913 | ExitOnFailure(hr, "Failed to write rollback."); | ||
914 | |||
915 | hr = VariableSerialize(pVariables, FALSE, &pbData, &cbData); | ||
916 | ExitOnFailure(hr, "Failed to write variables."); | ||
917 | |||
918 | // send message | ||
919 | context.pfnGenericMessageHandler = pfnGenericMessageHandler; | ||
920 | context.pvContext = pvContext; | ||
921 | |||
866 | hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE, pbData, cbData, ProcessGenericExecuteMessages, &context, &dwResult); | 922 | hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE, pbData, cbData, ProcessGenericExecuteMessages, &context, &dwResult); |
867 | ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE message to per-machine process."); | 923 | ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE message to per-machine process."); |
868 | 924 | ||
@@ -1911,8 +1967,12 @@ static HRESULT ProcessElevatedChildMessage( | |||
1911 | hrResult = OnProcessDependentRegistration(pContext->pRegistration, (BYTE*)pMsg->pvData, pMsg->cbData); | 1967 | hrResult = OnProcessDependentRegistration(pContext->pRegistration, (BYTE*)pMsg->pvData, pMsg->cbData); |
1912 | break; | 1968 | break; |
1913 | 1969 | ||
1970 | case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_RELATED_BUNDLE: | ||
1971 | hrResult = OnExecuteRelatedBundle(pContext->hPipe, pContext->pCache, &pContext->pRegistration->relatedBundles, pContext->pVariables, (BYTE*)pMsg->pvData, pMsg->cbData); | ||
1972 | break; | ||
1973 | |||
1914 | case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE: | 1974 | case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE: |
1915 | hrResult = OnExecuteExePackage(pContext->hPipe, pContext->pCache, pContext->pPackages, &pContext->pRegistration->relatedBundles, pContext->pVariables, (BYTE*)pMsg->pvData, pMsg->cbData); | 1975 | hrResult = OnExecuteExePackage(pContext->hPipe, pContext->pCache, pContext->pPackages, pContext->pVariables, (BYTE*)pMsg->pvData, pMsg->cbData); |
1916 | break; | 1976 | break; |
1917 | 1977 | ||
1918 | case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_MSI_PACKAGE: | 1978 | case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_MSI_PACKAGE: |
@@ -2473,10 +2533,9 @@ LExit: | |||
2473 | return hr; | 2533 | return hr; |
2474 | } | 2534 | } |
2475 | 2535 | ||
2476 | static HRESULT OnExecuteExePackage( | 2536 | static HRESULT OnExecuteRelatedBundle( |
2477 | __in HANDLE hPipe, | 2537 | __in HANDLE hPipe, |
2478 | __in BURN_CACHE* pCache, | 2538 | __in BURN_CACHE* pCache, |
2479 | __in BURN_PACKAGES* pPackages, | ||
2480 | __in BURN_RELATED_BUNDLES* pRelatedBundles, | 2539 | __in BURN_RELATED_BUNDLES* pRelatedBundles, |
2481 | __in BURN_VARIABLES* pVariables, | 2540 | __in BURN_VARIABLES* pVariables, |
2482 | __in BYTE* pbData, | 2541 | __in BYTE* pbData, |
@@ -2491,15 +2550,15 @@ static HRESULT OnExecuteExePackage( | |||
2491 | LPWSTR sczIgnoreDependencies = NULL; | 2550 | LPWSTR sczIgnoreDependencies = NULL; |
2492 | LPWSTR sczAncestors = NULL; | 2551 | LPWSTR sczAncestors = NULL; |
2493 | LPWSTR sczEngineWorkingDirectory = NULL; | 2552 | LPWSTR sczEngineWorkingDirectory = NULL; |
2494 | BOOTSTRAPPER_APPLY_RESTART exeRestart = BOOTSTRAPPER_APPLY_RESTART_NONE; | 2553 | BOOTSTRAPPER_APPLY_RESTART bundleRestart = BOOTSTRAPPER_APPLY_RESTART_NONE; |
2495 | 2554 | ||
2496 | executeAction.type = BURN_EXECUTE_ACTION_TYPE_EXE_PACKAGE; | 2555 | executeAction.type = BURN_EXECUTE_ACTION_TYPE_RELATED_BUNDLE; |
2497 | 2556 | ||
2498 | // Deserialize message data. | 2557 | // Deserialize message data. |
2499 | hr = BuffReadString(pbData, cbData, &iData, &sczPackage); | 2558 | hr = BuffReadString(pbData, cbData, &iData, &sczPackage); |
2500 | ExitOnFailure(hr, "Failed to read EXE package id."); | 2559 | ExitOnFailure(hr, "Failed to read related bundle id."); |
2501 | 2560 | ||
2502 | hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&executeAction.exePackage.action); | 2561 | hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&executeAction.relatedBundle.action); |
2503 | ExitOnFailure(hr, "Failed to read action."); | 2562 | ExitOnFailure(hr, "Failed to read action."); |
2504 | 2563 | ||
2505 | hr = BuffReadNumber(pbData, cbData, &iData, &dwRollback); | 2564 | hr = BuffReadNumber(pbData, cbData, &iData, &dwRollback); |
@@ -2517,36 +2576,32 @@ static HRESULT OnExecuteExePackage( | |||
2517 | hr = VariableDeserialize(pVariables, FALSE, pbData, cbData, &iData); | 2576 | hr = VariableDeserialize(pVariables, FALSE, pbData, cbData, &iData); |
2518 | ExitOnFailure(hr, "Failed to read variables."); | 2577 | ExitOnFailure(hr, "Failed to read variables."); |
2519 | 2578 | ||
2520 | hr = PackageFindById(pPackages, sczPackage, &executeAction.exePackage.pPackage); | 2579 | hr = RelatedBundleFindById(pRelatedBundles, sczPackage, &executeAction.relatedBundle.pRelatedBundle); |
2521 | if (E_NOTFOUND == hr) | 2580 | ExitOnFailure(hr, "Failed to find related bundle: %ls", sczPackage); |
2522 | { | ||
2523 | hr = PackageFindRelatedById(pRelatedBundles, sczPackage, &executeAction.exePackage.pPackage); | ||
2524 | } | ||
2525 | ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); | ||
2526 | 2581 | ||
2527 | // Pass the list of dependencies to ignore, if any, to the related bundle. | 2582 | // Pass the list of dependencies to ignore, if any, to the related bundle. |
2528 | if (sczIgnoreDependencies && *sczIgnoreDependencies) | 2583 | if (sczIgnoreDependencies && *sczIgnoreDependencies) |
2529 | { | 2584 | { |
2530 | hr = StrAllocString(&executeAction.exePackage.sczIgnoreDependencies, sczIgnoreDependencies, 0); | 2585 | hr = StrAllocString(&executeAction.relatedBundle.sczIgnoreDependencies, sczIgnoreDependencies, 0); |
2531 | ExitOnFailure(hr, "Failed to allocate the list of dependencies to ignore."); | 2586 | ExitOnFailure(hr, "Failed to allocate the list of dependencies to ignore."); |
2532 | } | 2587 | } |
2533 | 2588 | ||
2534 | // Pass the list of ancestors, if any, to the related bundle. | 2589 | // Pass the list of ancestors, if any, to the related bundle. |
2535 | if (sczAncestors && *sczAncestors) | 2590 | if (sczAncestors && *sczAncestors) |
2536 | { | 2591 | { |
2537 | hr = StrAllocString(&executeAction.exePackage.sczAncestors, sczAncestors, 0); | 2592 | hr = StrAllocString(&executeAction.relatedBundle.sczAncestors, sczAncestors, 0); |
2538 | ExitOnFailure(hr, "Failed to allocate the list of ancestors."); | 2593 | ExitOnFailure(hr, "Failed to allocate the list of ancestors."); |
2539 | } | 2594 | } |
2540 | 2595 | ||
2541 | if (sczEngineWorkingDirectory && *sczEngineWorkingDirectory) | 2596 | if (sczEngineWorkingDirectory && *sczEngineWorkingDirectory) |
2542 | { | 2597 | { |
2543 | hr = StrAllocString(&executeAction.exePackage.sczEngineWorkingDirectory, sczEngineWorkingDirectory, 0); | 2598 | hr = StrAllocString(&executeAction.relatedBundle.sczEngineWorkingDirectory, sczEngineWorkingDirectory, 0); |
2544 | ExitOnFailure(hr, "Failed to allocate the custom working directory."); | 2599 | ExitOnFailure(hr, "Failed to allocate the custom working directory."); |
2545 | } | 2600 | } |
2546 | 2601 | ||
2547 | // Execute EXE package. | 2602 | // Execute related bundle. |
2548 | hr = ExeEngineExecutePackage(&executeAction, pCache, pVariables, static_cast<BOOL>(dwRollback), GenericExecuteMessageHandler, hPipe, &exeRestart); | 2603 | hr = BundlePackageEngineExecuteRelatedBundle(&executeAction, pCache, pVariables, static_cast<BOOL>(dwRollback), GenericExecuteMessageHandler, hPipe, &bundleRestart); |
2549 | ExitOnFailure(hr, "Failed to execute EXE package."); | 2604 | ExitOnFailure(hr, "Failed to execute related bundle."); |
2550 | 2605 | ||
2551 | LExit: | 2606 | LExit: |
2552 | ReleaseStr(sczEngineWorkingDirectory); | 2607 | ReleaseStr(sczEngineWorkingDirectory); |
@@ -2557,6 +2612,63 @@ LExit: | |||
2557 | 2612 | ||
2558 | if (SUCCEEDED(hr)) | 2613 | if (SUCCEEDED(hr)) |
2559 | { | 2614 | { |
2615 | if (BOOTSTRAPPER_APPLY_RESTART_REQUIRED == bundleRestart) | ||
2616 | { | ||
2617 | hr = HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED); | ||
2618 | } | ||
2619 | else if (BOOTSTRAPPER_APPLY_RESTART_INITIATED == bundleRestart) | ||
2620 | { | ||
2621 | hr = HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_INITIATED); | ||
2622 | } | ||
2623 | } | ||
2624 | |||
2625 | return hr; | ||
2626 | } | ||
2627 | |||
2628 | static HRESULT OnExecuteExePackage( | ||
2629 | __in HANDLE hPipe, | ||
2630 | __in BURN_CACHE* pCache, | ||
2631 | __in BURN_PACKAGES* pPackages, | ||
2632 | __in BURN_VARIABLES* pVariables, | ||
2633 | __in BYTE* pbData, | ||
2634 | __in SIZE_T cbData | ||
2635 | ) | ||
2636 | { | ||
2637 | HRESULT hr = S_OK; | ||
2638 | SIZE_T iData = 0; | ||
2639 | LPWSTR sczPackage = NULL; | ||
2640 | DWORD dwRollback = 0; | ||
2641 | BURN_EXECUTE_ACTION executeAction = { }; | ||
2642 | BOOTSTRAPPER_APPLY_RESTART exeRestart = BOOTSTRAPPER_APPLY_RESTART_NONE; | ||
2643 | |||
2644 | executeAction.type = BURN_EXECUTE_ACTION_TYPE_EXE_PACKAGE; | ||
2645 | |||
2646 | // Deserialize message data. | ||
2647 | hr = BuffReadString(pbData, cbData, &iData, &sczPackage); | ||
2648 | ExitOnFailure(hr, "Failed to read EXE package id."); | ||
2649 | |||
2650 | hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&executeAction.exePackage.action); | ||
2651 | ExitOnFailure(hr, "Failed to read action."); | ||
2652 | |||
2653 | hr = BuffReadNumber(pbData, cbData, &iData, &dwRollback); | ||
2654 | ExitOnFailure(hr, "Failed to read rollback."); | ||
2655 | |||
2656 | hr = VariableDeserialize(pVariables, FALSE, pbData, cbData, &iData); | ||
2657 | ExitOnFailure(hr, "Failed to read variables."); | ||
2658 | |||
2659 | hr = PackageFindById(pPackages, sczPackage, &executeAction.exePackage.pPackage); | ||
2660 | ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); | ||
2661 | |||
2662 | // Execute EXE package. | ||
2663 | hr = ExeEngineExecutePackage(&executeAction, pCache, pVariables, static_cast<BOOL>(dwRollback), GenericExecuteMessageHandler, hPipe, &exeRestart); | ||
2664 | ExitOnFailure(hr, "Failed to execute EXE package."); | ||
2665 | |||
2666 | LExit: | ||
2667 | ReleaseStr(sczPackage); | ||
2668 | PlanUninitializeExecuteAction(&executeAction); | ||
2669 | |||
2670 | if (SUCCEEDED(hr)) | ||
2671 | { | ||
2560 | if (BOOTSTRAPPER_APPLY_RESTART_REQUIRED == exeRestart) | 2672 | if (BOOTSTRAPPER_APPLY_RESTART_REQUIRED == exeRestart) |
2561 | { | 2673 | { |
2562 | hr = HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED); | 2674 | hr = HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED); |