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 free_feature( MSIFEATURE
*feature
)
54 struct list
*item
, *cursor
;
56 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Children
)
58 FeatureList
*fl
= LIST_ENTRY( item
, FeatureList
, entry
);
59 list_remove( &fl
->entry
);
63 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Components
)
65 ComponentList
*cl
= LIST_ENTRY( item
, ComponentList
, entry
);
66 list_remove( &cl
->entry
);
69 msi_free( feature
->Feature
);
70 msi_free( feature
->Feature_Parent
);
71 msi_free( feature
->Directory
);
72 msi_free( feature
->Description
);
73 msi_free( feature
->Title
);
77 static void free_folder( MSIFOLDER
*folder
)
79 struct list
*item
, *cursor
;
81 LIST_FOR_EACH_SAFE( item
, cursor
, &folder
->children
)
83 FolderList
*fl
= LIST_ENTRY( item
, FolderList
, entry
);
84 list_remove( &fl
->entry
);
87 msi_free( folder
->Parent
);
88 msi_free( folder
->Directory
);
89 msi_free( folder
->TargetDefault
);
90 msi_free( folder
->SourceLongPath
);
91 msi_free( folder
->SourceShortPath
);
92 msi_free( folder
->ResolvedTarget
);
93 msi_free( folder
->ResolvedSource
);
97 static void free_extension( MSIEXTENSION
*ext
)
99 struct list
*item
, *cursor
;
101 LIST_FOR_EACH_SAFE( item
, cursor
, &ext
->verbs
)
103 MSIVERB
*verb
= LIST_ENTRY( item
, MSIVERB
, entry
);
105 list_remove( &verb
->entry
);
106 msi_free( verb
->Verb
);
107 msi_free( verb
->Command
);
108 msi_free( verb
->Argument
);
112 msi_free( ext
->Extension
);
113 msi_free( ext
->ProgIDText
);
117 static void free_assembly( MSIASSEMBLY
*assembly
)
119 msi_free( assembly
->feature
);
120 msi_free( assembly
->manifest
);
121 msi_free( assembly
->application
);
122 msi_free( assembly
->display_name
);
123 if (assembly
->tempdir
) RemoveDirectoryW( assembly
->tempdir
);
124 msi_free( assembly
->tempdir
);
125 msi_free( assembly
);
128 void msi_free_action_script( MSIPACKAGE
*package
, UINT script
)
131 for (i
= 0; i
< package
->script
->ActionCount
[script
]; i
++)
132 msi_free( package
->script
->Actions
[script
][i
] );
134 msi_free( package
->script
->Actions
[script
] );
135 package
->script
->Actions
[script
] = NULL
;
136 package
->script
->ActionCount
[script
] = 0;
139 static void free_package_structures( MSIPACKAGE
*package
)
141 struct list
*item
, *cursor
;
143 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->features
)
145 MSIFEATURE
*feature
= LIST_ENTRY( item
, MSIFEATURE
, entry
);
146 list_remove( &feature
->entry
);
147 free_feature( feature
);
150 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->folders
)
152 MSIFOLDER
*folder
= LIST_ENTRY( item
, MSIFOLDER
, entry
);
153 list_remove( &folder
->entry
);
154 free_folder( folder
);
157 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->files
)
159 MSIFILE
*file
= LIST_ENTRY( item
, MSIFILE
, entry
);
161 list_remove( &file
->entry
);
162 msi_free( file
->File
);
163 msi_free( file
->FileName
);
164 msi_free( file
->ShortName
);
165 msi_free( file
->LongName
);
166 msi_free( file
->Version
);
167 msi_free( file
->Language
);
168 if (msi_is_global_assembly( file
->Component
)) DeleteFileW( file
->TargetPath
);
169 msi_free( file
->TargetPath
);
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
->filepatches
)
190 MSIFILEPATCH
*patch
= LIST_ENTRY( item
, MSIFILEPATCH
, entry
);
192 list_remove( &patch
->entry
);
193 msi_free( patch
->path
);
197 /* clean up extension, progid, class and verb structures */
198 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->classes
)
200 MSICLASS
*cls
= LIST_ENTRY( item
, MSICLASS
, entry
);
202 list_remove( &cls
->entry
);
203 msi_free( cls
->clsid
);
204 msi_free( cls
->Context
);
205 msi_free( cls
->Description
);
206 msi_free( cls
->FileTypeMask
);
207 msi_free( cls
->IconPath
);
208 msi_free( cls
->DefInprocHandler
);
209 msi_free( cls
->DefInprocHandler32
);
210 msi_free( cls
->Argument
);
211 msi_free( cls
->ProgIDText
);
215 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->extensions
)
217 MSIEXTENSION
*ext
= LIST_ENTRY( item
, MSIEXTENSION
, entry
);
219 list_remove( &ext
->entry
);
220 free_extension( ext
);
223 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->progids
)
225 MSIPROGID
*progid
= LIST_ENTRY( item
, MSIPROGID
, entry
);
227 list_remove( &progid
->entry
);
228 msi_free( progid
->ProgID
);
229 msi_free( progid
->Description
);
230 msi_free( progid
->IconPath
);
234 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->mimes
)
236 MSIMIME
*mt
= LIST_ENTRY( item
, MSIMIME
, entry
);
238 list_remove( &mt
->entry
);
239 msi_free( mt
->suffix
);
240 msi_free( mt
->clsid
);
241 msi_free( mt
->ContentType
);
245 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->appids
)
247 MSIAPPID
*appid
= LIST_ENTRY( item
, MSIAPPID
, entry
);
249 list_remove( &appid
->entry
);
250 msi_free( appid
->AppID
);
251 msi_free( appid
->RemoteServerName
);
252 msi_free( appid
->LocalServer
);
253 msi_free( appid
->ServiceParameters
);
254 msi_free( appid
->DllSurrogate
);
258 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->sourcelist_info
)
260 MSISOURCELISTINFO
*info
= LIST_ENTRY( item
, MSISOURCELISTINFO
, entry
);
262 list_remove( &info
->entry
);
263 msi_free( info
->value
);
267 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->sourcelist_media
)
269 MSIMEDIADISK
*info
= LIST_ENTRY( item
, MSIMEDIADISK
, entry
);
271 list_remove( &info
->entry
);
272 msi_free( info
->volume_label
);
273 msi_free( info
->disk_prompt
);
282 for (i
= 0; i
< SCRIPT_MAX
; i
++)
283 msi_free_action_script( package
, i
);
285 for (j
= 0; j
< package
->script
->UniqueActionsCount
; j
++)
286 msi_free( package
->script
->UniqueActions
[j
] );
288 msi_free( package
->script
->UniqueActions
);
289 msi_free( package
->script
);
292 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->binaries
)
294 MSIBINARY
*binary
= LIST_ENTRY( item
, MSIBINARY
, entry
);
296 list_remove( &binary
->entry
);
298 FreeLibrary( binary
->module
);
299 if (!DeleteFileW( binary
->tmpfile
))
300 ERR("failed to delete %s (%u)\n", debugstr_w(binary
->tmpfile
), GetLastError());
301 msi_free( binary
->source
);
302 msi_free( binary
->tmpfile
);
306 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->cabinet_streams
)
308 MSICABINETSTREAM
*cab
= LIST_ENTRY( item
, MSICABINETSTREAM
, entry
);
310 list_remove( &cab
->entry
);
311 IStorage_Release( cab
->storage
);
312 msi_free( cab
->stream
);
316 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->patches
)
318 MSIPATCHINFO
*patch
= LIST_ENTRY( item
, MSIPATCHINFO
, entry
);
320 list_remove( &patch
->entry
);
321 if (patch
->delete_on_close
&& !DeleteFileW( patch
->localfile
))
323 ERR("failed to delete %s (%u)\n", debugstr_w(patch
->localfile
), GetLastError());
325 msi_free_patchinfo( patch
);
328 msi_free( package
->BaseURL
);
329 msi_free( package
->PackagePath
);
330 msi_free( package
->ProductCode
);
331 msi_free( package
->ActionFormat
);
332 msi_free( package
->LastAction
);
333 msi_free( package
->langids
);
335 /* cleanup control event subscriptions */
336 msi_event_cleanup_all_subscriptions( package
);
339 static void MSI_FreePackage( MSIOBJECTHDR
*arg
)
341 MSIPACKAGE
*package
= (MSIPACKAGE
*)arg
;
343 msi_destroy_assembly_caches( package
);
345 if( package
->dialog
)
346 msi_dialog_destroy( package
->dialog
);
348 msiobj_release( &package
->db
->hdr
);
349 free_package_structures(package
);
350 CloseHandle( package
->log_file
);
352 if (package
->delete_on_close
) DeleteFileW( package
->localfile
);
353 msi_free( package
->localfile
);
356 static UINT
create_temp_property_table(MSIPACKAGE
*package
)
358 static const WCHAR query
[] = {
359 'C','R','E','A','T','E',' ','T','A','B','L','E',' ',
360 '`','_','P','r','o','p','e','r','t','y','`',' ','(',' ',
361 '`','_','P','r','o','p','e','r','t','y','`',' ',
362 'C','H','A','R','(','5','6',')',' ','N','O','T',' ','N','U','L','L',' ',
363 'T','E','M','P','O','R','A','R','Y',',',' ',
364 '`','V','a','l','u','e','`',' ','C','H','A','R','(','9','8',')',' ',
365 'N','O','T',' ','N','U','L','L',' ','T','E','M','P','O','R','A','R','Y',
366 ' ','P','R','I','M','A','R','Y',' ','K','E','Y',' ',
367 '`','_','P','r','o','p','e','r','t','y','`',')',' ','H','O','L','D',0};
371 rc
= MSI_DatabaseOpenViewW(package
->db
, query
, &view
);
372 if (rc
!= ERROR_SUCCESS
)
375 rc
= MSI_ViewExecute(view
, 0);
377 msiobj_release(&view
->hdr
);
381 UINT
msi_clone_properties( MSIDATABASE
*db
)
383 static const WCHAR query_select
[] = {
384 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
385 '`','P','r','o','p','e','r','t','y','`',0};
386 static const WCHAR query_insert
[] = {
387 'I','N','S','E','R','T',' ','I','N','T','O',' ',
388 '`','_','P','r','o','p','e','r','t','y','`',' ',
389 '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
390 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
391 static const WCHAR query_update
[] = {
392 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
393 'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ',
394 'W','H','E','R','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','?',0};
395 MSIQUERY
*view_select
;
398 rc
= MSI_DatabaseOpenViewW( db
, query_select
, &view_select
);
399 if (rc
!= ERROR_SUCCESS
)
402 rc
= MSI_ViewExecute( view_select
, 0 );
403 if (rc
!= ERROR_SUCCESS
)
405 MSI_ViewClose( view_select
);
406 msiobj_release( &view_select
->hdr
);
412 MSIQUERY
*view_insert
, *view_update
;
413 MSIRECORD
*rec_select
;
415 rc
= MSI_ViewFetch( view_select
, &rec_select
);
416 if (rc
!= ERROR_SUCCESS
)
419 rc
= MSI_DatabaseOpenViewW( db
, query_insert
, &view_insert
);
420 if (rc
!= ERROR_SUCCESS
)
422 msiobj_release( &rec_select
->hdr
);
426 rc
= MSI_ViewExecute( view_insert
, rec_select
);
427 MSI_ViewClose( view_insert
);
428 msiobj_release( &view_insert
->hdr
);
429 if (rc
!= ERROR_SUCCESS
)
431 MSIRECORD
*rec_update
;
433 TRACE("insert failed, trying update\n");
435 rc
= MSI_DatabaseOpenViewW( db
, query_update
, &view_update
);
436 if (rc
!= ERROR_SUCCESS
)
438 WARN("open view failed %u\n", rc
);
439 msiobj_release( &rec_select
->hdr
);
443 rec_update
= MSI_CreateRecord( 2 );
444 MSI_RecordCopyField( rec_select
, 1, rec_update
, 2 );
445 MSI_RecordCopyField( rec_select
, 2, rec_update
, 1 );
446 rc
= MSI_ViewExecute( view_update
, rec_update
);
447 if (rc
!= ERROR_SUCCESS
)
448 WARN("update failed %u\n", rc
);
450 MSI_ViewClose( view_update
);
451 msiobj_release( &view_update
->hdr
);
452 msiobj_release( &rec_update
->hdr
);
455 msiobj_release( &rec_select
->hdr
);
458 MSI_ViewClose( view_select
);
459 msiobj_release( &view_select
->hdr
);
466 * Sets the "Installed" property to indicate that
467 * the product is installed for the current user.
469 static UINT
set_installed_prop( MSIPACKAGE
*package
)
474 if (!package
->ProductCode
) return ERROR_FUNCTION_FAILED
;
476 r
= MSIREG_OpenUninstallKey( package
->ProductCode
, package
->platform
, &hkey
, FALSE
);
477 if (r
== ERROR_SUCCESS
)
480 msi_set_property( package
->db
, szInstalled
, szOne
, -1 );
485 static UINT
set_user_sid_prop( MSIPACKAGE
*package
)
489 LPWSTR sid_str
= NULL
, dom
= NULL
;
490 DWORD size
, dom_size
;
492 UINT r
= ERROR_FUNCTION_FAILED
;
495 GetUserNameW( NULL
, &size
);
497 user_name
= msi_alloc( (size
+ 1) * sizeof(WCHAR
) );
499 return ERROR_OUTOFMEMORY
;
501 if (!GetUserNameW( user_name
, &size
))
506 LookupAccountNameW( NULL
, user_name
, NULL
, &size
, NULL
, &dom_size
, &use
);
508 psid
= msi_alloc( size
);
509 dom
= msi_alloc( dom_size
*sizeof (WCHAR
) );
512 r
= ERROR_OUTOFMEMORY
;
516 if (!LookupAccountNameW( NULL
, user_name
, psid
, &size
, dom
, &dom_size
, &use
))
519 if (!ConvertSidToStringSidW( psid
, &sid_str
))
522 r
= msi_set_property( package
->db
, szUserSID
, sid_str
, -1 );
525 LocalFree( sid_str
);
528 msi_free( user_name
);
533 static LPWSTR
get_fusion_filename(MSIPACKAGE
*package
)
538 DWORD index
= 0, size
;
540 WCHAR name
[MAX_PATH
];
541 WCHAR windir
[MAX_PATH
];
543 static const WCHAR fusion
[] = {'f','u','s','i','o','n','.','d','l','l',0};
544 static const WCHAR sub
[] = {
545 'S','o','f','t','w','a','r','e','\\',
546 'M','i','c','r','o','s','o','f','t','\\',
547 'N','E','T',' ','F','r','a','m','e','w','o','r','k',' ','S','e','t','u','p','\\',
550 static const WCHAR subdir
[] = {
551 'M','i','c','r','o','s','o','f','t','.','N','E','T','\\',
552 'F','r','a','m','e','w','o','r','k','\\',0
555 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, sub
, 0, KEY_ENUMERATE_SUB_KEYS
, &netsetup
);
556 if (res
!= ERROR_SUCCESS
)
559 GetWindowsDirectoryW(windir
, MAX_PATH
);
563 while (RegEnumKeyExW(netsetup
, index
, name
, &size
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
567 /* verify existence of fusion.dll .Net 3.0 does not install a new one */
568 if (strcmpW( ver
, name
) < 0)
571 size
= lstrlenW(windir
) + lstrlenW(subdir
) + lstrlenW(name
) +lstrlenW(fusion
) + 3;
572 check
= msi_alloc(size
* sizeof(WCHAR
));
580 lstrcpyW(check
, windir
);
581 lstrcatW(check
, szBackSlash
);
582 lstrcatW(check
, subdir
);
583 lstrcatW(check
, name
);
584 lstrcatW(check
, szBackSlash
);
585 lstrcatW(check
, fusion
);
587 if(GetFileAttributesW(check
) != INVALID_FILE_ATTRIBUTES
)
598 RegCloseKey(netsetup
);
602 typedef struct tagLANGANDCODEPAGE
608 static void set_msi_assembly_prop(MSIPACKAGE
*package
)
612 LPVOID version
= NULL
;
614 LPWSTR fusion
, verstr
;
615 LANGANDCODEPAGE
*translate
;
617 static const WCHAR netasm
[] = {
618 'M','s','i','N','e','t','A','s','s','e','m','b','l','y','S','u','p','p','o','r','t',0
620 static const WCHAR translation
[] = {
621 '\\','V','a','r','F','i','l','e','I','n','f','o',
622 '\\','T','r','a','n','s','l','a','t','i','o','n',0
624 static const WCHAR verfmt
[] = {
625 '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
626 '\\','%','0','4','x','%','0','4','x',
627 '\\','P','r','o','d','u','c','t','V','e','r','s','i','o','n',0
630 fusion
= get_fusion_filename(package
);
634 size
= GetFileVersionInfoSizeW(fusion
, &handle
);
638 version
= msi_alloc(size
);
642 if (!GetFileVersionInfoW(fusion
, handle
, size
, version
))
645 if (!VerQueryValueW(version
, translation
, (LPVOID
*)&translate
, &val_len
))
648 sprintfW(buf
, verfmt
, translate
[0].wLanguage
, translate
[0].wCodePage
);
650 if (!VerQueryValueW(version
, buf
, (LPVOID
*)&verstr
, &val_len
))
653 if (!val_len
|| !verstr
)
656 msi_set_property( package
->db
, netasm
, verstr
, -1 );
663 static VOID
set_installer_properties(MSIPACKAGE
*package
)
666 OSVERSIONINFOEXW OSVersion
;
669 WCHAR pth
[MAX_PATH
], verstr
[11], bufstr
[22];
672 LPWSTR username
, companyname
;
673 SYSTEM_INFO sys_info
;
674 SYSTEMTIME systemtime
;
677 static const WCHAR szCommonFilesFolder
[] = {'C','o','m','m','o','n','F','i','l','e','s','F','o','l','d','e','r',0};
678 static const WCHAR szProgramFilesFolder
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','F','o','l','d','e','r',0};
679 static const WCHAR szCommonAppDataFolder
[] = {'C','o','m','m','o','n','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
680 static const WCHAR szFavoritesFolder
[] = {'F','a','v','o','r','i','t','e','s','F','o','l','d','e','r',0};
681 static const WCHAR szFontsFolder
[] = {'F','o','n','t','s','F','o','l','d','e','r',0};
682 static const WCHAR szSendToFolder
[] = {'S','e','n','d','T','o','F','o','l','d','e','r',0};
683 static const WCHAR szStartMenuFolder
[] = {'S','t','a','r','t','M','e','n','u','F','o','l','d','e','r',0};
684 static const WCHAR szStartupFolder
[] = {'S','t','a','r','t','u','p','F','o','l','d','e','r',0};
685 static const WCHAR szTemplateFolder
[] = {'T','e','m','p','l','a','t','e','F','o','l','d','e','r',0};
686 static const WCHAR szDesktopFolder
[] = {'D','e','s','k','t','o','p','F','o','l','d','e','r',0};
687 static const WCHAR szProgramMenuFolder
[] = {'P','r','o','g','r','a','m','M','e','n','u','F','o','l','d','e','r',0};
688 static const WCHAR szAdminToolsFolder
[] = {'A','d','m','i','n','T','o','o','l','s','F','o','l','d','e','r',0};
689 static const WCHAR szSystemFolder
[] = {'S','y','s','t','e','m','F','o','l','d','e','r',0};
690 static const WCHAR szSystem16Folder
[] = {'S','y','s','t','e','m','1','6','F','o','l','d','e','r',0};
691 static const WCHAR szLocalAppDataFolder
[] = {'L','o','c','a','l','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
692 static const WCHAR szMyPicturesFolder
[] = {'M','y','P','i','c','t','u','r','e','s','F','o','l','d','e','r',0};
693 static const WCHAR szPersonalFolder
[] = {'P','e','r','s','o','n','a','l','F','o','l','d','e','r',0};
694 static const WCHAR szWindowsVolume
[] = {'W','i','n','d','o','w','s','V','o','l','u','m','e',0};
695 static const WCHAR szPrivileged
[] = {'P','r','i','v','i','l','e','g','e','d',0};
696 static const WCHAR szVersion9x
[] = {'V','e','r','s','i','o','n','9','X',0};
697 static const WCHAR szVersionNT
[] = {'V','e','r','s','i','o','n','N','T',0};
698 static const WCHAR szMsiNTProductType
[] = {'M','s','i','N','T','P','r','o','d','u','c','t','T','y','p','e',0};
699 static const WCHAR szFormat
[] = {'%','u',0};
700 static const WCHAR szFormat2
[] = {'%','u','.','%','u',0};
701 static const WCHAR szWindowsBuild
[] = {'W','i','n','d','o','w','s','B','u','i','l','d',0};
702 static const WCHAR szServicePackLevel
[] = {'S','e','r','v','i','c','e','P','a','c','k','L','e','v','e','l',0};
703 static const WCHAR szVersionMsi
[] = { 'V','e','r','s','i','o','n','M','s','i',0 };
704 static const WCHAR szVersionDatabase
[] = { 'V','e','r','s','i','o','n','D','a','t','a','b','a','s','e',0 };
705 static const WCHAR szPhysicalMemory
[] = { 'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0 };
706 static const WCHAR szScreenX
[] = {'S','c','r','e','e','n','X',0};
707 static const WCHAR szScreenY
[] = {'S','c','r','e','e','n','Y',0};
708 static const WCHAR szColorBits
[] = {'C','o','l','o','r','B','i','t','s',0};
709 static const WCHAR szIntFormat
[] = {'%','d',0};
710 static const WCHAR szMsiAMD64
[] = { 'M','s','i','A','M','D','6','4',0 };
711 static const WCHAR szMsix64
[] = { 'M','s','i','x','6','4',0 };
712 static const WCHAR szSystem64Folder
[] = { 'S','y','s','t','e','m','6','4','F','o','l','d','e','r',0 };
713 static const WCHAR szCommonFiles64Folder
[] = { 'C','o','m','m','o','n','F','i','l','e','s','6','4','F','o','l','d','e','r',0 };
714 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 };
715 static const WCHAR szVersionNT64
[] = { 'V','e','r','s','i','o','n','N','T','6','4',0 };
716 static const WCHAR szUserInfo
[] = {
717 'S','O','F','T','W','A','R','E','\\',
718 'M','i','c','r','o','s','o','f','t','\\',
719 'M','S',' ','S','e','t','u','p',' ','(','A','C','M','E',')','\\',
720 'U','s','e','r',' ','I','n','f','o',0
722 static const WCHAR szDefName
[] = { 'D','e','f','N','a','m','e',0 };
723 static const WCHAR szDefCompany
[] = { 'D','e','f','C','o','m','p','a','n','y',0 };
724 static const WCHAR szCurrentVersion
[] = {
725 'S','O','F','T','W','A','R','E','\\',
726 'M','i','c','r','o','s','o','f','t','\\',
727 'W','i','n','d','o','w','s',' ','N','T','\\',
728 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0
730 static const WCHAR szRegisteredUser
[] = {'R','e','g','i','s','t','e','r','e','d','O','w','n','e','r',0};
731 static const WCHAR szRegisteredOrganization
[] = {
732 'R','e','g','i','s','t','e','r','e','d','O','r','g','a','n','i','z','a','t','i','o','n',0
734 static const WCHAR szUSERNAME
[] = {'U','S','E','R','N','A','M','E',0};
735 static const WCHAR szCOMPANYNAME
[] = {'C','O','M','P','A','N','Y','N','A','M','E',0};
736 static const WCHAR szDate
[] = {'D','a','t','e',0};
737 static const WCHAR szTime
[] = {'T','i','m','e',0};
738 static const WCHAR szUserLanguageID
[] = {'U','s','e','r','L','a','n','g','u','a','g','e','I','D',0};
739 static const WCHAR szSystemLangID
[] = {'S','y','s','t','e','m','L','a','n','g','u','a','g','e','I','D',0};
740 static const WCHAR szProductState
[] = {'P','r','o','d','u','c','t','S','t','a','t','e',0};
741 static const WCHAR szLogonUser
[] = {'L','o','g','o','n','U','s','e','r',0};
742 static const WCHAR szNetHoodFolder
[] = {'N','e','t','H','o','o','d','F','o','l','d','e','r',0};
743 static const WCHAR szPrintHoodFolder
[] = {'P','r','i','n','t','H','o','o','d','F','o','l','d','e','r',0};
744 static const WCHAR szRecentFolder
[] = {'R','e','c','e','n','t','F','o','l','d','e','r',0};
745 static const WCHAR szComputerName
[] = {'C','o','m','p','u','t','e','r','N','a','m','e',0};
746 static const WCHAR szBrowseProperty
[] = {'_','B','r','o','w','s','e','P','r','o','p','e','r','t','y',0};
747 static const WCHAR szInstallDir
[] = {'I','N','S','T','A','L','L','D','I','R',0};
750 * Other things that probably should be set:
752 * VirtualMemory ShellAdvSupport DefaultUIFont PackagecodeChanging
753 * CaptionHeight BorderTop BorderSide TextHeight RedirectedDllSupport
756 SHGetFolderPathW(NULL
, CSIDL_COMMON_APPDATA
, NULL
, 0, pth
);
757 strcatW(pth
, szBackSlash
);
758 msi_set_property( package
->db
, szCommonAppDataFolder
, pth
, -1 );
760 SHGetFolderPathW(NULL
, CSIDL_FAVORITES
, NULL
, 0, pth
);
761 strcatW(pth
, szBackSlash
);
762 msi_set_property( package
->db
, szFavoritesFolder
, pth
, -1 );
764 SHGetFolderPathW(NULL
, CSIDL_FONTS
, NULL
, 0, pth
);
765 strcatW(pth
, szBackSlash
);
766 msi_set_property( package
->db
, szFontsFolder
, pth
, -1 );
768 SHGetFolderPathW(NULL
, CSIDL_SENDTO
, NULL
, 0, pth
);
769 strcatW(pth
, szBackSlash
);
770 msi_set_property( package
->db
, szSendToFolder
, pth
, -1 );
772 SHGetFolderPathW(NULL
, CSIDL_STARTMENU
, NULL
, 0, pth
);
773 strcatW(pth
, szBackSlash
);
774 msi_set_property( package
->db
, szStartMenuFolder
, pth
, -1 );
776 SHGetFolderPathW(NULL
, CSIDL_STARTUP
, NULL
, 0, pth
);
777 strcatW(pth
, szBackSlash
);
778 msi_set_property( package
->db
, szStartupFolder
, pth
, -1 );
780 SHGetFolderPathW(NULL
, CSIDL_TEMPLATES
, NULL
, 0, pth
);
781 strcatW(pth
, szBackSlash
);
782 msi_set_property( package
->db
, szTemplateFolder
, pth
, -1 );
784 SHGetFolderPathW(NULL
, CSIDL_DESKTOP
, NULL
, 0, pth
);
785 strcatW(pth
, szBackSlash
);
786 msi_set_property( package
->db
, szDesktopFolder
, pth
, -1 );
788 /* FIXME: set to AllUsers profile path if ALLUSERS is set */
789 SHGetFolderPathW(NULL
, CSIDL_PROGRAMS
, NULL
, 0, pth
);
790 strcatW(pth
, szBackSlash
);
791 msi_set_property( package
->db
, szProgramMenuFolder
, pth
, -1 );
793 SHGetFolderPathW(NULL
, CSIDL_ADMINTOOLS
, NULL
, 0, pth
);
794 strcatW(pth
, szBackSlash
);
795 msi_set_property( package
->db
, szAdminToolsFolder
, pth
, -1 );
797 SHGetFolderPathW(NULL
, CSIDL_APPDATA
, NULL
, 0, pth
);
798 strcatW(pth
, szBackSlash
);
799 msi_set_property( package
->db
, szAppDataFolder
, pth
, -1 );
801 SHGetFolderPathW(NULL
, CSIDL_SYSTEM
, NULL
, 0, pth
);
802 strcatW(pth
, szBackSlash
);
803 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
804 msi_set_property( package
->db
, szSystem16Folder
, pth
, -1 );
806 SHGetFolderPathW(NULL
, CSIDL_LOCAL_APPDATA
, NULL
, 0, pth
);
807 strcatW(pth
, szBackSlash
);
808 msi_set_property( package
->db
, szLocalAppDataFolder
, pth
, -1 );
810 SHGetFolderPathW(NULL
, CSIDL_MYPICTURES
, NULL
, 0, pth
);
811 strcatW(pth
, szBackSlash
);
812 msi_set_property( package
->db
, szMyPicturesFolder
, pth
, -1 );
814 SHGetFolderPathW(NULL
, CSIDL_PERSONAL
, NULL
, 0, pth
);
815 strcatW(pth
, szBackSlash
);
816 msi_set_property( package
->db
, szPersonalFolder
, pth
, -1 );
818 SHGetFolderPathW(NULL
, CSIDL_WINDOWS
, NULL
, 0, pth
);
819 strcatW(pth
, szBackSlash
);
820 msi_set_property( package
->db
, szWindowsFolder
, pth
, -1 );
822 SHGetFolderPathW(NULL
, CSIDL_PRINTHOOD
, NULL
, 0, pth
);
823 strcatW(pth
, szBackSlash
);
824 msi_set_property( package
->db
, szPrintHoodFolder
, pth
, -1 );
826 SHGetFolderPathW(NULL
, CSIDL_NETHOOD
, NULL
, 0, pth
);
827 strcatW(pth
, szBackSlash
);
828 msi_set_property( package
->db
, szNetHoodFolder
, pth
, -1 );
830 SHGetFolderPathW(NULL
, CSIDL_RECENT
, NULL
, 0, pth
);
831 strcatW(pth
, szBackSlash
);
832 msi_set_property( package
->db
, szRecentFolder
, pth
, -1 );
834 /* Physical Memory is specified in MB. Using total amount. */
835 msex
.dwLength
= sizeof(msex
);
836 GlobalMemoryStatusEx( &msex
);
837 len
= sprintfW( bufstr
, szIntFormat
, (int)(msex
.ullTotalPhys
/ 1024 / 1024) );
838 msi_set_property( package
->db
, szPhysicalMemory
, bufstr
, len
);
840 SHGetFolderPathW(NULL
, CSIDL_WINDOWS
, NULL
, 0, pth
);
841 ptr
= strchrW(pth
,'\\');
842 if (ptr
) *(ptr
+ 1) = 0;
843 msi_set_property( package
->db
, szWindowsVolume
, pth
, -1 );
845 len
= GetTempPathW(MAX_PATH
, pth
);
846 msi_set_property( package
->db
, szTempFolder
, pth
, len
);
848 /* in a wine environment the user is always admin and privileged */
849 msi_set_property( package
->db
, szAdminUser
, szOne
, -1 );
850 msi_set_property( package
->db
, szPrivileged
, szOne
, -1 );
852 /* set the os things */
853 OSVersion
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
854 GetVersionExW((OSVERSIONINFOW
*)&OSVersion
);
855 verval
= OSVersion
.dwMinorVersion
+ OSVersion
.dwMajorVersion
* 100;
856 len
= sprintfW( verstr
, szFormat
, verval
);
857 switch (OSVersion
.dwPlatformId
)
859 case VER_PLATFORM_WIN32_WINDOWS
:
860 msi_set_property( package
->db
, szVersion9x
, verstr
, len
);
862 case VER_PLATFORM_WIN32_NT
:
863 msi_set_property( package
->db
, szVersionNT
, verstr
, len
);
864 len
= sprintfW( bufstr
, szFormat
,OSVersion
.wProductType
);
865 msi_set_property( package
->db
, szMsiNTProductType
, bufstr
, len
);
868 len
= sprintfW( bufstr
, szFormat
, OSVersion
.dwBuildNumber
);
869 msi_set_property( package
->db
, szWindowsBuild
, bufstr
, len
);
870 len
= sprintfW( bufstr
, szFormat
, OSVersion
.wServicePackMajor
);
871 msi_set_property( package
->db
, szServicePackLevel
, bufstr
, len
);
873 len
= sprintfW( bufstr
, szFormat2
, MSI_MAJORVERSION
, MSI_MINORVERSION
);
874 msi_set_property( package
->db
, szVersionMsi
, bufstr
, len
);
875 len
= sprintfW( bufstr
, szFormat
, MSI_MAJORVERSION
* 100 );
876 msi_set_property( package
->db
, szVersionDatabase
, bufstr
, len
);
878 GetNativeSystemInfo( &sys_info
);
879 len
= sprintfW( bufstr
, szIntFormat
, sys_info
.wProcessorLevel
);
880 msi_set_property( package
->db
, szIntel
, bufstr
, len
);
881 if (sys_info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
883 GetSystemDirectoryW( pth
, MAX_PATH
);
884 PathAddBackslashW( pth
);
885 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
887 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, pth
);
888 PathAddBackslashW( pth
);
889 msi_set_property( package
->db
, szProgramFilesFolder
, pth
, -1 );
891 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, pth
);
892 PathAddBackslashW( pth
);
893 msi_set_property( package
->db
, szCommonFilesFolder
, pth
, -1 );
895 else if (sys_info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
)
897 msi_set_property( package
->db
, szMsiAMD64
, bufstr
, -1 );
898 msi_set_property( package
->db
, szMsix64
, bufstr
, -1 );
899 msi_set_property( package
->db
, szVersionNT64
, verstr
, -1 );
901 GetSystemDirectoryW( pth
, MAX_PATH
);
902 PathAddBackslashW( pth
);
903 msi_set_property( package
->db
, szSystem64Folder
, pth
, -1 );
905 GetSystemWow64DirectoryW( pth
, MAX_PATH
);
906 PathAddBackslashW( pth
);
907 msi_set_property( package
->db
, szSystemFolder
, pth
, -1 );
909 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, pth
);
910 PathAddBackslashW( pth
);
911 msi_set_property( package
->db
, szProgramFiles64Folder
, pth
, -1 );
913 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, pth
);
914 PathAddBackslashW( pth
);
915 msi_set_property( package
->db
, szProgramFilesFolder
, pth
, -1 );
917 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, pth
);
918 PathAddBackslashW( pth
);
919 msi_set_property( package
->db
, szCommonFiles64Folder
, pth
, -1 );
921 SHGetFolderPathW( NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, pth
);
922 PathAddBackslashW( pth
);
923 msi_set_property( package
->db
, szCommonFilesFolder
, pth
, -1 );
926 /* Screen properties. */
928 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, HORZRES
) );
929 msi_set_property( package
->db
, szScreenX
, bufstr
, len
);
930 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, VERTRES
) );
931 msi_set_property( package
->db
, szScreenY
, bufstr
, len
);
932 len
= sprintfW( bufstr
, szIntFormat
, GetDeviceCaps(dc
, BITSPIXEL
) );
933 msi_set_property( package
->db
, szColorBits
, bufstr
, len
);
936 /* USERNAME and COMPANYNAME */
937 username
= msi_dup_property( package
->db
, szUSERNAME
);
938 companyname
= msi_dup_property( package
->db
, szCOMPANYNAME
);
940 if ((!username
|| !companyname
) &&
941 RegOpenKeyW( HKEY_CURRENT_USER
, szUserInfo
, &hkey
) == ERROR_SUCCESS
)
944 (username
= msi_reg_get_val_str( hkey
, szDefName
)))
945 msi_set_property( package
->db
, szUSERNAME
, username
, -1 );
947 (companyname
= msi_reg_get_val_str( hkey
, szDefCompany
)))
948 msi_set_property( package
->db
, szCOMPANYNAME
, companyname
, -1 );
951 if ((!username
|| !companyname
) &&
952 RegOpenKeyW( HKEY_LOCAL_MACHINE
, szCurrentVersion
, &hkey
) == ERROR_SUCCESS
)
955 (username
= msi_reg_get_val_str( hkey
, szRegisteredUser
)))
956 msi_set_property( package
->db
, szUSERNAME
, username
, -1 );
958 (companyname
= msi_reg_get_val_str( hkey
, szRegisteredOrganization
)))
959 msi_set_property( package
->db
, szCOMPANYNAME
, companyname
, -1 );
962 msi_free( username
);
963 msi_free( companyname
);
965 if ( set_user_sid_prop( package
) != ERROR_SUCCESS
)
966 ERR("Failed to set the UserSID property\n");
968 /* Date and time properties */
969 GetSystemTime( &systemtime
);
970 if (GetDateFormatW( LOCALE_USER_DEFAULT
, DATE_SHORTDATE
, &systemtime
,
971 NULL
, bufstr
, sizeof(bufstr
)/sizeof(bufstr
[0]) ))
972 msi_set_property( package
->db
, szDate
, bufstr
, -1 );
974 ERR("Couldn't set Date property: GetDateFormat failed with error %d\n", GetLastError());
976 if (GetTimeFormatW( LOCALE_USER_DEFAULT
,
977 TIME_FORCE24HOURFORMAT
| TIME_NOTIMEMARKER
,
978 &systemtime
, NULL
, bufstr
,
979 sizeof(bufstr
)/sizeof(bufstr
[0]) ))
980 msi_set_property( package
->db
, szTime
, bufstr
, -1 );
982 ERR("Couldn't set Time property: GetTimeFormat failed with error %d\n", GetLastError());
984 set_msi_assembly_prop( package
);
986 langid
= GetUserDefaultLangID();
987 len
= sprintfW( bufstr
, szIntFormat
, langid
);
988 msi_set_property( package
->db
, szUserLanguageID
, bufstr
, len
);
990 langid
= GetSystemDefaultLangID();
991 len
= sprintfW( bufstr
, szIntFormat
, langid
);
992 msi_set_property( package
->db
, szSystemLangID
, bufstr
, len
);
994 len
= sprintfW( bufstr
, szIntFormat
, MsiQueryProductStateW(package
->ProductCode
) );
995 msi_set_property( package
->db
, szProductState
, bufstr
, len
);
998 if (!GetUserNameW( NULL
, &len
) && GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
1001 if ((username
= msi_alloc( len
* sizeof(WCHAR
) )))
1003 if (GetUserNameW( username
, &len
))
1004 msi_set_property( package
->db
, szLogonUser
, username
, len
- 1 );
1005 msi_free( username
);
1009 if (!GetComputerNameW( NULL
, &len
) && GetLastError() == ERROR_BUFFER_OVERFLOW
)
1011 WCHAR
*computername
;
1012 if ((computername
= msi_alloc( len
* sizeof(WCHAR
) )))
1014 if (GetComputerNameW( computername
, &len
))
1015 msi_set_property( package
->db
, szComputerName
, computername
, len
);
1016 msi_free( computername
);
1019 msi_set_property( package
->db
, szBrowseProperty
, szInstallDir
, -1 );
1022 static MSIPACKAGE
*msi_alloc_package( void )
1024 MSIPACKAGE
*package
;
1026 package
= alloc_msiobject( MSIHANDLETYPE_PACKAGE
, sizeof (MSIPACKAGE
),
1030 list_init( &package
->components
);
1031 list_init( &package
->features
);
1032 list_init( &package
->files
);
1033 list_init( &package
->filepatches
);
1034 list_init( &package
->tempfiles
);
1035 list_init( &package
->folders
);
1036 list_init( &package
->subscriptions
);
1037 list_init( &package
->appids
);
1038 list_init( &package
->classes
);
1039 list_init( &package
->mimes
);
1040 list_init( &package
->extensions
);
1041 list_init( &package
->progids
);
1042 list_init( &package
->RunningActions
);
1043 list_init( &package
->sourcelist_info
);
1044 list_init( &package
->sourcelist_media
);
1045 list_init( &package
->patches
);
1046 list_init( &package
->binaries
);
1047 list_init( &package
->cabinet_streams
);
1053 static UINT
msi_load_admin_properties(MSIPACKAGE
*package
)
1058 static const WCHAR stmname
[] = {'A','d','m','i','n','P','r','o','p','e','r','t','i','e','s',0};
1060 r
= read_stream_data(package
->db
->storage
, stmname
, FALSE
, &data
, &sz
);
1061 if (r
!= ERROR_SUCCESS
)
1064 r
= msi_parse_command_line(package
, (WCHAR
*)data
, TRUE
);
1070 void msi_adjust_privilege_properties( MSIPACKAGE
*package
)
1072 /* FIXME: this should depend on the user's privileges */
1073 if (msi_get_property_int( package
->db
, szAllUsers
, 0 ) == 2)
1075 TRACE("resetting ALLUSERS property from 2 to 1\n");
1076 msi_set_property( package
->db
, szAllUsers
, szOne
, -1 );
1078 msi_set_property( package
->db
, szAdminUser
, szOne
, -1 );
1081 MSIPACKAGE
*MSI_CreatePackage( MSIDATABASE
*db
, LPCWSTR base_url
)
1083 static const WCHAR fmtW
[] = {'%','u',0};
1084 MSIPACKAGE
*package
;
1091 package
= msi_alloc_package();
1094 msiobj_addref( &db
->hdr
);
1097 package
->WordCount
= 0;
1098 package
->PackagePath
= strdupW( db
->path
);
1099 package
->BaseURL
= strdupW( base_url
);
1101 create_temp_property_table( package
);
1102 msi_clone_properties( package
->db
);
1103 msi_adjust_privilege_properties( package
);
1105 package
->ProductCode
= msi_dup_property( package
->db
, szProductCode
);
1106 package
->script
= msi_alloc_zero( sizeof(MSISCRIPT
) );
1108 set_installer_properties( package
);
1110 package
->ui_level
= gUILevel
;
1111 len
= sprintfW( uilevel
, fmtW
, gUILevel
& INSTALLUILEVEL_MASK
);
1112 msi_set_property( package
->db
, szUILevel
, uilevel
, len
);
1114 r
= msi_load_suminfo_properties( package
);
1115 if (r
!= ERROR_SUCCESS
)
1117 msiobj_release( &package
->hdr
);
1121 if (package
->WordCount
& msidbSumInfoSourceTypeAdminImage
)
1122 msi_load_admin_properties( package
);
1124 package
->log_file
= INVALID_HANDLE_VALUE
;
1129 UINT
msi_download_file( LPCWSTR szUrl
, LPWSTR filename
)
1131 LPINTERNET_CACHE_ENTRY_INFOW cache_entry
;
1135 /* call will always fail, because size is 0,
1136 * but will return ERROR_FILE_NOT_FOUND first
1137 * if the file doesn't exist
1139 GetUrlCacheEntryInfoW( szUrl
, NULL
, &size
);
1140 if ( GetLastError() != ERROR_FILE_NOT_FOUND
)
1142 cache_entry
= msi_alloc( size
);
1143 if ( !GetUrlCacheEntryInfoW( szUrl
, cache_entry
, &size
) )
1145 UINT error
= GetLastError();
1146 msi_free( cache_entry
);
1150 lstrcpyW( filename
, cache_entry
->lpszLocalFileName
);
1151 msi_free( cache_entry
);
1152 return ERROR_SUCCESS
;
1155 hr
= URLDownloadToCacheFileW( NULL
, szUrl
, filename
, MAX_PATH
, 0, NULL
);
1158 WARN("failed to download %s to cache file\n", debugstr_w(szUrl
));
1159 return ERROR_FUNCTION_FAILED
;
1162 return ERROR_SUCCESS
;
1165 UINT
msi_create_empty_local_file( LPWSTR path
, LPCWSTR suffix
)
1167 static const WCHAR szInstaller
[] = {
1168 '\\','I','n','s','t','a','l','l','e','r','\\',0};
1169 static const WCHAR fmt
[] = {'%','x',0};
1170 DWORD time
, len
, i
, offset
;
1173 time
= GetTickCount();
1174 GetWindowsDirectoryW( path
, MAX_PATH
);
1175 strcatW( path
, szInstaller
);
1176 CreateDirectoryW( path
, NULL
);
1178 len
= strlenW(path
);
1179 for (i
= 0; i
< 0x10000; i
++)
1181 offset
= snprintfW( path
+ len
, MAX_PATH
- len
, fmt
, (time
+ i
) & 0xffff );
1182 memcpy( path
+ len
+ offset
, suffix
, (strlenW( suffix
) + 1) * sizeof(WCHAR
) );
1183 handle
= CreateFileW( path
, GENERIC_WRITE
, 0, NULL
,
1184 CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, 0 );
1185 if (handle
!= INVALID_HANDLE_VALUE
)
1187 CloseHandle(handle
);
1190 if (GetLastError() != ERROR_FILE_EXISTS
&&
1191 GetLastError() != ERROR_SHARING_VIOLATION
)
1192 return ERROR_FUNCTION_FAILED
;
1195 return ERROR_SUCCESS
;
1198 static enum platform
parse_platform( const WCHAR
*str
)
1200 if (!str
[0] || !strcmpW( str
, szIntel
)) return PLATFORM_INTEL
;
1201 else if (!strcmpW( str
, szIntel64
)) return PLATFORM_INTEL64
;
1202 else if (!strcmpW( str
, szX64
) || !strcmpW( str
, szAMD64
)) return PLATFORM_X64
;
1203 else if (!strcmpW( str
, szARM
)) return PLATFORM_ARM
;
1204 return PLATFORM_UNKNOWN
;
1207 static UINT
parse_suminfo( MSISUMMARYINFO
*si
, MSIPACKAGE
*package
)
1209 WCHAR
*template, *p
, *q
, *platform
;
1212 package
->version
= msi_suminfo_get_int32( si
, PID_PAGECOUNT
);
1213 TRACE("version: %d\n", package
->version
);
1215 template = msi_suminfo_dup_string( si
, PID_TEMPLATE
);
1217 return ERROR_SUCCESS
; /* native accepts missing template property */
1219 TRACE("template: %s\n", debugstr_w(template));
1221 p
= strchrW( template, ';' );
1224 WARN("invalid template string %s\n", debugstr_w(template));
1225 msi_free( template );
1226 return ERROR_PATCH_PACKAGE_INVALID
;
1229 platform
= template;
1230 if ((q
= strchrW( platform
, ',' ))) *q
= 0;
1231 package
->platform
= parse_platform( platform
);
1232 while (package
->platform
== PLATFORM_UNKNOWN
&& q
)
1235 if ((q
= strchrW( platform
, ',' ))) *q
= 0;
1236 package
->platform
= parse_platform( platform
);
1238 if (package
->platform
== PLATFORM_UNKNOWN
)
1240 WARN("unknown platform %s\n", debugstr_w(template));
1241 msi_free( template );
1242 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1247 msi_free( template );
1248 return ERROR_SUCCESS
;
1251 for (q
= p
; (q
= strchrW( q
, ',' )); q
++) count
++;
1253 package
->langids
= msi_alloc( count
* sizeof(LANGID
) );
1254 if (!package
->langids
)
1256 msi_free( template );
1257 return ERROR_OUTOFMEMORY
;
1263 q
= strchrW( p
, ',' );
1265 package
->langids
[i
] = atoiW( p
);
1270 package
->num_langids
= i
+ 1;
1272 msi_free( template );
1273 return ERROR_SUCCESS
;
1276 static UINT
validate_package( MSIPACKAGE
*package
)
1280 if (package
->platform
== PLATFORM_INTEL64
)
1281 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1283 if (package
->platform
== PLATFORM_ARM
)
1284 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1286 if (package
->platform
== PLATFORM_X64
)
1288 if (!is_64bit
&& !is_wow64
)
1289 return ERROR_INSTALL_PLATFORM_UNSUPPORTED
;
1290 if (package
->version
< 200)
1291 return ERROR_INSTALL_PACKAGE_INVALID
;
1293 if (!package
->num_langids
)
1295 return ERROR_SUCCESS
;
1297 for (i
= 0; i
< package
->num_langids
; i
++)
1299 LANGID langid
= package
->langids
[i
];
1301 if (PRIMARYLANGID( langid
) == LANG_NEUTRAL
)
1303 langid
= MAKELANGID( PRIMARYLANGID( GetSystemDefaultLangID() ), SUBLANGID( langid
) );
1305 if (SUBLANGID( langid
) == SUBLANG_NEUTRAL
)
1307 langid
= MAKELANGID( PRIMARYLANGID( langid
), SUBLANGID( GetSystemDefaultLangID() ) );
1309 if (IsValidLocale( langid
, LCID_INSTALLED
))
1310 return ERROR_SUCCESS
;
1312 return ERROR_INSTALL_LANGUAGE_UNSUPPORTED
;
1315 static WCHAR
*get_product_code( MSIDATABASE
*db
)
1317 static const WCHAR query
[] = {
1318 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
1319 'F','R','O','M',' ','`','P','r','o','p','e','r','t','y','`',' ',
1320 'W','H','E','R','E',' ','`','P','r','o','p','e','r','t','y','`','=',
1321 '\'','P','r','o','d','u','c','t','C','o','d','e','\'',0};
1326 if (MSI_DatabaseOpenViewW( db
, query
, &view
) != ERROR_SUCCESS
)
1330 if (MSI_ViewExecute( view
, 0 ) != ERROR_SUCCESS
)
1332 MSI_ViewClose( view
);
1333 msiobj_release( &view
->hdr
);
1336 if (MSI_ViewFetch( view
, &rec
) == ERROR_SUCCESS
)
1338 ret
= strdupW( MSI_RecordGetString( rec
, 1 ) );
1339 msiobj_release( &rec
->hdr
);
1341 MSI_ViewClose( view
);
1342 msiobj_release( &view
->hdr
);
1346 static UINT
get_registered_local_package( const WCHAR
*product
, const WCHAR
*package
, WCHAR
*localfile
)
1348 MSIINSTALLCONTEXT context
;
1349 HKEY product_key
, props_key
;
1350 WCHAR
*registered_package
= NULL
, unsquashed
[GUID_SIZE
];
1353 r
= msi_locate_product( product
, &context
);
1354 if (r
!= ERROR_SUCCESS
)
1357 r
= MSIREG_OpenProductKey( product
, NULL
, context
, &product_key
, FALSE
);
1358 if (r
!= ERROR_SUCCESS
)
1361 r
= MSIREG_OpenInstallProps( product
, context
, NULL
, &props_key
, FALSE
);
1362 if (r
!= ERROR_SUCCESS
)
1364 RegCloseKey( product_key
);
1367 r
= ERROR_FUNCTION_FAILED
;
1368 registered_package
= msi_reg_get_val_str( product_key
, INSTALLPROPERTY_PACKAGECODEW
);
1369 if (!registered_package
)
1372 unsquash_guid( registered_package
, unsquashed
);
1373 if (!strcmpiW( package
, unsquashed
))
1375 WCHAR
*filename
= msi_reg_get_val_str( props_key
, INSTALLPROPERTY_LOCALPACKAGEW
);
1379 strcpyW( localfile
, filename
);
1380 msi_free( filename
);
1384 msi_free( registered_package
);
1385 RegCloseKey( props_key
);
1386 RegCloseKey( product_key
);
1390 static WCHAR
*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( const WCHAR
*filename
, WCHAR
*localfile
)
1413 WCHAR
*product_code
, *package_code
;
1417 if ((r
= MSI_OpenDatabaseW( filename
, MSIDBOPEN_READONLY
, &db
)) != ERROR_SUCCESS
)
1419 if (GetFileAttributesW( filename
) == INVALID_FILE_ATTRIBUTES
)
1420 return ERROR_FILE_NOT_FOUND
;
1423 if (!(product_code
= get_product_code( db
)))
1425 msiobj_release( &db
->hdr
);
1426 return ERROR_INSTALL_PACKAGE_INVALID
;
1428 if (!(package_code
= get_package_code( db
)))
1430 msi_free( product_code
);
1431 msiobj_release( &db
->hdr
);
1432 return ERROR_INSTALL_PACKAGE_INVALID
;
1434 r
= get_registered_local_package( product_code
, package_code
, localfile
);
1435 msi_free( package_code
);
1436 msi_free( product_code
);
1437 msiobj_release( &db
->hdr
);
1441 UINT
msi_set_original_database_property( MSIDATABASE
*db
, const WCHAR
*package
)
1445 if (UrlIsW( package
, URLIS_URL
))
1446 r
= msi_set_property( db
, szOriginalDatabase
, package
, -1 );
1447 else if (package
[0] == '#')
1448 r
= msi_set_property( db
, szOriginalDatabase
, db
->path
, -1 );
1454 if (!(len
= GetFullPathNameW( package
, 0, NULL
, NULL
))) return GetLastError();
1455 if (!(path
= msi_alloc( len
* sizeof(WCHAR
) ))) return ERROR_OUTOFMEMORY
;
1456 len
= GetFullPathNameW( package
, len
, path
, NULL
);
1457 r
= msi_set_property( db
, szOriginalDatabase
, path
, len
);
1463 UINT
MSI_OpenPackageW(LPCWSTR szPackage
, MSIPACKAGE
**pPackage
)
1465 static const WCHAR dotmsi
[] = {'.','m','s','i',0};
1467 MSIPACKAGE
*package
;
1469 LPWSTR ptr
, base_url
= NULL
;
1471 WCHAR localfile
[MAX_PATH
], cachefile
[MAX_PATH
];
1472 LPCWSTR file
= szPackage
;
1475 BOOL delete_on_close
= FALSE
;
1477 TRACE("%s %p\n", debugstr_w(szPackage
), pPackage
);
1480 if( szPackage
[0] == '#' )
1482 handle
= atoiW(&szPackage
[1]);
1483 db
= msihandle2msiinfo( handle
, MSIHANDLETYPE_DATABASE
);
1486 IWineMsiRemoteDatabase
*remote_database
;
1488 remote_database
= (IWineMsiRemoteDatabase
*)msi_get_remote( handle
);
1489 if ( !remote_database
)
1490 return ERROR_INVALID_HANDLE
;
1492 IWineMsiRemoteDatabase_Release( remote_database
);
1493 WARN("MsiOpenPackage not allowed during a custom action!\n");
1495 return ERROR_FUNCTION_FAILED
;
1500 if ( UrlIsW( szPackage
, URLIS_URL
) )
1502 r
= msi_download_file( szPackage
, cachefile
);
1503 if (r
!= ERROR_SUCCESS
)
1508 base_url
= strdupW( szPackage
);
1510 return ERROR_OUTOFMEMORY
;
1512 ptr
= strrchrW( base_url
, '/' );
1513 if (ptr
) *(ptr
+ 1) = '\0';
1515 r
= get_local_package( file
, localfile
);
1516 if (r
!= ERROR_SUCCESS
|| GetFileAttributesW( localfile
) == INVALID_FILE_ATTRIBUTES
)
1518 r
= msi_create_empty_local_file( localfile
, dotmsi
);
1519 if (r
!= ERROR_SUCCESS
)
1521 msi_free ( base_url
);
1525 if (!CopyFileW( file
, localfile
, FALSE
))
1528 WARN("unable to copy package %s to %s (%u)\n", debugstr_w(file
), debugstr_w(localfile
), r
);
1529 DeleteFileW( localfile
);
1530 msi_free ( base_url
);
1533 delete_on_close
= TRUE
;
1535 TRACE("opening package %s\n", debugstr_w( localfile
));
1536 r
= MSI_OpenDatabaseW( localfile
, MSIDBOPEN_TRANSACT
, &db
);
1537 if (r
!= ERROR_SUCCESS
)
1539 msi_free ( base_url
);
1543 package
= MSI_CreatePackage( db
, base_url
);
1544 msi_free( base_url
);
1545 msiobj_release( &db
->hdr
);
1546 if (!package
) return ERROR_INSTALL_PACKAGE_INVALID
;
1547 package
->localfile
= strdupW( localfile
);
1548 package
->delete_on_close
= delete_on_close
;
1550 r
= msi_get_suminfo( db
->storage
, 0, &si
);
1551 if (r
!= ERROR_SUCCESS
)
1553 r
= msi_get_db_suminfo( db
, 0, &si
);
1554 if (r
!= ERROR_SUCCESS
)
1556 WARN("failed to load summary info\n");
1557 msiobj_release( &package
->hdr
);
1558 return ERROR_INSTALL_PACKAGE_INVALID
;
1561 r
= parse_suminfo( si
, package
);
1562 msiobj_release( &si
->hdr
);
1563 if (r
!= ERROR_SUCCESS
)
1565 WARN("failed to parse summary info %u\n", r
);
1566 msiobj_release( &package
->hdr
);
1569 r
= validate_package( package
);
1570 if (r
!= ERROR_SUCCESS
)
1572 msiobj_release( &package
->hdr
);
1575 msi_set_property( package
->db
, szDatabase
, db
->path
, -1 );
1576 set_installed_prop( package
);
1577 msi_set_context( package
);
1581 WCHAR patch_code
[GUID_SIZE
];
1582 r
= MsiEnumPatchesExW( package
->ProductCode
, NULL
, package
->Context
,
1583 MSIPATCHSTATE_APPLIED
, index
, patch_code
, NULL
, NULL
, NULL
, NULL
);
1584 if (r
!= ERROR_SUCCESS
)
1587 TRACE("found registered patch %s\n", debugstr_w(patch_code
));
1589 r
= msi_apply_registered_patch( package
, patch_code
);
1590 if (r
!= ERROR_SUCCESS
)
1592 ERR("registered patch failed to apply %u\n", r
);
1593 msiobj_release( &package
->hdr
);
1598 if (index
) msi_adjust_privilege_properties( package
);
1600 r
= msi_set_original_database_property( package
->db
, szPackage
);
1601 if (r
!= ERROR_SUCCESS
)
1603 msiobj_release( &package
->hdr
);
1607 package
->log_file
= CreateFileW( gszLogFile
, GENERIC_WRITE
, FILE_SHARE_WRITE
, NULL
,
1608 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1609 *pPackage
= package
;
1610 return ERROR_SUCCESS
;
1613 UINT WINAPI
MsiOpenPackageExW(LPCWSTR szPackage
, DWORD dwOptions
, MSIHANDLE
*phPackage
)
1615 MSIPACKAGE
*package
= NULL
;
1618 TRACE("%s %08x %p\n", debugstr_w(szPackage
), dwOptions
, phPackage
);
1620 if( !szPackage
|| !phPackage
)
1621 return ERROR_INVALID_PARAMETER
;
1625 FIXME("Should create an empty database and package\n");
1626 return ERROR_FUNCTION_FAILED
;
1630 FIXME("dwOptions %08x not supported\n", dwOptions
);
1632 ret
= MSI_OpenPackageW( szPackage
, &package
);
1633 if( ret
== ERROR_SUCCESS
)
1635 *phPackage
= alloc_msihandle( &package
->hdr
);
1637 ret
= ERROR_NOT_ENOUGH_MEMORY
;
1638 msiobj_release( &package
->hdr
);
1644 UINT WINAPI
MsiOpenPackageW(LPCWSTR szPackage
, MSIHANDLE
*phPackage
)
1646 return MsiOpenPackageExW( szPackage
, 0, phPackage
);
1649 UINT WINAPI
MsiOpenPackageExA(LPCSTR szPackage
, DWORD dwOptions
, MSIHANDLE
*phPackage
)
1651 LPWSTR szwPack
= NULL
;
1656 szwPack
= strdupAtoW( szPackage
);
1658 return ERROR_OUTOFMEMORY
;
1661 ret
= MsiOpenPackageExW( szwPack
, dwOptions
, phPackage
);
1663 msi_free( szwPack
);
1668 UINT WINAPI
MsiOpenPackageA(LPCSTR szPackage
, MSIHANDLE
*phPackage
)
1670 return MsiOpenPackageExA( szPackage
, 0, phPackage
);
1673 MSIHANDLE WINAPI
MsiGetActiveDatabase(MSIHANDLE hInstall
)
1675 MSIPACKAGE
*package
;
1676 MSIHANDLE handle
= 0;
1677 IUnknown
*remote_unk
;
1678 IWineMsiRemotePackage
*remote_package
;
1680 TRACE("(%d)\n",hInstall
);
1682 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
1685 handle
= alloc_msihandle( &package
->db
->hdr
);
1686 msiobj_release( &package
->hdr
);
1688 else if ((remote_unk
= msi_get_remote(hInstall
)))
1690 if (IUnknown_QueryInterface(remote_unk
, &IID_IWineMsiRemotePackage
,
1691 (LPVOID
*)&remote_package
) == S_OK
)
1693 IWineMsiRemotePackage_GetActiveDatabase(remote_package
, &handle
);
1694 IWineMsiRemotePackage_Release(remote_package
);
1698 WARN("remote handle %d is not a package\n", hInstall
);
1700 IUnknown_Release(remote_unk
);
1706 INT
MSI_ProcessMessage( MSIPACKAGE
*package
, INSTALLMESSAGE eMessageType
, MSIRECORD
*record
)
1708 static const WCHAR szActionData
[] = {'A','c','t','i','o','n','D','a','t','a',0};
1709 static const WCHAR szSetProgress
[] = {'S','e','t','P','r','o','g','r','e','s','s',0};
1710 static const WCHAR szActionText
[] = {'A','c','t','i','o','n','T','e','x','t',0};
1712 LPWSTR deformated
, message
;
1713 DWORD i
, len
, total_len
, log_type
= 0;
1717 TRACE("%x\n", eMessageType
);
1719 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_FATALEXIT
)
1720 log_type
|= INSTALLLOGMODE_FATALEXIT
;
1721 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_ERROR
)
1722 log_type
|= INSTALLLOGMODE_ERROR
;
1723 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_WARNING
)
1724 log_type
|= INSTALLLOGMODE_WARNING
;
1725 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_USER
)
1726 log_type
|= INSTALLLOGMODE_USER
;
1727 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_INFO
)
1728 log_type
|= INSTALLLOGMODE_INFO
;
1729 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_RESOLVESOURCE
)
1730 log_type
|= INSTALLLOGMODE_RESOLVESOURCE
;
1731 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_OUTOFDISKSPACE
)
1732 log_type
|= INSTALLLOGMODE_OUTOFDISKSPACE
;
1733 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_COMMONDATA
)
1734 log_type
|= INSTALLLOGMODE_COMMONDATA
;
1735 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_ACTIONSTART
)
1736 log_type
|= INSTALLLOGMODE_ACTIONSTART
;
1737 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_ACTIONDATA
)
1738 log_type
|= INSTALLLOGMODE_ACTIONDATA
;
1739 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_PROGRESS
)
1740 log_type
|= INSTALLLOGMODE_PROGRESS
;
1741 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_INITIALIZE
)
1742 log_type
|= INSTALLLOGMODE_INITIALIZE
;
1743 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_TERMINATE
)
1744 log_type
|= INSTALLLOGMODE_TERMINATE
;
1745 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_SHOWDIALOG
)
1746 log_type
|= INSTALLLOGMODE_SHOWDIALOG
;
1748 if ((eMessageType
& 0xff000000) == INSTALLMESSAGE_ACTIONSTART
)
1750 static const WCHAR template_s
[]=
1751 {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ',0};
1752 static const WCHAR format
[] =
1753 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
1755 LPCWSTR action_text
, action
;
1756 LPWSTR deformatted
= NULL
;
1758 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0, NULL
, format
, timet
, 0x100);
1760 action
= MSI_RecordGetString(record
, 1);
1761 action_text
= MSI_RecordGetString(record
, 2);
1763 if (!action
|| !action_text
)
1766 deformat_string(package
, action_text
, &deformatted
);
1768 len
= strlenW(timet
) + strlenW(action
) + strlenW(template_s
);
1770 len
+= strlenW(deformatted
);
1771 message
= msi_alloc(len
*sizeof(WCHAR
));
1772 sprintfW(message
, template_s
, timet
, action
);
1774 strcatW(message
, deformatted
);
1775 msi_free(deformatted
);
1779 static const WCHAR format
[] = {'%','u',':',' ',0};
1780 UINT count
= MSI_RecordGetFieldCount( record
);
1784 for (i
= 1; i
<= count
; i
++)
1787 MSI_RecordGetStringW( record
, i
, NULL
, &len
);
1788 total_len
+= len
+ 13;
1790 p
= message
= msi_alloc( total_len
* sizeof(WCHAR
) );
1791 if (!p
) return ERROR_OUTOFMEMORY
;
1793 for (i
= 1; i
<= count
; i
++)
1797 len
= sprintfW( p
, format
, i
);
1802 MSI_RecordGetStringW( record
, i
, p
, &len
);
1805 if (count
> 1 && total_len
)
1814 TRACE("%p %p %p %x %x %s\n", gUIHandlerA
, gUIHandlerW
, gUIHandlerRecord
,
1815 gUIFilter
, log_type
, debugstr_w(message
));
1817 /* convert it to ASCII */
1818 len
= WideCharToMultiByte( CP_ACP
, 0, message
, -1, NULL
, 0, NULL
, NULL
);
1819 msg
= msi_alloc( len
);
1820 WideCharToMultiByte( CP_ACP
, 0, message
, -1, msg
, len
, NULL
, NULL
);
1822 if (gUIHandlerW
&& (gUIFilter
& log_type
))
1824 rc
= gUIHandlerW( gUIContext
, eMessageType
, message
);
1826 else if (gUIHandlerA
&& (gUIFilter
& log_type
))
1828 rc
= gUIHandlerA( gUIContext
, eMessageType
, msg
);
1830 else if (gUIHandlerRecord
&& (gUIFilter
& log_type
))
1832 MSIHANDLE rec
= MsiCreateRecord( 1 );
1833 MsiRecordSetStringW( rec
, 0, message
);
1834 rc
= gUIHandlerRecord( gUIContext
, eMessageType
, rec
);
1835 MsiCloseHandle( rec
);
1838 if (!rc
&& package
->log_file
!= INVALID_HANDLE_VALUE
&&
1839 (eMessageType
& 0xff000000) != INSTALLMESSAGE_PROGRESS
)
1842 WriteFile( package
->log_file
, msg
, len
- 1, &written
, NULL
);
1843 WriteFile( package
->log_file
, "\n", 1, &written
, NULL
);
1846 msi_free( message
);
1848 switch (eMessageType
& 0xff000000)
1850 case INSTALLMESSAGE_ACTIONDATA
:
1851 deformat_string(package
, MSI_RecordGetString(record
, 2), &deformated
);
1852 uirow
= MSI_CreateRecord(1);
1853 MSI_RecordSetStringW(uirow
, 1, deformated
);
1854 msi_free(deformated
);
1856 msi_event_fire( package
, szActionData
, uirow
);
1857 msiobj_release(&uirow
->hdr
);
1859 if (package
->action_progress_increment
)
1861 uirow
= MSI_CreateRecord(2);
1862 MSI_RecordSetInteger(uirow
, 1, 2);
1863 MSI_RecordSetInteger(uirow
, 2, package
->action_progress_increment
);
1864 msi_event_fire( package
, szSetProgress
, uirow
);
1865 msiobj_release(&uirow
->hdr
);
1869 case INSTALLMESSAGE_ACTIONSTART
:
1870 deformat_string(package
, MSI_RecordGetString(record
, 2), &deformated
);
1871 uirow
= MSI_CreateRecord(1);
1872 MSI_RecordSetStringW(uirow
, 1, deformated
);
1873 msi_free(deformated
);
1875 msi_event_fire( package
, szActionText
, uirow
);
1877 msiobj_release(&uirow
->hdr
);
1880 case INSTALLMESSAGE_PROGRESS
:
1881 msi_event_fire( package
, szSetProgress
, record
);
1885 return ERROR_SUCCESS
;
1888 INT WINAPI
MsiProcessMessage( MSIHANDLE hInstall
, INSTALLMESSAGE eMessageType
,
1891 UINT ret
= ERROR_INVALID_HANDLE
;
1892 MSIPACKAGE
*package
= NULL
;
1893 MSIRECORD
*record
= NULL
;
1895 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
1899 IWineMsiRemotePackage
*remote_package
;
1901 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
1902 if (!remote_package
)
1903 return ERROR_INVALID_HANDLE
;
1905 hr
= IWineMsiRemotePackage_ProcessMessage( remote_package
, eMessageType
, hRecord
);
1907 IWineMsiRemotePackage_Release( remote_package
);
1911 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1912 return HRESULT_CODE(hr
);
1914 return ERROR_FUNCTION_FAILED
;
1917 return ERROR_SUCCESS
;
1920 record
= msihandle2msiinfo( hRecord
, MSIHANDLETYPE_RECORD
);
1924 ret
= MSI_ProcessMessage( package
, eMessageType
, record
);
1927 msiobj_release( &package
->hdr
);
1929 msiobj_release( &record
->hdr
);
1936 UINT WINAPI
MsiSetPropertyA( MSIHANDLE hInstall
, LPCSTR szName
, LPCSTR szValue
)
1938 LPWSTR szwName
= NULL
, szwValue
= NULL
;
1939 UINT r
= ERROR_OUTOFMEMORY
;
1941 szwName
= strdupAtoW( szName
);
1942 if( szName
&& !szwName
)
1945 szwValue
= strdupAtoW( szValue
);
1946 if( szValue
&& !szwValue
)
1949 r
= MsiSetPropertyW( hInstall
, szwName
, szwValue
);
1952 msi_free( szwName
);
1953 msi_free( szwValue
);
1958 void msi_reset_folders( MSIPACKAGE
*package
, BOOL source
)
1962 LIST_FOR_EACH_ENTRY( folder
, &package
->folders
, MSIFOLDER
, entry
)
1966 msi_free( folder
->ResolvedSource
);
1967 folder
->ResolvedSource
= NULL
;
1971 msi_free( folder
->ResolvedTarget
);
1972 folder
->ResolvedTarget
= NULL
;
1977 UINT
msi_set_property( MSIDATABASE
*db
, const WCHAR
*name
, const WCHAR
*value
, int len
)
1979 static const WCHAR insert_query
[] = {
1980 'I','N','S','E','R','T',' ','I','N','T','O',' ',
1981 '`','_','P','r','o','p','e','r','t','y','`',' ',
1982 '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
1983 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
1984 static const WCHAR update_query
[] = {
1985 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
1986 'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ','W','H','E','R','E',' ',
1987 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
1988 static const WCHAR delete_query
[] = {
1989 'D','E','L','E','T','E',' ','F','R','O','M',' ',
1990 '`','_','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
1991 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
1993 MSIRECORD
*row
= NULL
;
1998 TRACE("%p %s %s %d\n", db
, debugstr_w(name
), debugstr_wn(value
, len
), len
);
2001 return ERROR_INVALID_PARAMETER
;
2003 /* this one is weird... */
2005 return value
? ERROR_FUNCTION_FAILED
: ERROR_SUCCESS
;
2007 if (value
&& len
< 0) len
= strlenW( value
);
2009 rc
= msi_get_property( db
, name
, 0, &sz
);
2010 if (!value
|| (!*value
&& !len
))
2012 sprintfW( query
, delete_query
, name
);
2014 else if (rc
== ERROR_MORE_DATA
|| rc
== ERROR_SUCCESS
)
2016 sprintfW( query
, update_query
, name
);
2017 row
= MSI_CreateRecord(1);
2018 msi_record_set_string( row
, 1, value
, len
);
2022 strcpyW( query
, insert_query
);
2023 row
= MSI_CreateRecord(2);
2024 msi_record_set_string( row
, 1, name
, -1 );
2025 msi_record_set_string( row
, 2, value
, len
);
2028 rc
= MSI_DatabaseOpenViewW(db
, query
, &view
);
2029 if (rc
== ERROR_SUCCESS
)
2031 rc
= MSI_ViewExecute(view
, row
);
2032 MSI_ViewClose(view
);
2033 msiobj_release(&view
->hdr
);
2035 if (row
) msiobj_release(&row
->hdr
);
2039 UINT WINAPI
MsiSetPropertyW( MSIHANDLE hInstall
, LPCWSTR szName
, LPCWSTR szValue
)
2041 MSIPACKAGE
*package
;
2044 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
2048 BSTR name
= NULL
, value
= NULL
;
2049 IWineMsiRemotePackage
*remote_package
;
2051 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
2052 if (!remote_package
)
2053 return ERROR_INVALID_HANDLE
;
2055 name
= SysAllocString( szName
);
2056 value
= SysAllocString( szValue
);
2057 if ((!name
&& szName
) || (!value
&& szValue
))
2059 SysFreeString( name
);
2060 SysFreeString( value
);
2061 IWineMsiRemotePackage_Release( remote_package
);
2062 return ERROR_OUTOFMEMORY
;
2065 hr
= IWineMsiRemotePackage_SetProperty( remote_package
, name
, value
);
2067 SysFreeString( name
);
2068 SysFreeString( value
);
2069 IWineMsiRemotePackage_Release( remote_package
);
2073 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
2074 return HRESULT_CODE(hr
);
2076 return ERROR_FUNCTION_FAILED
;
2079 return ERROR_SUCCESS
;
2082 ret
= msi_set_property( package
->db
, szName
, szValue
, -1 );
2083 if (ret
== ERROR_SUCCESS
&& !strcmpW( szName
, szSourceDir
))
2084 msi_reset_folders( package
, TRUE
);
2086 msiobj_release( &package
->hdr
);
2090 static MSIRECORD
*msi_get_property_row( MSIDATABASE
*db
, LPCWSTR name
)
2092 static const WCHAR query
[]= {
2093 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
2094 'F','R','O','M',' ' ,'`','_','P','r','o','p','e','r','t','y','`',' ',
2095 'W','H','E','R','E',' ' ,'`','_','P','r','o','p','e','r','t','y','`','=','?',0};
2096 MSIRECORD
*rec
, *row
= NULL
;
2100 if (!name
|| !*name
)
2103 rec
= MSI_CreateRecord(1);
2107 MSI_RecordSetStringW(rec
, 1, name
);
2109 r
= MSI_DatabaseOpenViewW(db
, query
, &view
);
2110 if (r
== ERROR_SUCCESS
)
2112 MSI_ViewExecute(view
, rec
);
2113 MSI_ViewFetch(view
, &row
);
2114 MSI_ViewClose(view
);
2115 msiobj_release(&view
->hdr
);
2117 msiobj_release(&rec
->hdr
);
2121 /* internal function, not compatible with MsiGetPropertyW */
2122 UINT
msi_get_property( MSIDATABASE
*db
, LPCWSTR szName
,
2123 LPWSTR szValueBuf
, LPDWORD pchValueBuf
)
2126 UINT rc
= ERROR_FUNCTION_FAILED
;
2128 TRACE("%p %s %p %p\n", db
, debugstr_w(szName
), szValueBuf
, pchValueBuf
);
2130 row
= msi_get_property_row( db
, szName
);
2132 if (*pchValueBuf
> 0)
2137 rc
= MSI_RecordGetStringW(row
, 1, szValueBuf
, pchValueBuf
);
2138 msiobj_release(&row
->hdr
);
2141 if (rc
== ERROR_SUCCESS
)
2142 TRACE("returning %s for property %s\n", debugstr_wn(szValueBuf
, *pchValueBuf
),
2143 debugstr_w(szName
));
2144 else if (rc
== ERROR_MORE_DATA
)
2145 TRACE("need %d sized buffer for %s\n", *pchValueBuf
,
2146 debugstr_w(szName
));
2150 TRACE("property %s not found\n", debugstr_w(szName
));
2156 LPWSTR
msi_dup_property(MSIDATABASE
*db
, LPCWSTR prop
)
2162 r
= msi_get_property(db
, prop
, NULL
, &sz
);
2163 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
2167 str
= msi_alloc(sz
* sizeof(WCHAR
));
2168 r
= msi_get_property(db
, prop
, str
, &sz
);
2169 if (r
!= ERROR_SUCCESS
)
2178 int msi_get_property_int( MSIDATABASE
*db
, LPCWSTR prop
, int def
)
2180 LPWSTR str
= msi_dup_property( db
, prop
);
2181 int val
= str
? atoiW(str
) : def
;
2186 static UINT
MSI_GetProperty( MSIHANDLE handle
, LPCWSTR name
,
2187 awstring
*szValueBuf
, LPDWORD pchValueBuf
)
2189 MSIPACKAGE
*package
;
2190 MSIRECORD
*row
= NULL
;
2191 UINT r
= ERROR_FUNCTION_FAILED
;
2195 TRACE("%u %s %p %p\n", handle
, debugstr_w(name
),
2196 szValueBuf
->str
.w
, pchValueBuf
);
2199 return ERROR_INVALID_PARAMETER
;
2201 package
= msihandle2msiinfo( handle
, MSIHANDLETYPE_PACKAGE
);
2205 IWineMsiRemotePackage
*remote_package
;
2206 LPWSTR value
= NULL
;
2209 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( handle
);
2210 if (!remote_package
)
2211 return ERROR_INVALID_HANDLE
;
2213 bname
= SysAllocString( name
);
2216 IWineMsiRemotePackage_Release( remote_package
);
2217 return ERROR_OUTOFMEMORY
;
2220 hr
= IWineMsiRemotePackage_GetProperty( remote_package
, bname
, NULL
, &len
);
2225 value
= msi_alloc(len
* sizeof(WCHAR
));
2228 r
= ERROR_OUTOFMEMORY
;
2232 hr
= IWineMsiRemotePackage_GetProperty( remote_package
, bname
, value
, &len
);
2236 r
= msi_strcpy_to_awstring( value
, len
, szValueBuf
, pchValueBuf
);
2238 /* Bug required by Adobe installers */
2239 if (!szValueBuf
->unicode
&& !szValueBuf
->str
.a
)
2240 *pchValueBuf
*= sizeof(WCHAR
);
2243 IWineMsiRemotePackage_Release(remote_package
);
2244 SysFreeString(bname
);
2249 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
2250 return HRESULT_CODE(hr
);
2252 return ERROR_FUNCTION_FAILED
;
2258 row
= msi_get_property_row( package
->db
, name
);
2260 val
= msi_record_get_string( row
, 1, (int *)&len
);
2265 r
= msi_strcpy_to_awstring( val
, len
, szValueBuf
, pchValueBuf
);
2268 msiobj_release( &row
->hdr
);
2269 msiobj_release( &package
->hdr
);
2274 UINT WINAPI
MsiGetPropertyA( MSIHANDLE hInstall
, LPCSTR szName
,
2275 LPSTR szValueBuf
, LPDWORD pchValueBuf
)
2281 val
.unicode
= FALSE
;
2282 val
.str
.a
= szValueBuf
;
2284 name
= strdupAtoW( szName
);
2285 if (szName
&& !name
)
2286 return ERROR_OUTOFMEMORY
;
2288 r
= MSI_GetProperty( hInstall
, name
, &val
, pchValueBuf
);
2293 UINT WINAPI
MsiGetPropertyW( MSIHANDLE hInstall
, LPCWSTR szName
,
2294 LPWSTR szValueBuf
, LPDWORD pchValueBuf
)
2299 val
.str
.w
= szValueBuf
;
2301 return MSI_GetProperty( hInstall
, szName
, &val
, pchValueBuf
);
2304 typedef struct _msi_remote_package_impl
{
2305 IWineMsiRemotePackage IWineMsiRemotePackage_iface
;
2308 } msi_remote_package_impl
;
2310 static inline msi_remote_package_impl
*impl_from_IWineMsiRemotePackage( IWineMsiRemotePackage
*iface
)
2312 return CONTAINING_RECORD(iface
, msi_remote_package_impl
, IWineMsiRemotePackage_iface
);
2315 static HRESULT WINAPI
mrp_QueryInterface( IWineMsiRemotePackage
*iface
,
2316 REFIID riid
,LPVOID
*ppobj
)
2318 if( IsEqualCLSID( riid
, &IID_IUnknown
) ||
2319 IsEqualCLSID( riid
, &IID_IWineMsiRemotePackage
) )
2321 IWineMsiRemotePackage_AddRef( iface
);
2326 return E_NOINTERFACE
;
2329 static ULONG WINAPI
mrp_AddRef( IWineMsiRemotePackage
*iface
)
2331 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2333 return InterlockedIncrement( &This
->refs
);
2336 static ULONG WINAPI
mrp_Release( IWineMsiRemotePackage
*iface
)
2338 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2341 r
= InterlockedDecrement( &This
->refs
);
2344 MsiCloseHandle( This
->package
);
2350 static HRESULT WINAPI
mrp_SetMsiHandle( IWineMsiRemotePackage
*iface
, MSIHANDLE handle
)
2352 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2353 This
->package
= handle
;
2357 static HRESULT WINAPI
mrp_GetActiveDatabase( IWineMsiRemotePackage
*iface
, MSIHANDLE
*handle
)
2359 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2360 IWineMsiRemoteDatabase
*rdb
= NULL
;
2364 hr
= create_msi_remote_database( NULL
, (LPVOID
*)&rdb
);
2365 if (FAILED(hr
) || !rdb
)
2367 ERR("Failed to create remote database\n");
2371 hdb
= MsiGetActiveDatabase(This
->package
);
2373 hr
= IWineMsiRemoteDatabase_SetMsiHandle( rdb
, hdb
);
2376 ERR("Failed to set the database handle\n");
2380 *handle
= alloc_msi_remote_handle( (IUnknown
*)rdb
);
2384 static HRESULT WINAPI
mrp_GetProperty( IWineMsiRemotePackage
*iface
, BSTR property
, BSTR value
, DWORD
*size
)
2386 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2387 UINT r
= MsiGetPropertyW(This
->package
, property
, value
, size
);
2388 if (r
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(r
);
2392 static HRESULT WINAPI
mrp_SetProperty( IWineMsiRemotePackage
*iface
, BSTR property
, BSTR value
)
2394 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2395 UINT r
= MsiSetPropertyW(This
->package
, property
, value
);
2396 return HRESULT_FROM_WIN32(r
);
2399 static HRESULT WINAPI
mrp_ProcessMessage( IWineMsiRemotePackage
*iface
, INSTALLMESSAGE message
, MSIHANDLE record
)
2401 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2402 UINT r
= MsiProcessMessage(This
->package
, message
, record
);
2403 return HRESULT_FROM_WIN32(r
);
2406 static HRESULT WINAPI
mrp_DoAction( IWineMsiRemotePackage
*iface
, BSTR action
)
2408 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2409 UINT r
= MsiDoActionW(This
->package
, action
);
2410 return HRESULT_FROM_WIN32(r
);
2413 static HRESULT WINAPI
mrp_Sequence( IWineMsiRemotePackage
*iface
, BSTR table
, int sequence
)
2415 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2416 UINT r
= MsiSequenceW(This
->package
, table
, sequence
);
2417 return HRESULT_FROM_WIN32(r
);
2420 static HRESULT WINAPI
mrp_GetTargetPath( IWineMsiRemotePackage
*iface
, BSTR folder
, BSTR value
, DWORD
*size
)
2422 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2423 UINT r
= MsiGetTargetPathW(This
->package
, folder
, value
, size
);
2424 return HRESULT_FROM_WIN32(r
);
2427 static HRESULT WINAPI
mrp_SetTargetPath( IWineMsiRemotePackage
*iface
, BSTR folder
, BSTR value
)
2429 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2430 UINT r
= MsiSetTargetPathW(This
->package
, folder
, value
);
2431 return HRESULT_FROM_WIN32(r
);
2434 static HRESULT WINAPI
mrp_GetSourcePath( IWineMsiRemotePackage
*iface
, BSTR folder
, BSTR value
, DWORD
*size
)
2436 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2437 UINT r
= MsiGetSourcePathW(This
->package
, folder
, value
, size
);
2438 return HRESULT_FROM_WIN32(r
);
2441 static HRESULT WINAPI
mrp_GetMode( IWineMsiRemotePackage
*iface
, MSIRUNMODE mode
, BOOL
*ret
)
2443 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2444 *ret
= MsiGetMode(This
->package
, mode
);
2448 static HRESULT WINAPI
mrp_SetMode( IWineMsiRemotePackage
*iface
, MSIRUNMODE mode
, BOOL state
)
2450 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2451 UINT r
= MsiSetMode(This
->package
, mode
, state
);
2452 return HRESULT_FROM_WIN32(r
);
2455 static HRESULT WINAPI
mrp_GetFeatureState( IWineMsiRemotePackage
*iface
, BSTR feature
,
2456 INSTALLSTATE
*installed
, INSTALLSTATE
*action
)
2458 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2459 UINT r
= MsiGetFeatureStateW(This
->package
, feature
, installed
, action
);
2460 return HRESULT_FROM_WIN32(r
);
2463 static HRESULT WINAPI
mrp_SetFeatureState( IWineMsiRemotePackage
*iface
, BSTR feature
, INSTALLSTATE state
)
2465 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2466 UINT r
= MsiSetFeatureStateW(This
->package
, feature
, state
);
2467 return HRESULT_FROM_WIN32(r
);
2470 static HRESULT WINAPI
mrp_GetComponentState( IWineMsiRemotePackage
*iface
, BSTR component
,
2471 INSTALLSTATE
*installed
, INSTALLSTATE
*action
)
2473 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2474 UINT r
= MsiGetComponentStateW(This
->package
, component
, installed
, action
);
2475 return HRESULT_FROM_WIN32(r
);
2478 static HRESULT WINAPI
mrp_SetComponentState( IWineMsiRemotePackage
*iface
, BSTR component
, INSTALLSTATE state
)
2480 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2481 UINT r
= MsiSetComponentStateW(This
->package
, component
, state
);
2482 return HRESULT_FROM_WIN32(r
);
2485 static HRESULT WINAPI
mrp_GetLanguage( IWineMsiRemotePackage
*iface
, LANGID
*language
)
2487 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2488 *language
= MsiGetLanguage(This
->package
);
2492 static HRESULT WINAPI
mrp_SetInstallLevel( IWineMsiRemotePackage
*iface
, int level
)
2494 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2495 UINT r
= MsiSetInstallLevel(This
->package
, level
);
2496 return HRESULT_FROM_WIN32(r
);
2499 static HRESULT WINAPI
mrp_FormatRecord( IWineMsiRemotePackage
*iface
, MSIHANDLE record
,
2503 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2504 UINT r
= MsiFormatRecordW(This
->package
, record
, NULL
, &size
);
2505 if (r
== ERROR_SUCCESS
)
2507 *value
= SysAllocStringLen(NULL
, size
);
2509 return E_OUTOFMEMORY
;
2511 r
= MsiFormatRecordW(This
->package
, record
, *value
, &size
);
2513 return HRESULT_FROM_WIN32(r
);
2516 static HRESULT WINAPI
mrp_EvaluateCondition( IWineMsiRemotePackage
*iface
, BSTR condition
)
2518 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2519 UINT r
= MsiEvaluateConditionW(This
->package
, condition
);
2520 return HRESULT_FROM_WIN32(r
);
2523 static HRESULT WINAPI
mrp_GetFeatureCost( IWineMsiRemotePackage
*iface
, BSTR feature
,
2524 INT cost_tree
, INSTALLSTATE state
, INT
*cost
)
2526 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2527 UINT r
= MsiGetFeatureCostW(This
->package
, feature
, cost_tree
, state
, cost
);
2528 return HRESULT_FROM_WIN32(r
);
2531 static HRESULT WINAPI
mrp_EnumComponentCosts( IWineMsiRemotePackage
*iface
, BSTR component
,
2532 DWORD index
, INSTALLSTATE state
, BSTR drive
,
2533 DWORD
*buflen
, INT
*cost
, INT
*temp
)
2535 msi_remote_package_impl
* This
= impl_from_IWineMsiRemotePackage( iface
);
2536 UINT r
= MsiEnumComponentCostsW(This
->package
, component
, index
, state
, drive
, buflen
, cost
, temp
);
2537 return HRESULT_FROM_WIN32(r
);
2540 static const IWineMsiRemotePackageVtbl msi_remote_package_vtbl
=
2546 mrp_GetActiveDatabase
,
2557 mrp_GetFeatureState
,
2558 mrp_SetFeatureState
,
2559 mrp_GetComponentState
,
2560 mrp_SetComponentState
,
2562 mrp_SetInstallLevel
,
2564 mrp_EvaluateCondition
,
2566 mrp_EnumComponentCosts
2569 HRESULT
create_msi_remote_package( IUnknown
*pOuter
, LPVOID
*ppObj
)
2571 msi_remote_package_impl
* This
;
2573 This
= msi_alloc( sizeof *This
);
2575 return E_OUTOFMEMORY
;
2577 This
->IWineMsiRemotePackage_iface
.lpVtbl
= &msi_remote_package_vtbl
;
2581 *ppObj
= &This
->IWineMsiRemotePackage_iface
;
2586 UINT
msi_package_add_info(MSIPACKAGE
*package
, DWORD context
, DWORD options
,
2587 LPCWSTR property
, LPWSTR value
)
2589 MSISOURCELISTINFO
*info
;
2591 LIST_FOR_EACH_ENTRY( info
, &package
->sourcelist_info
, MSISOURCELISTINFO
, entry
)
2593 if (!strcmpW( info
->value
, value
)) return ERROR_SUCCESS
;
2596 info
= msi_alloc(sizeof(MSISOURCELISTINFO
));
2598 return ERROR_OUTOFMEMORY
;
2600 info
->context
= context
;
2601 info
->options
= options
;
2602 info
->property
= property
;
2603 info
->value
= strdupW(value
);
2604 list_add_head(&package
->sourcelist_info
, &info
->entry
);
2606 return ERROR_SUCCESS
;
2609 UINT
msi_package_add_media_disk(MSIPACKAGE
*package
, DWORD context
, DWORD options
,
2610 DWORD disk_id
, LPWSTR volume_label
, LPWSTR disk_prompt
)
2614 LIST_FOR_EACH_ENTRY( disk
, &package
->sourcelist_media
, MSIMEDIADISK
, entry
)
2616 if (disk
->disk_id
== disk_id
) return ERROR_SUCCESS
;
2619 disk
= msi_alloc(sizeof(MSIMEDIADISK
));
2621 return ERROR_OUTOFMEMORY
;
2623 disk
->context
= context
;
2624 disk
->options
= options
;
2625 disk
->disk_id
= disk_id
;
2626 disk
->volume_label
= strdupW(volume_label
);
2627 disk
->disk_prompt
= strdupW(disk_prompt
);
2628 list_add_head(&package
->sourcelist_media
, &disk
->entry
);
2630 return ERROR_SUCCESS
;