2005-06-09 14:05:27 +02:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2005 Aric Stewart for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Actions focused on in this module
|
|
|
|
*
|
|
|
|
* FindRelatedProducts
|
|
|
|
* MigrateFeatureStates (TODO)
|
|
|
|
* RemoveExistingProducts (TODO)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "msidefs.h"
|
|
|
|
#include "msipriv.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "action.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
2005-06-16 18:08:58 +02:00
|
|
|
extern const WCHAR szFindRelatedProducts[];
|
|
|
|
extern const WCHAR szMigrateFeatureStates[];
|
|
|
|
extern const WCHAR szRemoveExistingProducts[];
|
|
|
|
|
2005-06-09 14:05:27 +02:00
|
|
|
static BOOL check_language(DWORD lang1, LPCWSTR lang2, DWORD attributes)
|
|
|
|
{
|
|
|
|
DWORD langdword;
|
|
|
|
|
|
|
|
if (!lang2 || lang2[0]==0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
langdword = atoiW(lang2);
|
|
|
|
|
|
|
|
if (attributes & msidbUpgradeAttributesLanguagesExclusive)
|
|
|
|
return (lang1 != langdword);
|
|
|
|
else
|
|
|
|
return (lang1 == langdword);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void append_productcode(MSIPACKAGE* package, LPCWSTR action_property,
|
|
|
|
LPCWSTR productid)
|
|
|
|
{
|
|
|
|
LPWSTR prop;
|
|
|
|
LPWSTR newprop;
|
|
|
|
DWORD len;
|
|
|
|
static const WCHAR separator[] = {';',0};
|
|
|
|
|
|
|
|
prop = load_dynamic_property(package, action_property, NULL);
|
|
|
|
if (prop)
|
|
|
|
len = strlenW(prop);
|
|
|
|
else
|
|
|
|
len = 0;
|
|
|
|
|
|
|
|
/*separator*/
|
|
|
|
len ++;
|
|
|
|
|
|
|
|
len += strlenW(productid);
|
|
|
|
|
|
|
|
/*null*/
|
|
|
|
len++;
|
|
|
|
|
|
|
|
newprop = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (prop)
|
|
|
|
{
|
|
|
|
strcpyW(newprop,prop);
|
|
|
|
strcatW(newprop,separator);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
newprop[0] = 0;
|
|
|
|
strcatW(newprop,productid);
|
|
|
|
|
|
|
|
MSI_SetPropertyW(package, action_property, newprop);
|
|
|
|
TRACE("Found Related Product... %s now %s\n",debugstr_w(action_property),
|
|
|
|
debugstr_w(newprop));
|
|
|
|
HeapFree(GetProcessHeap(),0,prop);
|
|
|
|
HeapFree(GetProcessHeap(),0,newprop);
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param)
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = (MSIPACKAGE*)param;
|
|
|
|
WCHAR product[GUID_SIZE];
|
|
|
|
DWORD index = 0;
|
|
|
|
DWORD attributes = 0;
|
|
|
|
DWORD sz = GUID_SIZE;
|
|
|
|
LPCWSTR upgrade_code;
|
|
|
|
HKEY hkey = 0;
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
2005-06-16 18:08:58 +02:00
|
|
|
MSIRECORD *uirow;
|
2005-06-09 14:05:27 +02:00
|
|
|
|
|
|
|
upgrade_code = MSI_RecordGetString(rec,1);
|
|
|
|
|
|
|
|
rc = MSIREG_OpenUpgradeCodesKey(upgrade_code, &hkey, FALSE);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2005-06-16 18:08:58 +02:00
|
|
|
uirow = MSI_CreateRecord(1);
|
2005-06-09 14:05:27 +02:00
|
|
|
attributes = MSI_RecordGetInteger(rec,5);
|
|
|
|
|
|
|
|
while (rc == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
rc = RegEnumValueW(hkey, index, product, &sz, NULL, NULL, NULL, NULL);
|
|
|
|
TRACE("Looking at (%li) %s\n",index,debugstr_w(product));
|
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WCHAR productid[GUID_SIZE];
|
|
|
|
LPCWSTR ver;
|
|
|
|
LPCWSTR language;
|
|
|
|
LPCWSTR action_property;
|
|
|
|
DWORD check = 0x00000000;
|
|
|
|
DWORD comp_ver = 0x00000000;
|
|
|
|
DWORD sz = 0x100;
|
|
|
|
HKEY hukey;
|
|
|
|
INT r;
|
|
|
|
static const WCHAR szVersion[] =
|
|
|
|
{'V','e','r','s','i','o','n',0};
|
|
|
|
static const WCHAR szLanguage[] =
|
|
|
|
{'L','a','n','g','u','a','g','e',0};
|
|
|
|
|
|
|
|
unsquash_guid(product,productid);
|
|
|
|
rc = MSIREG_OpenUserProductsKey(productid, &hukey, FALSE);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
rc = ERROR_SUCCESS;
|
|
|
|
index ++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
sz = sizeof(DWORD);
|
|
|
|
RegQueryValueExW(hukey, szVersion, NULL, NULL, (LPBYTE)&check,
|
|
|
|
&sz);
|
|
|
|
/* check min */
|
|
|
|
ver = MSI_RecordGetString(rec,2);
|
|
|
|
comp_ver = build_version_dword(ver);
|
|
|
|
r = check - comp_ver;
|
|
|
|
if (r < 0 || (r == 0 && !(attributes &
|
|
|
|
msidbUpgradeAttributesVersionMinInclusive)))
|
|
|
|
{
|
|
|
|
RegCloseKey(hukey);
|
|
|
|
index ++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check max */
|
|
|
|
ver = MSI_RecordGetString(rec,3);
|
|
|
|
comp_ver = build_version_dword(ver);
|
|
|
|
r = check - comp_ver;
|
|
|
|
if (r > 0 || (r == 0 && !(attributes &
|
|
|
|
msidbUpgradeAttributesVersionMaxInclusive)))
|
|
|
|
{
|
|
|
|
RegCloseKey(hukey);
|
|
|
|
index ++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check language*/
|
|
|
|
sz = sizeof(DWORD);
|
|
|
|
RegQueryValueExW(hukey, szLanguage, NULL, NULL, (LPBYTE)&check,
|
|
|
|
&sz);
|
|
|
|
RegCloseKey(hukey);
|
|
|
|
language = MSI_RecordGetString(rec,4);
|
|
|
|
TRACE("Checking languages 0x%lx and %s\n", check,
|
|
|
|
debugstr_w(language));
|
|
|
|
if (!check_language(check, language, attributes))
|
|
|
|
{
|
|
|
|
index ++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
action_property = MSI_RecordGetString(rec,7);
|
|
|
|
append_productcode(package,action_property,productid);
|
2005-06-16 18:08:58 +02:00
|
|
|
ui_actiondata(package,szFindRelatedProducts,uirow);
|
2005-06-09 14:05:27 +02:00
|
|
|
}
|
|
|
|
index ++;
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
2005-06-16 18:08:58 +02:00
|
|
|
msiobj_release( &uirow->hdr);
|
2005-06-09 14:05:27 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT ACTION_FindRelatedProducts(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
static const WCHAR Query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',
|
|
|
|
' ','`','U','p','g','r','a','d','e','`',0};
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
|
|
|
MSIQUERY *view;
|
|
|
|
|
2005-06-30 22:45:43 +02:00
|
|
|
if (check_unique_action(package,szFindRelatedProducts))
|
|
|
|
{
|
|
|
|
TRACE("Skipping FindRelatedProducts action: already done on client side\n");
|
2005-06-09 14:05:27 +02:00
|
|
|
return ERROR_SUCCESS;
|
2005-06-30 22:45:43 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
register_unique_action(package,szFindRelatedProducts);
|
2005-06-09 14:05:27 +02:00
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_FindRelatedProducts, package);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|