Commit 108d5927 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Use the right interface to call 32-bit and 64-bit custom action scripts.

parent bdaf2e98
...@@ -81,7 +81,8 @@ DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function ...@@ -81,7 +81,8 @@ DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function
{ {
HRESULT hr; HRESULT hr;
IActiveScript *pActiveScript = NULL; IActiveScript *pActiveScript = NULL;
IActiveScriptParse *pActiveScriptParse = NULL; IActiveScriptParse32 *pActiveScriptParse32 = NULL;
IActiveScriptParse64 *pActiveScriptParse64 = NULL;
MsiActiveScriptSite *pActiveScriptSite = NULL; MsiActiveScriptSite *pActiveScriptSite = NULL;
IDispatch *pDispatch = NULL; IDispatch *pDispatch = NULL;
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
...@@ -123,27 +124,41 @@ DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function ...@@ -123,27 +124,41 @@ DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function
goto done; goto done;
} }
/* Get the IActiveScriptParse engine interface */ if (type & msidbCustomActionType64BitScript)
hr = IActiveScript_QueryInterface(pActiveScript, &IID_IActiveScriptParse, (void **)&pActiveScriptParse); {
if (FAILED(hr)) goto done; 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);
hr = IActiveScript_SetScriptSite(pActiveScript, (IActiveScriptSite *)pActiveScriptSite); if (FAILED(hr)) goto done;
if (FAILED(hr)) goto done;
/* Initialize the script engine */ hr = IActiveScriptParse64_InitNew(pActiveScriptParse64);
hr = IActiveScriptParse64_InitNew(pActiveScriptParse); if (FAILED(hr)) goto done;
if (FAILED(hr)) goto done;
/* Add the session object */ hr = IActiveScript_AddNamedItem(pActiveScript, szSession, SCRIPTITEM_GLOBALMEMBERS);
hr = IActiveScript_AddNamedItem(pActiveScript, szSession, SCRIPTITEM_GLOBALMEMBERS); if (FAILED(hr)) goto done;
if (FAILED(hr)) goto done;
/* Pass the script to the engine */ hr = IActiveScriptParse64_ParseScriptText(pActiveScriptParse64, script, NULL, NULL, NULL, 0, 0, 0L, NULL, NULL);
hr = IActiveScriptParse64_ParseScriptText(pActiveScriptParse, script, NULL, NULL, NULL, 0, 0, 0L, NULL, NULL); if (FAILED(hr)) goto done;
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); hr = IActiveScript_SetScriptState(pActiveScript, SCRIPTSTATE_CONNECTED);
if (FAILED(hr)) goto done; if (FAILED(hr)) goto done;
...@@ -176,17 +191,17 @@ DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function ...@@ -176,17 +191,17 @@ DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function
done: done:
/* Free everything that needs to be freed */
if (pDispatch) IDispatch_Release(pDispatch); if (pDispatch) IDispatch_Release(pDispatch);
if (pActiveScript) IActiveScriptSite_Release(pActiveScript); if (pActiveScript) IActiveScript_Release(pActiveScript);
if (pActiveScriptSite && if (pActiveScriptParse32) IActiveScriptParse32_Release(pActiveScriptParse32);
pActiveScriptSite->pSession) IUnknown_Release((IUnknown *)pActiveScriptSite->pSession); if (pActiveScriptParse64) IActiveScriptParse64_Release(pActiveScriptParse64);
if (pActiveScriptSite && if (pActiveScriptSite)
pActiveScriptSite->pInstaller) IUnknown_Release((IUnknown *)pActiveScriptSite->pInstaller); {
if (pActiveScriptSite) IUnknown_Release((IUnknown *)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 */ CoUninitialize(); /* must call even if CoInitialize failed */
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment