aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-12-30 15:12:26 -0600
committerSean Hall <r.sean.hall@gmail.com>2021-12-30 18:40:49 -0600
commit84a1b0f8ffe40a26916b1dfb3e1b59b6b0c31ad4 (patch)
treebb830b599bf014c1e93f319b4d8a349d60eb8b53
parentc86f75bcc104d5dc457fa2900a3ebb9c38f6ff65 (diff)
downloadwix-84a1b0f8ffe40a26916b1dfb3e1b59b6b0c31ad4.tar.gz
wix-84a1b0f8ffe40a26916b1dfb3e1b59b6b0c31ad4.tar.bz2
wix-84a1b0f8ffe40a26916b1dfb3e1b59b6b0c31ad4.zip
Add BURN_PROTOCOL_VERSION in registration to avoid version checks.
Also, old versions of Burn should ignore ancestors if they doesn't support them.
-rw-r--r--src/burn/engine/inc/engine.h2
-rw-r--r--src/burn/engine/pipe.cpp1
-rw-r--r--src/burn/engine/pseudobundle.cpp13
-rw-r--r--src/burn/engine/pseudobundle.h2
-rw-r--r--src/burn/engine/registration.cpp3
-rw-r--r--src/burn/engine/registration.h1
-rw-r--r--src/burn/engine/relatedbundle.cpp25
-rw-r--r--src/burn/test/BurnUnitTest/PlanTest.cpp2
8 files changed, 33 insertions, 16 deletions
diff --git a/src/burn/engine/inc/engine.h b/src/burn/engine/inc/engine.h
index b80b4213..9b29dd84 100644
--- a/src/burn/engine/inc/engine.h
+++ b/src/burn/engine/inc/engine.h
@@ -9,6 +9,8 @@
9#define BURN_SECTION_MAGIC 0x00f14300 9#define BURN_SECTION_MAGIC 0x00f14300
10#define BURN_SECTION_VERSION 0x00000002 10#define BURN_SECTION_VERSION 0x00000002
11 11
12// This needs to be incremented whenever a breaking change is made to the Burn protocol.
13#define BURN_PROTOCOL_VERSION 1
12 14
13#if defined(__cplusplus) 15#if defined(__cplusplus)
14extern "C" { 16extern "C" {
diff --git a/src/burn/engine/pipe.cpp b/src/burn/engine/pipe.cpp
index 48be8785..80275b52 100644
--- a/src/burn/engine/pipe.cpp
+++ b/src/burn/engine/pipe.cpp
@@ -710,6 +710,7 @@ static HRESULT ChildPipeConnected(
710 } 710 }
711 711
712 // All is well, tell the parent process. 712 // All is well, tell the parent process.
713 // TODO: consider sending BURN_PROTOCOL_VERSION as a way to verify compatibility.
713 hr = FileWriteHandle(hPipe, reinterpret_cast<LPCBYTE>(&dwAck), sizeof(dwAck)); 714 hr = FileWriteHandle(hPipe, reinterpret_cast<LPCBYTE>(&dwAck), sizeof(dwAck));
714 ExitOnFailure(hr, "Failed to inform parent process that child is running."); 715 ExitOnFailure(hr, "Failed to inform parent process that child is running.");
715 716
diff --git a/src/burn/engine/pseudobundle.cpp b/src/burn/engine/pseudobundle.cpp
index 91c6c14f..14dd2b77 100644
--- a/src/burn/engine/pseudobundle.cpp
+++ b/src/burn/engine/pseudobundle.cpp
@@ -4,8 +4,8 @@
4 4
5 5
6extern "C" HRESULT PseudoBundleInitialize( 6extern "C" HRESULT PseudoBundleInitialize(
7 __in DWORD64 qwEngineVersion,
8 __in BURN_PACKAGE* pPackage, 7 __in BURN_PACKAGE* pPackage,
8 __in BOOL fSupportsBurnProtocol,
9 __in BOOL fPerMachine, 9 __in BOOL fPerMachine,
10 __in_z LPCWSTR wzId, 10 __in_z LPCWSTR wzId,
11 __in BOOTSTRAPPER_RELATION_TYPE relationType, 11 __in BOOTSTRAPPER_RELATION_TYPE relationType,
@@ -84,6 +84,9 @@ extern "C" HRESULT PseudoBundleInitialize(
84 pPackage->qwSize = qwSize; 84 pPackage->qwSize = qwSize;
85 pPackage->fVital = fVital; 85 pPackage->fVital = fVital;
86 86
87 pPackage->Exe.protocol = fSupportsBurnProtocol ? BURN_EXE_PROTOCOL_TYPE_BURN : BURN_EXE_PROTOCOL_TYPE_NONE;
88 pPackage->Exe.fSupportsAncestors = TRUE;
89
87 hr = StrAllocString(&pPackage->sczId, wzId, 0); 90 hr = StrAllocString(&pPackage->sczId, wzId, 0);
88 ExitOnFailure(hr, "Failed to copy key for pseudo bundle."); 91 ExitOnFailure(hr, "Failed to copy key for pseudo bundle.");
89 92
@@ -131,12 +134,6 @@ extern "C" HRESULT PseudoBundleInitialize(
131 pPackage->fUninstallable = TRUE; 134 pPackage->fUninstallable = TRUE;
132 } 135 }
133 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
140 if (pDependencyProvider) 137 if (pDependencyProvider)
141 { 138 {
142 pPackage->rgDependencyProviders = (BURN_DEPENDENCY_PROVIDER*)MemAlloc(sizeof(BURN_DEPENDENCY_PROVIDER), TRUE); 139 pPackage->rgDependencyProviders = (BURN_DEPENDENCY_PROVIDER*)MemAlloc(sizeof(BURN_DEPENDENCY_PROVIDER), TRUE);
@@ -310,7 +307,7 @@ extern "C" HRESULT PseudoBundleInitializeUpdateBundle(
310 hr = StrAllocString(&pPackage->Exe.sczInstallArguments, wzInstallArguments, 0); 307 hr = StrAllocString(&pPackage->Exe.sczInstallArguments, wzInstallArguments, 0);
311 ExitOnFailure(hr, "Failed to copy install arguments for update bundle package"); 308 ExitOnFailure(hr, "Failed to copy install arguments for update bundle package");
312 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.
314 pPackage->Exe.protocol = BURN_EXE_PROTOCOL_TYPE_BURN; 311 pPackage->Exe.protocol = BURN_EXE_PROTOCOL_TYPE_BURN;
315 pPackage->Exe.fSupportsAncestors = TRUE; 312 pPackage->Exe.fSupportsAncestors = TRUE;
316 313
diff --git a/src/burn/engine/pseudobundle.h b/src/burn/engine/pseudobundle.h
index 0fd4cbdb..22132c5e 100644
--- a/src/burn/engine/pseudobundle.h
+++ b/src/burn/engine/pseudobundle.h
@@ -7,8 +7,8 @@ extern "C" {
7#endif 7#endif
8 8
9HRESULT PseudoBundleInitialize( 9HRESULT PseudoBundleInitialize(
10 __in DWORD64 qwEngineVersion,
11 __in BURN_PACKAGE* pPackage, 10 __in BURN_PACKAGE* pPackage,
11 __in BOOL fSupportsBurnProtocol,
12 __in BOOL fPerMachine, 12 __in BOOL fPerMachine,
13 __in_z LPCWSTR wzId, 13 __in_z LPCWSTR wzId,
14 __in BOOTSTRAPPER_RELATION_TYPE relationType, 14 __in BOOTSTRAPPER_RELATION_TYPE relationType,
diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp
index e06767e1..9cc4b199 100644
--- a/src/burn/engine/registration.cpp
+++ b/src/burn/engine/registration.cpp
@@ -671,6 +671,9 @@ extern "C" HRESULT RegistrationSessionBegin(
671 hr = RegWriteStringFormatted(hkRegistration, BURN_REGISTRATION_REGISTRY_ENGINE_VERSION, L"%hs", szVerMajorMinorBuild); 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); 672 ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_ENGINE_VERSION);
673 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
674 // DisplayIcon: [path to exe] and ",0" to refer to the first icon in the executable. 677 // DisplayIcon: [path to exe] and ",0" to refer to the first icon in the executable.
675 hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_DISPLAY_ICON, L"%s,0", pRegistration->sczCacheExecutablePath); 678 hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_DISPLAY_ICON, L"%s,0", pRegistration->sczCacheExecutablePath);
676 ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_DISPLAY_ICON); 679 ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_DISPLAY_ICON);
diff --git a/src/burn/engine/registration.h b/src/burn/engine/registration.h
index f9411636..e33d5270 100644
--- a/src/burn/engine/registration.h
+++ b/src/burn/engine/registration.h
@@ -23,6 +23,7 @@ const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_UPGRADE_CODE = L"BundleUpgradeCo
23const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_DISPLAY_NAME = L"DisplayName"; 23const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_DISPLAY_NAME = L"DisplayName";
24const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_VERSION = L"BundleVersion"; 24const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_VERSION = L"BundleVersion";
25const LPCWSTR BURN_REGISTRATION_REGISTRY_ENGINE_VERSION = L"EngineVersion"; 25const LPCWSTR BURN_REGISTRATION_REGISTRY_ENGINE_VERSION = L"EngineVersion";
26const LPCWSTR BURN_REGISTRATION_REGISTRY_ENGINE_PROTOCOL_VERSION = L"EngineProtocolVersion";
26const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY = L"BundleProviderKey"; 27const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY = L"BundleProviderKey";
27const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_TAG = L"BundleTag"; 28const LPCWSTR BURN_REGISTRATION_REGISTRY_BUNDLE_TAG = L"BundleTag";
28 29
diff --git a/src/burn/engine/relatedbundle.cpp b/src/burn/engine/relatedbundle.cpp
index d3c856a6..4a694ef6 100644
--- a/src/burn/engine/relatedbundle.cpp
+++ b/src/burn/engine/relatedbundle.cpp
@@ -21,7 +21,7 @@ static HRESULT LoadRelatedBundleFromKey(
21 __in HKEY hkBundleId, 21 __in HKEY hkBundleId,
22 __in BOOL fPerMachine, 22 __in BOOL fPerMachine,
23 __in BOOTSTRAPPER_RELATION_TYPE relationType, 23 __in BOOTSTRAPPER_RELATION_TYPE relationType,
24 __inout BURN_RELATED_BUNDLE *pRelatedBundle 24 __in BURN_RELATED_BUNDLE *pRelatedBundle
25 ); 25 );
26 26
27 27
@@ -398,21 +398,34 @@ static HRESULT LoadRelatedBundleFromKey(
398 __in HKEY hkBundleId, 398 __in HKEY hkBundleId,
399 __in BOOL fPerMachine, 399 __in BOOL fPerMachine,
400 __in BOOTSTRAPPER_RELATION_TYPE relationType, 400 __in BOOTSTRAPPER_RELATION_TYPE relationType,
401 __inout BURN_RELATED_BUNDLE* pRelatedBundle 401 __in BURN_RELATED_BUNDLE* pRelatedBundle
402 ) 402 )
403{ 403{
404 HRESULT hr = S_OK; 404 HRESULT hr = S_OK;
405 DWORD64 qwEngineVersion = 0; 405 DWORD64 qwEngineVersion = 0;
406 DWORD dwEngineProtocolVersion = 0;
407 BOOL fSupportsBurnProtocol = FALSE;
406 LPWSTR sczBundleVersion = NULL; 408 LPWSTR sczBundleVersion = NULL;
407 LPWSTR sczCachePath = NULL; 409 LPWSTR sczCachePath = NULL;
408 BOOL fCached = FALSE; 410 BOOL fCached = FALSE;
409 DWORD64 qwFileSize = 0; 411 DWORD64 qwFileSize = 0;
410 BURN_DEPENDENCY_PROVIDER dependencyProvider = { }; 412 BURN_DEPENDENCY_PROVIDER dependencyProvider = { };
411 413
412 hr = RegReadVersion(hkBundleId, BURN_REGISTRATION_REGISTRY_ENGINE_VERSION, &qwEngineVersion); 414 // Only support progress from engines that are compatible.
413 if (FAILED(hr)) 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
414 { 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
416 hr = S_OK; 429 hr = S_OK;
417 } 430 }
418 431
@@ -467,7 +480,7 @@ static HRESULT LoadRelatedBundleFromKey(
467 480
468 pRelatedBundle->relationType = relationType; 481 pRelatedBundle->relationType = relationType;
469 482
470 hr = PseudoBundleInitialize(qwEngineVersion, &pRelatedBundle->package, fPerMachine, wzRelatedBundleId, pRelatedBundle->relationType, 483 hr = PseudoBundleInitialize(&pRelatedBundle->package, fSupportsBurnProtocol, fPerMachine, wzRelatedBundleId, pRelatedBundle->relationType,
471 BOOTSTRAPPER_PACKAGE_STATE_PRESENT, fCached, sczCachePath, sczCachePath, NULL, qwFileSize, FALSE, 484 BOOTSTRAPPER_PACKAGE_STATE_PRESENT, fCached, sczCachePath, sczCachePath, NULL, qwFileSize, FALSE,
472 L"-quiet", L"-repair -quiet", L"-uninstall -quiet", 485 L"-quiet", L"-repair -quiet", L"-uninstall -quiet",
473 (dependencyProvider.sczKey && *dependencyProvider.sczKey) ? &dependencyProvider : NULL, 486 (dependencyProvider.sczKey && *dependencyProvider.sczKey) ? &dependencyProvider : NULL,
diff --git a/src/burn/test/BurnUnitTest/PlanTest.cpp b/src/burn/test/BurnUnitTest/PlanTest.cpp
index 627da49a..35ddb22f 100644
--- a/src/burn/test/BurnUnitTest/PlanTest.cpp
+++ b/src/burn/test/BurnUnitTest/PlanTest.cpp
@@ -1154,7 +1154,7 @@ namespace Bootstrapper
1154 pRelatedBundle->fPlannable = TRUE; 1154 pRelatedBundle->fPlannable = TRUE;
1155 pRelatedBundle->relationType = BOOTSTRAPPER_RELATION_UPGRADE; 1155 pRelatedBundle->relationType = BOOTSTRAPPER_RELATION_UPGRADE;
1156 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); 1158 NativeAssert::Succeeded(hr, "Failed to initialize related bundle to represent bundle: %ls", wzId);
1159 1159
1160 ++pRelatedBundles->cRelatedBundles; 1160 ++pRelatedBundles->cRelatedBundles;