ReactOS 0.4.15-dev-8348-gc1b9bb5
upgrade.c File Reference
#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 dependency graph for upgrade.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msi)
 
static BOOL check_language (DWORD lang1, LPCWSTR lang2, DWORD attributes)
 
static BOOL find_product (const WCHAR *list, const WCHAR *product)
 
static void append_productcode (MSIPACKAGE *package, const WCHAR *action_prop, const WCHAR *product)
 
static UINT ITERATE_FindRelatedProducts (MSIRECORD *rec, LPVOID param)
 
UINT ACTION_FindRelatedProducts (MSIPACKAGE *package)
 

Function Documentation

◆ ACTION_FindRelatedProducts()

UINT ACTION_FindRelatedProducts ( MSIPACKAGE package)

Definition at line 217 of file upgrade.c.

218{
219 MSIQUERY *view;
220 UINT rc;
221
222 if (msi_get_property_int(package->db, L"Installed", 0))
223 {
224 TRACE("Skipping FindRelatedProducts action: product already installed\n");
225 return ERROR_SUCCESS;
226 }
227 if (msi_action_is_unique(package, L"FindRelatedProducts"))
228 {
229 TRACE("Skipping FindRelatedProducts action: already done in UI sequence\n");
230 return ERROR_SUCCESS;
231 }
232 else
233 msi_register_unique_action(package, L"FindRelatedProducts");
234
235 rc = MSI_DatabaseOpenViewW(package->db, L"SELECT * FROM `Upgrade`", &view);
236 if (rc != ERROR_SUCCESS)
237 return ERROR_SUCCESS;
238
240 msiobj_release(&view->hdr);
241 return rc;
242}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
UINT msi_register_unique_action(MSIPACKAGE *package, const WCHAR *action)
Definition: custom.c:113
BOOL msi_action_is_unique(const MSIPACKAGE *package, const WCHAR *action)
Definition: custom.c:131
int msiobj_release(MSIOBJECTHDR *info)
Definition: handle.c:241
UINT MSI_IterateRecords(MSIQUERY *, LPDWORD, record_func, LPVOID) DECLSPEC_HIDDEN
Definition: msiquery.c:163
int msi_get_property_int(MSIDATABASE *package, LPCWSTR prop, int def) DECLSPEC_HIDDEN
Definition: package.c:2305
UINT MSI_DatabaseOpenViewW(MSIDATABASE *, LPCWSTR, MSIQUERY **) DECLSPEC_HIDDEN
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define TRACE(s)
Definition: solgame.cpp:4
MSIDATABASE * db
Definition: msipriv.h:394
static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param)
Definition: upgrade.c:115

◆ append_productcode()

static void append_productcode ( MSIPACKAGE package,
const WCHAR action_prop,
const WCHAR product 
)
static

Definition at line 80 of file upgrade.c.

