diff --git a/dlls/msi/action.c b/dlls/msi/action.c index 654a7d05f60..0a23136a1c7 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -3589,20 +3589,10 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package) if (rc != ERROR_SUCCESS) goto end; - if (package->Context == MSIINSTALLCONTEXT_MACHINE) - { - rc = MSIREG_OpenUserDataProductKey(package->ProductCode, szLocalSid, - &hudkey, TRUE); - if (rc != ERROR_SUCCESS) - goto end; - } - else - { - rc = MSIREG_OpenUserDataProductKey(package->ProductCode, NULL, - &hudkey, TRUE); - if (rc != ERROR_SUCCESS) - goto end; - } + rc = MSIREG_OpenUserDataProductKey(package->ProductCode, package->Context, + NULL, &hudkey, TRUE); + if (rc != ERROR_SUCCESS) + goto end; rc = msi_publish_upgrade_code(package); if (rc != ERROR_SUCCESS) diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c index c49f86d2c69..e6de69da441 100644 --- a/dlls/msi/msi.c +++ b/dlls/msi/msi.c @@ -1988,7 +1988,8 @@ static INSTALLSTATE MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent, state = INSTALLSTATE_ABSENT; if ((MSIREG_OpenInstallProps(szProduct, szLocalSid, &hkey, FALSE) == ERROR_SUCCESS || - MSIREG_OpenUserDataProductKey(szProduct, NULL, &hkey, FALSE) == ERROR_SUCCESS) && + MSIREG_OpenUserDataProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED, + NULL, &hkey, FALSE) == ERROR_SUCCESS) && msi_reg_get_val_dword(hkey, wininstaller, &version) && GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES) { diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 99eff8fbdd6..0eaa9f38349 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -776,8 +776,8 @@ extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL cr extern UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid, HKEY *key, BOOL create); extern UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create); -extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, LPCWSTR szUserSid, - HKEY* key, BOOL create); +extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext, + LPCWSTR szUserSid, HKEY *key, BOOL create); extern UINT MSIREG_OpenCurrentUserInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create); extern UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, LPCWSTR szUserSID, HKEY *key, BOOL create); diff --git a/dlls/msi/registry.c b/dlls/msi/registry.c index db9ec65dfc5..a1c3a48df6c 100644 --- a/dlls/msi/registry.c +++ b/dlls/msi/registry.c @@ -799,8 +799,8 @@ UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid) return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath); } -UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, LPCWSTR szUserSid, - HKEY *key, BOOL create) +UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext, + LPCWSTR szUserSid, HKEY *key, BOOL create) { UINT rc; WCHAR squished_pc[GUID_SIZE]; @@ -812,7 +812,11 @@ UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, LPCWSTR szUserSid, return ERROR_FUNCTION_FAILED; TRACE("squished (%s)\n", debugstr_w(squished_pc)); - if (!szUserSid) + if (dwContext == MSIINSTALLCONTEXT_MACHINE) + sprintfW(keypath, szUserDataProd_fmt, szLocalSid, squished_pc); + else if (szUserSid) + sprintfW(keypath, szUserDataProd_fmt, usersid, squished_pc); + else { rc = get_user_sid(&usersid); if (rc != ERROR_SUCCESS || !usersid) @@ -824,8 +828,6 @@ UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, LPCWSTR szUserSid, sprintfW(keypath, szUserDataProd_fmt, usersid, squished_pc); LocalFree(usersid); } - else - sprintfW(keypath, szUserDataProd_fmt, szUserSid, squished_pc); if (create) rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key); @@ -1679,7 +1681,8 @@ static UINT msi_get_patch_state(LPCWSTR prodcode, LPCWSTR usersid, *state = MSIPATCHSTATE_INVALID; /* FIXME: usersid might not be current user */ - r = MSIREG_OpenUserDataProductKey(prodcode, NULL, &prod, FALSE); + r = MSIREG_OpenUserDataProductKey(prodcode, MSIINSTALLCONTEXT_USERUNMANAGED, + NULL, &prod, FALSE); if (r != ERROR_SUCCESS) return ERROR_NO_MORE_ITEMS; @@ -1826,7 +1829,7 @@ static UINT msi_check_product_patches(LPCWSTR prodcode, LPCWSTR usersid, { usersid = szEmpty; - if (MSIREG_OpenUserDataProductKey(prodcode, szLocalSid, &localprod, FALSE) == ERROR_SUCCESS && + if (MSIREG_OpenUserDataProductKey(prodcode, context, NULL, &localprod, FALSE) == ERROR_SUCCESS && RegOpenKeyExW(localprod, szPatches, 0, KEY_READ, &localpatch) == ERROR_SUCCESS && RegOpenKeyExW(localpatch, ptr, 0, KEY_READ, &patchkey) == ERROR_SUCCESS) {