krnl386.exe16: Make a couple of functions static.
[wine.git] / dlls / msi / custom.c
blob851c5030e20b06e183e527a861a19ded53f498ba
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_actions_count[script];
80 package->script_actions_count[script]++;
81 if (count != 0) newbuf = msi_realloc( package->script_actions[script],
82 package->script_actions_count[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 TRACE("Registering %s as unique action\n", debugstr_w(action));
97 count = package->unique_actions_count;
98 package->unique_actions_count++;
99 if (count != 0) newbuf = msi_realloc( package->unique_actions,
100 package->unique_actions_count * sizeof(WCHAR *) );
101 else newbuf = msi_alloc( sizeof(WCHAR *) );
103 newbuf[count] = strdupW( action );
104 package->unique_actions = newbuf;
105 return ERROR_SUCCESS;
108 BOOL msi_action_is_unique( const MSIPACKAGE *package, const WCHAR *action )
110 UINT i;
112 for (i = 0; i < package->unique_actions_count; i++)
114 if (!strcmpW( package->unique_actions[i], action )) return TRUE;
116 return FALSE;
119 static BOOL check_execution_scheduling_options(MSIPACKAGE *package, LPCWSTR action, UINT options)
121 if ((options & msidbCustomActionTypeClientRepeat) ==
122 msidbCustomActionTypeClientRepeat)
124 if (!(package->InWhatSequence & SEQUENCE_UI &&
125 package->InWhatSequence & SEQUENCE_EXEC))
127 TRACE("Skipping action due to dbCustomActionTypeClientRepeat option.\n");
128 return FALSE;
131 else if (options & msidbCustomActionTypeFirstSequence)
133 if (package->InWhatSequence & SEQUENCE_UI &&
134 package->InWhatSequence & SEQUENCE_EXEC )
136 TRACE("Skipping action due to msidbCustomActionTypeFirstSequence option.\n");
137 return FALSE;
140 else if (options & msidbCustomActionTypeOncePerProcess)
142 if (msi_action_is_unique(package, action))
144 TRACE("Skipping action due to msidbCustomActionTypeOncePerProcess option.\n");
145 return FALSE;
147 else
148 msi_register_unique_action(package, action);
151 return TRUE;
154 /* stores the following properties before the action:
156 * [CustomActionData<=>UserSID<=>ProductCode]Action
158 static LPWSTR msi_get_deferred_action(LPCWSTR action, LPCWSTR actiondata,
159 LPCWSTR usersid, LPCWSTR prodcode)
161 LPWSTR deferred;
162 DWORD len;
164 static const WCHAR format[] = {
165 '[','%','s','<','=','>','%','s','<','=','>','%','s',']','%','s',0
168 if (!actiondata)
169 return strdupW(action);
171 len = lstrlenW(action) + lstrlenW(actiondata) +
172 lstrlenW(usersid) + lstrlenW(prodcode) +
173 lstrlenW(format) - 7;
174 deferred = msi_alloc(len * sizeof(WCHAR));
176 sprintfW(deferred, format, actiondata, usersid, prodcode, action);
177 return deferred;
180 static void set_deferred_action_props( MSIPACKAGE *package, const WCHAR *deferred_data )
182 static const WCHAR sep[] = {'<','=','>',0};
183 const WCHAR *end, *beg = deferred_data + 1;
185 end = strstrW(beg, sep);
186 msi_set_property( package->db, szCustomActionData, beg, end - beg );
187 beg = end + 3;
189 end = strstrW(beg, sep);
190 msi_set_property( package->db, szUserSID, beg, end - beg );
191 beg = end + 3;
193 end = strchrW(beg, ']');
194 msi_set_property( package->db, szProductCode, beg, end - beg );
197 WCHAR *msi_create_temp_file( MSIDATABASE *db )
199 WCHAR *ret;
201 if (!db->tempfolder)
203 WCHAR tmp[MAX_PATH];
204 UINT len = sizeof(tmp)/sizeof(tmp[0]);
206 if (msi_get_property( db, szTempFolder, tmp, &len ) ||
207 GetFileAttributesW( tmp ) != FILE_ATTRIBUTE_DIRECTORY)
209 GetTempPathW( MAX_PATH, tmp );
211 if (!(db->tempfolder = strdupW( tmp ))) return NULL;
214 if ((ret = msi_alloc( (strlenW( db->tempfolder ) + 20) * sizeof(WCHAR) )))
216 if (!GetTempFileNameW( db->tempfolder, szMsi, 0, ret ))
218 msi_free( ret );
219 return NULL;
223 return ret;
226 static MSIBINARY *create_temp_binary( MSIPACKAGE *package, LPCWSTR source, BOOL dll )
228 static const WCHAR query[] = {
229 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
230 '`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E',' ',
231 '`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0};
232 MSIRECORD *row;
233 MSIBINARY *binary = NULL;
234 HANDLE file;
235 CHAR buffer[1024];
236 WCHAR *tmpfile;
237 DWORD sz, write;
238 UINT r;
240 if (!(tmpfile = msi_create_temp_file( package->db ))) return NULL;
242 if (!(row = MSI_QueryGetRecord( package->db, query, source ))) goto error;
243 if (!(binary = msi_alloc_zero( sizeof(MSIBINARY) ))) goto error;
245 file = CreateFileW( tmpfile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
246 if (file == INVALID_HANDLE_VALUE) goto error;
250 sz = sizeof(buffer);
251 r = MSI_RecordReadStream( row, 2, buffer, &sz );
252 if (r != ERROR_SUCCESS)
254 ERR("Failed to get stream\n");
255 break;
257 WriteFile( file, buffer, sz, &write, NULL );
258 } while (sz == sizeof buffer);
260 CloseHandle( file );
261 if (r != ERROR_SUCCESS) goto error;
263 /* keep a reference to prevent the dll from being unloaded */
264 if (dll && !(binary->module = LoadLibraryW( tmpfile )))
266 ERR( "failed to load dll %s (%u)\n", debugstr_w( tmpfile ), GetLastError() );
268 binary->source = strdupW( source );
269 binary->tmpfile = tmpfile;
270 list_add_tail( &package->binaries, &binary->entry );
272 msiobj_release( &row->hdr );
273 return binary;
275 error:
276 if (row) msiobj_release( &row->hdr );
277 DeleteFileW( tmpfile );
278 msi_free( tmpfile );
279 msi_free( binary );
280 return NULL;
283 static MSIBINARY *get_temp_binary( MSIPACKAGE *package, LPCWSTR source, BOOL dll )
285 MSIBINARY *binary;
287 LIST_FOR_EACH_ENTRY( binary, &package->binaries, MSIBINARY, entry )
289 if (!strcmpW( binary->source, source ))
290 return binary;
293 return create_temp_binary( package, source, dll );
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 )
312 DWORD rc = 0;
314 GetExitCodeProcess( process, &rc );
315 TRACE("exit code is %u\n", rc);
316 if (rc != 0)
317 return ERROR_FUNCTION_FAILED;
318 return ERROR_SUCCESS;
321 static UINT custom_get_thread_return( MSIPACKAGE *package, HANDLE thread )
323 DWORD rc = 0;
325 GetExitCodeThread( thread, &rc );
327 switch (rc)
329 case ERROR_FUNCTION_NOT_CALLED:
330 case ERROR_SUCCESS:
331 case ERROR_INSTALL_USEREXIT:
332 case ERROR_INSTALL_FAILURE:
333 return rc;
334 case ERROR_NO_MORE_ITEMS:
335 return ERROR_SUCCESS;
336 case ERROR_INSTALL_SUSPEND:
337 ACTION_ForceReboot( package );
338 return ERROR_SUCCESS;
339 default:
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);
361 else
363 TRACE("%s running in background\n", debugstr_w(name));
365 if (!(type & msidbCustomActionTypeContinue))
366 file_running_action(package, ProcessHandle, TRUE, name);
367 else
368 CloseHandle(ProcessHandle);
371 return rc;
374 typedef struct _msi_custom_action_info {
375 struct list entry;
376 LONG refs;
377 MSIPACKAGE *package;
378 LPWSTR source;
379 LPWSTR target;
380 HANDLE handle;
381 LPWSTR action;
382 INT type;
383 GUID guid;
384 } msi_custom_action_info;
386 static void release_custom_action_data( msi_custom_action_info *info )
388 EnterCriticalSection( &msi_custom_action_cs );
390 if (!--info->refs)
392 list_remove( &info->entry );
393 if (info->handle)
394 CloseHandle( info->handle );
395 msi_free( info->action );
396 msi_free( info->source );
397 msi_free( info->target );
398 msiobj_release( &info->package->hdr );
399 msi_free( info );
402 LeaveCriticalSection( &msi_custom_action_cs );
405 /* must be called inside msi_custom_action_cs if info is in the pending custom actions list */
406 static void addref_custom_action_data( msi_custom_action_info *info )
408 info->refs++;
411 static UINT wait_thread_handle( msi_custom_action_info *info )
413 UINT rc = ERROR_SUCCESS;
415 if (!(info->type & msidbCustomActionTypeAsync))
417 TRACE("waiting for %s\n", debugstr_w( info->action ));
419 msi_dialog_check_messages( info->handle );
421 if (!(info->type & msidbCustomActionTypeContinue))
422 rc = custom_get_thread_return( info->package, info->handle );
424 release_custom_action_data( info );
426 else
428 TRACE("%s running in background\n", debugstr_w( info->action ));
431 return rc;
434 static msi_custom_action_info *find_action_by_guid( const GUID *guid )
436 msi_custom_action_info *info;
437 BOOL found = FALSE;
439 EnterCriticalSection( &msi_custom_action_cs );
441 LIST_FOR_EACH_ENTRY( info, &msi_pending_custom_actions, msi_custom_action_info, entry )
443 if (IsEqualGUID( &info->guid, guid ))
445 addref_custom_action_data( info );
446 found = TRUE;
447 break;
451 LeaveCriticalSection( &msi_custom_action_cs );
453 if (!found)
454 return NULL;
456 return info;
459 static void handle_msi_break( LPCWSTR target )
461 LPWSTR msg;
462 WCHAR val[MAX_PATH];
464 static const WCHAR MsiBreak[] = { 'M','s','i','B','r','e','a','k',0 };
465 static const WCHAR WindowsInstaller[] = {
466 'W','i','n','d','o','w','s',' ','I','n','s','t','a','l','l','e','r',0
469 static const WCHAR format[] = {
470 'T','o',' ','d','e','b','u','g',' ','y','o','u','r',' ',
471 'c','u','s','t','o','m',' ','a','c','t','i','o','n',',',' ',
472 'a','t','t','a','c','h',' ','y','o','u','r',' ','d','e','b','u','g','g','e','r',' ',
473 't','o',' ','p','r','o','c','e','s','s',' ','%','i',' ','(','0','x','%','X',')',' ',
474 'a','n','d',' ','p','r','e','s','s',' ','O','K',0
477 if( !GetEnvironmentVariableW( MsiBreak, val, MAX_PATH ))
478 return;
480 if( strcmpiW( val, target ))
481 return;
483 msg = msi_alloc( (lstrlenW(format) + 10) * sizeof(WCHAR) );
484 if (!msg)
485 return;
487 wsprintfW( msg, format, GetCurrentProcessId(), GetCurrentProcessId());
488 MessageBoxW( NULL, msg, WindowsInstaller, MB_OK);
489 msi_free(msg);
490 DebugBreak();
493 static UINT get_action_info( const GUID *guid, INT *type, MSIHANDLE *handle,
494 BSTR *dll, BSTR *funcname,
495 IWineMsiRemotePackage **package )
497 IClassFactory *cf = NULL;
498 IWineMsiRemoteCustomAction *rca = NULL;
499 HRESULT r;
501 r = DllGetClassObject( &CLSID_WineMsiRemoteCustomAction,
502 &IID_IClassFactory, (LPVOID *)&cf );
503 if (FAILED(r))
505 ERR("failed to get IClassFactory interface\n");
506 return ERROR_FUNCTION_FAILED;
509 r = IClassFactory_CreateInstance( cf, NULL, &IID_IWineMsiRemoteCustomAction, (LPVOID *)&rca );
510 if (FAILED(r))
512 ERR("failed to get IWineMsiRemoteCustomAction interface\n");
513 return ERROR_FUNCTION_FAILED;
516 r = IWineMsiRemoteCustomAction_GetActionInfo( rca, guid, type, handle, dll, funcname, package );
517 IWineMsiRemoteCustomAction_Release( rca );
518 if (FAILED(r))
520 ERR("GetActionInfo failed\n");
521 return ERROR_FUNCTION_FAILED;
524 return ERROR_SUCCESS;
527 #ifdef __i386__
528 extern UINT CUSTOMPROC_wrapper( MsiCustomActionEntryPoint proc, MSIHANDLE handle );
529 __ASM_GLOBAL_FUNC( CUSTOMPROC_wrapper,
530 "pushl %ebp\n\t"
531 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
532 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
533 "movl %esp,%ebp\n\t"
534 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
535 "subl $4,%esp\n\t"
536 "pushl 12(%ebp)\n\t"
537 "movl 8(%ebp),%eax\n\t"
538 "call *%eax\n\t"
539 "leave\n\t"
540 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
541 __ASM_CFI(".cfi_same_value %ebp\n\t")
542 "ret" )
543 #else
544 static inline UINT CUSTOMPROC_wrapper( MsiCustomActionEntryPoint proc, MSIHANDLE handle )
546 return proc(handle);
548 #endif
550 static DWORD ACTION_CallDllFunction( const GUID *guid )
552 MsiCustomActionEntryPoint fn;
553 MSIHANDLE hPackage, handle;
554 HANDLE hModule;
555 LPSTR proc;
556 UINT r = ERROR_FUNCTION_FAILED;
557 BSTR dll = NULL, function = NULL;
558 INT type;
559 IWineMsiRemotePackage *remote_package = NULL;
561 TRACE("%s\n", debugstr_guid( guid ));
563 r = get_action_info( guid, &type, &handle, &dll, &function, &remote_package );
564 if (r != ERROR_SUCCESS)
565 return r;
567 hModule = LoadLibraryW( dll );
568 if (!hModule)
570 ERR( "failed to load dll %s (%u)\n", debugstr_w( dll ), GetLastError() );
571 return ERROR_SUCCESS;
574 proc = strdupWtoA( function );
575 fn = (MsiCustomActionEntryPoint) GetProcAddress( hModule, proc );
576 msi_free( proc );
577 if (fn)
579 hPackage = alloc_msi_remote_handle( (IUnknown *)remote_package );
580 if (hPackage)
582 IWineMsiRemotePackage_SetMsiHandle( remote_package, handle );
583 TRACE("calling %s\n", debugstr_w( function ) );
584 handle_msi_break( function );
586 __TRY
588 r = CUSTOMPROC_wrapper( fn, hPackage );
590 __EXCEPT_PAGE_FAULT
592 ERR("Custom action (%s:%s) caused a page fault: %08x\n",
593 debugstr_w(dll), debugstr_w(function), GetExceptionCode());
594 r = ERROR_SUCCESS;
596 __ENDTRY;
598 MsiCloseHandle( hPackage );
600 else
601 ERR("failed to create handle for %p\n", remote_package );
603 else
604 ERR("GetProcAddress(%s) failed\n", debugstr_w( function ) );
606 FreeLibrary(hModule);
608 IWineMsiRemotePackage_Release( remote_package );
609 SysFreeString( dll );
610 SysFreeString( function );
611 MsiCloseHandle( handle );
613 return r;
616 static DWORD WINAPI DllThread( LPVOID arg )
618 LPGUID guid = arg;
619 DWORD rc = 0;
621 TRACE("custom action (%x) started\n", GetCurrentThreadId() );
623 rc = ACTION_CallDllFunction( guid );
625 TRACE("custom action (%x) returned %i\n", GetCurrentThreadId(), rc );
627 MsiCloseAllHandles();
628 return rc;
631 static msi_custom_action_info *do_msidbCustomActionTypeDll(
632 MSIPACKAGE *package, INT type, LPCWSTR source, LPCWSTR target, LPCWSTR action )
634 msi_custom_action_info *info;
636 info = msi_alloc( sizeof *info );
637 if (!info)
638 return NULL;
640 msiobj_addref( &package->hdr );
641 info->refs = 2; /* 1 for our caller and 1 for thread we created */
642 info->package = package;
643 info->type = type;
644 info->target = strdupW( target );
645 info->source = strdupW( source );
646 info->action = strdupW( action );
647 CoCreateGuid( &info->guid );
649 EnterCriticalSection( &msi_custom_action_cs );
650 list_add_tail( &msi_pending_custom_actions, &info->entry );
651 LeaveCriticalSection( &msi_custom_action_cs );
653 info->handle = CreateThread( NULL, 0, DllThread, &info->guid, 0, NULL );
654 if (!info->handle)
656 /* release both references */
657 release_custom_action_data( info );
658 release_custom_action_data( info );
659 return NULL;
662 return info;
665 static UINT HANDLE_CustomType1( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
666 INT type, const WCHAR *action )
668 msi_custom_action_info *info;
669 MSIBINARY *binary;
671 if (!(binary = get_temp_binary( package, source, TRUE )))
672 return ERROR_FUNCTION_FAILED;
674 TRACE("Calling function %s from %s\n", debugstr_w(target), debugstr_w(binary->tmpfile));
676 info = do_msidbCustomActionTypeDll( package, type, binary->tmpfile, target, action );
677 return wait_thread_handle( info );
680 static HANDLE execute_command( const WCHAR *app, WCHAR *arg, const WCHAR *dir )
682 static const WCHAR dotexeW[] = {'.','e','x','e',0};
683 STARTUPINFOW si;
684 PROCESS_INFORMATION info;
685 WCHAR *exe = NULL, *cmd = NULL, *p;
686 BOOL ret;
688 if (app)
690 int len_arg = 0;
691 DWORD len_exe;
693 if (!(exe = msi_alloc( MAX_PATH * sizeof(WCHAR) ))) return INVALID_HANDLE_VALUE;
694 len_exe = SearchPathW( NULL, app, dotexeW, MAX_PATH, exe, NULL );
695 if (len_exe >= MAX_PATH)
697 msi_free( exe );
698 if (!(exe = msi_alloc( len_exe * sizeof(WCHAR) ))) return INVALID_HANDLE_VALUE;
699 len_exe = SearchPathW( NULL, app, dotexeW, len_exe, exe, NULL );
701 if (!len_exe)
703 ERR("can't find executable %u\n", GetLastError());
704 msi_free( exe );
705 return INVALID_HANDLE_VALUE;
708 if (arg) len_arg = strlenW( arg );
709 if (!(cmd = msi_alloc( (len_exe + len_arg + 4) * sizeof(WCHAR) )))
711 msi_free( exe );
712 return INVALID_HANDLE_VALUE;
714 p = cmd;
715 if (strchrW( exe, ' ' ))
717 *p++ = '\"';
718 memcpy( p, exe, len_exe * sizeof(WCHAR) );
719 p += len_exe;
720 *p++ = '\"';
721 *p = 0;
723 else
725 strcpyW( p, exe );
726 p += len_exe;
728 if (arg)
730 *p++ = ' ';
731 memcpy( p, arg, len_arg * sizeof(WCHAR) );
732 p[len_arg] = 0;
735 memset( &si, 0, sizeof(STARTUPINFOW) );
736 ret = CreateProcessW( exe, exe ? cmd : arg, NULL, NULL, FALSE, 0, NULL, dir, &si, &info );
737 msi_free( cmd );
738 msi_free( exe );
739 if (!ret)
741 ERR("unable to execute command %u\n", GetLastError());
742 return INVALID_HANDLE_VALUE;
744 CloseHandle( info.hThread );
745 return info.hProcess;
748 static UINT HANDLE_CustomType2( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
749 INT type, const WCHAR *action )
751 MSIBINARY *binary;
752 HANDLE handle;
753 WCHAR *arg;
755 if (!(binary = get_temp_binary( package, source, FALSE ))) return ERROR_FUNCTION_FAILED;
757 deformat_string( package, target, &arg );
758 TRACE("exe %s arg %s\n", debugstr_w(binary->tmpfile), debugstr_w(arg));
760 handle = execute_command( binary->tmpfile, arg, szCRoot );
761 msi_free( arg );
762 if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
763 return wait_process_handle( package, type, handle, action );
766 static UINT HANDLE_CustomType17( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
767 INT type, const WCHAR *action )
769 msi_custom_action_info *info;
770 MSIFILE *file;
772 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
774 file = msi_get_loaded_file( package, source );
775 if (!file)
777 ERR("invalid file key %s\n", debugstr_w( source ));
778 return ERROR_FUNCTION_FAILED;
781 info = do_msidbCustomActionTypeDll( package, type, file->TargetPath, target, action );
782 return wait_thread_handle( info );
785 static UINT HANDLE_CustomType18( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
786 INT type, const WCHAR *action )
788 MSIFILE *file;
789 HANDLE handle;
790 WCHAR *arg;
792 if (!(file = msi_get_loaded_file( package, source ))) return ERROR_FUNCTION_FAILED;
794 deformat_string( package, target, &arg );
795 TRACE("exe %s arg %s\n", debugstr_w(file->TargetPath), debugstr_w(arg));
797 handle = execute_command( file->TargetPath, arg, szCRoot );
798 msi_free( arg );
799 if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
800 return wait_process_handle( package, type, handle, action );
803 static UINT HANDLE_CustomType19( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
804 INT type, const WCHAR *action )
806 static const WCHAR query[] = {
807 'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ',
808 'F','R','O','M',' ','`','E','r','r','o','r','`',' ',
809 'W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ',
810 '%','s',0
812 MSIRECORD *row = 0;
813 LPWSTR deformated = NULL;
815 deformat_string( package, target, &deformated );
817 /* first try treat the error as a number */
818 row = MSI_QueryGetRecord( package->db, query, deformated );
819 if( row )
821 LPCWSTR error = MSI_RecordGetString( row, 1 );
822 if ((package->ui_level & INSTALLUILEVEL_MASK) != INSTALLUILEVEL_NONE)
823 MessageBoxW( NULL, error, NULL, MB_OK );
824 msiobj_release( &row->hdr );
826 else if ((package->ui_level & INSTALLUILEVEL_MASK) != INSTALLUILEVEL_NONE)
827 MessageBoxW( NULL, deformated, NULL, MB_OK );
829 msi_free( deformated );
831 return ERROR_INSTALL_FAILURE;
834 static UINT HANDLE_CustomType23( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
835 INT type, const WCHAR *action )
837 static const WCHAR msiexecW[] = {'m','s','i','e','x','e','c',0};
838 static const WCHAR paramsW[] = {'/','q','b',' ','/','i',' '};
839 WCHAR *dir, *arg, *p;
840 UINT len_src, len_dir, len_tgt, len = sizeof(paramsW)/sizeof(paramsW[0]);
841 HANDLE handle;
843 if (!(dir = msi_dup_property( package->db, szOriginalDatabase ))) return ERROR_OUTOFMEMORY;
844 if (!(p = strrchrW( dir, '\\' )) && !(p = strrchrW( dir, '/' )))
846 msi_free( dir );
847 return ERROR_FUNCTION_FAILED;
849 *p = 0;
850 len_dir = p - dir;
851 len_src = strlenW( source );
852 len_tgt = strlenW( target );
853 if (!(arg = msi_alloc( (len + len_dir + len_src + len_tgt + 5) * sizeof(WCHAR) )))
855 msi_free( dir );
856 return ERROR_OUTOFMEMORY;
858 memcpy( arg, paramsW, sizeof(paramsW) );
859 arg[len++] = '"';
860 memcpy( arg + len, dir, len_dir * sizeof(WCHAR) );
861 len += len_dir;
862 arg[len++] = '\\';
863 memcpy( arg + len, source, len_src * sizeof(WCHAR) );
864 len += len_src;
865 arg[len++] = '"';
866 arg[len++] = ' ';
867 strcpyW( arg + len, target );
869 TRACE("installing %s concurrently\n", debugstr_w(source));
871 handle = execute_command( msiexecW, arg, dir );
872 msi_free( dir );
873 msi_free( arg );
874 if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
875 return wait_process_handle( package, type, handle, action );
878 static UINT HANDLE_CustomType50( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
879 INT type, const WCHAR *action )
881 WCHAR *exe, *arg;
882 HANDLE handle;
884 if (!(exe = msi_dup_property( package->db, source ))) return ERROR_SUCCESS;
886 deformat_string( package, target, &arg );
887 TRACE("exe %s arg %s\n", debugstr_w(exe), debugstr_w(arg));
889 handle = execute_command( exe, arg, szCRoot );
890 msi_free( exe );
891 msi_free( arg );
892 if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
893 return wait_process_handle( package, type, handle, action );
896 static UINT HANDLE_CustomType34( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
897 INT type, const WCHAR *action )
899 const WCHAR *workingdir = NULL;
900 HANDLE handle;
901 WCHAR *cmd;
903 if (source)
905 workingdir = msi_get_target_folder( package, source );
906 if (!workingdir) return ERROR_FUNCTION_FAILED;
908 deformat_string( package, target, &cmd );
909 if (!cmd) return ERROR_FUNCTION_FAILED;
911 TRACE("cmd %s dir %s\n", debugstr_w(cmd), debugstr_w(workingdir));
913 handle = execute_command( NULL, cmd, workingdir );
914 msi_free( cmd );
915 if (handle == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
916 return wait_process_handle( package, type, handle, action );
919 static DWORD ACTION_CallScript( const GUID *guid )
921 msi_custom_action_info *info;
922 MSIHANDLE hPackage;
923 UINT r = ERROR_FUNCTION_FAILED;
925 info = find_action_by_guid( guid );
926 if (!info)
928 ERR("failed to find action %s\n", debugstr_guid( guid) );
929 return ERROR_FUNCTION_FAILED;
932 TRACE("function %s, script %s\n", debugstr_w( info->target ), debugstr_w( info->source ) );
934 hPackage = alloc_msihandle( &info->package->hdr );
935 if (hPackage)
937 r = call_script( hPackage, info->type, info->source, info->target, info->action );
938 TRACE("script returned %u\n", r);
939 MsiCloseHandle( hPackage );
941 else
942 ERR("failed to create handle for %p\n", info->package );
944 release_custom_action_data( info );
945 return r;
948 static DWORD WINAPI ScriptThread( LPVOID arg )
950 LPGUID guid = arg;
951 DWORD rc;
953 TRACE("custom action (%x) started\n", GetCurrentThreadId() );
955 rc = ACTION_CallScript( guid );
957 TRACE("custom action (%x) returned %i\n", GetCurrentThreadId(), rc );
959 MsiCloseAllHandles();
960 return rc;
963 static msi_custom_action_info *do_msidbCustomActionTypeScript(
964 MSIPACKAGE *package, INT type, LPCWSTR script, LPCWSTR function, LPCWSTR action )
966 msi_custom_action_info *info;
968 info = msi_alloc( sizeof *info );
969 if (!info)
970 return NULL;
972 msiobj_addref( &package->hdr );
973 info->refs = 2; /* 1 for our caller and 1 for thread we created */
974 info->package = package;
975 info->type = type;
976 info->target = strdupW( function );
977 info->source = strdupW( script );
978 info->action = strdupW( action );
979 CoCreateGuid( &info->guid );
981 EnterCriticalSection( &msi_custom_action_cs );
982 list_add_tail( &msi_pending_custom_actions, &info->entry );
983 LeaveCriticalSection( &msi_custom_action_cs );
985 info->handle = CreateThread( NULL, 0, ScriptThread, &info->guid, 0, NULL );
986 if (!info->handle)
988 /* release both references */
989 release_custom_action_data( info );
990 release_custom_action_data( info );
991 return NULL;
994 return info;
997 static UINT HANDLE_CustomType37_38( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
998 INT type, const WCHAR *action )
1000 msi_custom_action_info *info;
1002 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
1004 info = do_msidbCustomActionTypeScript( package, type, target, NULL, action );
1005 return wait_thread_handle( info );
1008 static UINT HANDLE_CustomType5_6( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
1009 INT type, const WCHAR *action )
1011 static const WCHAR query[] = {
1012 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1013 '`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E',' ',
1014 '`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0};
1015 MSIRECORD *row = NULL;
1016 msi_custom_action_info *info;
1017 CHAR *buffer = NULL;
1018 WCHAR *bufferw = NULL;
1019 DWORD sz = 0;
1020 UINT r;
1022 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
1024 row = MSI_QueryGetRecord(package->db, query, source);
1025 if (!row)
1026 return ERROR_FUNCTION_FAILED;
1028 r = MSI_RecordReadStream(row, 2, NULL, &sz);
1029 if (r != ERROR_SUCCESS) goto done;
1031 buffer = msi_alloc( sz + 1 );
1032 if (!buffer)
1034 r = ERROR_FUNCTION_FAILED;
1035 goto done;
1038 r = MSI_RecordReadStream(row, 2, buffer, &sz);
1039 if (r != ERROR_SUCCESS)
1040 goto done;
1042 buffer[sz] = 0;
1043 bufferw = strdupAtoW(buffer);
1044 if (!bufferw)
1046 r = ERROR_FUNCTION_FAILED;
1047 goto done;
1050 info = do_msidbCustomActionTypeScript( package, type, bufferw, target, action );
1051 r = wait_thread_handle( info );
1053 done:
1054 msi_free(bufferw);
1055 msi_free(buffer);
1056 msiobj_release(&row->hdr);
1057 return r;
1060 static UINT HANDLE_CustomType21_22( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
1061 INT type, const WCHAR *action )
1063 msi_custom_action_info *info;
1064 MSIFILE *file;
1065 HANDLE hFile;
1066 DWORD sz, szHighWord = 0, read;
1067 CHAR *buffer=NULL;
1068 WCHAR *bufferw=NULL;
1069 BOOL bRet;
1070 UINT r;
1072 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
1074 file = msi_get_loaded_file(package, source);
1075 if (!file)
1077 ERR("invalid file key %s\n", debugstr_w(source));
1078 return ERROR_FUNCTION_FAILED;
1081 hFile = CreateFileW(file->TargetPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
1082 if (hFile == INVALID_HANDLE_VALUE) return ERROR_FUNCTION_FAILED;
1084 sz = GetFileSize(hFile, &szHighWord);
1085 if (sz == INVALID_FILE_SIZE || szHighWord != 0)
1087 CloseHandle(hFile);
1088 return ERROR_FUNCTION_FAILED;
1090 buffer = msi_alloc( sz + 1 );
1091 if (!buffer)
1093 CloseHandle(hFile);
1094 return ERROR_FUNCTION_FAILED;
1096 bRet = ReadFile(hFile, buffer, sz, &read, NULL);
1097 CloseHandle(hFile);
1098 if (!bRet)
1100 r = ERROR_FUNCTION_FAILED;
1101 goto done;
1103 buffer[read] = 0;
1104 bufferw = strdupAtoW(buffer);
1105 if (!bufferw)
1107 r = ERROR_FUNCTION_FAILED;
1108 goto done;
1110 info = do_msidbCustomActionTypeScript( package, type, bufferw, target, action );
1111 r = wait_thread_handle( info );
1113 done:
1114 msi_free(bufferw);
1115 msi_free(buffer);
1116 return r;
1119 static UINT HANDLE_CustomType53_54( MSIPACKAGE *package, const WCHAR *source, const WCHAR *target,
1120 INT type, const WCHAR *action )
1122 msi_custom_action_info *info;
1123 WCHAR *prop;
1125 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
1127 prop = msi_dup_property( package->db, source );
1128 if (!prop) return ERROR_SUCCESS;
1130 info = do_msidbCustomActionTypeScript( package, type, prop, NULL, action );
1131 msi_free(prop);
1132 return wait_thread_handle( info );
1135 static BOOL action_type_matches_script( UINT type, UINT script )
1137 switch (script)
1139 case SCRIPT_NONE:
1140 case SCRIPT_INSTALL:
1141 return !(type & msidbCustomActionTypeCommit) && !(type & msidbCustomActionTypeRollback);
1142 case SCRIPT_COMMIT:
1143 return (type & msidbCustomActionTypeCommit);
1144 case SCRIPT_ROLLBACK:
1145 return (type & msidbCustomActionTypeRollback);
1146 default:
1147 ERR("unhandled script %u\n", script);
1149 return FALSE;
1152 static UINT defer_custom_action( MSIPACKAGE *package, const WCHAR *action, UINT type )
1154 WCHAR *actiondata = msi_dup_property( package->db, action );
1155 WCHAR *usersid = msi_dup_property( package->db, szUserSID );
1156 WCHAR *prodcode = msi_dup_property( package->db, szProductCode );
1157 WCHAR *deferred = msi_get_deferred_action( action, actiondata, usersid, prodcode );
1159 if (!deferred)
1161 msi_free( actiondata );
1162 msi_free( usersid );
1163 msi_free( prodcode );
1164 return ERROR_OUTOFMEMORY;
1166 if (type & msidbCustomActionTypeCommit)
1168 TRACE("deferring commit action\n");
1169 msi_schedule_action( package, SCRIPT_COMMIT, deferred );
1171 else if (type & msidbCustomActionTypeRollback)
1173 TRACE("deferring rollback action\n");
1174 msi_schedule_action( package, SCRIPT_ROLLBACK, deferred );
1176 else
1178 TRACE("deferring install action\n");
1179 msi_schedule_action( package, SCRIPT_INSTALL, deferred );
1182 msi_free( actiondata );
1183 msi_free( usersid );
1184 msi_free( prodcode );
1185 msi_free( deferred );
1186 return ERROR_SUCCESS;
1189 UINT ACTION_CustomAction( MSIPACKAGE *package, LPCWSTR action, UINT script )
1191 static const WCHAR query[] = {
1192 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1193 '`','C','u','s','t','o','m','A','c','t','i','o','n','`',' ','W','H','E','R','E',' ',
1194 '`','A','c','t','i' ,'o','n','`',' ','=',' ','\'','%','s','\'',0};
1195 UINT rc = ERROR_SUCCESS;
1196 MSIRECORD *row;
1197 UINT type;
1198 const WCHAR *source, *target, *ptr, *deferred_data = NULL;
1199 WCHAR *deformated = NULL;
1200 int len;
1202 /* deferred action: [properties]Action */
1203 if ((ptr = strrchrW(action, ']')))
1205 deferred_data = action;
1206 action = ptr + 1;
1209 row = MSI_QueryGetRecord( package->db, query, action );
1210 if (!row)
1211 return ERROR_FUNCTION_NOT_CALLED;
1213 type = MSI_RecordGetInteger(row,2);
1214 source = MSI_RecordGetString(row,3);
1215 target = MSI_RecordGetString(row,4);
1217 TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action),type,
1218 debugstr_w(source), debugstr_w(target));
1220 /* handle some of the deferred actions */
1221 if (type & msidbCustomActionTypeTSAware)
1222 FIXME("msidbCustomActionTypeTSAware not handled\n");
1224 if (type & msidbCustomActionTypeInScript)
1226 if (type & msidbCustomActionTypeNoImpersonate)
1227 WARN("msidbCustomActionTypeNoImpersonate not handled\n");
1229 if (!action_type_matches_script( type, script ))
1231 rc = defer_custom_action( package, action, type );
1232 goto end;
1234 else
1236 LPWSTR actiondata = msi_dup_property( package->db, action );
1238 if (type & msidbCustomActionTypeInScript)
1239 package->scheduled_action_running = TRUE;
1241 if (type & msidbCustomActionTypeCommit)
1242 package->commit_action_running = TRUE;
1244 if (type & msidbCustomActionTypeRollback)
1245 package->rollback_action_running = TRUE;
1247 if (deferred_data)
1248 set_deferred_action_props(package, deferred_data);
1249 else if (actiondata)
1250 msi_set_property( package->db, szCustomActionData, actiondata, -1 );
1251 else
1252 msi_set_property( package->db, szCustomActionData, szEmpty, -1 );
1254 msi_free(actiondata);
1257 else if (!check_execution_scheduling_options(package,action,type))
1259 rc = ERROR_SUCCESS;
1260 goto end;
1263 switch (type & CUSTOM_ACTION_TYPE_MASK)
1265 case 1: /* DLL file stored in a Binary table stream */
1266 rc = HANDLE_CustomType1(package,source,target,type,action);
1267 break;
1268 case 2: /* EXE file stored in a Binary table stream */
1269 rc = HANDLE_CustomType2(package,source,target,type,action);
1270 break;
1271 case 18: /*EXE file installed with package */
1272 rc = HANDLE_CustomType18(package,source,target,type,action);
1273 break;
1274 case 19: /* Error that halts install */
1275 rc = HANDLE_CustomType19(package,source,target,type,action);
1276 break;
1277 case 17:
1278 rc = HANDLE_CustomType17(package,source,target,type,action);
1279 break;
1280 case 23: /* installs another package in the source tree */
1281 deformat_string(package,target,&deformated);
1282 rc = HANDLE_CustomType23(package,source,deformated,type,action);
1283 msi_free(deformated);
1284 break;
1285 case 50: /*EXE file specified by a property value */
1286 rc = HANDLE_CustomType50(package,source,target,type,action);
1287 break;
1288 case 34: /*EXE to be run in specified directory */
1289 rc = HANDLE_CustomType34(package,source,target,type,action);
1290 break;
1291 case 35: /* Directory set with formatted text. */
1292 deformat_string(package,target,&deformated);
1293 MSI_SetTargetPathW(package, source, deformated);
1294 msi_free(deformated);
1295 break;
1296 case 51: /* Property set with formatted text. */
1297 if (!source)
1298 break;
1300 len = deformat_string( package, target, &deformated );
1301 rc = msi_set_property( package->db, source, deformated, len );
1302 if (rc == ERROR_SUCCESS && !strcmpW( source, szSourceDir ))
1303 msi_reset_folders( package, TRUE );
1304 msi_free(deformated);
1305 break;
1306 case 37: /* JScript/VBScript text stored in target column. */
1307 case 38:
1308 rc = HANDLE_CustomType37_38(package,source,target,type,action);
1309 break;
1310 case 5:
1311 case 6: /* JScript/VBScript file stored in a Binary table stream. */
1312 rc = HANDLE_CustomType5_6(package,source,target,type,action);
1313 break;
1314 case 21: /* JScript/VBScript file installed with the product. */
1315 case 22:
1316 rc = HANDLE_CustomType21_22(package,source,target,type,action);
1317 break;
1318 case 53: /* JScript/VBScript text specified by a property value. */
1319 case 54:
1320 rc = HANDLE_CustomType53_54(package,source,target,type,action);
1321 break;
1322 default:
1323 FIXME("unhandled action type %u (%s %s)\n", type & CUSTOM_ACTION_TYPE_MASK,
1324 debugstr_w(source), debugstr_w(target));
1327 end:
1328 package->scheduled_action_running = FALSE;
1329 package->commit_action_running = FALSE;
1330 package->rollback_action_running = FALSE;
1331 msiobj_release(&row->hdr);
1332 return rc;
1335 void ACTION_FinishCustomActions(const MSIPACKAGE* package)
1337 struct list *item;
1338 HANDLE *wait_handles;
1339 unsigned int handle_count, i;
1340 msi_custom_action_info *info, *cursor;
1342 while ((item = list_head( &package->RunningActions )))
1344 MSIRUNNINGACTION *action = LIST_ENTRY( item, MSIRUNNINGACTION, entry );
1346 list_remove( &action->entry );
1348 TRACE("waiting for %s\n", debugstr_w( action->name ) );
1349 msi_dialog_check_messages( action->handle );
1351 CloseHandle( action->handle );
1352 msi_free( action->name );
1353 msi_free( action );
1356 EnterCriticalSection( &msi_custom_action_cs );
1358 handle_count = list_count( &msi_pending_custom_actions );
1359 wait_handles = msi_alloc( handle_count * sizeof(HANDLE) );
1361 handle_count = 0;
1362 LIST_FOR_EACH_ENTRY_SAFE( info, cursor, &msi_pending_custom_actions, msi_custom_action_info, entry )
1364 if (info->package == package )
1366 if (DuplicateHandle(GetCurrentProcess(), info->handle, GetCurrentProcess(), &wait_handles[handle_count], SYNCHRONIZE, FALSE, 0))
1367 handle_count++;
1371 LeaveCriticalSection( &msi_custom_action_cs );
1373 for (i = 0; i < handle_count; i++)
1375 msi_dialog_check_messages( wait_handles[i] );
1376 CloseHandle( wait_handles[i] );
1378 msi_free( wait_handles );
1380 EnterCriticalSection( &msi_custom_action_cs );
1381 LIST_FOR_EACH_ENTRY_SAFE( info, cursor, &msi_pending_custom_actions, msi_custom_action_info, entry )
1383 if (info->package == package) release_custom_action_data( info );
1385 LeaveCriticalSection( &msi_custom_action_cs );
1388 typedef struct _msi_custom_remote_impl {
1389 IWineMsiRemoteCustomAction IWineMsiRemoteCustomAction_iface;
1390 LONG refs;
1391 } msi_custom_remote_impl;
1393 static inline msi_custom_remote_impl *impl_from_IWineMsiRemoteCustomAction( IWineMsiRemoteCustomAction *iface )
1395 return CONTAINING_RECORD(iface, msi_custom_remote_impl, IWineMsiRemoteCustomAction_iface);
1398 static HRESULT WINAPI mcr_QueryInterface( IWineMsiRemoteCustomAction *iface,
1399 REFIID riid,LPVOID *ppobj)
1401 if( IsEqualCLSID( riid, &IID_IUnknown ) ||
1402 IsEqualCLSID( riid, &IID_IWineMsiRemoteCustomAction ) )
1404 IWineMsiRemoteCustomAction_AddRef( iface );
1405 *ppobj = iface;
1406 return S_OK;
1409 return E_NOINTERFACE;
1412 static ULONG WINAPI mcr_AddRef( IWineMsiRemoteCustomAction *iface )
1414 msi_custom_remote_impl* This = impl_from_IWineMsiRemoteCustomAction( iface );
1416 return InterlockedIncrement( &This->refs );
1419 static ULONG WINAPI mcr_Release( IWineMsiRemoteCustomAction *iface )
1421 msi_custom_remote_impl* This = impl_from_IWineMsiRemoteCustomAction( iface );
1422 ULONG r;
1424 r = InterlockedDecrement( &This->refs );
1425 if (r == 0)
1426 msi_free( This );
1427 return r;
1430 static HRESULT WINAPI mcr_GetActionInfo( IWineMsiRemoteCustomAction *iface, LPCGUID custom_action_guid,
1431 INT *type, MSIHANDLE *handle, BSTR *dll, BSTR *func, IWineMsiRemotePackage **remote_package )
1433 msi_custom_action_info *info;
1435 info = find_action_by_guid( custom_action_guid );
1436 if (!info)
1437 return E_FAIL;
1439 *type = info->type;
1440 *handle = alloc_msihandle( &info->package->hdr );
1441 *dll = SysAllocString( info->source );
1442 *func = SysAllocString( info->target );
1444 release_custom_action_data( info );
1445 return create_msi_remote_package( NULL, (LPVOID *)remote_package );
1448 static const IWineMsiRemoteCustomActionVtbl msi_custom_remote_vtbl =
1450 mcr_QueryInterface,
1451 mcr_AddRef,
1452 mcr_Release,
1453 mcr_GetActionInfo,
1456 HRESULT create_msi_custom_remote( IUnknown *pOuter, LPVOID *ppObj )
1458 msi_custom_remote_impl* This;
1460 This = msi_alloc( sizeof *This );
1461 if (!This)
1462 return E_OUTOFMEMORY;
1464 This->IWineMsiRemoteCustomAction_iface.lpVtbl = &msi_custom_remote_vtbl;
1465 This->refs = 1;
1467 *ppObj = &This->IWineMsiRemoteCustomAction_iface;
1469 return S_OK;