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);
89 * consts and values used
91 static const WCHAR c_colon[] = {'C',':','\\',0};
93 const static WCHAR szCreateFolders[] =
94 {'C','r','e','a','t','e','F','o','l','d','e','r','s',0};
95 const static WCHAR szCostFinalize[] =
96 {'C','o','s','t','F','i','n','a','l','i','z','e',0};
97 const WCHAR szInstallFiles[] =
98 {'I','n','s','t','a','l','l','F','i','l','e','s',0};
99 const WCHAR szDuplicateFiles[] =
100 {'D','u','p','l','i','c','a','t','e','F','i','l','e','s',0};
101 const static WCHAR szWriteRegistryValues[] =
102 {'W','r','i','t','e','R','e','g','i','s','t','r','y',
103 'V','a','l','u','e','s',0};
104 const static WCHAR szCostInitialize[] =
105 {'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0};
106 const static WCHAR szFileCost[] =
107 {'F','i','l','e','C','o','s','t',0};
108 const static WCHAR szInstallInitialize[] =
109 {'I','n','s','t','a','l','l','I','n','i','t','i','a','l','i','z','e',0};
110 const static WCHAR szInstallValidate[] =
111 {'I','n','s','t','a','l','l','V','a','l','i','d','a','t','e',0};
112 const static WCHAR szLaunchConditions[] =
113 {'L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','s',0};
114 const static WCHAR szProcessComponents[] =
115 {'P','r','o','c','e','s','s','C','o','m','p','o','n','e','n','t','s',0};
116 const static WCHAR szRegisterTypeLibraries[] =
117 {'R','e','g','i','s','t','e','r','T','y','p','e',
118 'L','i','b','r','a','r','i','e','s',0};
119 const WCHAR szRegisterClassInfo[] =
120 {'R','e','g','i','s','t','e','r','C','l','a','s','s','I','n','f','o',0};
121 const WCHAR szRegisterProgIdInfo[] =
122 {'R','e','g','i','s','t','e','r','P','r','o','g','I','d','I','n','f','o',0};
123 const static WCHAR szCreateShortcuts[] =
124 {'C','r','e','a','t','e','S','h','o','r','t','c','u','t','s',0};
125 const static WCHAR szPublishProduct[] =
126 {'P','u','b','l','i','s','h','P','r','o','d','u','c','t',0};
127 const static WCHAR szWriteIniValues[] =
128 {'W','r','i','t','e','I','n','i','V','a','l','u','e','s',0};
129 const static WCHAR szSelfRegModules[] =
130 {'S','e','l','f','R','e','g','M','o','d','u','l','e','s',0};
131 const static WCHAR szPublishFeatures[] =
132 {'P','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0};
133 const static WCHAR szRegisterProduct[] =
134 {'R','e','g','i','s','t','e','r','P','r','o','d','u','c','t',0};
135 const static WCHAR szInstallExecute[] =
136 {'I','n','s','t','a','l','l','E','x','e','c','u','t','e',0};
137 const static WCHAR szInstallExecuteAgain[] =
138 {'I','n','s','t','a','l','l','E','x','e','c','u','t','e',
139 'A','g','a','i','n',0};
140 const static WCHAR szInstallFinalize[] =
141 {'I','n','s','t','a','l','l','F','i','n','a','l','i','z','e',0};
142 const static WCHAR szForceReboot[] =
143 {'F','o','r','c','e','R','e','b','o','o','t',0};
144 const static WCHAR szResolveSource[] =
145 {'R','e','s','o','l','v','e','S','o','u','r','c','e',0};
146 const WCHAR szAppSearch[] =
147 {'A','p','p','S','e','a','r','c','h',0};
148 const static WCHAR szAllocateRegistrySpace[] =
149 {'A','l','l','o','c','a','t','e','R','e','g','i','s','t','r','y',
150 'S','p','a','c','e',0};
151 const static WCHAR szBindImage[] =
152 {'B','i','n','d','I','m','a','g','e',0};
153 const static WCHAR szCCPSearch[] =
154 {'C','C','P','S','e','a','r','c','h',0};
155 const static WCHAR szDeleteServices[] =
156 {'D','e','l','e','t','e','S','e','r','v','i','c','e','s',0};
157 const static WCHAR szDisableRollback[] =
158 {'D','i','s','a','b','l','e','R','o','l','l','b','a','c','k',0};
159 const static WCHAR szExecuteAction[] =
160 {'E','x','e','c','u','t','e','A','c','t','i','o','n',0};
161 const WCHAR szFindRelatedProducts[] =
162 {'F','i','n','d','R','e','l','a','t','e','d',
163 'P','r','o','d','u','c','t','s',0};
164 const static WCHAR szInstallAdminPackage[] =
165 {'I','n','s','t','a','l','l','A','d','m','i','n',
166 'P','a','c','k','a','g','e',0};
167 const static WCHAR szInstallSFPCatalogFile[] =
168 {'I','n','s','t','a','l','l','S','F','P','C','a','t','a','l','o','g',
170 const static WCHAR szIsolateComponents[] =
171 {'I','s','o','l','a','t','e','C','o','m','p','o','n','e','n','t','s',0};
172 const WCHAR szMigrateFeatureStates[] =
173 {'M','i','g','r','a','t','e','F','e','a','t','u','r','e',
174 'S','t','a','t','e','s',0};
175 const WCHAR szMoveFiles[] =
176 {'M','o','v','e','F','i','l','e','s',0};
177 const static WCHAR szMsiPublishAssemblies[] =
178 {'M','s','i','P','u','b','l','i','s','h',
179 'A','s','s','e','m','b','l','i','e','s',0};
180 const static WCHAR szMsiUnpublishAssemblies[] =
181 {'M','s','i','U','n','p','u','b','l','i','s','h',
182 'A','s','s','e','m','b','l','i','e','s',0};
183 const static WCHAR szInstallODBC[] =
184 {'I','n','s','t','a','l','l','O','D','B','C',0};
185 const static WCHAR szInstallServices[] =
186 {'I','n','s','t','a','l','l','S','e','r','v','i','c','e','s',0};
187 const WCHAR szPatchFiles[] =
188 {'P','a','t','c','h','F','i','l','e','s',0};
189 const static WCHAR szPublishComponents[] =
190 {'P','u','b','l','i','s','h','C','o','m','p','o','n','e','n','t','s',0};
191 const static WCHAR szRegisterComPlus[] =
192 {'R','e','g','i','s','t','e','r','C','o','m','P','l','u','s',0};
193 const WCHAR szRegisterExtensionInfo[] =
194 {'R','e','g','i','s','t','e','r','E','x','t','e','n','s','i','o','n',
196 const static WCHAR szRegisterFonts[] =
197 {'R','e','g','i','s','t','e','r','F','o','n','t','s',0};
198 const WCHAR szRegisterMIMEInfo[] =
199 {'R','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0};
200 const static WCHAR szRegisterUser[] =
201 {'R','e','g','i','s','t','e','r','U','s','e','r',0};
202 const WCHAR szRemoveDuplicateFiles[] =
203 {'R','e','m','o','v','e','D','u','p','l','i','c','a','t','e',
204 'F','i','l','e','s',0};
205 const static WCHAR szRemoveEnvironmentStrings[] =
206 {'R','e','m','o','v','e','E','n','v','i','r','o','n','m','e','n','t',
207 'S','t','r','i','n','g','s',0};
208 const WCHAR szRemoveExistingProducts[] =
209 {'R','e','m','o','v','e','E','x','i','s','t','i','n','g',
210 'P','r','o','d','u','c','t','s',0};
211 const WCHAR szRemoveFiles[] =
212 {'R','e','m','o','v','e','F','i','l','e','s',0};
213 const static WCHAR szRemoveFolders[] =
214 {'R','e','m','o','v','e','F','o','l','d','e','r','s',0};
215 const static WCHAR szRemoveIniValues[] =
216 {'R','e','m','o','v','e','I','n','i','V','a','l','u','e','s',0};
217 const static WCHAR szRemoveODBC[] =
218 {'R','e','m','o','v','e','O','D','B','C',0};
219 const static WCHAR szRemoveRegistryValues[] =
220 {'R','e','m','o','v','e','R','e','g','i','s','t','r','y',
221 'V','a','l','u','e','s',0};
222 const static WCHAR szRemoveShortcuts[] =
223 {'R','e','m','o','v','e','S','h','o','r','t','c','u','t','s',0};
224 const static WCHAR szRMCCPSearch[] =
225 {'R','M','C','C','P','S','e','a','r','c','h',0};
226 const static WCHAR szScheduleReboot[] =
227 {'S','c','h','e','d','u','l','e','R','e','b','o','o','t',0};
228 const static WCHAR szSelfUnregModules[] =
229 {'S','e','l','f','U','n','r','e','g','M','o','d','u','l','e','s',0};
230 const static WCHAR szSetODBCFolders[] =
231 {'S','e','t','O','D','B','C','F','o','l','d','e','r','s',0};
232 const static WCHAR szStartServices[] =
233 {'S','t','a','r','t','S','e','r','v','i','c','e','s',0};
234 const static WCHAR szStopServices[] =
235 {'S','t','o','p','S','e','r','v','i','c','e','s',0};
236 const static WCHAR szUnpublishComponents[] =
237 {'U','n','p','u','b','l','i','s','h',
238 'C','o','m','p','o','n','e','n','t','s',0};
239 const static WCHAR szUnpublishFeatures[] =
240 {'U','n','p','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0};
241 const WCHAR szUnregisterClassInfo[] =
242 {'U','n','r','e','g','i','s','t','e','r','C','l','a','s','s',
244 const static WCHAR szUnregisterComPlus[] =
245 {'U','n','r','e','g','i','s','t','e','r','C','o','m','P','l','u','s',0};
246 const WCHAR szUnregisterExtensionInfo[] =
247 {'U','n','r','e','g','i','s','t','e','r',
248 'E','x','t','e','n','s','i','o','n','I','n','f','o',0};
249 const static WCHAR szUnregisterFonts[] =
250 {'U','n','r','e','g','i','s','t','e','r','F','o','n','t','s',0};
251 const WCHAR szUnregisterMIMEInfo[] =
252 {'U','n','r','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0};
253 const WCHAR szUnregisterProgIdInfo[] =
254 {'U','n','r','e','g','i','s','t','e','r','P','r','o','g','I','d',
256 const static WCHAR szUnregisterTypeLibraries[] =
257 {'U','n','r','e','g','i','s','t','e','r','T','y','p','e',
258 'L','i','b','r','a','r','i','e','s',0};
259 const static WCHAR szValidateProductID[] =
260 {'V','a','l','i','d','a','t','e','P','r','o','d','u','c','t','I','D',0};
261 const static WCHAR szWriteEnvironmentStrings[] =
262 {'W','r','i','t','e','E','n','v','i','r','o','n','m','e','n','t',
263 'S','t','r','i','n','g','s',0};
267 STANDARDACTIONHANDLER handler;
270 static struct _actions StandardActions[] = {
271 { szAllocateRegistrySpace, NULL},
272 { szAppSearch, ACTION_AppSearch },
273 { szBindImage, NULL},
274 { szCCPSearch, NULL},
275 { szCostFinalize, ACTION_CostFinalize },
276 { szCostInitialize, ACTION_CostInitialize },
277 { szCreateFolders, ACTION_CreateFolders },
278 { szCreateShortcuts, ACTION_CreateShortcuts },
279 { szDeleteServices, NULL},
280 { szDisableRollback, NULL},
281 { szDuplicateFiles, ACTION_DuplicateFiles },
282 { szExecuteAction, ACTION_ExecuteAction },
283 { szFileCost, ACTION_FileCost },
284 { szFindRelatedProducts, ACTION_FindRelatedProducts },
285 { szForceReboot, ACTION_ForceReboot },
286 { szInstallAdminPackage, NULL},
287 { szInstallExecute, ACTION_InstallExecute },
288 { szInstallExecuteAgain, ACTION_InstallExecute },
289 { szInstallFiles, ACTION_InstallFiles},
290 { szInstallFinalize, ACTION_InstallFinalize },
291 { szInstallInitialize, ACTION_InstallInitialize },
292 { szInstallSFPCatalogFile, NULL},
293 { szInstallValidate, ACTION_InstallValidate },
294 { szIsolateComponents, NULL},
295 { szLaunchConditions, ACTION_LaunchConditions },
296 { szMigrateFeatureStates, NULL},
297 { szMoveFiles, NULL},
298 { szMsiPublishAssemblies, NULL},
299 { szMsiUnpublishAssemblies, NULL},
300 { szInstallODBC, NULL},
301 { szInstallServices, NULL},
302 { szPatchFiles, NULL},
303 { szProcessComponents, ACTION_ProcessComponents },
304 { szPublishComponents, ACTION_PublishComponents },
305 { szPublishFeatures, ACTION_PublishFeatures },
306 { szPublishProduct, ACTION_PublishProduct },
307 { szRegisterClassInfo, ACTION_RegisterClassInfo },
308 { szRegisterComPlus, NULL},
309 { szRegisterExtensionInfo, ACTION_RegisterExtensionInfo },
310 { szRegisterFonts, ACTION_RegisterFonts },
311 { szRegisterMIMEInfo, ACTION_RegisterMIMEInfo },
312 { szRegisterProduct, ACTION_RegisterProduct },
313 { szRegisterProgIdInfo, ACTION_RegisterProgIdInfo },
314 { szRegisterTypeLibraries, ACTION_RegisterTypeLibraries },
315 { szRegisterUser, ACTION_RegisterUser},
316 { szRemoveDuplicateFiles, NULL},
317 { szRemoveEnvironmentStrings, NULL},
318 { szRemoveExistingProducts, NULL},
319 { szRemoveFiles, NULL},
320 { szRemoveFolders, NULL},
321 { szRemoveIniValues, NULL},
322 { szRemoveODBC, NULL},
323 { szRemoveRegistryValues, NULL},
324 { szRemoveShortcuts, NULL},
325 { szResolveSource, ACTION_ResolveSource},
326 { szRMCCPSearch, NULL},
327 { szScheduleReboot, NULL},
328 { szSelfRegModules, ACTION_SelfRegModules },
329 { szSelfUnregModules, NULL},
330 { szSetODBCFolders, NULL},
331 { szStartServices, NULL},
332 { szStopServices, NULL},
333 { szUnpublishComponents, NULL},
334 { szUnpublishFeatures, NULL},
335 { szUnregisterClassInfo, NULL},
336 { szUnregisterComPlus, NULL},
337 { szUnregisterExtensionInfo, NULL},
338 { szUnregisterFonts, NULL},
339 { szUnregisterMIMEInfo, NULL},
340 { szUnregisterProgIdInfo, NULL},
341 { szUnregisterTypeLibraries, NULL},
342 { szValidateProductID, NULL},
343 { szWriteEnvironmentStrings, NULL},
344 { szWriteIniValues, ACTION_WriteIniValues },
345 { szWriteRegistryValues, ACTION_WriteRegistryValues},
350 /********************************************************
352 ********************************************************/
354 static void ce_actiontext(MSIPACKAGE* package, LPCWSTR action)
356 static const WCHAR szActionText[] =
357 {'A','c','t','i','o','n','T','e','x','t',0};
360 row = MSI_CreateRecord(1);
361 MSI_RecordSetStringW(row,1,action);
362 ControlEvent_FireSubscribedEvent(package,szActionText, row);
363 msiobj_release(&row->hdr);
366 static void ui_actionstart(MSIPACKAGE *package, LPCWSTR action)
368 static const WCHAR template_s[]=
369 {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ', '%','s',
371 static const WCHAR format[] =
372 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
373 static const WCHAR Query_t[] =
374 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
375 '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
376 'W','H','E','R','E', ' ','`','A','c','t','i','o','n','`',' ','=',
377 ' ','\'','%','s','\'',0};
384 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
386 row = MSI_QueryGetRecord( package->db, Query_t, action );
390 ActionText = MSI_RecordGetString(row,2);
391 deformat_string(package, ActionText, &deformated);
393 sprintfW(message,template_s,timet,action,deformated);
394 ce_actiontext(package, deformated);
395 msiobj_release(&row->hdr);
397 row = MSI_CreateRecord(1);
398 MSI_RecordSetStringW(row,1,message);
400 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONSTART, row);
401 msiobj_release(&row->hdr);
402 msi_free(deformated);
405 static void ui_actioninfo(MSIPACKAGE *package, LPCWSTR action, BOOL start,
409 static const WCHAR template_s[]=
410 {'A','c','t','i','o','n',' ','s','t','a','r','t',' ','%','s',':',' ',
412 static const WCHAR template_e[]=
413 {'A','c','t','i','o','n',' ','e','n','d','e','d',' ','%','s',':',' ',
414 '%','s', '.',' ','R','e','t','u','r','n',' ','v','a','l','u','e',' ',
416 static const WCHAR format[] =
417 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
421 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
423 sprintfW(message,template_s,timet,action);
425 sprintfW(message,template_e,timet,action,rc);
427 row = MSI_CreateRecord(1);
428 MSI_RecordSetStringW(row,1,message);
430 MSI_ProcessMessage(package, INSTALLMESSAGE_INFO, row);
431 msiobj_release(&row->hdr);
434 /****************************************************
435 * TOP level entry points
436 *****************************************************/
438 UINT ACTION_DoTopLevelINSTALL(MSIPACKAGE *package, LPCWSTR szPackagePath,
439 LPCWSTR szCommandLine, LPCWSTR msiFilePath)
445 static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0};
446 static const WCHAR szAction[] = {'A','C','T','I','O','N',0};
447 static const WCHAR szInstall[] = {'I','N','S','T','A','L','L',0};
449 MSI_SetPropertyW(package, szAction, szInstall);
451 package->script = msi_alloc(sizeof(MSISCRIPT));
452 memset(package->script,0,sizeof(MSISCRIPT));
454 package->script->InWhatSequence = SEQUENCE_INSTALL;
456 package->msiFilePath= strdupW(msiFilePath);
460 LPWSTR p, check, path;
462 package->PackagePath = strdupW(szPackagePath);
463 path = strdupW(szPackagePath);
464 p = strrchrW(path,'\\');
473 path = msi_alloc(MAX_PATH*sizeof(WCHAR));
474 GetCurrentDirectoryW(MAX_PATH,path);
478 check = msi_dup_property( package, cszSourceDir );
480 MSI_SetPropertyW(package, cszSourceDir, path);
488 ptr = (LPWSTR)szCommandLine;
495 TRACE("Looking at %s\n",debugstr_w(ptr));
497 ptr2 = strchrW(ptr,'=');
503 while (*ptr == ' ') ptr++;
505 prop = msi_alloc((len+1)*sizeof(WCHAR));
506 memcpy(prop,ptr,len*sizeof(WCHAR));
512 while (*ptr && (quote || (!quote && *ptr!=' ')))
525 val = msi_alloc((len+1)*sizeof(WCHAR));
526 memcpy(val,ptr2,len*sizeof(WCHAR));
529 if (strlenW(prop) > 0)
531 TRACE("Found commandline property (%s) = (%s)\n",
532 debugstr_w(prop), debugstr_w(val));
533 MSI_SetPropertyW(package,prop,val);
543 if (MSI_GetPropertyW(package,szUILevel,buffer,&sz) == ERROR_SUCCESS)
545 if (atoiW(buffer) >= INSTALLUILEVEL_REDUCED)
547 package->script->InWhatSequence |= SEQUENCE_UI;
548 rc = ACTION_ProcessUISequence(package);
550 if (rc == ERROR_SUCCESS)
552 package->script->InWhatSequence |= SEQUENCE_EXEC;
553 rc = ACTION_ProcessExecSequence(package,TRUE);
557 rc = ACTION_ProcessExecSequence(package,FALSE);
560 rc = ACTION_ProcessExecSequence(package,FALSE);
564 /* install was halted but should be considered a success */
568 package->script->CurrentlyScripting= FALSE;
570 /* process the ending type action */
571 if (rc == ERROR_SUCCESS)
572 ACTION_PerformActionSequence(package,-1,ui);
573 else if (rc == ERROR_INSTALL_USEREXIT)
574 ACTION_PerformActionSequence(package,-2,ui);
575 else if (rc == ERROR_INSTALL_SUSPEND)
576 ACTION_PerformActionSequence(package,-4,ui);
578 ACTION_PerformActionSequence(package,-3,ui);
580 /* finish up running custom actions */
581 ACTION_FinishCustomActions(package);
586 static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq, BOOL UI)
588 UINT rc = ERROR_SUCCESS;
590 static const WCHAR ExecSeqQuery[] =
591 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
592 '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
593 'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
594 '`','S','e','q','u','e','n','c','e','`',' ', '=',' ','%','i',0};
596 static const WCHAR UISeqQuery[] =
597 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
598 '`','I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e',
599 '`', ' ', 'W','H','E','R','E',' ','`','S','e','q','u','e','n','c','e','`',
600 ' ', '=',' ','%','i',0};
603 row = MSI_QueryGetRecord(package->db, UISeqQuery, seq);
605 row = MSI_QueryGetRecord(package->db, ExecSeqQuery, seq);
609 LPCWSTR action, cond;
611 TRACE("Running the actions\n");
613 /* check conditions */
614 cond = MSI_RecordGetString(row,2);
617 /* this is a hack to skip errors in the condition code */
618 if (MSI_EvaluateConditionW(package, cond) == MSICONDITION_FALSE)
622 action = MSI_RecordGetString(row,1);
625 ERR("failed to fetch action\n");
626 rc = ERROR_FUNCTION_FAILED;
631 rc = ACTION_PerformUIAction(package,action);
633 rc = ACTION_PerformAction(package,action,FALSE);
635 msiobj_release(&row->hdr);
646 } iterate_action_param;
648 static UINT ITERATE_Actions(MSIRECORD *row, LPVOID param)
650 iterate_action_param *iap= (iterate_action_param*)param;
652 LPCWSTR cond, action;
654 action = MSI_RecordGetString(row,1);
657 ERR("Error is retrieving action name\n");
658 return ERROR_FUNCTION_FAILED;
661 /* check conditions */
662 cond = MSI_RecordGetString(row,2);
665 /* this is a hack to skip errors in the condition code */
666 if (MSI_EvaluateConditionW(iap->package, cond) == MSICONDITION_FALSE)
668 TRACE("Skipping action: %s (condition is false)\n",
670 return ERROR_SUCCESS;
675 rc = ACTION_PerformUIAction(iap->package,action);
677 rc = ACTION_PerformAction(iap->package,action,FALSE);
679 msi_dialog_check_messages( NULL );
681 if (iap->package->CurrentInstallState != ERROR_SUCCESS )
682 rc = iap->package->CurrentInstallState;
684 if (rc == ERROR_FUNCTION_NOT_CALLED)
687 if (rc != ERROR_SUCCESS)
688 ERR("Execution halted due to error (%i)\n",rc);
693 UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode )
697 static const WCHAR query[] =
698 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
700 ' ','W','H','E','R','E',' ',
701 '`','S','e','q','u','e','n','c','e','`',' ',
702 '>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
703 '`','S','e','q','u','e','n','c','e','`',0};
704 iterate_action_param iap;
707 * FIXME: probably should be checking UILevel in the
708 * ACTION_PerformUIAction/ACTION_PerformAction
709 * rather than saving the UI level here. Those
710 * two functions can be merged too.
712 iap.package = package;
715 TRACE("%p %s %i\n", package, debugstr_w(szTable), iSequenceMode );
717 r = MSI_OpenQuery( package->db, &view, query, szTable );
718 if (r == ERROR_SUCCESS)
720 r = MSI_IterateRecords( view, NULL, ITERATE_Actions, &iap );
721 msiobj_release(&view->hdr);
727 static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran)
731 static const WCHAR ExecSeqQuery[] =
732 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
733 '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
734 'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
735 '`','S','e','q','u','e','n','c','e','`',' ', '>',' ','%','i',' ',
736 'O','R','D','E','R',' ', 'B','Y',' ',
737 '`','S','e','q','u','e','n','c','e','`',0 };
739 static const WCHAR IVQuery[] =
740 {'S','E','L','E','C','T',' ','`','S','e','q','u','e','n','c','e','`',
741 ' ', 'F','R','O','M',' ','`','I','n','s','t','a','l','l',
742 'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e','`',' ',
743 'W','H','E','R','E',' ','`','A','c','t','i','o','n','`',' ','=',
744 ' ','\'', 'I','n','s','t','a','l','l',
745 'V','a','l','i','d','a','t','e','\'', 0};
747 iterate_action_param iap;
749 iap.package = package;
752 if (package->script->ExecuteSequenceRun)
754 TRACE("Execute Sequence already Run\n");
755 return ERROR_SUCCESS;
758 package->script->ExecuteSequenceRun = TRUE;
760 /* get the sequence number */
763 row = MSI_QueryGetRecord(package->db, IVQuery);
765 return ERROR_FUNCTION_FAILED;
766 seq = MSI_RecordGetInteger(row,1);
767 msiobj_release(&row->hdr);
770 rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, seq);
771 if (rc == ERROR_SUCCESS)
773 TRACE("Running the actions\n");
775 rc = MSI_IterateRecords(view, NULL, ITERATE_Actions, &iap);
776 msiobj_release(&view->hdr);
782 static UINT ACTION_ProcessUISequence(MSIPACKAGE *package)
786 static const WCHAR ExecSeqQuery [] =
787 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
788 '`','I','n','s','t','a','l','l',
789 'U','I','S','e','q','u','e','n','c','e','`',
790 ' ','W','H','E','R','E',' ',
791 '`','S','e','q','u','e','n','c','e','`',' ',
792 '>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
793 '`','S','e','q','u','e','n','c','e','`',0};
794 iterate_action_param iap;
796 iap.package = package;
799 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
801 if (rc == ERROR_SUCCESS)
803 TRACE("Running the actions \n");
805 rc = MSI_IterateRecords(view, NULL, ITERATE_Actions, &iap);
806 msiobj_release(&view->hdr);
812 /********************************************************
813 * ACTION helper functions and functions that perform the actions
814 *******************************************************/
815 static BOOL ACTION_HandleStandardAction(MSIPACKAGE *package, LPCWSTR action,
816 UINT* rc, BOOL force )
822 if (!run && !package->script->CurrentlyScripting)
827 if (strcmpW(action,szInstallFinalize) == 0 ||
828 strcmpW(action,szInstallExecute) == 0 ||
829 strcmpW(action,szInstallExecuteAgain) == 0)
834 while (StandardActions[i].action != NULL)
836 if (strcmpW(StandardActions[i].action, action)==0)
840 ui_actioninfo(package, action, TRUE, 0);
841 *rc = schedule_action(package,INSTALL_SCRIPT,action);
842 ui_actioninfo(package, action, FALSE, *rc);
846 ui_actionstart(package, action);
847 if (StandardActions[i].handler)
849 *rc = StandardActions[i].handler(package);
853 FIXME("unhandled standard action %s\n",debugstr_w(action));
865 static BOOL ACTION_HandleCustomAction( MSIPACKAGE* package, LPCWSTR action,
866 UINT* rc, BOOL force )
871 arc = ACTION_CustomAction(package,action, force);
873 if (arc != ERROR_CALL_NOT_IMPLEMENTED)
882 * A lot of actions are really important even if they don't do anything
883 * explicit... Lots of properties are set at the beginning of the installation
884 * CostFinalize does a bunch of work to translate the directories and such
886 * But until I get write access to the database that is hard, so I am going to
887 * hack it to see if I can get something to run.
889 UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, BOOL force)
891 UINT rc = ERROR_SUCCESS;
894 TRACE("Performing action (%s)\n",debugstr_w(action));
896 handled = ACTION_HandleStandardAction(package, action, &rc, force);
899 handled = ACTION_HandleCustomAction(package, action, &rc, force);
903 FIXME("unhandled msi action %s\n",debugstr_w(action));
904 rc = ERROR_FUNCTION_NOT_CALLED;
910 UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action)
912 UINT rc = ERROR_SUCCESS;
913 BOOL handled = FALSE;
915 TRACE("Performing action (%s)\n",debugstr_w(action));
917 handled = ACTION_HandleStandardAction(package, action, &rc,TRUE);
920 handled = ACTION_HandleCustomAction(package, action, &rc, FALSE);
922 if( !handled && ACTION_DialogBox(package,action) == ERROR_SUCCESS )
927 FIXME("unhandled msi action %s\n",debugstr_w(action));
928 rc = ERROR_FUNCTION_NOT_CALLED;
936 * Actual Action Handlers
939 static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param)
941 MSIPACKAGE *package = (MSIPACKAGE*)param;
947 dir = MSI_RecordGetString(row,1);
950 ERR("Unable to get folder id \n");
951 return ERROR_SUCCESS;
954 full_path = resolve_folder(package,dir,FALSE,FALSE,&folder);
957 ERR("Unable to resolve folder id %s\n",debugstr_w(dir));
958 return ERROR_SUCCESS;
961 TRACE("Folder is %s\n",debugstr_w(full_path));
964 uirow = MSI_CreateRecord(1);
965 MSI_RecordSetStringW(uirow,1,full_path);
966 ui_actiondata(package,szCreateFolders,uirow);
967 msiobj_release( &uirow->hdr );
969 if (folder->State == 0)
970 create_full_pathW(full_path);
975 return ERROR_SUCCESS;
980 * Also we cannot enable/disable components either, so for now I am just going
981 * to do all the directories for all the components.
983 static UINT ACTION_CreateFolders(MSIPACKAGE *package)
985 static const WCHAR ExecSeqQuery[] =
986 {'S','E','L','E','C','T',' ',
987 '`','D','i','r','e','c','t','o','r','y','_','`',
988 ' ','F','R','O','M',' ',
989 '`','C','r','e','a','t','e','F','o','l','d','e','r','`',0 };
993 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view );
994 if (rc != ERROR_SUCCESS)
995 return ERROR_SUCCESS;
997 rc = MSI_IterateRecords(view, NULL, ITERATE_CreateFolders, package);
998 msiobj_release(&view->hdr);
1003 static MSICOMPONENT* load_component( MSIRECORD * row )
1007 comp = msi_alloc_zero( sizeof(MSICOMPONENT) );
1011 /* fill in the data */
1012 comp->Component = load_dynamic_stringW( row, 1 );
1014 TRACE("Loading Component %s\n", debugstr_w(comp->Component));
1016 comp->ComponentId = load_dynamic_stringW( row, 2 );
1017 comp->Directory = load_dynamic_stringW( row, 3 );
1018 comp->Attributes = MSI_RecordGetInteger(row,4);
1019 comp->Condition = load_dynamic_stringW( row, 5 );
1020 comp->KeyPath = load_dynamic_stringW( row, 6 );
1022 comp->Installed = INSTALLSTATE_ABSENT;
1023 comp->Action = INSTALLSTATE_UNKNOWN;
1024 comp->ActionRequest = INSTALLSTATE_UNKNOWN;
1026 comp->Enabled = TRUE;
1032 MSIPACKAGE *package;
1033 MSIFEATURE *feature;
1036 static UINT add_feature_component( MSIFEATURE *feature, MSICOMPONENT *comp )
1040 cl = msi_alloc( sizeof (*cl) );
1042 return ERROR_NOT_ENOUGH_MEMORY;
1043 cl->component = comp;
1044 list_add_tail( &feature->Components, &cl->entry );
1046 return ERROR_SUCCESS;
1049 static UINT iterate_component_check( MSIRECORD *row, LPVOID param )
1051 _ilfs* ilfs= (_ilfs*)param;
1052 MSIPACKAGE *package = ilfs->package;
1053 MSIFEATURE *feature = ilfs->feature;
1056 comp = load_component( row );
1058 return ERROR_FUNCTION_FAILED;
1060 list_add_tail( &package->components, &comp->entry );
1061 add_feature_component( feature, comp );
1063 TRACE("Loaded new component %p\n", comp);
1065 return ERROR_SUCCESS;
1068 static UINT iterate_load_featurecomponents(MSIRECORD *row, LPVOID param)
1070 _ilfs* ilfs= (_ilfs*)param;
1075 static const WCHAR Query[] =
1076 {'S','E','L','E','C','T',' ','*',' ','F','R', 'O','M',' ',
1077 '`','C','o','m','p','o','n','e','n','t','`',' ',
1078 'W','H','E','R','E',' ',
1079 '`','C','o','m','p','o','n','e','n','t','`',' ',
1080 '=','\'','%','s','\'',0};
1082 component = MSI_RecordGetString(row,1);
1084 /* check to see if the component is already loaded */
1085 comp = get_loaded_component( ilfs->package, component );
1088 TRACE("Component %s already loaded\n", debugstr_w(component) );
1089 add_feature_component( ilfs->feature, comp );
1090 return ERROR_SUCCESS;
1093 rc = MSI_OpenQuery(ilfs->package->db, &view, Query, component);
1094 if (rc != ERROR_SUCCESS)
1095 return ERROR_SUCCESS;
1097 rc = MSI_IterateRecords(view, NULL, iterate_component_check, ilfs);
1098 msiobj_release( &view->hdr );
1100 return ERROR_SUCCESS;
1103 static UINT load_feature(MSIRECORD * row, LPVOID param)
1105 MSIPACKAGE* package = (MSIPACKAGE*)param;
1106 MSIFEATURE* feature;
1107 static const WCHAR Query1[] =
1108 {'S','E','L','E','C','T',' ',
1109 '`','C','o','m','p','o','n','e','n','t','_','`',
1110 ' ','F','R','O','M',' ','`','F','e','a','t','u','r','e',
1111 'C','o','m','p','o','n','e','n','t','s','`',' ',
1112 'W','H','E','R','E',' ',
1113 '`','F','e', 'a','t','u','r','e','_','`',' ','=','\'','%','s','\'',0};
1118 /* fill in the data */
1120 feature = msi_alloc_zero( sizeof (MSIFEATURE) );
1122 return ERROR_NOT_ENOUGH_MEMORY;
1124 list_init( &feature->Components );
1126 feature->Feature = load_dynamic_stringW( row, 1 );
1128 TRACE("Loading feature %s\n",debugstr_w(feature->Feature));
1130 feature->Feature_Parent = load_dynamic_stringW( row, 2 );
1131 feature->Title = load_dynamic_stringW( row, 3 );
1132 feature->Description = load_dynamic_stringW( row, 4 );
1134 if (!MSI_RecordIsNull(row,5))
1135 feature->Display = MSI_RecordGetInteger(row,5);
1137 feature->Level= MSI_RecordGetInteger(row,6);
1138 feature->Directory = load_dynamic_stringW( row, 7 );
1139 feature->Attributes = MSI_RecordGetInteger(row,8);
1141 feature->Installed = INSTALLSTATE_ABSENT;
1142 feature->Action = INSTALLSTATE_UNKNOWN;
1143 feature->ActionRequest = INSTALLSTATE_UNKNOWN;
1145 list_add_tail( &package->features, &feature->entry );
1147 /* load feature components */
1149 rc = MSI_OpenQuery( package->db, &view, Query1, feature->Feature );
1150 if (rc != ERROR_SUCCESS)
1151 return ERROR_SUCCESS;
1153 ilfs.package = package;
1154 ilfs.feature = feature;
1156 MSI_IterateRecords(view, NULL, iterate_load_featurecomponents , &ilfs);
1157 msiobj_release(&view->hdr);
1159 return ERROR_SUCCESS;
1162 static UINT load_file(MSIRECORD *row, LPVOID param)
1164 MSIPACKAGE* package = (MSIPACKAGE*)param;
1168 /* fill in the data */
1170 file = msi_alloc_zero( sizeof (MSIFILE) );
1172 return ERROR_NOT_ENOUGH_MEMORY;
1174 file->File = load_dynamic_stringW( row, 1 );
1176 component = MSI_RecordGetString( row, 2 );
1177 file->Component = get_loaded_component( package, component );
1179 if (!file->Component)
1180 ERR("Unfound Component %s\n",debugstr_w(component));
1182 file->FileName = load_dynamic_stringW( row, 3 );
1183 reduce_to_longfilename( file->FileName );
1185 file->ShortName = load_dynamic_stringW( row, 3 );
1186 reduce_to_shortfilename( file->ShortName );
1188 file->FileSize = MSI_RecordGetInteger( row, 4 );
1189 file->Version = load_dynamic_stringW( row, 5 );
1190 file->Language = load_dynamic_stringW( row, 6 );
1191 file->Attributes = MSI_RecordGetInteger( row, 7 );
1192 file->Sequence = MSI_RecordGetInteger( row, 8 );
1196 TRACE("File Loaded (%s)\n",debugstr_w(file->File));
1198 list_add_tail( &package->files, &file->entry );
1200 return ERROR_SUCCESS;
1203 static UINT load_all_files(MSIPACKAGE *package)
1207 static const WCHAR Query[] =
1208 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
1209 '`','F','i','l','e','`',' ', 'O','R','D','E','R',' ','B','Y',' ',
1210 '`','S','e','q','u','e','n','c','e','`', 0};
1213 return ERROR_INVALID_HANDLE;
1215 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
1216 if (rc != ERROR_SUCCESS)
1217 return ERROR_SUCCESS;
1219 rc = MSI_IterateRecords(view, NULL, load_file, package);
1220 msiobj_release(&view->hdr);
1222 return ERROR_SUCCESS;
1227 * I am not doing any of the costing functionality yet.
1228 * Mostly looking at doing the Component and Feature loading
1230 * The native MSI does A LOT of modification to tables here. Mostly adding
1231 * a lot of temporary columns to the Feature and Component tables.
1233 * note: Native msi also tracks the short filename. But I am only going to
1234 * track the long ones. Also looking at this directory table
1235 * it appears that the directory table does not get the parents
1236 * resolved base on property only based on their entries in the
1239 static UINT ACTION_CostInitialize(MSIPACKAGE *package)
1243 static const WCHAR Query_all[] =
1244 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
1245 '`','F','e','a','t','u','r','e','`',0};
1246 static const WCHAR szCosting[] =
1247 {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
1248 static const WCHAR szZero[] = { '0', 0 };
1252 MSI_GetPropertyW(package, szCosting, buffer, &sz);
1254 return ERROR_SUCCESS;
1256 MSI_SetPropertyW(package, szCosting, szZero);
1257 MSI_SetPropertyW(package, cszRootDrive , c_colon);
1259 rc = MSI_DatabaseOpenViewW(package->db,Query_all,&view);
1260 if (rc != ERROR_SUCCESS)
1263 rc = MSI_IterateRecords(view, NULL, load_feature, package);
1264 msiobj_release(&view->hdr);
1266 load_all_files(package);
1268 return ERROR_SUCCESS;
1271 static UINT execute_script(MSIPACKAGE *package, UINT script )
1274 UINT rc = ERROR_SUCCESS;
1276 TRACE("Executing Script %i\n",script);
1278 for (i = 0; i < package->script->ActionCount[script]; i++)
1281 action = package->script->Actions[script][i];
1282 ui_actionstart(package, action);
1283 TRACE("Executing Action (%s)\n",debugstr_w(action));
1284 rc = ACTION_PerformAction(package, action, TRUE);
1285 msi_free(package->script->Actions[script][i]);
1286 if (rc != ERROR_SUCCESS)
1289 msi_free(package->script->Actions[script]);
1291 package->script->ActionCount[script] = 0;
1292 package->script->Actions[script] = NULL;
1296 static UINT ACTION_FileCost(MSIPACKAGE *package)
1298 return ERROR_SUCCESS;
1302 static MSIFOLDER *load_folder( MSIPACKAGE *package, LPCWSTR dir )
1304 static const WCHAR Query[] =
1305 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1306 '`','D','i','r','e','c', 't','o','r','y','`',' ',
1307 'W','H','E','R','E',' ', '`', 'D','i','r','e','c','t', 'o','r','y','`',
1308 ' ','=',' ','\'','%','s','\'',
1310 LPWSTR ptargetdir, targetdir, srcdir;
1312 LPWSTR shortname = NULL;
1313 MSIRECORD * row = 0;
1316 TRACE("Looking for dir %s\n",debugstr_w(dir));
1318 folder = get_loaded_folder( package, dir );
1322 TRACE("Working to load %s\n",debugstr_w(dir));
1324 folder = msi_alloc_zero( sizeof (MSIFOLDER) );
1328 folder->Directory = strdupW(dir);
1330 row = MSI_QueryGetRecord(package->db, Query, dir);
1334 ptargetdir = targetdir = load_dynamic_stringW(row,3);
1336 /* split src and target dir */
1337 if (strchrW(targetdir,':'))
1339 srcdir=strchrW(targetdir,':');
1346 /* for now only pick long filename versions */
1347 if (strchrW(targetdir,'|'))
1349 shortname = targetdir;
1350 targetdir = strchrW(targetdir,'|');
1354 /* for the sourcedir pick the short filename */
1355 if (srcdir && strchrW(srcdir,'|'))
1357 LPWSTR p = strchrW(srcdir,'|');
1361 /* now check for root dirs */
1362 if (targetdir[0] == '.' && targetdir[1] == 0)
1367 TRACE(" TargetDefault = %s\n",debugstr_w(targetdir));
1368 msi_free( folder->TargetDefault);
1369 folder->TargetDefault = strdupW(targetdir);
1373 folder->SourceDefault = strdupW(srcdir);
1375 folder->SourceDefault = strdupW(shortname);
1377 folder->SourceDefault = strdupW(targetdir);
1378 msi_free(ptargetdir);
1379 TRACE(" SourceDefault = %s\n", debugstr_w( folder->SourceDefault ));
1381 parent = MSI_RecordGetString(row,2);
1384 folder->Parent = load_folder( package, parent );
1385 if ( folder->Parent )
1386 TRACE("loaded parent %p %s\n", folder->Parent,
1387 debugstr_w(folder->Parent->Directory));
1389 ERR("failed to load parent folder %s\n", debugstr_w(parent));
1392 folder->Property = msi_dup_property( package, dir );
1394 msiobj_release(&row->hdr);
1396 list_add_tail( &package->folders, &folder->entry );
1398 TRACE("%s returning %p\n",debugstr_w(dir),folder);
1403 /* scan for and update current install states */
1404 static void ACTION_UpdateInstallStates(MSIPACKAGE *package)
1407 MSIFEATURE *feature;
1409 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
1412 res = MsiGetComponentPathW( package->ProductCode,
1413 comp->ComponentId, NULL, NULL);
1415 res = INSTALLSTATE_ABSENT;
1416 comp->Installed = res;
1419 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1422 INSTALLSTATE res = -10;
1424 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
1426 comp= cl->component;
1429 res = comp->Installed;
1432 if (res == comp->Installed)
1435 if (res != comp->Installed)
1436 res = INSTALLSTATE_INCOMPLETE;
1439 feature->Installed = res;
1443 static BOOL process_state_property (MSIPACKAGE* package, LPCWSTR property,
1446 static const WCHAR all[]={'A','L','L',0};
1448 MSIFEATURE *feature;
1450 override = msi_dup_property( package, property );
1454 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1456 if (strcmpiW(override,all)==0)
1458 feature->ActionRequest= state;
1459 feature->Action = state;
1463 LPWSTR ptr = override;
1464 LPWSTR ptr2 = strchrW(override,',');
1468 if ((ptr2 && strncmpW(ptr,feature->Feature, ptr2-ptr)==0)
1469 || (!ptr2 && strcmpW(ptr,feature->Feature)==0))
1471 feature->ActionRequest= state;
1472 feature->Action = state;
1478 ptr2 = strchrW(ptr,',');
1490 static UINT SetFeatureStates(MSIPACKAGE *package)
1494 static const WCHAR szlevel[] =
1495 {'I','N','S','T','A','L','L','L','E','V','E','L',0};
1496 static const WCHAR szAddLocal[] =
1497 {'A','D','D','L','O','C','A','L',0};
1498 static const WCHAR szRemove[] =
1499 {'R','E','M','O','V','E',0};
1500 BOOL override = FALSE;
1501 MSICOMPONENT* component;
1502 MSIFEATURE *feature;
1505 /* I do not know if this is where it should happen.. but */
1507 TRACE("Checking Install Level\n");
1509 level = msi_dup_property( package, szlevel );
1512 install_level = atoiW(level);
1518 /* ok hereis the _real_ rub
1519 * all these activation/deactivation things happen in order and things
1520 * later on the list override things earlier on the list.
1521 * 1) INSTALLLEVEL processing
1531 * 11) FILEADDDEFAULT
1532 * I have confirmed that if ADDLOCAL is stated then the INSTALLLEVEL is
1533 * ignored for all the features. seems strange, especially since it is not
1534 * documented anywhere, but it is how it works.
1536 * I am still ignoring a lot of these. But that is ok for now, ADDLOCAL and
1537 * REMOVE are the big ones, since we don't handle administrative installs
1540 override |= process_state_property(package,szAddLocal,INSTALLSTATE_LOCAL);
1541 override |= process_state_property(package,szRemove,INSTALLSTATE_ABSENT);
1545 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1547 BOOL feature_state = ((feature->Level > 0) &&
1548 (feature->Level <= install_level));
1550 if ((feature_state) && (feature->Action == INSTALLSTATE_UNKNOWN))
1552 if (feature->Attributes & msidbFeatureAttributesFavorSource)
1554 feature->ActionRequest = INSTALLSTATE_SOURCE;
1555 feature->Action = INSTALLSTATE_SOURCE;
1557 else if (feature->Attributes & msidbFeatureAttributesFavorAdvertise)
1559 feature->ActionRequest = INSTALLSTATE_ADVERTISED;
1560 feature->Action = INSTALLSTATE_ADVERTISED;
1564 feature->ActionRequest = INSTALLSTATE_LOCAL;
1565 feature->Action = INSTALLSTATE_LOCAL;
1572 /* set the Preselected Property */
1573 static const WCHAR szPreselected[] = {'P','r','e','s','e','l','e','c','t','e','d',0};
1574 static const WCHAR szOne[] = { '1', 0 };
1576 MSI_SetPropertyW(package,szPreselected,szOne);
1580 * now we want to enable or disable components base on feature
1583 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1587 TRACE("Examining Feature %s (Installed %i, Action %i, Request %i)\n",
1588 debugstr_w(feature->Feature), feature->Installed, feature->Action,
1589 feature->ActionRequest);
1591 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
1593 component = cl->component;
1595 if (!component->Enabled)
1597 component->Action = INSTALLSTATE_UNKNOWN;
1598 component->ActionRequest = INSTALLSTATE_UNKNOWN;
1602 if (feature->Action == INSTALLSTATE_LOCAL)
1604 component->Action = INSTALLSTATE_LOCAL;
1605 component->ActionRequest = INSTALLSTATE_LOCAL;
1607 else if (feature->ActionRequest == INSTALLSTATE_SOURCE)
1609 if ((component->Action == INSTALLSTATE_UNKNOWN) ||
1610 (component->Action == INSTALLSTATE_ABSENT) ||
1611 (component->Action == INSTALLSTATE_ADVERTISED))
1614 component->Action = INSTALLSTATE_SOURCE;
1615 component->ActionRequest = INSTALLSTATE_SOURCE;
1618 else if (feature->ActionRequest == INSTALLSTATE_ADVERTISED)
1620 if ((component->Action == INSTALLSTATE_UNKNOWN) ||
1621 (component->Action == INSTALLSTATE_ABSENT))
1624 component->Action = INSTALLSTATE_ADVERTISED;
1625 component->ActionRequest = INSTALLSTATE_ADVERTISED;
1628 else if (feature->ActionRequest == INSTALLSTATE_ABSENT)
1630 if (component->Action == INSTALLSTATE_UNKNOWN)
1632 component->Action = INSTALLSTATE_ABSENT;
1633 component->ActionRequest = INSTALLSTATE_ABSENT;
1640 LIST_FOR_EACH_ENTRY( component, &package->components, MSICOMPONENT, entry )
1642 TRACE("Result: Component %s (Installed %i, Action %i, Request %i)\n",
1643 debugstr_w(component->Component), component->Installed,
1644 component->Action, component->ActionRequest);
1648 return ERROR_SUCCESS;
1651 static UINT ITERATE_CostFinalizeDirectories(MSIRECORD *row, LPVOID param)
1653 MSIPACKAGE *package = (MSIPACKAGE*)param;
1657 name = MSI_RecordGetString(row,1);
1659 /* This helper function now does ALL the work */
1660 TRACE("Dir %s ...\n",debugstr_w(name));
1661 load_folder(package,name);
1662 path = resolve_folder(package,name,FALSE,TRUE,NULL);
1663 TRACE("resolves to %s\n",debugstr_w(path));
1666 return ERROR_SUCCESS;
1669 static UINT ITERATE_CostFinalizeConditions(MSIRECORD *row, LPVOID param)
1671 MSIPACKAGE *package = (MSIPACKAGE*)param;
1673 MSIFEATURE *feature;
1675 name = MSI_RecordGetString( row, 1 );
1677 feature = get_loaded_feature( package, name );
1679 ERR("FAILED to find loaded feature %s\n",debugstr_w(name));
1683 Condition = MSI_RecordGetString(row,3);
1685 if (MSI_EvaluateConditionW(package,Condition) == MSICONDITION_TRUE)
1687 int level = MSI_RecordGetInteger(row,2);
1688 TRACE("Reseting feature %s to level %i\n", debugstr_w(name), level);
1689 feature->Level = level;
1692 return ERROR_SUCCESS;
1697 * A lot is done in this function aside from just the costing.
1698 * The costing needs to be implemented at some point but for now I am going
1699 * to focus on the directory building
1702 static UINT ACTION_CostFinalize(MSIPACKAGE *package)
1704 static const WCHAR ExecSeqQuery[] =
1705 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1706 '`','D','i','r','e','c','t','o','r','y','`',0};
1707 static const WCHAR ConditionQuery[] =
1708 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1709 '`','C','o','n','d','i','t','i','o','n','`',0};
1710 static const WCHAR szCosting[] =
1711 {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
1712 static const WCHAR szlevel[] =
1713 {'I','N','S','T','A','L','L','L','E','V','E','L',0};
1714 static const WCHAR szOne[] = { '1', 0 };
1723 MSI_GetPropertyW(package, szCosting, buffer, &sz);
1725 return ERROR_SUCCESS;
1727 TRACE("Building Directory properties\n");
1729 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
1730 if (rc == ERROR_SUCCESS)
1732 rc = MSI_IterateRecords(view, NULL, ITERATE_CostFinalizeDirectories,
1734 msiobj_release(&view->hdr);
1737 TRACE("File calculations\n");
1739 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
1741 MSICOMPONENT* comp = file->Component;
1747 /* calculate target */
1748 p = resolve_folder(package, comp->Directory, FALSE, FALSE, NULL);
1750 msi_free(file->TargetPath);
1752 TRACE("file %s is named %s\n",
1753 debugstr_w(file->File),debugstr_w(file->FileName));
1755 file->TargetPath = build_directory_name(2, p, file->FileName);
1759 TRACE("file %s resolves to %s\n",
1760 debugstr_w(file->File),debugstr_w(file->TargetPath));
1762 if (GetFileAttributesW(file->TargetPath) == INVALID_FILE_ATTRIBUTES)
1765 comp->Cost += file->FileSize;
1775 static const WCHAR name[] =
1777 static const WCHAR name_fmt[] =
1778 {'%','u','.','%','u','.','%','u','.','%','u',0};
1779 WCHAR filever[0x100];
1780 VS_FIXEDFILEINFO *lpVer;
1782 TRACE("Version comparison.. \n");
1783 versize = GetFileVersionInfoSizeW(file->TargetPath,&handle);
1784 version = msi_alloc(versize);
1785 GetFileVersionInfoW(file->TargetPath, 0, versize, version);
1787 VerQueryValueW(version, name, (LPVOID*)&lpVer, &sz);
1789 sprintfW(filever,name_fmt,
1790 HIWORD(lpVer->dwFileVersionMS),
1791 LOWORD(lpVer->dwFileVersionMS),
1792 HIWORD(lpVer->dwFileVersionLS),
1793 LOWORD(lpVer->dwFileVersionLS));
1795 TRACE("new %s old %s\n", debugstr_w(file->Version),
1796 debugstr_w(filever));
1797 if (strcmpiW(filever,file->Version)<0)
1800 FIXME("cost should be diff in size\n");
1801 comp->Cost += file->FileSize;
1811 TRACE("Evaluating Condition Table\n");
1813 rc = MSI_DatabaseOpenViewW(package->db, ConditionQuery, &view);
1814 if (rc == ERROR_SUCCESS)
1816 rc = MSI_IterateRecords(view, NULL, ITERATE_CostFinalizeConditions,
1818 msiobj_release(&view->hdr);
1821 TRACE("Enabling or Disabling Components\n");
1822 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
1824 if (comp->Condition)
1826 if (MSI_EvaluateConditionW(package,
1827 comp->Condition) == MSICONDITION_FALSE)
1829 TRACE("Disabling component %s\n", debugstr_w(comp->Component));
1830 comp->Enabled = FALSE;
1835 MSI_SetPropertyW(package,szCosting,szOne);
1836 /* set default run level if not set */
1837 level = msi_dup_property( package, szlevel );
1839 MSI_SetPropertyW(package,szlevel, szOne);
1842 ACTION_UpdateInstallStates(package);
1844 return SetFeatureStates(package);
1847 /* OK this value is "interpreted" and then formatted based on the
1848 first few characters */
1849 static LPSTR parse_value(MSIPACKAGE *package, LPCWSTR value, DWORD *type,
1853 if (value[0]=='#' && value[1]!='#' && value[1]!='%')
1859 LPWSTR deformated = NULL;
1862 deformat_string(package, &value[2], &deformated);
1864 /* binary value type */
1868 *size = (strlenW(ptr)/2)+1;
1870 *size = strlenW(ptr)/2;
1872 data = msi_alloc(*size);
1878 /* if uneven pad with a zero in front */
1884 data[count] = (BYTE)strtol(byte,NULL,0);
1886 TRACE("Uneven byte count\n");
1894 data[count] = (BYTE)strtol(byte,NULL,0);
1897 msi_free(deformated);
1899 TRACE("Data %li bytes(%i)\n",*size,count);
1906 deformat_string(package, &value[1], &deformated);
1909 *size = sizeof(DWORD);
1910 data = msi_alloc(*size);
1916 if ( (*p < '0') || (*p > '9') )
1922 if (deformated[0] == '-')
1925 TRACE("DWORD %li\n",*(LPDWORD)data);
1927 msi_free(deformated);
1932 static const WCHAR szMulti[] = {'[','~',']',0};
1941 *type=REG_EXPAND_SZ;
1949 if (strstrW(value,szMulti))
1950 *type = REG_MULTI_SZ;
1952 *size = deformat_string(package, ptr,(LPWSTR*)&data);
1957 static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
1959 MSIPACKAGE *package = (MSIPACKAGE*)param;
1960 static const WCHAR szHCR[] =
1961 {'H','K','E','Y','_','C','L','A','S','S','E','S','_',
1962 'R','O','O','T','\\',0};
1963 static const WCHAR szHCU[] =
1964 {'H','K','E','Y','_','C','U','R','R','E','N','T','_',
1965 'U','S','E','R','\\',0};
1966 static const WCHAR szHLM[] =
1967 {'H','K','E','Y','_','L','O','C','A','L','_',
1968 'M','A','C','H','I','N','E','\\',0};
1969 static const WCHAR szHU[] =
1970 {'H','K','E','Y','_','U','S','E','R','S','\\',0};
1972 LPSTR value_data = NULL;
1973 HKEY root_key, hkey;
1976 LPCWSTR szRoot, component, name, key, value;
1981 BOOL check_first = FALSE;
1984 ui_progress(package,2,0,0,0);
1991 component = MSI_RecordGetString(row, 6);
1992 comp = get_loaded_component(package,component);
1994 return ERROR_SUCCESS;
1996 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL))
1998 TRACE("Skipping write due to disabled component %s\n",
1999 debugstr_w(component));
2001 comp->Action = comp->Installed;
2003 return ERROR_SUCCESS;
2006 comp->Action = INSTALLSTATE_LOCAL;
2008 name = MSI_RecordGetString(row, 4);
2009 if( MSI_RecordIsNull(row,5) && name )
2011 /* null values can have special meanings */
2012 if (name[0]=='-' && name[1] == 0)
2013 return ERROR_SUCCESS;
2014 else if ((name[0]=='+' && name[1] == 0) ||
2015 (name[0] == '*' && name[1] == 0))
2020 root = MSI_RecordGetInteger(row,2);
2021 key = MSI_RecordGetString(row, 3);
2023 /* get the root key */
2028 static const WCHAR szALLUSER[] = {'A','L','L','U','S','E','R','S',0};
2029 LPWSTR all_users = msi_dup_property( package, szALLUSER );
2030 if (all_users && all_users[0] == '1')
2032 root_key = HKEY_LOCAL_MACHINE;
2037 root_key = HKEY_CURRENT_USER;
2040 msi_free(all_users);
2043 case 0: root_key = HKEY_CLASSES_ROOT;
2046 case 1: root_key = HKEY_CURRENT_USER;
2049 case 2: root_key = HKEY_LOCAL_MACHINE;
2052 case 3: root_key = HKEY_USERS;
2056 ERR("Unknown root %i\n",root);
2062 return ERROR_SUCCESS;
2064 deformat_string(package, key , &deformated);
2065 size = strlenW(deformated) + strlenW(szRoot) + 1;
2066 uikey = msi_alloc(size*sizeof(WCHAR));
2067 strcpyW(uikey,szRoot);
2068 strcatW(uikey,deformated);
2070 if (RegCreateKeyW( root_key, deformated, &hkey))
2072 ERR("Could not create key %s\n",debugstr_w(deformated));
2073 msi_free(deformated);
2075 return ERROR_SUCCESS;
2077 msi_free(deformated);
2079 value = MSI_RecordGetString(row,5);
2081 value_data = parse_value(package, value, &type, &size);
2084 static const WCHAR szEmpty[] = {0};
2085 value_data = (LPSTR)strdupW(szEmpty);
2090 deformat_string(package, name, &deformated);
2092 /* get the double nulls to terminate SZ_MULTI */
2093 if (type == REG_MULTI_SZ)
2094 size +=sizeof(WCHAR);
2098 TRACE("Setting value %s of %s\n",debugstr_w(deformated),
2100 RegSetValueExW(hkey, deformated, 0, type, (LPBYTE)value_data, size);
2105 rc = RegQueryValueExW(hkey, deformated, NULL, NULL, NULL, &sz);
2106 if (rc == ERROR_SUCCESS || rc == ERROR_MORE_DATA)
2108 TRACE("value %s of %s checked already exists\n",
2109 debugstr_w(deformated), debugstr_w(uikey));
2113 TRACE("Checked and setting value %s of %s\n",
2114 debugstr_w(deformated), debugstr_w(uikey));
2115 if (deformated || size)
2116 RegSetValueExW(hkey, deformated, 0, type, (LPBYTE) value_data, size);
2121 uirow = MSI_CreateRecord(3);
2122 MSI_RecordSetStringW(uirow,2,deformated);
2123 MSI_RecordSetStringW(uirow,1,uikey);
2126 MSI_RecordSetStringW(uirow,3,(LPWSTR)value_data);
2128 MSI_RecordSetStringW(uirow,3,value);
2130 ui_actiondata(package,szWriteRegistryValues,uirow);
2131 msiobj_release( &uirow->hdr );
2133 msi_free(value_data);
2134 msi_free(deformated);
2137 return ERROR_SUCCESS;
2140 static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package)
2144 static const WCHAR ExecSeqQuery[] =
2145 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2146 '`','R','e','g','i','s','t','r','y','`',0 };
2149 return ERROR_INVALID_HANDLE;
2151 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
2152 if (rc != ERROR_SUCCESS)
2153 return ERROR_SUCCESS;
2155 /* increment progress bar each time action data is sent */
2156 ui_progress(package,1,REG_PROGRESS_VALUE,1,0);
2158 rc = MSI_IterateRecords(view, NULL, ITERATE_WriteRegistryValues, package);
2160 msiobj_release(&view->hdr);
2164 static UINT ACTION_InstallInitialize(MSIPACKAGE *package)
2166 package->script->CurrentlyScripting = TRUE;
2168 return ERROR_SUCCESS;
2172 static UINT ACTION_InstallValidate(MSIPACKAGE *package)
2177 static const WCHAR q1[]=
2178 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
2179 '`','R','e','g','i','s','t','r','y','`',0};
2182 MSIFEATURE *feature;
2185 TRACE("InstallValidate\n");
2187 rc = MSI_DatabaseOpenViewW(package->db, q1, &view);
2188 if (rc == ERROR_SUCCESS)
2190 MSI_IterateRecords( view, &progress, NULL, package );
2191 msiobj_release( &view->hdr );
2192 total += progress * REG_PROGRESS_VALUE;
2195 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
2196 total += COMPONENT_PROGRESS_VALUE;
2198 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
2199 total += file->FileSize;
2201 ui_progress(package,0,total,0,0);
2203 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
2205 TRACE("Feature: %s; Installed: %i; Action %i; Request %i\n",
2206 debugstr_w(feature->Feature), feature->Installed, feature->Action,
2207 feature->ActionRequest);
2210 return ERROR_SUCCESS;
2213 static UINT ITERATE_LaunchConditions(MSIRECORD *row, LPVOID param)
2215 MSIPACKAGE* package = (MSIPACKAGE*)param;
2216 LPCWSTR cond = NULL;
2217 LPCWSTR message = NULL;
2218 static const WCHAR title[]=
2219 {'I','n','s','t','a','l','l',' ','F','a', 'i','l','e','d',0};
2221 cond = MSI_RecordGetString(row,1);
2223 if (MSI_EvaluateConditionW(package,cond) != MSICONDITION_TRUE)
2226 message = MSI_RecordGetString(row,2);
2227 deformat_string(package,message,&deformated);
2228 MessageBoxW(NULL,deformated,title,MB_OK);
2229 msi_free(deformated);
2230 return ERROR_FUNCTION_FAILED;
2233 return ERROR_SUCCESS;
2236 static UINT ACTION_LaunchConditions(MSIPACKAGE *package)
2239 MSIQUERY * view = NULL;
2240 static const WCHAR ExecSeqQuery[] =
2241 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2242 '`','L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','`',0};
2244 TRACE("Checking launch conditions\n");
2246 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
2247 if (rc != ERROR_SUCCESS)
2248 return ERROR_SUCCESS;
2250 rc = MSI_IterateRecords(view, NULL, ITERATE_LaunchConditions, package);
2251 msiobj_release(&view->hdr);
2256 static LPWSTR resolve_keypath( MSIPACKAGE* package, MSICOMPONENT *cmp )
2260 return resolve_folder(package,cmp->Directory,FALSE,FALSE,NULL);
2262 if (cmp->Attributes & msidbComponentAttributesRegistryKeyPath)
2264 MSIRECORD * row = 0;
2266 LPWSTR deformated,buffer,deformated_name;
2268 static const WCHAR ExecSeqQuery[] =
2269 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2270 '`','R','e','g','i','s','t','r','y','`',' ',
2271 'W','H','E','R','E',' ', '`','R','e','g','i','s','t','r','y','`',
2272 ' ','=',' ' ,'\'','%','s','\'',0 };
2273 static const WCHAR fmt[]={'%','0','2','i',':','\\','%','s','\\',0};
2274 static const WCHAR fmt2[]=
2275 {'%','0','2','i',':','\\','%','s','\\','%','s',0};
2277 row = MSI_QueryGetRecord(package->db, ExecSeqQuery,cmp->KeyPath);
2281 root = MSI_RecordGetInteger(row,2);
2282 key = MSI_RecordGetString(row, 3);
2283 name = MSI_RecordGetString(row, 4);
2284 deformat_string(package, key , &deformated);
2285 deformat_string(package, name, &deformated_name);
2287 len = strlenW(deformated) + 6;
2288 if (deformated_name)
2289 len+=strlenW(deformated_name);
2291 buffer = msi_alloc( len *sizeof(WCHAR));
2293 if (deformated_name)
2294 sprintfW(buffer,fmt2,root,deformated,deformated_name);
2296 sprintfW(buffer,fmt,root,deformated);
2298 msi_free(deformated);
2299 msi_free(deformated_name);
2300 msiobj_release(&row->hdr);
2304 else if (cmp->Attributes & msidbComponentAttributesODBCDataSource)
2306 FIXME("UNIMPLEMENTED keypath as ODBC Source\n");
2311 MSIFILE *file = get_loaded_file( package, cmp->KeyPath );
2314 return strdupW( file->TargetPath );
2319 static HKEY openSharedDLLsKey(void)
2322 static const WCHAR path[] =
2323 {'S','o','f','t','w','a','r','e','\\',
2324 'M','i','c','r','o','s','o','f','t','\\',
2325 'W','i','n','d','o','w','s','\\',
2326 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
2327 'S','h','a','r','e','d','D','L','L','s',0};
2329 RegCreateKeyW(HKEY_LOCAL_MACHINE,path,&hkey);
2333 static UINT ACTION_GetSharedDLLsCount(LPCWSTR dll)
2338 DWORD sz = sizeof(count);
2341 hkey = openSharedDLLsKey();
2342 rc = RegQueryValueExW(hkey, dll, NULL, &type, (LPBYTE)&count, &sz);
2343 if (rc != ERROR_SUCCESS)
2349 static UINT ACTION_WriteSharedDLLsCount(LPCWSTR path, UINT count)
2353 hkey = openSharedDLLsKey();
2355 msi_reg_set_val_dword( hkey, path, count );
2357 RegDeleteValueW(hkey,path);
2363 * Return TRUE if the count should be written out and FALSE if not
2365 static void ACTION_RefCountComponent( MSIPACKAGE* package, MSICOMPONENT *comp )
2367 MSIFEATURE *feature;
2371 /* only refcount DLLs */
2372 if (comp->KeyPath == NULL ||
2373 comp->Attributes & msidbComponentAttributesRegistryKeyPath ||
2374 comp->Attributes & msidbComponentAttributesODBCDataSource)
2378 count = ACTION_GetSharedDLLsCount( comp->FullKeypath);
2379 write = (count > 0);
2381 if (comp->Attributes & msidbComponentAttributesSharedDllRefCount)
2385 /* increment counts */
2386 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
2390 if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL ))
2393 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
2395 if ( cl->component == comp )
2400 /* decrement counts */
2401 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
2405 if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ABSENT ))
2408 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
2410 if ( cl->component == comp )
2415 /* ref count all the files in the component */
2420 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
2422 if (file->Component == comp)
2423 ACTION_WriteSharedDLLsCount( file->TargetPath, count );
2427 /* add a count for permenent */
2428 if (comp->Attributes & msidbComponentAttributesPermanent)
2431 comp->RefCount = count;
2434 ACTION_WriteSharedDLLsCount( comp->FullKeypath, comp->RefCount );
2438 * Ok further analysis makes me think that this work is
2439 * actually done in the PublishComponents and PublishFeatures
2440 * step, and not here. It appears like the keypath and all that is
2441 * resolved in this step, however actually written in the Publish steps.
2442 * But we will leave it here for now because it is unclear
2444 static UINT ACTION_ProcessComponents(MSIPACKAGE *package)
2446 WCHAR squished_pc[GUID_SIZE];
2447 WCHAR squished_cc[GUID_SIZE];
2450 HKEY hkey=0,hkey2=0;
2453 return ERROR_INVALID_HANDLE;
2455 /* writes the Component and Features values to the registry */
2457 rc = MSIREG_OpenComponents(&hkey);
2458 if (rc != ERROR_SUCCESS)
2461 squash_guid(package->ProductCode,squished_pc);
2462 ui_progress(package,1,COMPONENT_PROGRESS_VALUE,1,0);
2464 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
2466 ui_progress(package,2,0,0,0);
2467 if (comp->ComponentId)
2469 WCHAR *keypath = NULL;
2472 squash_guid(comp->ComponentId,squished_cc);
2474 keypath = resolve_keypath( package, comp );
2475 comp->FullKeypath = keypath;
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)
2498 msi_reg_set_val_str( hkey2, squished_pc, keypath );
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, keypath );
2513 uirow = MSI_CreateRecord(3);
2514 MSI_RecordSetStringW(uirow,1,package->ProductCode);
2515 MSI_RecordSetStringW(uirow,2,comp->ComponentId);
2516 MSI_RecordSetStringW(uirow,3,keypath);
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);
2792 FIXME("poorly handled shortcut format, advertised shortcut\n");
2793 keypath = strdupW( comp->FullKeypath );
2794 IShellLinkW_SetPath(sl,keypath);
2798 if (!MSI_RecordIsNull(row,6))
2801 buffer = MSI_RecordGetString(row,6);
2802 deformat_string(package,buffer,&deformated);
2803 IShellLinkW_SetArguments(sl,deformated);
2804 msi_free(deformated);
2807 if (!MSI_RecordIsNull(row,7))
2809 buffer = MSI_RecordGetString(row,7);
2810 IShellLinkW_SetDescription(sl,buffer);
2813 if (!MSI_RecordIsNull(row,8))
2814 IShellLinkW_SetHotkey(sl,MSI_RecordGetInteger(row,8));
2816 if (!MSI_RecordIsNull(row,9))
2821 buffer = MSI_RecordGetString(row,9);
2823 build_icon_path(package,buffer,&Path);
2824 index = MSI_RecordGetInteger(row,10);
2826 IShellLinkW_SetIconLocation(sl,Path,index);
2830 if (!MSI_RecordIsNull(row,11))
2831 IShellLinkW_SetShowCmd(sl,MSI_RecordGetInteger(row,11));
2833 if (!MSI_RecordIsNull(row,12))
2836 buffer = MSI_RecordGetString(row,12);
2837 Path = resolve_folder(package, buffer, FALSE, FALSE, NULL);
2838 IShellLinkW_SetWorkingDirectory(sl,Path);
2842 TRACE("Writing shortcut to %s\n",debugstr_w(target_file));
2843 IPersistFile_Save(pf,target_file,FALSE);
2845 msi_free(target_file);
2847 IPersistFile_Release( pf );
2848 IShellLinkW_Release( sl );
2850 return ERROR_SUCCESS;
2853 static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
2858 static const WCHAR Query[] =
2859 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2860 '`','S','h','o','r','t','c','u','t','`',0};
2863 return ERROR_INVALID_HANDLE;
2865 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
2866 if (rc != ERROR_SUCCESS)
2867 return ERROR_SUCCESS;
2869 res = CoInitialize( NULL );
2872 ERR("CoInitialize failed\n");
2873 return ERROR_FUNCTION_FAILED;
2876 rc = MSI_IterateRecords(view, NULL, ITERATE_CreateShortcuts, package);
2877 msiobj_release(&view->hdr);
2884 static UINT ITERATE_PublishProduct(MSIRECORD *row, LPVOID param)
2886 MSIPACKAGE* package = (MSIPACKAGE*)param;
2888 LPWSTR FilePath=NULL;
2889 LPCWSTR FileName=NULL;
2894 FileName = MSI_RecordGetString(row,1);
2897 ERR("Unable to get FileName\n");
2898 return ERROR_SUCCESS;
2901 build_icon_path(package,FileName,&FilePath);
2903 TRACE("Creating icon file at %s\n",debugstr_w(FilePath));
2905 the_file = CreateFileW(FilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2906 FILE_ATTRIBUTE_NORMAL, NULL);
2908 if (the_file == INVALID_HANDLE_VALUE)
2910 ERR("Unable to create file %s\n",debugstr_w(FilePath));
2912 return ERROR_SUCCESS;
2919 rc = MSI_RecordReadStream(row,2,buffer,&sz);
2920 if (rc != ERROR_SUCCESS)
2922 ERR("Failed to get stream\n");
2923 CloseHandle(the_file);
2924 DeleteFileW(FilePath);
2927 WriteFile(the_file,buffer,sz,&write,NULL);
2928 } while (sz == 1024);
2932 CloseHandle(the_file);
2933 return ERROR_SUCCESS;
2937 * 99% of the work done here is only done for
2938 * advertised installs. However this is where the
2939 * Icon table is processed and written out
2940 * so that is what I am going to do here.
2942 static UINT ACTION_PublishProduct(MSIPACKAGE *package)
2946 static const WCHAR Query[]=
2947 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2948 '`','I','c','o','n','`',0};
2949 /* for registry stuff */
2952 static const WCHAR szProductLanguage[] =
2953 {'P','r','o','d','u','c','t','L','a','n','g','u','a','g','e',0};
2954 static const WCHAR szARPProductIcon[] =
2955 {'A','R','P','P','R','O','D','U','C','T','I','C','O','N',0};
2956 static const WCHAR szProductVersion[] =
2957 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0};
2961 MSIHANDLE hDb, hSumInfo;
2964 return ERROR_INVALID_HANDLE;
2966 /* write out icon files */
2968 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
2969 if (rc == ERROR_SUCCESS)
2971 MSI_IterateRecords(view, NULL, ITERATE_PublishProduct, package);
2972 msiobj_release(&view->hdr);
2975 /* ok there is a lot more done here but i need to figure out what */
2977 rc = MSIREG_OpenProductsKey(package->ProductCode,&hkey,TRUE);
2978 if (rc != ERROR_SUCCESS)
2981 rc = MSIREG_OpenUserProductsKey(package->ProductCode,&hukey,TRUE);
2982 if (rc != ERROR_SUCCESS)
2986 buffer = msi_dup_property( package, INSTALLPROPERTY_PRODUCTNAMEW );
2987 msi_reg_set_val_str( hukey, INSTALLPROPERTY_PRODUCTNAMEW, buffer );
2990 buffer = msi_dup_property( package, szProductLanguage );
2991 langid = atoiW(buffer);
2992 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_LANGUAGEW, langid );
2995 buffer = msi_dup_property( package, szARPProductIcon );
2999 build_icon_path(package,buffer,&path);
3000 msi_reg_set_val_str( hukey, INSTALLPROPERTY_PRODUCTICONW, path );
3004 buffer = msi_dup_property( package, szProductVersion );
3007 DWORD verdword = build_version_dword(buffer);
3008 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONW, verdword );
3012 FIXME("Need to write more keys to the user registry\n");
3014 hDb= alloc_msihandle( &package->db->hdr );
3015 rc = MsiGetSummaryInformationW(hDb, NULL, 0, &hSumInfo);
3016 MsiCloseHandle(hDb);
3017 if (rc == ERROR_SUCCESS)
3019 WCHAR guidbuffer[0x200];
3021 rc = MsiSummaryInfoGetPropertyW(hSumInfo, 9, NULL, NULL, NULL,
3023 if (rc == ERROR_SUCCESS)
3025 WCHAR squashed[GUID_SIZE];
3026 /* for now we only care about the first guid */
3027 LPWSTR ptr = strchrW(guidbuffer,';');
3029 squash_guid(guidbuffer,squashed);
3030 msi_reg_set_val_str( hukey, INSTALLPROPERTY_PACKAGECODEW, squashed );
3034 ERR("Unable to query Revision_Number... \n");
3037 MsiCloseHandle(hSumInfo);
3041 ERR("Unable to open Summary Information\n");
3053 static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param)
3055 MSIPACKAGE *package = (MSIPACKAGE*)param;
3056 LPCWSTR component,section,key,value,identifier,filename,dirproperty;
3057 LPWSTR deformated_section, deformated_key, deformated_value;
3058 LPWSTR folder, fullname = NULL;
3062 static const WCHAR szWindowsFolder[] =
3063 {'W','i','n','d','o','w','s','F','o','l','d','e','r',0};
3065 component = MSI_RecordGetString(row, 8);
3066 comp = get_loaded_component(package,component);
3068 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL))
3070 TRACE("Skipping ini file due to disabled component %s\n",
3071 debugstr_w(component));
3073 comp->Action = comp->Installed;
3075 return ERROR_SUCCESS;
3078 comp->Action = INSTALLSTATE_LOCAL;
3080 identifier = MSI_RecordGetString(row,1);
3081 filename = MSI_RecordGetString(row,2);
3082 dirproperty = MSI_RecordGetString(row,3);
3083 section = MSI_RecordGetString(row,4);
3084 key = MSI_RecordGetString(row,5);
3085 value = MSI_RecordGetString(row,6);
3086 action = MSI_RecordGetInteger(row,7);
3088 deformat_string(package,section,&deformated_section);
3089 deformat_string(package,key,&deformated_key);
3090 deformat_string(package,value,&deformated_value);
3094 folder = resolve_folder(package, dirproperty, FALSE, FALSE, NULL);
3096 folder = msi_dup_property( package, dirproperty );
3099 folder = msi_dup_property( package, szWindowsFolder );
3103 ERR("Unable to resolve folder! (%s)\n",debugstr_w(dirproperty));
3107 fullname = build_directory_name(2, folder, filename);
3111 TRACE("Adding value %s to section %s in %s\n",
3112 debugstr_w(deformated_key), debugstr_w(deformated_section),
3113 debugstr_w(fullname));
3114 WritePrivateProfileStringW(deformated_section, deformated_key,
3115 deformated_value, fullname);
3117 else if (action == 1)
3120 GetPrivateProfileStringW(deformated_section, deformated_key, NULL,
3121 returned, 10, fullname);
3122 if (returned[0] == 0)
3124 TRACE("Adding value %s to section %s in %s\n",
3125 debugstr_w(deformated_key), debugstr_w(deformated_section),
3126 debugstr_w(fullname));
3128 WritePrivateProfileStringW(deformated_section, deformated_key,
3129 deformated_value, fullname);
3132 else if (action == 3)
3133 FIXME("Append to existing section not yet implemented\n");
3135 uirow = MSI_CreateRecord(4);
3136 MSI_RecordSetStringW(uirow,1,identifier);
3137 MSI_RecordSetStringW(uirow,2,deformated_section);
3138 MSI_RecordSetStringW(uirow,3,deformated_key);
3139 MSI_RecordSetStringW(uirow,4,deformated_value);
3140 ui_actiondata(package,szWriteIniValues,uirow);
3141 msiobj_release( &uirow->hdr );
3145 msi_free(deformated_key);
3146 msi_free(deformated_value);
3147 msi_free(deformated_section);
3148 return ERROR_SUCCESS;
3151 static UINT ACTION_WriteIniValues(MSIPACKAGE *package)
3155 static const WCHAR ExecSeqQuery[] =
3156 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3157 '`','I','n','i','F','i','l','e','`',0};
3159 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3160 if (rc != ERROR_SUCCESS)
3162 TRACE("no IniFile table\n");
3163 return ERROR_SUCCESS;
3166 rc = MSI_IterateRecords(view, NULL, ITERATE_WriteIniValues, package);
3167 msiobj_release(&view->hdr);
3171 static UINT ITERATE_SelfRegModules(MSIRECORD *row, LPVOID param)
3173 MSIPACKAGE *package = (MSIPACKAGE*)param;
3178 static const WCHAR ExeStr[] =
3179 {'r','e','g','s','v','r','3','2','.','e','x','e',' ','\"',0};
3180 static const WCHAR close[] = {'\"',0};
3182 PROCESS_INFORMATION info;
3185 memset(&si,0,sizeof(STARTUPINFOW));
3187 filename = MSI_RecordGetString(row,1);
3188 file = get_loaded_file( package, filename );
3192 ERR("Unable to find file id %s\n",debugstr_w(filename));
3193 return ERROR_SUCCESS;
3196 len = strlenW(ExeStr) + strlenW( file->TargetPath ) + 2;
3198 FullName = msi_alloc(len*sizeof(WCHAR));
3199 strcpyW(FullName,ExeStr);
3200 strcatW( FullName, file->TargetPath );
3201 strcatW(FullName,close);
3203 TRACE("Registering %s\n",debugstr_w(FullName));
3204 brc = CreateProcessW(NULL, FullName, NULL, NULL, FALSE, 0, NULL, c_colon,
3208 msi_dialog_check_messages(info.hProcess);
3211 return ERROR_SUCCESS;
3214 static UINT ACTION_SelfRegModules(MSIPACKAGE *package)
3218 static const WCHAR ExecSeqQuery[] =
3219 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3220 '`','S','e','l','f','R','e','g','`',0};
3222 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3223 if (rc != ERROR_SUCCESS)
3225 TRACE("no SelfReg table\n");
3226 return ERROR_SUCCESS;
3229 MSI_IterateRecords(view, NULL, ITERATE_SelfRegModules, package);
3230 msiobj_release(&view->hdr);
3232 return ERROR_SUCCESS;
3235 static UINT ACTION_PublishFeatures(MSIPACKAGE *package)
3237 MSIFEATURE *feature;
3243 return ERROR_INVALID_HANDLE;
3245 rc = MSIREG_OpenFeaturesKey(package->ProductCode,&hkey,TRUE);
3246 if (rc != ERROR_SUCCESS)
3249 rc = MSIREG_OpenUserFeaturesKey(package->ProductCode,&hukey,TRUE);
3250 if (rc != ERROR_SUCCESS)
3253 /* here the guids are base 85 encoded */
3254 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
3260 BOOL absent = FALSE;
3262 if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL ) &&
3263 !ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_SOURCE ) &&
3264 !ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ADVERTISED ))
3268 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
3272 if (feature->Feature_Parent)
3273 size += strlenW( feature->Feature_Parent )+2;
3275 data = msi_alloc(size * sizeof(WCHAR));
3278 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
3280 MSICOMPONENT* component = cl->component;
3283 memset(buf,0,sizeof(buf));
3284 if (component->ComponentId)
3286 TRACE("From %s\n",debugstr_w(component->ComponentId));
3287 CLSIDFromString(component->ComponentId, &clsid);
3288 encode_base85_guid(&clsid,buf);
3289 TRACE("to %s\n",debugstr_w(buf));
3293 if (feature->Feature_Parent)
3295 static const WCHAR sep[] = {'\2',0};
3297 strcatW(data,feature->Feature_Parent);
3300 msi_reg_set_val_str( hkey, feature->Feature, data );
3304 if (feature->Feature_Parent)
3305 size = strlenW(feature->Feature_Parent)*sizeof(WCHAR);
3308 RegSetValueExW(hukey,feature->Feature,0,REG_SZ,
3309 (LPBYTE)feature->Feature_Parent,size);
3313 size += 2*sizeof(WCHAR);
3314 data = msi_alloc(size);
3317 if (feature->Feature_Parent)
3318 strcpyW( &data[1], feature->Feature_Parent );
3319 RegSetValueExW(hukey,feature->Feature,0,REG_SZ,
3331 static UINT ACTION_RegisterProduct(MSIPACKAGE *package)
3334 LPWSTR buffer = NULL;
3337 static const WCHAR szWindowsInstaller[] =
3338 {'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
3339 static const WCHAR szPropKeys[][80] =
3341 {'A','R','P','A','U','T','H','O','R','I','Z','E','D','C','D','F','P','R','E','F','I','X',0},
3342 {'A','R','P','C','O','N','T','A','C','T',0},
3343 {'A','R','P','C','O','M','M','E','N','T','S',0},
3344 {'P','r','o','d','u','c','t','N','a','m','e',0},
3345 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0},
3346 {'A','R','P','H','E','L','P','L','I','N','K',0},
3347 {'A','R','P','H','E','L','P','T','E','L','E','P','H','O','N','E',0},
3348 {'A','R','P','I','N','S','T','A','L','L','L','O','C','A','T','I','O','N',0},
3349 {'S','o','u','r','c','e','D','i','r',0},
3350 {'M','a','n','u','f','a','c','t','u','r','e','r',0},
3351 {'A','R','P','R','E','A','D','M','E',0},
3352 {'A','R','P','S','I','Z','E',0},
3353 {'A','R','P','U','R','L','I','N','F','O','A','B','O','U','T',0},
3354 {'A','R','P','U','R','L','U','P','D','A','T','E','I','N','F','O',0},
3358 static const WCHAR szRegKeys[][80] =
3360 {'A','u','t','h','o','r','i','z','e','d','C','D','F','P','r','e','f','i','x',0},
3361 {'C','o','n','t','a','c','t',0},
3362 {'C','o','m','m','e','n','t','s',0},
3363 {'D','i','s','p','l','a','y','N','a','m','e',0},
3364 {'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0},
3365 {'H','e','l','p','L','i','n','k',0},
3366 {'H','e','l','p','T','e','l','e','p','h','o','n','e',0},
3367 {'I','n','s','t','a','l','l','L','o','c','a','t','i','o','n',0},
3368 {'I','n','s','t','a','l','l','S','o','u','r','c','e',0},
3369 {'P','u','b','l','i','s','h','e','r',0},
3370 {'R','e','a','d','m','e',0},
3371 {'S','i','z','e',0},
3372 {'U','R','L','I','n','f','o','A','b','o','u','t',0},
3373 {'U','R','L','U','p','d','a','t','e','I','n','f','o',0},
3377 static const WCHAR installerPathFmt[] = {
3379 'I','n','s','t','a','l','l','e','r','\\',0};
3380 static const WCHAR fmt[] = {
3382 'I','n','s','t','a','l','l','e','r','\\',
3383 '%','x','.','m','s','i',0};
3384 static const WCHAR szUpgradeCode[] =
3385 {'U','p','g','r','a','d','e','C','o','d','e',0};
3386 static const WCHAR modpath_fmt[] =
3387 {'M','s','i','E','x','e','c','.','e','x','e',' ','/','I','[','P','r','o','d','u','c','t','C','o','d','e',']',0};
3388 static const WCHAR szModifyPath[] =
3389 {'M','o','d','i','f','y','P','a','t','h',0};
3390 static const WCHAR szUninstallString[] =
3391 {'U','n','i','n','s','t','a','l','l','S','t','r','i','n','g',0};
3392 static const WCHAR szEstimatedSize[] =
3393 {'E','s','t','i','m','a','t','e','d','S','i','z','e',0};
3394 static const WCHAR szProductLanguage[] =
3395 {'P','r','o','d','u','c','t','L','a','n','g','u','a','g','e',0};
3396 static const WCHAR szProductVersion[] =
3397 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0};
3400 static const WCHAR date_fmt[] = {'%','i','%','i','%','i',0};
3401 LPWSTR upgrade_code;
3402 WCHAR windir[MAX_PATH], path[MAX_PATH], packagefile[MAX_PATH];
3406 return ERROR_INVALID_HANDLE;
3408 rc = MSIREG_OpenUninstallKey(package->ProductCode,&hkey,TRUE);
3409 if (rc != ERROR_SUCCESS)
3412 /* dump all the info i can grab */
3413 FIXME("Flesh out more information \n");
3415 for( i=0; szPropKeys[i][0]; i++ )
3417 buffer = msi_dup_property( package, szPropKeys[i] );
3418 msi_reg_set_val_str( hkey, szRegKeys[i], buffer );
3422 msi_reg_set_val_dword( hkey, szWindowsInstaller, 1 );
3424 /* copy the package locally */
3425 num = GetTickCount() & 0xffff;
3429 GetWindowsDirectoryW(windir, sizeof(windir) / sizeof(windir[0]));
3430 snprintfW(packagefile,sizeof(packagefile)/sizeof(packagefile[0]),fmt,
3434 HANDLE handle = CreateFileW(packagefile,GENERIC_WRITE, 0, NULL,
3435 CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
3436 if (handle != INVALID_HANDLE_VALUE)
3438 CloseHandle(handle);
3441 if (GetLastError() != ERROR_FILE_EXISTS &&
3442 GetLastError() != ERROR_SHARING_VIOLATION)
3444 if (!(++num & 0xffff)) num = 1;
3445 sprintfW(packagefile,fmt,num);
3446 } while (num != start);
3448 snprintfW(path,sizeof(path)/sizeof(path[0]),installerPathFmt,windir);
3449 create_full_pathW(path);
3450 TRACE("Copying to local package %s\n",debugstr_w(packagefile));
3451 if (!CopyFileW(package->msiFilePath,packagefile,FALSE))
3452 ERR("Unable to copy package (%s -> %s) (error %ld)\n",
3453 debugstr_w(package->msiFilePath), debugstr_w(packagefile),
3455 msi_reg_set_val_str( hkey, INSTALLPROPERTY_LOCALPACKAGEW, packagefile );
3457 /* do ModifyPath and UninstallString */
3458 size = deformat_string(package,modpath_fmt,&buffer);
3459 RegSetValueExW(hkey,szModifyPath,0,REG_EXPAND_SZ,(LPBYTE)buffer,size);
3460 RegSetValueExW(hkey,szUninstallString,0,REG_EXPAND_SZ,(LPBYTE)buffer,size);
3463 FIXME("Write real Estimated Size when we have it\n");
3464 msi_reg_set_val_dword( hkey, szEstimatedSize, 0 );
3466 GetLocalTime(&systime);
3467 size = 9*sizeof(WCHAR);
3468 buffer= msi_alloc(size);
3469 sprintfW(buffer,date_fmt,systime.wYear,systime.wMonth,systime.wDay);
3470 msi_reg_set_val_str( hkey, INSTALLPROPERTY_INSTALLDATEW, buffer );
3473 buffer = msi_dup_property( package, szProductLanguage );
3474 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_LANGUAGEW, atoiW(buffer) );
3477 buffer = msi_dup_property( package, szProductVersion );
3480 DWORD verdword = build_version_dword(buffer);
3482 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONW, verdword );
3483 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONMAJORW, verdword>>24 );
3484 msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONMINORW, (verdword>>16)&0x00FF );
3488 /* Handle Upgrade Codes */
3489 upgrade_code = msi_dup_property( package, szUpgradeCode );
3494 MSIREG_OpenUpgradeCodesKey(upgrade_code, &hkey2, TRUE);
3495 squash_guid(package->ProductCode,squashed);
3496 msi_reg_set_val_str( hkey2, squashed, NULL );
3498 MSIREG_OpenUserUpgradeCodesKey(upgrade_code, &hkey2, TRUE);
3499 squash_guid(package->ProductCode,squashed);
3500 msi_reg_set_val_str( hkey2, squashed, NULL );
3503 msi_free(upgrade_code);
3509 return ERROR_SUCCESS;
3512 static UINT ACTION_InstallExecute(MSIPACKAGE *package)
3517 return ERROR_INVALID_HANDLE;
3519 rc = execute_script(package,INSTALL_SCRIPT);
3524 static UINT ACTION_InstallFinalize(MSIPACKAGE *package)
3529 return ERROR_INVALID_HANDLE;
3531 /* turn off scheduleing */
3532 package->script->CurrentlyScripting= FALSE;
3534 /* first do the same as an InstallExecute */
3535 rc = ACTION_InstallExecute(package);
3536 if (rc != ERROR_SUCCESS)
3539 /* then handle Commit Actions */
3540 rc = execute_script(package,COMMIT_SCRIPT);
3545 static UINT ACTION_ForceReboot(MSIPACKAGE *package)
3547 static const WCHAR RunOnce[] = {
3548 'S','o','f','t','w','a','r','e','\\',
3549 'M','i','c','r','o','s','o','f','t','\\',
3550 'W','i','n','d','o','w','s','\\',
3551 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3552 'R','u','n','O','n','c','e',0};
3553 static const WCHAR InstallRunOnce[] = {
3554 'S','o','f','t','w','a','r','e','\\',
3555 'M','i','c','r','o','s','o','f','t','\\',
3556 'W','i','n','d','o','w','s','\\',
3557 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3558 'I','n','s','t','a','l','l','e','r','\\',
3559 'R','u','n','O','n','c','e','E','n','t','r','i','e','s',0};
3561 static const WCHAR msiexec_fmt[] = {
3563 '\\','M','s','i','E','x','e','c','.','e','x','e',' ','/','@',' ',
3564 '\"','%','s','\"',0};
3565 static const WCHAR install_fmt[] = {
3566 '/','I',' ','\"','%','s','\"',' ',
3567 'A','F','T','E','R','R','E','B','O','O','T','=','1',' ',
3568 'R','U','N','O','N','C','E','E','N','T','R','Y','=','\"','%','s','\"',0};
3569 WCHAR buffer[256], sysdir[MAX_PATH];
3571 WCHAR squished_pc[100];
3574 return ERROR_INVALID_HANDLE;
3576 squash_guid(package->ProductCode,squished_pc);
3578 GetSystemDirectoryW(sysdir, sizeof(sysdir)/sizeof(sysdir[0]));
3579 RegCreateKeyW(HKEY_LOCAL_MACHINE,RunOnce,&hkey);
3580 snprintfW(buffer,sizeof(buffer)/sizeof(buffer[0]),msiexec_fmt,sysdir,
3583 msi_reg_set_val_str( hkey, squished_pc, buffer );
3586 TRACE("Reboot command %s\n",debugstr_w(buffer));
3588 RegCreateKeyW(HKEY_LOCAL_MACHINE,InstallRunOnce,&hkey);
3589 sprintfW(buffer,install_fmt,package->ProductCode,squished_pc);
3591 msi_reg_set_val_str( hkey, squished_pc, buffer );
3594 return ERROR_INSTALL_SUSPEND;
3597 UINT ACTION_ResolveSource(MSIPACKAGE* package)
3602 * we are currently doing what should be done here in the top level Install
3603 * however for Adminastrative and uninstalls this step will be needed
3605 if (!package->PackagePath)
3606 return ERROR_SUCCESS;
3608 attrib = GetFileAttributesW(package->PackagePath);
3609 if (attrib == INVALID_FILE_ATTRIBUTES)
3615 rc = MsiSourceListGetInfoW(package->ProductCode, NULL,
3616 MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT,
3617 INSTALLPROPERTY_DISKPROMPTW,NULL,&size);
3618 if (rc == ERROR_MORE_DATA)
3620 prompt = msi_alloc(size * sizeof(WCHAR));
3621 MsiSourceListGetInfoW(package->ProductCode, NULL,
3622 MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT,
3623 INSTALLPROPERTY_DISKPROMPTW,prompt,&size);
3626 prompt = strdupW(package->PackagePath);
3628 msg = generate_error_string(package,1302,1,prompt);
3629 while(attrib == INVALID_FILE_ATTRIBUTES)
3631 rc = MessageBoxW(NULL,msg,NULL,MB_OKCANCEL);
3634 rc = ERROR_INSTALL_USEREXIT;
3637 attrib = GetFileAttributesW(package->PackagePath);
3643 return ERROR_SUCCESS;
3648 static UINT ACTION_RegisterUser(MSIPACKAGE *package)
3655 static const WCHAR szPropKeys[][80] =
3657 {'P','r','o','d','u','c','t','I','D',0},
3658 {'U','S','E','R','N','A','M','E',0},
3659 {'C','O','M','P','A','N','Y','N','A','M','E',0},
3663 static const WCHAR szRegKeys[][80] =
3665 {'P','r','o','d','u','c','t','I','D',0},
3666 {'R','e','g','O','w','n','e','r',0},
3667 {'R','e','g','C','o','m','p','a','n','y',0},
3672 return ERROR_INVALID_HANDLE;
3674 productid = msi_dup_property( package, INSTALLPROPERTY_PRODUCTIDW );
3676 return ERROR_SUCCESS;
3678 rc = MSIREG_OpenUninstallKey(package->ProductCode,&hkey,TRUE);
3679 if (rc != ERROR_SUCCESS)
3682 for( i = 0; szPropKeys[i][0]; i++ )
3684 buffer = msi_dup_property( package, szPropKeys[i] );
3685 msi_reg_set_val_str( hkey, szRegKeys[i], buffer );
3690 msi_free(productid);
3693 return ERROR_SUCCESS;
3697 static UINT ACTION_ExecuteAction(MSIPACKAGE *package)
3699 static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0};
3700 static const WCHAR szTwo[] = {'2',0};
3703 level = msi_dup_property( package, szUILevel );
3705 MSI_SetPropertyW(package,szUILevel,szTwo);
3706 package->script->InWhatSequence |= SEQUENCE_EXEC;
3707 rc = ACTION_ProcessExecSequence(package,FALSE);
3708 MSI_SetPropertyW(package,szUILevel,level);
3715 * Code based off of code located here
3716 * http://www.codeproject.com/gdi/fontnamefromfile.asp
3718 * Using string index 4 (full font name) instead of 1 (family name)
3720 static LPWSTR load_ttfname_from(LPCWSTR filename)
3726 typedef struct _tagTT_OFFSET_TABLE{
3727 USHORT uMajorVersion;
3728 USHORT uMinorVersion;
3729 USHORT uNumOfTables;
3730 USHORT uSearchRange;
3731 USHORT uEntrySelector;
3735 typedef struct _tagTT_TABLE_DIRECTORY{
3736 char szTag[4]; /* table name */
3737 ULONG uCheckSum; /* Check sum */
3738 ULONG uOffset; /* Offset from beginning of file */
3739 ULONG uLength; /* length of the table in bytes */
3740 }TT_TABLE_DIRECTORY;
3742 typedef struct _tagTT_NAME_TABLE_HEADER{
3743 USHORT uFSelector; /* format selector. Always 0 */
3744 USHORT uNRCount; /* Name Records count */
3745 USHORT uStorageOffset; /* Offset for strings storage,
3746 * from start of the table */
3747 }TT_NAME_TABLE_HEADER;
3749 typedef struct _tagTT_NAME_RECORD{
3754 USHORT uStringLength;
3755 USHORT uStringOffset; /* from start of storage area */
3758 #define SWAPWORD(x) MAKEWORD(HIBYTE(x), LOBYTE(x))
3759 #define SWAPLONG(x) MAKELONG(SWAPWORD(HIWORD(x)), SWAPWORD(LOWORD(x)))
3761 handle = CreateFileW(filename ,GENERIC_READ, 0, NULL, OPEN_EXISTING,
3762 FILE_ATTRIBUTE_NORMAL, 0 );
3763 if (handle != INVALID_HANDLE_VALUE)
3765 TT_TABLE_DIRECTORY tblDir;
3766 BOOL bFound = FALSE;
3767 TT_OFFSET_TABLE ttOffsetTable;
3769 ReadFile(handle,&ttOffsetTable, sizeof(TT_OFFSET_TABLE),NULL,NULL);
3770 ttOffsetTable.uNumOfTables = SWAPWORD(ttOffsetTable.uNumOfTables);
3771 ttOffsetTable.uMajorVersion = SWAPWORD(ttOffsetTable.uMajorVersion);
3772 ttOffsetTable.uMinorVersion = SWAPWORD(ttOffsetTable.uMinorVersion);
3774 if (ttOffsetTable.uMajorVersion != 1 ||
3775 ttOffsetTable.uMinorVersion != 0)
3778 for (i=0; i< ttOffsetTable.uNumOfTables; i++)
3780 ReadFile(handle,&tblDir, sizeof(TT_TABLE_DIRECTORY),NULL,NULL);
3781 if (strncmp(tblDir.szTag,"name",4)==0)
3784 tblDir.uLength = SWAPLONG(tblDir.uLength);
3785 tblDir.uOffset = SWAPLONG(tblDir.uOffset);
3792 TT_NAME_TABLE_HEADER ttNTHeader;
3793 TT_NAME_RECORD ttRecord;
3795 SetFilePointer(handle, tblDir.uOffset, NULL, FILE_BEGIN);
3796 ReadFile(handle,&ttNTHeader, sizeof(TT_NAME_TABLE_HEADER),
3799 ttNTHeader.uNRCount = SWAPWORD(ttNTHeader.uNRCount);
3800 ttNTHeader.uStorageOffset = SWAPWORD(ttNTHeader.uStorageOffset);
3802 for(i=0; i<ttNTHeader.uNRCount; i++)
3804 ReadFile(handle,&ttRecord, sizeof(TT_NAME_RECORD),NULL,NULL);
3805 ttRecord.uNameID = SWAPWORD(ttRecord.uNameID);
3806 /* 4 is the Full Font Name */
3807 if(ttRecord.uNameID == 4)
3811 static LPCSTR tt = " (TrueType)";
3813 ttRecord.uStringLength = SWAPWORD(ttRecord.uStringLength);
3814 ttRecord.uStringOffset = SWAPWORD(ttRecord.uStringOffset);
3815 nPos = SetFilePointer(handle, 0, NULL, FILE_CURRENT);
3816 SetFilePointer(handle, tblDir.uOffset +
3817 ttRecord.uStringOffset +
3818 ttNTHeader.uStorageOffset,
3820 buf = msi_alloc( ttRecord.uStringLength + 1 + strlen(tt) );
3821 memset(buf, 0, ttRecord.uStringLength + 1 + strlen(tt));
3822 ReadFile(handle, buf, ttRecord.uStringLength, NULL, NULL);
3823 if (strlen(buf) > 0)
3826 ret = strdupAtoW(buf);
3832 SetFilePointer(handle,nPos, NULL, FILE_BEGIN);
3836 CloseHandle(handle);
3839 ERR("Unable to open font file %s\n", debugstr_w(filename));
3841 TRACE("Returning fontname %s\n",debugstr_w(ret));
3845 static UINT ITERATE_RegisterFonts(MSIRECORD *row, LPVOID param)
3847 MSIPACKAGE *package = (MSIPACKAGE*)param;
3851 static const WCHAR regfont1[] =
3852 {'S','o','f','t','w','a','r','e','\\',
3853 'M','i','c','r','o','s','o','f','t','\\',
3854 'W','i','n','d','o','w','s',' ','N','T','\\',
3855 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3856 'F','o','n','t','s',0};
3857 static const WCHAR regfont2[] =
3858 {'S','o','f','t','w','a','r','e','\\',
3859 'M','i','c','r','o','s','o','f','t','\\',
3860 'W','i','n','d','o','w','s','\\',
3861 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3862 'F','o','n','t','s',0};
3866 filename = MSI_RecordGetString( row, 1 );
3867 file = get_loaded_file( package, filename );
3870 ERR("Unable to load file\n");
3871 return ERROR_SUCCESS;
3874 /* check to make sure that component is installed */
3875 if (!ACTION_VerifyComponentForAction(package,
3876 file->Component, INSTALLSTATE_LOCAL))
3878 TRACE("Skipping: Component not scheduled for install\n");
3879 return ERROR_SUCCESS;
3882 RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont1,&hkey1);
3883 RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont2,&hkey2);
3885 if (MSI_RecordIsNull(row,2))
3886 name = load_ttfname_from( file->TargetPath );
3888 name = load_dynamic_stringW(row,2);
3892 msi_reg_set_val_str( hkey1, name, file->FileName );
3893 msi_reg_set_val_str( hkey2, name, file->FileName );
3899 return ERROR_SUCCESS;
3902 static UINT ACTION_RegisterFonts(MSIPACKAGE *package)
3906 static const WCHAR ExecSeqQuery[] =
3907 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3908 '`','F','o','n','t','`',0};
3910 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3911 if (rc != ERROR_SUCCESS)
3913 TRACE("MSI_DatabaseOpenViewW failed: %d\n", rc);
3914 return ERROR_SUCCESS;
3917 MSI_IterateRecords(view, NULL, ITERATE_RegisterFonts, package);
3918 msiobj_release(&view->hdr);
3920 return ERROR_SUCCESS;
3923 static UINT ITERATE_PublishComponent(MSIRECORD *rec, LPVOID param)
3925 MSIPACKAGE *package = (MSIPACKAGE*)param;
3926 LPCWSTR compgroupid=NULL;
3927 LPCWSTR feature=NULL;
3928 LPCWSTR text = NULL;
3929 LPCWSTR qualifier = NULL;
3930 LPCWSTR component = NULL;
3931 LPWSTR advertise = NULL;
3932 LPWSTR output = NULL;
3934 UINT rc = ERROR_SUCCESS;
3938 component = MSI_RecordGetString(rec,3);
3939 comp = get_loaded_component(package,component);
3941 if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL) &&
3942 !ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_SOURCE) &&
3943 !ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_ADVERTISED))
3945 TRACE("Skipping: Component %s not scheduled for install\n",
3946 debugstr_w(component));
3948 return ERROR_SUCCESS;
3951 compgroupid = MSI_RecordGetString(rec,1);
3953 rc = MSIREG_OpenUserComponentsKey(compgroupid, &hkey, TRUE);
3954 if (rc != ERROR_SUCCESS)
3957 text = MSI_RecordGetString(rec,4);
3958 qualifier = MSI_RecordGetString(rec,2);
3959 feature = MSI_RecordGetString(rec,5);
3961 advertise = create_component_advertise_string(package, comp, feature);
3963 sz = strlenW(advertise);
3966 sz += lstrlenW(text);
3969 sz *= sizeof(WCHAR);
3971 output = msi_alloc(sz);
3972 memset(output,0,sz);
3973 strcpyW(output,advertise);
3976 strcatW(output,text);
3978 msi_reg_set_val_multi_str( hkey, qualifier, output );
3988 * At present I am ignorning the advertised components part of this and only
3989 * focusing on the qualified component sets
3991 static UINT ACTION_PublishComponents(MSIPACKAGE *package)
3995 static const WCHAR ExecSeqQuery[] =
3996 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3997 '`','P','u','b','l','i','s','h',
3998 'C','o','m','p','o','n','e','n','t','`',0};
4000 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
4001 if (rc != ERROR_SUCCESS)
4002 return ERROR_SUCCESS;
4004 rc = MSI_IterateRecords(view, NULL, ITERATE_PublishComponent, package);
4005 msiobj_release(&view->hdr);