Hans Leidekker : msi: Pass the full custom action command to CreateProcess.
Alexandre Julliard
julliard at winehq.org
Tue Jun 14 11:57:46 CDT 2011
Module: wine
Branch: master
Commit: 5ca2277cc5ee5722de1b62c051890c8db950bacf
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5ca2277cc5ee5722de1b62c051890c8db950bacf
Author: Hans Leidekker <hans at codeweavers.com>
Date: Tue Jun 14 10:45:10 2011 +0200
msi: Pass the full custom action command to CreateProcess.
---
dlls/msi/custom.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c
index 211bec0..8de6431 100644
--- a/dlls/msi/custom.c
+++ b/dlls/msi/custom.c
@@ -768,14 +768,65 @@ static UINT HANDLE_CustomType1(MSIPACKAGE *package, LPCWSTR source,
return r;
}
-static HANDLE execute_command( const WCHAR *exe, WCHAR *arg, const WCHAR *dir )
+static HANDLE execute_command( const WCHAR *app, WCHAR *arg, const WCHAR *dir )
{
+ static const WCHAR dotexeW[] = {'.','e','x','e',0};
STARTUPINFOW si;
PROCESS_INFORMATION info;
+ WCHAR *exe = NULL, *cmd = NULL, *p;
BOOL ret;
+ if (app)
+ {
+ int len_arg = 0;
+ DWORD len_exe;
+
+ if (!(exe = msi_alloc( MAX_PATH * sizeof(WCHAR) ))) return INVALID_HANDLE_VALUE;
+ len_exe = SearchPathW( NULL, app, dotexeW, MAX_PATH, exe, NULL );
+ if (len_exe >= MAX_PATH)
+ {
+ msi_free( exe );
+ if (!(exe = msi_alloc( len_exe * sizeof(WCHAR) ))) return INVALID_HANDLE_VALUE;
+ len_exe = SearchPathW( NULL, app, dotexeW, len_exe, exe, NULL );
+ }
+ if (!len_exe)
+ {
+ WARN("can't find executable %u\n", GetLastError());
+ msi_free( exe );
+ return INVALID_HANDLE_VALUE;
+ }
+
+ if (arg) len_arg = strlenW( arg );
+ if (!(cmd = msi_alloc( (len_exe + len_arg + 4) * sizeof(WCHAR) )))
+ {
+ msi_free( exe );
+ return INVALID_HANDLE_VALUE;
+ }
+ p = cmd;
+ if (strchrW( exe, ' ' ))
+ {
+ *p++ = '\"';
+ memcpy( p, exe, len_exe * sizeof(WCHAR) );
+ p += len_exe;
+ *p++ = '\"';
+ *p = 0;
+ }
+ else
+ {
+ strcpyW( p, exe );
+ p += len_exe;
+ }
+ if (arg)
+ {
+ *p++ = ' ';
+ memcpy( p, arg, len_arg * sizeof(WCHAR) );
+ p[len_arg] = 0;
+ }
+ }
memset( &si, 0, sizeof(STARTUPINFOW) );
- ret = CreateProcessW( exe, arg, NULL, NULL, FALSE, 0, NULL, dir, &si, &info );
+ ret = CreateProcessW( exe, exe ? cmd : arg, NULL, NULL, FALSE, 0, NULL, dir, &si, &info );
+ msi_free( cmd );
+ msi_free( exe );
if (!ret)
{
WARN("unable to execute command %u\n", GetLastError());
More information about the wine-cvs
mailing list