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 inline static void reduce_to_shortfilename(WCHAR
* filename
)
386 LPWSTR p
= strchrW(filename
,'|');
391 WCHAR
*load_dynamic_stringW(MSIRECORD
*row
, INT index
)
398 if (MSI_RecordIsNull(row
,index
))
401 rc
= MSI_RecordGetStringW(row
,index
,NULL
,&sz
);
403 /* having an empty string is different than NULL */
406 ret
= HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
));
412 ret
= HeapAlloc(GetProcessHeap(),0,sz
* sizeof (WCHAR
));
413 rc
= MSI_RecordGetStringW(row
,index
,ret
,&sz
);
414 if (rc
!=ERROR_SUCCESS
)
416 ERR("Unable to load dynamic string\n");
417 HeapFree(GetProcessHeap(), 0, ret
);
423 LPWSTR
load_dynamic_property(MSIPACKAGE
*package
, LPCWSTR prop
, UINT
* rc
)
429 r
= MSI_GetPropertyW(package
, prop
, NULL
, &sz
);
430 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
437 str
= HeapAlloc(GetProcessHeap(),0,sz
*sizeof(WCHAR
));
438 r
= MSI_GetPropertyW(package
, prop
, str
, &sz
);
439 if (r
!= ERROR_SUCCESS
)
441 HeapFree(GetProcessHeap(),0,str
);
449 int get_loaded_component(MSIPACKAGE
* package
, LPCWSTR Component
)
454 for (i
= 0; i
< package
->loaded_components
; i
++)
456 if (strcmpW(Component
,package
->components
[i
].Component
)==0)
465 int get_loaded_feature(MSIPACKAGE
* package
, LPCWSTR Feature
)
470 for (i
= 0; i
< package
->loaded_features
; i
++)
472 if (strcmpW(Feature
,package
->features
[i
].Feature
)==0)
481 int get_loaded_file(MSIPACKAGE
* package
, LPCWSTR file
)
486 for (i
= 0; i
< package
->loaded_files
; i
++)
488 if (strcmpW(file
,package
->files
[i
].File
)==0)
497 int track_tempfile(MSIPACKAGE
*package
, LPCWSTR name
, LPCWSTR path
)
505 for (i
=0; i
< package
->loaded_files
; i
++)
506 if (strcmpW(package
->files
[i
].File
,name
)==0)
509 index
= package
->loaded_files
;
510 package
->loaded_files
++;
511 if (package
->loaded_files
== 1)
512 package
->files
= HeapAlloc(GetProcessHeap(),0,sizeof(MSIFILE
));
514 package
->files
= HeapReAlloc(GetProcessHeap(),0,
515 package
->files
, package
->loaded_files
* sizeof(MSIFILE
));
517 memset(&package
->files
[index
],0,sizeof(MSIFILE
));
519 package
->files
[index
].File
= strdupW(name
);
520 package
->files
[index
].TargetPath
= strdupW(path
);
521 package
->files
[index
].Temporary
= TRUE
;
523 TRACE("Tracking tempfile (%s)\n",debugstr_w(package
->files
[index
].File
));
528 static void remove_tracked_tempfiles(MSIPACKAGE
* package
)
535 for (i
= 0; i
< package
->loaded_files
; i
++)
537 if (package
->files
[i
].Temporary
)
539 TRACE("Cleaning up %s\n",debugstr_w(package
->files
[i
].TargetPath
));
540 DeleteFileW(package
->files
[i
].TargetPath
);
546 /* wrapper to resist a need for a full rewrite right now */
547 DWORD
deformat_string(MSIPACKAGE
*package
, LPCWSTR ptr
, WCHAR
** data
)
551 MSIRECORD
*rec
= MSI_CreateRecord(1);
554 MSI_RecordSetStringW(rec
,0,ptr
);
555 MSI_FormatRecordW(package
,rec
,NULL
,&size
);
559 *data
= HeapAlloc(GetProcessHeap(),0,size
*sizeof(WCHAR
));
561 MSI_FormatRecordW(package
,rec
,*data
,&size
);
564 msiobj_release( &rec
->hdr
);
565 return sizeof(WCHAR
)*size
;
567 msiobj_release( &rec
->hdr
);
574 /* Called when the package is being closed */
575 void ACTION_free_package_structures( MSIPACKAGE
* package
)
579 TRACE("Freeing package action data\n");
581 remove_tracked_tempfiles(package
);
583 /* No dynamic buffers in features */
584 if (package
->features
&& package
->loaded_features
> 0)
585 HeapFree(GetProcessHeap(),0,package
->features
);
587 for (i
= 0; i
< package
->loaded_folders
; i
++)
589 HeapFree(GetProcessHeap(),0,package
->folders
[i
].Directory
);
590 HeapFree(GetProcessHeap(),0,package
->folders
[i
].TargetDefault
);
591 HeapFree(GetProcessHeap(),0,package
->folders
[i
].SourceDefault
);
592 HeapFree(GetProcessHeap(),0,package
->folders
[i
].ResolvedTarget
);
593 HeapFree(GetProcessHeap(),0,package
->folders
[i
].ResolvedSource
);
594 HeapFree(GetProcessHeap(),0,package
->folders
[i
].Property
);
596 if (package
->folders
&& package
->loaded_folders
> 0)
597 HeapFree(GetProcessHeap(),0,package
->folders
);
599 for (i
= 0; i
< package
->loaded_components
; i
++)
600 HeapFree(GetProcessHeap(),0,package
->components
[i
].FullKeypath
);
602 if (package
->components
&& package
->loaded_components
> 0)
603 HeapFree(GetProcessHeap(),0,package
->components
);
605 for (i
= 0; i
< package
->loaded_files
; i
++)
607 HeapFree(GetProcessHeap(),0,package
->files
[i
].File
);
608 HeapFree(GetProcessHeap(),0,package
->files
[i
].FileName
);
609 HeapFree(GetProcessHeap(),0,package
->files
[i
].ShortName
);
610 HeapFree(GetProcessHeap(),0,package
->files
[i
].Version
);
611 HeapFree(GetProcessHeap(),0,package
->files
[i
].Language
);
612 HeapFree(GetProcessHeap(),0,package
->files
[i
].SourcePath
);
613 HeapFree(GetProcessHeap(),0,package
->files
[i
].TargetPath
);
616 if (package
->files
&& package
->loaded_files
> 0)
617 HeapFree(GetProcessHeap(),0,package
->files
);
619 for (i
= 0; i
< package
->DeferredActionCount
; i
++)
620 HeapFree(GetProcessHeap(),0,package
->DeferredAction
[i
]);
621 HeapFree(GetProcessHeap(),0,package
->DeferredAction
);
623 for (i
= 0; i
< package
->CommitActionCount
; i
++)
624 HeapFree(GetProcessHeap(),0,package
->CommitAction
[i
]);
625 HeapFree(GetProcessHeap(),0,package
->CommitAction
);
627 HeapFree(GetProcessHeap(),0,package
->PackagePath
);
630 static void ui_progress(MSIPACKAGE
*package
, int a
, int b
, int c
, int d
)
634 row
= MSI_CreateRecord(4);
635 MSI_RecordSetInteger(row
,1,a
);
636 MSI_RecordSetInteger(row
,2,b
);
637 MSI_RecordSetInteger(row
,3,c
);
638 MSI_RecordSetInteger(row
,4,d
);
639 MSI_ProcessMessage(package
, INSTALLMESSAGE_PROGRESS
, row
);
640 msiobj_release(&row
->hdr
);
642 msi_dialog_check_messages(NULL
);
645 static void ui_actiondata(MSIPACKAGE
*package
, LPCWSTR action
, MSIRECORD
* record
)
647 static const WCHAR Query_t
[] =
648 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
649 '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
650 'W','H','E','R','E',' ', '`','A','c','t','i','o','n','`',' ','=',
651 ' ','\'','%','s','\'',0};
658 if (!package
->LastAction
|| strcmpW(package
->LastAction
,action
))
660 rc
= MSI_OpenQuery(package
->db
, &view
, Query_t
, action
);
661 if (rc
!= ERROR_SUCCESS
)
664 rc
= MSI_ViewExecute(view
, 0);
665 if (rc
!= ERROR_SUCCESS
)
668 msiobj_release(&view
->hdr
);
671 rc
= MSI_ViewFetch(view
,&row
);
672 if (rc
!= ERROR_SUCCESS
)
675 msiobj_release(&view
->hdr
);
679 if (MSI_RecordIsNull(row
,3))
681 msiobj_release(&row
->hdr
);
683 msiobj_release(&view
->hdr
);
687 /* update the cached actionformat */
688 HeapFree(GetProcessHeap(),0,package
->ActionFormat
);
689 package
->ActionFormat
= load_dynamic_stringW(row
,3);
691 HeapFree(GetProcessHeap(),0,package
->LastAction
);
692 package
->LastAction
= strdupW(action
);
694 msiobj_release(&row
->hdr
);
696 msiobj_release(&view
->hdr
);
699 MSI_RecordSetStringW(record
,0,package
->ActionFormat
);
701 MSI_FormatRecordW(package
,record
,message
,&size
);
703 row
= MSI_CreateRecord(1);
704 MSI_RecordSetStringW(row
,1,message
);
706 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONDATA
, row
);
707 msiobj_release(&row
->hdr
);
711 static void ui_actionstart(MSIPACKAGE
*package
, LPCWSTR action
)
713 static const WCHAR template_s
[]=
714 {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ', '%','s',
716 static const WCHAR format
[] =
717 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
718 static const WCHAR Query_t
[] =
719 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
720 '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
721 'W','H','E','R','E', ' ','`','A','c','t','i','o','n','`',' ','=',
722 ' ','\'','%','s','\'',0};
728 WCHAR
*ActionText
=NULL
;
730 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0, NULL
, format
, timet
, 0x100);
732 rc
= MSI_OpenQuery(package
->db
, &view
, Query_t
, action
);
733 if (rc
!= ERROR_SUCCESS
)
735 rc
= MSI_ViewExecute(view
, 0);
736 if (rc
!= ERROR_SUCCESS
)
739 msiobj_release(&view
->hdr
);
742 rc
= MSI_ViewFetch(view
,&row
);
743 if (rc
!= ERROR_SUCCESS
)
746 msiobj_release(&view
->hdr
);
750 ActionText
= load_dynamic_stringW(row
,2);
751 msiobj_release(&row
->hdr
);
753 msiobj_release(&view
->hdr
);
755 sprintfW(message
,template_s
,timet
,action
,ActionText
);
757 row
= MSI_CreateRecord(1);
758 MSI_RecordSetStringW(row
,1,message
);
760 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONSTART
, row
);
761 msiobj_release(&row
->hdr
);
762 HeapFree(GetProcessHeap(),0,ActionText
);
765 static void ui_actioninfo(MSIPACKAGE
*package
, LPCWSTR action
, BOOL start
,
769 static const WCHAR template_s
[]=
770 {'A','c','t','i','o','n',' ','s','t','a','r','t',' ','%','s',':',' ',
772 static const WCHAR template_e
[]=
773 {'A','c','t','i','o','n',' ','e','n','d','e','d',' ','%','s',':',' ',
774 '%','s', '.',' ','R','e','t','u','r','n',' ','v','a','l','u','e',' ',
776 static const WCHAR format
[] =
777 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
781 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0, NULL
, format
, timet
, 0x100);
783 sprintfW(message
,template_s
,timet
,action
);
785 sprintfW(message
,template_e
,timet
,action
,rc
);
787 row
= MSI_CreateRecord(1);
788 MSI_RecordSetStringW(row
,1,message
);
790 MSI_ProcessMessage(package
, INSTALLMESSAGE_INFO
, row
);
791 msiobj_release(&row
->hdr
);
795 * build_directory_name()
797 * This function is to save messing round with directory names
798 * It handles adding backslashes between path segments,
799 * and can add \ at the end of the directory name if told to.
801 * It takes a variable number of arguments.
802 * It always allocates a new string for the result, so make sure
803 * to free the return value when finished with it.
805 * The first arg is the number of path segments that follow.
806 * The arguments following count are a list of path segments.
807 * A path segment may be NULL.
809 * Path segments will be added with a \ separating them.
810 * A \ will not be added after the last segment, however if the
811 * last segment is NULL, then the last character will be a \
814 static LPWSTR
build_directory_name(DWORD count
, ...)
821 for(i
=0; i
<count
; i
++)
823 LPCWSTR str
= va_arg(va
,LPCWSTR
);
825 sz
+= strlenW(str
) + 1;
829 dir
= HeapAlloc(GetProcessHeap(), 0, sz
*sizeof(WCHAR
));
833 for(i
=0; i
<count
; i
++)
835 LPCWSTR str
= va_arg(va
,LPCWSTR
);
839 if( ((i
+1)!=count
) && dir
[strlenW(dir
)-1]!='\\')
845 static BOOL
ACTION_VerifyComponentForAction(MSIPACKAGE
* package
, INT index
,
848 if (package
->components
[index
].Installed
== check
)
851 if (package
->components
[index
].ActionRequest
== check
)
857 static BOOL
ACTION_VerifyFeatureForAction(MSIPACKAGE
* package
, INT index
,
860 if (package
->features
[index
].Installed
== check
)
863 if (package
->features
[index
].ActionRequest
== check
)
870 /****************************************************
871 * TOP level entry points
872 *****************************************************/
874 UINT
ACTION_DoTopLevelINSTALL(MSIPACKAGE
*package
, LPCWSTR szPackagePath
,
875 LPCWSTR szCommandLine
)
881 static const WCHAR szUILevel
[] = {'U','I','L','e','v','e','l',0};
882 static const WCHAR szAction
[] = {'A','C','T','I','O','N',0};
883 static const WCHAR szInstall
[] = {'I','N','S','T','A','L','L',0};
885 MSI_SetPropertyW(package
, szAction
, szInstall
);
886 package
->ExecuteSequenceRun
= FALSE
;
890 LPWSTR p
, check
, path
;
892 package
->PackagePath
= strdupW(szPackagePath
);
893 path
= strdupW(szPackagePath
);
894 p
= strrchrW(path
,'\\');
902 HeapFree(GetProcessHeap(),0,path
);
903 path
= HeapAlloc(GetProcessHeap(),0,MAX_PATH
*sizeof(WCHAR
));
904 GetCurrentDirectoryW(MAX_PATH
,path
);
908 check
= load_dynamic_property(package
, cszSourceDir
,NULL
);
910 MSI_SetPropertyW(package
, cszSourceDir
, path
);
912 HeapFree(GetProcessHeap(), 0, check
);
914 HeapFree(GetProcessHeap(), 0, path
);
920 ptr
= (LPWSTR
)szCommandLine
;
927 TRACE("Looking at %s\n",debugstr_w(ptr
));
929 ptr2
= strchrW(ptr
,'=');
935 while (*ptr
== ' ') ptr
++;
937 prop
= HeapAlloc(GetProcessHeap(),0,(len
+1)*sizeof(WCHAR
));
938 memcpy(prop
,ptr
,len
*sizeof(WCHAR
));
944 while (*ptr
&& (quote
|| (!quote
&& *ptr
!=' ')))
957 val
= HeapAlloc(GetProcessHeap(),0,(len
+1)*sizeof(WCHAR
));
958 memcpy(val
,ptr2
,len
*sizeof(WCHAR
));
961 if (strlenW(prop
) > 0)
963 TRACE("Found commandline property (%s) = (%s)\n",
964 debugstr_w(prop
), debugstr_w(val
));
965 MSI_SetPropertyW(package
,prop
,val
);
967 HeapFree(GetProcessHeap(),0,val
);
968 HeapFree(GetProcessHeap(),0,prop
);
975 if (MSI_GetPropertyW(package
,szUILevel
,buffer
,&sz
) == ERROR_SUCCESS
)
977 if (atoiW(buffer
) >= INSTALLUILEVEL_REDUCED
)
979 rc
= ACTION_ProcessUISequence(package
);
981 if (rc
== ERROR_SUCCESS
)
982 rc
= ACTION_ProcessExecSequence(package
,TRUE
);
985 rc
= ACTION_ProcessExecSequence(package
,FALSE
);
988 rc
= ACTION_ProcessExecSequence(package
,FALSE
);
992 /* install was halted but should be considered a success */
996 /* process the ending type action */
997 if (rc
== ERROR_SUCCESS
)
998 ACTION_PerformActionSequence(package
,-1,ui
);
999 else if (rc
== ERROR_INSTALL_USEREXIT
)
1000 ACTION_PerformActionSequence(package
,-2,ui
);
1001 else if (rc
== ERROR_FUNCTION_FAILED
)
1002 ACTION_PerformActionSequence(package
,-3,ui
);
1003 else if (rc
== ERROR_INSTALL_SUSPEND
)
1004 ACTION_PerformActionSequence(package
,-4,ui
);
1006 /* finish up running custom actions */
1007 ACTION_FinishCustomActions(package
);
1012 static UINT
ACTION_PerformActionSequence(MSIPACKAGE
*package
, UINT seq
, BOOL UI
)
1016 WCHAR buffer
[0x100];
1018 MSIRECORD
* row
= 0;
1019 static const WCHAR ExecSeqQuery
[] =
1020 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1021 '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
1022 'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
1023 '`','S','e','q','u','e','n','c','e','`',' ', '=',' ','%','i',0};
1025 static const WCHAR UISeqQuery
[] =
1026 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1027 '`','I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e',
1028 '`', ' ', 'W','H','E','R','E',' ','`','S','e','q','u','e','n','c','e','`',
1029 ' ', '=',' ','%','i',0};
1032 rc
= MSI_OpenQuery(package
->db
, &view
, UISeqQuery
, seq
);
1034 rc
= MSI_OpenQuery(package
->db
, &view
, ExecSeqQuery
, seq
);
1036 if (rc
== ERROR_SUCCESS
)
1038 rc
= MSI_ViewExecute(view
, 0);
1040 if (rc
!= ERROR_SUCCESS
)
1042 MSI_ViewClose(view
);
1043 msiobj_release(&view
->hdr
);
1047 TRACE("Running the actions\n");
1049 rc
= MSI_ViewFetch(view
,&row
);
1050 if (rc
!= ERROR_SUCCESS
)
1056 /* check conditions */
1057 if (!MSI_RecordIsNull(row
,2))
1060 cond
= load_dynamic_stringW(row
,2);
1064 /* this is a hack to skip errors in the condition code */
1065 if (MSI_EvaluateConditionW(package
, cond
) == MSICONDITION_FALSE
)
1067 HeapFree(GetProcessHeap(),0,cond
);
1068 msiobj_release(&row
->hdr
);
1072 HeapFree(GetProcessHeap(),0,cond
);
1077 rc
= MSI_RecordGetStringW(row
,1,buffer
,&sz
);
1078 if (rc
!= ERROR_SUCCESS
)
1080 ERR("Error is %x\n",rc
);
1081 msiobj_release(&row
->hdr
);
1086 rc
= ACTION_PerformUIAction(package
,buffer
);
1088 rc
= ACTION_PerformAction(package
,buffer
);
1089 msiobj_release(&row
->hdr
);
1091 MSI_ViewClose(view
);
1092 msiobj_release(&view
->hdr
);
1100 static UINT
ACTION_ProcessExecSequence(MSIPACKAGE
*package
, BOOL UIran
)
1104 static const WCHAR ExecSeqQuery
[] =
1105 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
1106 '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
1107 'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
1108 '`','S','e','q','u','e','n','c','e','`',' ', '>',' ','%','i',' ',
1109 'O','R','D','E','R',' ', 'B','Y',' ',
1110 '`','S','e','q','u','e','n','c','e','`',0 };
1111 MSIRECORD
* row
= 0;
1112 static const WCHAR IVQuery
[] =
1113 {'S','E','L','E','C','T',' ','`','S','e','q','u','e','n','c','e','`',
1114 ' ', 'F','R','O','M',' ','`','I','n','s','t','a','l','l',
1115 'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e','`',' ',
1116 'W','H','E','R','E',' ','`','A','c','t','i','o','n','`',' ','=',
1117 ' ','\'', 'I','n','s','t','a','l','l',
1118 'V','a','l','i','d','a','t','e','\'', 0};
1122 if (package
->ExecuteSequenceRun
)
1124 TRACE("Execute Sequence already Run\n");
1125 return ERROR_SUCCESS
;
1128 package
->ExecuteSequenceRun
= TRUE
;
1130 /* get the sequence number */
1133 rc
= MSI_DatabaseOpenViewW(package
->db
, IVQuery
, &view
);
1134 if (rc
!= ERROR_SUCCESS
)
1136 rc
= MSI_ViewExecute(view
, 0);
1137 if (rc
!= ERROR_SUCCESS
)
1139 MSI_ViewClose(view
);
1140 msiobj_release(&view
->hdr
);
1143 rc
= MSI_ViewFetch(view
,&row
);
1144 if (rc
!= ERROR_SUCCESS
)
1146 MSI_ViewClose(view
);
1147 msiobj_release(&view
->hdr
);
1150 seq
= MSI_RecordGetInteger(row
,1);
1151 msiobj_release(&row
->hdr
);
1152 MSI_ViewClose(view
);
1153 msiobj_release(&view
->hdr
);
1156 rc
= MSI_OpenQuery(package
->db
, &view
, ExecSeqQuery
, seq
);
1157 if (rc
== ERROR_SUCCESS
)
1159 rc
= MSI_ViewExecute(view
, 0);
1161 if (rc
!= ERROR_SUCCESS
)
1163 MSI_ViewClose(view
);
1164 msiobj_release(&view
->hdr
);
1168 TRACE("Running the actions\n");
1172 WCHAR buffer
[0x100];
1175 rc
= MSI_ViewFetch(view
,&row
);
1176 if (rc
!= ERROR_SUCCESS
)
1182 /* check conditions */
1183 if (!MSI_RecordIsNull(row
,2))
1186 cond
= load_dynamic_stringW(row
,2);
1190 /* this is a hack to skip errors in the condition code */
1191 if (MSI_EvaluateConditionW(package
, cond
) ==
1194 HeapFree(GetProcessHeap(),0,cond
);
1195 msiobj_release(&row
->hdr
);
1199 HeapFree(GetProcessHeap(),0,cond
);
1204 rc
= MSI_RecordGetStringW(row
,1,buffer
,&sz
);
1205 if (rc
!= ERROR_SUCCESS
)
1207 ERR("Error is %x\n",rc
);
1208 msiobj_release(&row
->hdr
);
1212 rc
= ACTION_PerformAction(package
,buffer
);
1214 if (rc
== ERROR_FUNCTION_NOT_CALLED
)
1217 if (rc
!= ERROR_SUCCESS
)
1219 ERR("Execution halted due to error (%i)\n",rc
);
1220 msiobj_release(&row
->hdr
);
1224 msiobj_release(&row
->hdr
);
1227 MSI_ViewClose(view
);
1228 msiobj_release(&view
->hdr
);
1236 static UINT
ACTION_ProcessUISequence(MSIPACKAGE
*package
)
1240 static const WCHAR ExecSeqQuery
[] =
1241 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1242 '`','I','n','s','t','a','l','l',
1243 'U','I','S','e','q','u','e','n','c','e','`',
1244 ' ','W','H','E','R','E',' ',
1245 '`','S','e','q','u','e','n','c','e','`',' ',
1246 '>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
1247 '`','S','e','q','u','e','n','c','e','`',0};
1249 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
1251 if (rc
== ERROR_SUCCESS
)
1253 rc
= MSI_ViewExecute(view
, 0);
1255 if (rc
!= ERROR_SUCCESS
)
1257 MSI_ViewClose(view
);
1258 msiobj_release(&view
->hdr
);
1262 TRACE("Running the actions \n");
1266 WCHAR buffer
[0x100];
1268 MSIRECORD
* row
= 0;
1270 rc
= MSI_ViewFetch(view
,&row
);
1271 if (rc
!= ERROR_SUCCESS
)
1277 /* check conditions */
1278 if (!MSI_RecordIsNull(row
,2))
1281 cond
= load_dynamic_stringW(row
,2);
1285 /* this is a hack to skip errors in the condition code */
1286 if (MSI_EvaluateConditionW(package
, cond
) ==
1289 HeapFree(GetProcessHeap(),0,cond
);
1290 msiobj_release(&row
->hdr
);
1294 HeapFree(GetProcessHeap(),0,cond
);
1299 rc
= MSI_RecordGetStringW(row
,1,buffer
,&sz
);
1300 if (rc
!= ERROR_SUCCESS
)
1302 ERR("Error is %x\n",rc
);
1303 msiobj_release(&row
->hdr
);
1307 rc
= ACTION_PerformUIAction(package
,buffer
);
1309 if (rc
== ERROR_FUNCTION_NOT_CALLED
)
1312 if (rc
!= ERROR_SUCCESS
)
1314 ERR("Execution halted due to error (%i)\n",rc
);
1315 msiobj_release(&row
->hdr
);
1319 msiobj_release(&row
->hdr
);
1322 MSI_ViewClose(view
);
1323 msiobj_release(&view
->hdr
);
1330 /********************************************************
1331 * ACTION helper functions and functions that perform the actions
1332 *******************************************************/
1333 BOOL
ACTION_HandleStandardAction(MSIPACKAGE
*package
, LPCWSTR action
, UINT
* rc
)
1339 while (StandardActions
[i
].action
!= NULL
)
1341 if (strcmpW(StandardActions
[i
].action
, action
)==0)
1343 ui_actioninfo(package
, action
, TRUE
, 0);
1344 ui_actionstart(package
, action
);
1345 if (StandardActions
[i
].handler
)
1347 *rc
= StandardActions
[i
].handler(package
);
1351 FIXME("UNHANDLED Standard Action %s\n",debugstr_w(action
));
1352 *rc
= ERROR_SUCCESS
;
1354 ui_actioninfo(package
, action
, FALSE
, *rc
);
1363 BOOL
ACTION_HandleDialogBox(MSIPACKAGE
*package
, LPCWSTR dialog
, UINT
* rc
)
1368 * for the UI when we get that working
1370 if (ACTION_DialogBox(package,dialog) == ERROR_SUCCESS)
1372 *rc = package->CurrentInstallState;
1379 BOOL
ACTION_HandleCustomAction(MSIPACKAGE
* package
, LPCWSTR action
, UINT
* rc
)
1384 arc
= ACTION_CustomAction(package
,action
,FALSE
);
1386 if (arc
!= ERROR_CALL_NOT_IMPLEMENTED
)
1395 * A lot of actions are really important even if they don't do anything
1396 * explicit... Lots of properties are set at the beginning of the installation
1397 * CostFinalize does a bunch of work to translate the directories and such
1399 * But until I get write access to the database that is hard, so I am going to
1400 * hack it to see if I can get something to run.
1402 UINT
ACTION_PerformAction(MSIPACKAGE
*package
, const WCHAR
*action
)
1404 UINT rc
= ERROR_SUCCESS
;
1407 TRACE("Performing action (%s)\n",debugstr_w(action
));
1409 handled
= ACTION_HandleStandardAction(package
, action
, &rc
);
1412 handled
= ACTION_HandleCustomAction(package
, action
, &rc
);
1416 FIXME("UNHANDLED MSI ACTION %s\n",debugstr_w(action
));
1417 rc
= ERROR_FUNCTION_NOT_CALLED
;
1420 package
->CurrentInstallState
= rc
;
1424 UINT
ACTION_PerformUIAction(MSIPACKAGE
*package
, const WCHAR
*action
)
1426 UINT rc
= ERROR_SUCCESS
;
1427 BOOL handled
= FALSE
;
1429 TRACE("Performing action (%s)\n",debugstr_w(action
));
1431 handled
= ACTION_HandleStandardAction(package
, action
, &rc
);
1434 handled
= ACTION_HandleCustomAction(package
, action
, &rc
);
1437 handled
= ACTION_HandleDialogBox(package
, action
, &rc
);
1439 msi_dialog_check_messages( NULL
);
1443 FIXME("UNHANDLED MSI ACTION %s\n",debugstr_w(action
));
1444 rc
= ERROR_FUNCTION_NOT_CALLED
;
1447 package
->CurrentInstallState
= rc
;
1451 /***********************************************************************
1454 * Recursively create all directories in the path.
1456 * shamelessly stolen from setupapi/queue.c
1458 static BOOL
create_full_pathW(const WCHAR
*path
)
1464 new_path
= HeapAlloc(GetProcessHeap(), 0, (strlenW(path
) + 1) *
1467 strcpyW(new_path
, path
);
1469 while((len
= strlenW(new_path
)) && new_path
[len
- 1] == '\\')
1470 new_path
[len
- 1] = 0;
1472 while(!CreateDirectoryW(new_path
, NULL
))
1475 DWORD last_error
= GetLastError();
1476 if(last_error
== ERROR_ALREADY_EXISTS
)
1479 if(last_error
!= ERROR_PATH_NOT_FOUND
)
1485 if(!(slash
= strrchrW(new_path
, '\\')))
1491 len
= slash
- new_path
;
1493 if(!create_full_pathW(new_path
))
1498 new_path
[len
] = '\\';
1501 HeapFree(GetProcessHeap(), 0, new_path
);
1506 * Also we cannot enable/disable components either, so for now I am just going
1507 * to do all the directories for all the components.
1509 static UINT
ACTION_CreateFolders(MSIPACKAGE
*package
)
1511 static const WCHAR ExecSeqQuery
[] =
1512 {'S','E','L','E','C','T',' ',
1513 '`','D','i','r','e','c','t','o','r','y','_','`',
1514 ' ','F','R','O','M',' ',
1515 '`','C','r','e','a','t','e','F','o','l','d','e','r','`',0 };
1520 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
1521 if (rc
!= ERROR_SUCCESS
)
1522 return ERROR_SUCCESS
;
1524 rc
= MSI_ViewExecute(view
, 0);
1525 if (rc
!= ERROR_SUCCESS
)
1527 MSI_ViewClose(view
);
1528 msiobj_release(&view
->hdr
);
1537 MSIRECORD
*row
= NULL
, *uirow
;
1539 rc
= MSI_ViewFetch(view
,&row
);
1540 if (rc
!= ERROR_SUCCESS
)
1547 rc
= MSI_RecordGetStringW(row
,1,dir
,&sz
);
1549 if (rc
!= ERROR_SUCCESS
)
1551 ERR("Unable to get folder id \n");
1552 msiobj_release(&row
->hdr
);
1557 full_path
= resolve_folder(package
,dir
,FALSE
,FALSE
,&folder
);
1560 ERR("Unable to resolve folder id %s\n",debugstr_w(dir
));
1561 msiobj_release(&row
->hdr
);
1565 TRACE("Folder is %s\n",debugstr_w(full_path
));
1568 uirow
= MSI_CreateRecord(1);
1569 MSI_RecordSetStringW(uirow
,1,full_path
);
1570 ui_actiondata(package
,szCreateFolders
,uirow
);
1571 msiobj_release( &uirow
->hdr
);
1573 if (folder
->State
== 0)
1574 create_full_pathW(full_path
);
1578 msiobj_release(&row
->hdr
);
1579 HeapFree(GetProcessHeap(),0,full_path
);
1581 MSI_ViewClose(view
);
1582 msiobj_release(&view
->hdr
);
1587 static int load_component(MSIPACKAGE
* package
, MSIRECORD
* row
)
1589 int index
= package
->loaded_components
;
1592 /* fill in the data */
1594 package
->loaded_components
++;
1595 if (package
->loaded_components
== 1)
1596 package
->components
= HeapAlloc(GetProcessHeap(),0,
1597 sizeof(MSICOMPONENT
));
1599 package
->components
= HeapReAlloc(GetProcessHeap(),0,
1600 package
->components
, package
->loaded_components
*
1601 sizeof(MSICOMPONENT
));
1603 memset(&package
->components
[index
],0,sizeof(MSICOMPONENT
));
1606 MSI_RecordGetStringW(row
,1,package
->components
[index
].Component
,&sz
);
1608 TRACE("Loading Component %s\n",
1609 debugstr_w(package
->components
[index
].Component
));
1612 if (!MSI_RecordIsNull(row
,2))
1613 MSI_RecordGetStringW(row
,2,package
->components
[index
].ComponentId
,&sz
);
1616 MSI_RecordGetStringW(row
,3,package
->components
[index
].Directory
,&sz
);
1618 package
->components
[index
].Attributes
= MSI_RecordGetInteger(row
,4);
1621 MSI_RecordGetStringW(row
,5,package
->components
[index
].Condition
,&sz
);
1624 MSI_RecordGetStringW(row
,6,package
->components
[index
].KeyPath
,&sz
);
1626 package
->components
[index
].Installed
= INSTALLSTATE_ABSENT
;
1627 package
->components
[index
].Action
= INSTALLSTATE_UNKNOWN
;
1628 package
->components
[index
].ActionRequest
= INSTALLSTATE_UNKNOWN
;
1630 package
->components
[index
].Enabled
= TRUE
;
1635 static void load_feature(MSIPACKAGE
* package
, MSIRECORD
* row
)
1637 int index
= package
->loaded_features
;
1639 static const WCHAR Query1
[] =
1640 {'S','E','L','E','C','T',' ',
1641 '`','C','o','m','p','o','n','e','n','t','_','`',
1642 ' ','F','R','O','M',' ','`','F','e','a','t','u','r','e',
1643 'C','o','m','p','o','n','e','n','t','s','`',' ',
1644 'W','H','E','R','E',' ',
1645 '`','F','e', 'a','t','u','r','e','_','`',' ','=','\'','%','s','\'',0};
1646 static const WCHAR Query2
[] =
1647 {'S','E','L','E','C','T',' ','*',' ','F','R', 'O','M',' ',
1648 '`','C','o','m','p','o','n','e','n','t','`',' ',
1649 'W','H','E','R','E',' ',
1650 '`','C','o','m','p','o','n','e','n','t','`',' ',
1651 '=','\'','%','s','\'',0};
1658 /* fill in the data */
1660 package
->loaded_features
++;
1661 if (package
->loaded_features
== 1)
1662 package
->features
= HeapAlloc(GetProcessHeap(),0,sizeof(MSIFEATURE
));
1664 package
->features
= HeapReAlloc(GetProcessHeap(),0,package
->features
,
1665 package
->loaded_features
* sizeof(MSIFEATURE
));
1667 memset(&package
->features
[index
],0,sizeof(MSIFEATURE
));
1670 MSI_RecordGetStringW(row
,1,package
->features
[index
].Feature
,&sz
);
1672 TRACE("Loading feature %s\n",debugstr_w(package
->features
[index
].Feature
));
1675 if (!MSI_RecordIsNull(row
,2))
1676 MSI_RecordGetStringW(row
,2,package
->features
[index
].Feature_Parent
,&sz
);
1679 if (!MSI_RecordIsNull(row
,3))
1680 MSI_RecordGetStringW(row
,3,package
->features
[index
].Title
,&sz
);
1683 if (!MSI_RecordIsNull(row
,4))
1684 MSI_RecordGetStringW(row
,4,package
->features
[index
].Description
,&sz
);
1686 if (!MSI_RecordIsNull(row
,5))
1687 package
->features
[index
].Display
= MSI_RecordGetInteger(row
,5);
1689 package
->features
[index
].Level
= MSI_RecordGetInteger(row
,6);
1692 if (!MSI_RecordIsNull(row
,7))
1693 MSI_RecordGetStringW(row
,7,package
->features
[index
].Directory
,&sz
);
1695 package
->features
[index
].Attributes
= MSI_RecordGetInteger(row
,8);
1697 package
->features
[index
].Installed
= INSTALLSTATE_ABSENT
;
1698 package
->features
[index
].Action
= INSTALLSTATE_UNKNOWN
;
1699 package
->features
[index
].ActionRequest
= INSTALLSTATE_UNKNOWN
;
1701 /* load feature components */
1703 rc
= MSI_OpenQuery(package
->db
, &view
, Query1
, package
->features
[index
].Feature
);
1704 if (rc
!= ERROR_SUCCESS
)
1706 rc
= MSI_ViewExecute(view
,0);
1707 if (rc
!= ERROR_SUCCESS
)
1709 MSI_ViewClose(view
);
1710 msiobj_release(&view
->hdr
);
1716 WCHAR buffer
[0x100];
1719 INT cnt
= package
->features
[index
].ComponentCount
;
1721 rc
= MSI_ViewFetch(view
,&row2
);
1722 if (rc
!= ERROR_SUCCESS
)
1726 MSI_RecordGetStringW(row2
,1,buffer
,&sz
);
1728 /* check to see if the component is already loaded */
1729 c_indx
= get_loaded_component(package
,buffer
);
1732 TRACE("Component %s already loaded at %i\n", debugstr_w(buffer
),
1734 package
->features
[index
].Components
[cnt
] = c_indx
;
1735 package
->features
[index
].ComponentCount
++;
1736 msiobj_release( &row2
->hdr
);
1740 rc
= MSI_OpenQuery(package
->db
, &view2
, Query2
, buffer
);
1741 if (rc
!= ERROR_SUCCESS
)
1743 msiobj_release( &row2
->hdr
);
1746 rc
= MSI_ViewExecute(view2
,0);
1747 if (rc
!= ERROR_SUCCESS
)
1749 msiobj_release( &row2
->hdr
);
1750 MSI_ViewClose(view2
);
1751 msiobj_release( &view2
->hdr
);
1758 rc
= MSI_ViewFetch(view2
,&row3
);
1759 if (rc
!= ERROR_SUCCESS
)
1761 c_indx
= load_component(package
,row3
);
1762 msiobj_release( &row3
->hdr
);
1764 package
->features
[index
].Components
[cnt
] = c_indx
;
1765 package
->features
[index
].ComponentCount
++;
1766 TRACE("Loaded new component to index %i\n",c_indx
);
1768 MSI_ViewClose(view2
);
1769 msiobj_release( &view2
->hdr
);
1770 msiobj_release( &row2
->hdr
);
1772 MSI_ViewClose(view
);
1773 msiobj_release(&view
->hdr
);
1776 static UINT
load_file(MSIPACKAGE
* package
, MSIRECORD
* row
)
1778 DWORD index
= package
->loaded_files
;
1782 /* fill in the data */
1784 package
->loaded_files
++;
1785 if (package
->loaded_files
== 1)
1786 package
->files
= HeapAlloc(GetProcessHeap(),0,sizeof(MSIFILE
));
1788 package
->files
= HeapReAlloc(GetProcessHeap(),0,
1789 package
->files
, package
->loaded_files
* sizeof(MSIFILE
));
1791 memset(&package
->files
[index
],0,sizeof(MSIFILE
));
1793 package
->files
[index
].File
= load_dynamic_stringW(row
, 1);
1794 buffer
= load_dynamic_stringW(row
, 2);
1796 package
->files
[index
].ComponentIndex
= -1;
1797 for (i
= 0; i
< package
->loaded_components
; i
++)
1798 if (strcmpW(package
->components
[i
].Component
,buffer
)==0)
1800 package
->files
[index
].ComponentIndex
= i
;
1803 if (package
->files
[index
].ComponentIndex
== -1)
1804 ERR("Unfound Component %s\n",debugstr_w(buffer
));
1805 HeapFree(GetProcessHeap(), 0, buffer
);
1807 package
->files
[index
].FileName
= load_dynamic_stringW(row
,3);
1808 reduce_to_longfilename(package
->files
[index
].FileName
);
1810 package
->files
[index
].ShortName
= load_dynamic_stringW(row
,3);
1811 reduce_to_shortfilename(package
->files
[index
].ShortName
);
1813 package
->files
[index
].FileSize
= MSI_RecordGetInteger(row
,4);
1814 package
->files
[index
].Version
= load_dynamic_stringW(row
, 5);
1815 package
->files
[index
].Language
= load_dynamic_stringW(row
, 6);
1816 package
->files
[index
].Attributes
= MSI_RecordGetInteger(row
,7);
1817 package
->files
[index
].Sequence
= MSI_RecordGetInteger(row
,8);
1819 package
->files
[index
].Temporary
= FALSE
;
1820 package
->files
[index
].State
= 0;
1822 TRACE("File Loaded (%s)\n",debugstr_w(package
->files
[index
].File
));
1824 return ERROR_SUCCESS
;
1827 static UINT
load_all_files(MSIPACKAGE
*package
)
1832 static const WCHAR Query
[] =
1833 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
1834 '`','F','i','l','e','`',' ', 'O','R','D','E','R',' ','B','Y',' ',
1835 '`','S','e','q','u','e','n','c','e','`', 0};
1838 return ERROR_INVALID_HANDLE
;
1840 rc
= MSI_DatabaseOpenViewW(package
->db
, Query
, &view
);
1841 if (rc
!= ERROR_SUCCESS
)
1842 return ERROR_SUCCESS
;
1844 rc
= MSI_ViewExecute(view
, 0);
1845 if (rc
!= ERROR_SUCCESS
)
1847 MSI_ViewClose(view
);
1848 msiobj_release(&view
->hdr
);
1849 return ERROR_SUCCESS
;
1854 rc
= MSI_ViewFetch(view
,&row
);
1855 if (rc
!= ERROR_SUCCESS
)
1860 load_file(package
,row
);
1861 msiobj_release(&row
->hdr
);
1863 MSI_ViewClose(view
);
1864 msiobj_release(&view
->hdr
);
1866 return ERROR_SUCCESS
;
1871 * I am not doing any of the costing functionality yet.
1872 * Mostly looking at doing the Component and Feature loading
1874 * The native MSI does A LOT of modification to tables here. Mostly adding
1875 * a lot of temporary columns to the Feature and Component tables.
1877 * note: Native msi also tracks the short filename. But I am only going to
1878 * track the long ones. Also looking at this directory table
1879 * it appears that the directory table does not get the parents
1880 * resolved base on property only based on their entries in the
1883 static UINT
ACTION_CostInitialize(MSIPACKAGE
*package
)
1888 static const WCHAR Query_all
[] =
1889 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
1890 '`','F','e','a','t','u','r','e','`',0};
1891 static const WCHAR szCosting
[] =
1892 {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
1893 static const WCHAR szZero
[] = { '0', 0 };
1897 MSI_GetPropertyW(package
, szCosting
, buffer
, &sz
);
1899 return ERROR_SUCCESS
;
1901 MSI_SetPropertyW(package
, szCosting
, szZero
);
1902 MSI_SetPropertyW(package
, cszRootDrive
, c_colon
);
1904 rc
= MSI_DatabaseOpenViewW(package
->db
,Query_all
,&view
);
1905 if (rc
!= ERROR_SUCCESS
)
1907 rc
= MSI_ViewExecute(view
,0);
1908 if (rc
!= ERROR_SUCCESS
)
1910 MSI_ViewClose(view
);
1911 msiobj_release(&view
->hdr
);
1918 rc
= MSI_ViewFetch(view
,&row
);
1919 if (rc
!= ERROR_SUCCESS
)
1922 load_feature(package
,row
);
1923 msiobj_release(&row
->hdr
);
1925 MSI_ViewClose(view
);
1926 msiobj_release(&view
->hdr
);
1928 load_all_files(package
);
1930 return ERROR_SUCCESS
;
1933 static UINT
ACTION_FileCost(MSIPACKAGE
*package
)
1935 return ERROR_SUCCESS
;
1939 static INT
load_folder(MSIPACKAGE
*package
, const WCHAR
* dir
)
1941 static const WCHAR Query
[] =
1942 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1943 '`','D','i','r','e','c', 't','o','r','y','`',' ',
1944 'W','H','E','R','E',' ', '`', 'D','i','r','e','c','t', 'o','r','y','`',
1945 ' ','=',' ','\'','%','s','\'',
1949 LPWSTR ptargetdir
, targetdir
, parent
, srcdir
;
1950 LPWSTR shortname
= NULL
;
1951 MSIRECORD
* row
= 0;
1955 TRACE("Looking for dir %s\n",debugstr_w(dir
));
1957 for (i
= 0; i
< package
->loaded_folders
; i
++)
1959 if (strcmpW(package
->folders
[i
].Directory
,dir
)==0)
1961 TRACE(" %s retuning on index %lu\n",debugstr_w(dir
),i
);
1966 TRACE("Working to load %s\n",debugstr_w(dir
));
1968 index
= package
->loaded_folders
++;
1969 if (package
->loaded_folders
==1)
1970 package
->folders
= HeapAlloc(GetProcessHeap(),0,
1973 package
->folders
= HeapReAlloc(GetProcessHeap(),0,
1974 package
->folders
, package
->loaded_folders
*
1977 memset(&package
->folders
[index
],0,sizeof(MSIFOLDER
));
1979 package
->folders
[index
].Directory
= strdupW(dir
);
1981 rc
= MSI_OpenQuery(package
->db
, &view
, Query
, dir
);
1982 if (rc
!= ERROR_SUCCESS
)
1985 rc
= MSI_ViewExecute(view
, 0);
1986 if (rc
!= ERROR_SUCCESS
)
1988 MSI_ViewClose(view
);
1989 msiobj_release(&view
->hdr
);
1993 rc
= MSI_ViewFetch(view
,&row
);
1994 if (rc
!= ERROR_SUCCESS
)
1996 MSI_ViewClose(view
);
1997 msiobj_release(&view
->hdr
);
2001 ptargetdir
= targetdir
= load_dynamic_stringW(row
,3);
2003 /* split src and target dir */
2004 if (strchrW(targetdir
,':'))
2006 srcdir
=strchrW(targetdir
,':');
2013 /* for now only pick long filename versions */
2014 if (strchrW(targetdir
,'|'))
2016 shortname
= targetdir
;
2017 targetdir
= strchrW(targetdir
,'|');
2021 /* for the sourcedir pick the short filename */
2022 if (srcdir
&& strchrW(srcdir
,'|'))
2024 LPWSTR p
= strchrW(srcdir
,'|');
2028 /* now check for root dirs */
2029 if (targetdir
[0] == '.' && targetdir
[1] == 0)
2032 if (srcdir
&& srcdir
[0] == '.' && srcdir
[1] == 0)
2037 TRACE(" TargetDefault = %s\n",debugstr_w(targetdir
));
2038 HeapFree(GetProcessHeap(),0, package
->folders
[index
].TargetDefault
);
2039 package
->folders
[index
].TargetDefault
= strdupW(targetdir
);
2043 package
->folders
[index
].SourceDefault
= strdupW(srcdir
);
2045 package
->folders
[index
].SourceDefault
= strdupW(shortname
);
2047 package
->folders
[index
].SourceDefault
= strdupW(targetdir
);
2048 HeapFree(GetProcessHeap(), 0, ptargetdir
);
2049 TRACE(" SourceDefault = %s\n",debugstr_w(package
->folders
[index
].SourceDefault
));
2051 parent
= load_dynamic_stringW(row
,2);
2054 i
= load_folder(package
,parent
);
2055 package
->folders
[index
].ParentIndex
= i
;
2056 TRACE("Parent is index %i... %s %s\n",
2057 package
->folders
[index
].ParentIndex
,
2058 debugstr_w(package
->folders
[package
->folders
[index
].ParentIndex
].Directory
),
2059 debugstr_w(parent
));
2062 package
->folders
[index
].ParentIndex
= -2;
2063 HeapFree(GetProcessHeap(), 0, parent
);
2065 package
->folders
[index
].Property
= load_dynamic_property(package
, dir
,NULL
);
2067 msiobj_release(&row
->hdr
);
2068 MSI_ViewClose(view
);
2069 msiobj_release(&view
->hdr
);
2070 TRACE(" %s retuning on index %i\n",debugstr_w(dir
),index
);
2075 LPWSTR
resolve_folder(MSIPACKAGE
*package
, LPCWSTR name
, BOOL source
,
2076 BOOL set_prop
, MSIFOLDER
**folder
)
2079 LPWSTR p
, path
= NULL
;
2081 TRACE("Working to resolve %s\n",debugstr_w(name
));
2083 /* special resolving for Target and Source root dir */
2084 if (strcmpW(name
,cszTargetDir
)==0 || strcmpW(name
,cszSourceDir
)==0)
2088 path
= load_dynamic_property(package
,cszTargetDir
,NULL
);
2091 path
= load_dynamic_property(package
,cszRootDrive
,NULL
);
2093 MSI_SetPropertyW(package
,cszTargetDir
,path
);
2097 for (i
= 0; i
< package
->loaded_folders
; i
++)
2099 if (strcmpW(package
->folders
[i
].Directory
,name
)==0)
2102 *folder
= &(package
->folders
[i
]);
2108 path
= load_dynamic_property(package
,cszSourceDir
,NULL
);
2111 path
= load_dynamic_property(package
,cszDatabase
,NULL
);
2114 p
= strrchrW(path
,'\\');
2121 for (i
= 0; i
< package
->loaded_folders
; i
++)
2123 if (strcmpW(package
->folders
[i
].Directory
,name
)==0)
2126 *folder
= &(package
->folders
[i
]);
2132 for (i
= 0; i
< package
->loaded_folders
; i
++)
2134 if (strcmpW(package
->folders
[i
].Directory
,name
)==0)
2138 if (i
>= package
->loaded_folders
)
2142 *folder
= &(package
->folders
[i
]);
2144 if (!source
&& package
->folders
[i
].ResolvedTarget
)
2146 path
= strdupW(package
->folders
[i
].ResolvedTarget
);
2147 TRACE(" already resolved to %s\n",debugstr_w(path
));
2150 else if (source
&& package
->folders
[i
].ResolvedSource
)
2152 path
= strdupW(package
->folders
[i
].ResolvedSource
);
2153 TRACE(" (source)already resolved to %s\n",debugstr_w(path
));
2156 else if (!source
&& package
->folders
[i
].Property
)
2158 path
= build_directory_name(2, package
->folders
[i
].Property
, NULL
);
2160 TRACE(" internally set to %s\n",debugstr_w(path
));
2162 MSI_SetPropertyW(package
,name
,path
);
2166 if (package
->folders
[i
].ParentIndex
>= 0)
2168 LPWSTR parent
= package
->folders
[package
->folders
[i
].ParentIndex
].Directory
;
2170 TRACE(" ! Parent is %s\n", debugstr_w(parent
));
2172 p
= resolve_folder(package
, parent
, source
, set_prop
, NULL
);
2175 TRACE(" TargetDefault = %s\n",debugstr_w(package
->folders
[i
].TargetDefault
));
2176 path
= build_directory_name(3, p
, package
->folders
[i
].TargetDefault
, NULL
);
2177 package
->folders
[i
].ResolvedTarget
= strdupW(path
);
2178 TRACE(" resolved into %s\n",debugstr_w(path
));
2180 MSI_SetPropertyW(package
,name
,path
);
2184 path
= build_directory_name(3, p
, package
->folders
[i
].SourceDefault
, NULL
);
2185 TRACE(" (source)resolved into %s\n",debugstr_w(path
));
2186 package
->folders
[i
].ResolvedSource
= strdupW(path
);
2188 HeapFree(GetProcessHeap(),0,p
);
2193 /* scan for and update current install states */
2194 void ACTION_UpdateInstallStates(MSIPACKAGE
*package
)
2199 productcode
= load_dynamic_property(package
,szProductCode
,NULL
);
2201 for (i
= 0; i
< package
->loaded_components
; i
++)
2204 res
= MsiGetComponentPathW(productcode
,
2205 package
->components
[i
].ComponentId
, NULL
, NULL
);
2207 res
= INSTALLSTATE_ABSENT
;
2208 package
->components
[i
].Installed
= res
;
2211 for (i
= 0; i
< package
->loaded_features
; i
++)
2213 INSTALLSTATE res
= -10;
2215 for (j
= 0; j
< package
->features
[i
].ComponentCount
; j
++)
2217 MSICOMPONENT
* component
= &package
->components
[package
->features
[i
].
2220 res
= component
->Installed
;
2223 if (res
== component
->Installed
)
2226 if (res
!= component
->Installed
)
2227 res
= INSTALLSTATE_INCOMPLETE
;
2233 /* update compoennt state based on a feature change */
2234 void ACTION_UpdateComponentStates(MSIPACKAGE
*package
, LPCWSTR szFeature
)
2237 INSTALLSTATE newstate
;
2238 MSIFEATURE
*feature
;
2240 i
= get_loaded_feature(package
,szFeature
);
2244 feature
= &package
->features
[i
];
2245 newstate
= feature
->ActionRequest
;
2247 for( i
= 0; i
< feature
->ComponentCount
; i
++)
2249 MSICOMPONENT
* component
= &package
->components
[feature
->Components
[i
]];
2251 TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n",
2252 newstate
, debugstr_w(component
->Component
), component
->Installed
,
2253 component
->Action
, component
->ActionRequest
);
2255 if (!component
->Enabled
)
2259 if (newstate
== INSTALLSTATE_LOCAL
)
2261 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
2262 component
->Action
= INSTALLSTATE_LOCAL
;
2268 component
->ActionRequest
= newstate
;
2269 component
->Action
= newstate
;
2271 /*if any other feature wants is local we need to set it local*/
2273 j
< package
->loaded_features
&&
2274 component
->ActionRequest
!= INSTALLSTATE_LOCAL
;
2277 for (k
= 0; k
< package
->features
[j
].ComponentCount
; k
++)
2278 if ( package
->features
[j
].Components
[k
] ==
2279 feature
->Components
[i
] )
2281 if (package
->features
[j
].ActionRequest
==
2284 TRACE("Saved by %s\n", debugstr_w(package
->features
[j
].Feature
));
2285 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
2286 component
->Action
= INSTALLSTATE_LOCAL
;
2293 TRACE("Result (%i): Component %s (Installed %i, Action %i, Request %i)\n",
2294 newstate
, debugstr_w(component
->Component
), component
->Installed
,
2295 component
->Action
, component
->ActionRequest
);
2299 static BOOL
process_state_property (MSIPACKAGE
* package
, LPCWSTR property
,
2302 static const WCHAR all
[]={'A','L','L',0};
2303 LPWSTR override
= NULL
;
2307 override
= load_dynamic_property(package
, property
, NULL
);
2311 for(i
= 0; i
< package
->loaded_features
; i
++)
2313 if (strcmpiW(override
,all
)==0)
2315 package
->features
[i
].ActionRequest
= state
;
2316 package
->features
[i
].Action
= state
;
2320 LPWSTR ptr
= override
;
2321 LPWSTR ptr2
= strchrW(override
,',');
2326 strncmpW(ptr
,package
->features
[i
].Feature
, ptr2
-ptr
)==0)
2328 strcmpW(ptr
,package
->features
[i
].Feature
)==0))
2330 package
->features
[i
].ActionRequest
= state
;
2331 package
->features
[i
].Action
= state
;
2337 ptr2
= strchrW(ptr
,',');
2344 HeapFree(GetProcessHeap(),0,override
);
2350 static UINT
SetFeatureStates(MSIPACKAGE
*package
)
2356 static const WCHAR szlevel
[] =
2357 {'I','N','S','T','A','L','L','L','E','V','E','L',0};
2358 static const WCHAR szAddLocal
[] =
2359 {'A','D','D','L','O','C','A','L',0};
2360 static const WCHAR szRemove
[] =
2361 {'R','E','M','O','V','E',0};
2362 BOOL override
= FALSE
;
2364 /* I do not know if this is where it should happen.. but */
2366 TRACE("Checking Install Level\n");
2368 level
= load_dynamic_property(package
,szlevel
,NULL
);
2371 install_level
= atoiW(level
);
2372 HeapFree(GetProcessHeap(), 0, level
);
2377 /* ok hereis the _real_ rub
2378 * all these activation/deactivation things happen in order and things
2379 * later on the list override things earlier on the list.
2380 * 1) INSTALLLEVEL processing
2390 * 11) FILEADDDEFAULT
2391 * I have confirmed that if ADDLOCAL is stated then the INSTALLLEVEL is
2392 * ignored for all the features. seems strange, especially since it is not
2393 * documented anywhere, but it is how it works.
2395 * I am still ignoring a lot of these. But that is ok for now, ADDLOCAL and
2396 * REMOVE are the big ones, since we don't handle administrative installs
2399 override
|= process_state_property(package
,szAddLocal
,INSTALLSTATE_LOCAL
);
2400 override
|= process_state_property(package
,szRemove
,INSTALLSTATE_ABSENT
);
2404 for(i
= 0; i
< package
->loaded_features
; i
++)
2406 BOOL feature_state
= ((package
->features
[i
].Level
> 0) &&
2407 (package
->features
[i
].Level
<= install_level
));
2409 if ((feature_state
) &&
2410 (package
->features
[i
].Action
== INSTALLSTATE_UNKNOWN
))
2412 if (package
->features
[i
].Attributes
&
2413 msidbFeatureAttributesFavorSource
)
2415 package
->features
[i
].ActionRequest
= INSTALLSTATE_SOURCE
;
2416 package
->features
[i
].Action
= INSTALLSTATE_SOURCE
;
2418 else if (package
->features
[i
].Attributes
&
2419 msidbFeatureAttributesFavorAdvertise
)
2421 package
->features
[i
].ActionRequest
=INSTALLSTATE_ADVERTISED
;
2422 package
->features
[i
].Action
=INSTALLSTATE_ADVERTISED
;
2426 package
->features
[i
].ActionRequest
= INSTALLSTATE_LOCAL
;
2427 package
->features
[i
].Action
= INSTALLSTATE_LOCAL
;
2434 * now we want to enable or disable components base on feature
2437 for(i
= 0; i
< package
->loaded_features
; i
++)
2439 MSIFEATURE
* feature
= &package
->features
[i
];
2440 TRACE("Examining Feature %s (Installed %i, Action %i, Request %i)\n",
2441 debugstr_w(feature
->Feature
), feature
->Installed
, feature
->Action
,
2442 feature
->ActionRequest
);
2444 for( j
= 0; j
< feature
->ComponentCount
; j
++)
2446 MSICOMPONENT
* component
= &package
->components
[
2447 feature
->Components
[j
]];
2449 if (!component
->Enabled
)
2451 component
->Action
= INSTALLSTATE_UNKNOWN
;
2452 component
->ActionRequest
= INSTALLSTATE_UNKNOWN
;
2456 if (feature
->Action
== INSTALLSTATE_LOCAL
)
2458 component
->Action
= INSTALLSTATE_LOCAL
;
2459 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
2461 else if (feature
->ActionRequest
== INSTALLSTATE_SOURCE
)
2463 if ((component
->Action
== INSTALLSTATE_UNKNOWN
) ||
2464 (component
->Action
== INSTALLSTATE_ABSENT
) ||
2465 (component
->Action
== INSTALLSTATE_ADVERTISED
))
2468 component
->Action
= INSTALLSTATE_SOURCE
;
2469 component
->ActionRequest
= INSTALLSTATE_SOURCE
;
2472 else if (feature
->ActionRequest
== INSTALLSTATE_ADVERTISED
)
2474 if ((component
->Action
== INSTALLSTATE_UNKNOWN
) ||
2475 (component
->Action
== INSTALLSTATE_ABSENT
))
2478 component
->Action
= INSTALLSTATE_ADVERTISED
;
2479 component
->ActionRequest
= INSTALLSTATE_ADVERTISED
;
2482 else if (feature
->ActionRequest
== INSTALLSTATE_ABSENT
)
2484 if (component
->Action
== INSTALLSTATE_UNKNOWN
)
2486 component
->Action
= INSTALLSTATE_ABSENT
;
2487 component
->ActionRequest
= INSTALLSTATE_ABSENT
;
2494 for(i
= 0; i
< package
->loaded_components
; i
++)
2496 MSICOMPONENT
* component
= &package
->components
[i
];
2498 TRACE("Result: Component %s (Installed %i, Action %i, Request %i)\n",
2499 debugstr_w(component
->Component
), component
->Installed
,
2500 component
->Action
, component
->ActionRequest
);
2504 return ERROR_SUCCESS
;
2508 * A lot is done in this function aside from just the costing.
2509 * The costing needs to be implemented at some point but for now I am going
2510 * to focus on the directory building
2513 static UINT
ACTION_CostFinalize(MSIPACKAGE
*package
)
2515 static const WCHAR ExecSeqQuery
[] =
2516 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2517 '`','D','i','r','e','c','t','o','r','y','`',0};
2518 static const WCHAR ConditionQuery
[] =
2519 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2520 '`','C','o','n','d','i','t','i','o','n','`',0};
2521 static const WCHAR szCosting
[] =
2522 {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
2523 static const WCHAR szlevel
[] =
2524 {'I','N','S','T','A','L','L','L','E','V','E','L',0};
2525 static const WCHAR szOne
[] = { '1', 0 };
2533 MSI_GetPropertyW(package
, szCosting
, buffer
, &sz
);
2535 return ERROR_SUCCESS
;
2537 TRACE("Building Directory properties\n");
2539 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
2540 if (rc
== ERROR_SUCCESS
)
2542 rc
= MSI_ViewExecute(view
, 0);
2543 if (rc
!= ERROR_SUCCESS
)
2545 MSI_ViewClose(view
);
2546 msiobj_release(&view
->hdr
);
2554 MSIRECORD
* row
= 0;
2557 rc
= MSI_ViewFetch(view
,&row
);
2558 if (rc
!= ERROR_SUCCESS
)
2565 MSI_RecordGetStringW(row
,1,name
,&sz
);
2567 /* This helper function now does ALL the work */
2568 TRACE("Dir %s ...\n",debugstr_w(name
));
2569 load_folder(package
,name
);
2570 path
= resolve_folder(package
,name
,FALSE
,TRUE
,NULL
);
2571 TRACE("resolves to %s\n",debugstr_w(path
));
2572 HeapFree( GetProcessHeap(), 0, path
);
2574 msiobj_release(&row
->hdr
);
2576 MSI_ViewClose(view
);
2577 msiobj_release(&view
->hdr
);
2580 TRACE("File calculations %i files\n",package
->loaded_files
);
2582 for (i
= 0; i
< package
->loaded_files
; i
++)
2584 MSICOMPONENT
* comp
= NULL
;
2585 MSIFILE
* file
= NULL
;
2587 file
= &package
->files
[i
];
2588 if (file
->ComponentIndex
>= 0)
2589 comp
= &package
->components
[file
->ComponentIndex
];
2591 if (file
->Temporary
== TRUE
)
2598 /* calculate target */
2599 p
= resolve_folder(package
, comp
->Directory
, FALSE
, FALSE
, NULL
);
2601 HeapFree(GetProcessHeap(),0,file
->TargetPath
);
2603 TRACE("file %s is named %s\n",
2604 debugstr_w(file
->File
),debugstr_w(file
->FileName
));
2606 file
->TargetPath
= build_directory_name(2, p
, file
->FileName
);
2608 HeapFree(GetProcessHeap(),0,p
);
2610 TRACE("file %s resolves to %s\n",
2611 debugstr_w(file
->File
),debugstr_w(file
->TargetPath
));
2613 if (GetFileAttributesW(file
->TargetPath
) == INVALID_FILE_ATTRIBUTES
)
2616 comp
->Cost
+= file
->FileSize
;
2626 static const WCHAR name
[] =
2628 static const WCHAR name_fmt
[] =
2629 {'%','u','.','%','u','.','%','u','.','%','u',0};
2630 WCHAR filever
[0x100];
2631 VS_FIXEDFILEINFO
*lpVer
;
2633 TRACE("Version comparison.. \n");
2634 versize
= GetFileVersionInfoSizeW(file
->TargetPath
,&handle
);
2635 version
= HeapAlloc(GetProcessHeap(),0,versize
);
2636 GetFileVersionInfoW(file
->TargetPath
, 0, versize
, version
);
2638 VerQueryValueW(version
, name
, (LPVOID
*)&lpVer
, &sz
);
2640 sprintfW(filever
,name_fmt
,
2641 HIWORD(lpVer
->dwFileVersionMS
),
2642 LOWORD(lpVer
->dwFileVersionMS
),
2643 HIWORD(lpVer
->dwFileVersionLS
),
2644 LOWORD(lpVer
->dwFileVersionLS
));
2646 TRACE("new %s old %s\n", debugstr_w(file
->Version
),
2647 debugstr_w(filever
));
2648 if (strcmpiW(filever
,file
->Version
)<0)
2651 FIXME("cost should be diff in size\n");
2652 comp
->Cost
+= file
->FileSize
;
2656 HeapFree(GetProcessHeap(),0,version
);
2664 TRACE("Evaluating Condition Table\n");
2666 rc
= MSI_DatabaseOpenViewW(package
->db
, ConditionQuery
, &view
);
2667 if (rc
== ERROR_SUCCESS
)
2669 rc
= MSI_ViewExecute(view
, 0);
2670 if (rc
!= ERROR_SUCCESS
)
2672 MSI_ViewClose(view
);
2673 msiobj_release(&view
->hdr
);
2679 WCHAR Feature
[0x100];
2680 MSIRECORD
* row
= 0;
2684 rc
= MSI_ViewFetch(view
,&row
);
2686 if (rc
!= ERROR_SUCCESS
)
2693 MSI_RecordGetStringW(row
,1,Feature
,&sz
);
2695 feature_index
= get_loaded_feature(package
,Feature
);
2696 if (feature_index
< 0)
2697 ERR("FAILED to find loaded feature %s\n",debugstr_w(Feature
));
2701 Condition
= load_dynamic_stringW(row
,3);
2703 if (MSI_EvaluateConditionW(package
,Condition
) ==
2706 int level
= MSI_RecordGetInteger(row
,2);
2707 TRACE("Reseting feature %s to level %i\n",
2708 debugstr_w(Feature
), level
);
2709 package
->features
[feature_index
].Level
= level
;
2711 HeapFree(GetProcessHeap(),0,Condition
);
2714 msiobj_release(&row
->hdr
);
2716 MSI_ViewClose(view
);
2717 msiobj_release(&view
->hdr
);
2720 TRACE("Enabling or Disabling Components\n");
2721 for (i
= 0; i
< package
->loaded_components
; i
++)
2723 if (package
->components
[i
].Condition
[0])
2725 if (MSI_EvaluateConditionW(package
,
2726 package
->components
[i
].Condition
) == MSICONDITION_FALSE
)
2728 TRACE("Disabling component %s\n",
2729 debugstr_w(package
->components
[i
].Component
));
2730 package
->components
[i
].Enabled
= FALSE
;
2735 MSI_SetPropertyW(package
,szCosting
,szOne
);
2736 /* set default run level if not set */
2737 level
= load_dynamic_property(package
,szlevel
,NULL
);
2739 MSI_SetPropertyW(package
,szlevel
, szOne
);
2741 HeapFree(GetProcessHeap(),0,level
);
2743 ACTION_UpdateInstallStates(package
);
2745 return SetFeatureStates(package
);
2749 * This is a helper function for handling embedded cabinet media
2751 static UINT
writeout_cabinet_stream(MSIPACKAGE
*package
, WCHAR
* stream_name
,
2759 WCHAR tmp
[MAX_PATH
];
2761 rc
= read_raw_stream_data(package
->db
,stream_name
,&data
,&size
);
2762 if (rc
!= ERROR_SUCCESS
)
2766 if (MSI_GetPropertyW(package
, cszTempFolder
, tmp
, &write
))
2767 GetTempPathW(MAX_PATH
,tmp
);
2769 GetTempFileNameW(tmp
,stream_name
,0,source
);
2771 track_tempfile(package
,strrchrW(source
,'\\'), source
);
2772 the_file
= CreateFileW(source
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
2773 FILE_ATTRIBUTE_NORMAL
, NULL
);
2775 if (the_file
== INVALID_HANDLE_VALUE
)
2777 ERR("Unable to create file %s\n",debugstr_w(source
));
2778 rc
= ERROR_FUNCTION_FAILED
;
2782 WriteFile(the_file
,data
,size
,&write
,NULL
);
2783 CloseHandle(the_file
);
2784 TRACE("wrote %li bytes to %s\n",write
,debugstr_w(source
));
2786 HeapFree(GetProcessHeap(),0,data
);
2791 /* Support functions for FDI functions */
2794 MSIPACKAGE
* package
;
2799 static void * cabinet_alloc(ULONG cb
)
2801 return HeapAlloc(GetProcessHeap(), 0, cb
);
2804 static void cabinet_free(void *pv
)
2806 HeapFree(GetProcessHeap(), 0, pv
);
2809 static INT_PTR
cabinet_open(char *pszFile
, int oflag
, int pmode
)
2812 DWORD dwShareMode
= 0;
2813 DWORD dwCreateDisposition
= OPEN_EXISTING
;
2814 switch (oflag
& _O_ACCMODE
)
2817 dwAccess
= GENERIC_READ
;
2818 dwShareMode
= FILE_SHARE_READ
| FILE_SHARE_DELETE
;
2821 dwAccess
= GENERIC_WRITE
;
2822 dwShareMode
= FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
;
2825 dwAccess
= GENERIC_READ
| GENERIC_WRITE
;
2826 dwShareMode
= FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
;
2829 if ((oflag
& (_O_CREAT
| _O_EXCL
)) == (_O_CREAT
| _O_EXCL
))
2830 dwCreateDisposition
= CREATE_NEW
;
2831 else if (oflag
& _O_CREAT
)
2832 dwCreateDisposition
= CREATE_ALWAYS
;
2833 return (INT_PTR
)CreateFileA(pszFile
, dwAccess
, dwShareMode
, NULL
,
2834 dwCreateDisposition
, 0, NULL
);
2837 static UINT
cabinet_read(INT_PTR hf
, void *pv
, UINT cb
)
2840 if (ReadFile((HANDLE
)hf
, pv
, cb
, &dwRead
, NULL
))
2845 static UINT
cabinet_write(INT_PTR hf
, void *pv
, UINT cb
)
2848 if (WriteFile((HANDLE
)hf
, pv
, cb
, &dwWritten
, NULL
))
2853 static int cabinet_close(INT_PTR hf
)
2855 return CloseHandle((HANDLE
)hf
) ? 0 : -1;
2858 static long cabinet_seek(INT_PTR hf
, long dist
, int seektype
)
2860 /* flags are compatible and so are passed straight through */
2861 return SetFilePointer((HANDLE
)hf
, dist
, NULL
, seektype
);
2864 static INT_PTR
cabinet_notify(FDINOTIFICATIONTYPE fdint
, PFDINOTIFICATION pfdin
)
2866 /* FIXME: try to do more processing in this function */
2869 case fdintCOPY_FILE
:
2871 CabData
*data
= (CabData
*) pfdin
->pv
;
2872 ULONG len
= strlen(data
->cab_path
) + strlen(pfdin
->psz1
);
2877 LPWSTR tracknametmp
;
2878 static const WCHAR tmpprefix
[] = {'C','A','B','T','M','P','_',0};
2880 if (data
->file_name
&& lstrcmpiA(data
->file_name
,pfdin
->psz1
))
2883 file
= cabinet_alloc((len
+1)*sizeof(char));
2884 strcpy(file
, data
->cab_path
);
2885 strcat(file
, pfdin
->psz1
);
2887 TRACE("file: %s\n", debugstr_a(file
));
2889 /* track this file so it can be deleted if not installed */
2890 trackpath
=strdupAtoW(file
);
2891 tracknametmp
=strdupAtoW(strrchr(file
,'\\')+1);
2892 trackname
= HeapAlloc(GetProcessHeap(),0,(strlenW(tracknametmp
) +
2893 strlenW(tmpprefix
)+1) * sizeof(WCHAR
));
2895 strcpyW(trackname
,tmpprefix
);
2896 strcatW(trackname
,tracknametmp
);
2898 track_tempfile(data
->package
, trackname
, trackpath
);
2900 HeapFree(GetProcessHeap(),0,trackpath
);
2901 HeapFree(GetProcessHeap(),0,trackname
);
2902 HeapFree(GetProcessHeap(),0,tracknametmp
);
2904 return cabinet_open(file
, _O_WRONLY
| _O_CREAT
, 0);
2906 case fdintCLOSE_FILE_INFO
:
2910 if (!DosDateTimeToFileTime(pfdin
->date
, pfdin
->time
, &ft
))
2912 if (!LocalFileTimeToFileTime(&ft
, &ftLocal
))
2914 if (!SetFileTime((HANDLE
)pfdin
->hf
, &ftLocal
, 0, &ftLocal
))
2917 cabinet_close(pfdin
->hf
);
2925 /***********************************************************************
2926 * extract_cabinet_file
2928 * Extract files from a cab file.
2930 static BOOL
extract_a_cabinet_file(MSIPACKAGE
* package
, const WCHAR
* source
,
2931 const WCHAR
* path
, const WCHAR
* file
)
2941 TRACE("Extracting %s (%s) to %s\n",debugstr_w(source
),
2942 debugstr_w(file
), debugstr_w(path
));
2944 hfdi
= FDICreate(cabinet_alloc
,
2955 ERR("FDICreate failed\n");
2959 if (!(cabinet
= strdupWtoA( source
)))
2964 if (!(cab_path
= strdupWtoA( path
)))
2967 HeapFree(GetProcessHeap(), 0, cabinet
);
2971 data
.package
= package
;
2972 data
.cab_path
= cab_path
;
2974 file_name
= strdupWtoA(file
);
2977 data
.file_name
= file_name
;
2979 ret
= FDICopy(hfdi
, cabinet
, "", 0, cabinet_notify
, NULL
, &data
);
2982 ERR("FDICopy failed\n");
2986 HeapFree(GetProcessHeap(), 0, cabinet
);
2987 HeapFree(GetProcessHeap(), 0, cab_path
);
2988 HeapFree(GetProcessHeap(), 0, file_name
);
2993 static UINT
ready_media_for_file(MSIPACKAGE
*package
, WCHAR
* path
,
2998 MSIRECORD
* row
= 0;
2999 static WCHAR source
[MAX_PATH
];
3000 static const WCHAR ExecSeqQuery
[] =
3001 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
3002 '`','M','e','d','i','a','`',' ','W','H','E','R','E',' ',
3003 '`','L','a','s','t','S','e','q','u','e','n','c','e','`',' ','>','=',
3004 ' ','%', 'i',' ','O','R','D','E','R',' ','B','Y',' ',
3005 '`','L','a','s','t','S','e','q','u','e','n','c','e','`',0};
3010 static UINT last_sequence
= 0;
3012 if (file
->Attributes
& msidbFileAttributesNoncompressed
)
3014 TRACE("Uncompressed File, no media to ready.\n");
3015 return ERROR_SUCCESS
;
3018 if (file
->Sequence
<= last_sequence
)
3020 TRACE("Media already ready (%u, %u)\n",file
->Sequence
,last_sequence
);
3021 /*extract_a_cabinet_file(package, source,path,file->File); */
3022 return ERROR_SUCCESS
;
3025 sprintfW(Query
,ExecSeqQuery
,file
->Sequence
);
3027 rc
= MSI_DatabaseOpenViewW(package
->db
, Query
, &view
);
3028 if (rc
!= ERROR_SUCCESS
)
3031 rc
= MSI_ViewExecute(view
, 0);
3032 if (rc
!= ERROR_SUCCESS
)
3034 MSI_ViewClose(view
);
3035 msiobj_release(&view
->hdr
);
3039 rc
= MSI_ViewFetch(view
,&row
);
3040 if (rc
!= ERROR_SUCCESS
)
3042 MSI_ViewClose(view
);
3043 msiobj_release(&view
->hdr
);
3046 seq
= MSI_RecordGetInteger(row
,2);
3047 last_sequence
= seq
;
3049 if (!MSI_RecordIsNull(row
,4))
3052 MSI_RecordGetStringW(row
,4,cab
,&sz
);
3053 TRACE("Source is CAB %s\n",debugstr_w(cab
));
3054 /* the stream does not contain the # character */
3057 writeout_cabinet_stream(package
,&cab
[1],source
);
3058 strcpyW(path
,source
);
3059 *(strrchrW(path
,'\\')+1)=0;
3064 if (MSI_GetPropertyW(package
, cszSourceDir
, source
, &sz
))
3066 ERR("No Source dir defined \n");
3067 rc
= ERROR_FUNCTION_FAILED
;
3071 strcpyW(path
,source
);
3072 strcatW(source
,cab
);
3073 /* extract the cab file into a folder in the temp folder */
3075 if (MSI_GetPropertyW(package
, cszTempFolder
,path
, &sz
)
3077 GetTempPathW(MAX_PATH
,path
);
3080 rc
= !extract_a_cabinet_file(package
, source
,path
,NULL
);
3085 MSI_GetPropertyW(package
,cszSourceDir
,source
,&sz
);
3086 strcpyW(path
,source
);
3088 msiobj_release(&row
->hdr
);
3089 MSI_ViewClose(view
);
3090 msiobj_release(&view
->hdr
);
3094 inline static UINT
create_component_directory ( MSIPACKAGE
* package
, INT component
)
3096 UINT rc
= ERROR_SUCCESS
;
3098 LPWSTR install_path
;
3100 install_path
= resolve_folder(package
, package
->components
[component
].Directory
,
3101 FALSE
, FALSE
, &folder
);
3103 return ERROR_FUNCTION_FAILED
;
3105 /* create the path */
3106 if (folder
->State
== 0)
3108 create_full_pathW(install_path
);
3111 HeapFree(GetProcessHeap(), 0, install_path
);
3116 static UINT
ACTION_InstallFiles(MSIPACKAGE
*package
)
3118 UINT rc
= ERROR_SUCCESS
;
3121 WCHAR uipath
[MAX_PATH
];
3124 return ERROR_INVALID_HANDLE
;
3126 /* increment progress bar each time action data is sent */
3127 ui_progress(package
,1,1,0,0);
3129 for (index
= 0; index
< package
->loaded_files
; index
++)
3131 WCHAR path_to_source
[MAX_PATH
];
3134 file
= &package
->files
[index
];
3136 if (file
->Temporary
)
3140 if (!ACTION_VerifyComponentForAction(package
, file
->ComponentIndex
,
3141 INSTALLSTATE_LOCAL
))
3143 ui_progress(package
,2,file
->FileSize
,0,0);
3144 TRACE("File %s is not scheduled for install\n",
3145 debugstr_w(file
->File
));
3150 if ((file
->State
== 1) || (file
->State
== 2))
3153 MSICOMPONENT
* comp
= NULL
;
3155 TRACE("Installing %s\n",debugstr_w(file
->File
));
3156 rc
= ready_media_for_file(package
, path_to_source
, file
);
3159 * our file table could change here because a new temp file
3160 * may have been created
3162 file
= &package
->files
[index
];
3163 if (rc
!= ERROR_SUCCESS
)
3165 ERR("Unable to ready media\n");
3166 rc
= ERROR_FUNCTION_FAILED
;
3170 create_component_directory( package
, file
->ComponentIndex
);
3172 /* recalculate file paths because things may have changed */
3174 if (file
->ComponentIndex
>= 0)
3175 comp
= &package
->components
[file
->ComponentIndex
];
3177 p
= resolve_folder(package
, comp
->Directory
, FALSE
, FALSE
, NULL
);
3178 HeapFree(GetProcessHeap(),0,file
->TargetPath
);
3180 file
->TargetPath
= build_directory_name(2, p
, file
->FileName
);
3181 HeapFree(GetProcessHeap(),0,p
);
3183 if (file
->Attributes
& msidbFileAttributesNoncompressed
)
3185 p
= resolve_folder(package
, comp
->Directory
, TRUE
, FALSE
, NULL
);
3186 file
->SourcePath
= build_directory_name(2, p
, file
->ShortName
);
3187 HeapFree(GetProcessHeap(),0,p
);
3190 file
->SourcePath
= build_directory_name(2, path_to_source
,
3194 TRACE("file paths %s to %s\n",debugstr_w(file
->SourcePath
),
3195 debugstr_w(file
->TargetPath
));
3198 uirow
=MSI_CreateRecord(9);
3199 MSI_RecordSetStringW(uirow
,1,file
->File
);
3200 strcpyW(uipath
,file
->TargetPath
);
3201 *(strrchrW(uipath
,'\\')+1)=0;
3202 MSI_RecordSetStringW(uirow
,9,uipath
);
3203 MSI_RecordSetInteger(uirow
,6,file
->FileSize
);
3204 ui_actiondata(package
,szInstallFiles
,uirow
);
3205 msiobj_release( &uirow
->hdr
);
3206 ui_progress(package
,2,file
->FileSize
,0,0);
3209 if (file
->Attributes
& msidbFileAttributesNoncompressed
)
3210 rc
= CopyFileW(file
->SourcePath
,file
->TargetPath
,FALSE
);
3212 rc
= MoveFileW(file
->SourcePath
, file
->TargetPath
);
3216 rc
= GetLastError();
3217 ERR("Unable to move/copy file (%s -> %s) (error %d)\n",
3218 debugstr_w(file
->SourcePath
), debugstr_w(file
->TargetPath
),
3220 if (rc
== ERROR_ALREADY_EXISTS
&& file
->State
== 2)
3222 if (!CopyFileW(file
->SourcePath
,file
->TargetPath
,FALSE
))
3223 ERR("Unable to copy file (%s -> %s) (error %ld)\n",
3224 debugstr_w(file
->SourcePath
),
3225 debugstr_w(file
->TargetPath
), GetLastError());
3226 if (!(file
->Attributes
& msidbFileAttributesNoncompressed
))
3227 DeleteFileW(file
->SourcePath
);
3230 else if (rc
== ERROR_FILE_NOT_FOUND
)
3232 ERR("Source File Not Found! Continuing\n");
3235 else if (file
->Attributes
& msidbFileAttributesVital
)
3237 ERR("Ignoring Error and continuing (nonvital file)...\n");
3252 inline static UINT
get_file_target(MSIPACKAGE
*package
, LPCWSTR file_key
,
3253 LPWSTR
* file_source
)
3258 return ERROR_INVALID_HANDLE
;
3260 for (index
= 0; index
< package
->loaded_files
; index
++)
3262 if (strcmpW(file_key
,package
->files
[index
].File
)==0)
3264 if (package
->files
[index
].State
>= 2)
3266 *file_source
= strdupW(package
->files
[index
].TargetPath
);
3267 return ERROR_SUCCESS
;
3270 return ERROR_FILE_NOT_FOUND
;
3274 return ERROR_FUNCTION_FAILED
;
3277 static UINT
ACTION_DuplicateFiles(MSIPACKAGE
*package
)
3281 MSIRECORD
* row
= 0;
3282 static const WCHAR ExecSeqQuery
[] =
3283 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3284 '`','D','u','p','l','i','c','a','t','e','F','i','l','e','`',0};
3287 return ERROR_INVALID_HANDLE
;
3289 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
3290 if (rc
!= ERROR_SUCCESS
)
3291 return ERROR_SUCCESS
;
3293 rc
= MSI_ViewExecute(view
, 0);
3294 if (rc
!= ERROR_SUCCESS
)
3296 MSI_ViewClose(view
);
3297 msiobj_release(&view
->hdr
);
3303 WCHAR file_key
[0x100];
3304 WCHAR
*file_source
= NULL
;
3305 WCHAR dest_name
[0x100];
3306 LPWSTR dest_path
, dest
;
3307 WCHAR component
[0x100];
3308 INT component_index
;
3312 rc
= MSI_ViewFetch(view
,&row
);
3313 if (rc
!= ERROR_SUCCESS
)
3320 rc
= MSI_RecordGetStringW(row
,2,component
,&sz
);
3321 if (rc
!= ERROR_SUCCESS
)
3323 ERR("Unable to get component\n");
3324 msiobj_release(&row
->hdr
);
3328 component_index
= get_loaded_component(package
,component
);
3330 if (!ACTION_VerifyComponentForAction(package
, component_index
,
3331 INSTALLSTATE_LOCAL
))
3333 TRACE("Skipping copy due to disabled component\n");
3335 /* the action taken was the same as the current install state */
3336 package
->components
[component_index
].Action
=
3337 package
->components
[component_index
].Installed
;
3339 msiobj_release(&row
->hdr
);
3343 package
->components
[component_index
].Action
= INSTALLSTATE_LOCAL
;
3346 rc
= MSI_RecordGetStringW(row
,3,file_key
,&sz
);
3347 if (rc
!= ERROR_SUCCESS
)
3349 ERR("Unable to get file key\n");
3350 msiobj_release(&row
->hdr
);
3354 rc
= get_file_target(package
,file_key
,&file_source
);
3356 if (rc
!= ERROR_SUCCESS
)
3358 ERR("Original file unknown %s\n",debugstr_w(file_key
));
3359 msiobj_release(&row
->hdr
);
3360 HeapFree(GetProcessHeap(),0,file_source
);
3364 if (MSI_RecordIsNull(row
,4))
3366 strcpyW(dest_name
,strrchrW(file_source
,'\\')+1);
3371 MSI_RecordGetStringW(row
,4,dest_name
,&sz
);
3372 reduce_to_longfilename(dest_name
);
3375 if (MSI_RecordIsNull(row
,5))
3378 dest_path
= strdupW(file_source
);
3379 p
= strrchrW(dest_path
,'\\');
3385 WCHAR destkey
[0x100];
3387 MSI_RecordGetStringW(row
,5,destkey
,&sz
);
3389 dest_path
= resolve_folder(package
, destkey
, FALSE
,FALSE
,NULL
);
3392 ERR("Unable to get destination folder\n");
3393 msiobj_release(&row
->hdr
);
3394 HeapFree(GetProcessHeap(),0,file_source
);
3399 dest
= build_directory_name(2, dest_path
, dest_name
);
3401 TRACE("Duplicating file %s to %s\n",debugstr_w(file_source
),
3404 if (strcmpW(file_source
,dest
))
3405 rc
= !CopyFileW(file_source
,dest
,TRUE
);
3409 if (rc
!= ERROR_SUCCESS
)
3410 ERR("Failed to copy file %s -> %s, last error %ld\n", debugstr_w(file_source
), debugstr_w(dest_path
), GetLastError());
3412 FIXME("We should track these duplicate files as well\n");
3414 msiobj_release(&row
->hdr
);
3415 HeapFree(GetProcessHeap(),0,dest_path
);
3416 HeapFree(GetProcessHeap(),0,dest
);
3417 HeapFree(GetProcessHeap(),0,file_source
);
3419 MSI_ViewClose(view
);
3420 msiobj_release(&view
->hdr
);
3425 /* OK this value is "interpreted" and then formatted based on the
3426 first few characters */
3427 static LPSTR
parse_value(MSIPACKAGE
*package
, WCHAR
*value
, DWORD
*type
,
3431 if (value
[0]=='#' && value
[1]!='#' && value
[1]!='%')
3437 LPWSTR deformated
= NULL
;
3440 deformat_string(package
, &value
[2], &deformated
);
3442 /* binary value type */
3446 *size
= (strlenW(ptr
)/2)+1;
3448 *size
= strlenW(ptr
)/2;
3450 data
= HeapAlloc(GetProcessHeap(),0,*size
);
3456 /* if uneven pad with a zero in front */
3462 data
[count
] = (BYTE
)strtol(byte
,NULL
,0);
3464 TRACE("Uneven byte count\n");
3472 data
[count
] = (BYTE
)strtol(byte
,NULL
,0);
3475 HeapFree(GetProcessHeap(),0,deformated
);
3477 TRACE("Data %li bytes(%i)\n",*size
,count
);
3484 deformat_string(package
, &value
[1], &deformated
);
3487 *size
= sizeof(DWORD
);
3488 data
= HeapAlloc(GetProcessHeap(),0,*size
);
3494 if ( (*p
< '0') || (*p
> '9') )
3500 if (deformated
[0] == '-')
3503 TRACE("DWORD %li\n",*(LPDWORD
)data
);
3505 HeapFree(GetProcessHeap(),0,deformated
);
3510 static const WCHAR szMulti
[] = {'[','~',']',0};
3519 *type
=REG_EXPAND_SZ
;
3527 if (strstrW(value
,szMulti
))
3528 *type
= REG_MULTI_SZ
;
3530 *size
= deformat_string(package
, ptr
,(LPWSTR
*)&data
);
3535 static UINT
ACTION_WriteRegistryValues(MSIPACKAGE
*package
)
3539 MSIRECORD
* row
= 0;
3540 static const WCHAR ExecSeqQuery
[] =
3541 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3542 '`','R','e','g','i','s','t','r','y','`',0 };
3545 return ERROR_INVALID_HANDLE
;
3547 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
3548 if (rc
!= ERROR_SUCCESS
)
3549 return ERROR_SUCCESS
;
3551 rc
= MSI_ViewExecute(view
, 0);
3552 if (rc
!= ERROR_SUCCESS
)
3554 MSI_ViewClose(view
);
3555 msiobj_release(&view
->hdr
);
3559 /* increment progress bar each time action data is sent */
3560 ui_progress(package
,1,REG_PROGRESS_VALUE
,1,0);
3564 static const WCHAR szHCR
[] =
3565 {'H','K','E','Y','_','C','L','A','S','S','E','S','_',
3566 'R','O','O','T','\\',0};
3567 static const WCHAR szHCU
[] =
3568 {'H','K','E','Y','_','C','U','R','R','E','N','T','_',
3569 'U','S','E','R','\\',0};
3570 static const WCHAR szHLM
[] =
3571 {'H','K','E','Y','_','L','O','C','A','L','_',
3572 'M','A','C','H','I','N','E','\\',0};
3573 static const WCHAR szHU
[] =
3574 {'H','K','E','Y','_','U','S','E','R','S','\\',0};
3576 LPSTR value_data
= NULL
;
3577 HKEY root_key
, hkey
;
3579 LPWSTR value
, key
, name
, component
, deformated
;
3581 INT component_index
;
3585 BOOL check_first
= FALSE
;
3587 rc
= MSI_ViewFetch(view
,&row
);
3588 if (rc
!= ERROR_SUCCESS
)
3593 ui_progress(package
,2,0,0,0);
3600 component
= load_dynamic_stringW(row
, 6);
3601 component_index
= get_loaded_component(package
,component
);
3603 if (!ACTION_VerifyComponentForAction(package
, component_index
,
3604 INSTALLSTATE_LOCAL
))
3606 TRACE("Skipping write due to disabled component\n");
3607 msiobj_release(&row
->hdr
);
3609 package
->components
[component_index
].Action
=
3610 package
->components
[component_index
].Installed
;
3615 package
->components
[component_index
].Action
= INSTALLSTATE_LOCAL
;
3617 name
= load_dynamic_stringW(row
, 4);
3618 if( MSI_RecordIsNull(row
,5) && name
)
3620 /* null values can have special meanings */
3621 if (name
[0]=='-' && name
[1] == 0)
3623 msiobj_release(&row
->hdr
);
3626 else if ((name
[0]=='+' && name
[1] == 0) ||
3627 (name
[0] == '*' && name
[1] == 0))
3629 HeapFree(GetProcessHeap(),0,name
);
3635 root
= MSI_RecordGetInteger(row
,2);
3636 key
= load_dynamic_stringW(row
, 3);
3639 /* get the root key */
3642 case 0: root_key
= HKEY_CLASSES_ROOT
;
3645 case 1: root_key
= HKEY_CURRENT_USER
;
3648 case 2: root_key
= HKEY_LOCAL_MACHINE
;
3651 case 3: root_key
= HKEY_USERS
;
3655 ERR("Unknown root %i\n",root
);
3662 msiobj_release(&row
->hdr
);
3666 deformat_string(package
, key
, &deformated
);
3667 size
= strlenW(deformated
) + strlenW(szRoot
) + 1;
3668 uikey
= HeapAlloc(GetProcessHeap(), 0, size
*sizeof(WCHAR
));
3669 strcpyW(uikey
,szRoot
);
3670 strcatW(uikey
,deformated
);
3672 if (RegCreateKeyW( root_key
, deformated
, &hkey
))
3674 ERR("Could not create key %s\n",debugstr_w(deformated
));
3675 msiobj_release(&row
->hdr
);
3676 HeapFree(GetProcessHeap(),0,deformated
);
3679 HeapFree(GetProcessHeap(),0,deformated
);
3681 value
= load_dynamic_stringW(row
,5);
3683 value_data
= parse_value(package
, value
, &type
, &size
);
3686 static const WCHAR szEmpty
[] = {0};
3687 value_data
= (LPSTR
)strdupW(szEmpty
);
3692 deformat_string(package
, name
, &deformated
);
3694 /* get the double nulls to terminate SZ_MULTI */
3695 if (type
== REG_MULTI_SZ
)
3696 size
+=sizeof(WCHAR
);
3700 TRACE("Setting value %s of %s\n",debugstr_w(deformated
),
3702 RegSetValueExW(hkey
, deformated
, 0, type
, value_data
, size
);
3707 rc
= RegQueryValueExW(hkey
, deformated
, NULL
, NULL
, NULL
, &sz
);
3708 if (rc
== ERROR_SUCCESS
|| rc
== ERROR_MORE_DATA
)
3710 TRACE("value %s of %s checked already exists\n",
3711 debugstr_w(deformated
), debugstr_w(uikey
));
3715 TRACE("Checked and setting value %s of %s\n",
3716 debugstr_w(deformated
), debugstr_w(uikey
));
3717 RegSetValueExW(hkey
, deformated
, 0, type
, value_data
, size
);
3721 uirow
= MSI_CreateRecord(3);
3722 MSI_RecordSetStringW(uirow
,2,deformated
);
3723 MSI_RecordSetStringW(uirow
,1,uikey
);
3726 MSI_RecordSetStringW(uirow
,3,(LPWSTR
)value_data
);
3728 MSI_RecordSetStringW(uirow
,3,value
);
3730 ui_actiondata(package
,szWriteRegistryValues
,uirow
);
3731 msiobj_release( &uirow
->hdr
);
3733 HeapFree(GetProcessHeap(),0,value_data
);
3734 HeapFree(GetProcessHeap(),0,value
);
3735 HeapFree(GetProcessHeap(),0,deformated
);
3737 msiobj_release(&row
->hdr
);
3740 HeapFree(GetProcessHeap(),0,uikey
);
3741 HeapFree(GetProcessHeap(),0,key
);
3742 HeapFree(GetProcessHeap(),0,name
);
3743 HeapFree(GetProcessHeap(),0,component
);
3745 MSI_ViewClose(view
);
3746 msiobj_release(&view
->hdr
);
3750 static UINT
ACTION_InstallInitialize(MSIPACKAGE
*package
)
3752 return ERROR_SUCCESS
;
3756 static UINT
ACTION_InstallValidate(MSIPACKAGE
*package
)
3760 static const WCHAR q1
[]=
3761 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
3762 '`','R','e','g','i','s','t','r','y','`',0};
3765 MSIRECORD
* row
= 0;
3768 TRACE(" InstallValidate \n");
3770 rc
= MSI_DatabaseOpenViewW(package
->db
, q1
, &view
);
3771 if (rc
!= ERROR_SUCCESS
)
3772 return ERROR_SUCCESS
;
3774 rc
= MSI_ViewExecute(view
, 0);
3775 if (rc
!= ERROR_SUCCESS
)
3777 MSI_ViewClose(view
);
3778 msiobj_release(&view
->hdr
);
3783 rc
= MSI_ViewFetch(view
,&row
);
3784 if (rc
!= ERROR_SUCCESS
)
3791 msiobj_release(&row
->hdr
);
3793 MSI_ViewClose(view
);
3794 msiobj_release(&view
->hdr
);
3796 total
= total
+ progress
* REG_PROGRESS_VALUE
;
3797 total
= total
+ package
->loaded_components
* COMPONENT_PROGRESS_VALUE
;
3798 for (i
=0; i
< package
->loaded_files
; i
++)
3799 total
+= package
->files
[i
].FileSize
;
3800 ui_progress(package
,0,total
,0,0);
3802 for(i
= 0; i
< package
->loaded_features
; i
++)
3804 MSIFEATURE
* feature
= &package
->features
[i
];
3805 TRACE("Feature: %s; Installed: %i; Action %i; Request %i\n",
3806 debugstr_w(feature
->Feature
), feature
->Installed
, feature
->Action
,
3807 feature
->ActionRequest
);
3810 return ERROR_SUCCESS
;
3813 static UINT
ACTION_LaunchConditions(MSIPACKAGE
*package
)
3816 MSIQUERY
* view
= NULL
;
3817 MSIRECORD
* row
= 0;
3818 static const WCHAR ExecSeqQuery
[] =
3819 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3820 '`','L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','`',0};
3821 static const WCHAR title
[]=
3822 {'I','n','s','t','a','l','l',' ','F','a', 'i','l','e','d',0};
3824 TRACE("Checking launch conditions\n");
3826 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
3827 if (rc
!= ERROR_SUCCESS
)
3828 return ERROR_SUCCESS
;
3830 rc
= MSI_ViewExecute(view
, 0);
3831 if (rc
!= ERROR_SUCCESS
)
3833 MSI_ViewClose(view
);
3834 msiobj_release(&view
->hdr
);
3839 while (rc
== ERROR_SUCCESS
)
3842 LPWSTR message
= NULL
;
3844 rc
= MSI_ViewFetch(view
,&row
);
3845 if (rc
!= ERROR_SUCCESS
)
3851 cond
= load_dynamic_stringW(row
,1);
3853 if (MSI_EvaluateConditionW(package
,cond
) != MSICONDITION_TRUE
)
3856 message
= load_dynamic_stringW(row
,2);
3857 deformat_string(package
,message
,&deformated
);
3858 MessageBoxW(NULL
,deformated
,title
,MB_OK
);
3859 HeapFree(GetProcessHeap(),0,message
);
3860 HeapFree(GetProcessHeap(),0,deformated
);
3861 rc
= ERROR_FUNCTION_FAILED
;
3863 HeapFree(GetProcessHeap(),0,cond
);
3864 msiobj_release(&row
->hdr
);
3866 MSI_ViewClose(view
);
3867 msiobj_release(&view
->hdr
);
3871 static LPWSTR
resolve_keypath( MSIPACKAGE
* package
, INT
3874 MSICOMPONENT
* cmp
= &package
->components
[component_index
];
3876 if (cmp
->KeyPath
[0]==0)
3878 LPWSTR p
= resolve_folder(package
,cmp
->Directory
,FALSE
,FALSE
,NULL
);
3881 if (cmp
->Attributes
& msidbComponentAttributesRegistryKeyPath
)
3884 MSIRECORD
* row
= 0;
3886 LPWSTR key
,deformated
,buffer
,name
,deformated_name
;
3887 static const WCHAR ExecSeqQuery
[] =
3888 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
3889 '`','R','e','g','i','s','t','r','y','`',' ',
3890 'W','H','E','R','E',' ', '`','R','e','g','i','s','t','r','y','`',
3891 ' ','=',' ' ,'\'','%','s','\'',0 };
3892 static const WCHAR fmt
[]={'%','0','2','i',':','\\','%','s','\\',0};
3893 static const WCHAR fmt2
[]=
3894 {'%','0','2','i',':','\\','%','s','\\','%','s',0};
3896 rc
= MSI_OpenQuery(package
->db
,&view
,ExecSeqQuery
,cmp
->KeyPath
);
3898 if (rc
!=ERROR_SUCCESS
)
3901 rc
= MSI_ViewExecute(view
, 0);
3902 if (rc
!= ERROR_SUCCESS
)
3904 MSI_ViewClose(view
);
3905 msiobj_release(&view
->hdr
);
3909 rc
= MSI_ViewFetch(view
,&row
);
3910 if (rc
!= ERROR_SUCCESS
)
3912 MSI_ViewClose(view
);
3913 msiobj_release(&view
->hdr
);
3917 root
= MSI_RecordGetInteger(row
,2);
3918 key
= load_dynamic_stringW(row
, 3);
3919 name
= load_dynamic_stringW(row
, 4);
3920 deformat_string(package
, key
, &deformated
);
3921 deformat_string(package
, name
, &deformated_name
);
3923 len
= strlenW(deformated
) + 6;
3924 if (deformated_name
)
3925 len
+=strlenW(deformated_name
);
3927 buffer
= HeapAlloc(GetProcessHeap(),0, len
*sizeof(WCHAR
));
3929 if (deformated_name
)
3930 sprintfW(buffer
,fmt2
,root
,deformated
,deformated_name
);
3932 sprintfW(buffer
,fmt
,root
,deformated
);
3934 HeapFree(GetProcessHeap(),0,key
);
3935 HeapFree(GetProcessHeap(),0,deformated
);
3936 HeapFree(GetProcessHeap(),0,name
);
3937 HeapFree(GetProcessHeap(),0,deformated_name
);
3938 msiobj_release(&row
->hdr
);
3939 MSI_ViewClose(view
);
3940 msiobj_release(&view
->hdr
);
3944 else if (cmp
->Attributes
& msidbComponentAttributesODBCDataSource
)
3946 FIXME("UNIMPLEMENTED keypath as ODBC Source\n");
3952 j
= get_loaded_file(package
,cmp
->KeyPath
);
3956 LPWSTR p
= strdupW(package
->files
[j
].TargetPath
);
3963 static HKEY
openSharedDLLsKey()
3966 static const WCHAR path
[] =
3967 {'S','o','f','t','w','a','r','e','\\',
3968 'M','i','c','r','o','s','o','f','t','\\',
3969 'W','i','n','d','o','w','s','\\',
3970 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3971 'S','h','a','r','e','d','D','L','L','s',0};
3973 RegCreateKeyW(HKEY_LOCAL_MACHINE
,path
,&hkey
);
3977 static UINT
ACTION_GetSharedDLLsCount(LPCWSTR dll
)
3982 DWORD sz
= sizeof(count
);
3985 hkey
= openSharedDLLsKey();
3986 rc
= RegQueryValueExW(hkey
, dll
, NULL
, &type
, (LPBYTE
)&count
, &sz
);
3987 if (rc
!= ERROR_SUCCESS
)
3993 static UINT
ACTION_WriteSharedDLLsCount(LPCWSTR path
, UINT count
)
3997 hkey
= openSharedDLLsKey();
3999 RegSetValueExW(hkey
,path
,0,REG_DWORD
,
4000 (LPBYTE
)&count
,sizeof(count
));
4002 RegDeleteValueW(hkey
,path
);
4008 * Return TRUE if the count should be written out and FALSE if not
4010 static void ACTION_RefCountComponent( MSIPACKAGE
* package
, UINT index
)
4016 /* only refcount DLLs */
4017 if (package
->components
[index
].KeyPath
[0]==0 ||
4018 package
->components
[index
].Attributes
&
4019 msidbComponentAttributesRegistryKeyPath
||
4020 package
->components
[index
].Attributes
&
4021 msidbComponentAttributesODBCDataSource
)
4025 count
= ACTION_GetSharedDLLsCount(package
->components
[index
].
4027 write
= (count
> 0);
4029 if (package
->components
[index
].Attributes
&
4030 msidbComponentAttributesSharedDllRefCount
)
4034 /* increment counts */
4035 for (j
= 0; j
< package
->loaded_features
; j
++)
4039 if (!ACTION_VerifyFeatureForAction(package
,j
,INSTALLSTATE_LOCAL
))
4042 for (i
= 0; i
< package
->features
[j
].ComponentCount
; i
++)
4044 if (package
->features
[j
].Components
[i
] == index
)
4048 /* decrement counts */
4049 for (j
= 0; j
< package
->loaded_features
; j
++)
4052 if (!ACTION_VerifyFeatureForAction(package
,j
,INSTALLSTATE_ABSENT
))
4055 for (i
= 0; i
< package
->features
[j
].ComponentCount
; i
++)
4057 if (package
->features
[j
].Components
[i
] == index
)
4062 /* ref count all the files in the component */
4064 for (j
= 0; j
< package
->loaded_files
; j
++)
4066 if (package
->files
[j
].Temporary
)
4068 if (package
->files
[j
].ComponentIndex
== index
)
4069 ACTION_WriteSharedDLLsCount(package
->files
[j
].TargetPath
,count
);
4072 /* add a count for permenent */
4073 if (package
->components
[index
].Attributes
&
4074 msidbComponentAttributesPermanent
)
4077 package
->components
[index
].RefCount
= count
;
4080 ACTION_WriteSharedDLLsCount(package
->components
[index
].FullKeypath
,
4081 package
->components
[index
].RefCount
);
4085 * Ok further analysis makes me think that this work is
4086 * actually done in the PublishComponents and PublishFeatures
4087 * step, and not here. It appears like the keypath and all that is
4088 * resolved in this step, however actually written in the Publish steps.
4089 * But we will leave it here for now because it is unclear
4091 static UINT
ACTION_ProcessComponents(MSIPACKAGE
*package
)
4094 WCHAR squished_pc
[GUID_SIZE
];
4095 WCHAR squished_cc
[GUID_SIZE
];
4098 HKEY hkey
=0,hkey2
=0;
4101 return ERROR_INVALID_HANDLE
;
4103 /* writes the Component and Features values to the registry */
4104 productcode
= load_dynamic_property(package
,szProductCode
,&rc
);
4108 rc
= MSIREG_OpenComponents(&hkey
);
4109 if (rc
!= ERROR_SUCCESS
)
4112 squash_guid(productcode
,squished_pc
);
4113 ui_progress(package
,1,COMPONENT_PROGRESS_VALUE
,1,0);
4114 for (i
= 0; i
< package
->loaded_components
; i
++)
4116 ui_progress(package
,2,0,0,0);
4117 if (package
->components
[i
].ComponentId
[0]!=0)
4119 WCHAR
*keypath
= NULL
;
4122 squash_guid(package
->components
[i
].ComponentId
,squished_cc
);
4124 keypath
= resolve_keypath(package
,i
);
4125 package
->components
[i
].FullKeypath
= keypath
;
4127 /* do the refcounting */
4128 ACTION_RefCountComponent( package
, i
);
4130 TRACE("Component %s (%s), Keypath=%s, RefCount=%i\n",
4131 debugstr_w(package
->components
[i
].Component
),
4132 debugstr_w(squished_cc
),
4133 debugstr_w(package
->components
[i
].FullKeypath
),
4134 package
->components
[i
].RefCount
);
4136 * Write the keypath out if the component is to be registered
4137 * and delete the key if the component is to be deregistered
4139 if (ACTION_VerifyComponentForAction(package
, i
,
4140 INSTALLSTATE_LOCAL
))
4142 rc
= RegCreateKeyW(hkey
,squished_cc
,&hkey2
);
4143 if (rc
!= ERROR_SUCCESS
)
4148 RegSetValueExW(hkey2
,squished_pc
,0,REG_SZ
,(LPVOID
)keypath
,
4149 (strlenW(keypath
)+1)*sizeof(WCHAR
));
4151 if (package
->components
[i
].Attributes
&
4152 msidbComponentAttributesPermanent
)
4154 static const WCHAR szPermKey
[] =
4155 { '0','0','0','0','0','0','0','0','0','0','0','0',
4156 '0','0','0','0','0','0','0', '0','0','0','0','0',
4157 '0','0','0','0','0','0','0','0',0};
4159 RegSetValueExW(hkey2
,szPermKey
,0,REG_SZ
,
4161 (strlenW(keypath
)+1)*sizeof(WCHAR
));
4167 uirow
= MSI_CreateRecord(3);
4168 MSI_RecordSetStringW(uirow
,1,productcode
);
4169 MSI_RecordSetStringW(uirow
,2,package
->components
[i
].
4171 MSI_RecordSetStringW(uirow
,3,keypath
);
4172 ui_actiondata(package
,szProcessComponents
,uirow
);
4173 msiobj_release( &uirow
->hdr
);
4176 else if (ACTION_VerifyComponentForAction(package
, i
,
4177 INSTALLSTATE_ABSENT
))
4181 rc
= RegOpenKeyW(hkey
,squished_cc
,&hkey2
);
4182 if (rc
!= ERROR_SUCCESS
)
4185 RegDeleteValueW(hkey2
,squished_pc
);
4187 /* if the key is empty delete it */
4188 res
= RegEnumKeyExW(hkey2
,0,NULL
,0,0,NULL
,0,NULL
);
4190 if (res
== ERROR_NO_MORE_ITEMS
)
4191 RegDeleteKeyW(hkey
,squished_cc
);
4194 uirow
= MSI_CreateRecord(2);
4195 MSI_RecordSetStringW(uirow
,1,productcode
);
4196 MSI_RecordSetStringW(uirow
,2,package
->components
[i
].
4198 ui_actiondata(package
,szProcessComponents
,uirow
);
4199 msiobj_release( &uirow
->hdr
);
4204 HeapFree(GetProcessHeap(), 0, productcode
);
4217 BOOL CALLBACK
Typelib_EnumResNameProc( HMODULE hModule
, LPCWSTR lpszType
,
4218 LPWSTR lpszName
, LONG_PTR lParam
)
4221 typelib_struct
*tl_struct
= (typelib_struct
*) lParam
;
4222 static const WCHAR fmt
[] = {'%','s','\\','%','i',0};
4226 if (!IS_INTRESOURCE(lpszName
))
4228 ERR("Not Int Resource Name %s\n",debugstr_w(lpszName
));
4232 sz
= strlenW(tl_struct
->source
)+4;
4233 sz
*= sizeof(WCHAR
);
4235 tl_struct
->path
= HeapAlloc(GetProcessHeap(),0,sz
);
4236 sprintfW(tl_struct
->path
,fmt
,tl_struct
->source
, lpszName
);
4238 TRACE("trying %s\n", debugstr_w(tl_struct
->path
));
4239 res
= LoadTypeLib(tl_struct
->path
,&tl_struct
->ptLib
);
4240 if (!SUCCEEDED(res
))
4242 HeapFree(GetProcessHeap(),0,tl_struct
->path
);
4243 tl_struct
->path
= NULL
;
4248 ITypeLib_GetLibAttr(tl_struct
->ptLib
, &attr
);
4249 if (IsEqualGUID(&(tl_struct
->clsid
),&(attr
->guid
)))
4251 ITypeLib_ReleaseTLibAttr(tl_struct
->ptLib
, attr
);
4255 HeapFree(GetProcessHeap(),0,tl_struct
->path
);
4256 tl_struct
->path
= NULL
;
4258 ITypeLib_ReleaseTLibAttr(tl_struct
->ptLib
, attr
);
4259 ITypeLib_Release(tl_struct
->ptLib
);
4264 static UINT
ACTION_RegisterTypeLibraries(MSIPACKAGE
*package
)
4267 * OK this is a bit confusing.. I am given a _Component key and I believe
4268 * that the file that is being registered as a type library is the "key file
4269 * of that component" which I interpret to mean "The file in the KeyPath of
4274 MSIRECORD
* row
= 0;
4275 static const WCHAR Query
[] =
4276 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
4277 '`','T','y','p','e','L','i','b','`',0};
4280 return ERROR_INVALID_HANDLE
;
4282 rc
= MSI_DatabaseOpenViewW(package
->db
, Query
, &view
);
4283 if (rc
!= ERROR_SUCCESS
)
4284 return ERROR_SUCCESS
;
4286 rc
= MSI_ViewExecute(view
, 0);
4287 if (rc
!= ERROR_SUCCESS
)
4289 MSI_ViewClose(view
);
4290 msiobj_release(&view
->hdr
);
4296 WCHAR component
[0x100];
4300 typelib_struct tl_struct
;
4302 static const WCHAR szTYPELIB
[] = {'T','Y','P','E','L','I','B',0};
4304 rc
= MSI_ViewFetch(view
,&row
);
4305 if (rc
!= ERROR_SUCCESS
)
4312 MSI_RecordGetStringW(row
,3,component
,&sz
);
4314 index
= get_loaded_component(package
,component
);
4317 msiobj_release(&row
->hdr
);
4321 if (!ACTION_VerifyComponentForAction(package
, index
,
4322 INSTALLSTATE_LOCAL
))
4324 TRACE("Skipping typelib reg due to disabled component\n");
4325 msiobj_release(&row
->hdr
);
4327 package
->components
[index
].Action
=
4328 package
->components
[index
].Installed
;
4333 package
->components
[index
].Action
= INSTALLSTATE_LOCAL
;
4335 index
= get_loaded_file(package
,package
->components
[index
].KeyPath
);
4339 msiobj_release(&row
->hdr
);
4343 guid
= load_dynamic_stringW(row
,1);
4344 module
= LoadLibraryExW(package
->files
[index
].TargetPath
, NULL
,
4345 LOAD_LIBRARY_AS_DATAFILE
);
4348 CLSIDFromString(guid
, &tl_struct
.clsid
);
4349 tl_struct
.source
= strdupW(package
->files
[index
].TargetPath
);
4350 tl_struct
.path
= NULL
;
4352 EnumResourceNamesW(module
, szTYPELIB
, Typelib_EnumResNameProc
,
4353 (LONG_PTR
)&tl_struct
);
4355 if (tl_struct
.path
!= NULL
)
4358 WCHAR helpid
[0x100];
4362 MSI_RecordGetStringW(row
,6,helpid
,&sz
);
4364 help
= resolve_folder(package
,helpid
,FALSE
,FALSE
,NULL
);
4365 res
= RegisterTypeLib(tl_struct
.ptLib
,tl_struct
.path
,help
);
4366 HeapFree(GetProcessHeap(),0,help
);
4368 if (!SUCCEEDED(res
))
4369 ERR("Failed to register type library %s\n",
4370 debugstr_w(tl_struct
.path
));
4373 ui_actiondata(package
,szRegisterTypeLibraries
,row
);
4375 TRACE("Registered %s\n", debugstr_w(tl_struct
.path
));
4378 ITypeLib_Release(tl_struct
.ptLib
);
4379 HeapFree(GetProcessHeap(),0,tl_struct
.path
);
4382 ERR("Failed to load type library %s\n",
4383 debugstr_w(tl_struct
.source
));
4385 FreeLibrary(module
);
4386 HeapFree(GetProcessHeap(),0,tl_struct
.source
);
4389 ERR("Could not load file! %s\n",
4390 debugstr_w(package
->files
[index
].TargetPath
));
4391 msiobj_release(&row
->hdr
);
4393 MSI_ViewClose(view
);
4394 msiobj_release(&view
->hdr
);
4398 static UINT
register_appid(MSIPACKAGE
*package
, LPCWSTR clsid
, LPCWSTR app
)
4400 static const WCHAR szAppID
[] = { 'A','p','p','I','D',0 };
4403 MSIRECORD
* row
= 0;
4404 static const WCHAR ExecSeqQuery
[] =
4405 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
4406 '`','A','p','p','I' ,'d','`',' ','W','H','E','R','E',' ',
4407 '`','A','p','p','I','d','`',' ','=','\'','%','s','\'',0};
4412 return ERROR_INVALID_HANDLE
;
4414 rc
= MSI_OpenQuery(package
->db
, &view
, ExecSeqQuery
, clsid
);
4415 if (rc
!= ERROR_SUCCESS
)
4418 rc
= MSI_ViewExecute(view
, 0);
4419 if (rc
!= ERROR_SUCCESS
)
4421 MSI_ViewClose(view
);
4422 msiobj_release(&view
->hdr
);
4426 RegCreateKeyW(HKEY_CLASSES_ROOT
,szAppID
,&hkey2
);
4427 RegCreateKeyW(hkey2
,clsid
,&hkey3
);
4428 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
,(LPVOID
)app
,
4429 (strlenW(app
)+1)*sizeof(WCHAR
));
4431 rc
= MSI_ViewFetch(view
,&row
);
4432 if (rc
!= ERROR_SUCCESS
)
4434 MSI_ViewClose(view
);
4435 msiobj_release(&view
->hdr
);
4439 if (!MSI_RecordIsNull(row
,2))
4441 LPWSTR deformated
=0;
4443 static const WCHAR szRemoteServerName
[] =
4444 {'R','e','m','o','t','e','S','e','r','v','e','r','N','a','m','e',
4446 buffer
= load_dynamic_stringW(row
,2);
4447 size
= deformat_string(package
,buffer
,&deformated
);
4448 RegSetValueExW(hkey3
,szRemoteServerName
,0,REG_SZ
,(LPVOID
)deformated
,
4450 HeapFree(GetProcessHeap(),0,deformated
);
4451 HeapFree(GetProcessHeap(),0,buffer
);
4454 if (!MSI_RecordIsNull(row
,3))
4456 static const WCHAR szLocalService
[] =
4457 {'L','o','c','a','l','S','e','r','v','i','c','e',0};
4459 buffer
= load_dynamic_stringW(row
,3);
4460 size
= (strlenW(buffer
)+1) * sizeof(WCHAR
);
4461 RegSetValueExW(hkey3
,szLocalService
,0,REG_SZ
,(LPVOID
)buffer
,size
);
4462 HeapFree(GetProcessHeap(),0,buffer
);
4465 if (!MSI_RecordIsNull(row
,4))
4467 static const WCHAR szService
[] =
4468 {'S','e','r','v','i','c','e',
4469 'P','a','r','a','m','e','t','e','r','s',0};
4471 buffer
= load_dynamic_stringW(row
,4);
4472 size
= (strlenW(buffer
)+1) * sizeof(WCHAR
);
4473 RegSetValueExW(hkey3
,szService
,0,REG_SZ
,(LPVOID
)buffer
,size
);
4474 HeapFree(GetProcessHeap(),0,buffer
);
4477 if (!MSI_RecordIsNull(row
,5))
4479 static const WCHAR szDLL
[] =
4480 {'D','l','l','S','u','r','r','o','g','a','t','e',0};
4482 buffer
= load_dynamic_stringW(row
,5);
4483 size
= (strlenW(buffer
)+1) * sizeof(WCHAR
);
4484 RegSetValueExW(hkey3
,szDLL
,0,REG_SZ
,(LPVOID
)buffer
,size
);
4485 HeapFree(GetProcessHeap(),0,buffer
);
4488 if (!MSI_RecordIsNull(row
,6))
4490 static const WCHAR szActivate
[] =
4491 {'A','c','t','i','v','a','t','e','A','s',
4492 'S','t','o','r','a','g','e',0};
4493 static const WCHAR szY
[] = {'Y',0};
4495 if (MSI_RecordGetInteger(row
,6))
4496 RegSetValueExW(hkey3
,szActivate
,0,REG_SZ
,(LPVOID
)szY
,4);
4499 if (!MSI_RecordIsNull(row
,7))
4501 static const WCHAR szRunAs
[] = {'R','u','n','A','s',0};
4502 static const WCHAR szUser
[] =
4503 {'I','n','t','e','r','a','c','t','i','v','e',' ',
4506 if (MSI_RecordGetInteger(row
,7))
4507 RegSetValueExW(hkey3
,szRunAs
,0,REG_SZ
,(LPVOID
)szUser
,34);
4510 msiobj_release(&row
->hdr
);
4511 MSI_ViewClose(view
);
4512 msiobj_release(&view
->hdr
);
4518 static UINT
ACTION_RegisterClassInfo(MSIPACKAGE
*package
)
4521 * Again I am assuming the words, "Whose key file represents" when referring
4522 * to a Component as to meaning that Components KeyPath file
4524 * Also there is a very strong connection between ClassInfo and ProgID
4525 * that I am mostly glossing over.
4526 * What would be more propper is to load the ClassInfo and the ProgID info
4527 * into memory data structures and then be able to enable and disable them
4528 * based on component.
4533 MSIRECORD
* row
= 0;
4534 static const WCHAR ExecSeqQuery
[] =
4535 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
4536 '`','C','l','a','s','s','`',0};
4537 static const WCHAR szCLSID
[] = { 'C','L','S','I','D',0 };
4538 static const WCHAR szProgID
[] = { 'P','r','o','g','I','D',0 };
4539 static const WCHAR szAppID
[] = { 'A','p','p','I','D',0 };
4540 static const WCHAR szSpace
[] = {' ',0};
4541 HKEY hkey
,hkey2
,hkey3
;
4542 LPWSTR argument
,deformated
;
4545 return ERROR_INVALID_HANDLE
;
4547 rc
= RegCreateKeyW(HKEY_CLASSES_ROOT
,szCLSID
,&hkey
);
4548 if (rc
!= ERROR_SUCCESS
)
4549 return ERROR_FUNCTION_FAILED
;
4551 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
4552 if (rc
!= ERROR_SUCCESS
)
4558 rc
= MSI_ViewExecute(view
, 0);
4559 if (rc
!= ERROR_SUCCESS
)
4561 MSI_ViewClose(view
);
4562 msiobj_release(&view
->hdr
);
4569 WCHAR buffer
[0x100];
4575 rc
= MSI_ViewFetch(view
,&row
);
4576 if (rc
!= ERROR_SUCCESS
)
4583 MSI_RecordGetStringW(row
,3,buffer
,&sz
);
4585 index
= get_loaded_component(package
,buffer
);
4589 msiobj_release(&row
->hdr
);
4593 if ((!ACTION_VerifyComponentForAction(package
, index
,
4594 INSTALLSTATE_LOCAL
)) &&
4595 (!ACTION_VerifyComponentForAction(package
, index
,
4596 INSTALLSTATE_ADVERTISED
)))
4598 TRACE("Skipping class reg due to disabled component\n");
4599 msiobj_release(&row
->hdr
);
4601 package
->components
[index
].Action
=
4602 package
->components
[index
].Installed
;
4607 package
->components
[index
].Action
= INSTALLSTATE_LOCAL
;
4610 MSI_RecordGetStringW(row
,1,clsid
,&sz
);
4611 RegCreateKeyW(hkey
,clsid
,&hkey2
);
4613 if (!MSI_RecordIsNull(row
,5))
4616 MSI_RecordGetStringW(row
,5,desc
,&sz
);
4618 RegSetValueExW(hkey2
,NULL
,0,REG_SZ
,(LPVOID
)desc
,
4619 (strlenW(desc
)+1)*sizeof(WCHAR
));
4625 MSI_RecordGetStringW(row
,2,buffer
,&sz
);
4627 RegCreateKeyW(hkey2
,buffer
,&hkey3
);
4629 index
= get_loaded_file(package
,package
->components
[index
].KeyPath
);
4631 argument
= load_dynamic_stringW(row
,11);
4632 size
= deformat_string(package
,argument
,&deformated
);
4634 size
+=sizeof(WCHAR
);
4635 HeapFree(GetProcessHeap(),0,argument
);
4636 size
+= (strlenW(package
->files
[index
].TargetPath
))*sizeof(WCHAR
);
4638 argument
= HeapAlloc(GetProcessHeap(),0,size
+sizeof(WCHAR
));
4639 strcpyW(argument
,package
->files
[index
].TargetPath
);
4642 strcatW(argument
,szSpace
);
4643 strcatW(argument
,deformated
);
4646 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
, (LPVOID
)argument
, size
);
4647 HeapFree(GetProcessHeap(),0,deformated
);
4648 HeapFree(GetProcessHeap(),0,argument
);
4652 if (!MSI_RecordIsNull(row
,4))
4655 MSI_RecordGetStringW(row
,4,buffer
,&sz
);
4657 RegCreateKeyW(hkey2
,szProgID
,&hkey3
);
4659 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
,(LPVOID
)buffer
,
4660 (strlenW(buffer
)+1)*sizeof(WCHAR
));
4665 if (!MSI_RecordIsNull(row
,6))
4668 MSI_RecordGetStringW(row
,6,buffer
,&sz
);
4670 RegSetValueExW(hkey2
,szAppID
,0,REG_SZ
,(LPVOID
)buffer
,
4671 (strlenW(buffer
)+1)*sizeof(WCHAR
));
4673 register_appid(package
,buffer
,desc
);
4677 if (!MSI_RecordIsNull(row
,7))
4679 FIXME("Process field 7\n");
4682 if (!MSI_RecordIsNull(row
,8))
4684 static const WCHAR szDefaultIcon
[] =
4685 {'D','e','f','a','u','l','t','I','c','o','n',0};
4687 LPWSTR FileName
= load_dynamic_stringW(row
,8);
4691 RegCreateKeyW(hkey2
,szDefaultIcon
,&hkey3
);
4692 build_icon_path(package
,FileName
,&FilePath
);
4693 if (!MSI_RecordIsNull(row
,9))
4695 static const WCHAR index_fmt
[] = {',','%','i',0};
4696 WCHAR index_buf
[20];
4697 index
= MSI_RecordGetInteger(row
,9);
4698 sprintfW(index_buf
,index_fmt
,index
);
4699 size
= strlenW(FilePath
)+strlenW(index_buf
)+1;
4700 size
*= sizeof(WCHAR
);
4701 HeapReAlloc(GetProcessHeap(),0,FilePath
,size
);
4703 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
,(LPVOID
)FilePath
,
4704 (strlenW(FilePath
)+1) * sizeof(WCHAR
));
4705 HeapFree(GetProcessHeap(),0,FilePath
);
4706 HeapFree(GetProcessHeap(),0,FileName
);
4710 if (!MSI_RecordIsNull(row
,10))
4712 static const WCHAR szInproc32
[] =
4713 {'I','n','p','r','o','c','H','a','n','d','l','e','r','3','2',
4715 static const WCHAR szInproc
[] =
4716 {'I','n','p','r','o','c','H','a','n','d','l','e','r',0};
4717 INT i
= MSI_RecordGetInteger(row
,10);
4718 if (i
!= MSI_NULL_INTEGER
&& i
> 0 && i
< 4)
4720 static const WCHAR ole2
[] = {'o','l','e','2','.','d','l','l',0};
4721 static const WCHAR ole32
[] =
4722 {'o','l','e','3','2','.','d','l','l',0};
4726 size
= strlenW(ole2
) * sizeof(WCHAR
);
4727 RegCreateKeyW(hkey2
,szInproc
,&hkey3
);
4728 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
, (LPVOID
)ole2
, size
);
4732 size
= strlenW(ole32
) * sizeof(WCHAR
);
4733 RegCreateKeyW(hkey2
,szInproc32
,&hkey3
);
4734 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
, (LPVOID
)ole32
,size
);
4738 size
= strlenW(ole2
) * sizeof(WCHAR
);
4739 RegCreateKeyW(hkey2
,szInproc
,&hkey3
);
4740 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
, (LPVOID
)ole2
, size
);
4742 size
= strlenW(ole32
) * sizeof(WCHAR
);
4743 RegCreateKeyW(hkey2
,szInproc32
,&hkey3
);
4744 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
, (LPVOID
)ole32
,size
);
4752 RegCreateKeyW(hkey2
,szInproc32
,&hkey3
);
4753 argument
= load_dynamic_stringW(row
,10);
4754 reduce_to_longfilename(argument
);
4755 size
= strlenW(argument
)*sizeof(WCHAR
);
4757 RegSetValueExW(hkey3
,NULL
,0,REG_SZ
, (LPVOID
)argument
, size
);
4758 HeapFree(GetProcessHeap(),0,argument
);
4766 ui_actiondata(package
,szRegisterClassInfo
,row
);
4768 msiobj_release(&row
->hdr
);
4770 MSI_ViewClose(view
);
4771 msiobj_release(&view
->hdr
);
4778 static UINT
register_progid_base(MSIPACKAGE
* package
, MSIRECORD
* row
,
4781 static const WCHAR szCLSID
[] = { 'C','L','S','I','D',0 };
4782 static const WCHAR szDefaultIcon
[] =
4783 {'D','e','f','a','u','l','t','I','c','o','n',0};
4785 WCHAR buffer
[0x100];
4790 MSI_RecordGetStringW(row
,1,buffer
,&sz
);
4791 RegCreateKeyW(HKEY_CLASSES_ROOT
,buffer
,&hkey
);
4793 if (!MSI_RecordIsNull(row
,4))
4796 MSI_RecordGetStringW(row
,4,buffer
,&sz
);
4797 RegSetValueExW(hkey
,NULL
,0,REG_SZ
,(LPVOID
)buffer
, (strlenW(buffer
)+1) *
4801 if (!MSI_RecordIsNull(row
,3))
4805 MSI_RecordGetStringW(row
,3,buffer
,&sz
);
4806 RegCreateKeyW(hkey
,szCLSID
,&hkey2
);
4807 RegSetValueExW(hkey2
,NULL
,0,REG_SZ
,(LPVOID
)buffer
, (strlenW(buffer
)+1) *
4811 strcpyW(clsid
,buffer
);
4817 FIXME("UNHANDLED case, Parent progid but classid is NULL\n");
4818 return ERROR_FUNCTION_FAILED
;
4820 if (!MSI_RecordIsNull(row
,5))
4822 INT index
= MSI_RecordGetInteger(row
,6);
4823 LPWSTR FileName
= load_dynamic_stringW(row
,5);
4824 LPWSTR FilePath
,IconPath
;
4825 static const WCHAR fmt
[] = {'%','s',',','%','i',0};
4827 RegCreateKeyW(hkey
,szDefaultIcon
,&hkey2
);
4828 build_icon_path(package
,FileName
,&FilePath
);
4830 IconPath
= HeapAlloc(GetProcessHeap(),0,(strlenW(FilePath
)+5)*
4833 sprintfW(IconPath
,fmt
,FilePath
,index
);
4834 RegSetValueExW(hkey2
,NULL
,0,REG_SZ
,(LPVOID
)IconPath
,
4835 (strlenW(IconPath
)+1) * sizeof(WCHAR
));
4836 HeapFree(GetProcessHeap(),0,FilePath
);
4837 HeapFree(GetProcessHeap(),0,FileName
);
4840 return ERROR_SUCCESS
;
4843 static UINT
register_progid(MSIPACKAGE
*package
, MSIRECORD
* row
, LPWSTR clsid
);
4845 static UINT
register_parent_progid(MSIPACKAGE
*package
, LPCWSTR parent
,
4850 MSIRECORD
* row
= 0;
4851 static const WCHAR Query_t
[] =
4852 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
4853 '`','P','r','o','g' ,'I','d','`',' ','W','H','E','R','E',' ',
4854 '`','P','r','o','g','I','d','`',' ','=',' ','\'' ,'%','s','\'',0};
4857 return ERROR_INVALID_HANDLE
;
4859 rc
= MSI_OpenQuery(package
->db
, &view
, Query_t
, parent
);
4860 if (rc
!= ERROR_SUCCESS
)
4863 rc
= MSI_ViewExecute(view
, 0);
4864 if (rc
!= ERROR_SUCCESS
)
4866 MSI_ViewClose(view
);
4867 msiobj_release(&view
->hdr
);
4871 rc
= MSI_ViewFetch(view
,&row
);
4872 if (rc
!= ERROR_SUCCESS
)
4874 MSI_ViewClose(view
);
4875 msiobj_release(&view
->hdr
);
4879 register_progid(package
,row
,clsid
);
4881 msiobj_release(&row
->hdr
);
4882 MSI_ViewClose(view
);
4883 msiobj_release(&view
->hdr
);
4887 static UINT
register_progid(MSIPACKAGE
*package
, MSIRECORD
* row
, LPWSTR clsid
)
4889 UINT rc
= ERROR_SUCCESS
;
4891 if (MSI_RecordIsNull(row
,2))
4892 rc
= register_progid_base(package
,row
,clsid
);
4895 WCHAR buffer
[0x1000];
4898 static const WCHAR szCLSID
[] = { 'C','L','S','I','D',0 };
4899 static const WCHAR szDefaultIcon
[] =
4900 {'D','e','f','a','u','l','t','I','c','o','n',0};
4902 /* check if already registered */
4904 MSI_RecordGetStringW(row
,1,buffer
,&sz
);
4905 RegCreateKeyExW(HKEY_CLASSES_ROOT
, buffer
, 0, NULL
, 0,
4906 KEY_ALL_ACCESS
, NULL
, &hkey
, &disp
);
4907 if (disp
== REG_OPENED_EXISTING_KEY
)
4909 TRACE("Key already registered\n");
4915 MSI_RecordGetStringW(row
,2,buffer
,&sz
);
4916 rc
= register_parent_progid(package
,buffer
,clsid
);
4918 /* clsid is same as parent */
4919 RegCreateKeyW(hkey
,szCLSID
,&hkey2
);
4920 RegSetValueExW(hkey2
,NULL
,0,REG_SZ
,(LPVOID
)clsid
, (strlenW(clsid
)+1) *
4926 if (!MSI_RecordIsNull(row
,4))
4929 MSI_RecordGetStringW(row
,4,buffer
,&sz
);
4930 RegSetValueExW(hkey
,NULL
,0,REG_SZ
,(LPVOID
)buffer
,
4931 (strlenW(buffer
)+1) * sizeof(WCHAR
));
4934 if (!MSI_RecordIsNull(row
,5))
4936 LPWSTR FileName
= load_dynamic_stringW(row
,5);
4938 RegCreateKeyW(hkey
,szDefaultIcon
,&hkey2
);
4939 build_icon_path(package
,FileName
,&FilePath
);
4940 RegSetValueExW(hkey2
,NULL
,0,REG_SZ
,(LPVOID
)FilePath
,
4941 (strlenW(FilePath
)+1) * sizeof(WCHAR
));
4942 HeapFree(GetProcessHeap(),0,FilePath
);
4943 HeapFree(GetProcessHeap(),0,FileName
);
4952 static UINT
ACTION_RegisterProgIdInfo(MSIPACKAGE
*package
)
4955 * Sigh, here I am just brute force registering all progids
4956 * this needs to be linked to the Classes that have been registered
4957 * but the easiest way to do that is to load all these stuff into
4958 * memory for easy checking.
4960 * Gives me something to continue to work toward.
4964 MSIRECORD
* row
= 0;
4965 static const WCHAR Query
[] =
4966 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
4967 '`','P','r','o','g','I','d','`',0};
4970 return ERROR_INVALID_HANDLE
;
4972 rc
= MSI_DatabaseOpenViewW(package
->db
, Query
, &view
);
4973 if (rc
!= ERROR_SUCCESS
)
4974 return ERROR_SUCCESS
;
4976 rc
= MSI_ViewExecute(view
, 0);
4977 if (rc
!= ERROR_SUCCESS
)
4979 MSI_ViewClose(view
);
4980 msiobj_release(&view
->hdr
);
4986 WCHAR clsid
[0x1000];
4988 rc
= MSI_ViewFetch(view
,&row
);
4989 if (rc
!= ERROR_SUCCESS
)
4995 register_progid(package
,row
,clsid
);
4996 ui_actiondata(package
,szRegisterProgIdInfo
,row
);
4998 msiobj_release(&row
->hdr
);
5000 MSI_ViewClose(view
);
5001 msiobj_release(&view
->hdr
);
5005 static UINT
build_icon_path(MSIPACKAGE
*package
, LPCWSTR icon_name
,
5009 LPWSTR SystemFolder
;
5013 static const WCHAR szInstaller
[] =
5014 {'I','n','s','t','a','l','l','e','r','\\',0};
5015 static const WCHAR szFolder
[] =
5016 {'W','i','n','d','o','w','s','F','o','l','d','e','r',0};
5018 ProductCode
= load_dynamic_property(package
,szProductCode
,&rc
);
5022 SystemFolder
= load_dynamic_property(package
,szFolder
,NULL
);
5024 dest
= build_directory_name(3, SystemFolder
, szInstaller
, ProductCode
);
5026 create_full_pathW(dest
);
5028 *FilePath
= build_directory_name(2, dest
, icon_name
);
5030 HeapFree(GetProcessHeap(),0,SystemFolder
);
5031 HeapFree(GetProcessHeap(),0,ProductCode
);
5032 HeapFree(GetProcessHeap(),0,dest
);
5033 return ERROR_SUCCESS
;
5036 static UINT
ACTION_CreateShortcuts(MSIPACKAGE
*package
)
5040 MSIRECORD
* row
= 0;
5041 static const WCHAR Query
[] =
5042 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
5043 '`','S','h','o','r','t','c','u','t','`',0};
5049 return ERROR_INVALID_HANDLE
;
5051 res
= CoInitialize( NULL
);
5054 ERR("CoInitialize failed\n");
5055 return ERROR_FUNCTION_FAILED
;
5058 rc
= MSI_DatabaseOpenViewW(package
->db
, Query
, &view
);
5059 if (rc
!= ERROR_SUCCESS
)
5060 return ERROR_SUCCESS
;
5062 rc
= MSI_ViewExecute(view
, 0);
5063 if (rc
!= ERROR_SUCCESS
)
5065 MSI_ViewClose(view
);
5066 msiobj_release(&view
->hdr
);
5072 LPWSTR target_file
, target_folder
;
5073 WCHAR buffer
[0x100];
5076 static const WCHAR szlnk
[]={'.','l','n','k',0};
5078 rc
= MSI_ViewFetch(view
,&row
);
5079 if (rc
!= ERROR_SUCCESS
)
5086 MSI_RecordGetStringW(row
,4,buffer
,&sz
);
5088 index
= get_loaded_component(package
,buffer
);
5092 msiobj_release(&row
->hdr
);
5096 if (!ACTION_VerifyComponentForAction(package
, index
,
5097 INSTALLSTATE_LOCAL
))
5099 TRACE("Skipping shortcut creation due to disabled component\n");
5100 msiobj_release(&row
->hdr
);
5102 package
->components
[index
].Action
=
5103 package
->components
[index
].Installed
;
5108 package
->components
[index
].Action
= INSTALLSTATE_LOCAL
;
5110 ui_actiondata(package
,szCreateShortcuts
,row
);
5112 res
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
5113 &IID_IShellLinkW
, (LPVOID
*) &sl
);
5117 ERR("Is IID_IShellLink\n");
5118 msiobj_release(&row
->hdr
);
5122 res
= IShellLinkW_QueryInterface( sl
, &IID_IPersistFile
,(LPVOID
*) &pf
);
5125 ERR("Is IID_IPersistFile\n");
5126 msiobj_release(&row
->hdr
);
5131 MSI_RecordGetStringW(row
,2,buffer
,&sz
);
5132 target_folder
= resolve_folder(package
, buffer
,FALSE
,FALSE
,NULL
);
5134 /* may be needed because of a bug somehwere else */
5135 create_full_pathW(target_folder
);
5138 MSI_RecordGetStringW(row
,3,buffer
,&sz
);
5139 reduce_to_longfilename(buffer
);
5140 if (!strchrW(buffer
,'.') || strcmpiW(strchrW(buffer
,'.'),szlnk
))
5141 strcatW(buffer
,szlnk
);
5142 target_file
= build_directory_name(2, target_folder
, buffer
);
5143 HeapFree(GetProcessHeap(),0,target_folder
);
5146 MSI_RecordGetStringW(row
,5,buffer
,&sz
);
5147 if (strchrW(buffer
,'['))
5150 deformat_string(package
,buffer
,&deformated
);
5151 IShellLinkW_SetPath(sl
,deformated
);
5152 HeapFree(GetProcessHeap(),0,deformated
);
5157 FIXME("poorly handled shortcut format, advertised shortcut\n");
5158 keypath
= strdupW(package
->components
[index
].FullKeypath
);
5159 IShellLinkW_SetPath(sl
,keypath
);
5160 HeapFree(GetProcessHeap(),0,keypath
);
5163 if (!MSI_RecordIsNull(row
,6))
5167 MSI_RecordGetStringW(row
,6,buffer
,&sz
);
5168 deformat_string(package
,buffer
,&deformated
);
5169 IShellLinkW_SetArguments(sl
,deformated
);
5170 HeapFree(GetProcessHeap(),0,deformated
);
5173 if (!MSI_RecordIsNull(row
,7))
5176 deformated
= load_dynamic_stringW(row
,7);
5177 IShellLinkW_SetDescription(sl
,deformated
);
5178 HeapFree(GetProcessHeap(),0,deformated
);
5181 if (!MSI_RecordIsNull(row
,8))
5182 IShellLinkW_SetHotkey(sl
,MSI_RecordGetInteger(row
,8));
5184 if (!MSI_RecordIsNull(row
,9))
5190 MSI_RecordGetStringW(row
,9,buffer
,&sz
);
5192 build_icon_path(package
,buffer
,&Path
);
5193 index
= MSI_RecordGetInteger(row
,10);
5195 IShellLinkW_SetIconLocation(sl
,Path
,index
);
5196 HeapFree(GetProcessHeap(),0,Path
);
5199 if (!MSI_RecordIsNull(row
,11))
5200 IShellLinkW_SetShowCmd(sl
,MSI_RecordGetInteger(row
,11));
5202 if (!MSI_RecordIsNull(row
,12))
5206 MSI_RecordGetStringW(row
,12,buffer
,&sz
);
5207 Path
= resolve_folder(package
, buffer
, FALSE
, FALSE
, NULL
);
5208 IShellLinkW_SetWorkingDirectory(sl
,Path
);
5209 HeapFree(GetProcessHeap(), 0, Path
);
5212 TRACE("Writing shortcut to %s\n",debugstr_w(target_file
));
5213 IPersistFile_Save(pf
,target_file
,FALSE
);
5215 HeapFree(GetProcessHeap(),0,target_file
);
5217 IPersistFile_Release( pf
);
5218 IShellLinkW_Release( sl
);
5220 msiobj_release(&row
->hdr
);
5222 MSI_ViewClose(view
);
5223 msiobj_release(&view
->hdr
);
5233 * 99% of the work done here is only done for
5234 * advertised installs. However this is where the
5235 * Icon table is processed and written out
5236 * so that is what I am going to do here.
5238 static UINT
ACTION_PublishProduct(MSIPACKAGE
*package
)
5242 MSIRECORD
* row
= 0;
5243 static const WCHAR Query
[]=
5244 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
5245 '`','I','c','o','n','`',0};
5247 /* for registry stuff */
5251 static const WCHAR szProductName
[] =
5252 {'P','r','o','d','u','c','t','N','a','m','e',0};
5253 static const WCHAR szPackageCode
[] =
5254 {'P','a','c','k','a','g','e','C','o','d','e',0};
5257 MSIHANDLE hDb
, hSumInfo
;
5260 return ERROR_INVALID_HANDLE
;
5262 rc
= MSI_DatabaseOpenViewW(package
->db
, Query
, &view
);
5263 if (rc
!= ERROR_SUCCESS
)
5266 rc
= MSI_ViewExecute(view
, 0);
5267 if (rc
!= ERROR_SUCCESS
)
5269 MSI_ViewClose(view
);
5270 msiobj_release(&view
->hdr
);
5277 WCHAR
*FilePath
=NULL
;
5278 WCHAR
*FileName
=NULL
;
5281 rc
= MSI_ViewFetch(view
,&row
);
5282 if (rc
!= ERROR_SUCCESS
)
5288 FileName
= load_dynamic_stringW(row
,1);
5291 ERR("Unable to get FileName\n");
5292 msiobj_release(&row
->hdr
);
5296 build_icon_path(package
,FileName
,&FilePath
);
5298 HeapFree(GetProcessHeap(),0,FileName
);
5300 TRACE("Creating icon file at %s\n",debugstr_w(FilePath
));
5302 the_file
= CreateFileW(FilePath
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
5303 FILE_ATTRIBUTE_NORMAL
, NULL
);
5305 if (the_file
== INVALID_HANDLE_VALUE
)
5307 ERR("Unable to create file %s\n",debugstr_w(FilePath
));
5308 msiobj_release(&row
->hdr
);
5309 HeapFree(GetProcessHeap(),0,FilePath
);
5317 rc
= MSI_RecordReadStream(row
,2,buffer
,&sz
);
5318 if (rc
!= ERROR_SUCCESS
)
5320 ERR("Failed to get stream\n");
5321 CloseHandle(the_file
);
5322 DeleteFileW(FilePath
);
5325 WriteFile(the_file
,buffer
,sz
,&write
,NULL
);
5326 } while (sz
== 1024);
5328 HeapFree(GetProcessHeap(),0,FilePath
);
5330 CloseHandle(the_file
);
5331 msiobj_release(&row
->hdr
);
5333 MSI_ViewClose(view
);
5334 msiobj_release(&view
->hdr
);
5337 /* ok there is a lot more done here but i need to figure out what */
5338 productcode
= load_dynamic_property(package
,szProductCode
,&rc
);
5342 rc
= MSIREG_OpenProductsKey(productcode
,&hkey
,TRUE
);
5343 if (rc
!= ERROR_SUCCESS
)
5346 rc
= MSIREG_OpenUserProductsKey(productcode
,&hukey
,TRUE
);
5347 if (rc
!= ERROR_SUCCESS
)
5351 buffer
= load_dynamic_property(package
,szProductName
,NULL
);
5352 size
= strlenW(buffer
)*sizeof(WCHAR
);
5353 RegSetValueExW(hukey
,szProductName
,0,REG_SZ
, (LPSTR
)buffer
,size
);
5354 HeapFree(GetProcessHeap(),0,buffer
);
5355 FIXME("Need to write more keys to the user registry\n");
5357 hDb
= alloc_msihandle( &package
->db
->hdr
);
5358 rc
= MsiGetSummaryInformationW(hDb
, NULL
, 0, &hSumInfo
);
5359 MsiCloseHandle(hDb
);
5360 if (rc
== ERROR_SUCCESS
)
5362 WCHAR guidbuffer
[0x200];
5364 rc
= MsiSummaryInfoGetPropertyW(hSumInfo
, 9, NULL
, NULL
, NULL
,
5366 if (rc
== ERROR_SUCCESS
)
5368 WCHAR squashed
[GUID_SIZE
];
5369 /* for now we only care about the first guid */
5370 LPWSTR ptr
= strchrW(guidbuffer
,';');
5372 squash_guid(guidbuffer
,squashed
);
5373 size
= strlenW(squashed
)*sizeof(WCHAR
);
5374 RegSetValueExW(hukey
,szPackageCode
,0,REG_SZ
, (LPSTR
)squashed
,
5379 ERR("Unable to query Revision_Number... \n");
5382 MsiCloseHandle(hSumInfo
);
5386 ERR("Unable to open Summary Information\n");
5392 HeapFree(GetProcessHeap(),0,productcode
);
5399 static UINT
ACTION_WriteIniValues(MSIPACKAGE
*package
)
5403 MSIRECORD
* row
= 0;
5404 static const WCHAR ExecSeqQuery
[] =
5405 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
5406 '`','I','n','i','F','i','l','e','`',0};
5407 static const WCHAR szWindowsFolder
[] =
5408 {'W','i','n','d','o','w','s','F','o','l','d','e','r',0};
5410 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
5411 if (rc
!= ERROR_SUCCESS
)
5413 TRACE("no IniFile table\n");
5414 return ERROR_SUCCESS
;
5417 rc
= MSI_ViewExecute(view
, 0);
5418 if (rc
!= ERROR_SUCCESS
)
5420 MSI_ViewClose(view
);
5421 msiobj_release(&view
->hdr
);
5427 LPWSTR component
,filename
,dirproperty
,section
,key
,value
,identifier
;
5428 LPWSTR deformated_section
, deformated_key
, deformated_value
;
5429 LPWSTR folder
, fullname
= NULL
;
5431 INT component_index
,action
;
5433 rc
= MSI_ViewFetch(view
,&row
);
5434 if (rc
!= ERROR_SUCCESS
)
5440 component
= load_dynamic_stringW(row
, 8);
5441 component_index
= get_loaded_component(package
,component
);
5442 HeapFree(GetProcessHeap(),0,component
);
5444 if (!ACTION_VerifyComponentForAction(package
, component_index
,
5445 INSTALLSTATE_LOCAL
))
5447 TRACE("Skipping ini file due to disabled component\n");
5448 msiobj_release(&row
->hdr
);
5450 package
->components
[component_index
].Action
=
5451 package
->components
[component_index
].Installed
;
5456 package
->components
[component_index
].Action
= INSTALLSTATE_LOCAL
;
5458 identifier
= load_dynamic_stringW(row
,1);
5459 filename
= load_dynamic_stringW(row
,2);
5460 dirproperty
= load_dynamic_stringW(row
,3);
5461 section
= load_dynamic_stringW(row
,4);
5462 key
= load_dynamic_stringW(row
,5);
5463 value
= load_dynamic_stringW(row
,6);
5464 action
= MSI_RecordGetInteger(row
,7);
5466 deformat_string(package
,section
,&deformated_section
);
5467 deformat_string(package
,key
,&deformated_key
);
5468 deformat_string(package
,value
,&deformated_value
);
5472 folder
= resolve_folder(package
, dirproperty
, FALSE
, FALSE
, NULL
);
5474 folder
= load_dynamic_property(package
,dirproperty
,NULL
);
5477 folder
= load_dynamic_property(package
, szWindowsFolder
, NULL
);
5481 ERR("Unable to resolve folder! (%s)\n",debugstr_w(dirproperty
));
5485 fullname
= build_directory_name(3, folder
, filename
, NULL
);
5489 TRACE("Adding value %s to section %s in %s\n",
5490 debugstr_w(deformated_key
), debugstr_w(deformated_section
),
5491 debugstr_w(fullname
));
5492 WritePrivateProfileStringW(deformated_section
, deformated_key
,
5493 deformated_value
, fullname
);
5495 else if (action
== 1)
5498 GetPrivateProfileStringW(deformated_section
, deformated_key
, NULL
,
5499 returned
, 10, fullname
);
5500 if (returned
[0] == 0)
5502 TRACE("Adding value %s to section %s in %s\n",
5503 debugstr_w(deformated_key
), debugstr_w(deformated_section
),
5504 debugstr_w(fullname
));
5506 WritePrivateProfileStringW(deformated_section
, deformated_key
,
5507 deformated_value
, fullname
);
5510 else if (action
== 3)
5512 FIXME("Append to existing section not yet implemented\n");
5515 uirow
= MSI_CreateRecord(4);
5516 MSI_RecordSetStringW(uirow
,1,identifier
);
5517 MSI_RecordSetStringW(uirow
,2,deformated_section
);
5518 MSI_RecordSetStringW(uirow
,3,deformated_key
);
5519 MSI_RecordSetStringW(uirow
,4,deformated_value
);
5520 ui_actiondata(package
,szWriteIniValues
,uirow
);
5521 msiobj_release( &uirow
->hdr
);
5523 HeapFree(GetProcessHeap(),0,identifier
);
5524 HeapFree(GetProcessHeap(),0,fullname
);
5525 HeapFree(GetProcessHeap(),0,filename
);
5526 HeapFree(GetProcessHeap(),0,key
);
5527 HeapFree(GetProcessHeap(),0,value
);
5528 HeapFree(GetProcessHeap(),0,section
);
5529 HeapFree(GetProcessHeap(),0,dirproperty
);
5530 HeapFree(GetProcessHeap(),0,folder
);
5531 HeapFree(GetProcessHeap(),0,deformated_key
);
5532 HeapFree(GetProcessHeap(),0,deformated_value
);
5533 HeapFree(GetProcessHeap(),0,deformated_section
);
5534 msiobj_release(&row
->hdr
);
5536 MSI_ViewClose(view
);
5537 msiobj_release(&view
->hdr
);
5541 static UINT
ACTION_SelfRegModules(MSIPACKAGE
*package
)
5545 MSIRECORD
* row
= 0;
5546 static const WCHAR ExecSeqQuery
[] =
5547 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
5548 '`','S','e','l','f','R','e','g','`',0};
5550 static const WCHAR ExeStr
[] =
5551 {'r','e','g','s','v','r','3','2','.','e','x','e',' ','\"',0};
5552 static const WCHAR close
[] = {'\"',0};
5554 PROCESS_INFORMATION info
;
5557 memset(&si
,0,sizeof(STARTUPINFOW
));
5559 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
5560 if (rc
!= ERROR_SUCCESS
)
5562 TRACE("no SelfReg table\n");
5563 return ERROR_SUCCESS
;
5566 rc
= MSI_ViewExecute(view
, 0);
5567 if (rc
!= ERROR_SUCCESS
)
5569 MSI_ViewClose(view
);
5570 msiobj_release(&view
->hdr
);
5580 rc
= MSI_ViewFetch(view
,&row
);
5581 if (rc
!= ERROR_SUCCESS
)
5587 filename
= load_dynamic_stringW(row
,1);
5588 index
= get_loaded_file(package
,filename
);
5592 ERR("Unable to find file id %s\n",debugstr_w(filename
));
5593 HeapFree(GetProcessHeap(),0,filename
);
5594 msiobj_release(&row
->hdr
);
5597 HeapFree(GetProcessHeap(),0,filename
);
5599 len
= strlenW(ExeStr
);
5600 len
+= strlenW(package
->files
[index
].TargetPath
);
5603 filename
= HeapAlloc(GetProcessHeap(),0,len
*sizeof(WCHAR
));
5604 strcpyW(filename
,ExeStr
);
5605 strcatW(filename
,package
->files
[index
].TargetPath
);
5606 strcatW(filename
,close
);
5608 TRACE("Registering %s\n",debugstr_w(filename
));
5609 brc
= CreateProcessW(NULL
, filename
, NULL
, NULL
, FALSE
, 0, NULL
,
5610 c_colon
, &si
, &info
);
5613 msi_dialog_check_messages(info
.hProcess
);
5615 HeapFree(GetProcessHeap(),0,filename
);
5616 msiobj_release(&row
->hdr
);
5618 MSI_ViewClose(view
);
5619 msiobj_release(&view
->hdr
);
5623 static UINT
ACTION_PublishFeatures(MSIPACKAGE
*package
)
5632 return ERROR_INVALID_HANDLE
;
5634 productcode
= load_dynamic_property(package
,szProductCode
,&rc
);
5638 rc
= MSIREG_OpenFeaturesKey(productcode
,&hkey
,TRUE
);
5639 if (rc
!= ERROR_SUCCESS
)
5642 rc
= MSIREG_OpenUserFeaturesKey(productcode
,&hukey
,TRUE
);
5643 if (rc
!= ERROR_SUCCESS
)
5646 /* here the guids are base 85 encoded */
5647 for (i
= 0; i
< package
->loaded_features
; i
++)
5653 BOOL absent
= FALSE
;
5655 if (!ACTION_VerifyFeatureForAction(package
,i
,INSTALLSTATE_LOCAL
) &&
5656 !ACTION_VerifyFeatureForAction(package
,i
,INSTALLSTATE_SOURCE
) &&
5657 !ACTION_VerifyFeatureForAction(package
,i
,INSTALLSTATE_ADVERTISED
))
5660 size
= package
->features
[i
].ComponentCount
*21;
5662 if (package
->features
[i
].Feature_Parent
[0])
5663 size
+= strlenW(package
->features
[i
].Feature_Parent
)+2;
5665 data
= HeapAlloc(GetProcessHeap(), 0, size
* sizeof(WCHAR
));
5668 for (j
= 0; j
< package
->features
[i
].ComponentCount
; j
++)
5671 memset(buf
,0,sizeof(buf
));
5672 if (package
->components
5673 [package
->features
[i
].Components
[j
]].ComponentId
[0]!=0)
5675 TRACE("From %s\n",debugstr_w(package
->components
5676 [package
->features
[i
].Components
[j
]].ComponentId
));
5677 CLSIDFromString(package
->components
5678 [package
->features
[i
].Components
[j
]].ComponentId
,
5680 encode_base85_guid(&clsid
,buf
);
5681 TRACE("to %s\n",debugstr_w(buf
));
5685 if (package
->features
[i
].Feature_Parent
[0])
5687 static const WCHAR sep
[] = {'\2',0};
5689 strcatW(data
,package
->features
[i
].Feature_Parent
);
5692 size
= (strlenW(data
)+1)*sizeof(WCHAR
);
5693 RegSetValueExW(hkey
,package
->features
[i
].Feature
,0,REG_SZ
,
5695 HeapFree(GetProcessHeap(),0,data
);
5699 size
= strlenW(package
->features
[i
].Feature_Parent
)*sizeof(WCHAR
);
5700 RegSetValueExW(hukey
,package
->features
[i
].Feature
,0,REG_SZ
,
5701 (LPSTR
)package
->features
[i
].Feature_Parent
,size
);
5705 size
= (strlenW(package
->features
[i
].Feature_Parent
)+2)*
5707 data
= HeapAlloc(GetProcessHeap(),0,size
);
5709 strcpyW(&data
[1],package
->features
[i
].Feature_Parent
);
5710 RegSetValueExW(hukey
,package
->features
[i
].Feature
,0,REG_SZ
,
5712 HeapFree(GetProcessHeap(),0,data
);
5719 HeapFree(GetProcessHeap(), 0, productcode
);
5723 static UINT
ACTION_RegisterProduct(MSIPACKAGE
*package
)
5730 static WCHAR szNONE
[] = {0};
5731 static const WCHAR szWindowsInstaler
[] =
5732 {'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
5733 static const WCHAR szPropKeys
[][80] =
5735 {'A','R','P','A','U','T','H','O','R','I','Z','E','D','C','D','F','P','R','E','F','I','X',0},
5736 {'A','R','P','C','O','N','T','A','C','T',0},
5737 {'A','R','P','C','O','M','M','E','N','T','S',0},
5738 {'P','r','o','d','u','c','t','N','a','m','e',0},
5739 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0},
5740 {'A','R','P','H','E','L','P','L','I','N','K',0},
5741 {'A','R','P','H','E','L','P','T','E','L','E','P','H','O','N','E',0},
5742 {'A','R','P','I','N','S','T','A','L','L','L','O','C','A','T','I','O','N',0},
5743 {'S','o','u','r','c','e','D','i','r',0},
5744 {'M','a','n','u','f','a','c','t','u','r','e','r',0},
5745 {'A','R','P','R','E','A','D','M','E',0},
5746 {'A','R','P','S','I','Z','E',0},
5747 {'A','R','P','U','R','L','I','N','F','O','A','B','O','U','T',0},
5748 {'A','R','P','U','R','L','U','P','D','A','T','E','I','N','F','O',0},
5752 static const WCHAR szRegKeys
[][80] =
5754 {'A','u','t','h','o','r','i','z','e','d','C','D','F','P','r','e','f','i','x',0},
5755 {'C','o','n','t','a','c','t',0},
5756 {'C','o','m','m','e','n','t','s',0},
5757 {'D','i','s','p','l','a','y','N','a','m','e',0},
5758 {'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0},
5759 {'H','e','l','p','L','i','n','k',0},
5760 {'H','e','l','p','T','e','l','e','p','h','o','n','e',0},
5761 {'I','n','s','t','a','l','l','L','o','c','a','t','i','o','n',0},
5762 {'I','n','s','t','a','l','l','S','o','u','r','c','e',0},
5763 {'P','u','b','l','i','s','h','e','r',0},
5764 {'R','e','a','d','m','e',0},
5765 {'S','i','z','e',0},
5766 {'U','R','L','I','n','f','o','A','b','o','u','t',0},
5767 {'U','R','L','U','p','d','a','t','e','I','n','f','o',0},
5771 static const WCHAR installerPathFmt
[] = {
5773 'I','n','s','t','a','l','l','e','r','\\',0};
5774 static const WCHAR fmt
[] = {
5776 'I','n','s','t','a','l','l','e','r','\\',
5777 '%','x','.','m','s','i',0};
5778 static const WCHAR szLocalPackage
[]=
5779 {'L','o','c','a','l','P','a','c','k','a','g','e',0};
5780 WCHAR windir
[MAX_PATH
], path
[MAX_PATH
], packagefile
[MAX_PATH
];
5784 return ERROR_INVALID_HANDLE
;
5786 productcode
= load_dynamic_property(package
,szProductCode
,&rc
);
5790 rc
= MSIREG_OpenUninstallKey(productcode
,&hkey
,TRUE
);
5791 if (rc
!= ERROR_SUCCESS
)
5794 /* dump all the info i can grab */
5795 FIXME("Flesh out more information \n");
5798 while (szPropKeys
[i
][0]!=0)
5800 buffer
= load_dynamic_property(package
,szPropKeys
[i
],&rc
);
5801 if (rc
!= ERROR_SUCCESS
)
5803 size
= strlenW(buffer
)*sizeof(WCHAR
);
5804 RegSetValueExW(hkey
,szRegKeys
[i
],0,REG_SZ
,(LPSTR
)buffer
,size
);
5810 RegSetValueExW(hkey
,szWindowsInstaler
,0,REG_DWORD
,(LPSTR
)&rc
,size
);
5812 /* copy the package locally */
5813 num
= GetTickCount() & 0xffff;
5817 GetWindowsDirectoryW(windir
, sizeof(windir
) / sizeof(windir
[0]));
5818 snprintfW(packagefile
,sizeof(packagefile
)/sizeof(packagefile
[0]),fmt
,
5822 HANDLE handle
= CreateFileW(packagefile
,GENERIC_WRITE
, 0, NULL
,
5823 CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, 0 );
5824 if (handle
!= INVALID_HANDLE_VALUE
)
5826 CloseHandle(handle
);
5829 if (GetLastError() != ERROR_FILE_EXISTS
&&
5830 GetLastError() != ERROR_SHARING_VIOLATION
)
5832 if (!(++num
& 0xffff)) num
= 1;
5833 sprintfW(packagefile
,fmt
,num
);
5834 } while (num
!= start
);
5836 snprintfW(path
,sizeof(path
)/sizeof(path
[0]),installerPathFmt
,windir
);
5837 create_full_pathW(path
);
5838 TRACE("Copying to local package %s\n",debugstr_w(packagefile
));
5839 if (!CopyFileW(package
->PackagePath
,packagefile
,FALSE
))
5840 ERR("Unable to copy package (%s -> %s) (error %ld)\n",
5841 debugstr_w(package
->PackagePath
), debugstr_w(packagefile
),
5843 size
= strlenW(packagefile
)*sizeof(WCHAR
);
5844 RegSetValueExW(hkey
,szLocalPackage
,0,REG_SZ
,(LPSTR
)packagefile
,size
);
5847 HeapFree(GetProcessHeap(),0,productcode
);
5850 return ERROR_SUCCESS
;
5853 static UINT
ACTION_InstallExecute(MSIPACKAGE
*package
)
5857 return ERROR_INVALID_HANDLE
;
5859 for (i
= 0; i
< package
->DeferredActionCount
; i
++)
5862 action
= package
->DeferredAction
[i
];
5863 ui_actionstart(package
, action
);
5864 TRACE("Executing Action (%s)\n",debugstr_w(action
));
5865 ACTION_CustomAction(package
,action
,TRUE
);
5866 HeapFree(GetProcessHeap(),0,package
->DeferredAction
[i
]);
5868 HeapFree(GetProcessHeap(),0,package
->DeferredAction
);
5870 package
->DeferredActionCount
= 0;
5871 package
->DeferredAction
= NULL
;
5873 return ERROR_SUCCESS
;
5876 static UINT
ACTION_InstallFinalize(MSIPACKAGE
*package
)
5880 return ERROR_INVALID_HANDLE
;
5882 /* first do the same as an InstallExecute */
5883 ACTION_InstallExecute(package
);
5885 /* then handle Commit Actions */
5886 for (i
= 0; i
< package
->CommitActionCount
; i
++)
5889 action
= package
->CommitAction
[i
];
5890 ui_actionstart(package
, action
);
5891 TRACE("Executing Commit Action (%s)\n",debugstr_w(action
));
5892 ACTION_CustomAction(package
,action
,TRUE
);
5893 HeapFree(GetProcessHeap(),0,package
->CommitAction
[i
]);
5895 HeapFree(GetProcessHeap(),0,package
->CommitAction
);
5897 package
->CommitActionCount
= 0;
5898 package
->CommitAction
= NULL
;
5900 return ERROR_SUCCESS
;
5903 static UINT
ACTION_ForceReboot(MSIPACKAGE
*package
)
5905 static const WCHAR RunOnce
[] = {
5906 'S','o','f','t','w','a','r','e','\\',
5907 'M','i','c','r','o','s','o','f','t','\\',
5908 'W','i','n','d','o','w','s','\\',
5909 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
5910 'R','u','n','O','n','c','e',0};
5911 static const WCHAR InstallRunOnce
[] = {
5912 'S','o','f','t','w','a','r','e','\\',
5913 'M','i','c','r','o','s','o','f','t','\\',
5914 'W','i','n','d','o','w','s','\\',
5915 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
5916 'I','n','s','t','a','l','l','e','r','\\',
5917 'R','u','n','O','n','c','e','E','n','t','r','i','e','s',0};
5919 static const WCHAR msiexec_fmt
[] = {
5921 '\\','M','s','i','E','x','e','c','.','e','x','e',' ','/','@',' ',
5922 '\"','%','s','\"',0};
5923 static const WCHAR install_fmt
[] = {
5924 '/','I',' ','\"','%','s','\"',' ',
5925 'A','F','T','E','R','R','E','B','O','O','T','=','1',' ',
5926 'R','U','N','O','N','C','E','E','N','T','R','Y','=','\"','%','s','\"',0};
5927 WCHAR buffer
[256], sysdir
[MAX_PATH
];
5930 WCHAR squished_pc
[100];
5933 static const WCHAR szLUS
[] = {
5934 'L','a','s','t','U','s','e','d','S','o','u','r','c','e',0};
5935 static const WCHAR szSourceList
[] = {
5936 'S','o','u','r','c','e','L','i','s','t',0};
5937 static const WCHAR szPackageName
[] = {
5938 'P','a','c','k','a','g','e','N','a','m','e',0};
5941 return ERROR_INVALID_HANDLE
;
5943 productcode
= load_dynamic_property(package
,szProductCode
,&rc
);
5947 squash_guid(productcode
,squished_pc
);
5949 GetSystemDirectoryW(sysdir
, sizeof(sysdir
)/sizeof(sysdir
[0]));
5950 RegCreateKeyW(HKEY_LOCAL_MACHINE
,RunOnce
,&hkey
);
5951 snprintfW(buffer
,sizeof(buffer
)/sizeof(buffer
[0]),msiexec_fmt
,sysdir
,
5954 size
= strlenW(buffer
)*sizeof(WCHAR
);
5955 RegSetValueExW(hkey
,squished_pc
,0,REG_SZ
,(LPSTR
)buffer
,size
);
5958 TRACE("Reboot command %s\n",debugstr_w(buffer
));
5960 RegCreateKeyW(HKEY_LOCAL_MACHINE
,InstallRunOnce
,&hkey
);
5961 sprintfW(buffer
,install_fmt
,productcode
,squished_pc
);
5963 size
= strlenW(buffer
)*sizeof(WCHAR
);
5964 RegSetValueExW(hkey
,squished_pc
,0,REG_SZ
,(LPSTR
)buffer
,size
);
5967 rc
= MSIREG_OpenUserProductsKey(productcode
,&hukey
,TRUE
);
5968 if (rc
== ERROR_SUCCESS
)
5972 RegCreateKeyW(hukey
, szSourceList
, &hukey2
);
5973 buf
= load_dynamic_property(package
,cszSourceDir
,NULL
);
5974 size
= strlenW(buf
)*sizeof(WCHAR
);
5975 RegSetValueExW(hukey2
,szLUS
,0,REG_SZ
,(LPSTR
)buf
,size
);
5976 HeapFree(GetProcessHeap(),0,buf
);
5978 buf
= strrchrW(package
->PackagePath
,'\\');
5982 size
= strlenW(buf
)*sizeof(WCHAR
);
5983 RegSetValueExW(hukey2
,szPackageName
,0,REG_SZ
,(LPSTR
)buf
,size
);
5986 RegCloseKey(hukey2
);
5988 HeapFree(GetProcessHeap(),0,productcode
);
5990 return ERROR_INSTALL_SUSPEND
;
5993 UINT
ACTION_ResolveSource(MSIPACKAGE
* package
)
5996 * we are currently doing what should be done here in the top level Install
5997 * however for Adminastrative and uninstalls this step will be needed
5999 return ERROR_SUCCESS
;
6003 static UINT
ACTION_RegisterExtensionInfo(MSIPACKAGE
*package
)
6007 MSIRECORD
* row
= 0;
6008 static const WCHAR ExecSeqQuery
[] =
6009 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
6010 '`','E','x','t','e','n','s','i','o','n','`',0};
6011 static const WCHAR szContentType
[] =
6012 {'C','o','n','t','e','n','t',' ','T','y','p','e',0 };
6016 return ERROR_INVALID_HANDLE
;
6018 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
6019 if (rc
!= ERROR_SUCCESS
)
6025 rc
= MSI_ViewExecute(view
, 0);
6026 if (rc
!= ERROR_SUCCESS
)
6028 MSI_ViewClose(view
);
6029 msiobj_release(&view
->hdr
);
6035 WCHAR buffer
[0x100];
6036 WCHAR extension
[257];
6041 rc
= MSI_ViewFetch(view
,&row
);
6042 if (rc
!= ERROR_SUCCESS
)
6049 MSI_RecordGetStringW(row
,2,buffer
,&sz
);
6051 index
= get_loaded_component(package
,buffer
);
6055 msiobj_release(&row
->hdr
);
6059 if ((!ACTION_VerifyComponentForAction(package
, index
,
6060 INSTALLSTATE_LOCAL
)) &&
6061 (!ACTION_VerifyComponentForAction(package
, index
,
6062 INSTALLSTATE_ADVERTISED
)))
6064 TRACE("Skipping extension reg due to disabled component\n");
6065 msiobj_release(&row
->hdr
);
6067 package
->components
[index
].Action
=
6068 package
->components
[index
].Installed
;
6073 package
->components
[index
].Action
= INSTALLSTATE_LOCAL
;
6075 exten
= load_dynamic_stringW(row
,1);
6078 strcatW(extension
,exten
);
6079 HeapFree(GetProcessHeap(),0,exten
);
6081 RegCreateKeyW(HKEY_CLASSES_ROOT
,extension
,&hkey
);
6083 if (!MSI_RecordIsNull(row
,4))
6085 LPWSTR mime
= load_dynamic_stringW(row
,4);
6086 RegSetValueExW(hkey
,szContentType
,0,REG_SZ
,(LPVOID
)mime
,
6087 (strlenW(mime
)+1)*sizeof(WCHAR
));
6088 HeapFree(GetProcessHeap(),0,mime
);
6091 if (!MSI_RecordIsNull(row
,3))
6093 static const WCHAR szSN
[] =
6094 {'\\','S','h','e','l','l','N','e','w',0};
6097 LPWSTR progid
= load_dynamic_stringW(row
,3);
6099 RegSetValueExW(hkey
,NULL
,0,REG_SZ
,(LPVOID
)progid
,
6100 (strlenW(progid
)+1)*sizeof(WCHAR
));
6102 newkey
= HeapAlloc(GetProcessHeap(),0,
6103 (strlenW(progid
)+strlenW(szSN
)+1) * sizeof(WCHAR
));
6105 strcpyW(newkey
,progid
);
6106 strcatW(newkey
,szSN
);
6107 RegCreateKeyW(hkey
,newkey
,&hkey2
);
6110 HeapFree(GetProcessHeap(),0,progid
);
6111 HeapFree(GetProcessHeap(),0,newkey
);
6117 ui_actiondata(package
,szRegisterExtensionInfo
,row
);
6119 msiobj_release(&row
->hdr
);
6121 MSI_ViewClose(view
);
6122 msiobj_release(&view
->hdr
);
6128 static UINT
ACTION_RegisterMIMEInfo(MSIPACKAGE
*package
)
6132 MSIRECORD
* row
= 0;
6133 static const WCHAR ExecSeqQuery
[] =
6134 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
6135 '`','M','I','M','E','`',0};
6136 static const WCHAR szExten
[] =
6137 {'E','x','t','e','n','s','i','o','n',0 };
6141 return ERROR_INVALID_HANDLE
;
6143 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
6144 if (rc
!= ERROR_SUCCESS
)
6150 rc
= MSI_ViewExecute(view
, 0);
6151 if (rc
!= ERROR_SUCCESS
)
6153 MSI_ViewClose(view
);
6154 msiobj_release(&view
->hdr
);
6160 WCHAR extension
[257];
6163 static const WCHAR fmt
[] =
6164 {'M','I','M','E','\\','D','a','t','a','b','a','s','e','\\',
6165 'C','o','n','t','e','n','t',' ','T','y','p','e','\\', '%','s',0};
6168 rc
= MSI_ViewFetch(view
,&row
);
6169 if (rc
!= ERROR_SUCCESS
)
6175 mime
= load_dynamic_stringW(row
,1);
6176 exten
= load_dynamic_stringW(row
,2);
6179 strcatW(extension
,exten
);
6180 HeapFree(GetProcessHeap(),0,exten
);
6182 key
= HeapAlloc(GetProcessHeap(),0,(strlenW(mime
)+strlenW(fmt
)+1) *
6184 sprintfW(key
,fmt
,mime
);
6185 RegCreateKeyW(HKEY_CLASSES_ROOT
,key
,&hkey
);
6186 RegSetValueExW(hkey
,szExten
,0,REG_SZ
,(LPVOID
)extension
,
6187 (strlenW(extension
)+1)*sizeof(WCHAR
));
6189 HeapFree(GetProcessHeap(),0,mime
);
6190 HeapFree(GetProcessHeap(),0,key
);
6192 if (!MSI_RecordIsNull(row
,3))
6194 FIXME("Handle non null for field 3\n");
6199 ui_actiondata(package
,szRegisterMIMEInfo
,row
);
6201 msiobj_release(&row
->hdr
);
6203 MSI_ViewClose(view
);
6204 msiobj_release(&view
->hdr
);
6210 static UINT
ACTION_RegisterUser(MSIPACKAGE
*package
)
6212 static const WCHAR szProductID
[]=
6213 {'P','r','o','d','u','c','t','I','D',0};
6221 static const WCHAR szPropKeys
[][80] =
6223 {'P','r','o','d','u','c','t','I','D',0},
6224 {'U','S','E','R','N','A','M','E',0},
6225 {'C','O','M','P','A','N','Y','N','A','M','E',0},
6229 static const WCHAR szRegKeys
[][80] =
6231 {'P','r','o','d','u','c','t','I','D',0},
6232 {'R','e','g','O','w','n','e','r',0},
6233 {'R','e','g','C','o','m','p','a','n','y',0},
6238 return ERROR_INVALID_HANDLE
;
6240 productid
= load_dynamic_property(package
,szProductID
,&rc
);
6242 return ERROR_SUCCESS
;
6244 productcode
= load_dynamic_property(package
,szProductCode
,&rc
);
6248 rc
= MSIREG_OpenUninstallKey(productcode
,&hkey
,TRUE
);
6249 if (rc
!= ERROR_SUCCESS
)
6253 while (szPropKeys
[i
][0]!=0)
6255 buffer
= load_dynamic_property(package
,szPropKeys
[i
],&rc
);
6256 if (rc
== ERROR_SUCCESS
)
6258 size
= strlenW(buffer
)*sizeof(WCHAR
);
6259 RegSetValueExW(hkey
,szRegKeys
[i
],0,REG_SZ
,(LPSTR
)buffer
,size
);
6262 RegSetValueExW(hkey
,szRegKeys
[i
],0,REG_SZ
,NULL
,0);
6267 HeapFree(GetProcessHeap(),0,productcode
);
6268 HeapFree(GetProcessHeap(),0,productid
);
6271 return ERROR_SUCCESS
;
6275 static UINT
ACTION_ExecuteAction(MSIPACKAGE
*package
)
6278 rc
= ACTION_ProcessExecSequence(package
,FALSE
);
6284 * Code based off of code located here
6285 * http://www.codeproject.com/gdi/fontnamefromfile.asp
6287 * Using string index 4 (full font name) instead of 1 (family name)
6289 static LPWSTR
load_ttfname_from(LPCWSTR filename
)
6295 typedef struct _tagTT_OFFSET_TABLE
{
6296 USHORT uMajorVersion
;
6297 USHORT uMinorVersion
;
6298 USHORT uNumOfTables
;
6299 USHORT uSearchRange
;
6300 USHORT uEntrySelector
;
6304 typedef struct _tagTT_TABLE_DIRECTORY
{
6305 char szTag
[4]; /* table name */
6306 ULONG uCheckSum
; /* Check sum */
6307 ULONG uOffset
; /* Offset from beginning of file */
6308 ULONG uLength
; /* length of the table in bytes */
6309 }TT_TABLE_DIRECTORY
;
6311 typedef struct _tagTT_NAME_TABLE_HEADER
{
6312 USHORT uFSelector
; /* format selector. Always 0 */
6313 USHORT uNRCount
; /* Name Records count */
6314 USHORT uStorageOffset
; /* Offset for strings storage,
6315 * from start of the table */
6316 }TT_NAME_TABLE_HEADER
;
6318 typedef struct _tagTT_NAME_RECORD
{
6323 USHORT uStringLength
;
6324 USHORT uStringOffset
; /* from start of storage area */
6327 #define SWAPWORD(x) MAKEWORD(HIBYTE(x), LOBYTE(x))
6328 #define SWAPLONG(x) MAKELONG(SWAPWORD(HIWORD(x)), SWAPWORD(LOWORD(x)))
6330 handle
= CreateFileW(filename
,GENERIC_READ
, 0, NULL
, OPEN_EXISTING
,
6331 FILE_ATTRIBUTE_NORMAL
, 0 );
6332 if (handle
!= INVALID_HANDLE_VALUE
)
6334 TT_TABLE_DIRECTORY tblDir
;
6335 BOOL bFound
= FALSE
;
6336 TT_OFFSET_TABLE ttOffsetTable
;
6338 ReadFile(handle
,&ttOffsetTable
, sizeof(TT_OFFSET_TABLE
),NULL
,NULL
);
6339 ttOffsetTable
.uNumOfTables
= SWAPWORD(ttOffsetTable
.uNumOfTables
);
6340 ttOffsetTable
.uMajorVersion
= SWAPWORD(ttOffsetTable
.uMajorVersion
);
6341 ttOffsetTable
.uMinorVersion
= SWAPWORD(ttOffsetTable
.uMinorVersion
);
6343 if (ttOffsetTable
.uMajorVersion
!= 1 ||
6344 ttOffsetTable
.uMinorVersion
!= 0)
6347 for (i
=0; i
< ttOffsetTable
.uNumOfTables
; i
++)
6349 ReadFile(handle
,&tblDir
, sizeof(TT_TABLE_DIRECTORY
),NULL
,NULL
);
6350 if (strncmp(tblDir
.szTag
,"name",4)==0)
6353 tblDir
.uLength
= SWAPLONG(tblDir
.uLength
);
6354 tblDir
.uOffset
= SWAPLONG(tblDir
.uOffset
);
6361 TT_NAME_TABLE_HEADER ttNTHeader
;
6362 TT_NAME_RECORD ttRecord
;
6364 SetFilePointer(handle
, tblDir
.uOffset
, NULL
, FILE_BEGIN
);
6365 ReadFile(handle
,&ttNTHeader
, sizeof(TT_NAME_TABLE_HEADER
),
6368 ttNTHeader
.uNRCount
= SWAPWORD(ttNTHeader
.uNRCount
);
6369 ttNTHeader
.uStorageOffset
= SWAPWORD(ttNTHeader
.uStorageOffset
);
6371 for(i
=0; i
<ttNTHeader
.uNRCount
; i
++)
6373 ReadFile(handle
,&ttRecord
, sizeof(TT_NAME_RECORD
),NULL
,NULL
);
6374 ttRecord
.uNameID
= SWAPWORD(ttRecord
.uNameID
);
6375 /* 4 is the Full Font Name */
6376 if(ttRecord
.uNameID
== 4)
6380 static const LPSTR tt
= " (TrueType)";
6382 ttRecord
.uStringLength
= SWAPWORD(ttRecord
.uStringLength
);
6383 ttRecord
.uStringOffset
= SWAPWORD(ttRecord
.uStringOffset
);
6384 nPos
= SetFilePointer(handle
, 0, NULL
, FILE_CURRENT
);
6385 SetFilePointer(handle
, tblDir
.uOffset
+
6386 ttRecord
.uStringOffset
+
6387 ttNTHeader
.uStorageOffset
,
6389 buf
= HeapAlloc(GetProcessHeap(), 0,
6390 ttRecord
.uStringLength
+ 1 + strlen(tt
));
6391 memset(buf
, 0, ttRecord
.uStringLength
+ 1 + strlen(tt
));
6392 ReadFile(handle
, buf
, ttRecord
.uStringLength
, NULL
, NULL
);
6393 if (strlen(buf
) > 0)
6396 ret
= strdupAtoW(buf
);
6397 HeapFree(GetProcessHeap(),0,buf
);
6401 HeapFree(GetProcessHeap(),0,buf
);
6402 SetFilePointer(handle
,nPos
, NULL
, FILE_BEGIN
);
6406 CloseHandle(handle
);
6409 ERR("Unable to open font file %s\n", debugstr_w(filename
));
6411 TRACE("Returning fontname %s\n",debugstr_w(ret
));
6415 static UINT
ACTION_RegisterFonts(MSIPACKAGE
*package
)
6419 MSIRECORD
* row
= 0;
6420 static const WCHAR ExecSeqQuery
[] =
6421 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
6422 '`','F','o','n','t','`',0};
6423 static const WCHAR regfont1
[] =
6424 {'S','o','f','t','w','a','r','e','\\',
6425 'M','i','c','r','o','s','o','f','t','\\',
6426 'W','i','n','d','o','w','s',' ','N','T','\\',
6427 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
6428 'F','o','n','t','s',0};
6429 static const WCHAR regfont2
[] =
6430 {'S','o','f','t','w','a','r','e','\\',
6431 'M','i','c','r','o','s','o','f','t','\\',
6432 'W','i','n','d','o','w','s','\\',
6433 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
6434 'F','o','n','t','s',0};
6438 TRACE("%p\n", package
);
6440 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
6441 if (rc
!= ERROR_SUCCESS
)
6443 TRACE("MSI_DatabaseOpenViewW failed: %d\n", rc
);
6444 return ERROR_SUCCESS
;
6447 rc
= MSI_ViewExecute(view
, 0);
6448 if (rc
!= ERROR_SUCCESS
)
6450 MSI_ViewClose(view
);
6451 msiobj_release(&view
->hdr
);
6452 TRACE("MSI_ViewExecute returned %d\n", rc
);
6453 return ERROR_SUCCESS
;
6456 RegCreateKeyW(HKEY_LOCAL_MACHINE
,regfont1
,&hkey1
);
6457 RegCreateKeyW(HKEY_LOCAL_MACHINE
,regfont2
,&hkey2
);
6466 rc
= MSI_ViewFetch(view
,&row
);
6467 if (rc
!= ERROR_SUCCESS
)
6473 file
= load_dynamic_stringW(row
,1);
6474 index
= get_loaded_file(package
,file
);
6477 ERR("Unable to load file\n");
6478 HeapFree(GetProcessHeap(),0,file
);
6482 /* check to make sure that component is installed */
6483 if (!ACTION_VerifyComponentForAction(package
,
6484 package
->files
[index
].ComponentIndex
, INSTALLSTATE_LOCAL
))
6486 TRACE("Skipping: Component not scheduled for install\n");
6487 HeapFree(GetProcessHeap(),0,file
);
6489 msiobj_release(&row
->hdr
);
6494 if (MSI_RecordIsNull(row
,2))
6495 name
= load_ttfname_from(package
->files
[index
].TargetPath
);
6497 name
= load_dynamic_stringW(row
,2);
6501 size
= strlenW(package
->files
[index
].FileName
) * sizeof(WCHAR
);
6502 RegSetValueExW(hkey1
,name
,0,REG_SZ
,
6503 (LPBYTE
)package
->files
[index
].FileName
,size
);
6504 RegSetValueExW(hkey2
,name
,0,REG_SZ
,
6505 (LPBYTE
)package
->files
[index
].FileName
,size
);
6508 HeapFree(GetProcessHeap(),0,file
);
6509 HeapFree(GetProcessHeap(),0,name
);
6510 msiobj_release(&row
->hdr
);
6512 MSI_ViewClose(view
);
6513 msiobj_release(&view
->hdr
);
6518 TRACE("returning %d\n", rc
);
6522 static UINT
ITERATE_PublishComponent(MSIRECORD
*rec
, LPVOID param
)
6524 MSIPACKAGE
*package
= (MSIPACKAGE
*)param
;
6525 LPWSTR productid
=NULL
, compgroupid
=NULL
;
6526 LPWSTR feature
=NULL
;
6528 LPWSTR qualifier
= NULL
;
6529 LPWSTR component
= NULL
;
6531 WCHAR productid_85
[21];
6532 WCHAR component_85
[21];
6534 UINT rc
= ERROR_SUCCESS
;
6537 * I have a fair bit of confusion as to when a < is used and when a > is
6538 * used. I do not think i have it right...
6540 * Ok it appears that the > is used if there is a guid for the compoenent
6541 * and the < is used if not.
6543 static WCHAR fmt1
[] = {'%','s','%','s','<',0,0};
6544 static WCHAR fmt2
[] = {'%','s','%','s','>','%','s',0,0};
6545 LPWSTR output
= NULL
;
6547 INT component_index
;
6549 component
= load_dynamic_stringW(rec
,3);
6550 component_index
= get_loaded_component(package
,component
);
6552 if (!ACTION_VerifyComponentForAction(package
, component_index
,
6553 INSTALLSTATE_LOCAL
) &&
6554 !ACTION_VerifyComponentForAction(package
, component_index
,
6555 INSTALLSTATE_SOURCE
) &&
6556 !ACTION_VerifyComponentForAction(package
, component_index
,
6557 INSTALLSTATE_ADVERTISED
))
6559 TRACE("Skipping: Component %s not scheduled for install\n",
6560 debugstr_w(component
));
6561 HeapFree(GetProcessHeap(),0,component
);
6562 return ERROR_SUCCESS
;
6565 memset(productid_85
,0,sizeof(productid_85
));
6566 memset(component_85
,0,sizeof(component_85
));
6567 compgroupid
= load_dynamic_stringW(rec
,1);
6569 rc
= MSIREG_OpenUserComponentsKey(compgroupid
, &hkey
, TRUE
);
6570 if (rc
!= ERROR_SUCCESS
)
6573 productid
= load_dynamic_property(package
,szProductCode
,NULL
);
6574 CLSIDFromString(productid
, &clsid
);
6576 encode_base85_guid(&clsid
,productid_85
);
6578 text
= load_dynamic_stringW(rec
,4);
6579 qualifier
= load_dynamic_stringW(rec
,2);
6581 feature
= load_dynamic_stringW(rec
,5);
6583 index
= get_loaded_component(package
, component
);
6584 CLSIDFromString(package
->components
[index
].ComponentId
, &clsid
);
6585 encode_base85_guid(&clsid
,component_85
);
6587 TRACE("Doing something with this... %s = %s %s %s %s\n",
6588 debugstr_w(qualifier
), debugstr_w(productid_85
),
6589 debugstr_w(feature
), debugstr_w(text
), debugstr_w(component_85
));
6591 sz
= lstrlenW(productid_85
) + lstrlenW(feature
);
6593 sz
+= lstrlenW(text
);
6594 if (component
&& index
>= 0)
6595 sz
+= lstrlenW(component_85
);
6598 sz
*= sizeof(WCHAR
);
6600 output
= HeapAlloc(GetProcessHeap(),0,sz
);
6601 memset(output
,0,sz
);
6603 if (component
&& index
>= 0)
6604 sprintfW(output
,fmt2
,productid_85
,feature
,component_85
);
6606 sprintfW(output
,fmt1
,productid_85
,feature
);
6609 strcatW(output
,text
);
6611 sz
= (lstrlenW(output
)+2) * sizeof(WCHAR
);
6612 RegSetValueExW(hkey
, qualifier
,0,REG_MULTI_SZ
, (LPBYTE
)output
, sz
);
6616 HeapFree(GetProcessHeap(),0,output
);
6617 HeapFree(GetProcessHeap(),0,compgroupid
);
6618 HeapFree(GetProcessHeap(),0,component
);
6619 HeapFree(GetProcessHeap(),0,productid
);
6620 HeapFree(GetProcessHeap(),0,feature
);
6621 HeapFree(GetProcessHeap(),0,text
);
6622 HeapFree(GetProcessHeap(),0,qualifier
);
6628 * At present I am ignorning the advertised components part of this and only
6629 * focusing on the qualified component sets
6631 static UINT
ACTION_PublishComponents(MSIPACKAGE
*package
)
6635 static const WCHAR ExecSeqQuery
[] =
6636 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
6637 '`','P','u','b','l','i','s','h',
6638 'C','o','m','p','o','n','e','n','t','`',0};
6640 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
6641 if (rc
!= ERROR_SUCCESS
)
6642 return ERROR_SUCCESS
;
6644 rc
= MSI_IterateRecords(view
, NULL
, ITERATE_PublishComponent
, package
);
6645 msiobj_release(&view
->hdr
);
6650 /* Msi functions that seem appropriate here */
6652 /***********************************************************************
6653 * MsiDoActionA (MSI.@)
6655 UINT WINAPI
MsiDoActionA( MSIHANDLE hInstall
, LPCSTR szAction
)
6660 TRACE(" exteral attempt at action %s\n",szAction
);
6663 return ERROR_FUNCTION_FAILED
;
6665 return ERROR_FUNCTION_FAILED
;
6667 szwAction
= strdupAtoW(szAction
);
6670 return ERROR_FUNCTION_FAILED
;
6673 rc
= MsiDoActionW(hInstall
, szwAction
);
6674 HeapFree(GetProcessHeap(),0,szwAction
);
6678 /***********************************************************************
6679 * MsiDoActionW (MSI.@)
6681 UINT WINAPI
MsiDoActionW( MSIHANDLE hInstall
, LPCWSTR szAction
)
6683 MSIPACKAGE
*package
;
6684 UINT ret
= ERROR_INVALID_HANDLE
;
6686 TRACE(" external attempt at action %s \n",debugstr_w(szAction
));
6688 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
6691 ret
= ACTION_PerformUIAction(package
,szAction
);
6692 msiobj_release( &package
->hdr
);
6697 UINT WINAPI
MsiGetTargetPathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
6698 LPSTR szPathBuf
, DWORD
* pcchPathBuf
)
6704 TRACE("getting folder %s %p %li\n",szFolder
,szPathBuf
, *pcchPathBuf
);
6707 return ERROR_FUNCTION_FAILED
;
6709 return ERROR_FUNCTION_FAILED
;
6711 szwFolder
= strdupAtoW(szFolder
);
6714 return ERROR_FUNCTION_FAILED
;
6716 szwPathBuf
= HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf
* sizeof(WCHAR
));
6718 rc
= MsiGetTargetPathW(hInstall
, szwFolder
, szwPathBuf
,pcchPathBuf
);
6720 WideCharToMultiByte( CP_ACP
, 0, szwPathBuf
, *pcchPathBuf
, szPathBuf
,
6721 *pcchPathBuf
, NULL
, NULL
);
6723 HeapFree(GetProcessHeap(),0,szwFolder
);
6724 HeapFree(GetProcessHeap(),0,szwPathBuf
);
6729 UINT WINAPI
MsiGetTargetPathW( MSIHANDLE hInstall
, LPCWSTR szFolder
, LPWSTR
6730 szPathBuf
, DWORD
* pcchPathBuf
)
6733 UINT rc
= ERROR_FUNCTION_FAILED
;
6734 MSIPACKAGE
*package
;
6736 TRACE("(%s %p %li)\n",debugstr_w(szFolder
),szPathBuf
,*pcchPathBuf
);
6738 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
6740 return ERROR_INVALID_HANDLE
;
6741 path
= resolve_folder(package
, szFolder
, FALSE
, FALSE
, NULL
);
6742 msiobj_release( &package
->hdr
);
6744 if (path
&& (strlenW(path
) > *pcchPathBuf
))
6746 *pcchPathBuf
= strlenW(path
)+1;
6747 rc
= ERROR_MORE_DATA
;
6751 *pcchPathBuf
= strlenW(path
)+1;
6752 strcpyW(szPathBuf
,path
);
6753 TRACE("Returning Path %s\n",debugstr_w(path
));
6756 HeapFree(GetProcessHeap(),0,path
);
6762 UINT WINAPI
MsiGetSourcePathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
6763 LPSTR szPathBuf
, DWORD
* pcchPathBuf
)
6769 TRACE("getting source %s %p %li\n",szFolder
,szPathBuf
, *pcchPathBuf
);
6772 return ERROR_FUNCTION_FAILED
;
6774 return ERROR_FUNCTION_FAILED
;
6776 szwFolder
= strdupAtoW(szFolder
);
6778 return ERROR_FUNCTION_FAILED
;
6780 szwPathBuf
= HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf
* sizeof(WCHAR
));
6782 rc
= MsiGetSourcePathW(hInstall
, szwFolder
, szwPathBuf
,pcchPathBuf
);
6784 WideCharToMultiByte( CP_ACP
, 0, szwPathBuf
, *pcchPathBuf
, szPathBuf
,
6785 *pcchPathBuf
, NULL
, NULL
);
6787 HeapFree(GetProcessHeap(),0,szwFolder
);
6788 HeapFree(GetProcessHeap(),0,szwPathBuf
);
6793 UINT WINAPI
MsiGetSourcePathW( MSIHANDLE hInstall
, LPCWSTR szFolder
, LPWSTR
6794 szPathBuf
, DWORD
* pcchPathBuf
)
6797 UINT rc
= ERROR_FUNCTION_FAILED
;
6798 MSIPACKAGE
*package
;
6800 TRACE("(%s %p %li)\n",debugstr_w(szFolder
),szPathBuf
,*pcchPathBuf
);
6802 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
6804 return ERROR_INVALID_HANDLE
;
6805 path
= resolve_folder(package
, szFolder
, TRUE
, FALSE
, NULL
);
6806 msiobj_release( &package
->hdr
);
6808 if (path
&& strlenW(path
) > *pcchPathBuf
)
6810 *pcchPathBuf
= strlenW(path
)+1;
6811 rc
= ERROR_MORE_DATA
;
6815 *pcchPathBuf
= strlenW(path
)+1;
6816 strcpyW(szPathBuf
,path
);
6817 TRACE("Returning Path %s\n",debugstr_w(path
));
6820 HeapFree(GetProcessHeap(),0,path
);
6826 /***********************************************************************
6827 * MsiSetTargetPathA (MSI.@)
6829 UINT WINAPI
MsiSetTargetPathA(MSIHANDLE hInstall
, LPCSTR szFolder
,
6830 LPCSTR szFolderPath
)
6833 LPWSTR szwFolderPath
;
6837 return ERROR_FUNCTION_FAILED
;
6839 return ERROR_FUNCTION_FAILED
;
6841 szwFolder
= strdupAtoW(szFolder
);
6843 return ERROR_FUNCTION_FAILED
;
6845 szwFolderPath
= strdupAtoW(szFolderPath
);
6848 HeapFree(GetProcessHeap(),0,szwFolder
);
6849 return ERROR_FUNCTION_FAILED
;
6852 rc
= MsiSetTargetPathW(hInstall
, szwFolder
, szwFolderPath
);
6854 HeapFree(GetProcessHeap(),0,szwFolder
);
6855 HeapFree(GetProcessHeap(),0,szwFolderPath
);
6860 UINT
MSI_SetTargetPathW(MSIPACKAGE
*package
, LPCWSTR szFolder
,
6861 LPCWSTR szFolderPath
)
6865 LPWSTR path2
= NULL
;
6868 TRACE("(%p %s %s)\n",package
, debugstr_w(szFolder
),debugstr_w(szFolderPath
));
6871 return ERROR_INVALID_HANDLE
;
6873 if (szFolderPath
[0]==0)
6874 return ERROR_FUNCTION_FAILED
;
6876 if (GetFileAttributesW(szFolderPath
) == INVALID_FILE_ATTRIBUTES
)
6877 return ERROR_FUNCTION_FAILED
;
6879 path
= resolve_folder(package
,szFolder
,FALSE
,FALSE
,&folder
);
6882 return ERROR_INVALID_PARAMETER
;
6884 HeapFree(GetProcessHeap(),0,folder
->Property
);
6885 folder
->Property
= build_directory_name(2, szFolderPath
, NULL
);
6887 if (lstrcmpiW(path
, folder
->Property
) == 0)
6890 * Resolved Target has not really changed, so just
6891 * set this folder and do not recalculate everything.
6893 HeapFree(GetProcessHeap(),0,folder
->ResolvedTarget
);
6894 folder
->ResolvedTarget
= NULL
;
6895 path2
= resolve_folder(package
,szFolder
,FALSE
,TRUE
,NULL
);
6896 HeapFree(GetProcessHeap(),0,path2
);
6900 for (i
= 0; i
< package
->loaded_folders
; i
++)
6902 HeapFree(GetProcessHeap(),0,package
->folders
[i
].ResolvedTarget
);
6903 package
->folders
[i
].ResolvedTarget
=NULL
;
6906 for (i
= 0; i
< package
->loaded_folders
; i
++)
6908 path2
=resolve_folder(package
, package
->folders
[i
].Directory
, FALSE
,
6910 HeapFree(GetProcessHeap(),0,path2
);
6913 HeapFree(GetProcessHeap(),0,path
);
6915 return ERROR_SUCCESS
;
6918 /***********************************************************************
6919 * MsiSetTargetPathW (MSI.@)
6921 UINT WINAPI
MsiSetTargetPathW(MSIHANDLE hInstall
, LPCWSTR szFolder
,
6922 LPCWSTR szFolderPath
)
6924 MSIPACKAGE
*package
;
6927 TRACE("(%s %s)\n",debugstr_w(szFolder
),debugstr_w(szFolderPath
));
6929 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
6930 ret
= MSI_SetTargetPathW( package
, szFolder
, szFolderPath
);
6931 msiobj_release( &package
->hdr
);
6935 /***********************************************************************
6936 * MsiGetMode (MSI.@)
6938 * Returns an internal installer state (if it is running in a mode iRunMode)
6941 * hInstall [I] Handle to the installation
6942 * hRunMode [I] Checking run mode
6943 * MSIRUNMODE_ADMIN Administrative mode
6944 * MSIRUNMODE_ADVERTISE Advertisement mode
6945 * MSIRUNMODE_MAINTENANCE Maintenance mode
6946 * MSIRUNMODE_ROLLBACKENABLED Rollback is enabled
6947 * MSIRUNMODE_LOGENABLED Log file is writing
6948 * MSIRUNMODE_OPERATIONS Operations in progress??
6949 * MSIRUNMODE_REBOOTATEND We need to reboot after installation completed
6950 * MSIRUNMODE_REBOOTNOW We need to reboot to continue the installation
6951 * MSIRUNMODE_CABINET Files from cabinet are installed
6952 * MSIRUNMODE_SOURCESHORTNAMES Long names in source files is suppressed
6953 * MSIRUNMODE_TARGETSHORTNAMES Long names in destination files is suppressed
6954 * MSIRUNMODE_RESERVED11 Reserved
6955 * MSIRUNMODE_WINDOWS9X Running under Windows95/98
6956 * MSIRUNMODE_ZAWENABLED Demand installation is supported
6957 * MSIRUNMODE_RESERVED14 Reserved
6958 * MSIRUNMODE_RESERVED15 Reserved
6959 * MSIRUNMODE_SCHEDULED called from install script
6960 * MSIRUNMODE_ROLLBACK called from rollback script
6961 * MSIRUNMODE_COMMIT called from commit script
6964 * In the state: TRUE
6965 * Not in the state: FALSE
6969 BOOL WINAPI
MsiGetMode(MSIHANDLE hInstall
, MSIRUNMODE iRunMode
)
6971 FIXME("STUB (iRunMode=%i)\n",iRunMode
);
6975 /***********************************************************************
6976 * MsiSetFeatureStateA (MSI.@)
6978 * According to the docs, when this is called it immediately recalculates
6979 * all the component states as well
6981 UINT WINAPI
MsiSetFeatureStateA(MSIHANDLE hInstall
, LPCSTR szFeature
,
6982 INSTALLSTATE iState
)
6984 LPWSTR szwFeature
= NULL
;
6987 szwFeature
= strdupAtoW(szFeature
);
6990 return ERROR_FUNCTION_FAILED
;
6992 rc
= MsiSetFeatureStateW(hInstall
,szwFeature
, iState
);
6994 HeapFree(GetProcessHeap(),0,szwFeature
);
7001 UINT WINAPI
MSI_SetFeatureStateW(MSIPACKAGE
* package
, LPCWSTR szFeature
,
7002 INSTALLSTATE iState
)
7005 UINT rc
= ERROR_SUCCESS
;
7007 TRACE(" %s to %i\n",debugstr_w(szFeature
), iState
);
7009 index
= get_loaded_feature(package
,szFeature
);
7011 return ERROR_UNKNOWN_FEATURE
;
7013 package
->features
[index
].ActionRequest
= iState
;
7014 package
->features
[index
].Action
= iState
;
7016 ACTION_UpdateComponentStates(package
,szFeature
);
7018 /* update all the features that are children of this feature */
7019 for (i
= 0; i
< package
->loaded_features
; i
++)
7021 if (strcmpW(szFeature
, package
->features
[i
].Feature_Parent
) == 0)
7022 MSI_SetFeatureStateW(package
, package
->features
[i
].Feature
, iState
);
7028 /***********************************************************************
7029 * MsiSetFeatureStateW (MSI.@)
7031 UINT WINAPI
MsiSetFeatureStateW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
7032 INSTALLSTATE iState
)
7034 MSIPACKAGE
* package
;
7035 UINT rc
= ERROR_SUCCESS
;
7037 TRACE(" %s to %i\n",debugstr_w(szFeature
), iState
);
7039 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
7041 return ERROR_INVALID_HANDLE
;
7043 rc
= MSI_SetFeatureStateW(package
,szFeature
,iState
);
7045 msiobj_release( &package
->hdr
);
7049 UINT WINAPI
MsiGetFeatureStateA(MSIHANDLE hInstall
, LPSTR szFeature
,
7050 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
7052 LPWSTR szwFeature
= NULL
;
7055 szwFeature
= strdupAtoW(szFeature
);
7057 rc
= MsiGetFeatureStateW(hInstall
,szwFeature
,piInstalled
, piAction
);
7059 HeapFree( GetProcessHeap(), 0 , szwFeature
);
7064 UINT
MSI_GetFeatureStateW(MSIPACKAGE
*package
, LPWSTR szFeature
,
7065 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
7069 index
= get_loaded_feature(package
,szFeature
);
7071 return ERROR_UNKNOWN_FEATURE
;
7074 *piInstalled
= package
->features
[index
].Installed
;
7077 *piAction
= package
->features
[index
].Action
;
7079 TRACE("returning %i %i\n",*piInstalled
,*piAction
);
7081 return ERROR_SUCCESS
;
7084 UINT WINAPI
MsiGetFeatureStateW(MSIHANDLE hInstall
, LPWSTR szFeature
,
7085 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
7087 MSIPACKAGE
* package
;
7090 TRACE("%ld %s %p %p\n", hInstall
, debugstr_w(szFeature
), piInstalled
,
7093 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
7095 return ERROR_INVALID_HANDLE
;
7096 ret
= MSI_GetFeatureStateW(package
, szFeature
, piInstalled
, piAction
);
7097 msiobj_release( &package
->hdr
);
7101 /***********************************************************************
7102 * MsiGetComponentStateA (MSI.@)
7104 UINT WINAPI
MsiGetComponentStateA(MSIHANDLE hInstall
, LPSTR szComponent
,
7105 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
7107 LPWSTR szwComponent
= NULL
;
7110 szwComponent
= strdupAtoW(szComponent
);
7112 rc
= MsiGetComponentStateW(hInstall
,szwComponent
,piInstalled
, piAction
);
7114 HeapFree( GetProcessHeap(), 0 , szwComponent
);
7119 UINT
MSI_GetComponentStateW(MSIPACKAGE
*package
, LPWSTR szComponent
,
7120 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
7124 TRACE("%p %s %p %p\n", package
, debugstr_w(szComponent
), piInstalled
,
7127 index
= get_loaded_component(package
,szComponent
);
7129 return ERROR_UNKNOWN_COMPONENT
;
7132 *piInstalled
= package
->components
[index
].Installed
;
7135 *piAction
= package
->components
[index
].Action
;
7137 TRACE("states (%i, %i)\n",
7138 (piInstalled
)?*piInstalled
:-1,(piAction
)?*piAction
:-1);
7140 return ERROR_SUCCESS
;
7143 /***********************************************************************
7144 * MsiGetComponentStateW (MSI.@)
7146 UINT WINAPI
MsiGetComponentStateW(MSIHANDLE hInstall
, LPWSTR szComponent
,
7147 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
7149 MSIPACKAGE
* package
;
7152 TRACE("%ld %s %p %p\n", hInstall
, debugstr_w(szComponent
),
7153 piInstalled
, piAction
);
7155 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
7157 return ERROR_INVALID_HANDLE
;
7158 ret
= MSI_GetComponentStateW( package
, szComponent
, piInstalled
, piAction
);
7159 msiobj_release( &package
->hdr
);
7164 static UINT
ACTION_Template(MSIPACKAGE
*package
)
7168 MSIRECORD
* row
= 0;
7169 static const WCHAR ExecSeqQuery
[] = {0};
7171 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
7172 if (rc
!= ERROR_SUCCESS
)
7175 rc
= MSI_ViewExecute(view
, 0);
7176 if (rc
!= ERROR_SUCCESS
)
7178 MSI_ViewClose(view
);
7179 msiobj_release(&view
->hdr
);
7185 rc
= MSI_ViewFetch(view
,&row
);
7186 if (rc
!= ERROR_SUCCESS
)
7192 msiobj_release(&row
->hdr
);
7194 MSI_ViewClose(view
);
7195 msiobj_release(&view
->hdr
);