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/exception.h"
48 #include "wine/unicode.h"
54 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
56 static void free_feature( MSIFEATURE
*feature
)
58 struct list
*item
, *cursor
;
60 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Children
)
62 FeatureList
*fl
= LIST_ENTRY( item
, FeatureList
, entry
);
63 list_remove( &fl
->entry
);
67 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Components
)
69 ComponentList
*cl
= LIST_ENTRY( item
, ComponentList
, entry
);
70 list_remove( &cl
->entry
);
73 msi_free( feature
->Feature
);
74 msi_free( feature
->Feature_Parent
);
75 msi_free( feature
->Directory
);
76 msi_free( feature
->Description
);
77 msi_free( feature
->Title
);
81 static void free_folder( MSIFOLDER
*folder
)
83 struct list
*item
, *cursor
;
85 LIST_FOR_EACH_SAFE( item
, cursor
, &folder
->children
)
87 FolderList
*fl
= LIST_ENTRY( item
, FolderList
, entry
);
88 list_remove( &fl
->entry
);
91 msi_free( folder
->Parent
);
92 msi_free( folder
->Directory
);
93 msi_free( folder
->TargetDefault
);
94 msi_free( folder
->SourceLongPath
);
95 msi_free( folder
->SourceShortPath
);
96 msi_free( folder
->ResolvedTarget
);
97 msi_free( folder
->ResolvedSource
);
101 static void free_extension( MSIEXTENSION
*ext
)
103 struct list
*item
, *cursor
;
105 LIST_FOR_EACH_SAFE( item
, cursor
, &ext
->verbs
)
107 MSIVERB
*verb
= LIST_ENTRY( item
, MSIVERB
, entry
);
109 list_remove( &verb
->entry
);
110 msi_free( verb
->Verb
);
111 msi_free( verb
->Command
);
112 msi_free( verb
->Argument
);
116 msi_free( ext
->Extension
);
117 msi_free( ext
->ProgIDText
);
121 static void free_assembly( MSIASSEMBLY
*assembly
)
123 msi_free( assembly
->feature
);
124 msi_free( assembly
->manifest
);
125 msi_free( assembly
->application
);
126 msi_free( assembly
->display_name
);
127 if (assembly
->tempdir
) RemoveDirectoryW( assembly
->tempdir
);
128 msi_free( assembly
->tempdir
);
129 msi_free( assembly
);
132 void msi_free_action_script( MSIPACKAGE
*package
, UINT script
)
135 for (i
= 0; i
< package
->script_actions_count
[script
]; i
++)
136 msi_free( package
->script_actions
[script
][i
] );
138 msi_free( package
->script_actions
[script
] );
139 package
->script_actions
[script
] = NULL
;
140 package
->script_actions_count
[script
] = 0;
143 static void free_package_structures( MSIPACKAGE
*package
)
145 struct list
*item
, *cursor
;
148 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->features
)
150 MSIFEATURE
*feature
= LIST_ENTRY( item
, MSIFEATURE
, entry
);
151 list_remove( &feature
->entry
);
152 free_feature( feature
);
155 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->folders
)
157 MSIFOLDER
*folder
= LIST_ENTRY( item
, MSIFOLDER
, entry
);
158 list_remove( &folder
->entry
);
159 free_folder( folder
);
162 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->files
)
164 MSIFILE
*file
= LIST_ENTRY( item
, MSIFILE
, entry
);
166 list_remove( &file
->entry
);
167 msi_free( file
->File
);
168 msi_free( file
->FileName
);
169 msi_free( file
->ShortName
);
170 msi_free( file
->LongName
);
171 msi_free( file
->Version
);
172 msi_free( file
->Language
);
173 if (msi_is_global_assembly( file
->Component
)) DeleteFileW( file
->TargetPath
);
174 msi_free( file
->TargetPath
);
178 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->components
)
180 MSICOMPONENT
*comp
= LIST_ENTRY( item
, MSICOMPONENT
, entry
);
182 list_remove( &comp
->entry
);
183 msi_free( comp
->Component
);
184 msi_free( comp
->ComponentId
);
185 msi_free( comp
->Directory
);
186 msi_free( comp
->Condition
);
187 msi_free( comp
->KeyPath
);
188 msi_free( comp
->FullKeypath
);
189 if (comp
->assembly
) free_assembly( comp
->assembly
);
193 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->filepatches
)
195 MSIFILEPATCH
*patch
= LIST_ENTRY( item
, MSIFILEPATCH
, entry
);
197 list_remove( &patch
->entry
);
198 msi_free( patch
->path
);
202 /* clean up extension, progid, class and verb structures */
203 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->classes
)
205 MSICLASS
*cls
= LIST_ENTRY( item
, MSICLASS
, entry
);
207 list_remove( &cls
->entry
);
208 msi_free( cls
->clsid
);
209 msi_free( cls
->Context
);
210 msi_free( cls
->Description
);
211 msi_free( cls
->FileTypeMask
);
212 msi_free( cls
->IconPath
);
213 msi_free( cls
->DefInprocHandler
);
214 msi_free( cls
->DefInprocHandler32
);
215 msi_free( cls
->Argument
);
216 msi_free( cls
->ProgIDText
);
220 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->extensions
)
222 MSIEXTENSION
*ext
= LIST_ENTRY( item
, MSIEXTENSION
, entry
);
224 list_remove( &ext
->entry
);
225 free_extension( ext
);
228 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->progids
)
230 MSIPROGID
*progid
= LIST_ENTRY( item
, MSIPROGID
, entry
);
232 list_remove( &progid
->entry
);
233 msi_free( progid
->ProgID
);
234 msi_free( progid
->Description
);
235 msi_free( progid
->IconPath
);
239 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->mimes
)
241 MSIMIME
*mt
= LIST_ENTRY( item
, MSIMIME
, entry
);
243 list_remove( &mt
->entry
);
244 msi_free( mt
->suffix
);
245 msi_free( mt
->clsid
);
246 msi_free( mt
->ContentType
);
250 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->appids
)
252 MSIAPPID
*appid
= LIST_ENTRY( item
, MSIAPPID
, entry
);
254 list_remove( &appid
->entry
);
255 msi_free( appid
->AppID
);
256 msi_free( appid
->RemoteServerName
);
257 msi_free( appid
->LocalServer
);
258 msi_free( appid
->ServiceParameters
);
259 msi_free( appid
->DllSurrogate
);
263 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->sourcelist_info
)
265 MSISOURCELISTINFO
*info
= LIST_ENTRY( item
, MSISOURCELISTINFO
, entry
);
267 list_remove( &info
->entry
);
268 msi_free( info
->value
);
272 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->sourcelist_media
)
274 MSIMEDIADISK
*info
= LIST_ENTRY( item
, MSIMEDIADISK
, entry
);
276 list_remove( &info
->entry
);
277 msi_free( info
->volume_label
);
278 msi_free( info
->disk_prompt
);
282 for (i
= 0; i
< SCRIPT_MAX
; i
++)
283 msi_free_action_script( package
, i
);
285 for (i
= 0; i
< package
->unique_actions_count
; i
++)
286 msi_free( package
->unique_actions
[i
] );
287 msi_free( package
->unique_actions
);
289 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->binaries
)
291 MSIBINARY
*binary
= LIST_ENTRY( item
, MSIBINARY
, entry
);
293 list_remove( &binary
->entry
);
294 if (!DeleteFileW( binary
->tmpfile
))
295 ERR("failed to delete %s (%u)\n", debugstr_w(binary
->tmpfile
), GetLastError());
296 msi_free( binary
->source
);
297 msi_free( binary
->tmpfile
);
301 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->cabinet_streams
)
303 MSICABINETSTREAM
*cab
= LIST_ENTRY( item
, MSICABINETSTREAM
, entry
);
305 list_remove( &cab
->entry
);
306 IStorage_Release( cab
->storage
);
307 msi_free( cab
->stream
);
311 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->patches
)
313 MSIPATCHINFO
*patch
= LIST_ENTRY( item
, MSIPATCHINFO
, entry
);
315 list_remove( &patch
->entry
);
316 if (patch
->delete_on_close
&& !DeleteFileW( patch
->localfile
))
318 ERR("failed to delete %s (%u)\n", debugstr_w(patch
->localfile
), GetLastError());
320 msi_free_patchinfo( patch
);
323 msi_free( package
->PackagePath
);
324 msi_free( package
->ProductCode
);
325 msi_free( package
->ActionFormat
);
326 msi_free( package
->LastAction
);
327 msi_free( package
->LastActionTemplate
);
328 msi_free( package
->langids
);
330 /* cleanup control event subscriptions */
331 msi_event_cleanup_all_subscriptions( package
);
334 static void MSI_FreePackage( MSIOBJECTHDR
*arg
)
336 MSIPACKAGE
*package
= (MSIPACKAGE
*)arg
;
338 msi_destroy_assembly_caches( package
);
340 if( package
->dialog
)
341 msi_dialog_destroy( package
->dialog
);
343 msiobj_release( &package
->db
->hdr
);
344 free_package_structures(package
);
345 CloseHandle( package
->log_file
);
346 if (package
->rpc_server_started
)
347 RpcServerUnregisterIf(s_IWineMsiRemote_v0_0_s_ifspec
, NULL
, FALSE
);
349 RpcBindingFree(&rpc_handle
);
350 if (package
->custom_server_32_process
)
351 custom_stop_server(package
->custom_server_32_process
, package
->custom_server_32_pipe
);
352 if (package
->custom_server_64_process
)
353 custom_stop_server(package
->custom_server_64_process
, package
->custom_server_64_pipe
);
355 if (package
->delete_on_close
) DeleteFileW( package
->localfile
);
356 msi_free( package
->localfile
);
357 MSI_ProcessMessage(NULL
, INSTALLMESSAGE_TERMINATE
, 0);
360 static UINT
create_temp_property_table(MSIPACKAGE
*package
)
362 static const WCHAR query
[] = {
363 'C','R','E','A','T','E',' ','T','A','B','L','E',' ',
364 '`','_','P','r','o','p','e','r','t','y','`',' ','(',' ',
365 '`','_','P','r','o','p','e','r','t','y','`',' ',
366 'C','H','A','R','(','5','6',')',' ','N','O','T',' ','N','U','L','L',' ',
367 'T','E','M','P','O','R','A','R','Y',',',' ',
368 '`','V','a','l','u','e','`',' ','C','H','A','R','(','9','8',')',' ',
369 'N','O','T',' ','N','U','L','L',' ','T','E','M','P','O','R','A','R','Y',
370 ' ','P','R','I','M','A','R','Y',' ','K','E','Y',' ',
371 '`','_','P','r','o','p','e','r','t','y','`',')',' ','H','O','L','D',0};
375 rc
= MSI_DatabaseOpenViewW(package
->db
, query
, &view
);
376 if (rc
!= ERROR_SUCCESS
)
379 rc
= MSI_ViewExecute(view
, 0);
381 msiobj_release(&view
->hdr
);
385 UINT
msi_clone_properties( MSIDATABASE
*db
)
387 static const WCHAR query_select
[] = {
388 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
389 '`','P','r','o','p','e','r','t','y','`',0};
390 static const WCHAR query_insert
[] = {
391 'I','N','S','E','R','T',' ','I','N','T','O',' ',
392 '`','_','P','r','o','p','e','r','t','y','`',' ',
393 '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
394 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
395 static const WCHAR query_update
[] = {
396 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
397 'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ',
398 'W','H','E','R','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','?',0};
399 MSIQUERY
*view_select
;
402 rc
= MSI_DatabaseOpenViewW( db
, query_select
, &view_select
);
403 if (rc
!= ERROR_SUCCESS
)
406 rc
= MSI_ViewExecute( view_select
, 0 );
407 if (rc
!= ERROR_SUCCESS
)
409 MSI_ViewClose( view_select
);
410 msiobj_release( &view_select
->hdr
);
416 MSIQUERY
*view_insert
, *view_update
;
417 MSIRECORD
*rec_select
;
419 rc
= MSI_ViewFetch( view_select
, &rec_select
);
420 if (rc
!= ERROR_SUCCESS
)
423 rc
= MSI_DatabaseOpenViewW( db
, query_insert
, &view_insert
);
424 if (rc
!= ERROR_SUCCESS
)
426 msiobj_release( &rec_select
->hdr
);
430 rc
= MSI_ViewExecute( view_insert
, rec_select
);
431 MSI_ViewClose( view_insert
);
432 msiobj_release( &view_insert
->hdr
);
433 if (rc
!= ERROR_SUCCESS
)
435 MSIRECORD
*rec_update
;
437 TRACE("insert failed, trying update\n");
439 rc
= MSI_DatabaseOpenViewW( db
, query_update
, &view_update
);
440 if (rc
!= ERROR_SUCCESS
)
442 WARN("open view failed %u\n", rc
);
443 msiobj_release( &rec_select
->hdr
);
447 rec_update
= MSI_CreateRecord( 2 );
448 MSI_RecordCopyField( rec_select
, 1, rec_update
, 2 );
449 MSI_RecordCopyField( rec_select
, 2, rec_update
, 1 );
450 rc
= MSI_ViewExecute( view_update
, rec_update
);
451 if (rc
!= ERROR_SUCCESS
)
452 WARN("update failed %u\n", rc
);
454 MSI_ViewClose( view_update
);
455 msiobj_release( &view_update
->hdr
);
456 msiobj_release( &rec_update
->hdr
);
459 msiobj_release( &rec_select
->hdr
);
462 MSI_ViewClose( view_select
);
463 msiobj_release( &view_select
->hdr
);
470 * Sets the "Installed" property to indicate that
471 * the product is installed for the current user.
473 static UINT
set_installed_prop( MSIPACKAGE
*package
)
478 if (!package
->ProductCode
) return ERROR_FUNCTION_FAILED
;
480 r
= MSIREG_OpenUninstallKey( package
->ProductCode
, package
->platform
, &hkey
, FALSE
);
481 if (r
== ERROR_SUCCESS
)
484 msi_set_property( package
->db
, szInstalled
, szOne
, -1 );
489 static UINT
set_user_sid_prop( MSIPACKAGE
*package
)
493 LPWSTR sid_str
= NULL
, dom
= NULL
;
494 DWORD size
, dom_size
;
496 UINT r
= ERROR_FUNCTION_FAILED
;
499 GetUserNameW( NULL
, &size
);
501 user_name
= msi_alloc( (size
+ 1) * sizeof(WCHAR
) );
503 return ERROR_OUTOFMEMORY
;
505 if (!GetUserNameW( user_name
, &size
))
510 LookupAccountNameW( NULL
, user_name
, NULL
, &size
, NULL
, &dom_size
, &use
);
512 psid
= msi_alloc( size
);
513 dom
= msi_alloc( dom_size
*sizeof (WCHAR
) );
516 r
= ERROR_OUTOFMEMORY
;
520 if (!LookupAccountNameW( NULL
, user_name
, psid
, &size
, dom
, &dom_size
, &use
))
523 if (!ConvertSidToStringSidW( psid
, &sid_str
))
526 r
= msi_set_property( package
->db
, szUserSID
, sid_str
, -1 );
529 LocalFree( sid_str
);
532 msi_free( user_name
);
537 static LPWSTR
get_fusion_filename(MSIPACKAGE
*package
)
539 static const WCHAR fusion
[] =
540 {'f','u','s','i','o','n','.','d','l','l',0};
541 static const WCHAR subkey
[] =
542 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
543 'N','E','T',' ','F','r','a','m','e','w','o','r','k',' ','S','e','t','u','p','\\','N','D','P',0};
544 static const WCHAR subdir
[] =
545 {'M','i','c','r','o','s','o','f','t','.','N','E','T','\\','F','r','a','m','e','w','o','r','k','\\',0};
546 static const WCHAR v2050727
[] =
547 {'v','2','.','0','.','5','0','7','2','7',0};
548 static const WCHAR v4client
[] =
549 {'v','4','\\','C','l','i','e','n','t',0};
550 static const WCHAR installpath
[] =
551 {'I','n','s','t','a','l','l','P','a','t','h',0};
554 DWORD size
, len
, type
;
555 WCHAR windir
[MAX_PATH
], path
[MAX_PATH
], *filename
= NULL
;
557 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, subkey
, 0, KEY_CREATE_SUB_KEY
, &netsetup
);
558 if (res
!= ERROR_SUCCESS
)
561 if (!RegCreateKeyExW(netsetup
, v4client
, 0, NULL
, 0, KEY_QUERY_VALUE
, NULL
, &hkey
, NULL
))
563 size
= ARRAY_SIZE(path
);
564 if (!RegQueryValueExW(hkey
, installpath
, NULL
, &type
, (BYTE
*)path
, &size
))
566 len
= strlenW(path
) + strlenW(fusion
) + 2;
567 if (!(filename
= msi_alloc(len
* sizeof(WCHAR
)))) return NULL
;
569 strcpyW(filename
, path
);
570 strcatW(filename
, szBackSlash
);
571 strcatW(filename
, fusion
);
572 if (GetFileAttributesW(filename
) != INVALID_FILE_ATTRIBUTES
)
574 TRACE( "found %s\n", debugstr_w(filename
) );
576 RegCloseKey(netsetup
);
583 if (!RegCreateKeyExW(netsetup
, v2050727
, 0, NULL
, 0, KEY_QUERY_VALUE
, NULL
, &hkey
, NULL
))
586 GetWindowsDirectoryW(windir
, MAX_PATH
);
587 len
= strlenW(windir
) + strlenW(subdir
) + strlenW(v2050727
) + strlenW(fusion
) + 3;
588 if (!(filename
= msi_alloc(len
* sizeof(WCHAR
)))) return NULL
;
590 strcpyW(filename
, windir
);
591 strcatW(filename
, szBackSlash
);
592 strcatW(filename
, subdir
);
593 strcatW(filename
, v2050727
);
594 strcatW(filename
, szBackSlash
);
595 strcatW(filename
, fusion
);
596 if (GetFileAttributesW(filename
) != INVALID_FILE_ATTRIBUTES
)
598 TRACE( "found %s\n", debugstr_w(filename
) );
599 RegCloseKey(netsetup
);
604 RegCloseKey(netsetup
);
608 typedef struct tagLANGANDCODEPAGE
614 static void set_msi_assembly_prop(MSIPACKAGE
*package
)
618 LPVOID version
= NULL
;
620 LPWSTR fusion
, verstr
;
621 LANGANDCODEPAGE
*translate
;
623 static const WCHAR netasm
[] = {
624 'M','s','i','N','e','t','A','s','s','e','m','b','l','y','S','u','p','p','o','r','t',0
626 static const WCHAR translation
[] = {
627 '\\','V','a','r','F','i','l','e','I','n','f','o',
628 '\\','T','r','a','n','s','l','a','t','i','o','n',0
630 static const WCHAR verfmt
[] = {
631 '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
632 '\\','%','0','4','x','%','0','4','x',
633 '\\','P','r','o','d','u','c','t','V','e','r','s','i','o','n',0
636 fusion
= get_fusion_filename(package
);
640 size
= GetFileVersionInfoSizeW(fusion
, &handle
);
644 version
= msi_alloc(size
);
648 if (!GetFileVersionInfoW(fusion
, handle
, size
, version
))
651 if (!VerQueryValueW(version
, translation
, (LPVOID
*)&translate
, &val_len
))
654 sprintfW(buf
, verfmt
, translate
[0].wLanguage
, translate
[0].wCodePage
);
656 if (!VerQueryValueW(version
, buf
, (LPVOID
*)&verstr
, &val_len
))
659 if (!val_len
|| !verstr
)
662 msi_set_property( package
->db
, netasm
, verstr
, -1 );
669 static VOID
set_installer_properties(MSIPACKAGE
*package
)
672 OSVERSIONINFOEXW OSVersion
;
674 DWORD verval
, len
, type
;
675 WCHAR pth
[MAX_PATH
], verstr
[11], bufstr
[22];
678 LPWSTR username
, companyname
;
679 SYSTEM_INFO sys_info
;
682 static const WCHAR szCommonFilesFolder
[] = {'C','o','m','m','o','n','F','i','l','e','s','F','o','l','d','e','r',0};
683 static const WCHAR szProgramFilesFolder
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','F','o','l','d','e','r',0};
684 static const WCHAR szCommonAppDataFolder
[] = {'C','o','m','m','o','n','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
685 static const WCHAR szFavoritesFolder
[] = {'F','a','v','o','r','i','t','e','s','F','o','l','d','e','r',0};
686 static const WCHAR szFontsFolder
[] = {'F','o','n','t','s','F','o','l','d','e','r',0};
687 static const WCHAR szSendToFolder
[] = {'S','e','n','d','T','o','F','o','l','d','e','r',0};
688 static const WCHAR szStartMenuFolder
[] = {'S','t','a','r','t','M','e','n','u','F','o','l','d','e','r',0};
689 static const WCHAR szStartupFolder
[] = {'S','t','a','r','t','u','p','F','o','l','d','e','r',0};
690 static const WCHAR szTemplateFolder
[] = {'T','e','m','p','l','a','t','e','F','o','l','d','e','r',0};
691 static const WCHAR szDesktopFolder
[] = {'D','e','s','k','t','o','p','F','o','l','d','e','r',0};
692 static const WCHAR szProgramMenuFolder
[] = {'P','r','o','g','r','a','m','M','e','n','u','F','o','l','d','e','r',0};
693 static const WCHAR szAdminToolsFolder
[] = {'A','d','m','i','n','T','o','o','l','s','F','o','l','d','e','r',0};
694 static const WCHAR szSystemFolder
[] = {'S','y','s','t','e','m','F','o','l','d','e','r',0};
695 static const WCHAR szSystem16Folder
[] = {'S','y','s','t','e','m','1','6','F','o','l','d','e','r',0};
696 static const WCHAR szLocalAppDataFolder
[] = {'L','o','c','a','l','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
697 static const WCHAR szMyPicturesFolder
[] = {'M','y','P','i','c','t','u','r','e','s','F','o','l','d','e','r',0};
698 static const WCHAR szPersonalFolder
[] = {'P','e','r','s','o','n','a','l','F','o','l','d','e','r',0};
699 static const WCHAR szWindowsVolume
[] = {'W','i','n','d','o','w','s','V','o','l','u','m','e',0};
700 static const WCHAR szPrivileged
[] = {'P','r','i','v','i','l','e','g','e','d',0};
701 static const WCHAR szVersion9x
[] = {'V','e','r','s','i','o','n','9','X',0};
702 static const WCHAR szVersionNT
[] = {'V','e','r','s','i','o','n','N','T',0};
703 static const WCHAR szMsiNTProductType
[] = {'M','s','i','N','T','P','r','o','d','u','c','t','T','y','p','e',0};
704 static const WCHAR szFormat
[] = {'%','u',0};
705 static const WCHAR szFormat2
[] = {'%','u','.','%','u',0};
706 static const WCHAR szWindowsBuild
[] = {'W','i','n','d','o','w','s','B','u','i','l','d',0};
707 static const WCHAR szServicePackLevel
[] = {'S','e','r','v','i','c','e','P','a','c','k','L','e','v','e','l',0};
708 static const WCHAR szVersionMsi
[] = { 'V','e','r','s','i','o','n','M','s','i',0 };
709 static const WCHAR szVersionDatabase
[] = { 'V','e','r','s','i','o','n','D','a','t','a','b','a','s','e',0 };
710 static const WCHAR szPhysicalMemory
[] = { 'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0 };
711 static const WCHAR szScreenX
[] = {'S','c','r','e','e','n','X',0};
712 static const WCHAR szScreenY
[] = {'S','c','r','e','e','n','Y',0};
713 static const WCHAR szColorBits
[] = {'C','o','l','o','r','B','i','t','s',0};
714 static const WCHAR szIntFormat
[] = {'%','d',0};
715 static const WCHAR szMsiAMD64
[] = { 'M','s','i','A','M','D','6','4',0 };
716 static const WCHAR szMsix64
[] = { 'M','s','i','x','6','4',0 };
717 static const WCHAR szSystem64Folder
[] = { 'S','y','s','t','e','m','6','4','F','o','l','d','e','r',0 };
718 static const WCHAR szCommonFiles64Folder
[] = { 'C','o','m','m','o','n','F','i','l','e','s','6','4','F','o','l','d','e','r',0 };
719 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 };
720 static const WCHAR szProgramFilesDir
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',0};
721 static const WCHAR szProgramFilesDirx86
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')',0};
722 static const WCHAR szCommonFilesDir
[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r',0};
723 static const WCHAR szCommonFilesDirx86
[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r',' ','(','x','8','6',')',0};
724 static const WCHAR szVersionNT64
[] = { 'V','e','r','s','i','o','n','N','T','6','4',0 };
725 static const WCHAR szUserInfo
[] = {
726 'S','O','F','T','W','A','R','E','\\',
727 'M','i','c','r','o','s','o','f','t','\\',
728 'M','S',' ','S','e','t','u','p',' ','(','A','C','M','E',')','\\',
729 'U','s','e','r',' ','I','n','f','o',0
731 static const WCHAR szDefName
[] = { 'D','e','f','N','a','m','e',0 };
732 static const WCHAR szDefCompany
[] = { 'D','e','f','C','o','m','p','a','n','y',0 };
733 static const WCHAR szCurrentVersion
[] = {
734 'S','O','F','T','W','A','R','E','\\',
735 'M','i','c','r','o','s','o','f','t','\\',
736 'W','i','n','d','o','w','s','\\',
737 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0
739 static const WCHAR szCurrentVersionNT
[] = {
740 'S','O','F','T','W','A','R','E','\\',
741 'M','i','c','r','o','s','o','f','t','\\',
742 'W','i','n','d','o','w','s',' ','N','T','\\',
743 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0
745 static const WCHAR szRegisteredUser
[] = {'R','e','g','i','s','t','e','r','e','d','O','w','n','e','r',0};
746 static const WCHAR szRegisteredOrganization
[] = {
747 'R','e','g','i','s','t','e','r','e','d','O','r','g','a','n','i','z','a','t','i','o','n',0
749 static const WCHAR szUSERNAME
[] = {'U','S','E','R','N','A','M','E',0};
750 static const WCHAR szCOMPANYNAME
[] = {'C','O','M','P','A','N','Y','N','A','M','E',0};
751 static const WCHAR szUserLanguageID
[] = {'U','s','e','r','L','a','n','g','u','a','g','e','I','D',0};
752 static const WCHAR szSystemLangID
[] = {'S','y','s','t','e','m','L','a','n','g','u','a','g','e','I','D',0};
753 static const WCHAR szProductState
[] = {'P','r','o','d','u','c','t','S','t','a','t','e',0};
754 static const WCHAR szLogonUser
[] = {'L','o','g','o','n','U','s','e','r',0};
755 static const WCHAR szNetHoodFolder
[] = {'N','e','t','H','o','o','d','F','o','l','d','e','r',0};
756 static const WCHAR szPrintHoodFolder
[] = {'P','r','i','n','t','H','o','o','d','F','o','l','d','e','r',0};
757 static const WCHAR szRecentFolder
[] = {'R','e','c','e','n','t','F','o','l','d','e','r',0};
758 static const WCHAR szComputerName
[] = {'C','o','m','p','u','t','e','r','N','a','m','e',0};
761 * Other things that probably should be set:
763 * VirtualMemory ShellAdvSupport DefaultUIFont PackagecodeChanging
764 * CaptionHeight BorderTop BorderSide TextHeight RedirectedDllSupport
767 SHGetFolderPathW(NULL
, CSIDL_COMMON_APPDATA
, NULL
, 0, pth
);
768 strcatW(pth
, szBackSlash
);
769 msi_set_property( package
->db
, szCommonAppDataFolder
, pth
, -1 );
771 SHGetFolderPathW(NULL
, CSIDL_FAVORITES
, NULL
, 0, pth
);
772 strcatW(pth
, szBackSlash
);
773 msi_set_property( package
->db
, szFavoritesFolder
, pth
, -1 );
775 SHGetFolderPathW(NULL
, CSIDL_FONTS
, NULL
, 0, pth
);
776 strcatW(pth
, szBackSlash
);
777 msi_set_property( package
->db
, szFontsFolder
, pth
, -1 );
779 SHGetFolderPathW(NULL
, CSIDL_SENDTO
, NULL
, 0, pth
);
780 strcatW(pth
, szBackSlash
);
781 msi_set_property( package
->db
, szSendToFolder
, pth
, -1 );
783 SHGetFolderPathW(NULL
, CSIDL_STARTMENU
, NULL
, 0, pth
);
784 strcatW(pth
, szBackSlash
);
785 msi_set_property( package
->db
, szStartMenuFolder
, pth
, -1 );
787 SHGetFolderPathW(NULL
, CSIDL_STARTUP
, NULL
, 0, pth
);
788 strcatW(pth
, szBackSlash
);
789 msi_set_property( package
->db
, szStartupFolder
, pth
, -1 );
791 SHGetFolderPathW(NULL
, CSIDL_TEMPLATES
, NULL
, 0, pth
);
792 strcatW(pth
, szBackSlash
);
793 msi_set_property( package
->db
, szTemplateFolder
, pth
, -1 );
795 SHGetFolderPathW(NULL
, CSIDL_DESKTOP
, NULL
, 0, pth
);
796 strcatW(pth
, szBackSlash
);
797 msi_set_property( package
->db
, szDesktopFolder
, pth
, -1 );
799 /* FIXME: set to AllUsers profile path if ALLUSERS is set */
800 SHGetFolderPathW(NULL
, CSIDL_PROGRAMS
, NULL
, 0, pth
);
801 strcatW(pth
, szBackSlash
);
802 msi_set_property( package
->db
, szProgramMenuFolder
, pth
, -1 );
804 SHGetFolderPathW(NULL
, CSIDL_ADMINTOOLS
, NULL
, 0, pth
);
805 strcatW(pth
, szBackSlash
);
806 msi_set_property( package
->db
, szAdminToolsFolder
, pth
, -1 );
808 SHGetFolderPathW(NULL
, CSIDL_APPDATA
, NULL
, 0, pth
);
809 strcatW(pth
, szBackSlash
);
810 msi_set_property( package
->db
, szAppDataFolder
, pth
, -1 );
812 SHGetFolderPathW(NULL
, CSIDL_SYSTEM
, NULL
, 0, pth
);
813 strcatW(pth
, szBackSlash
);
814 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
815 msi_set_property( package
->db
, szSystem16Folder
, pth
, -1 );
817 SHGetFolderPathW(NULL
, CSIDL_LOCAL_APPDATA
, NULL
, 0, pth
);
818 strcatW(pth
, szBackSlash
);
819 msi_set_property( package
->db
, szLocalAppDataFolder
, pth
, -1 );
821 SHGetFolderPathW(NULL
, CSIDL_MYPICTURES
, NULL
, 0, pth
);
822 strcatW(pth
, szBackSlash
);
823 msi_set_property( package
->db
, szMyPicturesFolder
, pth
, -1 );
825 SHGetFolderPathW(NULL
, CSIDL_PERSONAL
, NULL
, 0, pth
);
826 strcatW(pth
, szBackSlash
);
827 msi_set_property( package
->db
, szPersonalFolder
, pth
, -1 );
829 SHGetFolderPathW(NULL
, CSIDL_WINDOWS
, NULL
, 0, pth
);
830 strcatW(pth
, szBackSlash
);
831 msi_set_property( package
->db
, szWindowsFolder
, pth
, -1 );
833 SHGetFolderPathW(NULL
, CSIDL_PRINTHOOD
, NULL
, 0, pth
);
834 strcatW(pth
, szBackSlash
);
835 msi_set_property( package
->db
, szPrintHoodFolder
, pth
, -1 );
837 SHGetFolderPathW(NULL
, CSIDL_NETHOOD
, NULL
, 0, pth
);
838 strcatW(pth
, szBackSlash
);
839 msi_set_property( package
->db
, szNetHoodFolder
, pth
, -1 );
841 SHGetFolderPathW(NULL
, CSIDL_RECENT
, NULL
, 0, pth
);
842 strcatW(pth
, szBackSlash
);
843 msi_set_property( package
->db
, szRecentFolder
, pth
, -1 );
845 /* Physical Memory is specified in MB. Using total amount. */
846 msex
.dwLength
= sizeof(msex
);
847 GlobalMemoryStatusEx( &msex
);
848 len
= sprintfW( bufstr
, szIntFormat
, (int)(msex
.ullTotalPhys
/ 1024 / 1024) );
849 msi_set_property( package
->db
, szPhysicalMemory
, bufstr
, len
);
851 SHGetFolderPathW(NULL
, CSIDL_WINDOWS
, NULL
, 0, pth
);
852 ptr
= strchrW(pth
,'\\');
853 if (ptr
) *(ptr
+ 1) = 0;
854 msi_set_property( package
->db
, szWindowsVolume
, pth
, -1 );
856 len
= GetTempPathW(MAX_PATH
, pth
);
857 msi_set_property( package
->db
, szTempFolder
, pth
, len
);
859 /* in a wine environment the user is always admin and privileged */
860 msi_set_property( package
->db
, szAdminUser
, szOne
, -1 );
861 msi_set_property( package
->db
, szPrivileged
, szOne
, -1 );
863 /* set the os things */
864 OSVersion
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
865 GetVersionExW((OSVERSIONINFOW
*)&OSVersion
);
866 verval
= OSVersion
.dwMinorVersion
+ OSVersion
.dwMajorVersion
* 100;
867 len
= sprintfW( verstr
, szFormat
, verval
);
868 switch (OSVersion
.dwPlatformId
)
870 case VER_PLATFORM_WIN32_WINDOWS
:
871 msi_set_property( package
->db
, szVersion9x
, verstr
, len
);
873 case VER_PLATFORM_WIN32_NT
:
874 msi_set_property( package
->db
, szVersionNT
, verstr
, len
);
875 len
= sprintfW( bufstr
, szFormat
,OSVersion
.wProductType
);
876 msi_set_property( package
->db
, szMsiNTProductType
, bufstr
, len
);
879 len
= sprintfW( bufstr
, szFormat
, OSVersion
.dwBuildNumber
);
880 msi_set_property( package
->db
, szWindowsBuild
, bufstr
, len
);
881 len
= sprintfW( bufstr
, szFormat
, OSVersion
.wServicePackMajor
);
882 msi_set_property( package
->db
, szServicePackLevel
, bufstr
, len
);
884 len
= sprintfW( bufstr
, szFormat2
, MSI_MAJORVERSION
, MSI_MINORVERSION
);
885 msi_set_property( package
->db
, szVersionMsi
, bufstr
, len
);
886 len
= sprintfW( bufstr
, szFormat
, MSI_MAJORVERSION
* 100 );
887 msi_set_property( package
->db
, szVersionDatabase
, bufstr
, len
);
889 RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szCurrentVersion
, 0,
890 KEY_QUERY_VALUE
| KEY_WOW64_64KEY
, &hkey
);
892 GetNativeSystemInfo( &sys_info
);
893 len
= sprintfW( bufstr
, szIntFormat
, sys_info
.wProcessorLevel
);
894 msi_set_property( package
->db
, szIntel
, bufstr
, len
);
895 if (sys_info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
897 GetSystemDirectoryW( pth
, MAX_PATH
);
898 PathAddBackslashW( pth
);
899 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
902 RegQueryValueExW(hkey
, szProgramFilesDir
, 0, &type
, (BYTE
*)pth
, &len
);
903 PathAddBackslashW( pth
);
904 msi_set_property( package
->db
, szProgramFilesFolder
, pth
, -1 );
907 RegQueryValueExW(hkey
, szCommonFilesDir
, 0, &type
, (BYTE
*)pth
, &len
);
908 PathAddBackslashW( pth
);
909 msi_set_property( package
->db
, szCommonFilesFolder
, pth
, -1 );
911 else if (sys_info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
)
913 msi_set_property( package
->db
, szMsiAMD64
, bufstr
, -1 );
914 msi_set_property( package
->db
, szMsix64
, bufstr
, -1 );
915 msi_set_property( package
->db
, szVersionNT64
, verstr
, -1 );
917 GetSystemDirectoryW( pth
, MAX_PATH
);
918 PathAddBackslashW( pth
);
919 msi_set_property( package
->db
, szSystem64Folder
, pth
, -1 );
921 GetSystemWow64DirectoryW( pth
, MAX_PATH
);
922 PathAddBackslashW( pth
);
923 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
926 RegQueryValueExW(hkey
, szProgramFilesDir
, 0, &type
, (BYTE
*)pth
, &len
);
927 PathAddBackslashW( pth
);
928 msi_set_property( package
->db
, szProgramFiles64Folder
, pth
, -1 );
931 RegQueryValueExW(hkey
, szProgramFilesDirx86
, 0, &type
, (BYTE
*)pth
, &len
);
932 PathAddBackslashW( pth
);
933 msi_set_property( package
->db
, szProgramFilesFolder
, pth
, -1 );
936 RegQueryValueExW(hkey
, szCommonFilesDir
, 0, &type
, (BYTE
*)pth
, &len
);
937 PathAddBackslashW( pth
);
938 msi_set_property( package
->db
, szCommonFiles64Folder
, pth
, -1 );
941 RegQueryValueExW(hkey
, szCommonFilesDirx86
, 0, &type
, (BYTE
*)pth
, &len
);
942 PathAddBackslashW( pth
);
943 msi_set_property( package
->db
, szCommonFilesFolder
, pth
, -1 );
948 /* Screen properties. */
950 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, HORZRES
) );
951 msi_set_property( package
->db
, szScreenX
, bufstr
, len
);
952 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, VERTRES
) );
953 msi_set_property( package
->db
, szScreenY
, bufstr
, len
);
954 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, BITSPIXEL
) );
955 msi_set_property( package
->db
, szColorBits
, bufstr
, len
);
958 /* USERNAME and COMPANYNAME */
959 username
= msi_dup_property( package
->db
, szUSERNAME
);
960 companyname
= msi_dup_property( package
->db
, szCOMPANYNAME
);
962 if ((!username
|| !companyname
) &&
963 RegOpenKeyW( HKEY_CURRENT_USER
, szUserInfo
, &hkey
) == ERROR_SUCCESS
)
966 (username
= msi_reg_get_val_str( hkey
, szDefName
)))
967 msi_set_property( package
->db
, szUSERNAME
, username
, -1 );
969 (companyname
= msi_reg_get_val_str( hkey
, szDefCompany
)))
970 msi_set_property( package
->db
, szCOMPANYNAME
, companyname
, -1 );
973 if ((!username
|| !companyname
) &&
974 RegOpenKeyW( HKEY_LOCAL_MACHINE
, szCurrentVersionNT
, &hkey
) == ERROR_SUCCESS
)
977 (username
= msi_reg_get_val_str( hkey
, szRegisteredUser
)))
978 msi_set_property( package
->db
, szUSERNAME
, username
, -1 );
980 (companyname
= msi_reg_get_val_str( hkey
, szRegisteredOrganization
)))
981 msi_set_property( package
->db
, szCOMPANYNAME
, companyname
, -1 );
984 msi_free( username
);
985 msi_free( companyname
);
987 if ( set_user_sid_prop( package
) != ERROR_SUCCESS
)
988 ERR("Failed to set the UserSID property\n");
990 set_msi_assembly_prop( package
);
992 langid
= GetUserDefaultLangID();
993 len
= sprintfW( bufstr
, szIntFormat
, langid
);
994 msi_set_property( package
->db
, szUserLanguageID
, bufstr
, len
);
996 langid
= GetSystemDefaultLangID();
997 len
= sprintfW( bufstr
, szIntFormat
, langid
);
998 msi_set_property( package
->db
, szSystemLangID
, bufstr
, len
);
1000 len
= sprintfW( bufstr
, szIntFormat
, MsiQueryProductStateW(package
->ProductCode
) );
1001 msi_set_property( package
->db
, szProductState
, bufstr
, len
);
1004 if (!GetUserNameW( NULL
, &len
) && GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
1007 if ((username
= msi_alloc( len
* sizeof(WCHAR
) )))
1009 if (GetUserNameW( username
, &len
))
1010 msi_set_property( package
->db
, szLogonUser
, username
, len
- 1 );
1011 msi_free( username
);
1015 if (!GetComputerNameW( NULL
, &len
) && GetLastError() == ERROR_BUFFER_OVERFLOW
)
1017 WCHAR
*computername
;
1018 if ((computername
= msi_alloc( len
* sizeof(WCHAR
) )))
1020 if (GetComputerNameW( computername
, &len
))
1021 msi_set_property( package
->db
, szComputerName
, computername
, len
);
1022 msi_free( computername
);
1027 static MSIPACKAGE
*msi_alloc_package( void )
1029 MSIPACKAGE
*package
;
1031 package
= alloc_msiobject( MSIHANDLETYPE_PACKAGE
, sizeof (MSIPACKAGE
),
1035 list_init( &package
->components
);
1036 list_init( &package
->features
);
1037 list_init( &package
->files
);
1038 list_init( &package
->filepatches
);
1039 list_init( &package
->tempfiles
);
1040 list_init( &package
->folders
);
1041 list_init( &package
->subscriptions
);
1042 list_init( &package
->appids
);
1043 list_init( &package
->classes
);
1044 list_init( &package
->mimes
);
1045 list_init( &package
->extensions
);
1046 list_init( &package
->progids
);
1047 list_init( &package
->RunningActions
);
1048 list_init( &package
->sourcelist_info
);
1049 list_init( &package
->sourcelist_media
);
1050 list_init( &package
->patches
);
1051 list_init( &package
->binaries
);
1052 list_init( &package
->cabinet_streams
);
1058 static UINT
msi_load_admin_properties(MSIPACKAGE
*package
)
1063 static const WCHAR stmname
[] = {'A','d','m','i','n','P','r','o','p','e','r','t','i','e','s',0};
1065 r
= read_stream_data(package
->db
->storage
, stmname
, FALSE
, &data
, &sz
);
1066 if (r
!= ERROR_SUCCESS
)
1069 r
= msi_parse_command_line(package
, (WCHAR
*)data
, TRUE
);
1075 void msi_adjust_privilege_properties( MSIPACKAGE
*package
)
1077 /* FIXME: this should depend on the user's privileges */
1078 if (msi_get_property_int( package
->db
, szAllUsers
, 0 ) == 2)
1080 TRACE("resetting ALLUSERS property from 2 to 1\n");
1081 msi_set_property( package
->db
, szAllUsers
, szOne
, -1 );
1083 msi_set_property( package
->db
, szAdminUser
, szOne
, -1 );
1086 MSIPACKAGE
*MSI_CreatePackage( MSIDATABASE
*db
)
1088 static const WCHAR fmtW
[] = {'%','u',0};
1089 MSIPACKAGE
*package
;
1096 package
= msi_alloc_package();
1099 msiobj_addref( &db
->hdr
);
1102 package
->LastAction
= NULL
;
1103 package
->LastActionTemplate
= NULL
;
1104 package
->LastActionResult
= MSI_NULL_INTEGER
;
1105 package
->WordCount
= 0;
1106 package
->PackagePath
= strdupW( db
->path
);
1108 create_temp_property_table( package
);
1109 msi_clone_properties( package
->db
);
1110 msi_adjust_privilege_properties( package
);
1112 package
->ProductCode
= msi_dup_property( package
->db
, szProductCode
);
1114 set_installer_properties( package
);
1116 package
->ui_level
= gUILevel
;
1117 len
= sprintfW( uilevel
, fmtW
, gUILevel
& INSTALLUILEVEL_MASK
);
1118 msi_set_property( package
->db
, szUILevel
, uilevel
, len
);
1120 r
= msi_load_suminfo_properties( package
);
1121 if (r
!= ERROR_SUCCESS
)
1123 msiobj_release( &package
->hdr
);
1127 if (package
->WordCount
& msidbSumInfoSourceTypeAdminImage
)
1128 msi_load_admin_properties( package
);
1130 package
->log_file
= INVALID_HANDLE_VALUE
;
1131 package
->script
= SCRIPT_NONE
;
1136 UINT
msi_download_file( LPCWSTR szUrl
, LPWSTR filename
)
1138 LPINTERNET_CACHE_ENTRY_INFOW cache_entry
;
1142 /* call will always fail, because size is 0,
1143 * but will return ERROR_FILE_NOT_FOUND first
1144 * if the file doesn't exist
1146 GetUrlCacheEntryInfoW( szUrl
, NULL
, &size
);
1147 if ( GetLastError() != ERROR_FILE_NOT_FOUND
)
1149 cache_entry
= msi_alloc( size
);
1150 if ( !GetUrlCacheEntryInfoW( szUrl
, cache_entry
, &size
) )
1152 UINT error
= GetLastError();
1153 msi_free( cache_entry
);
1157 lstrcpyW( filename
, cache_entry
->lpszLocalFileName
);
1158 msi_free( cache_entry
);
1159 return ERROR_SUCCESS
;
1162 hr
= URLDownloadToCacheFileW( NULL
, szUrl
, filename
, MAX_PATH
, 0, NULL
);
1165 WARN("failed to download %s to cache file\n", debugstr_w(szUrl
));
1166 return ERROR_FUNCTION_FAILED
;
1169 return ERROR_SUCCESS
;
1172 UINT
msi_create_empty_local_file( LPWSTR path
, LPCWSTR suffix
)
1174 static const WCHAR szInstaller
[] = {
1175 '\\','I','n','s','t','a','l','l','e','r','\\',0};
1176 static const WCHAR fmt
[] = {'%','x',0};
1177 DWORD time
, len
, i
, offset
;
1180 time
= GetTickCount();
1181 GetWindowsDirectoryW( path
, MAX_PATH
);
1182 strcatW( path
, szInstaller
);
1183 CreateDirectoryW( path
, NULL
);
1185 len
= strlenW(path
);
1186 for (i
= 0; i
< 0x10000; i
++)
1188 offset
= snprintfW( path
+ len
, MAX_PATH
- len
, fmt
, (time
+ i
) & 0xffff );
1189 memcpy( path
+ len
+ offset
, suffix
, (strlenW( suffix
) + 1) * sizeof(WCHAR
) );
1190 handle
= CreateFileW( path
, GENERIC_WRITE
, 0, NULL
,
1191 CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, 0 );
1192 if (handle
!= INVALID_HANDLE_VALUE
)
1194 CloseHandle(handle
);
1197 if (GetLastError() != ERROR_FILE_EXISTS
&&
1198 GetLastError() != ERROR_SHARING_VIOLATION
)
1199 return ERROR_FUNCTION_FAILED
;
1202 return ERROR_SUCCESS
;
1205 static enum platform
parse_platform( const WCHAR
*str
)
1207 if (!str
[0] || !strcmpW( str
, szIntel
)) return PLATFORM_INTEL
;
1208 else if (!strcmpW( str
, szIntel64
)) return PLATFORM_INTEL64
;
1209 else if (!strcmpW( str
, szX64
) || !strcmpW( str
, szAMD64
)) return PLATFORM_X64
;
1210 else if (!strcmpW( str
, szARM
)) return PLATFORM_ARM
;
1211 return PLATFORM_UNKNOWN
;
1214 static UINT
parse_suminfo( MSISUMMARYINFO
*si
, MSIPACKAGE
*package
)
1216 WCHAR
*template, *p
, *q
, *platform
;
1219 package
->version
= msi_suminfo_get_int32( si
, PID_PAGECOUNT
);
1220 TRACE("version: %d\n", package
->version
);
1222 template = msi_suminfo_dup_string( si
, PID_TEMPLATE
);
1224 return ERROR_SUCCESS
; /* native accepts missing template property */
1226 TRACE("template: %s\n", debugstr_w(template));
1228 p
= strchrW( template, ';' );
1231 WARN("invalid template string %s\n", debugstr_w(template));
1232 msi_free( template );
1233 return ERROR_PATCH_PACKAGE_INVALID
;
1236 platform
= template;
1237 if ((q
= strchrW( platform
, ',' ))) *q
= 0;
1238 package
->platform
= parse_platform( platform
);
1239 while (package
->platform
== PLATFORM_UNKNOWN
&& q
)
1242 if ((q
= strchrW( platform
, ',' ))) *q
= 0;
1243 package
->platform
= parse_platform( platform
);
1245 if (package
->platform
== PLATFORM_UNKNOWN
)
1247 WARN("unknown platform %s\n", debugstr_w(template));
1248 msi_free( template );
1249 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1254 msi_free( template );
1255 return ERROR_SUCCESS
;
1258 for (q
= p
; (q
= strchrW( q
, ',' )); q
++) count
++;
1260 package
->langids
= msi_alloc( count
* sizeof(LANGID
) );
1261 if (!package
->langids
)
1263 msi_free( template );
1264 return ERROR_OUTOFMEMORY
;
1270 q
= strchrW( p
, ',' );
1272 package
->langids
[i
] = atoiW( p
);
1277 package
->num_langids
= i
+ 1;
1279 msi_free( template );
1280 return ERROR_SUCCESS
;
1283 static UINT
validate_package( MSIPACKAGE
*package
)
1287 if (package
->platform
== PLATFORM_INTEL64
)
1288 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1290 if (package
->platform
== PLATFORM_ARM
)
1291 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1293 if (package
->platform
== PLATFORM_X64
)
1295 if (!is_64bit
&& !is_wow64
)
1296 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1297 if (package
->version
< 200)
1298 return ERROR_INSTALL_PACKAGE_INVALID
;
1300 if (!package
->num_langids
)
1302 return ERROR_SUCCESS
;
1304 for (i
= 0; i
< package
->num_langids
; i
++)
1306 LANGID langid
= package
->langids
[i
];
1308 if (PRIMARYLANGID( langid
) == LANG_NEUTRAL
)
1310 langid
= MAKELANGID( PRIMARYLANGID( GetSystemDefaultLangID() ), SUBLANGID( langid
) );
1312 if (SUBLANGID( langid
) == SUBLANG_NEUTRAL
)
1314 langid
= MAKELANGID( PRIMARYLANGID( langid
), SUBLANGID( GetSystemDefaultLangID() ) );
1316 if (IsValidLocale( langid
, LCID_INSTALLED
))
1317 return ERROR_SUCCESS
;
1319 return ERROR_INSTALL_LANGUAGE_UNSUPPORTED
;
1322 static WCHAR
*get_property( MSIDATABASE
*db
, const WCHAR
*prop
)
1324 static const WCHAR select_query
[] = {
1325 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
1326 'F','R','O','M',' ','`','P','r','o','p','e','r','t','y','`',' ',
1327 'W','H','E','R','E',' ','`','P','r','o','p','e','r','t','y','`','=',
1328 '\'','%','s','\'',0};
1329 WCHAR query
[MAX_PATH
];
1334 sprintfW(query
, select_query
, prop
);
1335 if (MSI_DatabaseOpenViewW( db
, query
, &view
) != ERROR_SUCCESS
)
1339 if (MSI_ViewExecute( view
, 0 ) != ERROR_SUCCESS
)
1341 MSI_ViewClose( view
);
1342 msiobj_release( &view
->hdr
);
1345 if (MSI_ViewFetch( view
, &rec
) == ERROR_SUCCESS
)
1347 ret
= strdupW( MSI_RecordGetString( rec
, 1 ) );
1348 msiobj_release( &rec
->hdr
);
1350 MSI_ViewClose( view
);
1351 msiobj_release( &view
->hdr
);
1355 static WCHAR
*get_product_code( MSIDATABASE
*db
)
1357 return get_property( db
, szProductCode
);
1360 static WCHAR
*get_product_version( MSIDATABASE
*db
)
1362 return get_property( db
, szProductVersion
);
1365 static UINT
get_registered_local_package( const WCHAR
*product
, WCHAR
*localfile
)
1367 MSIINSTALLCONTEXT context
;
1372 r
= msi_locate_product( product
, &context
);
1373 if (r
!= ERROR_SUCCESS
)
1376 r
= MSIREG_OpenInstallProps( product
, context
, NULL
, &props_key
, FALSE
);
1377 if (r
!= ERROR_SUCCESS
)
1380 filename
= msi_reg_get_val_str( props_key
, INSTALLPROPERTY_LOCALPACKAGEW
);
1381 RegCloseKey( props_key
);
1383 return ERROR_FUNCTION_FAILED
;
1385 strcpyW( localfile
, filename
);
1386 msi_free( filename
);
1387 return ERROR_SUCCESS
;
1390 WCHAR
*msi_get_package_code( MSIDATABASE
*db
)
1396 r
= msi_get_suminfo( db
->storage
, 0, &si
);
1397 if (r
!= ERROR_SUCCESS
)
1399 r
= msi_get_db_suminfo( db
, 0, &si
);
1400 if (r
!= ERROR_SUCCESS
)
1402 WARN("failed to load summary info %u\n", r
);
1406 ret
= msi_suminfo_dup_string( si
, PID_REVNUMBER
);
1407 msiobj_release( &si
->hdr
);
1411 static UINT
get_local_package( MSIDATABASE
*db
, WCHAR
*localfile
)
1413 WCHAR
*product_code
;
1416 if (!(product_code
= get_product_code( db
)))
1417 return ERROR_INSTALL_PACKAGE_INVALID
;
1418 r
= get_registered_local_package( product_code
, localfile
);
1419 msi_free( product_code
);
1423 UINT
msi_set_original_database_property( MSIDATABASE
*db
, const WCHAR
*package
)
1427 if (UrlIsW( package
, URLIS_URL
))
1428 r
= msi_set_property( db
, szOriginalDatabase
, package
, -1 );
1429 else if (package
[0] == '#')
1430 r
= msi_set_property( db
, szOriginalDatabase
, db
->path
, -1 );
1436 if (!(len
= GetFullPathNameW( package
, 0, NULL
, NULL
))) return GetLastError();
1437 if (!(path
= msi_alloc( len
* sizeof(WCHAR
) ))) return ERROR_OUTOFMEMORY
;
1438 len
= GetFullPathNameW( package
, len
, path
, NULL
);
1439 r
= msi_set_property( db
, szOriginalDatabase
, path
, len
);
1445 UINT
MSI_OpenPackageW(LPCWSTR szPackage
, DWORD dwOptions
, MSIPACKAGE
**pPackage
)
1447 static const WCHAR dotmsi
[] = {'.','m','s','i',0};
1449 MSIPACKAGE
*package
;
1451 MSIRECORD
*data_row
, *info_row
;
1453 WCHAR localfile
[MAX_PATH
], cachefile
[MAX_PATH
];
1454 LPCWSTR file
= szPackage
;
1457 BOOL delete_on_close
= FALSE
;
1458 WCHAR
*info_template
, *productname
, *product_code
;
1459 MSIINSTALLCONTEXT context
;
1461 TRACE("%s %p\n", debugstr_w(szPackage
), pPackage
);
1463 MSI_ProcessMessage(NULL
, INSTALLMESSAGE_INITIALIZE
, 0);
1466 if( szPackage
[0] == '#' )
1468 handle
= atoiW(&szPackage
[1]);
1469 db
= msihandle2msiinfo( handle
, MSIHANDLETYPE_DATABASE
);
1474 if (!(remote
= msi_get_remote(handle
)))
1475 return ERROR_INVALID_HANDLE
;
1477 WARN("MsiOpenPackage not allowed during a custom action!\n");
1479 return ERROR_FUNCTION_FAILED
;
1484 WCHAR
*product_version
= NULL
;
1486 if ( UrlIsW( szPackage
, URLIS_URL
) )
1488 r
= msi_download_file( szPackage
, cachefile
);
1489 if (r
!= ERROR_SUCCESS
)
1494 r
= MSI_OpenDatabaseW( file
, MSIDBOPEN_READONLY
, &db
);
1495 if (r
!= ERROR_SUCCESS
)
1497 if (GetFileAttributesW( file
) == INVALID_FILE_ATTRIBUTES
)
1498 return ERROR_FILE_NOT_FOUND
;
1501 r
= get_local_package( db
, localfile
);
1502 if (r
!= ERROR_SUCCESS
|| GetFileAttributesW( localfile
) == INVALID_FILE_ATTRIBUTES
)
1504 r
= msi_create_empty_local_file( localfile
, dotmsi
);
1505 if (r
!= ERROR_SUCCESS
)
1507 msiobj_release( &db
->hdr
);
1511 if (!CopyFileW( file
, localfile
, FALSE
))
1514 WARN("unable to copy package %s to %s (%u)\n", debugstr_w(file
), debugstr_w(localfile
), r
);
1515 DeleteFileW( localfile
);
1516 msiobj_release( &db
->hdr
);
1519 delete_on_close
= TRUE
;
1521 else if (dwOptions
& WINE_OPENPACKAGEFLAGS_RECACHE
)
1523 if (!CopyFileW( file
, localfile
, FALSE
))
1526 WARN("unable to update cached package (%u)\n", r
);
1527 msiobj_release( &db
->hdr
);
1532 product_version
= get_product_version( db
);
1533 msiobj_release( &db
->hdr
);
1534 TRACE("opening package %s\n", debugstr_w( localfile
));
1535 r
= MSI_OpenDatabaseW( localfile
, MSIDBOPEN_TRANSACT
, &db
);
1536 if (r
!= ERROR_SUCCESS
)
1539 if (product_version
)
1541 WCHAR
*cache_version
= get_product_version( db
);
1542 if (!product_version
!= !cache_version
||
1543 (product_version
&& strcmpW(product_version
, cache_version
)))
1545 msiobj_release( &db
->hdr
);
1546 msi_free(product_version
);
1547 msi_free(cache_version
);
1548 return ERROR_PRODUCT_VERSION
;
1550 msi_free(product_version
);
1551 msi_free(cache_version
);
1554 package
= MSI_CreatePackage( db
);
1555 msiobj_release( &db
->hdr
);
1556 if (!package
) return ERROR_INSTALL_PACKAGE_INVALID
;
1557 package
->localfile
= strdupW( localfile
);
1558 package
->delete_on_close
= delete_on_close
;
1560 r
= msi_get_suminfo( db
->storage
, 0, &si
);
1561 if (r
!= ERROR_SUCCESS
)
1563 r
= msi_get_db_suminfo( db
, 0, &si
);
1564 if (r
!= ERROR_SUCCESS
)
1566 WARN("failed to load summary info\n");
1567 msiobj_release( &package
->hdr
);
1568 return ERROR_INSTALL_PACKAGE_INVALID
;
1571 r
= parse_suminfo( si
, package
);
1572 msiobj_release( &si
->hdr
);
1573 if (r
!= ERROR_SUCCESS
)
1575 WARN("failed to parse summary info %u\n", r
);
1576 msiobj_release( &package
->hdr
);
1579 r
= validate_package( package
);
1580 if (r
!= ERROR_SUCCESS
)
1582 msiobj_release( &package
->hdr
);
1585 msi_set_property( package
->db
, szDatabase
, db
->path
, -1 );
1586 set_installed_prop( package
);
1587 msi_set_context( package
);
1589 product_code
= get_product_code( db
);
1590 if (msi_locate_product( product_code
, &context
) == ERROR_SUCCESS
)
1592 TRACE("product already registered\n");
1593 msi_set_property( package
->db
, szProductToBeRegistered
, szOne
, -1 );
1595 msi_free(product_code
);
1599 WCHAR patch_code
[GUID_SIZE
];
1600 r
= MsiEnumPatchesExW( package
->ProductCode
, NULL
, package
->Context
,
1601 MSIPATCHSTATE_APPLIED
, index
, patch_code
, NULL
, NULL
, NULL
, NULL
);
1602 if (r
!= ERROR_SUCCESS
)
1605 TRACE("found registered patch %s\n", debugstr_w(patch_code
));
1607 r
= msi_apply_registered_patch( package
, patch_code
);
1608 if (r
!= ERROR_SUCCESS
)
1610 ERR("registered patch failed to apply %u\n", r
);
1611 msiobj_release( &package
->hdr
);
1616 if (index
) msi_adjust_privilege_properties( package
);
1618 r
= msi_set_original_database_property( package
->db
, szPackage
);
1619 if (r
!= ERROR_SUCCESS
)
1621 msiobj_release( &package
->hdr
);
1625 package
->log_file
= CreateFileW( gszLogFile
, GENERIC_WRITE
, FILE_SHARE_WRITE
, NULL
,
1626 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1628 /* FIXME: when should these messages be sent? */
1629 data_row
= MSI_CreateRecord(3);
1631 return ERROR_OUTOFMEMORY
;
1632 MSI_RecordSetStringW(data_row
, 0, NULL
);
1633 MSI_RecordSetInteger(data_row
, 1, 0);
1634 MSI_RecordSetInteger(data_row
, 2, package
->num_langids
? package
->langids
[0] : 0);
1635 MSI_RecordSetInteger(data_row
, 3, msi_get_string_table_codepage(package
->db
->strings
));
1636 MSI_ProcessMessageVerbatim(package
, INSTALLMESSAGE_COMMONDATA
, data_row
);
1638 info_row
= MSI_CreateRecord(0);
1641 msiobj_release(&data_row
->hdr
);
1642 return ERROR_OUTOFMEMORY
;
1644 info_template
= msi_get_error_message(package
->db
, MSIERR_INFO_LOGGINGSTART
);
1645 MSI_RecordSetStringW(info_row
, 0, info_template
);
1646 msi_free(info_template
);
1647 MSI_ProcessMessage(package
, INSTALLMESSAGE_INFO
|MB_ICONHAND
, info_row
);
1649 MSI_ProcessMessage(package
, INSTALLMESSAGE_COMMONDATA
, data_row
);
1651 productname
= msi_dup_property(package
->db
, INSTALLPROPERTY_PRODUCTNAMEW
);
1652 MSI_RecordSetInteger(data_row
, 1, 1);
1653 MSI_RecordSetStringW(data_row
, 2, productname
);
1654 MSI_RecordSetStringW(data_row
, 3, NULL
);
1655 MSI_ProcessMessage(package
, INSTALLMESSAGE_COMMONDATA
, data_row
);
1657 msi_free(productname
);
1658 msiobj_release(&info_row
->hdr
);
1659 msiobj_release(&data_row
->hdr
);
1661 *pPackage
= package
;
1662 return ERROR_SUCCESS
;
1665 UINT WINAPI
MsiOpenPackageExW(LPCWSTR szPackage
, DWORD dwOptions
, MSIHANDLE
*phPackage
)
1667 MSIPACKAGE
*package
= NULL
;
1670 TRACE("%s %08x %p\n", debugstr_w(szPackage
), dwOptions
, phPackage
);
1672 if( !szPackage
|| !phPackage
)
1673 return ERROR_INVALID_PARAMETER
;
1677 FIXME("Should create an empty database and package\n");
1678 return ERROR_FUNCTION_FAILED
;
1682 FIXME("dwOptions %08x not supported\n", dwOptions
);
1684 ret
= MSI_OpenPackageW( szPackage
, 0, &package
);
1685 if( ret
== ERROR_SUCCESS
)
1687 *phPackage
= alloc_msihandle( &package
->hdr
);
1689 ret
= ERROR_NOT_ENOUGH_MEMORY
;
1690 msiobj_release( &package
->hdr
);
1693 MSI_ProcessMessage(NULL
, INSTALLMESSAGE_TERMINATE
, 0);
1698 UINT WINAPI
MsiOpenPackageW(LPCWSTR szPackage
, MSIHANDLE
*phPackage
)
1700 return MsiOpenPackageExW( szPackage
, 0, phPackage
);
1703 UINT WINAPI
MsiOpenPackageExA(LPCSTR szPackage
, DWORD dwOptions
, MSIHANDLE
*phPackage
)
1705 LPWSTR szwPack
= NULL
;
1710 szwPack
= strdupAtoW( szPackage
);
1712 return ERROR_OUTOFMEMORY
;
1715 ret
= MsiOpenPackageExW( szwPack
, dwOptions
, phPackage
);
1717 msi_free( szwPack
);
1722 UINT WINAPI
MsiOpenPackageA(LPCSTR szPackage
, MSIHANDLE
*phPackage
)
1724 return MsiOpenPackageExA( szPackage
, 0, phPackage
);
1727 MSIHANDLE WINAPI
MsiGetActiveDatabase(MSIHANDLE hInstall
)
1729 MSIPACKAGE
*package
;
1730 MSIHANDLE handle
= 0;
1733 TRACE("(%d)\n",hInstall
);
1735 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
1738 handle
= alloc_msihandle( &package
->db
->hdr
);
1739 msiobj_release( &package
->hdr
);
1741 else if ((remote
= msi_get_remote(hInstall
)))
1745 handle
= remote_GetActiveDatabase(hInstall
);
1746 handle
= alloc_msi_remote_handle(handle
);
1748 __EXCEPT(rpc_filter
)
1758 static INT
internal_ui_handler(MSIPACKAGE
*package
, INSTALLMESSAGE eMessageType
, MSIRECORD
*record
, LPCWSTR message
)
1760 static const WCHAR szActionData
[] = {'A','c','t','i','o','n','D','a','t','a',0};
1761 static const WCHAR szActionText
[] = {'A','c','t','i','o','n','T','e','x','t',0};
1762 static const WCHAR szSetProgress
[] = {'S','e','t','P','r','o','g','r','e','s','s',0};
1763 static const WCHAR szWindows_Installer
[] =
1764 {'W','i','n','d','o','w','s',' ','I','n','s','t','a','l','l','e','r',0};
1766 if (!package
|| (package
->ui_level
& INSTALLUILEVEL_MASK
) == INSTALLUILEVEL_NONE
)
1769 /* todo: check if message needs additional styles (topmost/foreground/modality?) */
1771 switch (eMessageType
& 0xff000000)
1773 case INSTALLMESSAGE_FATALEXIT
:
1774 case INSTALLMESSAGE_ERROR
:
1775 case INSTALLMESSAGE_OUTOFDISKSPACE
:
1776 if (package
->ui_level
& INSTALLUILEVEL_PROGRESSONLY
) return 0;
1777 if (!(eMessageType
& MB_ICONMASK
))
1778 eMessageType
|= MB_ICONEXCLAMATION
;
1779 return MessageBoxW(gUIhwnd
, message
, szWindows_Installer
, eMessageType
& 0x00ffffff);
1780 case INSTALLMESSAGE_WARNING
:
1781 if (package
->ui_level
& INSTALLUILEVEL_PROGRESSONLY
) return 0;
1782 if (!(eMessageType
& MB_ICONMASK
))
1783 eMessageType
|= MB_ICONASTERISK
;
1784 return MessageBoxW(gUIhwnd
, message
, szWindows_Installer
, eMessageType
& 0x00ffffff);
1785 case INSTALLMESSAGE_USER
:
1786 if (package
->ui_level
& INSTALLUILEVEL_PROGRESSONLY
) return 0;
1787 if (!(eMessageType
& MB_ICONMASK
))
1788 eMessageType
|= MB_USERICON
;
1789 return MessageBoxW(gUIhwnd
, message
, szWindows_Installer
, eMessageType
& 0x00ffffff);
1790 case INSTALLMESSAGE_INFO
:
1791 case INSTALLMESSAGE_INITIALIZE
:
1792 case INSTALLMESSAGE_TERMINATE
:
1793 case INSTALLMESSAGE_INSTALLSTART
:
1794 case INSTALLMESSAGE_INSTALLEND
:
1796 case INSTALLMESSAGE_SHOWDIALOG
:
1798 LPWSTR dialog
= msi_dup_record_field(record
, 0);
1799 INT rc
= ACTION_DialogBox(package
, dialog
);
1803 case INSTALLMESSAGE_ACTIONSTART
:
1806 MSIRECORD
*uirow
= MSI_CreateRecord(1);
1807 if (!uirow
) return -1;
1808 deformat_string(package
, MSI_RecordGetString(record
, 2), &deformatted
);
1809 MSI_RecordSetStringW(uirow
, 1, deformatted
);
1810 msi_event_fire(package
, szActionText
, uirow
);
1812 msi_free(deformatted
);
1813 msiobj_release(&uirow
->hdr
);
1816 case INSTALLMESSAGE_ACTIONDATA
:
1818 MSIRECORD
*uirow
= MSI_CreateRecord(1);
1819 if (!uirow
) return -1;
1820 MSI_RecordSetStringW(uirow
, 1, message
);
1821 msi_event_fire(package
, szActionData
, uirow
);
1822 msiobj_release(&uirow
->hdr
);
1824 if (package
->action_progress_increment
)
1826 uirow
= MSI_CreateRecord(2);
1827 if (!uirow
) return -1;
1828 MSI_RecordSetInteger(uirow
, 1, 2);
1829 MSI_RecordSetInteger(uirow
, 2, package
->action_progress_increment
);
1830 msi_event_fire(package
, szSetProgress
, uirow
);
1831 msiobj_release(&uirow
->hdr
);
1835 case INSTALLMESSAGE_PROGRESS
:
1836 msi_event_fire(package
, szSetProgress
, record
);
1838 case INSTALLMESSAGE_COMMONDATA
:
1839 switch (MSI_RecordGetInteger(record
, 1))
1850 FIXME("internal UI not implemented for message 0x%08x (UI level = %x)\n", eMessageType
, package
->ui_level
);
1855 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};
1864 {2726, szActionNotFound
},
1868 static LPCWSTR
get_internal_error_message(int error
)
1872 while (internal_errors
[i
].id
!= 0)
1874 if (internal_errors
[i
].id
== error
)
1875 return internal_errors
[i
].text
;
1879 FIXME("missing error message %d\n", error
);
1883 /* Returned string must be freed */
1884 LPWSTR
msi_get_error_message(MSIDATABASE
*db
, int error
)
1886 static const WCHAR query
[] =
1887 {'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ',
1888 'F','R','O','M',' ','`','E','r','r','o','r','`',' ','W','H','E','R','E',' ',
1889 '`','E','r','r','o','r','`',' ','=',' ','%','i',0};
1893 if ((record
= MSI_QueryGetRecord(db
, query
, error
)))
1895 ret
= msi_dup_record_field(record
, 1);
1896 msiobj_release(&record
->hdr
);
1898 else if (error
< 2000)
1900 int len
= LoadStringW(msi_hInstance
, IDS_ERROR_BASE
+ error
, (LPWSTR
) &ret
, 0);
1903 ret
= msi_alloc((len
+ 1) * sizeof(WCHAR
));
1904 LoadStringW(msi_hInstance
, IDS_ERROR_BASE
+ error
, ret
, len
+ 1);
1913 INT
MSI_ProcessMessageVerbatim(MSIPACKAGE
*package
, INSTALLMESSAGE eMessageType
, MSIRECORD
*record
)
1915 LPWSTR message
= {0};
1917 DWORD log_type
= 1 << (eMessageType
>> 24);
1922 TRACE("%x\n", eMessageType
);
1923 if (TRACE_ON(msi
)) dump_record(record
);
1925 if (!package
|| !record
)
1928 res
= MSI_FormatRecordW(package
, record
, message
, &len
);
1929 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
)
1932 message
= msi_alloc(len
* sizeof(WCHAR
));
1933 if (!message
) return ERROR_OUTOFMEMORY
;
1934 MSI_FormatRecordW(package
, record
, message
, &len
);
1937 /* convert it to ASCII */
1938 len
= WideCharToMultiByte( CP_ACP
, 0, message
, -1, NULL
, 0, NULL
, NULL
);
1939 msg
= msi_alloc( len
);
1940 WideCharToMultiByte( CP_ACP
, 0, message
, -1, msg
, len
, NULL
, NULL
);
1942 if (gUIHandlerRecord
&& (gUIFilterRecord
& log_type
))
1944 MSIHANDLE rec
= alloc_msihandle(&record
->hdr
);
1945 TRACE("Calling UI handler %p(pvContext=%p, iMessageType=%08x, hRecord=%u)\n",
1946 gUIHandlerRecord
, gUIContextRecord
, eMessageType
, rec
);
1947 rc
= gUIHandlerRecord( gUIContextRecord
, eMessageType
, rec
);
1948 MsiCloseHandle( rec
);
1950 if (!rc
&& gUIHandlerW
&& (gUIFilter
& log_type
))
1952 TRACE("Calling UI handler %p(pvContext=%p, iMessageType=%08x, szMessage=%s)\n",
1953 gUIHandlerW
, gUIContext
, eMessageType
, debugstr_w(message
));
1954 rc
= gUIHandlerW( gUIContext
, eMessageType
, message
);
1956 else if (!rc
&& gUIHandlerA
&& (gUIFilter
& log_type
))
1958 TRACE("Calling UI handler %p(pvContext=%p, iMessageType=%08x, szMessage=%s)\n",
1959 gUIHandlerA
, gUIContext
, eMessageType
, debugstr_a(msg
));
1960 rc
= gUIHandlerA( gUIContext
, eMessageType
, msg
);
1964 rc
= internal_ui_handler(package
, eMessageType
, record
, message
);
1966 if (!rc
&& package
&& package
->log_file
!= INVALID_HANDLE_VALUE
&&
1967 (eMessageType
& 0xff000000) != INSTALLMESSAGE_PROGRESS
)
1970 WriteFile( package
->log_file
, msg
, len
- 1, &written
, NULL
);
1971 WriteFile( package
->log_file
, "\n", 1, &written
, NULL
);
1974 msi_free( message
);
1979 INT
MSI_ProcessMessage( MSIPACKAGE
*package
, INSTALLMESSAGE eMessageType
, MSIRECORD
*record
)
1981 switch (eMessageType
& 0xff000000)
1983 case INSTALLMESSAGE_FATALEXIT
:
1984 case INSTALLMESSAGE_ERROR
:
1985 case INSTALLMESSAGE_WARNING
:
1986 case INSTALLMESSAGE_USER
:
1987 case INSTALLMESSAGE_INFO
:
1988 case INSTALLMESSAGE_OUTOFDISKSPACE
:
1989 if (MSI_RecordGetInteger(record
, 1) != MSI_NULL_INTEGER
)
1994 LPWSTR template_rec
= NULL
, template_prefix
= NULL
;
1995 int error
= MSI_RecordGetInteger(record
, 1);
1997 if (MSI_RecordIsNull(record
, 0))
2001 template_rec
= msi_get_error_message(package
->db
, error
);
2003 if (!template_rec
&& error
>= 2000)
2005 /* internal error, not localized */
2006 if ((template_rec
= (LPWSTR
) get_internal_error_message(error
)))
2008 MSI_RecordSetStringW(record
, 0, template_rec
);
2009 MSI_ProcessMessageVerbatim(package
, INSTALLMESSAGE_INFO
, record
);
2011 template_rec
= msi_get_error_message(package
->db
, MSIERR_INSTALLERROR
);
2012 MSI_RecordSetStringW(record
, 0, template_rec
);
2013 MSI_ProcessMessageVerbatim(package
, eMessageType
, record
);
2014 msi_free(template_rec
);
2020 template_rec
= msi_dup_record_field(record
, 0);
2022 template_prefix
= msi_get_error_message(package
->db
, eMessageType
>> 24);
2023 if (!template_prefix
) template_prefix
= strdupW(szEmpty
);
2027 /* always returns 0 */
2028 MSI_RecordSetStringW(record
, 0, template_prefix
);
2029 MSI_ProcessMessageVerbatim(package
, eMessageType
, record
);
2030 msi_free(template_prefix
);
2034 template = msi_alloc((strlenW(template_rec
) + strlenW(template_prefix
) + 1) * sizeof(WCHAR
));
2035 if (!template) return ERROR_OUTOFMEMORY
;
2037 strcpyW(template, template_prefix
);
2038 strcatW(template, template_rec
);
2039 MSI_RecordSetStringW(record
, 0, template);
2041 msi_free(template_prefix
);
2042 msi_free(template_rec
);
2046 case INSTALLMESSAGE_ACTIONSTART
:
2048 WCHAR
*template = msi_get_error_message(package
->db
, MSIERR_ACTIONSTART
);
2049 MSI_RecordSetStringW(record
, 0, template);
2052 msi_free(package
->LastAction
);
2053 msi_free(package
->LastActionTemplate
);
2054 package
->LastAction
= msi_dup_record_field(record
, 1);
2055 if (!package
->LastAction
) package
->LastAction
= strdupW(szEmpty
);
2056 package
->LastActionTemplate
= msi_dup_record_field(record
, 3);
2059 case INSTALLMESSAGE_ACTIONDATA
:
2060 if (package
->LastAction
&& package
->LastActionTemplate
)
2062 static const WCHAR template_s
[] =
2063 {'{','{','%','s',':',' ','}','}','%','s',0};
2066 template = msi_alloc((strlenW(package
->LastAction
) + strlenW(package
->LastActionTemplate
) + 7) * sizeof(WCHAR
));
2067 if (!template) return ERROR_OUTOFMEMORY
;
2068 sprintfW(template, template_s
, package
->LastAction
, package
->LastActionTemplate
);
2069 MSI_RecordSetStringW(record
, 0, template);
2073 case INSTALLMESSAGE_COMMONDATA
:
2075 WCHAR
*template = msi_get_error_message(package
->db
, MSIERR_COMMONDATA
);
2076 MSI_RecordSetStringW(record
, 0, template);
2082 return MSI_ProcessMessageVerbatim(package
, eMessageType
, record
);
2085 INT WINAPI
MsiProcessMessage( MSIHANDLE hInstall
, INSTALLMESSAGE eMessageType
,
2088 UINT ret
= ERROR_INVALID_HANDLE
;
2089 MSIPACKAGE
*package
= NULL
;
2090 MSIRECORD
*record
= NULL
;
2092 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_INITIALIZE
||
2093 (eMessageType
& 0xff000000) == INSTALLMESSAGE_TERMINATE
)
2096 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_COMMONDATA
&&
2097 MsiRecordGetInteger(hRecord
, 1) != 2)
2100 record
= msihandle2msiinfo(hRecord
, MSIHANDLETYPE_RECORD
);
2102 return ERROR_INVALID_HANDLE
;
2104 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
2109 if (!(remote
= msi_get_remote(hInstall
)))
2110 return ERROR_INVALID_HANDLE
;
2114 ret
= remote_ProcessMessage(remote
, eMessageType
, (struct wire_record
*)&record
->count
);
2116 __EXCEPT(rpc_filter
)
2118 ret
= GetExceptionCode();
2122 msiobj_release(&record
->hdr
);
2126 ret
= MSI_ProcessMessage( package
, eMessageType
, record
);
2128 msiobj_release( &package
->hdr
);
2134 UINT WINAPI
MsiSetPropertyA( MSIHANDLE hInstall
, LPCSTR szName
, LPCSTR szValue
)
2136 LPWSTR szwName
= NULL
, szwValue
= NULL
;
2137 UINT r
= ERROR_OUTOFMEMORY
;
2139 szwName
= strdupAtoW( szName
);
2140 if( szName
&& !szwName
)
2143 szwValue
= strdupAtoW( szValue
);
2144 if( szValue
&& !szwValue
)
2147 r
= MsiSetPropertyW( hInstall
, szwName
, szwValue
);
2150 msi_free( szwName
);
2151 msi_free( szwValue
);
2156 void msi_reset_folders( MSIPACKAGE
*package
, BOOL source
)
2160 LIST_FOR_EACH_ENTRY( folder
, &package
->folders
, MSIFOLDER
, entry
)
2164 msi_free( folder
->ResolvedSource
);
2165 folder
->ResolvedSource
= NULL
;
2169 msi_free( folder
->ResolvedTarget
);
2170 folder
->ResolvedTarget
= NULL
;
2175 UINT
msi_set_property( MSIDATABASE
*db
, const WCHAR
*name
, const WCHAR
*value
, int len
)
2177 static const WCHAR insert_query
[] = {
2178 'I','N','S','E','R','T',' ','I','N','T','O',' ',
2179 '`','_','P','r','o','p','e','r','t','y','`',' ',
2180 '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
2181 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
2182 static const WCHAR update_query
[] = {
2183 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
2184 'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ','W','H','E','R','E',' ',
2185 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
2186 static const WCHAR delete_query
[] = {
2187 'D','E','L','E','T','E',' ','F','R','O','M',' ',
2188 '`','_','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2189 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
2191 MSIRECORD
*row
= NULL
;
2196 TRACE("%p %s %s %d\n", db
, debugstr_w(name
), debugstr_wn(value
, len
), len
);
2199 return ERROR_INVALID_PARAMETER
;
2201 /* this one is weird... */
2203 return value
? ERROR_FUNCTION_FAILED
: ERROR_SUCCESS
;
2205 if (value
&& len
< 0) len
= strlenW( value
);
2207 rc
= msi_get_property( db
, name
, 0, &sz
);
2208 if (!value
|| (!*value
&& !len
))
2210 sprintfW( query
, delete_query
, name
);
2212 else if (rc
== ERROR_MORE_DATA
|| rc
== ERROR_SUCCESS
)
2214 sprintfW( query
, update_query
, name
);
2215 row
= MSI_CreateRecord(1);
2216 msi_record_set_string( row
, 1, value
, len
);
2220 strcpyW( query
, insert_query
);
2221 row
= MSI_CreateRecord(2);
2222 msi_record_set_string( row
, 1, name
, -1 );
2223 msi_record_set_string( row
, 2, value
, len
);
2226 rc
= MSI_DatabaseOpenViewW(db
, query
, &view
);
2227 if (rc
== ERROR_SUCCESS
)
2229 rc
= MSI_ViewExecute(view
, row
);
2230 MSI_ViewClose(view
);
2231 msiobj_release(&view
->hdr
);
2233 if (row
) msiobj_release(&row
->hdr
);
2237 UINT WINAPI
MsiSetPropertyW( MSIHANDLE hInstall
, LPCWSTR szName
, LPCWSTR szValue
)
2239 MSIPACKAGE
*package
;
2242 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
2247 if (!(remote
= msi_get_remote(hInstall
)))
2248 return ERROR_INVALID_HANDLE
;
2252 ret
= remote_SetProperty(remote
, szName
, szValue
);
2254 __EXCEPT(rpc_filter
)
2256 ret
= GetExceptionCode();
2263 ret
= msi_set_property( package
->db
, szName
, szValue
, -1 );
2264 if (ret
== ERROR_SUCCESS
&& !strcmpW( szName
, szSourceDir
))
2265 msi_reset_folders( package
, TRUE
);
2267 msiobj_release( &package
->hdr
);
2271 static MSIRECORD
*msi_get_property_row( MSIDATABASE
*db
, LPCWSTR name
)
2273 static const WCHAR query
[]= {
2274 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
2275 'F','R','O','M',' ' ,'`','_','P','r','o','p','e','r','t','y','`',' ',
2276 'W','H','E','R','E',' ' ,'`','_','P','r','o','p','e','r','t','y','`','=','?',0};
2277 MSIRECORD
*rec
, *row
= NULL
;
2281 static const WCHAR szDate
[] = {'D','a','t','e',0};
2282 static const WCHAR szTime
[] = {'T','i','m','e',0};
2286 if (!name
|| !*name
)
2289 if (!strcmpW(name
, szDate
))
2291 length
= GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_SHORTDATE
, NULL
, NULL
, NULL
, 0);
2294 buffer
= msi_alloc(length
* sizeof(WCHAR
));
2295 GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_SHORTDATE
, NULL
, NULL
, buffer
, length
);
2297 row
= MSI_CreateRecord(1);
2303 MSI_RecordSetStringW(row
, 1, buffer
);
2307 else if (!strcmpW(name
, szTime
))
2309 length
= GetTimeFormatW(LOCALE_USER_DEFAULT
, TIME_NOTIMEMARKER
, NULL
, NULL
, NULL
, 0);
2312 buffer
= msi_alloc(length
* sizeof(WCHAR
));
2313 GetTimeFormatW(LOCALE_USER_DEFAULT
, TIME_NOTIMEMARKER
, NULL
, NULL
, buffer
, length
);
2315 row
= MSI_CreateRecord(1);
2321 MSI_RecordSetStringW(row
, 1, buffer
);
2326 rec
= MSI_CreateRecord(1);
2330 MSI_RecordSetStringW(rec
, 1, name
);
2332 r
= MSI_DatabaseOpenViewW(db
, query
, &view
);
2333 if (r
== ERROR_SUCCESS
)
2335 MSI_ViewExecute(view
, rec
);
2336 MSI_ViewFetch(view
, &row
);
2337 MSI_ViewClose(view
);
2338 msiobj_release(&view
->hdr
);
2340 msiobj_release(&rec
->hdr
);
2344 /* internal function, not compatible with MsiGetPropertyW */
2345 UINT
msi_get_property( MSIDATABASE
*db
, LPCWSTR szName
,
2346 LPWSTR szValueBuf
, LPDWORD pchValueBuf
)
2349 UINT rc
= ERROR_FUNCTION_FAILED
;
2351 TRACE("%p %s %p %p\n", db
, debugstr_w(szName
), szValueBuf
, pchValueBuf
);
2353 row
= msi_get_property_row( db
, szName
);
2355 if (*pchValueBuf
> 0)
2360 rc
= MSI_RecordGetStringW(row
, 1, szValueBuf
, pchValueBuf
);
2361 msiobj_release(&row
->hdr
);
2364 if (rc
== ERROR_SUCCESS
)
2365 TRACE("returning %s for property %s\n", debugstr_wn(szValueBuf
, *pchValueBuf
),
2366 debugstr_w(szName
));
2367 else if (rc
== ERROR_MORE_DATA
)
2368 TRACE("need %d sized buffer for %s\n", *pchValueBuf
,
2369 debugstr_w(szName
));
2373 TRACE("property %s not found\n", debugstr_w(szName
));
2379 LPWSTR
msi_dup_property(MSIDATABASE
*db
, LPCWSTR prop
)
2385 r
= msi_get_property(db
, prop
, NULL
, &sz
);
2386 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
2390 str
= msi_alloc(sz
* sizeof(WCHAR
));
2391 r
= msi_get_property(db
, prop
, str
, &sz
);
2392 if (r
!= ERROR_SUCCESS
)
2401 int msi_get_property_int( MSIDATABASE
*db
, LPCWSTR prop
, int def
)
2403 LPWSTR str
= msi_dup_property( db
, prop
);
2404 int val
= str
? atoiW(str
) : def
;
2409 UINT WINAPI
MsiGetPropertyA(MSIHANDLE hinst
, const char *name
, char *buf
, DWORD
*sz
)
2411 const WCHAR
*value
= szEmpty
;
2412 MSIPACKAGE
*package
;
2419 return ERROR_INVALID_PARAMETER
;
2421 if (!(nameW
= strdupAtoW(name
)))
2422 return ERROR_OUTOFMEMORY
;
2424 package
= msihandle2msiinfo(hinst
, MSIHANDLETYPE_PACKAGE
);
2427 WCHAR
*value
= NULL
, *tmp
;
2431 if (!(remote
= msi_get_remote(hinst
)))
2434 return ERROR_INVALID_HANDLE
;
2439 r
= remote_GetProperty(remote
, nameW
, &value
, &len
);
2441 __EXCEPT(rpc_filter
)
2443 r
= GetExceptionCode();
2451 /* String might contain embedded nulls.
2452 * Native returns the correct size but truncates the string. */
2453 tmp
= heap_alloc_zero((len
+ 1) * sizeof(WCHAR
));
2456 midl_user_free(value
);
2457 return ERROR_OUTOFMEMORY
;
2459 strcpyW(tmp
, value
);
2461 r
= msi_strncpyWtoA(tmp
, len
, buf
, sz
, TRUE
);
2465 midl_user_free(value
);
2469 row
= msi_get_property_row(package
->db
, nameW
);
2471 value
= msi_record_get_string(row
, 1, &len
);
2473 r
= msi_strncpyWtoA(value
, len
, buf
, sz
, FALSE
);
2476 if (row
) msiobj_release(&row
->hdr
);
2477 msiobj_release(&package
->hdr
);
2481 UINT WINAPI
MsiGetPropertyW(MSIHANDLE hinst
, const WCHAR
*name
, WCHAR
*buf
, DWORD
*sz
)
2483 const WCHAR
*value
= szEmpty
;
2484 MSIPACKAGE
*package
;
2490 return ERROR_INVALID_PARAMETER
;
2492 package
= msihandle2msiinfo(hinst
, MSIHANDLETYPE_PACKAGE
);
2495 WCHAR
*value
= NULL
, *tmp
;
2499 if (!(remote
= msi_get_remote(hinst
)))
2500 return ERROR_INVALID_HANDLE
;
2504 r
= remote_GetProperty(remote
, name
, &value
, &len
);
2506 __EXCEPT(rpc_filter
)
2508 r
= GetExceptionCode();
2514 /* String might contain embedded nulls.
2515 * Native returns the correct size but truncates the string. */
2516 tmp
= heap_alloc_zero((len
+ 1) * sizeof(WCHAR
));
2519 midl_user_free(value
);
2520 return ERROR_OUTOFMEMORY
;
2522 strcpyW(tmp
, value
);
2524 r
= msi_strncpyW(tmp
, len
, buf
, sz
);
2528 midl_user_free(value
);
2532 row
= msi_get_property_row(package
->db
, name
);
2534 value
= msi_record_get_string(row
, 1, &len
);
2536 r
= msi_strncpyW(value
, len
, buf
, sz
);
2538 if (row
) msiobj_release(&row
->hdr
);
2539 msiobj_release(&package
->hdr
);
2543 MSIHANDLE __cdecl
s_remote_GetActiveDatabase(MSIHANDLE hinst
)
2545 return MsiGetActiveDatabase(hinst
);
2548 UINT __cdecl
s_remote_GetProperty(MSIHANDLE hinst
, LPCWSTR property
, LPWSTR
*value
, DWORD
*size
)
2554 r
= MsiGetPropertyW(hinst
, property
, empty
, size
);
2555 if (r
== ERROR_MORE_DATA
)
2558 *value
= midl_user_allocate(*size
* sizeof(WCHAR
));
2560 return ERROR_OUTOFMEMORY
;
2561 r
= MsiGetPropertyW(hinst
, property
, *value
, size
);
2566 UINT __cdecl
s_remote_SetProperty(MSIHANDLE hinst
, LPCWSTR property
, LPCWSTR value
)
2568 return MsiSetPropertyW(hinst
, property
, value
);
2571 int __cdecl
s_remote_ProcessMessage(MSIHANDLE hinst
, INSTALLMESSAGE message
, struct wire_record
*remote_rec
)
2577 if ((r
= unmarshal_record(remote_rec
, &rec
)))
2580 ret
= MsiProcessMessage(hinst
, message
, rec
);
2582 MsiCloseHandle(rec
);
2586 UINT __cdecl
s_remote_DoAction(MSIHANDLE hinst
, LPCWSTR action
)
2588 return MsiDoActionW(hinst
, action
);
2591 UINT __cdecl
s_remote_Sequence(MSIHANDLE hinst
, LPCWSTR table
, int sequence
)
2593 return MsiSequenceW(hinst
, table
, sequence
);
2596 UINT __cdecl
s_remote_GetTargetPath(MSIHANDLE hinst
, LPCWSTR folder
, LPWSTR
*value
)
2602 r
= MsiGetTargetPathW(hinst
, folder
, empty
, &size
);
2603 if (r
== ERROR_MORE_DATA
)
2605 *value
= midl_user_allocate(++size
* sizeof(WCHAR
));
2607 return ERROR_OUTOFMEMORY
;
2608 r
= MsiGetTargetPathW(hinst
, folder
, *value
, &size
);
2613 UINT __cdecl
s_remote_SetTargetPath(MSIHANDLE hinst
, LPCWSTR folder
, LPCWSTR value
)
2615 return MsiSetTargetPathW(hinst
, folder
, value
);
2618 UINT __cdecl
s_remote_GetSourcePath(MSIHANDLE hinst
, LPCWSTR folder
, LPWSTR
*value
)
2624 r
= MsiGetSourcePathW(hinst
, folder
, empty
, &size
);
2625 if (r
== ERROR_MORE_DATA
)
2627 *value
= midl_user_allocate(++size
* sizeof(WCHAR
));
2629 return ERROR_OUTOFMEMORY
;
2630 r
= MsiGetSourcePathW(hinst
, folder
, *value
, &size
);
2635 BOOL __cdecl
s_remote_GetMode(MSIHANDLE hinst
, MSIRUNMODE mode
)
2637 return MsiGetMode(hinst
, mode
);
2640 UINT __cdecl
s_remote_SetMode(MSIHANDLE hinst
, MSIRUNMODE mode
, BOOL state
)
2642 return MsiSetMode(hinst
, mode
, state
);
2645 UINT __cdecl
s_remote_GetFeatureState(MSIHANDLE hinst
, LPCWSTR feature
,
2646 INSTALLSTATE
*installed
, INSTALLSTATE
*action
)
2648 return MsiGetFeatureStateW(hinst
, feature
, installed
, action
);
2651 UINT __cdecl
s_remote_SetFeatureState(MSIHANDLE hinst
, LPCWSTR feature
, INSTALLSTATE state
)
2653 return MsiSetFeatureStateW(hinst
, feature
, state
);
2656 UINT __cdecl
s_remote_GetComponentState(MSIHANDLE hinst
, LPCWSTR component
,
2657 INSTALLSTATE
*installed
, INSTALLSTATE
*action
)
2659 return MsiGetComponentStateW(hinst
, component
, installed
, action
);
2662 UINT __cdecl
s_remote_SetComponentState(MSIHANDLE hinst
, LPCWSTR component
, INSTALLSTATE state
)
2664 return MsiSetComponentStateW(hinst
, component
, state
);
2667 LANGID __cdecl
s_remote_GetLanguage(MSIHANDLE hinst
)
2669 return MsiGetLanguage(hinst
);
2672 UINT __cdecl
s_remote_SetInstallLevel(MSIHANDLE hinst
, int level
)
2674 return MsiSetInstallLevel(hinst
, level
);
2677 UINT __cdecl
s_remote_FormatRecord(MSIHANDLE hinst
, struct wire_record
*remote_rec
, LPWSTR
*value
)
2684 if ((r
= unmarshal_record(remote_rec
, &rec
)))
2687 r
= MsiFormatRecordW(hinst
, rec
, empty
, &size
);
2688 if (r
== ERROR_MORE_DATA
)
2690 *value
= midl_user_allocate(++size
* sizeof(WCHAR
));
2692 return ERROR_OUTOFMEMORY
;
2693 r
= MsiFormatRecordW(hinst
, rec
, *value
, &size
);
2696 MsiCloseHandle(rec
);
2700 MSICONDITION __cdecl
s_remote_EvaluateCondition(MSIHANDLE hinst
, LPCWSTR condition
)
2702 return MsiEvaluateConditionW(hinst
, condition
);
2705 UINT __cdecl
s_remote_GetFeatureCost(MSIHANDLE hinst
, LPCWSTR feature
,
2706 MSICOSTTREE cost_tree
, INSTALLSTATE state
, INT
*cost
)
2708 return MsiGetFeatureCostW(hinst
, feature
, cost_tree
, state
, cost
);
2711 UINT __cdecl
s_remote_EnumComponentCosts(MSIHANDLE hinst
, LPCWSTR component
,
2712 DWORD index
, INSTALLSTATE state
, LPWSTR drive
, INT
*cost
, INT
*temp
)
2715 return MsiEnumComponentCostsW(hinst
, component
, index
, state
, drive
, &size
, cost
, temp
);
2718 UINT
msi_package_add_info(MSIPACKAGE
*package
, DWORD context
, DWORD options
,
2719 LPCWSTR property
, LPWSTR value
)
2721 MSISOURCELISTINFO
*info
;
2723 LIST_FOR_EACH_ENTRY( info
, &package
->sourcelist_info
, MSISOURCELISTINFO
, entry
)
2725 if (!strcmpW( info
->value
, value
)) return ERROR_SUCCESS
;
2728 info
= msi_alloc(sizeof(MSISOURCELISTINFO
));
2730 return ERROR_OUTOFMEMORY
;
2732 info
->context
= context
;
2733 info
->options
= options
;
2734 info
->property
= property
;
2735 info
->value
= strdupW(value
);
2736 list_add_head(&package
->sourcelist_info
, &info
->entry
);
2738 return ERROR_SUCCESS
;
2741 UINT
msi_package_add_media_disk(MSIPACKAGE
*package
, DWORD context
, DWORD options
,
2742 DWORD disk_id
, LPWSTR volume_label
, LPWSTR disk_prompt
)
2746 LIST_FOR_EACH_ENTRY( disk
, &package
->sourcelist_media
, MSIMEDIADISK
, entry
)
2748 if (disk
->disk_id
== disk_id
) return ERROR_SUCCESS
;
2751 disk
= msi_alloc(sizeof(MSIMEDIADISK
));
2753 return ERROR_OUTOFMEMORY
;
2755 disk
->context
= context
;
2756 disk
->options
= options
;
2757 disk
->disk_id
= disk_id
;
2758 disk
->volume_label
= strdupW(volume_label
);
2759 disk
->disk_prompt
= strdupW(disk_prompt
);
2760 list_add_head(&package
->sourcelist_media
, &disk
->entry
);
2762 return ERROR_SUCCESS
;