@joebigelow / wix / commits / 84a1b0f8

Add BURN_PROTOCOL_VERSION in registration to avoid version checks. Also, old versions of Burn should ignore ancestors if they doesn't support them.

Add BURN_PROTOCOL_VERSION in registration to avoid version checks. Also, old versions of Burn should ignore ancestors if they doesn't support them.

Sean Hall committed Dec 30, 2021 at 15:12 UTC 84a1b0f8ffe40a26916b1dfb3e1b59b6b0c31ad4
8 files changed +33 -16
src/burn/engine/inc/engine.h
+2
@@ -9,6 +9,8 @@
9 #define BURN_SECTION_MAGIC 0x00f14300
10 #define BURN_SECTION_VERSION 0x00000002
11
12 +// This needs to be incremented whenever a breaking change is made to the Burn protocol.
13 +#define BURN_PROTOCOL_VERSION 1
14
15 #if defined(__cplusplus)
16 extern "C" {
src/burn/engine/pipe.cpp
+1
@@ -710,6 +710,7 @@ static HRESULT ChildPipeConnected(
710 }
711
712 // All is well, tell the parent process.
713 + // TODO: consider sending BURN_PROTOCOL_VERSION as a way to verify compatibility.
714 hr = FileWriteHandle(hPipe, reinterpret_cast<LPCBYTE>(&dwAck), sizeof(dwAck));
715 ExitOnFailure(hr, "Failed to inform parent process that child is running.");
716
src/burn/engine/pseudobundle.cpp
+5 -8
@@ -4,8 +4,8 @@
4
5
6 extern "C" HRESULT PseudoBundleInitialize(
7 - __in DWORD64 qwEngineVersion,
7 __in BURN_PACKAGE* pPackage,
8 + __in BOOL fSupportsBurnProtocol,
9 __in BOOL fPerMachine,
10 __in_z LPCWSTR wzId,
11 __in BOOTSTRAPPER_RELATION_TYPE relationType,
@@ -84,6 +84,9 @@ extern "C" HRESULT PseudoBundleInitialize(
84 pPackage->qwSize = qwSize;
85 pPackage->fVital = fVital;
86
87 + pPackage->Exe.protocol = fSupportsBurnProtocol ? BURN_EXE_PROTOCOL_TYPE_BURN : BURN_EXE_PROTOCOL_TYPE_NONE;
88 + pPackage->Exe.fSupportsAncestors = TRUE;
89 +
90 hr = StrAllocString(&pPackage->sczId, wzId, 0);
91 ExitOnFailure(hr, "Failed to copy key for pseudo bundle.");
92
@@ -131,12 +134,6 @@ extern "C" HRESULT PseudoBundleInitialize(
134 pPackage->fUninstallable = TRUE;
135 }
136
134 - // Only support progress from engines that are compatible (aka: version greater than or equal to last protocol breaking change *and* versions that are older or the same as this engine).
135 - pPackage->Exe.protocol = (FILEMAKEVERSION(3, 6, 2221, 0) <= qwEngineVersion && qwEngineVersion <= FILEMAKEVERSION(rmj, rmm, rup, rpr)) ? BURN_EXE_PROTOCOL_TYPE_BURN : BURN_EXE_PROTOCOL_TYPE_NONE;
136 -
137 - // All versions of Burn past v3.9 RTM support suppressing ancestors.
138 - pPackage->Exe.fSupportsAncestors = FILEMAKEVERSION(3, 9, 1006, 0) <= qwEngineVersion;
139 -
137 if (pDependencyProvider)
138 {
139 pPackage->rgDependencyProviders = (BURN_DEPENDENCY_PROVIDER*)MemAlloc(sizeof(BURN_DEPENDENCY_PROVIDER), TRUE);
@@ -310,7 +307,7 @@ extern "C" HRESULT PseudoBundleInitializeUpdateBundle(
307 hr = StrAllocString(&pPackage->Exe.sczInstallArguments, wzInstallArguments, 0);
308 ExitOnFailure(hr, "Failed to copy install arguments for update bundle package");
309
313 - // Assume the update bundle has the same engine version as this one.
310 + // Trust the BA to only use UPDATE_REPLACE_EMBEDDED when appropriate.
311 pPackage->Exe.protocol = BURN_EXE_PROTOCOL_TYPE_BURN;
312 pPackage->Exe.fSupportsAncestors = TRUE;
313
src/burn/engine/pseudobundle.h
+1 -1
@@ -7,8 +7,8 @@ extern "C" {
7 #endif
8
9 HRESULT PseudoBundleInitialize(
10 - __in DWORD64 qwEngineVersion,
10 __in BURN_PACKAGE* pPackage,
11 + __in BOOL fSupportsBurnProtocol,
12 __in BOOL fPerMachine,
13 __in_z LPCWSTR wzId,
14 __in BOOTSTRAPPER_RELATION_TYPE relationType,
src/burn/engine/registration.cpp
+3
@@ -671,6 +671,9 @@ extern "C" HRESULT RegistrationSessionBegin(
671 hr = RegWriteStringFormatted(hkRegistration, BURN_REGISTRATION_REGISTRY_ENGINE_VERSION, L"%hs", szVerMajorMinorBuild);
672 ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_ENGINE_VERSION);
673
674 + hr = RegWriteNumber(hkRegistration, BURN_REGISTRATION_REGISTRY_ENGINE_PROTOCOL_VERSION, BURN_PROTOCOL_VERSION);
675 + ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_ENGINE_PROTOCOL_VERSION);
676 +
677 // DisplayIcon: [path to exe] and ",0" to refer to the first icon in the executable.
678 hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_DISPLAY_ICON, L"%s,0", pRegistration->sczCacheExecutablePath);
679 ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_DISPLAY_ICON);
src/burn/engine/registration.h
+1
@@ -23,6 +23,7 @@ const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_UPGRADE_CODE = L"BundleUpgradeCo
23 const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_DISPLAY_NAME = L"DisplayName";
24 const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_VERSION = L"BundleVersion";
25 const LPCWSTR BURN_REGISTRATION_REGISTRY_ENGINE_VERSION = L"EngineVersion";
26 +const LPCWSTR BURN_REGISTRATION_REGISTRY_ENGINE_PROTOCOL_VERSION = L"EngineProtocolVersion";
27 const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY = L"BundleProviderKey";
28 const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_TAG = L"BundleTag";
29
src/burn/engine/relatedbundle.cpp
+19 -6
@@ -21,7 +21,7 @@ static HRESULT LoadRelatedBundleFromKey(
21 __in HKEY hkBundleId,
22 __in BOOL fPerMachine,
23 __in BOOTSTRAPPER_RELATION_TYPE relationType,
24 - __inout BURN_RELATED_BUNDLE *pRelatedBundle
24 + __in BURN_RELATED_BUNDLE *pRelatedBundle
25 );
26
27
@@ -398,21 +398,34 @@ static HRESULT LoadRelatedBundleFromKey(
398 __in HKEY hkBundleId,
399 __in BOOL fPerMachine,
400 __in BOOTSTRAPPER_RELATION_TYPE relationType,
401 - __inout BURN_RELATED_BUNDLE* pRelatedBundle
401 + __in BURN_RELATED_BUNDLE* pRelatedBundle
402 )
403 {
404 HRESULT hr = S_OK;
405 DWORD64 qwEngineVersion = 0;
406 + DWORD dwEngineProtocolVersion = 0;
407 + BOOL fSupportsBurnProtocol = FALSE;
408 LPWSTR sczBundleVersion = NULL;
409 LPWSTR sczCachePath = NULL;
410 BOOL fCached = FALSE;
411 DWORD64 qwFileSize = 0;
412 BURN_DEPENDENCY_PROVIDER dependencyProvider = { };
413
412 - hr = RegReadVersion(hkBundleId, BURN_REGISTRATION_REGISTRY_ENGINE_VERSION, &qwEngineVersion);
413 - if (FAILED(hr))
414 + // Only support progress from engines that are compatible.
415 + hr = RegReadNumber(hkBundleId, BURN_REGISTRATION_REGISTRY_ENGINE_PROTOCOL_VERSION, &dwEngineProtocolVersion);
416 + if (SUCCEEDED(hr))
417 + {
418 + fSupportsBurnProtocol = BURN_PROTOCOL_VERSION == dwEngineProtocolVersion;
419 + }
420 + else
421 {
415 - qwEngineVersion = 0;
422 + // Rely on version checking (aka: version greater than or equal to last protocol breaking change *and* versions that are older or the same as this engine)
423 + hr = RegReadVersion(hkBundleId, BURN_REGISTRATION_REGISTRY_ENGINE_VERSION, &qwEngineVersion);
424 + if (SUCCEEDED(hr))
425 + {
426 + fSupportsBurnProtocol = (FILEMAKEVERSION(3, 6, 2221, 0) <= qwEngineVersion && qwEngineVersion <= FILEMAKEVERSION(rmj, rmm, rup, rpr));
427 + }
428 +
429 hr = S_OK;
430 }
431
@@ -467,7 +480,7 @@ static HRESULT LoadRelatedBundleFromKey(
480
481 pRelatedBundle->relationType = relationType;
482
470 - hr = PseudoBundleInitialize(qwEngineVersion, &pRelatedBundle->package, fPerMachine, wzRelatedBundleId, pRelatedBundle->relationType,
483 + hr = PseudoBundleInitialize(&pRelatedBundle->package, fSupportsBurnProtocol, fPerMachine, wzRelatedBundleId, pRelatedBundle->relationType,
484 BOOTSTRAPPER_PACKAGE_STATE_PRESENT, fCached, sczCachePath, sczCachePath, NULL, qwFileSize, FALSE,
485 L"-quiet", L"-repair -quiet", L"-uninstall -quiet",
486 (dependencyProvider.sczKey && *dependencyProvider.sczKey) ? &dependencyProvider : NULL,
src/burn/test/BurnUnitTest/PlanTest.cpp
+1 -1
@@ -1154,7 +1154,7 @@ namespace Bootstrapper
1154 pRelatedBundle->fPlannable = TRUE;
1155 pRelatedBundle->relationType = BOOTSTRAPPER_RELATION_UPGRADE;
1156
1157 - hr = PseudoBundleInitialize(0, &pRelatedBundle->package, TRUE, wzId, pRelatedBundle->relationType, BOOTSTRAPPER_PACKAGE_STATE_PRESENT, TRUE, wzFilePath, wzFilePath, NULL, 0, FALSE, L"-quiet", L"-repair -quiet", L"-uninstall -quiet", &dependencyProvider, NULL, 0);
1157 + hr = PseudoBundleInitialize(&pRelatedBundle->package, TRUE, TRUE, wzId, pRelatedBundle->relationType, BOOTSTRAPPER_PACKAGE_STATE_PRESENT, TRUE, wzFilePath, wzFilePath, NULL, 0, FALSE, L"-quiet", L"-repair -quiet", L"-uninstall -quiet", &dependencyProvider, NULL, 0);
1158 NativeAssert::Succeeded(hr, "Failed to initialize related bundle to represent bundle: %ls", wzId);
1159
1160 ++pRelatedBundles->cRelatedBundles;