Commit 4a9f6995 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Add the ability to query a specific context for a product key.

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