urlmon/tests: Use BOOL type where appropriate.
[wine/multimedia.git] / dlls / msi / custom.c
blob63bec19bc91cd3f58d128fe04fb46579f0e785e5
1 /*
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
21 #include "config.h"
22 #include "wine/port.h"
24 #define COBJMACROS
26 #include <stdarg.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winerror.h"
30 #include "msidefs.h"
31 #include "winuser.h"
32 #include "objbase.h"
33 #include "oleauto.h"
35 #include "msipriv.h"
36 #include "msiserver.h"
37 #include "wine/debug.h"
38 #include "wine/unicode.h"
39 #include "wine/exception.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msi);
43 #define CUSTOM_ACTION_TYPE_MASK 0x3F
45 typedef struct tagMSIRUNNINGACTION
47 struct list entry;
48 HANDLE handle;
49 BOOL process;
50 LPWSTR name;
51 } MSIRUNNINGACTION;
53 typedef UINT (WINAPI *MsiCustomActionEntryPoint)( MSIHANDLE );
55 static CRITICAL_SECTION msi_custom_action_cs;
56 static CRITICAL_SECTION_DEBUG msi_custom_action_cs_debug =
58 0, 0, &msi_custom_action_cs,
59 { &msi_custom_action_cs_debug.ProcessLocksList,
60 &msi_custom_action_cs_debug.ProcessLocksList },
61 0, 0, { (DWORD_PTR)(__FILE__ ": msi_custom_action_cs") }
63 static CRITICAL_SECTION msi_custom_action_cs = { &msi_custom_action_cs_debug, -1, 0, 0, 0, 0 };
65 static struct list msi_pending_custom_actions = LIST_INIT( msi_pending_custom_actions );
67 UINT msi_schedule_action( MSIPACKAGE *package, UINT script, const WCHAR *action )
69 UINT count;
70 WCHAR **newbuf = NULL;
72 if (script >= SCRIPT_MAX)
74 FIXME("Unknown script requested %u\n", script);
75 return ERROR_FUNCTION_FAILED;
77 TRACE("Scheduling action %s in script %u\n", debugstr_w(action), script);
79 count = package->script->ActionCount[script];
80 package->script->ActionCount[script]++;
81 if (count != 0) newbuf = msi_realloc( package->script->Actions[script],
82 package->script->ActionCount[script] * sizeof(WCHAR *) );
83 else newbuf = msi_alloc( sizeof(WCHAR *) );
85 newbuf[count] = strdupW( action );
86 package->script->Actions[script] = newbuf;
87 return ERROR_SUCCESS;
90 UINT msi_register_unique_action( MSIPACKAGE *package, const WCHAR *action )
92 UINT count;
93 WCHAR **newbuf = NULL;
95 if (!package->script) return FALSE;
97 TRACE("Registering %s as unique action\n", debugstr_w(action));
99 count = package->script->UniqueActionsCount;
100 package->script->UniqueActionsCount++;
101 if (count != 0) newbuf = msi_realloc( package->script->UniqueActions,
102 package->script->UniqueActionsCount * sizeof(WCHAR *) );
103 else newbuf = msi_alloc( sizeof(WCHAR *) );
105 newbuf[count] = strdupW( action );
106 package->script->UniqueActions = newbuf;
107 return ERROR_SUCCESS;
110 BOOL msi_action_is_unique( const MSIPACKAGE *package, const WCHAR *action )
112 UINT i;
114 if (!package->script) return FALSE;
116 for (i = 0; i < package->script->UniqueActionsCount; i++)
118 if (!strcmpW( package->script->UniqueActions[i], action )) return TRUE;
120 return FALSE;
123 static BOOL check_execution_scheduling_options(MSIPACKAGE *package, LPCWSTR action, UINT options)
125 if (!package->script)
126 return TRUE;
128 if ((options & msidbCustomActionTypeClientRepeat) ==
129 msidbCustomActionTypeClientRepeat)
131 if (!(package->script->InWhatSequence & SEQUENCE_UI &&
132 package->script->InWhatSequence & SEQUENCE_EXEC))
134 TRACE("Skipping action due to dbCustomActionTypeClientRepeat option.\n");
135 return FALSE;
138 else if (options & msidbCustomActionTypeFirstSequence)
140 if (package->script->InWhatSequence & SEQUENCE_UI &&
141 package->script->InWhatSequence & SEQUENCE_EXEC )
143 TRACE("Skipping action due to msidbCustomActionTypeFirstSequence option.\n");
144 return FALSE;
147 else if (options & msidbCustomActionTypeOncePerProcess)
149 if (msi_action_is_unique(package, action))
151 TRACE("Skipping action due to msidbCustomActionTypeOncePerProcess option.\n");
152 return FALSE;
154 else
155 msi_register_unique_action(package, action);
158 return TRUE;
161 /* stores the following properties before the action:
163 * [CustomActionData<=>UserSID<=>ProductCode]Action
165 static LPWSTR msi_get_deferred_action(LPCWSTR action, LPCWSTR actiondata,
166 LPCWSTR usersid, LPCWSTR prodcode)
168 LPWSTR deferred;
169 DWORD len;
171 static const WCHAR format[] = {
172 '[','%','s','<','=','>','%','s','<','=','>','%','s',']','%','s',0
175 if (!actiondata)
176 return strdupW(action);
178 len = lstrlenW(action) + lstrlenW(actiondata) +
179 lstrlenW(usersid) + lstrlenW(prodcode) +
180 lstrlenW(format) - 7;
181 deferred = msi_alloc(len * sizeof(WCHAR));
183 sprintfW(deferred, format, actiondata, usersid, prodcode, action);
184 return deferred;
187 static void set_deferred_action_props( MSIPACKAGE *package, const WCHAR *deferred_data )
189 static const WCHAR sep[] = {'<','=','>',0};
190 const WCHAR *end, *beg = deferred_data + 1;
192 end = strstrW(beg, sep);
193 msi_set_property( package->db, szCustomActionData, beg, end - beg );
194 beg = end + 3;
196 end = strstrW(beg, sep);
197 msi_set_property( package->db, szUserSID, beg, end - beg );
198 beg = end + 3;
200 end = strchrW(beg, ']');
201 msi_set_property( package->db, szProductCode, beg, end - beg );
204 static MSIBINARY *create_temp_binary( MSIPACKAGE *package, LPCWSTR source, BOOL dll )
206 static const WCHAR query[] = {
207 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
208 '`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E',' ',
209 '`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0};
210 MSIRECORD *row;
211 MSIBINARY *binary;
212 HANDLE file;
213 CHAR buffer[1024];
214 WCHAR fmt[MAX_PATH], tmpfile[MAX_PATH];
215 DWORD sz = MAX_PATH, write;
216 UINT r;
218 if (msi_get_property(package->db, szTempFolder, fmt, &sz) != ERROR_SUCCESS ||
219 GetFileAttributesW(fmt) == INVALID_FILE_ATTRIBUTES) GetTempPathW(MAX_PATH, fmt);
221 if (!GetTempFileNameW( fmt, szMsi, 0, tmpfile ))
223 TRACE("unable to create temp file %s (%u)\n", debugstr_w(tmpfile), GetLastError());
224 return NULL;
227 row = MSI_QueryGetRecord(package->db, query, source);
228 if (!row)
229 return NULL;
231 if (!(binary = msi_alloc_zero( sizeof(MSIBINARY) )))
233 msiobj_release( &row->hdr );
234 return NULL;
236 file = CreateFileW( tmpfile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
237 if (file == INVALID_HANDLE_VALUE)
239 msiobj_release( &row->hdr );
240 msi_free( binary );
241 return NULL;
245 sz = sizeof(buffer);
246 r = MSI_RecordReadStream( row, 2, buffer, &sz );
247 if (r != ERROR_SUCCESS)
249 ERR("Failed to get stream\n");
250 break;
252 WriteFile( file, buffer, sz, &write, NULL );
253 } while (sz == sizeof buffer);
255 CloseHandle( file );
256 msiobj_release( &row->hdr );
257 if (r != ERROR_SUCCESS)
259 DeleteFileW( tmpfile );
260 msi_free( binary );
261 return NULL;
264 /* keep a reference to prevent the dll from being unloaded */
265 if (dll && !(binary->module = LoadLibraryW( tmpfile )))
267 WARN( "failed to load dll %s (%u)\n", debugstr_w( tmpfile ), GetLastError() );
269 binary->source = strdupW( source );
270 binary->tmpfile = strdupW( tmpfile );
271 list_add_tail( &package->binaries, &binary->entry );
272 return binary;
275 static MSIBINARY *get_temp_binary( MSIPACKAGE *package, LPCWSTR source, BOOL dll )
277 MSIBINARY *binary;
279 LIST_FOR_EACH_ENTRY( binary, &package->binaries, MSIBINARY, entry )
281 if (!strcmpW( binary->source, source ))
282 return binary;
285 return create_temp_binary( package, source, dll );
288 static void file_running_action(MSIPACKAGE* package, HANDLE Handle,
289 BOOL process, LPCWSTR name)
291 MSIRUNNINGACTION *action;
293 action = msi_alloc( sizeof(MSIRUNNINGACTION) );
295 action->handle = Handle;
296 action->process = process;
297 action->name = strdupW(name);
299 list_add_tail( &package->RunningActions, &action->entry );
302 static UINT custom_get_process_return( HANDLE process )
304 DWORD rc = 0;
306 GetExitCodeProcess( process, &rc );
307 TRACE("exit code is %u\n", rc);
308 if (rc != 0)
309 return ERROR_FUNCTION_FAILED;
310 return ERROR_SUCCESS;
313 static UINT custom_get_thread_return( MSIPACKAGE *package, HANDLE thread )
315 DWORD rc = 0;
317 GetExitCodeThread( thread, &rc );
319 switch (rc)
321 case ERROR_FUNCTION_NOT_CALLED:
322 case ERROR_SUCCESS:
323 case ERROR_INSTALL_USEREXIT:
324 case ERROR_INSTALL_FAILURE:
325 return rc;
326 case ERROR_NO_MORE_ITEMS:
327 return ERROR_SUCCESS;
328 case ERROR_INSTALL_SUSPEND:
329 ACTION_ForceReboot( package );
330 return ERROR_SUCCESS;
331 default:
332 ERR("Invalid Return Code %d\n",rc);
333 return ERROR_INSTALL_FAILURE;
337 static UINT wait_process_handle(MSIPACKAGE* package, UINT type,
338 HANDLE ProcessHandle, LPCWSTR name)
340 UINT rc = ERROR_SUCCESS;
342 if (!(type & msidbCustomActionTypeAsync))
344 TRACE("waiting for %s\n", debugstr_w(name));
346 msi_dialog_check_messages(ProcessHandle);
348 if (!(type & msidbCustomActionTypeContinue))
349 rc = custom_get_process_return(ProcessHandle);
351 CloseHandle(ProcessHandle);
353 else
355 TRACE("%s running in background\n", debugstr_w(name));
357 if (!(type & msidbCustomActionTypeContinue))
358 file_running_action(package, ProcessHandle, TRUE, name);
359 else
360 CloseHandle(ProcessHandle);
363 return rc;
366 typedef struct _msi_custom_action_info {
367 struct list entry;
368 LONG refs;
369 MSIPACKAGE *package;
370 LPWSTR source;
371 LPWSTR target;
372 HANDLE handle;
373 LPWSTR action;
374 INT type;
375 GUID guid;
376 } msi_custom_action_info;
378 static void release_custom_action_data( msi_custom_action_info *info )
380 EnterCriticalSection( &msi_custom_action_cs );
382 if (!--info->refs)
384 list_remove( &info->entry );
385 if (info->handle)
386 CloseHandle( info->handle );
387 msi_free( info->action );
388 msi_free( info->source );
389 msi_free( info->target );
390 msiobj_release( &info->package->hdr );
391 msi_free( info );
394 LeaveCriticalSection( &msi_custom_action_cs );
397 /* must be called inside msi_custom_action_cs if info is in the pending custom actions list */
398 static void addref_custom_action_data( msi_custom_action_info *info )
400 info->refs++;
403 static UINT wait_thread_handle( msi_custom_action_info *info )
405 UINT rc = ERROR_SUCCESS;
407 if (!(info->type & msidbCustomActionTypeAsync))
409 TRACE("waiting for %s\n", debugstr_w( info->action ));
411 msi_dialog_check_messages( info->handle );
413 if (!(info->type & msidbCustomActionTypeContinue))
414 rc = custom_get_thread_return( info->package, info->handle );
416 release_custom_action_data( info );
418 else
420 TRACE("%s running in background\n", debugstr_w( info->action ));
423 return rc;
426 static msi_custom_action_info *find_action_by_guid( const GUID *guid )
428 msi_custom_action_info *info;
429 BOOL found = FALSE;
431 EnterCriticalSection( &msi_custom_action_cs );
433 LIST_FOR_EACH_ENTRY( info, &msi_pending_custom_actions, msi_custom_action_info, entry )
435 if (IsEqualGUID( &info->guid, guid ))
437 addref_custom_action_data( info );
438 found = TRUE;
439 break;
443 LeaveCriticalSection( &msi_custom_action_cs );
445 if (!found)
446 return NULL;
448 return info;
451 static void handle_msi_break( LPCWSTR target )
453 LPWSTR msg;
454 WCHAR val[MAX_PATH];
456 static const WCHAR MsiBreak[] = { 'M','s','i','B','r','e','a','k',0 };
457 static const WCHAR WindowsInstaller[] = {
458 'W','i','n','d','o','w','s',' ','I','n','s','t','a','l','l','e','r',0
461 static const WCHAR format[] = {
462 'T','o',' ','d','e','b','u','g',' ','y','o','u','r',' ',
463 'c','u','s','t','o','m',' ','a','c','t','i','o','n',',',' ',
464 'a','t','t','a','c','h',' ','y','o','u','r',' ','d','e','b','u','g','g','e','r',' ',
465 't','o',' ','p','r','o','c','e','s','s',' ','%','i',' ','(','0','x','%','X',')',' ',
466 'a','n','d',' ','p','r','e','s','s',' ','O','K',0
469 if( !GetEnvironmentVariableW( MsiBreak, val, MAX_PATH ))
470 return;
472 if( strcmpiW( val, target ))
473 return;
475 msg = msi_alloc( (lstrlenW(format) + 10) * sizeof(WCHAR) );
476 if (!msg)
477 return;
479 wsprintfW( msg, format, GetCurrentProcessId(), GetCurrentProcessId());
480 MessageBoxW( NULL, msg, WindowsInstaller, MB_OK);
481 msi_free(msg);
482 DebugBreak();
485 static UINT get_action_info( const GUID *guid, INT *type, MSIHANDLE *handle,
486 BSTR *dll, BSTR *funcname,
487 IWineMsiRemotePackage **package )
489 IClassFactory *cf = NULL;
490 IWineMsiRemoteCustomAction *rca = NULL;
491 HRESULT r;
493 r = DllGetClassObject( &CLSID_WineMsiRemoteCustomAction,
494 &IID_IClassFactory, (LPVOID *)&cf );
495 if (FAILED(r))
497 ERR("failed to get IClassFactory interface\n");
498 return ERROR_FUNCTION_FAILED;
501 r = IClassFactory_CreateInstance( cf, NULL, &IID_IWineMsiRemoteCustomAction, (LPVOID *)&rca );
502 if (FAILED(r))
504 ERR("failed to get IWineMsiRemoteCustomAction interface\n");
505 return ERROR_FUNCTION_FAILED;
508 r = IWineMsiRemoteCustomAction_GetActionInfo( rca, guid, type, handle, dll, funcname, package );
509 IWineMsiRemoteCustomAction_Release( rca );
510 if (FAILED(r))
512 ERR("GetActionInfo failed\n");
513 return ERROR_FUNCTION_FAILED;
516 return ERROR_SUCCESS;
519 #ifdef __i386__
520 extern UINT CUSTOMPROC_wrapper( MsiCustomActionEntryPoint proc, MSIHANDLE handle );
521 __ASM_GLOBAL_FUNC( CUSTOMPROC_wrapper,
522 "pushl %ebp\n\t"
523 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
524 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
525 "movl %esp,%ebp\n\t"
526 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
527 "pushl 12(%ebp)\n\t"
528 "movl 8(%ebp),%eax\n\t"
529 "call *%eax\n\t"
530 "leave\n\t"
531 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
532 __ASM_CFI(".cfi_same_value %ebp\n\t")
533 "ret" )
534 #else
535 static inline UINT CUSTOMPROC_wrapper( MsiCustomActionEntryPoint proc, MSIHANDLE handle )
537 return proc(handle);
539 #endif
541 static DWORD ACTION_CallDllFunction( const GUID *guid )
543 MsiCustomActionEntryPoint fn;
544 MSIHANDLE hPackage, handle;
545 HANDLE hModule;
546 LPSTR proc;
547 UINT r = ERROR_FUNCTION_FAILED;
548 BSTR dll = NULL, function = NULL;
549 INT type;
550 IWineMsiRemotePackage *remote_package = NULL;
552 TRACE("%s\n", debugstr_guid( guid ));
554 r = get_action_info( guid, &type, &handle, &dll, &function, &remote_package );
555 if (r != ERROR_SUCCESS)
556 return r;
558 hModule = LoadLibraryW( dll );
559 if (!hModule)
561 WARN( "failed to load dll %s (%u)\n", debugstr_w( dll ), GetLastError() );
562 return ERROR_SUCCESS;
565 proc = strdupWtoA( function );
566 fn = (MsiCustomActionEntryPoint) GetProcAddress( hModule, proc );
567 msi_free( proc );
568 if (fn)
570 hPackage = alloc_msi_remote_handle( (IUnknown *)remote_package );
571 if (hPackage)
573 IWineMsiRemotePackage_SetMsiHandle( remote_package, handle );
574 TRACE("calling %s\n", debugstr_w( function ) );
575 handle_msi_break( function );
577 __TRY
579 r = CUSTOMPROC_wrapper( fn, hPackage );
581 __EXCEPT_PAGE_FAULT
583 ERR("Custom action (%s:%s) caused a page fault: %08x\n",
584 debugstr_w(dll), debugstr_w(function), GetExceptionCode());
585 r = ERROR_SUCCESS;
587 __ENDTRY;
589 MsiCloseHandle( hPackage );
591 else
592 ERR("failed to create handle for %p\n", remote_package );
594 else
595 ERR("GetProcAddress(%s) failed\n", debugstr_w( function ) );
597 FreeLibrary(hModule);
599 IWineMsiRemotePackage_Release( remote_package );
600 SysFreeString( dll );
601 SysFreeString( function );
602 MsiCloseHandle( handle );
604 return r;
607 static DWORD WINAPI DllThread( LPVOID arg )
609 LPGUID guid = arg;
610 DWORD rc = 0;
612 TRACE("custom action (%x) started\n", GetCurrentThreadId() );
614 rc = ACTION_CallDllFunction( guid );
616 TRACE("custom action (%x) returned %i\n", GetCurrentThreadId(), rc );
618 MsiCloseAllHandles();
619 return rc;
622 static msi_custom_action_info *do_msidbCustomActionTypeDll(
623 MSIPACKAGE *package, INT type, LPCWSTR source, LPCWSTR target, LPCWSTR action )
625 msi_custom_action_info *info;
627 info = msi_alloc( sizeof *info );
628 if (!info)
629 return NULL;
631 msiobj_addref( &package->hdr );
632 info->refs = 2; /* 1 for our caller and 1 for thread we created */
633 info->package = package;
634 info->type = type;
635 info->target = strdupW( target );
636 info->source = strdupW( source );
637 info->action = strdupW( action );
638 CoCreateGuid( &info->guid );
640 EnterCriticalSection( &msi_custom_action_cs );
641 list_add_tail( &msi_pending_custom_actions, &info->entry );
642 LeaveCriticalSection( &msi_custom_action_cs );
644 info->handle = CreateThread( NULL, 0, DllThread, &info->guid, 0, NULL );
645 if (!info->handle)
647 /* release both references */
648 release_custom_action_data( info );
649 release_custom_action_data( info );
650 return NULL;
653 return info;
656 static UINT HANDLE_CustomType1( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
657 INT type, const WCHAR *action )
659 msi_custom_action_info *info;
660 MSIBINARY *binary;
662 if (!(binary = get_temp_binary( package, source, TRUE )))
663 return ERROR_FUNCTION_FAILED;
665 TRACE("Calling function %s from %s\n", debugstr_w(target), debugstr_w(binary->tmpfile));
667 info = do_msidbCustomActionTypeDll( package, type, binary->tmpfile, target, action );
668 return wait_thread_handle( info );
671 static HANDLE execute_command( const WCHAR *app, WCHAR *arg, const WCHAR *dir )
673 static const WCHAR dotexeW[] = {'.','e','x','e',0};
674 STARTUPINFOW si;
675 PROCESS_INFORMATION info;
676 WCHAR *exe = NULL, *cmd = NULL, *p;
677 BOOL ret;
679 if (app)
681 int len_arg = 0;
682 DWORD len_exe;
684 if (!(exe = msi_alloc( MAX_PATH * sizeof(WCHAR) ))) return INVALID_HANDLE_VALUE;
685 len_exe = SearchPathW( NULL, app, dotexeW, MAX_PATH, exe, NULL );
686 if (len_exe >= MAX_PATH)
688 msi_free( exe );
689 if (!(exe = msi_alloc( len_exe * sizeof(WCHAR) ))) return INVALID_HANDLE_VALUE;
690 len_exe = SearchPathW( NULL, app, dotexeW, len_exe, exe, NULL );
692 if (!len_exe)
694 WARN("can't find executable %u\n", GetLastError());
695 msi_free( exe );
696 return INVALID_HANDLE_VALUE;
699 if (arg) len_arg = strlenW( arg );
700 if (!(cmd = msi_alloc( (len_exe + len_arg + 4) * sizeof(WCHAR) )))
702 msi_free( exe );
703 return INVALID_HANDLE_VALUE;
705 p = cmd;
706 if (strchrW( exe, ' ' ))
708 *p++ = '\"';
709 memcpy( p, exe, len_exe * sizeof(WCHAR) );
710 p += len_exe;
711 *p++ = '\"';
712 *p = 0;
714 else
716 strcpyW( p, exe );
717 p += len_exe;
719 if (arg)
721 *p++ = ' ';
722 memcpy( p, arg, len_arg * sizeof(WCHAR) );
723 p[len_arg] = 0;
726 memset( &si, 0, sizeof(STARTUPINFOW) );
727 ret = CreateProcessW( exe, exe ? cmd : arg, NULL, NULL, FALSE, 0, NULL, dir, &si, &info );
728 msi_free( cmd );
729 msi_free( exe );
730 if (!ret)
732 WARN("unable to execute command %u\n", GetLastError());
733 return INVALID_HANDLE_VALUE;
735 CloseHandle( info.hThread );
736 return info.hProcess;
739 static UINT HANDLE_CustomType2( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
740 INT type, const WCHAR *action )
742 MSIBINARY *binary;
743 HANDLE handle;
744 WCHAR *arg;
746 if (!(binary = get_temp_binary( package, source, FALSE ))) return ERROR_FUNCTION_FAILED;
748 deformat_string( package, target, &arg );
749 TRACE("exe %s arg %s\n", debugstr_w(binary->tmpfile), debugstr_w(arg));
751 handle = execute_command( binary->tmpfile, arg, szCRoot );
752 msi_free( arg );
753 if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
754 return wait_process_handle( package, type, handle, action );
757 static UINT HANDLE_CustomType17( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
758 INT type, const WCHAR *action )
760 msi_custom_action_info *info;
761 MSIFILE *file;
763 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
765 file = msi_get_loaded_file( package, source );
766 if (!file)
768 ERR("invalid file key %s\n", debugstr_w( source ));
769 return ERROR_FUNCTION_FAILED;
772 info = do_msidbCustomActionTypeDll( package, type, file->TargetPath, target, action );
773 return wait_thread_handle( info );
776 static UINT HANDLE_CustomType18( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
777 INT type, const WCHAR *action )
779 MSIFILE *file;
780 HANDLE handle;
781 WCHAR *arg;
783 if (!(file = msi_get_loaded_file( package, source ))) return ERROR_FUNCTION_FAILED;
785 deformat_string( package, target, &arg );
786 TRACE("exe %s arg %s\n", debugstr_w(file->TargetPath), debugstr_w(arg));
788 handle = execute_command( file->TargetPath, arg, szCRoot );
789 msi_free( arg );
790 if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
791 return wait_process_handle( package, type, handle, action );
794 static UINT HANDLE_CustomType19( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
795 INT type, const WCHAR *action )
797 static const WCHAR query[] = {
798 'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ',
799 'F','R','O','M',' ','`','E','r','r','o','r','`',' ',
800 'W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ',
801 '%','s',0
803 MSIRECORD *row = 0;
804 LPWSTR deformated = NULL;
806 deformat_string( package, target, &deformated );
808 /* first try treat the error as a number */
809 row = MSI_QueryGetRecord( package->db, query, deformated );
810 if( row )
812 LPCWSTR error = MSI_RecordGetString( row, 1 );
813 if ((package->ui_level & INSTALLUILEVEL_MASK) != INSTALLUILEVEL_NONE)
814 MessageBoxW( NULL, error, NULL, MB_OK );
815 msiobj_release( &row->hdr );
817 else if ((package->ui_level & INSTALLUILEVEL_MASK) != INSTALLUILEVEL_NONE)
818 MessageBoxW( NULL, deformated, NULL, MB_OK );
820 msi_free( deformated );
822 return ERROR_INSTALL_FAILURE;
825 static UINT HANDLE_CustomType23( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
826 INT type, const WCHAR *action )
828 static const WCHAR msiexecW[] = {'m','s','i','e','x','e','c',0};
829 static const WCHAR paramsW[] = {'/','q','b',' ','/','i',' '};
830 WCHAR *dir, *arg, *p;
831 UINT len_src, len_dir, len_tgt, len = sizeof(paramsW)/sizeof(paramsW[0]);
832 HANDLE handle;
834 if (!(dir = msi_dup_property( package->db, szOriginalDatabase ))) return ERROR_OUTOFMEMORY;
835 if (!(p = strrchrW( dir, '\\' )) && !(p = strrchrW( dir, '/' )))
837 msi_free( dir );
838 return ERROR_FUNCTION_FAILED;
840 *p = 0;
841 len_dir = p - dir;
842 len_src = strlenW( source );
843 len_tgt = strlenW( target );
844 if (!(arg = msi_alloc( (len + len_dir + len_src + len_tgt + 5) * sizeof(WCHAR) )))
846 msi_free( dir );
847 return ERROR_OUTOFMEMORY;
849 memcpy( arg, paramsW, sizeof(paramsW) );
850 arg[len++] = '"';
851 memcpy( arg + len, dir, len_dir * sizeof(WCHAR) );
852 len += len_dir;
853 arg[len++] = '\\';
854 memcpy( arg + len, source, len_src * sizeof(WCHAR) );
855 len += len_src;
856 arg[len++] = '"';
857 arg[len++] = ' ';
858 strcpyW( arg + len, target );
860 TRACE("installing %s concurrently\n", debugstr_w(source));
862 handle = execute_command( msiexecW, arg, dir );
863 msi_free( dir );
864 msi_free( arg );
865 if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
866 return wait_process_handle( package, type, handle, action );
869 static UINT HANDLE_CustomType50( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
870 INT type, const WCHAR *action )
872 WCHAR *exe, *arg;
873 HANDLE handle;
875 if (!(exe = msi_dup_property( package->db, source ))) return ERROR_SUCCESS;
877 deformat_string( package, target, &arg );
878 TRACE("exe %s arg %s\n", debugstr_w(exe), debugstr_w(arg));
880 handle = execute_command( exe, arg, szCRoot );
881 msi_free( exe );
882 msi_free( arg );
883 if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
884 return wait_process_handle( package, type, handle, action );
887 static UINT HANDLE_CustomType34( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
888 INT type, const WCHAR *action )
890 const WCHAR *workingdir = NULL;
891 HANDLE handle;
892 WCHAR *cmd;
894 if (source)
896 workingdir = msi_get_target_folder( package, source );
897 if (!workingdir) return ERROR_FUNCTION_FAILED;
899 deformat_string( package, target, &cmd );
900 if (!cmd) return ERROR_FUNCTION_FAILED;
902 TRACE("cmd %s dir %s\n", debugstr_w(cmd), debugstr_w(workingdir));
904 handle = execute_command( NULL, cmd, workingdir );
905 msi_free( cmd );
906 if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
907 return wait_process_handle( package, type, handle, action );
910 static DWORD ACTION_CallScript( const GUID *guid )
912 msi_custom_action_info *info;
913 MSIHANDLE hPackage;
914 UINT r = ERROR_FUNCTION_FAILED;
916 info = find_action_by_guid( guid );
917 if (!info)
919 ERR("failed to find action %s\n", debugstr_guid( guid) );
920 return ERROR_FUNCTION_FAILED;
923 TRACE("function %s, script %s\n", debugstr_w( info->target ), debugstr_w( info->source ) );
925 hPackage = alloc_msihandle( &info->package->hdr );
926 if (hPackage)
928 r = call_script( hPackage, info->type, info->source, info->target, info->action );
929 TRACE("script returned %u\n", r);
930 MsiCloseHandle( hPackage );
932 else
933 ERR("failed to create handle for %p\n", info->package );
935 release_custom_action_data( info );
936 return r;
939 static DWORD WINAPI ScriptThread( LPVOID arg )
941 LPGUID guid = arg;
942 DWORD rc;
944 TRACE("custom action (%x) started\n", GetCurrentThreadId() );
946 rc = ACTION_CallScript( guid );
948 TRACE("custom action (%x) returned %i\n", GetCurrentThreadId(), rc );
950 MsiCloseAllHandles();
951 return rc;
954 static msi_custom_action_info *do_msidbCustomActionTypeScript(
955 MSIPACKAGE *package, INT type, LPCWSTR script, LPCWSTR function, LPCWSTR action )
957 msi_custom_action_info *info;
959 info = msi_alloc( sizeof *info );
960 if (!info)
961 return NULL;
963 msiobj_addref( &package->hdr );
964 info->refs = 2; /* 1 for our caller and 1 for thread we created */
965 info->package = package;
966 info->type = type;
967 info->target = strdupW( function );
968 info->source = strdupW( script );
969 info->action = strdupW( action );
970 CoCreateGuid( &info->guid );
972 EnterCriticalSection( &msi_custom_action_cs );
973 list_add_tail( &msi_pending_custom_actions, &info->entry );
974 LeaveCriticalSection( &msi_custom_action_cs );
976 info->handle = CreateThread( NULL, 0, ScriptThread, &info->guid, 0, NULL );
977 if (!info->handle)
979 /* release both references */
980 release_custom_action_data( info );
981 release_custom_action_data( info );
982 return NULL;
985 return info;
988 static UINT HANDLE_CustomType37_38( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
989 INT type, const WCHAR *action )
991 msi_custom_action_info *info;
993 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
995 info = do_msidbCustomActionTypeScript( package, type, target, NULL, action );
996 return wait_thread_handle( info );
999 static UINT HANDLE_CustomType5_6( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
1000 INT type, const WCHAR *action )
1002 static const WCHAR query[] = {
1003 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1004 '`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E',' ',
1005 '`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0};
1006 MSIRECORD *row = 0;
1007 msi_custom_action_info *info;
1008 CHAR *buffer = NULL;
1009 WCHAR *bufferw = NULL;
1010 DWORD sz = 0;
1011 UINT r;
1013 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
1015 row = MSI_QueryGetRecord(package->db, query, source);
1016 if (!row)
1017 return ERROR_FUNCTION_FAILED;
1019 r = MSI_RecordReadStream(row, 2, NULL, &sz);
1020 if (r != ERROR_SUCCESS) return r;
1022 buffer = msi_alloc( sz + 1 );
1023 if (!buffer) return ERROR_FUNCTION_FAILED;
1025 r = MSI_RecordReadStream(row, 2, buffer, &sz);
1026 if (r != ERROR_SUCCESS)
1027 goto done;
1029 buffer[sz] = 0;
1030 bufferw = strdupAtoW(buffer);
1031 if (!bufferw)
1033 r = ERROR_FUNCTION_FAILED;
1034 goto done;
1037 info = do_msidbCustomActionTypeScript( package, type, bufferw, target, action );
1038 r = wait_thread_handle( info );
1040 done:
1041 msi_free(bufferw);
1042 msi_free(buffer);
1043 return r;
1046 static UINT HANDLE_CustomType21_22( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
1047 INT type, const WCHAR *action )
1049 msi_custom_action_info *info;
1050 MSIFILE *file;
1051 HANDLE hFile;
1052 DWORD sz, szHighWord = 0, read;
1053 CHAR *buffer=NULL;
1054 WCHAR *bufferw=NULL;
1055 BOOL bRet;
1056 UINT r;
1058 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
1060 file = msi_get_loaded_file(package, source);
1061 if (!file)
1063 ERR("invalid file key %s\n", debugstr_w(source));
1064 return ERROR_FUNCTION_FAILED;
1067 hFile = CreateFileW(file->TargetPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
1068 if (hFile == INVALID_HANDLE_VALUE) return ERROR_FUNCTION_FAILED;
1070 sz = GetFileSize(hFile, &szHighWord);
1071 if (sz == INVALID_FILE_SIZE || szHighWord != 0)
1073 CloseHandle(hFile);
1074 return ERROR_FUNCTION_FAILED;
1076 buffer = msi_alloc( sz + 1 );
1077 if (!buffer)
1079 CloseHandle(hFile);
1080 return ERROR_FUNCTION_FAILED;
1082 bRet = ReadFile(hFile, buffer, sz, &read, NULL);
1083 CloseHandle(hFile);
1084 if (!bRet)
1086 r = ERROR_FUNCTION_FAILED;
1087 goto done;
1089 buffer[read] = 0;
1090 bufferw = strdupAtoW(buffer);
1091 if (!bufferw)
1093 r = ERROR_FUNCTION_FAILED;
1094 goto done;
1096 info = do_msidbCustomActionTypeScript( package, type, bufferw, target, action );
1097 r = wait_thread_handle( info );
1099 done:
1100 msi_free(bufferw);
1101 msi_free(buffer);
1102 return r;
1105 static UINT HANDLE_CustomType53_54( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
1106 INT type, const WCHAR *action )
1108 msi_custom_action_info *info;
1109 WCHAR *prop;
1111 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
1113 prop = msi_dup_property( package->db, source );
1114 if (!prop) return ERROR_SUCCESS;
1116 info = do_msidbCustomActionTypeScript( package, type, prop, NULL, action );
1117 msi_free(prop);
1118 return wait_thread_handle( info );
1121 static BOOL action_type_matches_script( UINT type, UINT script )
1123 switch (script)
1125 case SCRIPT_NONE:
1126 case SCRIPT_INSTALL:
1127 return !(type & msidbCustomActionTypeCommit) && !(type & msidbCustomActionTypeRollback);
1128 case SCRIPT_COMMIT:
1129 return (type & msidbCustomActionTypeCommit);
1130 case SCRIPT_ROLLBACK:
1131 return (type & msidbCustomActionTypeRollback);
1132 default:
1133 ERR("unhandled script %u\n", script);
1135 return FALSE;
1138 static UINT defer_custom_action( MSIPACKAGE *package, const WCHAR *action, UINT type )
1140 WCHAR *actiondata = msi_dup_property( package->db, action );
1141 WCHAR *usersid = msi_dup_property( package->db, szUserSID );
1142 WCHAR *prodcode = msi_dup_property( package->db, szProductCode );
1143 WCHAR *deferred = msi_get_deferred_action( action, actiondata, usersid, prodcode );
1145 if (!deferred)
1147 msi_free( actiondata );
1148 msi_free( usersid );
1149 msi_free( prodcode );
1150 return ERROR_OUTOFMEMORY;
1152 if (type & msidbCustomActionTypeCommit)
1154 TRACE("deferring commit action\n");
1155 msi_schedule_action( package, SCRIPT_COMMIT, deferred );
1157 else if (type & msidbCustomActionTypeRollback)
1159 TRACE("deferring rollback action\n");
1160 msi_schedule_action( package, SCRIPT_ROLLBACK, deferred );
1162 else
1164 TRACE("deferring install action\n");
1165 msi_schedule_action( package, SCRIPT_INSTALL, deferred );
1168 msi_free( actiondata );
1169 msi_free( usersid );
1170 msi_free( prodcode );
1171 msi_free( deferred );
1172 return ERROR_SUCCESS;
1175 UINT ACTION_CustomAction( MSIPACKAGE *package, LPCWSTR action, UINT script )
1177 static const WCHAR query[] = {
1178 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1179 '`','C','u','s','t','o','m','A','c','t','i','o','n','`',' ','W','H','E','R','E',' ',
1180 '`','A','c','t','i' ,'o','n','`',' ','=',' ','\'','%','s','\'',0};
1181 UINT rc = ERROR_SUCCESS;
1182 MSIRECORD *row;
1183 UINT type;
1184 const WCHAR *source, *target, *ptr, *deferred_data = NULL;
1185 WCHAR *deformated = NULL;
1186 int len;
1188 /* deferred action: [properties]Action */
1189 if ((ptr = strrchrW(action, ']')))
1191 deferred_data = action;
1192 action = ptr + 1;
1195 row = MSI_QueryGetRecord( package->db, query, action );
1196 if (!row)
1197 return ERROR_CALL_NOT_IMPLEMENTED;
1199 type = MSI_RecordGetInteger(row,2);
1200 source = MSI_RecordGetString(row,3);
1201 target = MSI_RecordGetString(row,4);
1203 TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action),type,
1204 debugstr_w(source), debugstr_w(target));
1206 /* handle some of the deferred actions */
1207 if (type & msidbCustomActionTypeTSAware)
1208 FIXME("msidbCustomActionTypeTSAware not handled\n");
1210 if (type & msidbCustomActionTypeInScript)
1212 if (type & msidbCustomActionTypeNoImpersonate)
1213 WARN("msidbCustomActionTypeNoImpersonate not handled\n");
1215 if (!action_type_matches_script( type, script ))
1217 rc = defer_custom_action( package, action, type );
1218 goto end;
1220 else
1222 LPWSTR actiondata = msi_dup_property( package->db, action );
1224 if (type & msidbCustomActionTypeInScript)
1225 package->scheduled_action_running = TRUE;
1227 if (type & msidbCustomActionTypeCommit)
1228 package->commit_action_running = TRUE;
1230 if (type & msidbCustomActionTypeRollback)
1231 package->rollback_action_running = TRUE;
1233 if (deferred_data)
1234 set_deferred_action_props(package, deferred_data);
1235 else if (actiondata)
1236 msi_set_property( package->db, szCustomActionData, actiondata, -1 );
1237 else
1238 msi_set_property( package->db, szCustomActionData, szEmpty, -1 );
1240 msi_free(actiondata);
1243 else if (!check_execution_scheduling_options(package,action,type))
1245 rc = ERROR_SUCCESS;
1246 goto end;
1249 switch (type & CUSTOM_ACTION_TYPE_MASK)
1251 case 1: /* DLL file stored in a Binary table stream */
1252 rc = HANDLE_CustomType1(package,source,target,type,action);
1253 break;
1254 case 2: /* EXE file stored in a Binary table stream */
1255 rc = HANDLE_CustomType2(package,source,target,type,action);
1256 break;
1257 case 18: /*EXE file installed with package */
1258 rc = HANDLE_CustomType18(package,source,target,type,action);
1259 break;
1260 case 19: /* Error that halts install */
1261 rc = HANDLE_CustomType19(package,source,target,type,action);
1262 break;
1263 case 17:
1264 rc = HANDLE_CustomType17(package,source,target,type,action);
1265 break;
1266 case 23: /* installs another package in the source tree */
1267 deformat_string(package,target,&deformated);
1268 rc = HANDLE_CustomType23(package,source,deformated,type,action);
1269 msi_free(deformated);
1270 break;
1271 case 50: /*EXE file specified by a property value */
1272 rc = HANDLE_CustomType50(package,source,target,type,action);
1273 break;
1274 case 34: /*EXE to be run in specified directory */
1275 rc = HANDLE_CustomType34(package,source,target,type,action);
1276 break;
1277 case 35: /* Directory set with formatted text. */
1278 deformat_string(package,target,&deformated);
1279 MSI_SetTargetPathW(package, source, deformated);
1280 msi_free(deformated);
1281 break;
1282 case 51: /* Property set with formatted text. */
1283 if (!source)
1284 break;
1286 len = deformat_string( package, target, &deformated );
1287 rc = msi_set_property( package->db, source, deformated, len );
1288 if (rc == ERROR_SUCCESS && !strcmpW( source, szSourceDir ))
1289 msi_reset_folders( package, TRUE );
1290 msi_free(deformated);
1291 break;
1292 case 37: /* JScript/VBScript text stored in target column. */
1293 case 38:
1294 rc = HANDLE_CustomType37_38(package,source,target,type,action);
1295 break;
1296 case 5:
1297 case 6: /* JScript/VBScript file stored in a Binary table stream. */
1298 rc = HANDLE_CustomType5_6(package,source,target,type,action);
1299 break;
1300 case 21: /* JScript/VBScript file installed with the product. */
1301 case 22:
1302 rc = HANDLE_CustomType21_22(package,source,target,type,action);
1303 break;
1304 case 53: /* JScript/VBScript text specified by a property value. */
1305 case 54:
1306 rc = HANDLE_CustomType53_54(package,source,target,type,action);
1307 break;
1308 default:
1309 FIXME("unhandled action type %u (%s %s)\n", type & CUSTOM_ACTION_TYPE_MASK,
1310 debugstr_w(source), debugstr_w(target));
1313 end:
1314 package->scheduled_action_running = FALSE;
1315 package->commit_action_running = FALSE;
1316 package->rollback_action_running = FALSE;
1317 msiobj_release(&row->hdr);
1318 return rc;
1321 void ACTION_FinishCustomActions(const MSIPACKAGE* package)
1323 struct list *item;
1324 HANDLE *wait_handles;
1325 unsigned int handle_count, i;
1326 msi_custom_action_info *info, *cursor;
1328 while ((item = list_head( &package->RunningActions )))
1330 MSIRUNNINGACTION *action = LIST_ENTRY( item, MSIRUNNINGACTION, entry );
1332 list_remove( &action->entry );
1334 TRACE("waiting for %s\n", debugstr_w( action->name ) );
1335 msi_dialog_check_messages( action->handle );
1337 CloseHandle( action->handle );
1338 msi_free( action->name );
1339 msi_free( action );
1342 EnterCriticalSection( &msi_custom_action_cs );
1344 handle_count = list_count( &msi_pending_custom_actions );
1345 wait_handles = msi_alloc( handle_count * sizeof(HANDLE) );
1347 handle_count = 0;
1348 LIST_FOR_EACH_ENTRY_SAFE( info, cursor, &msi_pending_custom_actions, msi_custom_action_info, entry )
1350 if (info->package == package )
1352 if (DuplicateHandle(GetCurrentProcess(), info->handle, GetCurrentProcess(), &wait_handles[handle_count], SYNCHRONIZE, FALSE, 0))
1353 handle_count++;
1357 LeaveCriticalSection( &msi_custom_action_cs );
1359 for (i = 0; i < handle_count; i++)
1361 msi_dialog_check_messages( wait_handles[i] );
1362 CloseHandle( wait_handles[i] );
1364 msi_free( wait_handles );
1366 EnterCriticalSection( &msi_custom_action_cs );
1367 LIST_FOR_EACH_ENTRY_SAFE( info, cursor, &msi_pending_custom_actions, msi_custom_action_info, entry )
1369 if (info->package == package) release_custom_action_data( info );
1371 LeaveCriticalSection( &msi_custom_action_cs );
1374 typedef struct _msi_custom_remote_impl {
1375 IWineMsiRemoteCustomAction IWineMsiRemoteCustomAction_iface;
1376 LONG refs;
1377 } msi_custom_remote_impl;
1379 static inline msi_custom_remote_impl *impl_from_IWineMsiRemoteCustomAction( IWineMsiRemoteCustomAction *iface )
1381 return CONTAINING_RECORD(iface, msi_custom_remote_impl, IWineMsiRemoteCustomAction_iface);
1384 static HRESULT WINAPI mcr_QueryInterface( IWineMsiRemoteCustomAction *iface,
1385 REFIID riid,LPVOID *ppobj)
1387 if( IsEqualCLSID( riid, &IID_IUnknown ) ||
1388 IsEqualCLSID( riid, &IID_IWineMsiRemoteCustomAction ) )
1390 IWineMsiRemoteCustomAction_AddRef( iface );
1391 *ppobj = iface;
1392 return S_OK;
1395 return E_NOINTERFACE;
1398 static ULONG WINAPI mcr_AddRef( IWineMsiRemoteCustomAction *iface )
1400 msi_custom_remote_impl* This = impl_from_IWineMsiRemoteCustomAction( iface );
1402 return InterlockedIncrement( &This->refs );
1405 static ULONG WINAPI mcr_Release( IWineMsiRemoteCustomAction *iface )
1407 msi_custom_remote_impl* This = impl_from_IWineMsiRemoteCustomAction( iface );
1408 ULONG r;
1410 r = InterlockedDecrement( &This->refs );
1411 if (r == 0)
1412 msi_free( This );
1413 return r;
1416 static HRESULT WINAPI mcr_GetActionInfo( IWineMsiRemoteCustomAction *iface, LPCGUID custom_action_guid,
1417 INT *type, MSIHANDLE *handle, BSTR *dll, BSTR *func, IWineMsiRemotePackage **remote_package )
1419 msi_custom_action_info *info;
1421 info = find_action_by_guid( custom_action_guid );
1422 if (!info)
1423 return E_FAIL;
1425 *type = info->type;
1426 *handle = alloc_msihandle( &info->package->hdr );
1427 *dll = SysAllocString( info->source );
1428 *func = SysAllocString( info->target );
1430 release_custom_action_data( info );
1431 return create_msi_remote_package( NULL, (LPVOID *)remote_package );
1434 static const IWineMsiRemoteCustomActionVtbl msi_custom_remote_vtbl =
1436 mcr_QueryInterface,
1437 mcr_AddRef,
1438 mcr_Release,
1439 mcr_GetActionInfo,
1442 HRESULT create_msi_custom_remote( IUnknown *pOuter, LPVOID *ppObj )
1444 msi_custom_remote_impl* This;
1446 This = msi_alloc( sizeof *This );
1447 if (!This)
1448 return E_OUTOFMEMORY;
1450 This->IWineMsiRemoteCustomAction_iface.lpVtbl = &msi_custom_remote_vtbl;
1451 This->refs = 1;
1453 *ppObj = This;
1455 return S_OK;