Overloading script engine from IHTMLDocument::get_Script

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hi,

I want to know if (and how) it possible to override the methods of the
IDispatch pointer,
Or replace the script engine, which is retrieved by
IHTMLDocument::get_Script(IDispatch **p).


The target is to be able to do (pseudo code):

// Start ----------------------------------
//
MyNewScriptEngine::GetIDsOfNames(...)
{
if (methodName== "javaScriptA")
{
*dispid = 7777;
}
}

MyNewScriptEngine::Invoke(dispidParam, ...)
{
if (dispidParam == 7777)
{
// do nothing or change params of "javaScriptA", etc...
}
else
{
call the Invoke of original script engine.
}
}
//
// End -------------------------------------

So , when the html contains for example the following function:

// Start -----------------------------------
//
function javaScriptA(msg)
{
alert(msg);
}
//
// End -------------------------------------

I will be able block any calls to it, change values of parameters, etc.

Please note that I have no control of the html content, so I cannot
change the function
To be window.external.javaScriptA, and then process it by intercepting
GetExternal (IDocHostUIHandler)

One more thing - The way I use get_Script, is by:

// Start -----------------------------------
//
RegisterWindowMessage( _T("WM_HTML_GETOBJECT") );
....
SendMessageTimeout(hWndIE, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, &dwRes
);
....
ObjectFromLresult(dwRes, IID_IHTMLDocument, 0, (void**)&spDoc );
....
spDoc->get_Script(&lpScriptEngine);
//
// End -------------------------------------

Thanks for any help,
Si.

.