2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2005 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
22 * Actions dealing with files:
28 * RemoveDuplicateFiles
47 #include "wine/debug.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
51 BOOL
msi_get_temp_file_name( MSIPACKAGE
*package
, const WCHAR
*tmp_path
, const WCHAR
*prefix
, WCHAR
*tmp_filename
)
54 msi_disable_fs_redirection( package
);
55 ret
= GetTempFileNameW( tmp_path
, prefix
, 0, tmp_filename
);
56 msi_revert_fs_redirection( package
);
60 HANDLE
msi_create_file( MSIPACKAGE
*package
, const WCHAR
*filename
, DWORD access
, DWORD sharing
, DWORD creation
,
64 msi_disable_fs_redirection( package
);
65 handle
= CreateFileW( filename
, access
, sharing
, NULL
, creation
, flags
, NULL
);
66 msi_revert_fs_redirection( package
);
70 static BOOL
copy_file( MSIPACKAGE
*package
, const WCHAR
*src
, const WCHAR
*dst
, BOOL fail_if_exists
)
73 msi_disable_fs_redirection( package
);
74 ret
= CopyFileW( src
, dst
, fail_if_exists
);
75 msi_revert_fs_redirection( package
);
79 BOOL
msi_delete_file( MSIPACKAGE
*package
, const WCHAR
*filename
)
82 msi_disable_fs_redirection( package
);
83 ret
= DeleteFileW( filename
);
84 msi_revert_fs_redirection( package
);
88 static BOOL
create_directory( MSIPACKAGE
*package
, const WCHAR
*path
)
91 msi_disable_fs_redirection( package
);
92 ret
= CreateDirectoryW( path
, NULL
);
93 msi_revert_fs_redirection( package
);
97 BOOL
msi_remove_directory( MSIPACKAGE
*package
, const WCHAR
*path
)
100 msi_disable_fs_redirection( package
);
101 ret
= RemoveDirectoryW( path
);
102 msi_revert_fs_redirection( package
);
106 BOOL
msi_set_file_attributes( MSIPACKAGE
*package
, const WCHAR
*filename
, DWORD attrs
)
109 msi_disable_fs_redirection( package
);
110 ret
= SetFileAttributesW( filename
, attrs
);
111 msi_revert_fs_redirection( package
);
115 DWORD
msi_get_file_attributes( MSIPACKAGE
*package
, const WCHAR
*path
)
118 msi_disable_fs_redirection( package
);
119 attrs
= GetFileAttributesW( path
);
120 msi_revert_fs_redirection( package
);
124 HANDLE
msi_find_first_file( MSIPACKAGE
*package
, const WCHAR
*filename
, WIN32_FIND_DATAW
*data
)
127 msi_disable_fs_redirection( package
);
128 handle
= FindFirstFileW( filename
, data
);
129 msi_revert_fs_redirection( package
);
133 BOOL
msi_find_next_file( MSIPACKAGE
*package
, HANDLE handle
, WIN32_FIND_DATAW
*data
)
136 msi_disable_fs_redirection( package
);
137 ret
= FindNextFileW( handle
, data
);
138 msi_revert_fs_redirection( package
);
142 BOOL
msi_move_file( MSIPACKAGE
*package
, const WCHAR
*from
, const WCHAR
*to
, DWORD flags
)
145 msi_disable_fs_redirection( package
);
146 ret
= MoveFileExW( from
, to
, flags
);
147 msi_revert_fs_redirection( package
);
151 static BOOL
apply_filepatch( MSIPACKAGE
*package
, const WCHAR
*patch
, const WCHAR
*old
, const WCHAR
*new )
154 msi_disable_fs_redirection( package
);
155 ret
= ApplyPatchToFileW( patch
, old
, new, 0 );
156 msi_revert_fs_redirection( package
);
160 DWORD
msi_get_file_version_info( MSIPACKAGE
*package
, const WCHAR
*path
, DWORD buflen
, BYTE
*buffer
)
163 msi_disable_fs_redirection( package
);
164 if (buffer
) size
= GetFileVersionInfoW( path
, 0, buflen
, buffer
);
165 else size
= GetFileVersionInfoSizeW( path
, &handle
);
166 msi_revert_fs_redirection( package
);
170 VS_FIXEDFILEINFO
*msi_get_disk_file_version( MSIPACKAGE
*package
, const WCHAR
*filename
)
172 VS_FIXEDFILEINFO
*ptr
, *ret
;
177 if (!(version_size
= msi_get_file_version_info( package
, filename
, 0, NULL
))) return NULL
;
178 if (!(version
= malloc( version_size
))) return NULL
;
180 msi_get_file_version_info( package
, filename
, version_size
, version
);
182 if (!VerQueryValueW( version
, L
"\\", (void **)&ptr
, &size
))
188 if (!(ret
= malloc( size
)))
194 memcpy( ret
, ptr
, size
);
199 DWORD
msi_get_disk_file_size( MSIPACKAGE
*package
, const WCHAR
*filename
)
203 file
= msi_create_file( package
, filename
, GENERIC_READ
, FILE_SHARE_READ
, OPEN_EXISTING
, 0 );
204 if (file
== INVALID_HANDLE_VALUE
) return INVALID_FILE_SIZE
;
205 size
= GetFileSize( file
, NULL
);
210 /* Recursively create all directories in the path. */
211 BOOL
msi_create_full_path( MSIPACKAGE
*package
, const WCHAR
*path
)
217 if (!(new_path
= malloc( (wcslen( path
) + 1) * sizeof(WCHAR
) ))) return FALSE
;
218 lstrcpyW( new_path
, path
);
220 while ((len
= lstrlenW( new_path
)) && new_path
[len
- 1] == '\\')
221 new_path
[len
- 1] = 0;
223 while (!create_directory( package
, new_path
))
226 DWORD last_error
= GetLastError();
227 if (last_error
== ERROR_ALREADY_EXISTS
) break;
228 if (last_error
!= ERROR_PATH_NOT_FOUND
)
233 if (!(slash
= wcsrchr( new_path
, '\\' )))
238 len
= slash
- new_path
;
240 if (!msi_create_full_path( package
, new_path
))
245 new_path
[len
] = '\\';
251 static void file_update_ui( MSIPACKAGE
*package
, MSIFILE
*f
, const WCHAR
*action
)
255 uirow
= MSI_CreateRecord( 9 );
256 MSI_RecordSetStringW( uirow
, 1, f
->FileName
);
257 MSI_RecordSetStringW( uirow
, 9, f
->Component
->Directory
);
258 MSI_RecordSetInteger( uirow
, 6, f
->FileSize
);
259 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONDATA
, uirow
);
260 msiobj_release( &uirow
->hdr
);
261 msi_ui_progress( package
, 2, f
->FileSize
, 0, 0 );
264 static BOOL
is_registered_patch_media( MSIPACKAGE
*package
, UINT disk_id
)
268 LIST_FOR_EACH_ENTRY( patch
, &package
->patches
, MSIPATCHINFO
, entry
)
270 if (patch
->disk_id
== disk_id
&& patch
->registered
) return TRUE
;
275 static BOOL
is_obsoleted_by_patch( MSIPACKAGE
*package
, MSIFILE
*file
)
277 if (!list_empty( &package
->patches
) && file
->disk_id
< MSI_INITIAL_MEDIA_TRANSFORM_DISKID
)
279 if (!msi_get_property_int( package
->db
, L
"Installed", 0 )) return FALSE
;
282 if (is_registered_patch_media( package
, file
->disk_id
)) return TRUE
;
286 static BOOL
file_hash_matches( MSIPACKAGE
*package
, MSIFILE
*file
)
289 MSIFILEHASHINFO hash
;
291 hash
.dwFileHashInfoSize
= sizeof(hash
);
292 r
= msi_get_filehash( package
, file
->TargetPath
, &hash
);
293 if (r
!= ERROR_SUCCESS
)
296 return !memcmp( &hash
, &file
->hash
, sizeof(hash
) );
299 static msi_file_state
calculate_install_state( MSIPACKAGE
*package
, MSIFILE
*file
)
301 MSICOMPONENT
*comp
= file
->Component
;
302 VS_FIXEDFILEINFO
*file_version
;
304 msi_file_state state
;
307 comp
->Action
= msi_get_component_action( package
, comp
);
308 if (!comp
->Enabled
|| comp
->Action
!= INSTALLSTATE_LOCAL
)
310 TRACE("skipping %s (not scheduled for install)\n", debugstr_w(file
->File
));
311 return msifs_skipped
;
313 if (is_obsoleted_by_patch( package
, file
))
315 TRACE("skipping %s (obsoleted by patch)\n", debugstr_w(file
->File
));
316 return msifs_skipped
;
318 if (msi_get_file_attributes( package
, file
->TargetPath
) == INVALID_FILE_ATTRIBUTES
)
320 TRACE("installing %s (missing)\n", debugstr_w(file
->File
));
321 return msifs_missing
;
325 if ((file_version
= msi_get_disk_file_version( package
, file
->TargetPath
)))
327 if (msi_compare_file_versions( file_version
, file
->Version
) < 0)
329 TRACE("overwriting %s (new version %s old version %u.%u.%u.%u)\n",
330 debugstr_w(file
->File
), debugstr_w(file
->Version
),
331 HIWORD(file_version
->dwFileVersionMS
), LOWORD(file_version
->dwFileVersionMS
),
332 HIWORD(file_version
->dwFileVersionLS
), LOWORD(file_version
->dwFileVersionLS
));
333 state
= msifs_overwrite
;
337 TRACE("keeping %s (new version %s old version %u.%u.%u.%u)\n",
338 debugstr_w(file
->File
), debugstr_w(file
->Version
),
339 HIWORD(file_version
->dwFileVersionMS
), LOWORD(file_version
->dwFileVersionMS
),
340 HIWORD(file_version
->dwFileVersionLS
), LOWORD(file_version
->dwFileVersionLS
));
341 state
= msifs_present
;
343 free( file_version
);
346 else if ((font_version
= msi_get_font_file_version( package
, file
->TargetPath
)))
348 if (msi_compare_font_versions( font_version
, file
->Version
) < 0)
350 TRACE("overwriting %s (new version %s old version %s)\n",
351 debugstr_w(file
->File
), debugstr_w(file
->Version
), debugstr_w(font_version
));
352 state
= msifs_overwrite
;
356 TRACE("keeping %s (new version %s old version %s)\n",
357 debugstr_w(file
->File
), debugstr_w(file
->Version
), debugstr_w(font_version
));
358 state
= msifs_present
;
360 free( font_version
);
364 if ((size
= msi_get_disk_file_size( package
, file
->TargetPath
)) != file
->FileSize
)
366 TRACE("overwriting %s (old size %lu new size %d)\n", debugstr_w(file
->File
), size
, file
->FileSize
);
367 return msifs_overwrite
;
369 if (file
->hash
.dwFileHashInfoSize
)
371 if (file_hash_matches( package
, file
))
373 TRACE("keeping %s (hash match)\n", debugstr_w(file
->File
));
374 return msifs_hashmatch
;
378 TRACE("overwriting %s (hash mismatch)\n", debugstr_w(file
->File
));
379 return msifs_overwrite
;
383 TRACE("keeping %s\n", debugstr_w(file
->File
));
384 return msifs_present
;
387 static void schedule_install_files(MSIPACKAGE
*package
)
391 LIST_FOR_EACH_ENTRY(file
, &package
->files
, MSIFILE
, entry
)
393 MSICOMPONENT
*comp
= file
->Component
;
395 file
->state
= calculate_install_state( package
, file
);
396 if (file
->state
== msifs_overwrite
&& (comp
->Attributes
& msidbComponentAttributesNeverOverwrite
))
398 TRACE("not overwriting %s\n", debugstr_w(file
->TargetPath
));
399 file
->state
= msifs_skipped
;
404 static UINT
copy_file_attributes( MSIPACKAGE
*package
, MSIFILE
*file
, WCHAR
*source
)
408 ret
= copy_file( package
, source
, file
->TargetPath
, FALSE
);
410 return GetLastError();
412 msi_set_file_attributes( package
, file
->TargetPath
, FILE_ATTRIBUTE_NORMAL
);
413 return ERROR_SUCCESS
;
416 static UINT
copy_install_file(MSIPACKAGE
*package
, MSIFILE
*file
, LPWSTR source
)
420 TRACE("Copying %s to %s\n", debugstr_w(source
), debugstr_w(file
->TargetPath
));
422 gle
= copy_file_attributes( package
, file
, source
);
423 if (gle
== ERROR_SUCCESS
)
426 if (gle
== ERROR_ALREADY_EXISTS
&& file
->state
== msifs_overwrite
)
428 TRACE("overwriting existing file\n");
429 return ERROR_SUCCESS
;
431 else if (gle
== ERROR_ACCESS_DENIED
)
433 msi_set_file_attributes( package
, file
->TargetPath
, FILE_ATTRIBUTE_NORMAL
);
435 gle
= copy_file_attributes( package
, file
, source
);
436 TRACE("Overwriting existing file: %d\n", gle
);
438 if (gle
== ERROR_SHARING_VIOLATION
|| gle
== ERROR_USER_MAPPED_FILE
)
440 WCHAR
*tmpfileW
, *pathW
, *p
;
443 TRACE("file in use, scheduling rename operation\n");
445 if (!(pathW
= wcsdup( file
->TargetPath
))) return ERROR_OUTOFMEMORY
;
446 if ((p
= wcsrchr(pathW
, '\\'))) *p
= 0;
447 len
= lstrlenW( pathW
) + 16;
448 if (!(tmpfileW
= malloc(len
* sizeof(WCHAR
))))
451 return ERROR_OUTOFMEMORY
;
453 if (!GetTempFileNameW( pathW
, L
"msi", 0, tmpfileW
)) tmpfileW
[0] = 0;
456 if (copy_file( package
, source
, tmpfileW
, FALSE
) &&
457 msi_move_file( package
, file
->TargetPath
, NULL
, MOVEFILE_DELAY_UNTIL_REBOOT
) &&
458 msi_move_file( package
, tmpfileW
, file
->TargetPath
, MOVEFILE_DELAY_UNTIL_REBOOT
))
460 package
->need_reboot_at_end
= 1;
465 gle
= GetLastError();
466 WARN("failed to schedule rename operation: %d)\n", gle
);
467 DeleteFileW( tmpfileW
);
475 static UINT
create_folder( MSIPACKAGE
*package
, const WCHAR
*dir
)
478 const WCHAR
*install_path
;
480 install_path
= msi_get_target_folder( package
, dir
);
481 if (!install_path
) return ERROR_FUNCTION_FAILED
;
483 folder
= msi_get_loaded_folder( package
, dir
);
484 if (folder
->State
== FOLDER_STATE_UNINITIALIZED
)
486 msi_create_full_path( package
, install_path
);
487 folder
->State
= FOLDER_STATE_CREATED
;
489 return ERROR_SUCCESS
;
492 static MSIFILE
*find_file( MSIPACKAGE
*package
, UINT disk_id
, const WCHAR
*filename
)
496 LIST_FOR_EACH_ENTRY( file
, &package
->files
, MSIFILE
, entry
)
498 if (file
->disk_id
== disk_id
&&
499 file
->state
!= msifs_installed
&&
500 !wcsicmp( filename
, file
->File
)) return file
;
505 static BOOL
installfiles_cb(MSIPACKAGE
*package
, LPCWSTR filename
, DWORD action
,
506 LPWSTR
*path
, DWORD
*attrs
, PVOID user
)
508 MSIFILE
*file
= *(MSIFILE
**)user
;
510 if (action
== MSICABEXTRACT_BEGINEXTRACT
)
512 if (!(file
= find_file( package
, file
->disk_id
, filename
)))
514 TRACE("unknown file in cabinet (%s)\n", debugstr_w(filename
));
517 if (file
->state
!= msifs_missing
&& file
->state
!= msifs_overwrite
)
520 if (!msi_is_global_assembly( file
->Component
))
522 create_folder( package
, file
->Component
->Directory
);
524 *path
= wcsdup( file
->TargetPath
);
525 *attrs
= file
->Attributes
;
526 *(MSIFILE
**)user
= file
;
528 else if (action
== MSICABEXTRACT_FILEEXTRACTED
)
530 if (!msi_is_global_assembly( file
->Component
)) file
->state
= msifs_installed
;
536 WCHAR
*msi_resolve_file_source( MSIPACKAGE
*package
, MSIFILE
*file
)
540 TRACE("Working to resolve source of file %s\n", debugstr_w(file
->File
));
542 if (file
->IsCompressed
) return NULL
;
544 p
= msi_resolve_source_folder( package
, file
->Component
->Directory
, NULL
);
545 path
= msi_build_directory_name( 2, p
, file
->ShortName
);
547 if (file
->LongName
&& msi_get_file_attributes( package
, path
) == INVALID_FILE_ATTRIBUTES
)
550 path
= msi_build_directory_name( 2, p
, file
->LongName
);
553 TRACE("file %s source resolves to %s\n", debugstr_w(file
->File
), debugstr_w(path
));
558 * ACTION_InstallFiles()
560 * For efficiency, this is done in two passes:
561 * 1) Correct all the TargetPaths and determine what files are to be installed.
562 * 2) Extract Cabinets and copy files.
564 UINT
ACTION_InstallFiles(MSIPACKAGE
*package
)
567 UINT rc
= ERROR_SUCCESS
;
570 msi_set_sourcedir_props(package
, FALSE
);
572 if (package
->script
== SCRIPT_NONE
)
573 return msi_schedule_action(package
, SCRIPT_INSTALL
, L
"InstallFiles");
575 schedule_install_files(package
);
576 mi
= calloc(1, sizeof(MSIMEDIAINFO
));
578 LIST_FOR_EACH_ENTRY( file
, &package
->files
, MSIFILE
, entry
)
580 BOOL is_global_assembly
= msi_is_global_assembly( file
->Component
);
582 file_update_ui( package
, file
, L
"InstallFiles" );
584 rc
= msi_load_media_info( package
, file
->Sequence
, mi
);
585 if (rc
!= ERROR_SUCCESS
)
587 ERR("Unable to load media info for %s (%u)\n", debugstr_w(file
->File
), rc
);
588 rc
= ERROR_FUNCTION_FAILED
;
592 if (file
->state
!= msifs_hashmatch
&&
593 file
->state
!= msifs_skipped
&&
594 (file
->state
!= msifs_present
|| !msi_get_property_int( package
->db
, L
"Installed", 0 )) &&
595 (rc
= ready_media( package
, file
->IsCompressed
, mi
)))
597 ERR("Failed to ready media for %s\n", debugstr_w(file
->File
));
601 if (file
->state
!= msifs_missing
&& !mi
->is_continuous
&& file
->state
!= msifs_overwrite
)
604 if (file
->Sequence
> mi
->last_sequence
|| mi
->is_continuous
||
605 (file
->IsCompressed
&& !mi
->is_extracted
))
608 MSIFILE
*cursor
= file
;
611 data
.package
= package
;
612 data
.cb
= installfiles_cb
;
615 if (file
->IsCompressed
&& !msi_cabextract(package
, mi
, &data
))
617 ERR("Failed to extract cabinet: %s\n", debugstr_w(mi
->cabinet
));
618 rc
= ERROR_INSTALL_FAILURE
;
623 if (!file
->IsCompressed
)
625 WCHAR
*source
= msi_resolve_file_source(package
, file
);
627 TRACE("copying %s to %s\n", debugstr_w(source
), debugstr_w(file
->TargetPath
));
629 if (!is_global_assembly
)
631 create_folder(package
, file
->Component
->Directory
);
633 rc
= copy_install_file(package
, file
, source
);
634 if (rc
!= ERROR_SUCCESS
)
636 ERR("Failed to copy %s to %s (%u)\n", debugstr_w(source
), debugstr_w(file
->TargetPath
), rc
);
637 rc
= ERROR_INSTALL_FAILURE
;
641 if (!is_global_assembly
) file
->state
= msifs_installed
;
644 else if (!is_global_assembly
&& file
->state
!= msifs_installed
&&
645 !(file
->Attributes
& msidbFileAttributesPatchAdded
))
647 ERR("compressed file wasn't installed (%s)\n", debugstr_w(file
->File
));
648 rc
= ERROR_INSTALL_FAILURE
;
654 msi_free_media_info(mi
);
658 static MSIFILEPATCH
*find_filepatch( MSIPACKAGE
*package
, UINT disk_id
, const WCHAR
*key
)
662 LIST_FOR_EACH_ENTRY( patch
, &package
->filepatches
, MSIFILEPATCH
, entry
)
664 if (!patch
->extracted
&& patch
->disk_id
== disk_id
&& !wcscmp( key
, patch
->File
->File
))
670 static BOOL
patchfiles_cb(MSIPACKAGE
*package
, LPCWSTR file
, DWORD action
,
671 LPWSTR
*path
, DWORD
*attrs
, PVOID user
)
673 MSIFILEPATCH
*patch
= *(MSIFILEPATCH
**)user
;
675 if (action
== MSICABEXTRACT_BEGINEXTRACT
)
679 if (is_registered_patch_media( package
, patch
->disk_id
) ||
680 !(patch
= find_filepatch( package
, patch
->disk_id
, file
))) return FALSE
;
682 comp
= patch
->File
->Component
;
683 comp
->Action
= msi_get_component_action( package
, comp
);
684 if (!comp
->Enabled
|| comp
->Action
!= INSTALLSTATE_LOCAL
)
686 TRACE("file %s component %s not installed or disabled\n",
687 debugstr_w(patch
->File
->File
), debugstr_w(comp
->Component
));
691 patch
->path
= msi_create_temp_file( package
->db
);
692 *path
= wcsdup( patch
->path
);
693 *attrs
= patch
->File
->Attributes
;
694 *(MSIFILEPATCH
**)user
= patch
;
696 else if (action
== MSICABEXTRACT_FILEEXTRACTED
)
698 patch
->extracted
= TRUE
;
704 static UINT
patch_file( MSIPACKAGE
*package
, MSIFILEPATCH
*patch
)
706 UINT r
= ERROR_SUCCESS
;
707 WCHAR
*tmpfile
= msi_create_temp_file( package
->db
);
709 if (!tmpfile
) return ERROR_INSTALL_FAILURE
;
710 if (apply_filepatch( package
, patch
->path
, patch
->File
->TargetPath
, tmpfile
))
712 msi_delete_file( package
, patch
->File
->TargetPath
);
713 msi_move_file( package
, tmpfile
, patch
->File
->TargetPath
, 0 );
717 WARN( "failed to patch %s: %#lx\n", debugstr_w(patch
->File
->TargetPath
), GetLastError() );
718 r
= ERROR_INSTALL_FAILURE
;
720 DeleteFileW( patch
->path
);
721 DeleteFileW( tmpfile
);
726 UINT
msi_patch_assembly( MSIPACKAGE
*package
, MSIASSEMBLY
*assembly
, MSIFILEPATCH
*patch
)
728 UINT r
= ERROR_FUNCTION_FAILED
;
732 if (!(iter
= msi_create_assembly_enum( package
, assembly
->display_name
)))
733 return ERROR_FUNCTION_FAILED
;
735 while ((IAssemblyEnum_GetNextAssembly( iter
, NULL
, &name
, 0 ) == S_OK
))
737 WCHAR
*displayname
, *path
;
741 hr
= IAssemblyName_GetDisplayName( name
, NULL
, &len
, 0 );
742 if (hr
!= E_NOT_SUFFICIENT_BUFFER
|| !(displayname
= malloc( len
* sizeof(WCHAR
) )))
745 hr
= IAssemblyName_GetDisplayName( name
, displayname
, &len
, 0 );
752 if ((path
= msi_get_assembly_path( package
, displayname
)))
754 if (!copy_file( package
, path
, patch
->File
->TargetPath
, FALSE
))
756 ERR( "failed to copy file %s -> %s (%lu)\n", debugstr_w(path
),
757 debugstr_w(patch
->File
->TargetPath
), GetLastError() );
760 IAssemblyName_Release( name
);
763 r
= patch_file( package
, patch
);
768 IAssemblyName_Release( name
);
769 if (r
== ERROR_SUCCESS
) break;
772 IAssemblyEnum_Release( iter
);
776 UINT
ACTION_PatchFiles( MSIPACKAGE
*package
)
780 UINT rc
= ERROR_SUCCESS
;
782 TRACE("%p\n", package
);
784 if (package
->script
== SCRIPT_NONE
)
785 return msi_schedule_action(package
, SCRIPT_INSTALL
, L
"PatchFiles");
787 mi
= calloc( 1, sizeof(MSIMEDIAINFO
) );
789 TRACE("extracting files\n");
791 LIST_FOR_EACH_ENTRY( patch
, &package
->filepatches
, MSIFILEPATCH
, entry
)
793 MSIFILE
*file
= patch
->File
;
794 MSICOMPONENT
*comp
= file
->Component
;
796 rc
= msi_load_media_info( package
, patch
->Sequence
, mi
);
797 if (rc
!= ERROR_SUCCESS
)
799 ERR("Unable to load media info for %s (%u)\n", debugstr_w(file
->File
), rc
);
800 rc
= ERROR_FUNCTION_FAILED
;
803 comp
->Action
= msi_get_component_action( package
, comp
);
804 if (!comp
->Enabled
|| comp
->Action
!= INSTALLSTATE_LOCAL
) continue;
806 if (!patch
->extracted
)
809 MSIFILEPATCH
*cursor
= patch
;
811 rc
= ready_media( package
, TRUE
, mi
);
812 if (rc
!= ERROR_SUCCESS
)
814 ERR("Failed to ready media for %s\n", debugstr_w(file
->File
));
818 data
.package
= package
;
819 data
.cb
= patchfiles_cb
;
822 if (!msi_cabextract( package
, mi
, &data
))
824 ERR("Failed to extract cabinet: %s\n", debugstr_w(mi
->cabinet
));
825 rc
= ERROR_INSTALL_FAILURE
;
831 TRACE("applying patches\n");
833 LIST_FOR_EACH_ENTRY( patch
, &package
->filepatches
, MSIFILEPATCH
, entry
)
835 MSICOMPONENT
*comp
= patch
->File
->Component
;
837 if (msi_is_global_assembly( comp
) || !patch
->path
) continue;
839 rc
= patch_file( package
, patch
);
840 if (rc
&& !(patch
->Attributes
& msidbPatchAttributesNonVital
))
842 ERR("Failed to apply patch to file: %s\n", debugstr_w(patch
->File
->File
));
848 msi_free_media_info(mi
);
852 #define is_dot_dir(x) ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0))))
863 static BOOL
move_file( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*dest
, int options
)
867 if (msi_get_file_attributes( package
, source
) == FILE_ATTRIBUTE_DIRECTORY
||
868 msi_get_file_attributes( package
, dest
) == FILE_ATTRIBUTE_DIRECTORY
)
870 WARN("Source or dest is directory, not moving\n");
874 if (options
== msidbMoveFileOptionsMove
)
876 TRACE("moving %s -> %s\n", debugstr_w(source
), debugstr_w(dest
));
877 ret
= msi_move_file( package
, source
, dest
, MOVEFILE_REPLACE_EXISTING
);
880 WARN( "msi_move_file failed: %lu\n", GetLastError() );
886 TRACE("copying %s -> %s\n", debugstr_w(source
), debugstr_w(dest
));
887 ret
= copy_file( package
, source
, dest
, FALSE
);
890 WARN( "copy_file failed: %lu\n", GetLastError() );
898 static WCHAR
*wildcard_to_file( const WCHAR
*wildcard
, const WCHAR
*filename
)
902 DWORD dirlen
, pathlen
;
904 ptr
= wcsrchr(wildcard
, '\\');
905 dirlen
= ptr
- wildcard
+ 1;
907 pathlen
= dirlen
+ lstrlenW(filename
) + 1;
908 if (!(path
= malloc(pathlen
* sizeof(WCHAR
)))) return NULL
;
910 lstrcpynW(path
, wildcard
, dirlen
+ 1);
911 lstrcatW(path
, filename
);
916 static void free_file_entry(struct file_list
*file
)
923 static void free_list(struct file_list
*list
)
925 while (!list_empty(&list
->entry
))
927 struct file_list
*file
= LIST_ENTRY(list_head(&list
->entry
), struct file_list
, entry
);
929 list_remove(&file
->entry
);
930 free_file_entry(file
);
934 static BOOL
add_wildcard( struct file_list
*files
, const WCHAR
*source
, WCHAR
*dest
)
936 struct file_list
*new, *file
;
937 WCHAR
*ptr
, *filename
;
940 new = calloc(1, sizeof(*new));
944 new->source
= wcsdup(source
);
945 ptr
= wcsrchr(dest
, '\\') + 1;
946 filename
= wcsrchr(new->source
, '\\') + 1;
948 new->sourcename
= filename
;
953 new->destname
= new->sourcename
;
955 size
= (ptr
- dest
) + lstrlenW(filename
) + 1;
956 new->dest
= malloc(size
* sizeof(WCHAR
));
959 free_file_entry(new);
963 lstrcpynW(new->dest
, dest
, ptr
- dest
+ 1);
964 lstrcatW(new->dest
, filename
);
966 if (list_empty(&files
->entry
))
968 list_add_head(&files
->entry
, &new->entry
);
972 LIST_FOR_EACH_ENTRY(file
, &files
->entry
, struct file_list
, entry
)
974 if (wcscmp( source
, file
->source
) < 0)
976 list_add_before(&file
->entry
, &new->entry
);
981 list_add_after(&file
->entry
, &new->entry
);
985 static BOOL
move_files_wildcard( MSIPACKAGE
*package
, const WCHAR
*source
, WCHAR
*dest
, int options
)
987 WIN32_FIND_DATAW wfd
;
991 struct file_list files
, *file
;
994 hfile
= msi_find_first_file( package
, source
, &wfd
);
995 if (hfile
== INVALID_HANDLE_VALUE
) return FALSE
;
997 list_init(&files
.entry
);
999 for (res
= TRUE
; res
; res
= msi_find_next_file( package
, hfile
, &wfd
))
1001 if (is_dot_dir(wfd
.cFileName
)) continue;
1003 path
= wildcard_to_file( source
, wfd
.cFileName
);
1010 add_wildcard(&files
, path
, dest
);
1014 /* no files match the wildcard */
1015 if (list_empty(&files
.entry
))
1018 /* only the first wildcard match gets renamed to dest */
1019 file
= LIST_ENTRY(list_head(&files
.entry
), struct file_list
, entry
);
1020 size
= (wcsrchr(file
->dest
, '\\') - file
->dest
) + lstrlenW(file
->destname
) + 2;
1021 file
->dest
= realloc(file
->dest
, size
* sizeof(WCHAR
));
1028 /* file->dest may be shorter after the reallocation, so add a NULL
1029 * terminator. This is needed for the call to wcsrchr, as there will no
1030 * longer be a NULL terminator within the bounds of the allocation in this case.
1032 file
->dest
[size
- 1] = '\0';
1033 lstrcpyW(wcsrchr(file
->dest
, '\\') + 1, file
->destname
);
1035 while (!list_empty(&files
.entry
))
1037 file
= LIST_ENTRY(list_head(&files
.entry
), struct file_list
, entry
);
1039 move_file( package
, file
->source
, file
->dest
, options
);
1041 list_remove(&file
->entry
);
1042 free_file_entry(file
);
1053 void msi_reduce_to_long_filename( WCHAR
*filename
)
1055 WCHAR
*p
= wcschr( filename
, '|' );
1056 if (p
) memmove( filename
, p
+ 1, (lstrlenW( p
+ 1 ) + 1) * sizeof(WCHAR
) );
1059 static UINT
ITERATE_MoveFiles( MSIRECORD
*rec
, LPVOID param
)
1061 MSIPACKAGE
*package
= param
;
1064 LPCWSTR sourcename
, component
;
1065 LPWSTR sourcedir
, destname
= NULL
, destdir
= NULL
, source
= NULL
, dest
= NULL
;
1070 component
= MSI_RecordGetString(rec
, 2);
1071 comp
= msi_get_loaded_component(package
, component
);
1073 return ERROR_SUCCESS
;
1075 comp
->Action
= msi_get_component_action( package
, comp
);
1076 if (comp
->Action
!= INSTALLSTATE_LOCAL
)
1078 TRACE("component not scheduled for installation %s\n", debugstr_w(component
));
1079 return ERROR_SUCCESS
;
1082 sourcename
= MSI_RecordGetString(rec
, 3);
1083 options
= MSI_RecordGetInteger(rec
, 7);
1085 sourcedir
= msi_dup_property(package
->db
, MSI_RecordGetString(rec
, 5));
1089 destdir
= msi_dup_property(package
->db
, MSI_RecordGetString(rec
, 6));
1095 if (msi_get_file_attributes( package
, sourcedir
) == INVALID_FILE_ATTRIBUTES
)
1098 source
= wcsdup(sourcedir
);
1104 size
= lstrlenW(sourcedir
) + lstrlenW(sourcename
) + 2;
1105 source
= malloc(size
* sizeof(WCHAR
));
1109 lstrcpyW(source
, sourcedir
);
1110 if (source
[lstrlenW(source
) - 1] != '\\')
1111 lstrcatW(source
, L
"\\");
1112 lstrcatW(source
, sourcename
);
1115 wildcards
= wcschr(source
, '*') || wcschr(source
, '?');
1117 if (MSI_RecordIsNull(rec
, 4))
1123 destname
= wcsdup(sourcename
);
1124 else if ((p
= wcsrchr(sourcedir
, '\\')))
1125 destname
= wcsdup(p
+ 1);
1127 destname
= wcsdup(sourcedir
);
1134 destname
= wcsdup(MSI_RecordGetString(rec
, 4));
1135 if (destname
) msi_reduce_to_long_filename(destname
);
1140 size
= lstrlenW(destname
);
1142 size
+= lstrlenW(destdir
) + 2;
1143 dest
= malloc(size
* sizeof(WCHAR
));
1147 lstrcpyW(dest
, destdir
);
1148 if (dest
[lstrlenW(dest
) - 1] != '\\')
1149 lstrcatW(dest
, L
"\\");
1152 lstrcatW(dest
, destname
);
1154 if (msi_get_file_attributes( package
, destdir
) == INVALID_FILE_ATTRIBUTES
)
1156 if (!msi_create_full_path( package
, destdir
))
1158 WARN( "failed to create directory %lu\n", GetLastError() );
1164 move_file( package
, source
, dest
, options
);
1166 move_files_wildcard( package
, source
, dest
, options
);
1169 uirow
= MSI_CreateRecord( 9 );
1170 MSI_RecordSetStringW( uirow
, 1, MSI_RecordGetString(rec
, 1) );
1171 MSI_RecordSetInteger( uirow
, 6, 1 ); /* FIXME */
1172 MSI_RecordSetStringW( uirow
, 9, destdir
);
1173 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONDATA
, uirow
);
1174 msiobj_release( &uirow
->hdr
);
1182 return ERROR_SUCCESS
;
1185 UINT
ACTION_MoveFiles( MSIPACKAGE
*package
)
1190 if (package
->script
== SCRIPT_NONE
)
1191 return msi_schedule_action(package
, SCRIPT_INSTALL
, L
"MoveFiles");
1193 rc
= MSI_DatabaseOpenViewW(package
->db
, L
"SELECT * FROM `MoveFile`", &view
);
1194 if (rc
!= ERROR_SUCCESS
)
1195 return ERROR_SUCCESS
;
1197 rc
= MSI_IterateRecords(view
, NULL
, ITERATE_MoveFiles
, package
);
1198 msiobj_release(&view
->hdr
);
1202 static WCHAR
*get_duplicate_filename( MSIPACKAGE
*package
, MSIRECORD
*row
, const WCHAR
*file_key
, const WCHAR
*src
)
1205 WCHAR
*dst_name
, *dst_path
, *dst
;
1207 if (MSI_RecordIsNull( row
, 4 ))
1209 len
= lstrlenW( src
) + 1;
1210 if (!(dst_name
= malloc( len
* sizeof(WCHAR
)))) return NULL
;
1211 lstrcpyW( dst_name
, wcsrchr( src
, '\\' ) + 1 );
1215 MSI_RecordGetStringW( row
, 4, NULL
, &len
);
1216 if (!(dst_name
= malloc( ++len
* sizeof(WCHAR
) ))) return NULL
;
1217 MSI_RecordGetStringW( row
, 4, dst_name
, &len
);
1218 msi_reduce_to_long_filename( dst_name
);
1221 if (MSI_RecordIsNull( row
, 5 ))
1224 dst_path
= wcsdup( src
);
1225 p
= wcsrchr( dst_path
, '\\' );
1230 const WCHAR
*dst_key
= MSI_RecordGetString( row
, 5 );
1232 dst_path
= wcsdup( msi_get_target_folder( package
, dst_key
) );
1235 /* try a property */
1236 dst_path
= msi_dup_property( package
->db
, dst_key
);
1239 FIXME("Unable to get destination folder, try AppSearch properties\n");
1246 dst
= msi_build_directory_name( 2, dst_path
, dst_name
);
1247 msi_create_full_path( package
, dst_path
);
1254 static UINT
ITERATE_DuplicateFiles(MSIRECORD
*row
, LPVOID param
)
1256 MSIPACKAGE
*package
= param
;
1258 LPCWSTR file_key
, component
;
1263 component
= MSI_RecordGetString(row
,2);
1264 comp
= msi_get_loaded_component(package
, component
);
1266 return ERROR_SUCCESS
;
1268 comp
->Action
= msi_get_component_action( package
, comp
);
1269 if (comp
->Action
!= INSTALLSTATE_LOCAL
)
1271 TRACE("component not scheduled for installation %s\n", debugstr_w(component
));
1272 return ERROR_SUCCESS
;
1275 file_key
= MSI_RecordGetString(row
,3);
1278 ERR("Unable to get file key\n");
1279 return ERROR_FUNCTION_FAILED
;
1282 file
= msi_get_loaded_file( package
, file_key
);
1285 ERR("Original file unknown %s\n", debugstr_w(file_key
));
1286 return ERROR_SUCCESS
;
1289 dest
= get_duplicate_filename( package
, row
, file_key
, file
->TargetPath
);
1292 WARN("Unable to get duplicate filename\n");
1293 return ERROR_SUCCESS
;
1296 TRACE("Duplicating file %s to %s\n", debugstr_w(file
->TargetPath
), debugstr_w(dest
));
1297 if (!copy_file( package
, file
->TargetPath
, dest
, TRUE
))
1299 WARN( "failed to copy file %s -> %s (%lu)\n",
1300 debugstr_w(file
->TargetPath
), debugstr_w(dest
), GetLastError() );
1302 FIXME("We should track these duplicate files as well\n");
1304 uirow
= MSI_CreateRecord( 9 );
1305 MSI_RecordSetStringW( uirow
, 1, MSI_RecordGetString( row
, 1 ) );
1306 MSI_RecordSetInteger( uirow
, 6, file
->FileSize
);
1307 MSI_RecordSetStringW( uirow
, 9, MSI_RecordGetString( row
, 5 ) );
1308 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONDATA
, uirow
);
1309 msiobj_release( &uirow
->hdr
);
1312 return ERROR_SUCCESS
;
1315 UINT
ACTION_DuplicateFiles(MSIPACKAGE
*package
)
1320 if (package
->script
== SCRIPT_NONE
)
1321 return msi_schedule_action(package
, SCRIPT_INSTALL
, L
"DuplicateFiles");
1323 rc
= MSI_DatabaseOpenViewW(package
->db
, L
"SELECT * FROM `DuplicateFile`", &view
);
1324 if (rc
!= ERROR_SUCCESS
)
1325 return ERROR_SUCCESS
;
1327 rc
= MSI_IterateRecords(view
, NULL
, ITERATE_DuplicateFiles
, package
);
1328 msiobj_release(&view
->hdr
);
1332 static UINT
ITERATE_RemoveDuplicateFiles( MSIRECORD
*row
, LPVOID param
)
1334 MSIPACKAGE
*package
= param
;
1336 LPCWSTR file_key
, component
;
1341 component
= MSI_RecordGetString( row
, 2 );
1342 comp
= msi_get_loaded_component( package
, component
);
1344 return ERROR_SUCCESS
;
1346 comp
->Action
= msi_get_component_action( package
, comp
);
1347 if (comp
->Action
!= INSTALLSTATE_ABSENT
)
1349 TRACE("component not scheduled for removal %s\n", debugstr_w(component
));
1350 return ERROR_SUCCESS
;
1353 file_key
= MSI_RecordGetString( row
, 3 );
1356 ERR("Unable to get file key\n");
1357 return ERROR_FUNCTION_FAILED
;
1360 file
= msi_get_loaded_file( package
, file_key
);
1363 ERR("Original file unknown %s\n", debugstr_w(file_key
));
1364 return ERROR_SUCCESS
;
1367 dest
= get_duplicate_filename( package
, row
, file_key
, file
->TargetPath
);
1370 WARN("Unable to get duplicate filename\n");
1371 return ERROR_SUCCESS
;
1374 TRACE("Removing duplicate %s of %s\n", debugstr_w(dest
), debugstr_w(file
->TargetPath
));
1375 if (!msi_delete_file( package
, dest
))
1377 WARN( "failed to delete duplicate file %s (%lu)\n", debugstr_w(dest
), GetLastError() );
1380 uirow
= MSI_CreateRecord( 9 );
1381 MSI_RecordSetStringW( uirow
, 1, MSI_RecordGetString( row
, 1 ) );
1382 MSI_RecordSetStringW( uirow
, 9, MSI_RecordGetString( row
, 5 ) );
1383 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONDATA
, uirow
);
1384 msiobj_release( &uirow
->hdr
);
1387 return ERROR_SUCCESS
;
1390 UINT
ACTION_RemoveDuplicateFiles( MSIPACKAGE
*package
)
1395 if (package
->script
== SCRIPT_NONE
)
1396 return msi_schedule_action(package
, SCRIPT_INSTALL
, L
"RemoveDuplicateFiles");
1398 rc
= MSI_DatabaseOpenViewW( package
->db
, L
"SELECT * FROM `DuplicateFile`", &view
);
1399 if (rc
!= ERROR_SUCCESS
)
1400 return ERROR_SUCCESS
;
1402 rc
= MSI_IterateRecords( view
, NULL
, ITERATE_RemoveDuplicateFiles
, package
);
1403 msiobj_release( &view
->hdr
);
1407 static BOOL
verify_comp_for_removal(MSICOMPONENT
*comp
, UINT install_mode
)
1410 if (comp
->Action
!= INSTALLSTATE_SOURCE
&&
1411 comp
->Attributes
& msidbComponentAttributesSourceOnly
&&
1412 (install_mode
== msidbRemoveFileInstallModeOnRemove
||
1413 install_mode
== msidbRemoveFileInstallModeOnBoth
)) return TRUE
;
1415 switch (comp
->Action
)
1417 case INSTALLSTATE_LOCAL
:
1418 case INSTALLSTATE_SOURCE
:
1419 if (install_mode
== msidbRemoveFileInstallModeOnInstall
||
1420 install_mode
== msidbRemoveFileInstallModeOnBoth
) return TRUE
;
1422 case INSTALLSTATE_ABSENT
:
1423 if (install_mode
== msidbRemoveFileInstallModeOnRemove
||
1424 install_mode
== msidbRemoveFileInstallModeOnBoth
) return TRUE
;
1431 static UINT
ITERATE_RemoveFiles(MSIRECORD
*row
, LPVOID param
)
1433 MSIPACKAGE
*package
= param
;
1436 LPCWSTR component
, dirprop
;
1438 LPWSTR dir
= NULL
, path
= NULL
, filename
= NULL
;
1440 UINT ret
= ERROR_SUCCESS
;
1442 component
= MSI_RecordGetString(row
, 2);
1443 dirprop
= MSI_RecordGetString(row
, 4);
1444 install_mode
= MSI_RecordGetInteger(row
, 5);
1446 comp
= msi_get_loaded_component(package
, component
);
1448 return ERROR_SUCCESS
;
1450 comp
->Action
= msi_get_component_action( package
, comp
);
1451 if (!verify_comp_for_removal(comp
, install_mode
))
1453 TRACE("Skipping removal due to install mode\n");
1454 return ERROR_SUCCESS
;
1456 if (comp
->assembly
&& !comp
->assembly
->application
)
1458 return ERROR_SUCCESS
;
1460 if (comp
->Attributes
& msidbComponentAttributesPermanent
)
1462 TRACE("permanent component, not removing file\n");
1463 return ERROR_SUCCESS
;
1466 dir
= msi_dup_property(package
->db
, dirprop
);
1469 WARN("directory property has no value\n");
1470 return ERROR_SUCCESS
;
1473 if ((filename
= wcsdup( MSI_RecordGetString(row
, 3) )))
1475 msi_reduce_to_long_filename( filename
);
1476 size
= lstrlenW( filename
);
1478 size
+= lstrlenW(dir
) + 2;
1479 path
= malloc(size
* sizeof(WCHAR
));
1482 ret
= ERROR_OUTOFMEMORY
;
1488 lstrcpyW(path
, dir
);
1489 PathAddBackslashW(path
);
1490 lstrcatW(path
, filename
);
1492 TRACE("Deleting misc file: %s\n", debugstr_w(path
));
1493 msi_delete_file( package
, path
);
1497 TRACE("Removing misc directory: %s\n", debugstr_w(dir
));
1498 msi_remove_directory( package
, dir
);
1502 uirow
= MSI_CreateRecord( 9 );
1503 MSI_RecordSetStringW( uirow
, 1, MSI_RecordGetString(row
, 1) );
1504 MSI_RecordSetStringW( uirow
, 9, dir
);
1505 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONDATA
, uirow
);
1506 msiobj_release( &uirow
->hdr
);
1514 static void remove_folder( MSIFOLDER
*folder
)
1518 LIST_FOR_EACH_ENTRY( fl
, &folder
->children
, FolderList
, entry
)
1520 remove_folder( fl
->folder
);
1522 if (!folder
->persistent
&& folder
->State
!= FOLDER_STATE_REMOVED
)
1524 if (RemoveDirectoryW( folder
->ResolvedTarget
)) folder
->State
= FOLDER_STATE_REMOVED
;
1528 UINT
ACTION_RemoveFiles( MSIPACKAGE
*package
)
1535 if (package
->script
== SCRIPT_NONE
)
1536 return msi_schedule_action(package
, SCRIPT_INSTALL
, L
"RemoveFiles");
1538 r
= MSI_DatabaseOpenViewW(package
->db
, L
"SELECT * FROM `RemoveFile`", &view
);
1539 if (r
== ERROR_SUCCESS
)
1541 r
= MSI_IterateRecords(view
, NULL
, ITERATE_RemoveFiles
, package
);
1542 msiobj_release(&view
->hdr
);
1543 if (r
!= ERROR_SUCCESS
)
1547 LIST_FOR_EACH_ENTRY( file
, &package
->files
, MSIFILE
, entry
)
1550 VS_FIXEDFILEINFO
*ver
;
1552 comp
= file
->Component
;
1553 file_update_ui( package
, file
, L
"RemoveFiles" );
1555 comp
->Action
= msi_get_component_action( package
, comp
);
1556 if (comp
->Action
!= INSTALLSTATE_ABSENT
|| comp
->Installed
== INSTALLSTATE_SOURCE
)
1559 if (comp
->assembly
&& !comp
->assembly
->application
)
1562 if (comp
->Attributes
& msidbComponentAttributesPermanent
)
1564 TRACE("permanent component, not removing file\n");
1570 ver
= msi_get_disk_file_version( package
, file
->TargetPath
);
1571 if (ver
&& msi_compare_file_versions( ver
, file
->Version
) > 0)
1573 TRACE("newer version detected, not removing file\n");
1580 if (file
->state
== msifs_installed
)
1581 WARN("removing installed file %s\n", debugstr_w(file
->TargetPath
));
1583 TRACE("removing %s\n", debugstr_w(file
->File
) );
1585 msi_set_file_attributes( package
, file
->TargetPath
, FILE_ATTRIBUTE_NORMAL
);
1586 if (!msi_delete_file( package
, file
->TargetPath
))
1588 WARN( "failed to delete %s (%lu)\n", debugstr_w(file
->TargetPath
), GetLastError() );
1590 file
->state
= msifs_missing
;
1592 uirow
= MSI_CreateRecord( 9 );
1593 MSI_RecordSetStringW( uirow
, 1, file
->FileName
);
1594 MSI_RecordSetStringW( uirow
, 9, comp
->Directory
);
1595 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONDATA
, uirow
);
1596 msiobj_release( &uirow
->hdr
);
1599 LIST_FOR_EACH_ENTRY( comp
, &package
->components
, MSICOMPONENT
, entry
)
1601 comp
->Action
= msi_get_component_action( package
, comp
);
1602 if (comp
->Action
!= INSTALLSTATE_ABSENT
) continue;
1604 if (comp
->Attributes
& msidbComponentAttributesPermanent
)
1606 TRACE("permanent component, not removing directory\n");
1609 if (comp
->assembly
&& !comp
->assembly
->application
)
1610 msi_uninstall_assembly( package
, comp
);
1613 MSIFOLDER
*folder
= msi_get_loaded_folder( package
, comp
->Directory
);
1614 if (folder
) remove_folder( folder
);
1617 return ERROR_SUCCESS
;