Commit 6488a6a5 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

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

parent f279d09f
...@@ -4852,12 +4852,12 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package) ...@@ -4852,12 +4852,12 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package)
if (!msi_check_publish(package)) if (!msi_check_publish(package))
return ERROR_SUCCESS; return ERROR_SUCCESS;
rc = MSIREG_OpenFeaturesKey(package->ProductCode, package->Context, rc = MSIREG_OpenFeaturesKey(package->ProductCode, NULL, package->Context,
&hkey, TRUE); &hkey, TRUE);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
goto end; goto end;
rc = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, package->Context, rc = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, NULL, package->Context,
&userdata, TRUE); &userdata, TRUE);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
goto end; goto end;
...@@ -4957,7 +4957,7 @@ static UINT msi_unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature) ...@@ -4957,7 +4957,7 @@ static UINT msi_unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature)
TRACE("unpublishing feature %s\n", debugstr_w(feature->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); &hkey, FALSE);
if (r == ERROR_SUCCESS) if (r == ERROR_SUCCESS)
{ {
...@@ -4965,7 +4965,7 @@ static UINT msi_unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature) ...@@ -4965,7 +4965,7 @@ static UINT msi_unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature)
RegCloseKey(hkey); RegCloseKey(hkey);
} }
r = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, package->Context, r = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, NULL, package->Context,
&hkey, FALSE); &hkey, FALSE);
if (r == ERROR_SUCCESS) if (r == ERROR_SUCCESS)
{ {
......
...@@ -2982,12 +2982,12 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature) ...@@ -2982,12 +2982,12 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
SetLastError( ERROR_SUCCESS ); SetLastError( ERROR_SUCCESS );
if (MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED, if (MSIREG_OpenFeaturesKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
&hkey, FALSE) != ERROR_SUCCESS && &hkey, FALSE) != ERROR_SUCCESS &&
MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED, MSIREG_OpenFeaturesKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
&hkey, FALSE) != ERROR_SUCCESS) &hkey, FALSE) != ERROR_SUCCESS)
{ {
rc = MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_MACHINE, rc = MSIREG_OpenFeaturesKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
&hkey, FALSE); &hkey, FALSE);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
return INSTALLSTATE_UNKNOWN; return INSTALLSTATE_UNKNOWN;
...@@ -3007,11 +3007,11 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature) ...@@ -3007,11 +3007,11 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
return r; return r;
if (machine) if (machine)
rc = MSIREG_OpenUserDataFeaturesKey(szProduct, rc = MSIREG_OpenUserDataFeaturesKey(szProduct, NULL,
MSIINSTALLCONTEXT_MACHINE, MSIINSTALLCONTEXT_MACHINE,
&hkey, FALSE); &hkey, FALSE);
else else
rc = MSIREG_OpenUserDataFeaturesKey(szProduct, rc = MSIREG_OpenUserDataFeaturesKey(szProduct, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED, MSIINSTALLCONTEXT_USERUNMANAGED,
&hkey, FALSE); &hkey, FALSE);
......
...@@ -885,10 +885,10 @@ extern UINT MSIREG_OpenUninstallKey(const WCHAR *, enum platform, HKEY *, BOOL) ...@@ -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_DeleteUninstallKey(const WCHAR *, enum platform) DECLSPEC_HIDDEN;
extern UINT MSIREG_OpenProductKey(LPCWSTR szProduct, LPCWSTR szUserSid, extern UINT MSIREG_OpenProductKey(LPCWSTR szProduct, LPCWSTR szUserSid,
MSIINSTALLCONTEXT context, HKEY* key, BOOL create) DECLSPEC_HIDDEN; 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; HKEY *key, BOOL create) DECLSPEC_HIDDEN;
extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, 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; HKEY *key, BOOL create) DECLSPEC_HIDDEN;
extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, 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, extern UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid,
......
...@@ -562,12 +562,12 @@ UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY *key, BOOL create) ...@@ -562,12 +562,12 @@ UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY *key, BOOL create)
return RegOpenKeyW(HKEY_CURRENT_USER, keypath, key); 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; HKEY root = HKEY_LOCAL_MACHINE;
REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS; 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; if (!squash_guid(szProduct, squished_pc)) return ERROR_FUNCTION_FAILED;
TRACE("%s squished %s\n", debugstr_w(szProduct), debugstr_w(squished_pc)); TRACE("%s squished %s\n", debugstr_w(szProduct), debugstr_w(squished_pc));
...@@ -585,12 +585,16 @@ UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context, HKEY * ...@@ -585,12 +585,16 @@ UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context, HKEY *
} }
else else
{ {
if (!(usersid = get_user_sid())) if (!szUserSid)
{ {
ERR("Failed to retrieve user SID\n"); if (!(usersid = get_user_sid()))
return ERROR_FUNCTION_FAILED; {
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); LocalFree(usersid);
} }
if (create) return RegCreateKeyExW(root, keypath, 0, NULL, 0, access, NULL, key, NULL); 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 ...@@ -624,11 +628,11 @@ static UINT MSIREG_OpenInstallerFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL c
return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key); 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; 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; if (!squash_guid(szProduct, squished_pc)) return ERROR_FUNCTION_FAILED;
TRACE("%s squished %s\n", debugstr_w(szProduct), debugstr_w(squished_pc)); TRACE("%s squished %s\n", debugstr_w(szProduct), debugstr_w(squished_pc));
...@@ -639,12 +643,16 @@ UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context ...@@ -639,12 +643,16 @@ UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context
} }
else else
{ {
if (!(usersid = get_user_sid())) if (!szUserSid)
{ {
ERR("Failed to retrieve user SID\n"); if (!(usersid = get_user_sid()))
return ERROR_FUNCTION_FAILED; {
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); LocalFree(usersid);
} }
if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL); if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment