aboutsummaryrefslogtreecommitdiff
path: root/src/engine/msiengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/msiengine.cpp')
-rw-r--r--src/engine/msiengine.cpp47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/engine/msiengine.cpp b/src/engine/msiengine.cpp
index 35ca5c62..b081b9ca 100644
--- a/src/engine/msiengine.cpp
+++ b/src/engine/msiengine.cpp
@@ -1099,6 +1099,8 @@ extern "C" HRESULT MsiEngineExecutePackage(
1099 LPWSTR sczMsiPath = NULL; 1099 LPWSTR sczMsiPath = NULL;
1100 LPWSTR sczProperties = NULL; 1100 LPWSTR sczProperties = NULL;
1101 LPWSTR sczObfuscatedProperties = NULL; 1101 LPWSTR sczObfuscatedProperties = NULL;
1102 BURN_PACKAGE* pPackage = pExecuteAction->msiPackage.pPackage;
1103 BURN_PAYLOAD* pPackagePayload = pPackage->payloads.rgpPayloads[0];
1102 1104
1103 // During rollback, if the package is already in the rollback state we expect don't 1105 // During rollback, if the package is already in the rollback state we expect don't
1104 // touch it again. 1106 // touch it again.
@@ -1106,10 +1108,10 @@ extern "C" HRESULT MsiEngineExecutePackage(
1106 { 1108 {
1107 if (BOOTSTRAPPER_ACTION_STATE_UNINSTALL == pExecuteAction->msiPackage.action) 1109 if (BOOTSTRAPPER_ACTION_STATE_UNINSTALL == pExecuteAction->msiPackage.action)
1108 { 1110 {
1109 hr = WiuGetProductInfoEx(pExecuteAction->msiPackage.pPackage->Msi.sczProductCode, NULL, pExecuteAction->msiPackage.pPackage->fPerMachine ? MSIINSTALLCONTEXT_MACHINE : MSIINSTALLCONTEXT_USERUNMANAGED, INSTALLPROPERTY_VERSIONSTRING, &sczInstalledVersion); 1111 hr = WiuGetProductInfoEx(pPackage->Msi.sczProductCode, NULL, pPackage->fPerMachine ? MSIINSTALLCONTEXT_MACHINE : MSIINSTALLCONTEXT_USERUNMANAGED, INSTALLPROPERTY_VERSIONSTRING, &sczInstalledVersion);
1110 if (FAILED(hr)) // package not present. 1112 if (FAILED(hr)) // package not present.
1111 { 1113 {
1112 LogId(REPORT_STANDARD, MSG_ROLLBACK_PACKAGE_SKIPPED, pExecuteAction->msiPackage.pPackage->sczId, LoggingActionStateToString(pExecuteAction->msiPackage.action), LoggingPackageStateToString(BOOTSTRAPPER_PACKAGE_STATE_ABSENT)); 1114 LogId(REPORT_STANDARD, MSG_ROLLBACK_PACKAGE_SKIPPED, pPackage->sczId, LoggingActionStateToString(pExecuteAction->msiPackage.action), LoggingPackageStateToString(BOOTSTRAPPER_PACKAGE_STATE_ABSENT));
1113 1115
1114 hr = S_OK; 1116 hr = S_OK;
1115 ExitFunction(); 1117 ExitFunction();
@@ -1117,10 +1119,10 @@ extern "C" HRESULT MsiEngineExecutePackage(
1117 } 1119 }
1118 else if (BOOTSTRAPPER_ACTION_STATE_INSTALL == pExecuteAction->msiPackage.action) 1120 else if (BOOTSTRAPPER_ACTION_STATE_INSTALL == pExecuteAction->msiPackage.action)
1119 { 1121 {
1120 hr = WiuGetProductInfoEx(pExecuteAction->msiPackage.pPackage->Msi.sczProductCode, NULL, pExecuteAction->msiPackage.pPackage->fPerMachine ? MSIINSTALLCONTEXT_MACHINE : MSIINSTALLCONTEXT_USERUNMANAGED, INSTALLPROPERTY_VERSIONSTRING, &sczInstalledVersion); 1122 hr = WiuGetProductInfoEx(pPackage->Msi.sczProductCode, NULL, pPackage->fPerMachine ? MSIINSTALLCONTEXT_MACHINE : MSIINSTALLCONTEXT_USERUNMANAGED, INSTALLPROPERTY_VERSIONSTRING, &sczInstalledVersion);
1121 if (SUCCEEDED(hr)) // package present. 1123 if (SUCCEEDED(hr)) // package present.
1122 { 1124 {
1123 LogId(REPORT_STANDARD, MSG_ROLLBACK_PACKAGE_SKIPPED, pExecuteAction->msiPackage.pPackage->sczId, LoggingActionStateToString(pExecuteAction->msiPackage.action), LoggingPackageStateToString(BOOTSTRAPPER_PACKAGE_STATE_PRESENT)); 1125 LogId(REPORT_STANDARD, MSG_ROLLBACK_PACKAGE_SKIPPED, pPackage->sczId, LoggingActionStateToString(pExecuteAction->msiPackage.action), LoggingPackageStateToString(BOOTSTRAPPER_PACKAGE_STATE_PRESENT));
1124 1126
1125 hr = S_OK; 1127 hr = S_OK;
1126 ExitFunction(); 1128 ExitFunction();
@@ -1141,13 +1143,13 @@ extern "C" HRESULT MsiEngineExecutePackage(
1141 if (BOOTSTRAPPER_ACTION_STATE_UNINSTALL != pExecuteAction->msiPackage.action) 1143 if (BOOTSTRAPPER_ACTION_STATE_UNINSTALL != pExecuteAction->msiPackage.action)
1142 { 1144 {
1143 // get cached MSI path 1145 // get cached MSI path
1144 hr = CacheGetCompletedPath(pExecuteAction->msiPackage.pPackage->fPerMachine, pExecuteAction->msiPackage.pPackage->sczCacheId, &sczCachedDirectory); 1146 hr = CacheGetCompletedPath(pPackage->fPerMachine, pPackage->sczCacheId, &sczCachedDirectory);
1145 ExitOnFailure(hr, "Failed to get cached path for package: %ls", pExecuteAction->msiPackage.pPackage->sczId); 1147 ExitOnFailure(hr, "Failed to get cached path for package: %ls", pPackage->sczId);
1146 1148
1147 // Best effort to set the execute package cache folder variable. 1149 // Best effort to set the execute package cache folder variable.
1148 VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, sczCachedDirectory, TRUE, FALSE); 1150 VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, sczCachedDirectory, TRUE, FALSE);
1149 1151
1150 hr = PathConcat(sczCachedDirectory, pExecuteAction->msiPackage.pPackage->rgPayloads[0].pPayload->sczFilePath, &sczMsiPath); 1152 hr = PathConcat(sczCachedDirectory, pPackagePayload->sczFilePath, &sczMsiPath);
1151 ExitOnFailure(hr, "Failed to build MSI path."); 1153 ExitOnFailure(hr, "Failed to build MSI path.");
1152 } 1154 }
1153 1155
@@ -1169,28 +1171,28 @@ extern "C" HRESULT MsiEngineExecutePackage(
1169 if (pExecuteAction->msiPackage.sczLogPath && *pExecuteAction->msiPackage.sczLogPath) 1171 if (pExecuteAction->msiPackage.sczLogPath && *pExecuteAction->msiPackage.sczLogPath)
1170 { 1172 {
1171 hr = WiuEnableLog(dwLogMode, pExecuteAction->msiPackage.sczLogPath, 0); 1173 hr = WiuEnableLog(dwLogMode, pExecuteAction->msiPackage.sczLogPath, 0);
1172 ExitOnFailure(hr, "Failed to enable logging for package: %ls to: %ls", pExecuteAction->msiPackage.pPackage->sczId, pExecuteAction->msiPackage.sczLogPath); 1174 ExitOnFailure(hr, "Failed to enable logging for package: %ls to: %ls", pPackage->sczId, pExecuteAction->msiPackage.sczLogPath);
1173 } 1175 }
1174 1176
1175 // set up properties 1177 // set up properties
1176 hr = MsiEngineConcatProperties(pExecuteAction->msiPackage.pPackage->Msi.rgProperties, pExecuteAction->msiPackage.pPackage->Msi.cProperties, pVariables, fRollback, &sczProperties, FALSE); 1178 hr = MsiEngineConcatProperties(pPackage->Msi.rgProperties, pPackage->Msi.cProperties, pVariables, fRollback, &sczProperties, FALSE);
1177 ExitOnFailure(hr, "Failed to add properties to argument string."); 1179 ExitOnFailure(hr, "Failed to add properties to argument string.");
1178 1180
1179 hr = MsiEngineConcatProperties(pExecuteAction->msiPackage.pPackage->Msi.rgProperties, pExecuteAction->msiPackage.pPackage->Msi.cProperties, pVariables, fRollback, &sczObfuscatedProperties, TRUE); 1181 hr = MsiEngineConcatProperties(pPackage->Msi.rgProperties, pPackage->Msi.cProperties, pVariables, fRollback, &sczObfuscatedProperties, TRUE);
1180 ExitOnFailure(hr, "Failed to add obfuscated properties to argument string."); 1182 ExitOnFailure(hr, "Failed to add obfuscated properties to argument string.");
1181 1183
1182 // add feature action properties 1184 // add feature action properties
1183 hr = ConcatFeatureActionProperties(pExecuteAction->msiPackage.pPackage, pExecuteAction->msiPackage.rgFeatures, &sczProperties); 1185 hr = ConcatFeatureActionProperties(pPackage, pExecuteAction->msiPackage.rgFeatures, &sczProperties);
1184 ExitOnFailure(hr, "Failed to add feature action properties to argument string."); 1186 ExitOnFailure(hr, "Failed to add feature action properties to argument string.");
1185 1187
1186 hr = ConcatFeatureActionProperties(pExecuteAction->msiPackage.pPackage, pExecuteAction->msiPackage.rgFeatures, &sczObfuscatedProperties); 1188 hr = ConcatFeatureActionProperties(pPackage, pExecuteAction->msiPackage.rgFeatures, &sczObfuscatedProperties);
1187 ExitOnFailure(hr, "Failed to add feature action properties to obfuscated argument string."); 1189 ExitOnFailure(hr, "Failed to add feature action properties to obfuscated argument string.");
1188 1190
1189 // add slipstream patch properties 1191 // add slipstream patch properties
1190 hr = ConcatPatchProperty(pExecuteAction->msiPackage.pPackage, fRollback, &sczProperties); 1192 hr = ConcatPatchProperty(pPackage, fRollback, &sczProperties);
1191 ExitOnFailure(hr, "Failed to add patch properties to argument string."); 1193 ExitOnFailure(hr, "Failed to add patch properties to argument string.");
1192 1194
1193 hr = ConcatPatchProperty(pExecuteAction->msiPackage.pPackage, fRollback, &sczObfuscatedProperties); 1195 hr = ConcatPatchProperty(pPackage, fRollback, &sczObfuscatedProperties);
1194 ExitOnFailure(hr, "Failed to add patch properties to obfuscated argument string."); 1196 ExitOnFailure(hr, "Failed to add patch properties to obfuscated argument string.");
1195 1197
1196 hr = MsiEngineConcatActionProperty(pExecuteAction->msiPackage.actionMsiProperty, &sczProperties); 1198 hr = MsiEngineConcatActionProperty(pExecuteAction->msiPackage.actionMsiProperty, &sczProperties);
@@ -1199,7 +1201,7 @@ extern "C" HRESULT MsiEngineExecutePackage(
1199 hr = MsiEngineConcatActionProperty(pExecuteAction->msiPackage.actionMsiProperty, &sczObfuscatedProperties); 1201 hr = MsiEngineConcatActionProperty(pExecuteAction->msiPackage.actionMsiProperty, &sczObfuscatedProperties);
1200 ExitOnFailure(hr, "Failed to add action property to obfuscated argument string."); 1202 ExitOnFailure(hr, "Failed to add action property to obfuscated argument string.");
1201 1203
1202 LogId(REPORT_STANDARD, MSG_APPLYING_PACKAGE, LoggingRollbackOrExecute(fRollback), pExecuteAction->msiPackage.pPackage->sczId, LoggingActionStateToString(pExecuteAction->msiPackage.action), sczMsiPath, sczObfuscatedProperties ? sczObfuscatedProperties : L""); 1204 LogId(REPORT_STANDARD, MSG_APPLYING_PACKAGE, LoggingRollbackOrExecute(fRollback), pPackage->sczId, LoggingActionStateToString(pExecuteAction->msiPackage.action), sczMsiPath, sczObfuscatedProperties ? sczObfuscatedProperties : L"");
1203 1205
1204 // 1206 //
1205 // Do the actual action. 1207 // Do the actual action.
@@ -1213,13 +1215,13 @@ extern "C" HRESULT MsiEngineExecutePackage(
1213 hr = WiuInstallProduct(sczMsiPath, sczProperties, &restart); 1215 hr = WiuInstallProduct(sczMsiPath, sczProperties, &restart);
1214 ExitOnFailure(hr, "Failed to install MSI package."); 1216 ExitOnFailure(hr, "Failed to install MSI package.");
1215 1217
1216 RegisterSourceDirectory(pExecuteAction->msiPackage.pPackage, sczMsiPath); 1218 RegisterSourceDirectory(pPackage, sczMsiPath);
1217 break; 1219 break;
1218 1220
1219 case BOOTSTRAPPER_ACTION_STATE_MINOR_UPGRADE: 1221 case BOOTSTRAPPER_ACTION_STATE_MINOR_UPGRADE:
1220 // If feature selection is not enabled, then reinstall the existing features to ensure they get 1222 // If feature selection is not enabled, then reinstall the existing features to ensure they get
1221 // updated. 1223 // updated.
1222 if (0 == pExecuteAction->msiPackage.pPackage->Msi.cFeatures) 1224 if (0 == pPackage->Msi.cFeatures)
1223 { 1225 {
1224 hr = StrAllocConcatSecure(&sczProperties, L" REINSTALL=ALL", 0); 1226 hr = StrAllocConcatSecure(&sczProperties, L" REINSTALL=ALL", 0);
1225 ExitOnFailure(hr, "Failed to add reinstall all property on minor upgrade."); 1227 ExitOnFailure(hr, "Failed to add reinstall all property on minor upgrade.");
@@ -1231,7 +1233,7 @@ extern "C" HRESULT MsiEngineExecutePackage(
1231 hr = WiuInstallProduct(sczMsiPath, sczProperties, &restart); 1233 hr = WiuInstallProduct(sczMsiPath, sczProperties, &restart);
1232 ExitOnFailure(hr, "Failed to perform minor upgrade of MSI package."); 1234 ExitOnFailure(hr, "Failed to perform minor upgrade of MSI package.");
1233 1235
1234 RegisterSourceDirectory(pExecuteAction->msiPackage.pPackage, sczMsiPath); 1236 RegisterSourceDirectory(pPackage, sczMsiPath);
1235 break; 1237 break;
1236 1238
1237 case BOOTSTRAPPER_ACTION_STATE_MODIFY: __fallthrough; 1239 case BOOTSTRAPPER_ACTION_STATE_MODIFY: __fallthrough;
@@ -1239,7 +1241,7 @@ extern "C" HRESULT MsiEngineExecutePackage(
1239 case BOOTSTRAPPER_ACTION_STATE_REPAIR: 1241 case BOOTSTRAPPER_ACTION_STATE_REPAIR:
1240 { 1242 {
1241 LPCWSTR wzReinstallAll = (BOOTSTRAPPER_ACTION_STATE_MODIFY == pExecuteAction->msiPackage.action || 1243 LPCWSTR wzReinstallAll = (BOOTSTRAPPER_ACTION_STATE_MODIFY == pExecuteAction->msiPackage.action ||
1242 pExecuteAction->msiPackage.pPackage->Msi.cFeatures) ? L"" : L" REINSTALL=ALL"; 1244 pPackage->Msi.cFeatures) ? L"" : L" REINSTALL=ALL";
1243 LPCWSTR wzReinstallMode = (BOOTSTRAPPER_ACTION_STATE_MODIFY == pExecuteAction->msiPackage.action || BOOTSTRAPPER_ACTION_STATE_MEND == pExecuteAction->msiPackage.action) ? L"o" : L"e"; 1245 LPCWSTR wzReinstallMode = (BOOTSTRAPPER_ACTION_STATE_MODIFY == pExecuteAction->msiPackage.action || BOOTSTRAPPER_ACTION_STATE_MEND == pExecuteAction->msiPackage.action) ? L"o" : L"e";
1244 1246
1245 hr = StrAllocFormattedSecure(&sczProperties, L"%ls%ls REINSTALLMODE=\"cmus%ls\" REBOOT=ReallySuppress", sczProperties ? sczProperties : L"", wzReinstallAll, wzReinstallMode); 1247 hr = StrAllocFormattedSecure(&sczProperties, L"%ls%ls REINSTALLMODE=\"cmus%ls\" REBOOT=ReallySuppress", sczProperties ? sczProperties : L"", wzReinstallAll, wzReinstallMode);
@@ -1262,10 +1264,10 @@ extern "C" HRESULT MsiEngineExecutePackage(
1262 hr = StrAllocFormattedSecure(&sczProperties, L"%ls %ls=ALL", sczProperties, DEPENDENCY_IGNOREDEPENDENCIES); 1264 hr = StrAllocFormattedSecure(&sczProperties, L"%ls %ls=ALL", sczProperties, DEPENDENCY_IGNOREDEPENDENCIES);
1263 ExitOnFailure(hr, "Failed to add the list of dependencies to ignore to the properties."); 1265 ExitOnFailure(hr, "Failed to add the list of dependencies to ignore to the properties.");
1264 1266
1265 hr = WiuConfigureProductEx(pExecuteAction->msiPackage.pPackage->Msi.sczProductCode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT, sczProperties, &restart); 1267 hr = WiuConfigureProductEx(pPackage->Msi.sczProductCode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT, sczProperties, &restart);
1266 if (HRESULT_FROM_WIN32(ERROR_UNKNOWN_PRODUCT) == hr) 1268 if (HRESULT_FROM_WIN32(ERROR_UNKNOWN_PRODUCT) == hr)
1267 { 1269 {
1268 LogId(REPORT_STANDARD, MSG_ATTEMPTED_UNINSTALL_ABSENT_PACKAGE, pExecuteAction->msiPackage.pPackage->sczId); 1270 LogId(REPORT_STANDARD, MSG_ATTEMPTED_UNINSTALL_ABSENT_PACKAGE, pPackage->sczId);
1269 hr = S_OK; 1271 hr = S_OK;
1270 } 1272 }
1271 ExitOnFailure(hr, "Failed to uninstall MSI package."); 1273 ExitOnFailure(hr, "Failed to uninstall MSI package.");
@@ -1979,6 +1981,7 @@ static HRESULT ConcatPatchProperty(
1979 { 1981 {
1980 BURN_SLIPSTREAM_MSP* pSlipstreamMsp = pPackage->Msi.rgSlipstreamMsps + i; 1982 BURN_SLIPSTREAM_MSP* pSlipstreamMsp = pPackage->Msi.rgSlipstreamMsps + i;
1981 BURN_PACKAGE* pMspPackage = pSlipstreamMsp->pMspPackage; 1983 BURN_PACKAGE* pMspPackage = pSlipstreamMsp->pMspPackage;
1984 BURN_PAYLOAD* pMspPackagePayload = pMspPackage->payloads.rgpPayloads[0];
1982 BOOTSTRAPPER_ACTION_STATE patchExecuteAction = fRollback ? pSlipstreamMsp->rollback : pSlipstreamMsp->execute; 1985 BOOTSTRAPPER_ACTION_STATE patchExecuteAction = fRollback ? pSlipstreamMsp->rollback : pSlipstreamMsp->execute;
1983 1986
1984 if (BOOTSTRAPPER_ACTION_STATE_UNINSTALL < patchExecuteAction) 1987 if (BOOTSTRAPPER_ACTION_STATE_UNINSTALL < patchExecuteAction)
@@ -1986,7 +1989,7 @@ static HRESULT ConcatPatchProperty(
1986 hr = CacheGetCompletedPath(pMspPackage->fPerMachine, pMspPackage->sczCacheId, &sczCachedDirectory); 1989 hr = CacheGetCompletedPath(pMspPackage->fPerMachine, pMspPackage->sczCacheId, &sczCachedDirectory);
1987 ExitOnFailure(hr, "Failed to get cached path for MSP package: %ls", pMspPackage->sczId); 1990 ExitOnFailure(hr, "Failed to get cached path for MSP package: %ls", pMspPackage->sczId);
1988 1991
1989 hr = PathConcat(sczCachedDirectory, pMspPackage->rgPayloads[0].pPayload->sczFilePath, &sczMspPath); 1992 hr = PathConcat(sczCachedDirectory, pMspPackagePayload->sczFilePath, &sczMspPath);
1990 ExitOnFailure(hr, "Failed to build MSP path."); 1993 ExitOnFailure(hr, "Failed to build MSP path.");
1991 1994
1992 if (!sczPatches) 1995 if (!sczPatches)