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
27 #define WIN32_NO_STATUS
39 #include "wine/debug.h"
40 #include "wine/exception.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
44 #define CUSTOM_ACTION_TYPE_MASK 0x3F
54 typedef UINT (WINAPI
*MsiCustomActionEntryPoint
)( MSIHANDLE
);
56 static CRITICAL_SECTION custom_action_cs
;
57 static CRITICAL_SECTION_DEBUG custom_action_cs_debug
=
59 0, 0, &custom_action_cs
,
60 { &custom_action_cs_debug
.ProcessLocksList
,
61 &custom_action_cs_debug
.ProcessLocksList
},
62 0, 0, { (DWORD_PTR
)(__FILE__
": custom_action_cs") }
64 static CRITICAL_SECTION custom_action_cs
= { &custom_action_cs_debug
, -1, 0, 0, 0, 0 };
66 static struct list pending_custom_actions
= LIST_INIT( pending_custom_actions
);
68 void __RPC_FAR
* __RPC_USER
MIDL_user_allocate(SIZE_T len
)
73 void __RPC_USER
MIDL_user_free(void __RPC_FAR
* ptr
)
78 LONG WINAPI
rpc_filter(EXCEPTION_POINTERS
*eptr
)
80 return I_RpcExceptionFilter(eptr
->ExceptionRecord
->ExceptionCode
);
83 UINT
msi_schedule_action( MSIPACKAGE
*package
, UINT script
, const WCHAR
*action
)
86 WCHAR
**newbuf
= NULL
;
88 if (script
>= SCRIPT_MAX
)
90 FIXME("Unknown script requested %u\n", script
);
91 return ERROR_FUNCTION_FAILED
;
93 TRACE("Scheduling action %s in script %u\n", debugstr_w(action
), script
);
95 count
= package
->script_actions_count
[script
];
96 package
->script_actions_count
[script
]++;
97 if (count
!= 0) newbuf
= realloc( package
->script_actions
[script
],
98 package
->script_actions_count
[script
] * sizeof(WCHAR
*) );
99 else newbuf
= malloc( sizeof(WCHAR
*) );
101 newbuf
[count
] = wcsdup( action
);
102 package
->script_actions
[script
] = newbuf
;
103 return ERROR_SUCCESS
;
106 UINT
msi_register_unique_action( MSIPACKAGE
*package
, const WCHAR
*action
)
109 WCHAR
**newbuf
= NULL
;
111 TRACE("Registering %s as unique action\n", debugstr_w(action
));
113 count
= package
->unique_actions_count
;
114 package
->unique_actions_count
++;
115 if (count
!= 0) newbuf
= realloc( package
->unique_actions
,
116 package
->unique_actions_count
* sizeof(WCHAR
*) );
117 else newbuf
= malloc( sizeof(WCHAR
*) );
119 newbuf
[count
] = wcsdup( action
);
120 package
->unique_actions
= newbuf
;
121 return ERROR_SUCCESS
;
124 BOOL
msi_action_is_unique( const MSIPACKAGE
*package
, const WCHAR
*action
)
128 for (i
= 0; i
< package
->unique_actions_count
; i
++)
130 if (!wcscmp( package
->unique_actions
[i
], action
)) return TRUE
;
135 static BOOL
check_execution_scheduling_options(MSIPACKAGE
*package
, LPCWSTR action
, UINT options
)
137 if ((options
& msidbCustomActionTypeClientRepeat
) ==
138 msidbCustomActionTypeClientRepeat
)
140 if (!(package
->InWhatSequence
& SEQUENCE_UI
&&
141 package
->InWhatSequence
& SEQUENCE_EXEC
))
143 TRACE("Skipping action due to dbCustomActionTypeClientRepeat option.\n");
147 else if (options
& msidbCustomActionTypeFirstSequence
)
149 if (package
->InWhatSequence
& SEQUENCE_UI
&&
150 package
->InWhatSequence
& SEQUENCE_EXEC
)
152 TRACE("Skipping action due to msidbCustomActionTypeFirstSequence option.\n");
156 else if (options
& msidbCustomActionTypeOncePerProcess
)
158 if (msi_action_is_unique(package
, action
))
160 TRACE("Skipping action due to msidbCustomActionTypeOncePerProcess option.\n");
164 msi_register_unique_action(package
, action
);
170 /* stores the following properties before the action:
172 * [CustomActionData<=>UserSID<=>ProductCode]Action
174 static WCHAR
*get_deferred_action(const WCHAR
*action
, const WCHAR
*actiondata
, const WCHAR
*usersid
,
175 const WCHAR
*prodcode
)
181 return wcsdup(action
);
183 len
= lstrlenW(action
) + lstrlenW(actiondata
) +
184 lstrlenW(usersid
) + lstrlenW(prodcode
) +
185 lstrlenW(L
"[%s<=>%s<=>%s]%s") - 7;
186 deferred
= malloc(len
* sizeof(WCHAR
));
188 swprintf(deferred
, len
, L
"[%s<=>%s<=>%s]%s", actiondata
, usersid
, prodcode
, action
);
192 static void set_deferred_action_props( MSIPACKAGE
*package
, const WCHAR
*deferred_data
)
194 const WCHAR
*end
, *beg
= deferred_data
+ 1;
196 end
= wcsstr(beg
, L
"<=>");
197 msi_set_property( package
->db
, L
"CustomActionData", beg
, end
- beg
);
200 end
= wcsstr(beg
, L
"<=>");
201 msi_set_property( package
->db
, L
"UserSID", beg
, end
- beg
);
204 end
= wcschr(beg
, ']');
205 msi_set_property( package
->db
, L
"ProductCode", beg
, end
- beg
);
208 WCHAR
*msi_create_temp_file( MSIDATABASE
*db
)
215 DWORD len
= ARRAY_SIZE( tmp
);
217 if (msi_get_property( db
, L
"TempFolder", tmp
, &len
) ||
218 GetFileAttributesW( tmp
) != FILE_ATTRIBUTE_DIRECTORY
)
220 GetTempPathW( MAX_PATH
, tmp
);
222 if (!(db
->tempfolder
= wcsdup( tmp
))) return NULL
;
225 if ((ret
= malloc( (wcslen( db
->tempfolder
) + 20) * sizeof(WCHAR
) )))
227 if (!GetTempFileNameW( db
->tempfolder
, L
"msi", 0, ret
))
237 static MSIBINARY
*create_temp_binary(MSIPACKAGE
*package
, LPCWSTR source
)
240 MSIBINARY
*binary
= NULL
;
247 if (!(tmpfile
= msi_create_temp_file( package
->db
))) return NULL
;
249 if (!(row
= MSI_QueryGetRecord( package
->db
, L
"SELECT * FROM `Binary` WHERE `Name` = '%s'", source
))) goto error
;
250 if (!(binary
= calloc( 1, sizeof(MSIBINARY
) ))) goto error
;
252 file
= CreateFileW( tmpfile
, GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
253 if (file
== INVALID_HANDLE_VALUE
) goto error
;
258 r
= MSI_RecordReadStream( row
, 2, buffer
, &sz
);
259 if (r
!= ERROR_SUCCESS
)
261 ERR("Failed to get stream\n");
264 WriteFile( file
, buffer
, sz
, &write
, NULL
);
265 } while (sz
== sizeof buffer
);
268 if (r
!= ERROR_SUCCESS
) goto error
;
270 binary
->source
= wcsdup( source
);
271 binary
->tmpfile
= tmpfile
;
272 list_add_tail( &package
->binaries
, &binary
->entry
);
274 msiobj_release( &row
->hdr
);
278 if (row
) msiobj_release( &row
->hdr
);
279 DeleteFileW( tmpfile
);
285 static MSIBINARY
*get_temp_binary(MSIPACKAGE
*package
, LPCWSTR source
)
289 LIST_FOR_EACH_ENTRY( binary
, &package
->binaries
, MSIBINARY
, entry
)
291 if (!wcscmp( binary
->source
, source
))
295 return create_temp_binary(package
, source
);
298 static void file_running_action(MSIPACKAGE
* package
, HANDLE Handle
,
299 BOOL process
, LPCWSTR name
)
301 struct running_action
*action
;
303 action
= malloc( sizeof(*action
) );
305 action
->handle
= Handle
;
306 action
->process
= process
;
307 action
->name
= wcsdup(name
);
309 list_add_tail( &package
->RunningActions
, &action
->entry
);
312 static UINT
custom_get_process_return( HANDLE process
)
316 GetExitCodeProcess( process
, &rc
);
317 TRACE( "exit code is %lu\n", rc
);
319 return ERROR_FUNCTION_FAILED
;
320 return ERROR_SUCCESS
;
323 static UINT
custom_get_thread_return( MSIPACKAGE
*package
, HANDLE thread
)
327 GetExitCodeThread( thread
, &rc
);
331 case ERROR_FUNCTION_NOT_CALLED
:
333 case ERROR_INSTALL_USEREXIT
:
334 case ERROR_INSTALL_FAILURE
:
336 case ERROR_NO_MORE_ITEMS
:
337 return ERROR_SUCCESS
;
338 case ERROR_INSTALL_SUSPEND
:
339 ACTION_ForceReboot( package
);
340 return ERROR_SUCCESS
;
342 ERR( "invalid Return Code %lu\n", rc
);
343 return ERROR_INSTALL_FAILURE
;
347 static UINT
wait_process_handle(MSIPACKAGE
* package
, UINT type
,
348 HANDLE ProcessHandle
, LPCWSTR name
)
350 UINT rc
= ERROR_SUCCESS
;
352 if (!(type
& msidbCustomActionTypeAsync
))
354 TRACE("waiting for %s\n", debugstr_w(name
));
356 msi_dialog_check_messages(ProcessHandle
);
358 if (!(type
& msidbCustomActionTypeContinue
))
359 rc
= custom_get_process_return(ProcessHandle
);
361 CloseHandle(ProcessHandle
);
365 TRACE("%s running in background\n", debugstr_w(name
));
367 if (!(type
& msidbCustomActionTypeContinue
))
368 file_running_action(package
, ProcessHandle
, TRUE
, name
);
370 CloseHandle(ProcessHandle
);
387 } custom_action_info
;
389 static void free_custom_action_data( custom_action_info
*info
)
391 EnterCriticalSection( &custom_action_cs
);
393 list_remove( &info
->entry
);
395 CloseHandle( info
->handle
);
396 free( info
->action
);
397 free( info
->source
);
398 free( info
->target
);
399 msiobj_release( &info
->package
->hdr
);
402 LeaveCriticalSection( &custom_action_cs
);
405 static UINT
wait_thread_handle( custom_action_info
*info
)
407 UINT rc
= ERROR_SUCCESS
;
409 if (!(info
->type
& msidbCustomActionTypeAsync
))
411 TRACE("waiting for %s\n", debugstr_w( info
->action
));
413 msi_dialog_check_messages( info
->handle
);
415 if (!(info
->type
& msidbCustomActionTypeContinue
))
416 rc
= custom_get_thread_return( info
->package
, info
->handle
);
418 free_custom_action_data( info
);
422 TRACE("%s running in background\n", debugstr_w( info
->action
));
428 static custom_action_info
*find_action_by_guid( const GUID
*guid
)
430 custom_action_info
*info
;
433 EnterCriticalSection( &custom_action_cs
);
435 LIST_FOR_EACH_ENTRY( info
, &pending_custom_actions
, custom_action_info
, entry
)
437 if (IsEqualGUID( &info
->guid
, guid
))
444 LeaveCriticalSection( &custom_action_cs
);
452 static void handle_msi_break( const WCHAR
*action
)
454 const WCHAR fmt
[] = L
"To debug your custom action, attach your debugger to process %u (0x%x) and press OK";
455 WCHAR val
[MAX_PATH
], msg
[100];
457 if (!GetEnvironmentVariableW( L
"MsiBreak", val
, MAX_PATH
) || wcscmp( val
, action
)) return;
459 swprintf( msg
, ARRAY_SIZE(msg
), fmt
, GetCurrentProcessId(), GetCurrentProcessId() );
460 MessageBoxW( NULL
, msg
, L
"Windows Installer", MB_OK
);
465 /* wrapper for apps that don't declare the thread function correctly */
466 extern UINT
custom_proc_wrapper( MsiCustomActionEntryPoint entry
, MSIHANDLE hinst
);
467 __ASM_GLOBAL_FUNC(custom_proc_wrapper
,
469 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
470 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
472 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
477 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
478 __ASM_CFI(".cfi_same_value %ebp\n\t")
481 static UINT
custom_proc_wrapper( MsiCustomActionEntryPoint entry
, MSIHANDLE hinst
)
487 UINT CDECL
__wine_msi_call_dll_function(DWORD client_pid
, const GUID
*guid
)
489 MsiCustomActionEntryPoint fn
;
490 MSIHANDLE remote_package
= 0;
491 RPC_WSTR binding_str
;
494 WCHAR
*dll
= NULL
, *action
= NULL
;
500 TRACE("%s\n", debugstr_guid( guid
));
506 swprintf(endpoint
, ARRAY_SIZE(endpoint
), L
"msi%x", client_pid
);
507 status
= RpcStringBindingComposeW(NULL
, (WCHAR
*)L
"ncalrpc", NULL
, endpoint
, NULL
, &binding_str
);
508 if (status
!= RPC_S_OK
)
510 ERR("RpcStringBindingCompose failed: %#lx\n", status
);
513 status
= RpcBindingFromStringBindingW(binding_str
, &rpc_handle
);
514 if (status
!= RPC_S_OK
)
516 ERR("RpcBindingFromStringBinding failed: %#lx\n", status
);
519 RpcStringFreeW(&binding_str
);
522 r
= remote_GetActionInfo(guid
, &action
, &type
, &dll
, &proc
, &remote_package
);
523 if (r
!= ERROR_SUCCESS
)
526 hPackage
= alloc_msi_remote_handle( remote_package
);
529 ERR( "failed to create handle for %#lx\n", remote_package
);
530 midl_user_free( action
);
531 midl_user_free( dll
);
532 midl_user_free( proc
);
533 return ERROR_INSTALL_FAILURE
;
536 hModule
= LoadLibraryW( dll
);
539 ERR( "failed to load dll %s (%lu)\n", debugstr_w( dll
), GetLastError() );
540 midl_user_free( action
);
541 midl_user_free( dll
);
542 midl_user_free( proc
);
543 MsiCloseHandle( hPackage
);
544 return ERROR_SUCCESS
;
547 fn
= (MsiCustomActionEntryPoint
) GetProcAddress( hModule
, proc
);
548 if (!fn
) WARN( "GetProcAddress(%s) failed\n", debugstr_a(proc
) );
551 handle_msi_break(action
);
555 r
= custom_proc_wrapper( fn
, hPackage
);
559 ERR( "Custom action (%s:%s) caused a page fault: %#lx\n",
560 debugstr_w(dll
), debugstr_a(proc
), GetExceptionCode() );
566 FreeLibrary(hModule
);
568 midl_user_free(action
);
570 midl_user_free(proc
);
572 MsiCloseAllHandles();
576 static DWORD
custom_start_server(MSIPACKAGE
*package
, DWORD arch
)
578 WCHAR path
[MAX_PATH
], cmdline
[MAX_PATH
+ 23];
579 PROCESS_INFORMATION pi
= {0};
580 STARTUPINFOW si
= {0};
585 if ((arch
== SCS_32BIT_BINARY
&& package
->custom_server_32_process
) ||
586 (arch
== SCS_64BIT_BINARY
&& package
->custom_server_64_process
))
587 return ERROR_SUCCESS
;
589 swprintf(buffer
, ARRAY_SIZE(buffer
), L
"\\\\.\\pipe\\msica_%x_%d",
590 GetCurrentProcessId(), arch
== SCS_32BIT_BINARY
? 32 : 64);
591 pipe
= CreateNamedPipeW(buffer
, PIPE_ACCESS_DUPLEX
, 0, 1, sizeof(DWORD64
),
592 sizeof(GUID
), 0, NULL
);
593 if (pipe
== INVALID_HANDLE_VALUE
)
594 ERR("failed to create custom action client pipe: %lu\n", GetLastError());
596 if ((sizeof(void *) == 8 || is_wow64
) && arch
== SCS_32BIT_BINARY
)
597 GetSystemWow64DirectoryW(path
, MAX_PATH
- ARRAY_SIZE(L
"\\msiexec.exe"));
599 GetSystemDirectoryW(path
, MAX_PATH
- ARRAY_SIZE(L
"\\msiexec.exe"));
600 lstrcatW(path
, L
"\\msiexec.exe");
601 swprintf(cmdline
, ARRAY_SIZE(cmdline
), L
"%s -Embedding %d", path
, GetCurrentProcessId());
603 if (is_wow64
&& arch
== SCS_64BIT_BINARY
)
605 Wow64DisableWow64FsRedirection(&cookie
);
606 CreateProcessW(path
, cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
607 Wow64RevertWow64FsRedirection(cookie
);
610 CreateProcessW(path
, cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
612 CloseHandle(pi
.hThread
);
614 if (arch
== SCS_32BIT_BINARY
)
616 package
->custom_server_32_process
= pi
.hProcess
;
617 package
->custom_server_32_pipe
= pipe
;
621 package
->custom_server_64_process
= pi
.hProcess
;
622 package
->custom_server_64_pipe
= pipe
;
625 if (!ConnectNamedPipe(pipe
, NULL
))
627 ERR("failed to connect to custom action server: %lu\n", GetLastError());
628 return GetLastError();
631 return ERROR_SUCCESS
;
634 void custom_stop_server(HANDLE process
, HANDLE pipe
)
638 WriteFile(pipe
, &GUID_NULL
, sizeof(GUID_NULL
), &size
, NULL
);
639 WaitForSingleObject(process
, INFINITE
);
640 CloseHandle(process
);
644 static DWORD WINAPI
custom_client_thread(void *arg
)
646 custom_action_info
*info
= arg
;
654 CoInitializeEx(NULL
, COINIT_MULTITHREADED
); /* needed to marshal streams */
656 if (info
->arch
== SCS_32BIT_BINARY
)
658 process
= info
->package
->custom_server_32_process
;
659 pipe
= info
->package
->custom_server_32_pipe
;
663 process
= info
->package
->custom_server_64_process
;
664 pipe
= info
->package
->custom_server_64_pipe
;
667 EnterCriticalSection(&custom_action_cs
);
669 if (!WriteFile(pipe
, &info
->guid
, sizeof(info
->guid
), &size
, NULL
) ||
670 size
!= sizeof(info
->guid
))
672 ERR("failed to write to custom action client pipe: %lu\n", GetLastError());
673 LeaveCriticalSection(&custom_action_cs
);
674 return GetLastError();
676 if (!ReadFile(pipe
, &thread64
, sizeof(thread64
), &size
, NULL
) || size
!= sizeof(thread64
))
678 ERR("failed to read from custom action client pipe: %lu\n", GetLastError());
679 LeaveCriticalSection(&custom_action_cs
);
680 return GetLastError();
683 LeaveCriticalSection(&custom_action_cs
);
685 if (DuplicateHandle(process
, (HANDLE
)(DWORD_PTR
)thread64
, GetCurrentProcess(),
686 &thread
, 0, FALSE
, DUPLICATE_SAME_ACCESS
| DUPLICATE_CLOSE_SOURCE
))
688 WaitForSingleObject(thread
, INFINITE
);
689 GetExitCodeThread(thread
, &rc
);
699 /* based on kernel32.GetBinaryTypeW() */
700 static BOOL
get_binary_type( const WCHAR
*name
, DWORD
*type
)
702 HANDLE hfile
, mapping
;
705 hfile
= CreateFileW( name
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0, 0 );
706 if (hfile
== INVALID_HANDLE_VALUE
)
709 status
= NtCreateSection( &mapping
, STANDARD_RIGHTS_REQUIRED
| SECTION_QUERY
, NULL
, NULL
, PAGE_READONLY
,
711 CloseHandle( hfile
);
717 SECTION_IMAGE_INFORMATION info
;
719 status
= NtQuerySection( mapping
, SectionImageInformation
, &info
, sizeof(info
), NULL
);
720 CloseHandle( mapping
);
721 if (status
) return FALSE
;
722 switch (info
.Machine
)
724 case IMAGE_FILE_MACHINE_I386
:
725 case IMAGE_FILE_MACHINE_ARMNT
:
726 *type
= SCS_32BIT_BINARY
;
728 case IMAGE_FILE_MACHINE_AMD64
:
729 case IMAGE_FILE_MACHINE_ARM64
:
730 *type
= SCS_64BIT_BINARY
;
736 case STATUS_INVALID_IMAGE_WIN_64
:
737 *type
= SCS_64BIT_BINARY
;
744 static custom_action_info
*do_msidbCustomActionTypeDll(
745 MSIPACKAGE
*package
, INT type
, LPCWSTR source
, LPCWSTR target
, LPCWSTR action
)
747 custom_action_info
*info
;
751 info
= malloc( sizeof *info
);
755 msiobj_addref( &package
->hdr
);
756 info
->package
= package
;
758 info
->target
= wcsdup( target
);
759 info
->source
= wcsdup( source
);
760 info
->action
= wcsdup( action
);
761 CoCreateGuid( &info
->guid
);
763 EnterCriticalSection( &custom_action_cs
);
764 list_add_tail( &pending_custom_actions
, &info
->entry
);
765 LeaveCriticalSection( &custom_action_cs
);
767 if (!package
->rpc_server_started
)
771 swprintf(endpoint
, ARRAY_SIZE(endpoint
), L
"msi%x", GetCurrentProcessId());
772 status
= RpcServerUseProtseqEpW((WCHAR
*)L
"ncalrpc", RPC_C_PROTSEQ_MAX_REQS_DEFAULT
,
774 if (status
!= RPC_S_OK
)
776 ERR("RpcServerUseProtseqEp failed: %#lx\n", status
);
780 status
= RpcServerRegisterIfEx(s_IWineMsiRemote_v0_0_s_ifspec
, NULL
, NULL
,
781 RPC_IF_AUTOLISTEN
, RPC_C_LISTEN_MAX_CALLS_DEFAULT
, NULL
);
782 if (status
!= RPC_S_OK
)
784 ERR("RpcServerRegisterIfEx failed: %#lx\n", status
);
788 info
->package
->rpc_server_started
= 1;
791 ret
= get_binary_type(source
, &info
->arch
);
793 info
->arch
= (sizeof(void *) == 8 ? SCS_64BIT_BINARY
: SCS_32BIT_BINARY
);
795 if (info
->arch
== SCS_64BIT_BINARY
&& sizeof(void *) == 4 && !is_wow64
)
797 ERR("Attempt to run a 64-bit custom action inside a 32-bit WINEPREFIX.\n");
798 free_custom_action_data( info
);
802 custom_start_server(package
, info
->arch
);
804 info
->handle
= CreateThread(NULL
, 0, custom_client_thread
, info
, 0, NULL
);
807 free_custom_action_data( info
);
814 static UINT
HANDLE_CustomType1( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
815 INT type
, const WCHAR
*action
)
817 custom_action_info
*info
;
820 if (!(binary
= get_temp_binary(package
, source
)))
821 return ERROR_FUNCTION_FAILED
;
823 TRACE("Calling function %s from %s\n", debugstr_w(target
), debugstr_w(binary
->tmpfile
));
825 if (!(info
= do_msidbCustomActionTypeDll( package
, type
, binary
->tmpfile
, target
, action
)))
826 return ERROR_FUNCTION_FAILED
;
827 return wait_thread_handle( info
);
830 static HANDLE
execute_command( const WCHAR
*app
, WCHAR
*arg
, const WCHAR
*dir
)
833 PROCESS_INFORMATION info
;
834 WCHAR
*exe
= NULL
, *cmd
= NULL
, *p
;
842 if (!(exe
= malloc( MAX_PATH
* sizeof(WCHAR
) ))) return INVALID_HANDLE_VALUE
;
843 len_exe
= SearchPathW( NULL
, app
, L
".exe", MAX_PATH
, exe
, NULL
);
844 if (len_exe
>= MAX_PATH
)
847 if (!(exe
= malloc( len_exe
* sizeof(WCHAR
) ))) return INVALID_HANDLE_VALUE
;
848 len_exe
= SearchPathW( NULL
, app
, L
".exe", len_exe
, exe
, NULL
);
852 ERR("can't find executable %lu\n", GetLastError());
854 return INVALID_HANDLE_VALUE
;
857 if (arg
) len_arg
= lstrlenW( arg
);
858 if (!(cmd
= malloc( (len_exe
+ len_arg
+ 4) * sizeof(WCHAR
) )))
861 return INVALID_HANDLE_VALUE
;
864 if (wcschr( exe
, ' ' ))
867 memcpy( p
, exe
, len_exe
* sizeof(WCHAR
) );
880 memcpy( p
, arg
, len_arg
* sizeof(WCHAR
) );
884 memset( &si
, 0, sizeof(STARTUPINFOW
) );
885 ret
= CreateProcessW( exe
, exe
? cmd
: arg
, NULL
, NULL
, FALSE
, 0, NULL
, dir
, &si
, &info
);
890 ERR("unable to execute command %lu\n", GetLastError());
891 return INVALID_HANDLE_VALUE
;
893 CloseHandle( info
.hThread
);
894 return info
.hProcess
;
897 static UINT
HANDLE_CustomType2( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
898 INT type
, const WCHAR
*action
)
904 if (!(binary
= get_temp_binary(package
, source
)))
905 return ERROR_FUNCTION_FAILED
;
907 deformat_string( package
, target
, &arg
);
908 TRACE("exe %s arg %s\n", debugstr_w(binary
->tmpfile
), debugstr_w(arg
));
910 handle
= execute_command( binary
->tmpfile
, arg
, L
"C:\\" );
912 if (handle
== INVALID_HANDLE_VALUE
) return ERROR_SUCCESS
;
913 return wait_process_handle( package
, type
, handle
, action
);
916 static UINT
HANDLE_CustomType17( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
917 INT type
, const WCHAR
*action
)
919 custom_action_info
*info
;
922 TRACE("%s %s\n", debugstr_w(source
), debugstr_w(target
));
924 file
= msi_get_loaded_file( package
, source
);
927 ERR("invalid file key %s\n", debugstr_w( source
));
928 return ERROR_FUNCTION_FAILED
;
931 if (!(info
= do_msidbCustomActionTypeDll( package
, type
, file
->TargetPath
, target
, action
)))
932 return ERROR_FUNCTION_FAILED
;
933 return wait_thread_handle( info
);
936 static UINT
HANDLE_CustomType18( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
937 INT type
, const WCHAR
*action
)
943 if (!(file
= msi_get_loaded_file( package
, source
))) return ERROR_FUNCTION_FAILED
;
945 deformat_string( package
, target
, &arg
);
946 TRACE("exe %s arg %s\n", debugstr_w(file
->TargetPath
), debugstr_w(arg
));
948 handle
= execute_command( file
->TargetPath
, arg
, L
"C:\\" );
950 if (handle
== INVALID_HANDLE_VALUE
) return ERROR_SUCCESS
;
951 return wait_process_handle( package
, type
, handle
, action
);
954 static UINT
HANDLE_CustomType19( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
955 INT type
, const WCHAR
*action
)
958 LPWSTR deformated
= NULL
;
960 deformat_string( package
, target
, &deformated
);
962 /* first try treat the error as a number */
963 row
= MSI_QueryGetRecord( package
->db
, L
"SELECT `Message` FROM `Error` WHERE `Error` = '%s'", deformated
);
966 LPCWSTR error
= MSI_RecordGetString( row
, 1 );
967 if ((package
->ui_level
& INSTALLUILEVEL_MASK
) != INSTALLUILEVEL_NONE
)
968 MessageBoxW( NULL
, error
, NULL
, MB_OK
);
969 msiobj_release( &row
->hdr
);
971 else if ((package
->ui_level
& INSTALLUILEVEL_MASK
) != INSTALLUILEVEL_NONE
)
972 MessageBoxW( NULL
, deformated
, NULL
, MB_OK
);
976 return ERROR_INSTALL_FAILURE
;
979 static WCHAR
*build_msiexec_args( const WCHAR
*filename
, const WCHAR
*params
)
981 UINT len_filename
= lstrlenW( filename
), len_params
= lstrlenW( params
);
982 UINT len
= ARRAY_SIZE(L
"/qb /i ") - 1;
985 if (!(ret
= malloc( (len
+ len_filename
+ len_params
+ 4) * sizeof(WCHAR
) ))) return NULL
;
986 memcpy( ret
, L
"/qb /i ", sizeof(L
"/qb /i ") );
988 memcpy( ret
+ len
, filename
, len_filename
* sizeof(WCHAR
) );
992 lstrcpyW( ret
+ len
, params
);
996 static UINT
HANDLE_CustomType23( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
997 INT type
, const WCHAR
*action
)
999 WCHAR
*dir
, *filename
, *args
, *p
;
1000 UINT len_dir
, len_source
= lstrlenW( source
);
1003 if (!(dir
= msi_dup_property( package
->db
, L
"OriginalDatabase" ))) return ERROR_OUTOFMEMORY
;
1004 if (!(p
= wcsrchr( dir
, '\\' )) && !(p
= wcsrchr( dir
, '/' )))
1007 return ERROR_FUNCTION_FAILED
;
1011 if (!(filename
= malloc( (len_dir
+ len_source
+ 2) * sizeof(WCHAR
) )))
1014 return ERROR_OUTOFMEMORY
;
1016 memcpy( filename
, dir
, len_dir
* sizeof(WCHAR
) );
1017 filename
[len_dir
++] = '\\';
1018 memcpy( filename
+ len_dir
, source
, len_source
* sizeof(WCHAR
) );
1019 filename
[len_dir
+ len_source
] = 0;
1021 if (!(args
= build_msiexec_args( filename
, target
)))
1024 return ERROR_OUTOFMEMORY
;
1027 TRACE("installing %s concurrently\n", debugstr_w(source
));
1029 handle
= execute_command( L
"msiexec", args
, dir
);
1032 if (handle
== INVALID_HANDLE_VALUE
) return ERROR_SUCCESS
;
1033 return wait_process_handle( package
, type
, handle
, action
);
1036 static UINT
write_substorage_to_file( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*filename
)
1038 IStorage
*src
= NULL
, *dst
= NULL
;
1039 UINT r
= ERROR_FUNCTION_FAILED
;
1042 hr
= StgCreateDocfile( filename
, STGM_CREATE
|STGM_TRANSACTED
|STGM_WRITE
|STGM_SHARE_EXCLUSIVE
, 0, &dst
);
1045 WARN( "can't open destination storage %s (%#lx)\n", debugstr_w(filename
), hr
);
1049 hr
= IStorage_OpenStorage( package
->db
->storage
, source
, NULL
, STGM_SHARE_EXCLUSIVE
, NULL
, 0, &src
);
1052 WARN( "can't open source storage %s (%#lx)\n", debugstr_w(source
), hr
);
1056 hr
= IStorage_CopyTo( src
, 0, NULL
, NULL
, dst
);
1059 ERR( "failed to copy storage %s (%#lx)\n", debugstr_w(source
), hr
);
1063 hr
= IStorage_Commit( dst
, 0 );
1065 ERR( "failed to commit storage (%#lx)\n", hr
);
1070 if (src
) IStorage_Release( src
);
1071 if (dst
) IStorage_Release( dst
);
1075 static UINT
HANDLE_CustomType7( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1076 INT type
, const WCHAR
*action
)
1078 WCHAR
*tmpfile
, *args
;
1079 MSIBINARY
*binary
= NULL
;
1083 if (!(tmpfile
= msi_create_temp_file( package
->db
))) return ERROR_FUNCTION_FAILED
;
1085 r
= write_substorage_to_file( package
, source
, tmpfile
);
1086 if (r
!= ERROR_SUCCESS
)
1089 if (!(binary
= malloc( sizeof(*binary
) ))) goto error
;
1090 binary
->source
= NULL
;
1091 binary
->tmpfile
= tmpfile
;
1092 list_add_tail( &package
->binaries
, &binary
->entry
);
1094 if (!(args
= build_msiexec_args( tmpfile
, target
))) return ERROR_OUTOFMEMORY
;
1096 TRACE("installing %s concurrently\n", debugstr_w(source
));
1098 handle
= execute_command( L
"msiexec", args
, L
"C:\\" );
1100 if (handle
== INVALID_HANDLE_VALUE
) return ERROR_SUCCESS
;
1101 return wait_process_handle( package
, type
, handle
, action
);
1104 DeleteFileW( tmpfile
);
1106 return ERROR_FUNCTION_FAILED
;
1109 static UINT
HANDLE_CustomType50( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1110 INT type
, const WCHAR
*action
)
1115 if (!(exe
= msi_dup_property( package
->db
, source
))) return ERROR_SUCCESS
;
1117 deformat_string( package
, target
, &arg
);
1118 TRACE("exe %s arg %s\n", debugstr_w(exe
), debugstr_w(arg
));
1120 handle
= execute_command( exe
, arg
, L
"C:\\" );
1123 if (handle
== INVALID_HANDLE_VALUE
) return ERROR_SUCCESS
;
1124 return wait_process_handle( package
, type
, handle
, action
);
1127 static UINT
HANDLE_CustomType34( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1128 INT type
, const WCHAR
*action
)
1130 const WCHAR
*workingdir
= NULL
;
1136 workingdir
= msi_get_target_folder( package
, source
);
1137 if (!workingdir
) return ERROR_FUNCTION_FAILED
;
1139 deformat_string( package
, target
, &cmd
);
1140 if (!cmd
) return ERROR_FUNCTION_FAILED
;
1142 TRACE("cmd %s dir %s\n", debugstr_w(cmd
), debugstr_w(workingdir
));
1144 handle
= execute_command( NULL
, cmd
, workingdir
);
1146 if (handle
== INVALID_HANDLE_VALUE
) return ERROR_SUCCESS
;
1147 return wait_process_handle( package
, type
, handle
, action
);
1150 static DWORD
ACTION_CallScript( const GUID
*guid
)
1152 custom_action_info
*info
;
1154 UINT r
= ERROR_FUNCTION_FAILED
;
1156 info
= find_action_by_guid( guid
);
1159 ERR("failed to find action %s\n", debugstr_guid( guid
) );
1160 return ERROR_FUNCTION_FAILED
;
1163 TRACE("function %s, script %s\n", debugstr_w( info
->target
), debugstr_w( info
->source
) );
1165 hPackage
= alloc_msihandle( &info
->package
->hdr
);
1168 r
= call_script( hPackage
, info
->type
, info
->source
, info
->target
, info
->action
);
1169 TRACE("script returned %u\n", r
);
1170 MsiCloseHandle( hPackage
);
1173 ERR("failed to create handle for %p\n", info
->package
);
1178 static DWORD WINAPI
ScriptThread( LPVOID arg
)
1183 TRACE("custom action (%#lx) started\n", GetCurrentThreadId() );
1185 rc
= ACTION_CallScript( guid
);
1187 TRACE("custom action (%#lx) returned %lu\n", GetCurrentThreadId(), rc
);
1189 MsiCloseAllHandles();
1193 static custom_action_info
*do_msidbCustomActionTypeScript(
1194 MSIPACKAGE
*package
, INT type
, LPCWSTR script
, LPCWSTR function
, LPCWSTR action
)
1196 custom_action_info
*info
;
1198 info
= malloc( sizeof *info
);
1202 msiobj_addref( &package
->hdr
);
1203 info
->package
= package
;
1205 info
->target
= wcsdup( function
);
1206 info
->source
= wcsdup( script
);
1207 info
->action
= wcsdup( action
);
1208 CoCreateGuid( &info
->guid
);
1210 EnterCriticalSection( &custom_action_cs
);
1211 list_add_tail( &pending_custom_actions
, &info
->entry
);
1212 LeaveCriticalSection( &custom_action_cs
);
1214 info
->handle
= CreateThread( NULL
, 0, ScriptThread
, &info
->guid
, 0, NULL
);
1217 free_custom_action_data( info
);
1224 static UINT
HANDLE_CustomType37_38( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1225 INT type
, const WCHAR
*action
)
1227 custom_action_info
*info
;
1229 TRACE("%s %s\n", debugstr_w(source
), debugstr_w(target
));
1231 info
= do_msidbCustomActionTypeScript( package
, type
, target
, NULL
, action
);
1232 return wait_thread_handle( info
);
1235 static UINT
HANDLE_CustomType5_6( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1236 INT type
, const WCHAR
*action
)
1238 MSIRECORD
*row
= NULL
;
1239 custom_action_info
*info
;
1240 CHAR
*buffer
= NULL
;
1241 WCHAR
*bufferw
= NULL
;
1245 TRACE("%s %s\n", debugstr_w(source
), debugstr_w(target
));
1247 row
= MSI_QueryGetRecord(package
->db
, L
"SELECT * FROM `Binary` WHERE `Name` = '%s'", source
);
1249 return ERROR_FUNCTION_FAILED
;
1251 r
= MSI_RecordReadStream(row
, 2, NULL
, &sz
);
1252 if (r
!= ERROR_SUCCESS
) goto done
;
1254 buffer
= malloc( sz
+ 1 );
1257 r
= ERROR_FUNCTION_FAILED
;
1261 r
= MSI_RecordReadStream(row
, 2, buffer
, &sz
);
1262 if (r
!= ERROR_SUCCESS
)
1266 bufferw
= strdupAtoW(buffer
);
1269 r
= ERROR_FUNCTION_FAILED
;
1273 info
= do_msidbCustomActionTypeScript( package
, type
, bufferw
, target
, action
);
1274 r
= wait_thread_handle( info
);
1279 msiobj_release(&row
->hdr
);
1283 static UINT
HANDLE_CustomType21_22( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1284 INT type
, const WCHAR
*action
)
1286 custom_action_info
*info
;
1289 DWORD sz
, szHighWord
= 0, read
;
1291 WCHAR
*bufferw
=NULL
;
1295 TRACE("%s %s\n", debugstr_w(source
), debugstr_w(target
));
1297 file
= msi_get_loaded_file(package
, source
);
1300 ERR("invalid file key %s\n", debugstr_w(source
));
1301 return ERROR_FUNCTION_FAILED
;
1304 hFile
= msi_create_file( package
, file
->TargetPath
, GENERIC_READ
, FILE_SHARE_READ
, OPEN_EXISTING
, 0 );
1305 if (hFile
== INVALID_HANDLE_VALUE
) return ERROR_FUNCTION_FAILED
;
1307 sz
= GetFileSize(hFile
, &szHighWord
);
1308 if (sz
== INVALID_FILE_SIZE
|| szHighWord
!= 0)
1311 return ERROR_FUNCTION_FAILED
;
1313 buffer
= malloc( sz
+ 1 );
1317 return ERROR_FUNCTION_FAILED
;
1319 bRet
= ReadFile(hFile
, buffer
, sz
, &read
, NULL
);
1323 r
= ERROR_FUNCTION_FAILED
;
1327 bufferw
= strdupAtoW(buffer
);
1330 r
= ERROR_FUNCTION_FAILED
;
1333 info
= do_msidbCustomActionTypeScript( package
, type
, bufferw
, target
, action
);
1334 r
= wait_thread_handle( info
);
1342 static UINT
HANDLE_CustomType53_54( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1343 INT type
, const WCHAR
*action
)
1345 custom_action_info
*info
;
1348 TRACE("%s %s\n", debugstr_w(source
), debugstr_w(target
));
1350 prop
= msi_dup_property( package
->db
, source
);
1351 if (!prop
) return ERROR_SUCCESS
;
1353 info
= do_msidbCustomActionTypeScript( package
, type
, prop
, NULL
, action
);
1355 return wait_thread_handle( info
);
1358 static BOOL
action_type_matches_script( UINT type
, UINT script
)
1364 case SCRIPT_INSTALL
:
1365 return !(type
& msidbCustomActionTypeCommit
) && !(type
& msidbCustomActionTypeRollback
);
1367 return (type
& msidbCustomActionTypeCommit
);
1368 case SCRIPT_ROLLBACK
:
1369 return (type
& msidbCustomActionTypeRollback
);
1371 ERR("unhandled script %u\n", script
);
1376 static UINT
defer_custom_action( MSIPACKAGE
*package
, const WCHAR
*action
, UINT type
)
1378 WCHAR
*actiondata
= msi_dup_property( package
->db
, action
);
1379 WCHAR
*usersid
= msi_dup_property( package
->db
, L
"UserSID" );
1380 WCHAR
*prodcode
= msi_dup_property( package
->db
, L
"ProductCode" );
1381 WCHAR
*deferred
= get_deferred_action( action
, actiondata
, usersid
, prodcode
);
1388 return ERROR_OUTOFMEMORY
;
1390 if (type
& msidbCustomActionTypeCommit
)
1392 TRACE("deferring commit action\n");
1393 msi_schedule_action( package
, SCRIPT_COMMIT
, deferred
);
1395 else if (type
& msidbCustomActionTypeRollback
)
1397 TRACE("deferring rollback action\n");
1398 msi_schedule_action( package
, SCRIPT_ROLLBACK
, deferred
);
1402 TRACE("deferring install action\n");
1403 msi_schedule_action( package
, SCRIPT_INSTALL
, deferred
);
1410 return ERROR_SUCCESS
;
1413 UINT
ACTION_CustomAction(MSIPACKAGE
*package
, const WCHAR
*action
)
1415 UINT rc
= ERROR_SUCCESS
;
1418 const WCHAR
*source
, *target
, *ptr
, *deferred_data
= NULL
;
1419 WCHAR
*deformated
= NULL
;
1422 /* deferred action: [properties]Action */
1423 if ((ptr
= wcsrchr(action
, ']')))
1425 deferred_data
= action
;
1429 row
= MSI_QueryGetRecord( package
->db
, L
"SELECT * FROM `CustomAction` WHERE `Action` = '%s'", action
);
1431 return ERROR_FUNCTION_NOT_CALLED
;
1433 type
= MSI_RecordGetInteger(row
,2);
1434 source
= MSI_RecordGetString(row
,3);
1435 target
= MSI_RecordGetString(row
,4);
1437 TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action
),type
,
1438 debugstr_w(source
), debugstr_w(target
));
1440 /* handle some of the deferred actions */
1441 if (type
& msidbCustomActionTypeTSAware
)
1442 FIXME("msidbCustomActionTypeTSAware not handled\n");
1444 if (type
& msidbCustomActionTypeInScript
)
1446 if (type
& msidbCustomActionTypeNoImpersonate
)
1447 WARN("msidbCustomActionTypeNoImpersonate not handled\n");
1449 if (!action_type_matches_script(type
, package
->script
))
1451 rc
= defer_custom_action( package
, action
, type
);
1456 LPWSTR actiondata
= msi_dup_property( package
->db
, action
);
1458 if (type
& msidbCustomActionTypeInScript
)
1459 package
->scheduled_action_running
= TRUE
;
1461 if (type
& msidbCustomActionTypeCommit
)
1462 package
->commit_action_running
= TRUE
;
1464 if (type
& msidbCustomActionTypeRollback
)
1465 package
->rollback_action_running
= TRUE
;
1468 set_deferred_action_props(package
, deferred_data
);
1469 else if (actiondata
)
1470 msi_set_property( package
->db
, L
"CustomActionData", actiondata
, -1 );
1472 msi_set_property( package
->db
, L
"CustomActionData", L
"", -1 );
1477 else if (!check_execution_scheduling_options(package
,action
,type
))
1483 switch (type
& CUSTOM_ACTION_TYPE_MASK
)
1485 case 1: /* DLL file stored in a Binary table stream */
1486 rc
= HANDLE_CustomType1( package
, source
, target
, type
, action
);
1488 case 2: /* EXE file stored in a Binary table stream */
1489 rc
= HANDLE_CustomType2( package
, source
, target
, type
, action
);
1492 case 6: /* JScript/VBScript file stored in a Binary table stream */
1493 rc
= HANDLE_CustomType5_6( package
, source
, target
, type
, action
);
1495 case 7: /* Concurrent install from substorage */
1496 deformat_string( package
, target
, &deformated
);
1497 rc
= HANDLE_CustomType7( package
, source
, target
, type
, action
);
1501 rc
= HANDLE_CustomType17( package
, source
, target
, type
, action
);
1503 case 18: /* EXE file installed with package */
1504 rc
= HANDLE_CustomType18( package
, source
, target
, type
, action
);
1506 case 19: /* Error that halts install */
1507 rc
= HANDLE_CustomType19( package
, source
, target
, type
, action
);
1509 case 21: /* JScript/VBScript file installed with the product */
1511 rc
= HANDLE_CustomType21_22( package
, source
, target
, type
, action
);
1513 case 23: /* Installs another package in the source tree */
1514 deformat_string( package
, target
, &deformated
);
1515 rc
= HANDLE_CustomType23( package
, source
, deformated
, type
, action
);
1518 case 34: /* EXE to be run in specified directory */
1519 rc
= HANDLE_CustomType34( package
, source
, target
, type
, action
);
1521 case 35: /* Directory set with formatted text */
1522 deformat_string( package
, target
, &deformated
);
1523 MSI_SetTargetPathW( package
, source
, deformated
);
1526 case 37: /* JScript/VBScript text stored in target column */
1528 rc
= HANDLE_CustomType37_38( package
, source
, target
, type
, action
);
1530 case 50: /* EXE file specified by a property value */
1531 rc
= HANDLE_CustomType50( package
, source
, target
, type
, action
);
1533 case 51: /* Property set with formatted text */
1535 len
= deformat_string( package
, target
, &deformated
);
1536 rc
= msi_set_property( package
->db
, source
, deformated
, len
);
1537 if (rc
== ERROR_SUCCESS
&& !wcscmp( source
, L
"SourceDir" )) msi_reset_source_folders( package
);
1540 case 53: /* JScript/VBScript text specified by a property value */
1542 rc
= HANDLE_CustomType53_54( package
, source
, target
, type
, action
);
1545 FIXME( "unhandled action type %u (%s %s)\n", type
& CUSTOM_ACTION_TYPE_MASK
, debugstr_w(source
),
1546 debugstr_w(target
) );
1550 package
->scheduled_action_running
= FALSE
;
1551 package
->commit_action_running
= FALSE
;
1552 package
->rollback_action_running
= FALSE
;
1553 msiobj_release(&row
->hdr
);
1557 void ACTION_FinishCustomActions(const MSIPACKAGE
* package
)
1560 HANDLE
*wait_handles
;
1561 unsigned int handle_count
, i
;
1562 custom_action_info
*info
, *cursor
;
1564 while ((item
= list_head( &package
->RunningActions
)))
1566 struct running_action
*action
= LIST_ENTRY( item
, struct running_action
, entry
);
1568 list_remove( &action
->entry
);
1570 TRACE("waiting for %s\n", debugstr_w( action
->name
) );
1571 msi_dialog_check_messages( action
->handle
);
1573 CloseHandle( action
->handle
);
1574 free( action
->name
);
1578 EnterCriticalSection( &custom_action_cs
);
1580 handle_count
= list_count( &pending_custom_actions
);
1581 wait_handles
= malloc( handle_count
* sizeof(HANDLE
) );
1584 LIST_FOR_EACH_ENTRY_SAFE( info
, cursor
, &pending_custom_actions
, custom_action_info
, entry
)
1586 if (info
->package
== package
)
1588 if (DuplicateHandle(GetCurrentProcess(), info
->handle
, GetCurrentProcess(), &wait_handles
[handle_count
], SYNCHRONIZE
, FALSE
, 0))
1593 LeaveCriticalSection( &custom_action_cs
);
1595 for (i
= 0; i
< handle_count
; i
++)
1597 msi_dialog_check_messages( wait_handles
[i
] );
1598 CloseHandle( wait_handles
[i
] );
1600 free( wait_handles
);
1602 EnterCriticalSection( &custom_action_cs
);
1603 LIST_FOR_EACH_ENTRY_SAFE( info
, cursor
, &pending_custom_actions
, custom_action_info
, entry
)
1605 if (info
->package
== package
)
1606 free_custom_action_data( info
);
1608 LeaveCriticalSection( &custom_action_cs
);
1611 UINT __cdecl
s_remote_GetActionInfo(const GUID
*guid
, WCHAR
**name
, int *type
, WCHAR
**dll
, char **func
, MSIHANDLE
*hinst
)
1613 custom_action_info
*info
;
1615 info
= find_action_by_guid(guid
);
1617 return ERROR_INVALID_DATA
;
1619 *name
= wcsdup(info
->action
);
1621 *hinst
= alloc_msihandle(&info
->package
->hdr
);
1622 *dll
= wcsdup(info
->source
);
1623 *func
= strdupWtoA(info
->target
);
1625 return ERROR_SUCCESS
;