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
25 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
27 static void remove_tracked_tempfiles( MSIPACKAGE
*package
)
29 struct list
*item
, *cursor
;
31 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->tempfiles
)
33 MSITEMPFILE
*temp
= LIST_ENTRY( item
, MSITEMPFILE
, entry
);
35 list_remove( &temp
->entry
);
36 TRACE("deleting temp file %s\n", debugstr_w( temp
->Path
));
37 DeleteFileW( temp
->Path
);
38 msi_free( temp
->Path
);
43 static void free_feature( MSIFEATURE
*feature
)
45 struct list
*item
, *cursor
;
47 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Children
)
49 FeatureList
*fl
= LIST_ENTRY( item
, FeatureList
, entry
);
50 list_remove( &fl
->entry
);
54 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Components
)
56 ComponentList
*cl
= LIST_ENTRY( item
, ComponentList
, entry
);
57 list_remove( &cl
->entry
);
60 msi_free( feature
->Feature
);
61 msi_free( feature
->Feature_Parent
);
62 msi_free( feature
->Directory
);
63 msi_free( feature
->Description
);
64 msi_free( feature
->Title
);
68 static void free_folder( MSIFOLDER
*folder
)
70 struct list
*item
, *cursor
;
72 LIST_FOR_EACH_SAFE( item
, cursor
, &folder
->children
)
74 FolderList
*fl
= LIST_ENTRY( item
, FolderList
, entry
);
75 list_remove( &fl
->entry
);
78 msi_free( folder
->Parent
);
79 msi_free( folder
->Directory
);
80 msi_free( folder
->TargetDefault
);
81 msi_free( folder
->SourceLongPath
);
82 msi_free( folder
->SourceShortPath
);
83 msi_free( folder
->ResolvedTarget
);
84 msi_free( folder
->ResolvedSource
);
88 static void free_extension( MSIEXTENSION
*ext
)
90 struct list
*item
, *cursor
;
92 LIST_FOR_EACH_SAFE( item
, cursor
, &ext
->verbs
)
94 MSIVERB
*verb
= LIST_ENTRY( item
, MSIVERB
, entry
);
96 list_remove( &verb
->entry
);
97 msi_free( verb
->Verb
);
98 msi_free( verb
->Command
);
99 msi_free( verb
->Argument
);
103 msi_free( ext
->Extension
);
104 msi_free( ext
->ProgIDText
);
108 static void free_assembly( MSIASSEMBLY
*assembly
)
110 msi_free( assembly
->feature
);
111 msi_free( assembly
->manifest
);
112 msi_free( assembly
->application
);
113 msi_free( assembly
->display_name
);
114 if (assembly
->tempdir
) RemoveDirectoryW( assembly
->tempdir
);
115 msi_free( assembly
->tempdir
);
116 msi_free( assembly
);
119 void msi_free_action_script( MSIPACKAGE
*package
, UINT script
)
122 for (i
= 0; i
< package
->script
->ActionCount
[script
]; i
++)
123 msi_free( package
->script
->Actions
[script
][i
] );
125 msi_free( package
->script
->Actions
[script
] );
126 package
->script
->Actions
[script
] = NULL
;
127 package
->script
->ActionCount
[script
] = 0;
130 static void free_package_structures( MSIPACKAGE
*package
)
132 struct list
*item
, *cursor
;
134 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->features
)
136 MSIFEATURE
*feature
= LIST_ENTRY( item
, MSIFEATURE
, entry
);
137 list_remove( &feature
->entry
);
138 free_feature( feature
);
141 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->folders
)
143 MSIFOLDER
*folder
= LIST_ENTRY( item
, MSIFOLDER
, entry
);
144 list_remove( &folder
->entry
);
145 free_folder( folder
);
148 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->components
)
150 MSICOMPONENT
*comp
= LIST_ENTRY( item
, MSICOMPONENT
, entry
);
152 list_remove( &comp
->entry
);
153 msi_free( comp
->Component
);
154 msi_free( comp
->ComponentId
);
155 msi_free( comp
->Directory
);
156 msi_free( comp
->Condition
);
157 msi_free( comp
->KeyPath
);
158 msi_free( comp
->FullKeypath
);
159 if (comp
->assembly
) free_assembly( comp
->assembly
);
163 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->files
)
165 MSIFILE
*file
= LIST_ENTRY( item
, MSIFILE
, entry
);
167 list_remove( &file
->entry
);
168 msi_free( file
->File
);
169 msi_free( file
->FileName
);
170 msi_free( file
->ShortName
);
171 msi_free( file
->LongName
);
172 msi_free( file
->Version
);
173 msi_free( file
->Language
);
174 msi_free( file
->TargetPath
);
178 /* clean up extension, progid, class and verb structures */
179 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->classes
)
181 MSICLASS
*cls
= LIST_ENTRY( item
, MSICLASS
, entry
);
183 list_remove( &cls
->entry
);
184 msi_free( cls
->clsid
);
185 msi_free( cls
->Context
);
186 msi_free( cls
->Description
);
187 msi_free( cls
->FileTypeMask
);
188 msi_free( cls
->IconPath
);
189 msi_free( cls
->DefInprocHandler
);
190 msi_free( cls
->DefInprocHandler32
);
191 msi_free( cls
->Argument
);
192 msi_free( cls
->ProgIDText
);
196 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->extensions
)
198 MSIEXTENSION
*ext
= LIST_ENTRY( item
, MSIEXTENSION
, entry
);
200 list_remove( &ext
->entry
);
201 free_extension( ext
);
204 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->progids
)
206 MSIPROGID
*progid
= LIST_ENTRY( item
, MSIPROGID
, entry
);
208 list_remove( &progid
->entry
);
209 msi_free( progid
->ProgID
);
210 msi_free( progid
->Description
);
211 msi_free( progid
->IconPath
);
215 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->mimes
)
217 MSIMIME
*mt
= LIST_ENTRY( item
, MSIMIME
, entry
);
219 list_remove( &mt
->entry
);
220 msi_free( mt
->suffix
);
221 msi_free( mt
->clsid
);
222 msi_free( mt
->ContentType
);
226 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->appids
)
228 MSIAPPID
*appid
= LIST_ENTRY( item
, MSIAPPID
, entry
);
230 list_remove( &appid
->entry
);
231 msi_free( appid
->AppID
);
232 msi_free( appid
->RemoteServerName
);
233 msi_free( appid
->LocalServer
);
234 msi_free( appid
->ServiceParameters
);
235 msi_free( appid
->DllSurrogate
);
239 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->sourcelist_info
)
241 MSISOURCELISTINFO
*info
= LIST_ENTRY( item
, MSISOURCELISTINFO
, entry
);
243 list_remove( &info
->entry
);
244 msi_free( info
->value
);
248 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->sourcelist_media
)
250 MSIMEDIADISK
*info
= LIST_ENTRY( item
, MSIMEDIADISK
, entry
);
252 list_remove( &info
->entry
);
253 msi_free( info
->volume_label
);
254 msi_free( info
->disk_prompt
);
263 for (i
= 0; i
< SCRIPT_MAX
; i
++)
264 msi_free_action_script( package
, i
);
266 for (j
= 0; j
< package
->script
->UniqueActionsCount
; j
++)
267 msi_free( package
->script
->UniqueActions
[j
] );
269 msi_free( package
->script
->UniqueActions
);
270 msi_free( package
->script
);
273 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->binaries
)
275 MSIBINARY
*binary
= LIST_ENTRY( item
, MSIBINARY
, entry
);
277 list_remove( &binary
->entry
);
279 FreeLibrary( binary
->module
);
280 if (!DeleteFileW( binary
->tmpfile
))
281 ERR("failed to delete %s (%u)\n", debugstr_w(binary
->tmpfile
), GetLastError());
282 msi_free( binary
->source
);
283 msi_free( binary
->tmpfile
);
287 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->cabinet_streams
)
289 MSICABINETSTREAM
*cab
= LIST_ENTRY( item
, MSICABINETSTREAM
, entry
);
291 list_remove( &cab
->entry
);
292 IStorage_Release( cab
->storage
);
293 msi_free( cab
->stream
);
297 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->patches
)
299 MSIPATCHINFO
*patch
= LIST_ENTRY( item
, MSIPATCHINFO
, entry
);
301 list_remove( &patch
->entry
);
302 if (patch
->delete_on_close
&& !DeleteFileW( patch
->localfile
))
304 ERR("failed to delete %s (%u)\n", debugstr_w(patch
->localfile
), GetLastError());
306 msi_free_patchinfo( patch
);
309 msi_free( package
->BaseURL
);
310 msi_free( package
->PackagePath
);
311 msi_free( package
->ProductCode
);
312 msi_free( package
->ActionFormat
);
313 msi_free( package
->LastAction
);
314 msi_free( package
->langids
);
316 remove_tracked_tempfiles(package
);
318 /* cleanup control event subscriptions */
319 msi_event_cleanup_all_subscriptions( package
);
322 static void MSI_FreePackage( MSIOBJECTHDR
*arg
)
324 MSIPACKAGE
*package
= (MSIPACKAGE
*)arg
;
326 msi_destroy_assembly_caches( package
);
328 if( package
->dialog
)
329 msi_dialog_destroy( package
->dialog
);
331 msiobj_release( &package
->db
->hdr
);
332 free_package_structures(package
);
333 CloseHandle( package
->log_file
);
335 if (package
->delete_on_close
) DeleteFileW( package
->localfile
);
336 msi_free( package
->localfile
);
339 static UINT
create_temp_property_table(MSIPACKAGE
*package
)
341 static const WCHAR query
[] = {
342 'C','R','E','A','T','E',' ','T','A','B','L','E',' ',
343 '`','_','P','r','o','p','e','r','t','y','`',' ','(',' ',
344 '`','_','P','r','o','p','e','r','t','y','`',' ',
345 'C','H','A','R','(','5','6',')',' ','N','O','T',' ','N','U','L','L',' ',
346 'T','E','M','P','O','R','A','R','Y',',',' ',
347 '`','V','a','l','u','e','`',' ','C','H','A','R','(','9','8',')',' ',
348 'N','O','T',' ','N','U','L','L',' ','T','E','M','P','O','R','A','R','Y',
349 ' ','P','R','I','M','A','R','Y',' ','K','E','Y',' ',
350 '`','_','P','r','o','p','e','r','t','y','`',')',' ','H','O','L','D',0};
354 rc
= MSI_DatabaseOpenViewW(package
->db
, query
, &view
);
355 if (rc
!= ERROR_SUCCESS
)
358 rc
= MSI_ViewExecute(view
, 0);
360 msiobj_release(&view
->hdr
);
364 UINT
msi_clone_properties(MSIPACKAGE
*package
)
366 static const WCHAR query_select
[] = {
367 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
368 '`','P','r','o','p','e','r','t','y','`',0};
369 static const WCHAR query_insert
[] = {
370 'I','N','S','E','R','T',' ','I','N','T','O',' ',
371 '`','_','P','r','o','p','e','r','t','y','`',' ',
372 '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
373 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
374 static const WCHAR query_update
[] = {
375 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
376 'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ',
377 'W','H','E','R','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','?',0};
378 MSIQUERY
*view_select
;
381 rc
= MSI_DatabaseOpenViewW( package
->db
, query_select
, &view_select
);
382 if (rc
!= ERROR_SUCCESS
)
385 rc
= MSI_ViewExecute( view_select
, 0 );
386 if (rc
!= ERROR_SUCCESS
)
388 MSI_ViewClose( view_select
);
389 msiobj_release( &view_select
->hdr
);
395 MSIQUERY
*view_insert
, *view_update
;
396 MSIRECORD
*rec_select
;
398 rc
= MSI_ViewFetch( view_select
, &rec_select
);
399 if (rc
!= ERROR_SUCCESS
)
402 rc
= MSI_DatabaseOpenViewW( package
->db
, query_insert
, &view_insert
);
403 if (rc
!= ERROR_SUCCESS
)
405 msiobj_release( &rec_select
->hdr
);
409 rc
= MSI_ViewExecute( view_insert
, rec_select
);
410 MSI_ViewClose( view_insert
);
411 msiobj_release( &view_insert
->hdr
);
412 if (rc
!= ERROR_SUCCESS
)
414 MSIRECORD
*rec_update
;
416 TRACE("insert failed, trying update\n");
418 rc
= MSI_DatabaseOpenViewW( package
->db
, query_update
, &view_update
);
419 if (rc
!= ERROR_SUCCESS
)
421 WARN("open view failed %u\n", rc
);
422 msiobj_release( &rec_select
->hdr
);
426 rec_update
= MSI_CreateRecord( 2 );
427 MSI_RecordCopyField( rec_select
, 1, rec_update
, 2 );
428 MSI_RecordCopyField( rec_select
, 2, rec_update
, 1 );
429 rc
= MSI_ViewExecute( view_update
, rec_update
);
430 if (rc
!= ERROR_SUCCESS
)
431 WARN("update failed %u\n", rc
);
433 MSI_ViewClose( view_update
);
434 msiobj_release( &view_update
->hdr
);
435 msiobj_release( &rec_update
->hdr
);
438 msiobj_release( &rec_select
->hdr
);
441 MSI_ViewClose( view_select
);
442 msiobj_release( &view_select
->hdr
);
449 * Sets the "Installed" property to indicate that
450 * the product is installed for the current user.
452 static UINT
set_installed_prop( MSIPACKAGE
*package
)
457 if (!package
->ProductCode
) return ERROR_FUNCTION_FAILED
;
459 r
= MSIREG_OpenUninstallKey( package
->ProductCode
, package
->platform
, &hkey
, FALSE
);
460 if (r
== ERROR_SUCCESS
)
463 msi_set_property( package
->db
, szInstalled
, szOne
, -1 );
468 static UINT
set_user_sid_prop( MSIPACKAGE
*package
)
472 LPWSTR sid_str
= NULL
, dom
= NULL
;
473 DWORD size
, dom_size
;
475 UINT r
= ERROR_FUNCTION_FAILED
;
478 GetUserNameW( NULL
, &size
);
480 user_name
= msi_alloc( (size
+ 1) * sizeof(WCHAR
) );
482 return ERROR_OUTOFMEMORY
;
484 if (!GetUserNameW( user_name
, &size
))
489 LookupAccountNameW( NULL
, user_name
, NULL
, &size
, NULL
, &dom_size
, &use
);
491 psid
= msi_alloc( size
);
492 dom
= msi_alloc( dom_size
*sizeof (WCHAR
) );
495 r
= ERROR_OUTOFMEMORY
;
499 if (!LookupAccountNameW( NULL
, user_name
, psid
, &size
, dom
, &dom_size
, &use
))
502 if (!ConvertSidToStringSidW( psid
, &sid_str
))
505 r
= msi_set_property( package
->db
, szUserSID
, sid_str
, -1 );
508 LocalFree( sid_str
);
511 msi_free( user_name
);
516 static LPWSTR
get_fusion_filename(MSIPACKAGE
*package
)
521 DWORD index
= 0, size
;
523 WCHAR name
[MAX_PATH
];
524 WCHAR windir
[MAX_PATH
];
526 static const WCHAR fusion
[] = {'f','u','s','i','o','n','.','d','l','l',0};
527 static const WCHAR sub
[] = {
528 'S','o','f','t','w','a','r','e','\\',
529 'M','i','c','r','o','s','o','f','t','\\',
530 'N','E','T',' ','F','r','a','m','e','w','o','r','k',' ','S','e','t','u','p','\\',
533 static const WCHAR subdir
[] = {
534 'M','i','c','r','o','s','o','f','t','.','N','E','T','\\',
535 'F','r','a','m','e','w','o','r','k','\\',0
538 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, sub
, 0, KEY_ENUMERATE_SUB_KEYS
, &netsetup
);
539 if (res
!= ERROR_SUCCESS
)
542 GetWindowsDirectoryW(windir
, MAX_PATH
);
546 while (RegEnumKeyExW(netsetup
, index
, name
, &size
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
550 /* verify existence of fusion.dll .Net 3.0 does not install a new one */
551 if (strcmpW( ver
, name
) < 0)
554 size
= lstrlenW(windir
) + lstrlenW(subdir
) + lstrlenW(name
) +lstrlenW(fusion
) + 3;
555 check
= msi_alloc(size
* sizeof(WCHAR
));
563 lstrcpyW(check
, windir
);
564 lstrcatW(check
, szBackSlash
);
565 lstrcatW(check
, subdir
);
566 lstrcatW(check
, name
);
567 lstrcatW(check
, szBackSlash
);
568 lstrcatW(check
, fusion
);
570 if(GetFileAttributesW(check
) != INVALID_FILE_ATTRIBUTES
)
581 RegCloseKey(netsetup
);
585 typedef struct tagLANGANDCODEPAGE
591 static void set_msi_assembly_prop(MSIPACKAGE
*package
)
595 LPVOID version
= NULL
;
597 LPWSTR fusion
, verstr
;
598 LANGANDCODEPAGE
*translate
;
600 static const WCHAR netasm
[] = {
601 'M','s','i','N','e','t','A','s','s','e','m','b','l','y','S','u','p','p','o','r','t',0
603 static const WCHAR translation
[] = {
604 '\\','V','a','r','F','i','l','e','I','n','f','o',
605 '\\','T','r','a','n','s','l','a','t','i','o','n',0
607 static const WCHAR verfmt
[] = {
608 '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
609 '\\','%','0','4','x','%','0','4','x',
610 '\\','P','r','o','d','u','c','t','V','e','r','s','i','o','n',0
613 fusion
= get_fusion_filename(package
);
617 size
= GetFileVersionInfoSizeW(fusion
, &handle
);
621 version
= msi_alloc(size
);
625 if (!GetFileVersionInfoW(fusion
, handle
, size
, version
))
628 if (!VerQueryValueW(version
, translation
, (LPVOID
*)&translate
, &val_len
))
631 sprintfW(buf
, verfmt
, translate
[0].wLanguage
, translate
[0].wCodePage
);
633 if (!VerQueryValueW(version
, buf
, (LPVOID
*)&verstr
, &val_len
))
636 if (!val_len
|| !verstr
)
639 msi_set_property( package
->db
, netasm
, verstr
, -1 );
646 static VOID
set_installer_properties(MSIPACKAGE
*package
)
649 OSVERSIONINFOEXW OSVersion
;
652 WCHAR pth
[MAX_PATH
], verstr
[11], bufstr
[22];
655 LPWSTR username
, companyname
;
656 SYSTEM_INFO sys_info
;
657 SYSTEMTIME systemtime
;
660 static const WCHAR szCommonFilesFolder
[] = {'C','o','m','m','o','n','F','i','l','e','s','F','o','l','d','e','r',0};
661 static const WCHAR szProgramFilesFolder
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','F','o','l','d','e','r',0};
662 static const WCHAR szCommonAppDataFolder
[] = {'C','o','m','m','o','n','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
663 static const WCHAR szFavoritesFolder
[] = {'F','a','v','o','r','i','t','e','s','F','o','l','d','e','r',0};
664 static const WCHAR szFontsFolder
[] = {'F','o','n','t','s','F','o','l','d','e','r',0};
665 static const WCHAR szSendToFolder
[] = {'S','e','n','d','T','o','F','o','l','d','e','r',0};
666 static const WCHAR szStartMenuFolder
[] = {'S','t','a','r','t','M','e','n','u','F','o','l','d','e','r',0};
667 static const WCHAR szStartupFolder
[] = {'S','t','a','r','t','u','p','F','o','l','d','e','r',0};
668 static const WCHAR szTemplateFolder
[] = {'T','e','m','p','l','a','t','e','F','o','l','d','e','r',0};
669 static const WCHAR szDesktopFolder
[] = {'D','e','s','k','t','o','p','F','o','l','d','e','r',0};
670 static const WCHAR szProgramMenuFolder
[] = {'P','r','o','g','r','a','m','M','e','n','u','F','o','l','d','e','r',0};
671 static const WCHAR szAdminToolsFolder
[] = {'A','d','m','i','n','T','o','o','l','s','F','o','l','d','e','r',0};
672 static const WCHAR szSystemFolder
[] = {'S','y','s','t','e','m','F','o','l','d','e','r',0};
673 static const WCHAR szSystem16Folder
[] = {'S','y','s','t','e','m','1','6','F','o','l','d','e','r',0};
674 static const WCHAR szLocalAppDataFolder
[] = {'L','o','c','a','l','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
675 static const WCHAR szMyPicturesFolder
[] = {'M','y','P','i','c','t','u','r','e','s','F','o','l','d','e','r',0};
676 static const WCHAR szPersonalFolder
[] = {'P','e','r','s','o','n','a','l','F','o','l','d','e','r',0};
677 static const WCHAR szWindowsVolume
[] = {'W','i','n','d','o','w','s','V','o','l','u','m','e',0};
678 static const WCHAR szPrivileged
[] = {'P','r','i','v','i','l','e','g','e','d',0};
679 static const WCHAR szVersion9x
[] = {'V','e','r','s','i','o','n','9','X',0};
680 static const WCHAR szVersionNT
[] = {'V','e','r','s','i','o','n','N','T',0};
681 static const WCHAR szMsiNTProductType
[] = {'M','s','i','N','T','P','r','o','d','u','c','t','T','y','p','e',0};
682 static const WCHAR szFormat
[] = {'%','u',0};
683 static const WCHAR szFormat2
[] = {'%','u','.','%','u',0};
684 static const WCHAR szWindowsBuild
[] = {'W','i','n','d','o','w','s','B','u','i','l','d',0};
685 static const WCHAR szServicePackLevel
[] = {'S','e','r','v','i','c','e','P','a','c','k','L','e','v','e','l',0};
686 static const WCHAR szVersionMsi
[] = { 'V','e','r','s','i','o','n','M','s','i',0 };
687 static const WCHAR szVersionDatabase
[] = { 'V','e','r','s','i','o','n','D','a','t','a','b','a','s','e',0 };
688 static const WCHAR szPhysicalMemory
[] = { 'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0 };
689 static const WCHAR szScreenX
[] = {'S','c','r','e','e','n','X',0};
690 static const WCHAR szScreenY
[] = {'S','c','r','e','e','n','Y',0};
691 static const WCHAR szColorBits
[] = {'C','o','l','o','r','B','i','t','s',0};
692 static const WCHAR szIntFormat
[] = {'%','d',0};
693 static const WCHAR szMsiAMD64
[] = { 'M','s','i','A','M','D','6','4',0 };
694 static const WCHAR szMsix64
[] = { 'M','s','i','x','6','4',0 };
695 static const WCHAR szSystem64Folder
[] = { 'S','y','s','t','e','m','6','4','F','o','l','d','e','r',0 };
696 static const WCHAR szCommonFiles64Folder
[] = { 'C','o','m','m','o','n','F','i','l','e','s','6','4','F','o','l','d','e','r',0 };
697 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 };
698 static const WCHAR szVersionNT64
[] = { 'V','e','r','s','i','o','n','N','T','6','4',0 };
699 static const WCHAR szUserInfo
[] = {
700 'S','O','F','T','W','A','R','E','\\',
701 'M','i','c','r','o','s','o','f','t','\\',
702 'M','S',' ','S','e','t','u','p',' ','(','A','C','M','E',')','\\',
703 'U','s','e','r',' ','I','n','f','o',0
705 static const WCHAR szDefName
[] = { 'D','e','f','N','a','m','e',0 };
706 static const WCHAR szDefCompany
[] = { 'D','e','f','C','o','m','p','a','n','y',0 };
707 static const WCHAR szCurrentVersion
[] = {
708 'S','O','F','T','W','A','R','E','\\',
709 'M','i','c','r','o','s','o','f','t','\\',
710 'W','i','n','d','o','w','s',' ','N','T','\\',
711 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0
713 static const WCHAR szRegisteredUser
[] = {'R','e','g','i','s','t','e','r','e','d','O','w','n','e','r',0};
714 static const WCHAR szRegisteredOrganization
[] = {
715 'R','e','g','i','s','t','e','r','e','d','O','r','g','a','n','i','z','a','t','i','o','n',0
717 static const WCHAR szUSERNAME
[] = {'U','S','E','R','N','A','M','E',0};
718 static const WCHAR szCOMPANYNAME
[] = {'C','O','M','P','A','N','Y','N','A','M','E',0};
719 static const WCHAR szDate
[] = {'D','a','t','e',0};
720 static const WCHAR szTime
[] = {'T','i','m','e',0};
721 static const WCHAR szUserLanguageID
[] = {'U','s','e','r','L','a','n','g','u','a','g','e','I','D',0};
722 static const WCHAR szSystemLangID
[] = {'S','y','s','t','e','m','L','a','n','g','u','a','g','e','I','D',0};
723 static const WCHAR szProductState
[] = {'P','r','o','d','u','c','t','S','t','a','t','e',0};
724 static const WCHAR szLogonUser
[] = {'L','o','g','o','n','U','s','e','r',0};
725 static const WCHAR szNetHoodFolder
[] = {'N','e','t','H','o','o','d','F','o','l','d','e','r',0};
726 static const WCHAR szPrintHoodFolder
[] = {'P','r','i','n','t','H','o','o','d','F','o','l','d','e','r',0};
727 static const WCHAR szRecentFolder
[] = {'R','e','c','e','n','t','F','o','l','d','e','r',0};
728 static const WCHAR szComputerName
[] = {'C','o','m','p','u','t','e','r','N','a','m','e',0};
729 static const WCHAR szBrowseProperty
[] = {'_','B','r','o','w','s','e','P','r','o','p','e','r','t','y',0};
730 static const WCHAR szInstallDir
[] = {'I','N','S','T','A','L','L','D','I','R',0};
733 * Other things that probably should be set:
735 * VirtualMemory ShellAdvSupport DefaultUIFont PackagecodeChanging
736 * CaptionHeight BorderTop BorderSide TextHeight RedirectedDllSupport
739 SHGetFolderPathW(NULL
, CSIDL_COMMON_APPDATA
, NULL
, 0, pth
);
740 strcatW(pth
, szBackSlash
);
741 msi_set_property( package
->db
, szCommonAppDataFolder
, pth
, -1 );
743 SHGetFolderPathW(NULL
, CSIDL_FAVORITES
, NULL
, 0, pth
);
744 strcatW(pth
, szBackSlash
);
745 msi_set_property( package
->db
, szFavoritesFolder
, pth
, -1 );
747 SHGetFolderPathW(NULL
, CSIDL_FONTS
, NULL
, 0, pth
);
748 strcatW(pth
, szBackSlash
);
749 msi_set_property( package
->db
, szFontsFolder
, pth
, -1 );
751 SHGetFolderPathW(NULL
, CSIDL_SENDTO
, NULL
, 0, pth
);
752 strcatW(pth
, szBackSlash
);
753 msi_set_property( package
->db
, szSendToFolder
, pth
, -1 );
755 SHGetFolderPathW(NULL
, CSIDL_STARTMENU
, NULL
, 0, pth
);
756 strcatW(pth
, szBackSlash
);
757 msi_set_property( package
->db
, szStartMenuFolder
, pth
, -1 );
759 SHGetFolderPathW(NULL
, CSIDL_STARTUP
, NULL
, 0, pth
);
760 strcatW(pth
, szBackSlash
);
761 msi_set_property( package
->db
, szStartupFolder
, pth
, -1 );
763 SHGetFolderPathW(NULL
, CSIDL_TEMPLATES
, NULL
, 0, pth
);
764 strcatW(pth
, szBackSlash
);
765 msi_set_property( package
->db
, szTemplateFolder
, pth
, -1 );
767 SHGetFolderPathW(NULL
, CSIDL_DESKTOP
, NULL
, 0, pth
);
768 strcatW(pth
, szBackSlash
);
769 msi_set_property( package
->db
, szDesktopFolder
, pth
, -1 );
771 /* FIXME: set to AllUsers profile path if ALLUSERS is set */
772 SHGetFolderPathW(NULL
, CSIDL_PROGRAMS
, NULL
, 0, pth
);
773 strcatW(pth
, szBackSlash
);
774 msi_set_property( package
->db
, szProgramMenuFolder
, pth
, -1 );
776 SHGetFolderPathW(NULL
, CSIDL_ADMINTOOLS
, NULL
, 0, pth
);
777 strcatW(pth
, szBackSlash
);
778 msi_set_property( package
->db
, szAdminToolsFolder
, pth
, -1 );
780 SHGetFolderPathW(NULL
, CSIDL_APPDATA
, NULL
, 0, pth
);
781 strcatW(pth
, szBackSlash
);
782 msi_set_property( package
->db
, szAppDataFolder
, pth
, -1 );
784 SHGetFolderPathW(NULL
, CSIDL_SYSTEM
, NULL
, 0, pth
);
785 strcatW(pth
, szBackSlash
);
786 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
787 msi_set_property( package
->db
, szSystem16Folder
, pth
, -1 );
789 SHGetFolderPathW(NULL
, CSIDL_LOCAL_APPDATA
, NULL
, 0, pth
);
790 strcatW(pth
, szBackSlash
);
791 msi_set_property( package
->db
, szLocalAppDataFolder
, pth
, -1 );
793 SHGetFolderPathW(NULL
, CSIDL_MYPICTURES
, NULL
, 0, pth
);
794 strcatW(pth
, szBackSlash
);
795 msi_set_property( package
->db
, szMyPicturesFolder
, pth
, -1 );
797 SHGetFolderPathW(NULL
, CSIDL_PERSONAL
, NULL
, 0, pth
);
798 strcatW(pth
, szBackSlash
);
799 msi_set_property( package
->db
, szPersonalFolder
, pth
, -1 );
801 SHGetFolderPathW(NULL
, CSIDL_WINDOWS
, NULL
, 0, pth
);
802 strcatW(pth
, szBackSlash
);
803 msi_set_property( package
->db
, szWindowsFolder
, pth
, -1 );
805 SHGetFolderPathW(NULL
, CSIDL_PRINTHOOD
, NULL
, 0, pth
);
806 strcatW(pth
, szBackSlash
);
807 msi_set_property( package
->db
, szPrintHoodFolder
, pth
, -1 );
809 SHGetFolderPathW(NULL
, CSIDL_NETHOOD
, NULL
, 0, pth
);
810 strcatW(pth
, szBackSlash
);
811 msi_set_property( package
->db
, szNetHoodFolder
, pth
, -1 );
813 SHGetFolderPathW(NULL
, CSIDL_RECENT
, NULL
, 0, pth
);
814 strcatW(pth
, szBackSlash
);
815 msi_set_property( package
->db
, szRecentFolder
, pth
, -1 );
817 /* Physical Memory is specified in MB. Using total amount. */
818 msex
.dwLength
= sizeof(msex
);
819 GlobalMemoryStatusEx( &msex
);
820 len
= sprintfW( bufstr
, szIntFormat
, (int)(msex
.ullTotalPhys
/ 1024 / 1024) );
821 msi_set_property( package
->db
, szPhysicalMemory
, bufstr
, len
);
823 SHGetFolderPathW(NULL
, CSIDL_WINDOWS
, NULL
, 0, pth
);
824 ptr
= strchrW(pth
,'\\');
825 if (ptr
) *(ptr
+ 1) = 0;
826 msi_set_property( package
->db
, szWindowsVolume
, pth
, -1 );
828 len
= GetTempPathW(MAX_PATH
, pth
);
829 msi_set_property( package
->db
, szTempFolder
, pth
, len
);
831 /* in a wine environment the user is always admin and privileged */
832 msi_set_property( package
->db
, szAdminUser
, szOne
, -1 );
833 msi_set_property( package
->db
, szPrivileged
, szOne
, -1 );
835 /* set the os things */
836 OSVersion
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
837 GetVersionExW((OSVERSIONINFOW
*)&OSVersion
);
838 verval
= OSVersion
.dwMinorVersion
+ OSVersion
.dwMajorVersion
* 100;
839 len
= sprintfW( verstr
, szFormat
, verval
);
840 switch (OSVersion
.dwPlatformId
)
842 case VER_PLATFORM_WIN32_WINDOWS
:
843 msi_set_property( package
->db
, szVersion9x
, verstr
, len
);
845 case VER_PLATFORM_WIN32_NT
:
846 msi_set_property( package
->db
, szVersionNT
, verstr
, len
);
847 len
= sprintfW( bufstr
, szFormat
,OSVersion
.wProductType
);
848 msi_set_property( package
->db
, szMsiNTProductType
, bufstr
, len
);
851 len
= sprintfW( bufstr
, szFormat
, OSVersion
.dwBuildNumber
);
852 msi_set_property( package
->db
, szWindowsBuild
, bufstr
, len
);
853 len
= sprintfW( bufstr
, szFormat
, OSVersion
.wServicePackMajor
);
854 msi_set_property( package
->db
, szServicePackLevel
, bufstr
, len
);
856 len
= sprintfW( bufstr
, szFormat2
, MSI_MAJORVERSION
, MSI_MINORVERSION
);
857 msi_set_property( package
->db
, szVersionMsi
, bufstr
, len
);
858 len
= sprintfW( bufstr
, szFormat
, MSI_MAJORVERSION
* 100 );
859 msi_set_property( package
->db
, szVersionDatabase
, bufstr
, len
);
861 GetNativeSystemInfo( &sys_info
);
862 len
= sprintfW( bufstr
, szIntFormat
, sys_info
.wProcessorLevel
);
863 msi_set_property( package
->db
, szIntel
, bufstr
, len
);
864 if (sys_info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
866 GetSystemDirectoryW( pth
, MAX_PATH
);
867 PathAddBackslashW( pth
);
868 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
870 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, pth
);
871 PathAddBackslashW( pth
);
872 msi_set_property( package
->db
, szProgramFilesFolder
, pth
, -1 );
874 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, pth
);
875 PathAddBackslashW( pth
);
876 msi_set_property( package
->db
, szCommonFilesFolder
, pth
, -1 );
878 else if (sys_info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
)
880 msi_set_property( package
->db
, szMsiAMD64
, bufstr
, -1 );
881 msi_set_property( package
->db
, szMsix64
, bufstr
, -1 );
882 msi_set_property( package
->db
, szVersionNT64
, verstr
, -1 );
884 GetSystemDirectoryW( pth
, MAX_PATH
);
885 PathAddBackslashW( pth
);
886 msi_set_property( package
->db
, szSystem64Folder
, pth
, -1 );
888 GetSystemWow64DirectoryW( pth
, MAX_PATH
);
889 PathAddBackslashW( pth
);
890 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
892 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, pth
);
893 PathAddBackslashW( pth
);
894 msi_set_property( package
->db
, szProgramFiles64Folder
, pth
, -1 );
896 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, pth
);
897 PathAddBackslashW( pth
);
898 msi_set_property( package
->db
, szProgramFilesFolder
, pth
, -1 );
900 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, pth
);
901 PathAddBackslashW( pth
);
902 msi_set_property( package
->db
, szCommonFiles64Folder
, pth
, -1 );
904 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, pth
);
905 PathAddBackslashW( pth
);
906 msi_set_property( package
->db
, szCommonFilesFolder
, pth
, -1 );
909 /* Screen properties. */
911 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, HORZRES
) );
912 msi_set_property( package
->db
, szScreenX
, bufstr
, len
);
913 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, VERTRES
) );
914 msi_set_property( package
->db
, szScreenY
, bufstr
, len
);
915 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, BITSPIXEL
) );
916 msi_set_property( package
->db
, szColorBits
, bufstr
, len
);
919 /* USERNAME and COMPANYNAME */
920 username
= msi_dup_property( package
->db
, szUSERNAME
);
921 companyname
= msi_dup_property( package
->db
, szCOMPANYNAME
);
923 if ((!username
|| !companyname
) &&
924 RegOpenKeyW( HKEY_CURRENT_USER
, szUserInfo
, &hkey
) == ERROR_SUCCESS
)
927 (username
= msi_reg_get_val_str( hkey
, szDefName
)))
928 msi_set_property( package
->db
, szUSERNAME
, username
, -1 );
930 (companyname
= msi_reg_get_val_str( hkey
, szDefCompany
)))
931 msi_set_property( package
->db
, szCOMPANYNAME
, companyname
, -1 );
934 if ((!username
|| !companyname
) &&
935 RegOpenKeyW( HKEY_LOCAL_MACHINE
, szCurrentVersion
, &hkey
) == ERROR_SUCCESS
)
938 (username
= msi_reg_get_val_str( hkey
, szRegisteredUser
)))
939 msi_set_property( package
->db
, szUSERNAME
, username
, -1 );
941 (companyname
= msi_reg_get_val_str( hkey
, szRegisteredOrganization
)))
942 msi_set_property( package
->db
, szCOMPANYNAME
, companyname
, -1 );
945 msi_free( username
);
946 msi_free( companyname
);
948 if ( set_user_sid_prop( package
) != ERROR_SUCCESS
)
949 ERR("Failed to set the UserSID property\n");
951 /* Date and time properties */
952 GetSystemTime( &systemtime
);
953 if (GetDateFormatW( LOCALE_USER_DEFAULT
, DATE_SHORTDATE
, &systemtime
,
954 NULL
, bufstr
, sizeof(bufstr
)/sizeof(bufstr
[0]) ))
955 msi_set_property( package
->db
, szDate
, bufstr
, -1 );
957 ERR("Couldn't set Date property: GetDateFormat failed with error %d\n", GetLastError());
959 if (GetTimeFormatW( LOCALE_USER_DEFAULT
,
960 TIME_FORCE24HOURFORMAT
| TIME_NOTIMEMARKER
,
961 &systemtime
, NULL
, bufstr
,
962 sizeof(bufstr
)/sizeof(bufstr
[0]) ))
963 msi_set_property( package
->db
, szTime
, bufstr
, -1 );
965 ERR("Couldn't set Time property: GetTimeFormat failed with error %d\n", GetLastError());
967 set_msi_assembly_prop( package
);
969 langid
= GetUserDefaultLangID();
970 len
= sprintfW( bufstr
, szIntFormat
, langid
);
971 msi_set_property( package
->db
, szUserLanguageID
, bufstr
, len
);
973 langid
= GetSystemDefaultLangID();
974 len
= sprintfW( bufstr
, szIntFormat
, langid
);
975 msi_set_property( package
->db
, szSystemLangID
, bufstr
, len
);
977 len
= sprintfW( bufstr
, szIntFormat
, MsiQueryProductStateW(package
->ProductCode
) );
978 msi_set_property( package
->db
, szProductState
, bufstr
, len
);
981 if (!GetUserNameW( NULL
, &len
) && GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
984 if ((username
= msi_alloc( len
* sizeof(WCHAR
) )))
986 if (GetUserNameW( username
, &len
))
987 msi_set_property( package
->db
, szLogonUser
, username
, len
- 1 );
988 msi_free( username
);
992 if (!GetComputerNameW( NULL
, &len
) && GetLastError() == ERROR_BUFFER_OVERFLOW
)
995 if ((computername
= msi_alloc( len
* sizeof(WCHAR
) )))
997 if (GetComputerNameW( computername
, &len
))
998 msi_set_property( package
->db
, szComputerName
, computername
, len
);
999 msi_free( computername
);
1002 msi_set_property( package
->db
, szBrowseProperty
, szInstallDir
, -1 );
1005 static UINT
msi_load_summary_properties( MSIPACKAGE
*package
)
1009 MSIHANDLE hdb
= alloc_msihandle( &package
->db
->hdr
);
1012 LPWSTR package_code
;
1013 static const WCHAR szPackageCode
[] = {
1014 'P','a','c','k','a','g','e','C','o','d','e',0};
1017 ERR("Unable to allocate handle\n");
1018 return ERROR_OUTOFMEMORY
;
1021 rc
= MsiGetSummaryInformationW( hdb
, NULL
, 0, &suminfo
);
1022 MsiCloseHandle(hdb
);
1023 if (rc
!= ERROR_SUCCESS
)
1025 ERR("Unable to open Summary Information\n");
1029 rc
= MsiSummaryInfoGetPropertyW( suminfo
, PID_PAGECOUNT
, NULL
,
1030 &count
, NULL
, NULL
, NULL
);
1031 if (rc
!= ERROR_SUCCESS
)
1033 WARN("Unable to query page count: %d\n", rc
);
1037 /* load package code property */
1039 rc
= MsiSummaryInfoGetPropertyW( suminfo
, PID_REVNUMBER
, NULL
,
1040 NULL
, NULL
, NULL
, &len
);
1041 if (rc
!= ERROR_MORE_DATA
)
1043 WARN("Unable to query revision number: %d\n", rc
);
1044 rc
= ERROR_FUNCTION_FAILED
;
1049 package_code
= msi_alloc( len
* sizeof(WCHAR
) );
1050 rc
= MsiSummaryInfoGetPropertyW( suminfo
, PID_REVNUMBER
, NULL
,
1051 NULL
, NULL
, package_code
, &len
);
1052 if (rc
!= ERROR_SUCCESS
)
1054 WARN("Unable to query rev number: %d\n", rc
);
1055 msi_free( package_code
);
1059 msi_set_property( package
->db
, szPackageCode
, package_code
, len
);
1060 msi_free( package_code
);
1062 /* load package attributes */
1064 MsiSummaryInfoGetPropertyW( suminfo
, PID_WORDCOUNT
, NULL
,
1065 &count
, NULL
, NULL
, NULL
);
1066 package
->WordCount
= count
;
1069 MsiCloseHandle(suminfo
);
1073 static MSIPACKAGE
*msi_alloc_package( void )
1075 MSIPACKAGE
*package
;
1077 package
= alloc_msiobject( MSIHANDLETYPE_PACKAGE
, sizeof (MSIPACKAGE
),
1081 list_init( &package
->components
);
1082 list_init( &package
->features
);
1083 list_init( &package
->files
);
1084 list_init( &package
->filepatches
);
1085 list_init( &package
->tempfiles
);
1086 list_init( &package
->folders
);
1087 list_init( &package
->subscriptions
);
1088 list_init( &package
->appids
);
1089 list_init( &package
->classes
);
1090 list_init( &package
->mimes
);
1091 list_init( &package
->extensions
);
1092 list_init( &package
->progids
);
1093 list_init( &package
->RunningActions
);
1094 list_init( &package
->sourcelist_info
);
1095 list_init( &package
->sourcelist_media
);
1096 list_init( &package
->patches
);
1097 list_init( &package
->binaries
);
1098 list_init( &package
->cabinet_streams
);
1104 static UINT
msi_load_admin_properties(MSIPACKAGE
*package
)
1109 static const WCHAR stmname
[] = {'A','d','m','i','n','P','r','o','p','e','r','t','i','e','s',0};
1111 r
= read_stream_data(package
->db
->storage
, stmname
, FALSE
, &data
, &sz
);
1112 if (r
!= ERROR_SUCCESS
)
1115 r
= msi_parse_command_line(package
, (WCHAR
*)data
, TRUE
);
1121 void msi_adjust_privilege_properties( MSIPACKAGE
*package
)
1123 /* FIXME: this should depend on the user's privileges */
1124 if (msi_get_property_int( package
->db
, szAllUsers
, 0 ) == 2)
1126 TRACE("resetting ALLUSERS property from 2 to 1\n");
1127 msi_set_property( package
->db
, szAllUsers
, szOne
, -1 );
1129 msi_set_property( package
->db
, szAdminUser
, szOne
, -1 );
1132 MSIPACKAGE
*MSI_CreatePackage( MSIDATABASE
*db
, LPCWSTR base_url
)
1134 static const WCHAR fmtW
[] = {'%','u',0};
1135 MSIPACKAGE
*package
;
1142 package
= msi_alloc_package();
1145 msiobj_addref( &db
->hdr
);
1148 package
->WordCount
= 0;
1149 package
->PackagePath
= strdupW( db
->path
);
1150 package
->BaseURL
= strdupW( base_url
);
1152 create_temp_property_table( package
);
1153 msi_clone_properties( package
);
1154 msi_adjust_privilege_properties( package
);
1156 package
->ProductCode
= msi_dup_property( package
->db
, szProductCode
);
1157 package
->script
= msi_alloc_zero( sizeof(MSISCRIPT
) );
1159 set_installer_properties( package
);
1161 package
->ui_level
= gUILevel
;
1162 len
= sprintfW( uilevel
, fmtW
, gUILevel
& INSTALLUILEVEL_MASK
);
1163 msi_set_property( package
->db
, szUILevel
, uilevel
, len
);
1165 r
= msi_load_summary_properties( package
);
1166 if (r
!= ERROR_SUCCESS
)
1168 msiobj_release( &package
->hdr
);
1172 if (package
->WordCount
& msidbSumInfoSourceTypeAdminImage
)
1173 msi_load_admin_properties( package
);
1175 package
->log_file
= INVALID_HANDLE_VALUE
;
1180 UINT
msi_download_file( LPCWSTR szUrl
, LPWSTR filename
)
1182 LPINTERNET_CACHE_ENTRY_INFOW cache_entry
;
1186 /* call will always fail, because size is 0,
1187 * but will return ERROR_FILE_NOT_FOUND first
1188 * if the file doesn't exist
1190 GetUrlCacheEntryInfoW( szUrl
, NULL
, &size
);
1191 if ( GetLastError() != ERROR_FILE_NOT_FOUND
)
1193 cache_entry
= msi_alloc( size
);
1194 if ( !GetUrlCacheEntryInfoW( szUrl
, cache_entry
, &size
) )
1196 UINT error
= GetLastError();
1197 msi_free( cache_entry
);
1201 lstrcpyW( filename
, cache_entry
->lpszLocalFileName
);
1202 msi_free( cache_entry
);
1203 return ERROR_SUCCESS
;
1206 hr
= URLDownloadToCacheFileW( NULL
, szUrl
, filename
, MAX_PATH
, 0, NULL
);
1209 WARN("failed to download %s to cache file\n", debugstr_w(szUrl
));
1210 return ERROR_FUNCTION_FAILED
;
1213 return ERROR_SUCCESS
;
1216 UINT
msi_create_empty_local_file( LPWSTR path
, LPCWSTR suffix
)
1218 static const WCHAR szInstaller
[] = {
1219 '\\','I','n','s','t','a','l','l','e','r','\\',0};
1220 static const WCHAR fmt
[] = {'%','x',0};
1221 DWORD time
, len
, i
, offset
;
1224 time
= GetTickCount();
1225 GetWindowsDirectoryW( path
, MAX_PATH
);
1226 strcatW( path
, szInstaller
);
1227 CreateDirectoryW( path
, NULL
);
1229 len
= strlenW(path
);
1230 for (i
= 0; i
< 0x10000; i
++)
1232 offset
= snprintfW( path
+ len
, MAX_PATH
- len
, fmt
, (time
+ i
) & 0xffff );
1233 memcpy( path
+ len
+ offset
, suffix
, (strlenW( suffix
) + 1) * sizeof(WCHAR
) );
1234 handle
= CreateFileW( path
, GENERIC_WRITE
, 0, NULL
,
1235 CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, 0 );
1236 if (handle
!= INVALID_HANDLE_VALUE
)
1238 CloseHandle(handle
);
1241 if (GetLastError() != ERROR_FILE_EXISTS
&&
1242 GetLastError() != ERROR_SHARING_VIOLATION
)
1243 return ERROR_FUNCTION_FAILED
;
1246 return ERROR_SUCCESS
;
1249 static enum platform
parse_platform( WCHAR
*str
)
1251 if (!str
[0] || !strcmpW( str
, szIntel
)) return PLATFORM_INTEL
;
1252 else if (!strcmpW( str
, szIntel64
)) return PLATFORM_INTEL64
;
1253 else if (!strcmpW( str
, szX64
) || !strcmpW( str
, szAMD64
)) return PLATFORM_X64
;
1254 else if (!strcmpW( str
, szARM
)) return PLATFORM_ARM
;
1255 return PLATFORM_UNKNOWN
;
1258 static UINT
msi_parse_summary( MSISUMMARYINFO
*si
, MSIPACKAGE
*package
)
1260 WCHAR
*template, *p
, *q
, *platform
;
1263 package
->version
= msi_suminfo_get_int32( si
, PID_PAGECOUNT
);
1264 TRACE("version: %d\n", package
->version
);
1266 template = msi_suminfo_dup_string( si
, PID_TEMPLATE
);
1268 return ERROR_SUCCESS
; /* native accepts missing template property */
1270 TRACE("template: %s\n", debugstr_w(template));
1272 p
= strchrW( template, ';' );
1275 WARN("invalid template string %s\n", debugstr_w(template));
1276 msi_free( template );
1277 return ERROR_PATCH_PACKAGE_INVALID
;
1280 platform
= template;
1281 if ((q
= strchrW( platform
, ',' ))) *q
= 0;
1282 package
->platform
= parse_platform( platform
);
1283 while (package
->platform
== PLATFORM_UNKNOWN
&& q
)
1286 if ((q
= strchrW( platform
, ',' ))) *q
= 0;
1287 package
->platform
= parse_platform( platform
);
1289 if (package
->platform
== PLATFORM_UNKNOWN
)
1291 WARN("unknown platform %s\n", debugstr_w(template));
1292 msi_free( template );
1293 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1298 msi_free( template );
1299 return ERROR_SUCCESS
;
1302 for (q
= p
; (q
= strchrW( q
, ',' )); q
++) count
++;
1304 package
->langids
= msi_alloc( count
* sizeof(LANGID
) );
1305 if (!package
->langids
)
1307 msi_free( template );
1308 return ERROR_OUTOFMEMORY
;
1314 q
= strchrW( p
, ',' );
1316 package
->langids
[i
] = atoiW( p
);
1321 package
->num_langids
= i
+ 1;
1323 msi_free( template );
1324 return ERROR_SUCCESS
;
1327 static UINT
validate_package( MSIPACKAGE
*package
)
1331 if (package
->platform
== PLATFORM_INTEL64
)
1332 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1334 if (package
->platform
== PLATFORM_ARM
)
1335 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1337 if (package
->platform
== PLATFORM_X64
)
1339 if (!is_64bit
&& !is_wow64
)
1340 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1341 if (package
->version
< 200)
1342 return ERROR_INSTALL_PACKAGE_INVALID
;
1344 if (!package
->num_langids
)
1346 return ERROR_SUCCESS
;
1348 for (i
= 0; i
< package
->num_langids
; i
++)
1350 LANGID langid
= package
->langids
[i
];
1352 if (PRIMARYLANGID( langid
) == LANG_NEUTRAL
)
1354 langid
= MAKELANGID( PRIMARYLANGID( GetSystemDefaultLangID() ), SUBLANGID( langid
) );
1356 if (SUBLANGID( langid
) == SUBLANG_NEUTRAL
)
1358 langid
= MAKELANGID( PRIMARYLANGID( langid
), SUBLANGID( GetSystemDefaultLangID() ) );
1360 if (IsValidLocale( langid
, LCID_INSTALLED
))
1361 return ERROR_SUCCESS
;
1363 return ERROR_INSTALL_LANGUAGE_UNSUPPORTED
;
1366 int msi_track_tempfile( MSIPACKAGE
*package
, const WCHAR
*path
)
1370 TRACE("%s\n", debugstr_w(path
));
1372 LIST_FOR_EACH_ENTRY( temp
, &package
->tempfiles
, MSITEMPFILE
, entry
)
1374 if (!strcmpW( path
, temp
->Path
)) return 0;
1376 if (!(temp
= msi_alloc_zero( sizeof (MSITEMPFILE
) ))) return -1;
1377 list_add_head( &package
->tempfiles
, &temp
->entry
);
1378 temp
->Path
= strdupW( path
);
1382 static WCHAR
*get_product_code( MSIDATABASE
*db
)
1384 static const WCHAR query
[] = {
1385 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
1386 'F','R','O','M',' ','`','P','r','o','p','e','r','t','y','`',' ',
1387 'W','H','E','R','E',' ','`','P','r','o','p','e','r','t','y','`','=',
1388 '\'','P','r','o','d','u','c','t','C','o','d','e','\'',0};
1393 if (MSI_DatabaseOpenViewW( db
, query
, &view
) != ERROR_SUCCESS
)
1397 if (MSI_ViewExecute( view
, 0 ) != ERROR_SUCCESS
)
1399 MSI_ViewClose( view
);
1400 msiobj_release( &view
->hdr
);
1403 if (MSI_ViewFetch( view
, &rec
) == ERROR_SUCCESS
)
1405 ret
= strdupW( MSI_RecordGetString( rec
, 1 ) );
1406 msiobj_release( &rec
->hdr
);
1408 MSI_ViewClose( view
);
1409 msiobj_release( &view
->hdr
);
1413 static UINT
get_registered_local_package( const WCHAR
*product
, const WCHAR
*package
, WCHAR
*localfile
)
1415 MSIINSTALLCONTEXT context
;
1416 HKEY product_key
, props_key
;
1417 WCHAR
*registered_package
= NULL
, unsquashed
[GUID_SIZE
];
1420 r
= msi_locate_product( product
, &context
);
1421 if (r
!= ERROR_SUCCESS
)
1424 r
= MSIREG_OpenProductKey( product
, NULL
, context
, &product_key
, FALSE
);
1425 if (r
!= ERROR_SUCCESS
)
1428 r
= MSIREG_OpenInstallProps( product
, context
, NULL
, &props_key
, FALSE
);
1429 if (r
!= ERROR_SUCCESS
)
1431 RegCloseKey( product_key
);
1434 r
= ERROR_FUNCTION_FAILED
;
1435 registered_package
= msi_reg_get_val_str( product_key
, INSTALLPROPERTY_PACKAGECODEW
);
1436 if (!registered_package
)
1439 unsquash_guid( registered_package
, unsquashed
);
1440 if (!strcmpiW( package
, unsquashed
))
1442 WCHAR
*filename
= msi_reg_get_val_str( props_key
, INSTALLPROPERTY_LOCALPACKAGEW
);
1446 strcpyW( localfile
, filename
);
1447 msi_free( filename
);
1451 msi_free( registered_package
);
1452 RegCloseKey( props_key
);
1453 RegCloseKey( product_key
);
1457 static WCHAR
*get_package_code( MSIDATABASE
*db
)
1462 if (!(si
= MSI_GetSummaryInformationW( db
->storage
, 0 )))
1464 WARN("failed to load summary info\n");
1467 ret
= msi_suminfo_dup_string( si
, PID_REVNUMBER
);
1468 msiobj_release( &si
->hdr
);
1472 static UINT
get_local_package( const WCHAR
*filename
, WCHAR
*localfile
)
1474 WCHAR
*product_code
, *package_code
;
1478 if ((r
= MSI_OpenDatabaseW( filename
, MSIDBOPEN_READONLY
, &db
)) != ERROR_SUCCESS
)
1480 if (GetFileAttributesW( filename
) == INVALID_FILE_ATTRIBUTES
)
1481 return ERROR_FILE_NOT_FOUND
;
1484 if (!(product_code
= get_product_code( db
)))
1486 msiobj_release( &db
->hdr
);
1487 return ERROR_INSTALL_PACKAGE_INVALID
;
1489 if (!(package_code
= get_package_code( db
)))
1491 msi_free( product_code
);
1492 msiobj_release( &db
->hdr
);
1493 return ERROR_INSTALL_PACKAGE_INVALID
;
1495 r
= get_registered_local_package( product_code
, package_code
, localfile
);
1496 msi_free( package_code
);
1497 msi_free( product_code
);
1498 msiobj_release( &db
->hdr
);
1502 UINT
msi_set_original_database_property( MSIDATABASE
*db
, const WCHAR
*package
)
1506 if (UrlIsW( package
, URLIS_URL
))
1507 r
= msi_set_property( db
, szOriginalDatabase
, package
, -1 );
1508 else if (package
[0] == '#')
1509 r
= msi_set_property( db
, szOriginalDatabase
, db
->path
, -1 );
1515 if (!(len
= GetFullPathNameW( package
, 0, NULL
, NULL
))) return GetLastError();
1516 if (!(path
= msi_alloc( len
* sizeof(WCHAR
) ))) return ERROR_OUTOFMEMORY
;
1517 len
= GetFullPathNameW( package
, len
, path
, NULL
);
1518 r
= msi_set_property( db
, szOriginalDatabase
, path
, len
);
1524 UINT
MSI_OpenPackageW(LPCWSTR szPackage
, MSIPACKAGE
**pPackage
)
1526 static const WCHAR dotmsi
[] = {'.','m','s','i',0};
1528 MSIPACKAGE
*package
;
1530 LPWSTR ptr
, base_url
= NULL
;
1532 WCHAR localfile
[MAX_PATH
], cachefile
[MAX_PATH
];
1533 LPCWSTR file
= szPackage
;
1536 BOOL delete_on_close
= FALSE
;
1538 TRACE("%s %p\n", debugstr_w(szPackage
), pPackage
);
1541 if( szPackage
[0] == '#' )
1543 handle
= atoiW(&szPackage
[1]);
1544 db
= msihandle2msiinfo( handle
, MSIHANDLETYPE_DATABASE
);
1547 IWineMsiRemoteDatabase
*remote_database
;
1549 remote_database
= (IWineMsiRemoteDatabase
*)msi_get_remote( handle
);
1550 if ( !remote_database
)
1551 return ERROR_INVALID_HANDLE
;
1553 IWineMsiRemoteDatabase_Release( remote_database
);
1554 WARN("MsiOpenPackage not allowed during a custom action!\n");
1556 return ERROR_FUNCTION_FAILED
;
1561 if ( UrlIsW( szPackage
, URLIS_URL
) )
1563 r
= msi_download_file( szPackage
, cachefile
);
1564 if (r
!= ERROR_SUCCESS
)
1569 base_url
= strdupW( szPackage
);
1571 return ERROR_OUTOFMEMORY
;
1573 ptr
= strrchrW( base_url
, '/' );
1574 if (ptr
) *(ptr
+ 1) = '\0';
1576 r
= get_local_package( file
, localfile
);
1577 if (r
!= ERROR_SUCCESS
|| GetFileAttributesW( localfile
) == INVALID_FILE_ATTRIBUTES
)
1579 r
= msi_create_empty_local_file( localfile
, dotmsi
);
1580 if (r
!= ERROR_SUCCESS
)
1582 msi_free ( base_url
);
1586 if (!CopyFileW( file
, localfile
, FALSE
))
1589 WARN("unable to copy package %s to %s (%u)\n", debugstr_w(file
), debugstr_w(localfile
), r
);
1590 DeleteFileW( localfile
);
1591 msi_free ( base_url
);
1594 delete_on_close
= TRUE
;
1596 TRACE("opening package %s\n", debugstr_w( localfile
));
1597 r
= MSI_OpenDatabaseW( localfile
, MSIDBOPEN_TRANSACT
, &db
);
1598 if (r
!= ERROR_SUCCESS
)
1600 msi_free ( base_url
);
1604 package
= MSI_CreatePackage( db
, base_url
);
1605 msi_free( base_url
);
1606 msiobj_release( &db
->hdr
);
1607 if (!package
) return ERROR_INSTALL_PACKAGE_INVALID
;
1608 package
->localfile
= strdupW( localfile
);
1609 package
->delete_on_close
= delete_on_close
;
1611 si
= MSI_GetSummaryInformationW( db
->storage
, 0 );
1614 WARN("failed to load summary info\n");
1615 msiobj_release( &package
->hdr
);
1616 return ERROR_INSTALL_PACKAGE_INVALID
;
1618 r
= msi_parse_summary( si
, package
);
1619 msiobj_release( &si
->hdr
);
1620 if (r
!= ERROR_SUCCESS
)
1622 WARN("failed to parse summary info %u\n", r
);
1623 msiobj_release( &package
->hdr
);
1626 r
= validate_package( package
);
1627 if (r
!= ERROR_SUCCESS
)
1629 msiobj_release( &package
->hdr
);
1632 msi_set_property( package
->db
, szDatabase
, db
->path
, -1 );
1633 set_installed_prop( package
);
1634 msi_set_context( package
);
1638 WCHAR patch_code
[GUID_SIZE
];
1639 r
= MsiEnumPatchesExW( package
->ProductCode
, NULL
, package
->Context
,
1640 MSIPATCHSTATE_APPLIED
, index
, patch_code
, NULL
, NULL
, NULL
, NULL
);
1641 if (r
!= ERROR_SUCCESS
)
1644 TRACE("found registered patch %s\n", debugstr_w(patch_code
));
1646 r
= msi_apply_registered_patch( package
, patch_code
);
1647 if (r
!= ERROR_SUCCESS
)
1649 ERR("registered patch failed to apply %u\n", r
);
1650 msiobj_release( &package
->hdr
);
1657 msi_clone_properties( package
);
1658 msi_adjust_privilege_properties( package
);
1660 r
= msi_set_original_database_property( package
->db
, szPackage
);
1661 if (r
!= ERROR_SUCCESS
)
1663 msiobj_release( &package
->hdr
);
1667 package
->log_file
= CreateFileW( gszLogFile
, GENERIC_WRITE
, FILE_SHARE_WRITE
, NULL
,
1668 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1669 *pPackage
= package
;
1670 return ERROR_SUCCESS
;
1673 UINT WINAPI
MsiOpenPackageExW(LPCWSTR szPackage
, DWORD dwOptions
, MSIHANDLE
*phPackage
)
1675 MSIPACKAGE
*package
= NULL
;
1678 TRACE("%s %08x %p\n", debugstr_w(szPackage
), dwOptions
, phPackage
);
1680 if( !szPackage
|| !phPackage
)
1681 return ERROR_INVALID_PARAMETER
;
1685 FIXME("Should create an empty database and package\n");
1686 return ERROR_FUNCTION_FAILED
;
1690 FIXME("dwOptions %08x not supported\n", dwOptions
);
1692 ret
= MSI_OpenPackageW( szPackage
, &package
);
1693 if( ret
== ERROR_SUCCESS
)
1695 *phPackage
= alloc_msihandle( &package
->hdr
);
1697 ret
= ERROR_NOT_ENOUGH_MEMORY
;
1698 msiobj_release( &package
->hdr
);
1704 UINT WINAPI
MsiOpenPackageW(LPCWSTR szPackage
, MSIHANDLE
*phPackage
)
1706 return MsiOpenPackageExW( szPackage
, 0, phPackage
);
1709 UINT WINAPI
MsiOpenPackageExA(LPCSTR szPackage
, DWORD dwOptions
, MSIHANDLE
*phPackage
)
1711 LPWSTR szwPack
= NULL
;
1716 szwPack
= strdupAtoW( szPackage
);
1718 return ERROR_OUTOFMEMORY
;
1721 ret
= MsiOpenPackageExW( szwPack
, dwOptions
, phPackage
);
1723 msi_free( szwPack
);
1728 UINT WINAPI
MsiOpenPackageA(LPCSTR szPackage
, MSIHANDLE
*phPackage
)
1730 return MsiOpenPackageExA( szPackage
, 0, phPackage
);
1733 MSIHANDLE WINAPI
MsiGetActiveDatabase(MSIHANDLE hInstall
)
1735 MSIPACKAGE
*package
;
1736 MSIHANDLE handle
= 0;
1737 IUnknown
*remote_unk
;
1738 IWineMsiRemotePackage
*remote_package
;
1740 TRACE("(%d)\n",hInstall
);
1742 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
1745 handle
= alloc_msihandle( &package
->db
->hdr
);
1746 msiobj_release( &package
->hdr
);
1748 else if ((remote_unk
= msi_get_remote(hInstall
)))
1750 if (IUnknown_QueryInterface(remote_unk
, &IID_IWineMsiRemotePackage
,
1751 (LPVOID
*)&remote_package
) == S_OK
)
1753 IWineMsiRemotePackage_GetActiveDatabase(remote_package
, &handle
);
1754 IWineMsiRemotePackage_Release(remote_package
);
1758 WARN("remote handle %d is not a package\n", hInstall
);
1760 IUnknown_Release(remote_unk
);
1766 INT
MSI_ProcessMessage( MSIPACKAGE
*package
, INSTALLMESSAGE eMessageType
, MSIRECORD
*record
)
1768 static const WCHAR szActionData
[] = {'A','c','t','i','o','n','D','a','t','a',0};
1769 static const WCHAR szSetProgress
[] = {'S','e','t','P','r','o','g','r','e','s','s',0};
1770 static const WCHAR szActionText
[] = {'A','c','t','i','o','n','T','e','x','t',0};
1772 LPWSTR deformated
, message
;
1773 DWORD i
, len
, total_len
, log_type
= 0;
1777 TRACE("%x\n", eMessageType
);
1779 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_FATALEXIT
)
1780 log_type
|= INSTALLLOGMODE_FATALEXIT
;
1781 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_ERROR
)
1782 log_type
|= INSTALLLOGMODE_ERROR
;
1783 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_WARNING
)
1784 log_type
|= INSTALLLOGMODE_WARNING
;
1785 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_USER
)
1786 log_type
|= INSTALLLOGMODE_USER
;
1787 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_INFO
)
1788 log_type
|= INSTALLLOGMODE_INFO
;
1789 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_RESOLVESOURCE
)
1790 log_type
|= INSTALLLOGMODE_RESOLVESOURCE
;
1791 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_OUTOFDISKSPACE
)
1792 log_type
|= INSTALLLOGMODE_OUTOFDISKSPACE
;
1793 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_COMMONDATA
)
1794 log_type
|= INSTALLLOGMODE_COMMONDATA
;
1795 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_ACTIONSTART
)
1796 log_type
|= INSTALLLOGMODE_ACTIONSTART
;
1797 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_ACTIONDATA
)
1798 log_type
|= INSTALLLOGMODE_ACTIONDATA
;
1799 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_PROGRESS
)
1800 log_type
|= INSTALLLOGMODE_PROGRESS
;
1801 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_INITIALIZE
)
1802 log_type
|= INSTALLLOGMODE_INITIALIZE
;
1803 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_TERMINATE
)
1804 log_type
|= INSTALLLOGMODE_TERMINATE
;
1805 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_SHOWDIALOG
)
1806 log_type
|= INSTALLLOGMODE_SHOWDIALOG
;
1808 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_ACTIONSTART
)
1810 static const WCHAR template_s
[]=
1811 {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ',0};
1812 static const WCHAR format
[] =
1813 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
1815 LPCWSTR action_text
, action
;
1816 LPWSTR deformatted
= NULL
;
1818 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0, NULL
, format
, timet
, 0x100);
1820 action
= MSI_RecordGetString(record
, 1);
1821 action_text
= MSI_RecordGetString(record
, 2);
1823 if (!action
|| !action_text
)
1826 deformat_string(package
, action_text
, &deformatted
);
1828 len
= strlenW(timet
) + strlenW(action
) + strlenW(template_s
);
1830 len
+= strlenW(deformatted
);
1831 message
= msi_alloc(len
*sizeof(WCHAR
));
1832 sprintfW(message
, template_s
, timet
, action
);
1834 strcatW(message
, deformatted
);
1835 msi_free(deformatted
);
1839 static const WCHAR format
[] = {'%','u',':',' ',0};
1840 UINT count
= MSI_RecordGetFieldCount( record
);
1844 for (i
= 1; i
<= count
; i
++)
1847 MSI_RecordGetStringW( record
, i
, NULL
, &len
);
1848 total_len
+= len
+ 13;
1850 p
= message
= msi_alloc( total_len
* sizeof(WCHAR
) );
1851 if (!p
) return ERROR_OUTOFMEMORY
;
1853 for (i
= 1; i
<= count
; i
++)
1857 len
= sprintfW( p
, format
, i
);
1862 MSI_RecordGetStringW( record
, i
, p
, &len
);
1865 if (count
> 1 && total_len
)
1874 TRACE("%p %p %p %x %x %s\n", gUIHandlerA
, gUIHandlerW
, gUIHandlerRecord
,
1875 gUIFilter
, log_type
, debugstr_w(message
));
1877 /* convert it to ASCII */
1878 len
= WideCharToMultiByte( CP_ACP
, 0, message
, -1, NULL
, 0, NULL
, NULL
);
1879 msg
= msi_alloc( len
);
1880 WideCharToMultiByte( CP_ACP
, 0, message
, -1, msg
, len
, NULL
, NULL
);
1882 if (gUIHandlerW
&& (gUIFilter
& log_type
))
1884 rc
= gUIHandlerW( gUIContext
, eMessageType
, message
);
1886 else if (gUIHandlerA
&& (gUIFilter
& log_type
))
1888 rc
= gUIHandlerA( gUIContext
, eMessageType
, msg
);
1890 else if (gUIHandlerRecord
&& (gUIFilter
& log_type
))
1892 MSIHANDLE rec
= MsiCreateRecord( 1 );
1893 MsiRecordSetStringW( rec
, 0, message
);
1894 rc
= gUIHandlerRecord( gUIContext
, eMessageType
, rec
);
1895 MsiCloseHandle( rec
);
1898 if (!rc
&& package
->log_file
!= INVALID_HANDLE_VALUE
&&
1899 (eMessageType
& 0xff000000) != INSTALLMESSAGE_PROGRESS
)
1902 WriteFile( package
->log_file
, msg
, len
- 1, &written
, NULL
);
1903 WriteFile( package
->log_file
, "\n", 1, &written
, NULL
);
1906 msi_free( message
);
1908 switch (eMessageType
& 0xff000000)
1910 case INSTALLMESSAGE_ACTIONDATA
:
1911 deformat_string(package
, MSI_RecordGetString(record
, 2), &deformated
);
1912 uirow
= MSI_CreateRecord(1);
1913 MSI_RecordSetStringW(uirow
, 1, deformated
);
1914 msi_free(deformated
);
1916 msi_event_fire( package
, szActionData
, uirow
);
1917 msiobj_release(&uirow
->hdr
);
1919 if (package
->action_progress_increment
)
1921 uirow
= MSI_CreateRecord(2);
1922 MSI_RecordSetInteger(uirow
, 1, 2);
1923 MSI_RecordSetInteger(uirow
, 2, package
->action_progress_increment
);
1924 msi_event_fire( package
, szSetProgress
, uirow
);
1925 msiobj_release(&uirow
->hdr
);
1929 case INSTALLMESSAGE_ACTIONSTART
:
1930 deformat_string(package
, MSI_RecordGetString(record
, 2), &deformated
);
1931 uirow
= MSI_CreateRecord(1);
1932 MSI_RecordSetStringW(uirow
, 1, deformated
);
1933 msi_free(deformated
);
1935 msi_event_fire( package
, szActionText
, uirow
);
1937 msiobj_release(&uirow
->hdr
);
1940 case INSTALLMESSAGE_PROGRESS
:
1941 msi_event_fire( package
, szSetProgress
, record
);
1945 return ERROR_SUCCESS
;
1948 INT WINAPI
MsiProcessMessage( MSIHANDLE hInstall
, INSTALLMESSAGE eMessageType
,
1951 UINT ret
= ERROR_INVALID_HANDLE
;
1952 MSIPACKAGE
*package
= NULL
;
1953 MSIRECORD
*record
= NULL
;
1955 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
1959 IWineMsiRemotePackage
*remote_package
;
1961 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
1962 if (!remote_package
)
1963 return ERROR_INVALID_HANDLE
;
1965 hr
= IWineMsiRemotePackage_ProcessMessage( remote_package
, eMessageType
, hRecord
);
1967 IWineMsiRemotePackage_Release( remote_package
);
1971 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1972 return HRESULT_CODE(hr
);
1974 return ERROR_FUNCTION_FAILED
;
1977 return ERROR_SUCCESS
;
1980 record
= msihandle2msiinfo( hRecord
, MSIHANDLETYPE_RECORD
);
1984 ret
= MSI_ProcessMessage( package
, eMessageType
, record
);
1987 msiobj_release( &package
->hdr
);
1989 msiobj_release( &record
->hdr
);
1996 UINT WINAPI
MsiSetPropertyA( MSIHANDLE hInstall
, LPCSTR szName
, LPCSTR szValue
)
1998 LPWSTR szwName
= NULL
, szwValue
= NULL
;
1999 UINT r
= ERROR_OUTOFMEMORY
;
2001 szwName
= strdupAtoW( szName
);
2002 if( szName
&& !szwName
)
2005 szwValue
= strdupAtoW( szValue
);
2006 if( szValue
&& !szwValue
)
2009 r
= MsiSetPropertyW( hInstall
, szwName
, szwValue
);
2012 msi_free( szwName
);
2013 msi_free( szwValue
);
2018 void msi_reset_folders( MSIPACKAGE
*package
, BOOL source
)
2022 LIST_FOR_EACH_ENTRY( folder
, &package
->folders
, MSIFOLDER
, entry
)
2026 msi_free( folder
->ResolvedSource
);
2027 folder
->ResolvedSource
= NULL
;
2031 msi_free( folder
->ResolvedTarget
);
2032 folder
->ResolvedTarget
= NULL
;
2037 UINT
msi_set_property( MSIDATABASE
*db
, const WCHAR
*name
, const WCHAR
*value
, int len
)
2039 static const WCHAR insert_query
[] = {
2040 'I','N','S','E','R','T',' ','I','N','T','O',' ',
2041 '`','_','P','r','o','p','e','r','t','y','`',' ',
2042 '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
2043 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
2044 static const WCHAR update_query
[] = {
2045 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
2046 'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ','W','H','E','R','E',' ',
2047 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
2048 static const WCHAR delete_query
[] = {
2049 'D','E','L','E','T','E',' ','F','R','O','M',' ',
2050 '`','_','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2051 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
2053 MSIRECORD
*row
= NULL
;
2058 TRACE("%p %s %s %d\n", db
, debugstr_w(name
), debugstr_wn(value
, len
), len
);
2061 return ERROR_INVALID_PARAMETER
;
2063 /* this one is weird... */
2065 return value
? ERROR_FUNCTION_FAILED
: ERROR_SUCCESS
;
2067 if (value
&& len
< 0) len
= strlenW( value
);
2069 rc
= msi_get_property( db
, name
, 0, &sz
);
2070 if (!value
|| (!*value
&& !len
))
2072 sprintfW( query
, delete_query
, name
);
2074 else if (rc
== ERROR_MORE_DATA
|| rc
== ERROR_SUCCESS
)
2076 sprintfW( query
, update_query
, name
);
2077 row
= MSI_CreateRecord(1);
2078 msi_record_set_string( row
, 1, value
, len
);
2082 strcpyW( query
, insert_query
);
2083 row
= MSI_CreateRecord(2);
2084 msi_record_set_string( row
, 1, name
, -1 );
2085 msi_record_set_string( row
, 2, value
, len
);
2088 rc
= MSI_DatabaseOpenViewW(db
, query
, &view
);
2089 if (rc
== ERROR_SUCCESS
)
2091 rc
= MSI_ViewExecute(view
, row
);
2092 MSI_ViewClose(view
);
2093 msiobj_release(&view
->hdr
);
2095 if (row
) msiobj_release(&row
->hdr
);
2099 UINT WINAPI
MsiSetPropertyW( MSIHANDLE hInstall
, LPCWSTR szName
, LPCWSTR szValue
)
2101 MSIPACKAGE
*package
;
2104 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
2108 BSTR name
= NULL
, value
= NULL
;
2109 IWineMsiRemotePackage
*remote_package
;
2111 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
2112 if (!remote_package
)
2113 return ERROR_INVALID_HANDLE
;
2115 name
= SysAllocString( szName
);
2116 value
= SysAllocString( szValue
);
2117 if ((!name
&& szName
) || (!value
&& szValue
))
2119 SysFreeString( name
);
2120 SysFreeString( value
);
2121 IWineMsiRemotePackage_Release( remote_package
);
2122 return ERROR_OUTOFMEMORY
;
2125 hr
= IWineMsiRemotePackage_SetProperty( remote_package
, name
, value
);
2127 SysFreeString( name
);
2128 SysFreeString( value
);
2129 IWineMsiRemotePackage_Release( remote_package
);
2133 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
2134 return HRESULT_CODE(hr
);
2136 return ERROR_FUNCTION_FAILED
;
2139 return ERROR_SUCCESS
;
2142 ret
= msi_set_property( package
->db
, szName
, szValue
, -1 );
2143 if (ret
== ERROR_SUCCESS
&& !strcmpW( szName
, szSourceDir
))
2144 msi_reset_folders( package
, TRUE
);
2146 msiobj_release( &package
->hdr
);
2150 static MSIRECORD
*msi_get_property_row( MSIDATABASE
*db
, LPCWSTR name
)
2152 static const WCHAR query
[]= {
2153 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
2154 'F','R','O','M',' ' ,'`','_','P','r','o','p','e','r','t','y','`',' ',
2155 'W','H','E','R','E',' ' ,'`','_','P','r','o','p','e','r','t','y','`','=','?',0};
2156 MSIRECORD
*rec
, *row
= NULL
;
2160 if (!name
|| !*name
)
2163 rec
= MSI_CreateRecord(1);
2167 MSI_RecordSetStringW(rec
, 1, name
);
2169 r
= MSI_DatabaseOpenViewW(db
, query
, &view
);
2170 if (r
== ERROR_SUCCESS
)
2172 MSI_ViewExecute(view
, rec
);
2173 MSI_ViewFetch(view
, &row
);
2174 MSI_ViewClose(view
);
2175 msiobj_release(&view
->hdr
);
2177 msiobj_release(&rec
->hdr
);
2181 /* internal function, not compatible with MsiGetPropertyW */
2182 UINT
msi_get_property( MSIDATABASE
*db
, LPCWSTR szName
,
2183 LPWSTR szValueBuf
, LPDWORD pchValueBuf
)
2186 UINT rc
= ERROR_FUNCTION_FAILED
;
2188 row
= msi_get_property_row( db
, szName
);
2190 if (*pchValueBuf
> 0)
2195 rc
= MSI_RecordGetStringW(row
, 1, szValueBuf
, pchValueBuf
);
2196 msiobj_release(&row
->hdr
);
2199 if (rc
== ERROR_SUCCESS
)
2200 TRACE("returning %s for property %s\n", debugstr_wn(szValueBuf
, *pchValueBuf
),
2201 debugstr_w(szName
));
2202 else if (rc
== ERROR_MORE_DATA
)
2203 TRACE("need %d sized buffer for %s\n", *pchValueBuf
,
2204 debugstr_w(szName
));
2208 TRACE("property %s not found\n", debugstr_w(szName
));
2214 LPWSTR
msi_dup_property(MSIDATABASE
*db
, LPCWSTR prop
)
2220 r
= msi_get_property(db
, prop
, NULL
, &sz
);
2221 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
2225 str
= msi_alloc(sz
* sizeof(WCHAR
));
2226 r
= msi_get_property(db
, prop
, str
, &sz
);
2227 if (r
!= ERROR_SUCCESS
)
2236 int msi_get_property_int( MSIDATABASE
*db
, LPCWSTR prop
, int def
)
2238 LPWSTR str
= msi_dup_property( db
, prop
);
2239 int val
= str
? atoiW(str
) : def
;
2244 static UINT
MSI_GetProperty( MSIHANDLE handle
, LPCWSTR name
,
2245 awstring
*szValueBuf
, LPDWORD pchValueBuf
)
2247 MSIPACKAGE
*package
;
2248 MSIRECORD
*row
= NULL
;
2249 UINT r
= ERROR_FUNCTION_FAILED
;
2253 TRACE("%u %s %p %p\n", handle
, debugstr_w(name
),
2254 szValueBuf
->str
.w
, pchValueBuf
);
2257 return ERROR_INVALID_PARAMETER
;
2259 package
= msihandle2msiinfo( handle
, MSIHANDLETYPE_PACKAGE
);
2263 IWineMsiRemotePackage
*remote_package
;
2264 LPWSTR value
= NULL
;
2267 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( handle
);
2268 if (!remote_package
)
2269 return ERROR_INVALID_HANDLE
;
2271 bname
= SysAllocString( name
);
2274 IWineMsiRemotePackage_Release( remote_package
);
2275 return ERROR_OUTOFMEMORY
;
2278 hr
= IWineMsiRemotePackage_GetProperty( remote_package
, bname
, NULL
, &len
);
2283 value
= msi_alloc(len
* sizeof(WCHAR
));
2286 r
= ERROR_OUTOFMEMORY
;
2290 hr
= IWineMsiRemotePackage_GetProperty( remote_package
, bname
, value
, &len
);
2294 r
= msi_strcpy_to_awstring( value
, len
, szValueBuf
, pchValueBuf
);
2296 /* Bug required by Adobe installers */
2297 if (!szValueBuf
->unicode
&& !szValueBuf
->str
.a
)
2298 *pchValueBuf
*= sizeof(WCHAR
);
2301 IWineMsiRemotePackage_Release(remote_package
);
2302 SysFreeString(bname
);
2307 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
2308 return HRESULT_CODE(hr
);
2310 return ERROR_FUNCTION_FAILED
;
2316 row
= msi_get_property_row( package
->db
, name
);
2318 val
= msi_record_get_string( row
, 1, (int *)&len
);
2323 r
= msi_strcpy_to_awstring( val
, len
, szValueBuf
, pchValueBuf
);
2326 msiobj_release( &row
->hdr
);
2327 msiobj_release( &package
->hdr
);
2332 UINT WINAPI
MsiGetPropertyA( MSIHANDLE hInstall
, LPCSTR szName
,
2333 LPSTR szValueBuf
, LPDWORD pchValueBuf
)
2339 val
.unicode
= FALSE
;
2340 val
.str
.a
= szValueBuf
;
2342 name
= strdupAtoW( szName
);
2343 if (szName
&& !name
)
2344 return ERROR_OUTOFMEMORY
;
2346 r
= MSI_GetProperty( hInstall
, name
, &val
, pchValueBuf
);
2351 UINT WINAPI
MsiGetPropertyW( MSIHANDLE hInstall
, LPCWSTR szName
,
2352 LPWSTR szValueBuf
, LPDWORD pchValueBuf
)
2357 val
.str
.w
= szValueBuf
;
2359 return MSI_GetProperty( hInstall
, szName
, &val
, pchValueBuf
);
2362 typedef struct _msi_remote_package_impl
{
2363 IWineMsiRemotePackage IWineMsiRemotePackage_iface
;
2366 } msi_remote_package_impl
;
2368 static inline msi_remote_package_impl
*impl_from_IWineMsiRemotePackage( IWineMsiRemotePackage
*iface
)
2370 return CONTAINING_RECORD(iface
, msi_remote_package_impl
, IWineMsiRemotePackage_iface
);
2373 static HRESULT WINAPI
mrp_QueryInterface( IWineMsiRemotePackage
*iface
,
2374 REFIID riid
,LPVOID
*ppobj
)
2376 if( IsEqualCLSID( riid
, &IID_IUnknown
) ||
2377 IsEqualCLSID( riid
, &IID_IWineMsiRemotePackage
) )
2379 IWineMsiRemotePackage_AddRef( iface
);
2384 return E_NOINTERFACE
;
2387 static ULONG WINAPI
mrp_AddRef( IWineMsiRemotePackage
*iface
)
2389 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2391 return InterlockedIncrement( &This
->refs
);
2394 static ULONG WINAPI
mrp_Release( IWineMsiRemotePackage
*iface
)
2396 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2399 r
= InterlockedDecrement( &This
->refs
);
2402 MsiCloseHandle( This
->package
);
2408 static HRESULT WINAPI
mrp_SetMsiHandle( IWineMsiRemotePackage
*iface
, MSIHANDLE handle
)
2410 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2411 This
->package
= handle
;
2415 static HRESULT WINAPI
mrp_GetActiveDatabase( IWineMsiRemotePackage
*iface
, MSIHANDLE
*handle
)
2417 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2418 IWineMsiRemoteDatabase
*rdb
= NULL
;
2422 hr
= create_msi_remote_database( NULL
, (LPVOID
*)&rdb
);
2423 if (FAILED(hr
) || !rdb
)
2425 ERR("Failed to create remote database\n");
2429 hdb
= MsiGetActiveDatabase(This
->package
);
2431 hr
= IWineMsiRemoteDatabase_SetMsiHandle( rdb
, hdb
);
2434 ERR("Failed to set the database handle\n");
2438 *handle
= alloc_msi_remote_handle( (IUnknown
*)rdb
);
2442 static HRESULT WINAPI
mrp_GetProperty( IWineMsiRemotePackage
*iface
, BSTR property
, BSTR value
, DWORD
*size
)
2444 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2445 UINT r
= MsiGetPropertyW(This
->package
, property
, value
, size
);
2446 if (r
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(r
);
2450 static HRESULT WINAPI
mrp_SetProperty( IWineMsiRemotePackage
*iface
, BSTR property
, BSTR value
)
2452 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2453 UINT r
= MsiSetPropertyW(This
->package
, property
, value
);
2454 return HRESULT_FROM_WIN32(r
);
2457 static HRESULT WINAPI
mrp_ProcessMessage( IWineMsiRemotePackage
*iface
, INSTALLMESSAGE message
, MSIHANDLE record
)
2459 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2460 UINT r
= MsiProcessMessage(This
->package
, message
, record
);
2461 return HRESULT_FROM_WIN32(r
);
2464 static HRESULT WINAPI
mrp_DoAction( IWineMsiRemotePackage
*iface
, BSTR action
)
2466 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2467 UINT r
= MsiDoActionW(This
->package
, action
);
2468 return HRESULT_FROM_WIN32(r
);
2471 static HRESULT WINAPI
mrp_Sequence( IWineMsiRemotePackage
*iface
, BSTR table
, int sequence
)
2473 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2474 UINT r
= MsiSequenceW(This
->package
, table
, sequence
);
2475 return HRESULT_FROM_WIN32(r
);
2478 static HRESULT WINAPI
mrp_GetTargetPath( IWineMsiRemotePackage
*iface
, BSTR folder
, BSTR value
, DWORD
*size
)
2480 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2481 UINT r
= MsiGetTargetPathW(This
->package
, folder
, value
, size
);
2482 return HRESULT_FROM_WIN32(r
);
2485 static HRESULT WINAPI
mrp_SetTargetPath( IWineMsiRemotePackage
*iface
, BSTR folder
, BSTR value
)
2487 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2488 UINT r
= MsiSetTargetPathW(This
->package
, folder
, value
);
2489 return HRESULT_FROM_WIN32(r
);
2492 static HRESULT WINAPI
mrp_GetSourcePath( IWineMsiRemotePackage
*iface
, BSTR folder
, BSTR value
, DWORD
*size
)
2494 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2495 UINT r
= MsiGetSourcePathW(This
->package
, folder
, value
, size
);
2496 return HRESULT_FROM_WIN32(r
);
2499 static HRESULT WINAPI
mrp_GetMode( IWineMsiRemotePackage
*iface
, MSIRUNMODE mode
, BOOL
*ret
)
2501 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2502 *ret
= MsiGetMode(This
->package
, mode
);
2506 static HRESULT WINAPI
mrp_SetMode( IWineMsiRemotePackage
*iface
, MSIRUNMODE mode
, BOOL state
)
2508 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2509 UINT r
= MsiSetMode(This
->package
, mode
, state
);
2510 return HRESULT_FROM_WIN32(r
);
2513 static HRESULT WINAPI
mrp_GetFeatureState( IWineMsiRemotePackage
*iface
, BSTR feature
,
2514 INSTALLSTATE
*installed
, INSTALLSTATE
*action
)
2516 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2517 UINT r
= MsiGetFeatureStateW(This
->package
, feature
, installed
, action
);
2518 return HRESULT_FROM_WIN32(r
);
2521 static HRESULT WINAPI
mrp_SetFeatureState( IWineMsiRemotePackage
*iface
, BSTR feature
, INSTALLSTATE state
)
2523 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2524 UINT r
= MsiSetFeatureStateW(This
->package
, feature
, state
);
2525 return HRESULT_FROM_WIN32(r
);
2528 static HRESULT WINAPI
mrp_GetComponentState( IWineMsiRemotePackage
*iface
, BSTR component
,
2529 INSTALLSTATE
*installed
, INSTALLSTATE
*action
)
2531 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2532 UINT r
= MsiGetComponentStateW(This
->package
, component
, installed
, action
);
2533 return HRESULT_FROM_WIN32(r
);
2536 static HRESULT WINAPI
mrp_SetComponentState( IWineMsiRemotePackage
*iface
, BSTR component
, INSTALLSTATE state
)
2538 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2539 UINT r
= MsiSetComponentStateW(This
->package
, component
, state
);
2540 return HRESULT_FROM_WIN32(r
);
2543 static HRESULT WINAPI
mrp_GetLanguage( IWineMsiRemotePackage
*iface
, LANGID
*language
)
2545 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2546 *language
= MsiGetLanguage(This
->package
);
2550 static HRESULT WINAPI
mrp_SetInstallLevel( IWineMsiRemotePackage
*iface
, int level
)
2552 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2553 UINT r
= MsiSetInstallLevel(This
->package
, level
);
2554 return HRESULT_FROM_WIN32(r
);
2557 static HRESULT WINAPI
mrp_FormatRecord( IWineMsiRemotePackage
*iface
, MSIHANDLE record
,
2561 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2562 UINT r
= MsiFormatRecordW(This
->package
, record
, NULL
, &size
);
2563 if (r
== ERROR_SUCCESS
)
2565 *value
= SysAllocStringLen(NULL
, size
);
2567 return E_OUTOFMEMORY
;
2569 r
= MsiFormatRecordW(This
->package
, record
, *value
, &size
);
2571 return HRESULT_FROM_WIN32(r
);
2574 static HRESULT WINAPI
mrp_EvaluateCondition( IWineMsiRemotePackage
*iface
, BSTR condition
)
2576 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2577 UINT r
= MsiEvaluateConditionW(This
->package
, condition
);
2578 return HRESULT_FROM_WIN32(r
);
2581 static HRESULT WINAPI
mrp_GetFeatureCost( IWineMsiRemotePackage
*iface
, BSTR feature
,
2582 INT cost_tree
, INSTALLSTATE state
, INT
*cost
)
2584 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2585 UINT r
= MsiGetFeatureCostW(This
->package
, feature
, cost_tree
, state
, cost
);
2586 return HRESULT_FROM_WIN32(r
);
2589 static HRESULT WINAPI
mrp_EnumComponentCosts( IWineMsiRemotePackage
*iface
, BSTR component
,
2590 DWORD index
, INSTALLSTATE state
, BSTR drive
,
2591 DWORD
*buflen
, INT
*cost
, INT
*temp
)
2593 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2594 UINT r
= MsiEnumComponentCostsW(This
->package
, component
, index
, state
, drive
, buflen
, cost
, temp
);
2595 return HRESULT_FROM_WIN32(r
);
2598 static const IWineMsiRemotePackageVtbl msi_remote_package_vtbl
=
2604 mrp_GetActiveDatabase
,
2615 mrp_GetFeatureState
,
2616 mrp_SetFeatureState
,
2617 mrp_GetComponentState
,
2618 mrp_SetComponentState
,
2620 mrp_SetInstallLevel
,
2622 mrp_EvaluateCondition
,
2624 mrp_EnumComponentCosts
2627 HRESULT
create_msi_remote_package( IUnknown
*pOuter
, LPVOID
*ppObj
)
2629 msi_remote_package_impl
* This
;
2631 This
= msi_alloc( sizeof *This
);
2633 return E_OUTOFMEMORY
;
2635 This
->IWineMsiRemotePackage_iface
.lpVtbl
= &msi_remote_package_vtbl
;
2644 UINT
msi_package_add_info(MSIPACKAGE
*package
, DWORD context
, DWORD options
,
2645 LPCWSTR property
, LPWSTR value
)
2647 MSISOURCELISTINFO
*info
;
2649 LIST_FOR_EACH_ENTRY( info
, &package
->sourcelist_info
, MSISOURCELISTINFO
, entry
)
2651 if (!strcmpW( info
->value
, value
)) return ERROR_SUCCESS
;
2654 info
= msi_alloc(sizeof(MSISOURCELISTINFO
));
2656 return ERROR_OUTOFMEMORY
;
2658 info
->context
= context
;
2659 info
->options
= options
;
2660 info
->property
= property
;
2661 info
->value
= strdupW(value
);
2662 list_add_head(&package
->sourcelist_info
, &info
->entry
);
2664 return ERROR_SUCCESS
;
2667 UINT
msi_package_add_media_disk(MSIPACKAGE
*package
, DWORD context
, DWORD options
,
2668 DWORD disk_id
, LPWSTR volume_label
, LPWSTR disk_prompt
)
2672 LIST_FOR_EACH_ENTRY( disk
, &package
->sourcelist_media
, MSIMEDIADISK
, entry
)
2674 if (disk
->disk_id
== disk_id
) return ERROR_SUCCESS
;
2677 disk
= msi_alloc(sizeof(MSIMEDIADISK
));
2679 return ERROR_OUTOFMEMORY
;
2681 disk
->context
= context
;
2682 disk
->options
= options
;
2683 disk
->disk_id
= disk_id
;
2684 disk
->volume_label
= strdupW(volume_label
);
2685 disk
->disk_prompt
= strdupW(disk_prompt
);
2686 list_add_head(&package
->sourcelist_media
, &disk
->entry
);
2688 return ERROR_SUCCESS
;