msi: Factor out the code to open a product key.
This commit is contained in:
parent
f12b9cea99
commit
70be1e7746
@ -3582,22 +3582,19 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
|
|||||||
if (!msi_check_publish(package))
|
if (!msi_check_publish(package))
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
||||||
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
|
rc = MSIREG_OpenProductKey(package->ProductCode, package->Context,
|
||||||
{
|
&hukey, TRUE);
|
||||||
rc = MSIREG_OpenLocalClassesProductKey(package->ProductCode, &hukey, TRUE);
|
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
|
||||||
|
{
|
||||||
rc = MSIREG_OpenLocalUserDataProductKey(package->ProductCode, &hudkey, TRUE);
|
rc = MSIREG_OpenLocalUserDataProductKey(package->ProductCode, &hudkey, TRUE);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rc = MSIREG_OpenUserProductsKey(package->ProductCode, &hukey, TRUE);
|
|
||||||
if (rc != ERROR_SUCCESS)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
rc = MSIREG_OpenUserDataProductKey(package->ProductCode, &hudkey, TRUE);
|
rc = MSIREG_OpenUserDataProductKey(package->ProductCode, &hudkey, TRUE);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -51,11 +51,14 @@ static UINT msi_locate_product(LPCWSTR szProduct, MSIINSTALLCONTEXT *context)
|
|||||||
|
|
||||||
*context = MSIINSTALLCONTEXT_NONE;
|
*context = MSIINSTALLCONTEXT_NONE;
|
||||||
|
|
||||||
if (MSIREG_OpenLocalManagedProductKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS)
|
if (MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
|
||||||
|
&hkey, FALSE) == ERROR_SUCCESS)
|
||||||
*context = MSIINSTALLCONTEXT_USERMANAGED;
|
*context = MSIINSTALLCONTEXT_USERMANAGED;
|
||||||
else if (MSIREG_OpenLocalClassesProductKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS)
|
else if (MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
|
||||||
|
&hkey, FALSE) == ERROR_SUCCESS)
|
||||||
*context = MSIINSTALLCONTEXT_MACHINE;
|
*context = MSIINSTALLCONTEXT_MACHINE;
|
||||||
else if (MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS)
|
else if (MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||||
|
&hkey, FALSE) == ERROR_SUCCESS)
|
||||||
*context = MSIINSTALLCONTEXT_USERUNMANAGED;
|
*context = MSIINSTALLCONTEXT_USERUNMANAGED;
|
||||||
|
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
@ -644,9 +647,12 @@ UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
|
|||||||
sz = GUID_SIZE;
|
sz = GUID_SIZE;
|
||||||
unsquash_guid(squished_prod, szBuffer);
|
unsquash_guid(squished_prod, szBuffer);
|
||||||
|
|
||||||
if (MSIREG_OpenLocalManagedProductKey(szBuffer, &prodkey, FALSE) == ERROR_SUCCESS ||
|
if (MSIREG_OpenProductKey(szBuffer, MSIINSTALLCONTEXT_USERMANAGED,
|
||||||
MSIREG_OpenUserProductsKey(szBuffer, &prodkey, FALSE) == ERROR_SUCCESS ||
|
&prodkey, FALSE) == ERROR_SUCCESS ||
|
||||||
MSIREG_OpenLocalClassesProductKey(szBuffer, &prodkey, FALSE) == ERROR_SUCCESS)
|
MSIREG_OpenProductKey(szBuffer, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||||
|
&prodkey, FALSE) == ERROR_SUCCESS ||
|
||||||
|
MSIREG_OpenProductKey(szBuffer, MSIINSTALLCONTEXT_MACHINE,
|
||||||
|
&prodkey, FALSE) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
RegCloseKey(prodkey);
|
RegCloseKey(prodkey);
|
||||||
rc = ERROR_SUCCESS;
|
rc = ERROR_SUCCESS;
|
||||||
@ -716,17 +722,15 @@ static UINT WINAPI MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
|
|||||||
if (!squash_guid(szProduct, squished_pc))
|
if (!squash_guid(szProduct, squished_pc))
|
||||||
return ERROR_INVALID_PARAMETER;
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
|
||||||
r = MSIREG_OpenLocalManagedProductKey(szProduct, &prodkey, FALSE);
|
if ((r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
|
||||||
if (r != ERROR_SUCCESS)
|
&prodkey, FALSE)) != ERROR_SUCCESS &&
|
||||||
|
(r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||||
|
&prodkey, FALSE)) != ERROR_SUCCESS &&
|
||||||
|
(r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
|
||||||
|
&prodkey, FALSE)) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
r = MSIREG_OpenUserProductsKey(szProduct, &prodkey, FALSE);
|
|
||||||
if (r != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
r = MSIREG_OpenLocalClassesProductKey(szProduct, &prodkey, FALSE);
|
|
||||||
if (r == ERROR_SUCCESS)
|
|
||||||
classes = TRUE;
|
classes = TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (classes)
|
if (classes)
|
||||||
MSIREG_OpenLocalSystemProductKey(szProduct, &userdata, FALSE);
|
MSIREG_OpenLocalSystemProductKey(szProduct, &userdata, FALSE);
|
||||||
@ -1034,8 +1038,10 @@ UINT WINAPI MsiGetProductInfoExW(LPCWSTR szProductCode, LPCWSTR szUserSid,
|
|||||||
if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
|
if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
|
||||||
return ERROR_INVALID_PARAMETER;
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
|
||||||
MSIREG_OpenLocalManagedProductKey(szProductCode, &managed, FALSE);
|
MSIREG_OpenProductKey(szProductCode, MSIINSTALLCONTEXT_USERMANAGED,
|
||||||
MSIREG_OpenUserProductsKey(szProductCode, &prod, FALSE);
|
&managed, FALSE);
|
||||||
|
MSIREG_OpenProductKey(szProductCode, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||||
|
&prod, FALSE);
|
||||||
|
|
||||||
if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED)
|
if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED)
|
||||||
{
|
{
|
||||||
@ -1057,7 +1063,7 @@ UINT WINAPI MsiGetProductInfoExW(LPCWSTR szProductCode, LPCWSTR szUserSid,
|
|||||||
{
|
{
|
||||||
package = INSTALLPROPERTY_LOCALPACKAGEW;
|
package = INSTALLPROPERTY_LOCALPACKAGEW;
|
||||||
MSIREG_OpenLocalSystemProductKey(szProductCode, &props, FALSE);
|
MSIREG_OpenLocalSystemProductKey(szProductCode, &props, FALSE);
|
||||||
MSIREG_OpenLocalClassesProductKey(szProductCode, &classes, FALSE);
|
MSIREG_OpenProductKey(szProductCode, dwContext, &classes, FALSE);
|
||||||
|
|
||||||
if (!props && !classes)
|
if (!props && !classes)
|
||||||
goto done;
|
goto done;
|
||||||
@ -1271,13 +1277,7 @@ static BOOL msi_comp_find_prod_key(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
|
|||||||
UINT r;
|
UINT r;
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
|
|
||||||
if (context == MSIINSTALLCONTEXT_MACHINE)
|
r = MSIREG_OpenProductKey(prodcode, context, &hkey, FALSE);
|
||||||
r = MSIREG_OpenLocalClassesProductKey(prodcode, &hkey, FALSE);
|
|
||||||
else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
|
|
||||||
r = MSIREG_OpenUserProductsKey(prodcode, &hkey, FALSE);
|
|
||||||
else
|
|
||||||
r = MSIREG_OpenLocalManagedProductKey(prodcode, &hkey, FALSE);
|
|
||||||
|
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
return (r == ERROR_SUCCESS);
|
return (r == ERROR_SUCCESS);
|
||||||
}
|
}
|
||||||
@ -1430,17 +1430,15 @@ INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
|
|||||||
if (lstrlenW(szProduct) != GUID_SIZE - 1)
|
if (lstrlenW(szProduct) != GUID_SIZE - 1)
|
||||||
return INSTALLSTATE_INVALIDARG;
|
return INSTALLSTATE_INVALIDARG;
|
||||||
|
|
||||||
r = MSIREG_OpenLocalManagedProductKey(szProduct, &prodkey, FALSE);
|
if (MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
|
||||||
if (r != ERROR_SUCCESS)
|
&prodkey, FALSE) != ERROR_SUCCESS &&
|
||||||
|
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||||
|
&prodkey, FALSE) != ERROR_SUCCESS &&
|
||||||
|
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
|
||||||
|
&prodkey, FALSE) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
r = MSIREG_OpenUserProductsKey(szProduct, &prodkey, FALSE);
|
|
||||||
if (r != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
r = MSIREG_OpenLocalClassesProductKey(szProduct, &prodkey, FALSE);
|
|
||||||
if (r == ERROR_SUCCESS)
|
|
||||||
user = FALSE;
|
user = FALSE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (user)
|
if (user)
|
||||||
{
|
{
|
||||||
@ -1797,8 +1795,10 @@ static INSTALLSTATE WINAPI MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szCom
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state != INSTALLSTATE_LOCAL &&
|
if (state != INSTALLSTATE_LOCAL &&
|
||||||
(MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS ||
|
(MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||||
MSIREG_OpenLocalClassesProductKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS))
|
&hkey, FALSE) == ERROR_SUCCESS ||
|
||||||
|
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
|
||||||
|
&hkey, FALSE) == ERROR_SUCCESS))
|
||||||
{
|
{
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
|
|
||||||
@ -2431,9 +2431,12 @@ static USERINFOSTATE WINAPI MSI_GetUserInfo(LPCWSTR szProduct,
|
|||||||
if (!szProduct || !squash_guid(szProduct, squished_pc))
|
if (!szProduct || !squash_guid(szProduct, squished_pc))
|
||||||
return USERINFOSTATE_INVALIDARG;
|
return USERINFOSTATE_INVALIDARG;
|
||||||
|
|
||||||
if (MSIREG_OpenLocalManagedProductKey(szProduct, &hkey, FALSE) != ERROR_SUCCESS &&
|
if (MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
|
||||||
MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE) != ERROR_SUCCESS &&
|
&hkey, FALSE) != ERROR_SUCCESS &&
|
||||||
MSIREG_OpenLocalClassesProductKey(szProduct, &hkey, FALSE) != ERROR_SUCCESS)
|
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||||
|
&hkey, FALSE) != ERROR_SUCCESS &&
|
||||||
|
MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
|
||||||
|
&hkey, FALSE) != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
return USERINFOSTATE_UNKNOWN;
|
return USERINFOSTATE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
@ -764,7 +764,8 @@ extern BOOL encode_base85_guid(GUID *,LPWSTR);
|
|||||||
extern BOOL decode_base85_guid(LPCWSTR,GUID*);
|
extern BOOL decode_base85_guid(LPCWSTR,GUID*);
|
||||||
extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||||
extern UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct);
|
extern UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct);
|
||||||
extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
extern UINT MSIREG_OpenProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
|
||||||
|
HKEY* key, BOOL create);
|
||||||
extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
|
extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
|
||||||
extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||||
extern UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
|
extern UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
|
||||||
@ -786,9 +787,7 @@ extern UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct);
|
|||||||
extern UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct);
|
extern UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct);
|
||||||
extern UINT MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
|
extern UINT MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
|
||||||
extern UINT MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
|
extern UINT MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
|
||||||
extern UINT MSIREG_OpenLocalClassesProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
|
|
||||||
extern UINT MSIREG_OpenLocalClassesFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
|
extern UINT MSIREG_OpenLocalClassesFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
|
||||||
extern UINT MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
|
|
||||||
extern UINT MSIREG_OpenManagedFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
|
extern UINT MSIREG_OpenManagedFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
|
||||||
extern UINT MSIREG_OpenLocalUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
|
extern UINT MSIREG_OpenLocalUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
|
||||||
extern UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct);
|
extern UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct);
|
||||||
|
@ -525,25 +525,48 @@ UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct)
|
|||||||
return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
|
return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create)
|
UINT MSIREG_OpenProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
|
||||||
|
HKEY *key, BOOL create)
|
||||||
{
|
{
|
||||||
UINT rc;
|
UINT r;
|
||||||
|
LPWSTR usersid;
|
||||||
|
HKEY root = HKEY_LOCAL_MACHINE;
|
||||||
WCHAR squished_pc[GUID_SIZE];
|
WCHAR squished_pc[GUID_SIZE];
|
||||||
WCHAR keypath[0x200];
|
WCHAR keypath[MAX_PATH];
|
||||||
|
|
||||||
TRACE("%s\n",debugstr_w(szProduct));
|
TRACE("(%s, %d, %d)\n", debugstr_w(szProduct), context, create);
|
||||||
if (!squash_guid(szProduct,squished_pc))
|
|
||||||
|
if (!squash_guid(szProduct, squished_pc))
|
||||||
return ERROR_FUNCTION_FAILED;
|
return ERROR_FUNCTION_FAILED;
|
||||||
|
|
||||||
TRACE("squished (%s)\n", debugstr_w(squished_pc));
|
TRACE("squished (%s)\n", debugstr_w(squished_pc));
|
||||||
|
|
||||||
sprintfW(keypath,szUserProduct_fmt,squished_pc);
|
if (context == MSIINSTALLCONTEXT_MACHINE)
|
||||||
|
{
|
||||||
|
sprintfW(keypath, szInstaller_LocalClassesProd_fmt, squished_pc);
|
||||||
|
}
|
||||||
|
else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
|
||||||
|
{
|
||||||
|
root = HKEY_CURRENT_USER;
|
||||||
|
sprintfW(keypath, szUserProduct_fmt, squished_pc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r = get_user_sid(&usersid);
|
||||||
|
if (r != ERROR_SUCCESS || !usersid)
|
||||||
|
{
|
||||||
|
ERR("Failed to retrieve user SID: %d\n", r);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintfW(keypath, szInstaller_LocalManagedProd_fmt, usersid, squished_pc);
|
||||||
|
LocalFree(usersid);
|
||||||
|
}
|
||||||
|
|
||||||
if (create)
|
if (create)
|
||||||
rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
|
return RegCreateKeyW(root, keypath, key);
|
||||||
else
|
|
||||||
rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
|
|
||||||
|
|
||||||
return rc;
|
return RegOpenKeyW(root, keypath, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct)
|
UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct)
|
||||||
@ -1068,26 +1091,6 @@ UINT MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent, HKEY *key, BOOL cre
|
|||||||
return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT MSIREG_OpenLocalClassesProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
|
|
||||||
{
|
|
||||||
WCHAR squished_pc[GUID_SIZE];
|
|
||||||
WCHAR keypath[0x200];
|
|
||||||
|
|
||||||
TRACE("%s\n", debugstr_w(szProductCode));
|
|
||||||
|
|
||||||
if (!squash_guid(szProductCode, squished_pc))
|
|
||||||
return ERROR_FUNCTION_FAILED;
|
|
||||||
|
|
||||||
TRACE("squished (%s)\n", debugstr_w(squished_pc));
|
|
||||||
|
|
||||||
sprintfW(keypath, szInstaller_LocalClassesProd_fmt, squished_pc);
|
|
||||||
|
|
||||||
if (create)
|
|
||||||
return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
|
||||||
|
|
||||||
return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT MSIREG_DeleteLocalClassesProductKey(LPCWSTR szProductCode)
|
UINT MSIREG_DeleteLocalClassesProductKey(LPCWSTR szProductCode)
|
||||||
{
|
{
|
||||||
WCHAR squished_pc[GUID_SIZE];
|
WCHAR squished_pc[GUID_SIZE];
|
||||||
@ -1142,36 +1145,6 @@ UINT MSIREG_DeleteLocalClassesFeaturesKey(LPCWSTR szProductCode)
|
|||||||
return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
|
return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
|
|
||||||
{
|
|
||||||
WCHAR squished_pc[GUID_SIZE];
|
|
||||||
WCHAR keypath[0x200];
|
|
||||||
LPWSTR usersid;
|
|
||||||
UINT r;
|
|
||||||
|
|
||||||
TRACE("%s\n", debugstr_w(szProductCode));
|
|
||||||
|
|
||||||
if (!squash_guid(szProductCode, squished_pc))
|
|
||||||
return ERROR_FUNCTION_FAILED;
|
|
||||||
|
|
||||||
TRACE("squished (%s)\n", debugstr_w(squished_pc));
|
|
||||||
|
|
||||||
r = get_user_sid(&usersid);
|
|
||||||
if (r != ERROR_SUCCESS || !usersid)
|
|
||||||
{
|
|
||||||
ERR("Failed to retrieve user SID: %d\n", r);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintfW(keypath, szInstaller_LocalManagedProd_fmt, usersid, squished_pc);
|
|
||||||
LocalFree(usersid);
|
|
||||||
|
|
||||||
if (create)
|
|
||||||
return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
|
||||||
|
|
||||||
return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT MSIREG_OpenManagedFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
|
UINT MSIREG_OpenManagedFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
|
||||||
{
|
{
|
||||||
WCHAR squished_pc[GUID_SIZE];
|
WCHAR squished_pc[GUID_SIZE];
|
||||||
|
@ -64,21 +64,21 @@ static UINT OpenSourceKey(LPCWSTR szProduct, HKEY* key, DWORD dwOptions,
|
|||||||
if (dwOptions & MSICODE_PATCH)
|
if (dwOptions & MSICODE_PATCH)
|
||||||
rc = MSIREG_OpenUserPatchesKey(szProduct, &rootkey, create);
|
rc = MSIREG_OpenUserPatchesKey(szProduct, &rootkey, create);
|
||||||
else
|
else
|
||||||
rc = MSIREG_OpenUserProductsKey(szProduct, &rootkey, create);
|
rc = MSIREG_OpenProductKey(szProduct, context, &rootkey, create);
|
||||||
}
|
}
|
||||||
else if (context == MSIINSTALLCONTEXT_USERMANAGED)
|
else if (context == MSIINSTALLCONTEXT_USERMANAGED)
|
||||||
{
|
{
|
||||||
if (dwOptions & MSICODE_PATCH)
|
if (dwOptions & MSICODE_PATCH)
|
||||||
rc = MSIREG_OpenUserPatchesKey(szProduct, &rootkey, create);
|
rc = MSIREG_OpenUserPatchesKey(szProduct, &rootkey, create);
|
||||||
else
|
else
|
||||||
rc = MSIREG_OpenLocalManagedProductKey(szProduct, &rootkey, create);
|
rc = MSIREG_OpenProductKey(szProduct, context, &rootkey, create);
|
||||||
}
|
}
|
||||||
else if (context == MSIINSTALLCONTEXT_MACHINE)
|
else if (context == MSIINSTALLCONTEXT_MACHINE)
|
||||||
{
|
{
|
||||||
if (dwOptions & MSICODE_PATCH)
|
if (dwOptions & MSICODE_PATCH)
|
||||||
rc = MSIREG_OpenPatchesKey(szProduct, &rootkey, create);
|
rc = MSIREG_OpenPatchesKey(szProduct, &rootkey, create);
|
||||||
else
|
else
|
||||||
rc = MSIREG_OpenLocalClassesProductKey(szProduct, &rootkey, create);
|
rc = MSIREG_OpenProductKey(szProduct, context, &rootkey, create);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
@ -903,12 +903,14 @@ UINT WINAPI MsiSourceListAddSourceW( LPCWSTR szProduct, LPCWSTR szUserName,
|
|||||||
msi_free(psid);
|
msi_free(psid);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = MSIREG_OpenLocalManagedProductKey(szProduct, &hkey, FALSE);
|
r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
|
||||||
|
&hkey, FALSE);
|
||||||
if (r == ERROR_SUCCESS)
|
if (r == ERROR_SUCCESS)
|
||||||
context = MSIINSTALLCONTEXT_USERMANAGED;
|
context = MSIINSTALLCONTEXT_USERMANAGED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r = MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE);
|
r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||||
|
&hkey, FALSE);
|
||||||
if (r != ERROR_SUCCESS)
|
if (r != ERROR_SUCCESS)
|
||||||
return ERROR_UNKNOWN_PRODUCT;
|
return ERROR_UNKNOWN_PRODUCT;
|
||||||
|
|
||||||
|
@ -136,8 +136,9 @@ static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param)
|
|||||||
HKEY hukey;
|
HKEY hukey;
|
||||||
INT r;
|
INT r;
|
||||||
|
|
||||||
unsquash_guid(product,productid);
|
unsquash_guid(product, productid);
|
||||||
rc = MSIREG_OpenUserProductsKey(productid, &hukey, FALSE);
|
rc = MSIREG_OpenProductKey(productid, package->Context,
|
||||||
|
&hukey, FALSE);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
rc = ERROR_SUCCESS;
|
rc = ERROR_SUCCESS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user