winepulse.drv: add a pulseaudio driver
[wine/hacks.git] / dlls / msi / custom.c
blob5a1787f7d15661848528d4d537d37278fb7706f0
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
44 static const WCHAR c_collen[] = {'C',':','\\',0};
45 static const WCHAR cszTempFolder[]= {'T','e','m','p','F','o','l','d','e','r',0};
47 typedef struct tagMSIRUNNINGACTION
49 struct list entry;
50 HANDLE handle;
51 BOOL process;
52 LPWSTR name;
53 } MSIRUNNINGACTION;
55 static UINT HANDLE_CustomType1(MSIPACKAGE *package, LPCWSTR source,
56 LPCWSTR target, const INT type, LPCWSTR action);
57 static UINT HANDLE_CustomType2(MSIPACKAGE *package, LPCWSTR source,
58 LPCWSTR target, const INT type, LPCWSTR action);
59 static UINT HANDLE_CustomType17(MSIPACKAGE *package, LPCWSTR source,
60 LPCWSTR target, const INT type, LPCWSTR action);
61 static UINT HANDLE_CustomType18(MSIPACKAGE *package, LPCWSTR source,
62 LPCWSTR target, const INT type, LPCWSTR action);
63 static UINT HANDLE_CustomType19(MSIPACKAGE *package, LPCWSTR source,
64 LPCWSTR target, const INT type, LPCWSTR action);
65 static UINT HANDLE_CustomType23(MSIPACKAGE *package, LPCWSTR source,
66 LPCWSTR target, const INT type, LPCWSTR action);
67 static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source,
68 LPCWSTR target, const INT type, LPCWSTR action);
69 static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source,
70 LPCWSTR target, const INT type, LPCWSTR action);
71 static UINT HANDLE_CustomType37_38(MSIPACKAGE *package, LPCWSTR source,
72 LPCWSTR target, const INT type, LPCWSTR action);
73 static UINT HANDLE_CustomType5_6(MSIPACKAGE *package, LPCWSTR source,
74 LPCWSTR target, const INT type, LPCWSTR action);
75 static UINT HANDLE_CustomType21_22(MSIPACKAGE *package, LPCWSTR source,
76 LPCWSTR target, const INT type, LPCWSTR action);
77 static UINT HANDLE_CustomType53_54(MSIPACKAGE *package, LPCWSTR source,
78 LPCWSTR target, const INT type, LPCWSTR action);
80 typedef UINT (WINAPI *MsiCustomActionEntryPoint)( MSIHANDLE );
82 static CRITICAL_SECTION msi_custom_action_cs;
83 static CRITICAL_SECTION_DEBUG msi_custom_action_cs_debug =
85 0, 0, &msi_custom_action_cs,
86 { &msi_custom_action_cs_debug.ProcessLocksList,
87 &msi_custom_action_cs_debug.ProcessLocksList },
88 0, 0, { (DWORD_PTR)(__FILE__ ": msi_custom_action_cs") }
90 static CRITICAL_SECTION msi_custom_action_cs = { &msi_custom_action_cs_debug, -1, 0, 0, 0, 0 };
92 static struct list msi_pending_custom_actions = LIST_INIT( msi_pending_custom_actions );
94 static BOOL check_execution_scheduling_options(MSIPACKAGE *package, LPCWSTR action, UINT options)
96 if (!package->script)
97 return TRUE;
99 if ((options & msidbCustomActionTypeClientRepeat) ==
100 msidbCustomActionTypeClientRepeat)
102 if (!(package->script->InWhatSequence & SEQUENCE_UI &&
103 package->script->InWhatSequence & SEQUENCE_EXEC))
105 TRACE("Skipping action due to dbCustomActionTypeClientRepeat option.\n");
106 return FALSE;
109 else if (options & msidbCustomActionTypeFirstSequence)
111 if (package->script->InWhatSequence & SEQUENCE_UI &&
112 package->script->InWhatSequence & SEQUENCE_EXEC )
114 TRACE("Skipping action due to msidbCustomActionTypeFirstSequence option.\n");
115 return FALSE;
118 else if (options & msidbCustomActionTypeOncePerProcess)
120 if (check_unique_action(package,action))
122 TRACE("Skipping action due to msidbCustomActionTypeOncePerProcess option.\n");
123 return FALSE;
125 else
126 register_unique_action(package,action);
129 return TRUE;
132 /* stores the following properties before the action:
134 * [CustomActionData<=>UserSID<=>ProductCode]Action
136 static LPWSTR msi_get_deferred_action(LPCWSTR action, LPCWSTR actiondata,
137 LPCWSTR usersid, LPCWSTR prodcode)
139 LPWSTR deferred;
140 DWORD len;
142 static const WCHAR format[] = {
143 '[','%','s','<','=','>','%','s','<','=','>','%','s',']','%','s',0
146 if (!actiondata)
147 return strdupW(action);
149 len = lstrlenW(action) + lstrlenW(actiondata) +
150 lstrlenW(usersid) + lstrlenW(prodcode) +
151 lstrlenW(format) - 7;
152 deferred = msi_alloc(len * sizeof(WCHAR));
154 sprintfW(deferred, format, actiondata, usersid, prodcode, action);
155 return deferred;
158 static void set_deferred_action_props(MSIPACKAGE *package, LPWSTR deferred_data)
160 LPWSTR end, beg = deferred_data + 1;
162 static const WCHAR sep[] = {'<','=','>',0};
164 end = strstrW(beg, sep);
165 *end = '\0';
166 msi_set_property(package->db, szCustomActionData, beg);
167 beg = end + 3;
169 end = strstrW(beg, sep);
170 *end = '\0';
171 msi_set_property(package->db, szUserSID, beg);
172 beg = end + 3;
174 end = strchrW(beg, ']');
175 *end = '\0';
176 msi_set_property(package->db, szProductCode, beg);
179 UINT ACTION_CustomAction(MSIPACKAGE *package, LPCWSTR action, UINT script, BOOL execute)
181 UINT rc = ERROR_SUCCESS;
182 MSIRECORD * row = 0;
183 static const WCHAR ExecSeqQuery[] =
184 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
185 '`','C','u','s','t','o' ,'m','A','c','t','i','o','n','`',
186 ' ','W','H','E','R','E',' ','`','A','c','t','i' ,'o','n','`',' ',
187 '=',' ','\'','%','s','\'',0};
188 UINT type;
189 LPCWSTR source, target;
190 LPWSTR ptr, deferred_data = NULL;
191 LPWSTR action_copy = strdupW(action);
192 WCHAR *deformated=NULL;
194 /* deferred action: [properties]Action */
195 if ((ptr = strrchrW(action_copy, ']')))
197 deferred_data = action_copy;
198 action = ptr + 1;
201 row = MSI_QueryGetRecord( package->db, ExecSeqQuery, action );
202 if (!row)
204 msi_free(action_copy);
205 return ERROR_CALL_NOT_IMPLEMENTED;
208 type = MSI_RecordGetInteger(row,2);
210 source = MSI_RecordGetString(row,3);
211 target = MSI_RecordGetString(row,4);
213 TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action),type,
214 debugstr_w(source), debugstr_w(target));
216 /* handle some of the deferred actions */
217 if (type & msidbCustomActionTypeTSAware)
218 FIXME("msidbCustomActionTypeTSAware not handled\n");
220 if (type & msidbCustomActionTypeInScript)
222 if (type & msidbCustomActionTypeNoImpersonate)
223 WARN("msidbCustomActionTypeNoImpersonate not handled\n");
225 if (type & msidbCustomActionTypeRollback)
227 FIXME("Rollback only action... rollbacks not supported yet\n");
228 schedule_action(package, ROLLBACK_SCRIPT, action);
229 rc = ERROR_SUCCESS;
230 goto end;
232 if (!execute)
234 LPWSTR actiondata = msi_dup_property(package->db, action);
235 LPWSTR usersid = msi_dup_property(package->db, szUserSID);
236 LPWSTR prodcode = msi_dup_property(package->db, szProductCode);
237 LPWSTR deferred = msi_get_deferred_action(action, actiondata, usersid, prodcode);
239 if (type & msidbCustomActionTypeCommit)
241 TRACE("Deferring Commit Action!\n");
242 schedule_action(package, COMMIT_SCRIPT, deferred);
244 else
246 TRACE("Deferring Action!\n");
247 schedule_action(package, INSTALL_SCRIPT, deferred);
250 rc = ERROR_SUCCESS;
251 msi_free(actiondata);
252 msi_free(usersid);
253 msi_free(prodcode);
254 msi_free(deferred);
255 goto end;
257 else
259 LPWSTR actiondata = msi_dup_property( package->db, action );
261 switch (script)
263 case INSTALL_SCRIPT:
264 package->scheduled_action_running = TRUE;
265 break;
266 case COMMIT_SCRIPT:
267 package->commit_action_running = TRUE;
268 break;
269 case ROLLBACK_SCRIPT:
270 package->rollback_action_running = TRUE;
271 break;
272 default:
273 break;
276 if (deferred_data)
277 set_deferred_action_props(package, deferred_data);
278 else if (actiondata)
279 msi_set_property(package->db, szCustomActionData, actiondata);
280 else
281 msi_set_property(package->db, szCustomActionData, szEmpty);
283 msi_free(actiondata);
286 else if (!check_execution_scheduling_options(package,action,type))
288 rc = ERROR_SUCCESS;
289 goto end;
292 switch (type & CUSTOM_ACTION_TYPE_MASK)
294 case 1: /* DLL file stored in a Binary table stream */
295 rc = HANDLE_CustomType1(package,source,target,type,action);
296 break;
297 case 2: /* EXE file stored in a Binary table stream */
298 rc = HANDLE_CustomType2(package,source,target,type,action);
299 break;
300 case 18: /*EXE file installed with package */
301 rc = HANDLE_CustomType18(package,source,target,type,action);
302 break;
303 case 19: /* Error that halts install */
304 rc = HANDLE_CustomType19(package,source,target,type,action);
305 break;
306 case 17:
307 rc = HANDLE_CustomType17(package,source,target,type,action);
308 break;
309 case 23: /* installs another package in the source tree */
310 deformat_string(package,target,&deformated);
311 rc = HANDLE_CustomType23(package,source,deformated,type,action);
312 msi_free(deformated);
313 break;
314 case 50: /*EXE file specified by a property value */
315 rc = HANDLE_CustomType50(package,source,target,type,action);
316 break;
317 case 34: /*EXE to be run in specified directory */
318 rc = HANDLE_CustomType34(package,source,target,type,action);
319 break;
320 case 35: /* Directory set with formatted text. */
321 deformat_string(package,target,&deformated);
322 MSI_SetTargetPathW(package, source, deformated);
323 msi_free(deformated);
324 break;
325 case 51: /* Property set with formatted text. */
326 if (!source)
327 break;
329 deformat_string(package,target,&deformated);
330 rc = msi_set_property( package->db, source, deformated );
331 if (rc == ERROR_SUCCESS && !strcmpW( source, cszSourceDir ))
332 msi_reset_folders( package, TRUE );
333 msi_free(deformated);
334 break;
335 case 37: /* JScript/VBScript text stored in target column. */
336 case 38:
337 rc = HANDLE_CustomType37_38(package,source,target,type,action);
338 break;
339 case 5:
340 case 6: /* JScript/VBScript file stored in a Binary table stream. */
341 rc = HANDLE_CustomType5_6(package,source,target,type,action);
342 break;
343 case 21: /* JScript/VBScript file installed with the product. */
344 case 22:
345 rc = HANDLE_CustomType21_22(package,source,target,type,action);
346 break;
347 case 53: /* JScript/VBScript text specified by a property value. */
348 case 54:
349 rc = HANDLE_CustomType53_54(package,source,target,type,action);
350 break;
351 default:
352 FIXME("UNHANDLED ACTION TYPE %i (%s %s)\n",
353 type & CUSTOM_ACTION_TYPE_MASK, debugstr_w(source),
354 debugstr_w(target));
357 end:
358 package->scheduled_action_running = FALSE;
359 package->commit_action_running = FALSE;
360 package->rollback_action_running = FALSE;
361 msi_free(action_copy);
362 msiobj_release(&row->hdr);
363 return rc;
367 static UINT store_binary_to_temp(MSIPACKAGE *package, LPCWSTR source,
368 LPWSTR tmp_file)
370 static const WCHAR query[] = {
371 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
372 '`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E',' ',
373 '`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0};
374 MSIRECORD *row = 0;
375 HANDLE file;
376 CHAR buffer[1024];
377 WCHAR fmt[MAX_PATH];
378 DWORD sz = MAX_PATH;
379 UINT r;
381 if (msi_get_property(package->db, cszTempFolder, fmt, &sz) != ERROR_SUCCESS)
382 GetTempPathW(MAX_PATH, fmt);
384 if (GetTempFileNameW(fmt, szMsi, 0, tmp_file) == 0)
386 TRACE("Unable to create file\n");
387 return ERROR_FUNCTION_FAILED;
389 track_tempfile(package, tmp_file);
391 row = MSI_QueryGetRecord(package->db, query, source);
392 if (!row)
393 return ERROR_FUNCTION_FAILED;
395 /* write out the file */
396 file = CreateFileW(tmp_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
397 FILE_ATTRIBUTE_NORMAL, NULL);
398 if (file == INVALID_HANDLE_VALUE)
399 r = ERROR_FUNCTION_FAILED;
400 else
404 DWORD write;
405 sz = sizeof buffer;
406 r = MSI_RecordReadStream(row, 2, buffer, &sz);
407 if (r != ERROR_SUCCESS)
409 ERR("Failed to get stream\n");
410 break;
412 WriteFile(file, buffer, sz, &write, NULL);
413 } while (sz == sizeof buffer);
414 CloseHandle(file);
417 msiobj_release(&row->hdr);
419 return r;
422 static void file_running_action(MSIPACKAGE* package, HANDLE Handle,
423 BOOL process, LPCWSTR name)
425 MSIRUNNINGACTION *action;
427 action = msi_alloc( sizeof(MSIRUNNINGACTION) );
429 action->handle = Handle;
430 action->process = process;
431 action->name = strdupW(name);
433 list_add_tail( &package->RunningActions, &action->entry );
436 static UINT custom_get_process_return( HANDLE process )
438 DWORD rc = 0;
440 GetExitCodeProcess( process, &rc );
441 if (rc != 0)
442 return ERROR_FUNCTION_FAILED;
443 return ERROR_SUCCESS;
446 static UINT custom_get_thread_return( MSIPACKAGE *package, HANDLE thread )
448 DWORD rc = 0;
450 GetExitCodeThread( thread, &rc );
452 switch (rc)
454 case ERROR_FUNCTION_NOT_CALLED:
455 case ERROR_SUCCESS:
456 case ERROR_INSTALL_USEREXIT:
457 case ERROR_INSTALL_FAILURE:
458 return rc;
459 case ERROR_NO_MORE_ITEMS:
460 return ERROR_SUCCESS;
461 case ERROR_INSTALL_SUSPEND:
462 ACTION_ForceReboot( package );
463 return ERROR_SUCCESS;
464 default:
465 ERR("Invalid Return Code %d\n",rc);
466 return ERROR_INSTALL_FAILURE;
470 static UINT wait_process_handle(MSIPACKAGE* package, UINT type,
471 HANDLE ProcessHandle, LPCWSTR name)
473 UINT rc = ERROR_SUCCESS;
475 if (!(type & msidbCustomActionTypeAsync))
477 TRACE("waiting for %s\n", debugstr_w(name));
479 msi_dialog_check_messages(ProcessHandle);
481 if (!(type & msidbCustomActionTypeContinue))
482 rc = custom_get_process_return(ProcessHandle);
484 CloseHandle(ProcessHandle);
486 else
488 TRACE("%s running in background\n", debugstr_w(name));
490 if (!(type & msidbCustomActionTypeContinue))
491 file_running_action(package, ProcessHandle, TRUE, name);
492 else
493 CloseHandle(ProcessHandle);
496 return rc;
499 typedef struct _msi_custom_action_info {
500 struct list entry;
501 LONG refs;
502 MSIPACKAGE *package;
503 LPWSTR source;
504 LPWSTR target;
505 HANDLE handle;
506 LPWSTR action;
507 INT type;
508 GUID guid;
509 } msi_custom_action_info;
511 static void release_custom_action_data( msi_custom_action_info *info )
513 EnterCriticalSection( &msi_custom_action_cs );
515 if (!--info->refs)
517 list_remove( &info->entry );
518 if (info->handle)
519 CloseHandle( info->handle );
520 msi_free( info->action );
521 msi_free( info->source );
522 msi_free( info->target );
523 msiobj_release( &info->package->hdr );
524 msi_free( info );
527 LeaveCriticalSection( &msi_custom_action_cs );
530 /* must be called inside msi_custom_action_cs if info is in the pending custom actions list */
531 static void addref_custom_action_data( msi_custom_action_info *info )
533 info->refs++;
536 static UINT wait_thread_handle( msi_custom_action_info *info )
538 UINT rc = ERROR_SUCCESS;
540 if (!(info->type & msidbCustomActionTypeAsync))
542 TRACE("waiting for %s\n", debugstr_w( info->action ));
544 msi_dialog_check_messages( info->handle );
546 if (!(info->type & msidbCustomActionTypeContinue))
547 rc = custom_get_thread_return( info->package, info->handle );
549 release_custom_action_data( info );
551 else
553 TRACE("%s running in background\n", debugstr_w( info->action ));
556 return rc;
559 static msi_custom_action_info *find_action_by_guid( const GUID *guid )
561 msi_custom_action_info *info;
562 BOOL found = FALSE;
564 EnterCriticalSection( &msi_custom_action_cs );
566 LIST_FOR_EACH_ENTRY( info, &msi_pending_custom_actions, msi_custom_action_info, entry )
568 if (IsEqualGUID( &info->guid, guid ))
570 addref_custom_action_data( info );
571 found = TRUE;
572 break;
576 LeaveCriticalSection( &msi_custom_action_cs );
578 if (!found)
579 return NULL;
581 return info;
584 static void handle_msi_break( LPCWSTR target )
586 LPWSTR msg;
587 WCHAR val[MAX_PATH];
589 static const WCHAR MsiBreak[] = { 'M','s','i','B','r','e','a','k',0 };
590 static const WCHAR WindowsInstaller[] = {
591 'W','i','n','d','o','w','s',' ','I','n','s','t','a','l','l','e','r',0
594 static const WCHAR format[] = {
595 'T','o',' ','d','e','b','u','g',' ','y','o','u','r',' ',
596 'c','u','s','t','o','m',' ','a','c','t','i','o','n',',',' ',
597 'a','t','t','a','c','h',' ','y','o','u','r',' ','d','e','b','u','g','g','e','r',' ',
598 't','o',' ','p','r','o','c','e','s','s',' ','%','i',' ','(','0','x','%','X',')',' ',
599 'a','n','d',' ','p','r','e','s','s',' ','O','K',0
602 if( !GetEnvironmentVariableW( MsiBreak, val, MAX_PATH ))
603 return;
605 if( lstrcmpiW( val, target ))
606 return;
608 msg = msi_alloc( (lstrlenW(format) + 10) * sizeof(WCHAR) );
609 if (!msg)
610 return;
612 wsprintfW( msg, format, GetCurrentProcessId(), GetCurrentProcessId());
613 MessageBoxW( NULL, msg, WindowsInstaller, MB_OK);
614 msi_free(msg);
615 DebugBreak();
618 static UINT get_action_info( const GUID *guid, INT *type, MSIHANDLE *handle,
619 BSTR *dll, BSTR *funcname,
620 IWineMsiRemotePackage **package )
622 IClassFactory *cf = NULL;
623 IWineMsiRemoteCustomAction *rca = NULL;
624 HRESULT r;
626 r = DllGetClassObject( &CLSID_IWineMsiRemoteCustomAction,
627 &IID_IClassFactory, (LPVOID *)&cf );
628 if (FAILED(r))
630 ERR("failed to get IClassFactory interface\n");
631 return ERROR_FUNCTION_FAILED;
634 r = IClassFactory_CreateInstance( cf, NULL, &IID_IWineMsiRemoteCustomAction, (LPVOID *)&rca );
635 if (FAILED(r))
637 ERR("failed to get IWineMsiRemoteCustomAction interface\n");
638 return ERROR_FUNCTION_FAILED;
641 r = IWineMsiRemoteCustomAction_GetActionInfo( rca, guid, type, handle, dll, funcname, package );
642 IWineMsiRemoteCustomAction_Release( rca );
643 if (FAILED(r))
645 ERR("GetActionInfo failed\n");
646 return ERROR_FUNCTION_FAILED;
649 return ERROR_SUCCESS;
652 #ifdef __i386__
653 extern UINT CUSTOMPROC_wrapper( MsiCustomActionEntryPoint proc, MSIHANDLE handle );
654 __ASM_GLOBAL_FUNC( CUSTOMPROC_wrapper,
655 "pushl %ebp\n\t"
656 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
657 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
658 "movl %esp,%ebp\n\t"
659 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
660 "pushl 12(%ebp)\n\t"
661 "movl 8(%ebp),%eax\n\t"
662 "call *%eax\n\t"
663 "leave\n\t"
664 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
665 __ASM_CFI(".cfi_same_value %ebp\n\t")
666 "ret" )
667 #else
668 static inline UINT CUSTOMPROC_wrapper( MsiCustomActionEntryPoint proc, MSIHANDLE handle )
670 return proc(handle);
672 #endif
674 static DWORD ACTION_CallDllFunction( const GUID *guid )
676 MsiCustomActionEntryPoint fn;
677 MSIHANDLE hPackage, handle;
678 HANDLE hModule;
679 LPSTR proc;
680 UINT r = ERROR_FUNCTION_FAILED;
681 BSTR dll = NULL, function = NULL;
682 INT type;
683 IWineMsiRemotePackage *remote_package = NULL;
685 TRACE("%s\n", debugstr_guid( guid ));
687 r = get_action_info( guid, &type, &handle, &dll, &function, &remote_package );
688 if (r != ERROR_SUCCESS)
689 return r;
691 hModule = LoadLibraryW( dll );
692 if (!hModule)
694 ERR("failed to load dll %s (%u)\n", debugstr_w( dll ), GetLastError() );
695 return r;
698 proc = strdupWtoA( function );
699 fn = (MsiCustomActionEntryPoint) GetProcAddress( hModule, proc );
700 msi_free( proc );
701 if (fn)
703 hPackage = alloc_msi_remote_handle( (IUnknown *)remote_package );
704 if (hPackage)
706 IWineMsiRemotePackage_SetMsiHandle( remote_package, handle );
707 TRACE("calling %s\n", debugstr_w( function ) );
708 handle_msi_break( function );
710 __TRY
712 r = CUSTOMPROC_wrapper( fn, hPackage );
714 __EXCEPT_PAGE_FAULT
716 ERR("Custom action (%s:%s) caused a page fault: %08x\n",
717 debugstr_w(dll), debugstr_w(function), GetExceptionCode());
718 r = ERROR_SUCCESS;
720 __ENDTRY;
722 MsiCloseHandle( hPackage );
724 else
725 ERR("failed to create handle for %p\n", remote_package );
727 else
728 ERR("GetProcAddress(%s) failed\n", debugstr_w( function ) );
730 FreeLibrary(hModule);
732 IWineMsiRemotePackage_Release( remote_package );
733 SysFreeString( dll );
734 SysFreeString( function );
735 MsiCloseHandle( handle );
737 return r;
740 static DWORD WINAPI DllThread( LPVOID arg )
742 LPGUID guid = arg;
743 DWORD rc = 0;
745 TRACE("custom action (%x) started\n", GetCurrentThreadId() );
747 rc = ACTION_CallDllFunction( guid );
749 TRACE("custom action (%x) returned %i\n", GetCurrentThreadId(), rc );
751 MsiCloseAllHandles();
752 return rc;
755 static DWORD ACTION_CAInstallPackage(const GUID *guid)
757 msi_custom_action_info *info;
758 UINT r = ERROR_FUNCTION_FAILED;
759 INSTALLUILEVEL old_level;
761 info = find_action_by_guid(guid);
762 if (!info)
764 ERR("failed to find action %s\n", debugstr_guid(guid));
765 return r;
768 old_level = MsiSetInternalUI(INSTALLUILEVEL_BASIC, NULL);
769 r = MsiInstallProductW(info->source, info->target);
770 MsiSetInternalUI(old_level, NULL);
772 release_custom_action_data(info);
774 return r;
777 static DWORD WINAPI ConcurrentInstallThread(LPVOID arg)
779 LPGUID guid = arg;
780 DWORD rc;
782 TRACE("concurrent installation (%x) started\n", GetCurrentThreadId());
784 rc = ACTION_CAInstallPackage(guid);
786 TRACE("concurrent installation (%x) returned %i\n", GetCurrentThreadId(), rc);
788 MsiCloseAllHandles();
789 return rc;
792 static msi_custom_action_info *do_msidbCustomActionTypeDll(
793 MSIPACKAGE *package, INT type, LPCWSTR source, LPCWSTR target, LPCWSTR action )
795 msi_custom_action_info *info;
797 info = msi_alloc( sizeof *info );
798 if (!info)
799 return NULL;
801 msiobj_addref( &package->hdr );
802 info->refs = 2; /* 1 for our caller and 1 for thread we created */
803 info->package = package;
804 info->type = type;
805 info->target = strdupW( target );
806 info->source = strdupW( source );
807 info->action = strdupW( action );
808 CoCreateGuid( &info->guid );
810 EnterCriticalSection( &msi_custom_action_cs );
811 list_add_tail( &msi_pending_custom_actions, &info->entry );
812 LeaveCriticalSection( &msi_custom_action_cs );
814 info->handle = CreateThread( NULL, 0, DllThread, &info->guid, 0, NULL );
815 if (!info->handle)
817 /* release both references */
818 release_custom_action_data( info );
819 release_custom_action_data( info );
820 return NULL;
823 return info;
826 static msi_custom_action_info *do_msidbCAConcurrentInstall(
827 MSIPACKAGE *package, INT type, LPCWSTR source, LPCWSTR target, LPCWSTR action)
829 msi_custom_action_info *info;
831 info = msi_alloc( sizeof *info );
832 if (!info)
833 return NULL;
835 msiobj_addref( &package->hdr );
836 info->refs = 2; /* 1 for our caller and 1 for thread we created */
837 info->package = package;
838 info->type = type;
839 info->target = strdupW( target );
840 info->source = strdupW( source );
841 info->action = strdupW( action );
842 CoCreateGuid( &info->guid );
844 EnterCriticalSection( &msi_custom_action_cs );
845 list_add_tail( &msi_pending_custom_actions, &info->entry );
846 LeaveCriticalSection( &msi_custom_action_cs );
848 info->handle = CreateThread( NULL, 0, ConcurrentInstallThread, &info->guid, 0, NULL );
849 if (!info->handle)
851 /* release both references */
852 release_custom_action_data( info );
853 release_custom_action_data( info );
854 return NULL;
857 return info;
860 static UINT HANDLE_CustomType23(MSIPACKAGE *package, LPCWSTR source,
861 LPCWSTR target, const INT type, LPCWSTR action)
863 msi_custom_action_info *info;
864 WCHAR package_path[MAX_PATH];
865 DWORD size;
866 UINT r;
868 size = MAX_PATH;
869 msi_get_property(package->db, cszSourceDir, package_path, &size);
870 lstrcatW(package_path, szBackSlash);
871 lstrcatW(package_path, source);
873 TRACE("Installing package %s concurrently\n", debugstr_w(package_path));
875 info = do_msidbCAConcurrentInstall(package, type, package_path, target, action);
877 r = wait_thread_handle(info);
878 release_custom_action_data( info );
879 return r;
882 static UINT HANDLE_CustomType1(MSIPACKAGE *package, LPCWSTR source,
883 LPCWSTR target, const INT type, LPCWSTR action)
885 msi_custom_action_info *info;
886 WCHAR tmp_file[MAX_PATH];
887 UINT r;
889 r = store_binary_to_temp(package, source, tmp_file);
890 if (r != ERROR_SUCCESS)
891 return r;
893 TRACE("Calling function %s from %s\n",debugstr_w(target),
894 debugstr_w(tmp_file));
896 if (!strchrW(tmp_file,'.'))
897 strcatW(tmp_file, szDot);
899 info = do_msidbCustomActionTypeDll( package, type, tmp_file, target, action );
901 r = wait_thread_handle( info );
902 release_custom_action_data( info );
903 return r;
906 static UINT HANDLE_CustomType2(MSIPACKAGE *package, LPCWSTR source,
907 LPCWSTR target, const INT type, LPCWSTR action)
909 WCHAR tmp_file[MAX_PATH];
910 STARTUPINFOW si;
911 PROCESS_INFORMATION info;
912 BOOL rc;
913 INT len;
914 WCHAR *deformated = NULL;
915 WCHAR *cmd;
916 static const WCHAR spc[] = {' ',0};
917 UINT r;
919 memset(&si,0,sizeof(STARTUPINFOW));
921 r = store_binary_to_temp(package, source, tmp_file);
922 if (r != ERROR_SUCCESS)
923 return r;
925 deformat_string(package,target,&deformated);
927 len = strlenW(tmp_file)+2;
929 if (deformated)
930 len += strlenW(deformated);
932 cmd = msi_alloc(sizeof(WCHAR)*len);
934 strcpyW(cmd,tmp_file);
935 if (deformated)
937 strcatW(cmd,spc);
938 strcatW(cmd,deformated);
940 msi_free(deformated);
943 TRACE("executing exe %s\n", debugstr_w(cmd));
945 rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
946 c_collen, &si, &info);
947 msi_free(cmd);
949 if ( !rc )
951 ERR("Unable to execute command %s\n", debugstr_w(cmd));
952 return ERROR_SUCCESS;
954 CloseHandle( info.hThread );
956 r = wait_process_handle(package, type, info.hProcess, action);
958 return r;
961 static UINT HANDLE_CustomType17(MSIPACKAGE *package, LPCWSTR source,
962 LPCWSTR target, const INT type, LPCWSTR action)
964 msi_custom_action_info *info;
965 MSIFILE *file;
966 UINT r;
968 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
970 file = get_loaded_file( package, source );
971 if (!file)
973 ERR("invalid file key %s\n", debugstr_w( source ));
974 return ERROR_FUNCTION_FAILED;
977 info = do_msidbCustomActionTypeDll( package, type, file->TargetPath, target, action );
979 r = wait_thread_handle( info );
980 release_custom_action_data( info );
981 return r;
984 static UINT HANDLE_CustomType18(MSIPACKAGE *package, LPCWSTR source,
985 LPCWSTR target, const INT type, LPCWSTR action)
987 STARTUPINFOW si;
988 PROCESS_INFORMATION info;
989 BOOL rc;
990 WCHAR *deformated;
991 WCHAR *cmd;
992 INT len;
993 static const WCHAR spc[] = {' ',0};
994 MSIFILE *file;
996 memset(&si,0,sizeof(STARTUPINFOW));
998 file = get_loaded_file(package,source);
999 if( !file )
1000 return ERROR_FUNCTION_FAILED;
1002 len = lstrlenW( file->TargetPath );
1004 deformat_string(package,target,&deformated);
1005 if (deformated)
1006 len += strlenW(deformated);
1007 len += 2;
1009 cmd = msi_alloc(len * sizeof(WCHAR));
1011 lstrcpyW( cmd, file->TargetPath);
1012 if (deformated)
1014 strcatW(cmd, spc);
1015 strcatW(cmd, deformated);
1017 msi_free(deformated);
1020 TRACE("executing exe %s\n", debugstr_w(cmd));
1022 rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
1023 c_collen, &si, &info);
1025 if ( !rc )
1027 ERR("Unable to execute command %s\n", debugstr_w(cmd));
1028 msi_free(cmd);
1029 return ERROR_SUCCESS;
1031 msi_free(cmd);
1032 CloseHandle( info.hThread );
1034 return wait_process_handle(package, type, info.hProcess, action);
1037 static UINT HANDLE_CustomType19(MSIPACKAGE *package, LPCWSTR source,
1038 LPCWSTR target, const INT type, LPCWSTR action)
1040 static const WCHAR query[] = {
1041 'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ',
1042 'F','R','O','M',' ','`','E','r','r','o','r','`',' ',
1043 'W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ',
1044 '%','s',0
1046 MSIRECORD *row = 0;
1047 LPWSTR deformated = NULL;
1049 deformat_string( package, target, &deformated );
1051 /* first try treat the error as a number */
1052 row = MSI_QueryGetRecord( package->db, query, deformated );
1053 if( row )
1055 LPCWSTR error = MSI_RecordGetString( row, 1 );
1056 if ((gUILevel & INSTALLUILEVEL_MASK) != INSTALLUILEVEL_NONE)
1057 MessageBoxW( NULL, error, NULL, MB_OK );
1058 msiobj_release( &row->hdr );
1060 else if ((gUILevel & INSTALLUILEVEL_MASK) != INSTALLUILEVEL_NONE)
1061 MessageBoxW( NULL, deformated, NULL, MB_OK );
1063 msi_free( deformated );
1065 return ERROR_INSTALL_FAILURE;
1068 static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source,
1069 LPCWSTR target, const INT type, LPCWSTR action)
1071 STARTUPINFOW si;
1072 PROCESS_INFORMATION info;
1073 WCHAR *prop;
1074 BOOL rc;
1075 WCHAR *deformated;
1076 WCHAR *cmd;
1077 INT len;
1078 static const WCHAR spc[] = {' ',0};
1080 memset(&si,0,sizeof(STARTUPINFOW));
1081 memset(&info,0,sizeof(PROCESS_INFORMATION));
1083 prop = msi_dup_property( package->db, source );
1084 if (!prop)
1085 return ERROR_SUCCESS;
1087 deformat_string(package,target,&deformated);
1088 len = strlenW(prop) + 2;
1089 if (deformated)
1090 len += strlenW(deformated);
1092 cmd = msi_alloc(sizeof(WCHAR)*len);
1094 strcpyW(cmd,prop);
1095 if (deformated)
1097 strcatW(cmd,spc);
1098 strcatW(cmd,deformated);
1100 msi_free(deformated);
1102 msi_free(prop);
1104 TRACE("executing exe %s\n", debugstr_w(cmd));
1106 rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
1107 c_collen, &si, &info);
1109 if ( !rc )
1111 ERR("Unable to execute command %s\n", debugstr_w(cmd));
1112 msi_free(cmd);
1113 return ERROR_SUCCESS;
1115 msi_free(cmd);
1117 CloseHandle( info.hThread );
1119 return wait_process_handle(package, type, info.hProcess, action);
1122 static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source,
1123 LPCWSTR target, const INT type, LPCWSTR action)
1125 LPWSTR workingdir, filename;
1126 STARTUPINFOW si;
1127 PROCESS_INFORMATION info;
1128 BOOL rc;
1130 memset(&si, 0, sizeof(STARTUPINFOW));
1132 workingdir = resolve_folder(package, source, FALSE, FALSE, TRUE, NULL);
1134 if (!workingdir)
1135 return ERROR_FUNCTION_FAILED;
1137 deformat_string(package, target, &filename);
1139 if (!filename)
1141 msi_free(workingdir);
1142 return ERROR_FUNCTION_FAILED;
1145 TRACE("executing exe %s with working directory %s\n",
1146 debugstr_w(filename), debugstr_w(workingdir));
1148 rc = CreateProcessW(NULL, filename, NULL, NULL, FALSE, 0, NULL,
1149 workingdir, &si, &info);
1151 if ( !rc )
1153 ERR("Unable to execute command %s with working directory %s\n",
1154 debugstr_w(filename), debugstr_w(workingdir));
1155 msi_free(filename);
1156 msi_free(workingdir);
1157 return ERROR_SUCCESS;
1160 msi_free(filename);
1161 msi_free(workingdir);
1163 CloseHandle( info.hThread );
1165 return wait_process_handle(package, type, info.hProcess, action);
1168 static DWORD ACTION_CallScript( const GUID *guid )
1170 msi_custom_action_info *info;
1171 MSIHANDLE hPackage;
1172 UINT r = ERROR_FUNCTION_FAILED;
1174 info = find_action_by_guid( guid );
1175 if (!info)
1177 ERR("failed to find action %s\n", debugstr_guid( guid) );
1178 return r;
1181 TRACE("function %s, script %s\n", debugstr_w( info->target ), debugstr_w( info->source ) );
1183 hPackage = alloc_msihandle( &info->package->hdr );
1184 if (hPackage)
1186 r = call_script( hPackage, info->type, info->source, info->target, info->action );
1187 MsiCloseHandle( hPackage );
1189 else
1190 ERR("failed to create handle for %p\n", info->package );
1192 release_custom_action_data( info );
1194 return S_OK;
1197 static DWORD WINAPI ScriptThread( LPVOID arg )
1199 LPGUID guid = arg;
1200 DWORD rc = 0;
1202 TRACE("custom action (%x) started\n", GetCurrentThreadId() );
1204 rc = ACTION_CallScript( guid );
1206 TRACE("custom action (%x) returned %i\n", GetCurrentThreadId(), rc );
1208 MsiCloseAllHandles();
1209 return rc;
1212 static msi_custom_action_info *do_msidbCustomActionTypeScript(
1213 MSIPACKAGE *package, INT type, LPCWSTR script, LPCWSTR function, LPCWSTR action )
1215 msi_custom_action_info *info;
1217 info = msi_alloc( sizeof *info );
1218 if (!info)
1219 return NULL;
1221 msiobj_addref( &package->hdr );
1222 info->refs = 2; /* 1 for our caller and 1 for thread we created */
1223 info->package = package;
1224 info->type = type;
1225 info->target = strdupW( function );
1226 info->source = strdupW( script );
1227 info->action = strdupW( action );
1228 CoCreateGuid( &info->guid );
1230 EnterCriticalSection( &msi_custom_action_cs );
1231 list_add_tail( &msi_pending_custom_actions, &info->entry );
1232 LeaveCriticalSection( &msi_custom_action_cs );
1234 info->handle = CreateThread( NULL, 0, ScriptThread, &info->guid, 0, NULL );
1235 if (!info->handle)
1237 /* release both references */
1238 release_custom_action_data( info );
1239 release_custom_action_data( info );
1240 return NULL;
1243 return info;
1246 static UINT HANDLE_CustomType37_38(MSIPACKAGE *package, LPCWSTR source,
1247 LPCWSTR target, const INT type, LPCWSTR action)
1249 UINT r;
1250 msi_custom_action_info *info;
1252 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
1254 info = do_msidbCustomActionTypeScript( package, type, target, NULL, action );
1256 r = wait_thread_handle( info );
1257 release_custom_action_data( info );
1258 return r;
1261 static UINT HANDLE_CustomType5_6(MSIPACKAGE *package, LPCWSTR source,
1262 LPCWSTR target, const INT type, LPCWSTR action)
1264 static const WCHAR query[] = {
1265 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1266 '`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E',' ',
1267 '`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0};
1268 MSIRECORD *row = 0;
1269 msi_custom_action_info *info;
1270 CHAR *buffer = NULL;
1271 WCHAR *bufferw = NULL;
1272 DWORD sz = 0;
1273 UINT r;
1275 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
1277 row = MSI_QueryGetRecord(package->db, query, source);
1278 if (!row)
1279 return ERROR_FUNCTION_FAILED;
1281 r = MSI_RecordReadStream(row, 2, NULL, &sz);
1282 if (r != ERROR_SUCCESS)
1283 return r;
1285 buffer = msi_alloc(sizeof(CHAR)*(sz+1));
1286 if (!buffer)
1287 return ERROR_FUNCTION_FAILED;
1289 r = MSI_RecordReadStream(row, 2, buffer, &sz);
1290 if (r != ERROR_SUCCESS)
1291 goto done;
1293 buffer[sz] = 0;
1294 bufferw = strdupAtoW(buffer);
1295 if (!bufferw)
1297 r = ERROR_FUNCTION_FAILED;
1298 goto done;
1301 info = do_msidbCustomActionTypeScript( package, type, bufferw, target, action );
1302 r = wait_thread_handle( info );
1303 release_custom_action_data( info );
1305 done:
1306 msi_free(bufferw);
1307 msi_free(buffer);
1308 return r;
1311 static UINT HANDLE_CustomType21_22(MSIPACKAGE *package, LPCWSTR source,
1312 LPCWSTR target, const INT type, LPCWSTR action)
1314 msi_custom_action_info *info;
1315 MSIFILE *file;
1316 HANDLE hFile;
1317 DWORD sz, szHighWord = 0, read;
1318 CHAR *buffer=NULL;
1319 WCHAR *bufferw=NULL;
1320 BOOL bRet;
1321 UINT r;
1323 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
1325 file = get_loaded_file(package,source);
1326 if (!file)
1328 ERR("invalid file key %s\n", debugstr_w(source));
1329 return ERROR_FUNCTION_FAILED;
1332 hFile = CreateFileW(file->TargetPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
1333 if (hFile == INVALID_HANDLE_VALUE)
1334 return ERROR_FUNCTION_FAILED;
1336 sz = GetFileSize(hFile, &szHighWord);
1337 if (sz == INVALID_FILE_SIZE || szHighWord != 0)
1339 CloseHandle(hFile);
1340 return ERROR_FUNCTION_FAILED;
1343 buffer = msi_alloc(sizeof(CHAR)*(sz+1));
1344 if (!buffer)
1346 CloseHandle(hFile);
1347 return ERROR_FUNCTION_FAILED;
1350 bRet = ReadFile(hFile, buffer, sz, &read, NULL);
1351 CloseHandle(hFile);
1352 if (!bRet)
1354 r = ERROR_FUNCTION_FAILED;
1355 goto done;
1358 buffer[read] = 0;
1359 bufferw = strdupAtoW(buffer);
1360 if (!bufferw)
1362 r = ERROR_FUNCTION_FAILED;
1363 goto done;
1366 info = do_msidbCustomActionTypeScript( package, type, bufferw, target, action );
1367 r = wait_thread_handle( info );
1368 release_custom_action_data( info );
1370 done:
1371 msi_free(bufferw);
1372 msi_free(buffer);
1373 return r;
1376 static UINT HANDLE_CustomType53_54(MSIPACKAGE *package, LPCWSTR source,
1377 LPCWSTR target, const INT type, LPCWSTR action)
1379 msi_custom_action_info *info;
1380 WCHAR *prop;
1381 UINT r;
1383 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
1385 prop = msi_dup_property( package->db, source );
1386 if (!prop)
1387 return ERROR_SUCCESS;
1389 info = do_msidbCustomActionTypeScript( package, type, prop, NULL, action );
1390 msi_free(prop);
1391 r = wait_thread_handle( info );
1392 release_custom_action_data( info );
1393 return r;
1396 void ACTION_FinishCustomActions(const MSIPACKAGE* package)
1398 struct list *item;
1399 HANDLE *wait_handles;
1400 unsigned int handle_count, i;
1401 msi_custom_action_info *info, *cursor;
1403 while ((item = list_head( &package->RunningActions )))
1405 MSIRUNNINGACTION *action = LIST_ENTRY( item, MSIRUNNINGACTION, entry );
1407 list_remove( &action->entry );
1409 TRACE("waiting for %s\n", debugstr_w( action->name ) );
1410 msi_dialog_check_messages( action->handle );
1412 CloseHandle( action->handle );
1413 msi_free( action->name );
1414 msi_free( action );
1417 EnterCriticalSection( &msi_custom_action_cs );
1419 handle_count = list_count( &msi_pending_custom_actions );
1420 wait_handles = msi_alloc( handle_count * sizeof(HANDLE) );
1422 handle_count = 0;
1423 LIST_FOR_EACH_ENTRY_SAFE( info, cursor, &msi_pending_custom_actions, msi_custom_action_info, entry )
1425 if (info->package == package )
1427 if (DuplicateHandle(GetCurrentProcess(), info->handle, GetCurrentProcess(), &wait_handles[handle_count], SYNCHRONIZE, FALSE, 0))
1428 handle_count++;
1432 LeaveCriticalSection( &msi_custom_action_cs );
1434 for (i = 0; i < handle_count; i++)
1436 msi_dialog_check_messages( wait_handles[i] );
1437 CloseHandle( wait_handles[i] );
1440 msi_free( wait_handles );
1443 typedef struct _msi_custom_remote_impl {
1444 const IWineMsiRemoteCustomActionVtbl *lpVtbl;
1445 LONG refs;
1446 } msi_custom_remote_impl;
1448 static inline msi_custom_remote_impl* mcr_from_IWineMsiRemoteCustomAction( IWineMsiRemoteCustomAction* iface )
1450 return (msi_custom_remote_impl*) iface;
1453 static HRESULT WINAPI mcr_QueryInterface( IWineMsiRemoteCustomAction *iface,
1454 REFIID riid,LPVOID *ppobj)
1456 if( IsEqualCLSID( riid, &IID_IUnknown ) ||
1457 IsEqualCLSID( riid, &IID_IWineMsiRemoteCustomAction ) )
1459 IUnknown_AddRef( iface );
1460 *ppobj = iface;
1461 return S_OK;
1464 return E_NOINTERFACE;
1467 static ULONG WINAPI mcr_AddRef( IWineMsiRemoteCustomAction *iface )
1469 msi_custom_remote_impl* This = mcr_from_IWineMsiRemoteCustomAction( iface );
1471 return InterlockedIncrement( &This->refs );
1474 static ULONG WINAPI mcr_Release( IWineMsiRemoteCustomAction *iface )
1476 msi_custom_remote_impl* This = mcr_from_IWineMsiRemoteCustomAction( iface );
1477 ULONG r;
1479 r = InterlockedDecrement( &This->refs );
1480 if (r == 0)
1481 msi_free( This );
1482 return r;
1485 static HRESULT WINAPI mcr_GetActionInfo( IWineMsiRemoteCustomAction *iface, LPCGUID custom_action_guid,
1486 INT *type, MSIHANDLE *handle, BSTR *dll, BSTR *func, IWineMsiRemotePackage **remote_package )
1488 msi_custom_action_info *info;
1490 info = find_action_by_guid( custom_action_guid );
1491 if (!info)
1492 return E_FAIL;
1494 *type = info->type;
1495 *handle = alloc_msihandle( &info->package->hdr );
1496 *dll = SysAllocString( info->source );
1497 *func = SysAllocString( info->target );
1499 release_custom_action_data( info );
1500 return create_msi_remote_package( NULL, (LPVOID *)remote_package );
1503 static const IWineMsiRemoteCustomActionVtbl msi_custom_remote_vtbl =
1505 mcr_QueryInterface,
1506 mcr_AddRef,
1507 mcr_Release,
1508 mcr_GetActionInfo,
1511 HRESULT create_msi_custom_remote( IUnknown *pOuter, LPVOID *ppObj )
1513 msi_custom_remote_impl* This;
1515 This = msi_alloc( sizeof *This );
1516 if (!This)
1517 return E_OUTOFMEMORY;
1519 This->lpVtbl = &msi_custom_remote_vtbl;
1520 This->refs = 1;
1522 *ppObj = This;
1524 return S_OK;