msi: Extend registry helpers to support opening the features key for a specific user.

This commit is contained in:
Hans Leidekker 2013-01-09 11:43:48 +01:00 committed by Alexandre Julliard
parent f279d09f78
commit 6488a6a5e4
4 changed files with 33 additions and 25 deletions

View file

@ -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)
{

View file

@ -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);

View file

@ -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,

View file

@ -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);