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 if (!DeleteFileW( temp->Path ))
63 ERR("failed to delete %s\n", debugstr_w( temp->Path ));
64 msi_free( temp->Path );
69 static void free_feature( MSIFEATURE *feature )
71 struct list *item, *cursor;
73 LIST_FOR_EACH_SAFE( item, cursor, &feature->Children )
75 FeatureList *fl = LIST_ENTRY( item, FeatureList, entry );
76 list_remove( &fl->entry );
80 LIST_FOR_EACH_SAFE( item, cursor, &feature->Components )
82 ComponentList *cl = LIST_ENTRY( item, ComponentList, entry );
83 list_remove( &cl->entry );
86 msi_free( feature->Feature );
87 msi_free( feature->Feature_Parent );
88 msi_free( feature->Directory );
89 msi_free( feature->Description );
90 msi_free( feature->Title );
94 static void free_extension( MSIEXTENSION *ext )
96 struct list *item, *cursor;
98 LIST_FOR_EACH_SAFE( item, cursor, &ext->verbs )
100 MSIVERB *verb = LIST_ENTRY( item, MSIVERB, entry );
102 list_remove( &verb->entry );
103 msi_free( verb->Verb );
104 msi_free( verb->Command );
105 msi_free( verb->Argument );
109 msi_free( ext->Extension );
110 msi_free( ext->ProgIDText );
114 static void free_package_structures( MSIPACKAGE *package )
117 struct list *item, *cursor;
119 TRACE("Freeing package action data\n");
121 remove_tracked_tempfiles(package);
123 LIST_FOR_EACH_SAFE( item, cursor, &package->features )
125 MSIFEATURE *feature = LIST_ENTRY( item, MSIFEATURE, entry );
126 list_remove( &feature->entry );
127 free_feature( feature );
130 LIST_FOR_EACH_SAFE( item, cursor, &package->folders )
132 MSIFOLDER *folder = LIST_ENTRY( item, MSIFOLDER, entry );
134 list_remove( &folder->entry );
135 msi_free( folder->Parent );
136 msi_free( folder->Directory );
137 msi_free( folder->TargetDefault );
138 msi_free( folder->SourceLongPath );
139 msi_free( folder->SourceShortPath );
140 msi_free( folder->ResolvedTarget );
141 msi_free( folder->ResolvedSource );
142 msi_free( folder->Property );
146 LIST_FOR_EACH_SAFE( item, cursor, &package->components )
148 MSICOMPONENT *comp = LIST_ENTRY( item, MSICOMPONENT, entry );
150 list_remove( &comp->entry );
151 msi_free( comp->Component );
152 msi_free( comp->ComponentId );
153 msi_free( comp->Directory );
154 msi_free( comp->Condition );
155 msi_free( comp->KeyPath );
156 msi_free( comp->FullKeypath );
160 LIST_FOR_EACH_SAFE( item, cursor, &package->files )
162 MSIFILE *file = LIST_ENTRY( item, MSIFILE, entry );
164 list_remove( &file->entry );
165 msi_free( file->File );
166 msi_free( file->FileName );
167 msi_free( file->ShortName );
168 msi_free( file->LongName );
169 msi_free( file->Version );
170 msi_free( file->Language );
171 msi_free( file->TargetPath );
175 /* clean up extension, progid, class and verb structures */
176 LIST_FOR_EACH_SAFE( item, cursor, &package->classes )
178 MSICLASS *cls = LIST_ENTRY( item, MSICLASS, entry );
180 list_remove( &cls->entry );
181 msi_free( cls->clsid );
182 msi_free( cls->Context );
183 msi_free( cls->Description );
184 msi_free( cls->FileTypeMask );
185 msi_free( cls->IconPath );
186 msi_free( cls->DefInprocHandler );
187 msi_free( cls->DefInprocHandler32 );
188 msi_free( cls->Argument );
189 msi_free( cls->ProgIDText );
193 LIST_FOR_EACH_SAFE( item, cursor, &package->extensions )
195 MSIEXTENSION *ext = LIST_ENTRY( item, MSIEXTENSION, entry );
197 list_remove( &ext->entry );
198 free_extension( ext );
201 LIST_FOR_EACH_SAFE( item, cursor, &package->progids )
203 MSIPROGID *progid = LIST_ENTRY( item, MSIPROGID, entry );
205 list_remove( &progid->entry );
206 msi_free( progid->ProgID );
207 msi_free( progid->Description );
208 msi_free( progid->IconPath );
212 LIST_FOR_EACH_SAFE( item, cursor, &package->mimes )
214 MSIMIME *mt = LIST_ENTRY( item, MSIMIME, entry );
216 list_remove( &mt->entry );
217 msi_free( mt->suffix );
218 msi_free( mt->clsid );
219 msi_free( mt->ContentType );
223 LIST_FOR_EACH_SAFE( item, cursor, &package->appids )
225 MSIAPPID *appid = LIST_ENTRY( item, MSIAPPID, entry );
227 list_remove( &appid->entry );
228 msi_free( appid->AppID );
229 msi_free( appid->RemoteServerName );
230 msi_free( appid->LocalServer );
231 msi_free( appid->ServiceParameters );
232 msi_free( appid->DllSurrogate );
236 LIST_FOR_EACH_SAFE( item, cursor, &package->sourcelist_info )
238 MSISOURCELISTINFO *info = LIST_ENTRY( item, MSISOURCELISTINFO, entry );
240 list_remove( &info->entry );
241 msi_free( info->value );
245 LIST_FOR_EACH_SAFE( item, cursor, &package->sourcelist_media )
247 MSIMEDIADISK *info = LIST_ENTRY( item, MSIMEDIADISK, entry );
249 list_remove( &info->entry );
250 msi_free( info->volume_label );
251 msi_free( info->disk_prompt );
257 for (i = 0; i < TOTAL_SCRIPTS; i++)
258 msi_free_action_script( package, i );
260 for (i = 0; i < package->script->UniqueActionsCount; i++)
261 msi_free( package->script->UniqueActions[i] );
263 msi_free( package->script->UniqueActions );
264 msi_free( package->script );
267 LIST_FOR_EACH_SAFE( item, cursor, &package->patches )
269 MSIPATCHINFO *patch = LIST_ENTRY( item, MSIPATCHINFO, entry );
271 list_remove( &patch->entry );
272 msi_free( patch->patchcode );
273 msi_free( patch->transforms );
277 msi_free( package->BaseURL );
278 msi_free( package->PackagePath );
279 msi_free( package->ProductCode );
280 msi_free( package->ActionFormat );
281 msi_free( package->LastAction );
283 /* cleanup control event subscriptions */
284 ControlEvent_CleanupSubscriptions( package );
287 static void MSI_FreePackage( MSIOBJECTHDR *arg)
289 MSIPACKAGE *package= (MSIPACKAGE*) arg;
291 if( package->dialog )
292 msi_dialog_destroy( package->dialog );
294 msiobj_release( &package->db->hdr );
295 free_package_structures(package);
298 static UINT create_temp_property_table(MSIPACKAGE *package)
300 MSIQUERY *view = NULL;
303 static const WCHAR CreateSql[] = {
304 'C','R','E','A','T','E',' ','T','A','B','L','E',' ',
305 '`','_','P','r','o','p','e','r','t','y','`',' ','(',' ',
306 '`','_','P','r','o','p','e','r','t','y','`',' ',
307 'C','H','A','R','(','5','6',')',' ','N','O','T',' ','N','U','L','L',' ',
308 'T','E','M','P','O','R','A','R','Y',',',' ',
309 '`','V','a','l','u','e','`',' ','C','H','A','R','(','9','8',')',' ',
310 'N','O','T',' ','N','U','L','L',' ','T','E','M','P','O','R','A','R','Y',
311 ' ','P','R','I','M','A','R','Y',' ','K','E','Y',' ',
312 '`','_','P','r','o','p','e','r','t','y','`',')',' ','H','O','L','D',0};
314 rc = MSI_DatabaseOpenViewW(package->db, CreateSql, &view);
315 if (rc != ERROR_SUCCESS)
318 rc = MSI_ViewExecute(view, 0);
320 msiobj_release(&view->hdr);
324 UINT msi_clone_properties(MSIPACKAGE *package)
326 MSIQUERY *view = NULL;
329 static const WCHAR Query[] = {
330 'S','E','L','E','C','T',' ','*',' ',
331 'F','R','O','M',' ','`','P','r','o','p','e','r','t','y','`',0};
332 static const WCHAR Insert[] = {
333 'I','N','S','E','R','T',' ','i','n','t','o',' ',
334 '`','_','P','r','o','p','e','r','t','y','`',' ',
335 '(','`','_','P','r','o','p','e','r','t','y','`',',',
336 '`','V','a','l','u','e','`',')',' ',
337 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
339 /* clone the existing properties */
340 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
341 if (rc != ERROR_SUCCESS)
344 rc = MSI_ViewExecute(view, 0);
345 if (rc != ERROR_SUCCESS)
348 msiobj_release(&view->hdr);
357 rc = MSI_ViewFetch(view, &row);
358 if (rc != ERROR_SUCCESS)
361 rc = MSI_DatabaseOpenViewW(package->db, Insert, &view2);
362 if (rc != ERROR_SUCCESS)
364 msiobj_release(&row->hdr);
368 MSI_ViewExecute(view2, row);
369 MSI_ViewClose(view2);
370 msiobj_release(&view2->hdr);
371 msiobj_release(&row->hdr);
375 msiobj_release(&view->hdr);
383 * Sets the "Installed" property to indicate that
384 * the product is installed for the current user.
386 static UINT set_installed_prop( MSIPACKAGE *package )
391 r = MSIREG_OpenUninstallKey( package->ProductCode, &hkey, FALSE );
392 if (r == ERROR_SUCCESS)
395 msi_set_property( package->db, szInstalled, szOne );
401 static UINT set_user_sid_prop( MSIPACKAGE *package )
405 LPWSTR sid_str = NULL, dom = NULL;
406 DWORD size, dom_size;
408 UINT r = ERROR_FUNCTION_FAILED;
411 GetUserNameW( NULL, &size );
413 user_name = msi_alloc( (size + 1) * sizeof(WCHAR) );
415 return ERROR_OUTOFMEMORY;
417 if (!GetUserNameW( user_name, &size ))
422 LookupAccountNameW( NULL, user_name, NULL, &size, NULL, &dom_size, &use );
424 psid = msi_alloc( size );
425 dom = msi_alloc( dom_size*sizeof (WCHAR) );
428 r = ERROR_OUTOFMEMORY;
432 if (!LookupAccountNameW( NULL, user_name, psid, &size, dom, &dom_size, &use ))
435 if (!ConvertSidToStringSidW( psid, &sid_str ))
438 r = msi_set_property( package->db, szUserSID, sid_str );
441 LocalFree( sid_str );
444 msi_free( user_name );
449 static LPWSTR get_fusion_filename(MSIPACKAGE *package)
454 DWORD index = 0, size;
456 WCHAR name[MAX_PATH];
457 WCHAR windir[MAX_PATH];
459 static const WCHAR fusion[] = {'f','u','s','i','o','n','.','d','l','l',0};
460 static const WCHAR sub[] = {
461 'S','o','f','t','w','a','r','e','\\',
462 'M','i','c','r','o','s','o','f','t','\\',
463 'N','E','T',' ','F','r','a','m','e','w','o','r','k',' ','S','e','t','u','p','\\',
466 static const WCHAR subdir[] = {
467 'M','i','c','r','o','s','o','f','t','.','N','E','T','\\',
468 'F','r','a','m','e','w','o','r','k','\\',0
471 res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, sub, 0, KEY_ENUMERATE_SUB_KEYS, &netsetup);
472 if (res != ERROR_SUCCESS)
475 GetWindowsDirectoryW(windir, MAX_PATH);
479 while (RegEnumKeyExW(netsetup, index, name, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
483 /* verify existence of fusion.dll .Net 3.0 does not install a new one */
484 if (lstrcmpW(ver, name) < 0)
487 size = lstrlenW(windir) + lstrlenW(subdir) + lstrlenW(name) +lstrlenW(fusion) + 3;
488 check = msi_alloc(size * sizeof(WCHAR));
496 lstrcpyW(check, windir);
497 lstrcatW(check, szBackSlash);
498 lstrcatW(check, subdir);
499 lstrcatW(check, name);
500 lstrcatW(check, szBackSlash);
501 lstrcatW(check, fusion);
503 if(GetFileAttributesW(check) != INVALID_FILE_ATTRIBUTES)
514 RegCloseKey(netsetup);
518 typedef struct tagLANGANDCODEPAGE
524 static void set_msi_assembly_prop(MSIPACKAGE *package)
528 LPVOID version = NULL;
530 LPWSTR fusion, verstr;
531 LANGANDCODEPAGE *translate;
533 static const WCHAR netasm[] = {
534 'M','s','i','N','e','t','A','s','s','e','m','b','l','y','S','u','p','p','o','r','t',0
536 static const WCHAR translation[] = {
537 '\\','V','a','r','F','i','l','e','I','n','f','o',
538 '\\','T','r','a','n','s','l','a','t','i','o','n',0
540 static const WCHAR verfmt[] = {
541 '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
542 '\\','%','0','4','x','%','0','4','x',
543 '\\','P','r','o','d','u','c','t','V','e','r','s','i','o','n',0
546 fusion = get_fusion_filename(package);
550 size = GetFileVersionInfoSizeW(fusion, &handle);
553 version = msi_alloc(size);
554 if (!version) return;
556 if (!GetFileVersionInfoW(fusion, handle, size, version))
559 if (!VerQueryValueW(version, translation, (LPVOID *)&translate, &val_len))
562 sprintfW(buf, verfmt, translate[0].wLanguage, translate[0].wCodePage);
564 if (!VerQueryValueW(version, buf, (LPVOID *)&verstr, &val_len))
567 if (!val_len || !verstr)
570 msi_set_property(package->db, netasm, verstr);
577 static VOID set_installer_properties(MSIPACKAGE *package)
581 OSVERSIONINFOEXW OSVersion;
584 WCHAR verstr[10], bufstr[20];
587 LPWSTR username, companyname;
588 SYSTEM_INFO sys_info;
589 SYSTEMTIME systemtime;
592 static const WCHAR CFF[] =
593 {'C','o','m','m','o','n','F','i','l','e','s','F','o','l','d','e','r',0};
594 static const WCHAR PFF[] =
595 {'P','r','o','g','r','a','m','F','i','l','e','s','F','o','l','d','e','r',0};
596 static const WCHAR CADF[] =
597 {'C','o','m','m','o','n','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
598 static const WCHAR FaF[] =
599 {'F','a','v','o','r','i','t','e','s','F','o','l','d','e','r',0};
600 static const WCHAR FoF[] =
601 {'F','o','n','t','s','F','o','l','d','e','r',0};
602 static const WCHAR SendTF[] =
603 {'S','e','n','d','T','o','F','o','l','d','e','r',0};
604 static const WCHAR SMF[] =
605 {'S','t','a','r','t','M','e','n','u','F','o','l','d','e','r',0};
606 static const WCHAR StF[] =
607 {'S','t','a','r','t','u','p','F','o','l','d','e','r',0};
608 static const WCHAR TemplF[] =
609 {'T','e','m','p','l','a','t','e','F','o','l','d','e','r',0};
610 static const WCHAR DF[] =
611 {'D','e','s','k','t','o','p','F','o','l','d','e','r',0};
612 static const WCHAR PMF[] =
613 {'P','r','o','g','r','a','m','M','e','n','u','F','o','l','d','e','r',0};
614 static const WCHAR ATF[] =
615 {'A','d','m','i','n','T','o','o','l','s','F','o','l','d','e','r',0};
616 static const WCHAR ADF[] =
617 {'A','p','p','D','a','t','a','F','o','l','d','e','r',0};
618 static const WCHAR SF[] =
619 {'S','y','s','t','e','m','F','o','l','d','e','r',0};
620 static const WCHAR SF16[] =
621 {'S','y','s','t','e','m','1','6','F','o','l','d','e','r',0};
622 static const WCHAR LADF[] =
623 {'L','o','c','a','l','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
624 static const WCHAR MPF[] =
625 {'M','y','P','i','c','t','u','r','e','s','F','o','l','d','e','r',0};
626 static const WCHAR PF[] =
627 {'P','e','r','s','o','n','a','l','F','o','l','d','e','r',0};
628 static const WCHAR WF[] =
629 {'W','i','n','d','o','w','s','F','o','l','d','e','r',0};
630 static const WCHAR WV[] =
631 {'W','i','n','d','o','w','s','V','o','l','u','m','e',0};
632 static const WCHAR TF[]=
633 {'T','e','m','p','F','o','l','d','e','r',0};
634 static const WCHAR szAdminUser[] =
635 {'A','d','m','i','n','U','s','e','r',0};
636 static const WCHAR szPriv[] =
637 {'P','r','i','v','i','l','e','g','e','d',0};
638 static const WCHAR v9x[] = { 'V','e','r','s','i','o','n','9','X',0 };
639 static const WCHAR vNT[] = { 'V','e','r','s','i','o','n','N','T',0 };
640 static const WCHAR szMsiNTProductType[] = { 'M','s','i','N','T','P','r','o','d','u','c','t','T','y','p','e',0 };
641 static const WCHAR szFormat[] = {'%','l','i',0};
642 static const WCHAR szWinBuild[] =
643 {'W','i','n','d','o','w','s','B','u','i','l','d', 0 };
644 static const WCHAR szSPL[] =
645 {'S','e','r','v','i','c','e','P','a','c','k','L','e','v','e','l',0 };
646 static const WCHAR szSix[] = {'6',0 };
648 static const WCHAR szVersionMsi[] = { 'V','e','r','s','i','o','n','M','s','i',0 };
649 static const WCHAR szVersionDatabase[] = { 'V','e','r','s','i','o','n','D','a','t','a','b','a','s','e',0 };
650 static const WCHAR szPhysicalMemory[] = { 'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0 };
651 static const WCHAR szFormat2[] = {'%','l','i','.','%','l','i',0};
652 /* Screen properties */
653 static const WCHAR szScreenX[] = {'S','c','r','e','e','n','X',0};
654 static const WCHAR szScreenY[] = {'S','c','r','e','e','n','Y',0};
655 static const WCHAR szColorBits[] = {'C','o','l','o','r','B','i','t','s',0};
656 static const WCHAR szIntFormat[] = {'%','d',0};
657 static const WCHAR szIntel[] = { 'I','n','t','e','l',0 };
658 static const WCHAR szUserInfo[] = {
659 'S','O','F','T','W','A','R','E','\\',
660 'M','i','c','r','o','s','o','f','t','\\',
661 'M','S',' ','S','e','t','u','p',' ','(','A','C','M','E',')','\\',
662 'U','s','e','r',' ','I','n','f','o',0
664 static const WCHAR szDefName[] = { 'D','e','f','N','a','m','e',0 };
665 static const WCHAR szDefCompany[] = { 'D','e','f','C','o','m','p','a','n','y',0 };
666 static const WCHAR szCurrentVersion[] = {
667 'S','O','F','T','W','A','R','E','\\',
668 'M','i','c','r','o','s','o','f','t','\\',
669 'W','i','n','d','o','w','s',' ','N','T','\\',
670 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0
672 static const WCHAR szRegisteredUser[] = {'R','e','g','i','s','t','e','r','e','d','O','w','n','e','r',0};
673 static const WCHAR szRegisteredOrg[] = {
674 'R','e','g','i','s','t','e','r','e','d','O','r','g','a','n','i','z','a','t','i','o','n',0
676 static const WCHAR szUSERNAME[] = {'U','S','E','R','N','A','M','E',0};
677 static const WCHAR szCOMPANYNAME[] = {'C','O','M','P','A','N','Y','N','A','M','E',0};
678 static const WCHAR szDate[] = {'D','a','t','e',0};
679 static const WCHAR szTime[] = {'T','i','m','e',0};
680 static const WCHAR szUserLangID[] = {'U','s','e','r','L','a','n','g','u','a','g','e','I','D',0};
681 static const WCHAR szSystemLangID[] = {'S','y','s','t','e','m','L','a','n','g','u','a','g','e','I','D',0};
682 static const WCHAR szProductState[] = {'P','r','o','d','u','c','t','S','t','a','t','e',0};
683 static const WCHAR szLogonUser[] = {'L','o','g','o','n','U','s','e','r',0};
686 * Other things that probably should be set:
688 * ComputerName VirtualMemory
689 * ShellAdvSupport DefaultUIFont PackagecodeChanging
690 * CaptionHeight BorderTop BorderSide TextHeight
691 * RedirectedDllSupport
694 SHGetFolderPathW(NULL,CSIDL_PROGRAM_FILES_COMMON,NULL,0,pth);
695 strcatW(pth, szBackSlash);
696 msi_set_property(package->db, CFF, pth);
698 SHGetFolderPathW(NULL,CSIDL_PROGRAM_FILES,NULL,0,pth);
699 strcatW(pth, szBackSlash);
700 msi_set_property(package->db, PFF, pth);
702 SHGetFolderPathW(NULL,CSIDL_COMMON_APPDATA,NULL,0,pth);
703 strcatW(pth, szBackSlash);
704 msi_set_property(package->db, CADF, pth);
706 SHGetFolderPathW(NULL,CSIDL_FAVORITES,NULL,0,pth);
707 strcatW(pth, szBackSlash);
708 msi_set_property(package->db, FaF, pth);
710 SHGetFolderPathW(NULL,CSIDL_FONTS,NULL,0,pth);
711 strcatW(pth, szBackSlash);
712 msi_set_property(package->db, FoF, pth);
714 SHGetFolderPathW(NULL,CSIDL_SENDTO,NULL,0,pth);
715 strcatW(pth, szBackSlash);
716 msi_set_property(package->db, SendTF, pth);
718 SHGetFolderPathW(NULL,CSIDL_STARTMENU,NULL,0,pth);
719 strcatW(pth, szBackSlash);
720 msi_set_property(package->db, SMF, pth);
722 SHGetFolderPathW(NULL,CSIDL_STARTUP,NULL,0,pth);
723 strcatW(pth, szBackSlash);
724 msi_set_property(package->db, StF, pth);
726 SHGetFolderPathW(NULL,CSIDL_TEMPLATES,NULL,0,pth);
727 strcatW(pth, szBackSlash);
728 msi_set_property(package->db, TemplF, pth);
730 SHGetFolderPathW(NULL,CSIDL_DESKTOP,NULL,0,pth);
731 strcatW(pth, szBackSlash);
732 msi_set_property(package->db, DF, pth);
734 SHGetFolderPathW(NULL,CSIDL_PROGRAMS,NULL,0,pth);
735 strcatW(pth, szBackSlash);
736 msi_set_property(package->db, PMF, pth);
738 SHGetFolderPathW(NULL,CSIDL_ADMINTOOLS,NULL,0,pth);
739 strcatW(pth, szBackSlash);
740 msi_set_property(package->db, ATF, pth);
742 SHGetFolderPathW(NULL,CSIDL_APPDATA,NULL,0,pth);
743 strcatW(pth, szBackSlash);
744 msi_set_property(package->db, ADF, pth);
746 SHGetFolderPathW(NULL,CSIDL_SYSTEM,NULL,0,pth);
747 strcatW(pth, szBackSlash);
748 msi_set_property(package->db, SF, pth);
749 msi_set_property(package->db, SF16, pth);
751 SHGetFolderPathW(NULL,CSIDL_LOCAL_APPDATA,NULL,0,pth);
752 strcatW(pth, szBackSlash);
753 msi_set_property(package->db, LADF, pth);
755 SHGetFolderPathW(NULL,CSIDL_MYPICTURES,NULL,0,pth);
756 strcatW(pth, szBackSlash);
757 msi_set_property(package->db, MPF, pth);
759 SHGetFolderPathW(NULL,CSIDL_PERSONAL,NULL,0,pth);
760 strcatW(pth, szBackSlash);
761 msi_set_property(package->db, PF, pth);
763 SHGetFolderPathW(NULL,CSIDL_WINDOWS,NULL,0,pth);
764 strcatW(pth, szBackSlash);
765 msi_set_property(package->db, WF, pth);
767 /* Physical Memory is specified in MB. Using total amount. */
768 msex.dwLength = sizeof(msex);
769 GlobalMemoryStatusEx( &msex );
770 sprintfW( bufstr, szIntFormat, (int)(msex.ullTotalPhys/1024/1024));
771 msi_set_property(package->db, szPhysicalMemory, bufstr);
773 SHGetFolderPathW(NULL,CSIDL_WINDOWS,NULL,0,pth);
774 ptr = strchrW(pth,'\\');
777 msi_set_property(package->db, WV, pth);
779 GetTempPathW(MAX_PATH,pth);
780 msi_set_property(package->db, TF, pth);
783 /* in a wine environment the user is always admin and privileged */
784 msi_set_property(package->db, szAdminUser, szOne);
785 msi_set_property(package->db, szPriv, szOne);
787 /* set the os things */
788 OSVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
789 GetVersionExW((OSVERSIONINFOW *)&OSVersion);
790 verval = OSVersion.dwMinorVersion+OSVersion.dwMajorVersion*100;
791 sprintfW(verstr,szFormat,verval);
792 switch (OSVersion.dwPlatformId)
794 case VER_PLATFORM_WIN32_WINDOWS:
795 msi_set_property(package->db, v9x, verstr);
797 case VER_PLATFORM_WIN32_NT:
798 msi_set_property(package->db, vNT, verstr);
799 sprintfW(verstr,szFormat,OSVersion.wProductType);
800 msi_set_property(package->db, szMsiNTProductType, verstr);
803 sprintfW(verstr,szFormat,OSVersion.dwBuildNumber);
804 msi_set_property(package->db, szWinBuild, verstr);
805 /* just fudge this */
806 msi_set_property(package->db, szSPL, szSix);
808 sprintfW( bufstr, szFormat2, MSI_MAJORVERSION, MSI_MINORVERSION);
809 msi_set_property( package->db, szVersionMsi, bufstr );
810 sprintfW( bufstr, szFormat, MSI_MAJORVERSION * 100);
811 msi_set_property( package->db, szVersionDatabase, bufstr );
813 GetSystemInfo( &sys_info );
814 if (sys_info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
816 sprintfW( bufstr, szIntFormat, sys_info.wProcessorLevel );
817 msi_set_property( package->db, szIntel, bufstr );
820 /* Screen properties. */
822 sprintfW( bufstr, szIntFormat, GetDeviceCaps( dc, HORZRES ) );
823 msi_set_property( package->db, szScreenX, bufstr );
824 sprintfW( bufstr, szIntFormat, GetDeviceCaps( dc, VERTRES ));
825 msi_set_property( package->db, szScreenY, bufstr );
826 sprintfW( bufstr, szIntFormat, GetDeviceCaps( dc, BITSPIXEL ));
827 msi_set_property( package->db, szColorBits, bufstr );
830 /* USERNAME and COMPANYNAME */
831 username = msi_dup_property( package->db, szUSERNAME );
832 companyname = msi_dup_property( package->db, szCOMPANYNAME );
834 if ((!username || !companyname) &&
835 RegOpenKeyW( HKEY_CURRENT_USER, szUserInfo, &hkey ) == ERROR_SUCCESS)
838 (username = msi_reg_get_val_str( hkey, szDefName )))
839 msi_set_property( package->db, szUSERNAME, username );
841 (companyname = msi_reg_get_val_str( hkey, szDefCompany )))
842 msi_set_property( package->db, szCOMPANYNAME, companyname );
845 if ((!username || !companyname) &&
846 RegOpenKeyW( HKEY_LOCAL_MACHINE, szCurrentVersion, &hkey ) == ERROR_SUCCESS)
849 (username = msi_reg_get_val_str( hkey, szRegisteredUser )))
850 msi_set_property( package->db, szUSERNAME, username );
852 (companyname = msi_reg_get_val_str( hkey, szRegisteredOrg )))
853 msi_set_property( package->db, szCOMPANYNAME, companyname );
856 msi_free( username );
857 msi_free( companyname );
859 if ( set_user_sid_prop( package ) != ERROR_SUCCESS)
860 ERR("Failed to set the UserSID property\n");
862 /* Date and time properties */
863 GetSystemTime( &systemtime );
864 if (GetDateFormatW( LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systemtime,
865 NULL, bufstr, sizeof(bufstr)/sizeof(bufstr[0]) ))
866 msi_set_property( package->db, szDate, bufstr );
868 ERR("Couldn't set Date property: GetDateFormat failed with error %d\n", GetLastError());
870 if (GetTimeFormatW( LOCALE_USER_DEFAULT,
871 TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER,
872 &systemtime, NULL, bufstr,
873 sizeof(bufstr)/sizeof(bufstr[0]) ))
874 msi_set_property( package->db, szTime, bufstr );
876 ERR("Couldn't set Time property: GetTimeFormat failed with error %d\n", GetLastError());
878 set_msi_assembly_prop( package );
880 langid = GetUserDefaultLangID();
881 sprintfW(bufstr, szIntFormat, langid);
882 msi_set_property( package->db, szUserLangID, bufstr );
884 langid = GetSystemDefaultLangID();
885 sprintfW(bufstr, szIntFormat, langid);
886 msi_set_property( package->db, szSystemLangID, bufstr );
888 sprintfW(bufstr, szIntFormat, MsiQueryProductStateW(package->ProductCode));
889 msi_set_property( package->db, szProductState, bufstr );
892 if (!GetUserNameW( NULL, &len ) && GetLastError() == ERROR_MORE_DATA)
895 if ((username = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
897 if (GetUserNameW( username, &len ))
898 msi_set_property( package->db, szLogonUser, username );
899 HeapFree( GetProcessHeap(), 0, username );
904 static UINT msi_load_summary_properties( MSIPACKAGE *package )
908 MSIHANDLE hdb = alloc_msihandle( &package->db->hdr );
912 static const WCHAR szPackageCode[] = {
913 'P','a','c','k','a','g','e','C','o','d','e',0};
916 ERR("Unable to allocate handle\n");
917 return ERROR_OUTOFMEMORY;
920 rc = MsiGetSummaryInformationW( hdb, NULL, 0, &suminfo );
922 if (rc != ERROR_SUCCESS)
924 ERR("Unable to open Summary Information\n");
928 rc = MsiSummaryInfoGetPropertyW( suminfo, PID_PAGECOUNT, NULL,
929 &count, NULL, NULL, NULL );
930 if (rc != ERROR_SUCCESS)
932 WARN("Unable to query page count: %d\n", rc);
936 /* load package code property */
938 rc = MsiSummaryInfoGetPropertyW( suminfo, PID_REVNUMBER, NULL,
939 NULL, NULL, NULL, &len );
940 if (rc != ERROR_MORE_DATA)
942 WARN("Unable to query revision number: %d\n", rc);
943 rc = ERROR_FUNCTION_FAILED;
948 package_code = msi_alloc( len * sizeof(WCHAR) );
949 rc = MsiSummaryInfoGetPropertyW( suminfo, PID_REVNUMBER, NULL,
950 NULL, NULL, package_code, &len );
951 if (rc != ERROR_SUCCESS)
953 WARN("Unable to query rev number: %d\n", rc);
957 msi_set_property( package->db, szPackageCode, package_code );
958 msi_free( package_code );
960 /* load package attributes */
962 MsiSummaryInfoGetPropertyW( suminfo, PID_WORDCOUNT, NULL,
963 &count, NULL, NULL, NULL );
964 package->WordCount = count;
967 MsiCloseHandle(suminfo);
971 static MSIPACKAGE *msi_alloc_package( void )
975 package = alloc_msiobject( MSIHANDLETYPE_PACKAGE, sizeof (MSIPACKAGE),
979 list_init( &package->components );
980 list_init( &package->features );
981 list_init( &package->files );
982 list_init( &package->tempfiles );
983 list_init( &package->folders );
984 list_init( &package->subscriptions );
985 list_init( &package->appids );
986 list_init( &package->classes );
987 list_init( &package->mimes );
988 list_init( &package->extensions );
989 list_init( &package->progids );
990 list_init( &package->RunningActions );
991 list_init( &package->sourcelist_info );
992 list_init( &package->sourcelist_media );
993 list_init( &package->patches );
999 static UINT msi_load_admin_properties(MSIPACKAGE *package)
1004 static const WCHAR stmname[] = {'A','d','m','i','n','P','r','o','p','e','r','t','i','e','s',0};
1006 r = read_stream_data(package->db->storage, stmname, FALSE, &data, &sz);
1007 if (r != ERROR_SUCCESS)
1010 r = msi_parse_command_line(package, (WCHAR *)data, TRUE);
1016 static void adjust_allusers_property( MSIPACKAGE *package )
1018 /* FIXME: this should depend on the user's privileges */
1019 if (msi_get_property_int( package->db, szAllUsers, 0 ) == 2)
1021 TRACE("resetting ALLUSERS property from 2 to 1\n");
1022 msi_set_property( package->db, szAllUsers, szOne );
1026 MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
1028 static const WCHAR szLevel[] = { 'U','I','L','e','v','e','l',0 };
1029 static const WCHAR szpi[] = {'%','i',0};
1030 MSIPACKAGE *package;
1036 package = msi_alloc_package();
1039 msiobj_addref( &db->hdr );
1042 package->WordCount = 0;
1043 package->PackagePath = strdupW( db->path );
1044 package->BaseURL = strdupW( base_url );
1046 create_temp_property_table( package );
1047 msi_clone_properties( package );
1049 package->ProductCode = msi_dup_property( package->db, szProductCode );
1050 set_installed_prop( package );
1051 set_installer_properties( package );
1053 sprintfW(uilevel,szpi,gUILevel);
1054 msi_set_property(package->db, szLevel, uilevel);
1056 r = msi_load_summary_properties( package );
1057 if (r != ERROR_SUCCESS)
1059 msiobj_release( &package->hdr );
1063 if (package->WordCount & msidbSumInfoSourceTypeAdminImage)
1064 msi_load_admin_properties( package );
1066 adjust_allusers_property( package );
1073 * copy_package_to_temp [internal]
1075 * copy the msi file to a temp file to prevent locking a CD
1076 * with a multi disc install
1078 * FIXME: I think this is wrong, and instead of copying the package,
1079 * we should read all the tables to memory, then open the
1080 * database to read binary streams on demand.
1082 static UINT copy_package_to_temp( LPCWSTR szPackage, LPWSTR filename )
1084 WCHAR path[MAX_PATH];
1086 GetTempPathW( MAX_PATH, path );
1087 GetTempFileNameW( path, szMsi, 0, filename );
1089 if( !CopyFileW( szPackage, filename, FALSE ) )
1091 UINT error = GetLastError();
1092 ERR("failed to copy package %s to %s (%u)\n", debugstr_w(szPackage), debugstr_w(filename), error);
1093 DeleteFileW( filename );
1097 return ERROR_SUCCESS;
1100 UINT msi_download_file( LPCWSTR szUrl, LPWSTR filename )
1102 LPINTERNET_CACHE_ENTRY_INFOW cache_entry;
1106 /* call will always fail, becase size is 0,
1107 * but will return ERROR_FILE_NOT_FOUND first
1108 * if the file doesn't exist
1110 GetUrlCacheEntryInfoW( szUrl, NULL, &size );
1111 if ( GetLastError() != ERROR_FILE_NOT_FOUND )
1113 cache_entry = HeapAlloc( GetProcessHeap(), 0, size );
1114 if ( !GetUrlCacheEntryInfoW( szUrl, cache_entry, &size ) )
1116 UINT error = GetLastError();
1117 HeapFree( GetProcessHeap(), 0, cache_entry );
1121 lstrcpyW( filename, cache_entry->lpszLocalFileName );
1122 HeapFree( GetProcessHeap(), 0, cache_entry );
1123 return ERROR_SUCCESS;
1126 hr = URLDownloadToCacheFileW( NULL, szUrl, filename, MAX_PATH, 0, NULL );
1129 WARN("failed to download %s to cache file\n", debugstr_w(szUrl));
1130 return ERROR_FUNCTION_FAILED;
1133 return ERROR_SUCCESS;
1136 static UINT msi_get_local_package_name( LPWSTR path )
1138 static const WCHAR szInstaller[] = {
1139 '\\','I','n','s','t','a','l','l','e','r','\\',0};
1140 static const WCHAR fmt[] = { '%','x','.','m','s','i',0};
1144 time = GetTickCount();
1145 GetWindowsDirectoryW( path, MAX_PATH );
1146 strcatW( path, szInstaller );
1147 CreateDirectoryW( path, NULL );
1149 len = strlenW(path);
1150 for (i = 0; i < 0x10000; i++)
1152 snprintfW( &path[len], MAX_PATH - len, fmt, (time + i)&0xffff );
1153 handle = CreateFileW( path, GENERIC_WRITE, 0, NULL,
1154 CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
1155 if (handle != INVALID_HANDLE_VALUE)
1157 CloseHandle(handle);
1160 if (GetLastError() != ERROR_FILE_EXISTS &&
1161 GetLastError() != ERROR_SHARING_VIOLATION)
1162 return ERROR_FUNCTION_FAILED;
1165 return ERROR_SUCCESS;
1168 UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
1170 static const WCHAR OriginalDatabase[] =
1171 {'O','r','i','g','i','n','a','l','D','a','t','a','b','a','s','e',0};
1172 static const WCHAR Database[] = {'D','A','T','A','B','A','S','E',0};
1173 MSIDATABASE *db = NULL;
1174 MSIPACKAGE *package;
1176 LPWSTR ptr, base_url = NULL;
1178 WCHAR temppath[MAX_PATH], localfile[MAX_PATH], cachefile[MAX_PATH];
1179 LPCWSTR file = szPackage;
1181 TRACE("%s %p\n", debugstr_w(szPackage), pPackage);
1183 if( szPackage[0] == '#' )
1185 handle = atoiW(&szPackage[1]);
1186 db = msihandle2msiinfo( handle, MSIHANDLETYPE_DATABASE );
1189 IWineMsiRemoteDatabase *remote_database;
1191 remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( handle );
1192 if ( !remote_database )
1193 return ERROR_INVALID_HANDLE;
1195 IWineMsiRemoteDatabase_Release( remote_database );
1196 WARN("MsiOpenPackage not allowed during a custom action!\n");
1198 return ERROR_FUNCTION_FAILED;
1203 if ( UrlIsW( szPackage, URLIS_URL ) )
1205 r = msi_download_file( szPackage, cachefile );
1206 if ( r != ERROR_SUCCESS )
1209 r = copy_package_to_temp( cachefile, temppath );
1210 if ( r != ERROR_SUCCESS )
1215 base_url = strdupW( szPackage );
1217 return ERROR_OUTOFMEMORY;
1219 ptr = strrchrW( base_url, '/' );
1220 if (ptr) *(ptr + 1) = '\0';
1224 r = copy_package_to_temp( szPackage, temppath );
1225 if ( r != ERROR_SUCCESS )
1231 r = msi_get_local_package_name( localfile );
1232 if (r != ERROR_SUCCESS)
1235 TRACE("Copying to local package %s\n", debugstr_w(localfile));
1237 if (!CopyFileW( file, localfile, FALSE ))
1239 ERR("Unable to copy package (%s -> %s) (error %u)\n",
1240 debugstr_w(file), debugstr_w(localfile), GetLastError());
1241 return GetLastError();
1244 TRACE("Opening relocated package %s\n", debugstr_w( file ));
1246 /* transforms that add binary streams require that we open the database
1247 * read/write, which is safe because we always create a copy that is thrown
1248 * away when we're done.
1250 r = MSI_OpenDatabaseW( file, MSIDBOPEN_DIRECT, &db );
1251 if( r != ERROR_SUCCESS )
1253 if (file != szPackage)
1254 DeleteFileW( file );
1256 if (GetFileAttributesW(szPackage) == INVALID_FILE_ATTRIBUTES)
1257 return ERROR_FILE_NOT_FOUND;
1262 db->localfile = strdupW( localfile );
1265 package = MSI_CreatePackage( db, base_url );
1266 msi_free( base_url );
1267 msiobj_release( &db->hdr );
1270 if (file != szPackage)
1271 DeleteFileW( file );
1273 return ERROR_INSTALL_PACKAGE_INVALID;
1276 if( file != szPackage )
1277 track_tempfile( package, file );
1279 msi_set_property( package->db, Database, db->path );
1281 if( UrlIsW( szPackage, URLIS_URL ) )
1282 msi_set_property( package->db, OriginalDatabase, szPackage );
1283 else if( szPackage[0] == '#' )
1284 msi_set_property( package->db, OriginalDatabase, db->path );
1287 WCHAR fullpath[MAX_PATH];
1289 GetFullPathNameW( szPackage, MAX_PATH, fullpath, NULL );
1290 msi_set_property( package->db, OriginalDatabase, fullpath );
1293 package->script = msi_alloc_zero( sizeof(MSISCRIPT) );
1294 *pPackage = package;
1296 return ERROR_SUCCESS;
1299 UINT WINAPI MsiOpenPackageExW(LPCWSTR szPackage, DWORD dwOptions, MSIHANDLE *phPackage)
1301 MSIPACKAGE *package = NULL;
1304 TRACE("%s %08x %p\n", debugstr_w(szPackage), dwOptions, phPackage );
1306 if( !szPackage || !phPackage )
1307 return ERROR_INVALID_PARAMETER;
1311 FIXME("Should create an empty database and package\n");
1312 return ERROR_FUNCTION_FAILED;
1316 FIXME("dwOptions %08x not supported\n", dwOptions);
1318 ret = MSI_OpenPackageW( szPackage, &package );
1319 if( ret == ERROR_SUCCESS )
1321 *phPackage = alloc_msihandle( &package->hdr );
1323 ret = ERROR_NOT_ENOUGH_MEMORY;
1324 msiobj_release( &package->hdr );
1330 UINT WINAPI MsiOpenPackageW(LPCWSTR szPackage, MSIHANDLE *phPackage)
1332 return MsiOpenPackageExW( szPackage, 0, phPackage );
1335 UINT WINAPI MsiOpenPackageExA(LPCSTR szPackage, DWORD dwOptions, MSIHANDLE *phPackage)
1337 LPWSTR szwPack = NULL;
1342 szwPack = strdupAtoW( szPackage );
1344 return ERROR_OUTOFMEMORY;
1347 ret = MsiOpenPackageExW( szwPack, dwOptions, phPackage );
1349 msi_free( szwPack );
1354 UINT WINAPI MsiOpenPackageA(LPCSTR szPackage, MSIHANDLE *phPackage)
1356 return MsiOpenPackageExA( szPackage, 0, phPackage );
1359 MSIHANDLE WINAPI MsiGetActiveDatabase(MSIHANDLE hInstall)
1361 MSIPACKAGE *package;
1362 MSIHANDLE handle = 0;
1363 IUnknown *remote_unk;
1364 IWineMsiRemotePackage *remote_package;
1366 TRACE("(%d)\n",hInstall);
1368 package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
1371 handle = alloc_msihandle( &package->db->hdr );
1372 msiobj_release( &package->hdr );
1374 else if ((remote_unk = msi_get_remote(hInstall)))
1376 if (IUnknown_QueryInterface(remote_unk, &IID_IWineMsiRemotePackage,
1377 (LPVOID *)&remote_package) == S_OK)
1379 IWineMsiRemotePackage_GetActiveDatabase(remote_package, &handle);
1380 IWineMsiRemotePackage_Release(remote_package);
1384 WARN("remote handle %d is not a package\n", hInstall);
1386 IUnknown_Release(remote_unk);
1392 INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
1395 static const WCHAR szActionData[] =
1396 {'A','c','t','i','o','n','D','a','t','a',0};
1397 static const WCHAR szSetProgress[] =
1398 {'S','e','t','P','r','o','g','r','e','s','s',0};
1399 static const WCHAR szActionText[] =
1400 {'A','c','t','i','o','n','T','e','x','t',0};
1404 DWORD total_size = 0;
1410 TRACE("%x\n", eMessageType);
1413 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ERROR)
1414 log_type |= INSTALLLOGMODE_ERROR;
1415 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_WARNING)
1416 log_type |= INSTALLLOGMODE_WARNING;
1417 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_USER)
1418 log_type |= INSTALLLOGMODE_USER;
1419 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_INFO)
1420 log_type |= INSTALLLOGMODE_INFO;
1421 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_COMMONDATA)
1422 log_type |= INSTALLLOGMODE_COMMONDATA;
1423 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ACTIONSTART)
1424 log_type |= INSTALLLOGMODE_ACTIONSTART;
1425 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ACTIONDATA)
1426 log_type |= INSTALLLOGMODE_ACTIONDATA;
1428 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_PROGRESS)
1431 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ACTIONSTART)
1433 static const WCHAR template_s[]=
1434 {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ',0};
1435 static const WCHAR format[] =
1436 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
1438 LPCWSTR action_text, action;
1439 LPWSTR deformatted = NULL;
1441 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
1443 action = MSI_RecordGetString(record, 1);
1444 action_text = MSI_RecordGetString(record, 2);
1446 if (!action || !action_text)
1449 deformat_string(package, action_text, &deformatted);
1451 len = strlenW(timet) + strlenW(action) + strlenW(template_s);
1453 len += strlenW(deformatted);
1454 message = msi_alloc(len*sizeof(WCHAR));
1455 sprintfW(message, template_s, timet, action);
1457 strcatW(message, deformatted);
1458 msi_free(deformatted);
1463 message = msi_alloc(1*sizeof (WCHAR));
1465 msg_field = MSI_RecordGetFieldCount(record);
1466 for (i = 1; i <= msg_field; i++)
1470 static const WCHAR format[] = { '%','i',':',' ',0};
1472 MSI_RecordGetStringW(record,i,NULL,&sz);
1474 total_size+=sz*sizeof(WCHAR);
1475 tmp = msi_alloc(sz*sizeof(WCHAR));
1476 message = msi_realloc(message,total_size*sizeof (WCHAR));
1478 MSI_RecordGetStringW(record,i,tmp,&sz);
1482 sprintfW(number,format,i);
1483 strcatW(message,number);
1485 strcatW(message,tmp);
1487 strcatW(message, szSpace);
1493 TRACE("%p %p %p %x %x %s\n", gUIHandlerA, gUIHandlerW, gUIHandlerRecord,
1494 gUIFilter, log_type, debugstr_w(message));
1496 /* convert it to ASCII */
1497 len = WideCharToMultiByte( CP_ACP, 0, message, -1, NULL, 0, NULL, NULL );
1498 msg = msi_alloc( len );
1499 WideCharToMultiByte( CP_ACP, 0, message, -1, msg, len, NULL, NULL );
1501 if (gUIHandlerW && (gUIFilter & log_type))
1503 rc = gUIHandlerW( gUIContext, eMessageType, message );
1505 else if (gUIHandlerA && (gUIFilter & log_type))
1507 rc = gUIHandlerA( gUIContext, eMessageType, msg );
1509 else if (gUIHandlerRecord && (gUIFilter & log_type))
1511 MSIHANDLE rec = MsiCreateRecord( 1 );
1512 MsiRecordSetStringW( rec, 0, message );
1513 rc = gUIHandlerRecord( gUIContext, eMessageType, rec );
1514 MsiCloseHandle( rec );
1517 if ((!rc) && (gszLogFile[0]) && !((eMessageType & 0xff000000) ==
1518 INSTALLMESSAGE_PROGRESS))
1521 HANDLE log_file = CreateFileW(gszLogFile,GENERIC_WRITE, 0, NULL,
1522 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
1524 if (log_file != INVALID_HANDLE_VALUE)
1526 SetFilePointer(log_file,0, NULL, FILE_END);
1527 WriteFile(log_file,msg,strlen(msg),&write,NULL);
1528 WriteFile(log_file,"\n",1,&write,NULL);
1529 CloseHandle(log_file);
1533 msi_free( message );
1535 switch (eMessageType & 0xff000000)
1537 case INSTALLMESSAGE_ACTIONDATA:
1538 /* FIXME: format record here instead of in ui_actiondata to get the
1539 * correct action data for external scripts */
1540 ControlEvent_FireSubscribedEvent(package, szActionData, record);
1542 case INSTALLMESSAGE_ACTIONSTART:
1546 LPCWSTR action_text = MSI_RecordGetString(record, 2);
1548 deformat_string(package, action_text, &deformated);
1549 uirow = MSI_CreateRecord(1);
1550 MSI_RecordSetStringW(uirow, 1, deformated);
1551 TRACE("INSTALLMESSAGE_ACTIONSTART: %s\n", debugstr_w(deformated));
1552 msi_free(deformated);
1554 ControlEvent_FireSubscribedEvent(package, szActionText, uirow);
1556 msiobj_release(&uirow->hdr);
1559 case INSTALLMESSAGE_PROGRESS:
1560 ControlEvent_FireSubscribedEvent(package, szSetProgress, record);
1564 return ERROR_SUCCESS;
1567 INT WINAPI MsiProcessMessage( MSIHANDLE hInstall, INSTALLMESSAGE eMessageType,
1570 UINT ret = ERROR_INVALID_HANDLE;
1571 MSIPACKAGE *package = NULL;
1572 MSIRECORD *record = NULL;
1574 package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
1578 IWineMsiRemotePackage *remote_package;
1580 remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
1581 if (!remote_package)
1582 return ERROR_INVALID_HANDLE;
1584 hr = IWineMsiRemotePackage_ProcessMessage( remote_package, eMessageType, hRecord );
1586 IWineMsiRemotePackage_Release( remote_package );
1590 if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
1591 return HRESULT_CODE(hr);
1593 return ERROR_FUNCTION_FAILED;
1596 return ERROR_SUCCESS;
1599 record = msihandle2msiinfo( hRecord, MSIHANDLETYPE_RECORD );
1603 ret = MSI_ProcessMessage( package, eMessageType, record );
1606 msiobj_release( &package->hdr );
1608 msiobj_release( &record->hdr );
1615 UINT WINAPI MsiSetPropertyA( MSIHANDLE hInstall, LPCSTR szName, LPCSTR szValue )
1617 LPWSTR szwName = NULL, szwValue = NULL;
1618 UINT r = ERROR_OUTOFMEMORY;
1620 szwName = strdupAtoW( szName );
1621 if( szName && !szwName )
1624 szwValue = strdupAtoW( szValue );
1625 if( szValue && !szwValue )
1628 r = MsiSetPropertyW( hInstall, szwName, szwValue);
1631 msi_free( szwName );
1632 msi_free( szwValue );
1637 void msi_reset_folders( MSIPACKAGE *package, BOOL source )
1641 LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry )
1645 msi_free( folder->ResolvedSource );
1646 folder->ResolvedSource = NULL;
1650 msi_free( folder->ResolvedTarget );
1651 folder->ResolvedTarget = NULL;
1656 UINT msi_set_property( MSIDATABASE *db, LPCWSTR szName, LPCWSTR szValue )
1659 MSIRECORD *row = NULL;
1664 static const WCHAR Insert[] = {
1665 'I','N','S','E','R','T',' ','i','n','t','o',' ',
1666 '`','_','P','r','o','p','e','r','t','y','`',' ','(',
1667 '`','_','P','r','o','p','e','r','t','y','`',',',
1668 '`','V','a','l','u','e','`',')',' ','V','A','L','U','E','S'
1669 ,' ','(','?',',','?',')',0};
1670 static const WCHAR Update[] = {
1671 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',
1672 ' ','s','e','t',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ',
1673 'w','h','e','r','e',' ','`','_','P','r','o','p','e','r','t','y','`',
1674 ' ','=',' ','\'','%','s','\'',0};
1675 static const WCHAR Delete[] = {
1676 'D','E','L','E','T','E',' ','F','R','O','M',' ',
1677 '`','_','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
1678 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
1680 TRACE("%p %s %s\n", db, debugstr_w(szName), debugstr_w(szValue));
1683 return ERROR_INVALID_PARAMETER;
1685 /* this one is weird... */
1687 return szValue ? ERROR_FUNCTION_FAILED : ERROR_SUCCESS;
1689 rc = msi_get_property(db, szName, 0, &sz);
1690 if (!szValue || !*szValue)
1692 sprintfW(Query, Delete, szName);
1694 else if (rc == ERROR_MORE_DATA || rc == ERROR_SUCCESS)
1696 sprintfW(Query, Update, szName);
1698 row = MSI_CreateRecord(1);
1699 MSI_RecordSetStringW(row, 1, szValue);
1703 strcpyW(Query, Insert);
1705 row = MSI_CreateRecord(2);
1706 MSI_RecordSetStringW(row, 1, szName);
1707 MSI_RecordSetStringW(row, 2, szValue);
1710 rc = MSI_DatabaseOpenViewW(db, Query, &view);
1711 if (rc == ERROR_SUCCESS)
1713 rc = MSI_ViewExecute(view, row);
1714 MSI_ViewClose(view);
1715 msiobj_release(&view->hdr);
1719 msiobj_release(&row->hdr);
1724 UINT WINAPI MsiSetPropertyW( MSIHANDLE hInstall, LPCWSTR szName, LPCWSTR szValue)
1726 MSIPACKAGE *package;
1729 package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
1733 BSTR name = NULL, value = NULL;
1734 IWineMsiRemotePackage *remote_package;
1736 remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
1737 if (!remote_package)
1738 return ERROR_INVALID_HANDLE;
1740 name = SysAllocString( szName );
1741 value = SysAllocString( szValue );
1742 if ((!name && szName) || (!value && szValue))
1744 SysFreeString( name );
1745 SysFreeString( value );
1746 IWineMsiRemotePackage_Release( remote_package );
1747 return ERROR_OUTOFMEMORY;
1750 hr = IWineMsiRemotePackage_SetProperty( remote_package, name, value );
1752 SysFreeString( name );
1753 SysFreeString( value );
1754 IWineMsiRemotePackage_Release( remote_package );
1758 if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
1759 return HRESULT_CODE(hr);
1761 return ERROR_FUNCTION_FAILED;
1764 return ERROR_SUCCESS;
1767 ret = msi_set_property( package->db, szName, szValue );
1768 if (ret == ERROR_SUCCESS && !strcmpW( szName, cszSourceDir ))
1769 msi_reset_folders( package, TRUE );
1771 msiobj_release( &package->hdr );
1775 static MSIRECORD *msi_get_property_row( MSIDATABASE *db, LPCWSTR name )
1778 MSIRECORD *rec, *row = NULL;
1781 static const WCHAR query[]= {
1782 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
1783 'F','R','O','M',' ' ,'`','_','P','r','o','p','e','r','t','y','`',
1784 ' ','W','H','E','R','E',' ' ,'`','_','P','r','o','p','e','r','t','y','`',
1787 if (!name || !*name)
1790 rec = MSI_CreateRecord(1);
1794 MSI_RecordSetStringW(rec, 1, name);
1796 r = MSI_DatabaseOpenViewW(db, query, &view);
1797 if (r == ERROR_SUCCESS)
1799 MSI_ViewExecute(view, rec);
1800 MSI_ViewFetch(view, &row);
1801 MSI_ViewClose(view);
1802 msiobj_release(&view->hdr);
1805 msiobj_release(&rec->hdr);
1809 /* internal function, not compatible with MsiGetPropertyW */
1810 UINT msi_get_property( MSIDATABASE *db, LPCWSTR szName,
1811 LPWSTR szValueBuf, LPDWORD pchValueBuf )
1814 UINT rc = ERROR_FUNCTION_FAILED;
1816 row = msi_get_property_row( db, szName );
1818 if (*pchValueBuf > 0)
1823 rc = MSI_RecordGetStringW(row, 1, szValueBuf, pchValueBuf);
1824 msiobj_release(&row->hdr);
1827 if (rc == ERROR_SUCCESS)
1828 TRACE("returning %s for property %s\n", debugstr_w(szValueBuf),
1829 debugstr_w(szName));
1830 else if (rc == ERROR_MORE_DATA)
1831 TRACE("need %d sized buffer for %s\n", *pchValueBuf,
1832 debugstr_w(szName));
1836 TRACE("property %s not found\n", debugstr_w(szName));
1842 LPWSTR msi_dup_property(MSIDATABASE *db, LPCWSTR prop)
1848 r = msi_get_property(db, prop, NULL, &sz);
1849 if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA)
1853 str = msi_alloc(sz * sizeof(WCHAR));
1854 r = msi_get_property(db, prop, str, &sz);
1855 if (r != ERROR_SUCCESS)
1864 int msi_get_property_int( MSIDATABASE *db, LPCWSTR prop, int def )
1866 LPWSTR str = msi_dup_property( db, prop );
1867 int val = str ? atoiW(str) : def;
1872 static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
1873 awstring *szValueBuf, LPDWORD pchValueBuf )
1875 MSIPACKAGE *package;
1876 MSIRECORD *row = NULL;
1877 UINT r = ERROR_FUNCTION_FAILED;
1880 TRACE("%u %s %p %p\n", handle, debugstr_w(name),
1881 szValueBuf->str.w, pchValueBuf );
1884 return ERROR_INVALID_PARAMETER;
1886 package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE );
1890 IWineMsiRemotePackage *remote_package;
1891 LPWSTR value = NULL;
1895 remote_package = (IWineMsiRemotePackage *)msi_get_remote( handle );
1896 if (!remote_package)
1897 return ERROR_INVALID_HANDLE;
1899 bname = SysAllocString( name );
1902 IWineMsiRemotePackage_Release( remote_package );
1903 return ERROR_OUTOFMEMORY;
1907 hr = IWineMsiRemotePackage_GetProperty( remote_package, bname, NULL, &len );
1912 value = msi_alloc(len * sizeof(WCHAR));
1915 r = ERROR_OUTOFMEMORY;
1919 hr = IWineMsiRemotePackage_GetProperty( remote_package, bname, (BSTR *)value, &len );
1923 r = msi_strcpy_to_awstring( value, szValueBuf, pchValueBuf );
1925 /* Bug required by Adobe installers */
1926 if (!szValueBuf->unicode && !szValueBuf->str.a)
1927 *pchValueBuf *= sizeof(WCHAR);
1930 IWineMsiRemotePackage_Release(remote_package);
1931 SysFreeString(bname);
1936 if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
1937 return HRESULT_CODE(hr);
1939 return ERROR_FUNCTION_FAILED;
1945 row = msi_get_property_row( package->db, name );
1947 val = MSI_RecordGetString( row, 1 );
1952 r = msi_strcpy_to_awstring( val, szValueBuf, pchValueBuf );
1955 msiobj_release( &row->hdr );
1956 msiobj_release( &package->hdr );
1961 UINT WINAPI MsiGetPropertyA( MSIHANDLE hInstall, LPCSTR szName,
1962 LPSTR szValueBuf, LPDWORD pchValueBuf )
1968 val.unicode = FALSE;
1969 val.str.a = szValueBuf;
1971 name = strdupAtoW( szName );
1972 if (szName && !name)
1973 return ERROR_OUTOFMEMORY;
1975 r = MSI_GetProperty( hInstall, name, &val, pchValueBuf );
1980 UINT WINAPI MsiGetPropertyW( MSIHANDLE hInstall, LPCWSTR szName,
1981 LPWSTR szValueBuf, LPDWORD pchValueBuf )
1986 val.str.w = szValueBuf;
1988 return MSI_GetProperty( hInstall, szName, &val, pchValueBuf );
1991 typedef struct _msi_remote_package_impl {
1992 const IWineMsiRemotePackageVtbl *lpVtbl;
1995 } msi_remote_package_impl;
1997 static inline msi_remote_package_impl* mrp_from_IWineMsiRemotePackage( IWineMsiRemotePackage* iface )
1999 return (msi_remote_package_impl*) iface;
2002 static HRESULT WINAPI mrp_QueryInterface( IWineMsiRemotePackage *iface,
2003 REFIID riid,LPVOID *ppobj)
2005 if( IsEqualCLSID( riid, &IID_IUnknown ) ||
2006 IsEqualCLSID( riid, &IID_IWineMsiRemotePackage ) )
2008 IUnknown_AddRef( iface );
2013 return E_NOINTERFACE;
2016 static ULONG WINAPI mrp_AddRef( IWineMsiRemotePackage *iface )
2018 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2020 return InterlockedIncrement( &This->refs );
2023 static ULONG WINAPI mrp_Release( IWineMsiRemotePackage *iface )
2025 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2028 r = InterlockedDecrement( &This->refs );
2031 MsiCloseHandle( This->package );
2037 static HRESULT WINAPI mrp_SetMsiHandle( IWineMsiRemotePackage *iface, MSIHANDLE handle )
2039 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2040 This->package = handle;
2044 static HRESULT WINAPI mrp_GetActiveDatabase( IWineMsiRemotePackage *iface, MSIHANDLE *handle )
2046 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2047 IWineMsiRemoteDatabase *rdb = NULL;
2051 hr = create_msi_remote_database( NULL, (LPVOID *)&rdb );
2052 if (FAILED(hr) || !rdb)
2054 ERR("Failed to create remote database\n");
2058 hdb = MsiGetActiveDatabase(This->package);
2060 hr = IWineMsiRemoteDatabase_SetMsiHandle( rdb, hdb );
2063 ERR("Failed to set the database handle\n");
2067 *handle = alloc_msi_remote_handle( (IUnknown *)rdb );
2071 static HRESULT WINAPI mrp_GetProperty( IWineMsiRemotePackage *iface, BSTR property, BSTR *value, DWORD *size )
2073 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2076 r = MsiGetPropertyW(This->package, (LPWSTR)property, (LPWSTR)value, size);
2077 if (r != ERROR_SUCCESS)
2078 return HRESULT_FROM_WIN32(r);
2083 static HRESULT WINAPI mrp_SetProperty( IWineMsiRemotePackage *iface, BSTR property, BSTR value )
2085 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2086 UINT r = MsiSetPropertyW(This->package, property, value);
2087 return HRESULT_FROM_WIN32(r);
2090 static HRESULT WINAPI mrp_ProcessMessage( IWineMsiRemotePackage *iface, INSTALLMESSAGE message, MSIHANDLE record )
2092 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2093 UINT r = MsiProcessMessage(This->package, message, record);
2094 return HRESULT_FROM_WIN32(r);
2097 static HRESULT WINAPI mrp_DoAction( IWineMsiRemotePackage *iface, BSTR action )
2099 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2100 UINT r = MsiDoActionW(This->package, action);
2101 return HRESULT_FROM_WIN32(r);
2104 static HRESULT WINAPI mrp_Sequence( IWineMsiRemotePackage *iface, BSTR table, int sequence )
2106 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2107 UINT r = MsiSequenceW(This->package, table, sequence);
2108 return HRESULT_FROM_WIN32(r);
2111 static HRESULT WINAPI mrp_GetTargetPath( IWineMsiRemotePackage *iface, BSTR folder, BSTR *value, DWORD *size )
2113 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2114 UINT r = MsiGetTargetPathW(This->package, (LPWSTR)folder, (LPWSTR)value, size);
2115 return HRESULT_FROM_WIN32(r);
2118 static HRESULT WINAPI mrp_SetTargetPath( IWineMsiRemotePackage *iface, BSTR folder, BSTR value)
2120 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2121 UINT r = MsiSetTargetPathW(This->package, folder, value);
2122 return HRESULT_FROM_WIN32(r);
2125 static HRESULT WINAPI mrp_GetSourcePath( IWineMsiRemotePackage *iface, BSTR folder, BSTR *value, DWORD *size )
2127 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2128 UINT r = MsiGetSourcePathW(This->package, (LPWSTR)folder, (LPWSTR)value, size);
2129 return HRESULT_FROM_WIN32(r);
2132 static HRESULT WINAPI mrp_GetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode, BOOL *ret )
2134 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2135 *ret = MsiGetMode(This->package, mode);
2139 static HRESULT WINAPI mrp_SetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode, BOOL state )
2141 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2142 UINT r = MsiSetMode(This->package, mode, state);
2143 return HRESULT_FROM_WIN32(r);
2146 static HRESULT WINAPI mrp_GetFeatureState( IWineMsiRemotePackage *iface, BSTR feature,
2147 INSTALLSTATE *installed, INSTALLSTATE *action )
2149 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2150 UINT r = MsiGetFeatureStateW(This->package, feature, installed, action);
2151 return HRESULT_FROM_WIN32(r);
2154 static HRESULT WINAPI mrp_SetFeatureState( IWineMsiRemotePackage *iface, BSTR feature, INSTALLSTATE state )
2156 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2157 UINT r = MsiSetFeatureStateW(This->package, feature, state);
2158 return HRESULT_FROM_WIN32(r);
2161 static HRESULT WINAPI mrp_GetComponentState( IWineMsiRemotePackage *iface, BSTR component,
2162 INSTALLSTATE *installed, INSTALLSTATE *action )
2164 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2165 UINT r = MsiGetComponentStateW(This->package, component, installed, action);
2166 return HRESULT_FROM_WIN32(r);
2169 static HRESULT WINAPI mrp_SetComponentState( IWineMsiRemotePackage *iface, BSTR component, INSTALLSTATE state )
2171 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2172 UINT r = MsiSetComponentStateW(This->package, component, state);
2173 return HRESULT_FROM_WIN32(r);
2176 static HRESULT WINAPI mrp_GetLanguage( IWineMsiRemotePackage *iface, LANGID *language )
2178 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2179 *language = MsiGetLanguage(This->package);
2183 static HRESULT WINAPI mrp_SetInstallLevel( IWineMsiRemotePackage *iface, int level )
2185 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2186 UINT r = MsiSetInstallLevel(This->package, level);
2187 return HRESULT_FROM_WIN32(r);
2190 static HRESULT WINAPI mrp_FormatRecord( IWineMsiRemotePackage *iface, MSIHANDLE record,
2194 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2195 UINT r = MsiFormatRecordW(This->package, record, NULL, &size);
2196 if (r == ERROR_SUCCESS)
2198 *value = SysAllocStringLen(NULL, size);
2200 return E_OUTOFMEMORY;
2202 r = MsiFormatRecordW(This->package, record, *value, &size);
2204 return HRESULT_FROM_WIN32(r);
2207 static HRESULT WINAPI mrp_EvaluateCondition( IWineMsiRemotePackage *iface, BSTR condition )
2209 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2210 UINT r = MsiEvaluateConditionW(This->package, condition);
2211 return HRESULT_FROM_WIN32(r);
2214 static HRESULT WINAPI mrp_GetFeatureCost( IWineMsiRemotePackage *iface, BSTR feature,
2215 INT cost_tree, INSTALLSTATE state, INT *cost )
2217 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2218 UINT r = MsiGetFeatureCostW(This->package, feature, cost_tree, state, cost);
2219 return HRESULT_FROM_WIN32(r);
2222 static const IWineMsiRemotePackageVtbl msi_remote_package_vtbl =
2228 mrp_GetActiveDatabase,
2239 mrp_GetFeatureState,
2240 mrp_SetFeatureState,
2241 mrp_GetComponentState,
2242 mrp_SetComponentState,
2244 mrp_SetInstallLevel,
2246 mrp_EvaluateCondition,
2250 HRESULT create_msi_remote_package( IUnknown *pOuter, LPVOID *ppObj )
2252 msi_remote_package_impl* This;
2254 This = msi_alloc( sizeof *This );
2256 return E_OUTOFMEMORY;
2258 This->lpVtbl = &msi_remote_package_vtbl;
2267 UINT msi_package_add_info(MSIPACKAGE *package, DWORD context, DWORD options,
2268 LPCWSTR property, LPWSTR value)
2270 MSISOURCELISTINFO *info;
2272 info = msi_alloc(sizeof(MSISOURCELISTINFO));
2274 return ERROR_OUTOFMEMORY;
2276 info->context = context;
2277 info->options = options;
2278 info->property = property;
2279 info->value = strdupW(value);
2280 list_add_head(&package->sourcelist_info, &info->entry);
2282 return ERROR_SUCCESS;
2285 UINT msi_package_add_media_disk(MSIPACKAGE *package, DWORD context, DWORD options,
2286 DWORD disk_id, LPWSTR volume_label, LPWSTR disk_prompt)
2290 disk = msi_alloc(sizeof(MSIMEDIADISK));
2292 return ERROR_OUTOFMEMORY;
2294 disk->context = context;
2295 disk->options = options;
2296 disk->disk_id = disk_id;
2297 disk->volume_label = strdupW(volume_label);
2298 disk->disk_prompt = strdupW(disk_prompt);
2299 list_add_head(&package->sourcelist_media, &disk->entry);
2301 return ERROR_SUCCESS;