From cede270b2bd3da6bd8d5205b8834e786c8d6c1ce Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 1 Feb 2021 18:54:54 -0600 Subject: Remove feature to uninstall compatible orphaned MSI packages. --- src/engine/msiengine.cpp | 156 ----------------------------------------------- 1 file changed, 156 deletions(-) (limited to 'src/engine/msiengine.cpp') 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( { ReleaseStr(pPackage->Msi.sczProductCode); ReleaseStr(pPackage->Msi.sczUpgradeCode); - ReleaseStr(pPackage->Msi.sczInstalledProductCode); // free features if (pPackage->Msi.rgFeatures) @@ -404,8 +403,6 @@ extern "C" HRESULT MsiEngineDetectPackage( int nCompareResult = 0; LPWSTR sczInstalledVersion = NULL; LPWSTR sczInstalledLanguage = NULL; - LPWSTR sczInstalledProductCode = NULL; - LPWSTR sczInstalledProviderKey = NULL; INSTALLSTATE installState = INSTALLSTATE_UNKNOWN; BOOTSTRAPPER_RELATED_OPERATION operation = BOOTSTRAPPER_RELATED_OPERATION_NONE; BOOTSTRAPPER_RELATED_OPERATION relatedMsiOperation = BOOTSTRAPPER_RELATED_OPERATION_NONE; @@ -457,42 +454,6 @@ extern "C" HRESULT MsiEngineDetectPackage( } else if (HRESULT_FROM_WIN32(ERROR_UNKNOWN_PRODUCT) == hr || HRESULT_FROM_WIN32(ERROR_UNKNOWN_PROPERTY) == hr) // package not present. { - // Check for newer, compatible packages based on a fixed provider key. - hr = DependencyDetectProviderKeyPackageId(pPackage, &sczInstalledProviderKey, &sczInstalledProductCode); - if (SUCCEEDED(hr)) - { - hr = WiuGetProductInfoEx(sczInstalledProductCode, NULL, pPackage->fPerMachine ? MSIINSTALLCONTEXT_MACHINE : MSIINSTALLCONTEXT_USERUNMANAGED, INSTALLPROPERTY_VERSIONSTRING, &sczInstalledVersion); - if (SUCCEEDED(hr)) - { - hr = VerParseVersion(sczInstalledVersion, 0, FALSE, &pVersion); - ExitOnFailure(hr, "Failed to parse dependency version: '%ls' for ProductCode: %ls", sczInstalledVersion, sczInstalledProductCode); - - if (pVersion->fInvalid) - { - LogId(REPORT_WARNING, MSG_DETECTED_MSI_PACKAGE_INVALID_VERSION, sczInstalledProductCode, sczInstalledVersion); - } - - // compare versions - hr = VerCompareParsedVersions(pPackage->Msi.pVersion, pVersion, &nCompareResult); - ExitOnFailure(hr, "Failed to compare version '%ls' to dependency version: '%ls'", pPackage->Msi.pVersion->sczVersion, pVersion->sczVersion); - - if (nCompareResult < 0) - { - LogId(REPORT_STANDARD, MSG_DETECTED_COMPATIBLE_PACKAGE_FROM_PROVIDER, pPackage->sczId, sczInstalledProviderKey, sczInstalledProductCode, sczInstalledVersion, pPackage->Msi.sczProductCode); - - hr = UserExperienceOnDetectCompatibleMsiPackage(pUserExperience, pPackage->sczId, sczInstalledProductCode, pVersion); - ExitOnRootFailure(hr, "BA aborted detect compatible MSI package."); - - hr = StrAllocString(&pPackage->Msi.sczInstalledProductCode, sczInstalledProductCode, 0); - ExitOnFailure(hr, "Failed to copy the installed ProductCode to the package."); - - pPackage->Msi.pInstalledVersion = pVersion; - pPackage->Msi.fCompatibleInstalled = TRUE; - pVersion = NULL; - } - } - } - pPackage->currentState = BOOTSTRAPPER_PACKAGE_STATE_ABSENT; hr = S_OK; } @@ -701,8 +662,6 @@ extern "C" HRESULT MsiEngineDetectPackage( } LExit: - ReleaseStr(sczInstalledProviderKey); - ReleaseStr(sczInstalledProductCode); ReleaseStr(sczInstalledLanguage); ReleaseStr(sczInstalledVersion); ReleaseVerutilVersion(pVersion); @@ -1023,121 +982,6 @@ LExit: return hr; } -extern "C" HRESULT MsiEngineAddCompatiblePackage( - __in BURN_PACKAGES* pPackages, - __in const BURN_PACKAGE* pPackage, - __out_opt BURN_PACKAGE** ppCompatiblePackage - ) -{ - Assert(BURN_PACKAGE_TYPE_MSI == pPackage->type); - - HRESULT hr = S_OK; - BURN_PACKAGE* pCompatiblePackage = NULL; - LPWSTR sczInstalledVersion = NULL; - - // Allocate enough memory all at once so pointers to packages within - // aren't invalidated if we otherwise reallocated. - hr = PackageEnsureCompatiblePackagesArray(pPackages); - ExitOnFailure(hr, "Failed to allocate memory for compatible MSI package."); - - pCompatiblePackage = pPackages->rgCompatiblePackages + pPackages->cCompatiblePackages; - ++pPackages->cCompatiblePackages; - - pCompatiblePackage->type = BURN_PACKAGE_TYPE_MSI; - - // Read in the compatible ProductCode if not already available. - if (pPackage->Msi.sczInstalledProductCode) - { - hr = StrAllocString(&pCompatiblePackage->Msi.sczProductCode, pPackage->Msi.sczInstalledProductCode, 0); - ExitOnFailure(hr, "Failed to copy installed ProductCode to compatible package."); - } - else - { - hr = DependencyDetectProviderKeyPackageId(pPackage, NULL, &pCompatiblePackage->Msi.sczProductCode); - ExitOnFailure(hr, "Failed to detect compatible package from provider key."); - } - - // Read in the compatible ProductVersion if not already available. - if (pPackage->Msi.pInstalledVersion) - { - hr = VerCopyVersion(pPackage->Msi.pInstalledVersion, &pCompatiblePackage->Msi.pVersion); - ExitOnFailure(hr, "Failed to copy version for compatible package."); - } - else - { - hr = WiuGetProductInfoEx(pCompatiblePackage->Msi.sczProductCode, NULL, pPackage->fPerMachine ? MSIINSTALLCONTEXT_MACHINE : MSIINSTALLCONTEXT_USERUNMANAGED, INSTALLPROPERTY_VERSIONSTRING, &sczInstalledVersion); - ExitOnFailure(hr, "Failed to read version from compatible package."); - - hr = VerParseVersion(sczInstalledVersion, 0, FALSE, &pCompatiblePackage->Msi.pVersion); - ExitOnFailure(hr, "Failed to parse version: '%ls' for ProductCode: %ls", sczInstalledVersion, pCompatiblePackage->Msi.sczProductCode); - - if (pCompatiblePackage->Msi.pVersion->fInvalid) - { - LogId(REPORT_WARNING, MSG_DETECTED_MSI_PACKAGE_INVALID_VERSION, pCompatiblePackage->Msi.sczProductCode, sczInstalledVersion); - } - } - - // For now, copy enough information to support uninstalling the newer, compatible package. - hr = StrAllocString(&pCompatiblePackage->sczId, pCompatiblePackage->Msi.sczProductCode, 0); - ExitOnFailure(hr, "Failed to copy installed ProductCode as compatible package ID."); - - pCompatiblePackage->fPerMachine = pPackage->fPerMachine; - pCompatiblePackage->fUninstallable = pPackage->fUninstallable; - pCompatiblePackage->cacheType = pPackage->cacheType; - - // Removing compatible packages is best effort. - pCompatiblePackage->fVital = FALSE; - - // Format a suitable log path variable from the original package. - hr = StrAllocFormatted(&pCompatiblePackage->sczLogPathVariable, L"%ls_Compatible", pPackage->sczLogPathVariable); - ExitOnFailure(hr, "Failed to format log path variable for compatible package."); - - // Use the default cache ID generation from the binder. - hr = StrAllocFormatted(&pCompatiblePackage->sczCacheId, L"%lsv%ls", pCompatiblePackage->sczId, pCompatiblePackage->Msi.pVersion->sczVersion); - ExitOnFailure(hr, "Failed to format cache ID for compatible package."); - - pCompatiblePackage->currentState = BOOTSTRAPPER_PACKAGE_STATE_PRESENT; - pCompatiblePackage->cache = BURN_CACHE_STATE_PARTIAL; // Cannot know if it's complete or not. - - // Copy all the providers to ensure no dependents. - if (pPackage->cDependencyProviders) - { - pCompatiblePackage->rgDependencyProviders = (BURN_DEPENDENCY_PROVIDER*)MemAlloc(sizeof(BURN_DEPENDENCY_PROVIDER) * pPackage->cDependencyProviders, TRUE); - ExitOnNull(pCompatiblePackage->rgDependencyProviders, hr, E_OUTOFMEMORY, "Failed to allocate for compatible package providers."); - - for (DWORD i = 0; i < pPackage->cDependencyProviders; ++i) - { - BURN_DEPENDENCY_PROVIDER* pProvider = pPackage->rgDependencyProviders + i; - BURN_DEPENDENCY_PROVIDER* pCompatibleProvider = pCompatiblePackage->rgDependencyProviders + i; - - // Only need to copy the key for uninstall. - hr = StrAllocString(&pCompatibleProvider->sczKey, pProvider->sczKey, 0); - ExitOnFailure(hr, "Failed to copy the compatible provider key."); - - // Assume the package version is the same as the provider version. - hr = StrAllocString(&pCompatibleProvider->sczVersion, pCompatiblePackage->Msi.pVersion->sczVersion, 0); - ExitOnFailure(hr, "Failed to copy the compatible provider version."); - - // Assume provider keys are similarly authored for this package. - pCompatibleProvider->fImported = pProvider->fImported; - } - - pCompatiblePackage->cDependencyProviders = pPackage->cDependencyProviders; - } - - pCompatiblePackage->type = BURN_PACKAGE_TYPE_MSI; - - if (ppCompatiblePackage) - { - *ppCompatiblePackage = pCompatiblePackage; - } - -LExit: - ReleaseStr(sczInstalledVersion); - - return hr; -} - extern "C" HRESULT MsiEngineBeginTransaction( __in LPCWSTR wzName ) -- cgit v1.2.3-55-g6feb