Commit c965d839 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Allow the enumeration of other users' patches.

parent f7c615b1
......@@ -3675,7 +3675,7 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
if (!msi_check_publish(package))
return ERROR_SUCCESS;
rc = MSIREG_OpenProductKey(package->ProductCode, package->Context,
rc = MSIREG_OpenProductKey(package->ProductCode, NULL, package->Context,
&hukey, TRUE);
if (rc != ERROR_SUCCESS)
goto end;
......
......@@ -51,13 +51,14 @@ static UINT msi_locate_product(LPCWSTR szProduct, MSIINSTALLCONTEXT *context)
*context = MSIINSTALLCONTEXT_NONE;
if (MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
&hkey, FALSE) == ERROR_SUCCESS)
*context = MSIINSTALLCONTEXT_USERMANAGED;
else if (MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
else if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
&hkey, FALSE) == ERROR_SUCCESS)
*context = MSIINSTALLCONTEXT_MACHINE;
else if (MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
else if (MSIREG_OpenProductKey(szProduct, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED,
&hkey, FALSE) == ERROR_SUCCESS)
*context = MSIINSTALLCONTEXT_USERUNMANAGED;
......@@ -639,11 +640,14 @@ UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
sz = GUID_SIZE;
unsquash_guid(squished_prod, szBuffer);
if (MSIREG_OpenProductKey(szBuffer, MSIINSTALLCONTEXT_USERMANAGED,
if (MSIREG_OpenProductKey(szBuffer, NULL,
MSIINSTALLCONTEXT_USERMANAGED,
&prodkey, FALSE) == ERROR_SUCCESS ||
MSIREG_OpenProductKey(szBuffer, MSIINSTALLCONTEXT_USERUNMANAGED,
MSIREG_OpenProductKey(szBuffer, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED,
&prodkey, FALSE) == ERROR_SUCCESS ||
MSIREG_OpenProductKey(szBuffer, MSIINSTALLCONTEXT_MACHINE,
MSIREG_OpenProductKey(szBuffer, NULL,
MSIINSTALLCONTEXT_MACHINE,
&prodkey, FALSE) == ERROR_SUCCESS)
{
RegCloseKey(prodkey);
......@@ -714,12 +718,15 @@ static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
if (!squash_guid(szProduct, squished_pc))
return ERROR_INVALID_PARAMETER;
if ((r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
if ((r = MSIREG_OpenProductKey(szProduct, NULL,
MSIINSTALLCONTEXT_USERMANAGED,
&prodkey, FALSE)) != ERROR_SUCCESS &&
(r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
(r = MSIREG_OpenProductKey(szProduct, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED,
&prodkey, FALSE)) != ERROR_SUCCESS &&
(r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
&prodkey, FALSE)) == ERROR_SUCCESS)
(r = MSIREG_OpenProductKey(szProduct, NULL,
MSIINSTALLCONTEXT_MACHINE,
&prodkey, FALSE)) == ERROR_SUCCESS)
{
context = MSIINSTALLCONTEXT_MACHINE;
}
......@@ -1028,9 +1035,9 @@ UINT WINAPI MsiGetProductInfoExW(LPCWSTR szProductCode, LPCWSTR szUserSid,
return ERROR_INVALID_PARAMETER;
/* FIXME: dwContext is provided, no need to search for it */
MSIREG_OpenProductKey(szProductCode, MSIINSTALLCONTEXT_USERMANAGED,
MSIREG_OpenProductKey(szProductCode, NULL,MSIINSTALLCONTEXT_USERMANAGED,
&managed, FALSE);
MSIREG_OpenProductKey(szProductCode, MSIINSTALLCONTEXT_USERUNMANAGED,
MSIREG_OpenProductKey(szProductCode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
&prod, FALSE);
MSIREG_OpenInstallProps(szProductCode, dwContext, NULL, &props, FALSE);
......@@ -1052,7 +1059,7 @@ UINT WINAPI MsiGetProductInfoExW(LPCWSTR szProductCode, LPCWSTR szUserSid,
else if (dwContext == MSIINSTALLCONTEXT_MACHINE)
{
package = INSTALLPROPERTY_LOCALPACKAGEW;
MSIREG_OpenProductKey(szProductCode, dwContext, &classes, FALSE);
MSIREG_OpenProductKey(szProductCode, NULL, dwContext, &classes, FALSE);
if (!props && !classes)
goto done;
......@@ -1314,7 +1321,7 @@ UINT WINAPI MsiGetPatchInfoExW(LPCWSTR szPatchCode, LPCWSTR szProductCode,
if (!lstrcmpW(szProperty, INSTALLPROPERTY_TRANSFORMSW))
{
if (MSIREG_OpenProductKey(szProductCode, dwContext,
if (MSIREG_OpenProductKey(szProductCode, NULL, dwContext,
&prod, FALSE) != ERROR_SUCCESS)
goto done;
......@@ -1483,7 +1490,7 @@ static BOOL msi_comp_find_prod_key(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
UINT r;
HKEY hkey;
r = MSIREG_OpenProductKey(prodcode, context, &hkey, FALSE);
r = MSIREG_OpenProductKey(prodcode, NULL, context, &hkey, FALSE);
RegCloseKey(hkey);
return (r == ERROR_SUCCESS);
}
......@@ -1632,11 +1639,11 @@ INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
if (lstrlenW(szProduct) != GUID_SIZE - 1)
return INSTALLSTATE_INVALIDARG;
if (MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
&prodkey, FALSE) != ERROR_SUCCESS &&
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
&prodkey, FALSE) != ERROR_SUCCESS &&
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
&prodkey, FALSE) == ERROR_SUCCESS)
{
context = MSIINSTALLCONTEXT_MACHINE;
......@@ -2115,9 +2122,10 @@ static INSTALLSTATE MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent,
}
if (state != INSTALLSTATE_LOCAL &&
(MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
(MSIREG_OpenProductKey(szProduct, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED,
&hkey, FALSE) == ERROR_SUCCESS ||
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
&hkey, FALSE) == ERROR_SUCCESS))
{
RegCloseKey(hkey);
......@@ -2758,11 +2766,11 @@ static USERINFOSTATE MSI_GetUserInfo(LPCWSTR szProduct,
if (!szProduct || !squash_guid(szProduct, squished_pc))
return USERINFOSTATE_INVALIDARG;
if (MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
&hkey, FALSE) != ERROR_SUCCESS &&
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
&hkey, FALSE) != ERROR_SUCCESS &&
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
&hkey, FALSE) != ERROR_SUCCESS)
{
return USERINFOSTATE_UNKNOWN;
......
......@@ -760,8 +760,8 @@ extern BOOL encode_base85_guid(GUID *,LPWSTR);
extern BOOL decode_base85_guid(LPCWSTR,GUID*);
extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct);
extern UINT MSIREG_OpenProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
HKEY* key, BOOL create);
extern UINT MSIREG_OpenProductKey(LPCWSTR szProduct, LPCWSTR szUserSid,
MSIINSTALLCONTEXT context, HKEY* key, BOOL create);
extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
HKEY *key, BOOL create);
extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
......
......@@ -504,11 +504,11 @@ UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct)
return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
}
UINT MSIREG_OpenProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
HKEY *key, BOOL create)
UINT MSIREG_OpenProductKey(LPCWSTR szProduct, LPCWSTR szUserSid,
MSIINSTALLCONTEXT context, HKEY *key, BOOL create)
{
UINT r;
LPWSTR usersid;
LPWSTR usersid = NULL;
HKEY root = HKEY_LOCAL_MACHINE;
WCHAR squished_pc[GUID_SIZE];
WCHAR keypath[MAX_PATH];
......@@ -531,14 +531,20 @@ UINT MSIREG_OpenProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
}
else
{
r = get_user_sid(&usersid);
if (r != ERROR_SUCCESS || !usersid)
if (!szUserSid)
{
ERR("Failed to retrieve user SID: %d\n", r);
return r;
r = get_user_sid(&usersid);
if (r != ERROR_SUCCESS || !usersid)
{
ERR("Failed to retrieve user SID: %d\n", r);
return r;
}
szUserSid = usersid;
}
sprintfW(keypath, szInstaller_LocalManagedProd_fmt, usersid, squished_pc);
sprintfW(keypath, szInstaller_LocalManagedProd_fmt,
szUserSid, squished_pc);
LocalFree(usersid);
}
......@@ -1659,6 +1665,7 @@ done:
}
static UINT msi_get_patch_state(LPCWSTR prodcode, LPCWSTR usersid,
MSIINSTALLCONTEXT context,
LPWSTR patch, MSIPATCHSTATE *state)
{
DWORD type, val, size;
......@@ -1672,9 +1679,8 @@ static UINT msi_get_patch_state(LPCWSTR prodcode, LPCWSTR usersid,
*state = MSIPATCHSTATE_INVALID;
/* FIXME: usersid might not be current user */
r = MSIREG_OpenUserDataProductKey(prodcode, MSIINSTALLCONTEXT_USERUNMANAGED,
NULL, &prod, FALSE);
r = MSIREG_OpenUserDataProductKey(prodcode, context,
usersid, &prod, FALSE);
if (r != ERROR_SUCCESS)
return ERROR_NO_MORE_ITEMS;
......@@ -1723,7 +1729,8 @@ static UINT msi_check_product_patches(LPCWSTR prodcode, LPCWSTR usersid,
static const WCHAR szState[] = {'S','t','a','t','e',0};
static const WCHAR szEmpty[] = {0};
if (MSIREG_OpenProductKey(prodcode, context, &prod, FALSE) != ERROR_SUCCESS)
if (MSIREG_OpenProductKey(prodcode, usersid, context,
&prod, FALSE) != ERROR_SUCCESS)
return ERROR_NO_MORE_ITEMS;
size = 0;
......@@ -1784,7 +1791,8 @@ static UINT msi_check_product_patches(LPCWSTR prodcode, LPCWSTR usersid,
{
if (!(filter & MSIPATCHSTATE_APPLIED))
{
temp = msi_get_patch_state(prodcode, usersid, ptr, &state);
temp = msi_get_patch_state(prodcode, usersid, context,
ptr, &state);
if (temp == ERROR_BAD_CONFIGURATION)
{
r = ERROR_BAD_CONFIGURATION;
......@@ -1799,7 +1807,8 @@ static UINT msi_check_product_patches(LPCWSTR prodcode, LPCWSTR usersid,
{
if (!(filter & MSIPATCHSTATE_APPLIED))
{
temp = msi_get_patch_state(prodcode, usersid, ptr, &state);
temp = msi_get_patch_state(prodcode, usersid, context,
ptr, &state);
if (temp == ERROR_BAD_CONFIGURATION)
{
r = ERROR_BAD_CONFIGURATION;
......@@ -2061,11 +2070,11 @@ UINT WINAPI MsiEnumPatchesW(LPCWSTR szProduct, DWORD iPatchIndex,
if (!lpPatchBuf || !lpTransformsBuf || !pcchTransformsBuf)
return ERROR_INVALID_PARAMETER;
if (MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
&prod, FALSE) != ERROR_SUCCESS &&
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
&prod, FALSE) != ERROR_SUCCESS &&
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
&prod, FALSE) != ERROR_SUCCESS)
return ERROR_UNKNOWN_PRODUCT;
......
......@@ -64,21 +64,24 @@ static UINT OpenSourceKey(LPCWSTR szProduct, HKEY* key, DWORD dwOptions,
if (dwOptions & MSICODE_PATCH)
rc = MSIREG_OpenUserPatchesKey(szProduct, &rootkey, create);
else
rc = MSIREG_OpenProductKey(szProduct, context, &rootkey, create);
rc = MSIREG_OpenProductKey(szProduct, NULL, context,
&rootkey, create);
}
else if (context == MSIINSTALLCONTEXT_USERMANAGED)
{
if (dwOptions & MSICODE_PATCH)
rc = MSIREG_OpenUserPatchesKey(szProduct, &rootkey, create);
else
rc = MSIREG_OpenProductKey(szProduct, context, &rootkey, create);
rc = MSIREG_OpenProductKey(szProduct, NULL, context,
&rootkey, create);
}
else if (context == MSIINSTALLCONTEXT_MACHINE)
{
if (dwOptions & MSICODE_PATCH)
rc = MSIREG_OpenPatchesKey(szProduct, &rootkey, create);
else
rc = MSIREG_OpenProductKey(szProduct, context, &rootkey, create);
rc = MSIREG_OpenProductKey(szProduct, NULL, context,
&rootkey, create);
}
if (rc != ERROR_SUCCESS)
......@@ -903,13 +906,14 @@ UINT WINAPI MsiSourceListAddSourceW( LPCWSTR szProduct, LPCWSTR szUserName,
msi_free(psid);
}
r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
&hkey, FALSE);
r = MSIREG_OpenProductKey(szProduct, NULL,
MSIINSTALLCONTEXT_USERMANAGED, &hkey, FALSE);
if (r == ERROR_SUCCESS)
context = MSIINSTALLCONTEXT_USERMANAGED;
else
{
r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
r = MSIREG_OpenProductKey(szProduct, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED,
&hkey, FALSE);
if (r != ERROR_SUCCESS)
return ERROR_UNKNOWN_PRODUCT;
......
......@@ -119,7 +119,7 @@ static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param)
uirow = MSI_CreateRecord(1);
attributes = MSI_RecordGetInteger(rec,5);
while (rc == ERROR_SUCCESS)
{
rc = RegEnumValueW(hkey, index, product, &sz, NULL, NULL, NULL, NULL);
......@@ -137,7 +137,7 @@ static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param)
INT r;
unsquash_guid(product, productid);
rc = MSIREG_OpenProductKey(productid, package->Context,
rc = MSIREG_OpenProductKey(productid, NULL, package->Context,
&hukey, FALSE);
if (rc != 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