Enumerate the substorage transforms for any patches that are passed on
[wine/multimedia.git] / dlls / msi / action.c
blobc1adc701fd26f1517ed248f210575d81245a36e8
1 /*
2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2004,2005 Aric Stewart for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Pages I need
24 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/installexecutesequence_table.asp
26 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/standard_actions_reference.asp
29 #include <stdarg.h>
31 #define COBJMACROS
33 #include "windef.h"
34 #include "winbase.h"
35 #include "winerror.h"
36 #include "winreg.h"
37 #include "wine/debug.h"
38 #include "msidefs.h"
39 #include "msipriv.h"
40 #include "winuser.h"
41 #include "shlobj.h"
42 #include "wine/unicode.h"
43 #include "winver.h"
44 #include "action.h"
46 #define REG_PROGRESS_VALUE 13200
47 #define COMPONENT_PROGRESS_VALUE 24000
49 #define LPCTSTR LPCWSTR
51 WINE_DEFAULT_DEBUG_CHANNEL(msi);
54 * Prototypes
56 static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran);
57 static UINT ACTION_ProcessUISequence(MSIPACKAGE *package);
58 static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq, BOOL UI);
61 * consts and values used
63 static const WCHAR c_colon[] = {'C',':','\\',0};
65 const static WCHAR szCreateFolders[] =
66 {'C','r','e','a','t','e','F','o','l','d','e','r','s',0};
67 const static WCHAR szCostFinalize[] =
68 {'C','o','s','t','F','i','n','a','l','i','z','e',0};
69 const WCHAR szInstallFiles[] =
70 {'I','n','s','t','a','l','l','F','i','l','e','s',0};
71 const WCHAR szDuplicateFiles[] =
72 {'D','u','p','l','i','c','a','t','e','F','i','l','e','s',0};
73 const static WCHAR szWriteRegistryValues[] =
74 {'W','r','i','t','e','R','e','g','i','s','t','r','y',
75 'V','a','l','u','e','s',0};
76 const static WCHAR szCostInitialize[] =
77 {'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0};
78 const static WCHAR szFileCost[] =
79 {'F','i','l','e','C','o','s','t',0};
80 const static WCHAR szInstallInitialize[] =
81 {'I','n','s','t','a','l','l','I','n','i','t','i','a','l','i','z','e',0};
82 const static WCHAR szInstallValidate[] =
83 {'I','n','s','t','a','l','l','V','a','l','i','d','a','t','e',0};
84 const static WCHAR szLaunchConditions[] =
85 {'L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','s',0};
86 const static WCHAR szProcessComponents[] =
87 {'P','r','o','c','e','s','s','C','o','m','p','o','n','e','n','t','s',0};
88 const static WCHAR szRegisterTypeLibraries[] =
89 {'R','e','g','i','s','t','e','r','T','y','p','e',
90 'L','i','b','r','a','r','i','e','s',0};
91 const WCHAR szRegisterClassInfo[] =
92 {'R','e','g','i','s','t','e','r','C','l','a','s','s','I','n','f','o',0};
93 const WCHAR szRegisterProgIdInfo[] =
94 {'R','e','g','i','s','t','e','r','P','r','o','g','I','d','I','n','f','o',0};
95 const static WCHAR szCreateShortcuts[] =
96 {'C','r','e','a','t','e','S','h','o','r','t','c','u','t','s',0};
97 const static WCHAR szPublishProduct[] =
98 {'P','u','b','l','i','s','h','P','r','o','d','u','c','t',0};
99 const static WCHAR szWriteIniValues[] =
100 {'W','r','i','t','e','I','n','i','V','a','l','u','e','s',0};
101 const static WCHAR szSelfRegModules[] =
102 {'S','e','l','f','R','e','g','M','o','d','u','l','e','s',0};
103 const static WCHAR szPublishFeatures[] =
104 {'P','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0};
105 const static WCHAR szRegisterProduct[] =
106 {'R','e','g','i','s','t','e','r','P','r','o','d','u','c','t',0};
107 const static WCHAR szInstallExecute[] =
108 {'I','n','s','t','a','l','l','E','x','e','c','u','t','e',0};
109 const static WCHAR szInstallExecuteAgain[] =
110 {'I','n','s','t','a','l','l','E','x','e','c','u','t','e',
111 'A','g','a','i','n',0};
112 const static WCHAR szInstallFinalize[] =
113 {'I','n','s','t','a','l','l','F','i','n','a','l','i','z','e',0};
114 const static WCHAR szForceReboot[] =
115 {'F','o','r','c','e','R','e','b','o','o','t',0};
116 const static WCHAR szResolveSource[] =
117 {'R','e','s','o','l','v','e','S','o','u','r','c','e',0};
118 const WCHAR szAppSearch[] =
119 {'A','p','p','S','e','a','r','c','h',0};
120 const static WCHAR szAllocateRegistrySpace[] =
121 {'A','l','l','o','c','a','t','e','R','e','g','i','s','t','r','y',
122 'S','p','a','c','e',0};
123 const static WCHAR szBindImage[] =
124 {'B','i','n','d','I','m','a','g','e',0};
125 const static WCHAR szCCPSearch[] =
126 {'C','C','P','S','e','a','r','c','h',0};
127 const static WCHAR szDeleteServices[] =
128 {'D','e','l','e','t','e','S','e','r','v','i','c','e','s',0};
129 const static WCHAR szDisableRollback[] =
130 {'D','i','s','a','b','l','e','R','o','l','l','b','a','c','k',0};
131 const static WCHAR szExecuteAction[] =
132 {'E','x','e','c','u','t','e','A','c','t','i','o','n',0};
133 const WCHAR szFindRelatedProducts[] =
134 {'F','i','n','d','R','e','l','a','t','e','d',
135 'P','r','o','d','u','c','t','s',0};
136 const static WCHAR szInstallAdminPackage[] =
137 {'I','n','s','t','a','l','l','A','d','m','i','n',
138 'P','a','c','k','a','g','e',0};
139 const static WCHAR szInstallSFPCatalogFile[] =
140 {'I','n','s','t','a','l','l','S','F','P','C','a','t','a','l','o','g',
141 'F','i','l','e',0};
142 const static WCHAR szIsolateComponents[] =
143 {'I','s','o','l','a','t','e','C','o','m','p','o','n','e','n','t','s',0};
144 const WCHAR szMigrateFeatureStates[] =
145 {'M','i','g','r','a','t','e','F','e','a','t','u','r','e',
146 'S','t','a','t','e','s',0};
147 const WCHAR szMoveFiles[] =
148 {'M','o','v','e','F','i','l','e','s',0};
149 const static WCHAR szMsiPublishAssemblies[] =
150 {'M','s','i','P','u','b','l','i','s','h',
151 'A','s','s','e','m','b','l','i','e','s',0};
152 const static WCHAR szMsiUnpublishAssemblies[] =
153 {'M','s','i','U','n','p','u','b','l','i','s','h',
154 'A','s','s','e','m','b','l','i','e','s',0};
155 const static WCHAR szInstallODBC[] =
156 {'I','n','s','t','a','l','l','O','D','B','C',0};
157 const static WCHAR szInstallServices[] =
158 {'I','n','s','t','a','l','l','S','e','r','v','i','c','e','s',0};
159 const WCHAR szPatchFiles[] =
160 {'P','a','t','c','h','F','i','l','e','s',0};
161 const static WCHAR szPublishComponents[] =
162 {'P','u','b','l','i','s','h','C','o','m','p','o','n','e','n','t','s',0};
163 const static WCHAR szRegisterComPlus[] =
164 {'R','e','g','i','s','t','e','r','C','o','m','P','l','u','s',0};
165 const WCHAR szRegisterExtensionInfo[] =
166 {'R','e','g','i','s','t','e','r','E','x','t','e','n','s','i','o','n',
167 'I','n','f','o',0};
168 const static WCHAR szRegisterFonts[] =
169 {'R','e','g','i','s','t','e','r','F','o','n','t','s',0};
170 const WCHAR szRegisterMIMEInfo[] =
171 {'R','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0};
172 const static WCHAR szRegisterUser[] =
173 {'R','e','g','i','s','t','e','r','U','s','e','r',0};
174 const WCHAR szRemoveDuplicateFiles[] =
175 {'R','e','m','o','v','e','D','u','p','l','i','c','a','t','e',
176 'F','i','l','e','s',0};
177 const static WCHAR szRemoveEnvironmentStrings[] =
178 {'R','e','m','o','v','e','E','n','v','i','r','o','n','m','e','n','t',
179 'S','t','r','i','n','g','s',0};
180 const WCHAR szRemoveExistingProducts[] =
181 {'R','e','m','o','v','e','E','x','i','s','t','i','n','g',
182 'P','r','o','d','u','c','t','s',0};
183 const WCHAR szRemoveFiles[] =
184 {'R','e','m','o','v','e','F','i','l','e','s',0};
185 const static WCHAR szRemoveFolders[] =
186 {'R','e','m','o','v','e','F','o','l','d','e','r','s',0};
187 const static WCHAR szRemoveIniValues[] =
188 {'R','e','m','o','v','e','I','n','i','V','a','l','u','e','s',0};
189 const static WCHAR szRemoveODBC[] =
190 {'R','e','m','o','v','e','O','D','B','C',0};
191 const static WCHAR szRemoveRegistryValues[] =
192 {'R','e','m','o','v','e','R','e','g','i','s','t','r','y',
193 'V','a','l','u','e','s',0};
194 const static WCHAR szRemoveShortcuts[] =
195 {'R','e','m','o','v','e','S','h','o','r','t','c','u','t','s',0};
196 const static WCHAR szRMCCPSearch[] =
197 {'R','M','C','C','P','S','e','a','r','c','h',0};
198 const static WCHAR szScheduleReboot[] =
199 {'S','c','h','e','d','u','l','e','R','e','b','o','o','t',0};
200 const static WCHAR szSelfUnregModules[] =
201 {'S','e','l','f','U','n','r','e','g','M','o','d','u','l','e','s',0};
202 const static WCHAR szSetODBCFolders[] =
203 {'S','e','t','O','D','B','C','F','o','l','d','e','r','s',0};
204 const static WCHAR szStartServices[] =
205 {'S','t','a','r','t','S','e','r','v','i','c','e','s',0};
206 const static WCHAR szStopServices[] =
207 {'S','t','o','p','S','e','r','v','i','c','e','s',0};
208 const static WCHAR szUnpublishComponents[] =
209 {'U','n','p','u','b','l','i','s','h',
210 'C','o','m','p','o','n','e','n','t','s',0};
211 const static WCHAR szUnpublishFeatures[] =
212 {'U','n','p','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0};
213 const WCHAR szUnregisterClassInfo[] =
214 {'U','n','r','e','g','i','s','t','e','r','C','l','a','s','s',
215 'I','n','f','o',0};
216 const static WCHAR szUnregisterComPlus[] =
217 {'U','n','r','e','g','i','s','t','e','r','C','o','m','P','l','u','s',0};
218 const WCHAR szUnregisterExtensionInfo[] =
219 {'U','n','r','e','g','i','s','t','e','r',
220 'E','x','t','e','n','s','i','o','n','I','n','f','o',0};
221 const static WCHAR szUnregisterFonts[] =
222 {'U','n','r','e','g','i','s','t','e','r','F','o','n','t','s',0};
223 const WCHAR szUnregisterMIMEInfo[] =
224 {'U','n','r','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0};
225 const WCHAR szUnregisterProgIdInfo[] =
226 {'U','n','r','e','g','i','s','t','e','r','P','r','o','g','I','d',
227 'I','n','f','o',0};
228 const static WCHAR szUnregisterTypeLibraries[] =
229 {'U','n','r','e','g','i','s','t','e','r','T','y','p','e',
230 'L','i','b','r','a','r','i','e','s',0};
231 const static WCHAR szValidateProductID[] =
232 {'V','a','l','i','d','a','t','e','P','r','o','d','u','c','t','I','D',0};
233 const static WCHAR szWriteEnvironmentStrings[] =
234 {'W','r','i','t','e','E','n','v','i','r','o','n','m','e','n','t',
235 'S','t','r','i','n','g','s',0};
237 /* action handlers */
238 typedef UINT (*STANDARDACTIONHANDLER)(MSIPACKAGE*);
240 struct _actions {
241 LPCWSTR action;
242 STANDARDACTIONHANDLER handler;
245 static struct _actions StandardActions[];
248 /********************************************************
249 * helper functions
250 ********************************************************/
252 static void ce_actiontext(MSIPACKAGE* package, LPCWSTR action)
254 static const WCHAR szActionText[] =
255 {'A','c','t','i','o','n','T','e','x','t',0};
256 MSIRECORD *row;
258 row = MSI_CreateRecord(1);
259 MSI_RecordSetStringW(row,1,action);
260 ControlEvent_FireSubscribedEvent(package,szActionText, row);
261 msiobj_release(&row->hdr);
264 static void ui_actionstart(MSIPACKAGE *package, LPCWSTR action)
266 static const WCHAR template_s[]=
267 {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ', '%','s',
268 '.',0};
269 static const WCHAR format[] =
270 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
271 static const WCHAR Query_t[] =
272 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
273 '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
274 'W','H','E','R','E', ' ','`','A','c','t','i','o','n','`',' ','=',
275 ' ','\'','%','s','\'',0};
276 WCHAR message[1024];
277 WCHAR timet[0x100];
278 MSIRECORD * row = 0;
279 LPCWSTR ActionText;
280 LPWSTR deformated;
282 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
284 row = MSI_QueryGetRecord( package->db, Query_t, action );
285 if (!row)
286 return;
288 ActionText = MSI_RecordGetString(row,2);
289 deformat_string(package, ActionText, &deformated);
291 sprintfW(message,template_s,timet,action,deformated);
292 ce_actiontext(package, deformated);
293 msiobj_release(&row->hdr);
295 row = MSI_CreateRecord(1);
296 MSI_RecordSetStringW(row,1,message);
298 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONSTART, row);
299 msiobj_release(&row->hdr);
300 msi_free(deformated);
303 static void ui_actioninfo(MSIPACKAGE *package, LPCWSTR action, BOOL start,
304 UINT rc)
306 MSIRECORD * row;
307 static const WCHAR template_s[]=
308 {'A','c','t','i','o','n',' ','s','t','a','r','t',' ','%','s',':',' ',
309 '%','s', '.',0};
310 static const WCHAR template_e[]=
311 {'A','c','t','i','o','n',' ','e','n','d','e','d',' ','%','s',':',' ',
312 '%','s', '.',' ','R','e','t','u','r','n',' ','v','a','l','u','e',' ',
313 '%','i','.',0};
314 static const WCHAR format[] =
315 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
316 WCHAR message[1024];
317 WCHAR timet[0x100];
319 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
320 if (start)
321 sprintfW(message,template_s,timet,action);
322 else
323 sprintfW(message,template_e,timet,action,rc);
325 row = MSI_CreateRecord(1);
326 MSI_RecordSetStringW(row,1,message);
328 MSI_ProcessMessage(package, INSTALLMESSAGE_INFO, row);
329 msiobj_release(&row->hdr);
332 static int msi_get_property_int( MSIPACKAGE *package, LPCWSTR prop, int def )
334 LPWSTR str = msi_dup_property( package, prop );
335 int val = str ? atoiW( str ) : def;
336 msi_free( str );
337 return val;
340 static UINT msi_parse_command_line( MSIPACKAGE *package, LPCWSTR szCommandLine )
342 LPCWSTR ptr,ptr2;
343 BOOL quote;
344 DWORD len;
345 LPWSTR prop = NULL, val = NULL;
347 if (!szCommandLine)
348 return ERROR_SUCCESS;
350 ptr = szCommandLine;
352 while (*ptr)
354 if (*ptr==' ')
356 ptr++;
357 continue;
360 TRACE("Looking at %s\n",debugstr_w(ptr));
362 ptr2 = strchrW(ptr,'=');
363 if (!ptr2)
365 ERR("command line contains unknown string : %s\n", debugstr_w(ptr));
366 break;
369 quote = FALSE;
371 len = ptr2-ptr;
372 prop = msi_alloc((len+1)*sizeof(WCHAR));
373 memcpy(prop,ptr,len*sizeof(WCHAR));
374 prop[len]=0;
375 ptr2++;
377 len = 0;
378 ptr = ptr2;
379 while (*ptr && (quote || (!quote && *ptr!=' ')))
381 if (*ptr == '"')
382 quote = !quote;
383 ptr++;
384 len++;
387 if (*ptr2=='"')
389 ptr2++;
390 len -= 2;
392 val = msi_alloc((len+1)*sizeof(WCHAR));
393 memcpy(val,ptr2,len*sizeof(WCHAR));
394 val[len] = 0;
396 if (lstrlenW(prop) > 0)
398 TRACE("Found commandline property (%s) = (%s)\n",
399 debugstr_w(prop), debugstr_w(val));
400 MSI_SetPropertyW(package,prop,val);
402 msi_free(val);
403 msi_free(prop);
406 return ERROR_SUCCESS;
410 static LPWSTR* msi_split_string( LPCWSTR str, WCHAR sep )
412 LPWSTR p, *ret = NULL;
413 UINT count = 0;
415 if (!str)
416 return ret;
418 /* count the number of substrings */
419 for ( p = (LPWSTR)str, count = 0; p; count++ )
421 p = strchrW( p, sep );
422 if (p)
423 p++;
426 /* allocate space for an array of substring pointers and the substrings */
427 ret = msi_alloc( (count+1) * sizeof (LPWSTR) +
428 (lstrlenW(str)+1) * sizeof(WCHAR) );
429 if (!ret)
430 return ret;
432 /* copy the string and set the pointers */
433 p = (LPWSTR) &ret[count+1];
434 lstrcpyW( p, str );
435 for( count = 0; (ret[count] = p); count++ )
437 p = strchrW( p, sep );
438 if (p)
439 *p++ = 0;
442 return ret;
445 static UINT msi_apply_substorage_transform( MSIPACKAGE *package,
446 MSIDATABASE *patch_db, LPCWSTR name )
448 UINT ret = ERROR_FUNCTION_FAILED;
449 IStorage *stg = NULL;
450 HRESULT r;
452 TRACE("%p %s\n", package, debugstr_w(name) );
454 if (*name++ != ':')
456 ERR("expected a colon in %s\n", debugstr_w(name));
457 return ERROR_FUNCTION_FAILED;
460 r = IStorage_OpenStorage( patch_db->storage, name, NULL, STGM_SHARE_EXCLUSIVE, NULL, 0, &stg );
461 if (SUCCEEDED(r))
463 FIXME("apply substorage transform %s\n", debugstr_w(name));
464 /* ret = table_apply_transform( package->db, stg ); */
465 IStorage_Release( stg );
466 ret = ERROR_SUCCESS;
468 else
469 ERR("failed to open substorage %s\n", debugstr_w(name));
471 return ret;
474 static UINT msi_check_patch_applicable( MSIPACKAGE *package, MSISUMMARYINFO *si )
476 static const WCHAR szProdID[] = { 'P','r','o','d','u','c','t','I','D',0 };
477 LPWSTR guid_list, *guids, product_id;
478 UINT i, ret = ERROR_FUNCTION_FAILED;
480 product_id = msi_dup_property( package, szProdID );
481 if (!product_id)
483 /* FIXME: the property ProductID should be written into the DB somewhere */
484 ERR("no product ID to check\n");
485 return ERROR_SUCCESS;
488 guid_list = msi_suminfo_dup_string( si, PID_TEMPLATE );
489 guids = msi_split_string( guid_list, ';' );
490 for ( i = 0; guids[i] && ret != ERROR_SUCCESS; i++ )
492 if (!lstrcmpW( guids[i], product_id ))
493 ret = ERROR_SUCCESS;
495 msi_free( guids );
496 msi_free( guid_list );
497 msi_free( product_id );
499 return ret;
502 static UINT msi_parse_patch_summary( MSIPACKAGE *package, MSIDATABASE *patch_db )
504 MSISUMMARYINFO *si;
505 LPWSTR str, *substorage;
506 UINT i, r = ERROR_SUCCESS;
508 si = MSI_GetSummaryInformationW( patch_db, 0 );
509 if (!si)
510 return ERROR_FUNCTION_FAILED;
512 msi_check_patch_applicable( package, si );
514 /* enumerate the substorage */
515 str = msi_suminfo_dup_string( si, PID_LASTAUTHOR );
516 substorage = msi_split_string( str, ';' );
517 for ( i = 0; substorage && substorage[i] && r == ERROR_SUCCESS; i++ )
518 r = msi_apply_substorage_transform( package, patch_db, substorage[i] );
519 msi_free( substorage );
520 msi_free( str );
522 /* FIXME: parse the sources in PID_REVNUMBER and do something with them... */
524 msiobj_release( &si->hdr );
526 return r;
529 static UINT msi_apply_patch_package( MSIPACKAGE *package, LPCWSTR file )
531 MSIDATABASE *patch_db = NULL;
532 UINT r;
534 TRACE("%p %s\n", package, debugstr_w( file ) );
536 /* FIXME:
537 * We probably want to make sure we only open a patch collection here.
538 * Patch collections (.msp) and databases (.msi) have different GUIDs
539 * but currently MSI_OpenDatabaseW will accept both.
541 r = MSI_OpenDatabaseW( file, MSIDBOPEN_READONLY, &patch_db );
542 if ( r != ERROR_SUCCESS )
544 ERR("failed to open patch collection %s\n", debugstr_w( file ) );
545 return r;
548 msi_parse_patch_summary( package, patch_db );
549 msiobj_release( &patch_db->hdr );
551 return ERROR_SUCCESS;
554 /* get the PATCH property, and apply all the patches it specifies */
555 static UINT msi_apply_patches( MSIPACKAGE *package )
557 static const WCHAR szPatch[] = { 'P','A','T','C','H',0 };
558 LPWSTR patch_list, *patches;
559 UINT i, r = ERROR_SUCCESS;
561 patch_list = msi_dup_property( package, szPatch );
563 TRACE("patches to be applied: %s\n", debugstr_w( patch_list ) );
565 patches = msi_split_string( patch_list, ';' );
566 for( i=0; patches && patches[i] && r == ERROR_SUCCESS; i++ )
567 r = msi_apply_patch_package( package, patches[i] );
569 msi_free( patches );
570 msi_free( patch_list );
572 return r;
575 /****************************************************
576 * TOP level entry points
577 *****************************************************/
579 UINT MSI_InstallPackage( MSIPACKAGE *package, LPCWSTR szPackagePath,
580 LPCWSTR szCommandLine )
582 UINT rc;
583 BOOL ui = FALSE;
584 static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0};
585 static const WCHAR szAction[] = {'A','C','T','I','O','N',0};
586 static const WCHAR szInstall[] = {'I','N','S','T','A','L','L',0};
588 MSI_SetPropertyW(package, szAction, szInstall);
590 package->script = msi_alloc(sizeof(MSISCRIPT));
591 memset(package->script,0,sizeof(MSISCRIPT));
593 package->script->InWhatSequence = SEQUENCE_INSTALL;
595 if (szPackagePath)
597 LPWSTR p, check, path;
599 package->PackagePath = strdupW(szPackagePath);
600 path = strdupW(szPackagePath);
601 p = strrchrW(path,'\\');
602 if (p)
604 p++;
605 *p=0;
607 else
609 msi_free(path);
610 path = msi_alloc(MAX_PATH*sizeof(WCHAR));
611 GetCurrentDirectoryW(MAX_PATH,path);
612 strcatW(path,cszbs);
615 check = msi_dup_property( package, cszSourceDir );
616 if (!check)
617 MSI_SetPropertyW(package, cszSourceDir, path);
618 msi_free(check);
619 msi_free(path);
622 msi_parse_command_line( package, szCommandLine );
624 msi_apply_patches( package );
626 if ( msi_get_property_int(package, szUILevel, 0) >= INSTALLUILEVEL_REDUCED )
628 package->script->InWhatSequence |= SEQUENCE_UI;
629 rc = ACTION_ProcessUISequence(package);
630 ui = TRUE;
631 if (rc == ERROR_SUCCESS)
633 package->script->InWhatSequence |= SEQUENCE_EXEC;
634 rc = ACTION_ProcessExecSequence(package,TRUE);
637 else
638 rc = ACTION_ProcessExecSequence(package,FALSE);
640 if (rc == -1)
642 /* install was halted but should be considered a success */
643 rc = ERROR_SUCCESS;
646 package->script->CurrentlyScripting= FALSE;
648 /* process the ending type action */
649 if (rc == ERROR_SUCCESS)
650 ACTION_PerformActionSequence(package,-1,ui);
651 else if (rc == ERROR_INSTALL_USEREXIT)
652 ACTION_PerformActionSequence(package,-2,ui);
653 else if (rc == ERROR_INSTALL_SUSPEND)
654 ACTION_PerformActionSequence(package,-4,ui);
655 else /* failed */
656 ACTION_PerformActionSequence(package,-3,ui);
658 /* finish up running custom actions */
659 ACTION_FinishCustomActions(package);
661 return rc;
664 static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq, BOOL UI)
666 UINT rc = ERROR_SUCCESS;
667 MSIRECORD * row = 0;
668 static const WCHAR ExecSeqQuery[] =
669 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
670 '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
671 'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
672 '`','S','e','q','u','e','n','c','e','`',' ', '=',' ','%','i',0};
674 static const WCHAR UISeqQuery[] =
675 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
676 '`','I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e',
677 '`', ' ', 'W','H','E','R','E',' ','`','S','e','q','u','e','n','c','e','`',
678 ' ', '=',' ','%','i',0};
680 if (UI)
681 row = MSI_QueryGetRecord(package->db, UISeqQuery, seq);
682 else
683 row = MSI_QueryGetRecord(package->db, ExecSeqQuery, seq);
685 if (row)
687 LPCWSTR action, cond;
689 TRACE("Running the actions\n");
691 /* check conditions */
692 cond = MSI_RecordGetString(row,2);
693 if (cond)
695 /* this is a hack to skip errors in the condition code */
696 if (MSI_EvaluateConditionW(package, cond) == MSICONDITION_FALSE)
697 goto end;
700 action = MSI_RecordGetString(row,1);
701 if (!action)
703 ERR("failed to fetch action\n");
704 rc = ERROR_FUNCTION_FAILED;
705 goto end;
708 if (UI)
709 rc = ACTION_PerformUIAction(package,action);
710 else
711 rc = ACTION_PerformAction(package,action,FALSE);
712 end:
713 msiobj_release(&row->hdr);
715 else
716 rc = ERROR_SUCCESS;
718 return rc;
721 typedef struct {
722 MSIPACKAGE* package;
723 BOOL UI;
724 } iterate_action_param;
726 static UINT ITERATE_Actions(MSIRECORD *row, LPVOID param)
728 iterate_action_param *iap= (iterate_action_param*)param;
729 UINT rc;
730 LPCWSTR cond, action;
732 action = MSI_RecordGetString(row,1);
733 if (!action)
735 ERR("Error is retrieving action name\n");
736 return ERROR_FUNCTION_FAILED;
739 /* check conditions */
740 cond = MSI_RecordGetString(row,2);
741 if (cond)
743 /* this is a hack to skip errors in the condition code */
744 if (MSI_EvaluateConditionW(iap->package, cond) == MSICONDITION_FALSE)
746 TRACE("Skipping action: %s (condition is false)\n",
747 debugstr_w(action));
748 return ERROR_SUCCESS;
752 if (iap->UI)
753 rc = ACTION_PerformUIAction(iap->package,action);
754 else
755 rc = ACTION_PerformAction(iap->package,action,FALSE);
757 msi_dialog_check_messages( NULL );
759 if (iap->package->CurrentInstallState != ERROR_SUCCESS )
760 rc = iap->package->CurrentInstallState;
762 if (rc == ERROR_FUNCTION_NOT_CALLED)
763 rc = ERROR_SUCCESS;
765 if (rc != ERROR_SUCCESS)
766 ERR("Execution halted due to error (%i)\n",rc);
768 return rc;
771 UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode )
773 MSIQUERY * view;
774 UINT r;
775 static const WCHAR query[] =
776 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
777 '`','%','s','`',
778 ' ','W','H','E','R','E',' ',
779 '`','S','e','q','u','e','n','c','e','`',' ',
780 '>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
781 '`','S','e','q','u','e','n','c','e','`',0};
782 iterate_action_param iap;
785 * FIXME: probably should be checking UILevel in the
786 * ACTION_PerformUIAction/ACTION_PerformAction
787 * rather than saving the UI level here. Those
788 * two functions can be merged too.
790 iap.package = package;
791 iap.UI = TRUE;
793 TRACE("%p %s %i\n", package, debugstr_w(szTable), iSequenceMode );
795 r = MSI_OpenQuery( package->db, &view, query, szTable );
796 if (r == ERROR_SUCCESS)
798 r = MSI_IterateRecords( view, NULL, ITERATE_Actions, &iap );
799 msiobj_release(&view->hdr);
802 return r;
805 static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran)
807 MSIQUERY * view;
808 UINT rc;
809 static const WCHAR ExecSeqQuery[] =
810 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
811 '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
812 'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
813 '`','S','e','q','u','e','n','c','e','`',' ', '>',' ','%','i',' ',
814 'O','R','D','E','R',' ', 'B','Y',' ',
815 '`','S','e','q','u','e','n','c','e','`',0 };
816 MSIRECORD * row = 0;
817 static const WCHAR IVQuery[] =
818 {'S','E','L','E','C','T',' ','`','S','e','q','u','e','n','c','e','`',
819 ' ', 'F','R','O','M',' ','`','I','n','s','t','a','l','l',
820 'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e','`',' ',
821 'W','H','E','R','E',' ','`','A','c','t','i','o','n','`',' ','=',
822 ' ','\'', 'I','n','s','t','a','l','l',
823 'V','a','l','i','d','a','t','e','\'', 0};
824 INT seq = 0;
825 iterate_action_param iap;
827 iap.package = package;
828 iap.UI = FALSE;
830 if (package->script->ExecuteSequenceRun)
832 TRACE("Execute Sequence already Run\n");
833 return ERROR_SUCCESS;
836 package->script->ExecuteSequenceRun = TRUE;
838 /* get the sequence number */
839 if (UIran)
841 row = MSI_QueryGetRecord(package->db, IVQuery);
842 if( !row )
843 return ERROR_FUNCTION_FAILED;
844 seq = MSI_RecordGetInteger(row,1);
845 msiobj_release(&row->hdr);
848 rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, seq);
849 if (rc == ERROR_SUCCESS)
851 TRACE("Running the actions\n");
853 rc = MSI_IterateRecords(view, NULL, ITERATE_Actions, &iap);
854 msiobj_release(&view->hdr);
857 return rc;
860 static UINT ACTION_ProcessUISequence(MSIPACKAGE *package)
862 MSIQUERY * view;
863 UINT rc;
864 static const WCHAR ExecSeqQuery [] =
865 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
866 '`','I','n','s','t','a','l','l',
867 'U','I','S','e','q','u','e','n','c','e','`',
868 ' ','W','H','E','R','E',' ',
869 '`','S','e','q','u','e','n','c','e','`',' ',
870 '>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
871 '`','S','e','q','u','e','n','c','e','`',0};
872 iterate_action_param iap;
874 iap.package = package;
875 iap.UI = TRUE;
877 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
879 if (rc == ERROR_SUCCESS)
881 TRACE("Running the actions \n");
883 rc = MSI_IterateRecords(view, NULL, ITERATE_Actions, &iap);
884 msiobj_release(&view->hdr);
887 return rc;
890 /********************************************************
891 * ACTION helper functions and functions that perform the actions
892 *******************************************************/
893 static BOOL ACTION_HandleStandardAction(MSIPACKAGE *package, LPCWSTR action,
894 UINT* rc, BOOL force )
896 BOOL ret = FALSE;
897 BOOL run = force;
898 int i;
900 if (!run && !package->script->CurrentlyScripting)
901 run = TRUE;
903 if (!run)
905 if (strcmpW(action,szInstallFinalize) == 0 ||
906 strcmpW(action,szInstallExecute) == 0 ||
907 strcmpW(action,szInstallExecuteAgain) == 0)
908 run = TRUE;
911 i = 0;
912 while (StandardActions[i].action != NULL)
914 if (strcmpW(StandardActions[i].action, action)==0)
916 if (!run)
918 ui_actioninfo(package, action, TRUE, 0);
919 *rc = schedule_action(package,INSTALL_SCRIPT,action);
920 ui_actioninfo(package, action, FALSE, *rc);
922 else
924 ui_actionstart(package, action);
925 if (StandardActions[i].handler)
927 *rc = StandardActions[i].handler(package);
929 else
931 FIXME("unhandled standard action %s\n",debugstr_w(action));
932 *rc = ERROR_SUCCESS;
935 ret = TRUE;
936 break;
938 i++;
940 return ret;
943 static BOOL ACTION_HandleCustomAction( MSIPACKAGE* package, LPCWSTR action,
944 UINT* rc, BOOL force )
946 BOOL ret=FALSE;
947 UINT arc;
949 arc = ACTION_CustomAction(package,action, force);
951 if (arc != ERROR_CALL_NOT_IMPLEMENTED)
953 *rc = arc;
954 ret = TRUE;
956 return ret;
960 * A lot of actions are really important even if they don't do anything
961 * explicit... Lots of properties are set at the beginning of the installation
962 * CostFinalize does a bunch of work to translate the directories and such
964 * But until I get write access to the database that is hard, so I am going to
965 * hack it to see if I can get something to run.
967 UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, BOOL force)
969 UINT rc = ERROR_SUCCESS;
970 BOOL handled;
972 TRACE("Performing action (%s)\n",debugstr_w(action));
974 handled = ACTION_HandleStandardAction(package, action, &rc, force);
976 if (!handled)
977 handled = ACTION_HandleCustomAction(package, action, &rc, force);
979 if (!handled)
981 FIXME("unhandled msi action %s\n",debugstr_w(action));
982 rc = ERROR_FUNCTION_NOT_CALLED;
985 return rc;
988 UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action)
990 UINT rc = ERROR_SUCCESS;
991 BOOL handled = FALSE;
993 TRACE("Performing action (%s)\n",debugstr_w(action));
995 handled = ACTION_HandleStandardAction(package, action, &rc,TRUE);
997 if (!handled)
998 handled = ACTION_HandleCustomAction(package, action, &rc, FALSE);
1000 if( !handled && ACTION_DialogBox(package,action) == ERROR_SUCCESS )
1001 handled = TRUE;
1003 if (!handled)
1005 FIXME("unhandled msi action %s\n",debugstr_w(action));
1006 rc = ERROR_FUNCTION_NOT_CALLED;
1009 return rc;
1014 * Actual Action Handlers
1017 static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param)
1019 MSIPACKAGE *package = (MSIPACKAGE*)param;
1020 LPCWSTR dir;
1021 LPWSTR full_path;
1022 MSIRECORD *uirow;
1023 MSIFOLDER *folder;
1025 dir = MSI_RecordGetString(row,1);
1026 if (!dir)
1028 ERR("Unable to get folder id \n");
1029 return ERROR_SUCCESS;
1032 full_path = resolve_folder(package,dir,FALSE,FALSE,&folder);
1033 if (!full_path)
1035 ERR("Unable to resolve folder id %s\n",debugstr_w(dir));
1036 return ERROR_SUCCESS;
1039 TRACE("Folder is %s\n",debugstr_w(full_path));
1041 /* UI stuff */
1042 uirow = MSI_CreateRecord(1);
1043 MSI_RecordSetStringW(uirow,1,full_path);
1044 ui_actiondata(package,szCreateFolders,uirow);
1045 msiobj_release( &uirow->hdr );
1047 if (folder->State == 0)
1048 create_full_pathW(full_path);
1050 folder->State = 3;
1052 msi_free(full_path);
1053 return ERROR_SUCCESS;
1058 * Also we cannot enable/disable components either, so for now I am just going
1059 * to do all the directories for all the components.
1061 static UINT ACTION_CreateFolders(MSIPACKAGE *package)
1063 static const WCHAR ExecSeqQuery[] =
1064 {'S','E','L','E','C','T',' ',
1065 '`','D','i','r','e','c','t','o','r','y','_','`',
1066 ' ','F','R','O','M',' ',
1067 '`','C','r','e','a','t','e','F','o','l','d','e','r','`',0 };
1068 UINT rc;
1069 MSIQUERY *view;
1071 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view );
1072 if (rc != ERROR_SUCCESS)
1073 return ERROR_SUCCESS;
1075 rc = MSI_IterateRecords(view, NULL, ITERATE_CreateFolders, package);
1076 msiobj_release(&view->hdr);
1078 return rc;
1081 static MSICOMPONENT* load_component( MSIRECORD * row )
1083 MSICOMPONENT *comp;
1085 comp = msi_alloc_zero( sizeof(MSICOMPONENT) );
1086 if (!comp)
1087 return comp;
1089 /* fill in the data */
1090 comp->Component = load_dynamic_stringW( row, 1 );
1092 TRACE("Loading Component %s\n", debugstr_w(comp->Component));
1094 comp->ComponentId = load_dynamic_stringW( row, 2 );
1095 comp->Directory = load_dynamic_stringW( row, 3 );
1096 comp->Attributes = MSI_RecordGetInteger(row,4);
1097 comp->Condition = load_dynamic_stringW( row, 5 );
1098 comp->KeyPath = load_dynamic_stringW( row, 6 );
1100 comp->Installed = INSTALLSTATE_ABSENT;
1101 comp->Action = INSTALLSTATE_UNKNOWN;
1102 comp->ActionRequest = INSTALLSTATE_UNKNOWN;
1104 comp->Enabled = TRUE;
1106 return comp;
1109 typedef struct {
1110 MSIPACKAGE *package;
1111 MSIFEATURE *feature;
1112 } _ilfs;
1114 static UINT add_feature_component( MSIFEATURE *feature, MSICOMPONENT *comp )
1116 ComponentList *cl;
1118 cl = msi_alloc( sizeof (*cl) );
1119 if ( !cl )
1120 return ERROR_NOT_ENOUGH_MEMORY;
1121 cl->component = comp;
1122 list_add_tail( &feature->Components, &cl->entry );
1124 return ERROR_SUCCESS;
1127 static UINT iterate_component_check( MSIRECORD *row, LPVOID param )
1129 _ilfs* ilfs= (_ilfs*)param;
1130 MSIPACKAGE *package = ilfs->package;
1131 MSIFEATURE *feature = ilfs->feature;
1132 MSICOMPONENT *comp;
1134 comp = load_component( row );
1135 if (!comp)
1136 return ERROR_FUNCTION_FAILED;
1138 list_add_tail( &package->components, &comp->entry );
1139 add_feature_component( feature, comp );
1141 TRACE("Loaded new component %p\n", comp);
1143 return ERROR_SUCCESS;
1146 static UINT iterate_load_featurecomponents(MSIRECORD *row, LPVOID param)
1148 _ilfs* ilfs= (_ilfs*)param;
1149 LPCWSTR component;
1150 DWORD rc;
1151 MSICOMPONENT *comp;
1152 MSIQUERY * view;
1153 static const WCHAR Query[] =
1154 {'S','E','L','E','C','T',' ','*',' ','F','R', 'O','M',' ',
1155 '`','C','o','m','p','o','n','e','n','t','`',' ',
1156 'W','H','E','R','E',' ',
1157 '`','C','o','m','p','o','n','e','n','t','`',' ',
1158 '=','\'','%','s','\'',0};
1160 component = MSI_RecordGetString(row,1);
1162 /* check to see if the component is already loaded */
1163 comp = get_loaded_component( ilfs->package, component );
1164 if (comp)
1166 TRACE("Component %s already loaded\n", debugstr_w(component) );
1167 add_feature_component( ilfs->feature, comp );
1168 return ERROR_SUCCESS;
1171 rc = MSI_OpenQuery(ilfs->package->db, &view, Query, component);
1172 if (rc != ERROR_SUCCESS)
1173 return ERROR_SUCCESS;
1175 rc = MSI_IterateRecords(view, NULL, iterate_component_check, ilfs);
1176 msiobj_release( &view->hdr );
1178 return ERROR_SUCCESS;
1181 static UINT load_feature(MSIRECORD * row, LPVOID param)
1183 MSIPACKAGE* package = (MSIPACKAGE*)param;
1184 MSIFEATURE* feature;
1185 static const WCHAR Query1[] =
1186 {'S','E','L','E','C','T',' ',
1187 '`','C','o','m','p','o','n','e','n','t','_','`',
1188 ' ','F','R','O','M',' ','`','F','e','a','t','u','r','e',
1189 'C','o','m','p','o','n','e','n','t','s','`',' ',
1190 'W','H','E','R','E',' ',
1191 '`','F','e', 'a','t','u','r','e','_','`',' ','=','\'','%','s','\'',0};
1192 MSIQUERY * view;
1193 UINT rc;
1194 _ilfs ilfs;
1196 /* fill in the data */
1198 feature = msi_alloc_zero( sizeof (MSIFEATURE) );
1199 if (!feature)
1200 return ERROR_NOT_ENOUGH_MEMORY;
1202 list_init( &feature->Components );
1204 feature->Feature = load_dynamic_stringW( row, 1 );
1206 TRACE("Loading feature %s\n",debugstr_w(feature->Feature));
1208 feature->Feature_Parent = load_dynamic_stringW( row, 2 );
1209 feature->Title = load_dynamic_stringW( row, 3 );
1210 feature->Description = load_dynamic_stringW( row, 4 );
1212 if (!MSI_RecordIsNull(row,5))
1213 feature->Display = MSI_RecordGetInteger(row,5);
1215 feature->Level= MSI_RecordGetInteger(row,6);
1216 feature->Directory = load_dynamic_stringW( row, 7 );
1217 feature->Attributes = MSI_RecordGetInteger(row,8);
1219 feature->Installed = INSTALLSTATE_ABSENT;
1220 feature->Action = INSTALLSTATE_UNKNOWN;
1221 feature->ActionRequest = INSTALLSTATE_UNKNOWN;
1223 list_add_tail( &package->features, &feature->entry );
1225 /* load feature components */
1227 rc = MSI_OpenQuery( package->db, &view, Query1, feature->Feature );
1228 if (rc != ERROR_SUCCESS)
1229 return ERROR_SUCCESS;
1231 ilfs.package = package;
1232 ilfs.feature = feature;
1234 MSI_IterateRecords(view, NULL, iterate_load_featurecomponents , &ilfs);
1235 msiobj_release(&view->hdr);
1237 return ERROR_SUCCESS;
1240 static UINT load_file(MSIRECORD *row, LPVOID param)
1242 MSIPACKAGE* package = (MSIPACKAGE*)param;
1243 LPCWSTR component;
1244 MSIFILE *file;
1246 /* fill in the data */
1248 file = msi_alloc_zero( sizeof (MSIFILE) );
1249 if (!file)
1250 return ERROR_NOT_ENOUGH_MEMORY;
1252 file->File = load_dynamic_stringW( row, 1 );
1254 component = MSI_RecordGetString( row, 2 );
1255 file->Component = get_loaded_component( package, component );
1257 if (!file->Component)
1258 ERR("Unfound Component %s\n",debugstr_w(component));
1260 file->FileName = load_dynamic_stringW( row, 3 );
1261 reduce_to_longfilename( file->FileName );
1263 file->ShortName = load_dynamic_stringW( row, 3 );
1264 reduce_to_shortfilename( file->ShortName );
1266 file->FileSize = MSI_RecordGetInteger( row, 4 );
1267 file->Version = load_dynamic_stringW( row, 5 );
1268 file->Language = load_dynamic_stringW( row, 6 );
1269 file->Attributes = MSI_RecordGetInteger( row, 7 );
1270 file->Sequence = MSI_RecordGetInteger( row, 8 );
1272 file->State = 0;
1274 TRACE("File Loaded (%s)\n",debugstr_w(file->File));
1276 list_add_tail( &package->files, &file->entry );
1278 return ERROR_SUCCESS;
1281 static UINT load_all_files(MSIPACKAGE *package)
1283 MSIQUERY * view;
1284 UINT rc;
1285 static const WCHAR Query[] =
1286 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
1287 '`','F','i','l','e','`',' ', 'O','R','D','E','R',' ','B','Y',' ',
1288 '`','S','e','q','u','e','n','c','e','`', 0};
1290 if (!package)
1291 return ERROR_INVALID_HANDLE;
1293 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
1294 if (rc != ERROR_SUCCESS)
1295 return ERROR_SUCCESS;
1297 rc = MSI_IterateRecords(view, NULL, load_file, package);
1298 msiobj_release(&view->hdr);
1300 return ERROR_SUCCESS;
1305 * I am not doing any of the costing functionality yet.
1306 * Mostly looking at doing the Component and Feature loading
1308 * The native MSI does A LOT of modification to tables here. Mostly adding
1309 * a lot of temporary columns to the Feature and Component tables.
1311 * note: Native msi also tracks the short filename. But I am only going to
1312 * track the long ones. Also looking at this directory table
1313 * it appears that the directory table does not get the parents
1314 * resolved base on property only based on their entries in the
1315 * directory table.
1317 static UINT ACTION_CostInitialize(MSIPACKAGE *package)
1319 MSIQUERY * view;
1320 UINT rc;
1321 static const WCHAR Query_all[] =
1322 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
1323 '`','F','e','a','t','u','r','e','`',0};
1324 static const WCHAR szCosting[] =
1325 {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
1326 static const WCHAR szZero[] = { '0', 0 };
1327 WCHAR buffer[3];
1328 DWORD sz = 3;
1330 MSI_GetPropertyW(package, szCosting, buffer, &sz);
1331 if (buffer[0]=='1')
1332 return ERROR_SUCCESS;
1334 MSI_SetPropertyW(package, szCosting, szZero);
1335 MSI_SetPropertyW(package, cszRootDrive , c_colon);
1337 rc = MSI_DatabaseOpenViewW(package->db,Query_all,&view);
1338 if (rc != ERROR_SUCCESS)
1339 return rc;
1341 rc = MSI_IterateRecords(view, NULL, load_feature, package);
1342 msiobj_release(&view->hdr);
1344 load_all_files(package);
1346 return ERROR_SUCCESS;
1349 static UINT execute_script(MSIPACKAGE *package, UINT script )
1351 int i;
1352 UINT rc = ERROR_SUCCESS;
1354 TRACE("Executing Script %i\n",script);
1356 for (i = 0; i < package->script->ActionCount[script]; i++)
1358 LPWSTR action;
1359 action = package->script->Actions[script][i];
1360 ui_actionstart(package, action);
1361 TRACE("Executing Action (%s)\n",debugstr_w(action));
1362 rc = ACTION_PerformAction(package, action, TRUE);
1363 msi_free(package->script->Actions[script][i]);
1364 if (rc != ERROR_SUCCESS)
1365 break;
1367 msi_free(package->script->Actions[script]);
1369 package->script->ActionCount[script] = 0;
1370 package->script->Actions[script] = NULL;
1371 return rc;
1374 static UINT ACTION_FileCost(MSIPACKAGE *package)
1376 return ERROR_SUCCESS;
1380 static MSIFOLDER *load_folder( MSIPACKAGE *package, LPCWSTR dir )
1382 static const WCHAR Query[] =
1383 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1384 '`','D','i','r','e','c', 't','o','r','y','`',' ',
1385 'W','H','E','R','E',' ', '`', 'D','i','r','e','c','t', 'o','r','y','`',
1386 ' ','=',' ','\'','%','s','\'',
1388 LPWSTR ptargetdir, targetdir, srcdir;
1389 LPCWSTR parent;
1390 LPWSTR shortname = NULL;
1391 MSIRECORD * row = 0;
1392 MSIFOLDER *folder;
1394 TRACE("Looking for dir %s\n",debugstr_w(dir));
1396 folder = get_loaded_folder( package, dir );
1397 if (folder)
1398 return folder;
1400 TRACE("Working to load %s\n",debugstr_w(dir));
1402 folder = msi_alloc_zero( sizeof (MSIFOLDER) );
1403 if (!folder)
1404 return NULL;
1406 folder->Directory = strdupW(dir);
1408 row = MSI_QueryGetRecord(package->db, Query, dir);
1409 if (!row)
1410 return NULL;
1412 ptargetdir = targetdir = load_dynamic_stringW(row,3);
1414 /* split src and target dir */
1415 if (strchrW(targetdir,':'))
1417 srcdir=strchrW(targetdir,':');
1418 *srcdir=0;
1419 srcdir ++;
1421 else
1422 srcdir=NULL;
1424 /* for now only pick long filename versions */
1425 if (strchrW(targetdir,'|'))
1427 shortname = targetdir;
1428 targetdir = strchrW(targetdir,'|');
1429 *targetdir = 0;
1430 targetdir ++;
1432 /* for the sourcedir pick the short filename */
1433 if (srcdir && strchrW(srcdir,'|'))
1435 LPWSTR p = strchrW(srcdir,'|');
1436 *p = 0;
1439 /* now check for root dirs */
1440 if (targetdir[0] == '.' && targetdir[1] == 0)
1441 targetdir = NULL;
1443 if (targetdir)
1445 TRACE(" TargetDefault = %s\n",debugstr_w(targetdir));
1446 msi_free( folder->TargetDefault);
1447 folder->TargetDefault = strdupW(targetdir);
1450 if (srcdir)
1451 folder->SourceDefault = strdupW(srcdir);
1452 else if (shortname)
1453 folder->SourceDefault = strdupW(shortname);
1454 else if (targetdir)
1455 folder->SourceDefault = strdupW(targetdir);
1456 msi_free(ptargetdir);
1457 TRACE(" SourceDefault = %s\n", debugstr_w( folder->SourceDefault ));
1459 parent = MSI_RecordGetString(row,2);
1460 if (parent)
1462 folder->Parent = load_folder( package, parent );
1463 if ( folder->Parent )
1464 TRACE("loaded parent %p %s\n", folder->Parent,
1465 debugstr_w(folder->Parent->Directory));
1466 else
1467 ERR("failed to load parent folder %s\n", debugstr_w(parent));
1470 folder->Property = msi_dup_property( package, dir );
1472 msiobj_release(&row->hdr);
1474 list_add_tail( &package->folders, &folder->entry );
1476 TRACE("%s returning %p\n",debugstr_w(dir),folder);
1478 return folder;
1481 /* scan for and update current install states */
1482 static void ACTION_UpdateInstallStates(MSIPACKAGE *package)
1484 MSICOMPONENT *comp;
1485 MSIFEATURE *feature;
1487 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
1489 INSTALLSTATE res;
1490 res = MsiGetComponentPathW( package->ProductCode,
1491 comp->ComponentId, NULL, NULL);
1492 if (res < 0)
1493 res = INSTALLSTATE_ABSENT;
1494 comp->Installed = res;
1497 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1499 ComponentList *cl;
1500 INSTALLSTATE res = -10;
1502 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
1504 comp= cl->component;
1506 if (res == -10)
1507 res = comp->Installed;
1508 else
1510 if (res == comp->Installed)
1511 continue;
1513 if (res != comp->Installed)
1514 res = INSTALLSTATE_INCOMPLETE;
1517 feature->Installed = res;
1521 static BOOL process_state_property (MSIPACKAGE* package, LPCWSTR property,
1522 INSTALLSTATE state)
1524 static const WCHAR all[]={'A','L','L',0};
1525 LPWSTR override;
1526 MSIFEATURE *feature;
1528 override = msi_dup_property( package, property );
1529 if (!override)
1530 return FALSE;
1532 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1534 if (strcmpiW(override,all)==0)
1536 feature->ActionRequest= state;
1537 feature->Action = state;
1539 else
1541 LPWSTR ptr = override;
1542 LPWSTR ptr2 = strchrW(override,',');
1544 while (ptr)
1546 if ((ptr2 && strncmpW(ptr,feature->Feature, ptr2-ptr)==0)
1547 || (!ptr2 && strcmpW(ptr,feature->Feature)==0))
1549 feature->ActionRequest= state;
1550 feature->Action = state;
1551 break;
1553 if (ptr2)
1555 ptr=ptr2+1;
1556 ptr2 = strchrW(ptr,',');
1558 else
1559 break;
1563 msi_free(override);
1565 return TRUE;
1568 static UINT SetFeatureStates(MSIPACKAGE *package)
1570 int install_level;
1571 static const WCHAR szlevel[] =
1572 {'I','N','S','T','A','L','L','L','E','V','E','L',0};
1573 static const WCHAR szAddLocal[] =
1574 {'A','D','D','L','O','C','A','L',0};
1575 static const WCHAR szRemove[] =
1576 {'R','E','M','O','V','E',0};
1577 BOOL override = FALSE;
1578 MSICOMPONENT* component;
1579 MSIFEATURE *feature;
1582 /* I do not know if this is where it should happen.. but */
1584 TRACE("Checking Install Level\n");
1586 install_level = msi_get_property_int( package, szlevel, 1 );
1588 /* ok hereis the _real_ rub
1589 * all these activation/deactivation things happen in order and things
1590 * later on the list override things earlier on the list.
1591 * 1) INSTALLLEVEL processing
1592 * 2) ADDLOCAL
1593 * 3) REMOVE
1594 * 4) ADDSOURCE
1595 * 5) ADDDEFAULT
1596 * 6) REINSTALL
1597 * 7) COMPADDLOCAL
1598 * 8) COMPADDSOURCE
1599 * 9) FILEADDLOCAL
1600 * 10) FILEADDSOURCE
1601 * 11) FILEADDDEFAULT
1602 * I have confirmed that if ADDLOCAL is stated then the INSTALLLEVEL is
1603 * ignored for all the features. seems strange, especially since it is not
1604 * documented anywhere, but it is how it works.
1606 * I am still ignoring a lot of these. But that is ok for now, ADDLOCAL and
1607 * REMOVE are the big ones, since we don't handle administrative installs
1608 * yet anyway.
1610 override |= process_state_property(package,szAddLocal,INSTALLSTATE_LOCAL);
1611 override |= process_state_property(package,szRemove,INSTALLSTATE_ABSENT);
1613 if (!override)
1615 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1617 BOOL feature_state = ((feature->Level > 0) &&
1618 (feature->Level <= install_level));
1620 if ((feature_state) && (feature->Action == INSTALLSTATE_UNKNOWN))
1622 if (feature->Attributes & msidbFeatureAttributesFavorSource)
1624 feature->ActionRequest = INSTALLSTATE_SOURCE;
1625 feature->Action = INSTALLSTATE_SOURCE;
1627 else if (feature->Attributes & msidbFeatureAttributesFavorAdvertise)
1629 feature->ActionRequest = INSTALLSTATE_ADVERTISED;
1630 feature->Action = INSTALLSTATE_ADVERTISED;
1632 else
1634 feature->ActionRequest = INSTALLSTATE_LOCAL;
1635 feature->Action = INSTALLSTATE_LOCAL;
1640 else
1642 /* set the Preselected Property */
1643 static const WCHAR szPreselected[] = {'P','r','e','s','e','l','e','c','t','e','d',0};
1644 static const WCHAR szOne[] = { '1', 0 };
1646 MSI_SetPropertyW(package,szPreselected,szOne);
1650 * now we want to enable or disable components base on feature
1653 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1655 ComponentList *cl;
1657 TRACE("Examining Feature %s (Installed %i, Action %i, Request %i)\n",
1658 debugstr_w(feature->Feature), feature->Installed, feature->Action,
1659 feature->ActionRequest);
1661 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
1663 component = cl->component;
1665 if (!component->Enabled)
1667 component->Action = INSTALLSTATE_UNKNOWN;
1668 component->ActionRequest = INSTALLSTATE_UNKNOWN;
1670 else
1672 if (feature->Action == INSTALLSTATE_LOCAL)
1674 component->Action = INSTALLSTATE_LOCAL;
1675 component->ActionRequest = INSTALLSTATE_LOCAL;
1677 else if (feature->ActionRequest == INSTALLSTATE_SOURCE)
1679 if ((component->Action == INSTALLSTATE_UNKNOWN) ||
1680 (component->Action == INSTALLSTATE_ABSENT) ||
1681 (component->Action == INSTALLSTATE_ADVERTISED))
1684 component->Action = INSTALLSTATE_SOURCE;
1685 component->ActionRequest = INSTALLSTATE_SOURCE;
1688 else if (feature->ActionRequest == INSTALLSTATE_ADVERTISED)
1690 if ((component->Action == INSTALLSTATE_UNKNOWN) ||
1691 (component->Action == INSTALLSTATE_ABSENT))
1694 component->Action = INSTALLSTATE_ADVERTISED;
1695 component->ActionRequest = INSTALLSTATE_ADVERTISED;
1698 else if (feature->ActionRequest == INSTALLSTATE_ABSENT)
1700 if (component->Action == INSTALLSTATE_UNKNOWN)
1702 component->Action = INSTALLSTATE_ABSENT;
1703 component->ActionRequest = INSTALLSTATE_ABSENT;
1710 LIST_FOR_EACH_ENTRY( component, &package->components, MSICOMPONENT, entry )
1712 TRACE("Result: Component %s (Installed %i, Action %i, Request %i)\n",
1713 debugstr_w(component->Component), component->Installed,
1714 component->Action, component->ActionRequest);
1718 return ERROR_SUCCESS;
1721 static UINT ITERATE_CostFinalizeDirectories(MSIRECORD *row, LPVOID param)
1723 MSIPACKAGE *package = (MSIPACKAGE*)param;
1724 LPCWSTR name;
1725 LPWSTR path;
1727 name = MSI_RecordGetString(row,1);
1729 /* This helper function now does ALL the work */
1730 TRACE("Dir %s ...\n",debugstr_w(name));
1731 load_folder(package,name);
1732 path = resolve_folder(package,name,FALSE,TRUE,NULL);
1733 TRACE("resolves to %s\n",debugstr_w(path));
1734 msi_free(path);
1736 return ERROR_SUCCESS;
1739 static UINT ITERATE_CostFinalizeConditions(MSIRECORD *row, LPVOID param)
1741 MSIPACKAGE *package = (MSIPACKAGE*)param;
1742 LPCWSTR name;
1743 MSIFEATURE *feature;
1745 name = MSI_RecordGetString( row, 1 );
1747 feature = get_loaded_feature( package, name );
1748 if (!feature)
1749 ERR("FAILED to find loaded feature %s\n",debugstr_w(name));
1750 else
1752 LPCWSTR Condition;
1753 Condition = MSI_RecordGetString(row,3);
1755 if (MSI_EvaluateConditionW(package,Condition) == MSICONDITION_TRUE)
1757 int level = MSI_RecordGetInteger(row,2);
1758 TRACE("Reseting feature %s to level %i\n", debugstr_w(name), level);
1759 feature->Level = level;
1762 return ERROR_SUCCESS;
1767 * A lot is done in this function aside from just the costing.
1768 * The costing needs to be implemented at some point but for now I am going
1769 * to focus on the directory building
1772 static UINT ACTION_CostFinalize(MSIPACKAGE *package)
1774 static const WCHAR ExecSeqQuery[] =
1775 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1776 '`','D','i','r','e','c','t','o','r','y','`',0};
1777 static const WCHAR ConditionQuery[] =
1778 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1779 '`','C','o','n','d','i','t','i','o','n','`',0};
1780 static const WCHAR szCosting[] =
1781 {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
1782 static const WCHAR szlevel[] =
1783 {'I','N','S','T','A','L','L','L','E','V','E','L',0};
1784 static const WCHAR szOne[] = { '1', 0 };
1785 MSICOMPONENT *comp;
1786 MSIFILE *file;
1787 UINT rc;
1788 MSIQUERY * view;
1789 LPWSTR level;
1790 DWORD sz = 3;
1791 WCHAR buffer[3];
1793 MSI_GetPropertyW(package, szCosting, buffer, &sz);
1794 if (buffer[0]=='1')
1795 return ERROR_SUCCESS;
1797 TRACE("Building Directory properties\n");
1799 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
1800 if (rc == ERROR_SUCCESS)
1802 rc = MSI_IterateRecords(view, NULL, ITERATE_CostFinalizeDirectories,
1803 package);
1804 msiobj_release(&view->hdr);
1807 TRACE("File calculations\n");
1809 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
1811 MSICOMPONENT* comp = file->Component;
1812 LPWSTR p;
1814 if (!comp)
1815 continue;
1817 /* calculate target */
1818 p = resolve_folder(package, comp->Directory, FALSE, FALSE, NULL);
1820 msi_free(file->TargetPath);
1822 TRACE("file %s is named %s\n",
1823 debugstr_w(file->File),debugstr_w(file->FileName));
1825 file->TargetPath = build_directory_name(2, p, file->FileName);
1827 msi_free(p);
1829 TRACE("file %s resolves to %s\n",
1830 debugstr_w(file->File),debugstr_w(file->TargetPath));
1832 if (GetFileAttributesW(file->TargetPath) == INVALID_FILE_ATTRIBUTES)
1834 file->State = 1;
1835 comp->Cost += file->FileSize;
1836 continue;
1839 if (file->Version)
1841 DWORD handle;
1842 DWORD versize;
1843 UINT sz;
1844 LPVOID version;
1845 static const WCHAR name[] =
1846 {'\\',0};
1847 static const WCHAR name_fmt[] =
1848 {'%','u','.','%','u','.','%','u','.','%','u',0};
1849 WCHAR filever[0x100];
1850 VS_FIXEDFILEINFO *lpVer;
1852 TRACE("Version comparison.. \n");
1853 versize = GetFileVersionInfoSizeW(file->TargetPath,&handle);
1854 version = msi_alloc(versize);
1855 GetFileVersionInfoW(file->TargetPath, 0, versize, version);
1857 VerQueryValueW(version, name, (LPVOID*)&lpVer, &sz);
1859 sprintfW(filever,name_fmt,
1860 HIWORD(lpVer->dwFileVersionMS),
1861 LOWORD(lpVer->dwFileVersionMS),
1862 HIWORD(lpVer->dwFileVersionLS),
1863 LOWORD(lpVer->dwFileVersionLS));
1865 TRACE("new %s old %s\n", debugstr_w(file->Version),
1866 debugstr_w(filever));
1867 if (strcmpiW(filever,file->Version)<0)
1869 file->State = 2;
1870 FIXME("cost should be diff in size\n");
1871 comp->Cost += file->FileSize;
1873 else
1874 file->State = 3;
1875 msi_free(version);
1877 else
1878 file->State = 3;
1881 TRACE("Evaluating Condition Table\n");
1883 rc = MSI_DatabaseOpenViewW(package->db, ConditionQuery, &view);
1884 if (rc == ERROR_SUCCESS)
1886 rc = MSI_IterateRecords(view, NULL, ITERATE_CostFinalizeConditions,
1887 package);
1888 msiobj_release(&view->hdr);
1891 TRACE("Enabling or Disabling Components\n");
1892 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
1894 if (comp->Condition)
1896 if (MSI_EvaluateConditionW(package,
1897 comp->Condition) == MSICONDITION_FALSE)
1899 TRACE("Disabling component %s\n", debugstr_w(comp->Component));
1900 comp->Enabled = FALSE;
1905 MSI_SetPropertyW(package,szCosting,szOne);
1906 /* set default run level if not set */
1907 level = msi_dup_property( package, szlevel );
1908 if (!level)
1909 MSI_SetPropertyW(package,szlevel, szOne);
1910 msi_free(level);
1912 ACTION_UpdateInstallStates(package);
1914 return SetFeatureStates(package);
1917 /* OK this value is "interpreted" and then formatted based on the
1918 first few characters */
1919 static LPSTR parse_value(MSIPACKAGE *package, LPCWSTR value, DWORD *type,
1920 DWORD *size)
1922 LPSTR data = NULL;
1923 if (value[0]=='#' && value[1]!='#' && value[1]!='%')
1925 if (value[1]=='x')
1927 LPWSTR ptr;
1928 CHAR byte[5];
1929 LPWSTR deformated = NULL;
1930 int count;
1932 deformat_string(package, &value[2], &deformated);
1934 /* binary value type */
1935 ptr = deformated;
1936 *type = REG_BINARY;
1937 if (strlenW(ptr)%2)
1938 *size = (strlenW(ptr)/2)+1;
1939 else
1940 *size = strlenW(ptr)/2;
1942 data = msi_alloc(*size);
1944 byte[0] = '0';
1945 byte[1] = 'x';
1946 byte[4] = 0;
1947 count = 0;
1948 /* if uneven pad with a zero in front */
1949 if (strlenW(ptr)%2)
1951 byte[2]= '0';
1952 byte[3]= *ptr;
1953 ptr++;
1954 data[count] = (BYTE)strtol(byte,NULL,0);
1955 count ++;
1956 TRACE("Uneven byte count\n");
1958 while (*ptr)
1960 byte[2]= *ptr;
1961 ptr++;
1962 byte[3]= *ptr;
1963 ptr++;
1964 data[count] = (BYTE)strtol(byte,NULL,0);
1965 count ++;
1967 msi_free(deformated);
1969 TRACE("Data %li bytes(%i)\n",*size,count);
1971 else
1973 LPWSTR deformated;
1974 LPWSTR p;
1975 DWORD d = 0;
1976 deformat_string(package, &value[1], &deformated);
1978 *type=REG_DWORD;
1979 *size = sizeof(DWORD);
1980 data = msi_alloc(*size);
1981 p = deformated;
1982 if (*p == '-')
1983 p++;
1984 while (*p)
1986 if ( (*p < '0') || (*p > '9') )
1987 break;
1988 d *= 10;
1989 d += (*p - '0');
1990 p++;
1992 if (deformated[0] == '-')
1993 d = -d;
1994 *(LPDWORD)data = d;
1995 TRACE("DWORD %li\n",*(LPDWORD)data);
1997 msi_free(deformated);
2000 else
2002 static const WCHAR szMulti[] = {'[','~',']',0};
2003 LPCWSTR ptr;
2004 *type=REG_SZ;
2006 if (value[0]=='#')
2008 if (value[1]=='%')
2010 ptr = &value[2];
2011 *type=REG_EXPAND_SZ;
2013 else
2014 ptr = &value[1];
2016 else
2017 ptr=value;
2019 if (strstrW(value,szMulti))
2020 *type = REG_MULTI_SZ;
2022 *size = deformat_string(package, ptr,(LPWSTR*)&data);
2024 return data;
2027 static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
2029 MSIPACKAGE *package = (MSIPACKAGE*)param;
2030 static const WCHAR szHCR[] =
2031 {'H','K','E','Y','_','C','L','A','S','S','E','S','_',
2032 'R','O','O','T','\\',0};
2033 static const WCHAR szHCU[] =
2034 {'H','K','E','Y','_','C','U','R','R','E','N','T','_',
2035 'U','S','E','R','\\',0};
2036 static const WCHAR szHLM[] =
2037 {'H','K','E','Y','_','L','O','C','A','L','_',
2038 'M','A','C','H','I','N','E','\\',0};
2039 static const WCHAR szHU[] =
2040 {'H','K','E','Y','_','U','S','E','R','S','\\',0};
2042 LPSTR value_data = NULL;
2043 HKEY root_key, hkey;
2044 DWORD type,size;
2045 LPWSTR deformated;
2046 LPCWSTR szRoot, component, name, key, value;
2047 MSICOMPONENT *comp;
2048 MSIRECORD * uirow;
2049 LPWSTR uikey;
2050 INT root;
2051 BOOL check_first = FALSE;
2052 UINT rc;
2054 ui_progress(package,2,0,0,0);
2056 value = NULL;
2057 key = NULL;
2058 uikey = NULL;
2059 name = NULL;
2061 component = MSI_RecordGetString(row, 6);
2062 comp = get_loaded_component(package,component);
2063 if (!comp)
2064 return ERROR_SUCCESS;
2066 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL))
2068 TRACE("Skipping write due to disabled component %s\n",
2069 debugstr_w(component));
2071 comp->Action = comp->Installed;
2073 return ERROR_SUCCESS;
2076 comp->Action = INSTALLSTATE_LOCAL;
2078 name = MSI_RecordGetString(row, 4);
2079 if( MSI_RecordIsNull(row,5) && name )
2081 /* null values can have special meanings */
2082 if (name[0]=='-' && name[1] == 0)
2083 return ERROR_SUCCESS;
2084 else if ((name[0]=='+' && name[1] == 0) ||
2085 (name[0] == '*' && name[1] == 0))
2086 name = NULL;
2087 check_first = TRUE;
2090 root = MSI_RecordGetInteger(row,2);
2091 key = MSI_RecordGetString(row, 3);
2093 /* get the root key */
2094 switch (root)
2096 case -1:
2098 static const WCHAR szALLUSER[] = {'A','L','L','U','S','E','R','S',0};
2099 LPWSTR all_users = msi_dup_property( package, szALLUSER );
2100 if (all_users && all_users[0] == '1')
2102 root_key = HKEY_LOCAL_MACHINE;
2103 szRoot = szHLM;
2105 else
2107 root_key = HKEY_CURRENT_USER;
2108 szRoot = szHCU;
2110 msi_free(all_users);
2112 break;
2113 case 0: root_key = HKEY_CLASSES_ROOT;
2114 szRoot = szHCR;
2115 break;
2116 case 1: root_key = HKEY_CURRENT_USER;
2117 szRoot = szHCU;
2118 break;
2119 case 2: root_key = HKEY_LOCAL_MACHINE;
2120 szRoot = szHLM;
2121 break;
2122 case 3: root_key = HKEY_USERS;
2123 szRoot = szHU;
2124 break;
2125 default:
2126 ERR("Unknown root %i\n",root);
2127 root_key=NULL;
2128 szRoot = NULL;
2129 break;
2131 if (!root_key)
2132 return ERROR_SUCCESS;
2134 deformat_string(package, key , &deformated);
2135 size = strlenW(deformated) + strlenW(szRoot) + 1;
2136 uikey = msi_alloc(size*sizeof(WCHAR));
2137 strcpyW(uikey,szRoot);
2138 strcatW(uikey,deformated);
2140 if (RegCreateKeyW( root_key, deformated, &hkey))
2142 ERR("Could not create key %s\n",debugstr_w(deformated));
2143 msi_free(deformated);
2144 msi_free(uikey);
2145 return ERROR_SUCCESS;
2147 msi_free(deformated);
2149 value = MSI_RecordGetString(row,5);
2150 if (value)
2151 value_data = parse_value(package, value, &type, &size);
2152 else
2154 static const WCHAR szEmpty[] = {0};
2155 value_data = (LPSTR)strdupW(szEmpty);
2156 size = 0;
2157 type = REG_SZ;
2160 deformat_string(package, name, &deformated);
2162 /* get the double nulls to terminate SZ_MULTI */
2163 if (type == REG_MULTI_SZ)
2164 size +=sizeof(WCHAR);
2166 if (!check_first)
2168 TRACE("Setting value %s of %s\n",debugstr_w(deformated),
2169 debugstr_w(uikey));
2170 RegSetValueExW(hkey, deformated, 0, type, (LPBYTE)value_data, size);
2172 else
2174 DWORD sz = 0;
2175 rc = RegQueryValueExW(hkey, deformated, NULL, NULL, NULL, &sz);
2176 if (rc == ERROR_SUCCESS || rc == ERROR_MORE_DATA)
2178 TRACE("value %s of %s checked already exists\n",
2179 debugstr_w(deformated), debugstr_w(uikey));
2181 else
2183 TRACE("Checked and setting value %s of %s\n",
2184 debugstr_w(deformated), debugstr_w(uikey));
2185 if (deformated || size)
2186 RegSetValueExW(hkey, deformated, 0, type, (LPBYTE) value_data, size);
2189 RegCloseKey(hkey);
2191 uirow = MSI_CreateRecord(3);
2192 MSI_RecordSetStringW(uirow,2,deformated);
2193 MSI_RecordSetStringW(uirow,1,uikey);
2195 if (type == REG_SZ)
2196 MSI_RecordSetStringW(uirow,3,(LPWSTR)value_data);
2197 else
2198 MSI_RecordSetStringW(uirow,3,value);
2200 ui_actiondata(package,szWriteRegistryValues,uirow);
2201 msiobj_release( &uirow->hdr );
2203 msi_free(value_data);
2204 msi_free(deformated);
2205 msi_free(uikey);
2207 return ERROR_SUCCESS;
2210 static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package)
2212 UINT rc;
2213 MSIQUERY * view;
2214 static const WCHAR ExecSeqQuery[] =
2215 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2216 '`','R','e','g','i','s','t','r','y','`',0 };
2218 if (!package)
2219 return ERROR_INVALID_HANDLE;
2221 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
2222 if (rc != ERROR_SUCCESS)
2223 return ERROR_SUCCESS;
2225 /* increment progress bar each time action data is sent */
2226 ui_progress(package,1,REG_PROGRESS_VALUE,1,0);
2228 rc = MSI_IterateRecords(view, NULL, ITERATE_WriteRegistryValues, package);
2230 msiobj_release(&view->hdr);
2231 return rc;
2234 static UINT ACTION_InstallInitialize(MSIPACKAGE *package)
2236 package->script->CurrentlyScripting = TRUE;
2238 return ERROR_SUCCESS;
2242 static UINT ACTION_InstallValidate(MSIPACKAGE *package)
2244 MSICOMPONENT *comp;
2245 DWORD progress = 0;
2246 DWORD total = 0;
2247 static const WCHAR q1[]=
2248 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
2249 '`','R','e','g','i','s','t','r','y','`',0};
2250 UINT rc;
2251 MSIQUERY * view;
2252 MSIFEATURE *feature;
2253 MSIFILE *file;
2255 TRACE("InstallValidate\n");
2257 rc = MSI_DatabaseOpenViewW(package->db, q1, &view);
2258 if (rc == ERROR_SUCCESS)
2260 MSI_IterateRecords( view, &progress, NULL, package );
2261 msiobj_release( &view->hdr );
2262 total += progress * REG_PROGRESS_VALUE;
2265 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
2266 total += COMPONENT_PROGRESS_VALUE;
2268 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
2269 total += file->FileSize;
2271 ui_progress(package,0,total,0,0);
2273 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
2275 TRACE("Feature: %s; Installed: %i; Action %i; Request %i\n",
2276 debugstr_w(feature->Feature), feature->Installed, feature->Action,
2277 feature->ActionRequest);
2280 return ERROR_SUCCESS;
2283 static UINT ITERATE_LaunchConditions(MSIRECORD *row, LPVOID param)
2285 MSIPACKAGE* package = (MSIPACKAGE*)param;
2286 LPCWSTR cond = NULL;
2287 LPCWSTR message = NULL;
2288 static const WCHAR title[]=
2289 {'I','n','s','t','a','l','l',' ','F','a', 'i','l','e','d',0};
2291 cond = MSI_RecordGetString(row,1);
2293 if (MSI_EvaluateConditionW(package,cond) != MSICONDITION_TRUE)
2295 LPWSTR deformated;
2296 message = MSI_RecordGetString(row,2);
2297 deformat_string(package,message,&deformated);
2298 MessageBoxW(NULL,deformated,title,MB_OK);
2299 msi_free(deformated);
2300 return ERROR_FUNCTION_FAILED;
2303 return ERROR_SUCCESS;
2306 static UINT ACTION_LaunchConditions(MSIPACKAGE *package)
2308 UINT rc;
2309 MSIQUERY * view = NULL;
2310 static const WCHAR ExecSeqQuery[] =
2311 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2312 '`','L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','`',0};
2314 TRACE("Checking launch conditions\n");
2316 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
2317 if (rc != ERROR_SUCCESS)
2318 return ERROR_SUCCESS;
2320 rc = MSI_IterateRecords(view, NULL, ITERATE_LaunchConditions, package);
2321 msiobj_release(&view->hdr);
2323 return rc;
2326 static LPWSTR resolve_keypath( MSIPACKAGE* package, MSICOMPONENT *cmp )
2329 if (!cmp->KeyPath)
2330 return resolve_folder(package,cmp->Directory,FALSE,FALSE,NULL);
2332 if (cmp->Attributes & msidbComponentAttributesRegistryKeyPath)
2334 MSIRECORD * row = 0;
2335 UINT root,len;
2336 LPWSTR deformated,buffer,deformated_name;
2337 LPCWSTR key,name;
2338 static const WCHAR ExecSeqQuery[] =
2339 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2340 '`','R','e','g','i','s','t','r','y','`',' ',
2341 'W','H','E','R','E',' ', '`','R','e','g','i','s','t','r','y','`',
2342 ' ','=',' ' ,'\'','%','s','\'',0 };
2343 static const WCHAR fmt[]={'%','0','2','i',':','\\','%','s','\\',0};
2344 static const WCHAR fmt2[]=
2345 {'%','0','2','i',':','\\','%','s','\\','%','s',0};
2347 row = MSI_QueryGetRecord(package->db, ExecSeqQuery,cmp->KeyPath);
2348 if (!row)
2349 return NULL;
2351 root = MSI_RecordGetInteger(row,2);
2352 key = MSI_RecordGetString(row, 3);
2353 name = MSI_RecordGetString(row, 4);
2354 deformat_string(package, key , &deformated);
2355 deformat_string(package, name, &deformated_name);
2357 len = strlenW(deformated) + 6;
2358 if (deformated_name)
2359 len+=strlenW(deformated_name);
2361 buffer = msi_alloc( len *sizeof(WCHAR));
2363 if (deformated_name)
2364 sprintfW(buffer,fmt2,root,deformated,deformated_name);
2365 else
2366 sprintfW(buffer,fmt,root,deformated);
2368 msi_free(deformated);
2369 msi_free(deformated_name);
2370 msiobj_release(&row->hdr);
2372 return buffer;
2374 else if (cmp->Attributes & msidbComponentAttributesODBCDataSource)
2376 FIXME("UNIMPLEMENTED keypath as ODBC Source\n");
2377 return NULL;
2379 else
2381 MSIFILE *file = get_loaded_file( package, cmp->KeyPath );
2383 if (file)
2384 return strdupW( file->TargetPath );
2386 return NULL;
2389 static HKEY openSharedDLLsKey(void)
2391 HKEY hkey=0;
2392 static const WCHAR path[] =
2393 {'S','o','f','t','w','a','r','e','\\',
2394 'M','i','c','r','o','s','o','f','t','\\',
2395 'W','i','n','d','o','w','s','\\',
2396 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
2397 'S','h','a','r','e','d','D','L','L','s',0};
2399 RegCreateKeyW(HKEY_LOCAL_MACHINE,path,&hkey);
2400 return hkey;
2403 static UINT ACTION_GetSharedDLLsCount(LPCWSTR dll)
2405 HKEY hkey;
2406 DWORD count=0;
2407 DWORD type;
2408 DWORD sz = sizeof(count);
2409 DWORD rc;
2411 hkey = openSharedDLLsKey();
2412 rc = RegQueryValueExW(hkey, dll, NULL, &type, (LPBYTE)&count, &sz);
2413 if (rc != ERROR_SUCCESS)
2414 count = 0;
2415 RegCloseKey(hkey);
2416 return count;
2419 static UINT ACTION_WriteSharedDLLsCount(LPCWSTR path, UINT count)
2421 HKEY hkey;
2423 hkey = openSharedDLLsKey();
2424 if (count > 0)
2425 msi_reg_set_val_dword( hkey, path, count );
2426 else
2427 RegDeleteValueW(hkey,path);
2428 RegCloseKey(hkey);
2429 return count;
2433 * Return TRUE if the count should be written out and FALSE if not
2435 static void ACTION_RefCountComponent( MSIPACKAGE* package, MSICOMPONENT *comp )
2437 MSIFEATURE *feature;
2438 INT count = 0;
2439 BOOL write = FALSE;
2441 /* only refcount DLLs */
2442 if (comp->KeyPath == NULL ||
2443 comp->Attributes & msidbComponentAttributesRegistryKeyPath ||
2444 comp->Attributes & msidbComponentAttributesODBCDataSource)
2445 write = FALSE;
2446 else
2448 count = ACTION_GetSharedDLLsCount( comp->FullKeypath);
2449 write = (count > 0);
2451 if (comp->Attributes & msidbComponentAttributesSharedDllRefCount)
2452 write = TRUE;
2455 /* increment counts */
2456 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
2458 ComponentList *cl;
2460 if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL ))
2461 continue;
2463 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
2465 if ( cl->component == comp )
2466 count++;
2470 /* decrement counts */
2471 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
2473 ComponentList *cl;
2475 if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ABSENT ))
2476 continue;
2478 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
2480 if ( cl->component == comp )
2481 count--;
2485 /* ref count all the files in the component */
2486 if (write)
2488 MSIFILE *file;
2490 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
2492 if (file->Component == comp)
2493 ACTION_WriteSharedDLLsCount( file->TargetPath, count );
2497 /* add a count for permenent */
2498 if (comp->Attributes & msidbComponentAttributesPermanent)
2499 count ++;
2501 comp->RefCount = count;
2503 if (write)
2504 ACTION_WriteSharedDLLsCount( comp->FullKeypath, comp->RefCount );
2508 * Ok further analysis makes me think that this work is
2509 * actually done in the PublishComponents and PublishFeatures
2510 * step, and not here. It appears like the keypath and all that is
2511 * resolved in this step, however actually written in the Publish steps.
2512 * But we will leave it here for now because it is unclear
2514 static UINT ACTION_ProcessComponents(MSIPACKAGE *package)
2516 WCHAR squished_pc[GUID_SIZE];
2517 WCHAR squished_cc[GUID_SIZE];
2518 UINT rc;
2519 MSICOMPONENT *comp;
2520 HKEY hkey=0,hkey2=0;
2522 if (!package)
2523 return ERROR_INVALID_HANDLE;
2525 /* writes the Component and Features values to the registry */
2527 rc = MSIREG_OpenComponents(&hkey);
2528 if (rc != ERROR_SUCCESS)
2529 goto end;
2531 squash_guid(package->ProductCode,squished_pc);
2532 ui_progress(package,1,COMPONENT_PROGRESS_VALUE,1,0);
2534 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
2536 ui_progress(package,2,0,0,0);
2537 if (comp->ComponentId)
2539 MSIRECORD * uirow;
2541 squash_guid(comp->ComponentId,squished_cc);
2543 msi_free(comp->FullKeypath);
2544 comp->FullKeypath = resolve_keypath( package, comp );
2546 /* do the refcounting */
2547 ACTION_RefCountComponent( package, comp );
2549 TRACE("Component %s (%s), Keypath=%s, RefCount=%i\n",
2550 debugstr_w(comp->Component),
2551 debugstr_w(squished_cc),
2552 debugstr_w(comp->FullKeypath),
2553 comp->RefCount);
2555 * Write the keypath out if the component is to be registered
2556 * and delete the key if the component is to be deregistered
2558 if (ACTION_VerifyComponentForAction(package, comp,
2559 INSTALLSTATE_LOCAL))
2561 rc = RegCreateKeyW(hkey,squished_cc,&hkey2);
2562 if (rc != ERROR_SUCCESS)
2563 continue;
2565 if (comp->FullKeypath)
2567 msi_reg_set_val_str( hkey2, squished_pc, comp->FullKeypath );
2569 if (comp->Attributes & msidbComponentAttributesPermanent)
2571 static const WCHAR szPermKey[] =
2572 { '0','0','0','0','0','0','0','0','0','0','0','0',
2573 '0','0','0','0','0','0','0','0','0','0','0','0',
2574 '0','0','0','0','0','0','0','0',0};
2576 msi_reg_set_val_str( hkey2, szPermKey, comp->FullKeypath );
2579 RegCloseKey(hkey2);
2581 /* UI stuff */
2582 uirow = MSI_CreateRecord(3);
2583 MSI_RecordSetStringW(uirow,1,package->ProductCode);
2584 MSI_RecordSetStringW(uirow,2,comp->ComponentId);
2585 MSI_RecordSetStringW(uirow,3,comp->FullKeypath);
2586 ui_actiondata(package,szProcessComponents,uirow);
2587 msiobj_release( &uirow->hdr );
2590 else if (ACTION_VerifyComponentForAction(package, comp,
2591 INSTALLSTATE_ABSENT))
2593 DWORD res;
2595 rc = RegOpenKeyW(hkey,squished_cc,&hkey2);
2596 if (rc != ERROR_SUCCESS)
2597 continue;
2599 RegDeleteValueW(hkey2,squished_pc);
2601 /* if the key is empty delete it */
2602 res = RegEnumKeyExW(hkey2,0,NULL,0,0,NULL,0,NULL);
2603 RegCloseKey(hkey2);
2604 if (res == ERROR_NO_MORE_ITEMS)
2605 RegDeleteKeyW(hkey,squished_cc);
2607 /* UI stuff */
2608 uirow = MSI_CreateRecord(2);
2609 MSI_RecordSetStringW(uirow,1,package->ProductCode);
2610 MSI_RecordSetStringW(uirow,2,comp->ComponentId);
2611 ui_actiondata(package,szProcessComponents,uirow);
2612 msiobj_release( &uirow->hdr );
2616 end:
2617 RegCloseKey(hkey);
2618 return rc;
2621 typedef struct {
2622 CLSID clsid;
2623 LPWSTR source;
2625 LPWSTR path;
2626 ITypeLib *ptLib;
2627 } typelib_struct;
2629 static BOOL CALLBACK Typelib_EnumResNameProc( HMODULE hModule, LPCWSTR lpszType,
2630 LPWSTR lpszName, LONG_PTR lParam)
2632 TLIBATTR *attr;
2633 typelib_struct *tl_struct = (typelib_struct*) lParam;
2634 static const WCHAR fmt[] = {'%','s','\\','%','i',0};
2635 int sz;
2636 HRESULT res;
2638 if (!IS_INTRESOURCE(lpszName))
2640 ERR("Not Int Resource Name %s\n",debugstr_w(lpszName));
2641 return TRUE;
2644 sz = strlenW(tl_struct->source)+4;
2645 sz *= sizeof(WCHAR);
2647 if ((INT)lpszName == 1)
2648 tl_struct->path = strdupW(tl_struct->source);
2649 else
2651 tl_struct->path = msi_alloc(sz);
2652 sprintfW(tl_struct->path,fmt,tl_struct->source, lpszName);
2655 TRACE("trying %s\n", debugstr_w(tl_struct->path));
2656 res = LoadTypeLib(tl_struct->path,&tl_struct->ptLib);
2657 if (!SUCCEEDED(res))
2659 msi_free(tl_struct->path);
2660 tl_struct->path = NULL;
2662 return TRUE;
2665 ITypeLib_GetLibAttr(tl_struct->ptLib, &attr);
2666 if (IsEqualGUID(&(tl_struct->clsid),&(attr->guid)))
2668 ITypeLib_ReleaseTLibAttr(tl_struct->ptLib, attr);
2669 return FALSE;
2672 msi_free(tl_struct->path);
2673 tl_struct->path = NULL;
2675 ITypeLib_ReleaseTLibAttr(tl_struct->ptLib, attr);
2676 ITypeLib_Release(tl_struct->ptLib);
2678 return TRUE;
2681 static UINT ITERATE_RegisterTypeLibraries(MSIRECORD *row, LPVOID param)
2683 MSIPACKAGE* package = (MSIPACKAGE*)param;
2684 LPCWSTR component;
2685 MSICOMPONENT *comp;
2686 MSIFILE *file;
2687 typelib_struct tl_struct;
2688 HMODULE module;
2689 static const WCHAR szTYPELIB[] = {'T','Y','P','E','L','I','B',0};
2691 component = MSI_RecordGetString(row,3);
2692 comp = get_loaded_component(package,component);
2693 if (!comp)
2694 return ERROR_SUCCESS;
2696 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL))
2698 TRACE("Skipping typelib reg due to disabled component\n");
2700 comp->Action = comp->Installed;
2702 return ERROR_SUCCESS;
2705 comp->Action = INSTALLSTATE_LOCAL;
2707 file = get_loaded_file( package, comp->KeyPath );
2708 if (!file)
2709 return ERROR_SUCCESS;
2711 module = LoadLibraryExW( file->TargetPath, NULL, LOAD_LIBRARY_AS_DATAFILE );
2712 if (module != NULL)
2714 LPWSTR guid;
2715 guid = load_dynamic_stringW(row,1);
2716 CLSIDFromString(guid, &tl_struct.clsid);
2717 msi_free(guid);
2718 tl_struct.source = strdupW( file->TargetPath );
2719 tl_struct.path = NULL;
2721 EnumResourceNamesW(module, szTYPELIB, Typelib_EnumResNameProc,
2722 (LONG_PTR)&tl_struct);
2724 if (tl_struct.path != NULL)
2726 LPWSTR help = NULL;
2727 LPCWSTR helpid;
2728 HRESULT res;
2730 helpid = MSI_RecordGetString(row,6);
2732 if (helpid)
2733 help = resolve_folder(package,helpid,FALSE,FALSE,NULL);
2734 res = RegisterTypeLib(tl_struct.ptLib,tl_struct.path,help);
2735 msi_free(help);
2737 if (!SUCCEEDED(res))
2738 ERR("Failed to register type library %s\n",
2739 debugstr_w(tl_struct.path));
2740 else
2742 ui_actiondata(package,szRegisterTypeLibraries,row);
2744 TRACE("Registered %s\n", debugstr_w(tl_struct.path));
2747 ITypeLib_Release(tl_struct.ptLib);
2748 msi_free(tl_struct.path);
2750 else
2751 ERR("Failed to load type library %s\n",
2752 debugstr_w(tl_struct.source));
2754 FreeLibrary(module);
2755 msi_free(tl_struct.source);
2757 else
2758 ERR("Could not load file! %s\n", debugstr_w(file->TargetPath));
2760 return ERROR_SUCCESS;
2763 static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package)
2766 * OK this is a bit confusing.. I am given a _Component key and I believe
2767 * that the file that is being registered as a type library is the "key file
2768 * of that component" which I interpret to mean "The file in the KeyPath of
2769 * that component".
2771 UINT rc;
2772 MSIQUERY * view;
2773 static const WCHAR Query[] =
2774 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2775 '`','T','y','p','e','L','i','b','`',0};
2777 if (!package)
2778 return ERROR_INVALID_HANDLE;
2780 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
2781 if (rc != ERROR_SUCCESS)
2782 return ERROR_SUCCESS;
2784 rc = MSI_IterateRecords(view, NULL, ITERATE_RegisterTypeLibraries, package);
2785 msiobj_release(&view->hdr);
2786 return rc;
2789 static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param)
2791 MSIPACKAGE *package = (MSIPACKAGE*)param;
2792 LPWSTR target_file, target_folder;
2793 LPCWSTR buffer;
2794 WCHAR filename[0x100];
2795 DWORD sz;
2796 MSICOMPONENT *comp;
2797 static const WCHAR szlnk[]={'.','l','n','k',0};
2798 IShellLinkW *sl;
2799 IPersistFile *pf;
2800 HRESULT res;
2802 buffer = MSI_RecordGetString(row,4);
2803 comp = get_loaded_component(package,buffer);
2804 if (!comp)
2805 return ERROR_SUCCESS;
2807 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL))
2809 TRACE("Skipping shortcut creation due to disabled component\n");
2811 comp->Action = comp->Installed;
2813 return ERROR_SUCCESS;
2816 comp->Action = INSTALLSTATE_LOCAL;
2818 ui_actiondata(package,szCreateShortcuts,row);
2820 res = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
2821 &IID_IShellLinkW, (LPVOID *) &sl );
2823 if (FAILED(res))
2825 ERR("Is IID_IShellLink\n");
2826 return ERROR_SUCCESS;
2829 res = IShellLinkW_QueryInterface( sl, &IID_IPersistFile,(LPVOID*) &pf );
2830 if( FAILED( res ) )
2832 ERR("Is IID_IPersistFile\n");
2833 return ERROR_SUCCESS;
2836 buffer = MSI_RecordGetString(row,2);
2837 target_folder = resolve_folder(package, buffer,FALSE,FALSE,NULL);
2839 /* may be needed because of a bug somehwere else */
2840 create_full_pathW(target_folder);
2842 sz = 0x100;
2843 MSI_RecordGetStringW(row,3,filename,&sz);
2844 reduce_to_longfilename(filename);
2845 if (!strchrW(filename,'.') || strcmpiW(strchrW(filename,'.'),szlnk))
2846 strcatW(filename,szlnk);
2847 target_file = build_directory_name(2, target_folder, filename);
2848 msi_free(target_folder);
2850 buffer = MSI_RecordGetString(row,5);
2851 if (strchrW(buffer,'['))
2853 LPWSTR deformated;
2854 deformat_string(package,buffer,&deformated);
2855 IShellLinkW_SetPath(sl,deformated);
2856 msi_free(deformated);
2858 else
2860 FIXME("poorly handled shortcut format, advertised shortcut\n");
2861 IShellLinkW_SetPath(sl,comp->FullKeypath);
2864 if (!MSI_RecordIsNull(row,6))
2866 LPWSTR deformated;
2867 buffer = MSI_RecordGetString(row,6);
2868 deformat_string(package,buffer,&deformated);
2869 IShellLinkW_SetArguments(sl,deformated);
2870 msi_free(deformated);
2873 if (!MSI_RecordIsNull(row,7))
2875 buffer = MSI_RecordGetString(row,7);
2876 IShellLinkW_SetDescription(sl,buffer);
2879 if (!MSI_RecordIsNull(row,8))
2880 IShellLinkW_SetHotkey(sl,MSI_RecordGetInteger(row,8));
2882 if (!MSI_RecordIsNull(row,9))
2884 LPWSTR Path;
2885 INT index;
2887 buffer = MSI_RecordGetString(row,9);
2889 Path = build_icon_path(package,buffer);
2890 index = MSI_RecordGetInteger(row,10);
2892 IShellLinkW_SetIconLocation(sl,Path,index);
2893 msi_free(Path);
2896 if (!MSI_RecordIsNull(row,11))
2897 IShellLinkW_SetShowCmd(sl,MSI_RecordGetInteger(row,11));
2899 if (!MSI_RecordIsNull(row,12))
2901 LPWSTR Path;
2902 buffer = MSI_RecordGetString(row,12);
2903 Path = resolve_folder(package, buffer, FALSE, FALSE, NULL);
2904 IShellLinkW_SetWorkingDirectory(sl,Path);
2905 msi_free(Path);
2908 TRACE("Writing shortcut to %s\n",debugstr_w(target_file));
2909 IPersistFile_Save(pf,target_file,FALSE);
2911 msi_free(target_file);
2913 IPersistFile_Release( pf );
2914 IShellLinkW_Release( sl );
2916 return ERROR_SUCCESS;
2919 static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
2921 UINT rc;
2922 HRESULT res;
2923 MSIQUERY * view;
2924 static const WCHAR Query[] =
2925 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2926 '`','S','h','o','r','t','c','u','t','`',0};
2928 if (!package)
2929 return ERROR_INVALID_HANDLE;
2931 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
2932 if (rc != ERROR_SUCCESS)
2933 return ERROR_SUCCESS;
2935 res = CoInitialize( NULL );
2936 if (FAILED (res))
2938 ERR("CoInitialize failed\n");
2939 return ERROR_FUNCTION_FAILED;
2942 rc = MSI_IterateRecords(view, NULL, ITERATE_CreateShortcuts, package);
2943 msiobj_release(&view->hdr);
2945 CoUninitialize();
2947 return rc;
2950 static UINT ITERATE_PublishProduct(MSIRECORD *row, LPVOID param)
2952 MSIPACKAGE* package = (MSIPACKAGE*)param;
2953 HANDLE the_file;
2954 LPWSTR FilePath;
2955 LPCWSTR FileName;
2956 CHAR buffer[1024];
2957 DWORD sz;
2958 UINT rc;
2960 FileName = MSI_RecordGetString(row,1);
2961 if (!FileName)
2963 ERR("Unable to get FileName\n");
2964 return ERROR_SUCCESS;
2967 FilePath = build_icon_path(package,FileName);
2969 TRACE("Creating icon file at %s\n",debugstr_w(FilePath));
2971 the_file = CreateFileW(FilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2972 FILE_ATTRIBUTE_NORMAL, NULL);
2974 if (the_file == INVALID_HANDLE_VALUE)
2976 ERR("Unable to create file %s\n",debugstr_w(FilePath));
2977 msi_free(FilePath);
2978 return ERROR_SUCCESS;
2983 DWORD write;
2984 sz = 1024;
2985 rc = MSI_RecordReadStream(row,2,buffer,&sz);
2986 if (rc != ERROR_SUCCESS)
2988 ERR("Failed to get stream\n");
2989 CloseHandle(the_file);
2990 DeleteFileW(FilePath);
2991 break;
2993 WriteFile(the_file,buffer,sz,&write,NULL);
2994 } while (sz == 1024);
2996 msi_free(FilePath);
2998 CloseHandle(the_file);
2999 return ERROR_SUCCESS;
3003 * 99% of the work done here is only done for
3004 * advertised installs. However this is where the
3005 * Icon table is processed and written out
3006 * so that is what I am going to do here.
3008 static UINT ACTION_PublishProduct(MSIPACKAGE *package)
3010 UINT rc;
3011 MSIQUERY * view;
3012 static const WCHAR Query[]=
3013 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3014 '`','I','c','o','n','`',0};
3015 /* for registry stuff */
3016 HKEY hkey=0;
3017 HKEY hukey=0;
3018 static const WCHAR szProductLanguage[] =
3019 {'P','r','o','d','u','c','t','L','a','n','g','u','a','g','e',0};
3020 static const WCHAR szARPProductIcon[] =
3021 {'A','R','P','P','R','O','D','U','C','T','I','C','O','N',0};
3022 static const WCHAR szProductVersion[] =
3023 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0};
3024 DWORD langid;
3025 LPWSTR buffer;
3026 DWORD size;
3027 MSIHANDLE hDb, hSumInfo;
3029 if (!package)
3030 return ERROR_INVALID_HANDLE;
3032 /* write out icon files */
3034 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
3035 if (rc == ERROR_SUCCESS)
3037 MSI_IterateRecords(view, NULL, ITERATE_PublishProduct, package);
3038 msiobj_release(&view->hdr);
3041 /* ok there is a lot more done here but i need to figure out what */
3043 rc = MSIREG_OpenProductsKey(package->ProductCode,&hkey,TRUE);
3044 if (rc != ERROR_SUCCESS)
3045 goto end;
3047 rc = MSIREG_OpenUserProductsKey(package->ProductCode,&hukey,TRUE);
3048 if (rc != ERROR_SUCCESS)
3049 goto end;
3052 buffer = msi_dup_property( package, INSTALLPROPERTY_PRODUCTNAMEW );
3053 msi_reg_set_val_str( hukey, INSTALLPROPERTY_PRODUCTNAMEW, buffer );
3054 msi_free(buffer);
3056 langid = msi_get_property_int( package, szProductLanguage, 0 );
3057 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_LANGUAGEW, langid );
3059 buffer = msi_dup_property( package, szARPProductIcon );
3060 if (buffer)
3062 LPWSTR path = build_icon_path(package,buffer);
3063 msi_reg_set_val_str( hukey, INSTALLPROPERTY_PRODUCTICONW, path );
3064 msi_free( path );
3066 msi_free(buffer);
3068 buffer = msi_dup_property( package, szProductVersion );
3069 if (buffer)
3071 DWORD verdword = build_version_dword(buffer);
3072 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONW, verdword );
3074 msi_free(buffer);
3076 FIXME("Need to write more keys to the user registry\n");
3078 hDb= alloc_msihandle( &package->db->hdr );
3079 rc = MsiGetSummaryInformationW(hDb, NULL, 0, &hSumInfo);
3080 MsiCloseHandle(hDb);
3081 if (rc == ERROR_SUCCESS)
3083 WCHAR guidbuffer[0x200];
3084 size = 0x200;
3085 rc = MsiSummaryInfoGetPropertyW(hSumInfo, 9, NULL, NULL, NULL,
3086 guidbuffer, &size);
3087 if (rc == ERROR_SUCCESS)
3089 WCHAR squashed[GUID_SIZE];
3090 /* for now we only care about the first guid */
3091 LPWSTR ptr = strchrW(guidbuffer,';');
3092 if (ptr) *ptr = 0;
3093 squash_guid(guidbuffer,squashed);
3094 msi_reg_set_val_str( hukey, INSTALLPROPERTY_PACKAGECODEW, squashed );
3096 else
3098 ERR("Unable to query Revision_Number... \n");
3099 rc = ERROR_SUCCESS;
3101 MsiCloseHandle(hSumInfo);
3103 else
3105 ERR("Unable to open Summary Information\n");
3106 rc = ERROR_SUCCESS;
3109 end:
3111 RegCloseKey(hkey);
3112 RegCloseKey(hukey);
3114 return rc;
3117 static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param)
3119 MSIPACKAGE *package = (MSIPACKAGE*)param;
3120 LPCWSTR component,section,key,value,identifier,filename,dirproperty;
3121 LPWSTR deformated_section, deformated_key, deformated_value;
3122 LPWSTR folder, fullname = NULL;
3123 MSIRECORD * uirow;
3124 INT action;
3125 MSICOMPONENT *comp;
3126 static const WCHAR szWindowsFolder[] =
3127 {'W','i','n','d','o','w','s','F','o','l','d','e','r',0};
3129 component = MSI_RecordGetString(row, 8);
3130 comp = get_loaded_component(package,component);
3132 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL))
3134 TRACE("Skipping ini file due to disabled component %s\n",
3135 debugstr_w(component));
3137 comp->Action = comp->Installed;
3139 return ERROR_SUCCESS;
3142 comp->Action = INSTALLSTATE_LOCAL;
3144 identifier = MSI_RecordGetString(row,1);
3145 filename = MSI_RecordGetString(row,2);
3146 dirproperty = MSI_RecordGetString(row,3);
3147 section = MSI_RecordGetString(row,4);
3148 key = MSI_RecordGetString(row,5);
3149 value = MSI_RecordGetString(row,6);
3150 action = MSI_RecordGetInteger(row,7);
3152 deformat_string(package,section,&deformated_section);
3153 deformat_string(package,key,&deformated_key);
3154 deformat_string(package,value,&deformated_value);
3156 if (dirproperty)
3158 folder = resolve_folder(package, dirproperty, FALSE, FALSE, NULL);
3159 if (!folder)
3160 folder = msi_dup_property( package, dirproperty );
3162 else
3163 folder = msi_dup_property( package, szWindowsFolder );
3165 if (!folder)
3167 ERR("Unable to resolve folder! (%s)\n",debugstr_w(dirproperty));
3168 goto cleanup;
3171 fullname = build_directory_name(2, folder, filename);
3173 if (action == 0)
3175 TRACE("Adding value %s to section %s in %s\n",
3176 debugstr_w(deformated_key), debugstr_w(deformated_section),
3177 debugstr_w(fullname));
3178 WritePrivateProfileStringW(deformated_section, deformated_key,
3179 deformated_value, fullname);
3181 else if (action == 1)
3183 WCHAR returned[10];
3184 GetPrivateProfileStringW(deformated_section, deformated_key, NULL,
3185 returned, 10, fullname);
3186 if (returned[0] == 0)
3188 TRACE("Adding value %s to section %s in %s\n",
3189 debugstr_w(deformated_key), debugstr_w(deformated_section),
3190 debugstr_w(fullname));
3192 WritePrivateProfileStringW(deformated_section, deformated_key,
3193 deformated_value, fullname);
3196 else if (action == 3)
3197 FIXME("Append to existing section not yet implemented\n");
3199 uirow = MSI_CreateRecord(4);
3200 MSI_RecordSetStringW(uirow,1,identifier);
3201 MSI_RecordSetStringW(uirow,2,deformated_section);
3202 MSI_RecordSetStringW(uirow,3,deformated_key);
3203 MSI_RecordSetStringW(uirow,4,deformated_value);
3204 ui_actiondata(package,szWriteIniValues,uirow);
3205 msiobj_release( &uirow->hdr );
3206 cleanup:
3207 msi_free(fullname);
3208 msi_free(folder);
3209 msi_free(deformated_key);
3210 msi_free(deformated_value);
3211 msi_free(deformated_section);
3212 return ERROR_SUCCESS;
3215 static UINT ACTION_WriteIniValues(MSIPACKAGE *package)
3217 UINT rc;
3218 MSIQUERY * view;
3219 static const WCHAR ExecSeqQuery[] =
3220 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3221 '`','I','n','i','F','i','l','e','`',0};
3223 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3224 if (rc != ERROR_SUCCESS)
3226 TRACE("no IniFile table\n");
3227 return ERROR_SUCCESS;
3230 rc = MSI_IterateRecords(view, NULL, ITERATE_WriteIniValues, package);
3231 msiobj_release(&view->hdr);
3232 return rc;
3235 static UINT ITERATE_SelfRegModules(MSIRECORD *row, LPVOID param)
3237 MSIPACKAGE *package = (MSIPACKAGE*)param;
3238 LPCWSTR filename;
3239 LPWSTR FullName;
3240 MSIFILE *file;
3241 DWORD len;
3242 static const WCHAR ExeStr[] =
3243 {'r','e','g','s','v','r','3','2','.','e','x','e',' ','\"',0};
3244 static const WCHAR close[] = {'\"',0};
3245 STARTUPINFOW si;
3246 PROCESS_INFORMATION info;
3247 BOOL brc;
3249 memset(&si,0,sizeof(STARTUPINFOW));
3251 filename = MSI_RecordGetString(row,1);
3252 file = get_loaded_file( package, filename );
3254 if (!file)
3256 ERR("Unable to find file id %s\n",debugstr_w(filename));
3257 return ERROR_SUCCESS;
3260 len = strlenW(ExeStr) + strlenW( file->TargetPath ) + 2;
3262 FullName = msi_alloc(len*sizeof(WCHAR));
3263 strcpyW(FullName,ExeStr);
3264 strcatW( FullName, file->TargetPath );
3265 strcatW(FullName,close);
3267 TRACE("Registering %s\n",debugstr_w(FullName));
3268 brc = CreateProcessW(NULL, FullName, NULL, NULL, FALSE, 0, NULL, c_colon,
3269 &si, &info);
3271 if (brc)
3272 msi_dialog_check_messages(info.hProcess);
3274 msi_free(FullName);
3275 return ERROR_SUCCESS;
3278 static UINT ACTION_SelfRegModules(MSIPACKAGE *package)
3280 UINT rc;
3281 MSIQUERY * view;
3282 static const WCHAR ExecSeqQuery[] =
3283 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3284 '`','S','e','l','f','R','e','g','`',0};
3286 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3287 if (rc != ERROR_SUCCESS)
3289 TRACE("no SelfReg table\n");
3290 return ERROR_SUCCESS;
3293 MSI_IterateRecords(view, NULL, ITERATE_SelfRegModules, package);
3294 msiobj_release(&view->hdr);
3296 return ERROR_SUCCESS;
3299 static UINT ACTION_PublishFeatures(MSIPACKAGE *package)
3301 MSIFEATURE *feature;
3302 UINT rc;
3303 HKEY hkey=0;
3304 HKEY hukey=0;
3306 if (!package)
3307 return ERROR_INVALID_HANDLE;
3309 rc = MSIREG_OpenFeaturesKey(package->ProductCode,&hkey,TRUE);
3310 if (rc != ERROR_SUCCESS)
3311 goto end;
3313 rc = MSIREG_OpenUserFeaturesKey(package->ProductCode,&hukey,TRUE);
3314 if (rc != ERROR_SUCCESS)
3315 goto end;
3317 /* here the guids are base 85 encoded */
3318 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
3320 ComponentList *cl;
3321 LPWSTR data = NULL;
3322 GUID clsid;
3323 INT size;
3324 BOOL absent = FALSE;
3326 if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL ) &&
3327 !ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_SOURCE ) &&
3328 !ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ADVERTISED ))
3329 absent = TRUE;
3331 size = 1;
3332 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
3334 size += 21;
3336 if (feature->Feature_Parent)
3337 size += strlenW( feature->Feature_Parent )+2;
3339 data = msi_alloc(size * sizeof(WCHAR));
3341 data[0] = 0;
3342 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
3344 MSICOMPONENT* component = cl->component;
3345 WCHAR buf[21];
3347 memset(buf,0,sizeof(buf));
3348 if (component->ComponentId)
3350 TRACE("From %s\n",debugstr_w(component->ComponentId));
3351 CLSIDFromString(component->ComponentId, &clsid);
3352 encode_base85_guid(&clsid,buf);
3353 TRACE("to %s\n",debugstr_w(buf));
3354 strcatW(data,buf);
3357 if (feature->Feature_Parent)
3359 static const WCHAR sep[] = {'\2',0};
3360 strcatW(data,sep);
3361 strcatW(data,feature->Feature_Parent);
3364 msi_reg_set_val_str( hkey, feature->Feature, data );
3365 msi_free(data);
3367 size = 0;
3368 if (feature->Feature_Parent)
3369 size = strlenW(feature->Feature_Parent)*sizeof(WCHAR);
3370 if (!absent)
3372 RegSetValueExW(hukey,feature->Feature,0,REG_SZ,
3373 (LPBYTE)feature->Feature_Parent,size);
3375 else
3377 size += 2*sizeof(WCHAR);
3378 data = msi_alloc(size);
3379 data[0] = 0x6;
3380 data[1] = 0;
3381 if (feature->Feature_Parent)
3382 strcpyW( &data[1], feature->Feature_Parent );
3383 RegSetValueExW(hukey,feature->Feature,0,REG_SZ,
3384 (LPBYTE)data,size);
3385 msi_free(data);
3389 end:
3390 RegCloseKey(hkey);
3391 RegCloseKey(hukey);
3392 return rc;
3395 static UINT msi_make_package_local( MSIPACKAGE *package, HKEY hkey )
3397 static const WCHAR installerPathFmt[] = {
3398 '%','s','\\','I','n','s','t','a','l','l','e','r','\\',0};
3399 static const WCHAR fmt[] = {
3400 '%','s','\\',
3401 'I','n','s','t','a','l','l','e','r','\\',
3402 '%','x','.','m','s','i',0};
3403 static const WCHAR szOriginalDatabase[] =
3404 {'O','r','i','g','i','n','a','l','D','a','t','a','b','a','s','e',0};
3405 WCHAR windir[MAX_PATH], path[MAX_PATH], packagefile[MAX_PATH];
3406 INT num, start;
3407 LPWSTR msiFilePath;
3408 BOOL r;
3410 /* copy the package locally */
3411 num = GetTickCount() & 0xffff;
3412 if (!num)
3413 num = 1;
3414 start = num;
3415 GetWindowsDirectoryW( windir, MAX_PATH );
3416 snprintfW( packagefile, MAX_PATH, fmt, windir, num );
3419 HANDLE handle = CreateFileW(packagefile,GENERIC_WRITE, 0, NULL,
3420 CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
3421 if (handle != INVALID_HANDLE_VALUE)
3423 CloseHandle(handle);
3424 break;
3426 if (GetLastError() != ERROR_FILE_EXISTS &&
3427 GetLastError() != ERROR_SHARING_VIOLATION)
3428 break;
3429 if (!(++num & 0xffff)) num = 1;
3430 sprintfW(packagefile,fmt,num);
3431 } while (num != start);
3433 snprintfW( path, MAX_PATH, installerPathFmt, windir );
3434 create_full_pathW(path);
3436 TRACE("Copying to local package %s\n",debugstr_w(packagefile));
3438 msiFilePath = msi_dup_property( package, szOriginalDatabase );
3439 r = CopyFileW( msiFilePath, packagefile, FALSE);
3440 msi_free( msiFilePath );
3442 if (!r)
3444 ERR("Unable to copy package (%s -> %s) (error %ld)\n",
3445 debugstr_w(msiFilePath), debugstr_w(packagefile), GetLastError());
3446 return ERROR_FUNCTION_FAILED;
3449 /* FIXME: maybe set this key in ACTION_RegisterProduct instead */
3450 msi_reg_set_val_str( hkey, INSTALLPROPERTY_LOCALPACKAGEW, packagefile );
3451 return ERROR_SUCCESS;
3454 static UINT ACTION_RegisterProduct(MSIPACKAGE *package)
3456 HKEY hkey=0;
3457 LPWSTR buffer = NULL;
3458 UINT rc,i;
3459 DWORD size, langid;
3460 static const WCHAR szWindowsInstaller[] =
3461 {'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
3462 static const WCHAR szPropKeys[][80] =
3464 {'A','R','P','A','U','T','H','O','R','I','Z','E','D','C','D','F','P','R','E','F','I','X',0},
3465 {'A','R','P','C','O','N','T','A','C','T',0},
3466 {'A','R','P','C','O','M','M','E','N','T','S',0},
3467 {'P','r','o','d','u','c','t','N','a','m','e',0},
3468 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0},
3469 {'A','R','P','H','E','L','P','L','I','N','K',0},
3470 {'A','R','P','H','E','L','P','T','E','L','E','P','H','O','N','E',0},
3471 {'A','R','P','I','N','S','T','A','L','L','L','O','C','A','T','I','O','N',0},
3472 {'S','o','u','r','c','e','D','i','r',0},
3473 {'M','a','n','u','f','a','c','t','u','r','e','r',0},
3474 {'A','R','P','R','E','A','D','M','E',0},
3475 {'A','R','P','S','I','Z','E',0},
3476 {'A','R','P','U','R','L','I','N','F','O','A','B','O','U','T',0},
3477 {'A','R','P','U','R','L','U','P','D','A','T','E','I','N','F','O',0},
3478 {0},
3481 static const WCHAR szRegKeys[][80] =
3483 {'A','u','t','h','o','r','i','z','e','d','C','D','F','P','r','e','f','i','x',0},
3484 {'C','o','n','t','a','c','t',0},
3485 {'C','o','m','m','e','n','t','s',0},
3486 {'D','i','s','p','l','a','y','N','a','m','e',0},
3487 {'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0},
3488 {'H','e','l','p','L','i','n','k',0},
3489 {'H','e','l','p','T','e','l','e','p','h','o','n','e',0},
3490 {'I','n','s','t','a','l','l','L','o','c','a','t','i','o','n',0},
3491 {'I','n','s','t','a','l','l','S','o','u','r','c','e',0},
3492 {'P','u','b','l','i','s','h','e','r',0},
3493 {'R','e','a','d','m','e',0},
3494 {'S','i','z','e',0},
3495 {'U','R','L','I','n','f','o','A','b','o','u','t',0},
3496 {'U','R','L','U','p','d','a','t','e','I','n','f','o',0},
3497 {0},
3499 static const WCHAR szUpgradeCode[] =
3500 {'U','p','g','r','a','d','e','C','o','d','e',0};
3501 static const WCHAR modpath_fmt[] =
3502 {'M','s','i','E','x','e','c','.','e','x','e',' ','/','I','[','P','r','o','d','u','c','t','C','o','d','e',']',0};
3503 static const WCHAR szModifyPath[] =
3504 {'M','o','d','i','f','y','P','a','t','h',0};
3505 static const WCHAR szUninstallString[] =
3506 {'U','n','i','n','s','t','a','l','l','S','t','r','i','n','g',0};
3507 static const WCHAR szEstimatedSize[] =
3508 {'E','s','t','i','m','a','t','e','d','S','i','z','e',0};
3509 static const WCHAR szProductLanguage[] =
3510 {'P','r','o','d','u','c','t','L','a','n','g','u','a','g','e',0};
3511 static const WCHAR szProductVersion[] =
3512 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0};
3514 SYSTEMTIME systime;
3515 static const WCHAR date_fmt[] = {'%','i','%','i','%','i',0};
3516 LPWSTR upgrade_code;
3518 if (!package)
3519 return ERROR_INVALID_HANDLE;
3521 rc = MSIREG_OpenUninstallKey(package->ProductCode,&hkey,TRUE);
3522 if (rc != ERROR_SUCCESS)
3523 goto end;
3525 /* dump all the info i can grab */
3526 FIXME("Flesh out more information \n");
3528 for( i=0; szPropKeys[i][0]; i++ )
3530 buffer = msi_dup_property( package, szPropKeys[i] );
3531 msi_reg_set_val_str( hkey, szRegKeys[i], buffer );
3532 msi_free(buffer);
3535 msi_reg_set_val_dword( hkey, szWindowsInstaller, 1 );
3537 msi_make_package_local( package, hkey );
3539 /* do ModifyPath and UninstallString */
3540 size = deformat_string(package,modpath_fmt,&buffer);
3541 RegSetValueExW(hkey,szModifyPath,0,REG_EXPAND_SZ,(LPBYTE)buffer,size);
3542 RegSetValueExW(hkey,szUninstallString,0,REG_EXPAND_SZ,(LPBYTE)buffer,size);
3543 msi_free(buffer);
3545 FIXME("Write real Estimated Size when we have it\n");
3546 msi_reg_set_val_dword( hkey, szEstimatedSize, 0 );
3548 GetLocalTime(&systime);
3549 size = 9*sizeof(WCHAR);
3550 buffer= msi_alloc(size);
3551 sprintfW(buffer,date_fmt,systime.wYear,systime.wMonth,systime.wDay);
3552 msi_reg_set_val_str( hkey, INSTALLPROPERTY_INSTALLDATEW, buffer );
3553 msi_free(buffer);
3555 langid = msi_get_property_int( package, szProductLanguage, 0 );
3556 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_LANGUAGEW, langid );
3558 buffer = msi_dup_property( package, szProductVersion );
3559 if (buffer)
3561 DWORD verdword = build_version_dword(buffer);
3563 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONW, verdword );
3564 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONMAJORW, verdword>>24 );
3565 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONMINORW, (verdword>>16)&0x00FF );
3567 msi_free(buffer);
3569 /* Handle Upgrade Codes */
3570 upgrade_code = msi_dup_property( package, szUpgradeCode );
3571 if (upgrade_code)
3573 HKEY hkey2;
3574 WCHAR squashed[33];
3575 MSIREG_OpenUpgradeCodesKey(upgrade_code, &hkey2, TRUE);
3576 squash_guid(package->ProductCode,squashed);
3577 msi_reg_set_val_str( hkey2, squashed, NULL );
3578 RegCloseKey(hkey2);
3579 MSIREG_OpenUserUpgradeCodesKey(upgrade_code, &hkey2, TRUE);
3580 squash_guid(package->ProductCode,squashed);
3581 msi_reg_set_val_str( hkey2, squashed, NULL );
3582 RegCloseKey(hkey2);
3584 msi_free(upgrade_code);
3587 end:
3588 RegCloseKey(hkey);
3590 return ERROR_SUCCESS;
3593 static UINT ACTION_InstallExecute(MSIPACKAGE *package)
3595 UINT rc;
3597 if (!package)
3598 return ERROR_INVALID_HANDLE;
3600 rc = execute_script(package,INSTALL_SCRIPT);
3602 return rc;
3605 static UINT ACTION_InstallFinalize(MSIPACKAGE *package)
3607 UINT rc;
3609 if (!package)
3610 return ERROR_INVALID_HANDLE;
3612 /* turn off scheduleing */
3613 package->script->CurrentlyScripting= FALSE;
3615 /* first do the same as an InstallExecute */
3616 rc = ACTION_InstallExecute(package);
3617 if (rc != ERROR_SUCCESS)
3618 return rc;
3620 /* then handle Commit Actions */
3621 rc = execute_script(package,COMMIT_SCRIPT);
3623 return rc;
3626 static UINT ACTION_ForceReboot(MSIPACKAGE *package)
3628 static const WCHAR RunOnce[] = {
3629 'S','o','f','t','w','a','r','e','\\',
3630 'M','i','c','r','o','s','o','f','t','\\',
3631 'W','i','n','d','o','w','s','\\',
3632 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3633 'R','u','n','O','n','c','e',0};
3634 static const WCHAR InstallRunOnce[] = {
3635 'S','o','f','t','w','a','r','e','\\',
3636 'M','i','c','r','o','s','o','f','t','\\',
3637 'W','i','n','d','o','w','s','\\',
3638 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3639 'I','n','s','t','a','l','l','e','r','\\',
3640 'R','u','n','O','n','c','e','E','n','t','r','i','e','s',0};
3642 static const WCHAR msiexec_fmt[] = {
3643 '%','s',
3644 '\\','M','s','i','E','x','e','c','.','e','x','e',' ','/','@',' ',
3645 '\"','%','s','\"',0};
3646 static const WCHAR install_fmt[] = {
3647 '/','I',' ','\"','%','s','\"',' ',
3648 'A','F','T','E','R','R','E','B','O','O','T','=','1',' ',
3649 'R','U','N','O','N','C','E','E','N','T','R','Y','=','\"','%','s','\"',0};
3650 WCHAR buffer[256], sysdir[MAX_PATH];
3651 HKEY hkey;
3652 WCHAR squished_pc[100];
3654 if (!package)
3655 return ERROR_INVALID_HANDLE;
3657 squash_guid(package->ProductCode,squished_pc);
3659 GetSystemDirectoryW(sysdir, sizeof(sysdir)/sizeof(sysdir[0]));
3660 RegCreateKeyW(HKEY_LOCAL_MACHINE,RunOnce,&hkey);
3661 snprintfW(buffer,sizeof(buffer)/sizeof(buffer[0]),msiexec_fmt,sysdir,
3662 squished_pc);
3664 msi_reg_set_val_str( hkey, squished_pc, buffer );
3665 RegCloseKey(hkey);
3667 TRACE("Reboot command %s\n",debugstr_w(buffer));
3669 RegCreateKeyW(HKEY_LOCAL_MACHINE,InstallRunOnce,&hkey);
3670 sprintfW(buffer,install_fmt,package->ProductCode,squished_pc);
3672 msi_reg_set_val_str( hkey, squished_pc, buffer );
3673 RegCloseKey(hkey);
3675 return ERROR_INSTALL_SUSPEND;
3678 UINT ACTION_ResolveSource(MSIPACKAGE* package)
3680 DWORD attrib;
3681 UINT rc;
3683 * we are currently doing what should be done here in the top level Install
3684 * however for Adminastrative and uninstalls this step will be needed
3686 if (!package->PackagePath)
3687 return ERROR_SUCCESS;
3689 attrib = GetFileAttributesW(package->PackagePath);
3690 if (attrib == INVALID_FILE_ATTRIBUTES)
3692 LPWSTR prompt;
3693 LPWSTR msg;
3694 DWORD size = 0;
3696 rc = MsiSourceListGetInfoW(package->ProductCode, NULL,
3697 MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT,
3698 INSTALLPROPERTY_DISKPROMPTW,NULL,&size);
3699 if (rc == ERROR_MORE_DATA)
3701 prompt = msi_alloc(size * sizeof(WCHAR));
3702 MsiSourceListGetInfoW(package->ProductCode, NULL,
3703 MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT,
3704 INSTALLPROPERTY_DISKPROMPTW,prompt,&size);
3706 else
3707 prompt = strdupW(package->PackagePath);
3709 msg = generate_error_string(package,1302,1,prompt);
3710 while(attrib == INVALID_FILE_ATTRIBUTES)
3712 rc = MessageBoxW(NULL,msg,NULL,MB_OKCANCEL);
3713 if (rc == IDCANCEL)
3715 rc = ERROR_INSTALL_USEREXIT;
3716 break;
3718 attrib = GetFileAttributesW(package->PackagePath);
3720 msi_free(prompt);
3721 rc = ERROR_SUCCESS;
3723 else
3724 return ERROR_SUCCESS;
3726 return rc;
3729 static UINT ACTION_RegisterUser(MSIPACKAGE *package)
3731 HKEY hkey=0;
3732 LPWSTR buffer;
3733 LPWSTR productid;
3734 UINT rc,i;
3736 static const WCHAR szPropKeys[][80] =
3738 {'P','r','o','d','u','c','t','I','D',0},
3739 {'U','S','E','R','N','A','M','E',0},
3740 {'C','O','M','P','A','N','Y','N','A','M','E',0},
3741 {0},
3744 static const WCHAR szRegKeys[][80] =
3746 {'P','r','o','d','u','c','t','I','D',0},
3747 {'R','e','g','O','w','n','e','r',0},
3748 {'R','e','g','C','o','m','p','a','n','y',0},
3749 {0},
3752 if (!package)
3753 return ERROR_INVALID_HANDLE;
3755 productid = msi_dup_property( package, INSTALLPROPERTY_PRODUCTIDW );
3756 if (!productid)
3757 return ERROR_SUCCESS;
3759 rc = MSIREG_OpenUninstallKey(package->ProductCode,&hkey,TRUE);
3760 if (rc != ERROR_SUCCESS)
3761 goto end;
3763 for( i = 0; szPropKeys[i][0]; i++ )
3765 buffer = msi_dup_property( package, szPropKeys[i] );
3766 msi_reg_set_val_str( hkey, szRegKeys[i], buffer );
3767 msi_free( buffer );
3770 end:
3771 msi_free(productid);
3772 RegCloseKey(hkey);
3774 return ERROR_SUCCESS;
3778 static UINT ACTION_ExecuteAction(MSIPACKAGE *package)
3780 static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0};
3781 static const WCHAR szTwo[] = {'2',0};
3782 UINT rc;
3783 LPWSTR level;
3784 level = msi_dup_property( package, szUILevel );
3786 MSI_SetPropertyW(package,szUILevel,szTwo);
3787 package->script->InWhatSequence |= SEQUENCE_EXEC;
3788 rc = ACTION_ProcessExecSequence(package,FALSE);
3789 MSI_SetPropertyW(package,szUILevel,level);
3790 msi_free(level);
3791 return rc;
3796 * Code based off of code located here
3797 * http://www.codeproject.com/gdi/fontnamefromfile.asp
3799 * Using string index 4 (full font name) instead of 1 (family name)
3801 static LPWSTR load_ttfname_from(LPCWSTR filename)
3803 HANDLE handle;
3804 LPWSTR ret = NULL;
3805 int i;
3807 typedef struct _tagTT_OFFSET_TABLE{
3808 USHORT uMajorVersion;
3809 USHORT uMinorVersion;
3810 USHORT uNumOfTables;
3811 USHORT uSearchRange;
3812 USHORT uEntrySelector;
3813 USHORT uRangeShift;
3814 }TT_OFFSET_TABLE;
3816 typedef struct _tagTT_TABLE_DIRECTORY{
3817 char szTag[4]; /* table name */
3818 ULONG uCheckSum; /* Check sum */
3819 ULONG uOffset; /* Offset from beginning of file */
3820 ULONG uLength; /* length of the table in bytes */
3821 }TT_TABLE_DIRECTORY;
3823 typedef struct _tagTT_NAME_TABLE_HEADER{
3824 USHORT uFSelector; /* format selector. Always 0 */
3825 USHORT uNRCount; /* Name Records count */
3826 USHORT uStorageOffset; /* Offset for strings storage,
3827 * from start of the table */
3828 }TT_NAME_TABLE_HEADER;
3830 typedef struct _tagTT_NAME_RECORD{
3831 USHORT uPlatformID;
3832 USHORT uEncodingID;
3833 USHORT uLanguageID;
3834 USHORT uNameID;
3835 USHORT uStringLength;
3836 USHORT uStringOffset; /* from start of storage area */
3837 }TT_NAME_RECORD;
3839 #define SWAPWORD(x) MAKEWORD(HIBYTE(x), LOBYTE(x))
3840 #define SWAPLONG(x) MAKELONG(SWAPWORD(HIWORD(x)), SWAPWORD(LOWORD(x)))
3842 handle = CreateFileW(filename ,GENERIC_READ, 0, NULL, OPEN_EXISTING,
3843 FILE_ATTRIBUTE_NORMAL, 0 );
3844 if (handle != INVALID_HANDLE_VALUE)
3846 TT_TABLE_DIRECTORY tblDir;
3847 BOOL bFound = FALSE;
3848 TT_OFFSET_TABLE ttOffsetTable;
3850 ReadFile(handle,&ttOffsetTable, sizeof(TT_OFFSET_TABLE),NULL,NULL);
3851 ttOffsetTable.uNumOfTables = SWAPWORD(ttOffsetTable.uNumOfTables);
3852 ttOffsetTable.uMajorVersion = SWAPWORD(ttOffsetTable.uMajorVersion);
3853 ttOffsetTable.uMinorVersion = SWAPWORD(ttOffsetTable.uMinorVersion);
3855 if (ttOffsetTable.uMajorVersion != 1 ||
3856 ttOffsetTable.uMinorVersion != 0)
3857 return NULL;
3859 for (i=0; i< ttOffsetTable.uNumOfTables; i++)
3861 ReadFile(handle,&tblDir, sizeof(TT_TABLE_DIRECTORY),NULL,NULL);
3862 if (strncmp(tblDir.szTag,"name",4)==0)
3864 bFound = TRUE;
3865 tblDir.uLength = SWAPLONG(tblDir.uLength);
3866 tblDir.uOffset = SWAPLONG(tblDir.uOffset);
3867 break;
3871 if (bFound)
3873 TT_NAME_TABLE_HEADER ttNTHeader;
3874 TT_NAME_RECORD ttRecord;
3876 SetFilePointer(handle, tblDir.uOffset, NULL, FILE_BEGIN);
3877 ReadFile(handle,&ttNTHeader, sizeof(TT_NAME_TABLE_HEADER),
3878 NULL,NULL);
3880 ttNTHeader.uNRCount = SWAPWORD(ttNTHeader.uNRCount);
3881 ttNTHeader.uStorageOffset = SWAPWORD(ttNTHeader.uStorageOffset);
3882 bFound = FALSE;
3883 for(i=0; i<ttNTHeader.uNRCount; i++)
3885 ReadFile(handle,&ttRecord, sizeof(TT_NAME_RECORD),NULL,NULL);
3886 ttRecord.uNameID = SWAPWORD(ttRecord.uNameID);
3887 /* 4 is the Full Font Name */
3888 if(ttRecord.uNameID == 4)
3890 int nPos;
3891 LPSTR buf;
3892 static LPCSTR tt = " (TrueType)";
3894 ttRecord.uStringLength = SWAPWORD(ttRecord.uStringLength);
3895 ttRecord.uStringOffset = SWAPWORD(ttRecord.uStringOffset);
3896 nPos = SetFilePointer(handle, 0, NULL, FILE_CURRENT);
3897 SetFilePointer(handle, tblDir.uOffset +
3898 ttRecord.uStringOffset +
3899 ttNTHeader.uStorageOffset,
3900 NULL, FILE_BEGIN);
3901 buf = msi_alloc( ttRecord.uStringLength + 1 + strlen(tt) );
3902 memset(buf, 0, ttRecord.uStringLength + 1 + strlen(tt));
3903 ReadFile(handle, buf, ttRecord.uStringLength, NULL, NULL);
3904 if (strlen(buf) > 0)
3906 strcat(buf,tt);
3907 ret = strdupAtoW(buf);
3908 msi_free(buf);
3909 break;
3912 msi_free(buf);
3913 SetFilePointer(handle,nPos, NULL, FILE_BEGIN);
3917 CloseHandle(handle);
3919 else
3920 ERR("Unable to open font file %s\n", debugstr_w(filename));
3922 TRACE("Returning fontname %s\n",debugstr_w(ret));
3923 return ret;
3926 static UINT ITERATE_RegisterFonts(MSIRECORD *row, LPVOID param)
3928 MSIPACKAGE *package = (MSIPACKAGE*)param;
3929 LPWSTR name;
3930 LPCWSTR filename;
3931 MSIFILE *file;
3932 static const WCHAR regfont1[] =
3933 {'S','o','f','t','w','a','r','e','\\',
3934 'M','i','c','r','o','s','o','f','t','\\',
3935 'W','i','n','d','o','w','s',' ','N','T','\\',
3936 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3937 'F','o','n','t','s',0};
3938 static const WCHAR regfont2[] =
3939 {'S','o','f','t','w','a','r','e','\\',
3940 'M','i','c','r','o','s','o','f','t','\\',
3941 'W','i','n','d','o','w','s','\\',
3942 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3943 'F','o','n','t','s',0};
3944 HKEY hkey1;
3945 HKEY hkey2;
3947 filename = MSI_RecordGetString( row, 1 );
3948 file = get_loaded_file( package, filename );
3949 if (!file)
3951 ERR("Unable to load file\n");
3952 return ERROR_SUCCESS;
3955 /* check to make sure that component is installed */
3956 if (!ACTION_VerifyComponentForAction(package,
3957 file->Component, INSTALLSTATE_LOCAL))
3959 TRACE("Skipping: Component not scheduled for install\n");
3960 return ERROR_SUCCESS;
3963 RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont1,&hkey1);
3964 RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont2,&hkey2);
3966 if (MSI_RecordIsNull(row,2))
3967 name = load_ttfname_from( file->TargetPath );
3968 else
3969 name = load_dynamic_stringW(row,2);
3971 if (name)
3973 msi_reg_set_val_str( hkey1, name, file->FileName );
3974 msi_reg_set_val_str( hkey2, name, file->FileName );
3977 msi_free(name);
3978 RegCloseKey(hkey1);
3979 RegCloseKey(hkey2);
3980 return ERROR_SUCCESS;
3983 static UINT ACTION_RegisterFonts(MSIPACKAGE *package)
3985 UINT rc;
3986 MSIQUERY * view;
3987 static const WCHAR ExecSeqQuery[] =
3988 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3989 '`','F','o','n','t','`',0};
3991 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3992 if (rc != ERROR_SUCCESS)
3994 TRACE("MSI_DatabaseOpenViewW failed: %d\n", rc);
3995 return ERROR_SUCCESS;
3998 MSI_IterateRecords(view, NULL, ITERATE_RegisterFonts, package);
3999 msiobj_release(&view->hdr);
4001 return ERROR_SUCCESS;
4004 static UINT ITERATE_PublishComponent(MSIRECORD *rec, LPVOID param)
4006 MSIPACKAGE *package = (MSIPACKAGE*)param;
4007 LPCWSTR compgroupid=NULL;
4008 LPCWSTR feature=NULL;
4009 LPCWSTR text = NULL;
4010 LPCWSTR qualifier = NULL;
4011 LPCWSTR component = NULL;
4012 LPWSTR advertise = NULL;
4013 LPWSTR output = NULL;
4014 HKEY hkey;
4015 UINT rc = ERROR_SUCCESS;
4016 MSICOMPONENT *comp;
4017 DWORD sz = 0;
4019 component = MSI_RecordGetString(rec,3);
4020 comp = get_loaded_component(package,component);
4022 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL) &&
4023 !ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_SOURCE) &&
4024 !ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_ADVERTISED))
4026 TRACE("Skipping: Component %s not scheduled for install\n",
4027 debugstr_w(component));
4029 return ERROR_SUCCESS;
4032 compgroupid = MSI_RecordGetString(rec,1);
4034 rc = MSIREG_OpenUserComponentsKey(compgroupid, &hkey, TRUE);
4035 if (rc != ERROR_SUCCESS)
4036 goto end;
4038 text = MSI_RecordGetString(rec,4);
4039 qualifier = MSI_RecordGetString(rec,2);
4040 feature = MSI_RecordGetString(rec,5);
4042 advertise = create_component_advertise_string(package, comp, feature);
4044 sz = strlenW(advertise);
4046 if (text)
4047 sz += lstrlenW(text);
4049 sz+=3;
4050 sz *= sizeof(WCHAR);
4052 output = msi_alloc(sz);
4053 memset(output,0,sz);
4054 strcpyW(output,advertise);
4055 msi_free(advertise);
4057 if (text)
4058 strcatW(output,text);
4060 msi_reg_set_val_multi_str( hkey, qualifier, output );
4062 end:
4063 RegCloseKey(hkey);
4064 msi_free(output);
4066 return rc;
4070 * At present I am ignorning the advertised components part of this and only
4071 * focusing on the qualified component sets
4073 static UINT ACTION_PublishComponents(MSIPACKAGE *package)
4075 UINT rc;
4076 MSIQUERY * view;
4077 static const WCHAR ExecSeqQuery[] =
4078 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
4079 '`','P','u','b','l','i','s','h',
4080 'C','o','m','p','o','n','e','n','t','`',0};
4082 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
4083 if (rc != ERROR_SUCCESS)
4084 return ERROR_SUCCESS;
4086 rc = MSI_IterateRecords(view, NULL, ITERATE_PublishComponent, package);
4087 msiobj_release(&view->hdr);
4089 return rc;
4092 static UINT msi_unimplemented_action_stub( MSIPACKAGE *package,
4093 LPCSTR action, LPCWSTR table )
4095 static const WCHAR query[] = {
4096 'S','E','L','E','C','T',' ','*',' ',
4097 'F','R','O','M',' ','`','%','s','`',0 };
4098 MSIQUERY *view = NULL;
4099 DWORD count = 0;
4100 UINT r;
4102 r = MSI_OpenQuery( package->db, &view, query, table );
4103 if (r == ERROR_SUCCESS)
4105 r = MSI_IterateRecords(view, &count, NULL, package);
4106 msiobj_release(&view->hdr);
4109 if (count)
4110 FIXME("%s -> %lu ignored %s table values\n",
4111 action, count, debugstr_w(table));
4113 return ERROR_SUCCESS;
4116 static UINT ACTION_RemoveIniValues( MSIPACKAGE *package )
4118 static const WCHAR table[] =
4119 {'R','e','m','o','v','e','I','n','i','F','i','l','e',0 };
4120 return msi_unimplemented_action_stub( package, "RemoveIniValues", table );
4123 static UINT ACTION_MoveFiles( MSIPACKAGE *package )
4125 static const WCHAR table[] = { 'M','o','v','e','F','i','l','e',0 };
4126 return msi_unimplemented_action_stub( package, "MoveFiles", table );
4129 static UINT ACTION_PatchFiles( MSIPACKAGE *package )
4131 static const WCHAR table[] = { 'P','a','t','c','h',0 };
4132 return msi_unimplemented_action_stub( package, "PatchFiles", table );
4135 static UINT ACTION_BindImage( MSIPACKAGE *package )
4137 static const WCHAR table[] = { 'B','i','n','d','I','m','a','g','e',0 };
4138 return msi_unimplemented_action_stub( package, "BindImage", table );
4141 static UINT ACTION_IsolateComponents( MSIPACKAGE *package )
4143 static const WCHAR table[] = {
4144 'I','s','o','l','a','t','e','C','o','m','p','o','n','e','n','t',0 };
4145 return msi_unimplemented_action_stub( package, "IsolateComponents", table );
4148 static UINT ACTION_MigrateFeatureStates( MSIPACKAGE *package )
4150 static const WCHAR table[] = { 'U','p','g','r','a','d','e',0 };
4151 return msi_unimplemented_action_stub( package, "MigrateFeatureStates", table );
4154 static UINT ACTION_SelfUnregModules( MSIPACKAGE *package )
4156 static const WCHAR table[] = { 'S','e','l','f','R','e','g',0 };
4157 return msi_unimplemented_action_stub( package, "SelfUnregModules", table );
4160 static UINT ACTION_InstallServices( MSIPACKAGE *package )
4162 static const WCHAR table[] = {
4163 'S','e','r','v','i','c','e','I','n','s','t','a','l','l',0 };
4164 return msi_unimplemented_action_stub( package, "InstallServices", table );
4167 static UINT ACTION_StartServices( MSIPACKAGE *package )
4169 static const WCHAR table[] = {
4170 'S','e','r','v','i','c','e','C','o','n','t','r','o','l',0 };
4171 return msi_unimplemented_action_stub( package, "StartServices", table );
4174 static UINT ACTION_StopServices( MSIPACKAGE *package )
4176 static const WCHAR table[] = {
4177 'S','e','r','v','i','c','e','C','o','n','t','r','o','l',0 };
4178 return msi_unimplemented_action_stub( package, "StopServices", table );
4181 static UINT ACTION_DeleteServices( MSIPACKAGE *package )
4183 static const WCHAR table[] = {
4184 'S','e','r','v','i','c','e','C','o','n','t','r','o','l',0 };
4185 return msi_unimplemented_action_stub( package, "DeleteServices", table );
4188 static UINT ACTION_WriteEnvironmentStrings( MSIPACKAGE *package )
4190 static const WCHAR table[] = {
4191 'E','n','v','i','r','o','n','m','e','n','t',0 };
4192 return msi_unimplemented_action_stub( package, "WriteEnvironmentStrings", table );
4195 static UINT ACTION_RemoveEnvironmentStrings( MSIPACKAGE *package )
4197 static const WCHAR table[] = {
4198 'E','n','v','i','r','o','n','m','e','n','t',0 };
4199 return msi_unimplemented_action_stub( package, "RemoveEnvironmentStrings", table );
4202 static UINT ACTION_MsiPublishAssemblies( MSIPACKAGE *package )
4204 static const WCHAR table[] = {
4205 'M','s','i','A','s','s','e','m','b','l','y',0 };
4206 return msi_unimplemented_action_stub( package, "MsiPublishAssemblies", table );
4209 static UINT ACTION_MsiUnpublishAssemblies( MSIPACKAGE *package )
4211 static const WCHAR table[] = {
4212 'M','s','i','A','s','s','e','m','b','l','y',0 };
4213 return msi_unimplemented_action_stub( package, "MsiUnpublishAssemblies", table );
4216 static UINT ACTION_UnregisterFonts( MSIPACKAGE *package )
4218 static const WCHAR table[] = { 'F','o','n','t',0 };
4219 return msi_unimplemented_action_stub( package, "UnregisterFonts", table );
4222 static struct _actions StandardActions[] = {
4223 { szAllocateRegistrySpace, NULL},
4224 { szAppSearch, ACTION_AppSearch },
4225 { szBindImage, ACTION_BindImage },
4226 { szCCPSearch, NULL},
4227 { szCostFinalize, ACTION_CostFinalize },
4228 { szCostInitialize, ACTION_CostInitialize },
4229 { szCreateFolders, ACTION_CreateFolders },
4230 { szCreateShortcuts, ACTION_CreateShortcuts },
4231 { szDeleteServices, ACTION_DeleteServices },
4232 { szDisableRollback, NULL},
4233 { szDuplicateFiles, ACTION_DuplicateFiles },
4234 { szExecuteAction, ACTION_ExecuteAction },
4235 { szFileCost, ACTION_FileCost },
4236 { szFindRelatedProducts, ACTION_FindRelatedProducts },
4237 { szForceReboot, ACTION_ForceReboot },
4238 { szInstallAdminPackage, NULL},
4239 { szInstallExecute, ACTION_InstallExecute },
4240 { szInstallExecuteAgain, ACTION_InstallExecute },
4241 { szInstallFiles, ACTION_InstallFiles},
4242 { szInstallFinalize, ACTION_InstallFinalize },
4243 { szInstallInitialize, ACTION_InstallInitialize },
4244 { szInstallSFPCatalogFile, NULL},
4245 { szInstallValidate, ACTION_InstallValidate },
4246 { szIsolateComponents, ACTION_IsolateComponents },
4247 { szLaunchConditions, ACTION_LaunchConditions },
4248 { szMigrateFeatureStates, ACTION_MigrateFeatureStates },
4249 { szMoveFiles, ACTION_MoveFiles },
4250 { szMsiPublishAssemblies, ACTION_MsiPublishAssemblies },
4251 { szMsiUnpublishAssemblies, ACTION_MsiUnpublishAssemblies },
4252 { szInstallODBC, NULL},
4253 { szInstallServices, ACTION_InstallServices },
4254 { szPatchFiles, ACTION_PatchFiles },
4255 { szProcessComponents, ACTION_ProcessComponents },
4256 { szPublishComponents, ACTION_PublishComponents },
4257 { szPublishFeatures, ACTION_PublishFeatures },
4258 { szPublishProduct, ACTION_PublishProduct },
4259 { szRegisterClassInfo, ACTION_RegisterClassInfo },
4260 { szRegisterComPlus, NULL},
4261 { szRegisterExtensionInfo, ACTION_RegisterExtensionInfo },
4262 { szRegisterFonts, ACTION_RegisterFonts },
4263 { szRegisterMIMEInfo, ACTION_RegisterMIMEInfo },
4264 { szRegisterProduct, ACTION_RegisterProduct },
4265 { szRegisterProgIdInfo, ACTION_RegisterProgIdInfo },
4266 { szRegisterTypeLibraries, ACTION_RegisterTypeLibraries },
4267 { szRegisterUser, ACTION_RegisterUser},
4268 { szRemoveDuplicateFiles, NULL},
4269 { szRemoveEnvironmentStrings, ACTION_RemoveEnvironmentStrings },
4270 { szRemoveExistingProducts, NULL},
4271 { szRemoveFiles, NULL},
4272 { szRemoveFolders, NULL},
4273 { szRemoveIniValues, ACTION_RemoveIniValues },
4274 { szRemoveODBC, NULL},
4275 { szRemoveRegistryValues, NULL},
4276 { szRemoveShortcuts, NULL},
4277 { szResolveSource, ACTION_ResolveSource},
4278 { szRMCCPSearch, NULL},
4279 { szScheduleReboot, NULL},
4280 { szSelfRegModules, ACTION_SelfRegModules },
4281 { szSelfUnregModules, ACTION_SelfUnregModules },
4282 { szSetODBCFolders, NULL},
4283 { szStartServices, ACTION_StartServices },
4284 { szStopServices, ACTION_StopServices },
4285 { szUnpublishComponents, NULL},
4286 { szUnpublishFeatures, NULL},
4287 { szUnregisterClassInfo, NULL},
4288 { szUnregisterComPlus, NULL},
4289 { szUnregisterExtensionInfo, NULL},
4290 { szUnregisterFonts, ACTION_UnregisterFonts },
4291 { szUnregisterMIMEInfo, NULL},
4292 { szUnregisterProgIdInfo, NULL},
4293 { szUnregisterTypeLibraries, NULL},
4294 { szValidateProductID, NULL},
4295 { szWriteEnvironmentStrings, ACTION_WriteEnvironmentStrings },
4296 { szWriteIniValues, ACTION_WriteIniValues },
4297 { szWriteRegistryValues, ACTION_WriteRegistryValues},
4298 { NULL, NULL},