aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine/relatedbundle.cpp
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2022-01-15 21:40:54 -0500
committerBob Arnson <github@bobs.org>2022-01-16 10:28:44 -0500
commit47bca2dc51525fcad86f325278b14953ac5b137e (patch)
tree80a153833efbe0794be7153c64e712a5799649c4 /src/burn/engine/relatedbundle.cpp
parent6d1c4cc83214b65032251c67239b02da59a3e635 (diff)
downloadwix-47bca2dc51525fcad86f325278b14953ac5b137e.tar.gz
wix-47bca2dc51525fcad86f325278b14953ac5b137e.tar.bz2
wix-47bca2dc51525fcad86f325278b14953ac5b137e.zip
Fix 32/64-bit bitness handling in Burn and BUtil.
- Take advantage of RegOpenEx. - Always look for related bundles in both 32 and 64 hives. - BundleEnumRelatedBundle requires caller to specify bitness.
Diffstat (limited to 'src/burn/engine/relatedbundle.cpp')
-rw-r--r--src/burn/engine/relatedbundle.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/burn/engine/relatedbundle.cpp b/src/burn/engine/relatedbundle.cpp
index 99ed8553..619fa8dd 100644
--- a/src/burn/engine/relatedbundle.cpp
+++ b/src/burn/engine/relatedbundle.cpp
@@ -11,13 +11,13 @@ static __callback int __cdecl CompareRelatedBundles(
11); 11);
12static HRESULT InitializeForScopeAndBitness( 12static HRESULT InitializeForScopeAndBitness(
13 __in BOOL fPerMachine, 13 __in BOOL fPerMachine,
14 __in BOOL fWow6432, 14 __in REG_KEY_BITNESS regBitness,
15 __in BURN_REGISTRATION* pRegistration, 15 __in BURN_REGISTRATION* pRegistration,
16 __in BURN_RELATED_BUNDLES* pRelatedBundles 16 __in BURN_RELATED_BUNDLES* pRelatedBundles
17 ); 17 );
18static HRESULT LoadIfRelatedBundle( 18static HRESULT LoadIfRelatedBundle(
19 __in BOOL fPerMachine, 19 __in BOOL fPerMachine,
20 __in BOOL fWow6432, 20 __in REG_KEY_BITNESS regBitness,
21 __in HKEY hkUninstallKey, 21 __in HKEY hkUninstallKey,
22 __in_z LPCWSTR sczRelatedBundleId, 22 __in_z LPCWSTR sczRelatedBundleId,
23 __in BURN_REGISTRATION* pRegistration, 23 __in BURN_REGISTRATION* pRegistration,
@@ -47,13 +47,11 @@ extern "C" HRESULT RelatedBundlesInitializeForScope(
47{ 47{
48 HRESULT hr = S_OK; 48 HRESULT hr = S_OK;
49 49
50 hr = InitializeForScopeAndBitness(fPerMachine, /*fWow6432*/FALSE, pRegistration, pRelatedBundles); 50 hr = InitializeForScopeAndBitness(fPerMachine, REG_KEY_32BIT, pRegistration, pRelatedBundles);
51 ExitOnFailure(hr, "Failed to open platform-native uninstall registry key.");
52
53#if defined(_WIN64)
54 hr = InitializeForScopeAndBitness(fPerMachine, /*fWow6432*/TRUE, pRegistration, pRelatedBundles);
55 ExitOnFailure(hr, "Failed to open 32-bit uninstall registry key."); 51 ExitOnFailure(hr, "Failed to open 32-bit uninstall registry key.");
56#endif 52
53 hr = InitializeForScopeAndBitness(fPerMachine, REG_KEY_64BIT, pRegistration, pRelatedBundles);
54 ExitOnFailure(hr, "Failed to open 64-bit uninstall registry key.");
57 55
58LExit: 56LExit:
59 return hr; 57 return hr;
@@ -170,7 +168,7 @@ static __callback int __cdecl CompareRelatedBundles(
170 168
171static HRESULT InitializeForScopeAndBitness( 169static HRESULT InitializeForScopeAndBitness(
172 __in BOOL fPerMachine, 170 __in BOOL fPerMachine,
173 __in BOOL fWow6432, 171 __in REG_KEY_BITNESS regBitness,
174 __in BURN_REGISTRATION * pRegistration, 172 __in BURN_REGISTRATION * pRegistration,
175 __in BURN_RELATED_BUNDLES * pRelatedBundles 173 __in BURN_RELATED_BUNDLES * pRelatedBundles
176) 174)
@@ -180,7 +178,7 @@ static HRESULT InitializeForScopeAndBitness(
180 HKEY hkUninstallKey = NULL; 178 HKEY hkUninstallKey = NULL;
181 LPWSTR sczRelatedBundleId = NULL; 179 LPWSTR sczRelatedBundleId = NULL;
182 180
183 hr = RegOpen(hkRoot, BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY, KEY_READ | (fWow6432 ? KEY_WOW64_32KEY : 0), &hkUninstallKey); 181 hr = RegOpenEx(hkRoot, BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY, KEY_READ, regBitness, &hkUninstallKey);
184 if (HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr || HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) 182 if (HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr || HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr)
185 { 183 {
186 ExitFunction1(hr = S_OK); 184 ExitFunction1(hr = S_OK);
@@ -202,7 +200,7 @@ static HRESULT InitializeForScopeAndBitness(
202 { 200 {
203 // Ignore failures here since we'll often find products that aren't actually 201 // Ignore failures here since we'll often find products that aren't actually
204 // related bundles (or even bundles at all). 202 // related bundles (or even bundles at all).
205 HRESULT hrRelatedBundle = LoadIfRelatedBundle(fPerMachine, fWow6432, hkUninstallKey, sczRelatedBundleId, pRegistration, pRelatedBundles); 203 HRESULT hrRelatedBundle = LoadIfRelatedBundle(fPerMachine, regBitness, hkUninstallKey, sczRelatedBundleId, pRegistration, pRelatedBundles);
206 UNREFERENCED_PARAMETER(hrRelatedBundle); 204 UNREFERENCED_PARAMETER(hrRelatedBundle);
207 } 205 }
208 } 206 }
@@ -216,7 +214,7 @@ LExit:
216 214
217static HRESULT LoadIfRelatedBundle( 215static HRESULT LoadIfRelatedBundle(
218 __in BOOL fPerMachine, 216 __in BOOL fPerMachine,
219 __in BOOL fWow6432, 217 __in REG_KEY_BITNESS regBitness,
220 __in HKEY hkUninstallKey, 218 __in HKEY hkUninstallKey,
221 __in_z LPCWSTR sczRelatedBundleId, 219 __in_z LPCWSTR sczRelatedBundleId,
222 __in BURN_REGISTRATION* pRegistration, 220 __in BURN_REGISTRATION* pRegistration,
@@ -227,7 +225,7 @@ static HRESULT LoadIfRelatedBundle(
227 HKEY hkBundleId = NULL; 225 HKEY hkBundleId = NULL;
228 BOOTSTRAPPER_RELATION_TYPE relationType = BOOTSTRAPPER_RELATION_NONE; 226 BOOTSTRAPPER_RELATION_TYPE relationType = BOOTSTRAPPER_RELATION_NONE;
229 227
230 hr = RegOpen(hkUninstallKey, sczRelatedBundleId, KEY_READ | (fWow6432 ? KEY_WOW64_32KEY : 0), &hkBundleId); 228 hr = RegOpenEx(hkUninstallKey, sczRelatedBundleId, KEY_READ, regBitness, &hkBundleId);
231 ExitOnFailure(hr, "Failed to open uninstall key for potential related bundle: %ls", sczRelatedBundleId); 229 ExitOnFailure(hr, "Failed to open uninstall key for potential related bundle: %ls", sczRelatedBundleId);
232 230
233 hr = DetermineRelationType(hkBundleId, pRegistration, &relationType); 231 hr = DetermineRelationType(hkBundleId, pRegistration, &relationType);