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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define NONAMELESSUNION
22 #define NONAMELESSSTRUCT
45 #include "wine/heap.h"
46 #include "wine/debug.h"
47 #include "wine/unicode.h"
53 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
55 static void free_feature( MSIFEATURE
*feature
)
57 struct list
*item
, *cursor
;
59 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Children
)
61 FeatureList
*fl
= LIST_ENTRY( item
, FeatureList
, entry
);
62 list_remove( &fl
->entry
);
66 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Components
)
68 ComponentList
*cl
= LIST_ENTRY( item
, ComponentList
, entry
);
69 list_remove( &cl
->entry
);
72 msi_free( feature
->Feature
);
73 msi_free( feature
->Feature_Parent
);
74 msi_free( feature
->Directory
);
75 msi_free( feature
->Description
);
76 msi_free( feature
->Title
);
80 static void free_folder( MSIFOLDER
*folder
)
82 struct list
*item
, *cursor
;
84 LIST_FOR_EACH_SAFE( item
, cursor
, &folder
->children
)
86 FolderList
*fl
= LIST_ENTRY( item
, FolderList
, entry
);
87 list_remove( &fl
->entry
);
90 msi_free( folder
->Parent
);
91 msi_free( folder
->Directory
);
92 msi_free( folder
->TargetDefault
);
93 msi_free( folder
->SourceLongPath
);
94 msi_free( folder
->SourceShortPath
);
95 msi_free( folder
->ResolvedTarget
);
96 msi_free( folder
->ResolvedSource
);
100 static void free_extension( MSIEXTENSION
*ext
)
102 struct list
*item
, *cursor
;
104 LIST_FOR_EACH_SAFE( item
, cursor
, &ext
->verbs
)
106 MSIVERB
*verb
= LIST_ENTRY( item
, MSIVERB
, entry
);
108 list_remove( &verb
->entry
);
109 msi_free( verb
->Verb
);
110 msi_free( verb
->Command
);
111 msi_free( verb
->Argument
);
115 msi_free( ext
->Extension
);
116 msi_free( ext
->ProgIDText
);
120 static void free_assembly( MSIASSEMBLY
*assembly
)
122 msi_free( assembly
->feature
);
123 msi_free( assembly
->manifest
);
124 msi_free( assembly
->application
);
125 msi_free( assembly
->display_name
);
126 if (assembly
->tempdir
) RemoveDirectoryW( assembly
->tempdir
);
127 msi_free( assembly
->tempdir
);
128 msi_free( assembly
);
131 void msi_free_action_script( MSIPACKAGE
*package
, UINT script
)
134 for (i
= 0; i
< package
->script_actions_count
[script
]; i
++)
135 msi_free( package
->script_actions
[script
][i
] );
137 msi_free( package
->script_actions
[script
] );
138 package
->script_actions
[script
] = NULL
;
139 package
->script_actions_count
[script
] = 0;
142 static void free_package_structures( MSIPACKAGE
*package
)
144 struct list
*item
, *cursor
;
147 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->features
)
149 MSIFEATURE
*feature
= LIST_ENTRY( item
, MSIFEATURE
, entry
);
150 list_remove( &feature
->entry
);
151 free_feature( feature
);
154 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->folders
)
156 MSIFOLDER
*folder
= LIST_ENTRY( item
, MSIFOLDER
, entry
);
157 list_remove( &folder
->entry
);
158 free_folder( folder
);
161 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->files
)
163 MSIFILE
*file
= LIST_ENTRY( item
, MSIFILE
, entry
);
165 list_remove( &file
->entry
);
166 msi_free( file
->File
);
167 msi_free( file
->FileName
);
168 msi_free( file
->ShortName
);
169 msi_free( file
->LongName
);
170 msi_free( file
->Version
);
171 msi_free( file
->Language
);
172 if (msi_is_global_assembly( file
->Component
)) DeleteFileW( file
->TargetPath
);
173 msi_free( file
->TargetPath
);
177 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->components
)
179 MSICOMPONENT
*comp
= LIST_ENTRY( item
, MSICOMPONENT
, entry
);
181 list_remove( &comp
->entry
);
182 msi_free( comp
->Component
);
183 msi_free( comp
->ComponentId
);
184 msi_free( comp
->Directory
);
185 msi_free( comp
->Condition
);
186 msi_free( comp
->KeyPath
);
187 msi_free( comp
->FullKeypath
);
188 if (comp
->assembly
) free_assembly( comp
->assembly
);
192 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->filepatches
)
194 MSIFILEPATCH
*patch
= LIST_ENTRY( item
, MSIFILEPATCH
, entry
);
196 list_remove( &patch
->entry
);
197 msi_free( patch
->path
);
201 /* clean up extension, progid, class and verb structures */
202 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->classes
)
204 MSICLASS
*cls
= LIST_ENTRY( item
, MSICLASS
, entry
);
206 list_remove( &cls
->entry
);
207 msi_free( cls
->clsid
);
208 msi_free( cls
->Context
);
209 msi_free( cls
->Description
);
210 msi_free( cls
->FileTypeMask
);
211 msi_free( cls
->IconPath
);
212 msi_free( cls
->DefInprocHandler
);
213 msi_free( cls
->DefInprocHandler32
);
214 msi_free( cls
->Argument
);
215 msi_free( cls
->ProgIDText
);
219 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->extensions
)
221 MSIEXTENSION
*ext
= LIST_ENTRY( item
, MSIEXTENSION
, entry
);
223 list_remove( &ext
->entry
);
224 free_extension( ext
);
227 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->progids
)
229 MSIPROGID
*progid
= LIST_ENTRY( item
, MSIPROGID
, entry
);
231 list_remove( &progid
->entry
);
232 msi_free( progid
->ProgID
);
233 msi_free( progid
->Description
);
234 msi_free( progid
->IconPath
);
238 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->mimes
)
240 MSIMIME
*mt
= LIST_ENTRY( item
, MSIMIME
, entry
);
242 list_remove( &mt
->entry
);
243 msi_free( mt
->suffix
);
244 msi_free( mt
->clsid
);
245 msi_free( mt
->ContentType
);
249 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->appids
)
251 MSIAPPID
*appid
= LIST_ENTRY( item
, MSIAPPID
, entry
);
253 list_remove( &appid
->entry
);
254 msi_free( appid
->AppID
);
255 msi_free( appid
->RemoteServerName
);
256 msi_free( appid
->LocalServer
);
257 msi_free( appid
->ServiceParameters
);
258 msi_free( appid
->DllSurrogate
);
262 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->sourcelist_info
)
264 MSISOURCELISTINFO
*info
= LIST_ENTRY( item
, MSISOURCELISTINFO
, entry
);
266 list_remove( &info
->entry
);
267 msi_free( info
->value
);
271 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->sourcelist_media
)
273 MSIMEDIADISK
*info
= LIST_ENTRY( item
, MSIMEDIADISK
, entry
);
275 list_remove( &info
->entry
);
276 msi_free( info
->volume_label
);
277 msi_free( info
->disk_prompt
);
281 for (i
= 0; i
< SCRIPT_MAX
; i
++)
282 msi_free_action_script( package
, i
);
284 for (i
= 0; i
< package
->unique_actions_count
; i
++)
285 msi_free( package
->unique_actions
[i
] );
286 msi_free( package
->unique_actions
);
288 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->binaries
)
290 MSIBINARY
*binary
= LIST_ENTRY( item
, MSIBINARY
, entry
);
292 list_remove( &binary
->entry
);
294 FreeLibrary( binary
->module
);
295 if (!DeleteFileW( binary
->tmpfile
))
296 ERR("failed to delete %s (%u)\n", debugstr_w(binary
->tmpfile
), GetLastError());
297 msi_free( binary
->source
);
298 msi_free( binary
->tmpfile
);
302 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->cabinet_streams
)
304 MSICABINETSTREAM
*cab
= LIST_ENTRY( item
, MSICABINETSTREAM
, entry
);
306 list_remove( &cab
->entry
);
307 IStorage_Release( cab
->storage
);
308 msi_free( cab
->stream
);
312 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->patches
)
314 MSIPATCHINFO
*patch
= LIST_ENTRY( item
, MSIPATCHINFO
, entry
);
316 list_remove( &patch
->entry
);
317 if (patch
->delete_on_close
&& !DeleteFileW( patch
->localfile
))
319 ERR("failed to delete %s (%u)\n", debugstr_w(patch
->localfile
), GetLastError());
321 msi_free_patchinfo( patch
);
324 msi_free( package
->PackagePath
);
325 msi_free( package
->ProductCode
);
326 msi_free( package
->ActionFormat
);
327 msi_free( package
->LastAction
);
328 msi_free( package
->LastActionTemplate
);
329 msi_free( package
->langids
);
331 /* cleanup control event subscriptions */
332 msi_event_cleanup_all_subscriptions( package
);
335 static void MSI_FreePackage( MSIOBJECTHDR
*arg
)
337 MSIPACKAGE
*package
= (MSIPACKAGE
*)arg
;
339 msi_destroy_assembly_caches( package
);
341 if( package
->dialog
)
342 msi_dialog_destroy( package
->dialog
);
344 msiobj_release( &package
->db
->hdr
);
345 free_package_structures(package
);
346 CloseHandle( package
->log_file
);
348 if (package
->delete_on_close
) DeleteFileW( package
->localfile
);
349 msi_free( package
->localfile
);
350 MSI_ProcessMessage(NULL
, INSTALLMESSAGE_TERMINATE
, 0);
353 static UINT
create_temp_property_table(MSIPACKAGE
*package
)
355 static const WCHAR query
[] = {
356 'C','R','E','A','T','E',' ','T','A','B','L','E',' ',
357 '`','_','P','r','o','p','e','r','t','y','`',' ','(',' ',
358 '`','_','P','r','o','p','e','r','t','y','`',' ',
359 'C','H','A','R','(','5','6',')',' ','N','O','T',' ','N','U','L','L',' ',
360 'T','E','M','P','O','R','A','R','Y',',',' ',
361 '`','V','a','l','u','e','`',' ','C','H','A','R','(','9','8',')',' ',
362 'N','O','T',' ','N','U','L','L',' ','T','E','M','P','O','R','A','R','Y',
363 ' ','P','R','I','M','A','R','Y',' ','K','E','Y',' ',
364 '`','_','P','r','o','p','e','r','t','y','`',')',' ','H','O','L','D',0};
368 rc
= MSI_DatabaseOpenViewW(package
->db
, query
, &view
);
369 if (rc
!= ERROR_SUCCESS
)
372 rc
= MSI_ViewExecute(view
, 0);
374 msiobj_release(&view
->hdr
);
378 UINT
msi_clone_properties( MSIDATABASE
*db
)
380 static const WCHAR query_select
[] = {
381 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
382 '`','P','r','o','p','e','r','t','y','`',0};
383 static const WCHAR query_insert
[] = {
384 'I','N','S','E','R','T',' ','I','N','T','O',' ',
385 '`','_','P','r','o','p','e','r','t','y','`',' ',
386 '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
387 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
388 static const WCHAR query_update
[] = {
389 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
390 'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ',
391 'W','H','E','R','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','?',0};
392 MSIQUERY
*view_select
;
395 rc
= MSI_DatabaseOpenViewW( db
, query_select
, &view_select
);
396 if (rc
!= ERROR_SUCCESS
)
399 rc
= MSI_ViewExecute( view_select
, 0 );
400 if (rc
!= ERROR_SUCCESS
)
402 MSI_ViewClose( view_select
);
403 msiobj_release( &view_select
->hdr
);
409 MSIQUERY
*view_insert
, *view_update
;
410 MSIRECORD
*rec_select
;
412 rc
= MSI_ViewFetch( view_select
, &rec_select
);
413 if (rc
!= ERROR_SUCCESS
)
416 rc
= MSI_DatabaseOpenViewW( db
, query_insert
, &view_insert
);
417 if (rc
!= ERROR_SUCCESS
)
419 msiobj_release( &rec_select
->hdr
);
423 rc
= MSI_ViewExecute( view_insert
, rec_select
);
424 MSI_ViewClose( view_insert
);
425 msiobj_release( &view_insert
->hdr
);
426 if (rc
!= ERROR_SUCCESS
)
428 MSIRECORD
*rec_update
;
430 TRACE("insert failed, trying update\n");
432 rc
= MSI_DatabaseOpenViewW( db
, query_update
, &view_update
);
433 if (rc
!= ERROR_SUCCESS
)
435 WARN("open view failed %u\n", rc
);
436 msiobj_release( &rec_select
->hdr
);
440 rec_update
= MSI_CreateRecord( 2 );
441 MSI_RecordCopyField( rec_select
, 1, rec_update
, 2 );
442 MSI_RecordCopyField( rec_select
, 2, rec_update
, 1 );
443 rc
= MSI_ViewExecute( view_update
, rec_update
);
444 if (rc
!= ERROR_SUCCESS
)
445 WARN("update failed %u\n", rc
);
447 MSI_ViewClose( view_update
);
448 msiobj_release( &view_update
->hdr
);
449 msiobj_release( &rec_update
->hdr
);
452 msiobj_release( &rec_select
->hdr
);
455 MSI_ViewClose( view_select
);
456 msiobj_release( &view_select
->hdr
);
463 * Sets the "Installed" property to indicate that
464 * the product is installed for the current user.
466 static UINT
set_installed_prop( MSIPACKAGE
*package
)
471 if (!package
->ProductCode
) return ERROR_FUNCTION_FAILED
;
473 r
= MSIREG_OpenUninstallKey( package
->ProductCode
, package
->platform
, &hkey
, FALSE
);
474 if (r
== ERROR_SUCCESS
)
477 msi_set_property( package
->db
, szInstalled
, szOne
, -1 );
482 static UINT
set_user_sid_prop( MSIPACKAGE
*package
)
486 LPWSTR sid_str
= NULL
, dom
= NULL
;
487 DWORD size
, dom_size
;
489 UINT r
= ERROR_FUNCTION_FAILED
;
492 GetUserNameW( NULL
, &size
);
494 user_name
= msi_alloc( (size
+ 1) * sizeof(WCHAR
) );
496 return ERROR_OUTOFMEMORY
;
498 if (!GetUserNameW( user_name
, &size
))
503 LookupAccountNameW( NULL
, user_name
, NULL
, &size
, NULL
, &dom_size
, &use
);
505 psid
= msi_alloc( size
);
506 dom
= msi_alloc( dom_size
*sizeof (WCHAR
) );
509 r
= ERROR_OUTOFMEMORY
;
513 if (!LookupAccountNameW( NULL
, user_name
, psid
, &size
, dom
, &dom_size
, &use
))
516 if (!ConvertSidToStringSidW( psid
, &sid_str
))
519 r
= msi_set_property( package
->db
, szUserSID
, sid_str
, -1 );
522 LocalFree( sid_str
);
525 msi_free( user_name
);
530 static LPWSTR
get_fusion_filename(MSIPACKAGE
*package
)
532 static const WCHAR fusion
[] =
533 {'f','u','s','i','o','n','.','d','l','l',0};
534 static const WCHAR subkey
[] =
535 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
536 'N','E','T',' ','F','r','a','m','e','w','o','r','k',' ','S','e','t','u','p','\\','N','D','P',0};
537 static const WCHAR subdir
[] =
538 {'M','i','c','r','o','s','o','f','t','.','N','E','T','\\','F','r','a','m','e','w','o','r','k','\\',0};
539 static const WCHAR v2050727
[] =
540 {'v','2','.','0','.','5','0','7','2','7',0};
541 static const WCHAR v4client
[] =
542 {'v','4','\\','C','l','i','e','n','t',0};
543 static const WCHAR installpath
[] =
544 {'I','n','s','t','a','l','l','P','a','t','h',0};
547 DWORD size
, len
, type
;
548 WCHAR windir
[MAX_PATH
], path
[MAX_PATH
], *filename
= NULL
;
550 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, subkey
, 0, KEY_CREATE_SUB_KEY
, &netsetup
);
551 if (res
!= ERROR_SUCCESS
)
554 if (!RegCreateKeyExW(netsetup
, v4client
, 0, NULL
, 0, KEY_QUERY_VALUE
, NULL
, &hkey
, NULL
))
556 size
= sizeof(path
)/sizeof(path
[0]);
557 if (!RegQueryValueExW(hkey
, installpath
, NULL
, &type
, (BYTE
*)path
, &size
))
559 len
= strlenW(path
) + strlenW(fusion
) + 2;
560 if (!(filename
= msi_alloc(len
* sizeof(WCHAR
)))) return NULL
;
562 strcpyW(filename
, path
);
563 strcatW(filename
, szBackSlash
);
564 strcatW(filename
, fusion
);
565 if (GetFileAttributesW(filename
) != INVALID_FILE_ATTRIBUTES
)
567 TRACE( "found %s\n", debugstr_w(filename
) );
569 RegCloseKey(netsetup
);
576 if (!RegCreateKeyExW(netsetup
, v2050727
, 0, NULL
, 0, KEY_QUERY_VALUE
, NULL
, &hkey
, NULL
))
579 GetWindowsDirectoryW(windir
, MAX_PATH
);
580 len
= strlenW(windir
) + strlenW(subdir
) + strlenW(v2050727
) + strlenW(fusion
) + 3;
581 if (!(filename
= msi_alloc(len
* sizeof(WCHAR
)))) return NULL
;
583 strcpyW(filename
, windir
);
584 strcatW(filename
, szBackSlash
);
585 strcatW(filename
, subdir
);
586 strcatW(filename
, v2050727
);
587 strcatW(filename
, szBackSlash
);
588 strcatW(filename
, fusion
);
589 if (GetFileAttributesW(filename
) != INVALID_FILE_ATTRIBUTES
)
591 TRACE( "found %s\n", debugstr_w(filename
) );
592 RegCloseKey(netsetup
);
597 RegCloseKey(netsetup
);
601 typedef struct tagLANGANDCODEPAGE
607 static void set_msi_assembly_prop(MSIPACKAGE
*package
)
611 LPVOID version
= NULL
;
613 LPWSTR fusion
, verstr
;
614 LANGANDCODEPAGE
*translate
;
616 static const WCHAR netasm
[] = {
617 'M','s','i','N','e','t','A','s','s','e','m','b','l','y','S','u','p','p','o','r','t',0
619 static const WCHAR translation
[] = {
620 '\\','V','a','r','F','i','l','e','I','n','f','o',
621 '\\','T','r','a','n','s','l','a','t','i','o','n',0
623 static const WCHAR verfmt
[] = {
624 '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
625 '\\','%','0','4','x','%','0','4','x',
626 '\\','P','r','o','d','u','c','t','V','e','r','s','i','o','n',0
629 fusion
= get_fusion_filename(package
);
633 size
= GetFileVersionInfoSizeW(fusion
, &handle
);
637 version
= msi_alloc(size
);
641 if (!GetFileVersionInfoW(fusion
, handle
, size
, version
))
644 if (!VerQueryValueW(version
, translation
, (LPVOID
*)&translate
, &val_len
))
647 sprintfW(buf
, verfmt
, translate
[0].wLanguage
, translate
[0].wCodePage
);
649 if (!VerQueryValueW(version
, buf
, (LPVOID
*)&verstr
, &val_len
))
652 if (!val_len
|| !verstr
)
655 msi_set_property( package
->db
, netasm
, verstr
, -1 );
662 static VOID
set_installer_properties(MSIPACKAGE
*package
)
665 OSVERSIONINFOEXW OSVersion
;
668 WCHAR pth
[MAX_PATH
], verstr
[11], bufstr
[22];
671 LPWSTR username
, companyname
;
672 SYSTEM_INFO sys_info
;
675 static const WCHAR szCommonFilesFolder
[] = {'C','o','m','m','o','n','F','i','l','e','s','F','o','l','d','e','r',0};
676 static const WCHAR szProgramFilesFolder
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','F','o','l','d','e','r',0};
677 static const WCHAR szCommonAppDataFolder
[] = {'C','o','m','m','o','n','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
678 static const WCHAR szFavoritesFolder
[] = {'F','a','v','o','r','i','t','e','s','F','o','l','d','e','r',0};
679 static const WCHAR szFontsFolder
[] = {'F','o','n','t','s','F','o','l','d','e','r',0};
680 static const WCHAR szSendToFolder
[] = {'S','e','n','d','T','o','F','o','l','d','e','r',0};
681 static const WCHAR szStartMenuFolder
[] = {'S','t','a','r','t','M','e','n','u','F','o','l','d','e','r',0};
682 static const WCHAR szStartupFolder
[] = {'S','t','a','r','t','u','p','F','o','l','d','e','r',0};
683 static const WCHAR szTemplateFolder
[] = {'T','e','m','p','l','a','t','e','F','o','l','d','e','r',0};
684 static const WCHAR szDesktopFolder
[] = {'D','e','s','k','t','o','p','F','o','l','d','e','r',0};
685 static const WCHAR szProgramMenuFolder
[] = {'P','r','o','g','r','a','m','M','e','n','u','F','o','l','d','e','r',0};
686 static const WCHAR szAdminToolsFolder
[] = {'A','d','m','i','n','T','o','o','l','s','F','o','l','d','e','r',0};
687 static const WCHAR szSystemFolder
[] = {'S','y','s','t','e','m','F','o','l','d','e','r',0};
688 static const WCHAR szSystem16Folder
[] = {'S','y','s','t','e','m','1','6','F','o','l','d','e','r',0};
689 static const WCHAR szLocalAppDataFolder
[] = {'L','o','c','a','l','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
690 static const WCHAR szMyPicturesFolder
[] = {'M','y','P','i','c','t','u','r','e','s','F','o','l','d','e','r',0};
691 static const WCHAR szPersonalFolder
[] = {'P','e','r','s','o','n','a','l','F','o','l','d','e','r',0};
692 static const WCHAR szWindowsVolume
[] = {'W','i','n','d','o','w','s','V','o','l','u','m','e',0};
693 static const WCHAR szPrivileged
[] = {'P','r','i','v','i','l','e','g','e','d',0};
694 static const WCHAR szVersion9x
[] = {'V','e','r','s','i','o','n','9','X',0};
695 static const WCHAR szVersionNT
[] = {'V','e','r','s','i','o','n','N','T',0};
696 static const WCHAR szMsiNTProductType
[] = {'M','s','i','N','T','P','r','o','d','u','c','t','T','y','p','e',0};
697 static const WCHAR szFormat
[] = {'%','u',0};
698 static const WCHAR szFormat2
[] = {'%','u','.','%','u',0};
699 static const WCHAR szWindowsBuild
[] = {'W','i','n','d','o','w','s','B','u','i','l','d',0};
700 static const WCHAR szServicePackLevel
[] = {'S','e','r','v','i','c','e','P','a','c','k','L','e','v','e','l',0};
701 static const WCHAR szVersionMsi
[] = { 'V','e','r','s','i','o','n','M','s','i',0 };
702 static const WCHAR szVersionDatabase
[] = { 'V','e','r','s','i','o','n','D','a','t','a','b','a','s','e',0 };
703 static const WCHAR szPhysicalMemory
[] = { 'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0 };
704 static const WCHAR szScreenX
[] = {'S','c','r','e','e','n','X',0};
705 static const WCHAR szScreenY
[] = {'S','c','r','e','e','n','Y',0};
706 static const WCHAR szColorBits
[] = {'C','o','l','o','r','B','i','t','s',0};
707 static const WCHAR szIntFormat
[] = {'%','d',0};
708 static const WCHAR szMsiAMD64
[] = { 'M','s','i','A','M','D','6','4',0 };
709 static const WCHAR szMsix64
[] = { 'M','s','i','x','6','4',0 };
710 static const WCHAR szSystem64Folder
[] = { 'S','y','s','t','e','m','6','4','F','o','l','d','e','r',0 };
711 static const WCHAR szCommonFiles64Folder
[] = { 'C','o','m','m','o','n','F','i','l','e','s','6','4','F','o','l','d','e','r',0 };
712 static const WCHAR szProgramFiles64Folder
[] = { 'P','r','o','g','r','a','m','F','i','l','e','s','6','4','F','o','l','d','e','r',0 };
713 static const WCHAR szVersionNT64
[] = { 'V','e','r','s','i','o','n','N','T','6','4',0 };
714 static const WCHAR szUserInfo
[] = {
715 'S','O','F','T','W','A','R','E','\\',
716 'M','i','c','r','o','s','o','f','t','\\',
717 'M','S',' ','S','e','t','u','p',' ','(','A','C','M','E',')','\\',
718 'U','s','e','r',' ','I','n','f','o',0
720 static const WCHAR szDefName
[] = { 'D','e','f','N','a','m','e',0 };
721 static const WCHAR szDefCompany
[] = { 'D','e','f','C','o','m','p','a','n','y',0 };
722 static const WCHAR szCurrentVersion
[] = {
723 'S','O','F','T','W','A','R','E','\\',
724 'M','i','c','r','o','s','o','f','t','\\',
725 'W','i','n','d','o','w','s',' ','N','T','\\',
726 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0
728 static const WCHAR szRegisteredUser
[] = {'R','e','g','i','s','t','e','r','e','d','O','w','n','e','r',0};
729 static const WCHAR szRegisteredOrganization
[] = {
730 'R','e','g','i','s','t','e','r','e','d','O','r','g','a','n','i','z','a','t','i','o','n',0
732 static const WCHAR szUSERNAME
[] = {'U','S','E','R','N','A','M','E',0};
733 static const WCHAR szCOMPANYNAME
[] = {'C','O','M','P','A','N','Y','N','A','M','E',0};
734 static const WCHAR szUserLanguageID
[] = {'U','s','e','r','L','a','n','g','u','a','g','e','I','D',0};
735 static const WCHAR szSystemLangID
[] = {'S','y','s','t','e','m','L','a','n','g','u','a','g','e','I','D',0};
736 static const WCHAR szProductState
[] = {'P','r','o','d','u','c','t','S','t','a','t','e',0};
737 static const WCHAR szLogonUser
[] = {'L','o','g','o','n','U','s','e','r',0};
738 static const WCHAR szNetHoodFolder
[] = {'N','e','t','H','o','o','d','F','o','l','d','e','r',0};
739 static const WCHAR szPrintHoodFolder
[] = {'P','r','i','n','t','H','o','o','d','F','o','l','d','e','r',0};
740 static const WCHAR szRecentFolder
[] = {'R','e','c','e','n','t','F','o','l','d','e','r',0};
741 static const WCHAR szComputerName
[] = {'C','o','m','p','u','t','e','r','N','a','m','e',0};
744 * Other things that probably should be set:
746 * VirtualMemory ShellAdvSupport DefaultUIFont PackagecodeChanging
747 * CaptionHeight BorderTop BorderSide TextHeight RedirectedDllSupport
750 SHGetFolderPathW(NULL
, CSIDL_COMMON_APPDATA
, NULL
, 0, pth
);
751 strcatW(pth
, szBackSlash
);
752 msi_set_property( package
->db
, szCommonAppDataFolder
, pth
, -1 );
754 SHGetFolderPathW(NULL
, CSIDL_FAVORITES
, NULL
, 0, pth
);
755 strcatW(pth
, szBackSlash
);
756 msi_set_property( package
->db
, szFavoritesFolder
, pth
, -1 );
758 SHGetFolderPathW(NULL
, CSIDL_FONTS
, NULL
, 0, pth
);
759 strcatW(pth
, szBackSlash
);
760 msi_set_property( package
->db
, szFontsFolder
, pth
, -1 );
762 SHGetFolderPathW(NULL
, CSIDL_SENDTO
, NULL
, 0, pth
);
763 strcatW(pth
, szBackSlash
);
764 msi_set_property( package
->db
, szSendToFolder
, pth
, -1 );
766 SHGetFolderPathW(NULL
, CSIDL_STARTMENU
, NULL
, 0, pth
);
767 strcatW(pth
, szBackSlash
);
768 msi_set_property( package
->db
, szStartMenuFolder
, pth
, -1 );
770 SHGetFolderPathW(NULL
, CSIDL_STARTUP
, NULL
, 0, pth
);
771 strcatW(pth
, szBackSlash
);
772 msi_set_property( package
->db
, szStartupFolder
, pth
, -1 );
774 SHGetFolderPathW(NULL
, CSIDL_TEMPLATES
, NULL
, 0, pth
);
775 strcatW(pth
, szBackSlash
);
776 msi_set_property( package
->db
, szTemplateFolder
, pth
, -1 );
778 SHGetFolderPathW(NULL
, CSIDL_DESKTOP
, NULL
, 0, pth
);
779 strcatW(pth
, szBackSlash
);
780 msi_set_property( package
->db
, szDesktopFolder
, pth
, -1 );
782 /* FIXME: set to AllUsers profile path if ALLUSERS is set */
783 SHGetFolderPathW(NULL
, CSIDL_PROGRAMS
, NULL
, 0, pth
);
784 strcatW(pth
, szBackSlash
);
785 msi_set_property( package
->db
, szProgramMenuFolder
, pth
, -1 );
787 SHGetFolderPathW(NULL
, CSIDL_ADMINTOOLS
, NULL
, 0, pth
);
788 strcatW(pth
, szBackSlash
);
789 msi_set_property( package
->db
, szAdminToolsFolder
, pth
, -1 );
791 SHGetFolderPathW(NULL
, CSIDL_APPDATA
, NULL
, 0, pth
);
792 strcatW(pth
, szBackSlash
);
793 msi_set_property( package
->db
, szAppDataFolder
, pth
, -1 );
795 SHGetFolderPathW(NULL
, CSIDL_SYSTEM
, NULL
, 0, pth
);
796 strcatW(pth
, szBackSlash
);
797 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
798 msi_set_property( package
->db
, szSystem16Folder
, pth
, -1 );
800 SHGetFolderPathW(NULL
, CSIDL_LOCAL_APPDATA
, NULL
, 0, pth
);
801 strcatW(pth
, szBackSlash
);
802 msi_set_property( package
->db
, szLocalAppDataFolder
, pth
, -1 );
804 SHGetFolderPathW(NULL
, CSIDL_MYPICTURES
, NULL
, 0, pth
);
805 strcatW(pth
, szBackSlash
);
806 msi_set_property( package
->db
, szMyPicturesFolder
, pth
, -1 );
808 SHGetFolderPathW(NULL
, CSIDL_PERSONAL
, NULL
, 0, pth
);
809 strcatW(pth
, szBackSlash
);
810 msi_set_property( package
->db
, szPersonalFolder
, pth
, -1 );
812 SHGetFolderPathW(NULL
, CSIDL_WINDOWS
, NULL
, 0, pth
);
813 strcatW(pth
, szBackSlash
);
814 msi_set_property( package
->db
, szWindowsFolder
, pth
, -1 );
816 SHGetFolderPathW(NULL
, CSIDL_PRINTHOOD
, NULL
, 0, pth
);
817 strcatW(pth
, szBackSlash
);
818 msi_set_property( package
->db
, szPrintHoodFolder
, pth
, -1 );
820 SHGetFolderPathW(NULL
, CSIDL_NETHOOD
, NULL
, 0, pth
);
821 strcatW(pth
, szBackSlash
);
822 msi_set_property( package
->db
, szNetHoodFolder
, pth
, -1 );
824 SHGetFolderPathW(NULL
, CSIDL_RECENT
, NULL
, 0, pth
);
825 strcatW(pth
, szBackSlash
);
826 msi_set_property( package
->db
, szRecentFolder
, pth
, -1 );
828 /* Physical Memory is specified in MB. Using total amount. */
829 msex
.dwLength
= sizeof(msex
);
830 GlobalMemoryStatusEx( &msex
);
831 len
= sprintfW( bufstr
, szIntFormat
, (int)(msex
.ullTotalPhys
/ 1024 / 1024) );
832 msi_set_property( package
->db
, szPhysicalMemory
, bufstr
, len
);
834 SHGetFolderPathW(NULL
, CSIDL_WINDOWS
, NULL
, 0, pth
);
835 ptr
= strchrW(pth
,'\\');
836 if (ptr
) *(ptr
+ 1) = 0;
837 msi_set_property( package
->db
, szWindowsVolume
, pth
, -1 );
839 len
= GetTempPathW(MAX_PATH
, pth
);
840 msi_set_property( package
->db
, szTempFolder
, pth
, len
);
842 /* in a wine environment the user is always admin and privileged */
843 msi_set_property( package
->db
, szAdminUser
, szOne
, -1 );
844 msi_set_property( package
->db
, szPrivileged
, szOne
, -1 );
846 /* set the os things */
847 OSVersion
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
848 GetVersionExW((OSVERSIONINFOW
*)&OSVersion
);
849 verval
= OSVersion
.dwMinorVersion
+ OSVersion
.dwMajorVersion
* 100;
850 len
= sprintfW( verstr
, szFormat
, verval
);
851 switch (OSVersion
.dwPlatformId
)
853 case VER_PLATFORM_WIN32_WINDOWS
:
854 msi_set_property( package
->db
, szVersion9x
, verstr
, len
);
856 case VER_PLATFORM_WIN32_NT
:
857 msi_set_property( package
->db
, szVersionNT
, verstr
, len
);
858 len
= sprintfW( bufstr
, szFormat
,OSVersion
.wProductType
);
859 msi_set_property( package
->db
, szMsiNTProductType
, bufstr
, len
);
862 len
= sprintfW( bufstr
, szFormat
, OSVersion
.dwBuildNumber
);
863 msi_set_property( package
->db
, szWindowsBuild
, bufstr
, len
);
864 len
= sprintfW( bufstr
, szFormat
, OSVersion
.wServicePackMajor
);
865 msi_set_property( package
->db
, szServicePackLevel
, bufstr
, len
);
867 len
= sprintfW( bufstr
, szFormat2
, MSI_MAJORVERSION
, MSI_MINORVERSION
);
868 msi_set_property( package
->db
, szVersionMsi
, bufstr
, len
);
869 len
= sprintfW( bufstr
, szFormat
, MSI_MAJORVERSION
* 100 );
870 msi_set_property( package
->db
, szVersionDatabase
, bufstr
, len
);
872 GetNativeSystemInfo( &sys_info
);
873 len
= sprintfW( bufstr
, szIntFormat
, sys_info
.wProcessorLevel
);
874 msi_set_property( package
->db
, szIntel
, bufstr
, len
);
875 if (sys_info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
877 GetSystemDirectoryW( pth
, MAX_PATH
);
878 PathAddBackslashW( pth
);
879 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
881 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, pth
);
882 PathAddBackslashW( pth
);
883 msi_set_property( package
->db
, szProgramFilesFolder
, pth
, -1 );
885 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, pth
);
886 PathAddBackslashW( pth
);
887 msi_set_property( package
->db
, szCommonFilesFolder
, pth
, -1 );
889 else if (sys_info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
)
891 msi_set_property( package
->db
, szMsiAMD64
, bufstr
, -1 );
892 msi_set_property( package
->db
, szMsix64
, bufstr
, -1 );
893 msi_set_property( package
->db
, szVersionNT64
, verstr
, -1 );
895 GetSystemDirectoryW( pth
, MAX_PATH
);
896 PathAddBackslashW( pth
);
897 msi_set_property( package
->db
, szSystem64Folder
, pth
, -1 );
899 GetSystemWow64DirectoryW( pth
, MAX_PATH
);
900 PathAddBackslashW( pth
);
901 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
903 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, pth
);
904 PathAddBackslashW( pth
);
905 msi_set_property( package
->db
, szProgramFiles64Folder
, pth
, -1 );
907 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, pth
);
908 PathAddBackslashW( pth
);
909 msi_set_property( package
->db
, szProgramFilesFolder
, pth
, -1 );
911 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, pth
);
912 PathAddBackslashW( pth
);
913 msi_set_property( package
->db
, szCommonFiles64Folder
, pth
, -1 );
915 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, pth
);
916 PathAddBackslashW( pth
);
917 msi_set_property( package
->db
, szCommonFilesFolder
, pth
, -1 );
920 /* Screen properties. */
922 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, HORZRES
) );
923 msi_set_property( package
->db
, szScreenX
, bufstr
, len
);
924 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, VERTRES
) );
925 msi_set_property( package
->db
, szScreenY
, bufstr
, len
);
926 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, BITSPIXEL
) );
927 msi_set_property( package
->db
, szColorBits
, bufstr
, len
);
930 /* USERNAME and COMPANYNAME */
931 username
= msi_dup_property( package
->db
, szUSERNAME
);
932 companyname
= msi_dup_property( package
->db
, szCOMPANYNAME
);
934 if ((!username
|| !companyname
) &&
935 RegOpenKeyW( HKEY_CURRENT_USER
, szUserInfo
, &hkey
) == ERROR_SUCCESS
)
938 (username
= msi_reg_get_val_str( hkey
, szDefName
)))
939 msi_set_property( package
->db
, szUSERNAME
, username
, -1 );
941 (companyname
= msi_reg_get_val_str( hkey
, szDefCompany
)))
942 msi_set_property( package
->db
, szCOMPANYNAME
, companyname
, -1 );
945 if ((!username
|| !companyname
) &&
946 RegOpenKeyW( HKEY_LOCAL_MACHINE
, szCurrentVersion
, &hkey
) == ERROR_SUCCESS
)
949 (username
= msi_reg_get_val_str( hkey
, szRegisteredUser
)))
950 msi_set_property( package
->db
, szUSERNAME
, username
, -1 );
952 (companyname
= msi_reg_get_val_str( hkey
, szRegisteredOrganization
)))
953 msi_set_property( package
->db
, szCOMPANYNAME
, companyname
, -1 );
956 msi_free( username
);
957 msi_free( companyname
);
959 if ( set_user_sid_prop( package
) != ERROR_SUCCESS
)
960 ERR("Failed to set the UserSID property\n");
962 set_msi_assembly_prop( package
);
964 langid
= GetUserDefaultLangID();
965 len
= sprintfW( bufstr
, szIntFormat
, langid
);
966 msi_set_property( package
->db
, szUserLanguageID
, bufstr
, len
);
968 langid
= GetSystemDefaultLangID();
969 len
= sprintfW( bufstr
, szIntFormat
, langid
);
970 msi_set_property( package
->db
, szSystemLangID
, bufstr
, len
);
972 len
= sprintfW( bufstr
, szIntFormat
, MsiQueryProductStateW(package
->ProductCode
) );
973 msi_set_property( package
->db
, szProductState
, bufstr
, len
);
976 if (!GetUserNameW( NULL
, &len
) && GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
979 if ((username
= msi_alloc( len
* sizeof(WCHAR
) )))
981 if (GetUserNameW( username
, &len
))
982 msi_set_property( package
->db
, szLogonUser
, username
, len
- 1 );
983 msi_free( username
);
987 if (!GetComputerNameW( NULL
, &len
) && GetLastError() == ERROR_BUFFER_OVERFLOW
)
990 if ((computername
= msi_alloc( len
* sizeof(WCHAR
) )))
992 if (GetComputerNameW( computername
, &len
))
993 msi_set_property( package
->db
, szComputerName
, computername
, len
);
994 msi_free( computername
);
999 static MSIPACKAGE
*msi_alloc_package( void )
1001 MSIPACKAGE
*package
;
1003 package
= alloc_msiobject( MSIHANDLETYPE_PACKAGE
, sizeof (MSIPACKAGE
),
1007 list_init( &package
->components
);
1008 list_init( &package
->features
);
1009 list_init( &package
->files
);
1010 list_init( &package
->filepatches
);
1011 list_init( &package
->tempfiles
);
1012 list_init( &package
->folders
);
1013 list_init( &package
->subscriptions
);
1014 list_init( &package
->appids
);
1015 list_init( &package
->classes
);
1016 list_init( &package
->mimes
);
1017 list_init( &package
->extensions
);
1018 list_init( &package
->progids
);
1019 list_init( &package
->RunningActions
);
1020 list_init( &package
->sourcelist_info
);
1021 list_init( &package
->sourcelist_media
);
1022 list_init( &package
->patches
);
1023 list_init( &package
->binaries
);
1024 list_init( &package
->cabinet_streams
);
1030 static UINT
msi_load_admin_properties(MSIPACKAGE
*package
)
1035 static const WCHAR stmname
[] = {'A','d','m','i','n','P','r','o','p','e','r','t','i','e','s',0};
1037 r
= read_stream_data(package
->db
->storage
, stmname
, FALSE
, &data
, &sz
);
1038 if (r
!= ERROR_SUCCESS
)
1041 r
= msi_parse_command_line(package
, (WCHAR
*)data
, TRUE
);
1047 void msi_adjust_privilege_properties( MSIPACKAGE
*package
)
1049 /* FIXME: this should depend on the user's privileges */
1050 if (msi_get_property_int( package
->db
, szAllUsers
, 0 ) == 2)
1052 TRACE("resetting ALLUSERS property from 2 to 1\n");
1053 msi_set_property( package
->db
, szAllUsers
, szOne
, -1 );
1055 msi_set_property( package
->db
, szAdminUser
, szOne
, -1 );
1058 MSIPACKAGE
*MSI_CreatePackage( MSIDATABASE
*db
)
1060 static const WCHAR fmtW
[] = {'%','u',0};
1061 MSIPACKAGE
*package
;
1068 package
= msi_alloc_package();
1071 msiobj_addref( &db
->hdr
);
1074 package
->LastAction
= NULL
;
1075 package
->LastActionTemplate
= NULL
;
1076 package
->LastActionResult
= MSI_NULL_INTEGER
;
1077 package
->WordCount
= 0;
1078 package
->PackagePath
= strdupW( db
->path
);
1080 create_temp_property_table( package
);
1081 msi_clone_properties( package
->db
);
1082 msi_adjust_privilege_properties( package
);
1084 package
->ProductCode
= msi_dup_property( package
->db
, szProductCode
);
1086 set_installer_properties( package
);
1088 package
->ui_level
= gUILevel
;
1089 len
= sprintfW( uilevel
, fmtW
, gUILevel
& INSTALLUILEVEL_MASK
);
1090 msi_set_property( package
->db
, szUILevel
, uilevel
, len
);
1092 r
= msi_load_suminfo_properties( package
);
1093 if (r
!= ERROR_SUCCESS
)
1095 msiobj_release( &package
->hdr
);
1099 if (package
->WordCount
& msidbSumInfoSourceTypeAdminImage
)
1100 msi_load_admin_properties( package
);
1102 package
->log_file
= INVALID_HANDLE_VALUE
;
1107 UINT
msi_download_file( LPCWSTR szUrl
, LPWSTR filename
)
1109 LPINTERNET_CACHE_ENTRY_INFOW cache_entry
;
1113 /* call will always fail, because size is 0,
1114 * but will return ERROR_FILE_NOT_FOUND first
1115 * if the file doesn't exist
1117 GetUrlCacheEntryInfoW( szUrl
, NULL
, &size
);
1118 if ( GetLastError() != ERROR_FILE_NOT_FOUND
)
1120 cache_entry
= msi_alloc( size
);
1121 if ( !GetUrlCacheEntryInfoW( szUrl
, cache_entry
, &size
) )
1123 UINT error
= GetLastError();
1124 msi_free( cache_entry
);
1128 lstrcpyW( filename
, cache_entry
->lpszLocalFileName
);
1129 msi_free( cache_entry
);
1130 return ERROR_SUCCESS
;
1133 hr
= URLDownloadToCacheFileW( NULL
, szUrl
, filename
, MAX_PATH
, 0, NULL
);
1136 WARN("failed to download %s to cache file\n", debugstr_w(szUrl
));
1137 return ERROR_FUNCTION_FAILED
;
1140 return ERROR_SUCCESS
;
1143 UINT
msi_create_empty_local_file( LPWSTR path
, LPCWSTR suffix
)
1145 static const WCHAR szInstaller
[] = {
1146 '\\','I','n','s','t','a','l','l','e','r','\\',0};
1147 static const WCHAR fmt
[] = {'%','x',0};
1148 DWORD time
, len
, i
, offset
;
1151 time
= GetTickCount();
1152 GetWindowsDirectoryW( path
, MAX_PATH
);
1153 strcatW( path
, szInstaller
);
1154 CreateDirectoryW( path
, NULL
);
1156 len
= strlenW(path
);
1157 for (i
= 0; i
< 0x10000; i
++)
1159 offset
= snprintfW( path
+ len
, MAX_PATH
- len
, fmt
, (time
+ i
) & 0xffff );
1160 memcpy( path
+ len
+ offset
, suffix
, (strlenW( suffix
) + 1) * sizeof(WCHAR
) );
1161 handle
= CreateFileW( path
, GENERIC_WRITE
, 0, NULL
,
1162 CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, 0 );
1163 if (handle
!= INVALID_HANDLE_VALUE
)
1165 CloseHandle(handle
);
1168 if (GetLastError() != ERROR_FILE_EXISTS
&&
1169 GetLastError() != ERROR_SHARING_VIOLATION
)
1170 return ERROR_FUNCTION_FAILED
;
1173 return ERROR_SUCCESS
;
1176 static enum platform
parse_platform( const WCHAR
*str
)
1178 if (!str
[0] || !strcmpW( str
, szIntel
)) return PLATFORM_INTEL
;
1179 else if (!strcmpW( str
, szIntel64
)) return PLATFORM_INTEL64
;
1180 else if (!strcmpW( str
, szX64
) || !strcmpW( str
, szAMD64
)) return PLATFORM_X64
;
1181 else if (!strcmpW( str
, szARM
)) return PLATFORM_ARM
;
1182 return PLATFORM_UNKNOWN
;
1185 static UINT
parse_suminfo( MSISUMMARYINFO
*si
, MSIPACKAGE
*package
)
1187 WCHAR
*template, *p
, *q
, *platform
;
1190 package
->version
= msi_suminfo_get_int32( si
, PID_PAGECOUNT
);
1191 TRACE("version: %d\n", package
->version
);
1193 template = msi_suminfo_dup_string( si
, PID_TEMPLATE
);
1195 return ERROR_SUCCESS
; /* native accepts missing template property */
1197 TRACE("template: %s\n", debugstr_w(template));
1199 p
= strchrW( template, ';' );
1202 WARN("invalid template string %s\n", debugstr_w(template));
1203 msi_free( template );
1204 return ERROR_PATCH_PACKAGE_INVALID
;
1207 platform
= template;
1208 if ((q
= strchrW( platform
, ',' ))) *q
= 0;
1209 package
->platform
= parse_platform( platform
);
1210 while (package
->platform
== PLATFORM_UNKNOWN
&& q
)
1213 if ((q
= strchrW( platform
, ',' ))) *q
= 0;
1214 package
->platform
= parse_platform( platform
);
1216 if (package
->platform
== PLATFORM_UNKNOWN
)
1218 WARN("unknown platform %s\n", debugstr_w(template));
1219 msi_free( template );
1220 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1225 msi_free( template );
1226 return ERROR_SUCCESS
;
1229 for (q
= p
; (q
= strchrW( q
, ',' )); q
++) count
++;
1231 package
->langids
= msi_alloc( count
* sizeof(LANGID
) );
1232 if (!package
->langids
)
1234 msi_free( template );
1235 return ERROR_OUTOFMEMORY
;
1241 q
= strchrW( p
, ',' );
1243 package
->langids
[i
] = atoiW( p
);
1248 package
->num_langids
= i
+ 1;
1250 msi_free( template );
1251 return ERROR_SUCCESS
;
1254 static UINT
validate_package( MSIPACKAGE
*package
)
1258 if (package
->platform
== PLATFORM_INTEL64
)
1259 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1261 if (package
->platform
== PLATFORM_ARM
)
1262 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1264 if (package
->platform
== PLATFORM_X64
)
1266 if (!is_64bit
&& !is_wow64
)
1267 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1268 if (package
->version
< 200)
1269 return ERROR_INSTALL_PACKAGE_INVALID
;
1271 if (!package
->num_langids
)
1273 return ERROR_SUCCESS
;
1275 for (i
= 0; i
< package
->num_langids
; i
++)
1277 LANGID langid
= package
->langids
[i
];
1279 if (PRIMARYLANGID( langid
) == LANG_NEUTRAL
)
1281 langid
= MAKELANGID( PRIMARYLANGID( GetSystemDefaultLangID() ), SUBLANGID( langid
) );
1283 if (SUBLANGID( langid
) == SUBLANG_NEUTRAL
)
1285 langid
= MAKELANGID( PRIMARYLANGID( langid
), SUBLANGID( GetSystemDefaultLangID() ) );
1287 if (IsValidLocale( langid
, LCID_INSTALLED
))
1288 return ERROR_SUCCESS
;
1290 return ERROR_INSTALL_LANGUAGE_UNSUPPORTED
;
1293 static WCHAR
*get_product_code( MSIDATABASE
*db
)
1295 static const WCHAR query
[] = {
1296 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
1297 'F','R','O','M',' ','`','P','r','o','p','e','r','t','y','`',' ',
1298 'W','H','E','R','E',' ','`','P','r','o','p','e','r','t','y','`','=',
1299 '\'','P','r','o','d','u','c','t','C','o','d','e','\'',0};
1304 if (MSI_DatabaseOpenViewW( db
, query
, &view
) != ERROR_SUCCESS
)
1308 if (MSI_ViewExecute( view
, 0 ) != ERROR_SUCCESS
)
1310 MSI_ViewClose( view
);
1311 msiobj_release( &view
->hdr
);
1314 if (MSI_ViewFetch( view
, &rec
) == ERROR_SUCCESS
)
1316 ret
= strdupW( MSI_RecordGetString( rec
, 1 ) );
1317 msiobj_release( &rec
->hdr
);
1319 MSI_ViewClose( view
);
1320 msiobj_release( &view
->hdr
);
1324 static UINT
get_registered_local_package( const WCHAR
*product
, const WCHAR
*package
, WCHAR
*localfile
)
1326 MSIINSTALLCONTEXT context
;
1327 HKEY product_key
, props_key
;
1328 WCHAR
*registered_package
= NULL
, unsquashed
[GUID_SIZE
];
1331 r
= msi_locate_product( product
, &context
);
1332 if (r
!= ERROR_SUCCESS
)
1335 r
= MSIREG_OpenProductKey( product
, NULL
, context
, &product_key
, FALSE
);
1336 if (r
!= ERROR_SUCCESS
)
1339 r
= MSIREG_OpenInstallProps( product
, context
, NULL
, &props_key
, FALSE
);
1340 if (r
!= ERROR_SUCCESS
)
1342 RegCloseKey( product_key
);
1345 r
= ERROR_FUNCTION_FAILED
;
1346 registered_package
= msi_reg_get_val_str( product_key
, INSTALLPROPERTY_PACKAGECODEW
);
1347 if (!registered_package
)
1350 unsquash_guid( registered_package
, unsquashed
);
1351 if (!strcmpiW( package
, unsquashed
))
1353 WCHAR
*filename
= msi_reg_get_val_str( props_key
, INSTALLPROPERTY_LOCALPACKAGEW
);
1357 strcpyW( localfile
, filename
);
1358 msi_free( filename
);
1362 msi_free( registered_package
);
1363 RegCloseKey( props_key
);
1364 RegCloseKey( product_key
);
1368 static WCHAR
*get_package_code( MSIDATABASE
*db
)
1374 r
= msi_get_suminfo( db
->storage
, 0, &si
);
1375 if (r
!= ERROR_SUCCESS
)
1377 r
= msi_get_db_suminfo( db
, 0, &si
);
1378 if (r
!= ERROR_SUCCESS
)
1380 WARN("failed to load summary info %u\n", r
);
1384 ret
= msi_suminfo_dup_string( si
, PID_REVNUMBER
);
1385 msiobj_release( &si
->hdr
);
1389 static UINT
get_local_package( const WCHAR
*filename
, WCHAR
*localfile
)
1391 WCHAR
*product_code
, *package_code
;
1395 if ((r
= MSI_OpenDatabaseW( filename
, MSIDBOPEN_READONLY
, &db
)) != ERROR_SUCCESS
)
1397 if (GetFileAttributesW( filename
) == INVALID_FILE_ATTRIBUTES
)
1398 return ERROR_FILE_NOT_FOUND
;
1401 if (!(product_code
= get_product_code( db
)))
1403 msiobj_release( &db
->hdr
);
1404 return ERROR_INSTALL_PACKAGE_INVALID
;
1406 if (!(package_code
= get_package_code( db
)))
1408 msi_free( product_code
);
1409 msiobj_release( &db
->hdr
);
1410 return ERROR_INSTALL_PACKAGE_INVALID
;
1412 r
= get_registered_local_package( product_code
, package_code
, localfile
);
1413 msi_free( package_code
);
1414 msi_free( product_code
);
1415 msiobj_release( &db
->hdr
);
1419 UINT
msi_set_original_database_property( MSIDATABASE
*db
, const WCHAR
*package
)
1423 if (UrlIsW( package
, URLIS_URL
))
1424 r
= msi_set_property( db
, szOriginalDatabase
, package
, -1 );
1425 else if (package
[0] == '#')
1426 r
= msi_set_property( db
, szOriginalDatabase
, db
->path
, -1 );
1432 if (!(len
= GetFullPathNameW( package
, 0, NULL
, NULL
))) return GetLastError();
1433 if (!(path
= msi_alloc( len
* sizeof(WCHAR
) ))) return ERROR_OUTOFMEMORY
;
1434 len
= GetFullPathNameW( package
, len
, path
, NULL
);
1435 r
= msi_set_property( db
, szOriginalDatabase
, path
, len
);
1441 UINT
MSI_OpenPackageW(LPCWSTR szPackage
, MSIPACKAGE
**pPackage
)
1443 static const WCHAR dotmsi
[] = {'.','m','s','i',0};
1445 MSIPACKAGE
*package
;
1447 MSIRECORD
*data_row
, *info_row
;
1449 WCHAR localfile
[MAX_PATH
], cachefile
[MAX_PATH
];
1450 LPCWSTR file
= szPackage
;
1453 BOOL delete_on_close
= FALSE
;
1454 WCHAR
*info_template
, *productname
;
1456 TRACE("%s %p\n", debugstr_w(szPackage
), pPackage
);
1458 MSI_ProcessMessage(NULL
, INSTALLMESSAGE_INITIALIZE
, 0);
1461 if( szPackage
[0] == '#' )
1463 handle
= atoiW(&szPackage
[1]);
1464 db
= msihandle2msiinfo( handle
, MSIHANDLETYPE_DATABASE
);
1469 if (!(remote
= msi_get_remote(handle
)))
1470 return ERROR_INVALID_HANDLE
;
1472 WARN("MsiOpenPackage not allowed during a custom action!\n");
1474 return ERROR_FUNCTION_FAILED
;
1479 if ( UrlIsW( szPackage
, URLIS_URL
) )
1481 r
= msi_download_file( szPackage
, cachefile
);
1482 if (r
!= ERROR_SUCCESS
)
1487 r
= get_local_package( file
, localfile
);
1488 if (r
!= ERROR_SUCCESS
|| GetFileAttributesW( localfile
) == INVALID_FILE_ATTRIBUTES
)
1490 r
= msi_create_empty_local_file( localfile
, dotmsi
);
1491 if (r
!= ERROR_SUCCESS
)
1494 if (!CopyFileW( file
, localfile
, FALSE
))
1497 WARN("unable to copy package %s to %s (%u)\n", debugstr_w(file
), debugstr_w(localfile
), r
);
1498 DeleteFileW( localfile
);
1501 delete_on_close
= TRUE
;
1503 TRACE("opening package %s\n", debugstr_w( localfile
));
1504 r
= MSI_OpenDatabaseW( localfile
, MSIDBOPEN_TRANSACT
, &db
);
1505 if (r
!= ERROR_SUCCESS
)
1508 package
= MSI_CreatePackage( db
);
1509 msiobj_release( &db
->hdr
);
1510 if (!package
) return ERROR_INSTALL_PACKAGE_INVALID
;
1511 package
->localfile
= strdupW( localfile
);
1512 package
->delete_on_close
= delete_on_close
;
1514 r
= msi_get_suminfo( db
->storage
, 0, &si
);
1515 if (r
!= ERROR_SUCCESS
)
1517 r
= msi_get_db_suminfo( db
, 0, &si
);
1518 if (r
!= ERROR_SUCCESS
)
1520 WARN("failed to load summary info\n");
1521 msiobj_release( &package
->hdr
);
1522 return ERROR_INSTALL_PACKAGE_INVALID
;
1525 r
= parse_suminfo( si
, package
);
1526 msiobj_release( &si
->hdr
);
1527 if (r
!= ERROR_SUCCESS
)
1529 WARN("failed to parse summary info %u\n", r
);
1530 msiobj_release( &package
->hdr
);
1533 r
= validate_package( package
);
1534 if (r
!= ERROR_SUCCESS
)
1536 msiobj_release( &package
->hdr
);
1539 msi_set_property( package
->db
, szDatabase
, db
->path
, -1 );
1540 set_installed_prop( package
);
1541 msi_set_context( package
);
1545 WCHAR patch_code
[GUID_SIZE
];
1546 r
= MsiEnumPatchesExW( package
->ProductCode
, NULL
, package
->Context
,
1547 MSIPATCHSTATE_APPLIED
, index
, patch_code
, NULL
, NULL
, NULL
, NULL
);
1548 if (r
!= ERROR_SUCCESS
)
1551 TRACE("found registered patch %s\n", debugstr_w(patch_code
));
1553 r
= msi_apply_registered_patch( package
, patch_code
);
1554 if (r
!= ERROR_SUCCESS
)
1556 ERR("registered patch failed to apply %u\n", r
);
1557 msiobj_release( &package
->hdr
);
1562 if (index
) msi_adjust_privilege_properties( package
);
1564 r
= msi_set_original_database_property( package
->db
, szPackage
);
1565 if (r
!= ERROR_SUCCESS
)
1567 msiobj_release( &package
->hdr
);
1571 package
->log_file
= CreateFileW( gszLogFile
, GENERIC_WRITE
, FILE_SHARE_WRITE
, NULL
,
1572 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1574 /* FIXME: when should these messages be sent? */
1575 data_row
= MSI_CreateRecord(3);
1577 return ERROR_OUTOFMEMORY
;
1578 MSI_RecordSetStringW(data_row
, 0, NULL
);
1579 MSI_RecordSetInteger(data_row
, 1, 0);
1580 MSI_RecordSetInteger(data_row
, 2, package
->num_langids
? package
->langids
[0] : 0);
1581 MSI_RecordSetInteger(data_row
, 3, msi_get_string_table_codepage(package
->db
->strings
));
1582 MSI_ProcessMessageVerbatim(package
, INSTALLMESSAGE_COMMONDATA
, data_row
);
1584 info_row
= MSI_CreateRecord(0);
1587 msiobj_release(&data_row
->hdr
);
1588 return ERROR_OUTOFMEMORY
;
1590 info_template
= msi_get_error_message(package
->db
, MSIERR_INFO_LOGGINGSTART
);
1591 MSI_RecordSetStringW(info_row
, 0, info_template
);
1592 msi_free(info_template
);
1593 MSI_ProcessMessage(package
, INSTALLMESSAGE_INFO
|MB_ICONHAND
, info_row
);
1595 MSI_ProcessMessage(package
, INSTALLMESSAGE_COMMONDATA
, data_row
);
1597 productname
= msi_dup_property(package
->db
, INSTALLPROPERTY_PRODUCTNAMEW
);
1598 MSI_RecordSetInteger(data_row
, 1, 1);
1599 MSI_RecordSetStringW(data_row
, 2, productname
);
1600 MSI_RecordSetStringW(data_row
, 3, NULL
);
1601 MSI_ProcessMessage(package
, INSTALLMESSAGE_COMMONDATA
, data_row
);
1603 msi_free(productname
);
1604 msiobj_release(&info_row
->hdr
);
1605 msiobj_release(&data_row
->hdr
);
1607 *pPackage
= package
;
1608 return ERROR_SUCCESS
;
1611 UINT WINAPI
MsiOpenPackageExW(LPCWSTR szPackage
, DWORD dwOptions
, MSIHANDLE
*phPackage
)
1613 MSIPACKAGE
*package
= NULL
;
1616 TRACE("%s %08x %p\n", debugstr_w(szPackage
), dwOptions
, phPackage
);
1618 if( !szPackage
|| !phPackage
)
1619 return ERROR_INVALID_PARAMETER
;
1623 FIXME("Should create an empty database and package\n");
1624 return ERROR_FUNCTION_FAILED
;
1628 FIXME("dwOptions %08x not supported\n", dwOptions
);
1630 ret
= MSI_OpenPackageW( szPackage
, &package
);
1631 if( ret
== ERROR_SUCCESS
)
1633 *phPackage
= alloc_msihandle( &package
->hdr
);
1635 ret
= ERROR_NOT_ENOUGH_MEMORY
;
1636 msiobj_release( &package
->hdr
);
1639 MSI_ProcessMessage(NULL
, INSTALLMESSAGE_TERMINATE
, 0);
1644 UINT WINAPI
MsiOpenPackageW(LPCWSTR szPackage
, MSIHANDLE
*phPackage
)
1646 return MsiOpenPackageExW( szPackage
, 0, phPackage
);
1649 UINT WINAPI
MsiOpenPackageExA(LPCSTR szPackage
, DWORD dwOptions
, MSIHANDLE
*phPackage
)
1651 LPWSTR szwPack
= NULL
;
1656 szwPack
= strdupAtoW( szPackage
);
1658 return ERROR_OUTOFMEMORY
;
1661 ret
= MsiOpenPackageExW( szwPack
, dwOptions
, phPackage
);
1663 msi_free( szwPack
);
1668 UINT WINAPI
MsiOpenPackageA(LPCSTR szPackage
, MSIHANDLE
*phPackage
)
1670 return MsiOpenPackageExA( szPackage
, 0, phPackage
);
1673 MSIHANDLE WINAPI
MsiGetActiveDatabase(MSIHANDLE hInstall
)
1675 MSIPACKAGE
*package
;
1676 MSIHANDLE handle
= 0;
1679 TRACE("(%d)\n",hInstall
);
1681 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
1684 handle
= alloc_msihandle( &package
->db
->hdr
);
1685 msiobj_release( &package
->hdr
);
1687 else if ((remote
= msi_get_remote(hInstall
)))
1689 handle
= remote_GetActiveDatabase(remote
);
1690 handle
= alloc_msi_remote_handle(handle
);
1696 static INT
internal_ui_handler(MSIPACKAGE
*package
, INSTALLMESSAGE eMessageType
, MSIRECORD
*record
, LPCWSTR message
)
1698 static const WCHAR szActionData
[] = {'A','c','t','i','o','n','D','a','t','a',0};
1699 static const WCHAR szActionText
[] = {'A','c','t','i','o','n','T','e','x','t',0};
1700 static const WCHAR szSetProgress
[] = {'S','e','t','P','r','o','g','r','e','s','s',0};
1701 static const WCHAR szWindows_Installer
[] =
1702 {'W','i','n','d','o','w','s',' ','I','n','s','t','a','l','l','e','r',0};
1704 if (!package
|| (package
->ui_level
& INSTALLUILEVEL_MASK
) == INSTALLUILEVEL_NONE
)
1707 /* todo: check if message needs additional styles (topmost/foreground/modality?) */
1709 switch (eMessageType
& 0xff000000)
1711 case INSTALLMESSAGE_FATALEXIT
:
1712 case INSTALLMESSAGE_ERROR
:
1713 case INSTALLMESSAGE_OUTOFDISKSPACE
:
1714 if (package
->ui_level
& INSTALLUILEVEL_PROGRESSONLY
) return 0;
1715 if (!(eMessageType
& MB_ICONMASK
))
1716 eMessageType
|= MB_ICONEXCLAMATION
;
1717 return MessageBoxW(gUIhwnd
, message
, szWindows_Installer
, eMessageType
& 0x00ffffff);
1718 case INSTALLMESSAGE_WARNING
:
1719 if (package
->ui_level
& INSTALLUILEVEL_PROGRESSONLY
) return 0;
1720 if (!(eMessageType
& MB_ICONMASK
))
1721 eMessageType
|= MB_ICONASTERISK
;
1722 return MessageBoxW(gUIhwnd
, message
, szWindows_Installer
, eMessageType
& 0x00ffffff);
1723 case INSTALLMESSAGE_USER
:
1724 if (package
->ui_level
& INSTALLUILEVEL_PROGRESSONLY
) return 0;
1725 if (!(eMessageType
& MB_ICONMASK
))
1726 eMessageType
|= MB_USERICON
;
1727 return MessageBoxW(gUIhwnd
, message
, szWindows_Installer
, eMessageType
& 0x00ffffff);
1728 case INSTALLMESSAGE_INFO
:
1729 case INSTALLMESSAGE_INITIALIZE
:
1730 case INSTALLMESSAGE_TERMINATE
:
1731 case INSTALLMESSAGE_INSTALLSTART
:
1732 case INSTALLMESSAGE_INSTALLEND
:
1734 case INSTALLMESSAGE_SHOWDIALOG
:
1736 LPWSTR dialog
= msi_dup_record_field(record
, 0);
1737 INT rc
= ACTION_DialogBox(package
, dialog
);
1741 case INSTALLMESSAGE_ACTIONSTART
:
1744 MSIRECORD
*uirow
= MSI_CreateRecord(1);
1745 if (!uirow
) return -1;
1746 deformat_string(package
, MSI_RecordGetString(record
, 2), &deformatted
);
1747 MSI_RecordSetStringW(uirow
, 1, deformatted
);
1748 msi_event_fire(package
, szActionText
, uirow
);
1750 msi_free(deformatted
);
1751 msiobj_release(&uirow
->hdr
);
1754 case INSTALLMESSAGE_ACTIONDATA
:
1756 MSIRECORD
*uirow
= MSI_CreateRecord(1);
1757 if (!uirow
) return -1;
1758 MSI_RecordSetStringW(uirow
, 1, message
);
1759 msi_event_fire(package
, szActionData
, uirow
);
1760 msiobj_release(&uirow
->hdr
);
1762 if (package
->action_progress_increment
)
1764 uirow
= MSI_CreateRecord(2);
1765 if (!uirow
) return -1;
1766 MSI_RecordSetInteger(uirow
, 1, 2);
1767 MSI_RecordSetInteger(uirow
, 2, package
->action_progress_increment
);
1768 msi_event_fire(package
, szSetProgress
, uirow
);
1769 msiobj_release(&uirow
->hdr
);
1773 case INSTALLMESSAGE_PROGRESS
:
1774 msi_event_fire(package
, szSetProgress
, record
);
1776 case INSTALLMESSAGE_COMMONDATA
:
1777 switch (MSI_RecordGetInteger(record
, 1))
1788 FIXME("internal UI not implemented for message 0x%08x (UI level = %x)\n", eMessageType
, package
->ui_level
);
1793 static const WCHAR szActionNotFound
[] = {'D','E','B','U','G',':',' ','E','r','r','o','r',' ','[','1',']',':',' ',' ','A','c','t','i','o','n',' ','n','o','t',' ','f','o','u','n','d',':',' ','[','2',']',0};
1802 {2726, szActionNotFound
},
1806 static LPCWSTR
get_internal_error_message(int error
)
1810 while (internal_errors
[i
].id
!= 0)
1812 if (internal_errors
[i
].id
== error
)
1813 return internal_errors
[i
].text
;
1817 FIXME("missing error message %d\n", error
);
1821 /* Returned string must be freed */
1822 LPWSTR
msi_get_error_message(MSIDATABASE
*db
, int error
)
1824 static const WCHAR query
[] =
1825 {'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ',
1826 'F','R','O','M',' ','`','E','r','r','o','r','`',' ','W','H','E','R','E',' ',
1827 '`','E','r','r','o','r','`',' ','=',' ','%','i',0};
1831 if ((record
= MSI_QueryGetRecord(db
, query
, error
)))
1833 ret
= msi_dup_record_field(record
, 1);
1834 msiobj_release(&record
->hdr
);
1836 else if (error
< 2000)
1838 int len
= LoadStringW(msi_hInstance
, IDS_ERROR_BASE
+ error
, (LPWSTR
) &ret
, 0);
1841 ret
= msi_alloc((len
+ 1) * sizeof(WCHAR
));
1842 LoadStringW(msi_hInstance
, IDS_ERROR_BASE
+ error
, ret
, len
+ 1);
1851 INT
MSI_ProcessMessageVerbatim(MSIPACKAGE
*package
, INSTALLMESSAGE eMessageType
, MSIRECORD
*record
)
1853 LPWSTR message
= {0};
1855 DWORD log_type
= 1 << (eMessageType
>> 24);
1860 TRACE("%x\n", eMessageType
);
1861 if (TRACE_ON(msi
)) dump_record(record
);
1863 if (!package
|| !record
)
1866 res
= MSI_FormatRecordW(package
, record
, message
, &len
);
1867 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
)
1870 message
= msi_alloc(len
* sizeof(WCHAR
));
1871 if (!message
) return ERROR_OUTOFMEMORY
;
1872 MSI_FormatRecordW(package
, record
, message
, &len
);
1875 /* convert it to ASCII */
1876 len
= WideCharToMultiByte( CP_ACP
, 0, message
, -1, NULL
, 0, NULL
, NULL
);
1877 msg
= msi_alloc( len
);
1878 WideCharToMultiByte( CP_ACP
, 0, message
, -1, msg
, len
, NULL
, NULL
);
1880 if (gUIHandlerRecord
&& (gUIFilterRecord
& log_type
))
1882 MSIHANDLE rec
= alloc_msihandle(&record
->hdr
);
1883 TRACE("Calling UI handler %p(pvContext=%p, iMessageType=%08x, hRecord=%u)\n",
1884 gUIHandlerRecord
, gUIContextRecord
, eMessageType
, rec
);
1885 rc
= gUIHandlerRecord( gUIContextRecord
, eMessageType
, rec
);
1886 MsiCloseHandle( rec
);
1888 if (!rc
&& gUIHandlerW
&& (gUIFilter
& log_type
))
1890 TRACE("Calling UI handler %p(pvContext=%p, iMessageType=%08x, szMessage=%s)\n",
1891 gUIHandlerW
, gUIContext
, eMessageType
, debugstr_w(message
));
1892 rc
= gUIHandlerW( gUIContext
, eMessageType
, message
);
1894 else if (!rc
&& gUIHandlerA
&& (gUIFilter
& log_type
))
1896 TRACE("Calling UI handler %p(pvContext=%p, iMessageType=%08x, szMessage=%s)\n",
1897 gUIHandlerA
, gUIContext
, eMessageType
, debugstr_a(msg
));
1898 rc
= gUIHandlerA( gUIContext
, eMessageType
, msg
);
1902 rc
= internal_ui_handler(package
, eMessageType
, record
, message
);
1904 if (!rc
&& package
&& package
->log_file
!= INVALID_HANDLE_VALUE
&&
1905 (eMessageType
& 0xff000000) != INSTALLMESSAGE_PROGRESS
)
1908 WriteFile( package
->log_file
, msg
, len
- 1, &written
, NULL
);
1909 WriteFile( package
->log_file
, "\n", 1, &written
, NULL
);
1912 msi_free( message
);
1917 INT
MSI_ProcessMessage( MSIPACKAGE
*package
, INSTALLMESSAGE eMessageType
, MSIRECORD
*record
)
1919 switch (eMessageType
& 0xff000000)
1921 case INSTALLMESSAGE_FATALEXIT
:
1922 case INSTALLMESSAGE_ERROR
:
1923 case INSTALLMESSAGE_WARNING
:
1924 case INSTALLMESSAGE_USER
:
1925 case INSTALLMESSAGE_INFO
:
1926 case INSTALLMESSAGE_OUTOFDISKSPACE
:
1927 if (MSI_RecordGetInteger(record
, 1) != MSI_NULL_INTEGER
)
1932 LPWSTR template_rec
= NULL
, template_prefix
= NULL
;
1933 int error
= MSI_RecordGetInteger(record
, 1);
1935 if (MSI_RecordIsNull(record
, 0))
1939 template_rec
= msi_get_error_message(package
->db
, error
);
1941 if (!template_rec
&& error
>= 2000)
1943 /* internal error, not localized */
1944 if ((template_rec
= (LPWSTR
) get_internal_error_message(error
)))
1946 MSI_RecordSetStringW(record
, 0, template_rec
);
1947 MSI_ProcessMessageVerbatim(package
, INSTALLMESSAGE_INFO
, record
);
1949 template_rec
= msi_get_error_message(package
->db
, MSIERR_INSTALLERROR
);
1950 MSI_RecordSetStringW(record
, 0, template_rec
);
1951 MSI_ProcessMessageVerbatim(package
, eMessageType
, record
);
1952 msi_free(template_rec
);
1958 template_rec
= msi_dup_record_field(record
, 0);
1960 template_prefix
= msi_get_error_message(package
->db
, eMessageType
>> 24);
1961 if (!template_prefix
) template_prefix
= strdupW(szEmpty
);
1965 /* always returns 0 */
1966 MSI_RecordSetStringW(record
, 0, template_prefix
);
1967 MSI_ProcessMessageVerbatim(package
, eMessageType
, record
);
1968 msi_free(template_prefix
);
1972 template = msi_alloc((strlenW(template_rec
) + strlenW(template_prefix
) + 1) * sizeof(WCHAR
));
1973 if (!template) return ERROR_OUTOFMEMORY
;
1975 strcpyW(template, template_prefix
);
1976 strcatW(template, template_rec
);
1977 MSI_RecordSetStringW(record
, 0, template);
1979 msi_free(template_prefix
);
1980 msi_free(template_rec
);
1984 case INSTALLMESSAGE_ACTIONSTART
:
1986 WCHAR
*template = msi_get_error_message(package
->db
, MSIERR_ACTIONSTART
);
1987 MSI_RecordSetStringW(record
, 0, template);
1990 msi_free(package
->LastAction
);
1991 msi_free(package
->LastActionTemplate
);
1992 package
->LastAction
= msi_dup_record_field(record
, 1);
1993 if (!package
->LastAction
) package
->LastAction
= strdupW(szEmpty
);
1994 package
->LastActionTemplate
= msi_dup_record_field(record
, 3);
1997 case INSTALLMESSAGE_ACTIONDATA
:
1998 if (package
->LastAction
&& package
->LastActionTemplate
)
2000 static const WCHAR template_s
[] =
2001 {'{','{','%','s',':',' ','}','}','%','s',0};
2004 template = msi_alloc((strlenW(package
->LastAction
) + strlenW(package
->LastActionTemplate
) + 7) * sizeof(WCHAR
));
2005 if (!template) return ERROR_OUTOFMEMORY
;
2006 sprintfW(template, template_s
, package
->LastAction
, package
->LastActionTemplate
);
2007 MSI_RecordSetStringW(record
, 0, template);
2011 case INSTALLMESSAGE_COMMONDATA
:
2013 WCHAR
*template = msi_get_error_message(package
->db
, MSIERR_COMMONDATA
);
2014 MSI_RecordSetStringW(record
, 0, template);
2020 return MSI_ProcessMessageVerbatim(package
, eMessageType
, record
);
2023 INT WINAPI
MsiProcessMessage( MSIHANDLE hInstall
, INSTALLMESSAGE eMessageType
,
2026 UINT ret
= ERROR_INVALID_HANDLE
;
2027 MSIPACKAGE
*package
= NULL
;
2028 MSIRECORD
*record
= NULL
;
2030 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_INITIALIZE
||
2031 (eMessageType
& 0xff000000) == INSTALLMESSAGE_TERMINATE
)
2034 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_COMMONDATA
&&
2035 MsiRecordGetInteger(hRecord
, 1) != 2)
2038 record
= msihandle2msiinfo(hRecord
, MSIHANDLETYPE_RECORD
);
2040 return ERROR_INVALID_HANDLE
;
2042 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
2047 if (!(remote
= msi_get_remote(hInstall
)))
2048 return ERROR_INVALID_HANDLE
;
2050 ret
= remote_ProcessMessage(remote
, eMessageType
, (struct wire_record
*)&record
->count
);
2052 msiobj_release(&record
->hdr
);
2056 ret
= MSI_ProcessMessage( package
, eMessageType
, record
);
2058 msiobj_release( &package
->hdr
);
2064 UINT WINAPI
MsiSetPropertyA( MSIHANDLE hInstall
, LPCSTR szName
, LPCSTR szValue
)
2066 LPWSTR szwName
= NULL
, szwValue
= NULL
;
2067 UINT r
= ERROR_OUTOFMEMORY
;
2069 szwName
= strdupAtoW( szName
);
2070 if( szName
&& !szwName
)
2073 szwValue
= strdupAtoW( szValue
);
2074 if( szValue
&& !szwValue
)
2077 r
= MsiSetPropertyW( hInstall
, szwName
, szwValue
);
2080 msi_free( szwName
);
2081 msi_free( szwValue
);
2086 void msi_reset_folders( MSIPACKAGE
*package
, BOOL source
)
2090 LIST_FOR_EACH_ENTRY( folder
, &package
->folders
, MSIFOLDER
, entry
)
2094 msi_free( folder
->ResolvedSource
);
2095 folder
->ResolvedSource
= NULL
;
2099 msi_free( folder
->ResolvedTarget
);
2100 folder
->ResolvedTarget
= NULL
;
2105 UINT
msi_set_property( MSIDATABASE
*db
, const WCHAR
*name
, const WCHAR
*value
, int len
)
2107 static const WCHAR insert_query
[] = {
2108 'I','N','S','E','R','T',' ','I','N','T','O',' ',
2109 '`','_','P','r','o','p','e','r','t','y','`',' ',
2110 '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
2111 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
2112 static const WCHAR update_query
[] = {
2113 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
2114 'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ','W','H','E','R','E',' ',
2115 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
2116 static const WCHAR delete_query
[] = {
2117 'D','E','L','E','T','E',' ','F','R','O','M',' ',
2118 '`','_','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2119 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
2121 MSIRECORD
*row
= NULL
;
2126 TRACE("%p %s %s %d\n", db
, debugstr_w(name
), debugstr_wn(value
, len
), len
);
2129 return ERROR_INVALID_PARAMETER
;
2131 /* this one is weird... */
2133 return value
? ERROR_FUNCTION_FAILED
: ERROR_SUCCESS
;
2135 if (value
&& len
< 0) len
= strlenW( value
);
2137 rc
= msi_get_property( db
, name
, 0, &sz
);
2138 if (!value
|| (!*value
&& !len
))
2140 sprintfW( query
, delete_query
, name
);
2142 else if (rc
== ERROR_MORE_DATA
|| rc
== ERROR_SUCCESS
)
2144 sprintfW( query
, update_query
, name
);
2145 row
= MSI_CreateRecord(1);
2146 msi_record_set_string( row
, 1, value
, len
);
2150 strcpyW( query
, insert_query
);
2151 row
= MSI_CreateRecord(2);
2152 msi_record_set_string( row
, 1, name
, -1 );
2153 msi_record_set_string( row
, 2, value
, len
);
2156 rc
= MSI_DatabaseOpenViewW(db
, query
, &view
);
2157 if (rc
== ERROR_SUCCESS
)
2159 rc
= MSI_ViewExecute(view
, row
);
2160 MSI_ViewClose(view
);
2161 msiobj_release(&view
->hdr
);
2163 if (row
) msiobj_release(&row
->hdr
);
2167 UINT WINAPI
MsiSetPropertyW( MSIHANDLE hInstall
, LPCWSTR szName
, LPCWSTR szValue
)
2169 MSIPACKAGE
*package
;
2172 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
2177 if (!(remote
= msi_get_remote(hInstall
)))
2178 return ERROR_INVALID_HANDLE
;
2180 return remote_SetProperty(remote
, szName
, szValue
);
2183 ret
= msi_set_property( package
->db
, szName
, szValue
, -1 );
2184 if (ret
== ERROR_SUCCESS
&& !strcmpW( szName
, szSourceDir
))
2185 msi_reset_folders( package
, TRUE
);
2187 msiobj_release( &package
->hdr
);
2191 static MSIRECORD
*msi_get_property_row( MSIDATABASE
*db
, LPCWSTR name
)
2193 static const WCHAR query
[]= {
2194 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
2195 'F','R','O','M',' ' ,'`','_','P','r','o','p','e','r','t','y','`',' ',
2196 'W','H','E','R','E',' ' ,'`','_','P','r','o','p','e','r','t','y','`','=','?',0};
2197 MSIRECORD
*rec
, *row
= NULL
;
2201 static const WCHAR szDate
[] = {'D','a','t','e',0};
2202 static const WCHAR szTime
[] = {'T','i','m','e',0};
2206 if (!name
|| !*name
)
2209 if (!strcmpW(name
, szDate
))
2211 length
= GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_SHORTDATE
, NULL
, NULL
, NULL
, 0);
2214 buffer
= msi_alloc(length
* sizeof(WCHAR
));
2215 GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_SHORTDATE
, NULL
, NULL
, buffer
, length
);
2217 row
= MSI_CreateRecord(1);
2223 MSI_RecordSetStringW(row
, 1, buffer
);
2227 else if (!strcmpW(name
, szTime
))
2229 length
= GetTimeFormatW(LOCALE_USER_DEFAULT
, TIME_NOTIMEMARKER
, NULL
, NULL
, NULL
, 0);
2232 buffer
= msi_alloc(length
* sizeof(WCHAR
));
2233 GetTimeFormatW(LOCALE_USER_DEFAULT
, TIME_NOTIMEMARKER
, NULL
, NULL
, buffer
, length
);
2235 row
= MSI_CreateRecord(1);
2241 MSI_RecordSetStringW(row
, 1, buffer
);
2246 rec
= MSI_CreateRecord(1);
2250 MSI_RecordSetStringW(rec
, 1, name
);
2252 r
= MSI_DatabaseOpenViewW(db
, query
, &view
);
2253 if (r
== ERROR_SUCCESS
)
2255 MSI_ViewExecute(view
, rec
);
2256 MSI_ViewFetch(view
, &row
);
2257 MSI_ViewClose(view
);
2258 msiobj_release(&view
->hdr
);
2260 msiobj_release(&rec
->hdr
);
2264 /* internal function, not compatible with MsiGetPropertyW */
2265 UINT
msi_get_property( MSIDATABASE
*db
, LPCWSTR szName
,
2266 LPWSTR szValueBuf
, LPDWORD pchValueBuf
)
2269 UINT rc
= ERROR_FUNCTION_FAILED
;
2271 TRACE("%p %s %p %p\n", db
, debugstr_w(szName
), szValueBuf
, pchValueBuf
);
2273 row
= msi_get_property_row( db
, szName
);
2275 if (*pchValueBuf
> 0)
2280 rc
= MSI_RecordGetStringW(row
, 1, szValueBuf
, pchValueBuf
);
2281 msiobj_release(&row
->hdr
);
2284 if (rc
== ERROR_SUCCESS
)
2285 TRACE("returning %s for property %s\n", debugstr_wn(szValueBuf
, *pchValueBuf
),
2286 debugstr_w(szName
));
2287 else if (rc
== ERROR_MORE_DATA
)
2288 TRACE("need %d sized buffer for %s\n", *pchValueBuf
,
2289 debugstr_w(szName
));
2293 TRACE("property %s not found\n", debugstr_w(szName
));
2299 LPWSTR
msi_dup_property(MSIDATABASE
*db
, LPCWSTR prop
)
2305 r
= msi_get_property(db
, prop
, NULL
, &sz
);
2306 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
2310 str
= msi_alloc(sz
* sizeof(WCHAR
));
2311 r
= msi_get_property(db
, prop
, str
, &sz
);
2312 if (r
!= ERROR_SUCCESS
)
2321 int msi_get_property_int( MSIDATABASE
*db
, LPCWSTR prop
, int def
)
2323 LPWSTR str
= msi_dup_property( db
, prop
);
2324 int val
= str
? atoiW(str
) : def
;
2329 static UINT
MSI_GetProperty( MSIHANDLE handle
, LPCWSTR name
,
2330 awstring
*szValueBuf
, LPDWORD pchValueBuf
)
2332 MSIPACKAGE
*package
;
2333 MSIRECORD
*row
= NULL
;
2334 UINT r
= ERROR_FUNCTION_FAILED
;
2338 TRACE("%u %s %p %p\n", handle
, debugstr_w(name
),
2339 szValueBuf
->str
.w
, pchValueBuf
);
2342 return ERROR_INVALID_PARAMETER
;
2344 package
= msihandle2msiinfo( handle
, MSIHANDLETYPE_PACKAGE
);
2347 LPWSTR value
= NULL
, buffer
;
2350 if (!(remote
= msi_get_remote(handle
)))
2351 return ERROR_INVALID_HANDLE
;
2353 r
= remote_GetProperty(remote
, name
, &value
, &len
);
2354 if (r
!= ERROR_SUCCESS
)
2357 /* String might contain embedded nulls.
2358 * Native returns the correct size but truncates the string. */
2359 buffer
= heap_alloc_zero((len
+ 1) * sizeof(WCHAR
));
2362 midl_user_free(value
);
2363 return ERROR_OUTOFMEMORY
;
2365 strcpyW(buffer
, value
);
2367 r
= msi_strcpy_to_awstring(buffer
, len
, szValueBuf
, pchValueBuf
);
2369 /* Bug required by Adobe installers */
2370 if (pchValueBuf
&& !szValueBuf
->unicode
&& !szValueBuf
->str
.a
)
2371 *pchValueBuf
*= sizeof(WCHAR
);
2374 midl_user_free(value
);
2378 row
= msi_get_property_row( package
->db
, name
);
2380 val
= msi_record_get_string( row
, 1, (int *)&len
);
2385 r
= msi_strcpy_to_awstring( val
, len
, szValueBuf
, pchValueBuf
);
2388 msiobj_release( &row
->hdr
);
2389 msiobj_release( &package
->hdr
);
2394 UINT WINAPI
MsiGetPropertyA( MSIHANDLE hInstall
, LPCSTR szName
,
2395 LPSTR szValueBuf
, LPDWORD pchValueBuf
)
2401 val
.unicode
= FALSE
;
2402 val
.str
.a
= szValueBuf
;
2404 name
= strdupAtoW( szName
);
2405 if (szName
&& !name
)
2406 return ERROR_OUTOFMEMORY
;
2408 r
= MSI_GetProperty( hInstall
, name
, &val
, pchValueBuf
);
2413 UINT WINAPI
MsiGetPropertyW( MSIHANDLE hInstall
, LPCWSTR szName
,
2414 LPWSTR szValueBuf
, LPDWORD pchValueBuf
)
2419 val
.str
.w
= szValueBuf
;
2421 return MSI_GetProperty( hInstall
, szName
, &val
, pchValueBuf
);
2424 MSIHANDLE __cdecl
remote_GetActiveDatabase(MSIHANDLE hinst
)
2426 return MsiGetActiveDatabase(hinst
);
2429 UINT __cdecl
remote_GetProperty(MSIHANDLE hinst
, LPCWSTR property
, LPWSTR
*value
, DWORD
*size
)
2435 r
= MsiGetPropertyW(hinst
, property
, empty
, size
);
2436 if (r
== ERROR_MORE_DATA
)
2439 *value
= midl_user_allocate(*size
* sizeof(WCHAR
));
2441 return ERROR_OUTOFMEMORY
;
2442 r
= MsiGetPropertyW(hinst
, property
, *value
, size
);
2447 UINT __cdecl
remote_SetProperty(MSIHANDLE hinst
, LPCWSTR property
, LPCWSTR value
)
2449 return MsiSetPropertyW(hinst
, property
, value
);
2452 int __cdecl
remote_ProcessMessage(MSIHANDLE hinst
, INSTALLMESSAGE message
, struct wire_record
*remote_rec
)
2458 if ((r
= unmarshal_record(remote_rec
, &rec
)))
2461 ret
= MsiProcessMessage(hinst
, message
, rec
);
2463 MsiCloseHandle(rec
);
2467 UINT __cdecl
remote_DoAction(MSIHANDLE hinst
, LPCWSTR action
)
2469 return MsiDoActionW(hinst
, action
);
2472 UINT __cdecl
remote_Sequence(MSIHANDLE hinst
, LPCWSTR table
, int sequence
)
2474 return MsiSequenceW(hinst
, table
, sequence
);
2477 UINT __cdecl
remote_GetTargetPath(MSIHANDLE hinst
, LPCWSTR folder
, LPWSTR
*value
)
2483 r
= MsiGetTargetPathW(hinst
, folder
, empty
, &size
);
2484 if (r
== ERROR_MORE_DATA
)
2486 *value
= midl_user_allocate(++size
* sizeof(WCHAR
));
2488 return ERROR_OUTOFMEMORY
;
2489 r
= MsiGetTargetPathW(hinst
, folder
, *value
, &size
);
2494 UINT __cdecl
remote_SetTargetPath(MSIHANDLE hinst
, LPCWSTR folder
, LPCWSTR value
)
2496 return MsiSetTargetPathW(hinst
, folder
, value
);
2499 UINT __cdecl
remote_GetSourcePath(MSIHANDLE hinst
, LPCWSTR folder
, LPWSTR
*value
)
2505 r
= MsiGetSourcePathW(hinst
, folder
, empty
, &size
);
2506 if (r
== ERROR_MORE_DATA
)
2508 *value
= midl_user_allocate(++size
* sizeof(WCHAR
));
2510 return ERROR_OUTOFMEMORY
;
2511 r
= MsiGetSourcePathW(hinst
, folder
, *value
, &size
);
2516 HRESULT __cdecl
remote_GetMode(MSIHANDLE hinst
, MSIRUNMODE mode
, BOOL
*ret
)
2518 *ret
= MsiGetMode(hinst
, mode
);
2522 HRESULT __cdecl
remote_SetMode(MSIHANDLE hinst
, MSIRUNMODE mode
, BOOL state
)
2524 UINT r
= MsiSetMode(hinst
, mode
, state
);
2525 return HRESULT_FROM_WIN32(r
);
2528 HRESULT __cdecl
remote_GetFeatureState(MSIHANDLE hinst
, BSTR feature
,
2529 INSTALLSTATE
*installed
, INSTALLSTATE
*action
)
2531 UINT r
= MsiGetFeatureStateW(hinst
, feature
, installed
, action
);
2532 return HRESULT_FROM_WIN32(r
);
2535 HRESULT __cdecl
remote_SetFeatureState(MSIHANDLE hinst
, BSTR feature
, INSTALLSTATE state
)
2537 UINT r
= MsiSetFeatureStateW(hinst
, feature
, state
);
2538 return HRESULT_FROM_WIN32(r
);
2541 HRESULT __cdecl
remote_GetComponentState(MSIHANDLE hinst
, BSTR component
,
2542 INSTALLSTATE
*installed
, INSTALLSTATE
*action
)
2544 UINT r
= MsiGetComponentStateW(hinst
, component
, installed
, action
);
2545 return HRESULT_FROM_WIN32(r
);
2548 HRESULT __cdecl
remote_SetComponentState(MSIHANDLE hinst
, BSTR component
, INSTALLSTATE state
)
2550 UINT r
= MsiSetComponentStateW(hinst
, component
, state
);
2551 return HRESULT_FROM_WIN32(r
);
2554 HRESULT __cdecl
remote_GetLanguage(MSIHANDLE hinst
, LANGID
*language
)
2556 *language
= MsiGetLanguage(hinst
);
2560 HRESULT __cdecl
remote_SetInstallLevel(MSIHANDLE hinst
, int level
)
2562 UINT r
= MsiSetInstallLevel(hinst
, level
);
2563 return HRESULT_FROM_WIN32(r
);
2566 HRESULT __cdecl
remote_FormatRecord(MSIHANDLE hinst
, MSIHANDLE record
,
2570 UINT r
= MsiFormatRecordW(hinst
, record
, NULL
, &size
);
2571 if (r
== ERROR_SUCCESS
)
2573 *value
= SysAllocStringLen(NULL
, size
);
2575 return E_OUTOFMEMORY
;
2577 r
= MsiFormatRecordW(hinst
, record
, *value
, &size
);
2579 return HRESULT_FROM_WIN32(r
);
2582 HRESULT __cdecl
remote_EvaluateCondition(MSIHANDLE hinst
, BSTR condition
)
2584 UINT r
= MsiEvaluateConditionW(hinst
, condition
);
2585 return HRESULT_FROM_WIN32(r
);
2588 HRESULT __cdecl
remote_GetFeatureCost(MSIHANDLE hinst
, BSTR feature
,
2589 INT cost_tree
, INSTALLSTATE state
, INT
*cost
)
2591 UINT r
= MsiGetFeatureCostW(hinst
, feature
, cost_tree
, state
, cost
);
2592 return HRESULT_FROM_WIN32(r
);
2595 HRESULT __cdecl
remote_EnumComponentCosts(MSIHANDLE hinst
, BSTR component
,
2596 DWORD index
, INSTALLSTATE state
, BSTR drive
,
2597 DWORD
*buflen
, INT
*cost
, INT
*temp
)
2599 UINT r
= MsiEnumComponentCostsW(hinst
, component
, index
, state
, drive
, buflen
, cost
, temp
);
2600 return HRESULT_FROM_WIN32(r
);
2603 UINT
msi_package_add_info(MSIPACKAGE
*package
, DWORD context
, DWORD options
,
2604 LPCWSTR property
, LPWSTR value
)
2606 MSISOURCELISTINFO
*info
;
2608 LIST_FOR_EACH_ENTRY( info
, &package
->sourcelist_info
, MSISOURCELISTINFO
, entry
)
2610 if (!strcmpW( info
->value
, value
)) return ERROR_SUCCESS
;
2613 info
= msi_alloc(sizeof(MSISOURCELISTINFO
));
2615 return ERROR_OUTOFMEMORY
;
2617 info
->context
= context
;
2618 info
->options
= options
;
2619 info
->property
= property
;
2620 info
->value
= strdupW(value
);
2621 list_add_head(&package
->sourcelist_info
, &info
->entry
);
2623 return ERROR_SUCCESS
;
2626 UINT
msi_package_add_media_disk(MSIPACKAGE
*package
, DWORD context
, DWORD options
,
2627 DWORD disk_id
, LPWSTR volume_label
, LPWSTR disk_prompt
)
2631 LIST_FOR_EACH_ENTRY( disk
, &package
->sourcelist_media
, MSIMEDIADISK
, entry
)
2633 if (disk
->disk_id
== disk_id
) return ERROR_SUCCESS
;
2636 disk
= msi_alloc(sizeof(MSIMEDIADISK
));
2638 return ERROR_OUTOFMEMORY
;
2640 disk
->context
= context
;
2641 disk
->options
= options
;
2642 disk
->disk_id
= disk_id
;
2643 disk
->volume_label
= strdupW(volume_label
);
2644 disk
->disk_prompt
= strdupW(disk_prompt
);
2645 list_add_head(&package
->sourcelist_media
, &disk
->entry
);
2647 return ERROR_SUCCESS
;