2007-05-01 03:54:43 +02:00
|
|
|
/*
|
|
|
|
* Implementation of scripting for Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2007 Misha Koshelev
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "msidefs.h"
|
|
|
|
#include "msipriv.h"
|
|
|
|
#include "activscp.h"
|
|
|
|
#include "oleauto.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "msiserver.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
2012-09-18 12:24:16 +02:00
|
|
|
#ifdef _WIN64
|
|
|
|
|
|
|
|
#define IActiveScriptParse_Release IActiveScriptParse64_Release
|
|
|
|
#define IActiveScriptParse_InitNew IActiveScriptParse64_InitNew
|
|
|
|
#define IActiveScriptParse_ParseScriptText IActiveScriptParse64_ParseScriptText
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define IActiveScriptParse_Release IActiveScriptParse32_Release
|
|
|
|
#define IActiveScriptParse_InitNew IActiveScriptParse32_InitNew
|
|
|
|
#define IActiveScriptParse_ParseScriptText IActiveScriptParse32_ParseScriptText
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-05-01 03:54:43 +02:00
|
|
|
/*
|
|
|
|
* MsiActiveScriptSite - Our IActiveScriptSite implementation.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
2012-11-14 23:08:14 +01:00
|
|
|
IActiveScriptSite IActiveScriptSite_iface;
|
2012-11-14 23:42:16 +01:00
|
|
|
IDispatch *installer;
|
|
|
|
IDispatch *session;
|
2007-05-01 03:54:43 +02:00
|
|
|
LONG ref;
|
|
|
|
} MsiActiveScriptSite;
|
|
|
|
|
2012-11-14 23:08:14 +01:00
|
|
|
static inline MsiActiveScriptSite *impl_from_IActiveScriptSite( IActiveScriptSite *iface )
|
2007-05-01 03:54:43 +02:00
|
|
|
{
|
2012-11-14 23:08:14 +01:00
|
|
|
return CONTAINING_RECORD(iface, MsiActiveScriptSite, IActiveScriptSite_iface);
|
2007-05-01 03:54:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MsiActiveScriptSite
|
|
|
|
*/
|
2012-11-14 23:08:14 +01:00
|
|
|
static HRESULT WINAPI MsiActiveScriptSite_QueryInterface(IActiveScriptSite* iface, REFIID riid, void** obj)
|
2007-05-01 03:54:43 +02:00
|
|
|
{
|
2012-11-14 23:08:14 +01:00
|
|
|
MsiActiveScriptSite *This = impl_from_IActiveScriptSite(iface);
|
2007-05-01 03:54:43 +02:00
|
|
|
|
2012-11-14 23:08:14 +01:00
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
|
2007-05-01 03:54:43 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IActiveScriptSite))
|
|
|
|
{
|
2012-07-27 14:03:12 +02:00
|
|
|
IActiveScriptSite_AddRef(iface);
|
2012-11-14 23:08:14 +01:00
|
|
|
*obj = iface;
|
2007-05-01 03:54:43 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-14 23:08:14 +01:00
|
|
|
*obj = NULL;
|
2007-05-01 03:54:43 +02:00
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MsiActiveScriptSite_AddRef(IActiveScriptSite* iface)
|
|
|
|
{
|
2012-11-14 23:08:14 +01:00
|
|
|
MsiActiveScriptSite *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2022-02-07 17:47:05 +01:00
|
|
|
TRACE( "(%p)->(%lu)\n", This, ref );
|
2012-11-14 23:08:14 +01:00
|
|
|
return ref;
|
2007-05-01 03:54:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MsiActiveScriptSite_Release(IActiveScriptSite* iface)
|
|
|
|
{
|
2012-11-14 23:08:14 +01:00
|
|
|
MsiActiveScriptSite *This = impl_from_IActiveScriptSite(iface);
|
2007-05-01 03:54:43 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2022-02-07 17:47:05 +01:00
|
|
|
TRACE( "(%p)->(%lu)\n", This, ref );
|
2007-05-01 03:54:43 +02:00
|
|
|
|
|
|
|
if (!ref)
|
2010-05-20 12:01:50 +02:00
|
|
|
msi_free(This);
|
2007-05-01 03:54:43 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MsiActiveScriptSite_GetLCID(IActiveScriptSite* iface, LCID* plcid)
|
|
|
|
{
|
2012-11-14 23:08:14 +01:00
|
|
|
MsiActiveScriptSite *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, plcid);
|
2007-05-01 03:54:43 +02:00
|
|
|
return E_NOTIMPL; /* Script will use system-defined locale */
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MsiActiveScriptSite_GetItemInfo(IActiveScriptSite* iface, LPCOLESTR pstrName, DWORD dwReturnMask, IUnknown** ppiunkItem, ITypeInfo** ppti)
|
|
|
|
{
|
2012-11-14 23:08:14 +01:00
|
|
|
MsiActiveScriptSite *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
|
2022-02-07 17:47:05 +01:00
|
|
|
TRACE( "(%p)->(%p, %lu, %p, %p)\n", This, pstrName, dwReturnMask, ppiunkItem, ppti );
|
2007-05-01 03:54:43 +02:00
|
|
|
|
|
|
|
/* Determine the kind of pointer that is requested, and make sure placeholder is valid */
|
|
|
|
if (dwReturnMask & SCRIPTINFO_ITYPEINFO) {
|
2007-05-17 18:36:00 +02:00
|
|
|
if (!ppti) return E_INVALIDARG;
|
|
|
|
*ppti = NULL;
|
2007-05-01 03:54:43 +02:00
|
|
|
}
|
|
|
|
if (dwReturnMask & SCRIPTINFO_IUNKNOWN) {
|
2007-05-17 18:36:00 +02:00
|
|
|
if (!ppiunkItem) return E_INVALIDARG;
|
|
|
|
*ppiunkItem = NULL;
|
2007-05-01 03:54:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Are we looking for the session object? */
|
2020-10-29 11:47:14 +01:00
|
|
|
if (!wcscmp(L"Session", pstrName)) {
|
2012-11-14 05:45:02 +01:00
|
|
|
if (dwReturnMask & SCRIPTINFO_ITYPEINFO) {
|
|
|
|
HRESULT hr = get_typeinfo(Session_tid, ppti);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
ITypeInfo_AddRef(*ppti);
|
|
|
|
return hr;
|
|
|
|
}
|
2007-05-17 18:36:00 +02:00
|
|
|
else if (dwReturnMask & SCRIPTINFO_IUNKNOWN) {
|
2012-11-14 23:42:16 +01:00
|
|
|
IDispatch_QueryInterface(This->session, &IID_IUnknown, (void **)ppiunkItem);
|
2007-05-17 18:36:00 +02:00
|
|
|
return S_OK;
|
2007-05-01 03:54:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TYPE_E_ELEMENTNOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MsiActiveScriptSite_GetDocVersionString(IActiveScriptSite* iface, BSTR* pbstrVersion)
|
|
|
|
{
|
2012-11-14 23:08:14 +01:00
|
|
|
MsiActiveScriptSite *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, pbstrVersion);
|
2007-05-01 03:54:43 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MsiActiveScriptSite_OnScriptTerminate(IActiveScriptSite* iface, const VARIANT* pvarResult, const EXCEPINFO* pexcepinfo)
|
|
|
|
{
|
2012-11-14 23:08:14 +01:00
|
|
|
MsiActiveScriptSite *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
TRACE("(%p)->(%p, %p)\n", This, pvarResult, pexcepinfo);
|
2007-05-01 03:54:43 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MsiActiveScriptSite_OnStateChange(IActiveScriptSite* iface, SCRIPTSTATE ssScriptState)
|
|
|
|
{
|
|
|
|
switch (ssScriptState) {
|
2007-05-17 18:36:00 +02:00
|
|
|
case SCRIPTSTATE_UNINITIALIZED:
|
|
|
|
TRACE("State: Uninitialized.\n");
|
|
|
|
break;
|
2007-05-01 03:54:43 +02:00
|
|
|
|
2007-05-17 18:36:00 +02:00
|
|
|
case SCRIPTSTATE_INITIALIZED:
|
|
|
|
TRACE("State: Initialized.\n");
|
|
|
|
break;
|
2007-05-01 03:54:43 +02:00
|
|
|
|
2007-05-17 18:36:00 +02:00
|
|
|
case SCRIPTSTATE_STARTED:
|
|
|
|
TRACE("State: Started.\n");
|
|
|
|
break;
|
2007-05-01 03:54:43 +02:00
|
|
|
|
2007-05-17 18:36:00 +02:00
|
|
|
case SCRIPTSTATE_CONNECTED:
|
|
|
|
TRACE("State: Connected.\n");
|
|
|
|
break;
|
2007-05-01 03:54:43 +02:00
|
|
|
|
2007-05-17 18:36:00 +02:00
|
|
|
case SCRIPTSTATE_DISCONNECTED:
|
|
|
|
TRACE("State: Disconnected.\n");
|
|
|
|
break;
|
2007-05-01 03:54:43 +02:00
|
|
|
|
2007-05-17 18:36:00 +02:00
|
|
|
case SCRIPTSTATE_CLOSED:
|
|
|
|
TRACE("State: Closed.\n");
|
|
|
|
break;
|
2007-05-01 03:54:43 +02:00
|
|
|
|
2007-05-17 18:36:00 +02:00
|
|
|
default:
|
|
|
|
ERR("Unknown State: %d\n", ssScriptState);
|
|
|
|
break;
|
2007-05-01 03:54:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MsiActiveScriptSite_OnScriptError(IActiveScriptSite* iface, IActiveScriptError* pscripterror)
|
|
|
|
{
|
2012-11-14 23:08:14 +01:00
|
|
|
MsiActiveScriptSite *This = impl_from_IActiveScriptSite(iface);
|
2007-05-01 03:54:43 +02:00
|
|
|
EXCEPINFO exception;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2012-11-14 23:08:14 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, pscripterror);
|
2007-05-01 03:54:43 +02:00
|
|
|
|
2007-07-28 06:51:47 +02:00
|
|
|
memset(&exception, 0, sizeof(EXCEPINFO));
|
2007-05-01 03:54:43 +02:00
|
|
|
hr = IActiveScriptError_GetExceptionInfo(pscripterror, &exception);
|
|
|
|
if (SUCCEEDED(hr))
|
2007-07-28 06:51:47 +02:00
|
|
|
{
|
2007-05-17 18:36:00 +02:00
|
|
|
ERR("script error: %s\n", debugstr_w(exception.bstrDescription));
|
2007-07-28 06:51:47 +02:00
|
|
|
SysFreeString(exception.bstrSource);
|
|
|
|
SysFreeString(exception.bstrDescription);
|
|
|
|
SysFreeString(exception.bstrHelpFile);
|
|
|
|
}
|
2007-05-01 03:54:43 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MsiActiveScriptSite_OnEnterScript(IActiveScriptSite* iface)
|
|
|
|
{
|
2012-11-14 23:08:14 +01:00
|
|
|
MsiActiveScriptSite *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
2007-05-01 03:54:43 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MsiActiveScriptSite_OnLeaveScript(IActiveScriptSite* iface)
|
|
|
|
{
|
2012-11-14 23:08:14 +01:00
|
|
|
MsiActiveScriptSite *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
2007-05-01 03:54:43 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-14 23:08:14 +01:00
|
|
|
static const struct IActiveScriptSiteVtbl activescriptsitevtbl =
|
2007-05-01 03:54:43 +02:00
|
|
|
{
|
|
|
|
MsiActiveScriptSite_QueryInterface,
|
|
|
|
MsiActiveScriptSite_AddRef,
|
|
|
|
MsiActiveScriptSite_Release,
|
|
|
|
MsiActiveScriptSite_GetLCID,
|
|
|
|
MsiActiveScriptSite_GetItemInfo,
|
|
|
|
MsiActiveScriptSite_GetDocVersionString,
|
|
|
|
MsiActiveScriptSite_OnScriptTerminate,
|
|
|
|
MsiActiveScriptSite_OnStateChange,
|
|
|
|
MsiActiveScriptSite_OnScriptError,
|
|
|
|
MsiActiveScriptSite_OnEnterScript,
|
|
|
|
MsiActiveScriptSite_OnLeaveScript
|
|
|
|
};
|
2012-11-14 23:08:14 +01:00
|
|
|
|
2012-11-14 23:42:16 +01:00
|
|
|
static HRESULT create_activescriptsite(MsiActiveScriptSite **obj)
|
2012-11-14 23:08:14 +01:00
|
|
|
{
|
|
|
|
MsiActiveScriptSite* object;
|
|
|
|
|
2012-11-14 23:42:16 +01:00
|
|
|
TRACE("(%p)\n", obj);
|
2012-11-14 23:08:14 +01:00
|
|
|
|
2012-11-14 23:42:16 +01:00
|
|
|
*obj = NULL;
|
2012-11-14 23:08:14 +01:00
|
|
|
|
2012-11-14 23:32:47 +01:00
|
|
|
object = msi_alloc( sizeof(MsiActiveScriptSite) );
|
2012-11-14 23:42:16 +01:00
|
|
|
if (!object)
|
|
|
|
return E_OUTOFMEMORY;
|
2012-11-14 23:08:14 +01:00
|
|
|
|
|
|
|
object->IActiveScriptSite_iface.lpVtbl = &activescriptsitevtbl;
|
|
|
|
object->ref = 1;
|
2012-11-14 23:42:16 +01:00
|
|
|
object->installer = NULL;
|
|
|
|
object->session = NULL;
|
2012-11-14 23:08:14 +01:00
|
|
|
|
2012-11-14 23:42:16 +01:00
|
|
|
*obj = object;
|
2012-11-14 23:08:14 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-02 12:03:23 +02:00
|
|
|
static UINT map_return_value(LONG val)
|
|
|
|
{
|
|
|
|
switch (val)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case IDOK:
|
|
|
|
case IDIGNORE: return ERROR_SUCCESS;
|
|
|
|
case IDCANCEL: return ERROR_INSTALL_USEREXIT;
|
|
|
|
case IDRETRY: return ERROR_INSTALL_SUSPEND;
|
|
|
|
case IDABORT:
|
|
|
|
default: return ERROR_INSTALL_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-14 23:08:14 +01:00
|
|
|
/*
|
|
|
|
* Call a script.
|
|
|
|
*/
|
|
|
|
DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function, LPCWSTR action)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IActiveScript *pActiveScript = NULL;
|
|
|
|
IActiveScriptParse *pActiveScriptParse = NULL;
|
2012-11-14 23:42:16 +01:00
|
|
|
MsiActiveScriptSite *scriptsite;
|
2012-11-14 23:08:14 +01:00
|
|
|
IDispatch *pDispatch = NULL;
|
|
|
|
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
|
|
|
|
DISPID dispid;
|
|
|
|
CLSID clsid;
|
|
|
|
VARIANT var;
|
|
|
|
DWORD ret = ERROR_INSTALL_FAILURE;
|
|
|
|
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
|
|
|
/* Create MsiActiveScriptSite object */
|
2012-11-14 23:42:16 +01:00
|
|
|
hr = create_activescriptsite(&scriptsite);
|
2012-11-14 23:08:14 +01:00
|
|
|
if (hr != S_OK) goto done;
|
|
|
|
|
|
|
|
/* Create an installer object */
|
2012-11-14 23:42:16 +01:00
|
|
|
hr = create_msiserver(NULL, (void**)&scriptsite->installer);
|
2012-11-14 23:08:14 +01:00
|
|
|
if (hr != S_OK) goto done;
|
|
|
|
|
|
|
|
/* Create a session object */
|
2012-11-14 23:42:16 +01:00
|
|
|
hr = create_session(hPackage, scriptsite->installer, &scriptsite->session);
|
2012-11-14 23:08:14 +01:00
|
|
|
if (hr != S_OK) goto done;
|
|
|
|
|
|
|
|
/* Create the scripting engine */
|
2012-11-14 23:32:47 +01:00
|
|
|
type &= msidbCustomActionTypeJScript|msidbCustomActionTypeVBScript;
|
|
|
|
if (type == msidbCustomActionTypeJScript)
|
2020-10-29 11:47:14 +01:00
|
|
|
hr = CLSIDFromProgID(L"JScript", &clsid);
|
2012-11-14 23:32:47 +01:00
|
|
|
else if (type == msidbCustomActionTypeVBScript)
|
2020-10-29 11:47:14 +01:00
|
|
|
hr = CLSIDFromProgID(L"VBScript", &clsid);
|
2012-11-14 23:08:14 +01:00
|
|
|
else {
|
|
|
|
ERR("Unknown script type %d\n", type);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR("Could not find CLSID for Windows Script\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IActiveScript, (void **)&pActiveScript);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR("Could not instantiate class for Windows Script\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IActiveScript_QueryInterface(pActiveScript, &IID_IActiveScriptParse, (void **)&pActiveScriptParse);
|
|
|
|
if (FAILED(hr)) goto done;
|
|
|
|
|
2012-11-14 23:42:16 +01:00
|
|
|
hr = IActiveScript_SetScriptSite(pActiveScript, &scriptsite->IActiveScriptSite_iface);
|
2012-11-14 23:08:14 +01:00
|
|
|
if (FAILED(hr)) goto done;
|
|
|
|
|
|
|
|
hr = IActiveScriptParse_InitNew(pActiveScriptParse);
|
|
|
|
if (FAILED(hr)) goto done;
|
|
|
|
|
2020-10-29 11:47:14 +01:00
|
|
|
hr = IActiveScript_AddNamedItem(pActiveScript, L"Session", SCRIPTITEM_GLOBALMEMBERS|SCRIPTITEM_ISVISIBLE);
|
2012-11-14 23:08:14 +01:00
|
|
|
if (FAILED(hr)) goto done;
|
|
|
|
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(pActiveScriptParse, script, NULL, NULL, NULL, 0, 0, 0L, NULL, NULL);
|
|
|
|
if (FAILED(hr)) goto done;
|
|
|
|
|
|
|
|
hr = IActiveScript_SetScriptState(pActiveScript, SCRIPTSTATE_CONNECTED);
|
|
|
|
if (FAILED(hr)) goto done;
|
|
|
|
|
|
|
|
/* Call a function if necessary through the IDispatch interface */
|
2014-11-05 10:53:56 +01:00
|
|
|
if (function && function[0]) {
|
2012-11-14 23:08:14 +01:00
|
|
|
TRACE("Calling function %s\n", debugstr_w(function));
|
|
|
|
|
|
|
|
hr = IActiveScript_GetScriptDispatch(pActiveScript, NULL, &pDispatch);
|
|
|
|
if (FAILED(hr)) goto done;
|
|
|
|
|
|
|
|
hr = IDispatch_GetIDsOfNames(pDispatch, &IID_NULL, (WCHAR **)&function, 1,LOCALE_USER_DEFAULT, &dispid);
|
|
|
|
if (FAILED(hr)) goto done;
|
|
|
|
|
|
|
|
hr = IDispatch_Invoke(pDispatch, dispid, &IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparamsNoArgs, &var, NULL, NULL);
|
|
|
|
if (FAILED(hr)) goto done;
|
|
|
|
|
|
|
|
hr = VariantChangeType(&var, &var, 0, VT_I4);
|
|
|
|
if (FAILED(hr)) goto done;
|
|
|
|
|
2013-05-02 12:03:23 +02:00
|
|
|
ret = map_return_value(V_I4(&var));
|
2012-11-14 23:08:14 +01:00
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
} else {
|
|
|
|
/* If no function to be called, MSI behavior is to succeed */
|
|
|
|
ret = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
if (pDispatch) IDispatch_Release(pDispatch);
|
|
|
|
if (pActiveScript) IActiveScript_Release(pActiveScript);
|
|
|
|
if (pActiveScriptParse) IActiveScriptParse_Release(pActiveScriptParse);
|
2012-11-14 23:42:16 +01:00
|
|
|
if (scriptsite)
|
2012-11-14 23:08:14 +01:00
|
|
|
{
|
2012-11-14 23:42:16 +01:00
|
|
|
if (scriptsite->session) IDispatch_Release(scriptsite->session);
|
|
|
|
if (scriptsite->installer) IDispatch_Release(scriptsite->installer);
|
|
|
|
IActiveScriptSite_Release(&scriptsite->IActiveScriptSite_iface);
|
2012-11-14 23:08:14 +01:00
|
|
|
}
|
|
|
|
CoUninitialize(); /* must call even if CoInitialize failed */
|
|
|
|
return ret;
|
|
|
|
}
|