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
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
37 #include "wine/debug.h"
42 #include "wine/unicode.h"
46 #define REG_PROGRESS_VALUE 13200
47 #define COMPONENT_PROGRESS_VALUE 24000
49 WINE_DEFAULT_DEBUG_CHANNEL(msi);
54 static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran);
55 static UINT ACTION_ProcessUISequence(MSIPACKAGE *package);
56 static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq, BOOL UI);
61 typedef UINT (*STANDARDACTIONHANDLER)(MSIPACKAGE*);
63 static UINT ACTION_LaunchConditions(MSIPACKAGE *package);
64 static UINT ACTION_CostInitialize(MSIPACKAGE *package);
65 static UINT ACTION_CreateFolders(MSIPACKAGE *package);
66 static UINT ACTION_CostFinalize(MSIPACKAGE *package);
67 static UINT ACTION_FileCost(MSIPACKAGE *package);
68 static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package);
69 static UINT ACTION_InstallInitialize(MSIPACKAGE *package);
70 static UINT ACTION_InstallValidate(MSIPACKAGE *package);
71 static UINT ACTION_ProcessComponents(MSIPACKAGE *package);
72 static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package);
73 static UINT ACTION_RegisterUser(MSIPACKAGE *package);
74 static UINT ACTION_CreateShortcuts(MSIPACKAGE *package);
75 static UINT ACTION_PublishProduct(MSIPACKAGE *package);
76 static UINT ACTION_WriteIniValues(MSIPACKAGE *package);
77 static UINT ACTION_SelfRegModules(MSIPACKAGE *package);
78 static UINT ACTION_PublishFeatures(MSIPACKAGE *package);
79 static UINT ACTION_RegisterProduct(MSIPACKAGE *package);
80 static UINT ACTION_InstallExecute(MSIPACKAGE *package);
81 static UINT ACTION_InstallFinalize(MSIPACKAGE *package);
82 static UINT ACTION_ForceReboot(MSIPACKAGE *package);
83 static UINT ACTION_ResolveSource(MSIPACKAGE *package);
84 static UINT ACTION_ExecuteAction(MSIPACKAGE *package);
85 static UINT ACTION_RegisterFonts(MSIPACKAGE *package);
86 static UINT ACTION_PublishComponents(MSIPACKAGE *package);
87 static UINT ACTION_RemoveIniValues(MSIPACKAGE *package);
90 * consts and values used
92 static const WCHAR c_colon[] = {'C',':','\\',0};
94 const static WCHAR szCreateFolders[] =
95 {'C','r','e','a','t','e','F','o','l','d','e','r','s',0};
96 const static WCHAR szCostFinalize[] =
97 {'C','o','s','t','F','i','n','a','l','i','z','e',0};
98 const WCHAR szInstallFiles[] =
99 {'I','n','s','t','a','l','l','F','i','l','e','s',0};
100 const WCHAR szDuplicateFiles[] =
101 {'D','u','p','l','i','c','a','t','e','F','i','l','e','s',0};
102 const static WCHAR szWriteRegistryValues[] =
103 {'W','r','i','t','e','R','e','g','i','s','t','r','y',
104 'V','a','l','u','e','s',0};
105 const static WCHAR szCostInitialize[] =
106 {'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0};
107 const static WCHAR szFileCost[] =
108 {'F','i','l','e','C','o','s','t',0};
109 const static WCHAR szInstallInitialize[] =
110 {'I','n','s','t','a','l','l','I','n','i','t','i','a','l','i','z','e',0};
111 const static WCHAR szInstallValidate[] =
112 {'I','n','s','t','a','l','l','V','a','l','i','d','a','t','e',0};
113 const static WCHAR szLaunchConditions[] =
114 {'L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','s',0};
115 const static WCHAR szProcessComponents[] =
116 {'P','r','o','c','e','s','s','C','o','m','p','o','n','e','n','t','s',0};
117 const static WCHAR szRegisterTypeLibraries[] =
118 {'R','e','g','i','s','t','e','r','T','y','p','e',
119 'L','i','b','r','a','r','i','e','s',0};
120 const WCHAR szRegisterClassInfo[] =
121 {'R','e','g','i','s','t','e','r','C','l','a','s','s','I','n','f','o',0};
122 const WCHAR szRegisterProgIdInfo[] =
123 {'R','e','g','i','s','t','e','r','P','r','o','g','I','d','I','n','f','o',0};
124 const static WCHAR szCreateShortcuts[] =
125 {'C','r','e','a','t','e','S','h','o','r','t','c','u','t','s',0};
126 const static WCHAR szPublishProduct[] =
127 {'P','u','b','l','i','s','h','P','r','o','d','u','c','t',0};
128 const static WCHAR szWriteIniValues[] =
129 {'W','r','i','t','e','I','n','i','V','a','l','u','e','s',0};
130 const static WCHAR szSelfRegModules[] =
131 {'S','e','l','f','R','e','g','M','o','d','u','l','e','s',0};
132 const static WCHAR szPublishFeatures[] =
133 {'P','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0};
134 const static WCHAR szRegisterProduct[] =
135 {'R','e','g','i','s','t','e','r','P','r','o','d','u','c','t',0};
136 const static WCHAR szInstallExecute[] =
137 {'I','n','s','t','a','l','l','E','x','e','c','u','t','e',0};
138 const static WCHAR szInstallExecuteAgain[] =
139 {'I','n','s','t','a','l','l','E','x','e','c','u','t','e',
140 'A','g','a','i','n',0};
141 const static WCHAR szInstallFinalize[] =
142 {'I','n','s','t','a','l','l','F','i','n','a','l','i','z','e',0};
143 const static WCHAR szForceReboot[] =
144 {'F','o','r','c','e','R','e','b','o','o','t',0};
145 const static WCHAR szResolveSource[] =
146 {'R','e','s','o','l','v','e','S','o','u','r','c','e',0};
147 const WCHAR szAppSearch[] =
148 {'A','p','p','S','e','a','r','c','h',0};
149 const static WCHAR szAllocateRegistrySpace[] =
150 {'A','l','l','o','c','a','t','e','R','e','g','i','s','t','r','y',
151 'S','p','a','c','e',0};
152 const static WCHAR szBindImage[] =
153 {'B','i','n','d','I','m','a','g','e',0};
154 const static WCHAR szCCPSearch[] =
155 {'C','C','P','S','e','a','r','c','h',0};
156 const static WCHAR szDeleteServices[] =
157 {'D','e','l','e','t','e','S','e','r','v','i','c','e','s',0};
158 const static WCHAR szDisableRollback[] =
159 {'D','i','s','a','b','l','e','R','o','l','l','b','a','c','k',0};
160 const static WCHAR szExecuteAction[] =
161 {'E','x','e','c','u','t','e','A','c','t','i','o','n',0};
162 const WCHAR szFindRelatedProducts[] =
163 {'F','i','n','d','R','e','l','a','t','e','d',
164 'P','r','o','d','u','c','t','s',0};
165 const static WCHAR szInstallAdminPackage[] =
166 {'I','n','s','t','a','l','l','A','d','m','i','n',
167 'P','a','c','k','a','g','e',0};
168 const static WCHAR szInstallSFPCatalogFile[] =
169 {'I','n','s','t','a','l','l','S','F','P','C','a','t','a','l','o','g',
171 const static WCHAR szIsolateComponents[] =
172 {'I','s','o','l','a','t','e','C','o','m','p','o','n','e','n','t','s',0};
173 const WCHAR szMigrateFeatureStates[] =
174 {'M','i','g','r','a','t','e','F','e','a','t','u','r','e',
175 'S','t','a','t','e','s',0};
176 const WCHAR szMoveFiles[] =
177 {'M','o','v','e','F','i','l','e','s',0};
178 const static WCHAR szMsiPublishAssemblies[] =
179 {'M','s','i','P','u','b','l','i','s','h',
180 'A','s','s','e','m','b','l','i','e','s',0};
181 const static WCHAR szMsiUnpublishAssemblies[] =
182 {'M','s','i','U','n','p','u','b','l','i','s','h',
183 'A','s','s','e','m','b','l','i','e','s',0};
184 const static WCHAR szInstallODBC[] =
185 {'I','n','s','t','a','l','l','O','D','B','C',0};
186 const static WCHAR szInstallServices[] =
187 {'I','n','s','t','a','l','l','S','e','r','v','i','c','e','s',0};
188 const WCHAR szPatchFiles[] =
189 {'P','a','t','c','h','F','i','l','e','s',0};
190 const static WCHAR szPublishComponents[] =
191 {'P','u','b','l','i','s','h','C','o','m','p','o','n','e','n','t','s',0};
192 const static WCHAR szRegisterComPlus[] =
193 {'R','e','g','i','s','t','e','r','C','o','m','P','l','u','s',0};
194 const WCHAR szRegisterExtensionInfo[] =
195 {'R','e','g','i','s','t','e','r','E','x','t','e','n','s','i','o','n',
197 const static WCHAR szRegisterFonts[] =
198 {'R','e','g','i','s','t','e','r','F','o','n','t','s',0};
199 const WCHAR szRegisterMIMEInfo[] =
200 {'R','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0};
201 const static WCHAR szRegisterUser[] =
202 {'R','e','g','i','s','t','e','r','U','s','e','r',0};
203 const WCHAR szRemoveDuplicateFiles[] =
204 {'R','e','m','o','v','e','D','u','p','l','i','c','a','t','e',
205 'F','i','l','e','s',0};
206 const static WCHAR szRemoveEnvironmentStrings[] =
207 {'R','e','m','o','v','e','E','n','v','i','r','o','n','m','e','n','t',
208 'S','t','r','i','n','g','s',0};
209 const WCHAR szRemoveExistingProducts[] =
210 {'R','e','m','o','v','e','E','x','i','s','t','i','n','g',
211 'P','r','o','d','u','c','t','s',0};
212 const WCHAR szRemoveFiles[] =
213 {'R','e','m','o','v','e','F','i','l','e','s',0};
214 const static WCHAR szRemoveFolders[] =
215 {'R','e','m','o','v','e','F','o','l','d','e','r','s',0};
216 const static WCHAR szRemoveIniValues[] =
217 {'R','e','m','o','v','e','I','n','i','V','a','l','u','e','s',0};
218 const static WCHAR szRemoveODBC[] =
219 {'R','e','m','o','v','e','O','D','B','C',0};
220 const static WCHAR szRemoveRegistryValues[] =
221 {'R','e','m','o','v','e','R','e','g','i','s','t','r','y',
222 'V','a','l','u','e','s',0};
223 const static WCHAR szRemoveShortcuts[] =
224 {'R','e','m','o','v','e','S','h','o','r','t','c','u','t','s',0};
225 const static WCHAR szRMCCPSearch[] =
226 {'R','M','C','C','P','S','e','a','r','c','h',0};
227 const static WCHAR szScheduleReboot[] =
228 {'S','c','h','e','d','u','l','e','R','e','b','o','o','t',0};
229 const static WCHAR szSelfUnregModules[] =
230 {'S','e','l','f','U','n','r','e','g','M','o','d','u','l','e','s',0};
231 const static WCHAR szSetODBCFolders[] =
232 {'S','e','t','O','D','B','C','F','o','l','d','e','r','s',0};
233 const static WCHAR szStartServices[] =
234 {'S','t','a','r','t','S','e','r','v','i','c','e','s',0};
235 const static WCHAR szStopServices[] =
236 {'S','t','o','p','S','e','r','v','i','c','e','s',0};
237 const static WCHAR szUnpublishComponents[] =
238 {'U','n','p','u','b','l','i','s','h',
239 'C','o','m','p','o','n','e','n','t','s',0};
240 const static WCHAR szUnpublishFeatures[] =
241 {'U','n','p','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0};
242 const WCHAR szUnregisterClassInfo[] =
243 {'U','n','r','e','g','i','s','t','e','r','C','l','a','s','s',
245 const static WCHAR szUnregisterComPlus[] =
246 {'U','n','r','e','g','i','s','t','e','r','C','o','m','P','l','u','s',0};
247 const WCHAR szUnregisterExtensionInfo[] =
248 {'U','n','r','e','g','i','s','t','e','r',
249 'E','x','t','e','n','s','i','o','n','I','n','f','o',0};
250 const static WCHAR szUnregisterFonts[] =
251 {'U','n','r','e','g','i','s','t','e','r','F','o','n','t','s',0};
252 const WCHAR szUnregisterMIMEInfo[] =
253 {'U','n','r','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0};
254 const WCHAR szUnregisterProgIdInfo[] =
255 {'U','n','r','e','g','i','s','t','e','r','P','r','o','g','I','d',
257 const static WCHAR szUnregisterTypeLibraries[] =
258 {'U','n','r','e','g','i','s','t','e','r','T','y','p','e',
259 'L','i','b','r','a','r','i','e','s',0};
260 const static WCHAR szValidateProductID[] =
261 {'V','a','l','i','d','a','t','e','P','r','o','d','u','c','t','I','D',0};
262 const static WCHAR szWriteEnvironmentStrings[] =
263 {'W','r','i','t','e','E','n','v','i','r','o','n','m','e','n','t',
264 'S','t','r','i','n','g','s',0};
268 STANDARDACTIONHANDLER handler;
271 static struct _actions StandardActions[] = {
272 { szAllocateRegistrySpace, NULL},
273 { szAppSearch, ACTION_AppSearch },
274 { szBindImage, NULL},
275 { szCCPSearch, NULL},
276 { szCostFinalize, ACTION_CostFinalize },
277 { szCostInitialize, ACTION_CostInitialize },
278 { szCreateFolders, ACTION_CreateFolders },
279 { szCreateShortcuts, ACTION_CreateShortcuts },
280 { szDeleteServices, NULL},
281 { szDisableRollback, NULL},
282 { szDuplicateFiles, ACTION_DuplicateFiles },
283 { szExecuteAction, ACTION_ExecuteAction },
284 { szFileCost, ACTION_FileCost },
285 { szFindRelatedProducts, ACTION_FindRelatedProducts },
286 { szForceReboot, ACTION_ForceReboot },
287 { szInstallAdminPackage, NULL},
288 { szInstallExecute, ACTION_InstallExecute },
289 { szInstallExecuteAgain, ACTION_InstallExecute },
290 { szInstallFiles, ACTION_InstallFiles},
291 { szInstallFinalize, ACTION_InstallFinalize },
292 { szInstallInitialize, ACTION_InstallInitialize },
293 { szInstallSFPCatalogFile, NULL},
294 { szInstallValidate, ACTION_InstallValidate },
295 { szIsolateComponents, NULL},
296 { szLaunchConditions, ACTION_LaunchConditions },
297 { szMigrateFeatureStates, NULL},
298 { szMoveFiles, NULL},
299 { szMsiPublishAssemblies, NULL},
300 { szMsiUnpublishAssemblies, NULL},
301 { szInstallODBC, NULL},
302 { szInstallServices, NULL},
303 { szPatchFiles, NULL},
304 { szProcessComponents, ACTION_ProcessComponents },
305 { szPublishComponents, ACTION_PublishComponents },
306 { szPublishFeatures, ACTION_PublishFeatures },
307 { szPublishProduct, ACTION_PublishProduct },
308 { szRegisterClassInfo, ACTION_RegisterClassInfo },
309 { szRegisterComPlus, NULL},
310 { szRegisterExtensionInfo, ACTION_RegisterExtensionInfo },
311 { szRegisterFonts, ACTION_RegisterFonts },
312 { szRegisterMIMEInfo, ACTION_RegisterMIMEInfo },
313 { szRegisterProduct, ACTION_RegisterProduct },
314 { szRegisterProgIdInfo, ACTION_RegisterProgIdInfo },
315 { szRegisterTypeLibraries, ACTION_RegisterTypeLibraries },
316 { szRegisterUser, ACTION_RegisterUser},
317 { szRemoveDuplicateFiles, NULL},
318 { szRemoveEnvironmentStrings, NULL},
319 { szRemoveExistingProducts, NULL},
320 { szRemoveFiles, NULL},
321 { szRemoveFolders, NULL},
322 { szRemoveIniValues, ACTION_RemoveIniValues },
323 { szRemoveODBC, NULL},
324 { szRemoveRegistryValues, NULL},
325 { szRemoveShortcuts, NULL},
326 { szResolveSource, ACTION_ResolveSource},
327 { szRMCCPSearch, NULL},
328 { szScheduleReboot, NULL},
329 { szSelfRegModules, ACTION_SelfRegModules },
330 { szSelfUnregModules, NULL},
331 { szSetODBCFolders, NULL},
332 { szStartServices, NULL},
333 { szStopServices, NULL},
334 { szUnpublishComponents, NULL},
335 { szUnpublishFeatures, NULL},
336 { szUnregisterClassInfo, NULL},
337 { szUnregisterComPlus, NULL},
338 { szUnregisterExtensionInfo, NULL},
339 { szUnregisterFonts, NULL},
340 { szUnregisterMIMEInfo, NULL},
341 { szUnregisterProgIdInfo, NULL},
342 { szUnregisterTypeLibraries, NULL},
343 { szValidateProductID, NULL},
344 { szWriteEnvironmentStrings, NULL},
345 { szWriteIniValues, ACTION_WriteIniValues },
346 { szWriteRegistryValues, ACTION_WriteRegistryValues},
351 /********************************************************
353 ********************************************************/
355 static void ce_actiontext(MSIPACKAGE* package, LPCWSTR action)
357 static const WCHAR szActionText[] =
358 {'A','c','t','i','o','n','T','e','x','t',0};
361 row = MSI_CreateRecord(1);
362 MSI_RecordSetStringW(row,1,action);
363 ControlEvent_FireSubscribedEvent(package,szActionText, row);
364 msiobj_release(&row->hdr);
367 static void ui_actionstart(MSIPACKAGE *package, LPCWSTR action)
369 static const WCHAR template_s[]=
370 {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ', '%','s',
372 static const WCHAR format[] =
373 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
374 static const WCHAR Query_t[] =
375 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
376 '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
377 'W','H','E','R','E', ' ','`','A','c','t','i','o','n','`',' ','=',
378 ' ','\'','%','s','\'',0};
385 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
387 row = MSI_QueryGetRecord( package->db, Query_t, action );
391 ActionText = MSI_RecordGetString(row,2);
392 deformat_string(package, ActionText, &deformated);
394 sprintfW(message,template_s,timet,action,deformated);
395 ce_actiontext(package, deformated);
396 msiobj_release(&row->hdr);
398 row = MSI_CreateRecord(1);
399 MSI_RecordSetStringW(row,1,message);
401 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONSTART, row);
402 msiobj_release(&row->hdr);
403 msi_free(deformated);
406 static void ui_actioninfo(MSIPACKAGE *package, LPCWSTR action, BOOL start,
410 static const WCHAR template_s[]=
411 {'A','c','t','i','o','n',' ','s','t','a','r','t',' ','%','s',':',' ',
413 static const WCHAR template_e[]=
414 {'A','c','t','i','o','n',' ','e','n','d','e','d',' ','%','s',':',' ',
415 '%','s', '.',' ','R','e','t','u','r','n',' ','v','a','l','u','e',' ',
417 static const WCHAR format[] =
418 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
422 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
424 sprintfW(message,template_s,timet,action);
426 sprintfW(message,template_e,timet,action,rc);
428 row = MSI_CreateRecord(1);
429 MSI_RecordSetStringW(row,1,message);
431 MSI_ProcessMessage(package, INSTALLMESSAGE_INFO, row);
432 msiobj_release(&row->hdr);
435 /****************************************************
436 * TOP level entry points
437 *****************************************************/
439 UINT ACTION_DoTopLevelINSTALL(MSIPACKAGE *package, LPCWSTR szPackagePath,
440 LPCWSTR szCommandLine, LPCWSTR msiFilePath)
446 static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0};
447 static const WCHAR szAction[] = {'A','C','T','I','O','N',0};
448 static const WCHAR szInstall[] = {'I','N','S','T','A','L','L',0};
450 MSI_SetPropertyW(package, szAction, szInstall);
452 package->script = msi_alloc(sizeof(MSISCRIPT));
453 memset(package->script,0,sizeof(MSISCRIPT));
455 package->script->InWhatSequence = SEQUENCE_INSTALL;
457 package->msiFilePath= strdupW(msiFilePath);
461 LPWSTR p, check, path;
463 package->PackagePath = strdupW(szPackagePath);
464 path = strdupW(szPackagePath);
465 p = strrchrW(path,'\\');
474 path = msi_alloc(MAX_PATH*sizeof(WCHAR));
475 GetCurrentDirectoryW(MAX_PATH,path);
479 check = msi_dup_property( package, cszSourceDir );
481 MSI_SetPropertyW(package, cszSourceDir, path);
489 ptr = (LPWSTR)szCommandLine;
496 TRACE("Looking at %s\n",debugstr_w(ptr));
498 ptr2 = strchrW(ptr,'=');
504 while (*ptr == ' ') ptr++;
506 prop = msi_alloc((len+1)*sizeof(WCHAR));
507 memcpy(prop,ptr,len*sizeof(WCHAR));
513 while (*ptr && (quote || (!quote && *ptr!=' ')))
526 val = msi_alloc((len+1)*sizeof(WCHAR));
527 memcpy(val,ptr2,len*sizeof(WCHAR));
530 if (strlenW(prop) > 0)
532 TRACE("Found commandline property (%s) = (%s)\n",
533 debugstr_w(prop), debugstr_w(val));
534 MSI_SetPropertyW(package,prop,val);
544 if (MSI_GetPropertyW(package,szUILevel,buffer,&sz) == ERROR_SUCCESS)
546 if (atoiW(buffer) >= INSTALLUILEVEL_REDUCED)
548 package->script->InWhatSequence |= SEQUENCE_UI;
549 rc = ACTION_ProcessUISequence(package);
551 if (rc == ERROR_SUCCESS)
553 package->script->InWhatSequence |= SEQUENCE_EXEC;
554 rc = ACTION_ProcessExecSequence(package,TRUE);
558 rc = ACTION_ProcessExecSequence(package,FALSE);
561 rc = ACTION_ProcessExecSequence(package,FALSE);
565 /* install was halted but should be considered a success */
569 package->script->CurrentlyScripting= FALSE;
571 /* process the ending type action */
572 if (rc == ERROR_SUCCESS)
573 ACTION_PerformActionSequence(package,-1,ui);
574 else if (rc == ERROR_INSTALL_USEREXIT)
575 ACTION_PerformActionSequence(package,-2,ui);
576 else if (rc == ERROR_INSTALL_SUSPEND)
577 ACTION_PerformActionSequence(package,-4,ui);
579 ACTION_PerformActionSequence(package,-3,ui);
581 /* finish up running custom actions */
582 ACTION_FinishCustomActions(package);
587 static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq, BOOL UI)
589 UINT rc = ERROR_SUCCESS;
591 static const WCHAR ExecSeqQuery[] =
592 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
593 '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
594 'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
595 '`','S','e','q','u','e','n','c','e','`',' ', '=',' ','%','i',0};
597 static const WCHAR UISeqQuery[] =
598 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
599 '`','I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e',
600 '`', ' ', 'W','H','E','R','E',' ','`','S','e','q','u','e','n','c','e','`',
601 ' ', '=',' ','%','i',0};
604 row = MSI_QueryGetRecord(package->db, UISeqQuery, seq);
606 row = MSI_QueryGetRecord(package->db, ExecSeqQuery, seq);
610 LPCWSTR action, cond;
612 TRACE("Running the actions\n");
614 /* check conditions */
615 cond = MSI_RecordGetString(row,2);
618 /* this is a hack to skip errors in the condition code */
619 if (MSI_EvaluateConditionW(package, cond) == MSICONDITION_FALSE)
623 action = MSI_RecordGetString(row,1);
626 ERR("failed to fetch action\n");
627 rc = ERROR_FUNCTION_FAILED;
632 rc = ACTION_PerformUIAction(package,action);
634 rc = ACTION_PerformAction(package,action,FALSE);
636 msiobj_release(&row->hdr);
647 } iterate_action_param;
649 static UINT ITERATE_Actions(MSIRECORD *row, LPVOID param)
651 iterate_action_param *iap= (iterate_action_param*)param;
653 LPCWSTR cond, action;
655 action = MSI_RecordGetString(row,1);
658 ERR("Error is retrieving action name\n");
659 return ERROR_FUNCTION_FAILED;
662 /* check conditions */
663 cond = MSI_RecordGetString(row,2);
666 /* this is a hack to skip errors in the condition code */
667 if (MSI_EvaluateConditionW(iap->package, cond) == MSICONDITION_FALSE)
669 TRACE("Skipping action: %s (condition is false)\n",
671 return ERROR_SUCCESS;
676 rc = ACTION_PerformUIAction(iap->package,action);
678 rc = ACTION_PerformAction(iap->package,action,FALSE);
680 msi_dialog_check_messages( NULL );
682 if (iap->package->CurrentInstallState != ERROR_SUCCESS )
683 rc = iap->package->CurrentInstallState;
685 if (rc == ERROR_FUNCTION_NOT_CALLED)
688 if (rc != ERROR_SUCCESS)
689 ERR("Execution halted due to error (%i)\n",rc);
694 UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode )
698 static const WCHAR query[] =
699 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
701 ' ','W','H','E','R','E',' ',
702 '`','S','e','q','u','e','n','c','e','`',' ',
703 '>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
704 '`','S','e','q','u','e','n','c','e','`',0};
705 iterate_action_param iap;
708 * FIXME: probably should be checking UILevel in the
709 * ACTION_PerformUIAction/ACTION_PerformAction
710 * rather than saving the UI level here. Those
711 * two functions can be merged too.
713 iap.package = package;
716 TRACE("%p %s %i\n", package, debugstr_w(szTable), iSequenceMode );
718 r = MSI_OpenQuery( package->db, &view, query, szTable );
719 if (r == ERROR_SUCCESS)
721 r = MSI_IterateRecords( view, NULL, ITERATE_Actions, &iap );
722 msiobj_release(&view->hdr);
728 static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran)
732 static const WCHAR ExecSeqQuery[] =
733 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
734 '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
735 'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
736 '`','S','e','q','u','e','n','c','e','`',' ', '>',' ','%','i',' ',
737 'O','R','D','E','R',' ', 'B','Y',' ',
738 '`','S','e','q','u','e','n','c','e','`',0 };
740 static const WCHAR IVQuery[] =
741 {'S','E','L','E','C','T',' ','`','S','e','q','u','e','n','c','e','`',
742 ' ', 'F','R','O','M',' ','`','I','n','s','t','a','l','l',
743 'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e','`',' ',
744 'W','H','E','R','E',' ','`','A','c','t','i','o','n','`',' ','=',
745 ' ','\'', 'I','n','s','t','a','l','l',
746 'V','a','l','i','d','a','t','e','\'', 0};
748 iterate_action_param iap;
750 iap.package = package;
753 if (package->script->ExecuteSequenceRun)
755 TRACE("Execute Sequence already Run\n");
756 return ERROR_SUCCESS;
759 package->script->ExecuteSequenceRun = TRUE;
761 /* get the sequence number */
764 row = MSI_QueryGetRecord(package->db, IVQuery);
766 return ERROR_FUNCTION_FAILED;
767 seq = MSI_RecordGetInteger(row,1);
768 msiobj_release(&row->hdr);
771 rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, seq);
772 if (rc == ERROR_SUCCESS)
774 TRACE("Running the actions\n");
776 rc = MSI_IterateRecords(view, NULL, ITERATE_Actions, &iap);
777 msiobj_release(&view->hdr);
783 static UINT ACTION_ProcessUISequence(MSIPACKAGE *package)
787 static const WCHAR ExecSeqQuery [] =
788 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
789 '`','I','n','s','t','a','l','l',
790 'U','I','S','e','q','u','e','n','c','e','`',
791 ' ','W','H','E','R','E',' ',
792 '`','S','e','q','u','e','n','c','e','`',' ',
793 '>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
794 '`','S','e','q','u','e','n','c','e','`',0};
795 iterate_action_param iap;
797 iap.package = package;
800 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
802 if (rc == ERROR_SUCCESS)
804 TRACE("Running the actions \n");
806 rc = MSI_IterateRecords(view, NULL, ITERATE_Actions, &iap);
807 msiobj_release(&view->hdr);
813 /********************************************************
814 * ACTION helper functions and functions that perform the actions
815 *******************************************************/
816 static BOOL ACTION_HandleStandardAction(MSIPACKAGE *package, LPCWSTR action,
817 UINT* rc, BOOL force )
823 if (!run && !package->script->CurrentlyScripting)
828 if (strcmpW(action,szInstallFinalize) == 0 ||
829 strcmpW(action,szInstallExecute) == 0 ||
830 strcmpW(action,szInstallExecuteAgain) == 0)
835 while (StandardActions[i].action != NULL)
837 if (strcmpW(StandardActions[i].action, action)==0)
841 ui_actioninfo(package, action, TRUE, 0);
842 *rc = schedule_action(package,INSTALL_SCRIPT,action);
843 ui_actioninfo(package, action, FALSE, *rc);
847 ui_actionstart(package, action);
848 if (StandardActions[i].handler)
850 *rc = StandardActions[i].handler(package);
854 FIXME("unhandled standard action %s\n",debugstr_w(action));
866 static BOOL ACTION_HandleCustomAction( MSIPACKAGE* package, LPCWSTR action,
867 UINT* rc, BOOL force )
872 arc = ACTION_CustomAction(package,action, force);
874 if (arc != ERROR_CALL_NOT_IMPLEMENTED)
883 * A lot of actions are really important even if they don't do anything
884 * explicit... Lots of properties are set at the beginning of the installation
885 * CostFinalize does a bunch of work to translate the directories and such
887 * But until I get write access to the database that is hard, so I am going to
888 * hack it to see if I can get something to run.
890 UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, BOOL force)
892 UINT rc = ERROR_SUCCESS;
895 TRACE("Performing action (%s)\n",debugstr_w(action));
897 handled = ACTION_HandleStandardAction(package, action, &rc, force);
900 handled = ACTION_HandleCustomAction(package, action, &rc, force);
904 FIXME("unhandled msi action %s\n",debugstr_w(action));
905 rc = ERROR_FUNCTION_NOT_CALLED;
911 UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action)
913 UINT rc = ERROR_SUCCESS;
914 BOOL handled = FALSE;
916 TRACE("Performing action (%s)\n",debugstr_w(action));
918 handled = ACTION_HandleStandardAction(package, action, &rc,TRUE);
921 handled = ACTION_HandleCustomAction(package, action, &rc, FALSE);
923 if( !handled && ACTION_DialogBox(package,action) == ERROR_SUCCESS )
928 FIXME("unhandled msi action %s\n",debugstr_w(action));
929 rc = ERROR_FUNCTION_NOT_CALLED;
937 * Actual Action Handlers
940 static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param)
942 MSIPACKAGE *package = (MSIPACKAGE*)param;
948 dir = MSI_RecordGetString(row,1);
951 ERR("Unable to get folder id \n");
952 return ERROR_SUCCESS;
955 full_path = resolve_folder(package,dir,FALSE,FALSE,&folder);
958 ERR("Unable to resolve folder id %s\n",debugstr_w(dir));
959 return ERROR_SUCCESS;
962 TRACE("Folder is %s\n",debugstr_w(full_path));
965 uirow = MSI_CreateRecord(1);
966 MSI_RecordSetStringW(uirow,1,full_path);
967 ui_actiondata(package,szCreateFolders,uirow);
968 msiobj_release( &uirow->hdr );
970 if (folder->State == 0)
971 create_full_pathW(full_path);
976 return ERROR_SUCCESS;
981 * Also we cannot enable/disable components either, so for now I am just going
982 * to do all the directories for all the components.
984 static UINT ACTION_CreateFolders(MSIPACKAGE *package)
986 static const WCHAR ExecSeqQuery[] =
987 {'S','E','L','E','C','T',' ',
988 '`','D','i','r','e','c','t','o','r','y','_','`',
989 ' ','F','R','O','M',' ',
990 '`','C','r','e','a','t','e','F','o','l','d','e','r','`',0 };
994 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view );
995 if (rc != ERROR_SUCCESS)
996 return ERROR_SUCCESS;
998 rc = MSI_IterateRecords(view, NULL, ITERATE_CreateFolders, package);
999 msiobj_release(&view->hdr);
1004 static MSICOMPONENT* load_component( MSIRECORD * row )
1008 comp = msi_alloc_zero( sizeof(MSICOMPONENT) );
1012 /* fill in the data */
1013 comp->Component = load_dynamic_stringW( row, 1 );
1015 TRACE("Loading Component %s\n", debugstr_w(comp->Component));
1017 comp->ComponentId = load_dynamic_stringW( row, 2 );
1018 comp->Directory = load_dynamic_stringW( row, 3 );
1019 comp->Attributes = MSI_RecordGetInteger(row,4);
1020 comp->Condition = load_dynamic_stringW( row, 5 );
1021 comp->KeyPath = load_dynamic_stringW( row, 6 );
1023 comp->Installed = INSTALLSTATE_ABSENT;
1024 comp->Action = INSTALLSTATE_UNKNOWN;
1025 comp->ActionRequest = INSTALLSTATE_UNKNOWN;
1027 comp->Enabled = TRUE;
1033 MSIPACKAGE *package;
1034 MSIFEATURE *feature;
1037 static UINT add_feature_component( MSIFEATURE *feature, MSICOMPONENT *comp )
1041 cl = msi_alloc( sizeof (*cl) );
1043 return ERROR_NOT_ENOUGH_MEMORY;
1044 cl->component = comp;
1045 list_add_tail( &feature->Components, &cl->entry );
1047 return ERROR_SUCCESS;
1050 static UINT iterate_component_check( MSIRECORD *row, LPVOID param )
1052 _ilfs* ilfs= (_ilfs*)param;
1053 MSIPACKAGE *package = ilfs->package;
1054 MSIFEATURE *feature = ilfs->feature;
1057 comp = load_component( row );
1059 return ERROR_FUNCTION_FAILED;
1061 list_add_tail( &package->components, &comp->entry );
1062 add_feature_component( feature, comp );
1064 TRACE("Loaded new component %p\n", comp);
1066 return ERROR_SUCCESS;
1069 static UINT iterate_load_featurecomponents(MSIRECORD *row, LPVOID param)
1071 _ilfs* ilfs= (_ilfs*)param;
1076 static const WCHAR Query[] =
1077 {'S','E','L','E','C','T',' ','*',' ','F','R', 'O','M',' ',
1078 '`','C','o','m','p','o','n','e','n','t','`',' ',
1079 'W','H','E','R','E',' ',
1080 '`','C','o','m','p','o','n','e','n','t','`',' ',
1081 '=','\'','%','s','\'',0};
1083 component = MSI_RecordGetString(row,1);
1085 /* check to see if the component is already loaded */
1086 comp = get_loaded_component( ilfs->package, component );
1089 TRACE("Component %s already loaded\n", debugstr_w(component) );
1090 add_feature_component( ilfs->feature, comp );
1091 return ERROR_SUCCESS;
1094 rc = MSI_OpenQuery(ilfs->package->db, &view, Query, component);
1095 if (rc != ERROR_SUCCESS)
1096 return ERROR_SUCCESS;
1098 rc = MSI_IterateRecords(view, NULL, iterate_component_check, ilfs);
1099 msiobj_release( &view->hdr );
1101 return ERROR_SUCCESS;
1104 static UINT load_feature(MSIRECORD * row, LPVOID param)
1106 MSIPACKAGE* package = (MSIPACKAGE*)param;
1107 MSIFEATURE* feature;
1108 static const WCHAR Query1[] =
1109 {'S','E','L','E','C','T',' ',
1110 '`','C','o','m','p','o','n','e','n','t','_','`',
1111 ' ','F','R','O','M',' ','`','F','e','a','t','u','r','e',
1112 'C','o','m','p','o','n','e','n','t','s','`',' ',
1113 'W','H','E','R','E',' ',
1114 '`','F','e', 'a','t','u','r','e','_','`',' ','=','\'','%','s','\'',0};
1119 /* fill in the data */
1121 feature = msi_alloc_zero( sizeof (MSIFEATURE) );
1123 return ERROR_NOT_ENOUGH_MEMORY;
1125 list_init( &feature->Components );
1127 feature->Feature = load_dynamic_stringW( row, 1 );
1129 TRACE("Loading feature %s\n",debugstr_w(feature->Feature));
1131 feature->Feature_Parent = load_dynamic_stringW( row, 2 );
1132 feature->Title = load_dynamic_stringW( row, 3 );
1133 feature->Description = load_dynamic_stringW( row, 4 );
1135 if (!MSI_RecordIsNull(row,5))
1136 feature->Display = MSI_RecordGetInteger(row,5);
1138 feature->Level= MSI_RecordGetInteger(row,6);
1139 feature->Directory = load_dynamic_stringW( row, 7 );
1140 feature->Attributes = MSI_RecordGetInteger(row,8);
1142 feature->Installed = INSTALLSTATE_ABSENT;
1143 feature->Action = INSTALLSTATE_UNKNOWN;
1144 feature->ActionRequest = INSTALLSTATE_UNKNOWN;
1146 list_add_tail( &package->features, &feature->entry );
1148 /* load feature components */
1150 rc = MSI_OpenQuery( package->db, &view, Query1, feature->Feature );
1151 if (rc != ERROR_SUCCESS)
1152 return ERROR_SUCCESS;
1154 ilfs.package = package;
1155 ilfs.feature = feature;
1157 MSI_IterateRecords(view, NULL, iterate_load_featurecomponents , &ilfs);
1158 msiobj_release(&view->hdr);
1160 return ERROR_SUCCESS;
1163 static UINT load_file(MSIRECORD *row, LPVOID param)
1165 MSIPACKAGE* package = (MSIPACKAGE*)param;
1169 /* fill in the data */
1171 file = msi_alloc_zero( sizeof (MSIFILE) );
1173 return ERROR_NOT_ENOUGH_MEMORY;
1175 file->File = load_dynamic_stringW( row, 1 );
1177 component = MSI_RecordGetString( row, 2 );
1178 file->Component = get_loaded_component( package, component );
1180 if (!file->Component)
1181 ERR("Unfound Component %s\n",debugstr_w(component));
1183 file->FileName = load_dynamic_stringW( row, 3 );
1184 reduce_to_longfilename( file->FileName );
1186 file->ShortName = load_dynamic_stringW( row, 3 );
1187 reduce_to_shortfilename( file->ShortName );
1189 file->FileSize = MSI_RecordGetInteger( row, 4 );
1190 file->Version = load_dynamic_stringW( row, 5 );
1191 file->Language = load_dynamic_stringW( row, 6 );
1192 file->Attributes = MSI_RecordGetInteger( row, 7 );
1193 file->Sequence = MSI_RecordGetInteger( row, 8 );
1197 TRACE("File Loaded (%s)\n",debugstr_w(file->File));
1199 list_add_tail( &package->files, &file->entry );
1201 return ERROR_SUCCESS;
1204 static UINT load_all_files(MSIPACKAGE *package)
1208 static const WCHAR Query[] =
1209 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
1210 '`','F','i','l','e','`',' ', 'O','R','D','E','R',' ','B','Y',' ',
1211 '`','S','e','q','u','e','n','c','e','`', 0};
1214 return ERROR_INVALID_HANDLE;
1216 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
1217 if (rc != ERROR_SUCCESS)
1218 return ERROR_SUCCESS;
1220 rc = MSI_IterateRecords(view, NULL, load_file, package);
1221 msiobj_release(&view->hdr);
1223 return ERROR_SUCCESS;
1228 * I am not doing any of the costing functionality yet.
1229 * Mostly looking at doing the Component and Feature loading
1231 * The native MSI does A LOT of modification to tables here. Mostly adding
1232 * a lot of temporary columns to the Feature and Component tables.
1234 * note: Native msi also tracks the short filename. But I am only going to
1235 * track the long ones. Also looking at this directory table
1236 * it appears that the directory table does not get the parents
1237 * resolved base on property only based on their entries in the
1240 static UINT ACTION_CostInitialize(MSIPACKAGE *package)
1244 static const WCHAR Query_all[] =
1245 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
1246 '`','F','e','a','t','u','r','e','`',0};
1247 static const WCHAR szCosting[] =
1248 {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
1249 static const WCHAR szZero[] = { '0', 0 };
1253 MSI_GetPropertyW(package, szCosting, buffer, &sz);
1255 return ERROR_SUCCESS;
1257 MSI_SetPropertyW(package, szCosting, szZero);
1258 MSI_SetPropertyW(package, cszRootDrive , c_colon);
1260 rc = MSI_DatabaseOpenViewW(package->db,Query_all,&view);
1261 if (rc != ERROR_SUCCESS)
1264 rc = MSI_IterateRecords(view, NULL, load_feature, package);
1265 msiobj_release(&view->hdr);
1267 load_all_files(package);
1269 return ERROR_SUCCESS;
1272 static UINT execute_script(MSIPACKAGE *package, UINT script )
1275 UINT rc = ERROR_SUCCESS;
1277 TRACE("Executing Script %i\n",script);
1279 for (i = 0; i < package->script->ActionCount[script]; i++)
1282 action = package->script->Actions[script][i];
1283 ui_actionstart(package, action);
1284 TRACE("Executing Action (%s)\n",debugstr_w(action));
1285 rc = ACTION_PerformAction(package, action, TRUE);
1286 msi_free(package->script->Actions[script][i]);
1287 if (rc != ERROR_SUCCESS)
1290 msi_free(package->script->Actions[script]);
1292 package->script->ActionCount[script] = 0;
1293 package->script->Actions[script] = NULL;
1297 static UINT ACTION_FileCost(MSIPACKAGE *package)
1299 return ERROR_SUCCESS;
1303 static MSIFOLDER *load_folder( MSIPACKAGE *package, LPCWSTR dir )
1305 static const WCHAR Query[] =
1306 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1307 '`','D','i','r','e','c', 't','o','r','y','`',' ',
1308 'W','H','E','R','E',' ', '`', 'D','i','r','e','c','t', 'o','r','y','`',
1309 ' ','=',' ','\'','%','s','\'',
1311 LPWSTR ptargetdir, targetdir, srcdir;
1313 LPWSTR shortname = NULL;
1314 MSIRECORD * row = 0;
1317 TRACE("Looking for dir %s\n",debugstr_w(dir));
1319 folder = get_loaded_folder( package, dir );
1323 TRACE("Working to load %s\n",debugstr_w(dir));
1325 folder = msi_alloc_zero( sizeof (MSIFOLDER) );
1329 folder->Directory = strdupW(dir);
1331 row = MSI_QueryGetRecord(package->db, Query, dir);
1335 ptargetdir = targetdir = load_dynamic_stringW(row,3);
1337 /* split src and target dir */
1338 if (strchrW(targetdir,':'))
1340 srcdir=strchrW(targetdir,':');
1347 /* for now only pick long filename versions */
1348 if (strchrW(targetdir,'|'))
1350 shortname = targetdir;
1351 targetdir = strchrW(targetdir,'|');
1355 /* for the sourcedir pick the short filename */
1356 if (srcdir && strchrW(srcdir,'|'))
1358 LPWSTR p = strchrW(srcdir,'|');
1362 /* now check for root dirs */
1363 if (targetdir[0] == '.' && targetdir[1] == 0)
1368 TRACE(" TargetDefault = %s\n",debugstr_w(targetdir));
1369 msi_free( folder->TargetDefault);
1370 folder->TargetDefault = strdupW(targetdir);
1374 folder->SourceDefault = strdupW(srcdir);
1376 folder->SourceDefault = strdupW(shortname);
1378 folder->SourceDefault = strdupW(targetdir);
1379 msi_free(ptargetdir);
1380 TRACE(" SourceDefault = %s\n", debugstr_w( folder->SourceDefault ));
1382 parent = MSI_RecordGetString(row,2);
1385 folder->Parent = load_folder( package, parent );
1386 if ( folder->Parent )
1387 TRACE("loaded parent %p %s\n", folder->Parent,
1388 debugstr_w(folder->Parent->Directory));
1390 ERR("failed to load parent folder %s\n", debugstr_w(parent));
1393 folder->Property = msi_dup_property( package, dir );
1395 msiobj_release(&row->hdr);
1397 list_add_tail( &package->folders, &folder->entry );
1399 TRACE("%s returning %p\n",debugstr_w(dir),folder);
1404 /* scan for and update current install states */
1405 static void ACTION_UpdateInstallStates(MSIPACKAGE *package)
1408 MSIFEATURE *feature;
1410 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
1413 res = MsiGetComponentPathW( package->ProductCode,
1414 comp->ComponentId, NULL, NULL);
1416 res = INSTALLSTATE_ABSENT;
1417 comp->Installed = res;
1420 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1423 INSTALLSTATE res = -10;
1425 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
1427 comp= cl->component;
1430 res = comp->Installed;
1433 if (res == comp->Installed)
1436 if (res != comp->Installed)
1437 res = INSTALLSTATE_INCOMPLETE;
1440 feature->Installed = res;
1444 static BOOL process_state_property (MSIPACKAGE* package, LPCWSTR property,
1447 static const WCHAR all[]={'A','L','L',0};
1449 MSIFEATURE *feature;
1451 override = msi_dup_property( package, property );
1455 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1457 if (strcmpiW(override,all)==0)
1459 feature->ActionRequest= state;
1460 feature->Action = state;
1464 LPWSTR ptr = override;
1465 LPWSTR ptr2 = strchrW(override,',');
1469 if ((ptr2 && strncmpW(ptr,feature->Feature, ptr2-ptr)==0)
1470 || (!ptr2 && strcmpW(ptr,feature->Feature)==0))
1472 feature->ActionRequest= state;
1473 feature->Action = state;
1479 ptr2 = strchrW(ptr,',');
1491 static UINT SetFeatureStates(MSIPACKAGE *package)
1495 static const WCHAR szlevel[] =
1496 {'I','N','S','T','A','L','L','L','E','V','E','L',0};
1497 static const WCHAR szAddLocal[] =
1498 {'A','D','D','L','O','C','A','L',0};
1499 static const WCHAR szRemove[] =
1500 {'R','E','M','O','V','E',0};
1501 BOOL override = FALSE;
1502 MSICOMPONENT* component;
1503 MSIFEATURE *feature;
1506 /* I do not know if this is where it should happen.. but */
1508 TRACE("Checking Install Level\n");
1510 level = msi_dup_property( package, szlevel );
1513 install_level = atoiW(level);
1519 /* ok hereis the _real_ rub
1520 * all these activation/deactivation things happen in order and things
1521 * later on the list override things earlier on the list.
1522 * 1) INSTALLLEVEL processing
1532 * 11) FILEADDDEFAULT
1533 * I have confirmed that if ADDLOCAL is stated then the INSTALLLEVEL is
1534 * ignored for all the features. seems strange, especially since it is not
1535 * documented anywhere, but it is how it works.
1537 * I am still ignoring a lot of these. But that is ok for now, ADDLOCAL and
1538 * REMOVE are the big ones, since we don't handle administrative installs
1541 override |= process_state_property(package,szAddLocal,INSTALLSTATE_LOCAL);
1542 override |= process_state_property(package,szRemove,INSTALLSTATE_ABSENT);
1546 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1548 BOOL feature_state = ((feature->Level > 0) &&
1549 (feature->Level <= install_level));
1551 if ((feature_state) && (feature->Action == INSTALLSTATE_UNKNOWN))
1553 if (feature->Attributes & msidbFeatureAttributesFavorSource)
1555 feature->ActionRequest = INSTALLSTATE_SOURCE;
1556 feature->Action = INSTALLSTATE_SOURCE;
1558 else if (feature->Attributes & msidbFeatureAttributesFavorAdvertise)
1560 feature->ActionRequest = INSTALLSTATE_ADVERTISED;
1561 feature->Action = INSTALLSTATE_ADVERTISED;
1565 feature->ActionRequest = INSTALLSTATE_LOCAL;
1566 feature->Action = INSTALLSTATE_LOCAL;
1573 /* set the Preselected Property */
1574 static const WCHAR szPreselected[] = {'P','r','e','s','e','l','e','c','t','e','d',0};
1575 static const WCHAR szOne[] = { '1', 0 };
1577 MSI_SetPropertyW(package,szPreselected,szOne);
1581 * now we want to enable or disable components base on feature
1584 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1588 TRACE("Examining Feature %s (Installed %i, Action %i, Request %i)\n",
1589 debugstr_w(feature->Feature), feature->Installed, feature->Action,
1590 feature->ActionRequest);
1592 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
1594 component = cl->component;
1596 if (!component->Enabled)
1598 component->Action = INSTALLSTATE_UNKNOWN;
1599 component->ActionRequest = INSTALLSTATE_UNKNOWN;
1603 if (feature->Action == INSTALLSTATE_LOCAL)
1605 component->Action = INSTALLSTATE_LOCAL;
1606 component->ActionRequest = INSTALLSTATE_LOCAL;
1608 else if (feature->ActionRequest == INSTALLSTATE_SOURCE)
1610 if ((component->Action == INSTALLSTATE_UNKNOWN) ||
1611 (component->Action == INSTALLSTATE_ABSENT) ||
1612 (component->Action == INSTALLSTATE_ADVERTISED))
1615 component->Action = INSTALLSTATE_SOURCE;
1616 component->ActionRequest = INSTALLSTATE_SOURCE;
1619 else if (feature->ActionRequest == INSTALLSTATE_ADVERTISED)
1621 if ((component->Action == INSTALLSTATE_UNKNOWN) ||
1622 (component->Action == INSTALLSTATE_ABSENT))
1625 component->Action = INSTALLSTATE_ADVERTISED;
1626 component->ActionRequest = INSTALLSTATE_ADVERTISED;
1629 else if (feature->ActionRequest == INSTALLSTATE_ABSENT)
1631 if (component->Action == INSTALLSTATE_UNKNOWN)
1633 component->Action = INSTALLSTATE_ABSENT;
1634 component->ActionRequest = INSTALLSTATE_ABSENT;
1641 LIST_FOR_EACH_ENTRY( component, &package->components, MSICOMPONENT, entry )
1643 TRACE("Result: Component %s (Installed %i, Action %i, Request %i)\n",
1644 debugstr_w(component->Component), component->Installed,
1645 component->Action, component->ActionRequest);
1649 return ERROR_SUCCESS;
1652 static UINT ITERATE_CostFinalizeDirectories(MSIRECORD *row, LPVOID param)
1654 MSIPACKAGE *package = (MSIPACKAGE*)param;
1658 name = MSI_RecordGetString(row,1);
1660 /* This helper function now does ALL the work */
1661 TRACE("Dir %s ...\n",debugstr_w(name));
1662 load_folder(package,name);
1663 path = resolve_folder(package,name,FALSE,TRUE,NULL);
1664 TRACE("resolves to %s\n",debugstr_w(path));
1667 return ERROR_SUCCESS;
1670 static UINT ITERATE_CostFinalizeConditions(MSIRECORD *row, LPVOID param)
1672 MSIPACKAGE *package = (MSIPACKAGE*)param;
1674 MSIFEATURE *feature;
1676 name = MSI_RecordGetString( row, 1 );
1678 feature = get_loaded_feature( package, name );
1680 ERR("FAILED to find loaded feature %s\n",debugstr_w(name));
1684 Condition = MSI_RecordGetString(row,3);
1686 if (MSI_EvaluateConditionW(package,Condition) == MSICONDITION_TRUE)
1688 int level = MSI_RecordGetInteger(row,2);
1689 TRACE("Reseting feature %s to level %i\n", debugstr_w(name), level);
1690 feature->Level = level;
1693 return ERROR_SUCCESS;
1698 * A lot is done in this function aside from just the costing.
1699 * The costing needs to be implemented at some point but for now I am going
1700 * to focus on the directory building
1703 static UINT ACTION_CostFinalize(MSIPACKAGE *package)
1705 static const WCHAR ExecSeqQuery[] =
1706 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1707 '`','D','i','r','e','c','t','o','r','y','`',0};
1708 static const WCHAR ConditionQuery[] =
1709 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1710 '`','C','o','n','d','i','t','i','o','n','`',0};
1711 static const WCHAR szCosting[] =
1712 {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
1713 static const WCHAR szlevel[] =
1714 {'I','N','S','T','A','L','L','L','E','V','E','L',0};
1715 static const WCHAR szOne[] = { '1', 0 };
1724 MSI_GetPropertyW(package, szCosting, buffer, &sz);
1726 return ERROR_SUCCESS;
1728 TRACE("Building Directory properties\n");
1730 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
1731 if (rc == ERROR_SUCCESS)
1733 rc = MSI_IterateRecords(view, NULL, ITERATE_CostFinalizeDirectories,
1735 msiobj_release(&view->hdr);
1738 TRACE("File calculations\n");
1740 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
1742 MSICOMPONENT* comp = file->Component;
1748 /* calculate target */
1749 p = resolve_folder(package, comp->Directory, FALSE, FALSE, NULL);
1751 msi_free(file->TargetPath);
1753 TRACE("file %s is named %s\n",
1754 debugstr_w(file->File),debugstr_w(file->FileName));
1756 file->TargetPath = build_directory_name(2, p, file->FileName);
1760 TRACE("file %s resolves to %s\n",
1761 debugstr_w(file->File),debugstr_w(file->TargetPath));
1763 if (GetFileAttributesW(file->TargetPath) == INVALID_FILE_ATTRIBUTES)
1766 comp->Cost += file->FileSize;
1776 static const WCHAR name[] =
1778 static const WCHAR name_fmt[] =
1779 {'%','u','.','%','u','.','%','u','.','%','u',0};
1780 WCHAR filever[0x100];
1781 VS_FIXEDFILEINFO *lpVer;
1783 TRACE("Version comparison.. \n");
1784 versize = GetFileVersionInfoSizeW(file->TargetPath,&handle);
1785 version = msi_alloc(versize);
1786 GetFileVersionInfoW(file->TargetPath, 0, versize, version);
1788 VerQueryValueW(version, name, (LPVOID*)&lpVer, &sz);
1790 sprintfW(filever,name_fmt,
1791 HIWORD(lpVer->dwFileVersionMS),
1792 LOWORD(lpVer->dwFileVersionMS),
1793 HIWORD(lpVer->dwFileVersionLS),
1794 LOWORD(lpVer->dwFileVersionLS));
1796 TRACE("new %s old %s\n", debugstr_w(file->Version),
1797 debugstr_w(filever));
1798 if (strcmpiW(filever,file->Version)<0)
1801 FIXME("cost should be diff in size\n");
1802 comp->Cost += file->FileSize;
1812 TRACE("Evaluating Condition Table\n");
1814 rc = MSI_DatabaseOpenViewW(package->db, ConditionQuery, &view);
1815 if (rc == ERROR_SUCCESS)
1817 rc = MSI_IterateRecords(view, NULL, ITERATE_CostFinalizeConditions,
1819 msiobj_release(&view->hdr);
1822 TRACE("Enabling or Disabling Components\n");
1823 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
1825 if (comp->Condition)
1827 if (MSI_EvaluateConditionW(package,
1828 comp->Condition) == MSICONDITION_FALSE)
1830 TRACE("Disabling component %s\n", debugstr_w(comp->Component));
1831 comp->Enabled = FALSE;
1836 MSI_SetPropertyW(package,szCosting,szOne);
1837 /* set default run level if not set */
1838 level = msi_dup_property( package, szlevel );
1840 MSI_SetPropertyW(package,szlevel, szOne);
1843 ACTION_UpdateInstallStates(package);
1845 return SetFeatureStates(package);
1848 /* OK this value is "interpreted" and then formatted based on the
1849 first few characters */
1850 static LPSTR parse_value(MSIPACKAGE *package, LPCWSTR value, DWORD *type,
1854 if (value[0]=='#' && value[1]!='#' && value[1]!='%')
1860 LPWSTR deformated = NULL;
1863 deformat_string(package, &value[2], &deformated);
1865 /* binary value type */
1869 *size = (strlenW(ptr)/2)+1;
1871 *size = strlenW(ptr)/2;
1873 data = msi_alloc(*size);
1879 /* if uneven pad with a zero in front */
1885 data[count] = (BYTE)strtol(byte,NULL,0);
1887 TRACE("Uneven byte count\n");
1895 data[count] = (BYTE)strtol(byte,NULL,0);
1898 msi_free(deformated);
1900 TRACE("Data %li bytes(%i)\n",*size,count);
1907 deformat_string(package, &value[1], &deformated);
1910 *size = sizeof(DWORD);
1911 data = msi_alloc(*size);
1917 if ( (*p < '0') || (*p > '9') )
1923 if (deformated[0] == '-')
1926 TRACE("DWORD %li\n",*(LPDWORD)data);
1928 msi_free(deformated);
1933 static const WCHAR szMulti[] = {'[','~',']',0};
1942 *type=REG_EXPAND_SZ;
1950 if (strstrW(value,szMulti))
1951 *type = REG_MULTI_SZ;
1953 *size = deformat_string(package, ptr,(LPWSTR*)&data);
1958 static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
1960 MSIPACKAGE *package = (MSIPACKAGE*)param;
1961 static const WCHAR szHCR[] =
1962 {'H','K','E','Y','_','C','L','A','S','S','E','S','_',
1963 'R','O','O','T','\\',0};
1964 static const WCHAR szHCU[] =
1965 {'H','K','E','Y','_','C','U','R','R','E','N','T','_',
1966 'U','S','E','R','\\',0};
1967 static const WCHAR szHLM[] =
1968 {'H','K','E','Y','_','L','O','C','A','L','_',
1969 'M','A','C','H','I','N','E','\\',0};
1970 static const WCHAR szHU[] =
1971 {'H','K','E','Y','_','U','S','E','R','S','\\',0};
1973 LPSTR value_data = NULL;
1974 HKEY root_key, hkey;
1977 LPCWSTR szRoot, component, name, key, value;
1982 BOOL check_first = FALSE;
1985 ui_progress(package,2,0,0,0);
1992 component = MSI_RecordGetString(row, 6);
1993 comp = get_loaded_component(package,component);
1995 return ERROR_SUCCESS;
1997 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL))
1999 TRACE("Skipping write due to disabled component %s\n",
2000 debugstr_w(component));
2002 comp->Action = comp->Installed;
2004 return ERROR_SUCCESS;
2007 comp->Action = INSTALLSTATE_LOCAL;
2009 name = MSI_RecordGetString(row, 4);
2010 if( MSI_RecordIsNull(row,5) && name )
2012 /* null values can have special meanings */
2013 if (name[0]=='-' && name[1] == 0)
2014 return ERROR_SUCCESS;
2015 else if ((name[0]=='+' && name[1] == 0) ||
2016 (name[0] == '*' && name[1] == 0))
2021 root = MSI_RecordGetInteger(row,2);
2022 key = MSI_RecordGetString(row, 3);
2024 /* get the root key */
2029 static const WCHAR szALLUSER[] = {'A','L','L','U','S','E','R','S',0};
2030 LPWSTR all_users = msi_dup_property( package, szALLUSER );
2031 if (all_users && all_users[0] == '1')
2033 root_key = HKEY_LOCAL_MACHINE;
2038 root_key = HKEY_CURRENT_USER;
2041 msi_free(all_users);
2044 case 0: root_key = HKEY_CLASSES_ROOT;
2047 case 1: root_key = HKEY_CURRENT_USER;
2050 case 2: root_key = HKEY_LOCAL_MACHINE;
2053 case 3: root_key = HKEY_USERS;
2057 ERR("Unknown root %i\n",root);
2063 return ERROR_SUCCESS;
2065 deformat_string(package, key , &deformated);
2066 size = strlenW(deformated) + strlenW(szRoot) + 1;
2067 uikey = msi_alloc(size*sizeof(WCHAR));
2068 strcpyW(uikey,szRoot);
2069 strcatW(uikey,deformated);
2071 if (RegCreateKeyW( root_key, deformated, &hkey))
2073 ERR("Could not create key %s\n",debugstr_w(deformated));
2074 msi_free(deformated);
2076 return ERROR_SUCCESS;
2078 msi_free(deformated);
2080 value = MSI_RecordGetString(row,5);
2082 value_data = parse_value(package, value, &type, &size);
2085 static const WCHAR szEmpty[] = {0};
2086 value_data = (LPSTR)strdupW(szEmpty);
2091 deformat_string(package, name, &deformated);
2093 /* get the double nulls to terminate SZ_MULTI */
2094 if (type == REG_MULTI_SZ)
2095 size +=sizeof(WCHAR);
2099 TRACE("Setting value %s of %s\n",debugstr_w(deformated),
2101 RegSetValueExW(hkey, deformated, 0, type, (LPBYTE)value_data, size);
2106 rc = RegQueryValueExW(hkey, deformated, NULL, NULL, NULL, &sz);
2107 if (rc == ERROR_SUCCESS || rc == ERROR_MORE_DATA)
2109 TRACE("value %s of %s checked already exists\n",
2110 debugstr_w(deformated), debugstr_w(uikey));
2114 TRACE("Checked and setting value %s of %s\n",
2115 debugstr_w(deformated), debugstr_w(uikey));
2116 if (deformated || size)
2117 RegSetValueExW(hkey, deformated, 0, type, (LPBYTE) value_data, size);
2122 uirow = MSI_CreateRecord(3);
2123 MSI_RecordSetStringW(uirow,2,deformated);
2124 MSI_RecordSetStringW(uirow,1,uikey);
2127 MSI_RecordSetStringW(uirow,3,(LPWSTR)value_data);
2129 MSI_RecordSetStringW(uirow,3,value);
2131 ui_actiondata(package,szWriteRegistryValues,uirow);
2132 msiobj_release( &uirow->hdr );
2134 msi_free(value_data);
2135 msi_free(deformated);
2138 return ERROR_SUCCESS;
2141 static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package)
2145 static const WCHAR ExecSeqQuery[] =
2146 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2147 '`','R','e','g','i','s','t','r','y','`',0 };
2150 return ERROR_INVALID_HANDLE;
2152 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
2153 if (rc != ERROR_SUCCESS)
2154 return ERROR_SUCCESS;
2156 /* increment progress bar each time action data is sent */
2157 ui_progress(package,1,REG_PROGRESS_VALUE,1,0);
2159 rc = MSI_IterateRecords(view, NULL, ITERATE_WriteRegistryValues, package);
2161 msiobj_release(&view->hdr);
2165 static UINT ACTION_InstallInitialize(MSIPACKAGE *package)
2167 package->script->CurrentlyScripting = TRUE;
2169 return ERROR_SUCCESS;
2173 static UINT ACTION_InstallValidate(MSIPACKAGE *package)
2178 static const WCHAR q1[]=
2179 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
2180 '`','R','e','g','i','s','t','r','y','`',0};
2183 MSIFEATURE *feature;
2186 TRACE("InstallValidate\n");
2188 rc = MSI_DatabaseOpenViewW(package->db, q1, &view);
2189 if (rc == ERROR_SUCCESS)
2191 MSI_IterateRecords( view, &progress, NULL, package );
2192 msiobj_release( &view->hdr );
2193 total += progress * REG_PROGRESS_VALUE;
2196 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
2197 total += COMPONENT_PROGRESS_VALUE;
2199 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
2200 total += file->FileSize;
2202 ui_progress(package,0,total,0,0);
2204 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
2206 TRACE("Feature: %s; Installed: %i; Action %i; Request %i\n",
2207 debugstr_w(feature->Feature), feature->Installed, feature->Action,
2208 feature->ActionRequest);
2211 return ERROR_SUCCESS;
2214 static UINT ITERATE_LaunchConditions(MSIRECORD *row, LPVOID param)
2216 MSIPACKAGE* package = (MSIPACKAGE*)param;
2217 LPCWSTR cond = NULL;
2218 LPCWSTR message = NULL;
2219 static const WCHAR title[]=
2220 {'I','n','s','t','a','l','l',' ','F','a', 'i','l','e','d',0};
2222 cond = MSI_RecordGetString(row,1);
2224 if (MSI_EvaluateConditionW(package,cond) != MSICONDITION_TRUE)
2227 message = MSI_RecordGetString(row,2);
2228 deformat_string(package,message,&deformated);
2229 MessageBoxW(NULL,deformated,title,MB_OK);
2230 msi_free(deformated);
2231 return ERROR_FUNCTION_FAILED;
2234 return ERROR_SUCCESS;
2237 static UINT ACTION_LaunchConditions(MSIPACKAGE *package)
2240 MSIQUERY * view = NULL;
2241 static const WCHAR ExecSeqQuery[] =
2242 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2243 '`','L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','`',0};
2245 TRACE("Checking launch conditions\n");
2247 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
2248 if (rc != ERROR_SUCCESS)
2249 return ERROR_SUCCESS;
2251 rc = MSI_IterateRecords(view, NULL, ITERATE_LaunchConditions, package);
2252 msiobj_release(&view->hdr);
2257 static LPWSTR resolve_keypath( MSIPACKAGE* package, MSICOMPONENT *cmp )
2261 return resolve_folder(package,cmp->Directory,FALSE,FALSE,NULL);
2263 if (cmp->Attributes & msidbComponentAttributesRegistryKeyPath)
2265 MSIRECORD * row = 0;
2267 LPWSTR deformated,buffer,deformated_name;
2269 static const WCHAR ExecSeqQuery[] =
2270 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2271 '`','R','e','g','i','s','t','r','y','`',' ',
2272 'W','H','E','R','E',' ', '`','R','e','g','i','s','t','r','y','`',
2273 ' ','=',' ' ,'\'','%','s','\'',0 };
2274 static const WCHAR fmt[]={'%','0','2','i',':','\\','%','s','\\',0};
2275 static const WCHAR fmt2[]=
2276 {'%','0','2','i',':','\\','%','s','\\','%','s',0};
2278 row = MSI_QueryGetRecord(package->db, ExecSeqQuery,cmp->KeyPath);
2282 root = MSI_RecordGetInteger(row,2);
2283 key = MSI_RecordGetString(row, 3);
2284 name = MSI_RecordGetString(row, 4);
2285 deformat_string(package, key , &deformated);
2286 deformat_string(package, name, &deformated_name);
2288 len = strlenW(deformated) + 6;
2289 if (deformated_name)
2290 len+=strlenW(deformated_name);
2292 buffer = msi_alloc( len *sizeof(WCHAR));
2294 if (deformated_name)
2295 sprintfW(buffer,fmt2,root,deformated,deformated_name);
2297 sprintfW(buffer,fmt,root,deformated);
2299 msi_free(deformated);
2300 msi_free(deformated_name);
2301 msiobj_release(&row->hdr);
2305 else if (cmp->Attributes & msidbComponentAttributesODBCDataSource)
2307 FIXME("UNIMPLEMENTED keypath as ODBC Source\n");
2312 MSIFILE *file = get_loaded_file( package, cmp->KeyPath );
2315 return strdupW( file->TargetPath );
2320 static HKEY openSharedDLLsKey(void)
2323 static const WCHAR path[] =
2324 {'S','o','f','t','w','a','r','e','\\',
2325 'M','i','c','r','o','s','o','f','t','\\',
2326 'W','i','n','d','o','w','s','\\',
2327 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
2328 'S','h','a','r','e','d','D','L','L','s',0};
2330 RegCreateKeyW(HKEY_LOCAL_MACHINE,path,&hkey);
2334 static UINT ACTION_GetSharedDLLsCount(LPCWSTR dll)
2339 DWORD sz = sizeof(count);
2342 hkey = openSharedDLLsKey();
2343 rc = RegQueryValueExW(hkey, dll, NULL, &type, (LPBYTE)&count, &sz);
2344 if (rc != ERROR_SUCCESS)
2350 static UINT ACTION_WriteSharedDLLsCount(LPCWSTR path, UINT count)
2354 hkey = openSharedDLLsKey();
2356 msi_reg_set_val_dword( hkey, path, count );
2358 RegDeleteValueW(hkey,path);
2364 * Return TRUE if the count should be written out and FALSE if not
2366 static void ACTION_RefCountComponent( MSIPACKAGE* package, MSICOMPONENT *comp )
2368 MSIFEATURE *feature;
2372 /* only refcount DLLs */
2373 if (comp->KeyPath == NULL ||
2374 comp->Attributes & msidbComponentAttributesRegistryKeyPath ||
2375 comp->Attributes & msidbComponentAttributesODBCDataSource)
2379 count = ACTION_GetSharedDLLsCount( comp->FullKeypath);
2380 write = (count > 0);
2382 if (comp->Attributes & msidbComponentAttributesSharedDllRefCount)
2386 /* increment counts */
2387 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
2391 if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL ))
2394 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
2396 if ( cl->component == comp )
2401 /* decrement counts */
2402 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
2406 if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ABSENT ))
2409 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
2411 if ( cl->component == comp )
2416 /* ref count all the files in the component */
2421 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
2423 if (file->Component == comp)
2424 ACTION_WriteSharedDLLsCount( file->TargetPath, count );
2428 /* add a count for permenent */
2429 if (comp->Attributes & msidbComponentAttributesPermanent)
2432 comp->RefCount = count;
2435 ACTION_WriteSharedDLLsCount( comp->FullKeypath, comp->RefCount );
2439 * Ok further analysis makes me think that this work is
2440 * actually done in the PublishComponents and PublishFeatures
2441 * step, and not here. It appears like the keypath and all that is
2442 * resolved in this step, however actually written in the Publish steps.
2443 * But we will leave it here for now because it is unclear
2445 static UINT ACTION_ProcessComponents(MSIPACKAGE *package)
2447 WCHAR squished_pc[GUID_SIZE];
2448 WCHAR squished_cc[GUID_SIZE];
2451 HKEY hkey=0,hkey2=0;
2454 return ERROR_INVALID_HANDLE;
2456 /* writes the Component and Features values to the registry */
2458 rc = MSIREG_OpenComponents(&hkey);
2459 if (rc != ERROR_SUCCESS)
2462 squash_guid(package->ProductCode,squished_pc);
2463 ui_progress(package,1,COMPONENT_PROGRESS_VALUE,1,0);
2465 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
2467 ui_progress(package,2,0,0,0);
2468 if (comp->ComponentId)
2472 squash_guid(comp->ComponentId,squished_cc);
2474 msi_free(comp->FullKeypath);
2475 comp->FullKeypath = resolve_keypath( package, comp );
2477 /* do the refcounting */
2478 ACTION_RefCountComponent( package, comp );
2480 TRACE("Component %s (%s), Keypath=%s, RefCount=%i\n",
2481 debugstr_w(comp->Component),
2482 debugstr_w(squished_cc),
2483 debugstr_w(comp->FullKeypath),
2486 * Write the keypath out if the component is to be registered
2487 * and delete the key if the component is to be deregistered
2489 if (ACTION_VerifyComponentForAction(package, comp,
2490 INSTALLSTATE_LOCAL))
2492 rc = RegCreateKeyW(hkey,squished_cc,&hkey2);
2493 if (rc != ERROR_SUCCESS)
2496 if (comp->FullKeypath)
2498 msi_reg_set_val_str( hkey2, squished_pc, comp->FullKeypath );
2500 if (comp->Attributes & msidbComponentAttributesPermanent)
2502 static const WCHAR szPermKey[] =
2503 { '0','0','0','0','0','0','0','0','0','0','0','0',
2504 '0','0','0','0','0','0','0','0','0','0','0','0',
2505 '0','0','0','0','0','0','0','0',0};
2507 msi_reg_set_val_str( hkey2, szPermKey, comp->FullKeypath );
2513 uirow = MSI_CreateRecord(3);
2514 MSI_RecordSetStringW(uirow,1,package->ProductCode);
2515 MSI_RecordSetStringW(uirow,2,comp->ComponentId);
2516 MSI_RecordSetStringW(uirow,3,comp->FullKeypath);
2517 ui_actiondata(package,szProcessComponents,uirow);
2518 msiobj_release( &uirow->hdr );
2521 else if (ACTION_VerifyComponentForAction(package, comp,
2522 INSTALLSTATE_ABSENT))
2526 rc = RegOpenKeyW(hkey,squished_cc,&hkey2);
2527 if (rc != ERROR_SUCCESS)
2530 RegDeleteValueW(hkey2,squished_pc);
2532 /* if the key is empty delete it */
2533 res = RegEnumKeyExW(hkey2,0,NULL,0,0,NULL,0,NULL);
2535 if (res == ERROR_NO_MORE_ITEMS)
2536 RegDeleteKeyW(hkey,squished_cc);
2539 uirow = MSI_CreateRecord(2);
2540 MSI_RecordSetStringW(uirow,1,package->ProductCode);
2541 MSI_RecordSetStringW(uirow,2,comp->ComponentId);
2542 ui_actiondata(package,szProcessComponents,uirow);
2543 msiobj_release( &uirow->hdr );
2560 static BOOL CALLBACK Typelib_EnumResNameProc( HMODULE hModule, LPCWSTR lpszType,
2561 LPWSTR lpszName, LONG_PTR lParam)
2564 typelib_struct *tl_struct = (typelib_struct*) lParam;
2565 static const WCHAR fmt[] = {'%','s','\\','%','i',0};
2569 if (!IS_INTRESOURCE(lpszName))
2571 ERR("Not Int Resource Name %s\n",debugstr_w(lpszName));
2575 sz = strlenW(tl_struct->source)+4;
2576 sz *= sizeof(WCHAR);
2578 if ((INT)lpszName == 1)
2579 tl_struct->path = strdupW(tl_struct->source);
2582 tl_struct->path = msi_alloc(sz);
2583 sprintfW(tl_struct->path,fmt,tl_struct->source, lpszName);
2586 TRACE("trying %s\n", debugstr_w(tl_struct->path));
2587 res = LoadTypeLib(tl_struct->path,&tl_struct->ptLib);
2588 if (!SUCCEEDED(res))
2590 msi_free(tl_struct->path);
2591 tl_struct->path = NULL;
2596 ITypeLib_GetLibAttr(tl_struct->ptLib, &attr);
2597 if (IsEqualGUID(&(tl_struct->clsid),&(attr->guid)))
2599 ITypeLib_ReleaseTLibAttr(tl_struct->ptLib, attr);
2603 msi_free(tl_struct->path);
2604 tl_struct->path = NULL;
2606 ITypeLib_ReleaseTLibAttr(tl_struct->ptLib, attr);
2607 ITypeLib_Release(tl_struct->ptLib);
2612 static UINT ITERATE_RegisterTypeLibraries(MSIRECORD *row, LPVOID param)
2614 MSIPACKAGE* package = (MSIPACKAGE*)param;
2618 typelib_struct tl_struct;
2620 static const WCHAR szTYPELIB[] = {'T','Y','P','E','L','I','B',0};
2622 component = MSI_RecordGetString(row,3);
2623 comp = get_loaded_component(package,component);
2625 return ERROR_SUCCESS;
2627 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL))
2629 TRACE("Skipping typelib reg due to disabled component\n");
2631 comp->Action = comp->Installed;
2633 return ERROR_SUCCESS;
2636 comp->Action = INSTALLSTATE_LOCAL;
2638 file = get_loaded_file( package, comp->KeyPath );
2640 return ERROR_SUCCESS;
2642 module = LoadLibraryExW( file->TargetPath, NULL, LOAD_LIBRARY_AS_DATAFILE );
2646 guid = load_dynamic_stringW(row,1);
2647 CLSIDFromString(guid, &tl_struct.clsid);
2649 tl_struct.source = strdupW( file->TargetPath );
2650 tl_struct.path = NULL;
2652 EnumResourceNamesW(module, szTYPELIB, Typelib_EnumResNameProc,
2653 (LONG_PTR)&tl_struct);
2655 if (tl_struct.path != NULL)
2661 helpid = MSI_RecordGetString(row,6);
2664 help = resolve_folder(package,helpid,FALSE,FALSE,NULL);
2665 res = RegisterTypeLib(tl_struct.ptLib,tl_struct.path,help);
2668 if (!SUCCEEDED(res))
2669 ERR("Failed to register type library %s\n",
2670 debugstr_w(tl_struct.path));
2673 ui_actiondata(package,szRegisterTypeLibraries,row);
2675 TRACE("Registered %s\n", debugstr_w(tl_struct.path));
2678 ITypeLib_Release(tl_struct.ptLib);
2679 msi_free(tl_struct.path);
2682 ERR("Failed to load type library %s\n",
2683 debugstr_w(tl_struct.source));
2685 FreeLibrary(module);
2686 msi_free(tl_struct.source);
2689 ERR("Could not load file! %s\n", debugstr_w(file->TargetPath));
2691 return ERROR_SUCCESS;
2694 static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package)
2697 * OK this is a bit confusing.. I am given a _Component key and I believe
2698 * that the file that is being registered as a type library is the "key file
2699 * of that component" which I interpret to mean "The file in the KeyPath of
2704 static const WCHAR Query[] =
2705 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2706 '`','T','y','p','e','L','i','b','`',0};
2709 return ERROR_INVALID_HANDLE;
2711 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
2712 if (rc != ERROR_SUCCESS)
2713 return ERROR_SUCCESS;
2715 rc = MSI_IterateRecords(view, NULL, ITERATE_RegisterTypeLibraries, package);
2716 msiobj_release(&view->hdr);
2720 static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param)
2722 MSIPACKAGE *package = (MSIPACKAGE*)param;
2723 LPWSTR target_file, target_folder;
2725 WCHAR filename[0x100];
2728 static const WCHAR szlnk[]={'.','l','n','k',0};
2733 buffer = MSI_RecordGetString(row,4);
2734 comp = get_loaded_component(package,buffer);
2736 return ERROR_SUCCESS;
2738 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL))
2740 TRACE("Skipping shortcut creation due to disabled component\n");
2742 comp->Action = comp->Installed;
2744 return ERROR_SUCCESS;
2747 comp->Action = INSTALLSTATE_LOCAL;
2749 ui_actiondata(package,szCreateShortcuts,row);
2751 res = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
2752 &IID_IShellLinkW, (LPVOID *) &sl );
2756 ERR("Is IID_IShellLink\n");
2757 return ERROR_SUCCESS;
2760 res = IShellLinkW_QueryInterface( sl, &IID_IPersistFile,(LPVOID*) &pf );
2763 ERR("Is IID_IPersistFile\n");
2764 return ERROR_SUCCESS;
2767 buffer = MSI_RecordGetString(row,2);
2768 target_folder = resolve_folder(package, buffer,FALSE,FALSE,NULL);
2770 /* may be needed because of a bug somehwere else */
2771 create_full_pathW(target_folder);
2774 MSI_RecordGetStringW(row,3,filename,&sz);
2775 reduce_to_longfilename(filename);
2776 if (!strchrW(filename,'.') || strcmpiW(strchrW(filename,'.'),szlnk))
2777 strcatW(filename,szlnk);
2778 target_file = build_directory_name(2, target_folder, filename);
2779 msi_free(target_folder);
2781 buffer = MSI_RecordGetString(row,5);
2782 if (strchrW(buffer,'['))
2785 deformat_string(package,buffer,&deformated);
2786 IShellLinkW_SetPath(sl,deformated);
2787 msi_free(deformated);
2791 FIXME("poorly handled shortcut format, advertised shortcut\n");
2792 IShellLinkW_SetPath(sl,comp->FullKeypath);
2795 if (!MSI_RecordIsNull(row,6))
2798 buffer = MSI_RecordGetString(row,6);
2799 deformat_string(package,buffer,&deformated);
2800 IShellLinkW_SetArguments(sl,deformated);
2801 msi_free(deformated);
2804 if (!MSI_RecordIsNull(row,7))
2806 buffer = MSI_RecordGetString(row,7);
2807 IShellLinkW_SetDescription(sl,buffer);
2810 if (!MSI_RecordIsNull(row,8))
2811 IShellLinkW_SetHotkey(sl,MSI_RecordGetInteger(row,8));
2813 if (!MSI_RecordIsNull(row,9))
2818 buffer = MSI_RecordGetString(row,9);
2820 Path = build_icon_path(package,buffer);
2821 index = MSI_RecordGetInteger(row,10);
2823 IShellLinkW_SetIconLocation(sl,Path,index);
2827 if (!MSI_RecordIsNull(row,11))
2828 IShellLinkW_SetShowCmd(sl,MSI_RecordGetInteger(row,11));
2830 if (!MSI_RecordIsNull(row,12))
2833 buffer = MSI_RecordGetString(row,12);
2834 Path = resolve_folder(package, buffer, FALSE, FALSE, NULL);
2835 IShellLinkW_SetWorkingDirectory(sl,Path);
2839 TRACE("Writing shortcut to %s\n",debugstr_w(target_file));
2840 IPersistFile_Save(pf,target_file,FALSE);
2842 msi_free(target_file);
2844 IPersistFile_Release( pf );
2845 IShellLinkW_Release( sl );
2847 return ERROR_SUCCESS;
2850 static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
2855 static const WCHAR Query[] =
2856 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2857 '`','S','h','o','r','t','c','u','t','`',0};
2860 return ERROR_INVALID_HANDLE;
2862 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
2863 if (rc != ERROR_SUCCESS)
2864 return ERROR_SUCCESS;
2866 res = CoInitialize( NULL );
2869 ERR("CoInitialize failed\n");
2870 return ERROR_FUNCTION_FAILED;
2873 rc = MSI_IterateRecords(view, NULL, ITERATE_CreateShortcuts, package);
2874 msiobj_release(&view->hdr);
2881 static UINT ITERATE_PublishProduct(MSIRECORD *row, LPVOID param)
2883 MSIPACKAGE* package = (MSIPACKAGE*)param;
2891 FileName = MSI_RecordGetString(row,1);
2894 ERR("Unable to get FileName\n");
2895 return ERROR_SUCCESS;
2898 FilePath = build_icon_path(package,FileName);
2900 TRACE("Creating icon file at %s\n",debugstr_w(FilePath));
2902 the_file = CreateFileW(FilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2903 FILE_ATTRIBUTE_NORMAL, NULL);
2905 if (the_file == INVALID_HANDLE_VALUE)
2907 ERR("Unable to create file %s\n",debugstr_w(FilePath));
2909 return ERROR_SUCCESS;
2916 rc = MSI_RecordReadStream(row,2,buffer,&sz);
2917 if (rc != ERROR_SUCCESS)
2919 ERR("Failed to get stream\n");
2920 CloseHandle(the_file);
2921 DeleteFileW(FilePath);
2924 WriteFile(the_file,buffer,sz,&write,NULL);
2925 } while (sz == 1024);
2929 CloseHandle(the_file);
2930 return ERROR_SUCCESS;
2934 * 99% of the work done here is only done for
2935 * advertised installs. However this is where the
2936 * Icon table is processed and written out
2937 * so that is what I am going to do here.
2939 static UINT ACTION_PublishProduct(MSIPACKAGE *package)
2943 static const WCHAR Query[]=
2944 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2945 '`','I','c','o','n','`',0};
2946 /* for registry stuff */
2949 static const WCHAR szProductLanguage[] =
2950 {'P','r','o','d','u','c','t','L','a','n','g','u','a','g','e',0};
2951 static const WCHAR szARPProductIcon[] =
2952 {'A','R','P','P','R','O','D','U','C','T','I','C','O','N',0};
2953 static const WCHAR szProductVersion[] =
2954 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0};
2958 MSIHANDLE hDb, hSumInfo;
2961 return ERROR_INVALID_HANDLE;
2963 /* write out icon files */
2965 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
2966 if (rc == ERROR_SUCCESS)
2968 MSI_IterateRecords(view, NULL, ITERATE_PublishProduct, package);
2969 msiobj_release(&view->hdr);
2972 /* ok there is a lot more done here but i need to figure out what */
2974 rc = MSIREG_OpenProductsKey(package->ProductCode,&hkey,TRUE);
2975 if (rc != ERROR_SUCCESS)
2978 rc = MSIREG_OpenUserProductsKey(package->ProductCode,&hukey,TRUE);
2979 if (rc != ERROR_SUCCESS)
2983 buffer = msi_dup_property( package, INSTALLPROPERTY_PRODUCTNAMEW );
2984 msi_reg_set_val_str( hukey, INSTALLPROPERTY_PRODUCTNAMEW, buffer );
2987 buffer = msi_dup_property( package, szProductLanguage );
2988 langid = atoiW(buffer);
2989 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_LANGUAGEW, langid );
2992 buffer = msi_dup_property( package, szARPProductIcon );
2995 LPWSTR path = build_icon_path(package,buffer);
2996 msi_reg_set_val_str( hukey, INSTALLPROPERTY_PRODUCTICONW, path );
3001 buffer = msi_dup_property( package, szProductVersion );
3004 DWORD verdword = build_version_dword(buffer);
3005 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONW, verdword );
3009 FIXME("Need to write more keys to the user registry\n");
3011 hDb= alloc_msihandle( &package->db->hdr );
3012 rc = MsiGetSummaryInformationW(hDb, NULL, 0, &hSumInfo);
3013 MsiCloseHandle(hDb);
3014 if (rc == ERROR_SUCCESS)
3016 WCHAR guidbuffer[0x200];
3018 rc = MsiSummaryInfoGetPropertyW(hSumInfo, 9, NULL, NULL, NULL,
3020 if (rc == ERROR_SUCCESS)
3022 WCHAR squashed[GUID_SIZE];
3023 /* for now we only care about the first guid */
3024 LPWSTR ptr = strchrW(guidbuffer,';');
3026 squash_guid(guidbuffer,squashed);
3027 msi_reg_set_val_str( hukey, INSTALLPROPERTY_PACKAGECODEW, squashed );
3031 ERR("Unable to query Revision_Number... \n");
3034 MsiCloseHandle(hSumInfo);
3038 ERR("Unable to open Summary Information\n");
3050 static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param)
3052 MSIPACKAGE *package = (MSIPACKAGE*)param;
3053 LPCWSTR component,section,key,value,identifier,filename,dirproperty;
3054 LPWSTR deformated_section, deformated_key, deformated_value;
3055 LPWSTR folder, fullname = NULL;
3059 static const WCHAR szWindowsFolder[] =
3060 {'W','i','n','d','o','w','s','F','o','l','d','e','r',0};
3062 component = MSI_RecordGetString(row, 8);
3063 comp = get_loaded_component(package,component);
3065 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL))
3067 TRACE("Skipping ini file due to disabled component %s\n",
3068 debugstr_w(component));
3070 comp->Action = comp->Installed;
3072 return ERROR_SUCCESS;
3075 comp->Action = INSTALLSTATE_LOCAL;
3077 identifier = MSI_RecordGetString(row,1);
3078 filename = MSI_RecordGetString(row,2);
3079 dirproperty = MSI_RecordGetString(row,3);
3080 section = MSI_RecordGetString(row,4);
3081 key = MSI_RecordGetString(row,5);
3082 value = MSI_RecordGetString(row,6);
3083 action = MSI_RecordGetInteger(row,7);
3085 deformat_string(package,section,&deformated_section);
3086 deformat_string(package,key,&deformated_key);
3087 deformat_string(package,value,&deformated_value);
3091 folder = resolve_folder(package, dirproperty, FALSE, FALSE, NULL);
3093 folder = msi_dup_property( package, dirproperty );
3096 folder = msi_dup_property( package, szWindowsFolder );
3100 ERR("Unable to resolve folder! (%s)\n",debugstr_w(dirproperty));
3104 fullname = build_directory_name(2, folder, filename);
3108 TRACE("Adding value %s to section %s in %s\n",
3109 debugstr_w(deformated_key), debugstr_w(deformated_section),
3110 debugstr_w(fullname));
3111 WritePrivateProfileStringW(deformated_section, deformated_key,
3112 deformated_value, fullname);
3114 else if (action == 1)
3117 GetPrivateProfileStringW(deformated_section, deformated_key, NULL,
3118 returned, 10, fullname);
3119 if (returned[0] == 0)
3121 TRACE("Adding value %s to section %s in %s\n",
3122 debugstr_w(deformated_key), debugstr_w(deformated_section),
3123 debugstr_w(fullname));
3125 WritePrivateProfileStringW(deformated_section, deformated_key,
3126 deformated_value, fullname);
3129 else if (action == 3)
3130 FIXME("Append to existing section not yet implemented\n");
3132 uirow = MSI_CreateRecord(4);
3133 MSI_RecordSetStringW(uirow,1,identifier);
3134 MSI_RecordSetStringW(uirow,2,deformated_section);
3135 MSI_RecordSetStringW(uirow,3,deformated_key);
3136 MSI_RecordSetStringW(uirow,4,deformated_value);
3137 ui_actiondata(package,szWriteIniValues,uirow);
3138 msiobj_release( &uirow->hdr );
3142 msi_free(deformated_key);
3143 msi_free(deformated_value);
3144 msi_free(deformated_section);
3145 return ERROR_SUCCESS;
3148 static UINT ACTION_WriteIniValues(MSIPACKAGE *package)
3152 static const WCHAR ExecSeqQuery[] =
3153 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3154 '`','I','n','i','F','i','l','e','`',0};
3156 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3157 if (rc != ERROR_SUCCESS)
3159 TRACE("no IniFile table\n");
3160 return ERROR_SUCCESS;
3163 rc = MSI_IterateRecords(view, NULL, ITERATE_WriteIniValues, package);
3164 msiobj_release(&view->hdr);
3168 static UINT ITERATE_SelfRegModules(MSIRECORD *row, LPVOID param)
3170 MSIPACKAGE *package = (MSIPACKAGE*)param;
3175 static const WCHAR ExeStr[] =
3176 {'r','e','g','s','v','r','3','2','.','e','x','e',' ','\"',0};
3177 static const WCHAR close[] = {'\"',0};
3179 PROCESS_INFORMATION info;
3182 memset(&si,0,sizeof(STARTUPINFOW));
3184 filename = MSI_RecordGetString(row,1);
3185 file = get_loaded_file( package, filename );
3189 ERR("Unable to find file id %s\n",debugstr_w(filename));
3190 return ERROR_SUCCESS;
3193 len = strlenW(ExeStr) + strlenW( file->TargetPath ) + 2;
3195 FullName = msi_alloc(len*sizeof(WCHAR));
3196 strcpyW(FullName,ExeStr);
3197 strcatW( FullName, file->TargetPath );
3198 strcatW(FullName,close);
3200 TRACE("Registering %s\n",debugstr_w(FullName));
3201 brc = CreateProcessW(NULL, FullName, NULL, NULL, FALSE, 0, NULL, c_colon,
3205 msi_dialog_check_messages(info.hProcess);
3208 return ERROR_SUCCESS;
3211 static UINT ACTION_SelfRegModules(MSIPACKAGE *package)
3215 static const WCHAR ExecSeqQuery[] =
3216 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3217 '`','S','e','l','f','R','e','g','`',0};
3219 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3220 if (rc != ERROR_SUCCESS)
3222 TRACE("no SelfReg table\n");
3223 return ERROR_SUCCESS;
3226 MSI_IterateRecords(view, NULL, ITERATE_SelfRegModules, package);
3227 msiobj_release(&view->hdr);
3229 return ERROR_SUCCESS;
3232 static UINT ACTION_PublishFeatures(MSIPACKAGE *package)
3234 MSIFEATURE *feature;
3240 return ERROR_INVALID_HANDLE;
3242 rc = MSIREG_OpenFeaturesKey(package->ProductCode,&hkey,TRUE);
3243 if (rc != ERROR_SUCCESS)
3246 rc = MSIREG_OpenUserFeaturesKey(package->ProductCode,&hukey,TRUE);
3247 if (rc != ERROR_SUCCESS)
3250 /* here the guids are base 85 encoded */
3251 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
3257 BOOL absent = FALSE;
3259 if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL ) &&
3260 !ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_SOURCE ) &&
3261 !ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ADVERTISED ))
3265 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
3269 if (feature->Feature_Parent)
3270 size += strlenW( feature->Feature_Parent )+2;
3272 data = msi_alloc(size * sizeof(WCHAR));
3275 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
3277 MSICOMPONENT* component = cl->component;
3280 memset(buf,0,sizeof(buf));
3281 if (component->ComponentId)
3283 TRACE("From %s\n",debugstr_w(component->ComponentId));
3284 CLSIDFromString(component->ComponentId, &clsid);
3285 encode_base85_guid(&clsid,buf);
3286 TRACE("to %s\n",debugstr_w(buf));
3290 if (feature->Feature_Parent)
3292 static const WCHAR sep[] = {'\2',0};
3294 strcatW(data,feature->Feature_Parent);
3297 msi_reg_set_val_str( hkey, feature->Feature, data );
3301 if (feature->Feature_Parent)
3302 size = strlenW(feature->Feature_Parent)*sizeof(WCHAR);
3305 RegSetValueExW(hukey,feature->Feature,0,REG_SZ,
3306 (LPBYTE)feature->Feature_Parent,size);
3310 size += 2*sizeof(WCHAR);
3311 data = msi_alloc(size);
3314 if (feature->Feature_Parent)
3315 strcpyW( &data[1], feature->Feature_Parent );
3316 RegSetValueExW(hukey,feature->Feature,0,REG_SZ,
3328 static UINT ACTION_RegisterProduct(MSIPACKAGE *package)
3331 LPWSTR buffer = NULL;
3334 static const WCHAR szWindowsInstaller[] =
3335 {'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
3336 static const WCHAR szPropKeys[][80] =
3338 {'A','R','P','A','U','T','H','O','R','I','Z','E','D','C','D','F','P','R','E','F','I','X',0},
3339 {'A','R','P','C','O','N','T','A','C','T',0},
3340 {'A','R','P','C','O','M','M','E','N','T','S',0},
3341 {'P','r','o','d','u','c','t','N','a','m','e',0},
3342 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0},
3343 {'A','R','P','H','E','L','P','L','I','N','K',0},
3344 {'A','R','P','H','E','L','P','T','E','L','E','P','H','O','N','E',0},
3345 {'A','R','P','I','N','S','T','A','L','L','L','O','C','A','T','I','O','N',0},
3346 {'S','o','u','r','c','e','D','i','r',0},
3347 {'M','a','n','u','f','a','c','t','u','r','e','r',0},
3348 {'A','R','P','R','E','A','D','M','E',0},
3349 {'A','R','P','S','I','Z','E',0},
3350 {'A','R','P','U','R','L','I','N','F','O','A','B','O','U','T',0},
3351 {'A','R','P','U','R','L','U','P','D','A','T','E','I','N','F','O',0},
3355 static const WCHAR szRegKeys[][80] =
3357 {'A','u','t','h','o','r','i','z','e','d','C','D','F','P','r','e','f','i','x',0},
3358 {'C','o','n','t','a','c','t',0},
3359 {'C','o','m','m','e','n','t','s',0},
3360 {'D','i','s','p','l','a','y','N','a','m','e',0},
3361 {'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0},
3362 {'H','e','l','p','L','i','n','k',0},
3363 {'H','e','l','p','T','e','l','e','p','h','o','n','e',0},
3364 {'I','n','s','t','a','l','l','L','o','c','a','t','i','o','n',0},
3365 {'I','n','s','t','a','l','l','S','o','u','r','c','e',0},
3366 {'P','u','b','l','i','s','h','e','r',0},
3367 {'R','e','a','d','m','e',0},
3368 {'S','i','z','e',0},
3369 {'U','R','L','I','n','f','o','A','b','o','u','t',0},
3370 {'U','R','L','U','p','d','a','t','e','I','n','f','o',0},
3374 static const WCHAR installerPathFmt[] = {
3376 'I','n','s','t','a','l','l','e','r','\\',0};
3377 static const WCHAR fmt[] = {
3379 'I','n','s','t','a','l','l','e','r','\\',
3380 '%','x','.','m','s','i',0};
3381 static const WCHAR szUpgradeCode[] =
3382 {'U','p','g','r','a','d','e','C','o','d','e',0};
3383 static const WCHAR modpath_fmt[] =
3384 {'M','s','i','E','x','e','c','.','e','x','e',' ','/','I','[','P','r','o','d','u','c','t','C','o','d','e',']',0};
3385 static const WCHAR szModifyPath[] =
3386 {'M','o','d','i','f','y','P','a','t','h',0};
3387 static const WCHAR szUninstallString[] =
3388 {'U','n','i','n','s','t','a','l','l','S','t','r','i','n','g',0};
3389 static const WCHAR szEstimatedSize[] =
3390 {'E','s','t','i','m','a','t','e','d','S','i','z','e',0};
3391 static const WCHAR szProductLanguage[] =
3392 {'P','r','o','d','u','c','t','L','a','n','g','u','a','g','e',0};
3393 static const WCHAR szProductVersion[] =
3394 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0};
3397 static const WCHAR date_fmt[] = {'%','i','%','i','%','i',0};
3398 LPWSTR upgrade_code;
3399 WCHAR windir[MAX_PATH], path[MAX_PATH], packagefile[MAX_PATH];
3403 return ERROR_INVALID_HANDLE;
3405 rc = MSIREG_OpenUninstallKey(package->ProductCode,&hkey,TRUE);
3406 if (rc != ERROR_SUCCESS)
3409 /* dump all the info i can grab */
3410 FIXME("Flesh out more information \n");
3412 for( i=0; szPropKeys[i][0]; i++ )
3414 buffer = msi_dup_property( package, szPropKeys[i] );
3415 msi_reg_set_val_str( hkey, szRegKeys[i], buffer );
3419 msi_reg_set_val_dword( hkey, szWindowsInstaller, 1 );
3421 /* copy the package locally */
3422 num = GetTickCount() & 0xffff;
3426 GetWindowsDirectoryW(windir, sizeof(windir) / sizeof(windir[0]));
3427 snprintfW(packagefile,sizeof(packagefile)/sizeof(packagefile[0]),fmt,
3431 HANDLE handle = CreateFileW(packagefile,GENERIC_WRITE, 0, NULL,
3432 CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
3433 if (handle != INVALID_HANDLE_VALUE)
3435 CloseHandle(handle);
3438 if (GetLastError() != ERROR_FILE_EXISTS &&
3439 GetLastError() != ERROR_SHARING_VIOLATION)
3441 if (!(++num & 0xffff)) num = 1;
3442 sprintfW(packagefile,fmt,num);
3443 } while (num != start);
3445 snprintfW(path,sizeof(path)/sizeof(path[0]),installerPathFmt,windir);
3446 create_full_pathW(path);
3447 TRACE("Copying to local package %s\n",debugstr_w(packagefile));
3448 if (!CopyFileW(package->msiFilePath,packagefile,FALSE))
3449 ERR("Unable to copy package (%s -> %s) (error %ld)\n",
3450 debugstr_w(package->msiFilePath), debugstr_w(packagefile),
3452 msi_reg_set_val_str( hkey, INSTALLPROPERTY_LOCALPACKAGEW, packagefile );
3454 /* do ModifyPath and UninstallString */
3455 size = deformat_string(package,modpath_fmt,&buffer);
3456 RegSetValueExW(hkey,szModifyPath,0,REG_EXPAND_SZ,(LPBYTE)buffer,size);
3457 RegSetValueExW(hkey,szUninstallString,0,REG_EXPAND_SZ,(LPBYTE)buffer,size);
3460 FIXME("Write real Estimated Size when we have it\n");
3461 msi_reg_set_val_dword( hkey, szEstimatedSize, 0 );
3463 GetLocalTime(&systime);
3464 size = 9*sizeof(WCHAR);
3465 buffer= msi_alloc(size);
3466 sprintfW(buffer,date_fmt,systime.wYear,systime.wMonth,systime.wDay);
3467 msi_reg_set_val_str( hkey, INSTALLPROPERTY_INSTALLDATEW, buffer );
3470 buffer = msi_dup_property( package, szProductLanguage );
3471 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_LANGUAGEW, atoiW(buffer) );
3474 buffer = msi_dup_property( package, szProductVersion );
3477 DWORD verdword = build_version_dword(buffer);
3479 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONW, verdword );
3480 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONMAJORW, verdword>>24 );
3481 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONMINORW, (verdword>>16)&0x00FF );
3485 /* Handle Upgrade Codes */
3486 upgrade_code = msi_dup_property( package, szUpgradeCode );
3491 MSIREG_OpenUpgradeCodesKey(upgrade_code, &hkey2, TRUE);
3492 squash_guid(package->ProductCode,squashed);
3493 msi_reg_set_val_str( hkey2, squashed, NULL );
3495 MSIREG_OpenUserUpgradeCodesKey(upgrade_code, &hkey2, TRUE);
3496 squash_guid(package->ProductCode,squashed);
3497 msi_reg_set_val_str( hkey2, squashed, NULL );
3500 msi_free(upgrade_code);
3506 return ERROR_SUCCESS;
3509 static UINT ACTION_InstallExecute(MSIPACKAGE *package)
3514 return ERROR_INVALID_HANDLE;
3516 rc = execute_script(package,INSTALL_SCRIPT);
3521 static UINT ACTION_InstallFinalize(MSIPACKAGE *package)
3526 return ERROR_INVALID_HANDLE;
3528 /* turn off scheduleing */
3529 package->script->CurrentlyScripting= FALSE;
3531 /* first do the same as an InstallExecute */
3532 rc = ACTION_InstallExecute(package);
3533 if (rc != ERROR_SUCCESS)
3536 /* then handle Commit Actions */
3537 rc = execute_script(package,COMMIT_SCRIPT);
3542 static UINT ACTION_ForceReboot(MSIPACKAGE *package)
3544 static const WCHAR RunOnce[] = {
3545 'S','o','f','t','w','a','r','e','\\',
3546 'M','i','c','r','o','s','o','f','t','\\',
3547 'W','i','n','d','o','w','s','\\',
3548 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3549 'R','u','n','O','n','c','e',0};
3550 static const WCHAR InstallRunOnce[] = {
3551 'S','o','f','t','w','a','r','e','\\',
3552 'M','i','c','r','o','s','o','f','t','\\',
3553 'W','i','n','d','o','w','s','\\',
3554 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3555 'I','n','s','t','a','l','l','e','r','\\',
3556 'R','u','n','O','n','c','e','E','n','t','r','i','e','s',0};
3558 static const WCHAR msiexec_fmt[] = {
3560 '\\','M','s','i','E','x','e','c','.','e','x','e',' ','/','@',' ',
3561 '\"','%','s','\"',0};
3562 static const WCHAR install_fmt[] = {
3563 '/','I',' ','\"','%','s','\"',' ',
3564 'A','F','T','E','R','R','E','B','O','O','T','=','1',' ',
3565 'R','U','N','O','N','C','E','E','N','T','R','Y','=','\"','%','s','\"',0};
3566 WCHAR buffer[256], sysdir[MAX_PATH];
3568 WCHAR squished_pc[100];
3571 return ERROR_INVALID_HANDLE;
3573 squash_guid(package->ProductCode,squished_pc);
3575 GetSystemDirectoryW(sysdir, sizeof(sysdir)/sizeof(sysdir[0]));
3576 RegCreateKeyW(HKEY_LOCAL_MACHINE,RunOnce,&hkey);
3577 snprintfW(buffer,sizeof(buffer)/sizeof(buffer[0]),msiexec_fmt,sysdir,
3580 msi_reg_set_val_str( hkey, squished_pc, buffer );
3583 TRACE("Reboot command %s\n",debugstr_w(buffer));
3585 RegCreateKeyW(HKEY_LOCAL_MACHINE,InstallRunOnce,&hkey);
3586 sprintfW(buffer,install_fmt,package->ProductCode,squished_pc);
3588 msi_reg_set_val_str( hkey, squished_pc, buffer );
3591 return ERROR_INSTALL_SUSPEND;
3594 UINT ACTION_ResolveSource(MSIPACKAGE* package)
3599 * we are currently doing what should be done here in the top level Install
3600 * however for Adminastrative and uninstalls this step will be needed
3602 if (!package->PackagePath)
3603 return ERROR_SUCCESS;
3605 attrib = GetFileAttributesW(package->PackagePath);
3606 if (attrib == INVALID_FILE_ATTRIBUTES)
3612 rc = MsiSourceListGetInfoW(package->ProductCode, NULL,
3613 MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT,
3614 INSTALLPROPERTY_DISKPROMPTW,NULL,&size);
3615 if (rc == ERROR_MORE_DATA)
3617 prompt = msi_alloc(size * sizeof(WCHAR));
3618 MsiSourceListGetInfoW(package->ProductCode, NULL,
3619 MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT,
3620 INSTALLPROPERTY_DISKPROMPTW,prompt,&size);
3623 prompt = strdupW(package->PackagePath);
3625 msg = generate_error_string(package,1302,1,prompt);
3626 while(attrib == INVALID_FILE_ATTRIBUTES)
3628 rc = MessageBoxW(NULL,msg,NULL,MB_OKCANCEL);
3631 rc = ERROR_INSTALL_USEREXIT;
3634 attrib = GetFileAttributesW(package->PackagePath);
3640 return ERROR_SUCCESS;
3645 static UINT ACTION_RegisterUser(MSIPACKAGE *package)
3652 static const WCHAR szPropKeys[][80] =
3654 {'P','r','o','d','u','c','t','I','D',0},
3655 {'U','S','E','R','N','A','M','E',0},
3656 {'C','O','M','P','A','N','Y','N','A','M','E',0},
3660 static const WCHAR szRegKeys[][80] =
3662 {'P','r','o','d','u','c','t','I','D',0},
3663 {'R','e','g','O','w','n','e','r',0},
3664 {'R','e','g','C','o','m','p','a','n','y',0},
3669 return ERROR_INVALID_HANDLE;
3671 productid = msi_dup_property( package, INSTALLPROPERTY_PRODUCTIDW );
3673 return ERROR_SUCCESS;
3675 rc = MSIREG_OpenUninstallKey(package->ProductCode,&hkey,TRUE);
3676 if (rc != ERROR_SUCCESS)
3679 for( i = 0; szPropKeys[i][0]; i++ )
3681 buffer = msi_dup_property( package, szPropKeys[i] );
3682 msi_reg_set_val_str( hkey, szRegKeys[i], buffer );
3687 msi_free(productid);
3690 return ERROR_SUCCESS;
3694 static UINT ACTION_ExecuteAction(MSIPACKAGE *package)
3696 static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0};
3697 static const WCHAR szTwo[] = {'2',0};
3700 level = msi_dup_property( package, szUILevel );
3702 MSI_SetPropertyW(package,szUILevel,szTwo);
3703 package->script->InWhatSequence |= SEQUENCE_EXEC;
3704 rc = ACTION_ProcessExecSequence(package,FALSE);
3705 MSI_SetPropertyW(package,szUILevel,level);
3712 * Code based off of code located here
3713 * http://www.codeproject.com/gdi/fontnamefromfile.asp
3715 * Using string index 4 (full font name) instead of 1 (family name)
3717 static LPWSTR load_ttfname_from(LPCWSTR filename)
3723 typedef struct _tagTT_OFFSET_TABLE{
3724 USHORT uMajorVersion;
3725 USHORT uMinorVersion;
3726 USHORT uNumOfTables;
3727 USHORT uSearchRange;
3728 USHORT uEntrySelector;
3732 typedef struct _tagTT_TABLE_DIRECTORY{
3733 char szTag[4]; /* table name */
3734 ULONG uCheckSum; /* Check sum */
3735 ULONG uOffset; /* Offset from beginning of file */
3736 ULONG uLength; /* length of the table in bytes */
3737 }TT_TABLE_DIRECTORY;
3739 typedef struct _tagTT_NAME_TABLE_HEADER{
3740 USHORT uFSelector; /* format selector. Always 0 */
3741 USHORT uNRCount; /* Name Records count */
3742 USHORT uStorageOffset; /* Offset for strings storage,
3743 * from start of the table */
3744 }TT_NAME_TABLE_HEADER;
3746 typedef struct _tagTT_NAME_RECORD{
3751 USHORT uStringLength;
3752 USHORT uStringOffset; /* from start of storage area */
3755 #define SWAPWORD(x) MAKEWORD(HIBYTE(x), LOBYTE(x))
3756 #define SWAPLONG(x) MAKELONG(SWAPWORD(HIWORD(x)), SWAPWORD(LOWORD(x)))
3758 handle = CreateFileW(filename ,GENERIC_READ, 0, NULL, OPEN_EXISTING,
3759 FILE_ATTRIBUTE_NORMAL, 0 );
3760 if (handle != INVALID_HANDLE_VALUE)
3762 TT_TABLE_DIRECTORY tblDir;
3763 BOOL bFound = FALSE;
3764 TT_OFFSET_TABLE ttOffsetTable;
3766 ReadFile(handle,&ttOffsetTable, sizeof(TT_OFFSET_TABLE),NULL,NULL);
3767 ttOffsetTable.uNumOfTables = SWAPWORD(ttOffsetTable.uNumOfTables);
3768 ttOffsetTable.uMajorVersion = SWAPWORD(ttOffsetTable.uMajorVersion);
3769 ttOffsetTable.uMinorVersion = SWAPWORD(ttOffsetTable.uMinorVersion);
3771 if (ttOffsetTable.uMajorVersion != 1 ||
3772 ttOffsetTable.uMinorVersion != 0)
3775 for (i=0; i< ttOffsetTable.uNumOfTables; i++)
3777 ReadFile(handle,&tblDir, sizeof(TT_TABLE_DIRECTORY),NULL,NULL);
3778 if (strncmp(tblDir.szTag,"name",4)==0)
3781 tblDir.uLength = SWAPLONG(tblDir.uLength);
3782 tblDir.uOffset = SWAPLONG(tblDir.uOffset);
3789 TT_NAME_TABLE_HEADER ttNTHeader;
3790 TT_NAME_RECORD ttRecord;
3792 SetFilePointer(handle, tblDir.uOffset, NULL, FILE_BEGIN);
3793 ReadFile(handle,&ttNTHeader, sizeof(TT_NAME_TABLE_HEADER),
3796 ttNTHeader.uNRCount = SWAPWORD(ttNTHeader.uNRCount);
3797 ttNTHeader.uStorageOffset = SWAPWORD(ttNTHeader.uStorageOffset);
3799 for(i=0; i<ttNTHeader.uNRCount; i++)
3801 ReadFile(handle,&ttRecord, sizeof(TT_NAME_RECORD),NULL,NULL);
3802 ttRecord.uNameID = SWAPWORD(ttRecord.uNameID);
3803 /* 4 is the Full Font Name */
3804 if(ttRecord.uNameID == 4)
3808 static LPCSTR tt = " (TrueType)";
3810 ttRecord.uStringLength = SWAPWORD(ttRecord.uStringLength);
3811 ttRecord.uStringOffset = SWAPWORD(ttRecord.uStringOffset);
3812 nPos = SetFilePointer(handle, 0, NULL, FILE_CURRENT);
3813 SetFilePointer(handle, tblDir.uOffset +
3814 ttRecord.uStringOffset +
3815 ttNTHeader.uStorageOffset,
3817 buf = msi_alloc( ttRecord.uStringLength + 1 + strlen(tt) );
3818 memset(buf, 0, ttRecord.uStringLength + 1 + strlen(tt));
3819 ReadFile(handle, buf, ttRecord.uStringLength, NULL, NULL);
3820 if (strlen(buf) > 0)
3823 ret = strdupAtoW(buf);
3829 SetFilePointer(handle,nPos, NULL, FILE_BEGIN);
3833 CloseHandle(handle);
3836 ERR("Unable to open font file %s\n", debugstr_w(filename));
3838 TRACE("Returning fontname %s\n",debugstr_w(ret));
3842 static UINT ITERATE_RegisterFonts(MSIRECORD *row, LPVOID param)
3844 MSIPACKAGE *package = (MSIPACKAGE*)param;
3848 static const WCHAR regfont1[] =
3849 {'S','o','f','t','w','a','r','e','\\',
3850 'M','i','c','r','o','s','o','f','t','\\',
3851 'W','i','n','d','o','w','s',' ','N','T','\\',
3852 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3853 'F','o','n','t','s',0};
3854 static const WCHAR regfont2[] =
3855 {'S','o','f','t','w','a','r','e','\\',
3856 'M','i','c','r','o','s','o','f','t','\\',
3857 'W','i','n','d','o','w','s','\\',
3858 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3859 'F','o','n','t','s',0};
3863 filename = MSI_RecordGetString( row, 1 );
3864 file = get_loaded_file( package, filename );
3867 ERR("Unable to load file\n");
3868 return ERROR_SUCCESS;
3871 /* check to make sure that component is installed */
3872 if (!ACTION_VerifyComponentForAction(package,
3873 file->Component, INSTALLSTATE_LOCAL))
3875 TRACE("Skipping: Component not scheduled for install\n");
3876 return ERROR_SUCCESS;
3879 RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont1,&hkey1);
3880 RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont2,&hkey2);
3882 if (MSI_RecordIsNull(row,2))
3883 name = load_ttfname_from( file->TargetPath );
3885 name = load_dynamic_stringW(row,2);
3889 msi_reg_set_val_str( hkey1, name, file->FileName );
3890 msi_reg_set_val_str( hkey2, name, file->FileName );
3896 return ERROR_SUCCESS;
3899 static UINT ACTION_RegisterFonts(MSIPACKAGE *package)
3903 static const WCHAR ExecSeqQuery[] =
3904 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3905 '`','F','o','n','t','`',0};
3907 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3908 if (rc != ERROR_SUCCESS)
3910 TRACE("MSI_DatabaseOpenViewW failed: %d\n", rc);
3911 return ERROR_SUCCESS;
3914 MSI_IterateRecords(view, NULL, ITERATE_RegisterFonts, package);
3915 msiobj_release(&view->hdr);
3917 return ERROR_SUCCESS;
3920 static UINT ITERATE_PublishComponent(MSIRECORD *rec, LPVOID param)
3922 MSIPACKAGE *package = (MSIPACKAGE*)param;
3923 LPCWSTR compgroupid=NULL;
3924 LPCWSTR feature=NULL;
3925 LPCWSTR text = NULL;
3926 LPCWSTR qualifier = NULL;
3927 LPCWSTR component = NULL;
3928 LPWSTR advertise = NULL;
3929 LPWSTR output = NULL;
3931 UINT rc = ERROR_SUCCESS;
3935 component = MSI_RecordGetString(rec,3);
3936 comp = get_loaded_component(package,component);
3938 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL) &&
3939 !ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_SOURCE) &&
3940 !ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_ADVERTISED))
3942 TRACE("Skipping: Component %s not scheduled for install\n",
3943 debugstr_w(component));
3945 return ERROR_SUCCESS;
3948 compgroupid = MSI_RecordGetString(rec,1);
3950 rc = MSIREG_OpenUserComponentsKey(compgroupid, &hkey, TRUE);
3951 if (rc != ERROR_SUCCESS)
3954 text = MSI_RecordGetString(rec,4);
3955 qualifier = MSI_RecordGetString(rec,2);
3956 feature = MSI_RecordGetString(rec,5);
3958 advertise = create_component_advertise_string(package, comp, feature);
3960 sz = strlenW(advertise);
3963 sz += lstrlenW(text);
3966 sz *= sizeof(WCHAR);
3968 output = msi_alloc(sz);
3969 memset(output,0,sz);
3970 strcpyW(output,advertise);
3971 msi_free(advertise);
3974 strcatW(output,text);
3976 msi_reg_set_val_multi_str( hkey, qualifier, output );
3986 * At present I am ignorning the advertised components part of this and only
3987 * focusing on the qualified component sets
3989 static UINT ACTION_PublishComponents(MSIPACKAGE *package)
3993 static const WCHAR ExecSeqQuery[] =
3994 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3995 '`','P','u','b','l','i','s','h',
3996 'C','o','m','p','o','n','e','n','t','`',0};
3998 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3999 if (rc != ERROR_SUCCESS)
4000 return ERROR_SUCCESS;
4002 rc = MSI_IterateRecords(view, NULL, ITERATE_PublishComponent, package);
4003 msiobj_release(&view->hdr);
4008 static UINT ACTION_RemoveIniValues(MSIPACKAGE *package)
4010 static const WCHAR query[] =
4011 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
4012 'R','e','m','o','v','e','I','n','i','F','i','l','e',0 };
4013 MSIQUERY *view = NULL;
4017 rc = MSI_DatabaseOpenViewW(package->db, query, &view);
4018 if (rc == ERROR_SUCCESS)
4020 rc = MSI_IterateRecords(view, &count, NULL, package);
4022 FIXME("%lu ignored RemoveIniFile table values\n", count);
4023 msiobj_release(&view->hdr);
4026 return ERROR_SUCCESS;