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 );
274 msi_free( patch->localfile );
278 msi_free( package->BaseURL );
279 msi_free( package->PackagePath );
280 msi_free( package->ProductCode );
281 msi_free( package->ActionFormat );
282 msi_free( package->LastAction );
284 /* cleanup control event subscriptions */
285 ControlEvent_CleanupSubscriptions( package );
288 static void MSI_FreePackage( MSIOBJECTHDR *arg)
290 MSIPACKAGE *package= (MSIPACKAGE*) arg;
292 if( package->dialog )
293 msi_dialog_destroy( package->dialog );
295 msiobj_release( &package->db->hdr );
296 free_package_structures(package);
299 static UINT create_temp_property_table(MSIPACKAGE *package)
301 MSIQUERY *view = NULL;
304 static const WCHAR CreateSql[] = {
305 'C','R','E','A','T','E',' ','T','A','B','L','E',' ',
306 '`','_','P','r','o','p','e','r','t','y','`',' ','(',' ',
307 '`','_','P','r','o','p','e','r','t','y','`',' ',
308 'C','H','A','R','(','5','6',')',' ','N','O','T',' ','N','U','L','L',' ',
309 'T','E','M','P','O','R','A','R','Y',',',' ',
310 '`','V','a','l','u','e','`',' ','C','H','A','R','(','9','8',')',' ',
311 'N','O','T',' ','N','U','L','L',' ','T','E','M','P','O','R','A','R','Y',
312 ' ','P','R','I','M','A','R','Y',' ','K','E','Y',' ',
313 '`','_','P','r','o','p','e','r','t','y','`',')',' ','H','O','L','D',0};
315 rc = MSI_DatabaseOpenViewW(package->db, CreateSql, &view);
316 if (rc != ERROR_SUCCESS)
319 rc = MSI_ViewExecute(view, 0);
321 msiobj_release(&view->hdr);
325 UINT msi_clone_properties(MSIPACKAGE *package)
327 MSIQUERY *view = NULL;
330 static const WCHAR Query[] = {
331 'S','E','L','E','C','T',' ','*',' ',
332 'F','R','O','M',' ','`','P','r','o','p','e','r','t','y','`',0};
333 static const WCHAR Insert[] = {
334 'I','N','S','E','R','T',' ','i','n','t','o',' ',
335 '`','_','P','r','o','p','e','r','t','y','`',' ',
336 '(','`','_','P','r','o','p','e','r','t','y','`',',',
337 '`','V','a','l','u','e','`',')',' ',
338 'V','A','L','U','E','S',' ','(','?',',','?',')',0};
340 /* clone the existing properties */
341 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
342 if (rc != ERROR_SUCCESS)
345 rc = MSI_ViewExecute(view, 0);
346 if (rc != ERROR_SUCCESS)
349 msiobj_release(&view->hdr);
358 rc = MSI_ViewFetch(view, &row);
359 if (rc != ERROR_SUCCESS)
362 rc = MSI_DatabaseOpenViewW(package->db, Insert, &view2);
363 if (rc != ERROR_SUCCESS)
365 msiobj_release(&row->hdr);
369 MSI_ViewExecute(view2, row);
370 MSI_ViewClose(view2);
371 msiobj_release(&view2->hdr);
372 msiobj_release(&row->hdr);
376 msiobj_release(&view->hdr);
384 * Sets the "Installed" property to indicate that
385 * the product is installed for the current user.
387 static UINT set_installed_prop( MSIPACKAGE *package )
392 r = MSIREG_OpenUninstallKey( package->ProductCode, &hkey, FALSE );
393 if (r == ERROR_SUCCESS)
396 msi_set_property( package->db, szInstalled, szOne );
402 static UINT set_user_sid_prop( MSIPACKAGE *package )
406 LPWSTR sid_str = NULL, dom = NULL;
407 DWORD size, dom_size;
409 UINT r = ERROR_FUNCTION_FAILED;
412 GetUserNameW( NULL, &size );
414 user_name = msi_alloc( (size + 1) * sizeof(WCHAR) );
416 return ERROR_OUTOFMEMORY;
418 if (!GetUserNameW( user_name, &size ))
423 LookupAccountNameW( NULL, user_name, NULL, &size, NULL, &dom_size, &use );
425 psid = msi_alloc( size );
426 dom = msi_alloc( dom_size*sizeof (WCHAR) );
429 r = ERROR_OUTOFMEMORY;
433 if (!LookupAccountNameW( NULL, user_name, psid, &size, dom, &dom_size, &use ))
436 if (!ConvertSidToStringSidW( psid, &sid_str ))
439 r = msi_set_property( package->db, szUserSID, sid_str );
442 LocalFree( sid_str );
445 msi_free( user_name );
450 static LPWSTR get_fusion_filename(MSIPACKAGE *package)
455 DWORD index = 0, size;
457 WCHAR name[MAX_PATH];
458 WCHAR windir[MAX_PATH];
460 static const WCHAR fusion[] = {'f','u','s','i','o','n','.','d','l','l',0};
461 static const WCHAR sub[] = {
462 'S','o','f','t','w','a','r','e','\\',
463 'M','i','c','r','o','s','o','f','t','\\',
464 'N','E','T',' ','F','r','a','m','e','w','o','r','k',' ','S','e','t','u','p','\\',
467 static const WCHAR subdir[] = {
468 'M','i','c','r','o','s','o','f','t','.','N','E','T','\\',
469 'F','r','a','m','e','w','o','r','k','\\',0
472 res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, sub, 0, KEY_ENUMERATE_SUB_KEYS, &netsetup);
473 if (res != ERROR_SUCCESS)
476 GetWindowsDirectoryW(windir, MAX_PATH);
480 while (RegEnumKeyExW(netsetup, index, name, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
484 /* verify existence of fusion.dll .Net 3.0 does not install a new one */
485 if (lstrcmpW(ver, name) < 0)
488 size = lstrlenW(windir) + lstrlenW(subdir) + lstrlenW(name) +lstrlenW(fusion) + 3;
489 check = msi_alloc(size * sizeof(WCHAR));
497 lstrcpyW(check, windir);
498 lstrcatW(check, szBackSlash);
499 lstrcatW(check, subdir);
500 lstrcatW(check, name);
501 lstrcatW(check, szBackSlash);
502 lstrcatW(check, fusion);
504 if(GetFileAttributesW(check) != INVALID_FILE_ATTRIBUTES)
515 RegCloseKey(netsetup);
519 typedef struct tagLANGANDCODEPAGE
525 static void set_msi_assembly_prop(MSIPACKAGE *package)
529 LPVOID version = NULL;
531 LPWSTR fusion, verstr;
532 LANGANDCODEPAGE *translate;
534 static const WCHAR netasm[] = {
535 'M','s','i','N','e','t','A','s','s','e','m','b','l','y','S','u','p','p','o','r','t',0
537 static const WCHAR translation[] = {
538 '\\','V','a','r','F','i','l','e','I','n','f','o',
539 '\\','T','r','a','n','s','l','a','t','i','o','n',0
541 static const WCHAR verfmt[] = {
542 '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
543 '\\','%','0','4','x','%','0','4','x',
544 '\\','P','r','o','d','u','c','t','V','e','r','s','i','o','n',0
547 fusion = get_fusion_filename(package);
551 size = GetFileVersionInfoSizeW(fusion, &handle);
554 version = msi_alloc(size);
555 if (!version) return;
557 if (!GetFileVersionInfoW(fusion, handle, size, version))
560 if (!VerQueryValueW(version, translation, (LPVOID *)&translate, &val_len))
563 sprintfW(buf, verfmt, translate[0].wLanguage, translate[0].wCodePage);
565 if (!VerQueryValueW(version, buf, (LPVOID *)&verstr, &val_len))
568 if (!val_len || !verstr)
571 msi_set_property(package->db, netasm, verstr);
578 static VOID set_installer_properties(MSIPACKAGE *package)
582 OSVERSIONINFOEXW OSVersion;
585 WCHAR verstr[10], bufstr[20];
588 LPWSTR username, companyname;
589 SYSTEM_INFO sys_info;
590 SYSTEMTIME systemtime;
593 static const WCHAR CFF[] =
594 {'C','o','m','m','o','n','F','i','l','e','s','F','o','l','d','e','r',0};
595 static const WCHAR PFF[] =
596 {'P','r','o','g','r','a','m','F','i','l','e','s','F','o','l','d','e','r',0};
597 static const WCHAR CADF[] =
598 {'C','o','m','m','o','n','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
599 static const WCHAR FaF[] =
600 {'F','a','v','o','r','i','t','e','s','F','o','l','d','e','r',0};
601 static const WCHAR FoF[] =
602 {'F','o','n','t','s','F','o','l','d','e','r',0};
603 static const WCHAR SendTF[] =
604 {'S','e','n','d','T','o','F','o','l','d','e','r',0};
605 static const WCHAR SMF[] =
606 {'S','t','a','r','t','M','e','n','u','F','o','l','d','e','r',0};
607 static const WCHAR StF[] =
608 {'S','t','a','r','t','u','p','F','o','l','d','e','r',0};
609 static const WCHAR TemplF[] =
610 {'T','e','m','p','l','a','t','e','F','o','l','d','e','r',0};
611 static const WCHAR DF[] =
612 {'D','e','s','k','t','o','p','F','o','l','d','e','r',0};
613 static const WCHAR PMF[] =
614 {'P','r','o','g','r','a','m','M','e','n','u','F','o','l','d','e','r',0};
615 static const WCHAR ATF[] =
616 {'A','d','m','i','n','T','o','o','l','s','F','o','l','d','e','r',0};
617 static const WCHAR ADF[] =
618 {'A','p','p','D','a','t','a','F','o','l','d','e','r',0};
619 static const WCHAR SF[] =
620 {'S','y','s','t','e','m','F','o','l','d','e','r',0};
621 static const WCHAR SF16[] =
622 {'S','y','s','t','e','m','1','6','F','o','l','d','e','r',0};
623 static const WCHAR LADF[] =
624 {'L','o','c','a','l','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
625 static const WCHAR MPF[] =
626 {'M','y','P','i','c','t','u','r','e','s','F','o','l','d','e','r',0};
627 static const WCHAR PF[] =
628 {'P','e','r','s','o','n','a','l','F','o','l','d','e','r',0};
629 static const WCHAR WF[] =
630 {'W','i','n','d','o','w','s','F','o','l','d','e','r',0};
631 static const WCHAR WV[] =
632 {'W','i','n','d','o','w','s','V','o','l','u','m','e',0};
633 static const WCHAR TF[]=
634 {'T','e','m','p','F','o','l','d','e','r',0};
635 static const WCHAR szAdminUser[] =
636 {'A','d','m','i','n','U','s','e','r',0};
637 static const WCHAR szPriv[] =
638 {'P','r','i','v','i','l','e','g','e','d',0};
639 static const WCHAR v9x[] = { 'V','e','r','s','i','o','n','9','X',0 };
640 static const WCHAR vNT[] = { 'V','e','r','s','i','o','n','N','T',0 };
641 static const WCHAR szMsiNTProductType[] = { 'M','s','i','N','T','P','r','o','d','u','c','t','T','y','p','e',0 };
642 static const WCHAR szFormat[] = {'%','l','i',0};
643 static const WCHAR szWinBuild[] =
644 {'W','i','n','d','o','w','s','B','u','i','l','d', 0 };
645 static const WCHAR szSPL[] =
646 {'S','e','r','v','i','c','e','P','a','c','k','L','e','v','e','l',0 };
647 static const WCHAR szSix[] = {'6',0 };
649 static const WCHAR szVersionMsi[] = { 'V','e','r','s','i','o','n','M','s','i',0 };
650 static const WCHAR szVersionDatabase[] = { 'V','e','r','s','i','o','n','D','a','t','a','b','a','s','e',0 };
651 static const WCHAR szPhysicalMemory[] = { 'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0 };
652 static const WCHAR szFormat2[] = {'%','l','i','.','%','l','i',0};
653 /* Screen properties */
654 static const WCHAR szScreenX[] = {'S','c','r','e','e','n','X',0};
655 static const WCHAR szScreenY[] = {'S','c','r','e','e','n','Y',0};
656 static const WCHAR szColorBits[] = {'C','o','l','o','r','B','i','t','s',0};
657 static const WCHAR szIntFormat[] = {'%','d',0};
658 static const WCHAR szIntel[] = { 'I','n','t','e','l',0 };
659 static const WCHAR szUserInfo[] = {
660 'S','O','F','T','W','A','R','E','\\',
661 'M','i','c','r','o','s','o','f','t','\\',
662 'M','S',' ','S','e','t','u','p',' ','(','A','C','M','E',')','\\',
663 'U','s','e','r',' ','I','n','f','o',0
665 static const WCHAR szDefName[] = { 'D','e','f','N','a','m','e',0 };
666 static const WCHAR szDefCompany[] = { 'D','e','f','C','o','m','p','a','n','y',0 };
667 static const WCHAR szCurrentVersion[] = {
668 'S','O','F','T','W','A','R','E','\\',
669 'M','i','c','r','o','s','o','f','t','\\',
670 'W','i','n','d','o','w','s',' ','N','T','\\',
671 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0
673 static const WCHAR szRegisteredUser[] = {'R','e','g','i','s','t','e','r','e','d','O','w','n','e','r',0};
674 static const WCHAR szRegisteredOrg[] = {
675 'R','e','g','i','s','t','e','r','e','d','O','r','g','a','n','i','z','a','t','i','o','n',0
677 static const WCHAR szUSERNAME[] = {'U','S','E','R','N','A','M','E',0};
678 static const WCHAR szCOMPANYNAME[] = {'C','O','M','P','A','N','Y','N','A','M','E',0};
679 static const WCHAR szDate[] = {'D','a','t','e',0};
680 static const WCHAR szTime[] = {'T','i','m','e',0};
681 static const WCHAR szUserLangID[] = {'U','s','e','r','L','a','n','g','u','a','g','e','I','D',0};
682 static const WCHAR szSystemLangID[] = {'S','y','s','t','e','m','L','a','n','g','u','a','g','e','I','D',0};
683 static const WCHAR szProductState[] = {'P','r','o','d','u','c','t','S','t','a','t','e',0};
684 static const WCHAR szLogonUser[] = {'L','o','g','o','n','U','s','e','r',0};
687 * Other things that probably should be set:
689 * ComputerName VirtualMemory
690 * ShellAdvSupport DefaultUIFont PackagecodeChanging
691 * CaptionHeight BorderTop BorderSide TextHeight
692 * RedirectedDllSupport
695 SHGetFolderPathW(NULL,CSIDL_PROGRAM_FILES_COMMON,NULL,0,pth);
696 strcatW(pth, szBackSlash);
697 msi_set_property(package->db, CFF, pth);
699 SHGetFolderPathW(NULL,CSIDL_PROGRAM_FILES,NULL,0,pth);
700 strcatW(pth, szBackSlash);
701 msi_set_property(package->db, PFF, pth);
703 SHGetFolderPathW(NULL,CSIDL_COMMON_APPDATA,NULL,0,pth);
704 strcatW(pth, szBackSlash);
705 msi_set_property(package->db, CADF, pth);
707 SHGetFolderPathW(NULL,CSIDL_FAVORITES,NULL,0,pth);
708 strcatW(pth, szBackSlash);
709 msi_set_property(package->db, FaF, pth);
711 SHGetFolderPathW(NULL,CSIDL_FONTS,NULL,0,pth);
712 strcatW(pth, szBackSlash);
713 msi_set_property(package->db, FoF, pth);
715 SHGetFolderPathW(NULL,CSIDL_SENDTO,NULL,0,pth);
716 strcatW(pth, szBackSlash);
717 msi_set_property(package->db, SendTF, pth);
719 SHGetFolderPathW(NULL,CSIDL_STARTMENU,NULL,0,pth);
720 strcatW(pth, szBackSlash);
721 msi_set_property(package->db, SMF, pth);
723 SHGetFolderPathW(NULL,CSIDL_STARTUP,NULL,0,pth);
724 strcatW(pth, szBackSlash);
725 msi_set_property(package->db, StF, pth);
727 SHGetFolderPathW(NULL,CSIDL_TEMPLATES,NULL,0,pth);
728 strcatW(pth, szBackSlash);
729 msi_set_property(package->db, TemplF, pth);
731 SHGetFolderPathW(NULL,CSIDL_DESKTOP,NULL,0,pth);
732 strcatW(pth, szBackSlash);
733 msi_set_property(package->db, DF, pth);
735 SHGetFolderPathW(NULL,CSIDL_PROGRAMS,NULL,0,pth);
736 strcatW(pth, szBackSlash);
737 msi_set_property(package->db, PMF, pth);
739 SHGetFolderPathW(NULL,CSIDL_ADMINTOOLS,NULL,0,pth);
740 strcatW(pth, szBackSlash);
741 msi_set_property(package->db, ATF, pth);
743 SHGetFolderPathW(NULL,CSIDL_APPDATA,NULL,0,pth);
744 strcatW(pth, szBackSlash);
745 msi_set_property(package->db, ADF, pth);
747 SHGetFolderPathW(NULL,CSIDL_SYSTEM,NULL,0,pth);
748 strcatW(pth, szBackSlash);
749 msi_set_property(package->db, SF, pth);
750 msi_set_property(package->db, SF16, pth);
752 SHGetFolderPathW(NULL,CSIDL_LOCAL_APPDATA,NULL,0,pth);
753 strcatW(pth, szBackSlash);
754 msi_set_property(package->db, LADF, pth);
756 SHGetFolderPathW(NULL,CSIDL_MYPICTURES,NULL,0,pth);
757 strcatW(pth, szBackSlash);
758 msi_set_property(package->db, MPF, pth);
760 SHGetFolderPathW(NULL,CSIDL_PERSONAL,NULL,0,pth);
761 strcatW(pth, szBackSlash);
762 msi_set_property(package->db, PF, pth);
764 SHGetFolderPathW(NULL,CSIDL_WINDOWS,NULL,0,pth);
765 strcatW(pth, szBackSlash);
766 msi_set_property(package->db, WF, pth);
768 /* Physical Memory is specified in MB. Using total amount. */
769 msex.dwLength = sizeof(msex);
770 GlobalMemoryStatusEx( &msex );
771 sprintfW( bufstr, szIntFormat, (int)(msex.ullTotalPhys/1024/1024));
772 msi_set_property(package->db, szPhysicalMemory, bufstr);
774 SHGetFolderPathW(NULL,CSIDL_WINDOWS,NULL,0,pth);
775 ptr = strchrW(pth,'\\');
778 msi_set_property(package->db, WV, pth);
780 GetTempPathW(MAX_PATH,pth);
781 msi_set_property(package->db, TF, pth);
784 /* in a wine environment the user is always admin and privileged */
785 msi_set_property(package->db, szAdminUser, szOne);
786 msi_set_property(package->db, szPriv, szOne);
788 /* set the os things */
789 OSVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
790 GetVersionExW((OSVERSIONINFOW *)&OSVersion);
791 verval = OSVersion.dwMinorVersion+OSVersion.dwMajorVersion*100;
792 sprintfW(verstr,szFormat,verval);
793 switch (OSVersion.dwPlatformId)
795 case VER_PLATFORM_WIN32_WINDOWS:
796 msi_set_property(package->db, v9x, verstr);
798 case VER_PLATFORM_WIN32_NT:
799 msi_set_property(package->db, vNT, verstr);
800 sprintfW(verstr,szFormat,OSVersion.wProductType);
801 msi_set_property(package->db, szMsiNTProductType, verstr);
804 sprintfW(verstr,szFormat,OSVersion.dwBuildNumber);
805 msi_set_property(package->db, szWinBuild, verstr);
806 /* just fudge this */
807 msi_set_property(package->db, szSPL, szSix);
809 sprintfW( bufstr, szFormat2, MSI_MAJORVERSION, MSI_MINORVERSION);
810 msi_set_property( package->db, szVersionMsi, bufstr );
811 sprintfW( bufstr, szFormat, MSI_MAJORVERSION * 100);
812 msi_set_property( package->db, szVersionDatabase, bufstr );
814 GetSystemInfo( &sys_info );
815 if (sys_info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
817 sprintfW( bufstr, szIntFormat, sys_info.wProcessorLevel );
818 msi_set_property( package->db, szIntel, bufstr );
821 /* Screen properties. */
823 sprintfW( bufstr, szIntFormat, GetDeviceCaps( dc, HORZRES ) );
824 msi_set_property( package->db, szScreenX, bufstr );
825 sprintfW( bufstr, szIntFormat, GetDeviceCaps( dc, VERTRES ));
826 msi_set_property( package->db, szScreenY, bufstr );
827 sprintfW( bufstr, szIntFormat, GetDeviceCaps( dc, BITSPIXEL ));
828 msi_set_property( package->db, szColorBits, bufstr );
831 /* USERNAME and COMPANYNAME */
832 username = msi_dup_property( package->db, szUSERNAME );
833 companyname = msi_dup_property( package->db, szCOMPANYNAME );
835 if ((!username || !companyname) &&
836 RegOpenKeyW( HKEY_CURRENT_USER, szUserInfo, &hkey ) == ERROR_SUCCESS)
839 (username = msi_reg_get_val_str( hkey, szDefName )))
840 msi_set_property( package->db, szUSERNAME, username );
842 (companyname = msi_reg_get_val_str( hkey, szDefCompany )))
843 msi_set_property( package->db, szCOMPANYNAME, companyname );
846 if ((!username || !companyname) &&
847 RegOpenKeyW( HKEY_LOCAL_MACHINE, szCurrentVersion, &hkey ) == ERROR_SUCCESS)
850 (username = msi_reg_get_val_str( hkey, szRegisteredUser )))
851 msi_set_property( package->db, szUSERNAME, username );
853 (companyname = msi_reg_get_val_str( hkey, szRegisteredOrg )))
854 msi_set_property( package->db, szCOMPANYNAME, companyname );
857 msi_free( username );
858 msi_free( companyname );
860 if ( set_user_sid_prop( package ) != ERROR_SUCCESS)
861 ERR("Failed to set the UserSID property\n");
863 /* Date and time properties */
864 GetSystemTime( &systemtime );
865 if (GetDateFormatW( LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systemtime,
866 NULL, bufstr, sizeof(bufstr)/sizeof(bufstr[0]) ))
867 msi_set_property( package->db, szDate, bufstr );
869 ERR("Couldn't set Date property: GetDateFormat failed with error %d\n", GetLastError());
871 if (GetTimeFormatW( LOCALE_USER_DEFAULT,
872 TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER,
873 &systemtime, NULL, bufstr,
874 sizeof(bufstr)/sizeof(bufstr[0]) ))
875 msi_set_property( package->db, szTime, bufstr );
877 ERR("Couldn't set Time property: GetTimeFormat failed with error %d\n", GetLastError());
879 set_msi_assembly_prop( package );
881 langid = GetUserDefaultLangID();
882 sprintfW(bufstr, szIntFormat, langid);
883 msi_set_property( package->db, szUserLangID, bufstr );
885 langid = GetSystemDefaultLangID();
886 sprintfW(bufstr, szIntFormat, langid);
887 msi_set_property( package->db, szSystemLangID, bufstr );
889 sprintfW(bufstr, szIntFormat, MsiQueryProductStateW(package->ProductCode));
890 msi_set_property( package->db, szProductState, bufstr );
893 if (!GetUserNameW( NULL, &len ) && GetLastError() == ERROR_MORE_DATA)
896 if ((username = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
898 if (GetUserNameW( username, &len ))
899 msi_set_property( package->db, szLogonUser, username );
900 HeapFree( GetProcessHeap(), 0, username );
905 static UINT msi_load_summary_properties( MSIPACKAGE *package )
909 MSIHANDLE hdb = alloc_msihandle( &package->db->hdr );
913 static const WCHAR szPackageCode[] = {
914 'P','a','c','k','a','g','e','C','o','d','e',0};
917 ERR("Unable to allocate handle\n");
918 return ERROR_OUTOFMEMORY;
921 rc = MsiGetSummaryInformationW( hdb, NULL, 0, &suminfo );
923 if (rc != ERROR_SUCCESS)
925 ERR("Unable to open Summary Information\n");
929 rc = MsiSummaryInfoGetPropertyW( suminfo, PID_PAGECOUNT, NULL,
930 &count, NULL, NULL, NULL );
931 if (rc != ERROR_SUCCESS)
933 WARN("Unable to query page count: %d\n", rc);
937 /* load package code property */
939 rc = MsiSummaryInfoGetPropertyW( suminfo, PID_REVNUMBER, NULL,
940 NULL, NULL, NULL, &len );
941 if (rc != ERROR_MORE_DATA)
943 WARN("Unable to query revision number: %d\n", rc);
944 rc = ERROR_FUNCTION_FAILED;
949 package_code = msi_alloc( len * sizeof(WCHAR) );
950 rc = MsiSummaryInfoGetPropertyW( suminfo, PID_REVNUMBER, NULL,
951 NULL, NULL, package_code, &len );
952 if (rc != ERROR_SUCCESS)
954 WARN("Unable to query rev number: %d\n", rc);
958 msi_set_property( package->db, szPackageCode, package_code );
959 msi_free( package_code );
961 /* load package attributes */
963 MsiSummaryInfoGetPropertyW( suminfo, PID_WORDCOUNT, NULL,
964 &count, NULL, NULL, NULL );
965 package->WordCount = count;
968 MsiCloseHandle(suminfo);
972 static MSIPACKAGE *msi_alloc_package( void )
976 package = alloc_msiobject( MSIHANDLETYPE_PACKAGE, sizeof (MSIPACKAGE),
980 list_init( &package->components );
981 list_init( &package->features );
982 list_init( &package->files );
983 list_init( &package->tempfiles );
984 list_init( &package->folders );
985 list_init( &package->subscriptions );
986 list_init( &package->appids );
987 list_init( &package->classes );
988 list_init( &package->mimes );
989 list_init( &package->extensions );
990 list_init( &package->progids );
991 list_init( &package->RunningActions );
992 list_init( &package->sourcelist_info );
993 list_init( &package->sourcelist_media );
994 list_init( &package->patches );
1000 static UINT msi_load_admin_properties(MSIPACKAGE *package)
1005 static const WCHAR stmname[] = {'A','d','m','i','n','P','r','o','p','e','r','t','i','e','s',0};
1007 r = read_stream_data(package->db->storage, stmname, FALSE, &data, &sz);
1008 if (r != ERROR_SUCCESS)
1011 r = msi_parse_command_line(package, (WCHAR *)data, TRUE);
1017 static void adjust_allusers_property( MSIPACKAGE *package )
1019 /* FIXME: this should depend on the user's privileges */
1020 if (msi_get_property_int( package->db, szAllUsers, 0 ) == 2)
1022 TRACE("resetting ALLUSERS property from 2 to 1\n");
1023 msi_set_property( package->db, szAllUsers, szOne );
1027 MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
1029 static const WCHAR szLevel[] = { 'U','I','L','e','v','e','l',0 };
1030 static const WCHAR szpi[] = {'%','i',0};
1031 MSIPACKAGE *package;
1037 package = msi_alloc_package();
1040 msiobj_addref( &db->hdr );
1043 package->WordCount = 0;
1044 package->PackagePath = strdupW( db->path );
1045 package->BaseURL = strdupW( base_url );
1047 create_temp_property_table( package );
1048 msi_clone_properties( package );
1050 package->ProductCode = msi_dup_property( package->db, szProductCode );
1051 set_installed_prop( package );
1052 set_installer_properties( package );
1054 sprintfW(uilevel,szpi,gUILevel);
1055 msi_set_property(package->db, szLevel, uilevel);
1057 r = msi_load_summary_properties( package );
1058 if (r != ERROR_SUCCESS)
1060 msiobj_release( &package->hdr );
1064 if (package->WordCount & msidbSumInfoSourceTypeAdminImage)
1065 msi_load_admin_properties( package );
1067 adjust_allusers_property( package );
1074 * copy_package_to_temp [internal]
1076 * copy the msi file to a temp file to prevent locking a CD
1077 * with a multi disc install
1079 * FIXME: I think this is wrong, and instead of copying the package,
1080 * we should read all the tables to memory, then open the
1081 * database to read binary streams on demand.
1083 static UINT copy_package_to_temp( LPCWSTR szPackage, LPWSTR filename )
1085 WCHAR path[MAX_PATH];
1087 GetTempPathW( MAX_PATH, path );
1088 GetTempFileNameW( path, szMsi, 0, filename );
1090 if( !CopyFileW( szPackage, filename, FALSE ) )
1092 UINT error = GetLastError();
1093 ERR("failed to copy package %s to %s (%u)\n", debugstr_w(szPackage), debugstr_w(filename), error);
1094 DeleteFileW( filename );
1098 return ERROR_SUCCESS;
1101 UINT msi_download_file( LPCWSTR szUrl, LPWSTR filename )
1103 LPINTERNET_CACHE_ENTRY_INFOW cache_entry;
1107 /* call will always fail, becase size is 0,
1108 * but will return ERROR_FILE_NOT_FOUND first
1109 * if the file doesn't exist
1111 GetUrlCacheEntryInfoW( szUrl, NULL, &size );
1112 if ( GetLastError() != ERROR_FILE_NOT_FOUND )
1114 cache_entry = HeapAlloc( GetProcessHeap(), 0, size );
1115 if ( !GetUrlCacheEntryInfoW( szUrl, cache_entry, &size ) )
1117 UINT error = GetLastError();
1118 HeapFree( GetProcessHeap(), 0, cache_entry );
1122 lstrcpyW( filename, cache_entry->lpszLocalFileName );
1123 HeapFree( GetProcessHeap(), 0, cache_entry );
1124 return ERROR_SUCCESS;
1127 hr = URLDownloadToCacheFileW( NULL, szUrl, filename, MAX_PATH, 0, NULL );
1130 WARN("failed to download %s to cache file\n", debugstr_w(szUrl));
1131 return ERROR_FUNCTION_FAILED;
1134 return ERROR_SUCCESS;
1137 UINT msi_get_local_package_name( LPWSTR path, LPCWSTR suffix )
1139 static const WCHAR szInstaller[] = {
1140 '\\','I','n','s','t','a','l','l','e','r','\\',0};
1141 static const WCHAR fmt[] = {'%','x',0};
1142 DWORD time, len, i, offset;
1145 time = GetTickCount();
1146 GetWindowsDirectoryW( path, MAX_PATH );
1147 strcatW( path, szInstaller );
1148 CreateDirectoryW( path, NULL );
1150 len = strlenW(path);
1151 for (i = 0; i < 0x10000; i++)
1153 offset = snprintfW( path + len, MAX_PATH - len, fmt, (time + i) & 0xffff );
1154 memcpy( path + len + offset, suffix, (strlenW( suffix ) + 1) * sizeof(WCHAR) );
1155 handle = CreateFileW( path, GENERIC_WRITE, 0, NULL,
1156 CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
1157 if (handle != INVALID_HANDLE_VALUE)
1159 CloseHandle(handle);
1162 if (GetLastError() != ERROR_FILE_EXISTS &&
1163 GetLastError() != ERROR_SHARING_VIOLATION)
1164 return ERROR_FUNCTION_FAILED;
1167 return ERROR_SUCCESS;
1170 UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
1172 static const WCHAR OriginalDatabase[] =
1173 {'O','r','i','g','i','n','a','l','D','a','t','a','b','a','s','e',0};
1174 static const WCHAR Database[] = {'D','A','T','A','B','A','S','E',0};
1175 static const WCHAR dotmsi[] = {'.','m','s','i',0};
1176 MSIDATABASE *db = NULL;
1177 MSIPACKAGE *package;
1179 LPWSTR ptr, base_url = NULL;
1181 WCHAR temppath[MAX_PATH], localfile[MAX_PATH], cachefile[MAX_PATH];
1182 LPCWSTR file = szPackage;
1184 TRACE("%s %p\n", debugstr_w(szPackage), pPackage);
1186 if( szPackage[0] == '#' )
1188 handle = atoiW(&szPackage[1]);
1189 db = msihandle2msiinfo( handle, MSIHANDLETYPE_DATABASE );
1192 IWineMsiRemoteDatabase *remote_database;
1194 remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( handle );
1195 if ( !remote_database )
1196 return ERROR_INVALID_HANDLE;
1198 IWineMsiRemoteDatabase_Release( remote_database );
1199 WARN("MsiOpenPackage not allowed during a custom action!\n");
1201 return ERROR_FUNCTION_FAILED;
1206 if ( UrlIsW( szPackage, URLIS_URL ) )
1208 r = msi_download_file( szPackage, cachefile );
1209 if ( r != ERROR_SUCCESS )
1212 r = copy_package_to_temp( cachefile, temppath );
1213 if ( r != ERROR_SUCCESS )
1218 base_url = strdupW( szPackage );
1220 return ERROR_OUTOFMEMORY;
1222 ptr = strrchrW( base_url, '/' );
1223 if (ptr) *(ptr + 1) = '\0';
1227 r = copy_package_to_temp( szPackage, temppath );
1228 if ( r != ERROR_SUCCESS )
1234 r = msi_get_local_package_name( localfile, dotmsi );
1235 if (r != ERROR_SUCCESS)
1238 TRACE("Copying to local package %s\n", debugstr_w(localfile));
1240 if (!CopyFileW( file, localfile, FALSE ))
1242 ERR("Unable to copy package (%s -> %s) (error %u)\n",
1243 debugstr_w(file), debugstr_w(localfile), GetLastError());
1244 return GetLastError();
1247 TRACE("Opening relocated package %s\n", debugstr_w( file ));
1249 /* transforms that add binary streams require that we open the database
1250 * read/write, which is safe because we always create a copy that is thrown
1251 * away when we're done.
1253 r = MSI_OpenDatabaseW( file, MSIDBOPEN_DIRECT, &db );
1254 if( r != ERROR_SUCCESS )
1256 if (file != szPackage)
1257 DeleteFileW( file );
1259 if (GetFileAttributesW(szPackage) == INVALID_FILE_ATTRIBUTES)
1260 return ERROR_FILE_NOT_FOUND;
1265 db->localfile = strdupW( localfile );
1268 package = MSI_CreatePackage( db, base_url );
1269 msi_free( base_url );
1270 msiobj_release( &db->hdr );
1273 if (file != szPackage)
1274 DeleteFileW( file );
1276 return ERROR_INSTALL_PACKAGE_INVALID;
1279 if( file != szPackage )
1280 track_tempfile( package, file );
1282 msi_set_property( package->db, Database, db->path );
1284 if( UrlIsW( szPackage, URLIS_URL ) )
1285 msi_set_property( package->db, OriginalDatabase, szPackage );
1286 else if( szPackage[0] == '#' )
1287 msi_set_property( package->db, OriginalDatabase, db->path );
1290 WCHAR fullpath[MAX_PATH];
1292 GetFullPathNameW( szPackage, MAX_PATH, fullpath, NULL );
1293 msi_set_property( package->db, OriginalDatabase, fullpath );
1296 package->script = msi_alloc_zero( sizeof(MSISCRIPT) );
1297 *pPackage = package;
1299 return ERROR_SUCCESS;
1302 UINT WINAPI MsiOpenPackageExW(LPCWSTR szPackage, DWORD dwOptions, MSIHANDLE *phPackage)
1304 MSIPACKAGE *package = NULL;
1307 TRACE("%s %08x %p\n", debugstr_w(szPackage), dwOptions, phPackage );
1309 if( !szPackage || !phPackage )
1310 return ERROR_INVALID_PARAMETER;
1314 FIXME("Should create an empty database and package\n");
1315 return ERROR_FUNCTION_FAILED;
1319 FIXME("dwOptions %08x not supported\n", dwOptions);
1321 ret = MSI_OpenPackageW( szPackage, &package );
1322 if( ret == ERROR_SUCCESS )
1324 *phPackage = alloc_msihandle( &package->hdr );
1326 ret = ERROR_NOT_ENOUGH_MEMORY;
1327 msiobj_release( &package->hdr );
1333 UINT WINAPI MsiOpenPackageW(LPCWSTR szPackage, MSIHANDLE *phPackage)
1335 return MsiOpenPackageExW( szPackage, 0, phPackage );
1338 UINT WINAPI MsiOpenPackageExA(LPCSTR szPackage, DWORD dwOptions, MSIHANDLE *phPackage)
1340 LPWSTR szwPack = NULL;
1345 szwPack = strdupAtoW( szPackage );
1347 return ERROR_OUTOFMEMORY;
1350 ret = MsiOpenPackageExW( szwPack, dwOptions, phPackage );
1352 msi_free( szwPack );
1357 UINT WINAPI MsiOpenPackageA(LPCSTR szPackage, MSIHANDLE *phPackage)
1359 return MsiOpenPackageExA( szPackage, 0, phPackage );
1362 MSIHANDLE WINAPI MsiGetActiveDatabase(MSIHANDLE hInstall)
1364 MSIPACKAGE *package;
1365 MSIHANDLE handle = 0;
1366 IUnknown *remote_unk;
1367 IWineMsiRemotePackage *remote_package;
1369 TRACE("(%d)\n",hInstall);
1371 package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
1374 handle = alloc_msihandle( &package->db->hdr );
1375 msiobj_release( &package->hdr );
1377 else if ((remote_unk = msi_get_remote(hInstall)))
1379 if (IUnknown_QueryInterface(remote_unk, &IID_IWineMsiRemotePackage,
1380 (LPVOID *)&remote_package) == S_OK)
1382 IWineMsiRemotePackage_GetActiveDatabase(remote_package, &handle);
1383 IWineMsiRemotePackage_Release(remote_package);
1387 WARN("remote handle %d is not a package\n", hInstall);
1389 IUnknown_Release(remote_unk);
1395 INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
1398 static const WCHAR szActionData[] =
1399 {'A','c','t','i','o','n','D','a','t','a',0};
1400 static const WCHAR szSetProgress[] =
1401 {'S','e','t','P','r','o','g','r','e','s','s',0};
1402 static const WCHAR szActionText[] =
1403 {'A','c','t','i','o','n','T','e','x','t',0};
1407 DWORD total_size = 0;
1413 TRACE("%x\n", eMessageType);
1416 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ERROR)
1417 log_type |= INSTALLLOGMODE_ERROR;
1418 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_WARNING)
1419 log_type |= INSTALLLOGMODE_WARNING;
1420 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_USER)
1421 log_type |= INSTALLLOGMODE_USER;
1422 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_INFO)
1423 log_type |= INSTALLLOGMODE_INFO;
1424 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_COMMONDATA)
1425 log_type |= INSTALLLOGMODE_COMMONDATA;
1426 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ACTIONSTART)
1427 log_type |= INSTALLLOGMODE_ACTIONSTART;
1428 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ACTIONDATA)
1429 log_type |= INSTALLLOGMODE_ACTIONDATA;
1431 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_PROGRESS)
1434 if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ACTIONSTART)
1436 static const WCHAR template_s[]=
1437 {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ',0};
1438 static const WCHAR format[] =
1439 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
1441 LPCWSTR action_text, action;
1442 LPWSTR deformatted = NULL;
1444 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
1446 action = MSI_RecordGetString(record, 1);
1447 action_text = MSI_RecordGetString(record, 2);
1449 if (!action || !action_text)
1452 deformat_string(package, action_text, &deformatted);
1454 len = strlenW(timet) + strlenW(action) + strlenW(template_s);
1456 len += strlenW(deformatted);
1457 message = msi_alloc(len*sizeof(WCHAR));
1458 sprintfW(message, template_s, timet, action);
1460 strcatW(message, deformatted);
1461 msi_free(deformatted);
1466 message = msi_alloc(1*sizeof (WCHAR));
1468 msg_field = MSI_RecordGetFieldCount(record);
1469 for (i = 1; i <= msg_field; i++)
1473 static const WCHAR format[] = { '%','i',':',' ',0};
1475 MSI_RecordGetStringW(record,i,NULL,&sz);
1477 total_size+=sz*sizeof(WCHAR);
1478 tmp = msi_alloc(sz*sizeof(WCHAR));
1479 message = msi_realloc(message,total_size*sizeof (WCHAR));
1481 MSI_RecordGetStringW(record,i,tmp,&sz);
1485 sprintfW(number,format,i);
1486 strcatW(message,number);
1488 strcatW(message,tmp);
1490 strcatW(message, szSpace);
1496 TRACE("%p %p %p %x %x %s\n", gUIHandlerA, gUIHandlerW, gUIHandlerRecord,
1497 gUIFilter, log_type, debugstr_w(message));
1499 /* convert it to ASCII */
1500 len = WideCharToMultiByte( CP_ACP, 0, message, -1, NULL, 0, NULL, NULL );
1501 msg = msi_alloc( len );
1502 WideCharToMultiByte( CP_ACP, 0, message, -1, msg, len, NULL, NULL );
1504 if (gUIHandlerW && (gUIFilter & log_type))
1506 rc = gUIHandlerW( gUIContext, eMessageType, message );
1508 else if (gUIHandlerA && (gUIFilter & log_type))
1510 rc = gUIHandlerA( gUIContext, eMessageType, msg );
1512 else if (gUIHandlerRecord && (gUIFilter & log_type))
1514 MSIHANDLE rec = MsiCreateRecord( 1 );
1515 MsiRecordSetStringW( rec, 0, message );
1516 rc = gUIHandlerRecord( gUIContext, eMessageType, rec );
1517 MsiCloseHandle( rec );
1520 if ((!rc) && (gszLogFile[0]) && !((eMessageType & 0xff000000) ==
1521 INSTALLMESSAGE_PROGRESS))
1524 HANDLE log_file = CreateFileW(gszLogFile,GENERIC_WRITE, 0, NULL,
1525 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
1527 if (log_file != INVALID_HANDLE_VALUE)
1529 SetFilePointer(log_file,0, NULL, FILE_END);
1530 WriteFile(log_file,msg,strlen(msg),&write,NULL);
1531 WriteFile(log_file,"\n",1,&write,NULL);
1532 CloseHandle(log_file);
1536 msi_free( message );
1538 switch (eMessageType & 0xff000000)
1540 case INSTALLMESSAGE_ACTIONDATA:
1541 /* FIXME: format record here instead of in ui_actiondata to get the
1542 * correct action data for external scripts */
1543 ControlEvent_FireSubscribedEvent(package, szActionData, record);
1545 case INSTALLMESSAGE_ACTIONSTART:
1549 LPCWSTR action_text = MSI_RecordGetString(record, 2);
1551 deformat_string(package, action_text, &deformated);
1552 uirow = MSI_CreateRecord(1);
1553 MSI_RecordSetStringW(uirow, 1, deformated);
1554 TRACE("INSTALLMESSAGE_ACTIONSTART: %s\n", debugstr_w(deformated));
1555 msi_free(deformated);
1557 ControlEvent_FireSubscribedEvent(package, szActionText, uirow);
1559 msiobj_release(&uirow->hdr);
1562 case INSTALLMESSAGE_PROGRESS:
1563 ControlEvent_FireSubscribedEvent(package, szSetProgress, record);
1567 return ERROR_SUCCESS;
1570 INT WINAPI MsiProcessMessage( MSIHANDLE hInstall, INSTALLMESSAGE eMessageType,
1573 UINT ret = ERROR_INVALID_HANDLE;
1574 MSIPACKAGE *package = NULL;
1575 MSIRECORD *record = NULL;
1577 package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
1581 IWineMsiRemotePackage *remote_package;
1583 remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
1584 if (!remote_package)
1585 return ERROR_INVALID_HANDLE;
1587 hr = IWineMsiRemotePackage_ProcessMessage( remote_package, eMessageType, hRecord );
1589 IWineMsiRemotePackage_Release( remote_package );
1593 if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
1594 return HRESULT_CODE(hr);
1596 return ERROR_FUNCTION_FAILED;
1599 return ERROR_SUCCESS;
1602 record = msihandle2msiinfo( hRecord, MSIHANDLETYPE_RECORD );
1606 ret = MSI_ProcessMessage( package, eMessageType, record );
1609 msiobj_release( &package->hdr );
1611 msiobj_release( &record->hdr );
1618 UINT WINAPI MsiSetPropertyA( MSIHANDLE hInstall, LPCSTR szName, LPCSTR szValue )
1620 LPWSTR szwName = NULL, szwValue = NULL;
1621 UINT r = ERROR_OUTOFMEMORY;
1623 szwName = strdupAtoW( szName );
1624 if( szName && !szwName )
1627 szwValue = strdupAtoW( szValue );
1628 if( szValue && !szwValue )
1631 r = MsiSetPropertyW( hInstall, szwName, szwValue);
1634 msi_free( szwName );
1635 msi_free( szwValue );
1640 void msi_reset_folders( MSIPACKAGE *package, BOOL source )
1644 LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry )
1648 msi_free( folder->ResolvedSource );
1649 folder->ResolvedSource = NULL;
1653 msi_free( folder->ResolvedTarget );
1654 folder->ResolvedTarget = NULL;
1659 UINT msi_set_property( MSIDATABASE *db, LPCWSTR szName, LPCWSTR szValue )
1662 MSIRECORD *row = NULL;
1667 static const WCHAR Insert[] = {
1668 'I','N','S','E','R','T',' ','i','n','t','o',' ',
1669 '`','_','P','r','o','p','e','r','t','y','`',' ','(',
1670 '`','_','P','r','o','p','e','r','t','y','`',',',
1671 '`','V','a','l','u','e','`',')',' ','V','A','L','U','E','S'
1672 ,' ','(','?',',','?',')',0};
1673 static const WCHAR Update[] = {
1674 'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',
1675 ' ','s','e','t',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ',
1676 'w','h','e','r','e',' ','`','_','P','r','o','p','e','r','t','y','`',
1677 ' ','=',' ','\'','%','s','\'',0};
1678 static const WCHAR Delete[] = {
1679 'D','E','L','E','T','E',' ','F','R','O','M',' ',
1680 '`','_','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
1681 '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
1683 TRACE("%p %s %s\n", db, debugstr_w(szName), debugstr_w(szValue));
1686 return ERROR_INVALID_PARAMETER;
1688 /* this one is weird... */
1690 return szValue ? ERROR_FUNCTION_FAILED : ERROR_SUCCESS;
1692 rc = msi_get_property(db, szName, 0, &sz);
1693 if (!szValue || !*szValue)
1695 sprintfW(Query, Delete, szName);
1697 else if (rc == ERROR_MORE_DATA || rc == ERROR_SUCCESS)
1699 sprintfW(Query, Update, szName);
1701 row = MSI_CreateRecord(1);
1702 MSI_RecordSetStringW(row, 1, szValue);
1706 strcpyW(Query, Insert);
1708 row = MSI_CreateRecord(2);
1709 MSI_RecordSetStringW(row, 1, szName);
1710 MSI_RecordSetStringW(row, 2, szValue);
1713 rc = MSI_DatabaseOpenViewW(db, Query, &view);
1714 if (rc == ERROR_SUCCESS)
1716 rc = MSI_ViewExecute(view, row);
1717 MSI_ViewClose(view);
1718 msiobj_release(&view->hdr);
1722 msiobj_release(&row->hdr);
1727 UINT WINAPI MsiSetPropertyW( MSIHANDLE hInstall, LPCWSTR szName, LPCWSTR szValue)
1729 MSIPACKAGE *package;
1732 package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
1736 BSTR name = NULL, value = NULL;
1737 IWineMsiRemotePackage *remote_package;
1739 remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
1740 if (!remote_package)
1741 return ERROR_INVALID_HANDLE;
1743 name = SysAllocString( szName );
1744 value = SysAllocString( szValue );
1745 if ((!name && szName) || (!value && szValue))
1747 SysFreeString( name );
1748 SysFreeString( value );
1749 IWineMsiRemotePackage_Release( remote_package );
1750 return ERROR_OUTOFMEMORY;
1753 hr = IWineMsiRemotePackage_SetProperty( remote_package, name, value );
1755 SysFreeString( name );
1756 SysFreeString( value );
1757 IWineMsiRemotePackage_Release( remote_package );
1761 if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
1762 return HRESULT_CODE(hr);
1764 return ERROR_FUNCTION_FAILED;
1767 return ERROR_SUCCESS;
1770 ret = msi_set_property( package->db, szName, szValue );
1771 if (ret == ERROR_SUCCESS && !strcmpW( szName, cszSourceDir ))
1772 msi_reset_folders( package, TRUE );
1774 msiobj_release( &package->hdr );
1778 static MSIRECORD *msi_get_property_row( MSIDATABASE *db, LPCWSTR name )
1781 MSIRECORD *rec, *row = NULL;
1784 static const WCHAR query[]= {
1785 'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
1786 'F','R','O','M',' ' ,'`','_','P','r','o','p','e','r','t','y','`',
1787 ' ','W','H','E','R','E',' ' ,'`','_','P','r','o','p','e','r','t','y','`',
1790 if (!name || !*name)
1793 rec = MSI_CreateRecord(1);
1797 MSI_RecordSetStringW(rec, 1, name);
1799 r = MSI_DatabaseOpenViewW(db, query, &view);
1800 if (r == ERROR_SUCCESS)
1802 MSI_ViewExecute(view, rec);
1803 MSI_ViewFetch(view, &row);
1804 MSI_ViewClose(view);
1805 msiobj_release(&view->hdr);
1808 msiobj_release(&rec->hdr);
1812 /* internal function, not compatible with MsiGetPropertyW */
1813 UINT msi_get_property( MSIDATABASE *db, LPCWSTR szName,
1814 LPWSTR szValueBuf, LPDWORD pchValueBuf )
1817 UINT rc = ERROR_FUNCTION_FAILED;
1819 row = msi_get_property_row( db, szName );
1821 if (*pchValueBuf > 0)
1826 rc = MSI_RecordGetStringW(row, 1, szValueBuf, pchValueBuf);
1827 msiobj_release(&row->hdr);
1830 if (rc == ERROR_SUCCESS)
1831 TRACE("returning %s for property %s\n", debugstr_w(szValueBuf),
1832 debugstr_w(szName));
1833 else if (rc == ERROR_MORE_DATA)
1834 TRACE("need %d sized buffer for %s\n", *pchValueBuf,
1835 debugstr_w(szName));
1839 TRACE("property %s not found\n", debugstr_w(szName));
1845 LPWSTR msi_dup_property(MSIDATABASE *db, LPCWSTR prop)
1851 r = msi_get_property(db, prop, NULL, &sz);
1852 if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA)
1856 str = msi_alloc(sz * sizeof(WCHAR));
1857 r = msi_get_property(db, prop, str, &sz);
1858 if (r != ERROR_SUCCESS)
1867 int msi_get_property_int( MSIDATABASE *db, LPCWSTR prop, int def )
1869 LPWSTR str = msi_dup_property( db, prop );
1870 int val = str ? atoiW(str) : def;
1875 static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
1876 awstring *szValueBuf, LPDWORD pchValueBuf )
1878 MSIPACKAGE *package;
1879 MSIRECORD *row = NULL;
1880 UINT r = ERROR_FUNCTION_FAILED;
1883 TRACE("%u %s %p %p\n", handle, debugstr_w(name),
1884 szValueBuf->str.w, pchValueBuf );
1887 return ERROR_INVALID_PARAMETER;
1889 package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE );
1893 IWineMsiRemotePackage *remote_package;
1894 LPWSTR value = NULL;
1898 remote_package = (IWineMsiRemotePackage *)msi_get_remote( handle );
1899 if (!remote_package)
1900 return ERROR_INVALID_HANDLE;
1902 bname = SysAllocString( name );
1905 IWineMsiRemotePackage_Release( remote_package );
1906 return ERROR_OUTOFMEMORY;
1910 hr = IWineMsiRemotePackage_GetProperty( remote_package, bname, NULL, &len );
1915 value = msi_alloc(len * sizeof(WCHAR));
1918 r = ERROR_OUTOFMEMORY;
1922 hr = IWineMsiRemotePackage_GetProperty( remote_package, bname, (BSTR *)value, &len );
1926 r = msi_strcpy_to_awstring( value, szValueBuf, pchValueBuf );
1928 /* Bug required by Adobe installers */
1929 if (!szValueBuf->unicode && !szValueBuf->str.a)
1930 *pchValueBuf *= sizeof(WCHAR);
1933 IWineMsiRemotePackage_Release(remote_package);
1934 SysFreeString(bname);
1939 if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
1940 return HRESULT_CODE(hr);
1942 return ERROR_FUNCTION_FAILED;
1948 row = msi_get_property_row( package->db, name );
1950 val = MSI_RecordGetString( row, 1 );
1955 r = msi_strcpy_to_awstring( val, szValueBuf, pchValueBuf );
1958 msiobj_release( &row->hdr );
1959 msiobj_release( &package->hdr );
1964 UINT WINAPI MsiGetPropertyA( MSIHANDLE hInstall, LPCSTR szName,
1965 LPSTR szValueBuf, LPDWORD pchValueBuf )
1971 val.unicode = FALSE;
1972 val.str.a = szValueBuf;
1974 name = strdupAtoW( szName );
1975 if (szName && !name)
1976 return ERROR_OUTOFMEMORY;
1978 r = MSI_GetProperty( hInstall, name, &val, pchValueBuf );
1983 UINT WINAPI MsiGetPropertyW( MSIHANDLE hInstall, LPCWSTR szName,
1984 LPWSTR szValueBuf, LPDWORD pchValueBuf )
1989 val.str.w = szValueBuf;
1991 return MSI_GetProperty( hInstall, szName, &val, pchValueBuf );
1994 typedef struct _msi_remote_package_impl {
1995 const IWineMsiRemotePackageVtbl *lpVtbl;
1998 } msi_remote_package_impl;
2000 static inline msi_remote_package_impl* mrp_from_IWineMsiRemotePackage( IWineMsiRemotePackage* iface )
2002 return (msi_remote_package_impl*) iface;
2005 static HRESULT WINAPI mrp_QueryInterface( IWineMsiRemotePackage *iface,
2006 REFIID riid,LPVOID *ppobj)
2008 if( IsEqualCLSID( riid, &IID_IUnknown ) ||
2009 IsEqualCLSID( riid, &IID_IWineMsiRemotePackage ) )
2011 IUnknown_AddRef( iface );
2016 return E_NOINTERFACE;
2019 static ULONG WINAPI mrp_AddRef( IWineMsiRemotePackage *iface )
2021 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2023 return InterlockedIncrement( &This->refs );
2026 static ULONG WINAPI mrp_Release( IWineMsiRemotePackage *iface )
2028 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2031 r = InterlockedDecrement( &This->refs );
2034 MsiCloseHandle( This->package );
2040 static HRESULT WINAPI mrp_SetMsiHandle( IWineMsiRemotePackage *iface, MSIHANDLE handle )
2042 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2043 This->package = handle;
2047 static HRESULT WINAPI mrp_GetActiveDatabase( IWineMsiRemotePackage *iface, MSIHANDLE *handle )
2049 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2050 IWineMsiRemoteDatabase *rdb = NULL;
2054 hr = create_msi_remote_database( NULL, (LPVOID *)&rdb );
2055 if (FAILED(hr) || !rdb)
2057 ERR("Failed to create remote database\n");
2061 hdb = MsiGetActiveDatabase(This->package);
2063 hr = IWineMsiRemoteDatabase_SetMsiHandle( rdb, hdb );
2066 ERR("Failed to set the database handle\n");
2070 *handle = alloc_msi_remote_handle( (IUnknown *)rdb );
2074 static HRESULT WINAPI mrp_GetProperty( IWineMsiRemotePackage *iface, BSTR property, BSTR *value, DWORD *size )
2076 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2079 r = MsiGetPropertyW(This->package, (LPWSTR)property, (LPWSTR)value, size);
2080 if (r != ERROR_SUCCESS)
2081 return HRESULT_FROM_WIN32(r);
2086 static HRESULT WINAPI mrp_SetProperty( IWineMsiRemotePackage *iface, BSTR property, BSTR value )
2088 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2089 UINT r = MsiSetPropertyW(This->package, property, value);
2090 return HRESULT_FROM_WIN32(r);
2093 static HRESULT WINAPI mrp_ProcessMessage( IWineMsiRemotePackage *iface, INSTALLMESSAGE message, MSIHANDLE record )
2095 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2096 UINT r = MsiProcessMessage(This->package, message, record);
2097 return HRESULT_FROM_WIN32(r);
2100 static HRESULT WINAPI mrp_DoAction( IWineMsiRemotePackage *iface, BSTR action )
2102 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2103 UINT r = MsiDoActionW(This->package, action);
2104 return HRESULT_FROM_WIN32(r);
2107 static HRESULT WINAPI mrp_Sequence( IWineMsiRemotePackage *iface, BSTR table, int sequence )
2109 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2110 UINT r = MsiSequenceW(This->package, table, sequence);
2111 return HRESULT_FROM_WIN32(r);
2114 static HRESULT WINAPI mrp_GetTargetPath( IWineMsiRemotePackage *iface, BSTR folder, BSTR *value, DWORD *size )
2116 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2117 UINT r = MsiGetTargetPathW(This->package, (LPWSTR)folder, (LPWSTR)value, size);
2118 return HRESULT_FROM_WIN32(r);
2121 static HRESULT WINAPI mrp_SetTargetPath( IWineMsiRemotePackage *iface, BSTR folder, BSTR value)
2123 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2124 UINT r = MsiSetTargetPathW(This->package, folder, value);
2125 return HRESULT_FROM_WIN32(r);
2128 static HRESULT WINAPI mrp_GetSourcePath( IWineMsiRemotePackage *iface, BSTR folder, BSTR *value, DWORD *size )
2130 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2131 UINT r = MsiGetSourcePathW(This->package, (LPWSTR)folder, (LPWSTR)value, size);
2132 return HRESULT_FROM_WIN32(r);
2135 static HRESULT WINAPI mrp_GetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode, BOOL *ret )
2137 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2138 *ret = MsiGetMode(This->package, mode);
2142 static HRESULT WINAPI mrp_SetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode, BOOL state )
2144 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2145 UINT r = MsiSetMode(This->package, mode, state);
2146 return HRESULT_FROM_WIN32(r);
2149 static HRESULT WINAPI mrp_GetFeatureState( IWineMsiRemotePackage *iface, BSTR feature,
2150 INSTALLSTATE *installed, INSTALLSTATE *action )
2152 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2153 UINT r = MsiGetFeatureStateW(This->package, feature, installed, action);
2154 return HRESULT_FROM_WIN32(r);
2157 static HRESULT WINAPI mrp_SetFeatureState( IWineMsiRemotePackage *iface, BSTR feature, INSTALLSTATE state )
2159 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2160 UINT r = MsiSetFeatureStateW(This->package, feature, state);
2161 return HRESULT_FROM_WIN32(r);
2164 static HRESULT WINAPI mrp_GetComponentState( IWineMsiRemotePackage *iface, BSTR component,
2165 INSTALLSTATE *installed, INSTALLSTATE *action )
2167 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2168 UINT r = MsiGetComponentStateW(This->package, component, installed, action);
2169 return HRESULT_FROM_WIN32(r);
2172 static HRESULT WINAPI mrp_SetComponentState( IWineMsiRemotePackage *iface, BSTR component, INSTALLSTATE state )
2174 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2175 UINT r = MsiSetComponentStateW(This->package, component, state);
2176 return HRESULT_FROM_WIN32(r);
2179 static HRESULT WINAPI mrp_GetLanguage( IWineMsiRemotePackage *iface, LANGID *language )
2181 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2182 *language = MsiGetLanguage(This->package);
2186 static HRESULT WINAPI mrp_SetInstallLevel( IWineMsiRemotePackage *iface, int level )
2188 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2189 UINT r = MsiSetInstallLevel(This->package, level);
2190 return HRESULT_FROM_WIN32(r);
2193 static HRESULT WINAPI mrp_FormatRecord( IWineMsiRemotePackage *iface, MSIHANDLE record,
2197 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2198 UINT r = MsiFormatRecordW(This->package, record, NULL, &size);
2199 if (r == ERROR_SUCCESS)
2201 *value = SysAllocStringLen(NULL, size);
2203 return E_OUTOFMEMORY;
2205 r = MsiFormatRecordW(This->package, record, *value, &size);
2207 return HRESULT_FROM_WIN32(r);
2210 static HRESULT WINAPI mrp_EvaluateCondition( IWineMsiRemotePackage *iface, BSTR condition )
2212 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2213 UINT r = MsiEvaluateConditionW(This->package, condition);
2214 return HRESULT_FROM_WIN32(r);
2217 static HRESULT WINAPI mrp_GetFeatureCost( IWineMsiRemotePackage *iface, BSTR feature,
2218 INT cost_tree, INSTALLSTATE state, INT *cost )
2220 msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
2221 UINT r = MsiGetFeatureCostW(This->package, feature, cost_tree, state, cost);
2222 return HRESULT_FROM_WIN32(r);
2225 static const IWineMsiRemotePackageVtbl msi_remote_package_vtbl =
2231 mrp_GetActiveDatabase,
2242 mrp_GetFeatureState,
2243 mrp_SetFeatureState,
2244 mrp_GetComponentState,
2245 mrp_SetComponentState,
2247 mrp_SetInstallLevel,
2249 mrp_EvaluateCondition,
2253 HRESULT create_msi_remote_package( IUnknown *pOuter, LPVOID *ppObj )
2255 msi_remote_package_impl* This;
2257 This = msi_alloc( sizeof *This );
2259 return E_OUTOFMEMORY;
2261 This->lpVtbl = &msi_remote_package_vtbl;
2270 UINT msi_package_add_info(MSIPACKAGE *package, DWORD context, DWORD options,
2271 LPCWSTR property, LPWSTR value)
2273 MSISOURCELISTINFO *info;
2275 info = msi_alloc(sizeof(MSISOURCELISTINFO));
2277 return ERROR_OUTOFMEMORY;
2279 info->context = context;
2280 info->options = options;
2281 info->property = property;
2282 info->value = strdupW(value);
2283 list_add_head(&package->sourcelist_info, &info->entry);
2285 return ERROR_SUCCESS;
2288 UINT msi_package_add_media_disk(MSIPACKAGE *package, DWORD context, DWORD options,
2289 DWORD disk_id, LPWSTR volume_label, LPWSTR disk_prompt)
2293 disk = msi_alloc(sizeof(MSIMEDIADISK));
2295 return ERROR_OUTOFMEMORY;
2297 disk->context = context;
2298 disk->options = options;
2299 disk->disk_id = disk_id;
2300 disk->volume_label = strdupW(volume_label);
2301 disk->disk_prompt = strdupW(disk_prompt);
2302 list_add_head(&package->sourcelist_media, &disk->entry);
2304 return ERROR_SUCCESS;