2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2008 James Hawkins
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
27 #include "wine/debug.h"
34 #include "wine/unicode.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
38 /* from msvcrt/fcntl.h */
42 #define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR)
43 #define _O_APPEND 0x0008
44 #define _O_RANDOM 0x0010
45 #define _O_SEQUENTIAL 0x0020
46 #define _O_TEMPORARY 0x0040
47 #define _O_NOINHERIT 0x0080
48 #define _O_CREAT 0x0100
49 #define _O_TRUNC 0x0200
50 #define _O_EXCL 0x0400
51 #define _O_SHORT_LIVED 0x1000
52 #define _O_TEXT 0x4000
53 #define _O_BINARY 0x8000
55 static BOOL
source_matches_volume(MSIMEDIAINFO
*mi
, LPCWSTR source_root
)
57 WCHAR volume_name
[MAX_PATH
+ 1];
58 WCHAR root
[MAX_PATH
+ 1];
60 strcpyW(root
, source_root
);
61 PathStripToRootW(root
);
62 PathAddBackslashW(root
);
64 if (!GetVolumeInformationW(root
, volume_name
, MAX_PATH
+ 1,
65 NULL
, NULL
, NULL
, NULL
, 0))
67 ERR("Failed to get volume information\n");
71 return !lstrcmpW(mi
->volume_label
, volume_name
);
74 static UINT
msi_change_media(MSIPACKAGE
*package
, MSIMEDIAINFO
*mi
)
76 LPWSTR error
, error_dialog
;
78 UINT r
= ERROR_SUCCESS
;
80 static const WCHAR error_prop
[] = {'E','r','r','o','r','D','i','a','l','o','g',0};
82 if ((msi_get_property_int(package
->db
, szUILevel
, 0) & INSTALLUILEVEL_MASK
) ==
83 INSTALLUILEVEL_NONE
&& !gUIHandlerA
&& !gUIHandlerW
&& !gUIHandlerRecord
)
86 error
= generate_error_string(package
, 1302, 1, mi
->disk_prompt
);
87 error_dialog
= msi_dup_property(package
->db
, error_prop
);
88 source_dir
= msi_dup_property(package
->db
, cszSourceDir
);
90 while (r
== ERROR_SUCCESS
&& !source_matches_volume(mi
, source_dir
))
92 r
= msi_spawn_error_dialog(package
, error_dialog
, error
);
96 gUIHandlerW(gUIContext
, MB_RETRYCANCEL
| INSTALLMESSAGE_ERROR
, error
);
100 char *msg
= strdupWtoA(error
);
101 gUIHandlerA(gUIContext
, MB_RETRYCANCEL
| INSTALLMESSAGE_ERROR
, msg
);
104 else if (gUIHandlerRecord
)
106 MSIHANDLE rec
= MsiCreateRecord(1);
107 MsiRecordSetStringW(rec
, 0, error
);
108 gUIHandlerRecord(gUIContext
, MB_RETRYCANCEL
| INSTALLMESSAGE_ERROR
, rec
);
114 msi_free(error_dialog
);
115 msi_free(source_dir
);
120 static void * CDECL
cabinet_alloc(ULONG cb
)
122 return msi_alloc(cb
);
125 static void CDECL
cabinet_free(void *pv
)
130 static INT_PTR CDECL
cabinet_open(char *pszFile
, int oflag
, int pmode
)
134 DWORD dwShareMode
= 0;
135 DWORD dwCreateDisposition
= OPEN_EXISTING
;
137 switch (oflag
& _O_ACCMODE
)
140 dwAccess
= GENERIC_READ
;
141 dwShareMode
= FILE_SHARE_READ
| FILE_SHARE_DELETE
;
144 dwAccess
= GENERIC_WRITE
;
145 dwShareMode
= FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
;
148 dwAccess
= GENERIC_READ
| GENERIC_WRITE
;
149 dwShareMode
= FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
;
153 if ((oflag
& (_O_CREAT
| _O_EXCL
)) == (_O_CREAT
| _O_EXCL
))
154 dwCreateDisposition
= CREATE_NEW
;
155 else if (oflag
& _O_CREAT
)
156 dwCreateDisposition
= CREATE_ALWAYS
;
158 handle
= CreateFileA(pszFile
, dwAccess
, dwShareMode
, NULL
,
159 dwCreateDisposition
, 0, NULL
);
160 if (handle
== INVALID_HANDLE_VALUE
)
163 return (INT_PTR
)handle
;
166 static UINT CDECL
cabinet_read(INT_PTR hf
, void *pv
, UINT cb
)
168 HANDLE handle
= (HANDLE
)hf
;
171 if (ReadFile(handle
, pv
, cb
, &read
, NULL
))
177 static UINT CDECL
cabinet_write(INT_PTR hf
, void *pv
, UINT cb
)
179 HANDLE handle
= (HANDLE
)hf
;
182 if (WriteFile(handle
, pv
, cb
, &written
, NULL
))
188 static int CDECL
cabinet_close(INT_PTR hf
)
190 HANDLE handle
= (HANDLE
)hf
;
191 return CloseHandle(handle
) ? 0 : -1;
194 static LONG CDECL
cabinet_seek(INT_PTR hf
, LONG dist
, int seektype
)
196 HANDLE handle
= (HANDLE
)hf
;
197 /* flags are compatible and so are passed straight through */
198 return SetFilePointer(handle
, dist
, NULL
, seektype
);
207 static struct cab_stream cab_stream
;
209 static INT_PTR CDECL
cabinet_open_stream( char *pszFile
, int oflag
, int pmode
)
215 WARN("ignoring open flags 0x%08x\n", oflag
);
217 r
= db_get_raw_stream( cab_stream
.db
, cab_stream
.name
, &stm
);
218 if (r
!= ERROR_SUCCESS
)
220 WARN("Failed to get cabinet stream %u\n", r
);
227 static UINT CDECL
cabinet_read_stream( INT_PTR hf
, void *pv
, UINT cb
)
229 IStream
*stm
= (IStream
*)hf
;
233 hr
= IStream_Read( stm
, pv
, cb
, &read
);
234 if (hr
== S_OK
|| hr
== S_FALSE
)
240 static int CDECL
cabinet_close_stream( INT_PTR hf
)
242 IStream
*stm
= (IStream
*)hf
;
243 IStream_Release( stm
);
247 static LONG CDECL
cabinet_seek_stream( INT_PTR hf
, LONG dist
, int seektype
)
249 IStream
*stm
= (IStream
*)hf
;
251 ULARGE_INTEGER newpos
;
254 move
.QuadPart
= dist
;
255 hr
= IStream_Seek( stm
, move
, seektype
, &newpos
);
258 if (newpos
.QuadPart
<= MAXLONG
) return newpos
.QuadPart
;
264 static UINT CDECL
msi_media_get_disk_info(MSIPACKAGE
*package
, MSIMEDIAINFO
*mi
)
268 static const WCHAR query
[] = {
269 'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
270 '`','M','e','d','i','a','`',' ','W','H','E','R','E',' ',
271 '`','D','i','s','k','I','d','`',' ','=',' ','%','i',0};
273 row
= MSI_QueryGetRecord(package
->db
, query
, mi
->disk_id
);
276 TRACE("Unable to query row\n");
277 return ERROR_FUNCTION_FAILED
;
280 mi
->disk_prompt
= strdupW(MSI_RecordGetString(row
, 3));
281 mi
->cabinet
= strdupW(MSI_RecordGetString(row
, 4));
282 mi
->volume_label
= strdupW(MSI_RecordGetString(row
, 5));
284 if (!mi
->first_volume
)
285 mi
->first_volume
= strdupW(mi
->volume_label
);
287 msiobj_release(&row
->hdr
);
288 return ERROR_SUCCESS
;
291 static INT_PTR
cabinet_partial_file(FDINOTIFICATIONTYPE fdint
,
292 PFDINOTIFICATION pfdin
)
294 MSICABDATA
*data
= pfdin
->pv
;
295 data
->mi
->is_continuous
= FALSE
;
299 static WCHAR
*get_cabinet_filename(MSIMEDIAINFO
*mi
)
304 len
= strlenW(mi
->sourcedir
) + strlenW(mi
->cabinet
) + 1;
305 if (!(ret
= msi_alloc(len
* sizeof(WCHAR
)))) return NULL
;
306 strcpyW(ret
, mi
->sourcedir
);
307 strcatW(ret
, mi
->cabinet
);
311 static INT_PTR
cabinet_next_cabinet(FDINOTIFICATIONTYPE fdint
,
312 PFDINOTIFICATION pfdin
)
314 MSICABDATA
*data
= pfdin
->pv
;
315 MSIMEDIAINFO
*mi
= data
->mi
;
316 LPWSTR cabinet_file
= NULL
, cab
= strdupAtoW(pfdin
->psz1
);
320 msi_free(mi
->disk_prompt
);
321 msi_free(mi
->cabinet
);
322 msi_free(mi
->volume_label
);
323 mi
->disk_prompt
= NULL
;
325 mi
->volume_label
= NULL
;
328 mi
->is_continuous
= TRUE
;
330 rc
= msi_media_get_disk_info(data
->package
, mi
);
331 if (rc
!= ERROR_SUCCESS
)
333 ERR("Failed to get next cabinet information: %d\n", rc
);
337 if (lstrcmpiW(mi
->cabinet
, cab
))
339 ERR("Continuous cabinet does not match the next cabinet in the Media table\n");
343 if (!(cabinet_file
= get_cabinet_filename(mi
)))
346 TRACE("Searching for %s\n", debugstr_w(cabinet_file
));
349 if (GetFileAttributesW(cabinet_file
) == INVALID_FILE_ATTRIBUTES
)
351 if (msi_change_media(data
->package
, mi
) != ERROR_SUCCESS
)
357 msi_free(cabinet_file
);
361 static INT_PTR
cabinet_copy_file(FDINOTIFICATIONTYPE fdint
,
362 PFDINOTIFICATION pfdin
)
364 MSICABDATA
*data
= pfdin
->pv
;
369 data
->curfile
= strdupAtoW(pfdin
->psz1
);
370 if (!data
->cb(data
->package
, data
->curfile
, MSICABEXTRACT_BEGINEXTRACT
, &path
,
373 /* We're not extracting this file, so free the filename. */
374 msi_free(data
->curfile
);
375 data
->curfile
= NULL
;
379 TRACE("extracting %s\n", debugstr_w(path
));
381 attrs
= attrs
& (FILE_ATTRIBUTE_READONLY
|FILE_ATTRIBUTE_HIDDEN
|FILE_ATTRIBUTE_SYSTEM
);
382 if (!attrs
) attrs
= FILE_ATTRIBUTE_NORMAL
;
384 handle
= CreateFileW(path
, GENERIC_READ
| GENERIC_WRITE
, 0,
385 NULL
, CREATE_ALWAYS
, attrs
, NULL
);
386 if (handle
== INVALID_HANDLE_VALUE
)
388 DWORD err
= GetLastError();
389 DWORD attrs2
= GetFileAttributesW(path
);
391 if (attrs2
== INVALID_FILE_ATTRIBUTES
)
393 ERR("failed to create %s (error %d)\n", debugstr_w(path
), err
);
396 else if (err
== ERROR_ACCESS_DENIED
&& (attrs2
& FILE_ATTRIBUTE_READONLY
))
398 TRACE("removing read-only attribute on %s\n", debugstr_w(path
));
399 SetFileAttributesW( path
, attrs2
& ~FILE_ATTRIBUTE_READONLY
);
400 handle
= CreateFileW(path
, GENERIC_READ
| GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, attrs2
, NULL
);
402 if (handle
!= INVALID_HANDLE_VALUE
) goto done
;
403 err
= GetLastError();
405 if (err
== ERROR_SHARING_VIOLATION
|| err
== ERROR_USER_MAPPED_FILE
)
407 WCHAR tmpfileW
[MAX_PATH
], *tmppathW
, *p
;
410 TRACE("file in use, scheduling rename operation\n");
412 GetTempFileNameW(szBackSlash
, szMsi
, 0, tmpfileW
);
413 len
= strlenW(path
) + strlenW(tmpfileW
) + 1;
414 if (!(tmppathW
= msi_alloc(len
* sizeof(WCHAR
))))
415 return ERROR_OUTOFMEMORY
;
417 strcpyW(tmppathW
, path
);
418 if ((p
= strrchrW(tmppathW
, '\\'))) *p
= 0;
419 strcatW(tmppathW
, tmpfileW
);
421 handle
= CreateFileW(tmppathW
, GENERIC_READ
| GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, attrs
, NULL
);
423 if (handle
!= INVALID_HANDLE_VALUE
&&
424 MoveFileExW(path
, NULL
, MOVEFILE_DELAY_UNTIL_REBOOT
) &&
425 MoveFileExW(tmppathW
, path
, MOVEFILE_DELAY_UNTIL_REBOOT
))
427 data
->package
->need_reboot
= 1;
430 WARN("failed to schedule rename operation %s (error %d)\n", debugstr_w(path
), GetLastError());
435 WARN("failed to create %s (error %d)\n", debugstr_w(path
), err
);
441 return (INT_PTR
)handle
;
444 static INT_PTR
cabinet_close_file_info(FDINOTIFICATIONTYPE fdint
,
445 PFDINOTIFICATION pfdin
)
447 MSICABDATA
*data
= pfdin
->pv
;
450 HANDLE handle
= (HANDLE
)pfdin
->hf
;
452 data
->mi
->is_continuous
= FALSE
;
454 if (!DosDateTimeToFileTime(pfdin
->date
, pfdin
->time
, &ft
))
456 if (!LocalFileTimeToFileTime(&ft
, &ftLocal
))
458 if (!SetFileTime(handle
, &ftLocal
, 0, &ftLocal
))
463 data
->cb(data
->package
, data
->curfile
, MSICABEXTRACT_FILEEXTRACTED
, NULL
, NULL
,
466 msi_free(data
->curfile
);
467 data
->curfile
= NULL
;
472 static INT_PTR CDECL
cabinet_notify(FDINOTIFICATIONTYPE fdint
, PFDINOTIFICATION pfdin
)
476 case fdintPARTIAL_FILE
:
477 return cabinet_partial_file(fdint
, pfdin
);
479 case fdintNEXT_CABINET
:
480 return cabinet_next_cabinet(fdint
, pfdin
);
483 return cabinet_copy_file(fdint
, pfdin
);
485 case fdintCLOSE_FILE_INFO
:
486 return cabinet_close_file_info(fdint
, pfdin
);
493 static INT_PTR CDECL
cabinet_notify_stream( FDINOTIFICATIONTYPE fdint
, PFDINOTIFICATION pfdin
)
498 return cabinet_copy_file( fdint
, pfdin
);
500 case fdintCLOSE_FILE_INFO
:
501 return cabinet_close_file_info( fdint
, pfdin
);
503 case fdintCABINET_INFO
:
507 ERR("Unexpected notification %d\n", fdint
);
512 static BOOL
extract_cabinet( MSIPACKAGE
* package
, MSIMEDIAINFO
*mi
, LPVOID data
)
514 LPSTR cabinet
, cab_path
= NULL
;
519 TRACE("Extracting %s\n", debugstr_w(mi
->cabinet
));
521 hfdi
= FDICreate( cabinet_alloc
, cabinet_free
, cabinet_open
, cabinet_read
,
522 cabinet_write
, cabinet_close
, cabinet_seek
, 0, &erf
);
525 ERR("FDICreate failed\n");
529 cabinet
= strdupWtoA( mi
->cabinet
);
533 cab_path
= strdupWtoA( mi
->sourcedir
);
537 ret
= FDICopy( hfdi
, cabinet
, cab_path
, 0, cabinet_notify
, NULL
, data
);
539 ERR("FDICopy failed\n");
544 msi_free( cab_path
);
547 mi
->is_extracted
= TRUE
;
552 static BOOL
extract_cabinet_stream( MSIPACKAGE
*package
, MSIMEDIAINFO
*mi
, LPVOID data
)
554 static char filename
[] = {'<','S','T','R','E','A','M','>',0};
559 TRACE("Extracting %s\n", debugstr_w(mi
->cabinet
));
561 hfdi
= FDICreate( cabinet_alloc
, cabinet_free
, cabinet_open_stream
, cabinet_read_stream
,
562 cabinet_write
, cabinet_close_stream
, cabinet_seek_stream
, 0, &erf
);
565 ERR("FDICreate failed\n");
569 cab_stream
.db
= package
->db
;
570 cab_stream
.name
= encode_streamname( FALSE
, mi
->cabinet
+ 1 );
571 if (!cab_stream
.name
)
574 ret
= FDICopy( hfdi
, filename
, NULL
, 0, cabinet_notify_stream
, NULL
, data
);
576 ERR("FDICopy failed\n");
580 msi_free( cab_stream
.name
);
583 mi
->is_extracted
= TRUE
;
588 /***********************************************************************
591 * Extract files from a cabinet file or stream.
593 BOOL
msi_cabextract(MSIPACKAGE
* package
, MSIMEDIAINFO
*mi
, LPVOID data
)
595 if (mi
->cabinet
[0] == '#')
597 return extract_cabinet_stream( package
, mi
, data
);
599 return extract_cabinet( package
, mi
, data
);
602 void msi_free_media_info(MSIMEDIAINFO
*mi
)
604 msi_free(mi
->disk_prompt
);
605 msi_free(mi
->cabinet
);
606 msi_free(mi
->volume_label
);
607 msi_free(mi
->first_volume
);
611 static UINT
get_drive_type(const WCHAR
*path
)
613 WCHAR root
[MAX_PATH
+ 1];
616 PathStripToRootW(root
);
617 PathAddBackslashW(root
);
619 return GetDriveTypeW(root
);
622 static UINT
msi_load_media_info(MSIPACKAGE
*package
, MSIFILE
*file
, MSIMEDIAINFO
*mi
)
629 static const WCHAR query
[] = {
630 'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
631 '`','M','e','d','i','a','`',' ','W','H','E','R','E',' ',
632 '`','L','a','s','t','S','e','q','u','e','n','c','e','`',' ','>','=',' ','%','i',
633 ' ','O','R','D','E','R',' ','B','Y',' ','`','D','i','s','k','I','d','`',0};
635 row
= MSI_QueryGetRecord(package
->db
, query
, file
->Sequence
);
638 TRACE("Unable to query row\n");
639 return ERROR_FUNCTION_FAILED
;
642 mi
->is_extracted
= FALSE
;
643 mi
->disk_id
= MSI_RecordGetInteger(row
, 1);
644 mi
->last_sequence
= MSI_RecordGetInteger(row
, 2);
645 msi_free(mi
->disk_prompt
);
646 mi
->disk_prompt
= strdupW(MSI_RecordGetString(row
, 3));
647 msi_free(mi
->cabinet
);
648 mi
->cabinet
= strdupW(MSI_RecordGetString(row
, 4));
649 msi_free(mi
->volume_label
);
650 mi
->volume_label
= strdupW(MSI_RecordGetString(row
, 5));
651 msiobj_release(&row
->hdr
);
653 if (!mi
->first_volume
)
654 mi
->first_volume
= strdupW(mi
->volume_label
);
656 source_dir
= msi_dup_property(package
->db
, cszSourceDir
);
657 lstrcpyW(mi
->sourcedir
, source_dir
);
658 mi
->type
= get_drive_type(source_dir
);
660 options
= MSICODE_PRODUCT
;
661 if (mi
->type
== DRIVE_CDROM
|| mi
->type
== DRIVE_REMOVABLE
)
664 options
|= MSISOURCETYPE_MEDIA
;
666 else if (package
->BaseURL
&& UrlIsW(package
->BaseURL
, URLIS_URL
))
668 source
= package
->BaseURL
;
669 options
|= MSISOURCETYPE_URL
;
673 source
= mi
->sourcedir
;
674 options
|= MSISOURCETYPE_NETWORK
;
677 msi_package_add_media_disk(package
, package
->Context
,
678 MSICODE_PRODUCT
, mi
->disk_id
,
679 mi
->volume_label
, mi
->disk_prompt
);
681 msi_package_add_info(package
, package
->Context
,
682 options
, INSTALLPROPERTY_LASTUSEDSOURCEW
, source
);
684 msi_free(source_dir
);
685 return ERROR_SUCCESS
;
688 /* FIXME: search URL sources as well */
689 static UINT
find_published_source(MSIPACKAGE
*package
, MSIMEDIAINFO
*mi
)
691 WCHAR source
[MAX_PATH
];
692 WCHAR volume
[MAX_PATH
];
693 WCHAR prompt
[MAX_PATH
];
694 DWORD volumesz
, promptsz
;
695 DWORD index
, size
, id
;
700 r
= MsiSourceListGetInfoW(package
->ProductCode
, NULL
,
701 package
->Context
, MSICODE_PRODUCT
,
702 INSTALLPROPERTY_LASTUSEDTYPEW
, last_type
, &size
);
703 if (r
!= ERROR_SUCCESS
)
707 r
= MsiSourceListGetInfoW(package
->ProductCode
, NULL
,
708 package
->Context
, MSICODE_PRODUCT
,
709 INSTALLPROPERTY_LASTUSEDSOURCEW
, source
, &size
);
710 if (r
!= ERROR_SUCCESS
)
717 if (last_type
[0] == 'n')
719 while (MsiSourceListEnumSourcesW(package
->ProductCode
, NULL
,
721 MSISOURCETYPE_NETWORK
, index
++,
722 volume
, &volumesz
) == ERROR_SUCCESS
)
724 if (!strncmpiW(source
, volume
, strlenW(source
)))
726 lstrcpyW(mi
->sourcedir
, source
);
727 TRACE("Found network source %s\n", debugstr_w(mi
->sourcedir
));
728 return ERROR_SUCCESS
;
736 while (MsiSourceListEnumMediaDisksW(package
->ProductCode
, NULL
,
738 MSICODE_PRODUCT
, index
++, &id
,
739 volume
, &volumesz
, prompt
, &promptsz
) == ERROR_SUCCESS
)
742 mi
->volume_label
= msi_realloc(mi
->volume_label
, ++volumesz
* sizeof(WCHAR
));
743 lstrcpyW(mi
->volume_label
, volume
);
744 mi
->disk_prompt
= msi_realloc(mi
->disk_prompt
, ++promptsz
* sizeof(WCHAR
));
745 lstrcpyW(mi
->disk_prompt
, prompt
);
747 if (source_matches_volume(mi
, source
))
749 /* FIXME: what about SourceDir */
750 lstrcpyW(mi
->sourcedir
, source
);
751 TRACE("Found disk source %s\n", debugstr_w(mi
->sourcedir
));
752 return ERROR_SUCCESS
;
756 return ERROR_FUNCTION_FAILED
;
759 UINT
ready_media(MSIPACKAGE
*package
, MSIFILE
*file
, MSIMEDIAINFO
*mi
)
761 UINT rc
= ERROR_SUCCESS
;
764 /* media info for continuous cabinet is already loaded */
765 if (mi
->is_continuous
)
766 return ERROR_SUCCESS
;
768 rc
= msi_load_media_info(package
, file
, mi
);
769 if (rc
!= ERROR_SUCCESS
)
771 ERR("Unable to load media info %u\n", rc
);
772 return ERROR_FUNCTION_FAILED
;
775 /* cabinet is internal, no checks needed */
776 if (!mi
->cabinet
|| mi
->cabinet
[0] == '#')
777 return ERROR_SUCCESS
;
779 cabinet_file
= get_cabinet_filename(mi
);
781 /* package should be downloaded */
782 if (file
->IsCompressed
&&
783 GetFileAttributesW(cabinet_file
) == INVALID_FILE_ATTRIBUTES
&&
784 package
->BaseURL
&& UrlIsW(package
->BaseURL
, URLIS_URL
))
786 WCHAR temppath
[MAX_PATH
], *p
;
788 msi_download_file(cabinet_file
, temppath
);
789 if ((p
= strrchrW(temppath
, '\\'))) *p
= 0;
791 msi_free(mi
->sourcedir
);
792 strcpyW(mi
->sourcedir
, temppath
);
793 msi_free(mi
->cabinet
);
794 strcpyW(mi
->cabinet
, p
+ 1);
796 msi_free(cabinet_file
);
797 return ERROR_SUCCESS
;
800 /* check volume matches, change media if not */
801 if (mi
->volume_label
&& mi
->disk_id
> 1 &&
802 lstrcmpW(mi
->first_volume
, mi
->volume_label
))
804 LPWSTR source
= msi_dup_property(package
->db
, cszSourceDir
);
807 matches
= source_matches_volume(mi
, source
);
810 if ((mi
->type
== DRIVE_CDROM
|| mi
->type
== DRIVE_REMOVABLE
) && !matches
)
812 rc
= msi_change_media(package
, mi
);
813 if (rc
!= ERROR_SUCCESS
)
815 msi_free(cabinet_file
);
821 if (file
->IsCompressed
&&
822 GetFileAttributesW(cabinet_file
) == INVALID_FILE_ATTRIBUTES
)
824 rc
= find_published_source(package
, mi
);
825 if (rc
!= ERROR_SUCCESS
)
827 ERR("Cabinet not found: %s\n", debugstr_w(cabinet_file
));
828 msi_free(cabinet_file
);
829 return ERROR_INSTALL_FAILURE
;
833 msi_free(cabinet_file
);
834 return ERROR_SUCCESS
;