2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2004 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
38 #include "wine/debug.h"
43 #include "msvcrt/fcntl.h"
50 #include "wine/unicode.h"
54 #define REG_PROGRESS_VALUE 13200
55 #define COMPONENT_PROGRESS_VALUE 24000
57 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
62 static UINT
ACTION_ProcessExecSequence(MSIPACKAGE
*package
, BOOL UIran
);
63 static UINT
ACTION_ProcessUISequence(MSIPACKAGE
*package
);
64 static UINT
ACTION_PerformActionSequence(MSIPACKAGE
*package
, UINT seq
, BOOL UI
);
65 static UINT
build_icon_path(MSIPACKAGE
*package
, LPCWSTR icon_name
,
71 typedef UINT (*STANDARDACTIONHANDLER
)(MSIPACKAGE
*);
73 static UINT
ACTION_LaunchConditions(MSIPACKAGE
*package
);
74 static UINT
ACTION_CostInitialize(MSIPACKAGE
*package
);
75 static UINT
ACTION_CreateFolders(MSIPACKAGE
*package
);
76 static UINT
ACTION_CostFinalize(MSIPACKAGE
*package
);
77 static UINT
ACTION_FileCost(MSIPACKAGE
*package
);
78 static UINT
ACTION_InstallFiles(MSIPACKAGE
*package
);
79 static UINT
ACTION_DuplicateFiles(MSIPACKAGE
*package
);
80 static UINT
ACTION_WriteRegistryValues(MSIPACKAGE
*package
);
81 static UINT
ACTION_InstallInitialize(MSIPACKAGE
*package
);
82 static UINT
ACTION_InstallValidate(MSIPACKAGE
*package
);
83 static UINT
ACTION_ProcessComponents(MSIPACKAGE
*package
);
84 static UINT
ACTION_RegisterTypeLibraries(MSIPACKAGE
*package
);
85 static UINT
ACTION_RegisterClassInfo(MSIPACKAGE
*package
);
86 static UINT
ACTION_RegisterProgIdInfo(MSIPACKAGE
*package
);
87 static UINT
ACTION_RegisterExtensionInfo(MSIPACKAGE
*package
);
88 static UINT
ACTION_RegisterMIMEInfo(MSIPACKAGE
*package
);
89 static UINT
ACTION_RegisterUser(MSIPACKAGE
*package
);
90 static UINT
ACTION_CreateShortcuts(MSIPACKAGE
*package
);
91 static UINT
ACTION_PublishProduct(MSIPACKAGE
*package
);
92 static UINT
ACTION_WriteIniValues(MSIPACKAGE
*package
);
93 static UINT
ACTION_SelfRegModules(MSIPACKAGE
*package
);
94 static UINT
ACTION_PublishFeatures(MSIPACKAGE
*package
);
95 static UINT
ACTION_RegisterProduct(MSIPACKAGE
*package
);
96 static UINT
ACTION_InstallExecute(MSIPACKAGE
*package
);
97 static UINT
ACTION_InstallFinalize(MSIPACKAGE
*package
);
98 static UINT
ACTION_ForceReboot(MSIPACKAGE
*package
);
99 static UINT
ACTION_ResolveSource(MSIPACKAGE
*package
);
100 static UINT
ACTION_ExecuteAction(MSIPACKAGE
*package
);
101 static UINT
ACTION_RegisterFonts(MSIPACKAGE
*package
);
102 static UINT
ACTION_PublishComponents(MSIPACKAGE
*package
);
106 * consts and values used
108 static const WCHAR cszSourceDir
[] = {'S','o','u','r','c','e','D','i','r',0};
109 static const WCHAR cszRootDrive
[] = {'R','O','O','T','D','R','I','V','E',0};
110 static const WCHAR cszTargetDir
[] = {'T','A','R','G','E','T','D','I','R',0};
111 static const WCHAR cszTempFolder
[]= {'T','e','m','p','F','o','l','d','e','r',0};
112 static const WCHAR cszDatabase
[]={'D','A','T','A','B','A','S','E',0};
113 static const WCHAR c_colon
[] = {'C',':','\\',0};
114 static const WCHAR szProductCode
[]=
115 {'P','r','o','d','u','c','t','C','o','d','e',0};
116 static const WCHAR cszbs
[]={'\\',0};
117 const static WCHAR szCreateFolders
[] =
118 {'C','r','e','a','t','e','F','o','l','d','e','r','s',0};
119 const static WCHAR szCostFinalize
[] =
120 {'C','o','s','t','F','i','n','a','l','i','z','e',0};
121 const static WCHAR szInstallFiles
[] =
122 {'I','n','s','t','a','l','l','F','i','l','e','s',0};
123 const static WCHAR szDuplicateFiles
[] =
124 {'D','u','p','l','i','c','a','t','e','F','i','l','e','s',0};
125 const static WCHAR szWriteRegistryValues
[] =
126 {'W','r','i','t','e','R','e','g','i','s','t','r','y',
127 'V','a','l','u','e','s',0};
128 const static WCHAR szCostInitialize
[] =
129 {'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0};
130 const static WCHAR szFileCost
[] =
131 {'F','i','l','e','C','o','s','t',0};
132 const static WCHAR szInstallInitialize
[] =
133 {'I','n','s','t','a','l','l','I','n','i','t','i','a','l','i','z','e',0};
134 const static WCHAR szInstallValidate
[] =
135 {'I','n','s','t','a','l','l','V','a','l','i','d','a','t','e',0};
136 const static WCHAR szLaunchConditions
[] =
137 {'L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','s',0};
138 const static WCHAR szProcessComponents
[] =
139 {'P','r','o','c','e','s','s','C','o','m','p','o','n','e','n','t','s',0};
140 const static WCHAR szRegisterTypeLibraries
[] =
141 {'R','e','g','i','s','t','e','r','T','y','p','e',
142 'L','i','b','r','a','r','i','e','s',0};
143 const static WCHAR szRegisterClassInfo
[] =
144 {'R','e','g','i','s','t','e','r','C','l','a','s','s','I','n','f','o',0};
145 const static WCHAR szRegisterProgIdInfo
[] =
146 {'R','e','g','i','s','t','e','r','P','r','o','g','I','d','I','n','f','o',0};
147 const static WCHAR szCreateShortcuts
[] =
148 {'C','r','e','a','t','e','S','h','o','r','t','c','u','t','s',0};
149 const static WCHAR szPublishProduct
[] =
150 {'P','u','b','l','i','s','h','P','r','o','d','u','c','t',0};
151 const static WCHAR szWriteIniValues
[] =
152 {'W','r','i','t','e','I','n','i','V','a','l','u','e','s',0};
153 const static WCHAR szSelfRegModules
[] =
154 {'S','e','l','f','R','e','g','M','o','d','u','l','e','s',0};
155 const static WCHAR szPublishFeatures
[] =
156 {'P','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0};
157 const static WCHAR szRegisterProduct
[] =
158 {'R','e','g','i','s','t','e','r','P','r','o','d','u','c','t',0};
159 const static WCHAR szInstallExecute
[] =
160 {'I','n','s','t','a','l','l','E','x','e','c','u','t','e',0};
161 const static WCHAR szInstallExecuteAgain
[] =
162 {'I','n','s','t','a','l','l','E','x','e','c','u','t','e',
163 'A','g','a','i','n',0};
164 const static WCHAR szInstallFinalize
[] =
165 {'I','n','s','t','a','l','l','F','i','n','a','l','i','z','e',0};
166 const static WCHAR szForceReboot
[] =
167 {'F','o','r','c','e','R','e','b','o','o','t',0};
168 const static WCHAR szResolveSource
[] =
169 {'R','e','s','o','l','v','e','S','o','u','r','c','e',0};
170 const static WCHAR szAppSearch
[] =
171 {'A','p','p','S','e','a','r','c','h',0};
172 const static WCHAR szAllocateRegistrySpace
[] =
173 {'A','l','l','o','c','a','t','e','R','e','g','i','s','t','r','y',
174 'S','p','a','c','e',0};
175 const static WCHAR szBindImage
[] =
176 {'B','i','n','d','I','m','a','g','e',0};
177 const static WCHAR szCCPSearch
[] =
178 {'C','C','P','S','e','a','r','c','h',0};
179 const static WCHAR szDeleteServices
[] =
180 {'D','e','l','e','t','e','S','e','r','v','i','c','e','s',0};
181 const static WCHAR szDisableRollback
[] =
182 {'D','i','s','a','b','l','e','R','o','l','l','b','a','c','k',0};
183 const static WCHAR szExecuteAction
[] =
184 {'E','x','e','c','u','t','e','A','c','t','i','o','n',0};
185 const static WCHAR szFindRelatedProducts
[] =
186 {'F','i','n','d','R','e','l','a','t','e','d',
187 'P','r','o','d','u','c','t','s',0};
188 const static WCHAR szInstallAdminPackage
[] =
189 {'I','n','s','t','a','l','l','A','d','m','i','n',
190 'P','a','c','k','a','g','e',0};
191 const static WCHAR szInstallSFPCatalogFile
[] =
192 {'I','n','s','t','a','l','l','S','F','P','C','a','t','a','l','o','g',
194 const static WCHAR szIsolateComponents
[] =
195 {'I','s','o','l','a','t','e','C','o','m','p','o','n','e','n','t','s',0};
196 const static WCHAR szMigrateFeatureStates
[] =
197 {'M','i','g','r','a','t','e','F','e','a','t','u','r','e',
198 'S','t','a','t','e','s',0};
199 const static WCHAR szMoveFiles
[] =
200 {'M','o','v','e','F','i','l','e','s',0};
201 const static WCHAR szMsiPublishAssemblies
[] =
202 {'M','s','i','P','u','b','l','i','s','h',
203 'A','s','s','e','m','b','l','i','e','s',0};
204 const static WCHAR szMsiUnpublishAssemblies
[] =
205 {'M','s','i','U','n','p','u','b','l','i','s','h',
206 'A','s','s','e','m','b','l','i','e','s',0};
207 const static WCHAR szInstallODBC
[] =
208 {'I','n','s','t','a','l','l','O','D','B','C',0};
209 const static WCHAR szInstallServices
[] =
210 {'I','n','s','t','a','l','l','S','e','r','v','i','c','e','s',0};
211 const static WCHAR szPatchFiles
[] =
212 {'P','a','t','c','h','F','i','l','e','s',0};
213 const static WCHAR szPublishComponents
[] =
214 {'P','u','b','l','i','s','h','C','o','m','p','o','n','e','n','t','s',0};
215 const static WCHAR szRegisterComPlus
[] =
216 {'R','e','g','i','s','t','e','r','C','o','m','P','l','u','s',0};
217 const static WCHAR szRegisterExtensionInfo
[] =
218 {'R','e','g','i','s','t','e','r','E','x','t','e','n','s','i','o','n',
220 const static WCHAR szRegisterFonts
[] =
221 {'R','e','g','i','s','t','e','r','F','o','n','t','s',0};
222 const static WCHAR szRegisterMIMEInfo
[] =
223 {'R','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0};
224 const static WCHAR szRegisterUser
[] =
225 {'R','e','g','i','s','t','e','r','U','s','e','r',0};
226 const static WCHAR szRemoveDuplicateFiles
[] =
227 {'R','e','m','o','v','e','D','u','p','l','i','c','a','t','e',
228 'F','i','l','e','s',0};
229 const static WCHAR szRemoveEnvironmentStrings
[] =
230 {'R','e','m','o','v','e','E','n','v','i','r','o','n','m','e','n','t',
231 'S','t','r','i','n','g','s',0};
232 const static WCHAR szRemoveExistingProducts
[] =
233 {'R','e','m','o','v','e','E','x','i','s','t','i','n','g',
234 'P','r','o','d','u','c','t','s',0};
235 const static WCHAR szRemoveFiles
[] =
236 {'R','e','m','o','v','e','F','i','l','e','s',0};
237 const static WCHAR szRemoveFolders
[] =
238 {'R','e','m','o','v','e','F','o','l','d','e','r','s',0};
239 const static WCHAR szRemoveIniValues
[] =
240 {'R','e','m','o','v','e','I','n','i','V','a','l','u','e','s',0};
241 const static WCHAR szRemoveODBC
[] =
242 {'R','e','m','o','v','e','O','D','B','C',0};
243 const static WCHAR szRemoveRegistryValues
[] =
244 {'R','e','m','o','v','e','R','e','g','i','s','t','r','y',
245 'V','a','l','u','e','s',0};
246 const static WCHAR szRemoveShortcuts
[] =
247 {'R','e','m','o','v','e','S','h','o','r','t','c','u','t','s',0};
248 const static WCHAR szRMCCPSearch
[] =
249 {'R','M','C','C','P','S','e','a','r','c','h',0};
250 const static WCHAR szScheduleReboot
[] =
251 {'S','c','h','e','d','u','l','e','R','e','b','o','o','t',0};
252 const static WCHAR szSelfUnregModules
[] =
253 {'S','e','l','f','U','n','r','e','g','M','o','d','u','l','e','s',0};
254 const static WCHAR szSetODBCFolders
[] =
255 {'S','e','t','O','D','B','C','F','o','l','d','e','r','s',0};
256 const static WCHAR szStartServices
[] =
257 {'S','t','a','r','t','S','e','r','v','i','c','e','s',0};
258 const static WCHAR szStopServices
[] =
259 {'S','t','o','p','S','e','r','v','i','c','e','s',0};
260 const static WCHAR szUnpublishComponents
[] =
261 {'U','n','p','u','b','l','i','s','h',
262 'C','o','m','p','o','n','e','n','t','s',0};
263 const static WCHAR szUnpublishFeatures
[] =
264 {'U','n','p','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0};
265 const static WCHAR szUnregisterClassInfo
[] =
266 {'U','n','r','e','g','i','s','t','e','r','C','l','a','s','s',
268 const static WCHAR szUnregisterComPlus
[] =
269 {'U','n','r','e','g','i','s','t','e','r','C','o','m','P','l','u','s',0};
270 const static WCHAR szUnregisterExtensionInfo
[] =
271 {'U','n','r','e','g','i','s','t','e','r',
272 'E','x','t','e','n','s','i','o','n','I','n','f','o',0};
273 const static WCHAR szUnregisterFonts
[] =
274 {'U','n','r','e','g','i','s','t','e','r','F','o','n','t','s',0};
275 const static WCHAR szUnregisterMIMEInfo
[] =
276 {'U','n','r','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0};
277 const static WCHAR szUnregisterProgIdInfo
[] =
278 {'U','n','r','e','g','i','s','t','e','r','P','r','o','g','I','d',
280 const static WCHAR szUnregisterTypeLibraries
[] =
281 {'U','n','r','e','g','i','s','t','e','r','T','y','p','e',
282 'L','i','b','r','a','r','i','e','s',0};
283 const static WCHAR szValidateProductID
[] =
284 {'V','a','l','i','d','a','t','e','P','r','o','d','u','c','t','I','D',0};
285 const static WCHAR szWriteEnvironmentStrings
[] =
286 {'W','r','i','t','e','E','n','v','i','r','o','n','m','e','n','t',
287 'S','t','r','i','n','g','s',0};
291 STANDARDACTIONHANDLER handler
;
294 static struct _actions StandardActions
[] = {
295 { szAllocateRegistrySpace
, NULL
},
296 { szAppSearch
, ACTION_AppSearch
},
297 { szBindImage
, NULL
},
298 { szCCPSearch
, NULL
},
299 { szCostFinalize
, ACTION_CostFinalize
},
300 { szCostInitialize
, ACTION_CostInitialize
},
301 { szCreateFolders
, ACTION_CreateFolders
},
302 { szCreateShortcuts
, ACTION_CreateShortcuts
},
303 { szDeleteServices
, NULL
},
304 { szDisableRollback
, NULL
},
305 { szDuplicateFiles
, ACTION_DuplicateFiles
},
306 { szExecuteAction
, ACTION_ExecuteAction
},
307 { szFileCost
, ACTION_FileCost
},
308 { szFindRelatedProducts
, NULL
},
309 { szForceReboot
, ACTION_ForceReboot
},
310 { szInstallAdminPackage
, NULL
},
311 { szInstallExecute
, ACTION_InstallExecute
},
312 { szInstallExecuteAgain
, ACTION_InstallExecute
},
313 { szInstallFiles
, ACTION_InstallFiles
},
314 { szInstallFinalize
, ACTION_InstallFinalize
},
315 { szInstallInitialize
, ACTION_InstallInitialize
},
316 { szInstallSFPCatalogFile
, NULL
},
317 { szInstallValidate
, ACTION_InstallValidate
},
318 { szIsolateComponents
, NULL
},
319 { szLaunchConditions
, ACTION_LaunchConditions
},
320 { szMigrateFeatureStates
, NULL
},
321 { szMoveFiles
, NULL
},
322 { szMsiPublishAssemblies
, NULL
},
323 { szMsiUnpublishAssemblies
, NULL
},
324 { szInstallODBC
, NULL
},
325 { szInstallServices
, NULL
},
326 { szPatchFiles
, NULL
},
327 { szProcessComponents
, ACTION_ProcessComponents
},
328 { szPublishComponents
, ACTION_PublishComponents
},
329 { szPublishFeatures
, ACTION_PublishFeatures
},
330 { szPublishProduct
, ACTION_PublishProduct
},
331 { szRegisterClassInfo
, ACTION_RegisterClassInfo
},
332 { szRegisterComPlus
, NULL
},
333 { szRegisterExtensionInfo
, ACTION_RegisterExtensionInfo
},
334 { szRegisterFonts
, ACTION_RegisterFonts
},
335 { szRegisterMIMEInfo
, ACTION_RegisterMIMEInfo
},
336 { szRegisterProduct
, ACTION_RegisterProduct
},
337 { szRegisterProgIdInfo
, ACTION_RegisterProgIdInfo
},
338 { szRegisterTypeLibraries
, ACTION_RegisterTypeLibraries
},
339 { szRegisterUser
, ACTION_RegisterUser
},
340 { szRemoveDuplicateFiles
, NULL
},
341 { szRemoveEnvironmentStrings
, NULL
},
342 { szRemoveExistingProducts
, NULL
},
343 { szRemoveFiles
, NULL
},
344 { szRemoveFolders
, NULL
},
345 { szRemoveIniValues
, NULL
},
346 { szRemoveODBC
, NULL
},
347 { szRemoveRegistryValues
, NULL
},
348 { szRemoveShortcuts
, NULL
},
349 { szResolveSource
, ACTION_ResolveSource
},
350 { szRMCCPSearch
, NULL
},
351 { szScheduleReboot
, NULL
},
352 { szSelfRegModules
, ACTION_SelfRegModules
},
353 { szSelfUnregModules
, NULL
},
354 { szSetODBCFolders
, NULL
},
355 { szStartServices
, NULL
},
356 { szStopServices
, NULL
},
357 { szUnpublishComponents
, NULL
},
358 { szUnpublishFeatures
, NULL
},
359 { szUnregisterClassInfo
, NULL
},
360 { szUnregisterComPlus
, NULL
},
361 { szUnregisterExtensionInfo
, NULL
},
362 { szUnregisterFonts
, NULL
},
363 { szUnregisterMIMEInfo
, NULL
},
364 { szUnregisterProgIdInfo
, NULL
},
365 { szUnregisterTypeLibraries
, NULL
},
366 { szValidateProductID
, NULL
},
367 { szWriteEnvironmentStrings
, NULL
},
368 { szWriteIniValues
, ACTION_WriteIniValues
},
369 { szWriteRegistryValues
, ACTION_WriteRegistryValues
},
374 /********************************************************
375 * helper functions to get around current HACKS and such
376 ********************************************************/
377 inline static void reduce_to_longfilename(WCHAR
* filename
)
379 LPWSTR p
= strchrW(filename
,'|');
381 memmove(filename
, p
+1, (strlenW(p
+1)+1)*sizeof(WCHAR
));
384 WCHAR
*load_dynamic_stringW(MSIRECORD
*row
, INT index
)
391 if (MSI_RecordIsNull(row
,index
))
394 rc
= MSI_RecordGetStringW(row
,index
,NULL
,&sz
);
396 /* having an empty string is different than NULL */
399 ret
= HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
));
405 ret
= HeapAlloc(GetProcessHeap(),0,sz
* sizeof (WCHAR
));
406 rc
= MSI_RecordGetStringW(row
,index
,ret
,&sz
);
407 if (rc
!=ERROR_SUCCESS
)
409 ERR("Unable to load dynamic string\n");
410 HeapFree(GetProcessHeap(), 0, ret
);
416 LPWSTR
load_dynamic_property(MSIPACKAGE
*package
, LPCWSTR prop
, UINT
* rc
)
422 r
= MSI_GetPropertyW(package
, prop
, NULL
, &sz
);
423 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
430 str
= HeapAlloc(GetProcessHeap(),0,sz
*sizeof(WCHAR
));
431 r
= MSI_GetPropertyW(package
, prop
, str
, &sz
);
432 if (r
!= ERROR_SUCCESS
)
434 HeapFree(GetProcessHeap(),0,str
);
442 int get_loaded_component(MSIPACKAGE
* package
, LPCWSTR Component
)
447 for (i
= 0; i
< package
->loaded_components
; i
++)
449 if (strcmpW(Component
,package
->components
[i
].Component
)==0)
458 int get_loaded_feature(MSIPACKAGE
* package
, LPCWSTR Feature
)
463 for (i
= 0; i
< package
->loaded_features
; i
++)
465 if (strcmpW(Feature
,package
->features
[i
].Feature
)==0)
474 int get_loaded_file(MSIPACKAGE
* package
, LPCWSTR file
)
479 for (i
= 0; i
< package
->loaded_files
; i
++)
481 if (strcmpW(file
,package
->files
[i
].File
)==0)
490 int track_tempfile(MSIPACKAGE
*package
, LPCWSTR name
, LPCWSTR path
)
498 for (i
=0; i
< package
->loaded_files
; i
++)
499 if (strcmpW(package
->files
[i
].File
,name
)==0)
502 index
= package
->loaded_files
;
503 package
->loaded_files
++;
504 if (package
->loaded_files
== 1)
505 package
->files
= HeapAlloc(GetProcessHeap(),0,sizeof(MSIFILE
));
507 package
->files
= HeapReAlloc(GetProcessHeap(),0,
508 package
->files
, package
->loaded_files
* sizeof(MSIFILE
));
510 memset(&package
->files
[index
],0,sizeof(MSIFILE
));
512 package
->files
[index
].File
= strdupW(name
);
513 package
->files
[index
].TargetPath
= strdupW(path
);
514 package
->files
[index
].Temporary
= TRUE
;
516 TRACE("Tracking tempfile (%s)\n",debugstr_w(package
->files
[index
].File
));
521 static void remove_tracked_tempfiles(MSIPACKAGE
* package
)
528 for (i
= 0; i
< package
->loaded_files
; i
++)
530 if (package
->files
[i
].Temporary
)
532 TRACE("Cleaning up %s\n",debugstr_w(package
->files
[i
].TargetPath
));
533 DeleteFileW(package
->files
[i
].TargetPath
);
539 /* wrapper to resist a need for a full rewrite right now */
540 DWORD
deformat_string(MSIPACKAGE
*package
, LPCWSTR ptr
, WCHAR
** data
)
544 MSIRECORD
*rec
= MSI_CreateRecord(1);
547 MSI_RecordSetStringW(rec
,0,ptr
);
548 MSI_FormatRecordW(package
,rec
,NULL
,&size
);
552 *data
= HeapAlloc(GetProcessHeap(),0,size
*sizeof(WCHAR
));
554 MSI_FormatRecordW(package
,rec
,*data
,&size
);
557 msiobj_release( &rec
->hdr
);
558 return sizeof(WCHAR
)*size
;
560 msiobj_release( &rec
->hdr
);
567 /* Called when the package is being closed */
568 void ACTION_free_package_structures( MSIPACKAGE
* package
)
572 TRACE("Freeing package action data\n");
574 remove_tracked_tempfiles(package
);
576 /* No dynamic buffers in features */
577 if (package
->features
&& package
->loaded_features
> 0)
578 HeapFree(GetProcessHeap(),0,package
->features
);
580 for (i
= 0; i
< package
->loaded_folders
; i
++)
582 HeapFree(GetProcessHeap(),0,package
->folders
[i
].Directory
);
583 HeapFree(GetProcessHeap(),0,package
->folders
[i
].TargetDefault
);
584 HeapFree(GetProcessHeap(),0,package
->folders
[i
].SourceDefault
);
585 HeapFree(GetProcessHeap(),0,package
->folders
[i
].ResolvedTarget
);
586 HeapFree(GetProcessHeap(),0,package
->folders
[i
].ResolvedSource
);
587 HeapFree(GetProcessHeap(),0,package
->folders
[i
].Property
);
589 if (package
->folders
&& package
->loaded_folders
> 0)
590 HeapFree(GetProcessHeap(),0,package
->folders
);
592 for (i
= 0; i
< package
->loaded_components
; i
++)
593 HeapFree(GetProcessHeap(),0,package
->components
[i
].FullKeypath
);
595 if (package
->components
&& package
->loaded_components
> 0)
596 HeapFree(GetProcessHeap(),0,package
->components
);
598 for (i
= 0; i
< package
->loaded_files
; i
++)
600 HeapFree(GetProcessHeap(),0,package
->files
[i
].File
);
601 HeapFree(GetProcessHeap(),0,package
->files
[i
].FileName
);
602 HeapFree(GetProcessHeap(),0,package
->files
[i
].Version
);
603 HeapFree(GetProcessHeap(),0,package
->files
[i
].Language
);
604 HeapFree(GetProcessHeap(),0,package
->files
[i
].SourcePath
);
605 HeapFree(GetProcessHeap(),0,package
->files
[i
].TargetPath
);
608 if (package
->files
&& package
->loaded_files
> 0)
609 HeapFree(GetProcessHeap(),0,package
->files
);
611 for (i
= 0; i
< package
->DeferredActionCount
; i
++)
612 HeapFree(GetProcessHeap(),0,package
->DeferredAction
[i
]);
613 HeapFree(GetProcessHeap(),0,package
->DeferredAction
);
615 for (i
= 0; i
< package
->CommitActionCount
; i
++)
616 HeapFree(GetProcessHeap(),0,package
->CommitAction
[i
]);
617 HeapFree(GetProcessHeap(),0,package
->CommitAction
);
619 HeapFree(GetProcessHeap(),0,package
->PackagePath
);
622 static void ui_progress(MSIPACKAGE
*package
, int a
, int b
, int c
, int d
)
626 row
= MSI_CreateRecord(4);
627 MSI_RecordSetInteger(row
,1,a
);
628 MSI_RecordSetInteger(row
,2,b
);
629 MSI_RecordSetInteger(row
,3,c
);
630 MSI_RecordSetInteger(row
,4,d
);
631 MSI_ProcessMessage(package
, INSTALLMESSAGE_PROGRESS
, row
);
632 msiobj_release(&row
->hdr
);
634 msi_dialog_check_messages(package
->dialog
, NULL
);
637 static void ui_actiondata(MSIPACKAGE
*package
, LPCWSTR action
, MSIRECORD
* record
)
639 static const WCHAR Query_t
[] =
640 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
641 'A','c','t','i','o', 'n','T','e','x','t',' ','W','H','E','R','E',' ',
642 'A','c','t','i','o','n',' ','=', ' ','\'','%','s','\'',0};
649 if (!package
->LastAction
|| strcmpW(package
->LastAction
,action
))
651 rc
= MSI_OpenQuery(package
->db
, &view
, Query_t
, action
);
652 if (rc
!= ERROR_SUCCESS
)
655 rc
= MSI_ViewExecute(view
, 0);
656 if (rc
!= ERROR_SUCCESS
)
661 rc
= MSI_ViewFetch(view
,&row
);
662 if (rc
!= ERROR_SUCCESS
)
668 if (MSI_RecordIsNull(row
,3))
670 msiobj_release(&row
->hdr
);
672 msiobj_release(&view
->hdr
);
676 /* update the cached actionformat */
677 HeapFree(GetProcessHeap(),0,package
->ActionFormat
);
678 package
->ActionFormat
= load_dynamic_stringW(row
,3);
680 HeapFree(GetProcessHeap(),0,package
->LastAction
);
681 package
->LastAction
= strdupW(action
);
683 msiobj_release(&row
->hdr
);
685 msiobj_release(&view
->hdr
);
688 MSI_RecordSetStringW(record
,0,package
->ActionFormat
);
690 MSI_FormatRecordW(package
,record
,message
,&size
);
692 row
= MSI_CreateRecord(1);
693 MSI_RecordSetStringW(row
,1,message
);
695 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONDATA
, row
);
696 msiobj_release(&row
->hdr
);
700 static void ui_actionstart(MSIPACKAGE
*package
, LPCWSTR action
)
702 static const WCHAR template_s
[]=
703 {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ', '%','s',
705 static const WCHAR format
[] =
706 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
707 static const WCHAR Query_t
[] =
708 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
709 'A','c','t','i','o', 'n','T','e','x','t',' ','W','H','E','R','E', ' ',
710 'A','c','t','i','o','n',' ','=', ' ','\'','%','s','\'',0};
716 WCHAR
*ActionText
=NULL
;
718 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0, NULL
, format
, timet
, 0x100);
720 rc
= MSI_OpenQuery(package
->db
, &view
, Query_t
, action
);
721 if (rc
!= ERROR_SUCCESS
)
723 rc
= MSI_ViewExecute(view
, 0);
724 if (rc
!= ERROR_SUCCESS
)
727 msiobj_release(&view
->hdr
);
730 rc
= MSI_ViewFetch(view
,&row
);
731 if (rc
!= ERROR_SUCCESS
)
734 msiobj_release(&view
->hdr
);
738 ActionText
= load_dynamic_stringW(row
,2);
739 msiobj_release(&row
->hdr
);
741 msiobj_release(&view
->hdr
);
743 sprintfW(message
,template_s
,timet
,action
,ActionText
);
745 row
= MSI_CreateRecord(1);
746 MSI_RecordSetStringW(row
,1,message
);
748 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONSTART
, row
);
749 msiobj_release(&row
->hdr
);
750 HeapFree(GetProcessHeap(),0,ActionText
);
753 static void ui_actioninfo(MSIPACKAGE
*package
, LPCWSTR action
, BOOL start
,
757 static const WCHAR template_s
[]=
758 {'A','c','t','i','o','n',' ','s','t','a','r','t',' ','%','s',':',' ',
760 static const WCHAR template_e
[]=
761 {'A','c','t','i','o','n',' ','e','n','d','e','d',' ','%','s',':',' ',
762 '%','s', '.',' ','R','e','t','u','r','n',' ','v','a','l','u','e',' ',
764 static const WCHAR format
[] =
765 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
769 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0, NULL
, format
, timet
, 0x100);
771 sprintfW(message
,template_s
,timet
,action
);
773 sprintfW(message
,template_e
,timet
,action
,rc
);
775 row
= MSI_CreateRecord(1);
776 MSI_RecordSetStringW(row
,1,message
);
778 MSI_ProcessMessage(package
, INSTALLMESSAGE_INFO
, row
);
779 msiobj_release(&row
->hdr
);
783 * build_directory_name()
785 * This function is to save messing round with directory names
786 * It handles adding backslashes between path segments,
787 * and can add \ at the end of the directory name if told to.
789 * It takes a variable number of arguments.
790 * It always allocates a new string for the result, so make sure
791 * to free the return value when finished with it.
793 * The first arg is the number of path segments that follow.
794 * The arguments following count are a list of path segments.
795 * A path segment may be NULL.
797 * Path segments will be added with a \ separating them.
798 * A \ will not be added after the last segment, however if the
799 * last segment is NULL, then the last character will be a \
802 static LPWSTR
build_directory_name(DWORD count
, ...)
809 for(i
=0; i
<count
; i
++)
811 LPCWSTR str
= va_arg(va
,LPCWSTR
);
813 sz
+= strlenW(str
) + 1;
817 dir
= HeapAlloc(GetProcessHeap(), 0, sz
*sizeof(WCHAR
));
821 for(i
=0; i
<count
; i
++)
823 LPCWSTR str
= va_arg(va
,LPCWSTR
);
827 if( ((i
+1)!=count
) && dir
[strlenW(dir
)-1]!='\\')
833 static BOOL
ACTION_VerifyComponentForAction(MSIPACKAGE
* package
, INT index
,
836 if (package
->components
[index
].Installed
== check
)
839 if (package
->components
[index
].ActionRequest
== check
)
845 static BOOL
ACTION_VerifyFeatureForAction(MSIPACKAGE
* package
, INT index
,
848 if (package
->features
[index
].Installed
== check
)
851 if (package
->features
[index
].ActionRequest
== check
)
858 /****************************************************
859 * TOP level entry points
860 *****************************************************/
862 UINT
ACTION_DoTopLevelINSTALL(MSIPACKAGE
*package
, LPCWSTR szPackagePath
,
863 LPCWSTR szCommandLine
)
869 static const WCHAR szUILevel
[] = {'U','I','L','e','v','e','l',0};
870 static const WCHAR szAction
[] = {'A','C','T','I','O','N',0};
871 static const WCHAR szInstall
[] = {'I','N','S','T','A','L','L',0};
873 MSI_SetPropertyW(package
, szAction
, szInstall
);
874 package
->ExecuteSequenceRun
= FALSE
;
878 LPWSTR p
, check
, path
;
880 package
->PackagePath
= strdupW(szPackagePath
);
881 path
= strdupW(szPackagePath
);
882 p
= strrchrW(path
,'\\');
890 HeapFree(GetProcessHeap(),0,path
);
891 path
= HeapAlloc(GetProcessHeap(),0,MAX_PATH
*sizeof(WCHAR
));
892 GetCurrentDirectoryW(MAX_PATH
,path
);
896 check
= load_dynamic_property(package
, cszSourceDir
,NULL
);
898 MSI_SetPropertyW(package
, cszSourceDir
, path
);
900 HeapFree(GetProcessHeap(), 0, check
);
902 HeapFree(GetProcessHeap(), 0, path
);
908 ptr
= (LPWSTR
)szCommandLine
;
915 TRACE("Looking at %s\n",debugstr_w(ptr
));
917 ptr2
= strchrW(ptr
,'=');
923 while (*ptr
== ' ') ptr
++;
925 prop
= HeapAlloc(GetProcessHeap(),0,(len
+1)*sizeof(WCHAR
));
926 memcpy(prop
,ptr
,len
*sizeof(WCHAR
));
932 while (*ptr
&& (quote
|| (!quote
&& *ptr
!=' ')))
945 val
= HeapAlloc(GetProcessHeap(),0,(len
+1)*sizeof(WCHAR
));
946 memcpy(val
,ptr2
,len
*sizeof(WCHAR
));
949 if (strlenW(prop
) > 0)
951 TRACE("Found commandline property (%s) = (%s)\n",
952 debugstr_w(prop
), debugstr_w(val
));
953 MSI_SetPropertyW(package
,prop
,val
);
955 HeapFree(GetProcessHeap(),0,val
);
956 HeapFree(GetProcessHeap(),0,prop
);
963 if (MSI_GetPropertyW(package
,szUILevel
,buffer
,&sz
) == ERROR_SUCCESS
)
965 if (atoiW(buffer
) >= INSTALLUILEVEL_REDUCED
)
967 rc
= ACTION_ProcessUISequence(package
);
969 if (rc
== ERROR_SUCCESS
)
970 rc
= ACTION_ProcessExecSequence(package
,TRUE
);
973 rc
= ACTION_ProcessExecSequence(package
,FALSE
);
976 rc
= ACTION_ProcessExecSequence(package
,FALSE
);
980 /* install was halted but should be considered a success */
984 /* process the ending type action */
985 if (rc
== ERROR_SUCCESS
)
986 ACTION_PerformActionSequence(package
,-1,ui
);
987 else if (rc
== ERROR_INSTALL_USEREXIT
)
988 ACTION_PerformActionSequence(package
,-2,ui
);
989 else if (rc
== ERROR_FUNCTION_FAILED
)
990 ACTION_PerformActionSequence(package
,-3,ui
);
991 else if (rc
== ERROR_INSTALL_SUSPEND
)
992 ACTION_PerformActionSequence(package
,-4,ui
);
994 /* finish up running custom actions */
995 ACTION_FinishCustomActions(package
);
1000 static UINT
ACTION_PerformActionSequence(MSIPACKAGE
*package
, UINT seq
, BOOL UI
)
1004 WCHAR buffer
[0x100];
1006 MSIRECORD
* row
= 0;
1007 static const WCHAR ExecSeqQuery
[] =
1008 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1009 'I','n','s','t','a','l','l','E','x','e','c','u','t','e',
1010 'S','e','q','u','e','n','c','e',' ', 'W','H','E','R','E',' ',
1011 'S','e','q','u','e','n','c','e',' ', '=',' ','%','i',0};
1013 static const WCHAR UISeqQuery
[] =
1014 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1015 'I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e',
1016 ' ', 'W','H','E','R','E',' ', 'S','e','q','u','e','n','c','e',
1017 ' ', '=',' ','%','i',0};
1020 rc
= MSI_OpenQuery(package
->db
, &view
, UISeqQuery
, seq
);
1022 rc
= MSI_OpenQuery(package
->db
, &view
, ExecSeqQuery
, seq
);
1024 if (rc
== ERROR_SUCCESS
)
1026 rc
= MSI_ViewExecute(view
, 0);
1028 if (rc
!= ERROR_SUCCESS
)
1030 MSI_ViewClose(view
);
1031 msiobj_release(&view
->hdr
);
1035 TRACE("Running the actions\n");
1037 rc
= MSI_ViewFetch(view
,&row
);
1038 if (rc
!= ERROR_SUCCESS
)
1044 /* check conditions */
1045 if (!MSI_RecordIsNull(row
,2))
1048 cond
= load_dynamic_stringW(row
,2);
1052 /* this is a hack to skip errors in the condition code */
1053 if (MSI_EvaluateConditionW(package
, cond
) == MSICONDITION_FALSE
)
1055 HeapFree(GetProcessHeap(),0,cond
);
1056 msiobj_release(&row
->hdr
);
1060 HeapFree(GetProcessHeap(),0,cond
);
1065 rc
= MSI_RecordGetStringW(row
,1,buffer
,&sz
);
1066 if (rc
!= ERROR_SUCCESS
)
1068 ERR("Error is %x\n",rc
);
1069 msiobj_release(&row
->hdr
);
1074 rc
= ACTION_PerformUIAction(package
,buffer
);
1076 rc
= ACTION_PerformAction(package
,buffer
);
1077 msiobj_release(&row
->hdr
);
1079 MSI_ViewClose(view
);
1080 msiobj_release(&view
->hdr
);
1088 static UINT
ACTION_ProcessExecSequence(MSIPACKAGE
*package
, BOOL UIran
)
1092 static const WCHAR ExecSeqQuery
[] =
1093 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
1094 'I','n','s','t','a','l','l','E','x','e','c','u','t','e',
1095 'S','e','q','u','e','n','c','e',' ', 'W','H','E','R','E',' ',
1096 'S','e','q','u','e','n','c','e',' ', '>',' ','%','i',' ',
1097 'O','R','D','E','R',' ', 'B','Y',' ',
1098 'S','e','q','u','e','n','c','e',0 };
1099 MSIRECORD
* row
= 0;
1100 static const WCHAR IVQuery
[] =
1101 {'S','E','L','E','C','T',' ','S','e','q','u','e','n','c','e',' ',
1102 'F','R','O','M',' ','I','n','s','t','a','l','l',
1103 'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e',' ',
1104 'W','H','E','R','E',' ','A','c','t','i','o','n',' ','=',' ','`',
1105 'I','n','s','t','a','l','l','V','a','l','i','d','a','t','e','`', 0};
1109 if (package
->ExecuteSequenceRun
)
1111 TRACE("Execute Sequence already Run\n");
1112 return ERROR_SUCCESS
;
1115 package
->ExecuteSequenceRun
= TRUE
;
1117 /* get the sequence number */
1120 rc
= MSI_DatabaseOpenViewW(package
->db
, IVQuery
, &view
);
1121 if (rc
!= ERROR_SUCCESS
)
1123 rc
= MSI_ViewExecute(view
, 0);
1124 if (rc
!= ERROR_SUCCESS
)
1126 MSI_ViewClose(view
);
1127 msiobj_release(&view
->hdr
);
1130 rc
= MSI_ViewFetch(view
,&row
);
1131 if (rc
!= ERROR_SUCCESS
)
1133 MSI_ViewClose(view
);
1134 msiobj_release(&view
->hdr
);
1137 seq
= MSI_RecordGetInteger(row
,1);
1138 msiobj_release(&row
->hdr
);
1139 MSI_ViewClose(view
);
1140 msiobj_release(&view
->hdr
);
1143 rc
= MSI_OpenQuery(package
->db
, &view
, ExecSeqQuery
, seq
);
1144 if (rc
== ERROR_SUCCESS
)
1146 rc
= MSI_ViewExecute(view
, 0);
1148 if (rc
!= ERROR_SUCCESS
)
1150 MSI_ViewClose(view
);
1151 msiobj_release(&view
->hdr
);
1155 TRACE("Running the actions\n");
1159 WCHAR buffer
[0x100];
1162 rc
= MSI_ViewFetch(view
,&row
);
1163 if (rc
!= ERROR_SUCCESS
)
1169 /* check conditions */
1170 if (!MSI_RecordIsNull(row
,2))
1173 cond
= load_dynamic_stringW(row
,2);
1177 /* this is a hack to skip errors in the condition code */
1178 if (MSI_EvaluateConditionW(package
, cond
) ==
1181 HeapFree(GetProcessHeap(),0,cond
);
1182 msiobj_release(&row
->hdr
);
1186 HeapFree(GetProcessHeap(),0,cond
);
1191 rc
= MSI_RecordGetStringW(row
,1,buffer
,&sz
);
1192 if (rc
!= ERROR_SUCCESS
)
1194 ERR("Error is %x\n",rc
);
1195 msiobj_release(&row
->hdr
);
1199 rc
= ACTION_PerformAction(package
,buffer
);
1201 if (rc
== ERROR_FUNCTION_NOT_CALLED
)
1204 if (rc
!= ERROR_SUCCESS
)
1206 ERR("Execution halted due to error (%i)\n",rc
);
1207 msiobj_release(&row
->hdr
);
1211 msiobj_release(&row
->hdr
);
1214 MSI_ViewClose(view
);
1215 msiobj_release(&view
->hdr
);
1223 static UINT
ACTION_ProcessUISequence(MSIPACKAGE
*package
)
1227 static const WCHAR ExecSeqQuery
[] =
1228 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1229 'I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e',
1230 ' ','W','H','E','R','E',' ', 'S','e','q','u','e','n','c','e',' ',
1231 '>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
1232 'S','e','q','u','e','n','c','e',0};
1234 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
1236 if (rc
== ERROR_SUCCESS
)
1238 rc
= MSI_ViewExecute(view
, 0);
1240 if (rc
!= ERROR_SUCCESS
)
1242 MSI_ViewClose(view
);
1243 msiobj_release(&view
->hdr
);
1247 TRACE("Running the actions \n");
1251 WCHAR buffer
[0x100];
1253 MSIRECORD
* row
= 0;
1255 rc
= MSI_ViewFetch(view
,&row
);
1256 if (rc
!= ERROR_SUCCESS
)
1262 /* check conditions */
1263 if (!MSI_RecordIsNull(row
,2))
1266 cond
= load_dynamic_stringW(row
,2);
1270 /* this is a hack to skip errors in the condition code */
1271 if (MSI_EvaluateConditionW(package
, cond
) ==
1274 HeapFree(GetProcessHeap(),0,cond
);
1275 msiobj_release(&row
->hdr
);
1279 HeapFree(GetProcessHeap(),0,cond
);
1284 rc
= MSI_RecordGetStringW(row
,1,buffer
,&sz
);
1285 if (rc
!= ERROR_SUCCESS
)
1287 ERR("Error is %x\n",rc
);
1288 msiobj_release(&row
->hdr
);
1292 rc
= ACTION_PerformUIAction(package
,buffer
);
1294 if (rc
== ERROR_FUNCTION_NOT_CALLED
)
1297 if (rc
!= ERROR_SUCCESS
)
1299 ERR("Execution halted due to error (%i)\n",rc
);
1300 msiobj_release(&row
->hdr
);
1304 msiobj_release(&row
->hdr
);
1307 MSI_ViewClose(view
);
1308 msiobj_release(&view
->hdr
);
1315 /********************************************************
1316 * ACTION helper functions and functions that perform the actions
1317 *******************************************************/
1318 BOOL
ACTION_HandleStandardAction(MSIPACKAGE
*package
, LPCWSTR action
, UINT
* rc
)
1324 while (StandardActions
[i
].action
!= NULL
)
1326 if (strcmpW(StandardActions
[i
].action
, action
)==0)
1328 ui_actioninfo(package
, action
, TRUE
, 0);
1329 ui_actionstart(package
, action
);
1330 if (StandardActions
[i
].handler
)
1332 *rc
= StandardActions
[i
].handler(package
);
1336 FIXME("UNHANDLED Standard Action %s\n",debugstr_w(action
));
1337 *rc
= ERROR_SUCCESS
;
1339 ui_actioninfo(package
, action
, FALSE
, *rc
);
1348 BOOL
ACTION_HandleDialogBox(MSIPACKAGE
*package
, LPCWSTR dialog
, UINT
* rc
)
1353 * for the UI when we get that working
1355 if (ACTION_DialogBox(package,dialog) == ERROR_SUCCESS)
1357 *rc = package->CurrentInstallState;
1364 BOOL
ACTION_HandleCustomAction(MSIPACKAGE
* package
, LPCWSTR action
, UINT
* rc
)
1369 arc
= ACTION_CustomAction(package
,action
,FALSE
);
1371 if (arc
!= ERROR_CALL_NOT_IMPLEMENTED
)
1380 * A lot of actions are really important even if they don't do anything
1381 * explicit... Lots of properties are set at the beginning of the installation
1382 * CostFinalize does a bunch of work to translate the directories and such
1384 * But until I get write access to the database that is hard, so I am going to
1385 * hack it to see if I can get something to run.
1387 UINT
ACTION_PerformAction(MSIPACKAGE
*package
, const WCHAR
*action
)
1389 UINT rc
= ERROR_SUCCESS
;
1392 TRACE("Performing action (%s)\n",debugstr_w(action
));
1394 handled
= ACTION_HandleStandardAction(package
, action
, &rc
);
1397 handled
= ACTION_HandleCustomAction(package
, action
, &rc
);
1401 FIXME("UNHANDLED MSI ACTION %s\n",debugstr_w(action
));
1402 rc
= ERROR_FUNCTION_NOT_CALLED
;
1405 package
->CurrentInstallState
= rc
;
1409 UINT
ACTION_PerformUIAction(MSIPACKAGE
*package
, const WCHAR
*action
)
1411 UINT rc
= ERROR_SUCCESS
;
1412 BOOL handled
= FALSE
;
1414 TRACE("Performing action (%s)\n",debugstr_w(action
));
1416 handled
= ACTION_HandleStandardAction(package
, action
, &rc
);
1419 handled
= ACTION_HandleCustomAction(package
, action
, &rc
);
1422 handled
= ACTION_HandleDialogBox(package
, action
, &rc
);
1424 msi_dialog_check_messages( package
->dialog
, NULL
);
1428 FIXME("UNHANDLED MSI ACTION %s\n",debugstr_w(action
));
1429 rc
= ERROR_FUNCTION_NOT_CALLED
;
1432 package
->CurrentInstallState
= rc
;
1436 /***********************************************************************
1439 * Recursively create all directories in the path.
1441 * shamelessly stolen from setupapi/queue.c
1443 static BOOL
create_full_pathW(const WCHAR
*path
)
1449 new_path
= HeapAlloc(GetProcessHeap(), 0, (strlenW(path
) + 1) *
1452 strcpyW(new_path
, path
);
1454 while((len
= strlenW(new_path
)) && new_path
[len
- 1] == '\\')
1455 new_path
[len
- 1] = 0;
1457 while(!CreateDirectoryW(new_path
, NULL
))
1460 DWORD last_error
= GetLastError();
1461 if(last_error
== ERROR_ALREADY_EXISTS
)
1464 if(last_error
!= ERROR_PATH_NOT_FOUND
)
1470 if(!(slash
= strrchrW(new_path
, '\\')))
1476 len
= slash
- new_path
;
1478 if(!create_full_pathW(new_path
))
1483 new_path
[len
] = '\\';
1486 HeapFree(GetProcessHeap(), 0, new_path
);
1491 * Also we cannot enable/disable components either, so for now I am just going
1492 * to do all the directories for all the components.
1494 static UINT
ACTION_CreateFolders(MSIPACKAGE
*package
)
1496 static const WCHAR ExecSeqQuery
[] =
1497 {'S','E','L','E','C','T',' ','D','i','r','e','c','t','o','r','y','_',
1498 ' ','F','R','O','M',' ',
1499 'C','r','e','a','t','e','F','o','l','d','e','r',0 };
1504 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
1505 if (rc
!= ERROR_SUCCESS
)
1506 return ERROR_SUCCESS
;
1508 rc
= MSI_ViewExecute(view
, 0);
1509 if (rc
!= ERROR_SUCCESS
)
1511 MSI_ViewClose(view
);
1512 msiobj_release(&view
->hdr
);
1521 MSIRECORD
*row
= NULL
, *uirow
;
1523 rc
= MSI_ViewFetch(view
,&row
);
1524 if (rc
!= ERROR_SUCCESS
)
1531 rc
= MSI_RecordGetStringW(row
,1,dir
,&sz
);
1533 if (rc
!= ERROR_SUCCESS
)
1535 ERR("Unable to get folder id \n");
1536 msiobj_release(&row
->hdr
);
1541 full_path
= resolve_folder(package
,dir
,FALSE
,FALSE
,&folder
);
1544 ERR("Unable to resolve folder id %s\n",debugstr_w(dir
));
1545 msiobj_release(&row
->hdr
);
1549 TRACE("Folder is %s\n",debugstr_w(full_path
));
1552 uirow
= MSI_CreateRecord(1);
1553 MSI_RecordSetStringW(uirow
,1,full_path
);
1554 ui_actiondata(package
,szCreateFolders
,uirow
);
1555 msiobj_release( &uirow
->hdr
);
1557 if (folder
->State
== 0)
1558 create_full_pathW(full_path
);
1562 msiobj_release(&row
->hdr
);
1563 HeapFree(GetProcessHeap(),0,full_path
);
1565 MSI_ViewClose(view
);
1566 msiobj_release(&view
->hdr
);
1571 static int load_component(MSIPACKAGE
* package
, MSIRECORD
* row
)
1573 int index
= package
->loaded_components
;
1576 /* fill in the data */
1578 package
->loaded_components
++;
1579 if (package
->loaded_components
== 1)
1580 package
->components
= HeapAlloc(GetProcessHeap(),0,
1581 sizeof(MSICOMPONENT
));
1583 package
->components
= HeapReAlloc(GetProcessHeap(),0,
1584 package
->components
, package
->loaded_components
*
1585 sizeof(MSICOMPONENT
));
1587 memset(&package
->components
[index
],0,sizeof(MSICOMPONENT
));
1590 MSI_RecordGetStringW(row
,1,package
->components
[index
].Component
,&sz
);
1592 TRACE("Loading Component %s\n",
1593 debugstr_w(package
->components
[index
].Component
));
1596 if (!MSI_RecordIsNull(row
,2))
1597 MSI_RecordGetStringW(row
,2,package
->components
[index
].ComponentId
,&sz
);
1600 MSI_RecordGetStringW(row
,3,package
->components
[index
].Directory
,&sz
);
1602 package
->components
[index
].Attributes
= MSI_RecordGetInteger(row
,4);
1605 MSI_RecordGetStringW(row
,5,package
->components
[index
].Condition
,&sz
);
1608 MSI_RecordGetStringW(row
,6,package
->components
[index
].KeyPath
,&sz
);
1610 package
->components
[index
].Installed
= INSTALLSTATE_UNKNOWN
;
1611 package
->components
[index
].Action
= INSTALLSTATE_UNKNOWN
;
1612 package
->components
[index
].ActionRequest
= INSTALLSTATE_UNKNOWN
;
1614 package
->components
[index
].Enabled
= TRUE
;
1619 static void load_feature(MSIPACKAGE
* package
, MSIRECORD
* row
)
1621 int index
= package
->loaded_features
;
1623 static const WCHAR Query1
[] =
1624 {'S','E','L','E','C','T',' ','C','o','m','p','o','n','e','n','t','_',
1625 ' ','F','R','O','M',' ','F','e','a','t','u','r','e',
1626 'C','o','m','p','o','n','e','n','t','s',' ','W','H','E','R','E',' ',
1627 'F','e', 'a','t','u','r','e','_','=','\'','%','s','\'',0};
1628 static const WCHAR Query2
[] =
1629 {'S','E','L','E','C','T',' ','*',' ','F','R', 'O','M',' ',
1630 'C','o','m','p','o','n','e','n','t',' ','W','H','E','R','E',' ',
1631 'C','o','m','p','o','n','e','n','t','=','\'','%','s','\'',0};
1638 /* fill in the data */
1640 package
->loaded_features
++;
1641 if (package
->loaded_features
== 1)
1642 package
->features
= HeapAlloc(GetProcessHeap(),0,sizeof(MSIFEATURE
));
1644 package
->features
= HeapReAlloc(GetProcessHeap(),0,package
->features
,
1645 package
->loaded_features
* sizeof(MSIFEATURE
));
1647 memset(&package
->features
[index
],0,sizeof(MSIFEATURE
));
1650 MSI_RecordGetStringW(row
,1,package
->features
[index
].Feature
,&sz
);
1652 TRACE("Loading feature %s\n",debugstr_w(package
->features
[index
].Feature
));
1655 if (!MSI_RecordIsNull(row
,2))
1656 MSI_RecordGetStringW(row
,2,package
->features
[index
].Feature_Parent
,&sz
);
1659 if (!MSI_RecordIsNull(row
,3))
1660 MSI_RecordGetStringW(row
,3,package
->features
[index
].Title
,&sz
);
1663 if (!MSI_RecordIsNull(row
,4))
1664 MSI_RecordGetStringW(row
,4,package
->features
[index
].Description
,&sz
);
1666 if (!MSI_RecordIsNull(row
,5))
1667 package
->features
[index
].Display
= MSI_RecordGetInteger(row
,5);
1669 package
->features
[index
].Level
= MSI_RecordGetInteger(row
,6);
1672 if (!MSI_RecordIsNull(row
,7))
1673 MSI_RecordGetStringW(row
,7,package
->features
[index
].Directory
,&sz
);
1675 package
->features
[index
].Attributes
= MSI_RecordGetInteger(row
,8);
1677 package
->features
[index
].Installed
= INSTALLSTATE_UNKNOWN
;
1678 package
->features
[index
].Action
= INSTALLSTATE_UNKNOWN
;
1679 package
->features
[index
].ActionRequest
= INSTALLSTATE_UNKNOWN
;
1681 /* load feature components */
1683 rc
= MSI_OpenQuery(package
->db
, &view
, Query1
, package
->features
[index
].Feature
);
1684 if (rc
!= ERROR_SUCCESS
)
1686 rc
= MSI_ViewExecute(view
,0);
1687 if (rc
!= ERROR_SUCCESS
)
1689 MSI_ViewClose(view
);
1690 msiobj_release(&view
->hdr
);
1696 WCHAR buffer
[0x100];
1699 INT cnt
= package
->features
[index
].ComponentCount
;
1701 rc
= MSI_ViewFetch(view
,&row2
);
1702 if (rc
!= ERROR_SUCCESS
)
1706 MSI_RecordGetStringW(row2
,1,buffer
,&sz
);
1708 /* check to see if the component is already loaded */
1709 c_indx
= get_loaded_component(package
,buffer
);
1712 TRACE("Component %s already loaded at %i\n", debugstr_w(buffer
),
1714 package
->features
[index
].Components
[cnt
] = c_indx
;
1715 package
->features
[index
].ComponentCount
++;
1719 rc
= MSI_OpenQuery(package
->db
, &view2
, Query2
, buffer
);
1720 if (rc
!= ERROR_SUCCESS
)
1722 msiobj_release( &row2
->hdr
);
1725 rc
= MSI_ViewExecute(view2
,0);
1726 if (rc
!= ERROR_SUCCESS
)
1728 msiobj_release( &row2
->hdr
);
1729 MSI_ViewClose(view2
);
1730 msiobj_release( &view2
->hdr
);
1737 rc
= MSI_ViewFetch(view2
,&row3
);
1738 if (rc
!= ERROR_SUCCESS
)
1740 c_indx
= load_component(package
,row3
);
1741 msiobj_release( &row3
->hdr
);
1743 package
->features
[index
].Components
[cnt
] = c_indx
;
1744 package
->features
[index
].ComponentCount
++;
1745 TRACE("Loaded new component to index %i\n",c_indx
);
1747 MSI_ViewClose(view2
);
1748 msiobj_release( &view2
->hdr
);
1749 msiobj_release( &row2
->hdr
);
1751 MSI_ViewClose(view
);
1752 msiobj_release(&view
->hdr
);
1756 * I am not doing any of the costing functionality yet.
1757 * Mostly looking at doing the Component and Feature loading
1759 * The native MSI does A LOT of modification to tables here. Mostly adding
1760 * a lot of temporary columns to the Feature and Component tables.
1762 * note: Native msi also tracks the short filename. But I am only going to
1763 * track the long ones. Also looking at this directory table
1764 * it appears that the directory table does not get the parents
1765 * resolved base on property only based on their entries in the
1768 static UINT
ACTION_CostInitialize(MSIPACKAGE
*package
)
1773 static const WCHAR Query_all
[] =
1774 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
1775 'F','e','a','t','u','r','e',0};
1776 static const WCHAR szCosting
[] =
1777 {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
1778 static const WCHAR szZero
[] = { '0', 0 };
1780 MSI_SetPropertyW(package
, szCosting
, szZero
);
1781 MSI_SetPropertyW(package
, cszRootDrive
, c_colon
);
1783 rc
= MSI_DatabaseOpenViewW(package
->db
,Query_all
,&view
);
1784 if (rc
!= ERROR_SUCCESS
)
1786 rc
= MSI_ViewExecute(view
,0);
1787 if (rc
!= ERROR_SUCCESS
)
1789 MSI_ViewClose(view
);
1790 msiobj_release(&view
->hdr
);
1797 rc
= MSI_ViewFetch(view
,&row
);
1798 if (rc
!= ERROR_SUCCESS
)
1801 load_feature(package
,row
);
1802 msiobj_release(&row
->hdr
);
1804 MSI_ViewClose(view
);
1805 msiobj_release(&view
->hdr
);
1807 return ERROR_SUCCESS
;
1810 static UINT
load_file(MSIPACKAGE
* package
, MSIRECORD
* row
)
1812 DWORD index
= package
->loaded_files
;
1816 /* fill in the data */
1818 package
->loaded_files
++;
1819 if (package
->loaded_files
== 1)
1820 package
->files
= HeapAlloc(GetProcessHeap(),0,sizeof(MSIFILE
));
1822 package
->files
= HeapReAlloc(GetProcessHeap(),0,
1823 package
->files
, package
->loaded_files
* sizeof(MSIFILE
));
1825 memset(&package
->files
[index
],0,sizeof(MSIFILE
));
1827 package
->files
[index
].File
= load_dynamic_stringW(row
, 1);
1828 buffer
= load_dynamic_stringW(row
, 2);
1830 package
->files
[index
].ComponentIndex
= -1;
1831 for (i
= 0; i
< package
->loaded_components
; i
++)
1832 if (strcmpW(package
->components
[i
].Component
,buffer
)==0)
1834 package
->files
[index
].ComponentIndex
= i
;
1837 if (package
->files
[index
].ComponentIndex
== -1)
1838 ERR("Unfound Component %s\n",debugstr_w(buffer
));
1839 HeapFree(GetProcessHeap(), 0, buffer
);
1841 package
->files
[index
].FileName
= load_dynamic_stringW(row
,3);
1843 reduce_to_longfilename(package
->files
[index
].FileName
);
1845 package
->files
[index
].FileSize
= MSI_RecordGetInteger(row
,4);
1846 package
->files
[index
].Version
= load_dynamic_stringW(row
, 5);
1847 package
->files
[index
].Language
= load_dynamic_stringW(row
, 6);
1848 package
->files
[index
].Attributes
= MSI_RecordGetInteger(row
,7);
1849 package
->files
[index
].Sequence
= MSI_RecordGetInteger(row
,8);
1851 package
->files
[index
].Temporary
= FALSE
;
1852 package
->files
[index
].State
= 0;
1854 TRACE("File Loaded (%s)\n",debugstr_w(package
->files
[index
].File
));
1856 return ERROR_SUCCESS
;
1859 static UINT
ACTION_FileCost(MSIPACKAGE
*package
)
1864 static const WCHAR Query
[] =
1865 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
1866 'F','i','l','e',' ', 'O','R','D','E','R',' ','B','Y',' ',
1867 'S','e','q','u','e','n','c','e', 0};
1870 return ERROR_INVALID_HANDLE
;
1872 rc
= MSI_DatabaseOpenViewW(package
->db
, Query
, &view
);
1873 if (rc
!= ERROR_SUCCESS
)
1874 return ERROR_SUCCESS
;
1876 rc
= MSI_ViewExecute(view
, 0);
1877 if (rc
!= ERROR_SUCCESS
)
1879 MSI_ViewClose(view
);
1880 msiobj_release(&view
->hdr
);
1881 return ERROR_SUCCESS
;
1886 rc
= MSI_ViewFetch(view
,&row
);
1887 if (rc
!= ERROR_SUCCESS
)
1892 load_file(package
,row
);
1893 msiobj_release(&row
->hdr
);
1895 MSI_ViewClose(view
);
1896 msiobj_release(&view
->hdr
);
1898 return ERROR_SUCCESS
;
1901 static INT
load_folder(MSIPACKAGE
*package
, const WCHAR
* dir
)
1903 static const WCHAR Query
[] =
1904 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1905 'D','i','r','e','c', 't','o','r','y',' ','W','H','E','R','E',' ','`',
1906 'D','i','r','e','c','t', 'o','r','y','`',' ','=',' ','`','%','s','`',
1910 LPWSTR ptargetdir
, targetdir
, parent
, srcdir
;
1911 MSIRECORD
* row
= 0;
1915 TRACE("Looking for dir %s\n",debugstr_w(dir
));
1917 for (i
= 0; i
< package
->loaded_folders
; i
++)
1919 if (strcmpW(package
->folders
[i
].Directory
,dir
)==0)
1921 TRACE(" %s retuning on index %lu\n",debugstr_w(dir
),i
);
1926 TRACE("Working to load %s\n",debugstr_w(dir
));
1928 index
= package
->loaded_folders
++;
1929 if (package
->loaded_folders
==1)
1930 package
->folders
= HeapAlloc(GetProcessHeap(),0,
1933 package
->folders
= HeapReAlloc(GetProcessHeap(),0,
1934 package
->folders
, package
->loaded_folders
*
1937 memset(&package
->folders
[index
],0,sizeof(MSIFOLDER
));
1939 package
->folders
[index
].Directory
= strdupW(dir
);
1941 rc
= MSI_OpenQuery(package
->db
, &view
, Query
, dir
);
1942 if (rc
!= ERROR_SUCCESS
)
1945 rc
= MSI_ViewExecute(view
, 0);
1946 if (rc
!= ERROR_SUCCESS
)
1948 MSI_ViewClose(view
);
1949 msiobj_release(&view
->hdr
);
1953 rc
= MSI_ViewFetch(view
,&row
);
1954 if (rc
!= ERROR_SUCCESS
)
1956 MSI_ViewClose(view
);
1957 msiobj_release(&view
->hdr
);
1961 ptargetdir
= targetdir
= load_dynamic_stringW(row
,3);
1963 /* split src and target dir */
1964 if (strchrW(targetdir
,':'))
1966 srcdir
=strchrW(targetdir
,':');
1973 /* for now only pick long filename versions */
1974 if (strchrW(targetdir
,'|'))
1976 targetdir
= strchrW(targetdir
,'|');
1980 if (srcdir
&& strchrW(srcdir
,'|'))
1982 srcdir
= strchrW(srcdir
,'|');
1987 /* now check for root dirs */
1988 if (targetdir
[0] == '.' && targetdir
[1] == 0)
1991 if (srcdir
&& srcdir
[0] == '.' && srcdir
[1] == 0)
1996 TRACE(" TargetDefault = %s\n",debugstr_w(targetdir
));
1997 HeapFree(GetProcessHeap(),0, package
->folders
[index
].TargetDefault
);
1998 package
->folders
[index
].TargetDefault
= strdupW(targetdir
);
2002 package
->folders
[index
].SourceDefault
= strdupW(srcdir
);
2004 package
->folders
[index
].SourceDefault
= strdupW(targetdir
);
2005 HeapFree(GetProcessHeap(), 0, ptargetdir
);
2007 parent
= load_dynamic_stringW(row
,2);
2010 i
= load_folder(package
,parent
);
2011 package
->folders
[index
].ParentIndex
= i
;
2012 TRACE("Parent is index %i... %s %s\n",
2013 package
->folders
[index
].ParentIndex
,
2014 debugstr_w(package
->folders
[package
->folders
[index
].ParentIndex
].Directory
),
2015 debugstr_w(parent
));
2018 package
->folders
[index
].ParentIndex
= -2;
2019 HeapFree(GetProcessHeap(), 0, parent
);
2021 package
->folders
[index
].Property
= load_dynamic_property(package
, dir
,NULL
);
2023 msiobj_release(&row
->hdr
);
2024 MSI_ViewClose(view
);
2025 msiobj_release(&view
->hdr
);
2026 TRACE(" %s retuning on index %i\n",debugstr_w(dir
),index
);
2031 LPWSTR
resolve_folder(MSIPACKAGE
*package
, LPCWSTR name
, BOOL source
,
2032 BOOL set_prop
, MSIFOLDER
**folder
)
2035 LPWSTR p
, path
= NULL
;
2037 TRACE("Working to resolve %s\n",debugstr_w(name
));
2039 /* special resolving for Target and Source root dir */
2040 if (strcmpW(name
,cszTargetDir
)==0 || strcmpW(name
,cszSourceDir
)==0)
2044 path
= load_dynamic_property(package
,cszTargetDir
,NULL
);
2047 path
= load_dynamic_property(package
,cszRootDrive
,NULL
);
2049 MSI_SetPropertyW(package
,cszTargetDir
,path
);
2053 for (i
= 0; i
< package
->loaded_folders
; i
++)
2055 if (strcmpW(package
->folders
[i
].Directory
,name
)==0)
2058 *folder
= &(package
->folders
[i
]);
2064 path
= load_dynamic_property(package
,cszSourceDir
,NULL
);
2067 path
= load_dynamic_property(package
,cszDatabase
,NULL
);
2070 p
= strrchrW(path
,'\\');
2077 for (i
= 0; i
< package
->loaded_folders
; i
++)
2079 if (strcmpW(package
->folders
[i
].Directory
,name
)==0)
2082 *folder
= &(package
->folders
[i
]);
2088 for (i
= 0; i
< package
->loaded_folders
; i
++)
2090 if (strcmpW(package
->folders
[i
].Directory
,name
)==0)
2094 if (i
>= package
->loaded_folders
)
2098 *folder
= &(package
->folders
[i
]);
2100 if (!source
&& package
->folders
[i
].ResolvedTarget
)
2102 path
= strdupW(package
->folders
[i
].ResolvedTarget
);
2103 TRACE(" already resolved to %s\n",debugstr_w(path
));
2106 else if (source
&& package
->folders
[i
].ResolvedSource
)
2108 path
= strdupW(package
->folders
[i
].ResolvedSource
);
2111 else if (!source
&& package
->folders
[i
].Property
)
2113 path
= build_directory_name(2, package
->folders
[i
].Property
, NULL
);
2115 TRACE(" internally set to %s\n",debugstr_w(path
));
2117 MSI_SetPropertyW(package
,name
,path
);
2121 if (package
->folders
[i
].ParentIndex
>= 0)
2123 LPWSTR parent
= package
->folders
[package
->folders
[i
].ParentIndex
].Directory
;
2125 TRACE(" ! Parent is %s\n", debugstr_w(parent
));
2127 p
= resolve_folder(package
, parent
, source
, set_prop
, NULL
);
2130 TRACE(" TargetDefault = %s\n",debugstr_w(package
->folders
[i
].TargetDefault
));
2131 path
= build_directory_name(3, p
, package
->folders
[i
].TargetDefault
, NULL
);
2132 package
->folders
[i
].ResolvedTarget
= strdupW(path
);
2133 TRACE(" resolved into %s\n",debugstr_w(path
));
2135 MSI_SetPropertyW(package
,name
,path
);
2139 path
= build_directory_name(3, p
, package
->folders
[i
].SourceDefault
, NULL
);
2140 package
->folders
[i
].ResolvedSource
= strdupW(path
);
2142 HeapFree(GetProcessHeap(),0,p
);
2147 /* scan for and update current install states */
2148 void ACTION_UpdateInstallStates(MSIPACKAGE
*package
)
2153 productcode
= load_dynamic_property(package
,szProductCode
,NULL
);
2155 for (i
= 0; i
< package
->loaded_components
; i
++)
2158 res
= MsiGetComponentPathW(productcode
,
2159 package
->components
[i
].ComponentId
, NULL
, NULL
);
2161 res
= INSTALLSTATE_ABSENT
;
2162 package
->components
[i
].Installed
= res
;
2165 for (i
= 0; i
< package
->loaded_features
; i
++)
2167 INSTALLSTATE res
= -10;
2169 for (j
= 0; j
< package
->features
[i
].ComponentCount
; j
++)
2171 MSICOMPONENT
* component
= &package
->components
[package
->features
[i
].
2174 res
= component
->Installed
;
2177 if (res
== component
->Installed
)
2180 if (res
!= component
->Installed
)
2181 res
= INSTALLSTATE_INCOMPLETE
;
2187 /* update compoennt state based on a feature change */
2188 void ACTION_UpdateComponentStates(MSIPACKAGE
*package
, LPCWSTR szFeature
)
2191 INSTALLSTATE newstate
;
2192 MSIFEATURE
*feature
;
2194 i
= get_loaded_feature(package
,szFeature
);
2198 feature
= &package
->features
[i
];
2199 newstate
= feature
->ActionRequest
;
2201 for( i
= 0; i
< feature
->ComponentCount
; i
++)
2203 MSICOMPONENT
* component
= &package
->components
[feature
->Components
[i
]];
2205 if (!component
->Enabled
)
2209 if (newstate
== INSTALLSTATE_LOCAL
)
2210 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
2215 component
->ActionRequest
= newstate
;
2217 /*if any other feature wants is local we need to set it local*/
2219 j
< package
->loaded_features
&&
2220 component
->ActionRequest
!= INSTALLSTATE_LOCAL
;
2223 for (k
= 0; k
< package
->features
[j
].ComponentCount
; k
++)
2224 if ( package
->features
[j
].Components
[k
] ==
2225 feature
->Components
[i
] )
2227 if (package
->features
[j
].ActionRequest
==
2229 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
2238 static BOOL
process_state_property (MSIPACKAGE
* package
, LPCWSTR property
,
2241 static const WCHAR all
[]={'A','L','L',0};
2242 LPWSTR override
= NULL
;
2246 override
= load_dynamic_property(package
, property
, NULL
);
2250 for(i
= 0; i
< package
->loaded_features
; i
++)
2252 if (strcmpiW(override
,all
)==0)
2254 package
->features
[i
].ActionRequest
= state
;
2255 package
->features
[i
].Action
= state
;
2259 LPWSTR ptr
= override
;
2260 LPWSTR ptr2
= strchrW(override
,',');
2265 strncmpW(ptr
,package
->features
[i
].Feature
, ptr2
-ptr
)==0)
2267 strcmpW(ptr
,package
->features
[i
].Feature
)==0))
2269 package
->features
[i
].ActionRequest
= state
;
2270 package
->features
[i
].Action
= state
;
2276 ptr2
= strchrW(ptr
,',');
2283 HeapFree(GetProcessHeap(),0,override
);
2289 static UINT
SetFeatureStates(MSIPACKAGE
*package
)
2295 static const WCHAR szlevel
[] =
2296 {'I','N','S','T','A','L','L','L','E','V','E','L',0};
2297 static const WCHAR szAddLocal
[] =
2298 {'A','D','D','L','O','C','A','L',0};
2299 static const WCHAR szRemove
[] =
2300 {'R','E','M','O','V','E',0};
2301 BOOL override
= FALSE
;
2303 /* I do not know if this is where it should happen.. but */
2305 TRACE("Checking Install Level\n");
2307 level
= load_dynamic_property(package
,szlevel
,NULL
);
2310 install_level
= atoiW(level
);
2311 HeapFree(GetProcessHeap(), 0, level
);
2316 /* ok hereis the _real_ rub
2317 * all these activation/deactivation things happen in order and things
2318 * later on the list override things earlier on the list.
2319 * 1) INSTALLLEVEL processing
2329 * 11) FILEADDDEFAULT
2330 * I have confirmed that if ADDLOCAL is stated then the INSTALLLEVEL is
2331 * ignored for all the features. seems strange, especially since it is not
2332 * documented anywhere, but it is how it works.
2334 * I am still ignoring a lot of these. But that is ok for now, ADDLOCAL and
2335 * REMOVE are the big ones, since we don't handle administrative installs
2338 override
|= process_state_property(package
,szAddLocal
,INSTALLSTATE_LOCAL
);
2339 override
|= process_state_property(package
,szRemove
,INSTALLSTATE_ABSENT
);
2343 for(i
= 0; i
< package
->loaded_features
; i
++)
2345 BOOL feature_state
= ((package
->features
[i
].Level
> 0) &&
2346 (package
->features
[i
].Level
<= install_level
));
2350 package
->features
[i
].ActionRequest
= INSTALLSTATE_LOCAL
;
2351 package
->features
[i
].Action
= INSTALLSTATE_LOCAL
;
2357 * now we want to enable or disable components base on feature
2360 for(i
= 0; i
< package
->loaded_features
; i
++)
2362 MSIFEATURE
* feature
= &package
->features
[i
];
2363 TRACE("Examining Feature %s (Installed %i, Action %i, Request %i)\n",
2364 debugstr_w(feature
->Feature
), feature
->Installed
, feature
->Action
,
2365 feature
->ActionRequest
);
2367 for( j
= 0; j
< feature
->ComponentCount
; j
++)
2369 MSICOMPONENT
* component
= &package
->components
[
2370 feature
->Components
[j
]];
2372 if (!component
->Enabled
)
2374 component
->Action
= INSTALLSTATE_UNKNOWN
;
2375 component
->ActionRequest
= INSTALLSTATE_UNKNOWN
;
2379 if (feature
->Action
== INSTALLSTATE_LOCAL
)
2381 component
->Action
= INSTALLSTATE_LOCAL
;
2382 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
2384 else if (feature
->ActionRequest
== INSTALLSTATE_ABSENT
)
2386 if (component
->Action
== INSTALLSTATE_UNKNOWN
)
2388 component
->Action
= INSTALLSTATE_ABSENT
;
2389 component
->ActionRequest
= INSTALLSTATE_ABSENT
;
2396 for(i
= 0; i
< package
->loaded_components
; i
++)
2398 MSICOMPONENT
* component
= &package
->components
[i
];
2400 TRACE("Result: Component %s (Installed %i, Action %i, Request %i)\n",
2401 debugstr_w(component
->Component
), component
->Installed
,
2402 component
->Action
, component
->ActionRequest
);
2406 return ERROR_SUCCESS
;
2410 * A lot is done in this function aside from just the costing.
2411 * The costing needs to be implemented at some point but for now I am going
2412 * to focus on the directory building
2415 static UINT
ACTION_CostFinalize(MSIPACKAGE
*package
)
2417 static const WCHAR ExecSeqQuery
[] =
2418 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2419 'D','i','r','e','c','t','o','r','y',0};
2420 static const WCHAR ConditionQuery
[] =
2421 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2422 'C','o','n','d','i','t','i','o','n',0};
2423 static const WCHAR szCosting
[] =
2424 {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
2425 static const WCHAR szlevel
[] =
2426 {'I','N','S','T','A','L','L','L','E','V','E','L',0};
2427 static const WCHAR szOne
[] = { '1', 0 };
2433 TRACE("Building Directory properties\n");
2435 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
2436 if (rc
== ERROR_SUCCESS
)
2438 rc
= MSI_ViewExecute(view
, 0);
2439 if (rc
!= ERROR_SUCCESS
)
2441 MSI_ViewClose(view
);
2442 msiobj_release(&view
->hdr
);
2450 MSIRECORD
* row
= 0;
2453 rc
= MSI_ViewFetch(view
,&row
);
2454 if (rc
!= ERROR_SUCCESS
)
2461 MSI_RecordGetStringW(row
,1,name
,&sz
);
2463 /* This helper function now does ALL the work */
2464 TRACE("Dir %s ...\n",debugstr_w(name
));
2465 load_folder(package
,name
);
2466 path
= resolve_folder(package
,name
,FALSE
,TRUE
,NULL
);
2467 TRACE("resolves to %s\n",debugstr_w(path
));
2468 HeapFree( GetProcessHeap(), 0, path
);
2470 msiobj_release(&row
->hdr
);
2472 MSI_ViewClose(view
);
2473 msiobj_release(&view
->hdr
);
2476 TRACE("File calculations %i files\n",package
->loaded_files
);
2478 for (i
= 0; i
< package
->loaded_files
; i
++)
2480 MSICOMPONENT
* comp
= NULL
;
2481 MSIFILE
* file
= NULL
;
2483 file
= &package
->files
[i
];
2484 if (file
->ComponentIndex
>= 0)
2485 comp
= &package
->components
[file
->ComponentIndex
];
2487 if (file
->Temporary
== TRUE
)
2494 /* calculate target */
2495 p
= resolve_folder(package
, comp
->Directory
, FALSE
, FALSE
, NULL
);
2497 HeapFree(GetProcessHeap(),0,file
->TargetPath
);
2499 TRACE("file %s is named %s\n",
2500 debugstr_w(file
->File
),debugstr_w(file
->FileName
));
2502 file
->TargetPath
= build_directory_name(2, p
, file
->FileName
);
2504 HeapFree(GetProcessHeap(),0,p
);
2506 TRACE("file %s resolves to %s\n",
2507 debugstr_w(file
->File
),debugstr_w(file
->TargetPath
));
2509 if (GetFileAttributesW(file
->TargetPath
) == INVALID_FILE_ATTRIBUTES
)
2512 comp
->Cost
+= file
->FileSize
;
2522 static const WCHAR name
[] =
2524 static const WCHAR name_fmt
[] =
2525 {'%','u','.','%','u','.','%','u','.','%','u',0};
2526 WCHAR filever
[0x100];
2527 VS_FIXEDFILEINFO
*lpVer
;
2529 TRACE("Version comparison.. \n");
2530 versize
= GetFileVersionInfoSizeW(file
->TargetPath
,&handle
);
2531 version
= HeapAlloc(GetProcessHeap(),0,versize
);
2532 GetFileVersionInfoW(file
->TargetPath
, 0, versize
, version
);
2534 VerQueryValueW(version
, name
, (LPVOID
*)&lpVer
, &sz
);
2536 sprintfW(filever
,name_fmt
,
2537 HIWORD(lpVer
->dwFileVersionMS
),
2538 LOWORD(lpVer
->dwFileVersionMS
),
2539 HIWORD(lpVer
->dwFileVersionLS
),
2540 LOWORD(lpVer
->dwFileVersionLS
));
2542 TRACE("new %s old %s\n", debugstr_w(file
->Version
),
2543 debugstr_w(filever
));
2544 if (strcmpiW(filever
,file
->Version
)<0)
2547 FIXME("cost should be diff in size\n");
2548 comp
->Cost
+= file
->FileSize
;
2552 HeapFree(GetProcessHeap(),0,version
);
2560 TRACE("Evaluating Condition Table\n");
2562 rc
= MSI_DatabaseOpenViewW(package
->db
, ConditionQuery
, &view
);
2563 if (rc
== ERROR_SUCCESS
)
2565 rc
= MSI_ViewExecute(view
, 0);
2566 if (rc
!= ERROR_SUCCESS
)
2568 MSI_ViewClose(view
);
2569 msiobj_release(&view
->hdr
);
2575 WCHAR Feature
[0x100];
2576 MSIRECORD
* row
= 0;
2580 rc
= MSI_ViewFetch(view
,&row
);
2582 if (rc
!= ERROR_SUCCESS
)
2589 MSI_RecordGetStringW(row
,1,Feature
,&sz
);
2591 feature_index
= get_loaded_feature(package
,Feature
);
2592 if (feature_index
< 0)
2593 ERR("FAILED to find loaded feature %s\n",debugstr_w(Feature
));
2597 Condition
= load_dynamic_stringW(row
,3);
2599 if (MSI_EvaluateConditionW(package
,Condition
) ==
2602 int level
= MSI_RecordGetInteger(row
,2);
2603 TRACE("Reseting feature %s to level %i\n",
2604 debugstr_w(Feature
), level
);
2605 package
->features
[feature_index
].Level
= level
;
2607 HeapFree(GetProcessHeap(),0,Condition
);
2610 msiobj_release(&row
->hdr
);
2612 MSI_ViewClose(view
);
2613 msiobj_release(&view
->hdr
);
2616 TRACE("Enabling or Disabling Components\n");
2617 for (i
= 0; i
< package
->loaded_components
; i
++)
2619 if (package
->components
[i
].Condition
[0])
2621 if (MSI_EvaluateConditionW(package
,
2622 package
->components
[i
].Condition
) == MSICONDITION_FALSE
)
2624 TRACE("Disabling component %s\n",
2625 debugstr_w(package
->components
[i
].Component
));
2626 package
->components
[i
].Enabled
= FALSE
;
2631 MSI_SetPropertyW(package
,szCosting
,szOne
);
2632 /* set default run level if not set */
2633 level
= load_dynamic_property(package
,szlevel
,NULL
);
2635 MSI_SetPropertyW(package
,szlevel
, szOne
);
2637 HeapFree(GetProcessHeap(),0,level
);
2639 ACTION_UpdateInstallStates(package
);
2641 return SetFeatureStates(package
);
2645 * This is a helper function for handling embedded cabinet media
2647 static UINT
writeout_cabinet_stream(MSIPACKAGE
*package
, WCHAR
* stream_name
,
2655 WCHAR tmp
[MAX_PATH
];
2657 rc
= read_raw_stream_data(package
->db
,stream_name
,&data
,&size
);
2658 if (rc
!= ERROR_SUCCESS
)
2662 if (MSI_GetPropertyW(package
, cszTempFolder
, tmp
, &write
))
2663 GetTempPathW(MAX_PATH
,tmp
);
2665 GetTempFileNameW(tmp
,stream_name
,0,source
);
2667 track_tempfile(package
,strrchrW(source
,'\\'), source
);
2668 the_file
= CreateFileW(source
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
2669 FILE_ATTRIBUTE_NORMAL
, NULL
);
2671 if (the_file
== INVALID_HANDLE_VALUE
)
2673 rc
= ERROR_FUNCTION_FAILED
;
2677 WriteFile(the_file
,data
,size
,&write
,NULL
);
2678 CloseHandle(the_file
);
2679 TRACE("wrote %li bytes to %s\n",write
,debugstr_w(source
));
2681 HeapFree(GetProcessHeap(),0,data
);
2686 /* Support functions for FDI functions */
2689 MSIPACKAGE
* package
;
2694 static void * cabinet_alloc(ULONG cb
)
2696 return HeapAlloc(GetProcessHeap(), 0, cb
);
2699 static void cabinet_free(void *pv
)
2701 HeapFree(GetProcessHeap(), 0, pv
);
2704 static INT_PTR
cabinet_open(char *pszFile
, int oflag
, int pmode
)
2707 DWORD dwShareMode
= 0;
2708 DWORD dwCreateDisposition
= OPEN_EXISTING
;
2709 switch (oflag
& _O_ACCMODE
)
2712 dwAccess
= GENERIC_READ
;
2713 dwShareMode
= FILE_SHARE_READ
| FILE_SHARE_DELETE
;
2716 dwAccess
= GENERIC_WRITE
;
2717 dwShareMode
= FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
;
2720 dwAccess
= GENERIC_READ
| GENERIC_WRITE
;
2721 dwShareMode
= FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
;
2724 if ((oflag
& (_O_CREAT
| _O_EXCL
)) == (_O_CREAT
| _O_EXCL
))
2725 dwCreateDisposition
= CREATE_NEW
;
2726 else if (oflag
& _O_CREAT
)
2727 dwCreateDisposition
= CREATE_ALWAYS
;
2728 return (INT_PTR
)CreateFileA(pszFile
, dwAccess
, dwShareMode
, NULL
,
2729 dwCreateDisposition
, 0, NULL
);
2732 static UINT
cabinet_read(INT_PTR hf
, void *pv
, UINT cb
)
2735 if (ReadFile((HANDLE
)hf
, pv
, cb
, &dwRead
, NULL
))
2740 static UINT
cabinet_write(INT_PTR hf
, void *pv
, UINT cb
)
2743 if (WriteFile((HANDLE
)hf
, pv
, cb
, &dwWritten
, NULL
))
2748 static int cabinet_close(INT_PTR hf
)
2750 return CloseHandle((HANDLE
)hf
) ? 0 : -1;
2753 static long cabinet_seek(INT_PTR hf
, long dist
, int seektype
)
2755 /* flags are compatible and so are passed straight through */
2756 return SetFilePointer((HANDLE
)hf
, dist
, NULL
, seektype
);
2759 static INT_PTR
cabinet_notify(FDINOTIFICATIONTYPE fdint
, PFDINOTIFICATION pfdin
)
2761 /* FIXME: try to do more processing in this function */
2764 case fdintCOPY_FILE
:
2766 CabData
*data
= (CabData
*) pfdin
->pv
;
2767 ULONG len
= strlen(data
->cab_path
) + strlen(pfdin
->psz1
);
2772 LPWSTR tracknametmp
;
2773 static const WCHAR tmpprefix
[] = {'C','A','B','T','M','P','_',0};
2775 if (data
->file_name
&& strcmp(data
->file_name
,pfdin
->psz1
))
2778 file
= cabinet_alloc((len
+1)*sizeof(char));
2779 strcpy(file
, data
->cab_path
);
2780 strcat(file
, pfdin
->psz1
);
2782 TRACE("file: %s\n", debugstr_a(file
));
2784 /* track this file so it can be deleted if not installed */
2785 trackpath
=strdupAtoW(file
);
2786 tracknametmp
=strdupAtoW(strrchr(file
,'\\')+1);
2787 trackname
= HeapAlloc(GetProcessHeap(),0,(strlenW(tracknametmp
) +
2788 strlenW(tmpprefix
)+1) * sizeof(WCHAR
));
2790 strcpyW(trackname
,tmpprefix
);
2791 strcatW(trackname
,tracknametmp
);
2793 track_tempfile(data
->package
, trackname
, trackpath
);
2795 HeapFree(GetProcessHeap(),0,trackpath
);
2796 HeapFree(GetProcessHeap(),0,trackname
);
2797 HeapFree(GetProcessHeap(),0,tracknametmp
);
2799 return cabinet_open(file
, _O_WRONLY
| _O_CREAT
, 0);
2801 case fdintCLOSE_FILE_INFO
:
2805 if (!DosDateTimeToFileTime(pfdin
->date
, pfdin
->time
, &ft
))
2807 if (!LocalFileTimeToFileTime(&ft
, &ftLocal
))
2809 if (!SetFileTime((HANDLE
)pfdin
->hf
, &ftLocal
, 0, &ftLocal
))
2812 cabinet_close(pfdin
->hf
);
2820 /***********************************************************************
2821 * extract_cabinet_file
2823 * Extract files from a cab file.
2825 static BOOL
extract_a_cabinet_file(MSIPACKAGE
* package
, const WCHAR
* source
,
2826 const WCHAR
* path
, const WCHAR
* file
)
2836 TRACE("Extracting %s (%s) to %s\n",debugstr_w(source
),
2837 debugstr_w(file
), debugstr_w(path
));
2839 hfdi
= FDICreate(cabinet_alloc
,
2850 ERR("FDICreate failed\n");
2854 if (!(cabinet
= strdupWtoA( source
)))
2859 if (!(cab_path
= strdupWtoA( path
)))
2862 HeapFree(GetProcessHeap(), 0, cabinet
);
2866 data
.package
= package
;
2867 data
.cab_path
= cab_path
;
2869 file_name
= strdupWtoA(file
);
2872 data
.file_name
= file_name
;
2874 ret
= FDICopy(hfdi
, cabinet
, "", 0, cabinet_notify
, NULL
, &data
);
2877 ERR("FDICopy failed\n");
2881 HeapFree(GetProcessHeap(), 0, cabinet
);
2882 HeapFree(GetProcessHeap(), 0, cab_path
);
2883 HeapFree(GetProcessHeap(), 0, file_name
);
2888 static UINT
ready_media_for_file(MSIPACKAGE
*package
, UINT sequence
,
2889 WCHAR
* path
, WCHAR
* file
)
2893 MSIRECORD
* row
= 0;
2894 static WCHAR source
[MAX_PATH
];
2895 static const WCHAR ExecSeqQuery
[] =
2896 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
2897 'M','e','d','i','a',' ','W','H','E','R','E',' ',
2898 'L','a','s','t','S','e','q','u','e','n','c','e',' ','>','=',' ','%',
2899 'i',' ','O','R','D','E','R',' ','B','Y',' ',
2900 'L','a','s','t','S','e','q','u','e','n','c','e',0};
2905 static UINT last_sequence
= 0;
2907 if (sequence
<= last_sequence
)
2909 TRACE("Media already ready (%u, %u)\n",sequence
,last_sequence
);
2910 /*extract_a_cabinet_file(package, source,path,file); */
2911 return ERROR_SUCCESS
;
2914 sprintfW(Query
,ExecSeqQuery
,sequence
);
2916 rc
= MSI_DatabaseOpenViewW(package
->db
, Query
, &view
);
2917 if (rc
!= ERROR_SUCCESS
)
2920 rc
= MSI_ViewExecute(view
, 0);
2921 if (rc
!= ERROR_SUCCESS
)
2923 MSI_ViewClose(view
);
2924 msiobj_release(&view
->hdr
);
2928 rc
= MSI_ViewFetch(view
,&row
);
2929 if (rc
!= ERROR_SUCCESS
)
2931 MSI_ViewClose(view
);
2932 msiobj_release(&view
->hdr
);
2935 seq
= MSI_RecordGetInteger(row
,2);
2936 last_sequence
= seq
;
2938 if (!MSI_RecordIsNull(row
,4))
2941 MSI_RecordGetStringW(row
,4,cab
,&sz
);
2942 TRACE("Source is CAB %s\n",debugstr_w(cab
));
2943 /* the stream does not contain the # character */
2946 writeout_cabinet_stream(package
,&cab
[1],source
);
2947 strcpyW(path
,source
);
2948 *(strrchrW(path
,'\\')+1)=0;
2953 if (MSI_GetPropertyW(package
, cszSourceDir
, source
, &sz
))
2955 ERR("No Source dir defined \n");
2956 rc
= ERROR_FUNCTION_FAILED
;
2960 strcpyW(path
,source
);
2961 strcatW(source
,cab
);
2962 /* extract the cab file into a folder in the temp folder */
2964 if (MSI_GetPropertyW(package
, cszTempFolder
,path
, &sz
)
2966 GetTempPathW(MAX_PATH
,path
);
2969 rc
= !extract_a_cabinet_file(package
, source
,path
,NULL
);
2974 MSI_GetPropertyW(package
,cszSourceDir
,source
,&sz
);
2975 strcpyW(path
,source
);
2977 msiobj_release(&row
->hdr
);
2978 MSI_ViewClose(view
);
2979 msiobj_release(&view
->hdr
);
2983 inline static UINT
create_component_directory ( MSIPACKAGE
* package
, INT component
)
2985 UINT rc
= ERROR_SUCCESS
;
2987 LPWSTR install_path
;
2989 install_path
= resolve_folder(package
, package
->components
[component
].Directory
,
2990 FALSE
, FALSE
, &folder
);
2992 return ERROR_FUNCTION_FAILED
;
2994 /* create the path */
2995 if (folder
->State
== 0)
2997 create_full_pathW(install_path
);
3000 HeapFree(GetProcessHeap(), 0, install_path
);
3005 static UINT
ACTION_InstallFiles(MSIPACKAGE
*package
)
3007 UINT rc
= ERROR_SUCCESS
;
3010 WCHAR uipath
[MAX_PATH
];
3013 return ERROR_INVALID_HANDLE
;
3015 /* increment progress bar each time action data is sent */
3016 ui_progress(package
,1,1,0,0);
3018 for (index
= 0; index
< package
->loaded_files
; index
++)
3020 WCHAR path_to_source
[MAX_PATH
];
3023 file
= &package
->files
[index
];
3025 if (file
->Temporary
)
3029 if (!ACTION_VerifyComponentForAction(package
, file
->ComponentIndex
,
3030 INSTALLSTATE_LOCAL
))
3032 ui_progress(package
,2,file
->FileSize
,0,0);
3033 TRACE("File %s is not scheduled for install\n",
3034 debugstr_w(file
->File
));
3039 if ((file
->State
== 1) || (file
->State
== 2))
3043 MSICOMPONENT
* comp
= NULL
;
3045 TRACE("Installing %s\n",debugstr_w(file
->File
));
3046 rc
= ready_media_for_file(package
,file
->Sequence
,path_to_source
,
3050 * our file table could change here because a new temp file
3051 * may have been created
3053 file
= &package
->files
[index
];
3054 if (rc
!= ERROR_SUCCESS
)
3056 ERR("Unable to ready media\n");
3057 rc
= ERROR_FUNCTION_FAILED
;
3061 create_component_directory( package
, file
->ComponentIndex
);
3063 /* recalculate file paths because things may have changed */
3065 if (file
->ComponentIndex
>= 0)
3066 comp
= &package
->components
[file
->ComponentIndex
];
3068 p
= resolve_folder(package
, comp
->Directory
, FALSE
, FALSE
, NULL
);
3069 HeapFree(GetProcessHeap(),0,file
->TargetPath
);
3071 file
->TargetPath
= build_directory_name(2, p
, file
->FileName
);
3073 len
= strlenW(path_to_source
) + strlenW(file
->File
) + 2;
3074 file
->SourcePath
= HeapAlloc(GetProcessHeap(),0,len
*sizeof(WCHAR
));
3075 strcpyW(file
->SourcePath
, path_to_source
);
3076 strcatW(file
->SourcePath
, file
->File
);
3078 TRACE("file paths %s to %s\n",debugstr_w(file
->SourcePath
),
3079 debugstr_w(file
->TargetPath
));
3082 uirow
=MSI_CreateRecord(9);
3083 MSI_RecordSetStringW(uirow
,1,file
->File
);
3084 strcpyW(uipath
,file
->TargetPath
);
3085 *(strrchrW(uipath
,'\\')+1)=0;
3086 MSI_RecordSetStringW(uirow
,9,uipath
);
3087 MSI_RecordSetInteger(uirow
,6,file
->FileSize
);
3088 ui_actiondata(package
,szInstallFiles
,uirow
);
3089 msiobj_release( &uirow
->hdr
);
3090 ui_progress(package
,2,file
->FileSize
,0,0);
3092 if (!MoveFileW(file
->SourcePath
,file
->TargetPath
))
3094 rc
= GetLastError();
3095 ERR("Unable to move file (%s -> %s) (error %d)\n",
3096 debugstr_w(file
->SourcePath
), debugstr_w(file
->TargetPath
),
3098 if (rc
== ERROR_ALREADY_EXISTS
&& file
->State
== 2)
3100 CopyFileW(file
->SourcePath
,file
->TargetPath
,FALSE
);
3101 DeleteFileW(file
->SourcePath
);
3104 else if (rc
== ERROR_FILE_NOT_FOUND
)
3106 ERR("Source File Not Found! Continuing\n");
3111 ERR("Ignoring Error and continuing...\n");
3123 inline static UINT
get_file_target(MSIPACKAGE
*package
, LPCWSTR file_key
,
3124 LPWSTR
* file_source
)
3129 return ERROR_INVALID_HANDLE
;
3131 for (index
= 0; index
< package
->loaded_files
; index
++)
3133 if (strcmpW(file_key
,package
->files
[index
].File
)==0)
3135 if (package
->files
[index
].State
>= 2)
3137 *file_source
= strdupW(package
->files
[index
].TargetPath
);
3138 return ERROR_SUCCESS
;
3141 return ERROR_FILE_NOT_FOUND
;
3145 return ERROR_FUNCTION_FAILED
;
3148 static UINT
ACTION_DuplicateFiles(MSIPACKAGE
*package
)
3152 MSIRECORD
* row
= 0;
3153 static const WCHAR ExecSeqQuery
[] =
3154 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3155 'D','u','p','l','i','c','a','t','e','F','i','l','e',0};
3158 return ERROR_INVALID_HANDLE
;
3160 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
3161 if (rc
!= ERROR_SUCCESS
)
3162 return ERROR_SUCCESS
;
3164 rc
= MSI_ViewExecute(view
, 0);
3165 if (rc
!= ERROR_SUCCESS
)
3167 MSI_ViewClose(view
);
3168 msiobj_release(&view
->hdr
);
3174 WCHAR file_key
[0x100];
3175 WCHAR
*file_source
= NULL
;
3176 WCHAR dest_name
[0x100];
3177 LPWSTR dest_path
, dest
;
3178 WCHAR component
[0x100];
3179 INT component_index
;
3183 rc
= MSI_ViewFetch(view
,&row
);
3184 if (rc
!= ERROR_SUCCESS
)
3191 rc
= MSI_RecordGetStringW(row
,2,component
,&sz
);
3192 if (rc
!= ERROR_SUCCESS
)
3194 ERR("Unable to get component\n");
3195 msiobj_release(&row
->hdr
);
3199 component_index
= get_loaded_component(package
,component
);
3201 if (!ACTION_VerifyComponentForAction(package
, component_index
,
3202 INSTALLSTATE_LOCAL
))
3204 TRACE("Skipping copy due to disabled component\n");
3206 /* the action taken was the same as the current install state */
3207 package
->components
[component_index
].Action
=
3208 package
->components
[component_index
].Installed
;
3210 msiobj_release(&row
->hdr
);
3214 package
->components
[component_index
].Action
= INSTALLSTATE_LOCAL
;
3217 rc
= MSI_RecordGetStringW(row
,3,file_key
,&sz
);
3218 if (rc
!= ERROR_SUCCESS
)
3220 ERR("Unable to get file key\n");
3221 msiobj_release(&row
->hdr
);
3225 rc
= get_file_target(package
,file_key
,&file_source
);
3227 if (rc
!= ERROR_SUCCESS
)
3229 ERR("Original file unknown %s\n",debugstr_w(file_key
));
3230 msiobj_release(&row
->hdr
);
3231 HeapFree(GetProcessHeap(),0,file_source
);
3235 if (MSI_RecordIsNull(row
,4))
3237 strcpyW(dest_name
,strrchrW(file_source
,'\\')+1);
3242 MSI_RecordGetStringW(row
,4,dest_name
,&sz
);
3243 reduce_to_longfilename(dest_name
);
3246 if (MSI_RecordIsNull(row
,5))
3249 dest_path
= strdupW(file_source
);
3250 p
= strrchrW(dest_path
,'\\');
3256 WCHAR destkey
[0x100];
3258 MSI_RecordGetStringW(row
,5,destkey
,&sz
);
3260 dest_path
= resolve_folder(package
, destkey
, FALSE
,FALSE
,NULL
);
3263 ERR("Unable to get destination folder\n");
3264 msiobj_release(&row
->hdr
);
3265 HeapFree(GetProcessHeap(),0,file_source
);
3270 dest
= build_directory_name(2, dest_path
, dest_name
);
3272 TRACE("Duplicating file %s to %s\n",debugstr_w(file_source
),
3275 if (strcmpW(file_source
,dest
))
3276 rc
= !CopyFileW(file_source
,dest
,TRUE
);
3280 if (rc
!= ERROR_SUCCESS
)
3281 ERR("Failed to copy file %s -> %s, last error %ld\n", debugstr_w(file_source
), debugstr_w(dest_path
), GetLastError());
3283 FIXME("We should track these duplicate files as well\n");
3285 msiobj_release(&row
->hdr
);
3286 HeapFree(GetProcessHeap(),0,dest_path
);
3287 HeapFree(GetProcessHeap(),0,dest
);
3288 HeapFree(GetProcessHeap(),0,file_source
);
3290 MSI_ViewClose(view
);
3291 msiobj_release(&view
->hdr
);
3296 /* OK this value is "interpreted" and then formatted based on the
3297 first few characters */
3298 static LPSTR
parse_value(MSIPACKAGE
*package
, WCHAR
*value
, DWORD
*type
,
3302 if (value
[0]=='#' && value
[1]!='#' && value
[1]!='%')
3311 deformat_string(package
, &value
[2], &deformated
);
3313 /* binary value type */
3316 *size
= strlenW(ptr
)/2;
3317 data
= HeapAlloc(GetProcessHeap(),0,*size
);
3329 data
[count
] = (BYTE
)strtol(byte
,NULL
,0);
3332 HeapFree(GetProcessHeap(),0,deformated
);
3334 TRACE("Data %li bytes(%i)\n",*size
,count
);
3341 deformat_string(package
, &value
[1], &deformated
);
3344 *size
= sizeof(DWORD
);
3345 data
= HeapAlloc(GetProcessHeap(),0,*size
);
3351 if ( (*p
< '0') || (*p
> '9') )
3357 if (deformated
[0] == '-')
3360 TRACE("DWORD %li\n",*(LPDWORD
)data
);
3362 HeapFree(GetProcessHeap(),0,deformated
);
3367 static const WCHAR szMulti
[] = {'[','~',']',0};
3376 *type
=REG_EXPAND_SZ
;
3384 if (strstrW(value
,szMulti
))
3385 *type
= REG_MULTI_SZ
;
3387 *size
= deformat_string(package
, ptr
,(LPWSTR
*)&data
);
3392 static UINT
ACTION_WriteRegistryValues(MSIPACKAGE
*package
)
3396 MSIRECORD
* row
= 0;
3397 static const WCHAR ExecSeqQuery
[] =
3398 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3399 'R','e','g','i','s','t','r','y',0 };
3402 return ERROR_INVALID_HANDLE
;
3404 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
3405 if (rc
!= ERROR_SUCCESS
)
3406 return ERROR_SUCCESS
;
3408 rc
= MSI_ViewExecute(view
, 0);
3409 if (rc
!= ERROR_SUCCESS
)
3411 MSI_ViewClose(view
);
3412 msiobj_release(&view
->hdr
);
3416 /* increment progress bar each time action data is sent */
3417 ui_progress(package
,1,REG_PROGRESS_VALUE
,1,0);
3421 static const WCHAR szHCR
[] =
3422 {'H','K','E','Y','_','C','L','A','S','S','E','S','_',
3423 'R','O','O','T','\\',0};
3424 static const WCHAR szHCU
[] =
3425 {'H','K','E','Y','_','C','U','R','R','E','N','T','_',
3426 'U','S','E','R','\\',0};
3427 static const WCHAR szHLM
[] =
3428 {'H','K','E','Y','_','L','O','C','A','L','_',
3429 'M','A','C','H','I','N','E','\\',0};
3430 static const WCHAR szHU
[] =
3431 {'H','K','E','Y','_','U','S','E','R','S','\\',0};
3433 LPSTR value_data
= NULL
;
3434 HKEY root_key
, hkey
;
3436 LPWSTR value
, key
, name
, component
, deformated
;
3438 INT component_index
;
3443 rc
= MSI_ViewFetch(view
,&row
);
3444 if (rc
!= ERROR_SUCCESS
)
3449 ui_progress(package
,2,0,0,0);
3456 component
= load_dynamic_stringW(row
, 6);
3457 component_index
= get_loaded_component(package
,component
);
3459 if (!ACTION_VerifyComponentForAction(package
, component_index
,
3460 INSTALLSTATE_LOCAL
))
3462 TRACE("Skipping write due to disabled component\n");
3463 msiobj_release(&row
->hdr
);
3465 package
->components
[component_index
].Action
=
3466 package
->components
[component_index
].Installed
;
3471 package
->components
[component_index
].Action
= INSTALLSTATE_LOCAL
;
3473 name
= load_dynamic_stringW(row
, 4);
3474 if( MSI_RecordIsNull(row
,5) && name
)
3476 /* null values can have special meanings */
3477 if (name
[0]=='-' && name
[1] == 0)
3479 msiobj_release(&row
->hdr
);
3482 else if ((name
[0]=='+' && name
[1] == 0) ||
3483 (name
[0] == '*' && name
[1] == 0))
3485 HeapFree(GetProcessHeap(),0,name
);
3490 root
= MSI_RecordGetInteger(row
,2);
3491 key
= load_dynamic_stringW(row
, 3);
3494 /* get the root key */
3497 case 0: root_key
= HKEY_CLASSES_ROOT
;
3500 case 1: root_key
= HKEY_CURRENT_USER
;
3503 case 2: root_key
= HKEY_LOCAL_MACHINE
;
3506 case 3: root_key
= HKEY_USERS
;
3510 ERR("Unknown root %i\n",root
);
3517 msiobj_release(&row
->hdr
);
3521 deformat_string(package
, key
, &deformated
);
3522 size
= strlenW(deformated
) + strlenW(szRoot
) + 1;
3523 uikey
= HeapAlloc(GetProcessHeap(), 0, size
*sizeof(WCHAR
));
3524 strcpyW(uikey
,szRoot
);
3525 strcatW(uikey
,deformated
);
3527 if (RegCreateKeyW( root_key
, deformated
, &hkey
))
3529 ERR("Could not create key %s\n",debugstr_w(deformated
));
3530 msiobj_release(&row
->hdr
);
3531 HeapFree(GetProcessHeap(),0,deformated
);
3534 HeapFree(GetProcessHeap(),0,deformated
);
3536 value
= load_dynamic_stringW(row
,5);
3538 value_data
= parse_value(package
, value
, &type
, &size
);
3541 static const WCHAR szEmpty
[] = {0};
3542 value_data
= (LPSTR
)strdupW(szEmpty
);
3547 deformat_string(package
, name
, &deformated
);
3549 TRACE("Setting value %s\n",debugstr_w(deformated
));
3550 RegSetValueExW(hkey
, deformated
, 0, type
, value_data
, size
);
3552 uirow
= MSI_CreateRecord(3);
3553 MSI_RecordSetStringW(uirow
,2,deformated
);
3554 MSI_RecordSetStringW(uirow
,1,uikey
);
3557 MSI_RecordSetStringW(uirow
,3,(LPWSTR
)value_data
);
3559 MSI_RecordSetStringW(uirow
,3,value
);
3561 ui_actiondata(package
,szWriteRegistryValues
,uirow
);
3562 msiobj_release( &uirow
->hdr
);
3564 HeapFree(GetProcessHeap(),0,value_data
);
3565 HeapFree(GetProcessHeap(),0,value
);
3566 HeapFree(GetProcessHeap(),0,deformated
);
3568 msiobj_release(&row
->hdr
);
3571 HeapFree(GetProcessHeap(),0,uikey
);
3572 HeapFree(GetProcessHeap(),0,key
);
3573 HeapFree(GetProcessHeap(),0,name
);
3574 HeapFree(GetProcessHeap(),0,component
);
3576 MSI_ViewClose(view
);
3577 msiobj_release(&view
->hdr
);
3581 static UINT
ACTION_InstallInitialize(MSIPACKAGE
*package
)
3583 return ERROR_SUCCESS
;
3587 static UINT
ACTION_InstallValidate(MSIPACKAGE
*package
)
3591 static const WCHAR q1
[]=
3592 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
3593 'R','e','g','i','s','t','r','y',0};
3596 MSIRECORD
* row
= 0;
3599 TRACE(" InstallValidate \n");
3601 rc
= MSI_DatabaseOpenViewW(package
->db
, q1
, &view
);
3602 if (rc
!= ERROR_SUCCESS
)
3603 return ERROR_SUCCESS
;
3605 rc
= MSI_ViewExecute(view
, 0);
3606 if (rc
!= ERROR_SUCCESS
)
3608 MSI_ViewClose(view
);
3609 msiobj_release(&view
->hdr
);
3614 rc
= MSI_ViewFetch(view
,&row
);
3615 if (rc
!= ERROR_SUCCESS
)
3622 msiobj_release(&row
->hdr
);
3624 MSI_ViewClose(view
);
3625 msiobj_release(&view
->hdr
);
3627 total
= total
+ progress
* REG_PROGRESS_VALUE
;
3628 total
= total
+ package
->loaded_components
* COMPONENT_PROGRESS_VALUE
;
3629 for (i
=0; i
< package
->loaded_files
; i
++)
3630 total
+= package
->files
[i
].FileSize
;
3631 ui_progress(package
,0,total
,0,0);
3633 return ERROR_SUCCESS
;
3636 static UINT
ACTION_LaunchConditions(MSIPACKAGE
*package
)
3639 MSIQUERY
* view
= NULL
;
3640 MSIRECORD
* row
= 0;
3641 static const WCHAR ExecSeqQuery
[] =
3642 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3643 'L','a','u','n','c','h','C','o','n','d','i','t','i','o','n',0};
3644 static const WCHAR title
[]=
3645 {'I','n','s','t','a','l','l',' ','F','a', 'i','l','e','d',0};
3647 TRACE("Checking launch conditions\n");
3649 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
3650 if (rc
!= ERROR_SUCCESS
)
3651 return ERROR_SUCCESS
;
3653 rc
= MSI_ViewExecute(view
, 0);
3654 if (rc
!= ERROR_SUCCESS
)
3656 MSI_ViewClose(view
);
3657 msiobj_release(&view
->hdr
);
3662 while (rc
== ERROR_SUCCESS
)
3665 LPWSTR message
= NULL
;
3667 rc
= MSI_ViewFetch(view
,&row
);
3668 if (rc
!= ERROR_SUCCESS
)
3674 cond
= load_dynamic_stringW(row
,1);
3676 if (MSI_EvaluateConditionW(package
,cond
) != MSICONDITION_TRUE
)
3679 message
= load_dynamic_stringW(row
,2);
3680 deformat_string(package
,message
,&deformated
);
3681 MessageBoxW(NULL
,deformated
,title
,MB_OK
);
3682 HeapFree(GetProcessHeap(),0,message
);
3683 HeapFree(GetProcessHeap(),0,deformated
);
3684 rc
= ERROR_FUNCTION_FAILED
;
3686 HeapFree(GetProcessHeap(),0,cond
);
3687 msiobj_release(&row
->hdr
);
3689 MSI_ViewClose(view
);
3690 msiobj_release(&view
->hdr
);
3694 static LPWSTR
resolve_keypath( MSIPACKAGE
* package
, INT
3697 MSICOMPONENT
* cmp
= &package
->components
[component_index
];
3699 if (cmp
->KeyPath
[0]==0)
3701 LPWSTR p
= resolve_folder(package
,cmp
->Directory
,FALSE
,FALSE
,NULL
);
3704 if (cmp
->Attributes
& msidbComponentAttributesRegistryKeyPath
)
3707 MSIRECORD
* row
= 0;
3709 LPWSTR key
,deformated
,buffer
,name
,deformated_name
;
3710 static const WCHAR ExecSeqQuery
[] =
3711 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3712 'R','e','g','i','s','t','r','y',' ','W','H','E','R','E',' ',
3713 'R','e','g','i','s','t','r','y',' ','=',' ' ,'`','%','s','`',0 };
3714 static const WCHAR fmt
[]={'%','0','2','i',':','\\','%','s','\\',0};
3715 static const WCHAR fmt2
[]=
3716 {'%','0','2','i',':','\\','%','s','\\','%','s',0};
3718 rc
= MSI_OpenQuery(package
->db
,&view
,ExecSeqQuery
,cmp
->KeyPath
);
3720 if (rc
!=ERROR_SUCCESS
)
3723 rc
= MSI_ViewExecute(view
, 0);
3724 if (rc
!= ERROR_SUCCESS
)
3726 MSI_ViewClose(view
);
3727 msiobj_release(&view
->hdr
);
3731 rc
= MSI_ViewFetch(view
,&row
);
3732 if (rc
!= ERROR_SUCCESS
)
3734 MSI_ViewClose(view
);
3735 msiobj_release(&view
->hdr
);
3739 root
= MSI_RecordGetInteger(row
,2);
3740 key
= load_dynamic_stringW(row
, 3);
3741 name
= load_dynamic_stringW(row
, 4);
3742 deformat_string(package
, key
, &deformated
);
3743 deformat_string(package
, name
, &deformated_name
);
3745 len
= strlenW(deformated
) + 6;
3746 if (deformated_name
)
3747 len
+=strlenW(deformated_name
);
3749 buffer
= HeapAlloc(GetProcessHeap(),0, len
*sizeof(WCHAR
));
3751 if (deformated_name
)
3752 sprintfW(buffer
,fmt2
,root
,deformated
,deformated_name
);
3754 sprintfW(buffer
,fmt
,root
,deformated
);
3756 HeapFree(GetProcessHeap(),0,key
);
3757 HeapFree(GetProcessHeap(),0,deformated
);
3758 HeapFree(GetProcessHeap(),0,name
);
3759 HeapFree(GetProcessHeap(),0,deformated_name
);
3760 msiobj_release(&row
->hdr
);
3761 MSI_ViewClose(view
);
3762 msiobj_release(&view
->hdr
);
3766 else if (cmp
->Attributes
& msidbComponentAttributesODBCDataSource
)
3768 FIXME("UNIMPLEMENTED keypath as ODBC Source\n");
3774 j
= get_loaded_file(package
,cmp
->KeyPath
);
3778 LPWSTR p
= strdupW(package
->files
[j
].TargetPath
);
3785 static HKEY
openSharedDLLsKey()
3788 static const WCHAR path
[] =
3789 {'S','o','f','t','w','a','r','e','\\',
3790 'M','i','c','r','o','s','o','f','t','\\',
3791 'W','i','n','d','o','w','s','\\',
3792 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3793 'S','h','a','r','e','d','D','L','L','s',0};
3795 RegCreateKeyW(HKEY_LOCAL_MACHINE
,path
,&hkey
);
3799 static UINT
ACTION_GetSharedDLLsCount(LPCWSTR dll
)
3804 DWORD sz
= sizeof(count
);
3807 hkey
= openSharedDLLsKey();
3808 rc
= RegQueryValueExW(hkey
, dll
, NULL
, &type
, (LPBYTE
)&count
, &sz
);
3809 if (rc
!= ERROR_SUCCESS
)
3815 static UINT
ACTION_WriteSharedDLLsCount(LPCWSTR path
, UINT count
)
3819 hkey
= openSharedDLLsKey();
3821 RegSetValueExW(hkey
,path
,0,REG_DWORD
,
3822 (LPBYTE
)&count
,sizeof(count
));
3824 RegDeleteValueW(hkey
,path
);
3830 * Return TRUE if the count should be written out and FALSE if not
3832 static void ACTION_RefCountComponent( MSIPACKAGE
* package
, UINT index
)
3838 /* only refcount DLLs */
3839 if (package
->components
[index
].KeyPath
[0]==0 ||
3840 package
->components
[index
].Attributes
&
3841 msidbComponentAttributesRegistryKeyPath
||
3842 package
->components
[index
].Attributes
&
3843 msidbComponentAttributesODBCDataSource
)
3847 count
= ACTION_GetSharedDLLsCount(package
->components
[index
].
3849 write
= (count
> 0);
3851 if (package
->components
[index
].Attributes
&
3852 msidbComponentAttributesSharedDllRefCount
)
3856 /* increment counts */
3857 for (j
= 0; j
< package
->loaded_features
; j
++)
3861 if (!ACTION_VerifyFeatureForAction(package
,j
,INSTALLSTATE_LOCAL
))
3864 for (i
= 0; i
< package
->features
[j
].ComponentCount
; i
++)
3866 if (package
->features
[j
].Components
[i
] == index
)
3870 /* decrement counts */
3871 for (j
= 0; j
< package
->loaded_features
; j
++)
3874 if (!ACTION_VerifyFeatureForAction(package
,j
,INSTALLSTATE_ABSENT
))
3877 for (i
= 0; i
< package
->features
[j
].ComponentCount
; i
++)
3879 if (package
->features
[j
].Components
[i
] == index
)
3884 /* ref count all the files in the component */
3886 for (j
= 0; j
< package
->loaded_files
; j
++)
3888 if (package
->files
[j
].Temporary
)
3890 if (package
->files
[j
].ComponentIndex
== index
)
3891 ACTION_WriteSharedDLLsCount(package
->files
[j
].TargetPath
,count
);
3894 /* add a count for permenent */
3895 if (package
->components
[index
].Attributes
&
3896 msidbComponentAttributesPermanent
)
3899 package
->components
[index
].RefCount
= count
;
3902 ACTION_WriteSharedDLLsCount(package
->components
[index
].FullKeypath
,
3903 package
->components
[index
].RefCount
);
3907 * Ok further analysis makes me think that this work is
3908 * actually done in the PublishComponents and PublishFeatures
3909 * step, and not here. It appears like the keypath and all that is
3910 * resolved in this step, however actually written in the Publish steps.
3911 * But we will leave it here for now because it is unclear
3913 static UINT
ACTION_ProcessComponents(MSIPACKAGE
*package
)
3916 WCHAR squished_pc
[GUID_SIZE
];
3917 WCHAR squished_cc
[GUID_SIZE
];
3920 HKEY hkey
=0,hkey2
=0;
3923 return ERROR_INVALID_HANDLE
;
3925 /* writes the Component and Features values to the registry */
3926 productcode
= load_dynamic_property(package
,szProductCode
,&rc
);
3930 rc
= MSIREG_OpenComponents(&hkey
);
3931 if (rc
!= ERROR_SUCCESS
)
3934 squash_guid(productcode
,squished_pc
);
3935 ui_progress(package
,1,COMPONENT_PROGRESS_VALUE
,1,0);
3936 for (i
= 0; i
< package
->loaded_components
; i
++)
3938 ui_progress(package
,2,0,0,0);
3939 if (package
->components
[i
].ComponentId
[0]!=0)
3941 WCHAR
*keypath
= NULL
;
3944 squash_guid(package
->components
[i
].ComponentId
,squished_cc
);
3945 rc
= RegCreateKeyW(hkey
,squished_cc
,&hkey2
);
3946 if (rc
!= ERROR_SUCCESS
)
3949 keypath
= resolve_keypath(package
,i
);
3950 package
->components
[i
].FullKeypath
= keypath
;
3952 /* do the refcounting */
3953 ACTION_RefCountComponent( package
, i
);
3955 TRACE("Component %s, Keypath=%s, RefCount=%i\n",
3956 debugstr_w(package
->components
[i
].Component
),
3957 debugstr_w(package
->components
[i
].FullKeypath
),
3958 package
->components
[i
].RefCount
);
3960 * Write the keypath out if the component is to be registered
3961 * and delete the key if the component is to be deregistered
3963 if (ACTION_VerifyComponentForAction(package
, i
,
3964 INSTALLSTATE_LOCAL
))
3968 RegSetValueExW(hkey2
,squished_pc
,0,REG_SZ
,(LPVOID
)keypath
,
3969 (strlenW(keypath
)+1)*sizeof(WCHAR
));
3971 if (package
->components
[i
].Attributes
&
3972 msidbComponentAttributesPermanent
)
3974 static const WCHAR szPermKey
[] =
3975 { '0','0','0','0','0','0','0','0','0','0','0','0',
3976 '0','0','0','0','0','0','0', '0','0','0','0','0',
3977 '0','0','0','0','0','0','0','0',0};
3979 RegSetValueExW(hkey2
,szPermKey
,0,REG_SZ
,
3981 (strlenW(keypath
)+1)*sizeof(WCHAR
));
3987 uirow
= MSI_CreateRecord(3);
3988 MSI_RecordSetStringW(uirow
,1,productcode
);
3989 MSI_RecordSetStringW(uirow
,2,package
->components
[i
].
3991 MSI_RecordSetStringW(uirow
,3,keypath
);
3992 ui_actiondata(package
,szProcessComponents
,uirow
);
3993 msiobj_release( &uirow
->hdr
);
3996 else if (ACTION_VerifyComponentForAction(package
, i
,
3997 INSTALLSTATE_ABSENT
))
4000 RegDeleteValueW(hkey2
,squished_pc
);
4002 /* if the key is empty delete it */
4003 res
= RegEnumKeyExW(hkey2
,0,NULL
,0,0,NULL
,0,NULL
);
4005 if (res
== ERROR_NO_MORE_ITEMS
)
4006 RegDeleteKeyW(hkey
,squished_cc
);
4009 uirow
= MSI_CreateRecord(2);
4010 MSI_RecordSetStringW(uirow
,1,productcode
);
4011 MSI_RecordSetStringW(uirow
,2,package
->components
[i
].
4013 ui_actiondata(package
,szProcessComponents
,uirow
);
4014 msiobj_release( &uirow
->hdr
);
4019 HeapFree(GetProcessHeap(), 0, productcode
);
4032 BOOL CALLBACK
Typelib_EnumResNameProc( HMODULE hModule
, LPCWSTR lpszType
,
4033 LPWSTR lpszName
, LONG_PTR lParam
)
4036 typelib_struct
*tl_struct
= (typelib_struct
*) lParam
;
4037 static const WCHAR fmt
[] = {'%','s','\\','%','i',0};
4041 if (!IS_INTRESOURCE(lpszName
))
4043 ERR("Not Int Resource Name %s\n",debugstr_w(lpszName
));
4047 sz
= strlenW(tl_struct
->source
)+4;
4048 sz
*= sizeof(WCHAR
);
4050 tl_struct
->path
= HeapAlloc(GetProcessHeap(),0,sz
);
4051 sprintfW(tl_struct
->path
,fmt
,tl_struct
->source
, lpszName
);
4053 TRACE("trying %s\n", debugstr_w(tl_struct
->path
));
4054 res
= LoadTypeLib(tl_struct
->path
,&tl_struct
->ptLib
);
4055 if (!SUCCEEDED(res
))
4057 HeapFree(GetProcessHeap(),0,tl_struct
->path
);
4058 tl_struct
->path
= NULL
;
4063 ITypeLib_GetLibAttr(tl_struct
->ptLib
, &attr
);
4064 if (IsEqualGUID(&(tl_struct
->clsid
),&(attr
->guid
)))
4066 ITypeLib_ReleaseTLibAttr(tl_struct
->ptLib
, attr
);
4070 HeapFree(GetProcessHeap(),0,tl_struct
->path
);
4071 tl_struct
->path
= NULL
;
4073 ITypeLib_ReleaseTLibAttr(tl_struct
->ptLib
, attr
);
4074 ITypeLib_Release(tl_struct
->ptLib
);
4079 static UINT
ACTION_RegisterTypeLibraries(MSIPACKAGE
*package
)
4082 * OK this is a bit confusing.. I am given a _Component key and I believe
4083 * that the file that is being registered as a type library is the "key file
4084 * of that component" which I interpret to mean "The file in the KeyPath of
4089 MSIRECORD
* row
= 0;
4090 static const WCHAR Query
[] =
4091 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
4092 'T','y','p','e','L','i','b',0};
4095 return ERROR_INVALID_HANDLE
;
4097 rc
= MSI_DatabaseOpenViewW(package
->db
, Query
, &view
);
4098 if (rc
!= ERROR_SUCCESS
)
4099 return ERROR_SUCCESS
;
4101 rc
= MSI_ViewExecute(view
, 0);
4102 if (rc
!= ERROR_SUCCESS
)
4104 MSI_ViewClose(view
);
4105 msiobj_release(&view
->hdr
);
4111 WCHAR component
[0x100];
4115 typelib_struct tl_struct
;
4117 static const WCHAR szTYPELIB
[] = {'T','Y','P','E','L','I','B',0};
4119 rc
= MSI_ViewFetch(view
,&row
);
4120 if (rc
!= ERROR_SUCCESS
)
4127 MSI_RecordGetStringW(row
,3,component
,&sz
);
4129 index
= get_loaded_component(package
,component
);
4132 msiobj_release(&row
->hdr
);
4136 if (!ACTION_VerifyComponentForAction(package
, index
,
4137 INSTALLSTATE_LOCAL
))
4139 TRACE("Skipping typelib reg due to disabled component\n");
4140 msiobj_release(&row
->hdr
);
4142 package
->components
[index
].Action
=
4143 package
->components
[index
].Installed
;
4148 package
->components
[index
].Action
= INSTALLSTATE_LOCAL
;
4150 index
= get_loaded_file(package
,package
->components
[index
].KeyPath
);
4154 msiobj_release(&row
->hdr
);
4158 guid
= load_dynamic_stringW(row
,1);
4159 module
= LoadLibraryExW(package
->files
[index
].TargetPath
, NULL
,
4160 LOAD_LIBRARY_AS_DATAFILE
);
4163 CLSIDFromString(guid
, &tl_struct
.clsid
);
4164 tl_struct
.source
= strdupW(package
->files
[index
].TargetPath
);
4165 tl_struct
.path
= NULL
;
4167 EnumResourceNamesW(module
, szTYPELIB
, Typelib_EnumResNameProc
,
4168 (LONG_PTR
)&tl_struct
);
4170 if (tl_struct
.path
!= NULL
)
4173 WCHAR helpid
[0x100];
4177 MSI_RecordGetStringW(row
,6,helpid
,&sz
);
4179 help
= resolve_folder(package
,helpid
,FALSE
,FALSE
,NULL
);
4180 res
= RegisterTypeLib(tl_struct
.ptLib
,tl_struct
.path
,help
);
4181 HeapFree(GetProcessHeap(),0,help
);
4183 if (!SUCCEEDED(res
))
4184 ERR("Failed to register type library %s\n",
4185 debugstr_w(tl_struct
.path
));
4188 ui_actiondata(package
,szRegisterTypeLibraries
,row
);
4190 TRACE("Registered %s\n", debugstr_w(tl_struct
.path
));
4193 ITypeLib_Release(tl_struct
.ptLib
);
4194 HeapFree(GetProcessHeap(),0,tl_struct
.path
);
4197 ERR("Failed to load type library %s\n",
4198 debugstr_w(tl_struct
.source
));
4200 FreeLibrary(module
);
4201 HeapFree(GetProcessHeap(),0,tl_struct
.source
);
4204 ERR("Could not load file! %s\n",
4205 debugstr_w(package
->files
[index
].TargetPath
));
4206 msiobj_release(&row
->hdr
);
4208 MSI_ViewClose(view
);
4209 msiobj_release(&view
->hdr
);
4213 static UINT
register_appid(MSIPACKAGE
*package
, LPCWSTR clsid
, LPCWSTR app
)
4215 static const WCHAR szAppID
[] = { 'A','p','p','I','D',0 };
4218 MSIRECORD
* row
= 0;
4219 static const WCHAR ExecSeqQuery
[] =
4220 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
4221 'A','p','p','I' ,'d',' ','w','h','e','r','e',' ',
4222 'A','p','p','I','d','=','`','%','s','`',0};
4227 return ERROR_INVALID_HANDLE
;
4229 rc
= MSI_OpenQuery(package
->db
, &view
, ExecSeqQuery
, clsid
);
4230 if (rc
!= ERROR_SUCCESS
)
4233 rc
= MSI_ViewExecute(view
, 0);
4234 if (rc
!= ERROR_SUCCESS
)
4236 MSI_ViewClose(view
);
4237 msiobj_release(&view
->hdr
);
4241 RegCreateKeyW(HKEY_CLASSES_ROOT
,szAppID
,&hkey2
);
4242 RegCreateKeyW(hkey2
,clsid
,&hkey3
);
4243 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
,(LPVOID
)app
,
4244 (strlenW(app
)+1)*sizeof(WCHAR
));
4246 rc
= MSI_ViewFetch(view
,&row
);
4247 if (rc
!= ERROR_SUCCESS
)
4249 MSI_ViewClose(view
);
4250 msiobj_release(&view
->hdr
);
4254 if (!MSI_RecordIsNull(row
,2))
4256 LPWSTR deformated
=0;
4258 static const WCHAR szRemoteServerName
[] =
4259 {'R','e','m','o','t','e','S','e','r','v','e','r','N','a','m','e',
4261 buffer
= load_dynamic_stringW(row
,2);
4262 size
= deformat_string(package
,buffer
,&deformated
);
4263 RegSetValueExW(hkey3
,szRemoteServerName
,0,REG_SZ
,(LPVOID
)deformated
,
4265 HeapFree(GetProcessHeap(),0,deformated
);
4266 HeapFree(GetProcessHeap(),0,buffer
);
4269 if (!MSI_RecordIsNull(row
,3))
4271 static const WCHAR szLocalService
[] =
4272 {'L','o','c','a','l','S','e','r','v','i','c','e',0};
4274 buffer
= load_dynamic_stringW(row
,3);
4275 size
= (strlenW(buffer
)+1) * sizeof(WCHAR
);
4276 RegSetValueExW(hkey3
,szLocalService
,0,REG_SZ
,(LPVOID
)buffer
,size
);
4277 HeapFree(GetProcessHeap(),0,buffer
);
4280 if (!MSI_RecordIsNull(row
,4))
4282 static const WCHAR szService
[] =
4283 {'S','e','r','v','i','c','e',
4284 'P','a','r','a','m','e','t','e','r','s',0};
4286 buffer
= load_dynamic_stringW(row
,4);
4287 size
= (strlenW(buffer
)+1) * sizeof(WCHAR
);
4288 RegSetValueExW(hkey3
,szService
,0,REG_SZ
,(LPVOID
)buffer
,size
);
4289 HeapFree(GetProcessHeap(),0,buffer
);
4292 if (!MSI_RecordIsNull(row
,5))
4294 static const WCHAR szDLL
[] =
4295 {'D','l','l','S','u','r','r','o','g','a','t','e',0};
4297 buffer
= load_dynamic_stringW(row
,5);
4298 size
= (strlenW(buffer
)+1) * sizeof(WCHAR
);
4299 RegSetValueExW(hkey3
,szDLL
,0,REG_SZ
,(LPVOID
)buffer
,size
);
4300 HeapFree(GetProcessHeap(),0,buffer
);
4303 if (!MSI_RecordIsNull(row
,6))
4305 static const WCHAR szActivate
[] =
4306 {'A','c','t','i','v','a','t','e','A','s',
4307 'S','t','o','r','a','g','e',0};
4308 static const WCHAR szY
[] = {'Y',0};
4310 if (MSI_RecordGetInteger(row
,6))
4311 RegSetValueExW(hkey3
,szActivate
,0,REG_SZ
,(LPVOID
)szY
,4);
4314 if (!MSI_RecordIsNull(row
,7))
4316 static const WCHAR szRunAs
[] = {'R','u','n','A','s',0};
4317 static const WCHAR szUser
[] =
4318 {'I','n','t','e','r','a','c','t','i','v','e',' ',
4321 if (MSI_RecordGetInteger(row
,7))
4322 RegSetValueExW(hkey3
,szRunAs
,0,REG_SZ
,(LPVOID
)szUser
,34);
4325 msiobj_release(&row
->hdr
);
4326 MSI_ViewClose(view
);
4327 msiobj_release(&view
->hdr
);
4333 static UINT
ACTION_RegisterClassInfo(MSIPACKAGE
*package
)
4336 * Again I am assuming the words, "Whose key file represents" when referring
4337 * to a Component as to meaning that Components KeyPath file
4339 * Also there is a very strong connection between ClassInfo and ProgID
4340 * that I am mostly glossing over.
4341 * What would be more propper is to load the ClassInfo and the ProgID info
4342 * into memory data structures and then be able to enable and disable them
4343 * based on component.
4348 MSIRECORD
* row
= 0;
4349 static const WCHAR ExecSeqQuery
[] =
4350 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
4351 'C','l','a','s','s',0};
4352 static const WCHAR szCLSID
[] = { 'C','L','S','I','D',0 };
4353 static const WCHAR szProgID
[] = { 'P','r','o','g','I','D',0 };
4354 static const WCHAR szAppID
[] = { 'A','p','p','I','D',0 };
4355 static const WCHAR szSpace
[] = {' ',0};
4356 HKEY hkey
,hkey2
,hkey3
;
4357 LPWSTR argument
,deformated
;
4360 return ERROR_INVALID_HANDLE
;
4362 rc
= RegCreateKeyW(HKEY_CLASSES_ROOT
,szCLSID
,&hkey
);
4363 if (rc
!= ERROR_SUCCESS
)
4364 return ERROR_FUNCTION_FAILED
;
4366 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
4367 if (rc
!= ERROR_SUCCESS
)
4373 rc
= MSI_ViewExecute(view
, 0);
4374 if (rc
!= ERROR_SUCCESS
)
4376 MSI_ViewClose(view
);
4377 msiobj_release(&view
->hdr
);
4384 WCHAR buffer
[0x100];
4390 rc
= MSI_ViewFetch(view
,&row
);
4391 if (rc
!= ERROR_SUCCESS
)
4398 MSI_RecordGetStringW(row
,3,buffer
,&sz
);
4400 index
= get_loaded_component(package
,buffer
);
4404 msiobj_release(&row
->hdr
);
4408 if (!ACTION_VerifyComponentForAction(package
, index
,
4409 INSTALLSTATE_LOCAL
))
4411 TRACE("Skipping class reg due to disabled component\n");
4412 msiobj_release(&row
->hdr
);
4414 package
->components
[index
].Action
=
4415 package
->components
[index
].Installed
;
4420 package
->components
[index
].Action
= INSTALLSTATE_LOCAL
;
4423 MSI_RecordGetStringW(row
,1,clsid
,&sz
);
4424 RegCreateKeyW(hkey
,clsid
,&hkey2
);
4426 if (!MSI_RecordIsNull(row
,5))
4429 MSI_RecordGetStringW(row
,5,desc
,&sz
);
4431 RegSetValueExW(hkey2
,NULL
,0,REG_SZ
,(LPVOID
)desc
,
4432 (strlenW(desc
)+1)*sizeof(WCHAR
));
4438 MSI_RecordGetStringW(row
,2,buffer
,&sz
);
4440 RegCreateKeyW(hkey2
,buffer
,&hkey3
);
4442 index
= get_loaded_file(package
,package
->components
[index
].KeyPath
);
4444 argument
= load_dynamic_stringW(row
,11);
4445 size
= deformat_string(package
,argument
,&deformated
);
4447 size
+=sizeof(WCHAR
);
4448 HeapFree(GetProcessHeap(),0,argument
);
4449 size
+= (strlenW(package
->files
[index
].TargetPath
))*sizeof(WCHAR
);
4451 argument
= HeapAlloc(GetProcessHeap(),0,size
+sizeof(WCHAR
));
4452 strcpyW(argument
,package
->files
[index
].TargetPath
);
4455 strcatW(argument
,szSpace
);
4456 strcatW(argument
,deformated
);
4459 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
, (LPVOID
)argument
, size
);
4460 HeapFree(GetProcessHeap(),0,deformated
);
4461 HeapFree(GetProcessHeap(),0,argument
);
4465 if (!MSI_RecordIsNull(row
,4))
4468 MSI_RecordGetStringW(row
,4,buffer
,&sz
);
4470 RegCreateKeyW(hkey2
,szProgID
,&hkey3
);
4472 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
,(LPVOID
)buffer
,
4473 (strlenW(buffer
)+1)*sizeof(WCHAR
));
4478 if (!MSI_RecordIsNull(row
,6))
4481 MSI_RecordGetStringW(row
,6,buffer
,&sz
);
4483 RegSetValueExW(hkey2
,szAppID
,0,REG_SZ
,(LPVOID
)buffer
,
4484 (strlenW(buffer
)+1)*sizeof(WCHAR
));
4486 register_appid(package
,buffer
,desc
);
4490 if (!MSI_RecordIsNull(row
,7))
4492 FIXME("Process field 7\n");
4495 if (!MSI_RecordIsNull(row
,8))
4497 static const WCHAR szDefaultIcon
[] =
4498 {'D','e','f','a','u','l','t','I','c','o','n',0};
4500 LPWSTR FileName
= load_dynamic_stringW(row
,8);
4504 RegCreateKeyW(hkey2
,szDefaultIcon
,&hkey3
);
4505 build_icon_path(package
,FileName
,&FilePath
);
4506 if (!MSI_RecordIsNull(row
,9))
4508 static const WCHAR index_fmt
[] = {',','%','i',0};
4509 WCHAR index_buf
[20];
4510 index
= MSI_RecordGetInteger(row
,9);
4511 sprintfW(index_buf
,index_fmt
,index
);
4512 size
= strlenW(FilePath
)+strlenW(index_buf
)+1;
4513 size
*= sizeof(WCHAR
);
4514 HeapReAlloc(GetProcessHeap(),0,FilePath
,size
);
4516 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
,(LPVOID
)FilePath
,
4517 (strlenW(FilePath
)+1) * sizeof(WCHAR
));
4518 HeapFree(GetProcessHeap(),0,FilePath
);
4519 HeapFree(GetProcessHeap(),0,FileName
);
4523 if (!MSI_RecordIsNull(row
,10))
4525 static const WCHAR szInproc32
[] =
4526 {'I','n','p','r','o','c','H','a','n','d','l','e','r','3','2',
4528 static const WCHAR szInproc
[] =
4529 {'I','n','p','r','o','c','H','a','n','d','l','e','r',0};
4530 INT i
= MSI_RecordGetInteger(row
,10);
4531 if (i
!= MSI_NULL_INTEGER
&& i
> 0 && i
< 4)
4533 static const WCHAR ole2
[] = {'o','l','e','2','.','d','l','l',0};
4534 static const WCHAR ole32
[] =
4535 {'o','l','e','3','2','.','d','l','l',0};
4539 size
= strlenW(ole2
) * sizeof(WCHAR
);
4540 RegCreateKeyW(hkey2
,szInproc
,&hkey3
);
4541 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
, (LPVOID
)ole2
, size
);
4545 size
= strlenW(ole32
) * sizeof(WCHAR
);
4546 RegCreateKeyW(hkey2
,szInproc32
,&hkey3
);
4547 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
, (LPVOID
)ole32
,size
);
4551 size
= strlenW(ole2
) * sizeof(WCHAR
);
4552 RegCreateKeyW(hkey2
,szInproc
,&hkey3
);
4553 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
, (LPVOID
)ole2
, size
);
4555 size
= strlenW(ole32
) * sizeof(WCHAR
);
4556 RegCreateKeyW(hkey2
,szInproc32
,&hkey3
);
4557 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
, (LPVOID
)ole32
,size
);
4565 RegCreateKeyW(hkey2
,szInproc32
,&hkey3
);
4566 argument
= load_dynamic_stringW(row
,10);
4567 reduce_to_longfilename(argument
);
4568 size
= strlenW(argument
)*sizeof(WCHAR
);
4570 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
, (LPVOID
)argument
, size
);
4571 HeapFree(GetProcessHeap(),0,argument
);
4579 ui_actiondata(package
,szRegisterClassInfo
,row
);
4581 msiobj_release(&row
->hdr
);
4583 MSI_ViewClose(view
);
4584 msiobj_release(&view
->hdr
);
4591 static UINT
register_progid_base(MSIPACKAGE
* package
, MSIRECORD
* row
,
4594 static const WCHAR szCLSID
[] = { 'C','L','S','I','D',0 };
4595 static const WCHAR szDefaultIcon
[] =
4596 {'D','e','f','a','u','l','t','I','c','o','n',0};
4598 WCHAR buffer
[0x100];
4603 MSI_RecordGetStringW(row
,1,buffer
,&sz
);
4604 RegCreateKeyW(HKEY_CLASSES_ROOT
,buffer
,&hkey
);
4606 if (!MSI_RecordIsNull(row
,4))
4609 MSI_RecordGetStringW(row
,4,buffer
,&sz
);
4610 RegSetValueExW(hkey
,NULL
,0,REG_SZ
,(LPVOID
)buffer
, (strlenW(buffer
)+1) *
4614 if (!MSI_RecordIsNull(row
,3))
4618 MSI_RecordGetStringW(row
,3,buffer
,&sz
);
4619 RegCreateKeyW(hkey
,szCLSID
,&hkey2
);
4620 RegSetValueExW(hkey2
,NULL
,0,REG_SZ
,(LPVOID
)buffer
, (strlenW(buffer
)+1) *
4624 strcpyW(clsid
,buffer
);
4630 FIXME("UNHANDLED case, Parent progid but classid is NULL\n");
4631 return ERROR_FUNCTION_FAILED
;
4633 if (!MSI_RecordIsNull(row
,5))
4635 INT index
= MSI_RecordGetInteger(row
,6);
4636 LPWSTR FileName
= load_dynamic_stringW(row
,5);
4637 LPWSTR FilePath
,IconPath
;
4638 static const WCHAR fmt
[] = {'%','s',',','%','i',0};
4640 RegCreateKeyW(hkey
,szDefaultIcon
,&hkey2
);
4641 build_icon_path(package
,FileName
,&FilePath
);
4643 IconPath
= HeapAlloc(GetProcessHeap(),0,(strlenW(FilePath
)+5)*
4646 sprintfW(IconPath
,fmt
,FilePath
,index
);
4647 RegSetValueExW(hkey2
,NULL
,0,REG_SZ
,(LPVOID
)IconPath
,
4648 (strlenW(IconPath
)+1) * sizeof(WCHAR
));
4649 HeapFree(GetProcessHeap(),0,FilePath
);
4650 HeapFree(GetProcessHeap(),0,FileName
);
4653 return ERROR_SUCCESS
;
4656 static UINT
register_progid(MSIPACKAGE
*package
, MSIRECORD
* row
, LPWSTR clsid
);
4658 static UINT
register_parent_progid(MSIPACKAGE
*package
, LPCWSTR parent
,
4663 MSIRECORD
* row
= 0;
4664 static const WCHAR Query_t
[] =
4665 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
4666 'P','r','o','g' ,'I','d',' ','W','H','E','R','E',' ',
4667 'P','r','o','g','I','d',' ','=',' ','`' ,'%','s','`',0};
4670 return ERROR_INVALID_HANDLE
;
4672 rc
= MSI_OpenQuery(package
->db
, &view
, Query_t
, parent
);
4673 if (rc
!= ERROR_SUCCESS
)
4676 rc
= MSI_ViewExecute(view
, 0);
4677 if (rc
!= ERROR_SUCCESS
)
4679 MSI_ViewClose(view
);
4680 msiobj_release(&view
->hdr
);
4684 rc
= MSI_ViewFetch(view
,&row
);
4685 if (rc
!= ERROR_SUCCESS
)
4687 MSI_ViewClose(view
);
4688 msiobj_release(&view
->hdr
);
4692 register_progid(package
,row
,clsid
);
4694 msiobj_release(&row
->hdr
);
4695 MSI_ViewClose(view
);
4696 msiobj_release(&view
->hdr
);
4700 static UINT
register_progid(MSIPACKAGE
*package
, MSIRECORD
* row
, LPWSTR clsid
)
4702 UINT rc
= ERROR_SUCCESS
;
4704 if (MSI_RecordIsNull(row
,2))
4705 rc
= register_progid_base(package
,row
,clsid
);
4708 WCHAR buffer
[0x1000];
4711 static const WCHAR szCLSID
[] = { 'C','L','S','I','D',0 };
4712 static const WCHAR szDefaultIcon
[] =
4713 {'D','e','f','a','u','l','t','I','c','o','n',0};
4715 /* check if already registered */
4717 MSI_RecordGetStringW(row
,1,buffer
,&sz
);
4718 RegCreateKeyExW(HKEY_CLASSES_ROOT
, buffer
, 0, NULL
, 0,
4719 KEY_ALL_ACCESS
, NULL
, &hkey
, &disp
);
4720 if (disp
== REG_OPENED_EXISTING_KEY
)
4722 TRACE("Key already registered\n");
4728 MSI_RecordGetStringW(row
,2,buffer
,&sz
);
4729 rc
= register_parent_progid(package
,buffer
,clsid
);
4731 /* clsid is same as parent */
4732 RegCreateKeyW(hkey
,szCLSID
,&hkey2
);
4733 RegSetValueExW(hkey2
,NULL
,0,REG_SZ
,(LPVOID
)clsid
, (strlenW(clsid
)+1) *
4739 if (!MSI_RecordIsNull(row
,4))
4742 MSI_RecordGetStringW(row
,4,buffer
,&sz
);
4743 RegSetValueExW(hkey
,NULL
,0,REG_SZ
,(LPVOID
)buffer
,
4744 (strlenW(buffer
)+1) * sizeof(WCHAR
));
4747 if (!MSI_RecordIsNull(row
,5))
4749 LPWSTR FileName
= load_dynamic_stringW(row
,5);
4751 RegCreateKeyW(hkey
,szDefaultIcon
,&hkey2
);
4752 build_icon_path(package
,FileName
,&FilePath
);
4753 RegSetValueExW(hkey2
,NULL
,0,REG_SZ
,(LPVOID
)FilePath
,
4754 (strlenW(FilePath
)+1) * sizeof(WCHAR
));
4755 HeapFree(GetProcessHeap(),0,FilePath
);
4756 HeapFree(GetProcessHeap(),0,FileName
);
4765 static UINT
ACTION_RegisterProgIdInfo(MSIPACKAGE
*package
)
4768 * Sigh, here I am just brute force registering all progids
4769 * this needs to be linked to the Classes that have been registered
4770 * but the easiest way to do that is to load all these stuff into
4771 * memory for easy checking.
4773 * Gives me something to continue to work toward.
4777 MSIRECORD
* row
= 0;
4778 static const WCHAR Query
[] =
4779 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
4780 'P','r','o','g','I','d',0};
4783 return ERROR_INVALID_HANDLE
;
4785 rc
= MSI_DatabaseOpenViewW(package
->db
, Query
, &view
);
4786 if (rc
!= ERROR_SUCCESS
)
4787 return ERROR_SUCCESS
;
4789 rc
= MSI_ViewExecute(view
, 0);
4790 if (rc
!= ERROR_SUCCESS
)
4792 MSI_ViewClose(view
);
4793 msiobj_release(&view
->hdr
);
4799 WCHAR clsid
[0x1000];
4801 rc
= MSI_ViewFetch(view
,&row
);
4802 if (rc
!= ERROR_SUCCESS
)
4808 register_progid(package
,row
,clsid
);
4809 ui_actiondata(package
,szRegisterProgIdInfo
,row
);
4811 msiobj_release(&row
->hdr
);
4813 MSI_ViewClose(view
);
4814 msiobj_release(&view
->hdr
);
4818 static UINT
build_icon_path(MSIPACKAGE
*package
, LPCWSTR icon_name
,
4822 LPWSTR SystemFolder
;
4826 static const WCHAR szInstaller
[] =
4827 {'I','n','s','t','a','l','l','e','r','\\',0};
4828 static const WCHAR szFolder
[] =
4829 {'W','i','n','d','o','w','s','F','o','l','d','e','r',0};
4831 ProductCode
= load_dynamic_property(package
,szProductCode
,&rc
);
4835 SystemFolder
= load_dynamic_property(package
,szFolder
,NULL
);
4837 dest
= build_directory_name(3, SystemFolder
, szInstaller
, ProductCode
);
4839 create_full_pathW(dest
);
4841 *FilePath
= build_directory_name(2, dest
, icon_name
);
4843 HeapFree(GetProcessHeap(),0,SystemFolder
);
4844 HeapFree(GetProcessHeap(),0,ProductCode
);
4845 HeapFree(GetProcessHeap(),0,dest
);
4846 return ERROR_SUCCESS
;
4849 static UINT
ACTION_CreateShortcuts(MSIPACKAGE
*package
)
4853 MSIRECORD
* row
= 0;
4854 static const WCHAR Query
[] =
4855 {'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ',
4856 'S','h','o','r','t','c','u','t',0};
4862 return ERROR_INVALID_HANDLE
;
4864 res
= CoInitialize( NULL
);
4867 ERR("CoInitialize failed\n");
4868 return ERROR_FUNCTION_FAILED
;
4871 rc
= MSI_DatabaseOpenViewW(package
->db
, Query
, &view
);
4872 if (rc
!= ERROR_SUCCESS
)
4873 return ERROR_SUCCESS
;
4875 rc
= MSI_ViewExecute(view
, 0);
4876 if (rc
!= ERROR_SUCCESS
)
4878 MSI_ViewClose(view
);
4879 msiobj_release(&view
->hdr
);
4885 LPWSTR target_file
, target_folder
;
4886 WCHAR buffer
[0x100];
4889 static const WCHAR szlnk
[]={'.','l','n','k',0};
4891 rc
= MSI_ViewFetch(view
,&row
);
4892 if (rc
!= ERROR_SUCCESS
)
4899 MSI_RecordGetStringW(row
,4,buffer
,&sz
);
4901 index
= get_loaded_component(package
,buffer
);
4905 msiobj_release(&row
->hdr
);
4909 if (!ACTION_VerifyComponentForAction(package
, index
,
4910 INSTALLSTATE_LOCAL
))
4912 TRACE("Skipping shortcut creation due to disabled component\n");
4913 msiobj_release(&row
->hdr
);
4915 package
->components
[index
].Action
=
4916 package
->components
[index
].Installed
;
4921 package
->components
[index
].Action
= INSTALLSTATE_LOCAL
;
4923 ui_actiondata(package
,szCreateShortcuts
,row
);
4925 res
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
4926 &IID_IShellLinkW
, (LPVOID
*) &sl
);
4930 ERR("Is IID_IShellLink\n");
4931 msiobj_release(&row
->hdr
);
4935 res
= IShellLinkW_QueryInterface( sl
, &IID_IPersistFile
,(LPVOID
*) &pf
);
4938 ERR("Is IID_IPersistFile\n");
4939 msiobj_release(&row
->hdr
);
4944 MSI_RecordGetStringW(row
,2,buffer
,&sz
);
4945 target_folder
= resolve_folder(package
, buffer
,FALSE
,FALSE
,NULL
);
4947 /* may be needed because of a bug somehwere else */
4948 create_full_pathW(target_folder
);
4951 MSI_RecordGetStringW(row
,3,buffer
,&sz
);
4952 reduce_to_longfilename(buffer
);
4953 if (!strchrW(buffer
,'.') || strcmpiW(strchrW(buffer
,'.'),szlnk
))
4954 strcatW(buffer
,szlnk
);
4955 target_file
= build_directory_name(2, target_folder
, buffer
);
4956 HeapFree(GetProcessHeap(),0,target_folder
);
4959 MSI_RecordGetStringW(row
,5,buffer
,&sz
);
4960 if (strchrW(buffer
,'['))
4963 deformat_string(package
,buffer
,&deformated
);
4964 IShellLinkW_SetPath(sl
,deformated
);
4965 HeapFree(GetProcessHeap(),0,deformated
);
4970 FIXME("poorly handled shortcut format, advertised shortcut\n");
4971 keypath
= strdupW(package
->components
[index
].FullKeypath
);
4972 IShellLinkW_SetPath(sl
,keypath
);
4973 HeapFree(GetProcessHeap(),0,keypath
);
4976 if (!MSI_RecordIsNull(row
,6))
4980 MSI_RecordGetStringW(row
,6,buffer
,&sz
);
4981 deformat_string(package
,buffer
,&deformated
);
4982 IShellLinkW_SetArguments(sl
,deformated
);
4983 HeapFree(GetProcessHeap(),0,deformated
);
4986 if (!MSI_RecordIsNull(row
,7))
4989 deformated
= load_dynamic_stringW(row
,7);
4990 IShellLinkW_SetDescription(sl
,deformated
);
4991 HeapFree(GetProcessHeap(),0,deformated
);
4994 if (!MSI_RecordIsNull(row
,8))
4995 IShellLinkW_SetHotkey(sl
,MSI_RecordGetInteger(row
,8));
4997 if (!MSI_RecordIsNull(row
,9))
5003 MSI_RecordGetStringW(row
,9,buffer
,&sz
);
5005 build_icon_path(package
,buffer
,&Path
);
5006 index
= MSI_RecordGetInteger(row
,10);
5008 IShellLinkW_SetIconLocation(sl
,Path
,index
);
5009 HeapFree(GetProcessHeap(),0,Path
);
5012 if (!MSI_RecordIsNull(row
,11))
5013 IShellLinkW_SetShowCmd(sl
,MSI_RecordGetInteger(row
,11));
5015 if (!MSI_RecordIsNull(row
,12))
5019 MSI_RecordGetStringW(row
,12,buffer
,&sz
);
5020 Path
= resolve_folder(package
, buffer
, FALSE
, FALSE
, NULL
);
5021 IShellLinkW_SetWorkingDirectory(sl
,Path
);
5022 HeapFree(GetProcessHeap(), 0, Path
);
5025 TRACE("Writing shortcut to %s\n",debugstr_w(target_file
));
5026 IPersistFile_Save(pf
,target_file
,FALSE
);
5028 HeapFree(GetProcessHeap(),0,target_file
);
5030 IPersistFile_Release( pf
);
5031 IShellLinkW_Release( sl
);
5033 msiobj_release(&row
->hdr
);
5035 MSI_ViewClose(view
);
5036 msiobj_release(&view
->hdr
);
5046 * 99% of the work done here is only done for
5047 * advertised installs. However this is where the
5048 * Icon table is processed and written out
5049 * so that is what I am going to do here.
5051 static UINT
ACTION_PublishProduct(MSIPACKAGE
*package
)
5055 MSIRECORD
* row
= 0;
5056 static const WCHAR Query
[]=
5057 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
5060 /* for registry stuff */
5064 static const WCHAR szProductName
[] =
5065 {'P','r','o','d','u','c','t','N','a','m','e',0};
5066 static const WCHAR szPackageCode
[] =
5067 {'P','a','c','k','a','g','e','C','o','d','e',0};
5070 MSIHANDLE hDb
, hSumInfo
;
5073 return ERROR_INVALID_HANDLE
;
5075 rc
= MSI_DatabaseOpenViewW(package
->db
, Query
, &view
);
5076 if (rc
!= ERROR_SUCCESS
)
5079 rc
= MSI_ViewExecute(view
, 0);
5080 if (rc
!= ERROR_SUCCESS
)
5082 MSI_ViewClose(view
);
5083 msiobj_release(&view
->hdr
);
5090 WCHAR
*FilePath
=NULL
;
5091 WCHAR
*FileName
=NULL
;
5094 rc
= MSI_ViewFetch(view
,&row
);
5095 if (rc
!= ERROR_SUCCESS
)
5101 FileName
= load_dynamic_stringW(row
,1);
5104 ERR("Unable to get FileName\n");
5105 msiobj_release(&row
->hdr
);
5109 build_icon_path(package
,FileName
,&FilePath
);
5111 HeapFree(GetProcessHeap(),0,FileName
);
5113 TRACE("Creating icon file at %s\n",debugstr_w(FilePath
));
5115 the_file
= CreateFileW(FilePath
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
5116 FILE_ATTRIBUTE_NORMAL
, NULL
);
5118 if (the_file
== INVALID_HANDLE_VALUE
)
5120 ERR("Unable to create file %s\n",debugstr_w(FilePath
));
5121 msiobj_release(&row
->hdr
);
5122 HeapFree(GetProcessHeap(),0,FilePath
);
5130 rc
= MSI_RecordReadStream(row
,2,buffer
,&sz
);
5131 if (rc
!= ERROR_SUCCESS
)
5133 ERR("Failed to get stream\n");
5134 CloseHandle(the_file
);
5135 DeleteFileW(FilePath
);
5138 WriteFile(the_file
,buffer
,sz
,&write
,NULL
);
5139 } while (sz
== 1024);
5141 HeapFree(GetProcessHeap(),0,FilePath
);
5143 CloseHandle(the_file
);
5144 msiobj_release(&row
->hdr
);
5146 MSI_ViewClose(view
);
5147 msiobj_release(&view
->hdr
);
5150 /* ok there is a lot more done here but i need to figure out what */
5151 productcode
= load_dynamic_property(package
,szProductCode
,&rc
);
5155 rc
= MSIREG_OpenProductsKey(productcode
,&hkey
,TRUE
);
5156 if (rc
!= ERROR_SUCCESS
)
5159 rc
= MSIREG_OpenUserProductsKey(productcode
,&hukey
,TRUE
);
5160 if (rc
!= ERROR_SUCCESS
)
5164 buffer
= load_dynamic_property(package
,szProductName
,NULL
);
5165 size
= strlenW(buffer
)*sizeof(WCHAR
);
5166 RegSetValueExW(hukey
,szProductName
,0,REG_SZ
, (LPSTR
)buffer
,size
);
5167 HeapFree(GetProcessHeap(),0,buffer
);
5168 FIXME("Need to write more keys to the user registry\n");
5170 hDb
= alloc_msihandle( &package
->db
->hdr
);
5171 rc
= MsiGetSummaryInformationW(hDb
, NULL
, 0, &hSumInfo
);
5172 MsiCloseHandle(hDb
);
5173 if (rc
== ERROR_SUCCESS
)
5175 WCHAR guidbuffer
[0x200];
5177 rc
= MsiSummaryInfoGetPropertyW(hSumInfo
, 9, NULL
, NULL
, NULL
,
5179 if (rc
== ERROR_SUCCESS
)
5181 WCHAR squashed
[GUID_SIZE
];
5182 /* for now we only care about the first guid */
5183 LPWSTR ptr
= strchrW(guidbuffer
,';');
5185 squash_guid(guidbuffer
,squashed
);
5186 size
= strlenW(squashed
)*sizeof(WCHAR
);
5187 RegSetValueExW(hukey
,szPackageCode
,0,REG_SZ
, (LPSTR
)squashed
,
5192 ERR("Unable to query Revision_Number... \n");
5195 MsiCloseHandle(hSumInfo
);
5199 ERR("Unable to open Summary Information\n");
5205 HeapFree(GetProcessHeap(),0,productcode
);
5212 static UINT
ACTION_WriteIniValues(MSIPACKAGE
*package
)
5216 MSIRECORD
* row
= 0;
5217 static const WCHAR ExecSeqQuery
[] =
5218 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
5219 'I','n','i','F','i','l','e',0};
5220 static const WCHAR szWindowsFolder
[] =
5221 {'W','i','n','d','o','w','s','F','o','l','d','e','r',0};
5223 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
5224 if (rc
!= ERROR_SUCCESS
)
5226 TRACE("no IniFile table\n");
5227 return ERROR_SUCCESS
;
5230 rc
= MSI_ViewExecute(view
, 0);
5231 if (rc
!= ERROR_SUCCESS
)
5233 MSI_ViewClose(view
);
5234 msiobj_release(&view
->hdr
);
5240 LPWSTR component
,filename
,dirproperty
,section
,key
,value
,identifier
;
5241 LPWSTR deformated_section
, deformated_key
, deformated_value
;
5242 LPWSTR folder
, fullname
= NULL
;
5244 INT component_index
,action
;
5246 rc
= MSI_ViewFetch(view
,&row
);
5247 if (rc
!= ERROR_SUCCESS
)
5253 component
= load_dynamic_stringW(row
, 8);
5254 component_index
= get_loaded_component(package
,component
);
5255 HeapFree(GetProcessHeap(),0,component
);
5257 if (!ACTION_VerifyComponentForAction(package
, component_index
,
5258 INSTALLSTATE_LOCAL
))
5260 TRACE("Skipping ini file due to disabled component\n");
5261 msiobj_release(&row
->hdr
);
5263 package
->components
[component_index
].Action
=
5264 package
->components
[component_index
].Installed
;
5269 package
->components
[component_index
].Action
= INSTALLSTATE_LOCAL
;
5271 identifier
= load_dynamic_stringW(row
,1);
5272 filename
= load_dynamic_stringW(row
,2);
5273 dirproperty
= load_dynamic_stringW(row
,3);
5274 section
= load_dynamic_stringW(row
,4);
5275 key
= load_dynamic_stringW(row
,5);
5276 value
= load_dynamic_stringW(row
,6);
5277 action
= MSI_RecordGetInteger(row
,7);
5279 deformat_string(package
,section
,&deformated_section
);
5280 deformat_string(package
,key
,&deformated_key
);
5281 deformat_string(package
,value
,&deformated_value
);
5285 folder
= resolve_folder(package
, dirproperty
, FALSE
, FALSE
, NULL
);
5287 folder
= load_dynamic_property(package
,dirproperty
,NULL
);
5290 folder
= load_dynamic_property(package
, szWindowsFolder
, NULL
);
5294 ERR("Unable to resolve folder! (%s)\n",debugstr_w(dirproperty
));
5298 fullname
= build_directory_name(3, folder
, filename
, NULL
);
5302 TRACE("Adding value %s to section %s in %s\n",
5303 debugstr_w(deformated_key
), debugstr_w(deformated_section
),
5304 debugstr_w(fullname
));
5305 WritePrivateProfileStringW(deformated_section
, deformated_key
,
5306 deformated_value
, fullname
);
5308 else if (action
== 1)
5311 GetPrivateProfileStringW(deformated_section
, deformated_key
, NULL
,
5312 returned
, 10, fullname
);
5313 if (returned
[0] == 0)
5315 TRACE("Adding value %s to section %s in %s\n",
5316 debugstr_w(deformated_key
), debugstr_w(deformated_section
),
5317 debugstr_w(fullname
));
5319 WritePrivateProfileStringW(deformated_section
, deformated_key
,
5320 deformated_value
, fullname
);
5323 else if (action
== 3)
5325 FIXME("Append to existing section not yet implemented\n");
5328 uirow
= MSI_CreateRecord(4);
5329 MSI_RecordSetStringW(uirow
,1,identifier
);
5330 MSI_RecordSetStringW(uirow
,2,deformated_section
);
5331 MSI_RecordSetStringW(uirow
,3,deformated_key
);
5332 MSI_RecordSetStringW(uirow
,4,deformated_value
);
5333 ui_actiondata(package
,szWriteIniValues
,uirow
);
5334 msiobj_release( &uirow
->hdr
);
5336 HeapFree(GetProcessHeap(),0,identifier
);
5337 HeapFree(GetProcessHeap(),0,fullname
);
5338 HeapFree(GetProcessHeap(),0,filename
);
5339 HeapFree(GetProcessHeap(),0,key
);
5340 HeapFree(GetProcessHeap(),0,value
);
5341 HeapFree(GetProcessHeap(),0,section
);
5342 HeapFree(GetProcessHeap(),0,dirproperty
);
5343 HeapFree(GetProcessHeap(),0,folder
);
5344 HeapFree(GetProcessHeap(),0,deformated_key
);
5345 HeapFree(GetProcessHeap(),0,deformated_value
);
5346 HeapFree(GetProcessHeap(),0,deformated_section
);
5347 msiobj_release(&row
->hdr
);
5349 MSI_ViewClose(view
);
5350 msiobj_release(&view
->hdr
);
5354 static UINT
ACTION_SelfRegModules(MSIPACKAGE
*package
)
5358 MSIRECORD
* row
= 0;
5359 static const WCHAR ExecSeqQuery
[] =
5360 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
5361 'S','e','l','f','R','e','g',0};
5363 static const WCHAR ExeStr
[] =
5364 {'r','e','g','s','v','r','3','2','.','e','x','e',' ','/','s',' ',0};
5366 PROCESS_INFORMATION info
;
5369 memset(&si
,0,sizeof(STARTUPINFOW
));
5371 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
5372 if (rc
!= ERROR_SUCCESS
)
5374 TRACE("no SelfReg table\n");
5375 return ERROR_SUCCESS
;
5378 rc
= MSI_ViewExecute(view
, 0);
5379 if (rc
!= ERROR_SUCCESS
)
5381 MSI_ViewClose(view
);
5382 msiobj_release(&view
->hdr
);
5392 rc
= MSI_ViewFetch(view
,&row
);
5393 if (rc
!= ERROR_SUCCESS
)
5399 filename
= load_dynamic_stringW(row
,1);
5400 index
= get_loaded_file(package
,filename
);
5404 ERR("Unable to find file id %s\n",debugstr_w(filename
));
5405 HeapFree(GetProcessHeap(),0,filename
);
5406 msiobj_release(&row
->hdr
);
5409 HeapFree(GetProcessHeap(),0,filename
);
5411 len
= strlenW(ExeStr
);
5412 len
+= strlenW(package
->files
[index
].TargetPath
);
5415 filename
= HeapAlloc(GetProcessHeap(),0,len
*sizeof(WCHAR
));
5416 strcpyW(filename
,ExeStr
);
5417 strcatW(filename
,package
->files
[index
].TargetPath
);
5419 TRACE("Registering %s\n",debugstr_w(filename
));
5420 brc
= CreateProcessW(NULL
, filename
, NULL
, NULL
, FALSE
, 0, NULL
,
5421 c_colon
, &si
, &info
);
5424 msi_dialog_check_messages(package
->dialog
, info
.hProcess
);
5426 HeapFree(GetProcessHeap(),0,filename
);
5427 msiobj_release(&row
->hdr
);
5429 MSI_ViewClose(view
);
5430 msiobj_release(&view
->hdr
);
5434 static UINT
ACTION_PublishFeatures(MSIPACKAGE
*package
)
5443 return ERROR_INVALID_HANDLE
;
5445 productcode
= load_dynamic_property(package
,szProductCode
,&rc
);
5449 rc
= MSIREG_OpenFeaturesKey(productcode
,&hkey
,TRUE
);
5450 if (rc
!= ERROR_SUCCESS
)
5453 rc
= MSIREG_OpenUserFeaturesKey(productcode
,&hukey
,TRUE
);
5454 if (rc
!= ERROR_SUCCESS
)
5457 /* here the guids are base 85 encoded */
5458 for (i
= 0; i
< package
->loaded_features
; i
++)
5465 if (!ACTION_VerifyFeatureForAction(package
,i
,INSTALLSTATE_LOCAL
))
5468 size
= package
->features
[i
].ComponentCount
*21;
5470 if (package
->features
[i
].Feature_Parent
[0])
5471 size
+= strlenW(package
->features
[i
].Feature_Parent
)+2;
5473 data
= HeapAlloc(GetProcessHeap(), 0, size
* sizeof(WCHAR
));
5476 for (j
= 0; j
< package
->features
[i
].ComponentCount
; j
++)
5479 memset(buf
,0,sizeof(buf
));
5480 TRACE("From %s\n",debugstr_w(package
->components
5481 [package
->features
[i
].Components
[j
]].ComponentId
));
5482 CLSIDFromString(package
->components
5483 [package
->features
[i
].Components
[j
]].ComponentId
,
5485 encode_base85_guid(&clsid
,buf
);
5486 TRACE("to %s\n",debugstr_w(buf
));
5489 if (package
->features
[i
].Feature_Parent
[0])
5491 static const WCHAR sep
[] = {'\2',0};
5493 strcatW(data
,package
->features
[i
].Feature_Parent
);
5496 size
= (strlenW(data
)+1)*sizeof(WCHAR
);
5497 RegSetValueExW(hkey
,package
->features
[i
].Feature
,0,REG_SZ
,
5499 HeapFree(GetProcessHeap(),0,data
);
5501 size
= strlenW(package
->features
[i
].Feature_Parent
)*sizeof(WCHAR
);
5502 RegSetValueExW(hukey
,package
->features
[i
].Feature
,0,REG_SZ
,
5503 (LPSTR
)package
->features
[i
].Feature_Parent
,size
);
5509 HeapFree(GetProcessHeap(), 0, productcode
);
5513 static UINT
ACTION_RegisterProduct(MSIPACKAGE
*package
)
5520 static WCHAR szNONE
[] = {0};
5521 static const WCHAR szWindowsInstaler
[] =
5522 {'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
5523 static const WCHAR szPropKeys
[][80] =
5525 {'A','R','P','A','U','T','H','O','R','I','Z','E','D','C','D','F','P','R','E','F','I','X',0},
5526 {'A','R','P','C','O','N','T','A','C','T',0},
5527 {'A','R','P','C','O','M','M','E','N','T','S',0},
5528 {'P','r','o','d','u','c','t','N','a','m','e',0},
5529 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0},
5530 {'A','R','P','H','E','L','P','L','I','N','K',0},
5531 {'A','R','P','H','E','L','P','T','E','L','E','P','H','O','N','E',0},
5532 {'A','R','P','I','N','S','T','A','L','L','L','O','C','A','T','I','O','N',0},
5533 {'S','o','u','r','c','e','D','i','r',0},
5534 {'M','a','n','u','f','a','c','t','u','r','e','r',0},
5535 {'A','R','P','R','E','A','D','M','E',0},
5536 {'A','R','P','S','I','Z','E',0},
5537 {'A','R','P','U','R','L','I','N','F','O','A','B','O','U','T',0},
5538 {'A','R','P','U','R','L','U','P','D','A','T','E','I','N','F','O',0},
5542 static const WCHAR szRegKeys
[][80] =
5544 {'A','u','t','h','o','r','i','z','e','d','C','D','F','P','r','e','f','i','x',0},
5545 {'C','o','n','t','a','c','t',0},
5546 {'C','o','m','m','e','n','t','s',0},
5547 {'D','i','s','p','l','a','y','N','a','m','e',0},
5548 {'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0},
5549 {'H','e','l','p','L','i','n','k',0},
5550 {'H','e','l','p','T','e','l','e','p','h','o','n','e',0},
5551 {'I','n','s','t','a','l','l','L','o','c','a','t','i','o','n',0},
5552 {'I','n','s','t','a','l','l','S','o','u','r','c','e',0},
5553 {'P','u','b','l','i','s','h','e','r',0},
5554 {'R','e','a','d','m','e',0},
5555 {'S','i','z','e',0},
5556 {'U','R','L','I','n','f','o','A','b','o','u','t',0},
5557 {'U','R','L','U','p','d','a','t','e','I','n','f','o',0},
5561 static const WCHAR installerPathFmt
[] = {
5563 'I','n','s','t','a','l','l','e','r','\\',0};
5564 static const WCHAR fmt
[] = {
5566 'I','n','s','t','a','l','l','e','r','\\',
5567 '%','x','.','m','s','i',0};
5568 static const WCHAR szLocalPackage
[]=
5569 {'L','o','c','a','l','P','a','c','k','a','g','e',0};
5570 WCHAR windir
[MAX_PATH
], path
[MAX_PATH
], packagefile
[MAX_PATH
];
5574 return ERROR_INVALID_HANDLE
;
5576 productcode
= load_dynamic_property(package
,szProductCode
,&rc
);
5580 rc
= MSIREG_OpenUninstallKey(productcode
,&hkey
,TRUE
);
5581 if (rc
!= ERROR_SUCCESS
)
5584 /* dump all the info i can grab */
5585 FIXME("Flesh out more information \n");
5588 while (szPropKeys
[i
][0]!=0)
5590 buffer
= load_dynamic_property(package
,szPropKeys
[i
],&rc
);
5591 if (rc
!= ERROR_SUCCESS
)
5593 size
= strlenW(buffer
)*sizeof(WCHAR
);
5594 RegSetValueExW(hkey
,szRegKeys
[i
],0,REG_SZ
,(LPSTR
)buffer
,size
);
5600 RegSetValueExW(hkey
,szWindowsInstaler
,0,REG_DWORD
,(LPSTR
)&rc
,size
);
5602 /* copy the package locally */
5603 num
= GetTickCount() & 0xffff;
5607 GetWindowsDirectoryW(windir
, sizeof(windir
) / sizeof(windir
[0]));
5608 snprintfW(packagefile
,sizeof(packagefile
)/sizeof(packagefile
[0]),fmt
,
5612 HANDLE handle
= CreateFileW(packagefile
,GENERIC_WRITE
, 0, NULL
,
5613 CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, 0 );
5614 if (handle
!= INVALID_HANDLE_VALUE
)
5616 CloseHandle(handle
);
5619 if (GetLastError() != ERROR_FILE_EXISTS
&&
5620 GetLastError() != ERROR_SHARING_VIOLATION
)
5622 if (!(++num
& 0xffff)) num
= 1;
5623 sprintfW(packagefile
,fmt
,num
);
5624 } while (num
!= start
);
5626 snprintfW(path
,sizeof(path
)/sizeof(path
[0]),installerPathFmt
,windir
);
5627 create_full_pathW(path
);
5628 TRACE("Copying to local package %s\n",debugstr_w(packagefile
));
5629 CopyFileW(package
->PackagePath
,packagefile
,FALSE
);
5630 size
= strlenW(packagefile
)*sizeof(WCHAR
);
5631 RegSetValueExW(hkey
,szLocalPackage
,0,REG_SZ
,(LPSTR
)packagefile
,size
);
5634 HeapFree(GetProcessHeap(),0,productcode
);
5637 return ERROR_SUCCESS
;
5640 static UINT
ACTION_InstallExecute(MSIPACKAGE
*package
)
5644 return ERROR_INVALID_HANDLE
;
5646 for (i
= 0; i
< package
->DeferredActionCount
; i
++)
5649 action
= package
->DeferredAction
[i
];
5650 ui_actionstart(package
, action
);
5651 TRACE("Executing Action (%s)\n",debugstr_w(action
));
5652 ACTION_CustomAction(package
,action
,TRUE
);
5653 HeapFree(GetProcessHeap(),0,package
->DeferredAction
[i
]);
5655 HeapFree(GetProcessHeap(),0,package
->DeferredAction
);
5657 package
->DeferredActionCount
= 0;
5658 package
->DeferredAction
= NULL
;
5660 return ERROR_SUCCESS
;
5663 static UINT
ACTION_InstallFinalize(MSIPACKAGE
*package
)
5667 return ERROR_INVALID_HANDLE
;
5669 /* first do the same as an InstallExecute */
5670 ACTION_InstallExecute(package
);
5672 /* then handle Commit Actions */
5673 for (i
= 0; i
< package
->CommitActionCount
; i
++)
5676 action
= package
->CommitAction
[i
];
5677 ui_actionstart(package
, action
);
5678 TRACE("Executing Commit Action (%s)\n",debugstr_w(action
));
5679 ACTION_CustomAction(package
,action
,TRUE
);
5680 HeapFree(GetProcessHeap(),0,package
->CommitAction
[i
]);
5682 HeapFree(GetProcessHeap(),0,package
->CommitAction
);
5684 package
->CommitActionCount
= 0;
5685 package
->CommitAction
= NULL
;
5687 return ERROR_SUCCESS
;
5690 static UINT
ACTION_ForceReboot(MSIPACKAGE
*package
)
5692 static const WCHAR RunOnce
[] = {
5693 'S','o','f','t','w','a','r','e','\\',
5694 'M','i','c','r','o','s','o','f','t','\\',
5695 'W','i','n','d','o','w','s','\\',
5696 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
5697 'R','u','n','O','n','c','e',0};
5698 static const WCHAR InstallRunOnce
[] = {
5699 'S','o','f','t','w','a','r','e','\\',
5700 'M','i','c','r','o','s','o','f','t','\\',
5701 'W','i','n','d','o','w','s','\\',
5702 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
5703 'I','n','s','t','a','l','l','e','r','\\',
5704 'R','u','n','O','n','c','e','E','n','t','r','i','e','s',0};
5706 static const WCHAR msiexec_fmt
[] = {
5708 '\\','M','s','i','E','x','e','c','.','e','x','e',' ','/','@',' ',
5709 '\"','%','s','\"',0};
5710 static const WCHAR install_fmt
[] = {
5711 '/','I',' ','\"','%','s','\"',' ',
5712 'A','F','T','E','R','R','E','B','O','O','T','=','1',' ',
5713 'R','U','N','O','N','C','E','E','N','T','R','Y','=','\"','%','s','\"',0};
5714 WCHAR buffer
[256], sysdir
[MAX_PATH
];
5717 WCHAR squished_pc
[100];
5720 static const WCHAR szLUS
[] = {
5721 'L','a','s','t','U','s','e','d','S','o','u','r','c','e',0};
5722 static const WCHAR szSourceList
[] = {
5723 'S','o','u','r','c','e','L','i','s','t',0};
5724 static const WCHAR szPackageName
[] = {
5725 'P','a','c','k','a','g','e','N','a','m','e',0};
5728 return ERROR_INVALID_HANDLE
;
5730 productcode
= load_dynamic_property(package
,szProductCode
,&rc
);
5734 squash_guid(productcode
,squished_pc
);
5736 GetSystemDirectoryW(sysdir
, sizeof(sysdir
)/sizeof(sysdir
[0]));
5737 RegCreateKeyW(HKEY_LOCAL_MACHINE
,RunOnce
,&hkey
);
5738 snprintfW(buffer
,sizeof(buffer
)/sizeof(buffer
[0]),msiexec_fmt
,sysdir
,
5741 size
= strlenW(buffer
)*sizeof(WCHAR
);
5742 RegSetValueExW(hkey
,squished_pc
,0,REG_SZ
,(LPSTR
)buffer
,size
);
5745 TRACE("Reboot command %s\n",debugstr_w(buffer
));
5747 RegCreateKeyW(HKEY_LOCAL_MACHINE
,InstallRunOnce
,&hkey
);
5748 sprintfW(buffer
,install_fmt
,productcode
,squished_pc
);
5750 size
= strlenW(buffer
)*sizeof(WCHAR
);
5751 RegSetValueExW(hkey
,squished_pc
,0,REG_SZ
,(LPSTR
)buffer
,size
);
5754 rc
= MSIREG_OpenUserProductsKey(productcode
,&hukey
,TRUE
);
5755 if (rc
== ERROR_SUCCESS
)
5759 RegCreateKeyW(hukey
, szSourceList
, &hukey2
);
5760 buf
= load_dynamic_property(package
,cszSourceDir
,NULL
);
5761 size
= strlenW(buf
)*sizeof(WCHAR
);
5762 RegSetValueExW(hukey2
,szLUS
,0,REG_SZ
,(LPSTR
)buf
,size
);
5763 HeapFree(GetProcessHeap(),0,buf
);
5765 buf
= strrchrW(package
->PackagePath
,'\\');
5769 size
= strlenW(buf
)*sizeof(WCHAR
);
5770 RegSetValueExW(hukey2
,szPackageName
,0,REG_SZ
,(LPSTR
)buf
,size
);
5773 RegCloseKey(hukey2
);
5775 HeapFree(GetProcessHeap(),0,productcode
);
5777 return ERROR_INSTALL_SUSPEND
;
5780 UINT
ACTION_ResolveSource(MSIPACKAGE
* package
)
5783 * we are currently doing what should be done here in the top level Install
5784 * however for Adminastrative and uninstalls this step will be needed
5786 return ERROR_SUCCESS
;
5790 static UINT
ACTION_RegisterExtensionInfo(MSIPACKAGE
*package
)
5794 MSIRECORD
* row
= 0;
5795 static const WCHAR ExecSeqQuery
[] =
5796 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
5797 'E','x','t','e','n','s','i','o','n',0};
5798 static const WCHAR szContentType
[] =
5799 {'C','o','n','t','e','n','t',' ','T','y','p','e',0 };
5803 return ERROR_INVALID_HANDLE
;
5805 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
5806 if (rc
!= ERROR_SUCCESS
)
5812 rc
= MSI_ViewExecute(view
, 0);
5813 if (rc
!= ERROR_SUCCESS
)
5815 MSI_ViewClose(view
);
5816 msiobj_release(&view
->hdr
);
5822 WCHAR buffer
[0x100];
5823 WCHAR extension
[257];
5828 rc
= MSI_ViewFetch(view
,&row
);
5829 if (rc
!= ERROR_SUCCESS
)
5836 MSI_RecordGetStringW(row
,2,buffer
,&sz
);
5838 index
= get_loaded_component(package
,buffer
);
5842 msiobj_release(&row
->hdr
);
5846 if (!ACTION_VerifyComponentForAction(package
, index
,
5847 INSTALLSTATE_LOCAL
))
5849 TRACE("Skipping extension reg due to disabled component\n");
5850 msiobj_release(&row
->hdr
);
5852 package
->components
[index
].Action
=
5853 package
->components
[index
].Installed
;
5858 package
->components
[index
].Action
= INSTALLSTATE_LOCAL
;
5860 exten
= load_dynamic_stringW(row
,1);
5863 strcatW(extension
,exten
);
5864 HeapFree(GetProcessHeap(),0,exten
);
5866 RegCreateKeyW(HKEY_CLASSES_ROOT
,extension
,&hkey
);
5868 if (!MSI_RecordIsNull(row
,4))
5870 LPWSTR mime
= load_dynamic_stringW(row
,4);
5871 RegSetValueExW(hkey
,szContentType
,0,REG_SZ
,(LPVOID
)mime
,
5872 (strlenW(mime
)+1)*sizeof(WCHAR
));
5873 HeapFree(GetProcessHeap(),0,mime
);
5876 if (!MSI_RecordIsNull(row
,3))
5878 static const WCHAR szSN
[] =
5879 {'\\','S','h','e','l','l','N','e','w',0};
5882 LPWSTR progid
= load_dynamic_stringW(row
,3);
5884 RegSetValueExW(hkey
,NULL
,0,REG_SZ
,(LPVOID
)progid
,
5885 (strlenW(progid
)+1)*sizeof(WCHAR
));
5887 newkey
= HeapAlloc(GetProcessHeap(),0,
5888 (strlenW(progid
)+strlenW(szSN
)+1) * sizeof(WCHAR
));
5890 strcpyW(newkey
,progid
);
5891 strcatW(newkey
,szSN
);
5892 RegCreateKeyW(hkey
,newkey
,&hkey2
);
5895 HeapFree(GetProcessHeap(),0,progid
);
5896 HeapFree(GetProcessHeap(),0,newkey
);
5902 ui_actiondata(package
,szRegisterExtensionInfo
,row
);
5904 msiobj_release(&row
->hdr
);
5906 MSI_ViewClose(view
);
5907 msiobj_release(&view
->hdr
);
5913 static UINT
ACTION_RegisterMIMEInfo(MSIPACKAGE
*package
)
5917 MSIRECORD
* row
= 0;
5918 static const WCHAR ExecSeqQuery
[] =
5919 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
5921 static const WCHAR szExten
[] =
5922 {'E','x','t','e','n','s','i','o','n',0 };
5926 return ERROR_INVALID_HANDLE
;
5928 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
5929 if (rc
!= ERROR_SUCCESS
)
5935 rc
= MSI_ViewExecute(view
, 0);
5936 if (rc
!= ERROR_SUCCESS
)
5938 MSI_ViewClose(view
);
5939 msiobj_release(&view
->hdr
);
5945 WCHAR extension
[257];
5948 static const WCHAR fmt
[] =
5949 {'M','I','M','E','\\','D','a','t','a','b','a','s','e','\\',
5950 'C','o','n','t','e','n','t',' ','T','y','p','e','\\', '%','s',0};
5953 rc
= MSI_ViewFetch(view
,&row
);
5954 if (rc
!= ERROR_SUCCESS
)
5960 mime
= load_dynamic_stringW(row
,1);
5961 exten
= load_dynamic_stringW(row
,2);
5964 strcatW(extension
,exten
);
5965 HeapFree(GetProcessHeap(),0,exten
);
5967 key
= HeapAlloc(GetProcessHeap(),0,(strlenW(mime
)+strlenW(fmt
)+1) *
5969 sprintfW(key
,fmt
,mime
);
5970 RegCreateKeyW(HKEY_CLASSES_ROOT
,key
,&hkey
);
5971 RegSetValueExW(hkey
,szExten
,0,REG_SZ
,(LPVOID
)extension
,
5972 (strlenW(extension
)+1)*sizeof(WCHAR
));
5974 HeapFree(GetProcessHeap(),0,mime
);
5975 HeapFree(GetProcessHeap(),0,key
);
5977 if (!MSI_RecordIsNull(row
,3))
5979 FIXME("Handle non null for field 3\n");
5984 ui_actiondata(package
,szRegisterMIMEInfo
,row
);
5986 msiobj_release(&row
->hdr
);
5988 MSI_ViewClose(view
);
5989 msiobj_release(&view
->hdr
);
5995 static UINT
ACTION_RegisterUser(MSIPACKAGE
*package
)
5997 static const WCHAR szProductID
[]=
5998 {'P','r','o','d','u','c','t','I','D',0};
6006 static const WCHAR szPropKeys
[][80] =
6008 {'P','r','o','d','u','c','t','I','D',0},
6009 {'U','S','E','R','N','A','M','E',0},
6010 {'C','O','M','P','A','N','Y','N','A','M','E',0},
6014 static const WCHAR szRegKeys
[][80] =
6016 {'P','r','o','d','u','c','t','I','D',0},
6017 {'R','e','g','O','w','n','e','r',0},
6018 {'R','e','g','C','o','m','p','a','n','y',0},
6023 return ERROR_INVALID_HANDLE
;
6025 productid
= load_dynamic_property(package
,szProductID
,&rc
);
6027 return ERROR_SUCCESS
;
6029 productcode
= load_dynamic_property(package
,szProductCode
,&rc
);
6033 rc
= MSIREG_OpenUninstallKey(productcode
,&hkey
,TRUE
);
6034 if (rc
!= ERROR_SUCCESS
)
6038 while (szPropKeys
[i
][0]!=0)
6040 buffer
= load_dynamic_property(package
,szPropKeys
[i
],&rc
);
6041 if (rc
== ERROR_SUCCESS
)
6043 size
= strlenW(buffer
)*sizeof(WCHAR
);
6044 RegSetValueExW(hkey
,szRegKeys
[i
],0,REG_SZ
,(LPSTR
)buffer
,size
);
6050 HeapFree(GetProcessHeap(),0,productcode
);
6051 HeapFree(GetProcessHeap(),0,productid
);
6054 return ERROR_SUCCESS
;
6058 static UINT
ACTION_ExecuteAction(MSIPACKAGE
*package
)
6061 rc
= ACTION_ProcessExecSequence(package
,TRUE
);
6067 * Code based off of code located here
6068 * http://www.codeproject.com/gdi/fontnamefromfile.asp
6070 * Using string index 4 (full font name) instead of 1 (family name)
6072 static LPWSTR
load_ttfname_from(LPCWSTR filename
)
6078 typedef struct _tagTT_OFFSET_TABLE
{
6079 USHORT uMajorVersion
;
6080 USHORT uMinorVersion
;
6081 USHORT uNumOfTables
;
6082 USHORT uSearchRange
;
6083 USHORT uEntrySelector
;
6087 typedef struct _tagTT_TABLE_DIRECTORY
{
6088 char szTag
[4]; /* table name */
6089 ULONG uCheckSum
; /* Check sum */
6090 ULONG uOffset
; /* Offset from beginning of file */
6091 ULONG uLength
; /* length of the table in bytes */
6092 }TT_TABLE_DIRECTORY
;
6094 typedef struct _tagTT_NAME_TABLE_HEADER
{
6095 USHORT uFSelector
; /* format selector. Always 0 */
6096 USHORT uNRCount
; /* Name Records count */
6097 USHORT uStorageOffset
; /* Offset for strings storage,
6098 * from start of the table */
6099 }TT_NAME_TABLE_HEADER
;
6101 typedef struct _tagTT_NAME_RECORD
{
6106 USHORT uStringLength
;
6107 USHORT uStringOffset
; /* from start of storage area */
6110 #define SWAPWORD(x) MAKEWORD(HIBYTE(x), LOBYTE(x))
6111 #define SWAPLONG(x) MAKELONG(SWAPWORD(HIWORD(x)), SWAPWORD(LOWORD(x)))
6113 handle
= CreateFileW(filename
,GENERIC_READ
, 0, NULL
, OPEN_EXISTING
,
6114 FILE_ATTRIBUTE_NORMAL
, 0 );
6115 if (handle
!= INVALID_HANDLE_VALUE
)
6117 TT_TABLE_DIRECTORY tblDir
;
6118 BOOL bFound
= FALSE
;
6119 TT_OFFSET_TABLE ttOffsetTable
;
6121 ReadFile(handle
,&ttOffsetTable
, sizeof(TT_OFFSET_TABLE
),NULL
,NULL
);
6122 ttOffsetTable
.uNumOfTables
= SWAPWORD(ttOffsetTable
.uNumOfTables
);
6123 ttOffsetTable
.uMajorVersion
= SWAPWORD(ttOffsetTable
.uMajorVersion
);
6124 ttOffsetTable
.uMinorVersion
= SWAPWORD(ttOffsetTable
.uMinorVersion
);
6126 if (ttOffsetTable
.uMajorVersion
!= 1 ||
6127 ttOffsetTable
.uMinorVersion
!= 0)
6130 for (i
=0; i
< ttOffsetTable
.uNumOfTables
; i
++)
6132 ReadFile(handle
,&tblDir
, sizeof(TT_TABLE_DIRECTORY
),NULL
,NULL
);
6133 if (strncmp(tblDir
.szTag
,"name",4)==0)
6136 tblDir
.uLength
= SWAPLONG(tblDir
.uLength
);
6137 tblDir
.uOffset
= SWAPLONG(tblDir
.uOffset
);
6144 TT_NAME_TABLE_HEADER ttNTHeader
;
6145 TT_NAME_RECORD ttRecord
;
6147 SetFilePointer(handle
, tblDir
.uOffset
, NULL
, FILE_BEGIN
);
6148 ReadFile(handle
,&ttNTHeader
, sizeof(TT_NAME_TABLE_HEADER
),
6151 ttNTHeader
.uNRCount
= SWAPWORD(ttNTHeader
.uNRCount
);
6152 ttNTHeader
.uStorageOffset
= SWAPWORD(ttNTHeader
.uStorageOffset
);
6154 for(i
=0; i
<ttNTHeader
.uNRCount
; i
++)
6156 ReadFile(handle
,&ttRecord
, sizeof(TT_NAME_RECORD
),NULL
,NULL
);
6157 ttRecord
.uNameID
= SWAPWORD(ttRecord
.uNameID
);
6158 /* 4 is the Full Font Name */
6159 if(ttRecord
.uNameID
== 4)
6163 static const LPSTR tt
= " (TrueType)";
6165 ttRecord
.uStringLength
= SWAPWORD(ttRecord
.uStringLength
);
6166 ttRecord
.uStringOffset
= SWAPWORD(ttRecord
.uStringOffset
);
6167 nPos
= SetFilePointer(handle
, 0, NULL
, FILE_CURRENT
);
6168 SetFilePointer(handle
, tblDir
.uOffset
+
6169 ttRecord
.uStringOffset
+
6170 ttNTHeader
.uStorageOffset
,
6172 buf
= HeapAlloc(GetProcessHeap(), 0,
6173 ttRecord
.uStringLength
+ 1 + strlen(tt
));
6174 memset(buf
, 0, ttRecord
.uStringLength
+ 1 + strlen(tt
));
6175 ReadFile(handle
, buf
, ttRecord
.uStringLength
, NULL
, NULL
);
6176 if (strlen(buf
) > 0)
6179 ret
= strdupAtoW(buf
);
6180 HeapFree(GetProcessHeap(),0,buf
);
6184 HeapFree(GetProcessHeap(),0,buf
);
6185 SetFilePointer(handle
,nPos
, NULL
, FILE_BEGIN
);
6189 CloseHandle(handle
);
6192 TRACE("Returning fontname %s\n",debugstr_w(ret
));
6196 static UINT
ACTION_RegisterFonts(MSIPACKAGE
*package
)
6200 MSIRECORD
* row
= 0;
6201 static const WCHAR ExecSeqQuery
[] =
6202 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
6204 static const WCHAR regfont1
[] =
6205 {'S','o','f','t','w','a','r','e','\\',
6206 'M','i','c','r','o','s','o','f','t','\\',
6207 'W','i','n','d','o','w','s',' ','N','T','\\',
6208 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
6209 'F','o','n','t','s',0};
6210 static const WCHAR regfont2
[] =
6211 {'S','o','f','t','w','a','r','e','\\',
6212 'M','i','c','r','o','s','o','f','t','\\',
6213 'W','i','n','d','o','w','s','\\',
6214 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
6215 'F','o','n','t','s',0};
6219 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
6220 if (rc
!= ERROR_SUCCESS
)
6223 rc
= MSI_ViewExecute(view
, 0);
6224 if (rc
!= ERROR_SUCCESS
)
6226 MSI_ViewClose(view
);
6227 msiobj_release(&view
->hdr
);
6231 RegCreateKeyW(HKEY_LOCAL_MACHINE
,regfont1
,&hkey1
);
6232 RegCreateKeyW(HKEY_LOCAL_MACHINE
,regfont2
,&hkey2
);
6241 rc
= MSI_ViewFetch(view
,&row
);
6242 if (rc
!= ERROR_SUCCESS
)
6248 file
= load_dynamic_stringW(row
,1);
6249 index
= get_loaded_file(package
,file
);
6252 ERR("Unable to load file\n");
6253 HeapFree(GetProcessHeap(),0,file
);
6257 /* check to make sure that component is installed */
6258 if (!ACTION_VerifyComponentForAction(package
,
6259 package
->files
[index
].ComponentIndex
, INSTALLSTATE_LOCAL
))
6261 TRACE("Skipping: Component not scheduled for install\n");
6262 HeapFree(GetProcessHeap(),0,file
);
6264 msiobj_release(&row
->hdr
);
6269 if (MSI_RecordIsNull(row
,2))
6270 name
= load_ttfname_from(package
->files
[index
].TargetPath
);
6272 name
= load_dynamic_stringW(row
,2);
6276 size
= strlenW(package
->files
[index
].FileName
) * sizeof(WCHAR
);
6277 RegSetValueExW(hkey1
,name
,0,REG_SZ
,
6278 (LPBYTE
)package
->files
[index
].FileName
,size
);
6279 RegSetValueExW(hkey2
,name
,0,REG_SZ
,
6280 (LPBYTE
)package
->files
[index
].FileName
,size
);
6283 HeapFree(GetProcessHeap(),0,file
);
6284 HeapFree(GetProcessHeap(),0,name
);
6285 msiobj_release(&row
->hdr
);
6287 MSI_ViewClose(view
);
6288 msiobj_release(&view
->hdr
);
6296 static UINT
ITERATE_PublishComponent(MSIRECORD
*rec
, LPVOID param
)
6298 MSIPACKAGE
*package
= (MSIPACKAGE
*)param
;
6299 LPWSTR productid
=NULL
, compgroupid
=NULL
;
6300 LPWSTR feature
=NULL
;
6302 LPWSTR qualifier
= NULL
;
6303 LPWSTR component
= NULL
;
6305 WCHAR productid_85
[21];
6306 WCHAR component_85
[21];
6308 UINT rc
= ERROR_SUCCESS
;
6311 * I have a fair bit of confusion as to when a < is used and when a > is
6312 * used. I do not think i have it right...
6314 static WCHAR fmt1
[] = {'%','s','%','s','<','%','s',0,0};
6315 static WCHAR fmt2
[] = {'%','s','%','s','>',0,0};
6316 LPWSTR output
= NULL
;
6319 memset(productid_85
,0,sizeof(productid_85
));
6320 memset(component_85
,0,sizeof(component_85
));
6321 compgroupid
= load_dynamic_stringW(rec
,1);
6323 rc
= MSIREG_OpenUserComponentsKey(compgroupid
, &hkey
, TRUE
);
6324 if (rc
!= ERROR_SUCCESS
)
6327 productid
= load_dynamic_property(package
,szProductCode
,NULL
);
6328 CLSIDFromString(productid
, &clsid
);
6330 encode_base85_guid(&clsid
,productid_85
);
6332 text
= load_dynamic_stringW(rec
,4);
6333 qualifier
= load_dynamic_stringW(rec
,2);
6335 feature
= load_dynamic_stringW(rec
,5);
6336 component
= load_dynamic_stringW(rec
,3);
6338 index
= get_loaded_component(package
, component
);
6339 CLSIDFromString(package
->components
[index
].ComponentId
, &clsid
);
6340 encode_base85_guid(&clsid
,component_85
);
6342 TRACE("Doing something with this... %s = %s %s %s %s\n",
6343 debugstr_w(qualifier
), debugstr_w(productid_85
),
6344 debugstr_w(feature
), debugstr_w(text
), debugstr_w(component_85
));
6346 sz
= lstrlenW(productid_85
) + lstrlenW(feature
);
6348 sz
+= lstrlenW(text
);
6349 if (component
&& index
>= 0)
6350 sz
+= lstrlenW(component_85
);
6353 sz
*= sizeof(WCHAR
);
6355 output
= HeapAlloc(GetProcessHeap(),0,sz
);
6356 memset(output
,0,sz
);
6358 if (ACTION_VerifyComponentForAction(package
, index
, INSTALLSTATE_LOCAL
))
6359 sprintfW(output
,fmt1
,productid_85
,feature
,component_85
);
6361 sprintfW(output
,fmt2
,productid_85
,feature
);
6364 strcatW(output
,text
);
6366 sz
= (lstrlenW(output
)+2) * sizeof(WCHAR
);
6367 RegSetValueExW(hkey
, qualifier
,0,REG_MULTI_SZ
, (LPBYTE
)output
, sz
);
6371 HeapFree(GetProcessHeap(),0,output
);
6372 HeapFree(GetProcessHeap(),0,compgroupid
);
6373 HeapFree(GetProcessHeap(),0,component
);
6374 HeapFree(GetProcessHeap(),0,productid
);
6375 HeapFree(GetProcessHeap(),0,feature
);
6376 HeapFree(GetProcessHeap(),0,text
);
6377 HeapFree(GetProcessHeap(),0,qualifier
);
6383 * At present I am ignorning the advertised components part of this and only
6384 * focusing on the qualified component sets
6386 static UINT
ACTION_PublishComponents(MSIPACKAGE
*package
)
6390 static const WCHAR ExecSeqQuery
[] =
6391 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
6392 'P','u','b','l','i','s','h','C','o','m','p','o','n','e','n','t',0};
6394 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
6395 if (rc
!= ERROR_SUCCESS
)
6396 return ERROR_SUCCESS
;
6398 rc
= MSI_IterateRecords(view
, NULL
, ITERATE_PublishComponent
, package
);
6399 msiobj_release(&view
->hdr
);
6404 /* Msi functions that seem appropriate here */
6406 /***********************************************************************
6407 * MsiDoActionA (MSI.@)
6409 UINT WINAPI
MsiDoActionA( MSIHANDLE hInstall
, LPCSTR szAction
)
6414 TRACE(" exteral attempt at action %s\n",szAction
);
6417 return ERROR_FUNCTION_FAILED
;
6419 return ERROR_FUNCTION_FAILED
;
6421 szwAction
= strdupAtoW(szAction
);
6424 return ERROR_FUNCTION_FAILED
;
6427 rc
= MsiDoActionW(hInstall
, szwAction
);
6428 HeapFree(GetProcessHeap(),0,szwAction
);
6432 /***********************************************************************
6433 * MsiDoActionW (MSI.@)
6435 UINT WINAPI
MsiDoActionW( MSIHANDLE hInstall
, LPCWSTR szAction
)
6437 MSIPACKAGE
*package
;
6438 UINT ret
= ERROR_INVALID_HANDLE
;
6440 TRACE(" external attempt at action %s \n",debugstr_w(szAction
));
6442 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
6445 ret
= ACTION_PerformUIAction(package
,szAction
);
6446 msiobj_release( &package
->hdr
);
6451 UINT WINAPI
MsiGetTargetPathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
6452 LPSTR szPathBuf
, DWORD
* pcchPathBuf
)
6458 TRACE("getting folder %s %p %li\n",szFolder
,szPathBuf
, *pcchPathBuf
);
6461 return ERROR_FUNCTION_FAILED
;
6463 return ERROR_FUNCTION_FAILED
;
6465 szwFolder
= strdupAtoW(szFolder
);
6468 return ERROR_FUNCTION_FAILED
;
6470 szwPathBuf
= HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf
* sizeof(WCHAR
));
6472 rc
= MsiGetTargetPathW(hInstall
, szwFolder
, szwPathBuf
,pcchPathBuf
);
6474 WideCharToMultiByte( CP_ACP
, 0, szwPathBuf
, *pcchPathBuf
, szPathBuf
,
6475 *pcchPathBuf
, NULL
, NULL
);
6477 HeapFree(GetProcessHeap(),0,szwFolder
);
6478 HeapFree(GetProcessHeap(),0,szwPathBuf
);
6483 UINT WINAPI
MsiGetTargetPathW( MSIHANDLE hInstall
, LPCWSTR szFolder
, LPWSTR
6484 szPathBuf
, DWORD
* pcchPathBuf
)
6487 UINT rc
= ERROR_FUNCTION_FAILED
;
6488 MSIPACKAGE
*package
;
6490 TRACE("(%s %p %li)\n",debugstr_w(szFolder
),szPathBuf
,*pcchPathBuf
);
6492 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
6494 return ERROR_INVALID_HANDLE
;
6495 path
= resolve_folder(package
, szFolder
, FALSE
, FALSE
, NULL
);
6496 msiobj_release( &package
->hdr
);
6498 if (path
&& (strlenW(path
) > *pcchPathBuf
))
6500 *pcchPathBuf
= strlenW(path
)+1;
6501 rc
= ERROR_MORE_DATA
;
6505 *pcchPathBuf
= strlenW(path
)+1;
6506 strcpyW(szPathBuf
,path
);
6507 TRACE("Returning Path %s\n",debugstr_w(path
));
6510 HeapFree(GetProcessHeap(),0,path
);
6516 UINT WINAPI
MsiGetSourcePathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
6517 LPSTR szPathBuf
, DWORD
* pcchPathBuf
)
6523 TRACE("getting source %s %p %li\n",szFolder
,szPathBuf
, *pcchPathBuf
);
6526 return ERROR_FUNCTION_FAILED
;
6528 return ERROR_FUNCTION_FAILED
;
6530 szwFolder
= strdupAtoW(szFolder
);
6532 return ERROR_FUNCTION_FAILED
;
6534 szwPathBuf
= HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf
* sizeof(WCHAR
));
6536 rc
= MsiGetSourcePathW(hInstall
, szwFolder
, szwPathBuf
,pcchPathBuf
);
6538 WideCharToMultiByte( CP_ACP
, 0, szwPathBuf
, *pcchPathBuf
, szPathBuf
,
6539 *pcchPathBuf
, NULL
, NULL
);
6541 HeapFree(GetProcessHeap(),0,szwFolder
);
6542 HeapFree(GetProcessHeap(),0,szwPathBuf
);
6547 UINT WINAPI
MsiGetSourcePathW( MSIHANDLE hInstall
, LPCWSTR szFolder
, LPWSTR
6548 szPathBuf
, DWORD
* pcchPathBuf
)
6551 UINT rc
= ERROR_FUNCTION_FAILED
;
6552 MSIPACKAGE
*package
;
6554 TRACE("(%s %p %li)\n",debugstr_w(szFolder
),szPathBuf
,*pcchPathBuf
);
6556 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
6558 return ERROR_INVALID_HANDLE
;
6559 path
= resolve_folder(package
, szFolder
, TRUE
, FALSE
, NULL
);
6560 msiobj_release( &package
->hdr
);
6562 if (path
&& strlenW(path
) > *pcchPathBuf
)
6564 *pcchPathBuf
= strlenW(path
)+1;
6565 rc
= ERROR_MORE_DATA
;
6569 *pcchPathBuf
= strlenW(path
)+1;
6570 strcpyW(szPathBuf
,path
);
6571 TRACE("Returning Path %s\n",debugstr_w(path
));
6574 HeapFree(GetProcessHeap(),0,path
);
6580 /***********************************************************************
6581 * MsiSetTargetPathA (MSI.@)
6583 UINT WINAPI
MsiSetTargetPathA(MSIHANDLE hInstall
, LPCSTR szFolder
,
6584 LPCSTR szFolderPath
)
6587 LPWSTR szwFolderPath
;
6591 return ERROR_FUNCTION_FAILED
;
6593 return ERROR_FUNCTION_FAILED
;
6595 szwFolder
= strdupAtoW(szFolder
);
6597 return ERROR_FUNCTION_FAILED
;
6599 szwFolderPath
= strdupAtoW(szFolderPath
);
6602 HeapFree(GetProcessHeap(),0,szwFolder
);
6603 return ERROR_FUNCTION_FAILED
;
6606 rc
= MsiSetTargetPathW(hInstall
, szwFolder
, szwFolderPath
);
6608 HeapFree(GetProcessHeap(),0,szwFolder
);
6609 HeapFree(GetProcessHeap(),0,szwFolderPath
);
6614 UINT
MSI_SetTargetPathW(MSIPACKAGE
*package
, LPCWSTR szFolder
,
6615 LPCWSTR szFolderPath
)
6619 LPWSTR path2
= NULL
;
6622 TRACE("(%p %s %s)\n",package
, debugstr_w(szFolder
),debugstr_w(szFolderPath
));
6625 return ERROR_INVALID_HANDLE
;
6627 if (szFolderPath
[0]==0)
6628 return ERROR_FUNCTION_FAILED
;
6630 if (GetFileAttributesW(szFolderPath
) == INVALID_FILE_ATTRIBUTES
)
6631 return ERROR_FUNCTION_FAILED
;
6633 path
= resolve_folder(package
,szFolder
,FALSE
,FALSE
,&folder
);
6636 return ERROR_INVALID_PARAMETER
;
6638 HeapFree(GetProcessHeap(),0,folder
->Property
);
6639 folder
->Property
= build_directory_name(2, szFolderPath
, NULL
);
6641 if (strcmpiW(path
, folder
->Property
) == 0)
6644 * Resolved Target has not really changed, so just
6645 * set this folder and do not recalculate everything.
6647 HeapFree(GetProcessHeap(),0,folder
->ResolvedTarget
);
6648 folder
->ResolvedTarget
= NULL
;
6649 path2
= resolve_folder(package
,szFolder
,FALSE
,TRUE
,NULL
);
6650 HeapFree(GetProcessHeap(),0,path2
);
6654 for (i
= 0; i
< package
->loaded_folders
; i
++)
6656 HeapFree(GetProcessHeap(),0,package
->folders
[i
].ResolvedTarget
);
6657 package
->folders
[i
].ResolvedTarget
=NULL
;
6660 for (i
= 0; i
< package
->loaded_folders
; i
++)
6662 path2
=resolve_folder(package
, package
->folders
[i
].Directory
, FALSE
,
6664 HeapFree(GetProcessHeap(),0,path2
);
6667 HeapFree(GetProcessHeap(),0,path
);
6669 return ERROR_SUCCESS
;
6672 /***********************************************************************
6673 * MsiSetTargetPathW (MSI.@)
6675 UINT WINAPI
MsiSetTargetPathW(MSIHANDLE hInstall
, LPCWSTR szFolder
,
6676 LPCWSTR szFolderPath
)
6678 MSIPACKAGE
*package
;
6681 TRACE("(%s %s)\n",debugstr_w(szFolder
),debugstr_w(szFolderPath
));
6683 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
6684 ret
= MSI_SetTargetPathW( package
, szFolder
, szFolderPath
);
6685 msiobj_release( &package
->hdr
);
6689 /***********************************************************************
6690 * MsiGetMode (MSI.@)
6692 * Returns an internal installer state (if it is running in a mode iRunMode)
6695 * hInstall [I] Handle to the installation
6696 * hRunMode [I] Checking run mode
6697 * MSIRUNMODE_ADMIN Administrative mode
6698 * MSIRUNMODE_ADVERTISE Advertisement mode
6699 * MSIRUNMODE_MAINTENANCE Maintenance mode
6700 * MSIRUNMODE_ROLLBACKENABLED Rollback is enabled
6701 * MSIRUNMODE_LOGENABLED Log file is writing
6702 * MSIRUNMODE_OPERATIONS Operations in progress??
6703 * MSIRUNMODE_REBOOTATEND We need to reboot after installation completed
6704 * MSIRUNMODE_REBOOTNOW We need to reboot to continue the installation
6705 * MSIRUNMODE_CABINET Files from cabinet are installed
6706 * MSIRUNMODE_SOURCESHORTNAMES Long names in source files is suppressed
6707 * MSIRUNMODE_TARGETSHORTNAMES Long names in destination files is suppressed
6708 * MSIRUNMODE_RESERVED11 Reserved
6709 * MSIRUNMODE_WINDOWS9X Running under Windows95/98
6710 * MSIRUNMODE_ZAWENABLED Demand installation is supported
6711 * MSIRUNMODE_RESERVED14 Reserved
6712 * MSIRUNMODE_RESERVED15 Reserved
6713 * MSIRUNMODE_SCHEDULED called from install script
6714 * MSIRUNMODE_ROLLBACK called from rollback script
6715 * MSIRUNMODE_COMMIT called from commit script
6718 * In the state: TRUE
6719 * Not in the state: FALSE
6723 BOOL WINAPI
MsiGetMode(MSIHANDLE hInstall
, MSIRUNMODE iRunMode
)
6725 FIXME("STUB (iRunMode=%i)\n",iRunMode
);
6729 /***********************************************************************
6730 * MsiSetFeatureStateA (MSI.@)
6732 * According to the docs, when this is called it immediately recalculates
6733 * all the component states as well
6735 UINT WINAPI
MsiSetFeatureStateA(MSIHANDLE hInstall
, LPCSTR szFeature
,
6736 INSTALLSTATE iState
)
6738 LPWSTR szwFeature
= NULL
;
6741 szwFeature
= strdupAtoW(szFeature
);
6744 return ERROR_FUNCTION_FAILED
;
6746 rc
= MsiSetFeatureStateW(hInstall
,szwFeature
, iState
);
6748 HeapFree(GetProcessHeap(),0,szwFeature
);
6753 /***********************************************************************
6754 * MsiSetFeatureStateW (MSI.@)
6756 UINT WINAPI
MsiSetFeatureStateW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
6757 INSTALLSTATE iState
)
6759 MSIPACKAGE
* package
;
6761 UINT rc
= ERROR_SUCCESS
;
6763 TRACE(" %s to %i\n",debugstr_w(szFeature
), iState
);
6765 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
6767 return ERROR_INVALID_HANDLE
;
6769 index
= get_loaded_feature(package
,szFeature
);
6772 rc
= ERROR_UNKNOWN_FEATURE
;
6776 package
->features
[index
].ActionRequest
= iState
;
6777 ACTION_UpdateComponentStates(package
,szFeature
);
6780 msiobj_release( &package
->hdr
);
6784 UINT WINAPI
MsiGetFeatureStateA(MSIHANDLE hInstall
, LPSTR szFeature
,
6785 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
6787 LPWSTR szwFeature
= NULL
;
6790 szwFeature
= strdupAtoW(szFeature
);
6792 rc
= MsiGetFeatureStateW(hInstall
,szwFeature
,piInstalled
, piAction
);
6794 HeapFree( GetProcessHeap(), 0 , szwFeature
);
6799 UINT
MSI_GetFeatureStateW(MSIPACKAGE
*package
, LPWSTR szFeature
,
6800 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
6804 index
= get_loaded_feature(package
,szFeature
);
6806 return ERROR_UNKNOWN_FEATURE
;
6809 *piInstalled
= package
->features
[index
].Installed
;
6812 *piAction
= package
->features
[index
].Action
;
6814 TRACE("returning %i %i\n",*piInstalled
,*piAction
);
6816 return ERROR_SUCCESS
;
6819 UINT WINAPI
MsiGetFeatureStateW(MSIHANDLE hInstall
, LPWSTR szFeature
,
6820 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
6822 MSIPACKAGE
* package
;
6825 TRACE("%ld %s %p %p\n", hInstall
, debugstr_w(szFeature
), piInstalled
,
6828 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
6830 return ERROR_INVALID_HANDLE
;
6831 ret
= MSI_GetFeatureStateW(package
, szFeature
, piInstalled
, piAction
);
6832 msiobj_release( &package
->hdr
);
6836 /***********************************************************************
6837 * MsiGetComponentStateA (MSI.@)
6839 UINT WINAPI
MsiGetComponentStateA(MSIHANDLE hInstall
, LPSTR szComponent
,
6840 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
6842 LPWSTR szwComponent
= NULL
;
6845 szwComponent
= strdupAtoW(szComponent
);
6847 rc
= MsiGetComponentStateW(hInstall
,szwComponent
,piInstalled
, piAction
);
6849 HeapFree( GetProcessHeap(), 0 , szwComponent
);
6854 UINT
MSI_GetComponentStateW(MSIPACKAGE
*package
, LPWSTR szComponent
,
6855 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
6859 TRACE("%p %s %p %p\n", package
, debugstr_w(szComponent
), piInstalled
,
6862 index
= get_loaded_component(package
,szComponent
);
6864 return ERROR_UNKNOWN_COMPONENT
;
6867 *piInstalled
= package
->components
[index
].Installed
;
6870 *piAction
= package
->components
[index
].Action
;
6872 TRACE("states (%i, %i)\n",
6873 (piInstalled
)?*piInstalled
:-1,(piAction
)?*piAction
:-1);
6875 return ERROR_SUCCESS
;
6878 /***********************************************************************
6879 * MsiGetComponentStateW (MSI.@)
6881 UINT WINAPI
MsiGetComponentStateW(MSIHANDLE hInstall
, LPWSTR szComponent
,
6882 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
6884 MSIPACKAGE
* package
;
6887 TRACE("%ld %s %p %p\n", hInstall
, debugstr_w(szComponent
),
6888 piInstalled
, piAction
);
6890 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
6892 return ERROR_INVALID_HANDLE
;
6893 ret
= MSI_GetComponentStateW( package
, szComponent
, piInstalled
, piAction
);
6894 msiobj_release( &package
->hdr
);
6899 static UINT
ACTION_Template(MSIPACKAGE
*package
)
6903 MSIRECORD
* row
= 0;
6904 static const WCHAR ExecSeqQuery
[] = {0};
6906 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
6907 if (rc
!= ERROR_SUCCESS
)
6910 rc
= MSI_ViewExecute(view
, 0);
6911 if (rc
!= ERROR_SUCCESS
)
6913 MSI_ViewClose(view
);
6914 msiobj_release(&view
->hdr
);
6920 rc
= MSI_ViewFetch(view
,&row
);
6921 if (rc
!= ERROR_SUCCESS
)
6927 msiobj_release(&row
->hdr
);
6929 MSI_ViewClose(view
);
6930 msiobj_release(&view
->hdr
);