msi: Add the ability to query a specific context for install properties.
This commit is contained in:
parent
880b9199a9
commit
b5e3e19a19
|
@ -4158,19 +4158,10 @@ static UINT ACTION_RegisterProduct(MSIPACKAGE *package)
|
|||
if (rc != ERROR_SUCCESS)
|
||||
return rc;
|
||||
|
||||
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
|
||||
{
|
||||
rc = MSIREG_OpenInstallProps(package->ProductCode, szLocalSid,
|
||||
&props, TRUE);
|
||||
rc = MSIREG_OpenInstallProps(package->ProductCode, package->Context,
|
||||
NULL, &props, TRUE);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = MSIREG_OpenCurrentUserInstallProps(package->ProductCode, &props, TRUE);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
goto done;
|
||||
}
|
||||
|
||||
msi_make_package_local(package, props);
|
||||
|
||||
|
@ -4428,11 +4419,8 @@ static UINT ACTION_RegisterUser(MSIPACKAGE *package)
|
|||
if (!productid)
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
|
||||
rc = MSIREG_OpenInstallProps(package->ProductCode, szLocalSid, &hkey, TRUE);
|
||||
else
|
||||
rc = MSIREG_OpenCurrentUserInstallProps(package->ProductCode, &hkey, TRUE);
|
||||
|
||||
rc = MSIREG_OpenInstallProps(package->ProductCode, package->Context,
|
||||
NULL, &hkey, TRUE);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
goto end;
|
||||
|
||||
|
|
|
@ -107,12 +107,7 @@ static UINT MSI_OpenProductW(LPCWSTR szProduct, MSIPACKAGE **package)
|
|||
if (r != ERROR_SUCCESS)
|
||||
return r;
|
||||
|
||||
if (context == MSIINSTALLCONTEXT_MACHINE)
|
||||
r = MSIREG_OpenInstallProps(szProduct, szLocalSid, &props, FALSE);
|
||||
else if (context == MSIINSTALLCONTEXT_USERMANAGED ||
|
||||
context == MSIINSTALLCONTEXT_USERUNMANAGED)
|
||||
r = MSIREG_OpenCurrentUserInstallProps(szProduct, &props, FALSE);
|
||||
|
||||
r = MSIREG_OpenInstallProps(szProduct, context, NULL, &props, FALSE);
|
||||
if (r != ERROR_SUCCESS)
|
||||
return ERROR_UNKNOWN_PRODUCT;
|
||||
|
||||
|
@ -406,11 +401,8 @@ static UINT msi_open_package(LPCWSTR product, MSIINSTALLCONTEXT context,
|
|||
static const WCHAR szLocalPackage[] = {
|
||||
'L','o','c','a','l','P','a','c','k','a','g','e',0};
|
||||
|
||||
if (context == MSIINSTALLCONTEXT_MACHINE)
|
||||
r = MSIREG_OpenInstallProps(product, szLocalSid, &props, FALSE);
|
||||
else
|
||||
r = MSIREG_OpenCurrentUserInstallProps(product, &props, FALSE);
|
||||
|
||||
r = MSIREG_OpenInstallProps(product, context, NULL, &props, FALSE);
|
||||
if (r != ERROR_SUCCESS)
|
||||
return ERROR_BAD_CONFIGURATION;
|
||||
|
||||
|
@ -693,12 +685,12 @@ static LPWSTR msi_reg_get_value(HKEY hkey, LPCWSTR name, DWORD *type)
|
|||
static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
|
||||
awstring *szValue, LPDWORD pcchValueBuf)
|
||||
{
|
||||
MSIINSTALLCONTEXT context = MSIINSTALLCONTEXT_USERUNMANAGED;
|
||||
UINT r = ERROR_UNKNOWN_PROPERTY;
|
||||
HKEY prodkey, userdata, source;
|
||||
LPWSTR val = NULL;
|
||||
WCHAR squished_pc[GUID_SIZE];
|
||||
WCHAR packagecode[GUID_SIZE];
|
||||
BOOL classes = FALSE;
|
||||
BOOL badconfig = FALSE;
|
||||
LONG res;
|
||||
DWORD save, type = REG_NONE;
|
||||
|
@ -729,13 +721,10 @@ static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
|
|||
(r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
|
||||
&prodkey, FALSE)) == ERROR_SUCCESS)
|
||||
{
|
||||
classes = TRUE;
|
||||
context = MSIINSTALLCONTEXT_MACHINE;
|
||||
}
|
||||
|
||||
if (classes)
|
||||
MSIREG_OpenInstallProps(szProduct, szLocalSid, &userdata, FALSE);
|
||||
else
|
||||
MSIREG_OpenCurrentUserInstallProps(szProduct, &userdata, FALSE);
|
||||
MSIREG_OpenInstallProps(szProduct, context, NULL, &userdata, FALSE);
|
||||
|
||||
if (!lstrcmpW(szAttribute, INSTALLPROPERTY_HELPLINKW) ||
|
||||
!lstrcmpW(szAttribute, INSTALLPROPERTY_HELPTELEPHONEW) ||
|
||||
|
@ -1038,15 +1027,17 @@ UINT WINAPI MsiGetProductInfoExW(LPCWSTR szProductCode, LPCWSTR szUserSid,
|
|||
if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
/* FIXME: dwContext is provided, no need to search for it */
|
||||
MSIREG_OpenProductKey(szProductCode, MSIINSTALLCONTEXT_USERMANAGED,
|
||||
&managed, FALSE);
|
||||
MSIREG_OpenProductKey(szProductCode, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||
&prod, FALSE);
|
||||
|
||||
MSIREG_OpenInstallProps(szProductCode, dwContext, NULL, &props, FALSE);
|
||||
|
||||
if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED)
|
||||
{
|
||||
package = INSTALLPROPERTY_LOCALPACKAGEW;
|
||||
MSIREG_OpenCurrentUserInstallProps(szProductCode, &props, FALSE);
|
||||
|
||||
if (!props && !prod)
|
||||
goto done;
|
||||
|
@ -1054,7 +1045,6 @@ UINT WINAPI MsiGetProductInfoExW(LPCWSTR szProductCode, LPCWSTR szUserSid,
|
|||
else if (dwContext == MSIINSTALLCONTEXT_USERMANAGED)
|
||||
{
|
||||
package = managed_local_package;
|
||||
MSIREG_OpenCurrentUserInstallProps(szProductCode, &props, FALSE);
|
||||
|
||||
if (!props && !managed)
|
||||
goto done;
|
||||
|
@ -1062,7 +1052,6 @@ UINT WINAPI MsiGetProductInfoExW(LPCWSTR szProductCode, LPCWSTR szUserSid,
|
|||
else if (dwContext == MSIINSTALLCONTEXT_MACHINE)
|
||||
{
|
||||
package = INSTALLPROPERTY_LOCALPACKAGEW;
|
||||
MSIREG_OpenInstallProps(szProductCode, szLocalSid, &props, FALSE);
|
||||
MSIREG_OpenProductKey(szProductCode, dwContext, &classes, FALSE);
|
||||
|
||||
if (!props && !classes)
|
||||
|
@ -1373,11 +1362,7 @@ static BOOL msi_comp_find_package(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
|
|||
'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
|
||||
};
|
||||
|
||||
if (context == MSIINSTALLCONTEXT_MACHINE)
|
||||
r = MSIREG_OpenInstallProps(prodcode, szLocalSid, &hkey, FALSE);
|
||||
else
|
||||
r = MSIREG_OpenCurrentUserInstallProps(prodcode, &hkey, FALSE);
|
||||
|
||||
r = MSIREG_OpenInstallProps(prodcode, context, NULL, &hkey, FALSE);
|
||||
if (r != ERROR_SUCCESS)
|
||||
return FALSE;
|
||||
|
||||
|
@ -1491,9 +1476,9 @@ INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
|
|||
|
||||
INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
|
||||
{
|
||||
MSIINSTALLCONTEXT context = MSIINSTALLCONTEXT_USERUNMANAGED;
|
||||
INSTALLSTATE state = INSTALLSTATE_ADVERTISED;
|
||||
HKEY prodkey = 0, userdata = 0;
|
||||
BOOL user = TRUE;
|
||||
DWORD val;
|
||||
UINT r;
|
||||
|
||||
|
@ -1515,21 +1500,12 @@ INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
|
|||
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
|
||||
&prodkey, FALSE) == ERROR_SUCCESS)
|
||||
{
|
||||
user = FALSE;
|
||||
context = MSIINSTALLCONTEXT_MACHINE;
|
||||
}
|
||||
|
||||
if (user)
|
||||
{
|
||||
r = MSIREG_OpenCurrentUserInstallProps(szProduct, &userdata, FALSE);
|
||||
r = MSIREG_OpenInstallProps(szProduct, context, NULL, &userdata, FALSE);
|
||||
if (r != ERROR_SUCCESS)
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = MSIREG_OpenInstallProps(szProduct, szLocalSid, &userdata, FALSE);
|
||||
if (r != ERROR_SUCCESS)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!msi_reg_get_val_dword(userdata, szWindowsInstaller, &val))
|
||||
goto done;
|
||||
|
@ -1987,7 +1963,8 @@ static INSTALLSTATE MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent,
|
|||
|
||||
state = INSTALLSTATE_ABSENT;
|
||||
|
||||
if ((MSIREG_OpenInstallProps(szProduct, szLocalSid, &hkey, FALSE) == ERROR_SUCCESS ||
|
||||
if ((MSIREG_OpenInstallProps(szProduct, MSIINSTALLCONTEXT_MACHINE, NULL,
|
||||
&hkey, FALSE) == ERROR_SUCCESS ||
|
||||
MSIREG_OpenUserDataProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||
NULL, &hkey, FALSE) == ERROR_SUCCESS) &&
|
||||
msi_reg_get_val_dword(hkey, wininstaller, &version) &&
|
||||
|
@ -2652,8 +2629,10 @@ static USERINFOSTATE MSI_GetUserInfo(LPCWSTR szProduct,
|
|||
return USERINFOSTATE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (MSIREG_OpenCurrentUserInstallProps(szProduct, &props, FALSE) != ERROR_SUCCESS &&
|
||||
MSIREG_OpenInstallProps(szProduct, szLocalSid, &props, FALSE) != ERROR_SUCCESS)
|
||||
if (MSIREG_OpenInstallProps(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||
NULL, &props, FALSE) != ERROR_SUCCESS &&
|
||||
MSIREG_OpenInstallProps(szProduct, MSIINSTALLCONTEXT_MACHINE,
|
||||
NULL, &props, FALSE) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hkey);
|
||||
return USERINFOSTATE_ABSENT;
|
||||
|
|
|
@ -780,9 +780,8 @@ extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT d
|
|||
LPCWSTR szUserSid, HKEY *key, BOOL create);
|
||||
extern UINT MSIREG_OpenUserDataPatchKey(LPCWSTR szPatch, MSIINSTALLCONTEXT dwContext,
|
||||
HKEY *key, BOOL create);
|
||||
extern UINT MSIREG_OpenCurrentUserInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, LPCWSTR szUserSID,
|
||||
HKEY *key, BOOL create);
|
||||
extern UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext,
|
||||
LPCWSTR szUserSid, HKEY *key, BOOL create);
|
||||
extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_DeleteProductKey(LPCWSTR szProduct);
|
||||
|
|
|
@ -871,10 +871,11 @@ UINT MSIREG_OpenUserDataPatchKey(LPCWSTR szPatch, MSIINSTALLCONTEXT dwContext,
|
|||
return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||
}
|
||||
|
||||
UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, LPCWSTR szUserSID,
|
||||
HKEY *key, BOOL create)
|
||||
UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext,
|
||||
LPCWSTR szUserSid, HKEY *key, BOOL create)
|
||||
{
|
||||
UINT rc;
|
||||
LPWSTR usersid;
|
||||
WCHAR squished_pc[GUID_SIZE];
|
||||
WCHAR keypath[0x200];
|
||||
|
||||
|
@ -883,22 +884,12 @@ UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, LPCWSTR szUserSID,
|
|||
return ERROR_FUNCTION_FAILED;
|
||||
TRACE("squished (%s)\n", debugstr_w(squished_pc));
|
||||
|
||||
sprintfW(keypath, szInstallProperties_fmt, szUserSID, squished_pc);
|
||||
|
||||
if (create)
|
||||
rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||
if (dwContext == MSIINSTALLCONTEXT_MACHINE)
|
||||
sprintfW(keypath, szInstallProperties_fmt, szLocalSid, squished_pc);
|
||||
else if (szUserSid)
|
||||
sprintfW(keypath, szInstallProperties_fmt, szUserSid, squished_pc);
|
||||
else
|
||||
rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
UINT MSIREG_OpenCurrentUserInstallProps(LPCWSTR szProduct, HKEY *key,
|
||||
BOOL create)
|
||||
{
|
||||
UINT rc;
|
||||
LPWSTR usersid;
|
||||
|
||||
{
|
||||
rc = get_user_sid(&usersid);
|
||||
if (rc != ERROR_SUCCESS || !usersid)
|
||||
{
|
||||
|
@ -906,10 +897,14 @@ UINT MSIREG_OpenCurrentUserInstallProps(LPCWSTR szProduct, HKEY *key,
|
|||
return rc;
|
||||
}
|
||||
|
||||
rc = MSIREG_OpenInstallProps(szProduct, usersid, key, create);
|
||||
|
||||
sprintfW(keypath, szInstallProperties_fmt, usersid, squished_pc);
|
||||
LocalFree(usersid);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (create)
|
||||
return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||
|
||||
return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||
}
|
||||
|
||||
UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct)
|
||||
|
|
Loading…
Reference in New Issue