Assorted spelling fixes.
[wine/dibdrv.git] / dlls / msi / custom.c
blob9c0a7d2b57755e4cba6fe9fc9b8476748780952a
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
22 * Pages I need
24 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/summary_list_of_all_custom_action_types.asp
27 #include <stdarg.h>
28 #include <stdio.h>
30 #define COBJMACROS
32 #include "windef.h"
33 #include "winbase.h"
34 #include "winerror.h"
35 #include "winreg.h"
36 #include "wine/debug.h"
37 #include "fdi.h"
38 #include "msi.h"
39 #include "msidefs.h"
40 #include "msiquery.h"
41 #include "msvcrt/fcntl.h"
42 #include "objbase.h"
43 #include "objidl.h"
44 #include "msipriv.h"
45 #include "winnls.h"
46 #include "winuser.h"
47 #include "shlobj.h"
48 #include "wine/unicode.h"
49 #include "winver.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(msi);
53 #define CUSTOM_ACTION_TYPE_MASK 0x3F
54 static const WCHAR c_collen[] = {'C',':','\\',0};
55 static const WCHAR cszTempFolder[]= {'T','e','m','p','F','o','l','d','e','r',0};
57 typedef struct tagMSIRUNNINGACTION
59 struct list entry;
60 HANDLE handle;
61 BOOL process;
62 LPWSTR name;
63 } MSIRUNNINGACTION;
65 static UINT HANDLE_CustomType1(MSIPACKAGE *package, LPCWSTR source,
66 LPCWSTR target, const INT type, LPCWSTR action);
67 static UINT HANDLE_CustomType2(MSIPACKAGE *package, LPCWSTR source,
68 LPCWSTR target, const INT type, LPCWSTR action);
69 static UINT HANDLE_CustomType17(MSIPACKAGE *package, LPCWSTR source,
70 LPCWSTR target, const INT type, LPCWSTR action);
71 static UINT HANDLE_CustomType18(MSIPACKAGE *package, LPCWSTR source,
72 LPCWSTR target, const INT type, LPCWSTR action);
73 static UINT HANDLE_CustomType19(MSIPACKAGE *package, LPCWSTR source,
74 LPCWSTR target, const INT type, LPCWSTR action);
75 static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source,
76 LPCWSTR target, const INT type, LPCWSTR action);
77 static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source,
78 LPCWSTR target, const INT type, LPCWSTR action);
81 static BOOL check_execution_scheduling_options(MSIPACKAGE *package, LPCWSTR action, UINT options)
83 if (!package->script)
84 return TRUE;
86 if ((options & msidbCustomActionTypeClientRepeat) ==
87 msidbCustomActionTypeClientRepeat)
89 if (!(package->script->InWhatSequence & SEQUENCE_UI &&
90 package->script->InWhatSequence & SEQUENCE_EXEC))
92 TRACE("Skipping action due to dbCustomActionTypeClientRepeat option.\n");
93 return FALSE;
96 else if (options & msidbCustomActionTypeFirstSequence)
98 if (package->script->InWhatSequence & SEQUENCE_UI &&
99 package->script->InWhatSequence & SEQUENCE_EXEC )
101 TRACE("Skipping action due to msidbCustomActionTypeFirstSequence option.\n");
102 return FALSE;
105 else if (options & msidbCustomActionTypeOncePerProcess)
107 if (check_unique_action(package,action))
109 TRACE("Skipping action due to msidbCustomActionTypeOncePerProcess option.\n");
110 return FALSE;
112 else
113 register_unique_action(package,action);
116 return TRUE;
119 /* stores the CustomActionData before the action:
120 * [CustomActionData]Action
122 static LPWSTR msi_get_deferred_action(LPCWSTR action, LPWSTR actiondata)
124 LPWSTR deferred;
125 DWORD len;
127 static const WCHAR begin[] = {'[',0};
128 static const WCHAR end[] = {']',0};
130 if (!actiondata)
131 return strdupW(action);
133 len = lstrlenW(action) + lstrlenW(actiondata) + 3;
134 deferred = msi_alloc(len * sizeof(WCHAR));
136 lstrcpyW(deferred, begin);
137 lstrcatW(deferred, actiondata);
138 lstrcatW(deferred, end);
139 lstrcatW(deferred, action);
141 return deferred;
144 UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute)
146 UINT rc = ERROR_SUCCESS;
147 MSIRECORD * row = 0;
148 static const WCHAR ExecSeqQuery[] =
149 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
150 '`','C','u','s','t','o' ,'m','A','c','t','i','o','n','`',
151 ' ','W','H','E','R','E',' ','`','A','c','t','i' ,'o','n','`',' ',
152 '=',' ','\'','%','s','\'',0};
153 UINT type;
154 LPCWSTR source, target;
155 LPWSTR ptr, deferred_data = NULL;
156 LPWSTR action_copy = strdupW(action);
157 WCHAR *deformated=NULL;
159 /* deferred action: [CustomActionData]Action */
160 if ((ptr = strchrW(action_copy, ']')))
162 deferred_data = action_copy + 1;
163 *ptr = '\0';
164 action = ptr + 1;
167 row = MSI_QueryGetRecord( package->db, ExecSeqQuery, action );
168 if (!row)
170 msi_free(action_copy);
171 return ERROR_CALL_NOT_IMPLEMENTED;
174 type = MSI_RecordGetInteger(row,2);
176 source = MSI_RecordGetString(row,3);
177 target = MSI_RecordGetString(row,4);
179 TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action),type,
180 debugstr_w(source), debugstr_w(target));
182 /* handle some of the deferred actions */
183 if (type & msidbCustomActionTypeTSAware)
184 FIXME("msidbCustomActionTypeTSAware not handled\n");
186 if (type & msidbCustomActionTypeInScript)
188 if (type & msidbCustomActionTypeNoImpersonate)
189 FIXME("msidbCustomActionTypeNoImpersonate not handled\n");
191 if (type & msidbCustomActionTypeRollback)
193 FIXME("Rollback only action... rollbacks not supported yet\n");
194 schedule_action(package, ROLLBACK_SCRIPT, action);
195 rc = ERROR_SUCCESS;
196 goto end;
198 if (!execute)
200 LPWSTR actiondata = msi_dup_property(package, action);
201 LPWSTR deferred = msi_get_deferred_action(action, actiondata);
203 if (type & msidbCustomActionTypeCommit)
205 TRACE("Deferring Commit Action!\n");
206 schedule_action(package, COMMIT_SCRIPT, deferred);
208 else
210 TRACE("Deferring Action!\n");
211 schedule_action(package, INSTALL_SCRIPT, deferred);
214 rc = ERROR_SUCCESS;
215 msi_free(deferred);
216 goto end;
218 else
220 /*Set ActionData*/
222 static const WCHAR szActionData[] = {
223 'C','u','s','t','o','m','A','c','t','i','o','n','D','a','t','a',0};
224 static const WCHAR szBlank[] = {0};
225 LPWSTR actiondata = msi_dup_property( package, action );
226 if (deferred_data)
227 MSI_SetPropertyW(package,szActionData,deferred_data);
228 else if (actiondata)
229 MSI_SetPropertyW(package,szActionData,actiondata);
230 else
231 MSI_SetPropertyW(package,szActionData,szBlank);
232 msi_free(actiondata);
235 else if (!check_execution_scheduling_options(package,action,type))
237 rc = ERROR_SUCCESS;
238 goto end;
241 switch (type & CUSTOM_ACTION_TYPE_MASK)
243 case 1: /* DLL file stored in a Binary table stream */
244 rc = HANDLE_CustomType1(package,source,target,type,action);
245 break;
246 case 2: /* EXE file stored in a Binary table stream */
247 rc = HANDLE_CustomType2(package,source,target,type,action);
248 break;
249 case 18: /*EXE file installed with package */
250 rc = HANDLE_CustomType18(package,source,target,type,action);
251 break;
252 case 19: /* Error that halts install */
253 rc = HANDLE_CustomType19(package,source,target,type,action);
254 break;
255 case 17:
256 rc = HANDLE_CustomType17(package,source,target,type,action);
257 break;
258 case 50: /*EXE file specified by a property value */
259 rc = HANDLE_CustomType50(package,source,target,type,action);
260 break;
261 case 34: /*EXE to be run in specified directory */
262 rc = HANDLE_CustomType34(package,source,target,type,action);
263 break;
264 case 35: /* Directory set with formatted text. */
265 deformat_string(package,target,&deformated);
266 MSI_SetTargetPathW(package, source, deformated);
267 msi_free(deformated);
268 break;
269 case 51: /* Property set with formatted text. */
270 deformat_string(package,target,&deformated);
271 rc = MSI_SetPropertyW(package,source,deformated);
272 msi_free(deformated);
273 break;
274 default:
275 FIXME("UNHANDLED ACTION TYPE %i (%s %s)\n",
276 type & CUSTOM_ACTION_TYPE_MASK, debugstr_w(source),
277 debugstr_w(target));
280 end:
281 msi_free(action_copy);
282 msiobj_release(&row->hdr);
283 return rc;
287 static UINT store_binary_to_temp(MSIPACKAGE *package, LPCWSTR source,
288 LPWSTR tmp_file)
290 DWORD sz=MAX_PATH;
291 static const WCHAR f1[] = {'m','s','i',0};
292 WCHAR fmt[MAX_PATH];
294 if (MSI_GetPropertyW(package, cszTempFolder, fmt, &sz) != ERROR_SUCCESS)
295 GetTempPathW(MAX_PATH,fmt);
297 if (GetTempFileNameW(fmt,f1,0,tmp_file) == 0)
299 TRACE("Unable to create file\n");
300 return ERROR_FUNCTION_FAILED;
302 else
304 /* write out the file */
305 UINT rc;
306 MSIRECORD * row = 0;
307 static const WCHAR fmt[] =
308 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
309 '`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E',
310 ' ','`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0};
311 HANDLE the_file;
312 CHAR buffer[1024];
314 the_file = CreateFileW(tmp_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
315 FILE_ATTRIBUTE_NORMAL, NULL);
317 if (the_file == INVALID_HANDLE_VALUE)
318 return ERROR_FUNCTION_FAILED;
320 row = MSI_QueryGetRecord(package->db, fmt, source);
321 if (!row)
322 return ERROR_FUNCTION_FAILED;
326 DWORD write;
327 sz = 1024;
328 rc = MSI_RecordReadStream(row,2,buffer,&sz);
329 if (rc != ERROR_SUCCESS)
331 ERR("Failed to get stream\n");
332 CloseHandle(the_file);
333 DeleteFileW(tmp_file);
334 break;
336 WriteFile(the_file,buffer,sz,&write,NULL);
337 } while (sz == 1024);
339 CloseHandle(the_file);
341 msiobj_release(&row->hdr);
344 return ERROR_SUCCESS;
347 static void file_running_action(MSIPACKAGE* package, HANDLE Handle,
348 BOOL process, LPCWSTR name)
350 MSIRUNNINGACTION *action;
352 action = msi_alloc( sizeof(MSIRUNNINGACTION) );
354 action->handle = Handle;
355 action->process = process;
356 action->name = strdupW(name);
358 list_add_tail( &package->RunningActions, &action->entry );
361 static UINT process_action_return_value(UINT type, HANDLE ThreadHandle)
363 DWORD rc=0;
365 if (type == 2)
367 GetExitCodeProcess(ThreadHandle,&rc);
369 if (rc == 0)
370 return ERROR_SUCCESS;
371 else
372 return ERROR_FUNCTION_FAILED;
375 GetExitCodeThread(ThreadHandle,&rc);
377 switch (rc)
379 case ERROR_FUNCTION_NOT_CALLED:
380 case ERROR_SUCCESS:
381 case ERROR_INSTALL_USEREXIT:
382 case ERROR_INSTALL_FAILURE:
383 return rc;
384 case ERROR_NO_MORE_ITEMS:
385 return ERROR_SUCCESS;
386 default:
387 ERR("Invalid Return Code %d\n",rc);
388 return ERROR_INSTALL_FAILURE;
392 static UINT process_handle(MSIPACKAGE* package, UINT type,
393 HANDLE ThreadHandle, HANDLE ProcessHandle,
394 LPCWSTR Name, BOOL *finished)
396 UINT rc = ERROR_SUCCESS;
398 if (!(type & msidbCustomActionTypeAsync))
400 /* synchronous */
401 TRACE("Synchronous Execution of action %s\n",debugstr_w(Name));
402 if (ProcessHandle)
403 msi_dialog_check_messages(ProcessHandle);
404 else
405 msi_dialog_check_messages(ThreadHandle);
407 if (!(type & msidbCustomActionTypeContinue))
409 if (ProcessHandle)
410 rc = process_action_return_value(2,ProcessHandle);
411 else
412 rc = process_action_return_value(1,ThreadHandle);
415 CloseHandle(ThreadHandle);
416 if (ProcessHandle)
417 CloseHandle(ProcessHandle);
418 if (finished)
419 *finished = TRUE;
421 else
423 TRACE("Asynchronous Execution of action %s\n",debugstr_w(Name));
424 /* asynchronous */
425 if (type & msidbCustomActionTypeContinue)
427 if (ProcessHandle)
429 file_running_action(package, ProcessHandle, TRUE, Name);
430 CloseHandle(ThreadHandle);
432 else
433 file_running_action(package, ThreadHandle, FALSE, Name);
435 else
437 CloseHandle(ThreadHandle);
438 if (ProcessHandle)
439 CloseHandle(ProcessHandle);
441 if (finished)
442 *finished = FALSE;
445 return rc;
449 typedef UINT __stdcall CustomEntry(MSIHANDLE);
451 typedef struct
453 MSIPACKAGE *package;
454 WCHAR *target;
455 WCHAR *source;
456 } thread_struct;
458 static DWORD WINAPI ACTION_CallDllFunction(thread_struct *stuff)
460 HANDLE hModule;
461 LPSTR proc;
462 CustomEntry *fn;
463 DWORD rc = ERROR_SUCCESS;
465 TRACE("calling function (%s, %s)\n", debugstr_w(stuff->source),
466 debugstr_w(stuff->target));
468 hModule = LoadLibraryW(stuff->source);
469 if (hModule)
471 proc = strdupWtoA( stuff->target );
472 fn = (CustomEntry*)GetProcAddress(hModule,proc);
473 if (fn)
475 MSIHANDLE hPackage;
476 MSIPACKAGE *package = stuff->package;
478 TRACE("Calling function %s\n", proc);
479 hPackage = alloc_msihandle( &package->hdr );
480 if (hPackage)
482 rc = fn( hPackage );
483 MsiCloseHandle( hPackage );
485 else
486 ERR("Handle for object %p not found\n", package );
488 else
489 ERR("failed to resolve functon %s\n", debugstr_a(proc));
491 msi_free(proc);
492 FreeLibrary(hModule);
494 else
495 ERR("failed to load dll %s\n", debugstr_w(stuff->source));
496 msiobj_release( &stuff->package->hdr );
497 msi_free(stuff->source);
498 msi_free(stuff->target);
499 msi_free(stuff);
500 return rc;
503 static DWORD WINAPI DllThread(LPVOID info)
505 thread_struct *stuff;
506 DWORD rc = 0;
508 TRACE("MSI Thread (%x) started for custom action\n", GetCurrentThreadId());
510 stuff = (thread_struct*)info;
511 rc = ACTION_CallDllFunction(stuff);
513 TRACE("MSI Thread (%x) finished (rc %i)\n",GetCurrentThreadId(), rc);
514 /* close all handles for this thread */
515 MsiCloseAllHandles();
516 return rc;
519 static HANDLE do_msidbCustomActionTypeDll(MSIPACKAGE *package, LPCWSTR dll, LPCWSTR target)
521 thread_struct *info;
523 info = msi_alloc( sizeof(*info) );
524 msiobj_addref( &package->hdr );
525 info->package = package;
526 info->target = strdupW(target);
527 info->source = strdupW(dll);
529 return CreateThread(NULL, 0, DllThread, info, 0, NULL);
532 static UINT HANDLE_CustomType1(MSIPACKAGE *package, LPCWSTR source,
533 LPCWSTR target, const INT type, LPCWSTR action)
535 WCHAR tmp_file[MAX_PATH];
536 UINT rc = ERROR_SUCCESS;
537 BOOL finished = FALSE;
538 HANDLE ThreadHandle;
540 store_binary_to_temp(package, source, tmp_file);
542 TRACE("Calling function %s from %s\n",debugstr_w(target),
543 debugstr_w(tmp_file));
545 if (!strchrW(tmp_file,'.'))
547 static const WCHAR dot[]={'.',0};
548 strcatW(tmp_file,dot);
551 ThreadHandle = do_msidbCustomActionTypeDll( package, tmp_file, target );
553 rc = process_handle(package, type, ThreadHandle, NULL, action, &finished );
555 if (!finished)
556 track_tempfile(package, tmp_file, tmp_file);
557 else
558 DeleteFileW(tmp_file);
560 return rc;
563 static UINT HANDLE_CustomType2(MSIPACKAGE *package, LPCWSTR source,
564 LPCWSTR target, const INT type, LPCWSTR action)
566 WCHAR tmp_file[MAX_PATH];
567 STARTUPINFOW si;
568 PROCESS_INFORMATION info;
569 BOOL rc;
570 INT len;
571 WCHAR *deformated;
572 WCHAR *cmd;
573 static const WCHAR spc[] = {' ',0};
574 UINT prc = ERROR_SUCCESS;
575 BOOL finished = FALSE;
577 memset(&si,0,sizeof(STARTUPINFOW));
579 store_binary_to_temp(package, source, tmp_file);
581 deformat_string(package,target,&deformated);
583 len = strlenW(tmp_file)+2;
585 if (deformated)
586 len += strlenW(deformated);
588 cmd = msi_alloc(sizeof(WCHAR)*len);
590 strcpyW(cmd,tmp_file);
591 if (deformated)
593 strcatW(cmd,spc);
594 strcatW(cmd,deformated);
596 msi_free(deformated);
599 TRACE("executing exe %s\n", debugstr_w(cmd));
601 rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
602 c_collen, &si, &info);
605 if ( !rc )
607 ERR("Unable to execute command %s\n", debugstr_w(cmd));
608 msi_free(cmd);
609 return ERROR_SUCCESS;
611 msi_free(cmd);
613 prc = process_handle(package, type, info.hThread, info.hProcess, action,
614 &finished);
616 if (!finished)
617 track_tempfile(package, tmp_file, tmp_file);
618 else
619 DeleteFileW(tmp_file);
621 return prc;
624 static UINT HANDLE_CustomType17(MSIPACKAGE *package, LPCWSTR source,
625 LPCWSTR target, const INT type, LPCWSTR action)
627 HANDLE hThread;
628 MSIFILE *file;
630 TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
632 file = get_loaded_file( package, source );
633 if (!file)
635 ERR("invalid file key %s\n", debugstr_w( source ));
636 return ERROR_FUNCTION_FAILED;
639 hThread = do_msidbCustomActionTypeDll( package, file->TargetPath, target );
641 return process_handle(package, type, hThread, NULL, action, NULL );
644 static UINT HANDLE_CustomType18(MSIPACKAGE *package, LPCWSTR source,
645 LPCWSTR target, const INT type, LPCWSTR action)
647 STARTUPINFOW si;
648 PROCESS_INFORMATION info;
649 BOOL rc;
650 WCHAR *deformated;
651 WCHAR *cmd;
652 INT len;
653 static const WCHAR spc[] = {' ',0};
654 MSIFILE *file;
655 UINT prc;
657 memset(&si,0,sizeof(STARTUPINFOW));
659 file = get_loaded_file(package,source);
660 if( !file )
661 return ERROR_FUNCTION_FAILED;
663 len = lstrlenW( file->TargetPath );
665 deformat_string(package,target,&deformated);
666 if (deformated)
667 len += strlenW(deformated);
668 len += 2;
670 cmd = msi_alloc(len * sizeof(WCHAR));
672 lstrcpyW( cmd, file->TargetPath);
673 if (deformated)
675 strcatW(cmd, spc);
676 strcatW(cmd, deformated);
678 msi_free(deformated);
681 TRACE("executing exe %s\n", debugstr_w(cmd));
683 rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
684 c_collen, &si, &info);
687 if ( !rc )
689 ERR("Unable to execute command %s\n", debugstr_w(cmd));
690 msi_free(cmd);
691 return ERROR_SUCCESS;
693 msi_free(cmd);
695 prc = process_handle(package, type, info.hThread, info.hProcess, action,
696 NULL);
698 return prc;
701 static UINT HANDLE_CustomType19(MSIPACKAGE *package, LPCWSTR source,
702 LPCWSTR target, const INT type, LPCWSTR action)
704 static const WCHAR query[] = {
705 'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ',
706 'F','R','O','M',' ','`','E','r','r','o','r','`',' ',
707 'W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ',
708 '%','s',0
710 MSIRECORD *row = 0;
711 LPWSTR deformated = NULL;
713 deformat_string( package, target, &deformated );
715 /* first try treat the error as a number */
716 row = MSI_QueryGetRecord( package->db, query, deformated );
717 if( row )
719 LPCWSTR error = MSI_RecordGetString( row, 1 );
720 MessageBoxW( NULL, error, NULL, MB_OK );
721 msiobj_release( &row->hdr );
723 else
724 MessageBoxW( NULL, deformated, NULL, MB_OK );
726 msi_free( deformated );
728 return ERROR_FUNCTION_FAILED;
731 static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source,
732 LPCWSTR target, const INT type, LPCWSTR action)
734 STARTUPINFOW si;
735 PROCESS_INFORMATION info;
736 WCHAR *prop;
737 BOOL rc;
738 WCHAR *deformated;
739 WCHAR *cmd;
740 INT len;
741 static const WCHAR spc[] = {' ',0};
743 memset(&si,0,sizeof(STARTUPINFOW));
744 memset(&info,0,sizeof(PROCESS_INFORMATION));
746 prop = msi_dup_property( package, source );
747 if (!prop)
748 return ERROR_SUCCESS;
750 deformat_string(package,target,&deformated);
751 len = strlenW(prop) + 2;
752 if (deformated)
753 len += strlenW(deformated);
755 cmd = msi_alloc(sizeof(WCHAR)*len);
757 strcpyW(cmd,prop);
758 if (deformated)
760 strcatW(cmd,spc);
761 strcatW(cmd,deformated);
763 msi_free(deformated);
765 msi_free(prop);
767 TRACE("executing exe %s\n", debugstr_w(cmd));
769 rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
770 c_collen, &si, &info);
773 if ( !rc )
775 ERR("Unable to execute command %s\n", debugstr_w(cmd));
776 msi_free(cmd);
777 return ERROR_SUCCESS;
779 msi_free(cmd);
781 return process_handle(package, type, info.hThread, info.hProcess, action, NULL);
784 static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source,
785 LPCWSTR target, const INT type, LPCWSTR action)
787 LPWSTR filename, deformated;
788 STARTUPINFOW si;
789 PROCESS_INFORMATION info;
790 BOOL rc;
791 UINT prc;
793 memset(&si,0,sizeof(STARTUPINFOW));
795 filename = resolve_folder(package, source, FALSE, FALSE, NULL);
797 if (!filename)
798 return ERROR_FUNCTION_FAILED;
800 SetCurrentDirectoryW(filename);
801 msi_free(filename);
803 deformat_string(package,target,&deformated);
805 if (!deformated)
806 return ERROR_FUNCTION_FAILED;
808 TRACE("executing exe %s\n", debugstr_w(deformated));
810 rc = CreateProcessW(NULL, deformated, NULL, NULL, FALSE, 0, NULL,
811 c_collen, &si, &info);
813 if ( !rc )
815 ERR("Unable to execute command %s\n", debugstr_w(deformated));
816 msi_free(deformated);
817 return ERROR_SUCCESS;
819 msi_free(deformated);
821 prc = process_handle(package, type, info.hThread, info.hProcess, action,
822 NULL);
824 return prc;
828 void ACTION_FinishCustomActions(MSIPACKAGE* package)
830 struct list *item, *cursor;
831 DWORD rc;
833 LIST_FOR_EACH_SAFE( item, cursor, &package->RunningActions )
835 MSIRUNNINGACTION *action = LIST_ENTRY( item, MSIRUNNINGACTION, entry );
837 TRACE("Checking on action %s\n", debugstr_w(action->name));
839 list_remove( &action->entry );
841 if (action->process)
842 GetExitCodeProcess( action->handle, &rc );
843 else
844 GetExitCodeThread( action->handle, &rc );
846 if (rc == STILL_ACTIVE)
848 TRACE("Waiting on action %s\n", debugstr_w( action->name) );
849 msi_dialog_check_messages( action->handle );
852 CloseHandle( action->handle );
853 msi_free( action->name );
854 msi_free( action );