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
->BaseURL
);
325 msi_free( package
->PackagePath
);
326 msi_free( package
->ProductCode
);
327 msi_free( package
->ActionFormat
);
328 msi_free( package
->LastAction
);
329 msi_free( package
->LastActionTemplate
);
330 msi_free( package
->langids
);
332 /* cleanup control event subscriptions */
333 msi_event_cleanup_all_subscriptions( package
);
336 static void MSI_FreePackage( MSIOBJECTHDR
*arg
)
338 MSIPACKAGE
*package
= (MSIPACKAGE
*)arg
;
340 msi_destroy_assembly_caches( package
);
342 if( package
->dialog
)
343 msi_dialog_destroy( package
->dialog
);
345 msiobj_release( &package
->db
->hdr
);
346 free_package_structures(package
);
347 CloseHandle( package
->log_file
);
349 if (package
->delete_on_close
) DeleteFileW( package
->localfile
);
350 msi_free( package
->localfile
);
351 MSI_ProcessMessage(NULL
, INSTALLMESSAGE_TERMINATE
, 0);
354 static UINT
create_temp_property_table(MSIPACKAGE
*package
)
356 static const WCHAR query
[] = {
357 'C','R','E','A','T','E',' ','T','A','B','L','E',' ',
358 '`','_','P','r','o','p','e','r','t','y','`',' ','(',' ',
359 '`','_','P','r','o','p','e','r','t','y','`',' ',
360 'C','H','A','R','(','5','6',')',' ','N','O','T',' ','N','U','L','L',' ',
361 'T','E','M','P','O','R','A','R','Y',',',' ',
362 '`','V','a','l','u','e','`',' ','C','H','A','R','(','9','8',')',' ',
363 'N','O','T',' ','N','U','L','L',' ','T','E','M','P','O','R','A','R','Y',
364 ' ','P','R','I','M','A','R','Y',' ','K','E','Y',' ',
365 '`','_','P','r','o','p','e','r','t','y','`',')',' ','H','O','L','D',0};
369 rc
= MSI_DatabaseOpenViewW(package
->db
, query
, &view
);
370 if (rc
!= ERROR_SUCCESS
)
373 rc
= MSI_ViewExecute(view
, 0);
375 msiobj_release(&view
->hdr
);
379 UINT
msi_clone_properties( MSIDATABASE
*db
)
381 static const WCHAR query_select
[] = {
382 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
383 '`','P','r','o','p','e','r','t','y','`',0};
384 static const WCHAR query_insert
[] = {
385 'I','N','S','E','R','T',' ','I','N','T','O',' ',
386 '`','_','P','r','o','p','e','r','t','y','`',' ',
387 '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
388 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
389 static const WCHAR query_update
[] = {
390 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
391 'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ',
392 'W','H','E','R','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','?',0};
393 MSIQUERY
*view_select
;
396 rc
= MSI_DatabaseOpenViewW( db
, query_select
, &view_select
);
397 if (rc
!= ERROR_SUCCESS
)
400 rc
= MSI_ViewExecute( view_select
, 0 );
401 if (rc
!= ERROR_SUCCESS
)
403 MSI_ViewClose( view_select
);
404 msiobj_release( &view_select
->hdr
);
410 MSIQUERY
*view_insert
, *view_update
;
411 MSIRECORD
*rec_select
;
413 rc
= MSI_ViewFetch( view_select
, &rec_select
);
414 if (rc
!= ERROR_SUCCESS
)
417 rc
= MSI_DatabaseOpenViewW( db
, query_insert
, &view_insert
);
418 if (rc
!= ERROR_SUCCESS
)
420 msiobj_release( &rec_select
->hdr
);
424 rc
= MSI_ViewExecute( view_insert
, rec_select
);
425 MSI_ViewClose( view_insert
);
426 msiobj_release( &view_insert
->hdr
);
427 if (rc
!= ERROR_SUCCESS
)
429 MSIRECORD
*rec_update
;
431 TRACE("insert failed, trying update\n");
433 rc
= MSI_DatabaseOpenViewW( db
, query_update
, &view_update
);
434 if (rc
!= ERROR_SUCCESS
)
436 WARN("open view failed %u\n", rc
);
437 msiobj_release( &rec_select
->hdr
);
441 rec_update
= MSI_CreateRecord( 2 );
442 MSI_RecordCopyField( rec_select
, 1, rec_update
, 2 );
443 MSI_RecordCopyField( rec_select
, 2, rec_update
, 1 );
444 rc
= MSI_ViewExecute( view_update
, rec_update
);
445 if (rc
!= ERROR_SUCCESS
)
446 WARN("update failed %u\n", rc
);
448 MSI_ViewClose( view_update
);
449 msiobj_release( &view_update
->hdr
);
450 msiobj_release( &rec_update
->hdr
);
453 msiobj_release( &rec_select
->hdr
);
456 MSI_ViewClose( view_select
);
457 msiobj_release( &view_select
->hdr
);
464 * Sets the "Installed" property to indicate that
465 * the product is installed for the current user.
467 static UINT
set_installed_prop( MSIPACKAGE
*package
)
472 if (!package
->ProductCode
) return ERROR_FUNCTION_FAILED
;
474 r
= MSIREG_OpenUninstallKey( package
->ProductCode
, package
->platform
, &hkey
, FALSE
);
475 if (r
== ERROR_SUCCESS
)
478 msi_set_property( package
->db
, szInstalled
, szOne
, -1 );
483 static UINT
set_user_sid_prop( MSIPACKAGE
*package
)
487 LPWSTR sid_str
= NULL
, dom
= NULL
;
488 DWORD size
, dom_size
;
490 UINT r
= ERROR_FUNCTION_FAILED
;
493 GetUserNameW( NULL
, &size
);
495 user_name
= msi_alloc( (size
+ 1) * sizeof(WCHAR
) );
497 return ERROR_OUTOFMEMORY
;
499 if (!GetUserNameW( user_name
, &size
))
504 LookupAccountNameW( NULL
, user_name
, NULL
, &size
, NULL
, &dom_size
, &use
);
506 psid
= msi_alloc( size
);
507 dom
= msi_alloc( dom_size
*sizeof (WCHAR
) );
510 r
= ERROR_OUTOFMEMORY
;
514 if (!LookupAccountNameW( NULL
, user_name
, psid
, &size
, dom
, &dom_size
, &use
))
517 if (!ConvertSidToStringSidW( psid
, &sid_str
))
520 r
= msi_set_property( package
->db
, szUserSID
, sid_str
, -1 );
523 LocalFree( sid_str
);
526 msi_free( user_name
);
531 static LPWSTR
get_fusion_filename(MSIPACKAGE
*package
)
533 static const WCHAR fusion
[] =
534 {'f','u','s','i','o','n','.','d','l','l',0};
535 static const WCHAR subkey
[] =
536 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
537 'N','E','T',' ','F','r','a','m','e','w','o','r','k',' ','S','e','t','u','p','\\','N','D','P',0};
538 static const WCHAR subdir
[] =
539 {'M','i','c','r','o','s','o','f','t','.','N','E','T','\\','F','r','a','m','e','w','o','r','k','\\',0};
540 static const WCHAR v2050727
[] =
541 {'v','2','.','0','.','5','0','7','2','7',0};
542 static const WCHAR v4client
[] =
543 {'v','4','\\','C','l','i','e','n','t',0};
544 static const WCHAR installpath
[] =
545 {'I','n','s','t','a','l','l','P','a','t','h',0};
548 DWORD size
, len
, type
;
549 WCHAR windir
[MAX_PATH
], path
[MAX_PATH
], *filename
= NULL
;
551 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, subkey
, 0, KEY_CREATE_SUB_KEY
, &netsetup
);
552 if (res
!= ERROR_SUCCESS
)
555 if (!RegCreateKeyExW(netsetup
, v4client
, 0, NULL
, 0, KEY_QUERY_VALUE
, NULL
, &hkey
, NULL
))
557 size
= sizeof(path
)/sizeof(path
[0]);
558 if (!RegQueryValueExW(hkey
, installpath
, NULL
, &type
, (BYTE
*)path
, &size
))
560 len
= strlenW(path
) + strlenW(fusion
) + 2;
561 if (!(filename
= msi_alloc(len
* sizeof(WCHAR
)))) return NULL
;
563 strcpyW(filename
, path
);
564 strcatW(filename
, szBackSlash
);
565 strcatW(filename
, fusion
);
566 if (GetFileAttributesW(filename
) != INVALID_FILE_ATTRIBUTES
)
568 TRACE( "found %s\n", debugstr_w(filename
) );
570 RegCloseKey(netsetup
);
577 if (!RegCreateKeyExW(netsetup
, v2050727
, 0, NULL
, 0, KEY_QUERY_VALUE
, NULL
, &hkey
, NULL
))
580 GetWindowsDirectoryW(windir
, MAX_PATH
);
581 len
= strlenW(windir
) + strlenW(subdir
) + strlenW(v2050727
) + strlenW(fusion
) + 3;
582 if (!(filename
= msi_alloc(len
* sizeof(WCHAR
)))) return NULL
;
584 strcpyW(filename
, windir
);
585 strcatW(filename
, szBackSlash
);
586 strcatW(filename
, subdir
);
587 strcatW(filename
, v2050727
);
588 strcatW(filename
, szBackSlash
);
589 strcatW(filename
, fusion
);
590 if (GetFileAttributesW(filename
) != INVALID_FILE_ATTRIBUTES
)
592 TRACE( "found %s\n", debugstr_w(filename
) );
593 RegCloseKey(netsetup
);
598 RegCloseKey(netsetup
);
602 typedef struct tagLANGANDCODEPAGE
608 static void set_msi_assembly_prop(MSIPACKAGE
*package
)
612 LPVOID version
= NULL
;
614 LPWSTR fusion
, verstr
;
615 LANGANDCODEPAGE
*translate
;
617 static const WCHAR netasm
[] = {
618 'M','s','i','N','e','t','A','s','s','e','m','b','l','y','S','u','p','p','o','r','t',0
620 static const WCHAR translation
[] = {
621 '\\','V','a','r','F','i','l','e','I','n','f','o',
622 '\\','T','r','a','n','s','l','a','t','i','o','n',0
624 static const WCHAR verfmt
[] = {
625 '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
626 '\\','%','0','4','x','%','0','4','x',
627 '\\','P','r','o','d','u','c','t','V','e','r','s','i','o','n',0
630 fusion
= get_fusion_filename(package
);
634 size
= GetFileVersionInfoSizeW(fusion
, &handle
);
638 version
= msi_alloc(size
);
642 if (!GetFileVersionInfoW(fusion
, handle
, size
, version
))
645 if (!VerQueryValueW(version
, translation
, (LPVOID
*)&translate
, &val_len
))
648 sprintfW(buf
, verfmt
, translate
[0].wLanguage
, translate
[0].wCodePage
);
650 if (!VerQueryValueW(version
, buf
, (LPVOID
*)&verstr
, &val_len
))
653 if (!val_len
|| !verstr
)
656 msi_set_property( package
->db
, netasm
, verstr
, -1 );
663 static VOID
set_installer_properties(MSIPACKAGE
*package
)
666 OSVERSIONINFOEXW OSVersion
;
669 WCHAR pth
[MAX_PATH
], verstr
[11], bufstr
[22];
672 LPWSTR username
, companyname
;
673 SYSTEM_INFO sys_info
;
676 static const WCHAR szCommonFilesFolder
[] = {'C','o','m','m','o','n','F','i','l','e','s','F','o','l','d','e','r',0};
677 static const WCHAR szProgramFilesFolder
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','F','o','l','d','e','r',0};
678 static const WCHAR szCommonAppDataFolder
[] = {'C','o','m','m','o','n','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
679 static const WCHAR szFavoritesFolder
[] = {'F','a','v','o','r','i','t','e','s','F','o','l','d','e','r',0};
680 static const WCHAR szFontsFolder
[] = {'F','o','n','t','s','F','o','l','d','e','r',0};
681 static const WCHAR szSendToFolder
[] = {'S','e','n','d','T','o','F','o','l','d','e','r',0};
682 static const WCHAR szStartMenuFolder
[] = {'S','t','a','r','t','M','e','n','u','F','o','l','d','e','r',0};
683 static const WCHAR szStartupFolder
[] = {'S','t','a','r','t','u','p','F','o','l','d','e','r',0};
684 static const WCHAR szTemplateFolder
[] = {'T','e','m','p','l','a','t','e','F','o','l','d','e','r',0};
685 static const WCHAR szDesktopFolder
[] = {'D','e','s','k','t','o','p','F','o','l','d','e','r',0};
686 static const WCHAR szProgramMenuFolder
[] = {'P','r','o','g','r','a','m','M','e','n','u','F','o','l','d','e','r',0};
687 static const WCHAR szAdminToolsFolder
[] = {'A','d','m','i','n','T','o','o','l','s','F','o','l','d','e','r',0};
688 static const WCHAR szSystemFolder
[] = {'S','y','s','t','e','m','F','o','l','d','e','r',0};
689 static const WCHAR szSystem16Folder
[] = {'S','y','s','t','e','m','1','6','F','o','l','d','e','r',0};
690 static const WCHAR szLocalAppDataFolder
[] = {'L','o','c','a','l','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
691 static const WCHAR szMyPicturesFolder
[] = {'M','y','P','i','c','t','u','r','e','s','F','o','l','d','e','r',0};
692 static const WCHAR szPersonalFolder
[] = {'P','e','r','s','o','n','a','l','F','o','l','d','e','r',0};
693 static const WCHAR szWindowsVolume
[] = {'W','i','n','d','o','w','s','V','o','l','u','m','e',0};
694 static const WCHAR szPrivileged
[] = {'P','r','i','v','i','l','e','g','e','d',0};
695 static const WCHAR szVersion9x
[] = {'V','e','r','s','i','o','n','9','X',0};
696 static const WCHAR szVersionNT
[] = {'V','e','r','s','i','o','n','N','T',0};
697 static const WCHAR szMsiNTProductType
[] = {'M','s','i','N','T','P','r','o','d','u','c','t','T','y','p','e',0};
698 static const WCHAR szFormat
[] = {'%','u',0};
699 static const WCHAR szFormat2
[] = {'%','u','.','%','u',0};
700 static const WCHAR szWindowsBuild
[] = {'W','i','n','d','o','w','s','B','u','i','l','d',0};
701 static const WCHAR szServicePackLevel
[] = {'S','e','r','v','i','c','e','P','a','c','k','L','e','v','e','l',0};
702 static const WCHAR szVersionMsi
[] = { 'V','e','r','s','i','o','n','M','s','i',0 };
703 static const WCHAR szVersionDatabase
[] = { 'V','e','r','s','i','o','n','D','a','t','a','b','a','s','e',0 };
704 static const WCHAR szPhysicalMemory
[] = { 'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0 };
705 static const WCHAR szScreenX
[] = {'S','c','r','e','e','n','X',0};
706 static const WCHAR szScreenY
[] = {'S','c','r','e','e','n','Y',0};
707 static const WCHAR szColorBits
[] = {'C','o','l','o','r','B','i','t','s',0};
708 static const WCHAR szIntFormat
[] = {'%','d',0};
709 static const WCHAR szMsiAMD64
[] = { 'M','s','i','A','M','D','6','4',0 };
710 static const WCHAR szMsix64
[] = { 'M','s','i','x','6','4',0 };
711 static const WCHAR szSystem64Folder
[] = { 'S','y','s','t','e','m','6','4','F','o','l','d','e','r',0 };
712 static const WCHAR szCommonFiles64Folder
[] = { 'C','o','m','m','o','n','F','i','l','e','s','6','4','F','o','l','d','e','r',0 };
713 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 };
714 static const WCHAR szVersionNT64
[] = { 'V','e','r','s','i','o','n','N','T','6','4',0 };
715 static const WCHAR szUserInfo
[] = {
716 'S','O','F','T','W','A','R','E','\\',
717 'M','i','c','r','o','s','o','f','t','\\',
718 'M','S',' ','S','e','t','u','p',' ','(','A','C','M','E',')','\\',
719 'U','s','e','r',' ','I','n','f','o',0
721 static const WCHAR szDefName
[] = { 'D','e','f','N','a','m','e',0 };
722 static const WCHAR szDefCompany
[] = { 'D','e','f','C','o','m','p','a','n','y',0 };
723 static const WCHAR szCurrentVersion
[] = {
724 'S','O','F','T','W','A','R','E','\\',
725 'M','i','c','r','o','s','o','f','t','\\',
726 'W','i','n','d','o','w','s',' ','N','T','\\',
727 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0
729 static const WCHAR szRegisteredUser
[] = {'R','e','g','i','s','t','e','r','e','d','O','w','n','e','r',0};
730 static const WCHAR szRegisteredOrganization
[] = {
731 'R','e','g','i','s','t','e','r','e','d','O','r','g','a','n','i','z','a','t','i','o','n',0
733 static const WCHAR szUSERNAME
[] = {'U','S','E','R','N','A','M','E',0};
734 static const WCHAR szCOMPANYNAME
[] = {'C','O','M','P','A','N','Y','N','A','M','E',0};
735 static const WCHAR szUserLanguageID
[] = {'U','s','e','r','L','a','n','g','u','a','g','e','I','D',0};
736 static const WCHAR szSystemLangID
[] = {'S','y','s','t','e','m','L','a','n','g','u','a','g','e','I','D',0};
737 static const WCHAR szProductState
[] = {'P','r','o','d','u','c','t','S','t','a','t','e',0};
738 static const WCHAR szLogonUser
[] = {'L','o','g','o','n','U','s','e','r',0};
739 static const WCHAR szNetHoodFolder
[] = {'N','e','t','H','o','o','d','F','o','l','d','e','r',0};
740 static const WCHAR szPrintHoodFolder
[] = {'P','r','i','n','t','H','o','o','d','F','o','l','d','e','r',0};
741 static const WCHAR szRecentFolder
[] = {'R','e','c','e','n','t','F','o','l','d','e','r',0};
742 static const WCHAR szComputerName
[] = {'C','o','m','p','u','t','e','r','N','a','m','e',0};
745 * Other things that probably should be set:
747 * VirtualMemory ShellAdvSupport DefaultUIFont PackagecodeChanging
748 * CaptionHeight BorderTop BorderSide TextHeight RedirectedDllSupport
751 SHGetFolderPathW(NULL
, CSIDL_COMMON_APPDATA
, NULL
, 0, pth
);
752 strcatW(pth
, szBackSlash
);
753 msi_set_property( package
->db
, szCommonAppDataFolder
, pth
, -1 );
755 SHGetFolderPathW(NULL
, CSIDL_FAVORITES
, NULL
, 0, pth
);
756 strcatW(pth
, szBackSlash
);
757 msi_set_property( package
->db
, szFavoritesFolder
, pth
, -1 );
759 SHGetFolderPathW(NULL
, CSIDL_FONTS
, NULL
, 0, pth
);
760 strcatW(pth
, szBackSlash
);
761 msi_set_property( package
->db
, szFontsFolder
, pth
, -1 );
763 SHGetFolderPathW(NULL
, CSIDL_SENDTO
, NULL
, 0, pth
);
764 strcatW(pth
, szBackSlash
);
765 msi_set_property( package
->db
, szSendToFolder
, pth
, -1 );
767 SHGetFolderPathW(NULL
, CSIDL_STARTMENU
, NULL
, 0, pth
);
768 strcatW(pth
, szBackSlash
);
769 msi_set_property( package
->db
, szStartMenuFolder
, pth
, -1 );
771 SHGetFolderPathW(NULL
, CSIDL_STARTUP
, NULL
, 0, pth
);
772 strcatW(pth
, szBackSlash
);
773 msi_set_property( package
->db
, szStartupFolder
, pth
, -1 );
775 SHGetFolderPathW(NULL
, CSIDL_TEMPLATES
, NULL
, 0, pth
);
776 strcatW(pth
, szBackSlash
);
777 msi_set_property( package
->db
, szTemplateFolder
, pth
, -1 );
779 SHGetFolderPathW(NULL
, CSIDL_DESKTOP
, NULL
, 0, pth
);
780 strcatW(pth
, szBackSlash
);
781 msi_set_property( package
->db
, szDesktopFolder
, pth
, -1 );
783 /* FIXME: set to AllUsers profile path if ALLUSERS is set */
784 SHGetFolderPathW(NULL
, CSIDL_PROGRAMS
, NULL
, 0, pth
);
785 strcatW(pth
, szBackSlash
);
786 msi_set_property( package
->db
, szProgramMenuFolder
, pth
, -1 );
788 SHGetFolderPathW(NULL
, CSIDL_ADMINTOOLS
, NULL
, 0, pth
);
789 strcatW(pth
, szBackSlash
);
790 msi_set_property( package
->db
, szAdminToolsFolder
, pth
, -1 );
792 SHGetFolderPathW(NULL
, CSIDL_APPDATA
, NULL
, 0, pth
);
793 strcatW(pth
, szBackSlash
);
794 msi_set_property( package
->db
, szAppDataFolder
, pth
, -1 );
796 SHGetFolderPathW(NULL
, CSIDL_SYSTEM
, NULL
, 0, pth
);
797 strcatW(pth
, szBackSlash
);
798 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
799 msi_set_property( package
->db
, szSystem16Folder
, pth
, -1 );
801 SHGetFolderPathW(NULL
, CSIDL_LOCAL_APPDATA
, NULL
, 0, pth
);
802 strcatW(pth
, szBackSlash
);
803 msi_set_property( package
->db
, szLocalAppDataFolder
, pth
, -1 );
805 SHGetFolderPathW(NULL
, CSIDL_MYPICTURES
, NULL
, 0, pth
);
806 strcatW(pth
, szBackSlash
);
807 msi_set_property( package
->db
, szMyPicturesFolder
, pth
, -1 );
809 SHGetFolderPathW(NULL
, CSIDL_PERSONAL
, NULL
, 0, pth
);
810 strcatW(pth
, szBackSlash
);
811 msi_set_property( package
->db
, szPersonalFolder
, pth
, -1 );
813 SHGetFolderPathW(NULL
, CSIDL_WINDOWS
, NULL
, 0, pth
);
814 strcatW(pth
, szBackSlash
);
815 msi_set_property( package
->db
, szWindowsFolder
, pth
, -1 );
817 SHGetFolderPathW(NULL
, CSIDL_PRINTHOOD
, NULL
, 0, pth
);
818 strcatW(pth
, szBackSlash
);
819 msi_set_property( package
->db
, szPrintHoodFolder
, pth
, -1 );
821 SHGetFolderPathW(NULL
, CSIDL_NETHOOD
, NULL
, 0, pth
);
822 strcatW(pth
, szBackSlash
);
823 msi_set_property( package
->db
, szNetHoodFolder
, pth
, -1 );
825 SHGetFolderPathW(NULL
, CSIDL_RECENT
, NULL
, 0, pth
);
826 strcatW(pth
, szBackSlash
);
827 msi_set_property( package
->db
, szRecentFolder
, pth
, -1 );
829 /* Physical Memory is specified in MB. Using total amount. */
830 msex
.dwLength
= sizeof(msex
);
831 GlobalMemoryStatusEx( &msex
);
832 len
= sprintfW( bufstr
, szIntFormat
, (int)(msex
.ullTotalPhys
/ 1024 / 1024) );
833 msi_set_property( package
->db
, szPhysicalMemory
, bufstr
, len
);
835 SHGetFolderPathW(NULL
, CSIDL_WINDOWS
, NULL
, 0, pth
);
836 ptr
= strchrW(pth
,'\\');
837 if (ptr
) *(ptr
+ 1) = 0;
838 msi_set_property( package
->db
, szWindowsVolume
, pth
, -1 );
840 len
= GetTempPathW(MAX_PATH
, pth
);
841 msi_set_property( package
->db
, szTempFolder
, pth
, len
);
843 /* in a wine environment the user is always admin and privileged */
844 msi_set_property( package
->db
, szAdminUser
, szOne
, -1 );
845 msi_set_property( package
->db
, szPrivileged
, szOne
, -1 );
847 /* set the os things */
848 OSVersion
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
849 GetVersionExW((OSVERSIONINFOW
*)&OSVersion
);
850 verval
= OSVersion
.dwMinorVersion
+ OSVersion
.dwMajorVersion
* 100;
851 len
= sprintfW( verstr
, szFormat
, verval
);
852 switch (OSVersion
.dwPlatformId
)
854 case VER_PLATFORM_WIN32_WINDOWS
:
855 msi_set_property( package
->db
, szVersion9x
, verstr
, len
);
857 case VER_PLATFORM_WIN32_NT
:
858 msi_set_property( package
->db
, szVersionNT
, verstr
, len
);
859 len
= sprintfW( bufstr
, szFormat
,OSVersion
.wProductType
);
860 msi_set_property( package
->db
, szMsiNTProductType
, bufstr
, len
);
863 len
= sprintfW( bufstr
, szFormat
, OSVersion
.dwBuildNumber
);
864 msi_set_property( package
->db
, szWindowsBuild
, bufstr
, len
);
865 len
= sprintfW( bufstr
, szFormat
, OSVersion
.wServicePackMajor
);
866 msi_set_property( package
->db
, szServicePackLevel
, bufstr
, len
);
868 len
= sprintfW( bufstr
, szFormat2
, MSI_MAJORVERSION
, MSI_MINORVERSION
);
869 msi_set_property( package
->db
, szVersionMsi
, bufstr
, len
);
870 len
= sprintfW( bufstr
, szFormat
, MSI_MAJORVERSION
* 100 );
871 msi_set_property( package
->db
, szVersionDatabase
, bufstr
, len
);
873 GetNativeSystemInfo( &sys_info
);
874 len
= sprintfW( bufstr
, szIntFormat
, sys_info
.wProcessorLevel
);
875 msi_set_property( package
->db
, szIntel
, bufstr
, len
);
876 if (sys_info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
878 GetSystemDirectoryW( pth
, MAX_PATH
);
879 PathAddBackslashW( pth
);
880 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
882 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, pth
);
883 PathAddBackslashW( pth
);
884 msi_set_property( package
->db
, szProgramFilesFolder
, pth
, -1 );
886 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, pth
);
887 PathAddBackslashW( pth
);
888 msi_set_property( package
->db
, szCommonFilesFolder
, pth
, -1 );
890 else if (sys_info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
)
892 msi_set_property( package
->db
, szMsiAMD64
, bufstr
, -1 );
893 msi_set_property( package
->db
, szMsix64
, bufstr
, -1 );
894 msi_set_property( package
->db
, szVersionNT64
, verstr
, -1 );
896 GetSystemDirectoryW( pth
, MAX_PATH
);
897 PathAddBackslashW( pth
);
898 msi_set_property( package
->db
, szSystem64Folder
, pth
, -1 );
900 GetSystemWow64DirectoryW( pth
, MAX_PATH
);
901 PathAddBackslashW( pth
);
902 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
904 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, pth
);
905 PathAddBackslashW( pth
);
906 msi_set_property( package
->db
, szProgramFiles64Folder
, pth
, -1 );
908 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, pth
);
909 PathAddBackslashW( pth
);
910 msi_set_property( package
->db
, szProgramFilesFolder
, pth
, -1 );
912 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, pth
);
913 PathAddBackslashW( pth
);
914 msi_set_property( package
->db
, szCommonFiles64Folder
, pth
, -1 );
916 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, pth
);
917 PathAddBackslashW( pth
);
918 msi_set_property( package
->db
, szCommonFilesFolder
, pth
, -1 );
921 /* Screen properties. */
923 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, HORZRES
) );
924 msi_set_property( package
->db
, szScreenX
, bufstr
, len
);
925 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, VERTRES
) );
926 msi_set_property( package
->db
, szScreenY
, bufstr
, len
);
927 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, BITSPIXEL
) );
928 msi_set_property( package
->db
, szColorBits
, bufstr
, len
);
931 /* USERNAME and COMPANYNAME */
932 username
= msi_dup_property( package
->db
, szUSERNAME
);
933 companyname
= msi_dup_property( package
->db
, szCOMPANYNAME
);
935 if ((!username
|| !companyname
) &&
936 RegOpenKeyW( HKEY_CURRENT_USER
, szUserInfo
, &hkey
) == ERROR_SUCCESS
)
939 (username
= msi_reg_get_val_str( hkey
, szDefName
)))
940 msi_set_property( package
->db
, szUSERNAME
, username
, -1 );
942 (companyname
= msi_reg_get_val_str( hkey
, szDefCompany
)))
943 msi_set_property( package
->db
, szCOMPANYNAME
, companyname
, -1 );
946 if ((!username
|| !companyname
) &&
947 RegOpenKeyW( HKEY_LOCAL_MACHINE
, szCurrentVersion
, &hkey
) == ERROR_SUCCESS
)
950 (username
= msi_reg_get_val_str( hkey
, szRegisteredUser
)))
951 msi_set_property( package
->db
, szUSERNAME
, username
, -1 );
953 (companyname
= msi_reg_get_val_str( hkey
, szRegisteredOrganization
)))
954 msi_set_property( package
->db
, szCOMPANYNAME
, companyname
, -1 );
957 msi_free( username
);
958 msi_free( companyname
);
960 if ( set_user_sid_prop( package
) != ERROR_SUCCESS
)
961 ERR("Failed to set the UserSID property\n");
963 set_msi_assembly_prop( package
);
965 langid
= GetUserDefaultLangID();
966 len
= sprintfW( bufstr
, szIntFormat
, langid
);
967 msi_set_property( package
->db
, szUserLanguageID
, bufstr
, len
);
969 langid
= GetSystemDefaultLangID();
970 len
= sprintfW( bufstr
, szIntFormat
, langid
);
971 msi_set_property( package
->db
, szSystemLangID
, bufstr
, len
);
973 len
= sprintfW( bufstr
, szIntFormat
, MsiQueryProductStateW(package
->ProductCode
) );
974 msi_set_property( package
->db
, szProductState
, bufstr
, len
);
977 if (!GetUserNameW( NULL
, &len
) && GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
980 if ((username
= msi_alloc( len
* sizeof(WCHAR
) )))
982 if (GetUserNameW( username
, &len
))
983 msi_set_property( package
->db
, szLogonUser
, username
, len
- 1 );
984 msi_free( username
);
988 if (!GetComputerNameW( NULL
, &len
) && GetLastError() == ERROR_BUFFER_OVERFLOW
)
991 if ((computername
= msi_alloc( len
* sizeof(WCHAR
) )))
993 if (GetComputerNameW( computername
, &len
))
994 msi_set_property( package
->db
, szComputerName
, computername
, len
);
995 msi_free( computername
);
1000 static MSIPACKAGE
*msi_alloc_package( void )
1002 MSIPACKAGE
*package
;
1004 package
= alloc_msiobject( MSIHANDLETYPE_PACKAGE
, sizeof (MSIPACKAGE
),
1008 list_init( &package
->components
);
1009 list_init( &package
->features
);
1010 list_init( &package
->files
);
1011 list_init( &package
->filepatches
);
1012 list_init( &package
->tempfiles
);
1013 list_init( &package
->folders
);
1014 list_init( &package
->subscriptions
);
1015 list_init( &package
->appids
);
1016 list_init( &package
->classes
);
1017 list_init( &package
->mimes
);
1018 list_init( &package
->extensions
);
1019 list_init( &package
->progids
);
1020 list_init( &package
->RunningActions
);
1021 list_init( &package
->sourcelist_info
);
1022 list_init( &package
->sourcelist_media
);
1023 list_init( &package
->patches
);
1024 list_init( &package
->binaries
);
1025 list_init( &package
->cabinet_streams
);
1031 static UINT
msi_load_admin_properties(MSIPACKAGE
*package
)
1036 static const WCHAR stmname
[] = {'A','d','m','i','n','P','r','o','p','e','r','t','i','e','s',0};
1038 r
= read_stream_data(package
->db
->storage
, stmname
, FALSE
, &data
, &sz
);
1039 if (r
!= ERROR_SUCCESS
)
1042 r
= msi_parse_command_line(package
, (WCHAR
*)data
, TRUE
);
1048 void msi_adjust_privilege_properties( MSIPACKAGE
*package
)
1050 /* FIXME: this should depend on the user's privileges */
1051 if (msi_get_property_int( package
->db
, szAllUsers
, 0 ) == 2)
1053 TRACE("resetting ALLUSERS property from 2 to 1\n");
1054 msi_set_property( package
->db
, szAllUsers
, szOne
, -1 );
1056 msi_set_property( package
->db
, szAdminUser
, szOne
, -1 );
1059 MSIPACKAGE
*MSI_CreatePackage( MSIDATABASE
*db
, LPCWSTR base_url
)
1061 static const WCHAR fmtW
[] = {'%','u',0};
1062 MSIPACKAGE
*package
;
1069 package
= msi_alloc_package();
1072 msiobj_addref( &db
->hdr
);
1075 package
->LastAction
= NULL
;
1076 package
->LastActionTemplate
= NULL
;
1077 package
->LastActionResult
= MSI_NULL_INTEGER
;
1078 package
->WordCount
= 0;
1079 package
->PackagePath
= strdupW( db
->path
);
1080 package
->BaseURL
= strdupW( base_url
);
1082 create_temp_property_table( package
);
1083 msi_clone_properties( package
->db
);
1084 msi_adjust_privilege_properties( package
);
1086 package
->ProductCode
= msi_dup_property( package
->db
, szProductCode
);
1088 set_installer_properties( package
);
1090 package
->ui_level
= gUILevel
;
1091 len
= sprintfW( uilevel
, fmtW
, gUILevel
& INSTALLUILEVEL_MASK
);
1092 msi_set_property( package
->db
, szUILevel
, uilevel
, len
);
1094 r
= msi_load_suminfo_properties( package
);
1095 if (r
!= ERROR_SUCCESS
)
1097 msiobj_release( &package
->hdr
);
1101 if (package
->WordCount
& msidbSumInfoSourceTypeAdminImage
)
1102 msi_load_admin_properties( package
);
1104 package
->log_file
= INVALID_HANDLE_VALUE
;
1109 UINT
msi_download_file( LPCWSTR szUrl
, LPWSTR filename
)
1111 LPINTERNET_CACHE_ENTRY_INFOW cache_entry
;
1115 /* call will always fail, because size is 0,
1116 * but will return ERROR_FILE_NOT_FOUND first
1117 * if the file doesn't exist
1119 GetUrlCacheEntryInfoW( szUrl
, NULL
, &size
);
1120 if ( GetLastError() != ERROR_FILE_NOT_FOUND
)
1122 cache_entry
= msi_alloc( size
);
1123 if ( !GetUrlCacheEntryInfoW( szUrl
, cache_entry
, &size
) )
1125 UINT error
= GetLastError();
1126 msi_free( cache_entry
);
1130 lstrcpyW( filename
, cache_entry
->lpszLocalFileName
);
1131 msi_free( cache_entry
);
1132 return ERROR_SUCCESS
;
1135 hr
= URLDownloadToCacheFileW( NULL
, szUrl
, filename
, MAX_PATH
, 0, NULL
);
1138 WARN("failed to download %s to cache file\n", debugstr_w(szUrl
));
1139 return ERROR_FUNCTION_FAILED
;
1142 return ERROR_SUCCESS
;
1145 UINT
msi_create_empty_local_file( LPWSTR path
, LPCWSTR suffix
)
1147 static const WCHAR szInstaller
[] = {
1148 '\\','I','n','s','t','a','l','l','e','r','\\',0};
1149 static const WCHAR fmt
[] = {'%','x',0};
1150 DWORD time
, len
, i
, offset
;
1153 time
= GetTickCount();
1154 GetWindowsDirectoryW( path
, MAX_PATH
);
1155 strcatW( path
, szInstaller
);
1156 CreateDirectoryW( path
, NULL
);
1158 len
= strlenW(path
);
1159 for (i
= 0; i
< 0x10000; i
++)
1161 offset
= snprintfW( path
+ len
, MAX_PATH
- len
, fmt
, (time
+ i
) & 0xffff );
1162 memcpy( path
+ len
+ offset
, suffix
, (strlenW( suffix
) + 1) * sizeof(WCHAR
) );
1163 handle
= CreateFileW( path
, GENERIC_WRITE
, 0, NULL
,
1164 CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, 0 );
1165 if (handle
!= INVALID_HANDLE_VALUE
)
1167 CloseHandle(handle
);
1170 if (GetLastError() != ERROR_FILE_EXISTS
&&
1171 GetLastError() != ERROR_SHARING_VIOLATION
)
1172 return ERROR_FUNCTION_FAILED
;
1175 return ERROR_SUCCESS
;
1178 static enum platform
parse_platform( const WCHAR
*str
)
1180 if (!str
[0] || !strcmpW( str
, szIntel
)) return PLATFORM_INTEL
;
1181 else if (!strcmpW( str
, szIntel64
)) return PLATFORM_INTEL64
;
1182 else if (!strcmpW( str
, szX64
) || !strcmpW( str
, szAMD64
)) return PLATFORM_X64
;
1183 else if (!strcmpW( str
, szARM
)) return PLATFORM_ARM
;
1184 return PLATFORM_UNKNOWN
;
1187 static UINT
parse_suminfo( MSISUMMARYINFO
*si
, MSIPACKAGE
*package
)
1189 WCHAR
*template, *p
, *q
, *platform
;
1192 package
->version
= msi_suminfo_get_int32( si
, PID_PAGECOUNT
);
1193 TRACE("version: %d\n", package
->version
);
1195 template = msi_suminfo_dup_string( si
, PID_TEMPLATE
);
1197 return ERROR_SUCCESS
; /* native accepts missing template property */
1199 TRACE("template: %s\n", debugstr_w(template));
1201 p
= strchrW( template, ';' );
1204 WARN("invalid template string %s\n", debugstr_w(template));
1205 msi_free( template );
1206 return ERROR_PATCH_PACKAGE_INVALID
;
1209 platform
= template;
1210 if ((q
= strchrW( platform
, ',' ))) *q
= 0;
1211 package
->platform
= parse_platform( platform
);
1212 while (package
->platform
== PLATFORM_UNKNOWN
&& q
)
1215 if ((q
= strchrW( platform
, ',' ))) *q
= 0;
1216 package
->platform
= parse_platform( platform
);
1218 if (package
->platform
== PLATFORM_UNKNOWN
)
1220 WARN("unknown platform %s\n", debugstr_w(template));
1221 msi_free( template );
1222 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1227 msi_free( template );
1228 return ERROR_SUCCESS
;
1231 for (q
= p
; (q
= strchrW( q
, ',' )); q
++) count
++;
1233 package
->langids
= msi_alloc( count
* sizeof(LANGID
) );
1234 if (!package
->langids
)
1236 msi_free( template );
1237 return ERROR_OUTOFMEMORY
;
1243 q
= strchrW( p
, ',' );
1245 package
->langids
[i
] = atoiW( p
);
1250 package
->num_langids
= i
+ 1;
1252 msi_free( template );
1253 return ERROR_SUCCESS
;
1256 static UINT
validate_package( MSIPACKAGE
*package
)
1260 if (package
->platform
== PLATFORM_INTEL64
)
1261 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1263 if (package
->platform
== PLATFORM_ARM
)
1264 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1266 if (package
->platform
== PLATFORM_X64
)
1268 if (!is_64bit
&& !is_wow64
)
1269 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1270 if (package
->version
< 200)
1271 return ERROR_INSTALL_PACKAGE_INVALID
;
1273 if (!package
->num_langids
)
1275 return ERROR_SUCCESS
;
1277 for (i
= 0; i
< package
->num_langids
; i
++)
1279 LANGID langid
= package
->langids
[i
];
1281 if (PRIMARYLANGID( langid
) == LANG_NEUTRAL
)
1283 langid
= MAKELANGID( PRIMARYLANGID( GetSystemDefaultLangID() ), SUBLANGID( langid
) );
1285 if (SUBLANGID( langid
) == SUBLANG_NEUTRAL
)
1287 langid
= MAKELANGID( PRIMARYLANGID( langid
), SUBLANGID( GetSystemDefaultLangID() ) );
1289 if (IsValidLocale( langid
, LCID_INSTALLED
))
1290 return ERROR_SUCCESS
;
1292 return ERROR_INSTALL_LANGUAGE_UNSUPPORTED
;
1295 static WCHAR
*get_product_code( MSIDATABASE
*db
)
1297 static const WCHAR query
[] = {
1298 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
1299 'F','R','O','M',' ','`','P','r','o','p','e','r','t','y','`',' ',
1300 'W','H','E','R','E',' ','`','P','r','o','p','e','r','t','y','`','=',
1301 '\'','P','r','o','d','u','c','t','C','o','d','e','\'',0};
1306 if (MSI_DatabaseOpenViewW( db
, query
, &view
) != ERROR_SUCCESS
)
1310 if (MSI_ViewExecute( view
, 0 ) != ERROR_SUCCESS
)
1312 MSI_ViewClose( view
);
1313 msiobj_release( &view
->hdr
);
1316 if (MSI_ViewFetch( view
, &rec
) == ERROR_SUCCESS
)
1318 ret
= strdupW( MSI_RecordGetString( rec
, 1 ) );
1319 msiobj_release( &rec
->hdr
);
1321 MSI_ViewClose( view
);
1322 msiobj_release( &view
->hdr
);
1326 static UINT
get_registered_local_package( const WCHAR
*product
, const WCHAR
*package
, WCHAR
*localfile
)
1328 MSIINSTALLCONTEXT context
;
1329 HKEY product_key
, props_key
;
1330 WCHAR
*registered_package
= NULL
, unsquashed
[GUID_SIZE
];
1333 r
= msi_locate_product( product
, &context
);
1334 if (r
!= ERROR_SUCCESS
)
1337 r
= MSIREG_OpenProductKey( product
, NULL
, context
, &product_key
, FALSE
);
1338 if (r
!= ERROR_SUCCESS
)
1341 r
= MSIREG_OpenInstallProps( product
, context
, NULL
, &props_key
, FALSE
);
1342 if (r
!= ERROR_SUCCESS
)
1344 RegCloseKey( product_key
);
1347 r
= ERROR_FUNCTION_FAILED
;
1348 registered_package
= msi_reg_get_val_str( product_key
, INSTALLPROPERTY_PACKAGECODEW
);
1349 if (!registered_package
)
1352 unsquash_guid( registered_package
, unsquashed
);
1353 if (!strcmpiW( package
, unsquashed
))
1355 WCHAR
*filename
= msi_reg_get_val_str( props_key
, INSTALLPROPERTY_LOCALPACKAGEW
);
1359 strcpyW( localfile
, filename
);
1360 msi_free( filename
);
1364 msi_free( registered_package
);
1365 RegCloseKey( props_key
);
1366 RegCloseKey( product_key
);
1370 static WCHAR
*get_package_code( MSIDATABASE
*db
)
1376 r
= msi_get_suminfo( db
->storage
, 0, &si
);
1377 if (r
!= ERROR_SUCCESS
)
1379 r
= msi_get_db_suminfo( db
, 0, &si
);
1380 if (r
!= ERROR_SUCCESS
)
1382 WARN("failed to load summary info %u\n", r
);
1386 ret
= msi_suminfo_dup_string( si
, PID_REVNUMBER
);
1387 msiobj_release( &si
->hdr
);
1391 static UINT
get_local_package( const WCHAR
*filename
, WCHAR
*localfile
)
1393 WCHAR
*product_code
, *package_code
;
1397 if ((r
= MSI_OpenDatabaseW( filename
, MSIDBOPEN_READONLY
, &db
)) != ERROR_SUCCESS
)
1399 if (GetFileAttributesW( filename
) == INVALID_FILE_ATTRIBUTES
)
1400 return ERROR_FILE_NOT_FOUND
;
1403 if (!(product_code
= get_product_code( db
)))
1405 msiobj_release( &db
->hdr
);
1406 return ERROR_INSTALL_PACKAGE_INVALID
;
1408 if (!(package_code
= get_package_code( db
)))
1410 msi_free( product_code
);
1411 msiobj_release( &db
->hdr
);
1412 return ERROR_INSTALL_PACKAGE_INVALID
;
1414 r
= get_registered_local_package( product_code
, package_code
, localfile
);
1415 msi_free( package_code
);
1416 msi_free( product_code
);
1417 msiobj_release( &db
->hdr
);
1421 UINT
msi_set_original_database_property( MSIDATABASE
*db
, const WCHAR
*package
)
1425 if (UrlIsW( package
, URLIS_URL
))
1426 r
= msi_set_property( db
, szOriginalDatabase
, package
, -1 );
1427 else if (package
[0] == '#')
1428 r
= msi_set_property( db
, szOriginalDatabase
, db
->path
, -1 );
1434 if (!(len
= GetFullPathNameW( package
, 0, NULL
, NULL
))) return GetLastError();
1435 if (!(path
= msi_alloc( len
* sizeof(WCHAR
) ))) return ERROR_OUTOFMEMORY
;
1436 len
= GetFullPathNameW( package
, len
, path
, NULL
);
1437 r
= msi_set_property( db
, szOriginalDatabase
, path
, len
);
1443 UINT
MSI_OpenPackageW(LPCWSTR szPackage
, MSIPACKAGE
**pPackage
)
1445 static const WCHAR dotmsi
[] = {'.','m','s','i',0};
1447 MSIPACKAGE
*package
;
1449 MSIRECORD
*data_row
, *info_row
;
1450 LPWSTR ptr
, base_url
= NULL
;
1452 WCHAR localfile
[MAX_PATH
], cachefile
[MAX_PATH
];
1453 LPCWSTR file
= szPackage
;
1456 BOOL delete_on_close
= FALSE
;
1458 WCHAR
*info_template
;
1460 TRACE("%s %p\n", debugstr_w(szPackage
), pPackage
);
1462 MSI_ProcessMessage(NULL
, INSTALLMESSAGE_INITIALIZE
, 0);
1465 if( szPackage
[0] == '#' )
1467 handle
= atoiW(&szPackage
[1]);
1468 db
= msihandle2msiinfo( handle
, MSIHANDLETYPE_DATABASE
);
1473 if (!(remote
= msi_get_remote(handle
)))
1474 return ERROR_INVALID_HANDLE
;
1476 WARN("MsiOpenPackage not allowed during a custom action!\n");
1478 return ERROR_FUNCTION_FAILED
;
1483 if ( UrlIsW( szPackage
, URLIS_URL
) )
1485 r
= msi_download_file( szPackage
, cachefile
);
1486 if (r
!= ERROR_SUCCESS
)
1491 base_url
= strdupW( szPackage
);
1493 return ERROR_OUTOFMEMORY
;
1495 ptr
= strrchrW( base_url
, '/' );
1496 if (ptr
) *(ptr
+ 1) = '\0';
1498 r
= get_local_package( file
, localfile
);
1499 if (r
!= ERROR_SUCCESS
|| GetFileAttributesW( localfile
) == INVALID_FILE_ATTRIBUTES
)
1501 r
= msi_create_empty_local_file( localfile
, dotmsi
);
1502 if (r
!= ERROR_SUCCESS
)
1504 msi_free ( base_url
);
1508 if (!CopyFileW( file
, localfile
, FALSE
))
1511 WARN("unable to copy package %s to %s (%u)\n", debugstr_w(file
), debugstr_w(localfile
), r
);
1512 DeleteFileW( localfile
);
1513 msi_free ( base_url
);
1516 delete_on_close
= TRUE
;
1518 TRACE("opening package %s\n", debugstr_w( localfile
));
1519 r
= MSI_OpenDatabaseW( localfile
, MSIDBOPEN_TRANSACT
, &db
);
1520 if (r
!= ERROR_SUCCESS
)
1522 msi_free ( base_url
);
1526 package
= MSI_CreatePackage( db
, base_url
);
1527 msi_free( base_url
);
1528 msiobj_release( &db
->hdr
);
1529 if (!package
) return ERROR_INSTALL_PACKAGE_INVALID
;
1530 package
->localfile
= strdupW( localfile
);
1531 package
->delete_on_close
= delete_on_close
;
1533 r
= msi_get_suminfo( db
->storage
, 0, &si
);
1534 if (r
!= ERROR_SUCCESS
)
1536 r
= msi_get_db_suminfo( db
, 0, &si
);
1537 if (r
!= ERROR_SUCCESS
)
1539 WARN("failed to load summary info\n");
1540 msiobj_release( &package
->hdr
);
1541 return ERROR_INSTALL_PACKAGE_INVALID
;
1544 r
= parse_suminfo( si
, package
);
1545 msiobj_release( &si
->hdr
);
1546 if (r
!= ERROR_SUCCESS
)
1548 WARN("failed to parse summary info %u\n", r
);
1549 msiobj_release( &package
->hdr
);
1552 r
= validate_package( package
);
1553 if (r
!= ERROR_SUCCESS
)
1555 msiobj_release( &package
->hdr
);
1558 msi_set_property( package
->db
, szDatabase
, db
->path
, -1 );
1559 set_installed_prop( package
);
1560 msi_set_context( package
);
1564 WCHAR patch_code
[GUID_SIZE
];
1565 r
= MsiEnumPatchesExW( package
->ProductCode
, NULL
, package
->Context
,
1566 MSIPATCHSTATE_APPLIED
, index
, patch_code
, NULL
, NULL
, NULL
, NULL
);
1567 if (r
!= ERROR_SUCCESS
)
1570 TRACE("found registered patch %s\n", debugstr_w(patch_code
));
1572 r
= msi_apply_registered_patch( package
, patch_code
);
1573 if (r
!= ERROR_SUCCESS
)
1575 ERR("registered patch failed to apply %u\n", r
);
1576 msiobj_release( &package
->hdr
);
1581 if (index
) msi_adjust_privilege_properties( package
);
1583 r
= msi_set_original_database_property( package
->db
, szPackage
);
1584 if (r
!= ERROR_SUCCESS
)
1586 msiobj_release( &package
->hdr
);
1590 package
->log_file
= CreateFileW( gszLogFile
, GENERIC_WRITE
, FILE_SHARE_WRITE
, NULL
,
1591 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1593 /* FIXME: when should these messages be sent? */
1594 data_row
= MSI_CreateRecord(3);
1596 return ERROR_OUTOFMEMORY
;
1597 MSI_RecordSetStringW(data_row
, 0, NULL
);
1598 MSI_RecordSetInteger(data_row
, 1, 0);
1599 MSI_RecordSetInteger(data_row
, 2, package
->num_langids
? package
->langids
[0] : 0);
1600 MSI_RecordSetInteger(data_row
, 3, msi_get_string_table_codepage(package
->db
->strings
));
1601 MSI_ProcessMessageVerbatim(package
, INSTALLMESSAGE_COMMONDATA
, data_row
);
1603 info_row
= MSI_CreateRecord(0);
1606 msiobj_release(&data_row
->hdr
);
1607 return ERROR_OUTOFMEMORY
;
1609 info_template
= msi_get_error_message(package
->db
, MSIERR_INFO_LOGGINGSTART
);
1610 MSI_RecordSetStringW(info_row
, 0, info_template
);
1611 msi_free(info_template
);
1612 MSI_ProcessMessage(package
, INSTALLMESSAGE_INFO
|MB_ICONHAND
, info_row
);
1614 MSI_ProcessMessage(package
, INSTALLMESSAGE_COMMONDATA
, data_row
);
1616 productname
= msi_dup_property(package
->db
, INSTALLPROPERTY_PRODUCTNAMEW
);
1617 MSI_RecordSetInteger(data_row
, 1, 1);
1618 MSI_RecordSetStringW(data_row
, 2, productname
);
1619 MSI_RecordSetStringW(data_row
, 3, NULL
);
1620 MSI_ProcessMessage(package
, INSTALLMESSAGE_COMMONDATA
, data_row
);
1622 msi_free(productname
);
1623 msiobj_release(&info_row
->hdr
);
1624 msiobj_release(&data_row
->hdr
);
1626 *pPackage
= package
;
1627 return ERROR_SUCCESS
;
1630 UINT WINAPI
MsiOpenPackageExW(LPCWSTR szPackage
, DWORD dwOptions
, MSIHANDLE
*phPackage
)
1632 MSIPACKAGE
*package
= NULL
;
1635 TRACE("%s %08x %p\n", debugstr_w(szPackage
), dwOptions
, phPackage
);
1637 if( !szPackage
|| !phPackage
)
1638 return ERROR_INVALID_PARAMETER
;
1642 FIXME("Should create an empty database and package\n");
1643 return ERROR_FUNCTION_FAILED
;
1647 FIXME("dwOptions %08x not supported\n", dwOptions
);
1649 ret
= MSI_OpenPackageW( szPackage
, &package
);
1650 if( ret
== ERROR_SUCCESS
)
1652 *phPackage
= alloc_msihandle( &package
->hdr
);
1654 ret
= ERROR_NOT_ENOUGH_MEMORY
;
1655 msiobj_release( &package
->hdr
);
1658 MSI_ProcessMessage(NULL
, INSTALLMESSAGE_TERMINATE
, 0);
1663 UINT WINAPI
MsiOpenPackageW(LPCWSTR szPackage
, MSIHANDLE
*phPackage
)
1665 return MsiOpenPackageExW( szPackage
, 0, phPackage
);
1668 UINT WINAPI
MsiOpenPackageExA(LPCSTR szPackage
, DWORD dwOptions
, MSIHANDLE
*phPackage
)
1670 LPWSTR szwPack
= NULL
;
1675 szwPack
= strdupAtoW( szPackage
);
1677 return ERROR_OUTOFMEMORY
;
1680 ret
= MsiOpenPackageExW( szwPack
, dwOptions
, phPackage
);
1682 msi_free( szwPack
);
1687 UINT WINAPI
MsiOpenPackageA(LPCSTR szPackage
, MSIHANDLE
*phPackage
)
1689 return MsiOpenPackageExA( szPackage
, 0, phPackage
);
1692 MSIHANDLE WINAPI
MsiGetActiveDatabase(MSIHANDLE hInstall
)
1694 MSIPACKAGE
*package
;
1695 MSIHANDLE handle
= 0;
1698 TRACE("(%d)\n",hInstall
);
1700 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
1703 handle
= alloc_msihandle( &package
->db
->hdr
);
1704 msiobj_release( &package
->hdr
);
1706 else if ((remote
= msi_get_remote(hInstall
)))
1708 remote_GetActiveDatabase(remote
, &handle
);
1714 static INT
internal_ui_handler(MSIPACKAGE
*package
, INSTALLMESSAGE eMessageType
, MSIRECORD
*record
, LPCWSTR message
)
1716 static const WCHAR szActionData
[] = {'A','c','t','i','o','n','D','a','t','a',0};
1717 static const WCHAR szActionText
[] = {'A','c','t','i','o','n','T','e','x','t',0};
1718 static const WCHAR szSetProgress
[] = {'S','e','t','P','r','o','g','r','e','s','s',0};
1719 static const WCHAR szWindows_Installer
[] =
1720 {'W','i','n','d','o','w','s',' ','I','n','s','t','a','l','l','e','r',0};
1722 if (!package
|| (package
->ui_level
& INSTALLUILEVEL_MASK
) == INSTALLUILEVEL_NONE
)
1725 /* todo: check if message needs additional styles (topmost/foreground/modality?) */
1727 switch (eMessageType
& 0xff000000)
1729 case INSTALLMESSAGE_FATALEXIT
:
1730 case INSTALLMESSAGE_ERROR
:
1731 case INSTALLMESSAGE_OUTOFDISKSPACE
:
1732 if (package
->ui_level
& INSTALLUILEVEL_PROGRESSONLY
) return 0;
1733 if (!(eMessageType
& MB_ICONMASK
))
1734 eMessageType
|= MB_ICONEXCLAMATION
;
1735 return MessageBoxW(gUIhwnd
, message
, szWindows_Installer
, eMessageType
& 0x00ffffff);
1736 case INSTALLMESSAGE_WARNING
:
1737 if (package
->ui_level
& INSTALLUILEVEL_PROGRESSONLY
) return 0;
1738 if (!(eMessageType
& MB_ICONMASK
))
1739 eMessageType
|= MB_ICONASTERISK
;
1740 return MessageBoxW(gUIhwnd
, message
, szWindows_Installer
, eMessageType
& 0x00ffffff);
1741 case INSTALLMESSAGE_USER
:
1742 if (package
->ui_level
& INSTALLUILEVEL_PROGRESSONLY
) return 0;
1743 if (!(eMessageType
& MB_ICONMASK
))
1744 eMessageType
|= MB_USERICON
;
1745 return MessageBoxW(gUIhwnd
, message
, szWindows_Installer
, eMessageType
& 0x00ffffff);
1746 case INSTALLMESSAGE_INFO
:
1747 case INSTALLMESSAGE_INITIALIZE
:
1748 case INSTALLMESSAGE_TERMINATE
:
1749 case INSTALLMESSAGE_INSTALLSTART
:
1750 case INSTALLMESSAGE_INSTALLEND
:
1752 case INSTALLMESSAGE_SHOWDIALOG
:
1754 LPWSTR dialog
= msi_dup_record_field(record
, 0);
1755 INT rc
= ACTION_DialogBox(package
, dialog
);
1759 case INSTALLMESSAGE_ACTIONSTART
:
1762 MSIRECORD
*uirow
= MSI_CreateRecord(1);
1763 if (!uirow
) return -1;
1764 deformat_string(package
, MSI_RecordGetString(record
, 2), &deformatted
);
1765 MSI_RecordSetStringW(uirow
, 1, deformatted
);
1766 msi_event_fire(package
, szActionText
, uirow
);
1768 msi_free(deformatted
);
1769 msiobj_release(&uirow
->hdr
);
1772 case INSTALLMESSAGE_ACTIONDATA
:
1774 MSIRECORD
*uirow
= MSI_CreateRecord(1);
1775 if (!uirow
) return -1;
1776 MSI_RecordSetStringW(uirow
, 1, message
);
1777 msi_event_fire(package
, szActionData
, uirow
);
1778 msiobj_release(&uirow
->hdr
);
1780 if (package
->action_progress_increment
)
1782 uirow
= MSI_CreateRecord(2);
1783 if (!uirow
) return -1;
1784 MSI_RecordSetInteger(uirow
, 1, 2);
1785 MSI_RecordSetInteger(uirow
, 2, package
->action_progress_increment
);
1786 msi_event_fire(package
, szSetProgress
, uirow
);
1787 msiobj_release(&uirow
->hdr
);
1791 case INSTALLMESSAGE_PROGRESS
:
1792 msi_event_fire(package
, szSetProgress
, record
);
1794 case INSTALLMESSAGE_COMMONDATA
:
1795 switch (MSI_RecordGetInteger(record
, 1))
1806 FIXME("internal UI not implemented for message 0x%08x (UI level = %x)\n", eMessageType
, package
->ui_level
);
1811 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};
1820 {2726, szActionNotFound
},
1824 static LPCWSTR
get_internal_error_message(int error
)
1828 while (internal_errors
[i
].id
!= 0)
1830 if (internal_errors
[i
].id
== error
)
1831 return internal_errors
[i
].text
;
1835 FIXME("missing error message %d\n", error
);
1839 /* Returned string must be freed */
1840 LPWSTR
msi_get_error_message(MSIDATABASE
*db
, int error
)
1842 static const WCHAR query
[] =
1843 {'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ',
1844 'F','R','O','M',' ','`','E','r','r','o','r','`',' ','W','H','E','R','E',' ',
1845 '`','E','r','r','o','r','`',' ','=',' ','%','i',0};
1849 if ((record
= MSI_QueryGetRecord(db
, query
, error
)))
1851 ret
= msi_dup_record_field(record
, 1);
1852 msiobj_release(&record
->hdr
);
1854 else if (error
< 2000)
1856 int len
= LoadStringW(msi_hInstance
, IDS_ERROR_BASE
+ error
, (LPWSTR
) &ret
, 0);
1859 ret
= msi_alloc((len
+ 1) * sizeof(WCHAR
));
1860 LoadStringW(msi_hInstance
, IDS_ERROR_BASE
+ error
, ret
, len
+ 1);
1869 INT
MSI_ProcessMessageVerbatim(MSIPACKAGE
*package
, INSTALLMESSAGE eMessageType
, MSIRECORD
*record
)
1871 LPWSTR message
= {0};
1873 DWORD log_type
= 1 << (eMessageType
>> 24);
1878 TRACE("%x\n", eMessageType
);
1879 if (TRACE_ON(msi
)) dump_record(record
);
1881 if (!package
|| !record
)
1884 res
= MSI_FormatRecordW(package
, record
, message
, &len
);
1885 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
)
1888 message
= msi_alloc(len
* sizeof(WCHAR
));
1889 if (!message
) return ERROR_OUTOFMEMORY
;
1890 MSI_FormatRecordW(package
, record
, message
, &len
);
1893 /* convert it to ASCII */
1894 len
= WideCharToMultiByte( CP_ACP
, 0, message
, -1, NULL
, 0, NULL
, NULL
);
1895 msg
= msi_alloc( len
);
1896 WideCharToMultiByte( CP_ACP
, 0, message
, -1, msg
, len
, NULL
, NULL
);
1898 if (gUIHandlerRecord
&& (gUIFilterRecord
& log_type
))
1900 MSIHANDLE rec
= alloc_msihandle(&record
->hdr
);
1901 TRACE("Calling UI handler %p(pvContext=%p, iMessageType=%08x, hRecord=%u)\n",
1902 gUIHandlerRecord
, gUIContextRecord
, eMessageType
, rec
);
1903 rc
= gUIHandlerRecord( gUIContextRecord
, eMessageType
, rec
);
1904 MsiCloseHandle( rec
);
1906 if (!rc
&& gUIHandlerW
&& (gUIFilter
& log_type
))
1908 TRACE("Calling UI handler %p(pvContext=%p, iMessageType=%08x, szMessage=%s)\n",
1909 gUIHandlerW
, gUIContext
, eMessageType
, debugstr_w(message
));
1910 rc
= gUIHandlerW( gUIContext
, eMessageType
, message
);
1912 else if (!rc
&& gUIHandlerA
&& (gUIFilter
& log_type
))
1914 TRACE("Calling UI handler %p(pvContext=%p, iMessageType=%08x, szMessage=%s)\n",
1915 gUIHandlerA
, gUIContext
, eMessageType
, debugstr_a(msg
));
1916 rc
= gUIHandlerA( gUIContext
, eMessageType
, msg
);
1920 rc
= internal_ui_handler(package
, eMessageType
, record
, message
);
1922 if (!rc
&& package
&& package
->log_file
!= INVALID_HANDLE_VALUE
&&
1923 (eMessageType
& 0xff000000) != INSTALLMESSAGE_PROGRESS
)
1926 WriteFile( package
->log_file
, msg
, len
- 1, &written
, NULL
);
1927 WriteFile( package
->log_file
, "\n", 1, &written
, NULL
);
1930 msi_free( message
);
1935 INT
MSI_ProcessMessage( MSIPACKAGE
*package
, INSTALLMESSAGE eMessageType
, MSIRECORD
*record
)
1937 switch (eMessageType
& 0xff000000)
1939 case INSTALLMESSAGE_FATALEXIT
:
1940 case INSTALLMESSAGE_ERROR
:
1941 case INSTALLMESSAGE_WARNING
:
1942 case INSTALLMESSAGE_USER
:
1943 case INSTALLMESSAGE_INFO
:
1944 case INSTALLMESSAGE_OUTOFDISKSPACE
:
1945 if (MSI_RecordGetInteger(record
, 1) != MSI_NULL_INTEGER
)
1950 LPWSTR template_rec
= NULL
, template_prefix
= NULL
;
1951 int error
= MSI_RecordGetInteger(record
, 1);
1953 if (MSI_RecordIsNull(record
, 0))
1957 template_rec
= msi_get_error_message(package
->db
, error
);
1959 if (!template_rec
&& error
>= 2000)
1961 /* internal error, not localized */
1962 if ((template_rec
= (LPWSTR
) get_internal_error_message(error
)))
1964 MSI_RecordSetStringW(record
, 0, template_rec
);
1965 MSI_ProcessMessageVerbatim(package
, INSTALLMESSAGE_INFO
, record
);
1967 template_rec
= msi_get_error_message(package
->db
, MSIERR_INSTALLERROR
);
1968 MSI_RecordSetStringW(record
, 0, template_rec
);
1969 MSI_ProcessMessageVerbatim(package
, eMessageType
, record
);
1970 msi_free(template_rec
);
1976 template_rec
= msi_dup_record_field(record
, 0);
1978 template_prefix
= msi_get_error_message(package
->db
, eMessageType
>> 24);
1979 if (!template_prefix
) template_prefix
= strdupW(szEmpty
);
1983 /* always returns 0 */
1984 MSI_RecordSetStringW(record
, 0, template_prefix
);
1985 MSI_ProcessMessageVerbatim(package
, eMessageType
, record
);
1986 msi_free(template_prefix
);
1990 template = msi_alloc((strlenW(template_rec
) + strlenW(template_prefix
) + 1) * sizeof(WCHAR
));
1991 if (!template) return ERROR_OUTOFMEMORY
;
1993 strcpyW(template, template_prefix
);
1994 strcatW(template, template_rec
);
1995 MSI_RecordSetStringW(record
, 0, template);
1997 msi_free(template_prefix
);
1998 msi_free(template_rec
);
2002 case INSTALLMESSAGE_ACTIONSTART
:
2004 WCHAR
*template = msi_get_error_message(package
->db
, MSIERR_ACTIONSTART
);
2005 MSI_RecordSetStringW(record
, 0, template);
2008 msi_free(package
->LastAction
);
2009 msi_free(package
->LastActionTemplate
);
2010 package
->LastAction
= msi_dup_record_field(record
, 1);
2011 if (!package
->LastAction
) package
->LastAction
= strdupW(szEmpty
);
2012 package
->LastActionTemplate
= msi_dup_record_field(record
, 3);
2015 case INSTALLMESSAGE_ACTIONDATA
:
2016 if (package
->LastAction
&& package
->LastActionTemplate
)
2018 static const WCHAR template_s
[] =
2019 {'{','{','%','s',':',' ','}','}','%','s',0};
2022 template = msi_alloc((strlenW(package
->LastAction
) + strlenW(package
->LastActionTemplate
) + 7) * sizeof(WCHAR
));
2023 if (!template) return ERROR_OUTOFMEMORY
;
2024 sprintfW(template, template_s
, package
->LastAction
, package
->LastActionTemplate
);
2025 MSI_RecordSetStringW(record
, 0, template);
2029 case INSTALLMESSAGE_COMMONDATA
:
2031 WCHAR
*template = msi_get_error_message(package
->db
, MSIERR_COMMONDATA
);
2032 MSI_RecordSetStringW(record
, 0, template);
2038 return MSI_ProcessMessageVerbatim(package
, eMessageType
, record
);
2041 INT WINAPI
MsiProcessMessage( MSIHANDLE hInstall
, INSTALLMESSAGE eMessageType
,
2044 UINT ret
= ERROR_INVALID_HANDLE
;
2045 MSIPACKAGE
*package
= NULL
;
2046 MSIRECORD
*record
= NULL
;
2048 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_INITIALIZE
||
2049 (eMessageType
& 0xff000000) == INSTALLMESSAGE_TERMINATE
)
2052 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_COMMONDATA
&&
2053 MsiRecordGetInteger(hRecord
, 1) != 2)
2056 record
= msihandle2msiinfo(hRecord
, MSIHANDLETYPE_RECORD
);
2058 return ERROR_INVALID_HANDLE
;
2060 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
2065 if (!(remote
= msi_get_remote(hInstall
)))
2066 return ERROR_INVALID_HANDLE
;
2068 ret
= remote_ProcessMessage(remote
, eMessageType
, (struct wire_record
*)&record
->count
);
2070 msiobj_release(&record
->hdr
);
2074 ret
= MSI_ProcessMessage( package
, eMessageType
, record
);
2076 msiobj_release( &package
->hdr
);
2082 UINT WINAPI
MsiSetPropertyA( MSIHANDLE hInstall
, LPCSTR szName
, LPCSTR szValue
)
2084 LPWSTR szwName
= NULL
, szwValue
= NULL
;
2085 UINT r
= ERROR_OUTOFMEMORY
;
2087 szwName
= strdupAtoW( szName
);
2088 if( szName
&& !szwName
)
2091 szwValue
= strdupAtoW( szValue
);
2092 if( szValue
&& !szwValue
)
2095 r
= MsiSetPropertyW( hInstall
, szwName
, szwValue
);
2098 msi_free( szwName
);
2099 msi_free( szwValue
);
2104 void msi_reset_folders( MSIPACKAGE
*package
, BOOL source
)
2108 LIST_FOR_EACH_ENTRY( folder
, &package
->folders
, MSIFOLDER
, entry
)
2112 msi_free( folder
->ResolvedSource
);
2113 folder
->ResolvedSource
= NULL
;
2117 msi_free( folder
->ResolvedTarget
);
2118 folder
->ResolvedTarget
= NULL
;
2123 UINT
msi_set_property( MSIDATABASE
*db
, const WCHAR
*name
, const WCHAR
*value
, int len
)
2125 static const WCHAR insert_query
[] = {
2126 'I','N','S','E','R','T',' ','I','N','T','O',' ',
2127 '`','_','P','r','o','p','e','r','t','y','`',' ',
2128 '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
2129 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
2130 static const WCHAR update_query
[] = {
2131 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
2132 'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ','W','H','E','R','E',' ',
2133 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
2134 static const WCHAR delete_query
[] = {
2135 'D','E','L','E','T','E',' ','F','R','O','M',' ',
2136 '`','_','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2137 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
2139 MSIRECORD
*row
= NULL
;
2144 TRACE("%p %s %s %d\n", db
, debugstr_w(name
), debugstr_wn(value
, len
), len
);
2147 return ERROR_INVALID_PARAMETER
;
2149 /* this one is weird... */
2151 return value
? ERROR_FUNCTION_FAILED
: ERROR_SUCCESS
;
2153 if (value
&& len
< 0) len
= strlenW( value
);
2155 rc
= msi_get_property( db
, name
, 0, &sz
);
2156 if (!value
|| (!*value
&& !len
))
2158 sprintfW( query
, delete_query
, name
);
2160 else if (rc
== ERROR_MORE_DATA
|| rc
== ERROR_SUCCESS
)
2162 sprintfW( query
, update_query
, name
);
2163 row
= MSI_CreateRecord(1);
2164 msi_record_set_string( row
, 1, value
, len
);
2168 strcpyW( query
, insert_query
);
2169 row
= MSI_CreateRecord(2);
2170 msi_record_set_string( row
, 1, name
, -1 );
2171 msi_record_set_string( row
, 2, value
, len
);
2174 rc
= MSI_DatabaseOpenViewW(db
, query
, &view
);
2175 if (rc
== ERROR_SUCCESS
)
2177 rc
= MSI_ViewExecute(view
, row
);
2178 MSI_ViewClose(view
);
2179 msiobj_release(&view
->hdr
);
2181 if (row
) msiobj_release(&row
->hdr
);
2185 UINT WINAPI
MsiSetPropertyW( MSIHANDLE hInstall
, LPCWSTR szName
, LPCWSTR szValue
)
2187 MSIPACKAGE
*package
;
2190 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
2195 if (!(remote
= msi_get_remote(hInstall
)))
2196 return ERROR_INVALID_HANDLE
;
2198 return remote_SetProperty(remote
, szName
, szValue
);
2201 ret
= msi_set_property( package
->db
, szName
, szValue
, -1 );
2202 if (ret
== ERROR_SUCCESS
&& !strcmpW( szName
, szSourceDir
))
2203 msi_reset_folders( package
, TRUE
);
2205 msiobj_release( &package
->hdr
);
2209 static MSIRECORD
*msi_get_property_row( MSIDATABASE
*db
, LPCWSTR name
)
2211 static const WCHAR query
[]= {
2212 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
2213 'F','R','O','M',' ' ,'`','_','P','r','o','p','e','r','t','y','`',' ',
2214 'W','H','E','R','E',' ' ,'`','_','P','r','o','p','e','r','t','y','`','=','?',0};
2215 MSIRECORD
*rec
, *row
= NULL
;
2219 static const WCHAR szDate
[] = {'D','a','t','e',0};
2220 static const WCHAR szTime
[] = {'T','i','m','e',0};
2224 if (!name
|| !*name
)
2227 if (!strcmpW(name
, szDate
))
2229 length
= GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_SHORTDATE
, NULL
, NULL
, NULL
, 0);
2232 buffer
= msi_alloc(length
* sizeof(WCHAR
));
2233 GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_SHORTDATE
, NULL
, NULL
, buffer
, length
);
2235 row
= MSI_CreateRecord(1);
2241 MSI_RecordSetStringW(row
, 1, buffer
);
2245 else if (!strcmpW(name
, szTime
))
2247 length
= GetTimeFormatW(LOCALE_USER_DEFAULT
, TIME_NOTIMEMARKER
, NULL
, NULL
, NULL
, 0);
2250 buffer
= msi_alloc(length
* sizeof(WCHAR
));
2251 GetTimeFormatW(LOCALE_USER_DEFAULT
, TIME_NOTIMEMARKER
, NULL
, NULL
, buffer
, length
);
2253 row
= MSI_CreateRecord(1);
2259 MSI_RecordSetStringW(row
, 1, buffer
);
2264 rec
= MSI_CreateRecord(1);
2268 MSI_RecordSetStringW(rec
, 1, name
);
2270 r
= MSI_DatabaseOpenViewW(db
, query
, &view
);
2271 if (r
== ERROR_SUCCESS
)
2273 MSI_ViewExecute(view
, rec
);
2274 MSI_ViewFetch(view
, &row
);
2275 MSI_ViewClose(view
);
2276 msiobj_release(&view
->hdr
);
2278 msiobj_release(&rec
->hdr
);
2282 /* internal function, not compatible with MsiGetPropertyW */
2283 UINT
msi_get_property( MSIDATABASE
*db
, LPCWSTR szName
,
2284 LPWSTR szValueBuf
, LPDWORD pchValueBuf
)
2287 UINT rc
= ERROR_FUNCTION_FAILED
;
2289 TRACE("%p %s %p %p\n", db
, debugstr_w(szName
), szValueBuf
, pchValueBuf
);
2291 row
= msi_get_property_row( db
, szName
);
2293 if (*pchValueBuf
> 0)
2298 rc
= MSI_RecordGetStringW(row
, 1, szValueBuf
, pchValueBuf
);
2299 msiobj_release(&row
->hdr
);
2302 if (rc
== ERROR_SUCCESS
)
2303 TRACE("returning %s for property %s\n", debugstr_wn(szValueBuf
, *pchValueBuf
),
2304 debugstr_w(szName
));
2305 else if (rc
== ERROR_MORE_DATA
)
2306 TRACE("need %d sized buffer for %s\n", *pchValueBuf
,
2307 debugstr_w(szName
));
2311 TRACE("property %s not found\n", debugstr_w(szName
));
2317 LPWSTR
msi_dup_property(MSIDATABASE
*db
, LPCWSTR prop
)
2323 r
= msi_get_property(db
, prop
, NULL
, &sz
);
2324 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
2328 str
= msi_alloc(sz
* sizeof(WCHAR
));
2329 r
= msi_get_property(db
, prop
, str
, &sz
);
2330 if (r
!= ERROR_SUCCESS
)
2339 int msi_get_property_int( MSIDATABASE
*db
, LPCWSTR prop
, int def
)
2341 LPWSTR str
= msi_dup_property( db
, prop
);
2342 int val
= str
? atoiW(str
) : def
;
2347 static UINT
MSI_GetProperty( MSIHANDLE handle
, LPCWSTR name
,
2348 awstring
*szValueBuf
, LPDWORD pchValueBuf
)
2350 MSIPACKAGE
*package
;
2351 MSIRECORD
*row
= NULL
;
2352 UINT r
= ERROR_FUNCTION_FAILED
;
2356 TRACE("%u %s %p %p\n", handle
, debugstr_w(name
),
2357 szValueBuf
->str
.w
, pchValueBuf
);
2360 return ERROR_INVALID_PARAMETER
;
2362 package
= msihandle2msiinfo( handle
, MSIHANDLETYPE_PACKAGE
);
2365 LPWSTR value
= NULL
, buffer
;
2368 if (!(remote
= msi_get_remote(handle
)))
2369 return ERROR_INVALID_HANDLE
;
2371 r
= remote_GetProperty(remote
, name
, &value
, &len
);
2372 if (r
!= ERROR_SUCCESS
)
2375 /* String might contain embedded nulls.
2376 * Native returns the correct size but truncates the string. */
2377 buffer
= heap_alloc_zero((len
+ 1) * sizeof(WCHAR
));
2380 midl_user_free(value
);
2381 return ERROR_OUTOFMEMORY
;
2383 strcpyW(buffer
, value
);
2385 r
= msi_strcpy_to_awstring(buffer
, len
, szValueBuf
, pchValueBuf
);
2387 /* Bug required by Adobe installers */
2388 if (pchValueBuf
&& !szValueBuf
->unicode
&& !szValueBuf
->str
.a
)
2389 *pchValueBuf
*= sizeof(WCHAR
);
2392 midl_user_free(value
);
2396 row
= msi_get_property_row( package
->db
, name
);
2398 val
= msi_record_get_string( row
, 1, (int *)&len
);
2403 r
= msi_strcpy_to_awstring( val
, len
, szValueBuf
, pchValueBuf
);
2406 msiobj_release( &row
->hdr
);
2407 msiobj_release( &package
->hdr
);
2412 UINT WINAPI
MsiGetPropertyA( MSIHANDLE hInstall
, LPCSTR szName
,
2413 LPSTR szValueBuf
, LPDWORD pchValueBuf
)
2419 val
.unicode
= FALSE
;
2420 val
.str
.a
= szValueBuf
;
2422 name
= strdupAtoW( szName
);
2423 if (szName
&& !name
)
2424 return ERROR_OUTOFMEMORY
;
2426 r
= MSI_GetProperty( hInstall
, name
, &val
, pchValueBuf
);
2431 UINT WINAPI
MsiGetPropertyW( MSIHANDLE hInstall
, LPCWSTR szName
,
2432 LPWSTR szValueBuf
, LPDWORD pchValueBuf
)
2437 val
.str
.w
= szValueBuf
;
2439 return MSI_GetProperty( hInstall
, szName
, &val
, pchValueBuf
);
2442 HRESULT __cdecl
remote_GetActiveDatabase(MSIHANDLE hinst
, MSIHANDLE
*handle
)
2444 *handle
= MsiGetActiveDatabase(hinst
);
2449 UINT __cdecl
remote_GetProperty(MSIHANDLE hinst
, LPCWSTR property
, LPWSTR
*value
, DWORD
*size
)
2455 r
= MsiGetPropertyW(hinst
, property
, empty
, size
);
2456 if (r
== ERROR_MORE_DATA
)
2459 *value
= midl_user_allocate(*size
* sizeof(WCHAR
));
2461 return ERROR_OUTOFMEMORY
;
2462 r
= MsiGetPropertyW(hinst
, property
, *value
, size
);
2467 UINT __cdecl
remote_SetProperty(MSIHANDLE hinst
, LPCWSTR property
, LPCWSTR value
)
2469 return MsiSetPropertyW(hinst
, property
, value
);
2472 int __cdecl
remote_ProcessMessage(MSIHANDLE hinst
, INSTALLMESSAGE message
, struct wire_record
*remote_rec
)
2478 if ((r
= unmarshal_record(remote_rec
, &rec
)))
2481 ret
= MsiProcessMessage(hinst
, message
, rec
);
2483 MsiCloseHandle(rec
);
2487 HRESULT __cdecl
remote_DoAction(MSIHANDLE hinst
, BSTR action
)
2489 UINT r
= MsiDoActionW(hinst
, action
);
2490 return HRESULT_FROM_WIN32(r
);
2493 HRESULT __cdecl
remote_Sequence(MSIHANDLE hinst
, BSTR table
, int sequence
)
2495 UINT r
= MsiSequenceW(hinst
, table
, sequence
);
2496 return HRESULT_FROM_WIN32(r
);
2499 HRESULT __cdecl
remote_GetTargetPath(MSIHANDLE hinst
, BSTR folder
, BSTR value
, DWORD
*size
)
2501 UINT r
= MsiGetTargetPathW(hinst
, folder
, value
, size
);
2502 return HRESULT_FROM_WIN32(r
);
2505 HRESULT __cdecl
remote_SetTargetPath(MSIHANDLE hinst
, BSTR folder
, BSTR value
)
2507 UINT r
= MsiSetTargetPathW(hinst
, folder
, value
);
2508 return HRESULT_FROM_WIN32(r
);
2511 HRESULT __cdecl
remote_GetSourcePath(MSIHANDLE hinst
, BSTR folder
, BSTR value
, DWORD
*size
)
2513 UINT r
= MsiGetSourcePathW(hinst
, folder
, value
, size
);
2514 return HRESULT_FROM_WIN32(r
);
2517 HRESULT __cdecl
remote_GetMode(MSIHANDLE hinst
, MSIRUNMODE mode
, BOOL
*ret
)
2519 *ret
= MsiGetMode(hinst
, mode
);
2523 HRESULT __cdecl
remote_SetMode(MSIHANDLE hinst
, MSIRUNMODE mode
, BOOL state
)
2525 UINT r
= MsiSetMode(hinst
, mode
, state
);
2526 return HRESULT_FROM_WIN32(r
);
2529 HRESULT __cdecl
remote_GetFeatureState(MSIHANDLE hinst
, BSTR feature
,
2530 INSTALLSTATE
*installed
, INSTALLSTATE
*action
)
2532 UINT r
= MsiGetFeatureStateW(hinst
, feature
, installed
, action
);
2533 return HRESULT_FROM_WIN32(r
);
2536 HRESULT __cdecl
remote_SetFeatureState(MSIHANDLE hinst
, BSTR feature
, INSTALLSTATE state
)
2538 UINT r
= MsiSetFeatureStateW(hinst
, feature
, state
);
2539 return HRESULT_FROM_WIN32(r
);
2542 HRESULT __cdecl
remote_GetComponentState(MSIHANDLE hinst
, BSTR component
,
2543 INSTALLSTATE
*installed
, INSTALLSTATE
*action
)
2545 UINT r
= MsiGetComponentStateW(hinst
, component
, installed
, action
);
2546 return HRESULT_FROM_WIN32(r
);
2549 HRESULT __cdecl
remote_SetComponentState(MSIHANDLE hinst
, BSTR component
, INSTALLSTATE state
)
2551 UINT r
= MsiSetComponentStateW(hinst
, component
, state
);
2552 return HRESULT_FROM_WIN32(r
);
2555 HRESULT __cdecl
remote_GetLanguage(MSIHANDLE hinst
, LANGID
*language
)
2557 *language
= MsiGetLanguage(hinst
);
2561 HRESULT __cdecl
remote_SetInstallLevel(MSIHANDLE hinst
, int level
)
2563 UINT r
= MsiSetInstallLevel(hinst
, level
);
2564 return HRESULT_FROM_WIN32(r
);
2567 HRESULT __cdecl
remote_FormatRecord(MSIHANDLE hinst
, MSIHANDLE record
,
2571 UINT r
= MsiFormatRecordW(hinst
, record
, NULL
, &size
);
2572 if (r
== ERROR_SUCCESS
)
2574 *value
= SysAllocStringLen(NULL
, size
);
2576 return E_OUTOFMEMORY
;
2578 r
= MsiFormatRecordW(hinst
, record
, *value
, &size
);
2580 return HRESULT_FROM_WIN32(r
);
2583 HRESULT __cdecl
remote_EvaluateCondition(MSIHANDLE hinst
, BSTR condition
)
2585 UINT r
= MsiEvaluateConditionW(hinst
, condition
);
2586 return HRESULT_FROM_WIN32(r
);
2589 HRESULT __cdecl
remote_GetFeatureCost(MSIHANDLE hinst
, BSTR feature
,
2590 INT cost_tree
, INSTALLSTATE state
, INT
*cost
)
2592 UINT r
= MsiGetFeatureCostW(hinst
, feature
, cost_tree
, state
, cost
);
2593 return HRESULT_FROM_WIN32(r
);
2596 HRESULT __cdecl
remote_EnumComponentCosts(MSIHANDLE hinst
, BSTR component
,
2597 DWORD index
, INSTALLSTATE state
, BSTR drive
,
2598 DWORD
*buflen
, INT
*cost
, INT
*temp
)
2600 UINT r
= MsiEnumComponentCostsW(hinst
, component
, index
, state
, drive
, buflen
, cost
, temp
);
2601 return HRESULT_FROM_WIN32(r
);
2604 UINT
msi_package_add_info(MSIPACKAGE
*package
, DWORD context
, DWORD options
,
2605 LPCWSTR property
, LPWSTR value
)
2607 MSISOURCELISTINFO
*info
;
2609 LIST_FOR_EACH_ENTRY( info
, &package
->sourcelist_info
, MSISOURCELISTINFO
, entry
)
2611 if (!strcmpW( info
->value
, value
)) return ERROR_SUCCESS
;
2614 info
= msi_alloc(sizeof(MSISOURCELISTINFO
));
2616 return ERROR_OUTOFMEMORY
;
2618 info
->context
= context
;
2619 info
->options
= options
;
2620 info
->property
= property
;
2621 info
->value
= strdupW(value
);
2622 list_add_head(&package
->sourcelist_info
, &info
->entry
);
2624 return ERROR_SUCCESS
;
2627 UINT
msi_package_add_media_disk(MSIPACKAGE
*package
, DWORD context
, DWORD options
,
2628 DWORD disk_id
, LPWSTR volume_label
, LPWSTR disk_prompt
)
2632 LIST_FOR_EACH_ENTRY( disk
, &package
->sourcelist_media
, MSIMEDIADISK
, entry
)
2634 if (disk
->disk_id
== disk_id
) return ERROR_SUCCESS
;
2637 disk
= msi_alloc(sizeof(MSIMEDIADISK
));
2639 return ERROR_OUTOFMEMORY
;
2641 disk
->context
= context
;
2642 disk
->options
= options
;
2643 disk
->disk_id
= disk_id
;
2644 disk
->volume_label
= strdupW(volume_label
);
2645 disk
->disk_prompt
= strdupW(disk_prompt
);
2646 list_add_head(&package
->sourcelist_media
, &disk
->entry
);
2648 return ERROR_SUCCESS
;