From 108d5927d005c0dec95f78bee3c5d7cbe0b94708 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Fri, 27 Jul 2012 14:02:22 +0200 Subject: [PATCH] msi: Use the right interface to call 32-bit and 64-bit custom action scripts. --- dlls/msi/script.c | 67 +++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/dlls/msi/script.c b/dlls/msi/script.c index 236b60b6049..4866630b587 100644 --- a/dlls/msi/script.c +++ b/dlls/msi/script.c @@ -81,7 +81,8 @@ DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function { HRESULT hr; IActiveScript *pActiveScript = NULL; - IActiveScriptParse *pActiveScriptParse = NULL; + IActiveScriptParse32 *pActiveScriptParse32 = NULL; + IActiveScriptParse64 *pActiveScriptParse64 = NULL; MsiActiveScriptSite *pActiveScriptSite = NULL; IDispatch *pDispatch = NULL; DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; @@ -123,27 +124,41 @@ DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function goto done; } - /* Get the IActiveScriptParse engine interface */ - hr = IActiveScript_QueryInterface(pActiveScript, &IID_IActiveScriptParse, (void **)&pActiveScriptParse); - if (FAILED(hr)) goto done; + if (type & msidbCustomActionType64BitScript) + { + hr = IActiveScript_QueryInterface(pActiveScript, &IID_IActiveScriptParse64, (void **)&pActiveScriptParse64); + if (FAILED(hr)) goto done; - /* Give our host to the engine */ - hr = IActiveScript_SetScriptSite(pActiveScript, (IActiveScriptSite *)pActiveScriptSite); - if (FAILED(hr)) goto done; + hr = IActiveScript_SetScriptSite(pActiveScript, (IActiveScriptSite *)pActiveScriptSite); + if (FAILED(hr)) goto done; - /* Initialize the script engine */ - hr = IActiveScriptParse64_InitNew(pActiveScriptParse); - if (FAILED(hr)) goto done; + hr = IActiveScriptParse64_InitNew(pActiveScriptParse64); + if (FAILED(hr)) goto done; - /* Add the session object */ - hr = IActiveScript_AddNamedItem(pActiveScript, szSession, SCRIPTITEM_GLOBALMEMBERS); - if (FAILED(hr)) goto done; + hr = IActiveScript_AddNamedItem(pActiveScript, szSession, SCRIPTITEM_GLOBALMEMBERS); + if (FAILED(hr)) goto done; - /* Pass the script to the engine */ - hr = IActiveScriptParse64_ParseScriptText(pActiveScriptParse, script, NULL, NULL, NULL, 0, 0, 0L, NULL, NULL); - if (FAILED(hr)) goto done; + hr = IActiveScriptParse64_ParseScriptText(pActiveScriptParse64, script, NULL, NULL, NULL, 0, 0, 0L, NULL, NULL); + if (FAILED(hr)) goto done; + } + else + { + hr = IActiveScript_QueryInterface(pActiveScript, &IID_IActiveScriptParse32, (void **)&pActiveScriptParse32); + if (FAILED(hr)) goto done; + + hr = IActiveScript_SetScriptSite(pActiveScript, (IActiveScriptSite *)pActiveScriptSite); + if (FAILED(hr)) goto done; + + hr = IActiveScriptParse32_InitNew(pActiveScriptParse32); + if (FAILED(hr)) goto done; + + hr = IActiveScript_AddNamedItem(pActiveScript, szSession, SCRIPTITEM_GLOBALMEMBERS); + if (FAILED(hr)) goto done; + + hr = IActiveScriptParse32_ParseScriptText(pActiveScriptParse32, script, NULL, NULL, NULL, 0, 0, 0L, NULL, NULL); + if (FAILED(hr)) goto done; + } - /* Start processing the script */ hr = IActiveScript_SetScriptState(pActiveScript, SCRIPTSTATE_CONNECTED); if (FAILED(hr)) goto done; @@ -176,17 +191,17 @@ DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function done: - /* Free everything that needs to be freed */ if (pDispatch) IDispatch_Release(pDispatch); - if (pActiveScript) IActiveScriptSite_Release(pActiveScript); - if (pActiveScriptSite && - pActiveScriptSite->pSession) IUnknown_Release((IUnknown *)pActiveScriptSite->pSession); - if (pActiveScriptSite && - pActiveScriptSite->pInstaller) IUnknown_Release((IUnknown *)pActiveScriptSite->pInstaller); - if (pActiveScriptSite) IUnknown_Release((IUnknown *)pActiveScriptSite); - + if (pActiveScript) IActiveScript_Release(pActiveScript); + if (pActiveScriptParse32) IActiveScriptParse32_Release(pActiveScriptParse32); + if (pActiveScriptParse64) IActiveScriptParse64_Release(pActiveScriptParse64); + if (pActiveScriptSite) + { + if (pActiveScriptSite->pSession) IDispatch_Release(pActiveScriptSite->pSession); + if (pActiveScriptSite->pInstaller) IDispatch_Release(pActiveScriptSite->pInstaller); + IActiveScriptSite_Release((IActiveScriptSite *)pActiveScriptSite); + } CoUninitialize(); /* must call even if CoInitialize failed */ - return ret; }