2005-01-25 20:17:09 +00:00
|
|
|
/*
|
|
|
|
* Custom Action processing for the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2005 Aric Stewart for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-01-25 20:17:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
2006-11-17 06:16:13 +00:00
|
|
|
#include <stdarg.h>
|
2005-01-25 20:17:09 +00:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
2005-06-30 20:45:43 +00:00
|
|
|
#include "msidefs.h"
|
2005-01-25 20:17:09 +00:00
|
|
|
#include "msipriv.h"
|
|
|
|
#include "winuser.h"
|
2006-11-17 06:16:13 +00:00
|
|
|
#include "wine/debug.h"
|
2005-01-25 20:17:09 +00:00
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
|
|
|
#define CUSTOM_ACTION_TYPE_MASK 0x3F
|
|
|
|
static const WCHAR c_collen[] = {'C',':','\\',0};
|
|
|
|
static const WCHAR cszTempFolder[]= {'T','e','m','p','F','o','l','d','e','r',0};
|
|
|
|
|
|
|
|
typedef struct tagMSIRUNNINGACTION
|
|
|
|
{
|
2005-09-08 12:42:07 +00:00
|
|
|
struct list entry;
|
2005-01-25 20:17:09 +00:00
|
|
|
HANDLE handle;
|
|
|
|
BOOL process;
|
|
|
|
LPWSTR name;
|
|
|
|
} MSIRUNNINGACTION;
|
|
|
|
|
|
|
|
static UINT HANDLE_CustomType1(MSIPACKAGE *package, LPCWSTR source,
|
|
|
|
LPCWSTR target, const INT type, LPCWSTR action);
|
|
|
|
static UINT HANDLE_CustomType2(MSIPACKAGE *package, LPCWSTR source,
|
|
|
|
LPCWSTR target, const INT type, LPCWSTR action);
|
2006-03-22 04:42:52 +00:00
|
|
|
static UINT HANDLE_CustomType17(MSIPACKAGE *package, LPCWSTR source,
|
|
|
|
LPCWSTR target, const INT type, LPCWSTR action);
|
2005-01-25 20:17:09 +00:00
|
|
|
static UINT HANDLE_CustomType18(MSIPACKAGE *package, LPCWSTR source,
|
|
|
|
LPCWSTR target, const INT type, LPCWSTR action);
|
2005-02-09 13:57:54 +00:00
|
|
|
static UINT HANDLE_CustomType19(MSIPACKAGE *package, LPCWSTR source,
|
|
|
|
LPCWSTR target, const INT type, LPCWSTR action);
|
2005-01-25 20:17:09 +00:00
|
|
|
static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source,
|
|
|
|
LPCWSTR target, const INT type, LPCWSTR action);
|
|
|
|
static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source,
|
|
|
|
LPCWSTR target, const INT type, LPCWSTR action);
|
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
typedef UINT (WINAPI *MsiCustomActionEntryPoint)( MSIHANDLE );
|
2005-06-30 20:45:43 +00:00
|
|
|
|
2007-02-13 13:48:05 +00:00
|
|
|
static CRITICAL_SECTION msi_custom_action_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG msi_custom_action_cs_debug =
|
|
|
|
{
|
|
|
|
0, 0, &msi_custom_action_cs,
|
|
|
|
{ &msi_custom_action_cs_debug.ProcessLocksList,
|
|
|
|
&msi_custom_action_cs_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": msi_custom_action_cs") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION msi_custom_action_cs = { &msi_custom_action_cs_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
static struct list msi_pending_custom_actions = LIST_INIT( msi_pending_custom_actions );
|
|
|
|
|
2005-06-30 20:45:43 +00:00
|
|
|
static BOOL check_execution_scheduling_options(MSIPACKAGE *package, LPCWSTR action, UINT options)
|
|
|
|
{
|
|
|
|
if (!package->script)
|
|
|
|
return TRUE;
|
|
|
|
|
2007-02-13 13:48:05 +00:00
|
|
|
if ((options & msidbCustomActionTypeClientRepeat) ==
|
2005-06-30 20:45:43 +00:00
|
|
|
msidbCustomActionTypeClientRepeat)
|
|
|
|
{
|
|
|
|
if (!(package->script->InWhatSequence & SEQUENCE_UI &&
|
|
|
|
package->script->InWhatSequence & SEQUENCE_EXEC))
|
|
|
|
{
|
|
|
|
TRACE("Skipping action due to dbCustomActionTypeClientRepeat option.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (options & msidbCustomActionTypeFirstSequence)
|
|
|
|
{
|
|
|
|
if (package->script->InWhatSequence & SEQUENCE_UI &&
|
|
|
|
package->script->InWhatSequence & SEQUENCE_EXEC )
|
|
|
|
{
|
|
|
|
TRACE("Skipping action due to msidbCustomActionTypeFirstSequence option.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (options & msidbCustomActionTypeOncePerProcess)
|
|
|
|
{
|
|
|
|
if (check_unique_action(package,action))
|
|
|
|
{
|
|
|
|
TRACE("Skipping action due to msidbCustomActionTypeOncePerProcess option.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
register_unique_action(package,action);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-09-04 03:13:46 +00:00
|
|
|
/* stores the CustomActionData before the action:
|
|
|
|
* [CustomActionData]Action
|
|
|
|
*/
|
2006-10-09 07:05:04 +00:00
|
|
|
static LPWSTR msi_get_deferred_action(LPCWSTR action, LPWSTR actiondata)
|
2006-09-04 03:13:46 +00:00
|
|
|
{
|
|
|
|
LPWSTR deferred;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
static const WCHAR begin[] = {'[',0};
|
|
|
|
static const WCHAR end[] = {']',0};
|
|
|
|
|
|
|
|
if (!actiondata)
|
|
|
|
return strdupW(action);
|
|
|
|
|
|
|
|
len = lstrlenW(action) + lstrlenW(actiondata) + 3;
|
|
|
|
deferred = msi_alloc(len * sizeof(WCHAR));
|
|
|
|
|
|
|
|
lstrcpyW(deferred, begin);
|
|
|
|
lstrcatW(deferred, actiondata);
|
|
|
|
lstrcatW(deferred, end);
|
|
|
|
lstrcatW(deferred, action);
|
|
|
|
|
|
|
|
return deferred;
|
|
|
|
}
|
|
|
|
|
2005-01-25 20:17:09 +00:00
|
|
|
UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute)
|
|
|
|
{
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
|
|
|
MSIRECORD * row = 0;
|
|
|
|
static const WCHAR ExecSeqQuery[] =
|
2005-05-20 09:40:02 +00:00
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','C','u','s','t','o' ,'m','A','c','t','i','o','n','`',
|
|
|
|
' ','W','H','E','R','E',' ','`','A','c','t','i' ,'o','n','`',' ',
|
|
|
|
'=',' ','\'','%','s','\'',0};
|
2005-01-25 20:17:09 +00:00
|
|
|
UINT type;
|
2005-10-27 12:36:12 +00:00
|
|
|
LPCWSTR source, target;
|
2006-09-04 03:13:46 +00:00
|
|
|
LPWSTR ptr, deferred_data = NULL;
|
|
|
|
LPWSTR action_copy = strdupW(action);
|
2005-01-25 20:17:09 +00:00
|
|
|
WCHAR *deformated=NULL;
|
|
|
|
|
2006-09-04 03:13:46 +00:00
|
|
|
/* deferred action: [CustomActionData]Action */
|
|
|
|
if ((ptr = strchrW(action_copy, ']')))
|
|
|
|
{
|
|
|
|
deferred_data = action_copy + 1;
|
|
|
|
*ptr = '\0';
|
|
|
|
action = ptr + 1;
|
|
|
|
}
|
|
|
|
|
2005-06-02 10:29:57 +00:00
|
|
|
row = MSI_QueryGetRecord( package->db, ExecSeqQuery, action );
|
|
|
|
if (!row)
|
2006-10-10 06:20:39 +00:00
|
|
|
{
|
|
|
|
msi_free(action_copy);
|
2005-02-01 18:46:26 +00:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
2006-10-10 06:20:39 +00:00
|
|
|
}
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
type = MSI_RecordGetInteger(row,2);
|
|
|
|
|
2005-10-27 12:36:12 +00:00
|
|
|
source = MSI_RecordGetString(row,3);
|
|
|
|
target = MSI_RecordGetString(row,4);
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action),type,
|
|
|
|
debugstr_w(source), debugstr_w(target));
|
|
|
|
|
|
|
|
/* handle some of the deferred actions */
|
2005-06-30 20:45:43 +00:00
|
|
|
if (type & msidbCustomActionTypeTSAware)
|
|
|
|
FIXME("msidbCustomActionTypeTSAware not handled\n");
|
|
|
|
|
|
|
|
if (type & msidbCustomActionTypeInScript)
|
2005-01-25 20:17:09 +00:00
|
|
|
{
|
2005-06-30 20:45:43 +00:00
|
|
|
if (type & msidbCustomActionTypeNoImpersonate)
|
|
|
|
FIXME("msidbCustomActionTypeNoImpersonate not handled\n");
|
|
|
|
|
|
|
|
if (type & msidbCustomActionTypeRollback)
|
2005-01-25 20:17:09 +00:00
|
|
|
{
|
|
|
|
FIXME("Rollback only action... rollbacks not supported yet\n");
|
2005-05-27 19:24:22 +00:00
|
|
|
schedule_action(package, ROLLBACK_SCRIPT, action);
|
2005-09-23 17:21:46 +00:00
|
|
|
rc = ERROR_SUCCESS;
|
|
|
|
goto end;
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
if (!execute)
|
|
|
|
{
|
2006-09-04 03:13:46 +00:00
|
|
|
LPWSTR actiondata = msi_dup_property(package, action);
|
|
|
|
LPWSTR deferred = msi_get_deferred_action(action, actiondata);
|
|
|
|
|
2005-06-30 20:45:43 +00:00
|
|
|
if (type & msidbCustomActionTypeCommit)
|
2005-01-25 20:17:09 +00:00
|
|
|
{
|
|
|
|
TRACE("Deferring Commit Action!\n");
|
2006-09-04 03:13:46 +00:00
|
|
|
schedule_action(package, COMMIT_SCRIPT, deferred);
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Deferring Action!\n");
|
2006-09-04 03:13:46 +00:00
|
|
|
schedule_action(package, INSTALL_SCRIPT, deferred);
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
2005-09-23 17:21:46 +00:00
|
|
|
rc = ERROR_SUCCESS;
|
2006-09-04 03:13:46 +00:00
|
|
|
msi_free(deferred);
|
2005-09-23 17:21:46 +00:00
|
|
|
goto end;
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*Set ActionData*/
|
|
|
|
|
|
|
|
static const WCHAR szActionData[] = {
|
|
|
|
'C','u','s','t','o','m','A','c','t','i','o','n','D','a','t','a',0};
|
2005-07-12 19:18:48 +00:00
|
|
|
static const WCHAR szBlank[] = {0};
|
2005-09-15 15:04:08 +00:00
|
|
|
LPWSTR actiondata = msi_dup_property( package, action );
|
2006-09-04 03:13:46 +00:00
|
|
|
if (deferred_data)
|
|
|
|
MSI_SetPropertyW(package,szActionData,deferred_data);
|
|
|
|
else if (actiondata)
|
2005-01-25 20:17:09 +00:00
|
|
|
MSI_SetPropertyW(package,szActionData,actiondata);
|
2005-06-30 20:45:43 +00:00
|
|
|
else
|
|
|
|
MSI_SetPropertyW(package,szActionData,szBlank);
|
2005-09-20 11:59:14 +00:00
|
|
|
msi_free(actiondata);
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
}
|
2005-06-30 20:45:43 +00:00
|
|
|
else if (!check_execution_scheduling_options(package,action,type))
|
2005-09-22 10:56:26 +00:00
|
|
|
{
|
2005-09-23 17:21:46 +00:00
|
|
|
rc = ERROR_SUCCESS;
|
|
|
|
goto end;
|
2005-09-22 10:56:26 +00:00
|
|
|
}
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
switch (type & CUSTOM_ACTION_TYPE_MASK)
|
|
|
|
{
|
|
|
|
case 1: /* DLL file stored in a Binary table stream */
|
|
|
|
rc = HANDLE_CustomType1(package,source,target,type,action);
|
|
|
|
break;
|
2006-11-12 18:51:37 +00:00
|
|
|
case 2: /* EXE file stored in a Binary table stream */
|
2005-01-25 20:17:09 +00:00
|
|
|
rc = HANDLE_CustomType2(package,source,target,type,action);
|
|
|
|
break;
|
|
|
|
case 18: /*EXE file installed with package */
|
|
|
|
rc = HANDLE_CustomType18(package,source,target,type,action);
|
|
|
|
break;
|
2005-01-27 10:43:12 +00:00
|
|
|
case 19: /* Error that halts install */
|
2005-02-09 13:57:54 +00:00
|
|
|
rc = HANDLE_CustomType19(package,source,target,type,action);
|
2005-01-27 10:43:12 +00:00
|
|
|
break;
|
2006-03-22 04:42:52 +00:00
|
|
|
case 17:
|
|
|
|
rc = HANDLE_CustomType17(package,source,target,type,action);
|
|
|
|
break;
|
2005-01-25 20:17:09 +00:00
|
|
|
case 50: /*EXE file specified by a property value */
|
|
|
|
rc = HANDLE_CustomType50(package,source,target,type,action);
|
|
|
|
break;
|
|
|
|
case 34: /*EXE to be run in specified directory */
|
|
|
|
rc = HANDLE_CustomType34(package,source,target,type,action);
|
|
|
|
break;
|
|
|
|
case 35: /* Directory set with formatted text. */
|
|
|
|
deformat_string(package,target,&deformated);
|
|
|
|
MSI_SetTargetPathW(package, source, deformated);
|
2005-09-20 11:59:14 +00:00
|
|
|
msi_free(deformated);
|
2005-01-25 20:17:09 +00:00
|
|
|
break;
|
|
|
|
case 51: /* Property set with formatted text. */
|
|
|
|
deformat_string(package,target,&deformated);
|
|
|
|
rc = MSI_SetPropertyW(package,source,deformated);
|
2005-09-20 11:59:14 +00:00
|
|
|
msi_free(deformated);
|
2005-01-25 20:17:09 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("UNHANDLED ACTION TYPE %i (%s %s)\n",
|
|
|
|
type & CUSTOM_ACTION_TYPE_MASK, debugstr_w(source),
|
|
|
|
debugstr_w(target));
|
|
|
|
}
|
|
|
|
|
2005-09-23 17:21:46 +00:00
|
|
|
end:
|
2006-09-04 03:13:46 +00:00
|
|
|
msi_free(action_copy);
|
2005-01-25 20:17:09 +00:00
|
|
|
msiobj_release(&row->hdr);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-13 07:34:37 +00:00
|
|
|
static UINT store_binary_to_temp(MSIPACKAGE *package, LPCWSTR source,
|
2005-01-25 20:17:09 +00:00
|
|
|
LPWSTR tmp_file)
|
|
|
|
{
|
2006-11-13 07:34:37 +00:00
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E',' ',
|
|
|
|
'`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0};
|
|
|
|
MSIRECORD *row = 0;
|
|
|
|
HANDLE file;
|
|
|
|
CHAR buffer[1024];
|
2005-02-08 14:27:06 +00:00
|
|
|
static const WCHAR f1[] = {'m','s','i',0};
|
|
|
|
WCHAR fmt[MAX_PATH];
|
2006-11-13 07:34:37 +00:00
|
|
|
DWORD sz = MAX_PATH;
|
2006-11-13 07:35:46 +00:00
|
|
|
UINT r;
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2005-09-23 17:21:46 +00:00
|
|
|
if (MSI_GetPropertyW(package, cszTempFolder, fmt, &sz) != ERROR_SUCCESS)
|
2006-11-13 07:34:37 +00:00
|
|
|
GetTempPathW(MAX_PATH, fmt);
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2006-11-13 07:34:37 +00:00
|
|
|
if (GetTempFileNameW(fmt, f1, 0, tmp_file) == 0)
|
2005-01-25 20:17:09 +00:00
|
|
|
{
|
2005-02-08 14:27:06 +00:00
|
|
|
TRACE("Unable to create file\n");
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
2006-11-14 03:42:27 +00:00
|
|
|
track_tempfile(package, tmp_file);
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2006-11-13 07:34:37 +00:00
|
|
|
row = MSI_QueryGetRecord(package->db, query, source);
|
|
|
|
if (!row)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2006-11-13 07:35:46 +00:00
|
|
|
/* write out the file */
|
|
|
|
file = CreateFileW(tmp_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
if (file == INVALID_HANDLE_VALUE)
|
|
|
|
r = ERROR_FUNCTION_FAILED;
|
|
|
|
else
|
2006-11-13 07:34:37 +00:00
|
|
|
{
|
2006-11-13 07:35:46 +00:00
|
|
|
do
|
2006-11-13 07:34:37 +00:00
|
|
|
{
|
2006-11-13 07:35:46 +00:00
|
|
|
DWORD write;
|
|
|
|
sz = sizeof buffer;
|
|
|
|
r = MSI_RecordReadStream(row, 2, buffer, &sz);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("Failed to get stream\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
WriteFile(file, buffer, sz, &write, NULL);
|
|
|
|
} while (sz == sizeof buffer);
|
|
|
|
CloseHandle(file);
|
|
|
|
}
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2006-11-13 07:34:37 +00:00
|
|
|
msiobj_release(&row->hdr);
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2006-11-13 07:35:46 +00:00
|
|
|
return r;
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
2007-02-10 02:05:43 +00:00
|
|
|
static void file_running_action(MSIPACKAGE* package, HANDLE Handle,
|
2005-01-25 20:17:09 +00:00
|
|
|
BOOL process, LPCWSTR name)
|
|
|
|
{
|
2005-09-08 12:42:07 +00:00
|
|
|
MSIRUNNINGACTION *action;
|
|
|
|
|
2005-09-20 11:59:14 +00:00
|
|
|
action = msi_alloc( sizeof(MSIRUNNINGACTION) );
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2005-09-08 12:42:07 +00:00
|
|
|
action->handle = Handle;
|
|
|
|
action->process = process;
|
|
|
|
action->name = strdupW(name);
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2005-09-08 12:42:07 +00:00
|
|
|
list_add_tail( &package->RunningActions, &action->entry );
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
2006-11-22 08:04:42 +00:00
|
|
|
static UINT custom_get_process_return( HANDLE process )
|
2005-01-25 20:17:09 +00:00
|
|
|
{
|
2006-11-22 08:04:42 +00:00
|
|
|
DWORD rc = 0;
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2006-11-22 08:04:42 +00:00
|
|
|
GetExitCodeProcess( process, &rc );
|
|
|
|
if (rc != 0)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT custom_get_thread_return( HANDLE thread )
|
|
|
|
{
|
|
|
|
DWORD rc = 0;
|
|
|
|
|
|
|
|
GetExitCodeThread( thread, &rc );
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
switch (rc)
|
|
|
|
{
|
2005-10-27 12:39:28 +00:00
|
|
|
case ERROR_FUNCTION_NOT_CALLED:
|
|
|
|
case ERROR_SUCCESS:
|
|
|
|
case ERROR_INSTALL_USEREXIT:
|
|
|
|
case ERROR_INSTALL_FAILURE:
|
|
|
|
return rc;
|
|
|
|
case ERROR_NO_MORE_ITEMS:
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
default:
|
2006-10-05 04:41:22 +00:00
|
|
|
ERR("Invalid Return Code %d\n",rc);
|
2005-10-27 12:39:28 +00:00
|
|
|
return ERROR_INSTALL_FAILURE;
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-10 02:05:43 +00:00
|
|
|
static UINT wait_process_handle(MSIPACKAGE* package, UINT type,
|
|
|
|
HANDLE ProcessHandle, LPCWSTR name)
|
2005-01-25 20:17:09 +00:00
|
|
|
{
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
|
|
|
|
2005-06-30 20:45:43 +00:00
|
|
|
if (!(type & msidbCustomActionTypeAsync))
|
2005-01-25 20:17:09 +00:00
|
|
|
{
|
2007-02-10 02:05:43 +00:00
|
|
|
TRACE("waiting for %s\n", debugstr_w(name));
|
|
|
|
|
|
|
|
msi_dialog_check_messages(ProcessHandle);
|
|
|
|
|
|
|
|
if (!(type & msidbCustomActionTypeContinue))
|
|
|
|
rc = custom_get_process_return(ProcessHandle);
|
|
|
|
|
|
|
|
CloseHandle(ProcessHandle);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("%s running in background\n", debugstr_w(name));
|
|
|
|
|
|
|
|
if (!(type & msidbCustomActionTypeContinue))
|
|
|
|
file_running_action(package, ProcessHandle, TRUE, name);
|
2005-01-25 20:17:09 +00:00
|
|
|
else
|
2007-02-10 02:05:43 +00:00
|
|
|
CloseHandle(ProcessHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
typedef struct _msi_custom_action_info {
|
|
|
|
struct list entry;
|
|
|
|
MSIPACKAGE *package;
|
|
|
|
LPWSTR dllname;
|
|
|
|
LPWSTR function;
|
|
|
|
HANDLE handle;
|
|
|
|
LPWSTR action;
|
|
|
|
INT type;
|
2007-02-13 13:48:05 +00:00
|
|
|
GUID guid;
|
2007-02-12 02:31:41 +00:00
|
|
|
} msi_custom_action_info;
|
|
|
|
|
|
|
|
static void free_custom_action_data( msi_custom_action_info *info )
|
|
|
|
{
|
2007-02-13 13:48:05 +00:00
|
|
|
EnterCriticalSection( &msi_custom_action_cs );
|
2007-02-12 02:31:41 +00:00
|
|
|
list_remove( &info->entry );
|
2007-02-13 13:48:05 +00:00
|
|
|
LeaveCriticalSection( &msi_custom_action_cs );
|
2007-02-12 02:31:41 +00:00
|
|
|
if (info->handle)
|
|
|
|
CloseHandle( info->handle );
|
|
|
|
msi_free( info->action );
|
|
|
|
msi_free( info->dllname );
|
|
|
|
msi_free( info->function );
|
|
|
|
msiobj_release( &info->package->hdr );
|
|
|
|
msi_free( info );
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT wait_thread_handle( msi_custom_action_info *info )
|
2007-02-10 02:05:43 +00:00
|
|
|
{
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
if (!(info->type & msidbCustomActionTypeAsync))
|
2007-02-10 02:05:43 +00:00
|
|
|
{
|
2007-02-12 02:31:41 +00:00
|
|
|
TRACE("waiting for %s\n", debugstr_w( info->action ));
|
2007-02-10 02:05:43 +00:00
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
msi_dialog_check_messages( info->handle );
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
if (!(info->type & msidbCustomActionTypeContinue))
|
|
|
|
rc = custom_get_thread_return( info->handle );
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
free_custom_action_data( info );
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
2006-11-22 08:04:42 +00:00
|
|
|
else
|
2005-01-25 20:17:09 +00:00
|
|
|
{
|
2007-02-12 02:31:41 +00:00
|
|
|
TRACE("%s running in background\n", debugstr_w( info->action ));
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-02-13 13:48:05 +00:00
|
|
|
static msi_custom_action_info *find_action_by_guid( const LPGUID guid )
|
|
|
|
{
|
|
|
|
msi_custom_action_info *info;
|
|
|
|
BOOL found = FALSE;
|
|
|
|
|
|
|
|
EnterCriticalSection( &msi_custom_action_cs );
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( info, &msi_pending_custom_actions, msi_custom_action_info, entry )
|
|
|
|
{
|
|
|
|
if (IsEqualGUID( &info->guid, guid ))
|
|
|
|
{
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection( &msi_custom_action_cs );
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2007-02-13 13:48:05 +00:00
|
|
|
static DWORD WINAPI ACTION_CallDllFunction( const LPGUID guid )
|
2005-01-25 20:17:09 +00:00
|
|
|
{
|
2007-02-13 13:48:05 +00:00
|
|
|
msi_custom_action_info *info;
|
2007-02-12 02:31:41 +00:00
|
|
|
MsiCustomActionEntryPoint fn;
|
|
|
|
MSIHANDLE hPackage;
|
2005-01-25 20:17:09 +00:00
|
|
|
HANDLE hModule;
|
|
|
|
LPSTR proc;
|
2007-02-12 02:31:41 +00:00
|
|
|
UINT r = ERROR_FUNCTION_FAILED;
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2007-02-13 13:48:05 +00:00
|
|
|
info = find_action_by_guid( guid );
|
|
|
|
if (!info)
|
|
|
|
{
|
|
|
|
ERR("failed to find action %s\n", debugstr_guid( guid) );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
TRACE("%s %s\n", debugstr_w( info->dllname ), debugstr_w( info->function ) );
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
hModule = LoadLibraryW( info->dllname );
|
|
|
|
if (!hModule)
|
2005-01-25 20:17:09 +00:00
|
|
|
{
|
2007-02-12 02:31:41 +00:00
|
|
|
ERR("failed to load dll %s\n", debugstr_w( info->dllname ) );
|
|
|
|
return r;
|
|
|
|
}
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
proc = strdupWtoA( info->function );
|
|
|
|
fn = (MsiCustomActionEntryPoint) GetProcAddress( hModule, proc );
|
|
|
|
msi_free( proc );
|
|
|
|
if (fn)
|
|
|
|
{
|
|
|
|
hPackage = alloc_msihandle( &info->package->hdr );
|
|
|
|
if (hPackage)
|
|
|
|
{
|
|
|
|
TRACE("calling %s\n", debugstr_w( info->function ) );
|
|
|
|
r = fn( hPackage );
|
|
|
|
MsiCloseHandle( hPackage );
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
else
|
2007-02-12 02:31:41 +00:00
|
|
|
ERR("failed to create handle for %p\n", info->package );
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
else
|
2007-02-12 02:31:41 +00:00
|
|
|
ERR("GetProcAddress(%s) failed\n", debugstr_w( info->function ) );
|
|
|
|
|
|
|
|
FreeLibrary(hModule);
|
|
|
|
|
2007-02-25 05:06:54 +00:00
|
|
|
if (info->type & msidbCustomActionTypeAsync &&
|
|
|
|
info->type & msidbCustomActionTypeContinue)
|
|
|
|
free_custom_action_data( info );
|
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
return r;
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
static DWORD WINAPI DllThread( LPVOID arg )
|
2005-01-25 20:17:09 +00:00
|
|
|
{
|
2007-02-13 13:48:05 +00:00
|
|
|
LPGUID guid = arg;
|
2005-01-25 20:17:09 +00:00
|
|
|
DWORD rc = 0;
|
2006-10-05 04:41:22 +00:00
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
TRACE("custom action (%x) started\n", GetCurrentThreadId() );
|
2006-10-05 04:41:22 +00:00
|
|
|
|
2007-02-13 13:48:05 +00:00
|
|
|
rc = ACTION_CallDllFunction( guid );
|
2007-02-12 02:31:41 +00:00
|
|
|
|
|
|
|
TRACE("custom action (%x) returned %i\n", GetCurrentThreadId(), rc );
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
MsiCloseAllHandles();
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
static msi_custom_action_info *do_msidbCustomActionTypeDll(
|
|
|
|
MSIPACKAGE *package, INT type, LPCWSTR dllname, LPCWSTR function, LPCWSTR action )
|
2006-03-22 04:42:52 +00:00
|
|
|
{
|
2007-02-12 02:31:41 +00:00
|
|
|
msi_custom_action_info *info;
|
|
|
|
|
|
|
|
info = msi_alloc( sizeof *info );
|
|
|
|
if (!info)
|
|
|
|
return NULL;
|
2006-03-22 04:42:52 +00:00
|
|
|
|
|
|
|
msiobj_addref( &package->hdr );
|
|
|
|
info->package = package;
|
2007-02-12 02:31:41 +00:00
|
|
|
info->type = type;
|
|
|
|
info->function = strdupW( function );
|
|
|
|
info->dllname = strdupW( dllname );
|
|
|
|
info->action = strdupW( action );
|
2007-02-13 13:48:05 +00:00
|
|
|
CoCreateGuid( &info->guid );
|
|
|
|
|
|
|
|
EnterCriticalSection( &msi_custom_action_cs );
|
|
|
|
list_add_tail( &msi_pending_custom_actions, &info->entry );
|
|
|
|
LeaveCriticalSection( &msi_custom_action_cs );
|
2007-02-12 02:31:41 +00:00
|
|
|
|
2007-02-13 13:48:05 +00:00
|
|
|
info->handle = CreateThread( NULL, 0, DllThread, &info->guid, 0, NULL );
|
2007-02-12 02:31:41 +00:00
|
|
|
if (!info->handle)
|
|
|
|
{
|
|
|
|
free_custom_action_data( info );
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-03-22 04:42:52 +00:00
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
return info;
|
2006-03-22 04:42:52 +00:00
|
|
|
}
|
|
|
|
|
2007-02-10 02:05:43 +00:00
|
|
|
static UINT HANDLE_CustomType1(MSIPACKAGE *package, LPCWSTR source,
|
2005-01-25 20:17:09 +00:00
|
|
|
LPCWSTR target, const INT type, LPCWSTR action)
|
|
|
|
{
|
2007-02-12 02:31:41 +00:00
|
|
|
msi_custom_action_info *info;
|
2005-01-25 20:17:09 +00:00
|
|
|
WCHAR tmp_file[MAX_PATH];
|
2007-02-12 02:31:41 +00:00
|
|
|
UINT r;
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2006-11-13 07:35:09 +00:00
|
|
|
r = store_binary_to_temp(package, source, tmp_file);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
TRACE("Calling function %s from %s\n",debugstr_w(target),
|
|
|
|
debugstr_w(tmp_file));
|
|
|
|
|
|
|
|
if (!strchrW(tmp_file,'.'))
|
|
|
|
{
|
|
|
|
static const WCHAR dot[]={'.',0};
|
|
|
|
strcatW(tmp_file,dot);
|
2006-11-13 07:35:09 +00:00
|
|
|
}
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
info = do_msidbCustomActionTypeDll( package, type, tmp_file, target, action );
|
2005-06-16 20:33:58 +00:00
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
return wait_thread_handle( info );
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
2007-02-10 02:05:43 +00:00
|
|
|
static UINT HANDLE_CustomType2(MSIPACKAGE *package, LPCWSTR source,
|
2005-01-25 20:17:09 +00:00
|
|
|
LPCWSTR target, const INT type, LPCWSTR action)
|
|
|
|
{
|
|
|
|
WCHAR tmp_file[MAX_PATH];
|
|
|
|
STARTUPINFOW si;
|
|
|
|
PROCESS_INFORMATION info;
|
|
|
|
BOOL rc;
|
|
|
|
INT len;
|
2006-11-13 07:35:59 +00:00
|
|
|
WCHAR *deformated = NULL;
|
2005-01-25 20:17:09 +00:00
|
|
|
WCHAR *cmd;
|
|
|
|
static const WCHAR spc[] = {' ',0};
|
2007-02-13 10:50:35 +00:00
|
|
|
UINT r;
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
memset(&si,0,sizeof(STARTUPINFOW));
|
|
|
|
|
2006-11-13 07:35:09 +00:00
|
|
|
r = store_binary_to_temp(package, source, tmp_file);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
deformat_string(package,target,&deformated);
|
|
|
|
|
|
|
|
len = strlenW(tmp_file)+2;
|
|
|
|
|
|
|
|
if (deformated)
|
|
|
|
len += strlenW(deformated);
|
2006-11-13 07:35:09 +00:00
|
|
|
|
2005-09-20 11:59:14 +00:00
|
|
|
cmd = msi_alloc(sizeof(WCHAR)*len);
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
strcpyW(cmd,tmp_file);
|
|
|
|
if (deformated)
|
|
|
|
{
|
|
|
|
strcatW(cmd,spc);
|
|
|
|
strcatW(cmd,deformated);
|
|
|
|
|
2005-09-20 11:59:14 +00:00
|
|
|
msi_free(deformated);
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
2005-11-10 12:14:56 +00:00
|
|
|
TRACE("executing exe %s\n", debugstr_w(cmd));
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
|
|
|
|
c_collen, &si, &info);
|
2006-11-13 07:35:59 +00:00
|
|
|
msi_free(cmd);
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
if ( !rc )
|
|
|
|
{
|
2006-01-03 16:35:41 +00:00
|
|
|
ERR("Unable to execute command %s\n", debugstr_w(cmd));
|
2005-01-25 20:17:09 +00:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2007-02-10 02:05:43 +00:00
|
|
|
CloseHandle( info.hThread );
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2007-02-10 02:05:43 +00:00
|
|
|
r = wait_process_handle(package, type, info.hProcess, action);
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2006-11-13 07:35:09 +00:00
|
|
|
return r;
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
2006-03-22 04:42:52 +00:00
|
|
|
static UINT HANDLE_CustomType17(MSIPACKAGE *package, LPCWSTR source,
|
|
|
|
LPCWSTR target, const INT type, LPCWSTR action)
|
|
|
|
{
|
2007-02-12 02:31:41 +00:00
|
|
|
msi_custom_action_info *info;
|
2006-03-22 04:42:52 +00:00
|
|
|
MSIFILE *file;
|
|
|
|
|
|
|
|
TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
|
|
|
|
|
|
|
|
file = get_loaded_file( package, source );
|
|
|
|
if (!file)
|
|
|
|
{
|
|
|
|
ERR("invalid file key %s\n", debugstr_w( source ));
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
info = do_msidbCustomActionTypeDll( package, type, file->TargetPath, target, action );
|
2006-03-22 04:42:52 +00:00
|
|
|
|
2007-02-12 02:31:41 +00:00
|
|
|
return wait_thread_handle( info );
|
2006-03-22 04:42:52 +00:00
|
|
|
}
|
|
|
|
|
2005-01-25 20:17:09 +00:00
|
|
|
static UINT HANDLE_CustomType18(MSIPACKAGE *package, LPCWSTR source,
|
|
|
|
LPCWSTR target, const INT type, LPCWSTR action)
|
|
|
|
{
|
|
|
|
STARTUPINFOW si;
|
|
|
|
PROCESS_INFORMATION info;
|
|
|
|
BOOL rc;
|
|
|
|
WCHAR *deformated;
|
|
|
|
WCHAR *cmd;
|
|
|
|
INT len;
|
|
|
|
static const WCHAR spc[] = {' ',0};
|
2005-08-23 10:03:17 +00:00
|
|
|
MSIFILE *file;
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
memset(&si,0,sizeof(STARTUPINFOW));
|
|
|
|
|
2005-08-23 10:03:17 +00:00
|
|
|
file = get_loaded_file(package,source);
|
|
|
|
if( !file )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2005-08-23 10:03:17 +00:00
|
|
|
len = lstrlenW( file->TargetPath );
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
deformat_string(package,target,&deformated);
|
|
|
|
if (deformated)
|
|
|
|
len += strlenW(deformated);
|
|
|
|
len += 2;
|
|
|
|
|
2005-09-20 11:59:14 +00:00
|
|
|
cmd = msi_alloc(len * sizeof(WCHAR));
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2005-08-23 10:03:17 +00:00
|
|
|
lstrcpyW( cmd, file->TargetPath);
|
2005-01-25 20:17:09 +00:00
|
|
|
if (deformated)
|
|
|
|
{
|
|
|
|
strcatW(cmd, spc);
|
|
|
|
strcatW(cmd, deformated);
|
|
|
|
|
2005-09-20 11:59:14 +00:00
|
|
|
msi_free(deformated);
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
2005-11-10 12:14:56 +00:00
|
|
|
TRACE("executing exe %s\n", debugstr_w(cmd));
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
|
|
|
|
c_collen, &si, &info);
|
|
|
|
|
|
|
|
if ( !rc )
|
|
|
|
{
|
2006-01-03 16:35:41 +00:00
|
|
|
ERR("Unable to execute command %s\n", debugstr_w(cmd));
|
|
|
|
msi_free(cmd);
|
2005-01-25 20:17:09 +00:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2006-01-03 16:35:41 +00:00
|
|
|
msi_free(cmd);
|
2007-02-10 02:05:43 +00:00
|
|
|
CloseHandle( info.hThread );
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2007-02-10 02:05:43 +00:00
|
|
|
return wait_process_handle(package, type, info.hProcess, action);
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
2005-02-09 13:57:54 +00:00
|
|
|
static UINT HANDLE_CustomType19(MSIPACKAGE *package, LPCWSTR source,
|
|
|
|
LPCWSTR target, const INT type, LPCWSTR action)
|
|
|
|
{
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ',
|
|
|
|
'F','R','O','M',' ','`','E','r','r','o','r','`',' ',
|
2005-05-20 09:40:02 +00:00
|
|
|
'W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ',
|
2005-09-28 11:59:16 +00:00
|
|
|
'%','s',0
|
2005-02-09 13:57:54 +00:00
|
|
|
};
|
|
|
|
MSIRECORD *row = 0;
|
|
|
|
LPWSTR deformated = NULL;
|
|
|
|
|
|
|
|
deformat_string( package, target, &deformated );
|
|
|
|
|
|
|
|
/* first try treat the error as a number */
|
2005-06-02 10:29:57 +00:00
|
|
|
row = MSI_QueryGetRecord( package->db, query, deformated );
|
|
|
|
if( row )
|
2005-02-09 13:57:54 +00:00
|
|
|
{
|
2005-06-02 10:29:57 +00:00
|
|
|
LPCWSTR error = MSI_RecordGetString( row, 1 );
|
|
|
|
MessageBoxW( NULL, error, NULL, MB_OK );
|
|
|
|
msiobj_release( &row->hdr );
|
2005-02-09 13:57:54 +00:00
|
|
|
}
|
2005-06-02 10:29:57 +00:00
|
|
|
else
|
2005-02-09 13:57:54 +00:00
|
|
|
MessageBoxW( NULL, deformated, NULL, MB_OK );
|
2005-06-02 10:29:57 +00:00
|
|
|
|
2005-09-20 11:59:14 +00:00
|
|
|
msi_free( deformated );
|
2005-02-09 13:57:54 +00:00
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2005-01-25 20:17:09 +00:00
|
|
|
static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source,
|
|
|
|
LPCWSTR target, const INT type, LPCWSTR action)
|
|
|
|
{
|
|
|
|
STARTUPINFOW si;
|
|
|
|
PROCESS_INFORMATION info;
|
|
|
|
WCHAR *prop;
|
|
|
|
BOOL rc;
|
|
|
|
WCHAR *deformated;
|
|
|
|
WCHAR *cmd;
|
|
|
|
INT len;
|
|
|
|
static const WCHAR spc[] = {' ',0};
|
|
|
|
|
|
|
|
memset(&si,0,sizeof(STARTUPINFOW));
|
|
|
|
memset(&info,0,sizeof(PROCESS_INFORMATION));
|
|
|
|
|
2005-09-15 15:04:08 +00:00
|
|
|
prop = msi_dup_property( package, source );
|
2005-01-25 20:17:09 +00:00
|
|
|
if (!prop)
|
2005-05-20 09:40:02 +00:00
|
|
|
return ERROR_SUCCESS;
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
deformat_string(package,target,&deformated);
|
|
|
|
len = strlenW(prop) + 2;
|
|
|
|
if (deformated)
|
|
|
|
len += strlenW(deformated);
|
|
|
|
|
2005-09-20 11:59:14 +00:00
|
|
|
cmd = msi_alloc(sizeof(WCHAR)*len);
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
strcpyW(cmd,prop);
|
|
|
|
if (deformated)
|
|
|
|
{
|
|
|
|
strcatW(cmd,spc);
|
|
|
|
strcatW(cmd,deformated);
|
|
|
|
|
2005-09-20 11:59:14 +00:00
|
|
|
msi_free(deformated);
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
2005-09-20 11:59:14 +00:00
|
|
|
msi_free(prop);
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2005-11-10 12:14:56 +00:00
|
|
|
TRACE("executing exe %s\n", debugstr_w(cmd));
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
|
|
|
|
c_collen, &si, &info);
|
|
|
|
|
|
|
|
if ( !rc )
|
|
|
|
{
|
2006-01-03 16:35:41 +00:00
|
|
|
ERR("Unable to execute command %s\n", debugstr_w(cmd));
|
|
|
|
msi_free(cmd);
|
2005-01-25 20:17:09 +00:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2006-01-03 16:35:41 +00:00
|
|
|
msi_free(cmd);
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2007-02-10 02:05:43 +00:00
|
|
|
CloseHandle( info.hThread );
|
|
|
|
|
|
|
|
return wait_process_handle(package, type, info.hProcess, action);
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source,
|
|
|
|
LPCWSTR target, const INT type, LPCWSTR action)
|
|
|
|
{
|
|
|
|
LPWSTR filename, deformated;
|
|
|
|
STARTUPINFOW si;
|
|
|
|
PROCESS_INFORMATION info;
|
|
|
|
BOOL rc;
|
|
|
|
|
|
|
|
memset(&si,0,sizeof(STARTUPINFOW));
|
|
|
|
|
|
|
|
filename = resolve_folder(package, source, FALSE, FALSE, NULL);
|
|
|
|
|
|
|
|
if (!filename)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
SetCurrentDirectoryW(filename);
|
2005-09-20 11:59:14 +00:00
|
|
|
msi_free(filename);
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
deformat_string(package,target,&deformated);
|
|
|
|
|
|
|
|
if (!deformated)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2005-11-10 12:14:56 +00:00
|
|
|
TRACE("executing exe %s\n", debugstr_w(deformated));
|
2005-01-25 20:17:09 +00:00
|
|
|
|
|
|
|
rc = CreateProcessW(NULL, deformated, NULL, NULL, FALSE, 0, NULL,
|
|
|
|
c_collen, &si, &info);
|
|
|
|
|
|
|
|
if ( !rc )
|
|
|
|
{
|
2006-01-03 16:35:41 +00:00
|
|
|
ERR("Unable to execute command %s\n", debugstr_w(deformated));
|
|
|
|
msi_free(deformated);
|
2005-01-25 20:17:09 +00:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2006-01-03 16:35:41 +00:00
|
|
|
msi_free(deformated);
|
2007-02-10 02:05:43 +00:00
|
|
|
CloseHandle( info.hThread );
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2007-02-10 02:05:43 +00:00
|
|
|
return wait_process_handle(package, type, info.hProcess, action);
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ACTION_FinishCustomActions(MSIPACKAGE* package)
|
|
|
|
{
|
2007-02-12 02:30:43 +00:00
|
|
|
struct list *item;
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2007-02-12 02:30:43 +00:00
|
|
|
while ((item = list_head( &package->RunningActions )))
|
2005-01-25 20:17:09 +00:00
|
|
|
{
|
2005-09-08 12:42:07 +00:00
|
|
|
MSIRUNNINGACTION *action = LIST_ENTRY( item, MSIRUNNINGACTION, entry );
|
|
|
|
|
|
|
|
list_remove( &action->entry );
|
|
|
|
|
2007-02-12 02:30:43 +00:00
|
|
|
TRACE("waiting for %s\n", debugstr_w( action->name ) );
|
|
|
|
msi_dialog_check_messages( action->handle );
|
2005-01-25 20:17:09 +00:00
|
|
|
|
2005-09-08 12:42:07 +00:00
|
|
|
CloseHandle( action->handle );
|
2005-09-20 11:59:14 +00:00
|
|
|
msi_free( action->name );
|
|
|
|
msi_free( action );
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|
2007-02-12 02:31:41 +00:00
|
|
|
|
2007-02-13 13:48:05 +00:00
|
|
|
while (1)
|
2007-02-12 02:31:41 +00:00
|
|
|
{
|
2007-02-13 13:48:05 +00:00
|
|
|
HANDLE handle;
|
2007-02-12 02:31:41 +00:00
|
|
|
msi_custom_action_info *info;
|
|
|
|
|
2007-02-13 13:48:05 +00:00
|
|
|
EnterCriticalSection( &msi_custom_action_cs );
|
|
|
|
item = list_head( &msi_pending_custom_actions );
|
2007-02-12 02:31:41 +00:00
|
|
|
info = LIST_ENTRY( item, msi_custom_action_info, entry );
|
2007-02-13 13:48:05 +00:00
|
|
|
|
|
|
|
if (item && info->package == package )
|
|
|
|
{
|
|
|
|
handle = info->handle;
|
|
|
|
free_custom_action_data( info );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
handle = NULL;
|
|
|
|
LeaveCriticalSection( &msi_custom_action_cs );
|
|
|
|
|
|
|
|
if (!item)
|
|
|
|
break;
|
|
|
|
|
|
|
|
msi_dialog_check_messages( handle );
|
2007-02-12 02:31:41 +00:00
|
|
|
}
|
2005-01-25 20:17:09 +00:00
|
|
|
}
|