aboutsummaryrefslogtreecommitdiff
path: root/src/engine/msiengine.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-02-01 18:54:54 -0600
committerSean Hall <r.sean.hall@gmail.com>2021-02-04 22:16:10 -0600
commitcede270b2bd3da6bd8d5205b8834e786c8d6c1ce (patch)
treefc37ad41e0a03f67fc2a8946231e519551cdcc95 /src/engine/msiengine.cpp
parentf1f1a124df59e8639c2bcbfa7d3a4b37fb348bb7 (diff)
downloadwix-cede270b2bd3da6bd8d5205b8834e786c8d6c1ce.tar.gz
wix-cede270b2bd3da6bd8d5205b8834e786c8d6c1ce.tar.bz2
wix-cede270b2bd3da6bd8d5205b8834e786c8d6c1ce.zip
Remove feature to uninstall compatible orphaned MSI packages.
Diffstat (limited to 'src/engine/msiengine.cpp')
-rw-r--r--src/engine/msiengine.cpp156
1 files changed, 0 insertions, 156 deletions
diff --git a/src/engine/msiengine.cpp b/src/engine/msiengine.cpp
index 688be7af..5bccb375 100644
--- a/src/engine/msiengine.cpp
+++ b/src/engine/msiengine.cpp
@@ -325,7 +325,6 @@ extern "C" void MsiEnginePackageUninitialize(
325{ 325{
326 ReleaseStr(pPackage->Msi.sczProductCode); 326 ReleaseStr(pPackage->Msi.sczProductCode);
327 ReleaseStr(pPackage->Msi.sczUpgradeCode); 327 ReleaseStr(pPackage->Msi.sczUpgradeCode);
328 ReleaseStr(pPackage->Msi.sczInstalledProductCode);
329 328
330 // free features 329 // free features
331 if (pPackage->Msi.rgFeatures) 330 if (pPackage->Msi.rgFeatures)
@@ -404,8 +403,6 @@ extern "C" HRESULT MsiEngineDetectPackage(
404 int nCompareResult = 0; 403 int nCompareResult = 0;
405 LPWSTR sczInstalledVersion = NULL; 404 LPWSTR sczInstalledVersion = NULL;
406 LPWSTR sczInstalledLanguage = NULL; 405 LPWSTR sczInstalledLanguage = NULL;
407 LPWSTR sczInstalledProductCode = NULL;
408 LPWSTR sczInstalledProviderKey = NULL;
409 INSTALLSTATE installState = INSTALLSTATE_UNKNOWN; 406 INSTALLSTATE installState = INSTALLSTATE_UNKNOWN;
410 BOOTSTRAPPER_RELATED_OPERATION operation = BOOTSTRAPPER_RELATED_OPERATION_NONE; 407 BOOTSTRAPPER_RELATED_OPERATION operation = BOOTSTRAPPER_RELATED_OPERATION_NONE;
411 BOOTSTRAPPER_RELATED_OPERATION relatedMsiOperation = BOOTSTRAPPER_RELATED_OPERATION_NONE; 408 BOOTSTRAPPER_RELATED_OPERATION relatedMsiOperation = BOOTSTRAPPER_RELATED_OPERATION_NONE;
@@ -457,42 +454,6 @@ extern "C" HRESULT MsiEngineDetectPackage(
457 } 454 }
458 else if (HRESULT_FROM_WIN32(ERROR_UNKNOWN_PRODUCT) == hr || HRESULT_FROM_WIN32(ERROR_UNKNOWN_PROPERTY) == hr) // package not present. 455 else if (HRESULT_FROM_WIN32(ERROR_UNKNOWN_PRODUCT) == hr || HRESULT_FROM_WIN32(ERROR_UNKNOWN_PROPERTY) == hr) // package not present.
459 { 456 {
460 // Check for newer, compatible packages based on a fixed provider key.
461 hr = DependencyDetectProviderKeyPackageId(pPackage, &sczInstalledProviderKey, &sczInstalledProductCode);
462 if (SUCCEEDED(hr))
463 {
464 hr = WiuGetProductInfoEx(sczInstalledProductCode, NULL, pPackage->fPerMachine ? MSIINSTALLCONTEXT_MACHINE : MSIINSTALLCONTEXT_USERUNMANAGED, INSTALLPROPERTY_VERSIONSTRING, &sczInstalledVersion);
465 if (SUCCEEDED(hr))
466 {
467 hr = VerParseVersion(sczInstalledVersion, 0, FALSE, &pVersion);
468 ExitOnFailure(hr, "Failed to parse dependency version: '%ls' for ProductCode: %ls", sczInstalledVersion, sczInstalledProductCode);
469
470 if (pVersion->fInvalid)
471 {
472 LogId(REPORT_WARNING, MSG_DETECTED_MSI_PACKAGE_INVALID_VERSION, sczInstalledProductCode, sczInstalledVersion);
473 }
474
475 // compare versions
476 hr = VerCompareParsedVersions(pPackage->Msi.pVersion, pVersion, &nCompareResult);
477 ExitOnFailure(hr, "Failed to compare version '%ls' to dependency version: '%ls'", pPackage->Msi.pVersion->sczVersion, pVersion->sczVersion);
478
479 if (nCompareResult < 0)
480 {
481 LogId(REPORT_STANDARD, MSG_DETECTED_COMPATIBLE_PACKAGE_FROM_PROVIDER, pPackage->sczId, sczInstalledProviderKey, sczInstalledProductCode, sczInstalledVersion, pPackage->Msi.sczProductCode);
482
483 hr = UserExperienceOnDetectCompatibleMsiPackage(pUserExperience, pPackage->sczId, sczInstalledProductCode, pVersion);
484 ExitOnRootFailure(hr, "BA aborted detect compatible MSI package.");
485
486 hr = StrAllocString(&pPackage->Msi.sczInstalledProductCode, sczInstalledProductCode, 0);
487 ExitOnFailure(hr, "Failed to copy the installed ProductCode to the package.");
488
489 pPackage->Msi.pInstalledVersion = pVersion;
490 pPackage->Msi.fCompatibleInstalled = TRUE;
491 pVersion = NULL;
492 }
493 }
494 }
495
496 pPackage->currentState = BOOTSTRAPPER_PACKAGE_STATE_ABSENT; 457 pPackage->currentState = BOOTSTRAPPER_PACKAGE_STATE_ABSENT;
497 hr = S_OK; 458 hr = S_OK;
498 } 459 }
@@ -701,8 +662,6 @@ extern "C" HRESULT MsiEngineDetectPackage(
701 } 662 }
702 663
703LExit: 664LExit:
704 ReleaseStr(sczInstalledProviderKey);
705 ReleaseStr(sczInstalledProductCode);
706 ReleaseStr(sczInstalledLanguage); 665 ReleaseStr(sczInstalledLanguage);
707 ReleaseStr(sczInstalledVersion); 666 ReleaseStr(sczInstalledVersion);
708 ReleaseVerutilVersion(pVersion); 667 ReleaseVerutilVersion(pVersion);
@@ -1023,121 +982,6 @@ LExit:
1023 return hr; 982 return hr;
1024} 983}
1025 984
1026extern "C" HRESULT MsiEngineAddCompatiblePackage(
1027 __in BURN_PACKAGES* pPackages,
1028 __in const BURN_PACKAGE* pPackage,
1029 __out_opt BURN_PACKAGE** ppCompatiblePackage
1030 )
1031{
1032 Assert(BURN_PACKAGE_TYPE_MSI == pPackage->type);
1033
1034 HRESULT hr = S_OK;
1035 BURN_PACKAGE* pCompatiblePackage = NULL;
1036 LPWSTR sczInstalledVersion = NULL;
1037
1038 // Allocate enough memory all at once so pointers to packages within
1039 // aren't invalidated if we otherwise reallocated.
1040 hr = PackageEnsureCompatiblePackagesArray(pPackages);
1041 ExitOnFailure(hr, "Failed to allocate memory for compatible MSI package.");
1042
1043 pCompatiblePackage = pPackages->rgCompatiblePackages + pPackages->cCompatiblePackages;
1044 ++pPackages->cCompatiblePackages;
1045
1046 pCompatiblePackage->type = BURN_PACKAGE_TYPE_MSI;
1047
1048 // Read in the compatible ProductCode if not already available.
1049 if (pPackage->Msi.sczInstalledProductCode)
1050 {
1051 hr = StrAllocString(&pCompatiblePackage->Msi.sczProductCode, pPackage->Msi.sczInstalledProductCode, 0);
1052 ExitOnFailure(hr, "Failed to copy installed ProductCode to compatible package.");
1053 }
1054 else
1055 {
1056 hr = DependencyDetectProviderKeyPackageId(pPackage, NULL, &pCompatiblePackage->Msi.sczProductCode);
1057 ExitOnFailure(hr, "Failed to detect compatible package from provider key.");
1058 }
1059
1060 // Read in the compatible ProductVersion if not already available.
1061 if (pPackage->Msi.pInstalledVersion)
1062 {
1063 hr = VerCopyVersion(pPackage->Msi.pInstalledVersion, &pCompatiblePackage->Msi.pVersion);
1064 ExitOnFailure(hr, "Failed to copy version for compatible package.");
1065 }
1066 else
1067 {
1068 hr = WiuGetProductInfoEx(pCompatiblePackage->Msi.sczProductCode, NULL, pPackage->fPerMachine ? MSIINSTALLCONTEXT_MACHINE : MSIINSTALLCONTEXT_USERUNMANAGED, INSTALLPROPERTY_VERSIONSTRING, &sczInstalledVersion);
1069 ExitOnFailure(hr, "Failed to read version from compatible package.");
1070
1071 hr = VerParseVersion(sczInstalledVersion, 0, FALSE, &pCompatiblePackage->Msi.pVersion);
1072 ExitOnFailure(hr, "Failed to parse version: '%ls' for ProductCode: %ls", sczInstalledVersion, pCompatiblePackage->Msi.sczProductCode);
1073
1074 if (pCompatiblePackage->Msi.pVersion->fInvalid)
1075 {
1076 LogId(REPORT_WARNING, MSG_DETECTED_MSI_PACKAGE_INVALID_VERSION, pCompatiblePackage->Msi.sczProductCode, sczInstalledVersion);
1077 }
1078 }
1079
1080 // For now, copy enough information to support uninstalling the newer, compatible package.
1081 hr = StrAllocString(&pCompatiblePackage->sczId, pCompatiblePackage->Msi.sczProductCode, 0);
1082 ExitOnFailure(hr, "Failed to copy installed ProductCode as compatible package ID.");
1083
1084 pCompatiblePackage->fPerMachine = pPackage->fPerMachine;
1085 pCompatiblePackage->fUninstallable = pPackage->fUninstallable;
1086 pCompatiblePackage->cacheType = pPackage->cacheType;
1087
1088 // Removing compatible packages is best effort.
1089 pCompatiblePackage->fVital = FALSE;
1090
1091 // Format a suitable log path variable from the original package.
1092 hr = StrAllocFormatted(&pCompatiblePackage->sczLogPathVariable, L"%ls_Compatible", pPackage->sczLogPathVariable);
1093 ExitOnFailure(hr, "Failed to format log path variable for compatible package.");
1094
1095 // Use the default cache ID generation from the binder.
1096 hr = StrAllocFormatted(&pCompatiblePackage->sczCacheId, L"%lsv%ls", pCompatiblePackage->sczId, pCompatiblePackage->Msi.pVersion->sczVersion);
1097 ExitOnFailure(hr, "Failed to format cache ID for compatible package.");
1098
1099 pCompatiblePackage->currentState = BOOTSTRAPPER_PACKAGE_STATE_PRESENT;
1100 pCompatiblePackage->cache = BURN_CACHE_STATE_PARTIAL; // Cannot know if it's complete or not.
1101
1102 // Copy all the providers to ensure no dependents.
1103 if (pPackage->cDependencyProviders)
1104 {
1105 pCompatiblePackage->rgDependencyProviders = (BURN_DEPENDENCY_PROVIDER*)MemAlloc(sizeof(BURN_DEPENDENCY_PROVIDER) * pPackage->cDependencyProviders, TRUE);
1106 ExitOnNull(pCompatiblePackage->rgDependencyProviders, hr, E_OUTOFMEMORY, "Failed to allocate for compatible package providers.");
1107
1108 for (DWORD i = 0; i < pPackage->cDependencyProviders; ++i)
1109 {
1110 BURN_DEPENDENCY_PROVIDER* pProvider = pPackage->rgDependencyProviders + i;
1111 BURN_DEPENDENCY_PROVIDER* pCompatibleProvider = pCompatiblePackage->rgDependencyProviders + i;
1112
1113 // Only need to copy the key for uninstall.
1114 hr = StrAllocString(&pCompatibleProvider->sczKey, pProvider->sczKey, 0);
1115 ExitOnFailure(hr, "Failed to copy the compatible provider key.");
1116
1117 // Assume the package version is the same as the provider version.
1118 hr = StrAllocString(&pCompatibleProvider->sczVersion, pCompatiblePackage->Msi.pVersion->sczVersion, 0);
1119 ExitOnFailure(hr, "Failed to copy the compatible provider version.");
1120
1121 // Assume provider keys are similarly authored for this package.
1122 pCompatibleProvider->fImported = pProvider->fImported;
1123 }
1124
1125 pCompatiblePackage->cDependencyProviders = pPackage->cDependencyProviders;
1126 }
1127
1128 pCompatiblePackage->type = BURN_PACKAGE_TYPE_MSI;
1129
1130 if (ppCompatiblePackage)
1131 {
1132 *ppCompatiblePackage = pCompatiblePackage;
1133 }
1134
1135LExit:
1136 ReleaseStr(sczInstalledVersion);
1137
1138 return hr;
1139}
1140
1141extern "C" HRESULT MsiEngineBeginTransaction( 985extern "C" HRESULT MsiEngineBeginTransaction(
1142 __in LPCWSTR wzName 986 __in LPCWSTR wzName
1143 ) 987 )