[6/9] msi: Take the install context into account when deleting the product key.

Hans Leidekker hans at codeweavers.com
Fri Nov 4 07:28:08 CDT 2016


Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/msi/action.c   |  4 ++--
 dlls/msi/msipriv.h  |  2 +-
 dlls/msi/registry.c | 17 +++++++++++------
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index ee53684..b35969b 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -5307,7 +5307,7 @@ static UINT msi_unpublish_product( MSIPACKAGE *package, const WCHAR *remove )
         return ERROR_SUCCESS;
 
     MSIREG_DeleteProductKey(package->ProductCode);
-    MSIREG_DeleteUserDataProductKey(package->ProductCode);
+    MSIREG_DeleteUserDataProductKey(package->ProductCode, package->Context);
     MSIREG_DeleteUninstallKey(package->ProductCode, package->platform);
 
     MSIREG_DeleteLocalClassesProductKey(package->ProductCode);
@@ -5524,7 +5524,7 @@ static UINT ACTION_RegisterUser(MSIPACKAGE *package)
 
     if (msi_check_unpublish(package))
     {
-        MSIREG_DeleteUserDataProductKey(package->ProductCode);
+        MSIREG_DeleteUserDataProductKey(package->ProductCode, package->Context);
         goto end;
     }
 
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index ce1eb6d..a2939b3 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -915,7 +915,7 @@ extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL cr
 extern UINT MSIREG_DeleteProductKey(LPCWSTR szProduct) DECLSPEC_HIDDEN;
 extern UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct) DECLSPEC_HIDDEN;
 extern UINT MSIREG_DeleteUserDataPatchKey(LPCWSTR patch, MSIINSTALLCONTEXT context) DECLSPEC_HIDDEN;
-extern UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct) DECLSPEC_HIDDEN;
+extern UINT MSIREG_DeleteUserDataProductKey(LPCWSTR, MSIINSTALLCONTEXT) DECLSPEC_HIDDEN;
 extern UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct) DECLSPEC_HIDDEN;
 extern UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid) DECLSPEC_HIDDEN;
 extern UINT MSIREG_DeleteUserUpgradeCodesKey(LPCWSTR szUpgradeCode) DECLSPEC_HIDDEN;
diff --git a/dlls/msi/registry.c b/dlls/msi/registry.c
index 01d8ba7..8852f57 100644
--- a/dlls/msi/registry.c
+++ b/dlls/msi/registry.c
@@ -852,7 +852,7 @@ UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext, LPC
     return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
 }
 
-UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct)
+UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context)
 {
     REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
     WCHAR *usersid, squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
@@ -862,13 +862,18 @@ UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct)
     if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
     TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
 
-    if (!(usersid = get_user_sid()))
+    if (context == MSIINSTALLCONTEXT_MACHINE)
+        sprintfW(keypath, szUserDataProducts_fmt, szLocalSid);
+    else
     {
-        ERR("Failed to retrieve user SID\n");
-        return ERROR_FUNCTION_FAILED;
+        if (!(usersid = get_user_sid()))
+        {
+            ERR("Failed to retrieve user SID\n");
+            return ERROR_FUNCTION_FAILED;
+        }
+        sprintfW(keypath, szUserDataProducts_fmt, usersid);
+        LocalFree(usersid);
     }
-    sprintfW(keypath, szUserDataProducts_fmt, usersid);
-    LocalFree(usersid);
 
     if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey)) return ERROR_SUCCESS;
     r = RegDeleteTreeW( hkey, squashed_pc );
-- 
2.1.4




More information about the wine-patches mailing list