diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2022-03-30 17:08:40 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2022-04-01 22:06:11 -0500 |
| commit | 386a3578413ba16b3c0615d47870ee44a0e461f6 (patch) | |
| tree | 1dfcea9e5080f1f15cc880aba1541a962426c58b /src/burn/engine/elevation.cpp | |
| parent | d97c0d1685ef4c3840776327e76ce25d4dbdbeb1 (diff) | |
| download | wix-386a3578413ba16b3c0615d47870ee44a0e461f6.tar.gz wix-386a3578413ba16b3c0615d47870ee44a0e461f6.tar.bz2 wix-386a3578413ba16b3c0615d47870ee44a0e461f6.zip | |
Implement BundlePackage.
3693
Diffstat (limited to 'src/burn/engine/elevation.cpp')
| -rw-r--r-- | src/burn/engine/elevation.cpp | 176 |
1 files changed, 164 insertions, 12 deletions
diff --git a/src/burn/engine/elevation.cpp b/src/burn/engine/elevation.cpp index 8488b649..504ddaea 100644 --- a/src/burn/engine/elevation.cpp +++ b/src/burn/engine/elevation.cpp | |||
| @@ -20,6 +20,7 @@ typedef enum _BURN_ELEVATION_MESSAGE_TYPE | |||
| 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_RELATED_BUNDLE, |
| 23 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_BUNDLE_PACKAGE, | ||
| 23 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE, | 24 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE, |
| 24 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_MSI_PACKAGE, | 25 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_MSI_PACKAGE, |
| 25 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_MSP_PACKAGE, | 26 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_MSP_PACKAGE, |
| @@ -250,6 +251,14 @@ static HRESULT OnExecuteRelatedBundle( | |||
| 250 | __in BYTE* pbData, | 251 | __in BYTE* pbData, |
| 251 | __in SIZE_T cbData | 252 | __in SIZE_T cbData |
| 252 | ); | 253 | ); |
| 254 | static HRESULT OnExecuteBundlePackage( | ||
| 255 | __in HANDLE hPipe, | ||
| 256 | __in BURN_CACHE* pCache, | ||
| 257 | __in BURN_PACKAGES* pPackages, | ||
| 258 | __in BURN_VARIABLES* pVariables, | ||
| 259 | __in BYTE* pbData, | ||
| 260 | __in SIZE_T cbData | ||
| 261 | ); | ||
| 253 | static HRESULT OnExecuteExePackage( | 262 | static HRESULT OnExecuteExePackage( |
| 254 | __in HANDLE hPipe, | 263 | __in HANDLE hPipe, |
| 255 | __in BURN_CACHE* pCache, | 264 | __in BURN_CACHE* pCache, |
| @@ -911,6 +920,63 @@ LExit: | |||
| 911 | } | 920 | } |
| 912 | 921 | ||
| 913 | /******************************************************************* | 922 | /******************************************************************* |
| 923 | ElevationExecuteBundlePackage - | ||
| 924 | |||
| 925 | *******************************************************************/ | ||
| 926 | extern "C" HRESULT ElevationExecuteBundlePackage( | ||
| 927 | __in HANDLE hPipe, | ||
| 928 | __in BURN_EXECUTE_ACTION* pExecuteAction, | ||
| 929 | __in BURN_VARIABLES* pVariables, | ||
| 930 | __in BOOL fRollback, | ||
| 931 | __in PFN_GENERICMESSAGEHANDLER pfnGenericMessageHandler, | ||
| 932 | __in LPVOID pvContext, | ||
| 933 | __out BOOTSTRAPPER_APPLY_RESTART* pRestart | ||
| 934 | ) | ||
| 935 | { | ||
| 936 | HRESULT hr = S_OK; | ||
| 937 | BYTE* pbData = NULL; | ||
| 938 | SIZE_T cbData = 0; | ||
| 939 | BURN_ELEVATION_GENERIC_MESSAGE_CONTEXT context = { }; | ||
| 940 | DWORD dwResult = 0; | ||
| 941 | |||
| 942 | // serialize message data | ||
| 943 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->bundlePackage.pPackage->sczId); | ||
| 944 | ExitOnFailure(hr, "Failed to write package id to message buffer."); | ||
| 945 | |||
| 946 | hr = BuffWriteNumber(&pbData, &cbData, (DWORD)pExecuteAction->bundlePackage.action); | ||
| 947 | ExitOnFailure(hr, "Failed to write action to message buffer."); | ||
| 948 | |||
| 949 | hr = BuffWriteNumber(&pbData, &cbData, fRollback); | ||
| 950 | ExitOnFailure(hr, "Failed to write rollback."); | ||
| 951 | |||
| 952 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->bundlePackage.sczIgnoreDependencies); | ||
| 953 | ExitOnFailure(hr, "Failed to write the list of dependencies to ignore to the message buffer."); | ||
| 954 | |||
| 955 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->bundlePackage.sczAncestors); | ||
| 956 | ExitOnFailure(hr, "Failed to write the list of ancestors to the message buffer."); | ||
| 957 | |||
| 958 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->bundlePackage.sczEngineWorkingDirectory); | ||
| 959 | ExitOnFailure(hr, "Failed to write the custom working directory to the message buffer."); | ||
| 960 | |||
| 961 | hr = VariableSerialize(pVariables, FALSE, &pbData, &cbData); | ||
| 962 | ExitOnFailure(hr, "Failed to write variables."); | ||
| 963 | |||
| 964 | // send message | ||
| 965 | context.pfnGenericMessageHandler = pfnGenericMessageHandler; | ||
| 966 | context.pvContext = pvContext; | ||
| 967 | |||
| 968 | hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_BUNDLE_PACKAGE, pbData, cbData, ProcessGenericExecuteMessages, &context, &dwResult); | ||
| 969 | ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_BUNDLE_PACKAGE message to per-machine process."); | ||
| 970 | |||
| 971 | hr = ProcessResult(dwResult, pRestart); | ||
| 972 | |||
| 973 | LExit: | ||
| 974 | ReleaseBuffer(pbData); | ||
| 975 | |||
| 976 | return hr; | ||
| 977 | } | ||
| 978 | |||
| 979 | /******************************************************************* | ||
| 914 | ElevationExecuteExePackage - | 980 | ElevationExecuteExePackage - |
| 915 | 981 | ||
| 916 | *******************************************************************/ | 982 | *******************************************************************/ |
| @@ -940,9 +1006,6 @@ extern "C" HRESULT ElevationExecuteExePackage( | |||
| 940 | hr = BuffWriteNumber(&pbData, &cbData, fRollback); | 1006 | hr = BuffWriteNumber(&pbData, &cbData, fRollback); |
| 941 | ExitOnFailure(hr, "Failed to write rollback."); | 1007 | ExitOnFailure(hr, "Failed to write rollback."); |
| 942 | 1008 | ||
| 943 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->exePackage.sczIgnoreDependencies); | ||
| 944 | ExitOnFailure(hr, "Failed to write the list of dependencies to ignore to the message buffer."); | ||
| 945 | |||
| 946 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->exePackage.sczAncestors); | 1009 | hr = BuffWriteString(&pbData, &cbData, pExecuteAction->exePackage.sczAncestors); |
| 947 | ExitOnFailure(hr, "Failed to write the list of ancestors to the message buffer."); | 1010 | ExitOnFailure(hr, "Failed to write the list of ancestors to the message buffer."); |
| 948 | 1011 | ||
| @@ -2124,6 +2187,10 @@ static HRESULT ProcessElevatedChildMessage( | |||
| 2124 | hrResult = OnExecuteRelatedBundle(pContext->hPipe, pContext->pCache, &pContext->pRegistration->relatedBundles, pContext->pVariables, (BYTE*)pMsg->pvData, pMsg->cbData); | 2187 | hrResult = OnExecuteRelatedBundle(pContext->hPipe, pContext->pCache, &pContext->pRegistration->relatedBundles, pContext->pVariables, (BYTE*)pMsg->pvData, pMsg->cbData); |
| 2125 | break; | 2188 | break; |
| 2126 | 2189 | ||
| 2190 | case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_BUNDLE_PACKAGE: | ||
| 2191 | hrResult = OnExecuteBundlePackage(pContext->hPipe, pContext->pCache, pContext->pPackages, pContext->pVariables, (BYTE*)pMsg->pvData, pMsg->cbData); | ||
| 2192 | break; | ||
| 2193 | |||
| 2127 | case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE: | 2194 | case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE: |
| 2128 | hrResult = OnExecuteExePackage(pContext->hPipe, pContext->pCache, pContext->pPackages, pContext->pVariables, (BYTE*)pMsg->pvData, pMsg->cbData); | 2195 | hrResult = OnExecuteExePackage(pContext->hPipe, pContext->pCache, pContext->pPackages, pContext->pVariables, (BYTE*)pMsg->pvData, pMsg->cbData); |
| 2129 | break; | 2196 | break; |
| @@ -2839,7 +2906,7 @@ LExit: | |||
| 2839 | return hr; | 2906 | return hr; |
| 2840 | } | 2907 | } |
| 2841 | 2908 | ||
| 2842 | static HRESULT OnExecuteExePackage( | 2909 | static HRESULT OnExecuteBundlePackage( |
| 2843 | __in HANDLE hPipe, | 2910 | __in HANDLE hPipe, |
| 2844 | __in BURN_CACHE* pCache, | 2911 | __in BURN_CACHE* pCache, |
| 2845 | __in BURN_PACKAGES* pPackages, | 2912 | __in BURN_PACKAGES* pPackages, |
| @@ -2856,15 +2923,15 @@ static HRESULT OnExecuteExePackage( | |||
| 2856 | LPWSTR sczIgnoreDependencies = NULL; | 2923 | LPWSTR sczIgnoreDependencies = NULL; |
| 2857 | LPWSTR sczAncestors = NULL; | 2924 | LPWSTR sczAncestors = NULL; |
| 2858 | LPWSTR sczEngineWorkingDirectory = NULL; | 2925 | LPWSTR sczEngineWorkingDirectory = NULL; |
| 2859 | BOOTSTRAPPER_APPLY_RESTART exeRestart = BOOTSTRAPPER_APPLY_RESTART_NONE; | 2926 | BOOTSTRAPPER_APPLY_RESTART bundleRestart = BOOTSTRAPPER_APPLY_RESTART_NONE; |
| 2860 | 2927 | ||
| 2861 | executeAction.type = BURN_EXECUTE_ACTION_TYPE_EXE_PACKAGE; | 2928 | executeAction.type = BURN_EXECUTE_ACTION_TYPE_BUNDLE_PACKAGE; |
| 2862 | 2929 | ||
| 2863 | // Deserialize message data. | 2930 | // Deserialize message data. |
| 2864 | hr = BuffReadString(pbData, cbData, &iData, &sczPackage); | 2931 | hr = BuffReadString(pbData, cbData, &iData, &sczPackage); |
| 2865 | ExitOnFailure(hr, "Failed to read EXE package id."); | 2932 | ExitOnFailure(hr, "Failed to read EXE package id."); |
| 2866 | 2933 | ||
| 2867 | hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&executeAction.exePackage.action); | 2934 | hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&executeAction.bundlePackage.action); |
| 2868 | ExitOnFailure(hr, "Failed to read action."); | 2935 | ExitOnFailure(hr, "Failed to read action."); |
| 2869 | 2936 | ||
| 2870 | hr = BuffReadNumber(pbData, cbData, &iData, &dwRollback); | 2937 | hr = BuffReadNumber(pbData, cbData, &iData, &dwRollback); |
| @@ -2882,24 +2949,110 @@ static HRESULT OnExecuteExePackage( | |||
| 2882 | hr = VariableDeserialize(pVariables, FALSE, pbData, cbData, &iData); | 2949 | hr = VariableDeserialize(pVariables, FALSE, pbData, cbData, &iData); |
| 2883 | ExitOnFailure(hr, "Failed to read variables."); | 2950 | ExitOnFailure(hr, "Failed to read variables."); |
| 2884 | 2951 | ||
| 2885 | hr = PackageFindById(pPackages, sczPackage, &executeAction.exePackage.pPackage); | 2952 | hr = PackageFindById(pPackages, sczPackage, &executeAction.bundlePackage.pPackage); |
| 2886 | ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); | 2953 | ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); |
| 2887 | 2954 | ||
| 2888 | if (BURN_PACKAGE_TYPE_EXE != executeAction.exePackage.pPackage->type) | 2955 | if (BURN_PACKAGE_TYPE_BUNDLE != executeAction.bundlePackage.pPackage->type) |
| 2889 | { | 2956 | { |
| 2890 | ExitWithRootFailure(hr, E_INVALIDARG, "Package is not an EXE package: %ls", sczPackage); | 2957 | ExitWithRootFailure(hr, E_INVALIDARG, "Package is not a BUNDLE package: %ls", sczPackage); |
| 2891 | } | 2958 | } |
| 2892 | 2959 | ||
| 2893 | // Pass the list of dependencies to ignore, if any, to the related bundle. | 2960 | // Pass the list of dependencies to ignore, if any, to the related bundle. |
| 2894 | if (sczIgnoreDependencies && *sczIgnoreDependencies) | 2961 | if (sczIgnoreDependencies && *sczIgnoreDependencies) |
| 2895 | { | 2962 | { |
| 2896 | hr = StrAllocString(&executeAction.exePackage.sczIgnoreDependencies, sczIgnoreDependencies, 0); | 2963 | hr = StrAllocString(&executeAction.bundlePackage.sczIgnoreDependencies, sczIgnoreDependencies, 0); |
| 2897 | ExitOnFailure(hr, "Failed to allocate the list of dependencies to ignore."); | 2964 | ExitOnFailure(hr, "Failed to allocate the list of dependencies to ignore."); |
| 2898 | } | 2965 | } |
| 2899 | 2966 | ||
| 2900 | // Pass the list of ancestors, if any, to the related bundle. | 2967 | // Pass the list of ancestors, if any, to the related bundle. |
| 2901 | if (sczAncestors && *sczAncestors) | 2968 | if (sczAncestors && *sczAncestors) |
| 2902 | { | 2969 | { |
| 2970 | hr = StrAllocString(&executeAction.bundlePackage.sczAncestors, sczAncestors, 0); | ||
| 2971 | ExitOnFailure(hr, "Failed to allocate the list of ancestors."); | ||
| 2972 | } | ||
| 2973 | |||
| 2974 | if (sczEngineWorkingDirectory && *sczEngineWorkingDirectory) | ||
| 2975 | { | ||
| 2976 | hr = StrAllocString(&executeAction.bundlePackage.sczEngineWorkingDirectory, sczEngineWorkingDirectory, 0); | ||
| 2977 | ExitOnFailure(hr, "Failed to allocate the custom working directory."); | ||
| 2978 | } | ||
| 2979 | |||
| 2980 | // Execute BUNDLE package. | ||
| 2981 | hr = BundlePackageEngineExecutePackage(&executeAction, pCache, pVariables, static_cast<BOOL>(dwRollback), GenericExecuteMessageHandler, hPipe, &bundleRestart); | ||
| 2982 | ExitOnFailure(hr, "Failed to execute BUNDLE package."); | ||
| 2983 | |||
| 2984 | LExit: | ||
| 2985 | ReleaseStr(sczEngineWorkingDirectory); | ||
| 2986 | ReleaseStr(sczAncestors); | ||
| 2987 | ReleaseStr(sczIgnoreDependencies); | ||
| 2988 | ReleaseStr(sczPackage); | ||
| 2989 | PlanUninitializeExecuteAction(&executeAction); | ||
| 2990 | |||
| 2991 | if (SUCCEEDED(hr)) | ||
| 2992 | { | ||
| 2993 | if (BOOTSTRAPPER_APPLY_RESTART_REQUIRED == bundleRestart) | ||
| 2994 | { | ||
| 2995 | hr = HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED); | ||
| 2996 | } | ||
| 2997 | else if (BOOTSTRAPPER_APPLY_RESTART_INITIATED == bundleRestart) | ||
| 2998 | { | ||
| 2999 | hr = HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_INITIATED); | ||
| 3000 | } | ||
| 3001 | } | ||
| 3002 | |||
| 3003 | return hr; | ||
| 3004 | } | ||
| 3005 | |||
| 3006 | static HRESULT OnExecuteExePackage( | ||
| 3007 | __in HANDLE hPipe, | ||
| 3008 | __in BURN_CACHE* pCache, | ||
| 3009 | __in BURN_PACKAGES* pPackages, | ||
| 3010 | __in BURN_VARIABLES* pVariables, | ||
| 3011 | __in BYTE* pbData, | ||
| 3012 | __in SIZE_T cbData | ||
| 3013 | ) | ||
| 3014 | { | ||
| 3015 | HRESULT hr = S_OK; | ||
| 3016 | SIZE_T iData = 0; | ||
| 3017 | LPWSTR sczPackage = NULL; | ||
| 3018 | DWORD dwRollback = 0; | ||
| 3019 | BURN_EXECUTE_ACTION executeAction = { }; | ||
| 3020 | LPWSTR sczAncestors = NULL; | ||
| 3021 | LPWSTR sczEngineWorkingDirectory = NULL; | ||
| 3022 | BOOTSTRAPPER_APPLY_RESTART exeRestart = BOOTSTRAPPER_APPLY_RESTART_NONE; | ||
| 3023 | |||
| 3024 | executeAction.type = BURN_EXECUTE_ACTION_TYPE_EXE_PACKAGE; | ||
| 3025 | |||
| 3026 | // Deserialize message data. | ||
| 3027 | hr = BuffReadString(pbData, cbData, &iData, &sczPackage); | ||
| 3028 | ExitOnFailure(hr, "Failed to read EXE package id."); | ||
| 3029 | |||
| 3030 | hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&executeAction.exePackage.action); | ||
| 3031 | ExitOnFailure(hr, "Failed to read action."); | ||
| 3032 | |||
| 3033 | hr = BuffReadNumber(pbData, cbData, &iData, &dwRollback); | ||
| 3034 | ExitOnFailure(hr, "Failed to read rollback."); | ||
| 3035 | |||
| 3036 | hr = BuffReadString(pbData, cbData, &iData, &sczAncestors); | ||
| 3037 | ExitOnFailure(hr, "Failed to read the list of ancestors."); | ||
| 3038 | |||
| 3039 | hr = BuffReadString(pbData, cbData, &iData, &sczEngineWorkingDirectory); | ||
| 3040 | ExitOnFailure(hr, "Failed to read the custom working directory."); | ||
| 3041 | |||
| 3042 | hr = VariableDeserialize(pVariables, FALSE, pbData, cbData, &iData); | ||
| 3043 | ExitOnFailure(hr, "Failed to read variables."); | ||
| 3044 | |||
| 3045 | hr = PackageFindById(pPackages, sczPackage, &executeAction.exePackage.pPackage); | ||
| 3046 | ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); | ||
| 3047 | |||
| 3048 | if (BURN_PACKAGE_TYPE_EXE != executeAction.exePackage.pPackage->type) | ||
| 3049 | { | ||
| 3050 | ExitWithRootFailure(hr, E_INVALIDARG, "Package is not an EXE package: %ls", sczPackage); | ||
| 3051 | } | ||
| 3052 | |||
| 3053 | // Pass the list of ancestors, if any, to the related bundle. | ||
| 3054 | if (sczAncestors && *sczAncestors) | ||
| 3055 | { | ||
| 2903 | hr = StrAllocString(&executeAction.exePackage.sczAncestors, sczAncestors, 0); | 3056 | hr = StrAllocString(&executeAction.exePackage.sczAncestors, sczAncestors, 0); |
| 2904 | ExitOnFailure(hr, "Failed to allocate the list of ancestors."); | 3057 | ExitOnFailure(hr, "Failed to allocate the list of ancestors."); |
| 2905 | } | 3058 | } |
| @@ -2917,7 +3070,6 @@ static HRESULT OnExecuteExePackage( | |||
| 2917 | LExit: | 3070 | LExit: |
| 2918 | ReleaseStr(sczEngineWorkingDirectory); | 3071 | ReleaseStr(sczEngineWorkingDirectory); |
| 2919 | ReleaseStr(sczAncestors); | 3072 | ReleaseStr(sczAncestors); |
| 2920 | ReleaseStr(sczIgnoreDependencies); | ||
| 2921 | ReleaseStr(sczPackage); | 3073 | ReleaseStr(sczPackage); |
| 2922 | PlanUninitializeExecuteAction(&executeAction); | 3074 | PlanUninitializeExecuteAction(&executeAction); |
| 2923 | 3075 | ||
