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
32 #include "wine/debug.h"
42 #include "wine/unicode.h"
48 #include "msiserver.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
52 static void remove_tracked_tempfiles( MSIPACKAGE
*package
)
54 struct list
*item
, *cursor
;
56 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->tempfiles
)
58 MSITEMPFILE
*temp
= LIST_ENTRY( item
, MSITEMPFILE
, entry
);
60 list_remove( &temp
->entry
);
61 TRACE("deleting temp file %s\n", debugstr_w( temp
->Path
));
62 DeleteFileW( temp
->Path
);
63 msi_free( temp
->Path
);
68 static void free_feature( MSIFEATURE
*feature
)
70 struct list
*item
, *cursor
;
72 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Children
)
74 FeatureList
*fl
= LIST_ENTRY( item
, FeatureList
, entry
);
75 list_remove( &fl
->entry
);
79 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Components
)
81 ComponentList
*cl
= LIST_ENTRY( item
, ComponentList
, entry
);
82 list_remove( &cl
->entry
);
85 msi_free( feature
->Feature
);
86 msi_free( feature
->Feature_Parent
);
87 msi_free( feature
->Directory
);
88 msi_free( feature
->Description
);
89 msi_free( feature
->Title
);
93 static void free_folder( MSIFOLDER
*folder
)
95 struct list
*item
, *cursor
;
97 LIST_FOR_EACH_SAFE( item
, cursor
, &folder
->children
)
99 FolderList
*fl
= LIST_ENTRY( item
, FolderList
, entry
);
100 list_remove( &fl
->entry
);
103 msi_free( folder
->Parent
);
104 msi_free( folder
->Directory
);
105 msi_free( folder
->TargetDefault
);
106 msi_free( folder
->SourceLongPath
);
107 msi_free( folder
->SourceShortPath
);
108 msi_free( folder
->ResolvedTarget
);
109 msi_free( folder
->ResolvedSource
);
113 static void free_extension( MSIEXTENSION
*ext
)
115 struct list
*item
, *cursor
;
117 LIST_FOR_EACH_SAFE( item
, cursor
, &ext
->verbs
)
119 MSIVERB
*verb
= LIST_ENTRY( item
, MSIVERB
, entry
);
121 list_remove( &verb
->entry
);
122 msi_free( verb
->Verb
);
123 msi_free( verb
->Command
);
124 msi_free( verb
->Argument
);
128 msi_free( ext
->Extension
);
129 msi_free( ext
->ProgIDText
);
133 static void free_assembly( MSIASSEMBLY
*assembly
)
135 msi_free( assembly
->feature
);
136 msi_free( assembly
->manifest
);
137 msi_free( assembly
->application
);
138 msi_free( assembly
->display_name
);
139 if (assembly
->tempdir
) RemoveDirectoryW( assembly
->tempdir
);
140 msi_free( assembly
->tempdir
);
141 msi_free( assembly
);
144 void msi_free_action_script( MSIPACKAGE
*package
, UINT script
)
147 for (i
= 0; i
< package
->script
->ActionCount
[script
]; i
++)
148 msi_free( package
->script
->Actions
[script
][i
] );
150 msi_free( package
->script
->Actions
[script
] );
151 package
->script
->Actions
[script
] = NULL
;
152 package
->script
->ActionCount
[script
] = 0;
155 static void free_package_structures( MSIPACKAGE
*package
)
157 struct list
*item
, *cursor
;
159 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->features
)
161 MSIFEATURE
*feature
= LIST_ENTRY( item
, MSIFEATURE
, entry
);
162 list_remove( &feature
->entry
);
163 free_feature( feature
);
166 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->folders
)
168 MSIFOLDER
*folder
= LIST_ENTRY( item
, MSIFOLDER
, entry
);
169 list_remove( &folder
->entry
);
170 free_folder( folder
);
173 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->components
)
175 MSICOMPONENT
*comp
= LIST_ENTRY( item
, MSICOMPONENT
, entry
);
177 list_remove( &comp
->entry
);
178 msi_free( comp
->Component
);
179 msi_free( comp
->ComponentId
);
180 msi_free( comp
->Directory
);
181 msi_free( comp
->Condition
);
182 msi_free( comp
->KeyPath
);
183 msi_free( comp
->FullKeypath
);
184 if (comp
->assembly
) free_assembly( comp
->assembly
);
188 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->files
)
190 MSIFILE
*file
= LIST_ENTRY( item
, MSIFILE
, entry
);
192 list_remove( &file
->entry
);
193 msi_free( file
->File
);
194 msi_free( file
->FileName
);
195 msi_free( file
->ShortName
);
196 msi_free( file
->LongName
);
197 msi_free( file
->Version
);
198 msi_free( file
->Language
);
199 msi_free( file
->TargetPath
);
203 /* clean up extension, progid, class and verb structures */
204 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->classes
)
206 MSICLASS
*cls
= LIST_ENTRY( item
, MSICLASS
, entry
);
208 list_remove( &cls
->entry
);
209 msi_free( cls
->clsid
);
210 msi_free( cls
->Context
);
211 msi_free( cls
->Description
);
212 msi_free( cls
->FileTypeMask
);
213 msi_free( cls
->IconPath
);
214 msi_free( cls
->DefInprocHandler
);
215 msi_free( cls
->DefInprocHandler32
);
216 msi_free( cls
->Argument
);
217 msi_free( cls
->ProgIDText
);
221 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->extensions
)
223 MSIEXTENSION
*ext
= LIST_ENTRY( item
, MSIEXTENSION
, entry
);
225 list_remove( &ext
->entry
);
226 free_extension( ext
);
229 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->progids
)
231 MSIPROGID
*progid
= LIST_ENTRY( item
, MSIPROGID
, entry
);
233 list_remove( &progid
->entry
);
234 msi_free( progid
->ProgID
);
235 msi_free( progid
->Description
);
236 msi_free( progid
->IconPath
);
240 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->mimes
)
242 MSIMIME
*mt
= LIST_ENTRY( item
, MSIMIME
, entry
);
244 list_remove( &mt
->entry
);
245 msi_free( mt
->suffix
);
246 msi_free( mt
->clsid
);
247 msi_free( mt
->ContentType
);
251 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->appids
)
253 MSIAPPID
*appid
= LIST_ENTRY( item
, MSIAPPID
, entry
);
255 list_remove( &appid
->entry
);
256 msi_free( appid
->AppID
);
257 msi_free( appid
->RemoteServerName
);
258 msi_free( appid
->LocalServer
);
259 msi_free( appid
->ServiceParameters
);
260 msi_free( appid
->DllSurrogate
);
264 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->sourcelist_info
)
266 MSISOURCELISTINFO
*info
= LIST_ENTRY( item
, MSISOURCELISTINFO
, entry
);
268 list_remove( &info
->entry
);
269 msi_free( info
->value
);
273 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->sourcelist_media
)
275 MSIMEDIADISK
*info
= LIST_ENTRY( item
, MSIMEDIADISK
, entry
);
277 list_remove( &info
->entry
);
278 msi_free( info
->volume_label
);
279 msi_free( info
->disk_prompt
);
288 for (i
= 0; i
< SCRIPT_MAX
; i
++)
289 msi_free_action_script( package
, i
);
291 for (j
= 0; j
< package
->script
->UniqueActionsCount
; j
++)
292 msi_free( package
->script
->UniqueActions
[j
] );
294 msi_free( package
->script
->UniqueActions
);
295 msi_free( package
->script
);
298 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->binaries
)
300 MSIBINARY
*binary
= LIST_ENTRY( item
, MSIBINARY
, entry
);
302 list_remove( &binary
->entry
);
304 FreeLibrary( binary
->module
);
305 if (!DeleteFileW( binary
->tmpfile
))
306 ERR("failed to delete %s (%u)\n", debugstr_w(binary
->tmpfile
), GetLastError());
307 msi_free( binary
->source
);
308 msi_free( binary
->tmpfile
);
312 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->cabinet_streams
)
314 MSICABINETSTREAM
*cab
= LIST_ENTRY( item
, MSICABINETSTREAM
, entry
);
316 list_remove( &cab
->entry
);
317 IStorage_Release( cab
->storage
);
318 msi_free( cab
->stream
);
322 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->patches
)
324 MSIPATCHINFO
*patch
= LIST_ENTRY( item
, MSIPATCHINFO
, entry
);
326 list_remove( &patch
->entry
);
327 if (patch
->delete_on_close
&& !DeleteFileW( patch
->localfile
))
329 ERR("failed to delete %s (%u)\n", debugstr_w(patch
->localfile
), GetLastError());
331 msi_free_patchinfo( patch
);
334 msi_free( package
->BaseURL
);
335 msi_free( package
->PackagePath
);
336 msi_free( package
->ProductCode
);
337 msi_free( package
->ActionFormat
);
338 msi_free( package
->LastAction
);
339 msi_free( package
->langids
);
341 remove_tracked_tempfiles(package
);
343 /* cleanup control event subscriptions */
344 msi_event_cleanup_all_subscriptions( package
);
347 static void MSI_FreePackage( MSIOBJECTHDR
*arg
)
349 MSIPACKAGE
*package
= (MSIPACKAGE
*)arg
;
351 msi_destroy_assembly_caches( package
);
353 if( package
->dialog
)
354 msi_dialog_destroy( package
->dialog
);
356 msiobj_release( &package
->db
->hdr
);
357 free_package_structures(package
);
358 CloseHandle( package
->log_file
);
360 if (package
->delete_on_close
) DeleteFileW( package
->localfile
);
361 msi_free( package
->localfile
);
364 static UINT
create_temp_property_table(MSIPACKAGE
*package
)
366 static const WCHAR query
[] = {
367 'C','R','E','A','T','E',' ','T','A','B','L','E',' ',
368 '`','_','P','r','o','p','e','r','t','y','`',' ','(',' ',
369 '`','_','P','r','o','p','e','r','t','y','`',' ',
370 'C','H','A','R','(','5','6',')',' ','N','O','T',' ','N','U','L','L',' ',
371 'T','E','M','P','O','R','A','R','Y',',',' ',
372 '`','V','a','l','u','e','`',' ','C','H','A','R','(','9','8',')',' ',
373 'N','O','T',' ','N','U','L','L',' ','T','E','M','P','O','R','A','R','Y',
374 ' ','P','R','I','M','A','R','Y',' ','K','E','Y',' ',
375 '`','_','P','r','o','p','e','r','t','y','`',')',' ','H','O','L','D',0};
379 rc
= MSI_DatabaseOpenViewW(package
->db
, query
, &view
);
380 if (rc
!= ERROR_SUCCESS
)
383 rc
= MSI_ViewExecute(view
, 0);
385 msiobj_release(&view
->hdr
);
389 UINT
msi_clone_properties(MSIPACKAGE
*package
)
391 static const WCHAR query_select
[] = {
392 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
393 '`','P','r','o','p','e','r','t','y','`',0};
394 static const WCHAR query_insert
[] = {
395 'I','N','S','E','R','T',' ','I','N','T','O',' ',
396 '`','_','P','r','o','p','e','r','t','y','`',' ',
397 '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
398 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
399 static const WCHAR query_update
[] = {
400 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
401 'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ',
402 'W','H','E','R','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','?',0};
403 MSIQUERY
*view_select
;
406 rc
= MSI_DatabaseOpenViewW( package
->db
, query_select
, &view_select
);
407 if (rc
!= ERROR_SUCCESS
)
410 rc
= MSI_ViewExecute( view_select
, 0 );
411 if (rc
!= ERROR_SUCCESS
)
413 MSI_ViewClose( view_select
);
414 msiobj_release( &view_select
->hdr
);
420 MSIQUERY
*view_insert
, *view_update
;
421 MSIRECORD
*rec_select
;
423 rc
= MSI_ViewFetch( view_select
, &rec_select
);
424 if (rc
!= ERROR_SUCCESS
)
427 rc
= MSI_DatabaseOpenViewW( package
->db
, query_insert
, &view_insert
);
428 if (rc
!= ERROR_SUCCESS
)
430 msiobj_release( &rec_select
->hdr
);
434 rc
= MSI_ViewExecute( view_insert
, rec_select
);
435 MSI_ViewClose( view_insert
);
436 msiobj_release( &view_insert
->hdr
);
437 if (rc
!= ERROR_SUCCESS
)
439 MSIRECORD
*rec_update
;
441 TRACE("insert failed, trying update\n");
443 rc
= MSI_DatabaseOpenViewW( package
->db
, query_update
, &view_update
);
444 if (rc
!= ERROR_SUCCESS
)
446 WARN("open view failed %u\n", rc
);
447 msiobj_release( &rec_select
->hdr
);
451 rec_update
= MSI_CreateRecord( 2 );
452 MSI_RecordCopyField( rec_select
, 1, rec_update
, 2 );
453 MSI_RecordCopyField( rec_select
, 2, rec_update
, 1 );
454 rc
= MSI_ViewExecute( view_update
, rec_update
);
455 if (rc
!= ERROR_SUCCESS
)
456 WARN("update failed %u\n", rc
);
458 MSI_ViewClose( view_update
);
459 msiobj_release( &view_update
->hdr
);
460 msiobj_release( &rec_update
->hdr
);
463 msiobj_release( &rec_select
->hdr
);
466 MSI_ViewClose( view_select
);
467 msiobj_release( &view_select
->hdr
);
474 * Sets the "Installed" property to indicate that
475 * the product is installed for the current user.
477 static UINT
set_installed_prop( MSIPACKAGE
*package
)
482 if (!package
->ProductCode
) return ERROR_FUNCTION_FAILED
;
484 r
= MSIREG_OpenUninstallKey( package
->ProductCode
, package
->platform
, &hkey
, FALSE
);
485 if (r
== ERROR_SUCCESS
)
488 msi_set_property( package
->db
, szInstalled
, szOne
, -1 );
493 static UINT
set_user_sid_prop( MSIPACKAGE
*package
)
497 LPWSTR sid_str
= NULL
, dom
= NULL
;
498 DWORD size
, dom_size
;
500 UINT r
= ERROR_FUNCTION_FAILED
;
503 GetUserNameW( NULL
, &size
);
505 user_name
= msi_alloc( (size
+ 1) * sizeof(WCHAR
) );
507 return ERROR_OUTOFMEMORY
;
509 if (!GetUserNameW( user_name
, &size
))
514 LookupAccountNameW( NULL
, user_name
, NULL
, &size
, NULL
, &dom_size
, &use
);
516 psid
= msi_alloc( size
);
517 dom
= msi_alloc( dom_size
*sizeof (WCHAR
) );
520 r
= ERROR_OUTOFMEMORY
;
524 if (!LookupAccountNameW( NULL
, user_name
, psid
, &size
, dom
, &dom_size
, &use
))
527 if (!ConvertSidToStringSidW( psid
, &sid_str
))
530 r
= msi_set_property( package
->db
, szUserSID
, sid_str
, -1 );
533 LocalFree( sid_str
);
536 msi_free( user_name
);
541 static LPWSTR
get_fusion_filename(MSIPACKAGE
*package
)
546 DWORD index
= 0, size
;
548 WCHAR name
[MAX_PATH
];
549 WCHAR windir
[MAX_PATH
];
551 static const WCHAR fusion
[] = {'f','u','s','i','o','n','.','d','l','l',0};
552 static const WCHAR sub
[] = {
553 'S','o','f','t','w','a','r','e','\\',
554 'M','i','c','r','o','s','o','f','t','\\',
555 'N','E','T',' ','F','r','a','m','e','w','o','r','k',' ','S','e','t','u','p','\\',
558 static const WCHAR subdir
[] = {
559 'M','i','c','r','o','s','o','f','t','.','N','E','T','\\',
560 'F','r','a','m','e','w','o','r','k','\\',0
563 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, sub
, 0, KEY_ENUMERATE_SUB_KEYS
, &netsetup
);
564 if (res
!= ERROR_SUCCESS
)
567 GetWindowsDirectoryW(windir
, MAX_PATH
);
571 while (RegEnumKeyExW(netsetup
, index
, name
, &size
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
575 /* verify existence of fusion.dll .Net 3.0 does not install a new one */
576 if (strcmpW( ver
, name
) < 0)
579 size
= lstrlenW(windir
) + lstrlenW(subdir
) + lstrlenW(name
) +lstrlenW(fusion
) + 3;
580 check
= msi_alloc(size
* sizeof(WCHAR
));
588 lstrcpyW(check
, windir
);
589 lstrcatW(check
, szBackSlash
);
590 lstrcatW(check
, subdir
);
591 lstrcatW(check
, name
);
592 lstrcatW(check
, szBackSlash
);
593 lstrcatW(check
, fusion
);
595 if(GetFileAttributesW(check
) != INVALID_FILE_ATTRIBUTES
)
606 RegCloseKey(netsetup
);
610 typedef struct tagLANGANDCODEPAGE
616 static void set_msi_assembly_prop(MSIPACKAGE
*package
)
620 LPVOID version
= NULL
;
622 LPWSTR fusion
, verstr
;
623 LANGANDCODEPAGE
*translate
;
625 static const WCHAR netasm
[] = {
626 'M','s','i','N','e','t','A','s','s','e','m','b','l','y','S','u','p','p','o','r','t',0
628 static const WCHAR translation
[] = {
629 '\\','V','a','r','F','i','l','e','I','n','f','o',
630 '\\','T','r','a','n','s','l','a','t','i','o','n',0
632 static const WCHAR verfmt
[] = {
633 '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
634 '\\','%','0','4','x','%','0','4','x',
635 '\\','P','r','o','d','u','c','t','V','e','r','s','i','o','n',0
638 fusion
= get_fusion_filename(package
);
642 size
= GetFileVersionInfoSizeW(fusion
, &handle
);
646 version
= msi_alloc(size
);
650 if (!GetFileVersionInfoW(fusion
, handle
, size
, version
))
653 if (!VerQueryValueW(version
, translation
, (LPVOID
*)&translate
, &val_len
))
656 sprintfW(buf
, verfmt
, translate
[0].wLanguage
, translate
[0].wCodePage
);
658 if (!VerQueryValueW(version
, buf
, (LPVOID
*)&verstr
, &val_len
))
661 if (!val_len
|| !verstr
)
664 msi_set_property( package
->db
, netasm
, verstr
, -1 );
671 static VOID
set_installer_properties(MSIPACKAGE
*package
)
674 OSVERSIONINFOEXW OSVersion
;
677 WCHAR pth
[MAX_PATH
], verstr
[11], bufstr
[22];
680 LPWSTR username
, companyname
;
681 SYSTEM_INFO sys_info
;
682 SYSTEMTIME systemtime
;
685 static const WCHAR szCommonFilesFolder
[] = {'C','o','m','m','o','n','F','i','l','e','s','F','o','l','d','e','r',0};
686 static const WCHAR szProgramFilesFolder
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','F','o','l','d','e','r',0};
687 static const WCHAR szCommonAppDataFolder
[] = {'C','o','m','m','o','n','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
688 static const WCHAR szFavoritesFolder
[] = {'F','a','v','o','r','i','t','e','s','F','o','l','d','e','r',0};
689 static const WCHAR szFontsFolder
[] = {'F','o','n','t','s','F','o','l','d','e','r',0};
690 static const WCHAR szSendToFolder
[] = {'S','e','n','d','T','o','F','o','l','d','e','r',0};
691 static const WCHAR szStartMenuFolder
[] = {'S','t','a','r','t','M','e','n','u','F','o','l','d','e','r',0};
692 static const WCHAR szStartupFolder
[] = {'S','t','a','r','t','u','p','F','o','l','d','e','r',0};
693 static const WCHAR szTemplateFolder
[] = {'T','e','m','p','l','a','t','e','F','o','l','d','e','r',0};
694 static const WCHAR szDesktopFolder
[] = {'D','e','s','k','t','o','p','F','o','l','d','e','r',0};
695 static const WCHAR szProgramMenuFolder
[] = {'P','r','o','g','r','a','m','M','e','n','u','F','o','l','d','e','r',0};
696 static const WCHAR szAdminToolsFolder
[] = {'A','d','m','i','n','T','o','o','l','s','F','o','l','d','e','r',0};
697 static const WCHAR szSystemFolder
[] = {'S','y','s','t','e','m','F','o','l','d','e','r',0};
698 static const WCHAR szSystem16Folder
[] = {'S','y','s','t','e','m','1','6','F','o','l','d','e','r',0};
699 static const WCHAR szLocalAppDataFolder
[] = {'L','o','c','a','l','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
700 static const WCHAR szMyPicturesFolder
[] = {'M','y','P','i','c','t','u','r','e','s','F','o','l','d','e','r',0};
701 static const WCHAR szPersonalFolder
[] = {'P','e','r','s','o','n','a','l','F','o','l','d','e','r',0};
702 static const WCHAR szWindowsVolume
[] = {'W','i','n','d','o','w','s','V','o','l','u','m','e',0};
703 static const WCHAR szPrivileged
[] = {'P','r','i','v','i','l','e','g','e','d',0};
704 static const WCHAR szVersion9x
[] = {'V','e','r','s','i','o','n','9','X',0};
705 static const WCHAR szVersionNT
[] = {'V','e','r','s','i','o','n','N','T',0};
706 static const WCHAR szMsiNTProductType
[] = {'M','s','i','N','T','P','r','o','d','u','c','t','T','y','p','e',0};
707 static const WCHAR szFormat
[] = {'%','u',0};
708 static const WCHAR szFormat2
[] = {'%','u','.','%','u',0};
709 static const WCHAR szWindowsBuild
[] = {'W','i','n','d','o','w','s','B','u','i','l','d',0};
710 static const WCHAR szServicePackLevel
[] = {'S','e','r','v','i','c','e','P','a','c','k','L','e','v','e','l',0};
711 static const WCHAR szVersionMsi
[] = { 'V','e','r','s','i','o','n','M','s','i',0 };
712 static const WCHAR szVersionDatabase
[] = { 'V','e','r','s','i','o','n','D','a','t','a','b','a','s','e',0 };
713 static const WCHAR szPhysicalMemory
[] = { 'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0 };
714 static const WCHAR szScreenX
[] = {'S','c','r','e','e','n','X',0};
715 static const WCHAR szScreenY
[] = {'S','c','r','e','e','n','Y',0};
716 static const WCHAR szColorBits
[] = {'C','o','l','o','r','B','i','t','s',0};
717 static const WCHAR szIntFormat
[] = {'%','d',0};
718 static const WCHAR szMsiAMD64
[] = { 'M','s','i','A','M','D','6','4',0 };
719 static const WCHAR szMsix64
[] = { 'M','s','i','x','6','4',0 };
720 static const WCHAR szSystem64Folder
[] = { 'S','y','s','t','e','m','6','4','F','o','l','d','e','r',0 };
721 static const WCHAR szCommonFiles64Folder
[] = { 'C','o','m','m','o','n','F','i','l','e','s','6','4','F','o','l','d','e','r',0 };
722 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 };
723 static const WCHAR szVersionNT64
[] = { 'V','e','r','s','i','o','n','N','T','6','4',0 };
724 static const WCHAR szUserInfo
[] = {
725 'S','O','F','T','W','A','R','E','\\',
726 'M','i','c','r','o','s','o','f','t','\\',
727 'M','S',' ','S','e','t','u','p',' ','(','A','C','M','E',')','\\',
728 'U','s','e','r',' ','I','n','f','o',0
730 static const WCHAR szDefName
[] = { 'D','e','f','N','a','m','e',0 };
731 static const WCHAR szDefCompany
[] = { 'D','e','f','C','o','m','p','a','n','y',0 };
732 static const WCHAR szCurrentVersion
[] = {
733 'S','O','F','T','W','A','R','E','\\',
734 'M','i','c','r','o','s','o','f','t','\\',
735 'W','i','n','d','o','w','s',' ','N','T','\\',
736 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0
738 static const WCHAR szRegisteredUser
[] = {'R','e','g','i','s','t','e','r','e','d','O','w','n','e','r',0};
739 static const WCHAR szRegisteredOrganization
[] = {
740 'R','e','g','i','s','t','e','r','e','d','O','r','g','a','n','i','z','a','t','i','o','n',0
742 static const WCHAR szUSERNAME
[] = {'U','S','E','R','N','A','M','E',0};
743 static const WCHAR szCOMPANYNAME
[] = {'C','O','M','P','A','N','Y','N','A','M','E',0};
744 static const WCHAR szDate
[] = {'D','a','t','e',0};
745 static const WCHAR szTime
[] = {'T','i','m','e',0};
746 static const WCHAR szUserLanguageID
[] = {'U','s','e','r','L','a','n','g','u','a','g','e','I','D',0};
747 static const WCHAR szSystemLangID
[] = {'S','y','s','t','e','m','L','a','n','g','u','a','g','e','I','D',0};
748 static const WCHAR szProductState
[] = {'P','r','o','d','u','c','t','S','t','a','t','e',0};
749 static const WCHAR szLogonUser
[] = {'L','o','g','o','n','U','s','e','r',0};
750 static const WCHAR szNetHoodFolder
[] = {'N','e','t','H','o','o','d','F','o','l','d','e','r',0};
751 static const WCHAR szPrintHoodFolder
[] = {'P','r','i','n','t','H','o','o','d','F','o','l','d','e','r',0};
752 static const WCHAR szRecentFolder
[] = {'R','e','c','e','n','t','F','o','l','d','e','r',0};
753 static const WCHAR szComputerName
[] = {'C','o','m','p','u','t','e','r','N','a','m','e',0};
754 static const WCHAR szBrowseProperty
[] = {'_','B','r','o','w','s','e','P','r','o','p','e','r','t','y',0};
755 static const WCHAR szInstallDir
[] = {'I','N','S','T','A','L','L','D','I','R',0};
758 * Other things that probably should be set:
760 * VirtualMemory ShellAdvSupport DefaultUIFont PackagecodeChanging
761 * CaptionHeight BorderTop BorderSide TextHeight RedirectedDllSupport
764 SHGetFolderPathW(NULL
, CSIDL_COMMON_APPDATA
, NULL
, 0, pth
);
765 strcatW(pth
, szBackSlash
);
766 msi_set_property( package
->db
, szCommonAppDataFolder
, pth
, -1 );
768 SHGetFolderPathW(NULL
, CSIDL_FAVORITES
, NULL
, 0, pth
);
769 strcatW(pth
, szBackSlash
);
770 msi_set_property( package
->db
, szFavoritesFolder
, pth
, -1 );
772 SHGetFolderPathW(NULL
, CSIDL_FONTS
, NULL
, 0, pth
);
773 strcatW(pth
, szBackSlash
);
774 msi_set_property( package
->db
, szFontsFolder
, pth
, -1 );
776 SHGetFolderPathW(NULL
, CSIDL_SENDTO
, NULL
, 0, pth
);
777 strcatW(pth
, szBackSlash
);
778 msi_set_property( package
->db
, szSendToFolder
, pth
, -1 );
780 SHGetFolderPathW(NULL
, CSIDL_STARTMENU
, NULL
, 0, pth
);
781 strcatW(pth
, szBackSlash
);
782 msi_set_property( package
->db
, szStartMenuFolder
, pth
, -1 );
784 SHGetFolderPathW(NULL
, CSIDL_STARTUP
, NULL
, 0, pth
);
785 strcatW(pth
, szBackSlash
);
786 msi_set_property( package
->db
, szStartupFolder
, pth
, -1 );
788 SHGetFolderPathW(NULL
, CSIDL_TEMPLATES
, NULL
, 0, pth
);
789 strcatW(pth
, szBackSlash
);
790 msi_set_property( package
->db
, szTemplateFolder
, pth
, -1 );
792 SHGetFolderPathW(NULL
, CSIDL_DESKTOP
, NULL
, 0, pth
);
793 strcatW(pth
, szBackSlash
);
794 msi_set_property( package
->db
, szDesktopFolder
, pth
, -1 );
796 /* FIXME: set to AllUsers profile path if ALLUSERS is set */
797 SHGetFolderPathW(NULL
, CSIDL_PROGRAMS
, NULL
, 0, pth
);
798 strcatW(pth
, szBackSlash
);
799 msi_set_property( package
->db
, szProgramMenuFolder
, pth
, -1 );
801 SHGetFolderPathW(NULL
, CSIDL_ADMINTOOLS
, NULL
, 0, pth
);
802 strcatW(pth
, szBackSlash
);
803 msi_set_property( package
->db
, szAdminToolsFolder
, pth
, -1 );
805 SHGetFolderPathW(NULL
, CSIDL_APPDATA
, NULL
, 0, pth
);
806 strcatW(pth
, szBackSlash
);
807 msi_set_property( package
->db
, szAppDataFolder
, pth
, -1 );
809 SHGetFolderPathW(NULL
, CSIDL_SYSTEM
, NULL
, 0, pth
);
810 strcatW(pth
, szBackSlash
);
811 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
812 msi_set_property( package
->db
, szSystem16Folder
, pth
, -1 );
814 SHGetFolderPathW(NULL
, CSIDL_LOCAL_APPDATA
, NULL
, 0, pth
);
815 strcatW(pth
, szBackSlash
);
816 msi_set_property( package
->db
, szLocalAppDataFolder
, pth
, -1 );
818 SHGetFolderPathW(NULL
, CSIDL_MYPICTURES
, NULL
, 0, pth
);
819 strcatW(pth
, szBackSlash
);
820 msi_set_property( package
->db
, szMyPicturesFolder
, pth
, -1 );
822 SHGetFolderPathW(NULL
, CSIDL_PERSONAL
, NULL
, 0, pth
);
823 strcatW(pth
, szBackSlash
);
824 msi_set_property( package
->db
, szPersonalFolder
, pth
, -1 );
826 SHGetFolderPathW(NULL
, CSIDL_WINDOWS
, NULL
, 0, pth
);
827 strcatW(pth
, szBackSlash
);
828 msi_set_property( package
->db
, szWindowsFolder
, pth
, -1 );
830 SHGetFolderPathW(NULL
, CSIDL_PRINTHOOD
, NULL
, 0, pth
);
831 strcatW(pth
, szBackSlash
);
832 msi_set_property( package
->db
, szPrintHoodFolder
, pth
, -1 );
834 SHGetFolderPathW(NULL
, CSIDL_NETHOOD
, NULL
, 0, pth
);
835 strcatW(pth
, szBackSlash
);
836 msi_set_property( package
->db
, szNetHoodFolder
, pth
, -1 );
838 SHGetFolderPathW(NULL
, CSIDL_RECENT
, NULL
, 0, pth
);
839 strcatW(pth
, szBackSlash
);
840 msi_set_property( package
->db
, szRecentFolder
, pth
, -1 );
842 /* Physical Memory is specified in MB. Using total amount. */
843 msex
.dwLength
= sizeof(msex
);
844 GlobalMemoryStatusEx( &msex
);
845 len
= sprintfW( bufstr
, szIntFormat
, (int)(msex
.ullTotalPhys
/ 1024 / 1024) );
846 msi_set_property( package
->db
, szPhysicalMemory
, bufstr
, len
);
848 SHGetFolderPathW(NULL
, CSIDL_WINDOWS
, NULL
, 0, pth
);
849 ptr
= strchrW(pth
,'\\');
850 if (ptr
) *(ptr
+ 1) = 0;
851 msi_set_property( package
->db
, szWindowsVolume
, pth
, -1 );
853 len
= GetTempPathW(MAX_PATH
, pth
);
854 msi_set_property( package
->db
, szTempFolder
, pth
, len
);
856 /* in a wine environment the user is always admin and privileged */
857 msi_set_property( package
->db
, szAdminUser
, szOne
, -1 );
858 msi_set_property( package
->db
, szPrivileged
, szOne
, -1 );
860 /* set the os things */
861 OSVersion
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
862 GetVersionExW((OSVERSIONINFOW
*)&OSVersion
);
863 verval
= OSVersion
.dwMinorVersion
+ OSVersion
.dwMajorVersion
* 100;
864 len
= sprintfW( verstr
, szFormat
, verval
);
865 switch (OSVersion
.dwPlatformId
)
867 case VER_PLATFORM_WIN32_WINDOWS
:
868 msi_set_property( package
->db
, szVersion9x
, verstr
, len
);
870 case VER_PLATFORM_WIN32_NT
:
871 msi_set_property( package
->db
, szVersionNT
, verstr
, len
);
872 len
= sprintfW( bufstr
, szFormat
,OSVersion
.wProductType
);
873 msi_set_property( package
->db
, szMsiNTProductType
, bufstr
, len
);
876 len
= sprintfW( bufstr
, szFormat
, OSVersion
.dwBuildNumber
);
877 msi_set_property( package
->db
, szWindowsBuild
, bufstr
, len
);
878 len
= sprintfW( bufstr
, szFormat
, OSVersion
.wServicePackMajor
);
879 msi_set_property( package
->db
, szServicePackLevel
, bufstr
, len
);
881 len
= sprintfW( bufstr
, szFormat2
, MSI_MAJORVERSION
, MSI_MINORVERSION
);
882 msi_set_property( package
->db
, szVersionMsi
, bufstr
, len
);
883 len
= sprintfW( bufstr
, szFormat
, MSI_MAJORVERSION
* 100 );
884 msi_set_property( package
->db
, szVersionDatabase
, bufstr
, len
);
886 GetNativeSystemInfo( &sys_info
);
887 len
= sprintfW( bufstr
, szIntFormat
, sys_info
.wProcessorLevel
);
888 msi_set_property( package
->db
, szIntel
, bufstr
, len
);
889 if (sys_info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
891 GetSystemDirectoryW( pth
, MAX_PATH
);
892 PathAddBackslashW( pth
);
893 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
895 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, pth
);
896 PathAddBackslashW( pth
);
897 msi_set_property( package
->db
, szProgramFilesFolder
, pth
, -1 );
899 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, pth
);
900 PathAddBackslashW( pth
);
901 msi_set_property( package
->db
, szCommonFilesFolder
, pth
, -1 );
903 else if (sys_info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
)
905 msi_set_property( package
->db
, szMsiAMD64
, bufstr
, -1 );
906 msi_set_property( package
->db
, szMsix64
, bufstr
, -1 );
907 msi_set_property( package
->db
, szVersionNT64
, verstr
, -1 );
909 GetSystemDirectoryW( pth
, MAX_PATH
);
910 PathAddBackslashW( pth
);
911 msi_set_property( package
->db
, szSystem64Folder
, pth
, -1 );
913 GetSystemWow64DirectoryW( pth
, MAX_PATH
);
914 PathAddBackslashW( pth
);
915 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
917 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, pth
);
918 PathAddBackslashW( pth
);
919 msi_set_property( package
->db
, szProgramFiles64Folder
, pth
, -1 );
921 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, pth
);
922 PathAddBackslashW( pth
);
923 msi_set_property( package
->db
, szProgramFilesFolder
, pth
, -1 );
925 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, pth
);
926 PathAddBackslashW( pth
);
927 msi_set_property( package
->db
, szCommonFiles64Folder
, pth
, -1 );
929 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, pth
);
930 PathAddBackslashW( pth
);
931 msi_set_property( package
->db
, szCommonFilesFolder
, pth
, -1 );
934 /* Screen properties. */
936 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, HORZRES
) );
937 msi_set_property( package
->db
, szScreenX
, bufstr
, len
);
938 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, VERTRES
) );
939 msi_set_property( package
->db
, szScreenY
, bufstr
, len
);
940 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, BITSPIXEL
) );
941 msi_set_property( package
->db
, szColorBits
, bufstr
, len
);
944 /* USERNAME and COMPANYNAME */
945 username
= msi_dup_property( package
->db
, szUSERNAME
);
946 companyname
= msi_dup_property( package
->db
, szCOMPANYNAME
);
948 if ((!username
|| !companyname
) &&
949 RegOpenKeyW( HKEY_CURRENT_USER
, szUserInfo
, &hkey
) == ERROR_SUCCESS
)
952 (username
= msi_reg_get_val_str( hkey
, szDefName
)))
953 msi_set_property( package
->db
, szUSERNAME
, username
, -1 );
955 (companyname
= msi_reg_get_val_str( hkey
, szDefCompany
)))
956 msi_set_property( package
->db
, szCOMPANYNAME
, companyname
, -1 );
959 if ((!username
|| !companyname
) &&
960 RegOpenKeyW( HKEY_LOCAL_MACHINE
, szCurrentVersion
, &hkey
) == ERROR_SUCCESS
)
963 (username
= msi_reg_get_val_str( hkey
, szRegisteredUser
)))
964 msi_set_property( package
->db
, szUSERNAME
, username
, -1 );
966 (companyname
= msi_reg_get_val_str( hkey
, szRegisteredOrganization
)))
967 msi_set_property( package
->db
, szCOMPANYNAME
, companyname
, -1 );
970 msi_free( username
);
971 msi_free( companyname
);
973 if ( set_user_sid_prop( package
) != ERROR_SUCCESS
)
974 ERR("Failed to set the UserSID property\n");
976 /* Date and time properties */
977 GetSystemTime( &systemtime
);
978 if (GetDateFormatW( LOCALE_USER_DEFAULT
, DATE_SHORTDATE
, &systemtime
,
979 NULL
, bufstr
, sizeof(bufstr
)/sizeof(bufstr
[0]) ))
980 msi_set_property( package
->db
, szDate
, bufstr
, -1 );
982 ERR("Couldn't set Date property: GetDateFormat failed with error %d\n", GetLastError());
984 if (GetTimeFormatW( LOCALE_USER_DEFAULT
,
985 TIME_FORCE24HOURFORMAT
| TIME_NOTIMEMARKER
,
986 &systemtime
, NULL
, bufstr
,
987 sizeof(bufstr
)/sizeof(bufstr
[0]) ))
988 msi_set_property( package
->db
, szTime
, bufstr
, -1 );
990 ERR("Couldn't set Time property: GetTimeFormat failed with error %d\n", GetLastError());
992 set_msi_assembly_prop( package
);
994 langid
= GetUserDefaultLangID();
995 len
= sprintfW( bufstr
, szIntFormat
, langid
);
996 msi_set_property( package
->db
, szUserLanguageID
, bufstr
, len
);
998 langid
= GetSystemDefaultLangID();
999 len
= sprintfW( bufstr
, szIntFormat
, langid
);
1000 msi_set_property( package
->db
, szSystemLangID
, bufstr
, len
);
1002 len
= sprintfW( bufstr
, szIntFormat
, MsiQueryProductStateW(package
->ProductCode
) );
1003 msi_set_property( package
->db
, szProductState
, bufstr
, len
);
1006 if (!GetUserNameW( NULL
, &len
) && GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
1009 if ((username
= msi_alloc( len
* sizeof(WCHAR
) )))
1011 if (GetUserNameW( username
, &len
))
1012 msi_set_property( package
->db
, szLogonUser
, username
, len
- 1 );
1013 msi_free( username
);
1017 if (!GetComputerNameW( NULL
, &len
) && GetLastError() == ERROR_BUFFER_OVERFLOW
)
1019 WCHAR
*computername
;
1020 if ((computername
= msi_alloc( len
* sizeof(WCHAR
) )))
1022 if (GetComputerNameW( computername
, &len
))
1023 msi_set_property( package
->db
, szComputerName
, computername
, len
);
1024 msi_free( computername
);
1027 msi_set_property( package
->db
, szBrowseProperty
, szInstallDir
, -1 );
1030 static UINT
msi_load_summary_properties( MSIPACKAGE
*package
)
1034 MSIHANDLE hdb
= alloc_msihandle( &package
->db
->hdr
);
1037 LPWSTR package_code
;
1038 static const WCHAR szPackageCode
[] = {
1039 'P','a','c','k','a','g','e','C','o','d','e',0};
1042 ERR("Unable to allocate handle\n");
1043 return ERROR_OUTOFMEMORY
;
1046 rc
= MsiGetSummaryInformationW( hdb
, NULL
, 0, &suminfo
);
1047 MsiCloseHandle(hdb
);
1048 if (rc
!= ERROR_SUCCESS
)
1050 ERR("Unable to open Summary Information\n");
1054 rc
= MsiSummaryInfoGetPropertyW( suminfo
, PID_PAGECOUNT
, NULL
,
1055 &count
, NULL
, NULL
, NULL
);
1056 if (rc
!= ERROR_SUCCESS
)
1058 WARN("Unable to query page count: %d\n", rc
);
1062 /* load package code property */
1064 rc
= MsiSummaryInfoGetPropertyW( suminfo
, PID_REVNUMBER
, NULL
,
1065 NULL
, NULL
, NULL
, &len
);
1066 if (rc
!= ERROR_MORE_DATA
)
1068 WARN("Unable to query revision number: %d\n", rc
);
1069 rc
= ERROR_FUNCTION_FAILED
;
1074 package_code
= msi_alloc( len
* sizeof(WCHAR
) );
1075 rc
= MsiSummaryInfoGetPropertyW( suminfo
, PID_REVNUMBER
, NULL
,
1076 NULL
, NULL
, package_code
, &len
);
1077 if (rc
!= ERROR_SUCCESS
)
1079 WARN("Unable to query rev number: %d\n", rc
);
1080 msi_free( package_code
);
1084 msi_set_property( package
->db
, szPackageCode
, package_code
, len
);
1085 msi_free( package_code
);
1087 /* load package attributes */
1089 MsiSummaryInfoGetPropertyW( suminfo
, PID_WORDCOUNT
, NULL
,
1090 &count
, NULL
, NULL
, NULL
);
1091 package
->WordCount
= count
;
1094 MsiCloseHandle(suminfo
);
1098 static MSIPACKAGE
*msi_alloc_package( void )
1100 MSIPACKAGE
*package
;
1102 package
= alloc_msiobject( MSIHANDLETYPE_PACKAGE
, sizeof (MSIPACKAGE
),
1106 list_init( &package
->components
);
1107 list_init( &package
->features
);
1108 list_init( &package
->files
);
1109 list_init( &package
->filepatches
);
1110 list_init( &package
->tempfiles
);
1111 list_init( &package
->folders
);
1112 list_init( &package
->subscriptions
);
1113 list_init( &package
->appids
);
1114 list_init( &package
->classes
);
1115 list_init( &package
->mimes
);
1116 list_init( &package
->extensions
);
1117 list_init( &package
->progids
);
1118 list_init( &package
->RunningActions
);
1119 list_init( &package
->sourcelist_info
);
1120 list_init( &package
->sourcelist_media
);
1121 list_init( &package
->patches
);
1122 list_init( &package
->binaries
);
1123 list_init( &package
->cabinet_streams
);
1129 static UINT
msi_load_admin_properties(MSIPACKAGE
*package
)
1134 static const WCHAR stmname
[] = {'A','d','m','i','n','P','r','o','p','e','r','t','i','e','s',0};
1136 r
= read_stream_data(package
->db
->storage
, stmname
, FALSE
, &data
, &sz
);
1137 if (r
!= ERROR_SUCCESS
)
1140 r
= msi_parse_command_line(package
, (WCHAR
*)data
, TRUE
);
1146 void msi_adjust_privilege_properties( MSIPACKAGE
*package
)
1148 /* FIXME: this should depend on the user's privileges */
1149 if (msi_get_property_int( package
->db
, szAllUsers
, 0 ) == 2)
1151 TRACE("resetting ALLUSERS property from 2 to 1\n");
1152 msi_set_property( package
->db
, szAllUsers
, szOne
, -1 );
1154 msi_set_property( package
->db
, szAdminUser
, szOne
, -1 );
1157 MSIPACKAGE
*MSI_CreatePackage( MSIDATABASE
*db
, LPCWSTR base_url
)
1159 static const WCHAR fmtW
[] = {'%','u',0};
1160 MSIPACKAGE
*package
;
1167 package
= msi_alloc_package();
1170 msiobj_addref( &db
->hdr
);
1173 package
->WordCount
= 0;
1174 package
->PackagePath
= strdupW( db
->path
);
1175 package
->BaseURL
= strdupW( base_url
);
1177 create_temp_property_table( package
);
1178 msi_clone_properties( package
);
1179 msi_adjust_privilege_properties( package
);
1181 package
->ProductCode
= msi_dup_property( package
->db
, szProductCode
);
1182 package
->script
= msi_alloc_zero( sizeof(MSISCRIPT
) );
1184 set_installed_prop( package
);
1185 set_installer_properties( package
);
1187 package
->ui_level
= gUILevel
;
1188 len
= sprintfW( uilevel
, fmtW
, gUILevel
& INSTALLUILEVEL_MASK
);
1189 msi_set_property( package
->db
, szUILevel
, uilevel
, len
);
1191 r
= msi_load_summary_properties( package
);
1192 if (r
!= ERROR_SUCCESS
)
1194 msiobj_release( &package
->hdr
);
1198 if (package
->WordCount
& msidbSumInfoSourceTypeAdminImage
)
1199 msi_load_admin_properties( package
);
1201 package
->log_file
= INVALID_HANDLE_VALUE
;
1206 UINT
msi_download_file( LPCWSTR szUrl
, LPWSTR filename
)
1208 LPINTERNET_CACHE_ENTRY_INFOW cache_entry
;
1212 /* call will always fail, because size is 0,
1213 * but will return ERROR_FILE_NOT_FOUND first
1214 * if the file doesn't exist
1216 GetUrlCacheEntryInfoW( szUrl
, NULL
, &size
);
1217 if ( GetLastError() != ERROR_FILE_NOT_FOUND
)
1219 cache_entry
= msi_alloc( size
);
1220 if ( !GetUrlCacheEntryInfoW( szUrl
, cache_entry
, &size
) )
1222 UINT error
= GetLastError();
1223 msi_free( cache_entry
);
1227 lstrcpyW( filename
, cache_entry
->lpszLocalFileName
);
1228 msi_free( cache_entry
);
1229 return ERROR_SUCCESS
;
1232 hr
= URLDownloadToCacheFileW( NULL
, szUrl
, filename
, MAX_PATH
, 0, NULL
);
1235 WARN("failed to download %s to cache file\n", debugstr_w(szUrl
));
1236 return ERROR_FUNCTION_FAILED
;
1239 return ERROR_SUCCESS
;
1242 UINT
msi_create_empty_local_file( LPWSTR path
, LPCWSTR suffix
)
1244 static const WCHAR szInstaller
[] = {
1245 '\\','I','n','s','t','a','l','l','e','r','\\',0};
1246 static const WCHAR fmt
[] = {'%','x',0};
1247 DWORD time
, len
, i
, offset
;
1250 time
= GetTickCount();
1251 GetWindowsDirectoryW( path
, MAX_PATH
);
1252 strcatW( path
, szInstaller
);
1253 CreateDirectoryW( path
, NULL
);
1255 len
= strlenW(path
);
1256 for (i
= 0; i
< 0x10000; i
++)
1258 offset
= snprintfW( path
+ len
, MAX_PATH
- len
, fmt
, (time
+ i
) & 0xffff );
1259 memcpy( path
+ len
+ offset
, suffix
, (strlenW( suffix
) + 1) * sizeof(WCHAR
) );
1260 handle
= CreateFileW( path
, GENERIC_WRITE
, 0, NULL
,
1261 CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, 0 );
1262 if (handle
!= INVALID_HANDLE_VALUE
)
1264 CloseHandle(handle
);
1267 if (GetLastError() != ERROR_FILE_EXISTS
&&
1268 GetLastError() != ERROR_SHARING_VIOLATION
)
1269 return ERROR_FUNCTION_FAILED
;
1272 return ERROR_SUCCESS
;
1275 static enum platform
parse_platform( WCHAR
*str
)
1277 if (!str
[0] || !strcmpW( str
, szIntel
)) return PLATFORM_INTEL
;
1278 else if (!strcmpW( str
, szIntel64
)) return PLATFORM_INTEL64
;
1279 else if (!strcmpW( str
, szX64
) || !strcmpW( str
, szAMD64
)) return PLATFORM_X64
;
1280 else if (!strcmpW( str
, szARM
)) return PLATFORM_ARM
;
1281 return PLATFORM_UNKNOWN
;
1284 static UINT
msi_parse_summary( MSISUMMARYINFO
*si
, MSIPACKAGE
*package
)
1286 WCHAR
*template, *p
, *q
, *platform
;
1289 package
->version
= msi_suminfo_get_int32( si
, PID_PAGECOUNT
);
1290 TRACE("version: %d\n", package
->version
);
1292 template = msi_suminfo_dup_string( si
, PID_TEMPLATE
);
1294 return ERROR_SUCCESS
; /* native accepts missing template property */
1296 TRACE("template: %s\n", debugstr_w(template));
1298 p
= strchrW( template, ';' );
1301 WARN("invalid template string %s\n", debugstr_w(template));
1302 msi_free( template );
1303 return ERROR_PATCH_PACKAGE_INVALID
;
1306 platform
= template;
1307 if ((q
= strchrW( platform
, ',' ))) *q
= 0;
1308 package
->platform
= parse_platform( platform
);
1309 while (package
->platform
== PLATFORM_UNKNOWN
&& q
)
1312 if ((q
= strchrW( platform
, ',' ))) *q
= 0;
1313 package
->platform
= parse_platform( platform
);
1315 if (package
->platform
== PLATFORM_UNKNOWN
)
1317 WARN("unknown platform %s\n", debugstr_w(template));
1318 msi_free( template );
1319 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1324 msi_free( template );
1325 return ERROR_SUCCESS
;
1328 for (q
= p
; (q
= strchrW( q
, ',' )); q
++) count
++;
1330 package
->langids
= msi_alloc( count
* sizeof(LANGID
) );
1331 if (!package
->langids
)
1333 msi_free( template );
1334 return ERROR_OUTOFMEMORY
;
1340 q
= strchrW( p
, ',' );
1342 package
->langids
[i
] = atoiW( p
);
1347 package
->num_langids
= i
+ 1;
1349 msi_free( template );
1350 return ERROR_SUCCESS
;
1353 static UINT
validate_package( MSIPACKAGE
*package
)
1357 if (package
->platform
== PLATFORM_INTEL64
)
1358 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1360 if (package
->platform
== PLATFORM_ARM
)
1361 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1363 if (package
->platform
== PLATFORM_X64
)
1365 if (!is_64bit
&& !is_wow64
)
1366 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1367 if (package
->version
< 200)
1368 return ERROR_INSTALL_PACKAGE_INVALID
;
1370 if (!package
->num_langids
)
1372 return ERROR_SUCCESS
;
1374 for (i
= 0; i
< package
->num_langids
; i
++)
1376 LANGID langid
= package
->langids
[i
];
1378 if (PRIMARYLANGID( langid
) == LANG_NEUTRAL
)
1380 langid
= MAKELANGID( PRIMARYLANGID( GetSystemDefaultLangID() ), SUBLANGID( langid
) );
1382 if (SUBLANGID( langid
) == SUBLANG_NEUTRAL
)
1384 langid
= MAKELANGID( PRIMARYLANGID( langid
), SUBLANGID( GetSystemDefaultLangID() ) );
1386 if (IsValidLocale( langid
, LCID_INSTALLED
))
1387 return ERROR_SUCCESS
;
1389 return ERROR_INSTALL_LANGUAGE_UNSUPPORTED
;
1392 int msi_track_tempfile( MSIPACKAGE
*package
, const WCHAR
*path
)
1396 TRACE("%s\n", debugstr_w(path
));
1398 LIST_FOR_EACH_ENTRY( temp
, &package
->tempfiles
, MSITEMPFILE
, entry
)
1400 if (!strcmpW( path
, temp
->Path
)) return 0;
1402 if (!(temp
= msi_alloc_zero( sizeof (MSITEMPFILE
) ))) return -1;
1403 list_add_head( &package
->tempfiles
, &temp
->entry
);
1404 temp
->Path
= strdupW( path
);
1408 static WCHAR
*get_product_code( MSIDATABASE
*db
)
1410 static const WCHAR query
[] = {
1411 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
1412 'F','R','O','M',' ','`','P','r','o','p','e','r','t','y','`',' ',
1413 'W','H','E','R','E',' ','`','P','r','o','p','e','r','t','y','`','=',
1414 '\'','P','r','o','d','u','c','t','C','o','d','e','\'',0};
1419 if (MSI_DatabaseOpenViewW( db
, query
, &view
) != ERROR_SUCCESS
)
1423 if (MSI_ViewExecute( view
, 0 ) != ERROR_SUCCESS
)
1425 MSI_ViewClose( view
);
1426 msiobj_release( &view
->hdr
);
1429 if (MSI_ViewFetch( view
, &rec
) == ERROR_SUCCESS
)
1431 ret
= strdupW( MSI_RecordGetString( rec
, 1 ) );
1432 msiobj_release( &rec
->hdr
);
1434 MSI_ViewClose( view
);
1435 msiobj_release( &view
->hdr
);
1439 static UINT
get_registered_local_package( const WCHAR
*product
, const WCHAR
*package
, WCHAR
*localfile
)
1441 MSIINSTALLCONTEXT context
;
1442 HKEY product_key
, props_key
;
1443 WCHAR
*registered_package
= NULL
, unsquashed
[GUID_SIZE
];
1446 r
= msi_locate_product( product
, &context
);
1447 if (r
!= ERROR_SUCCESS
)
1450 r
= MSIREG_OpenProductKey( product
, NULL
, context
, &product_key
, FALSE
);
1451 if (r
!= ERROR_SUCCESS
)
1454 r
= MSIREG_OpenInstallProps( product
, context
, NULL
, &props_key
, FALSE
);
1455 if (r
!= ERROR_SUCCESS
)
1457 RegCloseKey( product_key
);
1460 r
= ERROR_FUNCTION_FAILED
;
1461 registered_package
= msi_reg_get_val_str( product_key
, INSTALLPROPERTY_PACKAGECODEW
);
1462 if (!registered_package
)
1465 unsquash_guid( registered_package
, unsquashed
);
1466 if (!strcmpiW( package
, unsquashed
))
1468 WCHAR
*filename
= msi_reg_get_val_str( props_key
, INSTALLPROPERTY_LOCALPACKAGEW
);
1472 strcpyW( localfile
, filename
);
1473 msi_free( filename
);
1477 msi_free( registered_package
);
1478 RegCloseKey( props_key
);
1479 RegCloseKey( product_key
);
1483 static WCHAR
*get_package_code( MSIDATABASE
*db
)
1488 if (!(si
= MSI_GetSummaryInformationW( db
->storage
, 0 )))
1490 WARN("failed to load summary info\n");
1493 ret
= msi_suminfo_dup_string( si
, PID_REVNUMBER
);
1494 msiobj_release( &si
->hdr
);
1498 static UINT
get_local_package( const WCHAR
*filename
, WCHAR
*localfile
)
1500 WCHAR
*product_code
, *package_code
;
1504 if ((r
= MSI_OpenDatabaseW( filename
, MSIDBOPEN_READONLY
, &db
)) != ERROR_SUCCESS
)
1506 if (GetFileAttributesW( filename
) == INVALID_FILE_ATTRIBUTES
)
1507 return ERROR_FILE_NOT_FOUND
;
1510 if (!(product_code
= get_product_code( db
)))
1512 msiobj_release( &db
->hdr
);
1513 return ERROR_INSTALL_PACKAGE_INVALID
;
1515 if (!(package_code
= get_package_code( db
)))
1517 msi_free( product_code
);
1518 msiobj_release( &db
->hdr
);
1519 return ERROR_INSTALL_PACKAGE_INVALID
;
1521 r
= get_registered_local_package( product_code
, package_code
, localfile
);
1522 msi_free( package_code
);
1523 msi_free( product_code
);
1524 msiobj_release( &db
->hdr
);
1528 UINT
msi_set_original_database_property( MSIDATABASE
*db
, const WCHAR
*package
)
1532 if (UrlIsW( package
, URLIS_URL
))
1533 r
= msi_set_property( db
, szOriginalDatabase
, package
, -1 );
1534 else if (package
[0] == '#')
1535 r
= msi_set_property( db
, szOriginalDatabase
, db
->path
, -1 );
1541 if (!(len
= GetFullPathNameW( package
, 0, NULL
, NULL
))) return GetLastError();
1542 if (!(path
= msi_alloc( len
* sizeof(WCHAR
) ))) return ERROR_OUTOFMEMORY
;
1543 len
= GetFullPathNameW( package
, len
, path
, NULL
);
1544 r
= msi_set_property( db
, szOriginalDatabase
, path
, len
);
1550 UINT
MSI_OpenPackageW(LPCWSTR szPackage
, MSIPACKAGE
**pPackage
)
1552 static const WCHAR dotmsi
[] = {'.','m','s','i',0};
1554 MSIPACKAGE
*package
;
1556 LPWSTR ptr
, base_url
= NULL
;
1558 WCHAR localfile
[MAX_PATH
], cachefile
[MAX_PATH
];
1559 LPCWSTR file
= szPackage
;
1562 BOOL delete_on_close
= FALSE
;
1564 TRACE("%s %p\n", debugstr_w(szPackage
), pPackage
);
1567 if( szPackage
[0] == '#' )
1569 handle
= atoiW(&szPackage
[1]);
1570 db
= msihandle2msiinfo( handle
, MSIHANDLETYPE_DATABASE
);
1573 IWineMsiRemoteDatabase
*remote_database
;
1575 remote_database
= (IWineMsiRemoteDatabase
*)msi_get_remote( handle
);
1576 if ( !remote_database
)
1577 return ERROR_INVALID_HANDLE
;
1579 IWineMsiRemoteDatabase_Release( remote_database
);
1580 WARN("MsiOpenPackage not allowed during a custom action!\n");
1582 return ERROR_FUNCTION_FAILED
;
1587 if ( UrlIsW( szPackage
, URLIS_URL
) )
1589 r
= msi_download_file( szPackage
, cachefile
);
1590 if (r
!= ERROR_SUCCESS
)
1595 base_url
= strdupW( szPackage
);
1597 return ERROR_OUTOFMEMORY
;
1599 ptr
= strrchrW( base_url
, '/' );
1600 if (ptr
) *(ptr
+ 1) = '\0';
1602 r
= get_local_package( file
, localfile
);
1603 if (r
!= ERROR_SUCCESS
|| GetFileAttributesW( localfile
) == INVALID_FILE_ATTRIBUTES
)
1605 r
= msi_create_empty_local_file( localfile
, dotmsi
);
1606 if (r
!= ERROR_SUCCESS
)
1608 msi_free ( base_url
);
1612 if (!CopyFileW( file
, localfile
, FALSE
))
1615 WARN("unable to copy package %s to %s (%u)\n", debugstr_w(file
), debugstr_w(localfile
), r
);
1616 DeleteFileW( localfile
);
1617 msi_free ( base_url
);
1620 delete_on_close
= TRUE
;
1622 TRACE("opening package %s\n", debugstr_w( localfile
));
1623 r
= MSI_OpenDatabaseW( localfile
, MSIDBOPEN_TRANSACT
, &db
);
1624 if (r
!= ERROR_SUCCESS
)
1626 msi_free ( base_url
);
1630 package
= MSI_CreatePackage( db
, base_url
);
1631 msi_free( base_url
);
1632 msiobj_release( &db
->hdr
);
1633 if (!package
) return ERROR_INSTALL_PACKAGE_INVALID
;
1634 package
->localfile
= strdupW( localfile
);
1635 package
->delete_on_close
= delete_on_close
;
1637 si
= MSI_GetSummaryInformationW( db
->storage
, 0 );
1640 WARN("failed to load summary info\n");
1641 msiobj_release( &package
->hdr
);
1642 return ERROR_INSTALL_PACKAGE_INVALID
;
1644 r
= msi_parse_summary( si
, package
);
1645 msiobj_release( &si
->hdr
);
1646 if (r
!= ERROR_SUCCESS
)
1648 WARN("failed to parse summary info %u\n", r
);
1649 msiobj_release( &package
->hdr
);
1652 r
= validate_package( package
);
1653 if (r
!= ERROR_SUCCESS
)
1655 msiobj_release( &package
->hdr
);
1658 msi_set_property( package
->db
, szDatabase
, db
->path
, -1 );
1659 msi_set_context( package
);
1663 WCHAR patch_code
[GUID_SIZE
];
1664 r
= MsiEnumPatchesExW( package
->ProductCode
, NULL
, package
->Context
,
1665 MSIPATCHSTATE_APPLIED
, index
, patch_code
, NULL
, NULL
, NULL
, NULL
);
1666 if (r
!= ERROR_SUCCESS
)
1669 TRACE("found registered patch %s\n", debugstr_w(patch_code
));
1671 r
= msi_apply_registered_patch( package
, patch_code
);
1672 if (r
!= ERROR_SUCCESS
)
1674 ERR("registered patch failed to apply %u\n", r
);
1675 msiobj_release( &package
->hdr
);
1682 msi_clone_properties( package
);
1683 msi_adjust_privilege_properties( package
);
1685 r
= msi_set_original_database_property( package
->db
, szPackage
);
1686 if (r
!= ERROR_SUCCESS
)
1688 msiobj_release( &package
->hdr
);
1692 package
->log_file
= CreateFileW( gszLogFile
, GENERIC_WRITE
, FILE_SHARE_WRITE
, NULL
,
1693 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1694 *pPackage
= package
;
1695 return ERROR_SUCCESS
;
1698 UINT WINAPI
MsiOpenPackageExW(LPCWSTR szPackage
, DWORD dwOptions
, MSIHANDLE
*phPackage
)
1700 MSIPACKAGE
*package
= NULL
;
1703 TRACE("%s %08x %p\n", debugstr_w(szPackage
), dwOptions
, phPackage
);
1705 if( !szPackage
|| !phPackage
)
1706 return ERROR_INVALID_PARAMETER
;
1710 FIXME("Should create an empty database and package\n");
1711 return ERROR_FUNCTION_FAILED
;
1715 FIXME("dwOptions %08x not supported\n", dwOptions
);
1717 ret
= MSI_OpenPackageW( szPackage
, &package
);
1718 if( ret
== ERROR_SUCCESS
)
1720 *phPackage
= alloc_msihandle( &package
->hdr
);
1722 ret
= ERROR_NOT_ENOUGH_MEMORY
;
1723 msiobj_release( &package
->hdr
);
1729 UINT WINAPI
MsiOpenPackageW(LPCWSTR szPackage
, MSIHANDLE
*phPackage
)
1731 return MsiOpenPackageExW( szPackage
, 0, phPackage
);
1734 UINT WINAPI
MsiOpenPackageExA(LPCSTR szPackage
, DWORD dwOptions
, MSIHANDLE
*phPackage
)
1736 LPWSTR szwPack
= NULL
;
1741 szwPack
= strdupAtoW( szPackage
);
1743 return ERROR_OUTOFMEMORY
;
1746 ret
= MsiOpenPackageExW( szwPack
, dwOptions
, phPackage
);
1748 msi_free( szwPack
);
1753 UINT WINAPI
MsiOpenPackageA(LPCSTR szPackage
, MSIHANDLE
*phPackage
)
1755 return MsiOpenPackageExA( szPackage
, 0, phPackage
);
1758 MSIHANDLE WINAPI
MsiGetActiveDatabase(MSIHANDLE hInstall
)
1760 MSIPACKAGE
*package
;
1761 MSIHANDLE handle
= 0;
1762 IUnknown
*remote_unk
;
1763 IWineMsiRemotePackage
*remote_package
;
1765 TRACE("(%d)\n",hInstall
);
1767 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
1770 handle
= alloc_msihandle( &package
->db
->hdr
);
1771 msiobj_release( &package
->hdr
);
1773 else if ((remote_unk
= msi_get_remote(hInstall
)))
1775 if (IUnknown_QueryInterface(remote_unk
, &IID_IWineMsiRemotePackage
,
1776 (LPVOID
*)&remote_package
) == S_OK
)
1778 IWineMsiRemotePackage_GetActiveDatabase(remote_package
, &handle
);
1779 IWineMsiRemotePackage_Release(remote_package
);
1783 WARN("remote handle %d is not a package\n", hInstall
);
1785 IUnknown_Release(remote_unk
);
1791 INT
MSI_ProcessMessage( MSIPACKAGE
*package
, INSTALLMESSAGE eMessageType
, MSIRECORD
*record
)
1793 static const WCHAR szActionData
[] = {'A','c','t','i','o','n','D','a','t','a',0};
1794 static const WCHAR szSetProgress
[] = {'S','e','t','P','r','o','g','r','e','s','s',0};
1795 static const WCHAR szActionText
[] = {'A','c','t','i','o','n','T','e','x','t',0};
1797 LPWSTR deformated
, message
;
1798 DWORD i
, len
, total_len
, log_type
= 0;
1802 TRACE("%x\n", eMessageType
);
1804 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_FATALEXIT
)
1805 log_type
|= INSTALLLOGMODE_FATALEXIT
;
1806 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_ERROR
)
1807 log_type
|= INSTALLLOGMODE_ERROR
;
1808 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_WARNING
)
1809 log_type
|= INSTALLLOGMODE_WARNING
;
1810 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_USER
)
1811 log_type
|= INSTALLLOGMODE_USER
;
1812 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_INFO
)
1813 log_type
|= INSTALLLOGMODE_INFO
;
1814 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_RESOLVESOURCE
)
1815 log_type
|= INSTALLLOGMODE_RESOLVESOURCE
;
1816 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_OUTOFDISKSPACE
)
1817 log_type
|= INSTALLLOGMODE_OUTOFDISKSPACE
;
1818 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_COMMONDATA
)
1819 log_type
|= INSTALLLOGMODE_COMMONDATA
;
1820 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_ACTIONSTART
)
1821 log_type
|= INSTALLLOGMODE_ACTIONSTART
;
1822 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_ACTIONDATA
)
1823 log_type
|= INSTALLLOGMODE_ACTIONDATA
;
1824 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_PROGRESS
)
1825 log_type
|= INSTALLLOGMODE_PROGRESS
;
1826 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_INITIALIZE
)
1827 log_type
|= INSTALLLOGMODE_INITIALIZE
;
1828 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_TERMINATE
)
1829 log_type
|= INSTALLLOGMODE_TERMINATE
;
1830 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_SHOWDIALOG
)
1831 log_type
|= INSTALLLOGMODE_SHOWDIALOG
;
1833 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_ACTIONSTART
)
1835 static const WCHAR template_s
[]=
1836 {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ',0};
1837 static const WCHAR format
[] =
1838 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
1840 LPCWSTR action_text
, action
;
1841 LPWSTR deformatted
= NULL
;
1843 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0, NULL
, format
, timet
, 0x100);
1845 action
= MSI_RecordGetString(record
, 1);
1846 action_text
= MSI_RecordGetString(record
, 2);
1848 if (!action
|| !action_text
)
1851 deformat_string(package
, action_text
, &deformatted
);
1853 len
= strlenW(timet
) + strlenW(action
) + strlenW(template_s
);
1855 len
+= strlenW(deformatted
);
1856 message
= msi_alloc(len
*sizeof(WCHAR
));
1857 sprintfW(message
, template_s
, timet
, action
);
1859 strcatW(message
, deformatted
);
1860 msi_free(deformatted
);
1864 static const WCHAR format
[] = {'%','u',':',' ',0};
1865 UINT count
= MSI_RecordGetFieldCount( record
);
1869 for (i
= 1; i
<= count
; i
++)
1872 MSI_RecordGetStringW( record
, i
, NULL
, &len
);
1873 total_len
+= len
+ 13;
1875 p
= message
= msi_alloc( total_len
* sizeof(WCHAR
) );
1876 if (!p
) return ERROR_OUTOFMEMORY
;
1878 for (i
= 1; i
<= count
; i
++)
1882 len
= sprintfW( p
, format
, i
);
1887 MSI_RecordGetStringW( record
, i
, p
, &len
);
1890 if (count
> 1 && total_len
)
1899 TRACE("%p %p %p %x %x %s\n", gUIHandlerA
, gUIHandlerW
, gUIHandlerRecord
,
1900 gUIFilter
, log_type
, debugstr_w(message
));
1902 /* convert it to ASCII */
1903 len
= WideCharToMultiByte( CP_ACP
, 0, message
, -1, NULL
, 0, NULL
, NULL
);
1904 msg
= msi_alloc( len
);
1905 WideCharToMultiByte( CP_ACP
, 0, message
, -1, msg
, len
, NULL
, NULL
);
1907 if (gUIHandlerW
&& (gUIFilter
& log_type
))
1909 rc
= gUIHandlerW( gUIContext
, eMessageType
, message
);
1911 else if (gUIHandlerA
&& (gUIFilter
& log_type
))
1913 rc
= gUIHandlerA( gUIContext
, eMessageType
, msg
);
1915 else if (gUIHandlerRecord
&& (gUIFilter
& log_type
))
1917 MSIHANDLE rec
= MsiCreateRecord( 1 );
1918 MsiRecordSetStringW( rec
, 0, message
);
1919 rc
= gUIHandlerRecord( gUIContext
, eMessageType
, rec
);
1920 MsiCloseHandle( rec
);
1923 if (!rc
&& package
->log_file
!= INVALID_HANDLE_VALUE
&&
1924 (eMessageType
& 0xff000000) != INSTALLMESSAGE_PROGRESS
)
1927 WriteFile( package
->log_file
, msg
, len
- 1, &written
, NULL
);
1928 WriteFile( package
->log_file
, "\n", 1, &written
, NULL
);
1931 msi_free( message
);
1933 switch (eMessageType
& 0xff000000)
1935 case INSTALLMESSAGE_ACTIONDATA
:
1936 deformat_string(package
, MSI_RecordGetString(record
, 2), &deformated
);
1937 uirow
= MSI_CreateRecord(1);
1938 MSI_RecordSetStringW(uirow
, 1, deformated
);
1939 msi_free(deformated
);
1941 msi_event_fire( package
, szActionData
, uirow
);
1942 msiobj_release(&uirow
->hdr
);
1944 if (package
->action_progress_increment
)
1946 uirow
= MSI_CreateRecord(2);
1947 MSI_RecordSetInteger(uirow
, 1, 2);
1948 MSI_RecordSetInteger(uirow
, 2, package
->action_progress_increment
);
1949 msi_event_fire( package
, szSetProgress
, uirow
);
1950 msiobj_release(&uirow
->hdr
);
1954 case INSTALLMESSAGE_ACTIONSTART
:
1955 deformat_string(package
, MSI_RecordGetString(record
, 2), &deformated
);
1956 uirow
= MSI_CreateRecord(1);
1957 MSI_RecordSetStringW(uirow
, 1, deformated
);
1958 msi_free(deformated
);
1960 msi_event_fire( package
, szActionText
, uirow
);
1962 msiobj_release(&uirow
->hdr
);
1965 case INSTALLMESSAGE_PROGRESS
:
1966 msi_event_fire( package
, szSetProgress
, record
);
1970 return ERROR_SUCCESS
;
1973 INT WINAPI
MsiProcessMessage( MSIHANDLE hInstall
, INSTALLMESSAGE eMessageType
,
1976 UINT ret
= ERROR_INVALID_HANDLE
;
1977 MSIPACKAGE
*package
= NULL
;
1978 MSIRECORD
*record
= NULL
;
1980 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
1984 IWineMsiRemotePackage
*remote_package
;
1986 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
1987 if (!remote_package
)
1988 return ERROR_INVALID_HANDLE
;
1990 hr
= IWineMsiRemotePackage_ProcessMessage( remote_package
, eMessageType
, hRecord
);
1992 IWineMsiRemotePackage_Release( remote_package
);
1996 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1997 return HRESULT_CODE(hr
);
1999 return ERROR_FUNCTION_FAILED
;
2002 return ERROR_SUCCESS
;
2005 record
= msihandle2msiinfo( hRecord
, MSIHANDLETYPE_RECORD
);
2009 ret
= MSI_ProcessMessage( package
, eMessageType
, record
);
2012 msiobj_release( &package
->hdr
);
2014 msiobj_release( &record
->hdr
);
2021 UINT WINAPI
MsiSetPropertyA( MSIHANDLE hInstall
, LPCSTR szName
, LPCSTR szValue
)
2023 LPWSTR szwName
= NULL
, szwValue
= NULL
;
2024 UINT r
= ERROR_OUTOFMEMORY
;
2026 szwName
= strdupAtoW( szName
);
2027 if( szName
&& !szwName
)
2030 szwValue
= strdupAtoW( szValue
);
2031 if( szValue
&& !szwValue
)
2034 r
= MsiSetPropertyW( hInstall
, szwName
, szwValue
);
2037 msi_free( szwName
);
2038 msi_free( szwValue
);
2043 void msi_reset_folders( MSIPACKAGE
*package
, BOOL source
)
2047 LIST_FOR_EACH_ENTRY( folder
, &package
->folders
, MSIFOLDER
, entry
)
2051 msi_free( folder
->ResolvedSource
);
2052 folder
->ResolvedSource
= NULL
;
2056 msi_free( folder
->ResolvedTarget
);
2057 folder
->ResolvedTarget
= NULL
;
2062 UINT
msi_set_property( MSIDATABASE
*db
, const WCHAR
*name
, const WCHAR
*value
, int len
)
2064 static const WCHAR insert_query
[] = {
2065 'I','N','S','E','R','T',' ','I','N','T','O',' ',
2066 '`','_','P','r','o','p','e','r','t','y','`',' ',
2067 '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
2068 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
2069 static const WCHAR update_query
[] = {
2070 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
2071 'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ','W','H','E','R','E',' ',
2072 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
2073 static const WCHAR delete_query
[] = {
2074 'D','E','L','E','T','E',' ','F','R','O','M',' ',
2075 '`','_','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2076 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
2078 MSIRECORD
*row
= NULL
;
2083 TRACE("%p %s %s %d\n", db
, debugstr_w(name
), debugstr_wn(value
, len
), len
);
2086 return ERROR_INVALID_PARAMETER
;
2088 /* this one is weird... */
2090 return value
? ERROR_FUNCTION_FAILED
: ERROR_SUCCESS
;
2092 if (value
&& len
< 0) len
= strlenW( value
);
2094 rc
= msi_get_property( db
, name
, 0, &sz
);
2095 if (!value
|| (!*value
&& !len
))
2097 sprintfW( query
, delete_query
, name
);
2099 else if (rc
== ERROR_MORE_DATA
|| rc
== ERROR_SUCCESS
)
2101 sprintfW( query
, update_query
, name
);
2102 row
= MSI_CreateRecord(1);
2103 msi_record_set_string( row
, 1, value
, len
);
2107 strcpyW( query
, insert_query
);
2108 row
= MSI_CreateRecord(2);
2109 msi_record_set_string( row
, 1, name
, -1 );
2110 msi_record_set_string( row
, 2, value
, len
);
2113 rc
= MSI_DatabaseOpenViewW(db
, query
, &view
);
2114 if (rc
== ERROR_SUCCESS
)
2116 rc
= MSI_ViewExecute(view
, row
);
2117 MSI_ViewClose(view
);
2118 msiobj_release(&view
->hdr
);
2120 if (row
) msiobj_release(&row
->hdr
);
2124 UINT WINAPI
MsiSetPropertyW( MSIHANDLE hInstall
, LPCWSTR szName
, LPCWSTR szValue
)
2126 MSIPACKAGE
*package
;
2129 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
2133 BSTR name
= NULL
, value
= NULL
;
2134 IWineMsiRemotePackage
*remote_package
;
2136 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
2137 if (!remote_package
)
2138 return ERROR_INVALID_HANDLE
;
2140 name
= SysAllocString( szName
);
2141 value
= SysAllocString( szValue
);
2142 if ((!name
&& szName
) || (!value
&& szValue
))
2144 SysFreeString( name
);
2145 SysFreeString( value
);
2146 IWineMsiRemotePackage_Release( remote_package
);
2147 return ERROR_OUTOFMEMORY
;
2150 hr
= IWineMsiRemotePackage_SetProperty( remote_package
, name
, value
);
2152 SysFreeString( name
);
2153 SysFreeString( value
);
2154 IWineMsiRemotePackage_Release( remote_package
);
2158 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
2159 return HRESULT_CODE(hr
);
2161 return ERROR_FUNCTION_FAILED
;
2164 return ERROR_SUCCESS
;
2167 ret
= msi_set_property( package
->db
, szName
, szValue
, -1 );
2168 if (ret
== ERROR_SUCCESS
&& !strcmpW( szName
, szSourceDir
))
2169 msi_reset_folders( package
, TRUE
);
2171 msiobj_release( &package
->hdr
);
2175 static MSIRECORD
*msi_get_property_row( MSIDATABASE
*db
, LPCWSTR name
)
2177 static const WCHAR query
[]= {
2178 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
2179 'F','R','O','M',' ' ,'`','_','P','r','o','p','e','r','t','y','`',' ',
2180 'W','H','E','R','E',' ' ,'`','_','P','r','o','p','e','r','t','y','`','=','?',0};
2181 MSIRECORD
*rec
, *row
= NULL
;
2185 if (!name
|| !*name
)
2188 rec
= MSI_CreateRecord(1);
2192 MSI_RecordSetStringW(rec
, 1, name
);
2194 r
= MSI_DatabaseOpenViewW(db
, query
, &view
);
2195 if (r
== ERROR_SUCCESS
)
2197 MSI_ViewExecute(view
, rec
);
2198 MSI_ViewFetch(view
, &row
);
2199 MSI_ViewClose(view
);
2200 msiobj_release(&view
->hdr
);
2202 msiobj_release(&rec
->hdr
);
2206 /* internal function, not compatible with MsiGetPropertyW */
2207 UINT
msi_get_property( MSIDATABASE
*db
, LPCWSTR szName
,
2208 LPWSTR szValueBuf
, LPDWORD pchValueBuf
)
2211 UINT rc
= ERROR_FUNCTION_FAILED
;
2213 row
= msi_get_property_row( db
, szName
);
2215 if (*pchValueBuf
> 0)
2220 rc
= MSI_RecordGetStringW(row
, 1, szValueBuf
, pchValueBuf
);
2221 msiobj_release(&row
->hdr
);
2224 if (rc
== ERROR_SUCCESS
)
2225 TRACE("returning %s for property %s\n", debugstr_wn(szValueBuf
, *pchValueBuf
),
2226 debugstr_w(szName
));
2227 else if (rc
== ERROR_MORE_DATA
)
2228 TRACE("need %d sized buffer for %s\n", *pchValueBuf
,
2229 debugstr_w(szName
));
2233 TRACE("property %s not found\n", debugstr_w(szName
));
2239 LPWSTR
msi_dup_property(MSIDATABASE
*db
, LPCWSTR prop
)
2245 r
= msi_get_property(db
, prop
, NULL
, &sz
);
2246 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
2250 str
= msi_alloc(sz
* sizeof(WCHAR
));
2251 r
= msi_get_property(db
, prop
, str
, &sz
);
2252 if (r
!= ERROR_SUCCESS
)
2261 int msi_get_property_int( MSIDATABASE
*db
, LPCWSTR prop
, int def
)
2263 LPWSTR str
= msi_dup_property( db
, prop
);
2264 int val
= str
? atoiW(str
) : def
;
2269 static UINT
MSI_GetProperty( MSIHANDLE handle
, LPCWSTR name
,
2270 awstring
*szValueBuf
, LPDWORD pchValueBuf
)
2272 MSIPACKAGE
*package
;
2273 MSIRECORD
*row
= NULL
;
2274 UINT r
= ERROR_FUNCTION_FAILED
;
2278 TRACE("%u %s %p %p\n", handle
, debugstr_w(name
),
2279 szValueBuf
->str
.w
, pchValueBuf
);
2282 return ERROR_INVALID_PARAMETER
;
2284 package
= msihandle2msiinfo( handle
, MSIHANDLETYPE_PACKAGE
);
2288 IWineMsiRemotePackage
*remote_package
;
2289 LPWSTR value
= NULL
;
2292 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( handle
);
2293 if (!remote_package
)
2294 return ERROR_INVALID_HANDLE
;
2296 bname
= SysAllocString( name
);
2299 IWineMsiRemotePackage_Release( remote_package
);
2300 return ERROR_OUTOFMEMORY
;
2303 hr
= IWineMsiRemotePackage_GetProperty( remote_package
, bname
, NULL
, &len
);
2308 value
= msi_alloc(len
* sizeof(WCHAR
));
2311 r
= ERROR_OUTOFMEMORY
;
2315 hr
= IWineMsiRemotePackage_GetProperty( remote_package
, bname
, value
, &len
);
2319 r
= msi_strcpy_to_awstring( value
, len
, szValueBuf
, pchValueBuf
);
2321 /* Bug required by Adobe installers */
2322 if (!szValueBuf
->unicode
&& !szValueBuf
->str
.a
)
2323 *pchValueBuf
*= sizeof(WCHAR
);
2326 IWineMsiRemotePackage_Release(remote_package
);
2327 SysFreeString(bname
);
2332 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
2333 return HRESULT_CODE(hr
);
2335 return ERROR_FUNCTION_FAILED
;
2341 row
= msi_get_property_row( package
->db
, name
);
2343 val
= msi_record_get_string( row
, 1, (int *)&len
);
2348 r
= msi_strcpy_to_awstring( val
, len
, szValueBuf
, pchValueBuf
);
2351 msiobj_release( &row
->hdr
);
2352 msiobj_release( &package
->hdr
);
2357 UINT WINAPI
MsiGetPropertyA( MSIHANDLE hInstall
, LPCSTR szName
,
2358 LPSTR szValueBuf
, LPDWORD pchValueBuf
)
2364 val
.unicode
= FALSE
;
2365 val
.str
.a
= szValueBuf
;
2367 name
= strdupAtoW( szName
);
2368 if (szName
&& !name
)
2369 return ERROR_OUTOFMEMORY
;
2371 r
= MSI_GetProperty( hInstall
, name
, &val
, pchValueBuf
);
2376 UINT WINAPI
MsiGetPropertyW( MSIHANDLE hInstall
, LPCWSTR szName
,
2377 LPWSTR szValueBuf
, LPDWORD pchValueBuf
)
2382 val
.str
.w
= szValueBuf
;
2384 return MSI_GetProperty( hInstall
, szName
, &val
, pchValueBuf
);
2387 typedef struct _msi_remote_package_impl
{
2388 IWineMsiRemotePackage IWineMsiRemotePackage_iface
;
2391 } msi_remote_package_impl
;
2393 static inline msi_remote_package_impl
*impl_from_IWineMsiRemotePackage( IWineMsiRemotePackage
*iface
)
2395 return CONTAINING_RECORD(iface
, msi_remote_package_impl
, IWineMsiRemotePackage_iface
);
2398 static HRESULT WINAPI
mrp_QueryInterface( IWineMsiRemotePackage
*iface
,
2399 REFIID riid
,LPVOID
*ppobj
)
2401 if( IsEqualCLSID( riid
, &IID_IUnknown
) ||
2402 IsEqualCLSID( riid
, &IID_IWineMsiRemotePackage
) )
2404 IWineMsiRemotePackage_AddRef( iface
);
2409 return E_NOINTERFACE
;
2412 static ULONG WINAPI
mrp_AddRef( IWineMsiRemotePackage
*iface
)
2414 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2416 return InterlockedIncrement( &This
->refs
);
2419 static ULONG WINAPI
mrp_Release( IWineMsiRemotePackage
*iface
)
2421 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2424 r
= InterlockedDecrement( &This
->refs
);
2427 MsiCloseHandle( This
->package
);
2433 static HRESULT WINAPI
mrp_SetMsiHandle( IWineMsiRemotePackage
*iface
, MSIHANDLE handle
)
2435 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2436 This
->package
= handle
;
2440 static HRESULT WINAPI
mrp_GetActiveDatabase( IWineMsiRemotePackage
*iface
, MSIHANDLE
*handle
)
2442 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2443 IWineMsiRemoteDatabase
*rdb
= NULL
;
2447 hr
= create_msi_remote_database( NULL
, (LPVOID
*)&rdb
);
2448 if (FAILED(hr
) || !rdb
)
2450 ERR("Failed to create remote database\n");
2454 hdb
= MsiGetActiveDatabase(This
->package
);
2456 hr
= IWineMsiRemoteDatabase_SetMsiHandle( rdb
, hdb
);
2459 ERR("Failed to set the database handle\n");
2463 *handle
= alloc_msi_remote_handle( (IUnknown
*)rdb
);
2467 static HRESULT WINAPI
mrp_GetProperty( IWineMsiRemotePackage
*iface
, BSTR property
, BSTR value
, DWORD
*size
)
2469 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2470 UINT r
= MsiGetPropertyW(This
->package
, property
, value
, size
);
2471 if (r
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(r
);
2475 static HRESULT WINAPI
mrp_SetProperty( IWineMsiRemotePackage
*iface
, BSTR property
, BSTR value
)
2477 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2478 UINT r
= MsiSetPropertyW(This
->package
, property
, value
);
2479 return HRESULT_FROM_WIN32(r
);
2482 static HRESULT WINAPI
mrp_ProcessMessage( IWineMsiRemotePackage
*iface
, INSTALLMESSAGE message
, MSIHANDLE record
)
2484 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2485 UINT r
= MsiProcessMessage(This
->package
, message
, record
);
2486 return HRESULT_FROM_WIN32(r
);
2489 static HRESULT WINAPI
mrp_DoAction( IWineMsiRemotePackage
*iface
, BSTR action
)
2491 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2492 UINT r
= MsiDoActionW(This
->package
, action
);
2493 return HRESULT_FROM_WIN32(r
);
2496 static HRESULT WINAPI
mrp_Sequence( IWineMsiRemotePackage
*iface
, BSTR table
, int sequence
)
2498 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2499 UINT r
= MsiSequenceW(This
->package
, table
, sequence
);
2500 return HRESULT_FROM_WIN32(r
);
2503 static HRESULT WINAPI
mrp_GetTargetPath( IWineMsiRemotePackage
*iface
, BSTR folder
, BSTR value
, DWORD
*size
)
2505 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2506 UINT r
= MsiGetTargetPathW(This
->package
, folder
, value
, size
);
2507 return HRESULT_FROM_WIN32(r
);
2510 static HRESULT WINAPI
mrp_SetTargetPath( IWineMsiRemotePackage
*iface
, BSTR folder
, BSTR value
)
2512 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2513 UINT r
= MsiSetTargetPathW(This
->package
, folder
, value
);
2514 return HRESULT_FROM_WIN32(r
);
2517 static HRESULT WINAPI
mrp_GetSourcePath( IWineMsiRemotePackage
*iface
, BSTR folder
, BSTR value
, DWORD
*size
)
2519 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2520 UINT r
= MsiGetSourcePathW(This
->package
, folder
, value
, size
);
2521 return HRESULT_FROM_WIN32(r
);
2524 static HRESULT WINAPI
mrp_GetMode( IWineMsiRemotePackage
*iface
, MSIRUNMODE mode
, BOOL
*ret
)
2526 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2527 *ret
= MsiGetMode(This
->package
, mode
);
2531 static HRESULT WINAPI
mrp_SetMode( IWineMsiRemotePackage
*iface
, MSIRUNMODE mode
, BOOL state
)
2533 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2534 UINT r
= MsiSetMode(This
->package
, mode
, state
);
2535 return HRESULT_FROM_WIN32(r
);
2538 static HRESULT WINAPI
mrp_GetFeatureState( IWineMsiRemotePackage
*iface
, BSTR feature
,
2539 INSTALLSTATE
*installed
, INSTALLSTATE
*action
)
2541 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2542 UINT r
= MsiGetFeatureStateW(This
->package
, feature
, installed
, action
);
2543 return HRESULT_FROM_WIN32(r
);
2546 static HRESULT WINAPI
mrp_SetFeatureState( IWineMsiRemotePackage
*iface
, BSTR feature
, INSTALLSTATE state
)
2548 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2549 UINT r
= MsiSetFeatureStateW(This
->package
, feature
, state
);
2550 return HRESULT_FROM_WIN32(r
);
2553 static HRESULT WINAPI
mrp_GetComponentState( IWineMsiRemotePackage
*iface
, BSTR component
,
2554 INSTALLSTATE
*installed
, INSTALLSTATE
*action
)
2556 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2557 UINT r
= MsiGetComponentStateW(This
->package
, component
, installed
, action
);
2558 return HRESULT_FROM_WIN32(r
);
2561 static HRESULT WINAPI
mrp_SetComponentState( IWineMsiRemotePackage
*iface
, BSTR component
, INSTALLSTATE state
)
2563 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2564 UINT r
= MsiSetComponentStateW(This
->package
, component
, state
);
2565 return HRESULT_FROM_WIN32(r
);
2568 static HRESULT WINAPI
mrp_GetLanguage( IWineMsiRemotePackage
*iface
, LANGID
*language
)
2570 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2571 *language
= MsiGetLanguage(This
->package
);
2575 static HRESULT WINAPI
mrp_SetInstallLevel( IWineMsiRemotePackage
*iface
, int level
)
2577 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2578 UINT r
= MsiSetInstallLevel(This
->package
, level
);
2579 return HRESULT_FROM_WIN32(r
);
2582 static HRESULT WINAPI
mrp_FormatRecord( IWineMsiRemotePackage
*iface
, MSIHANDLE record
,
2586 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2587 UINT r
= MsiFormatRecordW(This
->package
, record
, NULL
, &size
);
2588 if (r
== ERROR_SUCCESS
)
2590 *value
= SysAllocStringLen(NULL
, size
);
2592 return E_OUTOFMEMORY
;
2594 r
= MsiFormatRecordW(This
->package
, record
, *value
, &size
);
2596 return HRESULT_FROM_WIN32(r
);
2599 static HRESULT WINAPI
mrp_EvaluateCondition( IWineMsiRemotePackage
*iface
, BSTR condition
)
2601 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2602 UINT r
= MsiEvaluateConditionW(This
->package
, condition
);
2603 return HRESULT_FROM_WIN32(r
);
2606 static HRESULT WINAPI
mrp_GetFeatureCost( IWineMsiRemotePackage
*iface
, BSTR feature
,
2607 INT cost_tree
, INSTALLSTATE state
, INT
*cost
)
2609 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2610 UINT r
= MsiGetFeatureCostW(This
->package
, feature
, cost_tree
, state
, cost
);
2611 return HRESULT_FROM_WIN32(r
);
2614 static HRESULT WINAPI
mrp_EnumComponentCosts( IWineMsiRemotePackage
*iface
, BSTR component
,
2615 DWORD index
, INSTALLSTATE state
, BSTR drive
,
2616 DWORD
*buflen
, INT
*cost
, INT
*temp
)
2618 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2619 UINT r
= MsiEnumComponentCostsW(This
->package
, component
, index
, state
, drive
, buflen
, cost
, temp
);
2620 return HRESULT_FROM_WIN32(r
);
2623 static const IWineMsiRemotePackageVtbl msi_remote_package_vtbl
=
2629 mrp_GetActiveDatabase
,
2640 mrp_GetFeatureState
,
2641 mrp_SetFeatureState
,
2642 mrp_GetComponentState
,
2643 mrp_SetComponentState
,
2645 mrp_SetInstallLevel
,
2647 mrp_EvaluateCondition
,
2649 mrp_EnumComponentCosts
2652 HRESULT
create_msi_remote_package( IUnknown
*pOuter
, LPVOID
*ppObj
)
2654 msi_remote_package_impl
* This
;
2656 This
= msi_alloc( sizeof *This
);
2658 return E_OUTOFMEMORY
;
2660 This
->IWineMsiRemotePackage_iface
.lpVtbl
= &msi_remote_package_vtbl
;
2669 UINT
msi_package_add_info(MSIPACKAGE
*package
, DWORD context
, DWORD options
,
2670 LPCWSTR property
, LPWSTR value
)
2672 MSISOURCELISTINFO
*info
;
2674 LIST_FOR_EACH_ENTRY( info
, &package
->sourcelist_info
, MSISOURCELISTINFO
, entry
)
2676 if (!strcmpW( info
->value
, value
)) return ERROR_SUCCESS
;
2679 info
= msi_alloc(sizeof(MSISOURCELISTINFO
));
2681 return ERROR_OUTOFMEMORY
;
2683 info
->context
= context
;
2684 info
->options
= options
;
2685 info
->property
= property
;
2686 info
->value
= strdupW(value
);
2687 list_add_head(&package
->sourcelist_info
, &info
->entry
);
2689 return ERROR_SUCCESS
;
2692 UINT
msi_package_add_media_disk(MSIPACKAGE
*package
, DWORD context
, DWORD options
,
2693 DWORD disk_id
, LPWSTR volume_label
, LPWSTR disk_prompt
)
2697 LIST_FOR_EACH_ENTRY( disk
, &package
->sourcelist_media
, MSIMEDIADISK
, entry
)
2699 if (disk
->disk_id
== disk_id
) return ERROR_SUCCESS
;
2702 disk
= msi_alloc(sizeof(MSIMEDIADISK
));
2704 return ERROR_OUTOFMEMORY
;
2706 disk
->context
= context
;
2707 disk
->options
= options
;
2708 disk
->disk_id
= disk_id
;
2709 disk
->volume_label
= strdupW(volume_label
);
2710 disk
->disk_prompt
= strdupW(disk_prompt
);
2711 list_add_head(&package
->sourcelist_media
, &disk
->entry
);
2713 return ERROR_SUCCESS
;