reshuffling of dlls
[reactos.git] / reactos / dll / win32 / msi / custom.c
1 /*
2 * Custom Action processing for the Microsoft Installer (msi.dll)
3 *
4 * Copyright 2005 Aric Stewart for CodeWeavers
5 *
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.
10 *
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.
15 *
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 /*
22 * Pages I need
23 *
24 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/summary_list_of_all_custom_action_types.asp
25 */
26
27 #include <stdarg.h>
28 #include <stdio.h>
29
30 #define COBJMACROS
31
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 "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"
50 #include "action.h"
51
52 WINE_DEFAULT_DEBUG_CHANNEL(msi);
53
54 #define CUSTOM_ACTION_TYPE_MASK 0x3F
55 static const WCHAR c_collen[] = {'C',':','\\',0};
56 static const WCHAR cszTempFolder[]= {'T','e','m','p','F','o','l','d','e','r',0};
57
58 typedef struct tagMSIRUNNINGACTION
59 {
60 struct list entry;
61 HANDLE handle;
62 BOOL process;
63 LPWSTR name;
64 } MSIRUNNINGACTION;
65
66 static UINT HANDLE_CustomType1(MSIPACKAGE *package, LPCWSTR source,
67 LPCWSTR target, const INT type, LPCWSTR action);
68 static UINT HANDLE_CustomType2(MSIPACKAGE *package, LPCWSTR source,
69 LPCWSTR target, const INT type, LPCWSTR action);
70 static UINT HANDLE_CustomType18(MSIPACKAGE *package, LPCWSTR source,
71 LPCWSTR target, const INT type, LPCWSTR action);
72 static UINT HANDLE_CustomType19(MSIPACKAGE *package, LPCWSTR source,
73 LPCWSTR target, const INT type, LPCWSTR action);
74 static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source,
75 LPCWSTR target, const INT type, LPCWSTR action);
76 static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source,
77 LPCWSTR target, const INT type, LPCWSTR action);
78
79
80 static BOOL check_execution_scheduling_options(MSIPACKAGE *package, LPCWSTR action, UINT options)
81 {
82 if (!package->script)
83 return TRUE;
84
85 if ((options & msidbCustomActionTypeClientRepeat) ==
86 msidbCustomActionTypeClientRepeat)
87 {
88 if (!(package->script->InWhatSequence & SEQUENCE_UI &&
89 package->script->InWhatSequence & SEQUENCE_EXEC))
90 {
91 TRACE("Skipping action due to dbCustomActionTypeClientRepeat option.\n");
92 return FALSE;
93 }
94 }
95 else if (options & msidbCustomActionTypeFirstSequence)
96 {
97 if (package->script->InWhatSequence & SEQUENCE_UI &&
98 package->script->InWhatSequence & SEQUENCE_EXEC )
99 {
100 TRACE("Skipping action due to msidbCustomActionTypeFirstSequence option.\n");
101 return FALSE;
102 }
103 }
104 else if (options & msidbCustomActionTypeOncePerProcess)
105 {
106 if (check_unique_action(package,action))
107 {
108 TRACE("Skipping action due to msidbCustomActionTypeOncePerProcess option.\n");
109 return FALSE;
110 }
111 else
112 register_unique_action(package,action);
113 }
114
115 return TRUE;
116 }
117
118 UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute)
119 {
120 UINT rc = ERROR_SUCCESS;
121 MSIRECORD * row = 0;
122 static const WCHAR ExecSeqQuery[] =
123 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
124 '`','C','u','s','t','o' ,'m','A','c','t','i','o','n','`',
125 ' ','W','H','E','R','E',' ','`','A','c','t','i' ,'o','n','`',' ',
126 '=',' ','\'','%','s','\'',0};
127 UINT type;
128 LPCWSTR source, target;
129 WCHAR *deformated=NULL;
130
131 row = MSI_QueryGetRecord( package->db, ExecSeqQuery, action );
132 if (!row)
133 return ERROR_CALL_NOT_IMPLEMENTED;
134
135 type = MSI_RecordGetInteger(row,2);
136
137 source = MSI_RecordGetString(row,3);
138 target = MSI_RecordGetString(row,4);
139
140 TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action),type,
141 debugstr_w(source), debugstr_w(target));
142
143 /* handle some of the deferred actions */
144 if (type & msidbCustomActionTypeTSAware)
145 FIXME("msidbCustomActionTypeTSAware not handled\n");
146
147 if (type & msidbCustomActionTypeInScript)
148 {
149 if (type & msidbCustomActionTypeNoImpersonate)
150 FIXME("msidbCustomActionTypeNoImpersonate not handled\n");
151
152 if (type & msidbCustomActionTypeRollback)
153 {
154 FIXME("Rollback only action... rollbacks not supported yet\n");
155 schedule_action(package, ROLLBACK_SCRIPT, action);
156 rc = ERROR_SUCCESS;
157 goto end;
158 }
159 if (!execute)
160 {
161 if (type & msidbCustomActionTypeCommit)
162 {
163 TRACE("Deferring Commit Action!\n");
164 schedule_action(package, COMMIT_SCRIPT, action);
165 }
166 else
167 {
168 TRACE("Deferring Action!\n");
169 schedule_action(package, INSTALL_SCRIPT, action);
170 }
171
172 rc = ERROR_SUCCESS;
173 goto end;
174 }
175 else
176 {
177 /*Set ActionData*/
178
179 static const WCHAR szActionData[] = {
180 'C','u','s','t','o','m','A','c','t','i','o','n','D','a','t','a',0};
181 static const WCHAR szBlank[] = {0};
182 LPWSTR actiondata = msi_dup_property( package, action );
183 if (actiondata)
184 MSI_SetPropertyW(package,szActionData,actiondata);
185 else
186 MSI_SetPropertyW(package,szActionData,szBlank);
187 msi_free(actiondata);
188 }
189 }
190 else if (!check_execution_scheduling_options(package,action,type))
191 {
192 rc = ERROR_SUCCESS;
193 goto end;
194 }
195
196 switch (type & CUSTOM_ACTION_TYPE_MASK)
197 {
198 case 1: /* DLL file stored in a Binary table stream */
199 rc = HANDLE_CustomType1(package,source,target,type,action);
200 break;
201 case 2: /* EXE file stored in a Binary table strem */
202 rc = HANDLE_CustomType2(package,source,target,type,action);
203 break;
204 case 18: /*EXE file installed with package */
205 rc = HANDLE_CustomType18(package,source,target,type,action);
206 break;
207 case 19: /* Error that halts install */
208 rc = HANDLE_CustomType19(package,source,target,type,action);
209 break;
210 case 50: /*EXE file specified by a property value */
211 rc = HANDLE_CustomType50(package,source,target,type,action);
212 break;
213 case 34: /*EXE to be run in specified directory */
214 rc = HANDLE_CustomType34(package,source,target,type,action);
215 break;
216 case 35: /* Directory set with formatted text. */
217 deformat_string(package,target,&deformated);
218 MSI_SetTargetPathW(package, source, deformated);
219 msi_free(deformated);
220 break;
221 case 51: /* Property set with formatted text. */
222 deformat_string(package,target,&deformated);
223 rc = MSI_SetPropertyW(package,source,deformated);
224 msi_free(deformated);
225 break;
226 default:
227 FIXME("UNHANDLED ACTION TYPE %i (%s %s)\n",
228 type & CUSTOM_ACTION_TYPE_MASK, debugstr_w(source),
229 debugstr_w(target));
230 }
231
232 end:
233 msiobj_release(&row->hdr);
234 return rc;
235 }
236
237
238 static UINT store_binary_to_temp(MSIPACKAGE *package, LPCWSTR source,
239 LPWSTR tmp_file)
240 {
241 DWORD sz=MAX_PATH;
242 static const WCHAR f1[] = {'m','s','i',0};
243 WCHAR fmt[MAX_PATH];
244
245 if (MSI_GetPropertyW(package, cszTempFolder, fmt, &sz) != ERROR_SUCCESS)
246 GetTempPathW(MAX_PATH,fmt);
247
248 if (GetTempFileNameW(fmt,f1,0,tmp_file) == 0)
249 {
250 TRACE("Unable to create file\n");
251 return ERROR_FUNCTION_FAILED;
252 }
253 else
254 {
255 /* write out the file */
256 UINT rc;
257 MSIRECORD * row = 0;
258 static const WCHAR fmt[] =
259 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
260 '`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E',
261 ' ','`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0};
262 HANDLE the_file;
263 CHAR buffer[1024];
264
265 the_file = CreateFileW(tmp_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
266 FILE_ATTRIBUTE_NORMAL, NULL);
267
268 if (the_file == INVALID_HANDLE_VALUE)
269 return ERROR_FUNCTION_FAILED;
270
271 row = MSI_QueryGetRecord(package->db, fmt, source);
272 if (!row)
273 return ERROR_FUNCTION_FAILED;
274
275 do
276 {
277 DWORD write;
278 sz = 1024;
279 rc = MSI_RecordReadStream(row,2,buffer,&sz);
280 if (rc != ERROR_SUCCESS)
281 {
282 ERR("Failed to get stream\n");
283 CloseHandle(the_file);
284 DeleteFileW(tmp_file);
285 break;
286 }
287 WriteFile(the_file,buffer,sz,&write,NULL);
288 } while (sz == 1024);
289
290 CloseHandle(the_file);
291
292 msiobj_release(&row->hdr);
293 }
294
295 return ERROR_SUCCESS;
296 }
297
298 static void file_running_action(MSIPACKAGE* package, HANDLE Handle,
299 BOOL process, LPCWSTR name)
300 {
301 MSIRUNNINGACTION *action;
302
303 action = msi_alloc( sizeof(MSIRUNNINGACTION) );
304
305 action->handle = Handle;
306 action->process = process;
307 action->name = strdupW(name);
308
309 list_add_tail( &package->RunningActions, &action->entry );
310 }
311
312 static UINT process_action_return_value(UINT type, HANDLE ThreadHandle)
313 {
314 DWORD rc=0;
315
316 if (type == 2)
317 {
318 GetExitCodeProcess(ThreadHandle,&rc);
319
320 if (rc == 0)
321 return ERROR_SUCCESS;
322 else
323 return ERROR_FUNCTION_FAILED;
324 }
325
326 GetExitCodeThread(ThreadHandle,&rc);
327
328 switch (rc)
329 {
330 case ERROR_FUNCTION_NOT_CALLED:
331 case ERROR_SUCCESS:
332 case ERROR_INSTALL_USEREXIT:
333 case ERROR_INSTALL_FAILURE:
334 return rc;
335 case ERROR_NO_MORE_ITEMS:
336 return ERROR_SUCCESS;
337 default:
338 ERR("Invalid Return Code %ld\n",rc);
339 return ERROR_INSTALL_FAILURE;
340 }
341 }
342
343 static UINT process_handle(MSIPACKAGE* package, UINT type,
344 HANDLE ThreadHandle, HANDLE ProcessHandle,
345 LPCWSTR Name, BOOL *finished)
346 {
347 UINT rc = ERROR_SUCCESS;
348
349 if (!(type & msidbCustomActionTypeAsync))
350 {
351 /* synchronous */
352 TRACE("Synchronous Execution of action %s\n",debugstr_w(Name));
353 if (ProcessHandle)
354 msi_dialog_check_messages(ProcessHandle);
355 else
356 msi_dialog_check_messages(ThreadHandle);
357
358 if (!(type & msidbCustomActionTypeContinue))
359 {
360 if (ProcessHandle)
361 rc = process_action_return_value(2,ProcessHandle);
362 else
363 rc = process_action_return_value(1,ThreadHandle);
364 }
365
366 CloseHandle(ThreadHandle);
367 if (ProcessHandle)
368 CloseHandle(ProcessHandle);
369 if (finished)
370 *finished = TRUE;
371 }
372 else
373 {
374 TRACE("Asynchronous Execution of action %s\n",debugstr_w(Name));
375 /* asynchronous */
376 if (type & msidbCustomActionTypeContinue)
377 {
378 if (ProcessHandle)
379 {
380 file_running_action(package, ProcessHandle, TRUE, Name);
381 CloseHandle(ThreadHandle);
382 }
383 else
384 file_running_action(package, ThreadHandle, FALSE, Name);
385 }
386 else
387 {
388 CloseHandle(ThreadHandle);
389 if (ProcessHandle)
390 CloseHandle(ProcessHandle);
391 }
392 if (finished)
393 *finished = FALSE;
394 }
395
396 return rc;
397 }
398
399
400 typedef UINT __stdcall CustomEntry(MSIHANDLE);
401
402 typedef struct
403 {
404 MSIPACKAGE *package;
405 WCHAR *target;
406 WCHAR *source;
407 } thread_struct;
408
409 static DWORD WINAPI ACTION_CallDllFunction(thread_struct *stuff)
410 {
411 HANDLE hModule;
412 LPSTR proc;
413 CustomEntry *fn;
414 DWORD rc = ERROR_SUCCESS;
415
416 TRACE("calling function (%s, %s)\n", debugstr_w(stuff->source),
417 debugstr_w(stuff->target));
418
419 hModule = LoadLibraryW(stuff->source);
420 if (hModule)
421 {
422 proc = strdupWtoA( stuff->target );
423 fn = (CustomEntry*)GetProcAddress(hModule,proc);
424 if (fn)
425 {
426 MSIHANDLE hPackage;
427 MSIPACKAGE *package = stuff->package;
428
429 TRACE("Calling function %s\n", proc);
430 hPackage = alloc_msihandle( &package->hdr );
431 if (hPackage)
432 {
433 rc = fn( hPackage );
434 MsiCloseHandle( hPackage );
435 }
436 else
437 ERR("Handle for object %p not found\n", package );
438 }
439 else
440 ERR("Cannot load functon\n");
441
442 msi_free(proc);
443 FreeLibrary(hModule);
444 }
445 else
446 ERR("Unable to load library\n");
447 msiobj_release( &stuff->package->hdr );
448 msi_free(stuff->source);
449 msi_free(stuff->target);
450 msi_free(stuff);
451 return rc;
452 }
453
454 static DWORD WINAPI DllThread(LPVOID info)
455 {
456 thread_struct *stuff;
457 DWORD rc = 0;
458
459 TRACE("MSI Thread (0x%lx) started for custom action\n",
460 GetCurrentThreadId());
461
462 stuff = (thread_struct*)info;
463 rc = ACTION_CallDllFunction(stuff);
464
465 TRACE("MSI Thread (0x%lx) finished (rc %li)\n",GetCurrentThreadId(), rc);
466 /* clse all handles for this thread */
467 MsiCloseAllHandles();
468 return rc;
469 }
470
471 static UINT HANDLE_CustomType1(MSIPACKAGE *package, LPCWSTR source,
472 LPCWSTR target, const INT type, LPCWSTR action)
473 {
474 WCHAR tmp_file[MAX_PATH];
475 thread_struct *info;
476 DWORD ThreadId;
477 HANDLE ThreadHandle;
478 UINT rc = ERROR_SUCCESS;
479 BOOL finished = FALSE;
480
481 store_binary_to_temp(package, source, tmp_file);
482
483 TRACE("Calling function %s from %s\n",debugstr_w(target),
484 debugstr_w(tmp_file));
485
486 if (!strchrW(tmp_file,'.'))
487 {
488 static const WCHAR dot[]={'.',0};
489 strcatW(tmp_file,dot);
490 }
491
492 info = msi_alloc( sizeof(*info) );
493 msiobj_addref( &package->hdr );
494 info->package = package;
495 info->target = strdupW(target);
496 info->source = strdupW(tmp_file);
497
498 ThreadHandle = CreateThread(NULL,0,DllThread,(LPVOID)info,0,&ThreadId);
499
500 rc = process_handle(package, type, ThreadHandle, NULL, action, &finished );
501
502 if (!finished)
503 track_tempfile(package, tmp_file, tmp_file);
504 else
505 DeleteFileW(tmp_file);
506
507 return rc;
508 }
509
510 static UINT HANDLE_CustomType2(MSIPACKAGE *package, LPCWSTR source,
511 LPCWSTR target, const INT type, LPCWSTR action)
512 {
513 WCHAR tmp_file[MAX_PATH];
514 STARTUPINFOW si;
515 PROCESS_INFORMATION info;
516 BOOL rc;
517 INT len;
518 WCHAR *deformated;
519 WCHAR *cmd;
520 static const WCHAR spc[] = {' ',0};
521 UINT prc = ERROR_SUCCESS;
522 BOOL finished = FALSE;
523
524 memset(&si,0,sizeof(STARTUPINFOW));
525
526 store_binary_to_temp(package, source, tmp_file);
527
528 deformat_string(package,target,&deformated);
529
530 len = strlenW(tmp_file)+2;
531
532 if (deformated)
533 len += strlenW(deformated);
534
535 cmd = msi_alloc(sizeof(WCHAR)*len);
536
537 strcpyW(cmd,tmp_file);
538 if (deformated)
539 {
540 strcatW(cmd,spc);
541 strcatW(cmd,deformated);
542
543 msi_free(deformated);
544 }
545
546 TRACE("executing exe %s\n", debugstr_w(cmd));
547
548 rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
549 c_collen, &si, &info);
550
551
552 if ( !rc )
553 {
554 ERR("Unable to execute command %s\n", debugstr_w(cmd));
555 msi_free(cmd);
556 return ERROR_SUCCESS;
557 }
558 msi_free(cmd);
559
560 prc = process_handle(package, type, info.hThread, info.hProcess, action,
561 &finished);
562
563 if (!finished)
564 track_tempfile(package, tmp_file, tmp_file);
565 else
566 DeleteFileW(tmp_file);
567
568 return prc;
569 }
570
571 static UINT HANDLE_CustomType18(MSIPACKAGE *package, LPCWSTR source,
572 LPCWSTR target, const INT type, LPCWSTR action)
573 {
574 STARTUPINFOW si;
575 PROCESS_INFORMATION info;
576 BOOL rc;
577 WCHAR *deformated;
578 WCHAR *cmd;
579 INT len;
580 static const WCHAR spc[] = {' ',0};
581 MSIFILE *file;
582 UINT prc;
583
584 memset(&si,0,sizeof(STARTUPINFOW));
585
586 file = get_loaded_file(package,source);
587 if( !file )
588 return ERROR_FUNCTION_FAILED;
589
590 len = lstrlenW( file->TargetPath );
591
592 deformat_string(package,target,&deformated);
593 if (deformated)
594 len += strlenW(deformated);
595 len += 2;
596
597 cmd = msi_alloc(len * sizeof(WCHAR));
598
599 lstrcpyW( cmd, file->TargetPath);
600 if (deformated)
601 {
602 strcatW(cmd, spc);
603 strcatW(cmd, deformated);
604
605 msi_free(deformated);
606 }
607
608 TRACE("executing exe %s\n", debugstr_w(cmd));
609
610 rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
611 c_collen, &si, &info);
612
613
614 if ( !rc )
615 {
616 ERR("Unable to execute command %s\n", debugstr_w(cmd));
617 msi_free(cmd);
618 return ERROR_SUCCESS;
619 }
620 msi_free(cmd);
621
622 prc = process_handle(package, type, info.hThread, info.hProcess, action,
623 NULL);
624
625 return prc;
626 }
627
628 static UINT HANDLE_CustomType19(MSIPACKAGE *package, LPCWSTR source,
629 LPCWSTR target, const INT type, LPCWSTR action)
630 {
631 static const WCHAR query[] = {
632 'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ',
633 'F','R','O','M',' ','`','E','r','r','o','r','`',' ',
634 'W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ',
635 '%','s',0
636 };
637 MSIRECORD *row = 0;
638 LPWSTR deformated = NULL;
639
640 deformat_string( package, target, &deformated );
641
642 /* first try treat the error as a number */
643 row = MSI_QueryGetRecord( package->db, query, deformated );
644 if( row )
645 {
646 LPCWSTR error = MSI_RecordGetString( row, 1 );
647 MessageBoxW( NULL, error, NULL, MB_OK );
648 msiobj_release( &row->hdr );
649 }
650 else
651 MessageBoxW( NULL, deformated, NULL, MB_OK );
652
653 msi_free( deformated );
654
655 return ERROR_FUNCTION_FAILED;
656 }
657
658 static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source,
659 LPCWSTR target, const INT type, LPCWSTR action)
660 {
661 STARTUPINFOW si;
662 PROCESS_INFORMATION info;
663 WCHAR *prop;
664 BOOL rc;
665 WCHAR *deformated;
666 WCHAR *cmd;
667 INT len;
668 static const WCHAR spc[] = {' ',0};
669
670 memset(&si,0,sizeof(STARTUPINFOW));
671 memset(&info,0,sizeof(PROCESS_INFORMATION));
672
673 prop = msi_dup_property( package, source );
674 if (!prop)
675 return ERROR_SUCCESS;
676
677 deformat_string(package,target,&deformated);
678 len = strlenW(prop) + 2;
679 if (deformated)
680 len += strlenW(deformated);
681
682 cmd = msi_alloc(sizeof(WCHAR)*len);
683
684 strcpyW(cmd,prop);
685 if (deformated)
686 {
687 strcatW(cmd,spc);
688 strcatW(cmd,deformated);
689
690 msi_free(deformated);
691 }
692 msi_free(prop);
693
694 TRACE("executing exe %s\n", debugstr_w(cmd));
695
696 rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
697 c_collen, &si, &info);
698
699
700 if ( !rc )
701 {
702 ERR("Unable to execute command %s\n", debugstr_w(cmd));
703 msi_free(cmd);
704 return ERROR_SUCCESS;
705 }
706 msi_free(cmd);
707
708 return process_handle(package, type, info.hThread, info.hProcess, action, NULL);
709 }
710
711 static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source,
712 LPCWSTR target, const INT type, LPCWSTR action)
713 {
714 LPWSTR filename, deformated;
715 STARTUPINFOW si;
716 PROCESS_INFORMATION info;
717 BOOL rc;
718 UINT prc;
719
720 memset(&si,0,sizeof(STARTUPINFOW));
721
722 filename = resolve_folder(package, source, FALSE, FALSE, NULL);
723
724 if (!filename)
725 return ERROR_FUNCTION_FAILED;
726
727 SetCurrentDirectoryW(filename);
728 msi_free(filename);
729
730 deformat_string(package,target,&deformated);
731
732 if (!deformated)
733 return ERROR_FUNCTION_FAILED;
734
735 TRACE("executing exe %s\n", debugstr_w(deformated));
736
737 rc = CreateProcessW(NULL, deformated, NULL, NULL, FALSE, 0, NULL,
738 c_collen, &si, &info);
739
740 if ( !rc )
741 {
742 ERR("Unable to execute command %s\n", debugstr_w(deformated));
743 msi_free(deformated);
744 return ERROR_SUCCESS;
745 }
746 msi_free(deformated);
747
748 prc = process_handle(package, type, info.hThread, info.hProcess, action,
749 NULL);
750
751 return prc;
752 }
753
754
755 void ACTION_FinishCustomActions(MSIPACKAGE* package)
756 {
757 struct list *item, *cursor;
758 DWORD rc;
759
760 LIST_FOR_EACH_SAFE( item, cursor, &package->RunningActions )
761 {
762 MSIRUNNINGACTION *action = LIST_ENTRY( item, MSIRUNNINGACTION, entry );
763
764 TRACE("Checking on action %s\n", debugstr_w(action->name));
765
766 list_remove( &action->entry );
767
768 if (action->process)
769 GetExitCodeProcess( action->handle, &rc );
770 else
771 GetExitCodeThread( action->handle, &rc );
772
773 if (rc == STILL_ACTIVE)
774 {
775 TRACE("Waiting on action %s\n", debugstr_w( action->name) );
776 msi_dialog_check_messages( action->handle );
777 }
778
779 CloseHandle( action->handle );
780 msi_free( action->name );
781 msi_free( action );
782 }
783 }