diff options
| author | Bob Arnson <bob@firegiant.com> | 2022-01-03 22:36:16 -0500 |
|---|---|---|
| committer | Bob Arnson <github@bobs.org> | 2022-01-09 19:18:25 -0500 |
| commit | bae756f4354fed4de6097c931590ccafc907fdb2 (patch) | |
| tree | abd51068cacae6eb4fd2b05840e8e6f64adae161 /src/burn/engine/relatedbundle.cpp | |
| parent | c2b00d75493798d9f2452d5e5014b14afcb14889 (diff) | |
| download | wix-bae756f4354fed4de6097c931590ccafc907fdb2.tar.gz wix-bae756f4354fed4de6097c931590ccafc907fdb2.tar.bz2 wix-bae756f4354fed4de6097c931590ccafc907fdb2.zip | |
Handle 32-bit related-bundle registration...
...from 64-bit bundles.
Diffstat (limited to 'src/burn/engine/relatedbundle.cpp')
| -rw-r--r-- | src/burn/engine/relatedbundle.cpp | 93 |
1 files changed, 61 insertions, 32 deletions
diff --git a/src/burn/engine/relatedbundle.cpp b/src/burn/engine/relatedbundle.cpp index 1eafef07..99ed8553 100644 --- a/src/burn/engine/relatedbundle.cpp +++ b/src/burn/engine/relatedbundle.cpp | |||
| @@ -8,9 +8,16 @@ static __callback int __cdecl CompareRelatedBundles( | |||
| 8 | __in void* pvContext, | 8 | __in void* pvContext, |
| 9 | __in const void* pvLeft, | 9 | __in const void* pvLeft, |
| 10 | __in const void* pvRight | 10 | __in const void* pvRight |
| 11 | ); | ||
| 12 | static HRESULT InitializeForScopeAndBitness( | ||
| 13 | __in BOOL fPerMachine, | ||
| 14 | __in BOOL fWow6432, | ||
| 15 | __in BURN_REGISTRATION* pRegistration, | ||
| 16 | __in BURN_RELATED_BUNDLES* pRelatedBundles | ||
| 11 | ); | 17 | ); |
| 12 | static HRESULT LoadIfRelatedBundle( | 18 | static HRESULT LoadIfRelatedBundle( |
| 13 | __in BOOL fPerMachine, | 19 | __in BOOL fPerMachine, |
| 20 | __in BOOL fWow6432, | ||
| 14 | __in HKEY hkUninstallKey, | 21 | __in HKEY hkUninstallKey, |
| 15 | __in_z LPCWSTR sczRelatedBundleId, | 22 | __in_z LPCWSTR sczRelatedBundleId, |
| 16 | __in BURN_REGISTRATION* pRegistration, | 23 | __in BURN_REGISTRATION* pRegistration, |
| @@ -39,41 +46,16 @@ extern "C" HRESULT RelatedBundlesInitializeForScope( | |||
| 39 | ) | 46 | ) |
| 40 | { | 47 | { |
| 41 | HRESULT hr = S_OK; | 48 | HRESULT hr = S_OK; |
| 42 | HKEY hkRoot = fPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | ||
| 43 | HKEY hkUninstallKey = NULL; | ||
| 44 | LPWSTR sczRelatedBundleId = NULL; | ||
| 45 | |||
| 46 | hr = RegOpen(hkRoot, BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY, KEY_READ, &hkUninstallKey); | ||
| 47 | if (HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr || HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) | ||
| 48 | { | ||
| 49 | ExitFunction1(hr = S_OK); | ||
| 50 | } | ||
| 51 | ExitOnFailure(hr, "Failed to open uninstall registry key."); | ||
| 52 | 49 | ||
| 53 | for (DWORD dwIndex = 0; /* exit via break below */; ++dwIndex) | 50 | hr = InitializeForScopeAndBitness(fPerMachine, /*fWow6432*/FALSE, pRegistration, pRelatedBundles); |
| 54 | { | 51 | ExitOnFailure(hr, "Failed to open platform-native uninstall registry key."); |
| 55 | hr = RegKeyEnum(hkUninstallKey, dwIndex, &sczRelatedBundleId); | ||
| 56 | if (E_NOMOREITEMS == hr) | ||
| 57 | { | ||
| 58 | hr = S_OK; | ||
| 59 | break; | ||
| 60 | } | ||
| 61 | ExitOnFailure(hr, "Failed to enumerate uninstall key for related bundles."); | ||
| 62 | 52 | ||
| 63 | // If we did not find our bundle id, try to load the subkey as a related bundle. | 53 | #if defined(_WIN64) |
| 64 | if (CSTR_EQUAL != ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, sczRelatedBundleId, -1, pRegistration->sczId, -1)) | 54 | hr = InitializeForScopeAndBitness(fPerMachine, /*fWow6432*/TRUE, pRegistration, pRelatedBundles); |
| 65 | { | 55 | ExitOnFailure(hr, "Failed to open 32-bit uninstall registry key."); |
| 66 | // Ignore failures here since we'll often find products that aren't actually | 56 | #endif |
| 67 | // related bundles (or even bundles at all). | ||
| 68 | HRESULT hrRelatedBundle = LoadIfRelatedBundle(fPerMachine, hkUninstallKey, sczRelatedBundleId, pRegistration, pRelatedBundles); | ||
| 69 | UNREFERENCED_PARAMETER(hrRelatedBundle); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | 57 | ||
| 73 | LExit: | 58 | LExit: |
| 74 | ReleaseStr(sczRelatedBundleId); | ||
| 75 | ReleaseRegKey(hkUninstallKey); | ||
| 76 | |||
| 77 | return hr; | 59 | return hr; |
| 78 | } | 60 | } |
| 79 | 61 | ||
| @@ -186,8 +168,55 @@ static __callback int __cdecl CompareRelatedBundles( | |||
| 186 | return ret; | 168 | return ret; |
| 187 | } | 169 | } |
| 188 | 170 | ||
| 171 | static HRESULT InitializeForScopeAndBitness( | ||
| 172 | __in BOOL fPerMachine, | ||
| 173 | __in BOOL fWow6432, | ||
| 174 | __in BURN_REGISTRATION * pRegistration, | ||
| 175 | __in BURN_RELATED_BUNDLES * pRelatedBundles | ||
| 176 | ) | ||
| 177 | { | ||
| 178 | HRESULT hr = S_OK; | ||
| 179 | HKEY hkRoot = fPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | ||
| 180 | HKEY hkUninstallKey = NULL; | ||
| 181 | LPWSTR sczRelatedBundleId = NULL; | ||
| 182 | |||
| 183 | hr = RegOpen(hkRoot, BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY, KEY_READ | (fWow6432 ? KEY_WOW64_32KEY : 0), &hkUninstallKey); | ||
| 184 | if (HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr || HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) | ||
| 185 | { | ||
| 186 | ExitFunction1(hr = S_OK); | ||
| 187 | } | ||
| 188 | ExitOnFailure(hr, "Failed to open uninstall registry key."); | ||
| 189 | |||
| 190 | for (DWORD dwIndex = 0; /* exit via break below */; ++dwIndex) | ||
| 191 | { | ||
| 192 | hr = RegKeyEnum(hkUninstallKey, dwIndex, &sczRelatedBundleId); | ||
| 193 | if (E_NOMOREITEMS == hr) | ||
| 194 | { | ||
| 195 | hr = S_OK; | ||
| 196 | break; | ||
| 197 | } | ||
| 198 | ExitOnFailure(hr, "Failed to enumerate uninstall key for related bundles."); | ||
| 199 | |||
| 200 | // If we did not find our bundle id, try to load the subkey as a related bundle. | ||
| 201 | if (CSTR_EQUAL != ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, sczRelatedBundleId, -1, pRegistration->sczId, -1)) | ||
| 202 | { | ||
| 203 | // Ignore failures here since we'll often find products that aren't actually | ||
| 204 | // related bundles (or even bundles at all). | ||
| 205 | HRESULT hrRelatedBundle = LoadIfRelatedBundle(fPerMachine, fWow6432, hkUninstallKey, sczRelatedBundleId, pRegistration, pRelatedBundles); | ||
| 206 | UNREFERENCED_PARAMETER(hrRelatedBundle); | ||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 210 | LExit: | ||
| 211 | ReleaseStr(sczRelatedBundleId); | ||
| 212 | ReleaseRegKey(hkUninstallKey); | ||
| 213 | |||
| 214 | return hr; | ||
| 215 | } | ||
| 216 | |||
| 189 | static HRESULT LoadIfRelatedBundle( | 217 | static HRESULT LoadIfRelatedBundle( |
| 190 | __in BOOL fPerMachine, | 218 | __in BOOL fPerMachine, |
| 219 | __in BOOL fWow6432, | ||
| 191 | __in HKEY hkUninstallKey, | 220 | __in HKEY hkUninstallKey, |
| 192 | __in_z LPCWSTR sczRelatedBundleId, | 221 | __in_z LPCWSTR sczRelatedBundleId, |
| 193 | __in BURN_REGISTRATION* pRegistration, | 222 | __in BURN_REGISTRATION* pRegistration, |
| @@ -198,7 +227,7 @@ static HRESULT LoadIfRelatedBundle( | |||
| 198 | HKEY hkBundleId = NULL; | 227 | HKEY hkBundleId = NULL; |
| 199 | BOOTSTRAPPER_RELATION_TYPE relationType = BOOTSTRAPPER_RELATION_NONE; | 228 | BOOTSTRAPPER_RELATION_TYPE relationType = BOOTSTRAPPER_RELATION_NONE; |
| 200 | 229 | ||
| 201 | hr = RegOpen(hkUninstallKey, sczRelatedBundleId, KEY_READ, &hkBundleId); | 230 | hr = RegOpen(hkUninstallKey, sczRelatedBundleId, KEY_READ | (fWow6432 ? KEY_WOW64_32KEY : 0), &hkBundleId); |
| 202 | ExitOnFailure(hr, "Failed to open uninstall key for potential related bundle: %ls", sczRelatedBundleId); | 231 | ExitOnFailure(hr, "Failed to open uninstall key for potential related bundle: %ls", sczRelatedBundleId); |
| 203 | 232 | ||
| 204 | hr = DetermineRelationType(hkBundleId, pRegistration, &relationType); | 233 | hr = DetermineRelationType(hkBundleId, pRegistration, &relationType); |