81{
82 WCHAR *prop, *newprop;
83 DWORD len = 0;
84 UINT r;
85
86 prop = msi_dup_property( package->db, action_prop );
87 if (find_product( prop, product ))
88 {
89 TRACE( "related product property %s already contains %s\n", debugstr_w(action_prop), debugstr_w(product) );
90 msi_free( prop );
91 return;
92 }
93
94 if (prop) len += lstrlenW( prop );
95 len += lstrlenW( product ) + 2;
96 if (!(newprop = msi_alloc( len * sizeof(WCHAR) ))) return;
97 if (prop)
98 {
99 lstrcpyW( newprop, prop );
100 lstrcatW( newprop, L";" );
101 }
102 else newprop[0] = 0;
103 lstrcatW( newprop, product );
104
105 r = msi_set_property( package->db, action_prop, newprop, -1 );
106 if (r == ERROR_SUCCESS && !wcscmp( action_prop, L"SourceDir" ))
107 msi_reset_source_folders( package );
108
109 TRACE( "related product property %s now %s\n", debugstr_w(action_prop), debugstr_w(newprop) );
110
111 msi_free( prop );
112 msi_free( newprop );
113}
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum GLsizei len
Definition: glext.h:6722
#define debugstr_w
Definition: kernel32.h:32
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
UINT msi_set_property(MSIDATABASE *, const WCHAR *, const WCHAR *, int) DECLSPEC_HIDDEN
Definition: package.c:2100
static void msi_free(void *mem)
Definition: msipriv.h:1159
void msi_reset_source_folders(MSIPACKAGE *package) DECLSPEC_HIDDEN
Definition: package.c:2089
static void * msi_alloc(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1142
LPWSTR msi_dup_property(MSIDATABASE *db, LPCWSTR prop) DECLSPEC_HIDDEN
Definition: package.c:2283
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static BOOL find_product(const WCHAR *list, const WCHAR *product)
Definition: upgrade.c:57
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ITERATE_FindRelatedProducts().

◆ check_language()

static BOOL check_language ( DWORD  lang1,
LPCWSTR  lang2,
DWORD  attributes 
)
static

Definition at line 42 of file upgrade.c.

43{
44 DWORD langdword;
45
46 if (!lang2 || lang2[0]==0)
47 return TRUE;
48
49 langdword = wcstol(lang2, NULL, 10);
50
52 return (lang1 != langdword);
53 else
54 return (lang1 == langdword);
55}
#define TRUE
Definition: types.h:120
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
@ msidbUpgradeAttributesLanguagesExclusive
Definition: msidefs.h:28

Referenced by ITERATE_FindRelatedProducts().

◆ find_product()

static BOOL find_product ( const WCHAR list,
const WCHAR product 
)
static

Definition at line 57 of file upgrade.c.

58{
59 const WCHAR *p = list, *q;
60
61 if (!list) return FALSE;
62 for (;;)
63 {
64 while (*p && *p != '{') p++;
65 if (*p != '{') return FALSE;
66 q = p;
67 while (*q && *q != '}') q++;
68 if (*q != '}') return FALSE;
69 q++;
70 if (q - p < lstrlenW( product )) return FALSE;
71 if (!memcmp( p, product, (q - p) * sizeof(WCHAR) )) return TRUE;
72 p = q + 1;
73 while (*p && *p != ';') p++;
74 if (*p != ';') break;
75 }
76
77 return FALSE;
78}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: list.h:37
#define FALSE
Definition: types.h:117
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902
#define list
Definition: rosglue.h:35

Referenced by append_productcode().

◆ ITERATE_FindRelatedProducts()

static UINT ITERATE_FindRelatedProducts ( MSIRECORD rec,
LPVOID  param 
)
static

Definition at line 115 of file upgrade.c.

116{
117 MSIPACKAGE *package = param;
118 WCHAR product[SQUASHED_GUID_SIZE];
119 DWORD index = 0, attributes = 0, sz = ARRAY_SIZE(product);
120 LPCWSTR upgrade_code;
121 HKEY hkey = 0;
122 UINT rc = ERROR_SUCCESS;
123 MSIRECORD *uirow;
124
125 upgrade_code = MSI_RecordGetString(rec,1);
126
127 rc = MSIREG_OpenUpgradeCodesKey(upgrade_code, &hkey, FALSE);
128 if (rc != ERROR_SUCCESS)
129 return ERROR_SUCCESS;
130
131 uirow = MSI_CreateRecord(1);
132 attributes = MSI_RecordGetInteger(rec,5);
133
134 while (rc == ERROR_SUCCESS)
135 {
136 rc = RegEnumValueW(hkey, index, product, &sz, NULL, NULL, NULL, NULL);
137 if (rc == ERROR_SUCCESS)
138 {
139 WCHAR productid[GUID_SIZE];
140 LPCWSTR ver, language, action_property;
141 DWORD check = 0, comp_ver, sz = 0x100;
142 HKEY hukey;
143 INT r;
144
145 TRACE( "looking at index %lu product %s\n", index, debugstr_w(product) );
146
147 unsquash_guid(product, productid);
151 {
152 TRACE("product key not found\n");
153 rc = ERROR_SUCCESS;
154 index ++;
155 continue;
156 }
157
158 sz = sizeof(DWORD);
160
161 /* check version minimum */
162 ver = MSI_RecordGetString(rec,2);
163 if (ver)
164 {
165 comp_ver = msi_version_str_to_dword(ver);
166 r = check - comp_ver;
167 if (r < 0 || (r == 0 && !(attributes & msidbUpgradeAttributesVersionMinInclusive)))
168 {
169 TRACE("version below minimum\n");
170 RegCloseKey(hukey);
171 index ++;
172 continue;
173 }
174 }
175
176 /* check version maximum */
177 ver = MSI_RecordGetString(rec,3);
178 if (ver)
179 {
180 comp_ver = msi_version_str_to_dword(ver);
181 r = check - comp_ver;
182 if (r > 0 || (r == 0 && !(attributes & msidbUpgradeAttributesVersionMaxInclusive)))
183 {
184 RegCloseKey(hukey);
185 index ++;
186 continue;
187 }
188 TRACE("version above maximum\n");
189 }
190
191 /* check language */
192 sz = sizeof(DWORD);
194 RegCloseKey(hukey);
195 language = MSI_RecordGetString(rec,4);
196 if (!check_language(check, language, attributes))
197 {
198 index ++;
199 TRACE("language doesn't match\n");
200 continue;
201 }
202 TRACE("found related product\n");
203
204 action_property = MSI_RecordGetString(rec, 7);
205 append_productcode(package, action_property, productid);
206 MSI_RecordSetStringW(uirow, 1, productid);
208 }
209 index ++;
210 }
211 RegCloseKey(hkey);
212 msiobj_release( &uirow->hdr);
213
214 return ERROR_SUCCESS;
215}
#define ARRAY_SIZE(A)
Definition: main.h:33
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define check(expected, result)
Definition: dplayx.c:32
GLuint index
Definition: glext.h:6031
@ INSTALLMESSAGE_ACTIONDATA
Definition: msi.h:103
@ MSIINSTALLCONTEXT_MACHINE
Definition: msi.h:200
@ MSIINSTALLCONTEXT_USERUNMANAGED
Definition: msi.h:199
@ MSIINSTALLCONTEXT_USERMANAGED
Definition: msi.h:198
static const WCHAR INSTALLPROPERTY_VERSIONW[]
Definition: msi.h:289
static const WCHAR INSTALLPROPERTY_LANGUAGEW[]
Definition: msi.h:273
@ msidbUpgradeAttributesVersionMaxInclusive
Definition: msidefs.h:27
@ msidbUpgradeAttributesVersionMinInclusive
Definition: msidefs.h:26
DWORD msi_version_str_to_dword(LPCWSTR p) DECLSPEC_HIDDEN
Definition: registry.c:188
UINT MSIREG_OpenProductKey(LPCWSTR szProduct, LPCWSTR szUserSid, MSIINSTALLCONTEXT context, HKEY *key, BOOL create) DECLSPEC_HIDDEN
Definition: registry.c:338
#define GUID_SIZE
Definition: msipriv.h:733
int MSI_RecordGetInteger(MSIRECORD *, UINT) DECLSPEC_HIDDEN
Definition: record.c:213
BOOL unsquash_guid(LPCWSTR in, LPWSTR out) DECLSPEC_HIDDEN
Definition: registry.c:41
UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY *key, BOOL create) DECLSPEC_HIDDEN
Definition: registry.c:783
const WCHAR * MSI_RecordGetString(const MSIRECORD *, UINT) DECLSPEC_HIDDEN
Definition: record.c:433
INT MSI_ProcessMessage(MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD *) DECLSPEC_HIDDEN
Definition: package.c:1914
MSIRECORD * MSI_CreateRecord(UINT) DECLSPEC_HIDDEN
Definition: record.c:76
#define SQUASHED_GUID_SIZE
Definition: msipriv.h:734
UINT MSI_RecordSetStringW(MSIRECORD *, UINT, LPCWSTR) DECLSPEC_HIDDEN
Definition: record.c:597
#define DWORD
Definition: nt_native.h:44
MSIOBJECTHDR hdr
Definition: msipriv.h:151
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
static void append_productcode(MSIPACKAGE *package, const WCHAR *action_prop, const WCHAR *product)
Definition: upgrade.c:80
static BOOL check_language(DWORD lang1, LPCWSTR lang2, DWORD attributes)
Definition: upgrade.c:42
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by ACTION_FindRelatedProducts().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msi  )