2 * Custom Action processing for 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
30 #include "wine/debug.h"
31 #include "wine/unicode.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
35 #define CUSTOM_ACTION_TYPE_MASK 0x3F
36 static const WCHAR c_collen
[] = {'C',':','\\',0};
37 static const WCHAR cszTempFolder
[]= {'T','e','m','p','F','o','l','d','e','r',0};
39 typedef struct tagMSIRUNNINGACTION
47 static UINT
HANDLE_CustomType1(MSIPACKAGE
*package
, LPCWSTR source
,
48 LPCWSTR target
, const INT type
, LPCWSTR action
);
49 static UINT
HANDLE_CustomType2(MSIPACKAGE
*package
, LPCWSTR source
,
50 LPCWSTR target
, const INT type
, LPCWSTR action
);
51 static UINT
HANDLE_CustomType17(MSIPACKAGE
*package
, LPCWSTR source
,
52 LPCWSTR target
, const INT type
, LPCWSTR action
);
53 static UINT
HANDLE_CustomType18(MSIPACKAGE
*package
, LPCWSTR source
,
54 LPCWSTR target
, const INT type
, LPCWSTR action
);
55 static UINT
HANDLE_CustomType19(MSIPACKAGE
*package
, LPCWSTR source
,
56 LPCWSTR target
, const INT type
, LPCWSTR action
);
57 static UINT
HANDLE_CustomType50(MSIPACKAGE
*package
, LPCWSTR source
,
58 LPCWSTR target
, const INT type
, LPCWSTR action
);
59 static UINT
HANDLE_CustomType34(MSIPACKAGE
*package
, LPCWSTR source
,
60 LPCWSTR target
, const INT type
, LPCWSTR action
);
62 typedef UINT (WINAPI
*MsiCustomActionEntryPoint
)( MSIHANDLE
);
64 static CRITICAL_SECTION msi_custom_action_cs
;
65 static CRITICAL_SECTION_DEBUG msi_custom_action_cs_debug
=
67 0, 0, &msi_custom_action_cs
,
68 { &msi_custom_action_cs_debug
.ProcessLocksList
,
69 &msi_custom_action_cs_debug
.ProcessLocksList
},
70 0, 0, { (DWORD_PTR
)(__FILE__
": msi_custom_action_cs") }
72 static CRITICAL_SECTION msi_custom_action_cs
= { &msi_custom_action_cs_debug
, -1, 0, 0, 0, 0 };
74 static struct list msi_pending_custom_actions
= LIST_INIT( msi_pending_custom_actions
);
76 static BOOL
check_execution_scheduling_options(MSIPACKAGE
*package
, LPCWSTR action
, UINT options
)
81 if ((options
& msidbCustomActionTypeClientRepeat
) ==
82 msidbCustomActionTypeClientRepeat
)
84 if (!(package
->script
->InWhatSequence
& SEQUENCE_UI
&&
85 package
->script
->InWhatSequence
& SEQUENCE_EXEC
))
87 TRACE("Skipping action due to dbCustomActionTypeClientRepeat option.\n");
91 else if (options
& msidbCustomActionTypeFirstSequence
)
93 if (package
->script
->InWhatSequence
& SEQUENCE_UI
&&
94 package
->script
->InWhatSequence
& SEQUENCE_EXEC
)
96 TRACE("Skipping action due to msidbCustomActionTypeFirstSequence option.\n");
100 else if (options
& msidbCustomActionTypeOncePerProcess
)
102 if (check_unique_action(package
,action
))
104 TRACE("Skipping action due to msidbCustomActionTypeOncePerProcess option.\n");
108 register_unique_action(package
,action
);
114 /* stores the CustomActionData before the action:
115 * [CustomActionData]Action
117 static LPWSTR
msi_get_deferred_action(LPCWSTR action
, LPWSTR actiondata
)
122 static const WCHAR begin
[] = {'[',0};
123 static const WCHAR end
[] = {']',0};
126 return strdupW(action
);
128 len
= lstrlenW(action
) + lstrlenW(actiondata
) + 3;
129 deferred
= msi_alloc(len
* sizeof(WCHAR
));
131 lstrcpyW(deferred
, begin
);
132 lstrcatW(deferred
, actiondata
);
133 lstrcatW(deferred
, end
);
134 lstrcatW(deferred
, action
);
139 UINT
ACTION_CustomAction(MSIPACKAGE
*package
,LPCWSTR action
, BOOL execute
)
141 UINT rc
= ERROR_SUCCESS
;
143 static const WCHAR ExecSeqQuery
[] =
144 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
145 '`','C','u','s','t','o' ,'m','A','c','t','i','o','n','`',
146 ' ','W','H','E','R','E',' ','`','A','c','t','i' ,'o','n','`',' ',
147 '=',' ','\'','%','s','\'',0};
149 LPCWSTR source
, target
;
150 LPWSTR ptr
, deferred_data
= NULL
;
151 LPWSTR action_copy
= strdupW(action
);
152 WCHAR
*deformated
=NULL
;
154 /* deferred action: [CustomActionData]Action */
155 if ((ptr
= strchrW(action_copy
, ']')))
157 deferred_data
= action_copy
+ 1;
162 row
= MSI_QueryGetRecord( package
->db
, ExecSeqQuery
, action
);
165 msi_free(action_copy
);
166 return ERROR_CALL_NOT_IMPLEMENTED
;
169 type
= MSI_RecordGetInteger(row
,2);
171 source
= MSI_RecordGetString(row
,3);
172 target
= MSI_RecordGetString(row
,4);
174 TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action
),type
,
175 debugstr_w(source
), debugstr_w(target
));
177 /* handle some of the deferred actions */
178 if (type
& msidbCustomActionTypeTSAware
)
179 FIXME("msidbCustomActionTypeTSAware not handled\n");
181 if (type
& msidbCustomActionTypeInScript
)
183 TRACE("msidbCustomActionTypeInScript\n");
184 if (type
& msidbCustomActionTypeNoImpersonate
)
185 FIXME("msidbCustomActionTypeNoImpersonate not handled\n");
187 if (type
& msidbCustomActionTypeRollback
)
189 FIXME("Rollback only action... rollbacks not supported yet\n");
190 schedule_action(package
, ROLLBACK_SCRIPT
, action
);
196 LPWSTR actiondata
= msi_dup_property(package
, action
);
197 LPWSTR deferred
= msi_get_deferred_action(action
, actiondata
);
199 if (type
& msidbCustomActionTypeCommit
)
201 TRACE("Deferring Commit Action!\n");
202 schedule_action(package
, COMMIT_SCRIPT
, deferred
);
206 TRACE("Deferring Action!\n");
207 schedule_action(package
, INSTALL_SCRIPT
, deferred
);
218 static const WCHAR szActionData
[] = {
219 'C','u','s','t','o','m','A','c','t','i','o','n','D','a','t','a',0};
220 static const WCHAR szBlank
[] = {0};
221 LPWSTR actiondata
= msi_dup_property( package
, action
);
223 MSI_SetPropertyW(package
,szActionData
,deferred_data
);
225 MSI_SetPropertyW(package
,szActionData
,actiondata
);
227 MSI_SetPropertyW(package
,szActionData
,szBlank
);
228 msi_free(actiondata
);
231 else if (!check_execution_scheduling_options(package
,action
,type
))
237 switch (type
& CUSTOM_ACTION_TYPE_MASK
)
239 case 1: /* DLL file stored in a Binary table stream */
240 rc
= HANDLE_CustomType1(package
,source
,target
,type
,action
);
242 case 2: /* EXE file stored in a Binary table stream */
243 rc
= HANDLE_CustomType2(package
,source
,target
,type
,action
);
245 case 18: /*EXE file installed with package */
246 rc
= HANDLE_CustomType18(package
,source
,target
,type
,action
);
248 case 19: /* Error that halts install */
249 rc
= HANDLE_CustomType19(package
,source
,target
,type
,action
);
252 rc
= HANDLE_CustomType17(package
,source
,target
,type
,action
);
254 case 50: /*EXE file specified by a property value */
255 rc
= HANDLE_CustomType50(package
,source
,target
,type
,action
);
257 case 34: /*EXE to be run in specified directory */
258 rc
= HANDLE_CustomType34(package
,source
,target
,type
,action
);
260 case 35: /* Directory set with formatted text. */
261 deformat_string(package
,target
,&deformated
);
262 MSI_SetTargetPathW(package
, source
, deformated
);
263 msi_free(deformated
);
265 case 51: /* Property set with formatted text. */
266 deformat_string(package
,target
,&deformated
);
267 rc
= MSI_SetPropertyW(package
,source
,deformated
);
268 msi_free(deformated
);
271 FIXME("UNHANDLED ACTION TYPE %i (%s %s)\n",
272 type
& CUSTOM_ACTION_TYPE_MASK
, debugstr_w(source
),
277 msi_free(action_copy
);
278 msiobj_release(&row
->hdr
);
283 static UINT
store_binary_to_temp(MSIPACKAGE
*package
, LPCWSTR source
,
286 static const WCHAR query
[] = {
287 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
288 '`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E',' ',
289 '`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0};
293 static const WCHAR f1
[] = {'m','s','i',0};
298 if (MSI_GetPropertyW(package
, cszTempFolder
, fmt
, &sz
) != ERROR_SUCCESS
)
299 GetTempPathW(MAX_PATH
, fmt
);
301 if (GetTempFileNameW(fmt
, f1
, 0, tmp_file
) == 0)
303 TRACE("Unable to create file\n");
304 return ERROR_FUNCTION_FAILED
;
306 track_tempfile(package
, tmp_file
);
308 row
= MSI_QueryGetRecord(package
->db
, query
, source
);
310 return ERROR_FUNCTION_FAILED
;
312 /* write out the file */
313 file
= CreateFileW(tmp_file
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
314 FILE_ATTRIBUTE_NORMAL
, NULL
);
315 if (file
== INVALID_HANDLE_VALUE
)
316 r
= ERROR_FUNCTION_FAILED
;
323 r
= MSI_RecordReadStream(row
, 2, buffer
, &sz
);
324 if (r
!= ERROR_SUCCESS
)
326 ERR("Failed to get stream\n");
329 WriteFile(file
, buffer
, sz
, &write
, NULL
);
330 } while (sz
== sizeof buffer
);
334 msiobj_release(&row
->hdr
);
339 static void file_running_action(MSIPACKAGE
* package
, HANDLE Handle
,
340 BOOL process
, LPCWSTR name
)
342 MSIRUNNINGACTION
*action
;
344 action
= msi_alloc( sizeof(MSIRUNNINGACTION
) );
346 action
->handle
= Handle
;
347 action
->process
= process
;
348 action
->name
= strdupW(name
);
350 list_add_tail( &package
->RunningActions
, &action
->entry
);
353 static UINT
custom_get_process_return( HANDLE process
)
357 GetExitCodeProcess( process
, &rc
);
359 return ERROR_FUNCTION_FAILED
;
360 return ERROR_SUCCESS
;
363 static UINT
custom_get_thread_return( HANDLE thread
)
367 GetExitCodeThread( thread
, &rc
);
371 case ERROR_FUNCTION_NOT_CALLED
:
373 case ERROR_INSTALL_USEREXIT
:
374 case ERROR_INSTALL_FAILURE
:
376 case ERROR_NO_MORE_ITEMS
:
377 return ERROR_SUCCESS
;
379 ERR("Invalid Return Code %d\n",rc
);
380 return ERROR_INSTALL_FAILURE
;
384 static UINT
wait_process_handle(MSIPACKAGE
* package
, UINT type
,
385 HANDLE ProcessHandle
, LPCWSTR name
)
387 UINT rc
= ERROR_SUCCESS
;
389 if (!(type
& msidbCustomActionTypeAsync
))
391 TRACE("waiting for %s\n", debugstr_w(name
));
393 msi_dialog_check_messages(ProcessHandle
);
395 if (!(type
& msidbCustomActionTypeContinue
))
396 rc
= custom_get_process_return(ProcessHandle
);
398 CloseHandle(ProcessHandle
);
402 TRACE("%s running in background\n", debugstr_w(name
));
404 if (!(type
& msidbCustomActionTypeContinue
))
405 file_running_action(package
, ProcessHandle
, TRUE
, name
);
407 CloseHandle(ProcessHandle
);
413 typedef struct _msi_custom_action_info
{
422 } msi_custom_action_info
;
424 static void free_custom_action_data( msi_custom_action_info
*info
)
426 EnterCriticalSection( &msi_custom_action_cs
);
427 list_remove( &info
->entry
);
428 LeaveCriticalSection( &msi_custom_action_cs
);
430 CloseHandle( info
->handle
);
431 msi_free( info
->action
);
432 msi_free( info
->dllname
);
433 msi_free( info
->function
);
434 msiobj_release( &info
->package
->hdr
);
438 static UINT
wait_thread_handle( msi_custom_action_info
*info
)
440 UINT rc
= ERROR_SUCCESS
;
442 if (!(info
->type
& msidbCustomActionTypeAsync
))
444 TRACE("waiting for %s\n", debugstr_w( info
->action
));
446 msi_dialog_check_messages( info
->handle
);
448 if (!(info
->type
& msidbCustomActionTypeContinue
))
449 rc
= custom_get_thread_return( info
->handle
);
451 free_custom_action_data( info
);
455 TRACE("%s running in background\n", debugstr_w( info
->action
));
461 static msi_custom_action_info
*find_action_by_guid( const GUID
*guid
)
463 msi_custom_action_info
*info
;
466 EnterCriticalSection( &msi_custom_action_cs
);
468 LIST_FOR_EACH_ENTRY( info
, &msi_pending_custom_actions
, msi_custom_action_info
, entry
)
470 if (IsEqualGUID( &info
->guid
, guid
))
477 LeaveCriticalSection( &msi_custom_action_cs
);
485 static DWORD WINAPI
ACTION_CallDllFunction( const GUID
*guid
)
487 msi_custom_action_info
*info
;
488 MsiCustomActionEntryPoint fn
;
492 UINT r
= ERROR_FUNCTION_FAILED
;
494 info
= find_action_by_guid( guid
);
497 ERR("failed to find action %s\n", debugstr_guid( guid
) );
501 TRACE("%s %s\n", debugstr_w( info
->dllname
), debugstr_w( info
->function
) );
503 TlsSetValue( tls_slot
, (void*) 1 );
505 hModule
= LoadLibraryW( info
->dllname
);
508 ERR("failed to load dll %s\n", debugstr_w( info
->dllname
) );
512 proc
= strdupWtoA( info
->function
);
513 fn
= (MsiCustomActionEntryPoint
) GetProcAddress( hModule
, proc
);
517 hPackage
= alloc_msihandle( &info
->package
->hdr
);
520 TRACE("calling %s\n", debugstr_w( info
->function
) );
522 MsiCloseHandle( hPackage
);
525 ERR("failed to create handle for %p\n", info
->package
);
528 ERR("GetProcAddress(%s) failed\n", debugstr_w( info
->function
) );
530 FreeLibrary(hModule
);
532 if (info
->type
& msidbCustomActionTypeAsync
&&
533 info
->type
& msidbCustomActionTypeContinue
)
534 free_custom_action_data( info
);
539 static DWORD WINAPI
DllThread( LPVOID arg
)
544 TRACE("custom action (%x) started\n", GetCurrentThreadId() );
546 rc
= ACTION_CallDllFunction( guid
);
548 TRACE("custom action (%x) returned %i\n", GetCurrentThreadId(), rc
);
550 MsiCloseAllHandles();
554 static msi_custom_action_info
*do_msidbCustomActionTypeDll(
555 MSIPACKAGE
*package
, INT type
, LPCWSTR dllname
, LPCWSTR function
, LPCWSTR action
)
557 msi_custom_action_info
*info
;
559 info
= msi_alloc( sizeof *info
);
563 msiobj_addref( &package
->hdr
);
564 info
->package
= package
;
566 info
->function
= strdupW( function
);
567 info
->dllname
= strdupW( dllname
);
568 info
->action
= strdupW( action
);
569 CoCreateGuid( &info
->guid
);
571 EnterCriticalSection( &msi_custom_action_cs
);
572 list_add_tail( &msi_pending_custom_actions
, &info
->entry
);
573 LeaveCriticalSection( &msi_custom_action_cs
);
575 info
->handle
= CreateThread( NULL
, 0, DllThread
, &info
->guid
, 0, NULL
);
578 free_custom_action_data( info
);
585 extern int global_deferred
;
586 static UINT
HANDLE_CustomType1(MSIPACKAGE
*package
, LPCWSTR source
,
587 LPCWSTR target
, const INT type
, LPCWSTR action
)
589 msi_custom_action_info
*info
;
590 WCHAR tmp_file
[MAX_PATH
];
593 if (type
& msidbCustomActionTypeInScript
)
595 TRACE("setting global_deferred=1\n");
599 r
= store_binary_to_temp(package
, source
, tmp_file
);
600 if (r
!= ERROR_SUCCESS
)
603 TRACE("Calling function %s from %s\n",debugstr_w(target
),
604 debugstr_w(tmp_file
));
606 if (!strchrW(tmp_file
,'.'))
608 static const WCHAR dot
[]={'.',0};
609 strcatW(tmp_file
,dot
);
612 info
= do_msidbCustomActionTypeDll( package
, type
, tmp_file
, target
, action
);
614 r
= wait_thread_handle( info
);
615 if (type
& msidbCustomActionTypeInScript
)
617 TRACE("setting global_deferred=0\n");
623 static UINT
HANDLE_CustomType2(MSIPACKAGE
*package
, LPCWSTR source
,
624 LPCWSTR target
, const INT type
, LPCWSTR action
)
626 WCHAR tmp_file
[MAX_PATH
];
628 PROCESS_INFORMATION info
;
631 WCHAR
*deformated
= NULL
;
633 static const WCHAR spc
[] = {' ',0};
636 memset(&si
,0,sizeof(STARTUPINFOW
));
638 r
= store_binary_to_temp(package
, source
, tmp_file
);
639 if (r
!= ERROR_SUCCESS
)
642 deformat_string(package
,target
,&deformated
);
644 len
= strlenW(tmp_file
)+2;
647 len
+= strlenW(deformated
);
649 cmd
= msi_alloc(sizeof(WCHAR
)*len
);
651 strcpyW(cmd
,tmp_file
);
655 strcatW(cmd
,deformated
);
657 msi_free(deformated
);
660 TRACE("executing exe %s\n", debugstr_w(cmd
));
662 rc
= CreateProcessW(NULL
, cmd
, NULL
, NULL
, FALSE
, 0, NULL
,
663 c_collen
, &si
, &info
);
668 ERR("Unable to execute command %s\n", debugstr_w(cmd
));
669 return ERROR_SUCCESS
;
671 CloseHandle( info
.hThread
);
673 r
= wait_process_handle(package
, type
, info
.hProcess
, action
);
678 static UINT
HANDLE_CustomType17(MSIPACKAGE
*package
, LPCWSTR source
,
679 LPCWSTR target
, const INT type
, LPCWSTR action
)
681 msi_custom_action_info
*info
;
684 TRACE("%s %s\n", debugstr_w(source
), debugstr_w(target
));
686 file
= get_loaded_file( package
, source
);
689 ERR("invalid file key %s\n", debugstr_w( source
));
690 return ERROR_FUNCTION_FAILED
;
693 info
= do_msidbCustomActionTypeDll( package
, type
, file
->TargetPath
, target
, action
);
695 return wait_thread_handle( info
);
698 static UINT
HANDLE_CustomType18(MSIPACKAGE
*package
, LPCWSTR source
,
699 LPCWSTR target
, const INT type
, LPCWSTR action
)
702 PROCESS_INFORMATION info
;
707 static const WCHAR spc
[] = {' ',0};
710 memset(&si
,0,sizeof(STARTUPINFOW
));
712 file
= get_loaded_file(package
,source
);
714 return ERROR_FUNCTION_FAILED
;
716 len
= lstrlenW( file
->TargetPath
);
718 deformat_string(package
,target
,&deformated
);
720 len
+= strlenW(deformated
);
723 cmd
= msi_alloc(len
* sizeof(WCHAR
));
725 lstrcpyW( cmd
, file
->TargetPath
);
729 strcatW(cmd
, deformated
);
731 msi_free(deformated
);
734 TRACE("executing exe %s\n", debugstr_w(cmd
));
736 rc
= CreateProcessW(NULL
, cmd
, NULL
, NULL
, FALSE
, 0, NULL
,
737 c_collen
, &si
, &info
);
741 ERR("Unable to execute command %s\n", debugstr_w(cmd
));
743 return ERROR_SUCCESS
;
746 CloseHandle( info
.hThread
);
748 return wait_process_handle(package
, type
, info
.hProcess
, action
);
751 static UINT
HANDLE_CustomType19(MSIPACKAGE
*package
, LPCWSTR source
,
752 LPCWSTR target
, const INT type
, LPCWSTR action
)
754 static const WCHAR query
[] = {
755 'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ',
756 'F','R','O','M',' ','`','E','r','r','o','r','`',' ',
757 'W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ',
761 LPWSTR deformated
= NULL
;
763 deformat_string( package
, target
, &deformated
);
765 /* first try treat the error as a number */
766 row
= MSI_QueryGetRecord( package
->db
, query
, deformated
);
769 LPCWSTR error
= MSI_RecordGetString( row
, 1 );
770 MessageBoxW( NULL
, error
, NULL
, MB_OK
);
771 msiobj_release( &row
->hdr
);
774 MessageBoxW( NULL
, deformated
, NULL
, MB_OK
);
776 msi_free( deformated
);
778 return ERROR_FUNCTION_FAILED
;
781 static UINT
HANDLE_CustomType50(MSIPACKAGE
*package
, LPCWSTR source
,
782 LPCWSTR target
, const INT type
, LPCWSTR action
)
785 PROCESS_INFORMATION info
;
791 static const WCHAR spc
[] = {' ',0};
793 memset(&si
,0,sizeof(STARTUPINFOW
));
794 memset(&info
,0,sizeof(PROCESS_INFORMATION
));
796 prop
= msi_dup_property( package
, source
);
798 return ERROR_SUCCESS
;
800 deformat_string(package
,target
,&deformated
);
801 len
= strlenW(prop
) + 2;
803 len
+= strlenW(deformated
);
805 cmd
= msi_alloc(sizeof(WCHAR
)*len
);
811 strcatW(cmd
,deformated
);
813 msi_free(deformated
);
817 TRACE("executing exe %s\n", debugstr_w(cmd
));
819 rc
= CreateProcessW(NULL
, cmd
, NULL
, NULL
, FALSE
, 0, NULL
,
820 c_collen
, &si
, &info
);
824 ERR("Unable to execute command %s\n", debugstr_w(cmd
));
826 return ERROR_SUCCESS
;
830 CloseHandle( info
.hThread
);
832 return wait_process_handle(package
, type
, info
.hProcess
, action
);
835 static UINT
HANDLE_CustomType34(MSIPACKAGE
*package
, LPCWSTR source
,
836 LPCWSTR target
, const INT type
, LPCWSTR action
)
838 LPWSTR filename
, deformated
;
840 PROCESS_INFORMATION info
;
843 memset(&si
,0,sizeof(STARTUPINFOW
));
845 filename
= resolve_folder(package
, source
, FALSE
, FALSE
, TRUE
, NULL
);
848 return ERROR_FUNCTION_FAILED
;
850 SetCurrentDirectoryW(filename
);
853 deformat_string(package
,target
,&deformated
);
856 return ERROR_FUNCTION_FAILED
;
858 TRACE("executing exe %s\n", debugstr_w(deformated
));
860 rc
= CreateProcessW(NULL
, deformated
, NULL
, NULL
, FALSE
, 0, NULL
,
861 c_collen
, &si
, &info
);
865 ERR("Unable to execute command %s\n", debugstr_w(deformated
));
866 msi_free(deformated
);
867 return ERROR_SUCCESS
;
869 msi_free(deformated
);
870 CloseHandle( info
.hThread
);
872 return wait_process_handle(package
, type
, info
.hProcess
, action
);
875 void ACTION_FinishCustomActions(MSIPACKAGE
* package
)
878 HANDLE
*wait_handles
;
879 unsigned int handle_count
, i
;
880 msi_custom_action_info
*info
, *cursor
;
882 while ((item
= list_head( &package
->RunningActions
)))
884 MSIRUNNINGACTION
*action
= LIST_ENTRY( item
, MSIRUNNINGACTION
, entry
);
886 list_remove( &action
->entry
);
888 TRACE("waiting for %s\n", debugstr_w( action
->name
) );
889 msi_dialog_check_messages( action
->handle
);
891 CloseHandle( action
->handle
);
892 msi_free( action
->name
);
896 EnterCriticalSection( &msi_custom_action_cs
);
898 handle_count
= list_count( &msi_pending_custom_actions
);
899 wait_handles
= HeapAlloc( GetProcessHeap(), 0, handle_count
* sizeof(HANDLE
) );
902 LIST_FOR_EACH_ENTRY_SAFE( info
, cursor
, &msi_pending_custom_actions
, msi_custom_action_info
, entry
)
904 if (info
->package
== package
)
906 if (DuplicateHandle(GetCurrentProcess(), info
->handle
, GetCurrentProcess(), &wait_handles
[handle_count
], SYNCHRONIZE
, FALSE
, 0))
908 free_custom_action_data( info
);
912 LeaveCriticalSection( &msi_custom_action_cs
);
914 for (i
= 0; i
< handle_count
; i
++)
916 msi_dialog_check_messages( wait_handles
[i
] );
917 CloseHandle( wait_handles
[i
] );
920 HeapFree( GetProcessHeap(), 0, wait_handles
);