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
36 #include "wine/heap.h"
37 #include "wine/debug.h"
38 #include "wine/exception.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
42 #define CUSTOM_ACTION_TYPE_MASK 0x3F
44 typedef struct tagMSIRUNNINGACTION
52 typedef UINT (WINAPI
*MsiCustomActionEntryPoint
)( MSIHANDLE
);
54 static CRITICAL_SECTION msi_custom_action_cs
;
55 static CRITICAL_SECTION_DEBUG msi_custom_action_cs_debug
=
57 0, 0, &msi_custom_action_cs
,
58 { &msi_custom_action_cs_debug
.ProcessLocksList
,
59 &msi_custom_action_cs_debug
.ProcessLocksList
},
60 0, 0, { (DWORD_PTR
)(__FILE__
": msi_custom_action_cs") }
62 static CRITICAL_SECTION msi_custom_action_cs
= { &msi_custom_action_cs_debug
, -1, 0, 0, 0, 0 };
64 static struct list msi_pending_custom_actions
= LIST_INIT( msi_pending_custom_actions
);
66 void __RPC_FAR
* __RPC_USER
MIDL_user_allocate(SIZE_T len
)
68 return heap_alloc(len
);
71 void __RPC_USER
MIDL_user_free(void __RPC_FAR
* ptr
)
76 LONG WINAPI
rpc_filter(EXCEPTION_POINTERS
*eptr
)
78 return I_RpcExceptionFilter(eptr
->ExceptionRecord
->ExceptionCode
);
81 UINT
msi_schedule_action( MSIPACKAGE
*package
, UINT script
, const WCHAR
*action
)
84 WCHAR
**newbuf
= NULL
;
86 if (script
>= SCRIPT_MAX
)
88 FIXME("Unknown script requested %u\n", script
);
89 return ERROR_FUNCTION_FAILED
;
91 TRACE("Scheduling action %s in script %u\n", debugstr_w(action
), script
);
93 count
= package
->script_actions_count
[script
];
94 package
->script_actions_count
[script
]++;
95 if (count
!= 0) newbuf
= msi_realloc( package
->script_actions
[script
],
96 package
->script_actions_count
[script
] * sizeof(WCHAR
*) );
97 else newbuf
= msi_alloc( sizeof(WCHAR
*) );
99 newbuf
[count
] = strdupW( action
);
100 package
->script_actions
[script
] = newbuf
;
101 return ERROR_SUCCESS
;
104 UINT
msi_register_unique_action( MSIPACKAGE
*package
, const WCHAR
*action
)
107 WCHAR
**newbuf
= NULL
;
109 TRACE("Registering %s as unique action\n", debugstr_w(action
));
111 count
= package
->unique_actions_count
;
112 package
->unique_actions_count
++;
113 if (count
!= 0) newbuf
= msi_realloc( package
->unique_actions
,
114 package
->unique_actions_count
* sizeof(WCHAR
*) );
115 else newbuf
= msi_alloc( sizeof(WCHAR
*) );
117 newbuf
[count
] = strdupW( action
);
118 package
->unique_actions
= newbuf
;
119 return ERROR_SUCCESS
;
122 BOOL
msi_action_is_unique( const MSIPACKAGE
*package
, const WCHAR
*action
)
126 for (i
= 0; i
< package
->unique_actions_count
; i
++)
128 if (!wcscmp( package
->unique_actions
[i
], action
)) return TRUE
;
133 static BOOL
check_execution_scheduling_options(MSIPACKAGE
*package
, LPCWSTR action
, UINT options
)
135 if ((options
& msidbCustomActionTypeClientRepeat
) ==
136 msidbCustomActionTypeClientRepeat
)
138 if (!(package
->InWhatSequence
& SEQUENCE_UI
&&
139 package
->InWhatSequence
& SEQUENCE_EXEC
))
141 TRACE("Skipping action due to dbCustomActionTypeClientRepeat option.\n");
145 else if (options
& msidbCustomActionTypeFirstSequence
)
147 if (package
->InWhatSequence
& SEQUENCE_UI
&&
148 package
->InWhatSequence
& SEQUENCE_EXEC
)
150 TRACE("Skipping action due to msidbCustomActionTypeFirstSequence option.\n");
154 else if (options
& msidbCustomActionTypeOncePerProcess
)
156 if (msi_action_is_unique(package
, action
))
158 TRACE("Skipping action due to msidbCustomActionTypeOncePerProcess option.\n");
162 msi_register_unique_action(package
, action
);
168 /* stores the following properties before the action:
170 * [CustomActionData<=>UserSID<=>ProductCode]Action
172 static LPWSTR
msi_get_deferred_action(LPCWSTR action
, LPCWSTR actiondata
,
173 LPCWSTR usersid
, LPCWSTR prodcode
)
179 return strdupW(action
);
181 len
= lstrlenW(action
) + lstrlenW(actiondata
) +
182 lstrlenW(usersid
) + lstrlenW(prodcode
) +
183 lstrlenW(L
"[%s<=>%s<=>%s]%s") - 7;
184 deferred
= msi_alloc(len
* sizeof(WCHAR
));
186 swprintf(deferred
, len
, L
"[%s<=>%s<=>%s]%s", actiondata
, usersid
, prodcode
, action
);
190 static void set_deferred_action_props( MSIPACKAGE
*package
, const WCHAR
*deferred_data
)
192 const WCHAR
*end
, *beg
= deferred_data
+ 1;
194 end
= wcsstr(beg
, L
"<=>");
195 msi_set_property( package
->db
, L
"CustomActionData", beg
, end
- beg
);
198 end
= wcsstr(beg
, L
"<=>");
199 msi_set_property( package
->db
, L
"UserSID", beg
, end
- beg
);
202 end
= wcschr(beg
, ']');
203 msi_set_property( package
->db
, L
"ProductCode", beg
, end
- beg
);
206 WCHAR
*msi_create_temp_file( MSIDATABASE
*db
)
213 UINT len
= ARRAY_SIZE( tmp
);
215 if (msi_get_property( db
, L
"TempFolder", tmp
, &len
) ||
216 GetFileAttributesW( tmp
) != FILE_ATTRIBUTE_DIRECTORY
)
218 GetTempPathW( MAX_PATH
, tmp
);
220 if (!(db
->tempfolder
= strdupW( tmp
))) return NULL
;
223 if ((ret
= msi_alloc( (lstrlenW( db
->tempfolder
) + 20) * sizeof(WCHAR
) )))
225 if (!GetTempFileNameW( db
->tempfolder
, L
"msi", 0, ret
))
235 static MSIBINARY
*create_temp_binary(MSIPACKAGE
*package
, LPCWSTR source
)
238 MSIBINARY
*binary
= NULL
;
245 if (!(tmpfile
= msi_create_temp_file( package
->db
))) return NULL
;
247 if (!(row
= MSI_QueryGetRecord( package
->db
, L
"SELECT * FROM `Binary` WHERE `Name` = '%s'", source
))) goto error
;
248 if (!(binary
= msi_alloc_zero( sizeof(MSIBINARY
) ))) goto error
;
250 file
= CreateFileW( tmpfile
, GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
251 if (file
== INVALID_HANDLE_VALUE
) goto error
;
256 r
= MSI_RecordReadStream( row
, 2, buffer
, &sz
);
257 if (r
!= ERROR_SUCCESS
)
259 ERR("Failed to get stream\n");
262 WriteFile( file
, buffer
, sz
, &write
, NULL
);
263 } while (sz
== sizeof buffer
);
266 if (r
!= ERROR_SUCCESS
) goto error
;
268 binary
->source
= strdupW( source
);
269 binary
->tmpfile
= tmpfile
;
270 list_add_tail( &package
->binaries
, &binary
->entry
);
272 msiobj_release( &row
->hdr
);
276 if (row
) msiobj_release( &row
->hdr
);
277 DeleteFileW( tmpfile
);
283 static MSIBINARY
*get_temp_binary(MSIPACKAGE
*package
, LPCWSTR source
)
287 LIST_FOR_EACH_ENTRY( binary
, &package
->binaries
, MSIBINARY
, entry
)
289 if (!wcscmp( binary
->source
, source
))
293 return create_temp_binary(package
, source
);
296 static void file_running_action(MSIPACKAGE
* package
, HANDLE Handle
,
297 BOOL process
, LPCWSTR name
)
299 MSIRUNNINGACTION
*action
;
301 action
= msi_alloc( sizeof(MSIRUNNINGACTION
) );
303 action
->handle
= Handle
;
304 action
->process
= process
;
305 action
->name
= strdupW(name
);
307 list_add_tail( &package
->RunningActions
, &action
->entry
);
310 static UINT
custom_get_process_return( HANDLE process
)
314 GetExitCodeProcess( process
, &rc
);
315 TRACE("exit code is %u\n", rc
);
317 return ERROR_FUNCTION_FAILED
;
318 return ERROR_SUCCESS
;
321 static UINT
custom_get_thread_return( MSIPACKAGE
*package
, HANDLE thread
)
325 GetExitCodeThread( thread
, &rc
);
329 case ERROR_FUNCTION_NOT_CALLED
:
331 case ERROR_INSTALL_USEREXIT
:
332 case ERROR_INSTALL_FAILURE
:
334 case ERROR_NO_MORE_ITEMS
:
335 return ERROR_SUCCESS
;
336 case ERROR_INSTALL_SUSPEND
:
337 ACTION_ForceReboot( package
);
338 return ERROR_SUCCESS
;
340 ERR("Invalid Return Code %d\n",rc
);
341 return ERROR_INSTALL_FAILURE
;
345 static UINT
wait_process_handle(MSIPACKAGE
* package
, UINT type
,
346 HANDLE ProcessHandle
, LPCWSTR name
)
348 UINT rc
= ERROR_SUCCESS
;
350 if (!(type
& msidbCustomActionTypeAsync
))
352 TRACE("waiting for %s\n", debugstr_w(name
));
354 msi_dialog_check_messages(ProcessHandle
);
356 if (!(type
& msidbCustomActionTypeContinue
))
357 rc
= custom_get_process_return(ProcessHandle
);
359 CloseHandle(ProcessHandle
);
363 TRACE("%s running in background\n", debugstr_w(name
));
365 if (!(type
& msidbCustomActionTypeContinue
))
366 file_running_action(package
, ProcessHandle
, TRUE
, name
);
368 CloseHandle(ProcessHandle
);
374 typedef struct _msi_custom_action_info
{
384 } msi_custom_action_info
;
386 static void free_custom_action_data( msi_custom_action_info
*info
)
388 EnterCriticalSection( &msi_custom_action_cs
);
390 list_remove( &info
->entry
);
392 CloseHandle( info
->handle
);
393 msi_free( info
->action
);
394 msi_free( info
->source
);
395 msi_free( info
->target
);
396 msiobj_release( &info
->package
->hdr
);
399 LeaveCriticalSection( &msi_custom_action_cs
);
402 static UINT
wait_thread_handle( msi_custom_action_info
*info
)
404 UINT rc
= ERROR_SUCCESS
;
406 if (!(info
->type
& msidbCustomActionTypeAsync
))
408 TRACE("waiting for %s\n", debugstr_w( info
->action
));
410 msi_dialog_check_messages( info
->handle
);
412 if (!(info
->type
& msidbCustomActionTypeContinue
))
413 rc
= custom_get_thread_return( info
->package
, info
->handle
);
415 free_custom_action_data( info
);
419 TRACE("%s running in background\n", debugstr_w( info
->action
));
425 static msi_custom_action_info
*find_action_by_guid( const GUID
*guid
)
427 msi_custom_action_info
*info
;
430 EnterCriticalSection( &msi_custom_action_cs
);
432 LIST_FOR_EACH_ENTRY( info
, &msi_pending_custom_actions
, msi_custom_action_info
, entry
)
434 if (IsEqualGUID( &info
->guid
, guid
))
441 LeaveCriticalSection( &msi_custom_action_cs
);
449 static void handle_msi_break(LPCSTR target
)
451 char format
[] = "To debug your custom action, attach your debugger to "
452 "process %i (0x%X) and press OK";
456 if (!GetEnvironmentVariableA("MsiBreak", val
, MAX_PATH
))
459 if (strcmp(val
, target
))
462 sprintf(msg
, format
, GetCurrentProcessId(), GetCurrentProcessId());
463 MessageBoxA(NULL
, msg
, "Windows Installer", MB_OK
);
468 /* wrapper for apps that don't declare the thread function correctly */
469 extern UINT
custom_proc_wrapper( MsiCustomActionEntryPoint entry
, MSIHANDLE hinst
);
470 __ASM_GLOBAL_FUNC(custom_proc_wrapper
,
472 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
473 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
475 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
480 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
481 __ASM_CFI(".cfi_same_value %ebp\n\t")
484 static UINT
custom_proc_wrapper( MsiCustomActionEntryPoint entry
, MSIHANDLE hinst
)
490 UINT CDECL
__wine_msi_call_dll_function(DWORD client_pid
, const GUID
*guid
)
492 MsiCustomActionEntryPoint fn
;
493 MSIHANDLE remote_package
= 0;
494 RPC_WSTR binding_str
;
503 TRACE("%s\n", debugstr_guid( guid
));
509 swprintf(endpoint
, ARRAY_SIZE(endpoint
), L
"msi%x", client_pid
);
510 status
= RpcStringBindingComposeW(NULL
, (WCHAR
*)L
"ncalrpc", NULL
, endpoint
, NULL
, &binding_str
);
511 if (status
!= RPC_S_OK
)
513 ERR("RpcStringBindingCompose failed: %#x\n", status
);
516 status
= RpcBindingFromStringBindingW(binding_str
, &rpc_handle
);
517 if (status
!= RPC_S_OK
)
519 ERR("RpcBindingFromStringBinding failed: %#x\n", status
);
522 RpcStringFreeW(&binding_str
);
525 r
= remote_GetActionInfo(guid
, &type
, &dll
, &proc
, &remote_package
);
526 if (r
!= ERROR_SUCCESS
)
529 hPackage
= alloc_msi_remote_handle( remote_package
);
532 ERR( "failed to create handle for %x\n", remote_package
);
533 midl_user_free( dll
);
534 midl_user_free( proc
);
535 return ERROR_INSTALL_FAILURE
;
538 hModule
= LoadLibraryW( dll
);
541 ERR( "failed to load dll %s (%u)\n", debugstr_w( dll
), GetLastError() );
542 midl_user_free( dll
);
543 midl_user_free( proc
);
544 MsiCloseHandle( hPackage
);
545 return ERROR_SUCCESS
;
548 fn
= (MsiCustomActionEntryPoint
) GetProcAddress( hModule
, proc
);
549 if (!fn
) WARN( "GetProcAddress(%s) failed\n", debugstr_a(proc
) );
552 handle_msi_break(proc
);
556 r
= custom_proc_wrapper( fn
, hPackage
);
560 ERR( "Custom action (%s:%s) caused a page fault: %08x\n",
561 debugstr_w(dll
), debugstr_a(proc
), GetExceptionCode() );
567 FreeLibrary(hModule
);
570 midl_user_free(proc
);
572 MsiCloseAllHandles();
577 static DWORD
custom_start_server(MSIPACKAGE
*package
, DWORD arch
)
579 WCHAR path
[MAX_PATH
], cmdline
[MAX_PATH
+ 23];
580 PROCESS_INFORMATION pi
= {0};
581 STARTUPINFOW si
= {0};
586 if ((arch
== SCS_32BIT_BINARY
&& package
->custom_server_32_process
) ||
587 (arch
== SCS_64BIT_BINARY
&& package
->custom_server_64_process
))
588 return ERROR_SUCCESS
;
590 swprintf(buffer
, ARRAY_SIZE(buffer
), L
"\\\\.\\pipe\\msica_%x_%d",
591 GetCurrentProcessId(), arch
== SCS_32BIT_BINARY
? 32 : 64);
592 pipe
= CreateNamedPipeW(buffer
, PIPE_ACCESS_DUPLEX
, 0, 1, sizeof(DWORD64
),
593 sizeof(GUID
), 0, NULL
);
594 if (pipe
== INVALID_HANDLE_VALUE
)
595 ERR("Failed to create custom action client pipe: %u\n", GetLastError());
597 if ((sizeof(void *) == 8 || is_wow64
) && arch
== SCS_32BIT_BINARY
)
598 GetSystemWow64DirectoryW(path
, MAX_PATH
- ARRAY_SIZE(L
"\\msiexec.exe"));
600 GetSystemDirectoryW(path
, MAX_PATH
- ARRAY_SIZE(L
"\\msiexec.exe"));
601 lstrcatW(path
, L
"\\msiexec.exe");
602 swprintf(cmdline
, ARRAY_SIZE(cmdline
), L
"%s -Embedding %d", path
, GetCurrentProcessId());
604 if (is_wow64
&& arch
== SCS_64BIT_BINARY
)
606 Wow64DisableWow64FsRedirection(&cookie
);
607 CreateProcessW(path
, cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
608 Wow64RevertWow64FsRedirection(cookie
);
611 CreateProcessW(path
, cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
613 CloseHandle(pi
.hThread
);
615 if (arch
== SCS_32BIT_BINARY
)
617 package
->custom_server_32_process
= pi
.hProcess
;
618 package
->custom_server_32_pipe
= pipe
;
622 package
->custom_server_64_process
= pi
.hProcess
;
623 package
->custom_server_64_pipe
= pipe
;
626 if (!ConnectNamedPipe(pipe
, NULL
))
628 ERR("Failed to connect to custom action server: %u\n", GetLastError());
629 return GetLastError();
632 return ERROR_SUCCESS
;
635 void custom_stop_server(HANDLE process
, HANDLE pipe
)
639 WriteFile(pipe
, &GUID_NULL
, sizeof(GUID_NULL
), &size
, NULL
);
640 WaitForSingleObject(process
, INFINITE
);
641 CloseHandle(process
);
645 static DWORD WINAPI
custom_client_thread(void *arg
)
647 msi_custom_action_info
*info
= arg
;
655 CoInitializeEx(NULL
, COINIT_MULTITHREADED
); /* needed to marshal streams */
657 if (info
->arch
== SCS_32BIT_BINARY
)
659 process
= info
->package
->custom_server_32_process
;
660 pipe
= info
->package
->custom_server_32_pipe
;
664 process
= info
->package
->custom_server_64_process
;
665 pipe
= info
->package
->custom_server_64_pipe
;
668 EnterCriticalSection(&msi_custom_action_cs
);
670 if (!WriteFile(pipe
, &info
->guid
, sizeof(info
->guid
), &size
, NULL
) ||
671 size
!= sizeof(info
->guid
))
673 ERR("Failed to write to custom action client pipe: %u\n", GetLastError());
674 LeaveCriticalSection(&msi_custom_action_cs
);
675 return GetLastError();
677 if (!ReadFile(pipe
, &thread64
, sizeof(thread64
), &size
, NULL
) || size
!= sizeof(thread64
))
679 ERR("Failed to read from custom action client pipe: %u\n", GetLastError());
680 LeaveCriticalSection(&msi_custom_action_cs
);
681 return GetLastError();
684 LeaveCriticalSection(&msi_custom_action_cs
);
686 if (DuplicateHandle(process
, (HANDLE
)(DWORD_PTR
)thread64
, GetCurrentProcess(),
687 &thread
, 0, FALSE
, DUPLICATE_SAME_ACCESS
| DUPLICATE_CLOSE_SOURCE
))
689 WaitForSingleObject(thread
, INFINITE
);
690 GetExitCodeThread(thread
, &rc
);
700 static msi_custom_action_info
*do_msidbCustomActionTypeDll(
701 MSIPACKAGE
*package
, INT type
, LPCWSTR source
, LPCWSTR target
, LPCWSTR action
)
703 msi_custom_action_info
*info
;
707 info
= msi_alloc( sizeof *info
);
711 msiobj_addref( &package
->hdr
);
712 info
->package
= package
;
714 info
->target
= strdupW( target
);
715 info
->source
= strdupW( source
);
716 info
->action
= strdupW( action
);
717 CoCreateGuid( &info
->guid
);
719 EnterCriticalSection( &msi_custom_action_cs
);
720 list_add_tail( &msi_pending_custom_actions
, &info
->entry
);
721 LeaveCriticalSection( &msi_custom_action_cs
);
723 if (!package
->rpc_server_started
)
727 swprintf(endpoint
, ARRAY_SIZE(endpoint
), L
"msi%x", GetCurrentProcessId());
728 status
= RpcServerUseProtseqEpW((WCHAR
*)L
"ncalrpc", RPC_C_PROTSEQ_MAX_REQS_DEFAULT
,
730 if (status
!= RPC_S_OK
)
732 ERR("RpcServerUseProtseqEp failed: %#x\n", status
);
736 status
= RpcServerRegisterIfEx(s_IWineMsiRemote_v0_0_s_ifspec
, NULL
, NULL
,
737 RPC_IF_AUTOLISTEN
, RPC_C_LISTEN_MAX_CALLS_DEFAULT
, NULL
);
738 if (status
!= RPC_S_OK
)
740 ERR("RpcServerRegisterIfEx failed: %#x\n", status
);
744 info
->package
->rpc_server_started
= 1;
747 ret
= GetBinaryTypeW(source
, &info
->arch
);
749 info
->arch
= (sizeof(void *) == 8 ? SCS_64BIT_BINARY
: SCS_32BIT_BINARY
);
751 if (info
->arch
== SCS_64BIT_BINARY
&& sizeof(void *) == 4 && !is_wow64
)
753 ERR("Attempt to run a 64-bit custom action inside a 32-bit WINEPREFIX.\n");
754 free_custom_action_data( info
);
758 custom_start_server(package
, info
->arch
);
760 info
->handle
= CreateThread(NULL
, 0, custom_client_thread
, info
, 0, NULL
);
763 free_custom_action_data( info
);
770 static UINT
HANDLE_CustomType1( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
771 INT type
, const WCHAR
*action
)
773 msi_custom_action_info
*info
;
776 if (!(binary
= get_temp_binary(package
, source
)))
777 return ERROR_FUNCTION_FAILED
;
779 TRACE("Calling function %s from %s\n", debugstr_w(target
), debugstr_w(binary
->tmpfile
));
781 if (!(info
= do_msidbCustomActionTypeDll( package
, type
, binary
->tmpfile
, target
, action
)))
782 return ERROR_FUNCTION_FAILED
;
783 return wait_thread_handle( info
);
786 static HANDLE
execute_command( const WCHAR
*app
, WCHAR
*arg
, const WCHAR
*dir
)
789 PROCESS_INFORMATION info
;
790 WCHAR
*exe
= NULL
, *cmd
= NULL
, *p
;
798 if (!(exe
= msi_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return INVALID_HANDLE_VALUE
;
799 len_exe
= SearchPathW( NULL
, app
, L
".exe", MAX_PATH
, exe
, NULL
);
800 if (len_exe
>= MAX_PATH
)
803 if (!(exe
= msi_alloc( len_exe
* sizeof(WCHAR
) ))) return INVALID_HANDLE_VALUE
;
804 len_exe
= SearchPathW( NULL
, app
, L
".exe", len_exe
, exe
, NULL
);
808 ERR("can't find executable %u\n", GetLastError());
810 return INVALID_HANDLE_VALUE
;
813 if (arg
) len_arg
= lstrlenW( arg
);
814 if (!(cmd
= msi_alloc( (len_exe
+ len_arg
+ 4) * sizeof(WCHAR
) )))
817 return INVALID_HANDLE_VALUE
;
820 if (wcschr( exe
, ' ' ))
823 memcpy( p
, exe
, len_exe
* sizeof(WCHAR
) );
836 memcpy( p
, arg
, len_arg
* sizeof(WCHAR
) );
840 memset( &si
, 0, sizeof(STARTUPINFOW
) );
841 ret
= CreateProcessW( exe
, exe
? cmd
: arg
, NULL
, NULL
, FALSE
, 0, NULL
, dir
, &si
, &info
);
846 ERR("unable to execute command %u\n", GetLastError());
847 return INVALID_HANDLE_VALUE
;
849 CloseHandle( info
.hThread
);
850 return info
.hProcess
;
853 static UINT
HANDLE_CustomType2( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
854 INT type
, const WCHAR
*action
)
860 if (!(binary
= get_temp_binary(package
, source
)))
861 return ERROR_FUNCTION_FAILED
;
863 deformat_string( package
, target
, &arg
);
864 TRACE("exe %s arg %s\n", debugstr_w(binary
->tmpfile
), debugstr_w(arg
));
866 handle
= execute_command( binary
->tmpfile
, arg
, L
"C:\\" );
868 if (handle
== INVALID_HANDLE_VALUE
) return ERROR_SUCCESS
;
869 return wait_process_handle( package
, type
, handle
, action
);
872 static UINT
HANDLE_CustomType17( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
873 INT type
, const WCHAR
*action
)
875 msi_custom_action_info
*info
;
878 TRACE("%s %s\n", debugstr_w(source
), debugstr_w(target
));
880 file
= msi_get_loaded_file( package
, source
);
883 ERR("invalid file key %s\n", debugstr_w( source
));
884 return ERROR_FUNCTION_FAILED
;
887 if (!(info
= do_msidbCustomActionTypeDll( package
, type
, file
->TargetPath
, target
, action
)))
888 return ERROR_FUNCTION_FAILED
;
889 return wait_thread_handle( info
);
892 static UINT
HANDLE_CustomType18( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
893 INT type
, const WCHAR
*action
)
899 if (!(file
= msi_get_loaded_file( package
, source
))) return ERROR_FUNCTION_FAILED
;
901 deformat_string( package
, target
, &arg
);
902 TRACE("exe %s arg %s\n", debugstr_w(file
->TargetPath
), debugstr_w(arg
));
904 handle
= execute_command( file
->TargetPath
, arg
, L
"C:\\" );
906 if (handle
== INVALID_HANDLE_VALUE
) return ERROR_SUCCESS
;
907 return wait_process_handle( package
, type
, handle
, action
);
910 static UINT
HANDLE_CustomType19( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
911 INT type
, const WCHAR
*action
)
914 LPWSTR deformated
= NULL
;
916 deformat_string( package
, target
, &deformated
);
918 /* first try treat the error as a number */
919 row
= MSI_QueryGetRecord( package
->db
, L
"SELECT `Message` FROM `Error` WHERE `Error` = '%s'", deformated
);
922 LPCWSTR error
= MSI_RecordGetString( row
, 1 );
923 if ((package
->ui_level
& INSTALLUILEVEL_MASK
) != INSTALLUILEVEL_NONE
)
924 MessageBoxW( NULL
, error
, NULL
, MB_OK
);
925 msiobj_release( &row
->hdr
);
927 else if ((package
->ui_level
& INSTALLUILEVEL_MASK
) != INSTALLUILEVEL_NONE
)
928 MessageBoxW( NULL
, deformated
, NULL
, MB_OK
);
930 msi_free( deformated
);
932 return ERROR_INSTALL_FAILURE
;
935 static WCHAR
*build_msiexec_args( const WCHAR
*filename
, const WCHAR
*params
)
937 UINT len_filename
= lstrlenW( filename
), len_params
= lstrlenW( params
);
938 UINT len
= ARRAY_SIZE(L
"/qb /i ") - 1;
941 if (!(ret
= msi_alloc( (len
+ len_filename
+ len_params
+ 4) * sizeof(WCHAR
) ))) return NULL
;
942 memcpy( ret
, L
"/qb /i ", sizeof(L
"/qb /i ") );
944 memcpy( ret
+ len
, filename
, len_filename
* sizeof(WCHAR
) );
948 lstrcpyW( ret
+ len
, params
);
952 static UINT
HANDLE_CustomType23( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
953 INT type
, const WCHAR
*action
)
955 WCHAR
*dir
, *filename
, *args
, *p
;
956 UINT len_dir
, len_source
= lstrlenW( source
);
959 if (!(dir
= msi_dup_property( package
->db
, L
"OriginalDatabase" ))) return ERROR_OUTOFMEMORY
;
960 if (!(p
= wcsrchr( dir
, '\\' )) && !(p
= wcsrchr( dir
, '/' )))
963 return ERROR_FUNCTION_FAILED
;
967 if (!(filename
= msi_alloc( (len_dir
+ len_source
+ 2) * sizeof(WCHAR
) )))
970 return ERROR_OUTOFMEMORY
;
972 memcpy( filename
, dir
, len_dir
* sizeof(WCHAR
) );
973 filename
[len_dir
++] = '\\';
974 memcpy( filename
+ len_dir
, source
, len_source
* sizeof(WCHAR
) );
975 filename
[len_dir
+ len_source
] = 0;
977 if (!(args
= build_msiexec_args( filename
, target
)))
980 return ERROR_OUTOFMEMORY
;
983 TRACE("installing %s concurrently\n", debugstr_w(source
));
985 handle
= execute_command( L
"msiexec", args
, dir
);
988 if (handle
== INVALID_HANDLE_VALUE
) return ERROR_SUCCESS
;
989 return wait_process_handle( package
, type
, handle
, action
);
992 static UINT
write_substorage_to_file( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*filename
)
994 IStorage
*src
= NULL
, *dst
= NULL
;
995 UINT r
= ERROR_FUNCTION_FAILED
;
998 hr
= StgCreateDocfile( filename
, STGM_CREATE
|STGM_TRANSACTED
|STGM_WRITE
|STGM_SHARE_EXCLUSIVE
, 0, &dst
);
1001 WARN( "can't open destination storage %s (%08x)\n", debugstr_w(filename
), hr
);
1005 hr
= IStorage_OpenStorage( package
->db
->storage
, source
, NULL
, STGM_SHARE_EXCLUSIVE
, NULL
, 0, &src
);
1008 WARN( "can't open source storage %s (%08x)\n", debugstr_w(source
), hr
);
1012 hr
= IStorage_CopyTo( src
, 0, NULL
, NULL
, dst
);
1015 ERR( "failed to copy storage %s (%08x)\n", debugstr_w(source
), hr
);
1019 hr
= IStorage_Commit( dst
, 0 );
1021 ERR( "failed to commit storage (%08x)\n", hr
);
1026 if (src
) IStorage_Release( src
);
1027 if (dst
) IStorage_Release( dst
);
1031 static UINT
HANDLE_CustomType7( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1032 INT type
, const WCHAR
*action
)
1034 WCHAR
*tmpfile
, *args
;
1035 MSIBINARY
*binary
= NULL
;
1039 if (!(tmpfile
= msi_create_temp_file( package
->db
))) return ERROR_FUNCTION_FAILED
;
1041 r
= write_substorage_to_file( package
, source
, tmpfile
);
1042 if (r
!= ERROR_SUCCESS
)
1045 if (!(binary
= msi_alloc( sizeof(*binary
) ))) goto error
;
1046 binary
->source
= NULL
;
1047 binary
->tmpfile
= tmpfile
;
1048 list_add_tail( &package
->binaries
, &binary
->entry
);
1050 if (!(args
= build_msiexec_args( tmpfile
, target
))) return ERROR_OUTOFMEMORY
;
1052 TRACE("installing %s concurrently\n", debugstr_w(source
));
1054 handle
= execute_command( L
"msiexec", args
, L
"C:\\" );
1056 if (handle
== INVALID_HANDLE_VALUE
) return ERROR_SUCCESS
;
1057 return wait_process_handle( package
, type
, handle
, action
);
1060 DeleteFileW( tmpfile
);
1061 msi_free( tmpfile
);
1062 return ERROR_FUNCTION_FAILED
;
1065 static UINT
HANDLE_CustomType50( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1066 INT type
, const WCHAR
*action
)
1071 if (!(exe
= msi_dup_property( package
->db
, source
))) return ERROR_SUCCESS
;
1073 deformat_string( package
, target
, &arg
);
1074 TRACE("exe %s arg %s\n", debugstr_w(exe
), debugstr_w(arg
));
1076 handle
= execute_command( exe
, arg
, L
"C:\\" );
1079 if (handle
== INVALID_HANDLE_VALUE
) return ERROR_SUCCESS
;
1080 return wait_process_handle( package
, type
, handle
, action
);
1083 static UINT
HANDLE_CustomType34( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1084 INT type
, const WCHAR
*action
)
1086 const WCHAR
*workingdir
= NULL
;
1092 workingdir
= msi_get_target_folder( package
, source
);
1093 if (!workingdir
) return ERROR_FUNCTION_FAILED
;
1095 deformat_string( package
, target
, &cmd
);
1096 if (!cmd
) return ERROR_FUNCTION_FAILED
;
1098 TRACE("cmd %s dir %s\n", debugstr_w(cmd
), debugstr_w(workingdir
));
1100 handle
= execute_command( NULL
, cmd
, workingdir
);
1102 if (handle
== INVALID_HANDLE_VALUE
) return ERROR_SUCCESS
;
1103 return wait_process_handle( package
, type
, handle
, action
);
1106 static DWORD
ACTION_CallScript( const GUID
*guid
)
1108 msi_custom_action_info
*info
;
1110 UINT r
= ERROR_FUNCTION_FAILED
;
1112 info
= find_action_by_guid( guid
);
1115 ERR("failed to find action %s\n", debugstr_guid( guid
) );
1116 return ERROR_FUNCTION_FAILED
;
1119 TRACE("function %s, script %s\n", debugstr_w( info
->target
), debugstr_w( info
->source
) );
1121 hPackage
= alloc_msihandle( &info
->package
->hdr
);
1124 r
= call_script( hPackage
, info
->type
, info
->source
, info
->target
, info
->action
);
1125 TRACE("script returned %u\n", r
);
1126 MsiCloseHandle( hPackage
);
1129 ERR("failed to create handle for %p\n", info
->package
);
1134 static DWORD WINAPI
ScriptThread( LPVOID arg
)
1139 TRACE("custom action (%x) started\n", GetCurrentThreadId() );
1141 rc
= ACTION_CallScript( guid
);
1143 TRACE("custom action (%x) returned %i\n", GetCurrentThreadId(), rc
);
1145 MsiCloseAllHandles();
1149 static msi_custom_action_info
*do_msidbCustomActionTypeScript(
1150 MSIPACKAGE
*package
, INT type
, LPCWSTR script
, LPCWSTR function
, LPCWSTR action
)
1152 msi_custom_action_info
*info
;
1154 info
= msi_alloc( sizeof *info
);
1158 msiobj_addref( &package
->hdr
);
1159 info
->package
= package
;
1161 info
->target
= strdupW( function
);
1162 info
->source
= strdupW( script
);
1163 info
->action
= strdupW( action
);
1164 CoCreateGuid( &info
->guid
);
1166 EnterCriticalSection( &msi_custom_action_cs
);
1167 list_add_tail( &msi_pending_custom_actions
, &info
->entry
);
1168 LeaveCriticalSection( &msi_custom_action_cs
);
1170 info
->handle
= CreateThread( NULL
, 0, ScriptThread
, &info
->guid
, 0, NULL
);
1173 free_custom_action_data( info
);
1180 static UINT
HANDLE_CustomType37_38( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1181 INT type
, const WCHAR
*action
)
1183 msi_custom_action_info
*info
;
1185 TRACE("%s %s\n", debugstr_w(source
), debugstr_w(target
));
1187 info
= do_msidbCustomActionTypeScript( package
, type
, target
, NULL
, action
);
1188 return wait_thread_handle( info
);
1191 static UINT
HANDLE_CustomType5_6( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1192 INT type
, const WCHAR
*action
)
1194 MSIRECORD
*row
= NULL
;
1195 msi_custom_action_info
*info
;
1196 CHAR
*buffer
= NULL
;
1197 WCHAR
*bufferw
= NULL
;
1201 TRACE("%s %s\n", debugstr_w(source
), debugstr_w(target
));
1203 row
= MSI_QueryGetRecord(package
->db
, L
"SELECT * FROM `Binary` WHERE `Name` = '%s'", source
);
1205 return ERROR_FUNCTION_FAILED
;
1207 r
= MSI_RecordReadStream(row
, 2, NULL
, &sz
);
1208 if (r
!= ERROR_SUCCESS
) goto done
;
1210 buffer
= msi_alloc( sz
+ 1 );
1213 r
= ERROR_FUNCTION_FAILED
;
1217 r
= MSI_RecordReadStream(row
, 2, buffer
, &sz
);
1218 if (r
!= ERROR_SUCCESS
)
1222 bufferw
= strdupAtoW(buffer
);
1225 r
= ERROR_FUNCTION_FAILED
;
1229 info
= do_msidbCustomActionTypeScript( package
, type
, bufferw
, target
, action
);
1230 r
= wait_thread_handle( info
);
1235 msiobj_release(&row
->hdr
);
1239 static UINT
HANDLE_CustomType21_22( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1240 INT type
, const WCHAR
*action
)
1242 msi_custom_action_info
*info
;
1245 DWORD sz
, szHighWord
= 0, read
;
1247 WCHAR
*bufferw
=NULL
;
1251 TRACE("%s %s\n", debugstr_w(source
), debugstr_w(target
));
1253 file
= msi_get_loaded_file(package
, source
);
1256 ERR("invalid file key %s\n", debugstr_w(source
));
1257 return ERROR_FUNCTION_FAILED
;
1260 hFile
= msi_create_file( package
, file
->TargetPath
, GENERIC_READ
, FILE_SHARE_READ
, OPEN_EXISTING
, 0 );
1261 if (hFile
== INVALID_HANDLE_VALUE
) return ERROR_FUNCTION_FAILED
;
1263 sz
= GetFileSize(hFile
, &szHighWord
);
1264 if (sz
== INVALID_FILE_SIZE
|| szHighWord
!= 0)
1267 return ERROR_FUNCTION_FAILED
;
1269 buffer
= msi_alloc( sz
+ 1 );
1273 return ERROR_FUNCTION_FAILED
;
1275 bRet
= ReadFile(hFile
, buffer
, sz
, &read
, NULL
);
1279 r
= ERROR_FUNCTION_FAILED
;
1283 bufferw
= strdupAtoW(buffer
);
1286 r
= ERROR_FUNCTION_FAILED
;
1289 info
= do_msidbCustomActionTypeScript( package
, type
, bufferw
, target
, action
);
1290 r
= wait_thread_handle( info
);
1298 static UINT
HANDLE_CustomType53_54( MSIPACKAGE
*package
, const WCHAR
*source
, const WCHAR
*target
,
1299 INT type
, const WCHAR
*action
)
1301 msi_custom_action_info
*info
;
1304 TRACE("%s %s\n", debugstr_w(source
), debugstr_w(target
));
1306 prop
= msi_dup_property( package
->db
, source
);
1307 if (!prop
) return ERROR_SUCCESS
;
1309 info
= do_msidbCustomActionTypeScript( package
, type
, prop
, NULL
, action
);
1311 return wait_thread_handle( info
);
1314 static BOOL
action_type_matches_script( UINT type
, UINT script
)
1320 case SCRIPT_INSTALL
:
1321 return !(type
& msidbCustomActionTypeCommit
) && !(type
& msidbCustomActionTypeRollback
);
1323 return (type
& msidbCustomActionTypeCommit
);
1324 case SCRIPT_ROLLBACK
:
1325 return (type
& msidbCustomActionTypeRollback
);
1327 ERR("unhandled script %u\n", script
);
1332 static UINT
defer_custom_action( MSIPACKAGE
*package
, const WCHAR
*action
, UINT type
)
1334 WCHAR
*actiondata
= msi_dup_property( package
->db
, action
);
1335 WCHAR
*usersid
= msi_dup_property( package
->db
, L
"UserSID" );
1336 WCHAR
*prodcode
= msi_dup_property( package
->db
, L
"ProductCode" );
1337 WCHAR
*deferred
= msi_get_deferred_action( action
, actiondata
, usersid
, prodcode
);
1341 msi_free( actiondata
);
1342 msi_free( usersid
);
1343 msi_free( prodcode
);
1344 return ERROR_OUTOFMEMORY
;
1346 if (type
& msidbCustomActionTypeCommit
)
1348 TRACE("deferring commit action\n");
1349 msi_schedule_action( package
, SCRIPT_COMMIT
, deferred
);
1351 else if (type
& msidbCustomActionTypeRollback
)
1353 TRACE("deferring rollback action\n");
1354 msi_schedule_action( package
, SCRIPT_ROLLBACK
, deferred
);
1358 TRACE("deferring install action\n");
1359 msi_schedule_action( package
, SCRIPT_INSTALL
, deferred
);
1362 msi_free( actiondata
);
1363 msi_free( usersid
);
1364 msi_free( prodcode
);
1365 msi_free( deferred
);
1366 return ERROR_SUCCESS
;
1369 UINT
ACTION_CustomAction(MSIPACKAGE
*package
, const WCHAR
*action
)
1371 UINT rc
= ERROR_SUCCESS
;
1374 const WCHAR
*source
, *target
, *ptr
, *deferred_data
= NULL
;
1375 WCHAR
*deformated
= NULL
;
1378 /* deferred action: [properties]Action */
1379 if ((ptr
= wcsrchr(action
, ']')))
1381 deferred_data
= action
;
1385 row
= MSI_QueryGetRecord( package
->db
, L
"SELECT * FROM `CustomAction` WHERE `Action` = '%s'", action
);
1387 return ERROR_FUNCTION_NOT_CALLED
;
1389 type
= MSI_RecordGetInteger(row
,2);
1390 source
= MSI_RecordGetString(row
,3);
1391 target
= MSI_RecordGetString(row
,4);
1393 TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action
),type
,
1394 debugstr_w(source
), debugstr_w(target
));
1396 /* handle some of the deferred actions */
1397 if (type
& msidbCustomActionTypeTSAware
)
1398 FIXME("msidbCustomActionTypeTSAware not handled\n");
1400 if (type
& msidbCustomActionTypeInScript
)
1402 if (type
& msidbCustomActionTypeNoImpersonate
)
1403 WARN("msidbCustomActionTypeNoImpersonate not handled\n");
1405 if (!action_type_matches_script(type
, package
->script
))
1407 rc
= defer_custom_action( package
, action
, type
);
1412 LPWSTR actiondata
= msi_dup_property( package
->db
, action
);
1414 if (type
& msidbCustomActionTypeInScript
)
1415 package
->scheduled_action_running
= TRUE
;
1417 if (type
& msidbCustomActionTypeCommit
)
1418 package
->commit_action_running
= TRUE
;
1420 if (type
& msidbCustomActionTypeRollback
)
1421 package
->rollback_action_running
= TRUE
;
1424 set_deferred_action_props(package
, deferred_data
);
1425 else if (actiondata
)
1426 msi_set_property( package
->db
, L
"CustomActionData", actiondata
, -1 );
1428 msi_set_property( package
->db
, L
"CustomActionData", L
"", -1 );
1430 msi_free(actiondata
);
1433 else if (!check_execution_scheduling_options(package
,action
,type
))
1439 switch (type
& CUSTOM_ACTION_TYPE_MASK
)
1441 case 1: /* DLL file stored in a Binary table stream */
1442 rc
= HANDLE_CustomType1( package
, source
, target
, type
, action
);
1444 case 2: /* EXE file stored in a Binary table stream */
1445 rc
= HANDLE_CustomType2( package
, source
, target
, type
, action
);
1448 case 6: /* JScript/VBScript file stored in a Binary table stream */
1449 rc
= HANDLE_CustomType5_6( package
, source
, target
, type
, action
);
1451 case 7: /* Concurrent install from substorage */
1452 deformat_string( package
, target
, &deformated
);
1453 rc
= HANDLE_CustomType7( package
, source
, target
, type
, action
);
1454 msi_free( deformated
);
1457 rc
= HANDLE_CustomType17( package
, source
, target
, type
, action
);
1459 case 18: /* EXE file installed with package */
1460 rc
= HANDLE_CustomType18( package
, source
, target
, type
, action
);
1462 case 19: /* Error that halts install */
1463 rc
= HANDLE_CustomType19( package
, source
, target
, type
, action
);
1465 case 21: /* JScript/VBScript file installed with the product */
1467 rc
= HANDLE_CustomType21_22( package
, source
, target
, type
, action
);
1469 case 23: /* Installs another package in the source tree */
1470 deformat_string( package
, target
, &deformated
);
1471 rc
= HANDLE_CustomType23( package
, source
, deformated
, type
, action
);
1472 msi_free( deformated
);
1474 case 34: /* EXE to be run in specified directory */
1475 rc
= HANDLE_CustomType34( package
, source
, target
, type
, action
);
1477 case 35: /* Directory set with formatted text */
1478 deformat_string( package
, target
, &deformated
);
1479 MSI_SetTargetPathW( package
, source
, deformated
);
1480 msi_free( deformated
);
1482 case 37: /* JScript/VBScript text stored in target column */
1484 rc
= HANDLE_CustomType37_38( package
, source
, target
, type
, action
);
1486 case 50: /* EXE file specified by a property value */
1487 rc
= HANDLE_CustomType50( package
, source
, target
, type
, action
);
1489 case 51: /* Property set with formatted text */
1491 len
= deformat_string( package
, target
, &deformated
);
1492 rc
= msi_set_property( package
->db
, source
, deformated
, len
);
1493 if (rc
== ERROR_SUCCESS
&& !wcscmp( source
, L
"SourceDir" )) msi_reset_source_folders( package
);
1494 msi_free( deformated
);
1496 case 53: /* JScript/VBScript text specified by a property value */
1498 rc
= HANDLE_CustomType53_54( package
, source
, target
, type
, action
);
1501 FIXME( "unhandled action type %u (%s %s)\n", type
& CUSTOM_ACTION_TYPE_MASK
, debugstr_w(source
),
1502 debugstr_w(target
) );
1506 package
->scheduled_action_running
= FALSE
;
1507 package
->commit_action_running
= FALSE
;
1508 package
->rollback_action_running
= FALSE
;
1509 msiobj_release(&row
->hdr
);
1513 void ACTION_FinishCustomActions(const MSIPACKAGE
* package
)
1516 HANDLE
*wait_handles
;
1517 unsigned int handle_count
, i
;
1518 msi_custom_action_info
*info
, *cursor
;
1520 while ((item
= list_head( &package
->RunningActions
)))
1522 MSIRUNNINGACTION
*action
= LIST_ENTRY( item
, MSIRUNNINGACTION
, entry
);
1524 list_remove( &action
->entry
);
1526 TRACE("waiting for %s\n", debugstr_w( action
->name
) );
1527 msi_dialog_check_messages( action
->handle
);
1529 CloseHandle( action
->handle
);
1530 msi_free( action
->name
);
1534 EnterCriticalSection( &msi_custom_action_cs
);
1536 handle_count
= list_count( &msi_pending_custom_actions
);
1537 wait_handles
= msi_alloc( handle_count
* sizeof(HANDLE
) );
1540 LIST_FOR_EACH_ENTRY_SAFE( info
, cursor
, &msi_pending_custom_actions
, msi_custom_action_info
, entry
)
1542 if (info
->package
== package
)
1544 if (DuplicateHandle(GetCurrentProcess(), info
->handle
, GetCurrentProcess(), &wait_handles
[handle_count
], SYNCHRONIZE
, FALSE
, 0))
1549 LeaveCriticalSection( &msi_custom_action_cs
);
1551 for (i
= 0; i
< handle_count
; i
++)
1553 msi_dialog_check_messages( wait_handles
[i
] );
1554 CloseHandle( wait_handles
[i
] );
1556 msi_free( wait_handles
);
1558 EnterCriticalSection( &msi_custom_action_cs
);
1559 LIST_FOR_EACH_ENTRY_SAFE( info
, cursor
, &msi_pending_custom_actions
, msi_custom_action_info
, entry
)
1561 if (info
->package
== package
)
1562 free_custom_action_data( info
);
1564 LeaveCriticalSection( &msi_custom_action_cs
);
1567 UINT __cdecl
s_remote_GetActionInfo(const GUID
*guid
, int *type
, LPWSTR
*dll
, LPSTR
*func
, MSIHANDLE
*hinst
)
1569 msi_custom_action_info
*info
;
1571 info
= find_action_by_guid(guid
);
1573 return ERROR_INVALID_DATA
;
1576 *hinst
= alloc_msihandle(&info
->package
->hdr
);
1577 *dll
= strdupW(info
->source
);
1578 *func
= strdupWtoA(info
->target
);
1580 return ERROR_SUCCESS
;