aboutsummaryrefslogtreecommitdiff
path: root/src/burn
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
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')
-rw-r--r--src/burn/engine/elevation.cpp8
-rw-r--r--src/burn/engine/relatedbundle.cpp24
-rw-r--r--src/burn/engine/search.cpp16
-rw-r--r--src/burn/engine/variable.cpp2
-rw-r--r--src/burn/test/BurnUnitTest/RegistrationTest.cpp2
5 files changed, 16 insertions, 36 deletions
diff --git a/src/burn/engine/elevation.cpp b/src/burn/engine/elevation.cpp
index 355b4a34..221d8b6d 100644
--- a/src/burn/engine/elevation.cpp
+++ b/src/burn/engine/elevation.cpp
@@ -3299,7 +3299,6 @@ static HRESULT OnLaunchApprovedExe(
3299 SIZE_T iData = 0; 3299 SIZE_T iData = 0;
3300 BURN_LAUNCH_APPROVED_EXE* pLaunchApprovedExe = NULL; 3300 BURN_LAUNCH_APPROVED_EXE* pLaunchApprovedExe = NULL;
3301 BURN_APPROVED_EXE* pApprovedExe = NULL; 3301 BURN_APPROVED_EXE* pApprovedExe = NULL;
3302 REGSAM samDesired = KEY_QUERY_VALUE;
3303 HKEY hKey = NULL; 3302 HKEY hKey = NULL;
3304 DWORD dwProcessId = 0; 3303 DWORD dwProcessId = 0;
3305 BYTE* pbSendData = NULL; 3304 BYTE* pbSendData = NULL;
@@ -3323,12 +3322,7 @@ static HRESULT OnLaunchApprovedExe(
3323 3322
3324 LogId(REPORT_STANDARD, MSG_LAUNCH_APPROVED_EXE_SEARCH, pApprovedExe->sczKey, pApprovedExe->sczValueName ? pApprovedExe->sczValueName : L"", pApprovedExe->fWin64 ? L"yes" : L"no"); 3323 LogId(REPORT_STANDARD, MSG_LAUNCH_APPROVED_EXE_SEARCH, pApprovedExe->sczKey, pApprovedExe->sczValueName ? pApprovedExe->sczValueName : L"", pApprovedExe->fWin64 ? L"yes" : L"no");
3325 3324
3326 if (pApprovedExe->fWin64) 3325 hr = RegOpenEx(HKEY_LOCAL_MACHINE, pApprovedExe->sczKey, KEY_QUERY_VALUE, pApprovedExe->fWin64 ? REG_KEY_64BIT : REG_KEY_32BIT, &hKey);
3327 {
3328 samDesired |= KEY_WOW64_64KEY;
3329 }
3330
3331 hr = RegOpen(HKEY_LOCAL_MACHINE, pApprovedExe->sczKey, samDesired, &hKey);
3332 ExitOnFailure(hr, "Failed to open the registry key for the approved exe path."); 3326 ExitOnFailure(hr, "Failed to open the registry key for the approved exe path.");
3333 3327
3334 hr = RegReadString(hKey, pApprovedExe->sczValueName, &pLaunchApprovedExe->sczExecutablePath); 3328 hr = RegReadString(hKey, pApprovedExe->sczValueName, &pLaunchApprovedExe->sczExecutablePath);
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);
diff --git a/src/burn/engine/search.cpp b/src/burn/engine/search.cpp
index 6d5f8d49..4505e1a2 100644
--- a/src/burn/engine/search.cpp
+++ b/src/burn/engine/search.cpp
@@ -836,19 +836,13 @@ static HRESULT RegistrySearchExists(
836 HKEY hKey = NULL; 836 HKEY hKey = NULL;
837 DWORD dwType = 0; 837 DWORD dwType = 0;
838 BOOL fExists = FALSE; 838 BOOL fExists = FALSE;
839 REGSAM samDesired = KEY_QUERY_VALUE;
840
841 if (pSearch->RegistrySearch.fWin64)
842 {
843 samDesired = samDesired | KEY_WOW64_64KEY;
844 }
845 839
846 // format key string 840 // format key string
847 hr = VariableFormatString(pVariables, pSearch->RegistrySearch.sczKey, &sczKey, NULL); 841 hr = VariableFormatString(pVariables, pSearch->RegistrySearch.sczKey, &sczKey, NULL);
848 ExitOnFailure(hr, "Failed to format key string."); 842 ExitOnFailure(hr, "Failed to format key string.");
849 843
850 // open key 844 // open key
851 hr = RegOpen(pSearch->RegistrySearch.hRoot, sczKey, samDesired, &hKey); 845 hr = RegOpenEx(pSearch->RegistrySearch.hRoot, sczKey, KEY_QUERY_VALUE, pSearch->RegistrySearch.fWin64 ? REG_KEY_64BIT : REG_KEY_32BIT, &hKey);
852 if (SUCCEEDED(hr)) 846 if (SUCCEEDED(hr))
853 { 847 {
854 fExists = TRUE; 848 fExists = TRUE;
@@ -922,12 +916,6 @@ static HRESULT RegistrySearchValue(
922 LPBYTE pData = NULL; 916 LPBYTE pData = NULL;
923 DWORD cch = 0; 917 DWORD cch = 0;
924 BURN_VARIANT value = { }; 918 BURN_VARIANT value = { };
925 REGSAM samDesired = KEY_QUERY_VALUE;
926
927 if (pSearch->RegistrySearch.fWin64)
928 {
929 samDesired = samDesired | KEY_WOW64_64KEY;
930 }
931 919
932 // format key string 920 // format key string
933 hr = VariableFormatString(pVariables, pSearch->RegistrySearch.sczKey, &sczKey, NULL); 921 hr = VariableFormatString(pVariables, pSearch->RegistrySearch.sczKey, &sczKey, NULL);
@@ -941,7 +929,7 @@ static HRESULT RegistrySearchValue(
941 } 929 }
942 930
943 // open key 931 // open key
944 hr = RegOpen(pSearch->RegistrySearch.hRoot, sczKey, samDesired, &hKey); 932 hr = RegOpenEx(pSearch->RegistrySearch.hRoot, sczKey, KEY_QUERY_VALUE, pSearch->RegistrySearch.fWin64 ? REG_KEY_64BIT : REG_KEY_32BIT, &hKey);
945 if (E_FILENOTFOUND == hr) 933 if (E_FILENOTFOUND == hr)
946 { 934 {
947 // What if there is a hidden variable in sczKey? 935 // What if there is a hidden variable in sczKey?
diff --git a/src/burn/engine/variable.cpp b/src/burn/engine/variable.cpp
index fa6190dd..b3dcdb7d 100644
--- a/src/burn/engine/variable.cpp
+++ b/src/burn/engine/variable.cpp
@@ -2361,7 +2361,7 @@ static HRESULT Get64bitFolderFromRegistry(
2361 AssertSz(CSIDL_PROGRAM_FILES == nFolder || CSIDL_PROGRAM_FILES_COMMON == nFolder, "Unknown folder CSIDL."); 2361 AssertSz(CSIDL_PROGRAM_FILES == nFolder || CSIDL_PROGRAM_FILES_COMMON == nFolder, "Unknown folder CSIDL.");
2362 LPCWSTR wzFolderValue = CSIDL_PROGRAM_FILES_COMMON == nFolder ? L"CommonFilesDir" : L"ProgramFilesDir"; 2362 LPCWSTR wzFolderValue = CSIDL_PROGRAM_FILES_COMMON == nFolder ? L"CommonFilesDir" : L"ProgramFilesDir";
2363 2363
2364 hr = RegOpen(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion", KEY_READ | KEY_WOW64_64KEY, &hkFolders); 2364 hr = RegOpenEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion", KEY_READ, REG_KEY_64BIT, &hkFolders);
2365 ExitOnFailure(hr, "Failed to open Windows folder key."); 2365 ExitOnFailure(hr, "Failed to open Windows folder key.");
2366 2366
2367 hr = RegReadString(hkFolders, wzFolderValue, psczPath); 2367 hr = RegReadString(hkFolders, wzFolderValue, psczPath);
diff --git a/src/burn/test/BurnUnitTest/RegistrationTest.cpp b/src/burn/test/BurnUnitTest/RegistrationTest.cpp
index dbcd2613..d2ec0a82 100644
--- a/src/burn/test/BurnUnitTest/RegistrationTest.cpp
+++ b/src/burn/test/BurnUnitTest/RegistrationTest.cpp
@@ -645,7 +645,7 @@ namespace Bootstrapper
645 NativeAssert::Succeeded(hr, "Failed to allocate buffer for related bundle id."); 645 NativeAssert::Succeeded(hr, "Failed to allocate buffer for related bundle id.");
646 646
647 // Verify we can find ourself via the UpgradeCode 647 // Verify we can find ourself via the UpgradeCode
648 hr = BundleEnumRelatedBundleFixed(TEST_BUNDLE_UPGRADE_CODE, BUNDLE_INSTALL_CONTEXT_USER, &dwRelatedBundleIndex, sczRelatedBundleId); 648 hr = BundleEnumRelatedBundleFixed(TEST_BUNDLE_UPGRADE_CODE, BUNDLE_INSTALL_CONTEXT_USER, REG_KEY_DEFAULT, &dwRelatedBundleIndex, sczRelatedBundleId);
649 TestThrowOnFailure(hr, L"Failed to enumerate related bundle."); 649 TestThrowOnFailure(hr, L"Failed to enumerate related bundle.");
650 650
651 NativeAssert::StringEqual(TEST_BUNDLE_ID, sczRelatedBundleId); 651 NativeAssert::StringEqual(TEST_BUNDLE_ID, sczRelatedBundleId);