Hans Leidekker : msi: Extend registry helpers to support opening the features key for a specific user .
Alexandre Julliard
julliard at winehq.org
Wed Jan 9 13:30:37 CST 2013
Module: wine
Branch: master
Commit: 6488a6a5e4e70f00a988d951e6877a576d07ce20
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6488a6a5e4e70f00a988d951e6877a576d07ce20
Author: Hans Leidekker <hans at codeweavers.com>
Date: Wed Jan 9 11:43:48 2013 +0100
msi: Extend registry helpers to support opening the features key for a specific user.
---
dlls/msi/action.c | 8 ++++----
dlls/msi/msi.c | 10 +++++-----
dlls/msi/msipriv.h | 4 ++--
dlls/msi/registry.c | 36 ++++++++++++++++++++++--------------
4 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index babf0f0..22fa388 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -4852,12 +4852,12 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package)
if (!msi_check_publish(package))
return ERROR_SUCCESS;
- rc = MSIREG_OpenFeaturesKey(package->ProductCode, package->Context,
+ rc = MSIREG_OpenFeaturesKey(package->ProductCode, NULL, package->Context,
&hkey, TRUE);
if (rc != ERROR_SUCCESS)
goto end;
- rc = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, package->Context,
+ rc = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, NULL, package->Context,
&userdata, TRUE);
if (rc != ERROR_SUCCESS)
goto end;
@@ -4957,7 +4957,7 @@ static UINT msi_unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature)
TRACE("unpublishing feature %s\n", debugstr_w(feature->Feature));
- r = MSIREG_OpenFeaturesKey(package->ProductCode, package->Context,
+ r = MSIREG_OpenFeaturesKey(package->ProductCode, NULL, package->Context,
&hkey, FALSE);
if (r == ERROR_SUCCESS)
{
@@ -4965,7 +4965,7 @@ static UINT msi_unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature)
RegCloseKey(hkey);
}
- r = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, package->Context,
+ r = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, NULL, package->Context,
&hkey, FALSE);
if (r == ERROR_SUCCESS)
{
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 92ef52c..0e57f09 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -2982,12 +2982,12 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
SetLastError( ERROR_SUCCESS );
- if (MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
+ if (MSIREG_OpenFeaturesKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
&hkey, FALSE) != ERROR_SUCCESS &&
- MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIREG_OpenFeaturesKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
&hkey, FALSE) != ERROR_SUCCESS)
{
- rc = MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
+ rc = MSIREG_OpenFeaturesKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
&hkey, FALSE);
if (rc != ERROR_SUCCESS)
return INSTALLSTATE_UNKNOWN;
@@ -3007,11 +3007,11 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
return r;
if (machine)
- rc = MSIREG_OpenUserDataFeaturesKey(szProduct,
+ rc = MSIREG_OpenUserDataFeaturesKey(szProduct, NULL,
MSIINSTALLCONTEXT_MACHINE,
&hkey, FALSE);
else
- rc = MSIREG_OpenUserDataFeaturesKey(szProduct,
+ rc = MSIREG_OpenUserDataFeaturesKey(szProduct, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED,
&hkey, FALSE);
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index c7a42cb..a3e1e0d 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -885,10 +885,10 @@ extern UINT MSIREG_OpenUninstallKey(const WCHAR *, enum platform, HKEY *, BOOL)
extern UINT MSIREG_DeleteUninstallKey(const WCHAR *, enum platform) DECLSPEC_HIDDEN;
extern UINT MSIREG_OpenProductKey(LPCWSTR szProduct, LPCWSTR szUserSid,
MSIINSTALLCONTEXT context, HKEY* key, BOOL create) DECLSPEC_HIDDEN;
-extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
+extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, LPCWSTR szUserSid, MSIINSTALLCONTEXT context,
HKEY *key, BOOL create) DECLSPEC_HIDDEN;
extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create) DECLSPEC_HIDDEN;
-UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
+UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, LPCWSTR szUserSid, MSIINSTALLCONTEXT context,
HKEY *key, BOOL create) DECLSPEC_HIDDEN;
extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create) DECLSPEC_HIDDEN;
extern UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid,
diff --git a/dlls/msi/registry.c b/dlls/msi/registry.c
index 388c077..bb564d8 100644
--- a/dlls/msi/registry.c
+++ b/dlls/msi/registry.c
@@ -562,12 +562,12 @@ UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY *key, BOOL create)
return RegOpenKeyW(HKEY_CURRENT_USER, keypath, key);
}
-UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context, HKEY *key, BOOL create)
+UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, LPCWSTR szUserSid, MSIINSTALLCONTEXT context,
+ HKEY *key, BOOL create)
{
- LPWSTR usersid;
HKEY root = HKEY_LOCAL_MACHINE;
REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
- WCHAR squished_pc[GUID_SIZE], keypath[MAX_PATH];
+ WCHAR squished_pc[GUID_SIZE], keypath[MAX_PATH], *usersid = NULL;
if (!squash_guid(szProduct, squished_pc)) return ERROR_FUNCTION_FAILED;
TRACE("%s squished %s\n", debugstr_w(szProduct), debugstr_w(squished_pc));
@@ -585,12 +585,16 @@ UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context, HKEY *
}
else
{
- if (!(usersid = get_user_sid()))
+ if (!szUserSid)
{
- 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;
+ }
+ szUserSid = usersid;
}
- sprintfW(keypath, szInstaller_LocalManagedFeat_fmt, usersid, squished_pc);
+ sprintfW(keypath, szInstaller_LocalManagedFeat_fmt, szUserSid, squished_pc);
LocalFree(usersid);
}
if (create) return RegCreateKeyExW(root, keypath, 0, NULL, 0, access, NULL, key, NULL);
@@ -624,11 +628,11 @@ static UINT MSIREG_OpenInstallerFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL c
return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
}
-UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context, HKEY *key, BOOL create)
+UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, LPCWSTR szUserSid, MSIINSTALLCONTEXT context,
+ HKEY *key, BOOL create)
{
- LPWSTR usersid;
REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
- WCHAR squished_pc[GUID_SIZE], keypath[0x200];
+ WCHAR squished_pc[GUID_SIZE], keypath[0x200], *usersid = NULL;
if (!squash_guid(szProduct, squished_pc)) return ERROR_FUNCTION_FAILED;
TRACE("%s squished %s\n", debugstr_w(szProduct), debugstr_w(squished_pc));
@@ -639,12 +643,16 @@ UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context
}
else
{
- if (!(usersid = get_user_sid()))
+ if (!szUserSid)
{
- 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;
+ }
+ szUserSid = usersid;
}
- sprintfW(keypath, szUserDataFeatures_fmt, usersid, squished_pc);
+ sprintfW(keypath, szUserDataFeatures_fmt, szUserSid, squished_pc);
LocalFree(usersid);
}
if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
More information about the wine-cvs
mailing list