2017-01-26 22:36:08 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Nikolay Sivov
|
2019-09-20 16:23:15 +02:00
|
|
|
* Copyright 2019 Jacek Caban for CodeWeavers
|
2017-01-26 22:36:08 +01:00
|
|
|
*
|
|
|
|
* 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 "ole2.h"
|
|
|
|
#include "olectl.h"
|
|
|
|
#include "rpcproxy.h"
|
2019-09-20 16:23:29 +02:00
|
|
|
#include "activscp.h"
|
2019-09-23 17:54:53 +02:00
|
|
|
#include "dispex.h"
|
2019-09-20 16:24:04 +02:00
|
|
|
#include "mshtmhst.h"
|
2017-01-26 22:36:08 +01:00
|
|
|
|
2017-01-26 22:36:10 +01:00
|
|
|
#include "initguid.h"
|
|
|
|
#include "scrobj.h"
|
2019-09-19 17:28:44 +02:00
|
|
|
#include "xmllite.h"
|
2019-09-19 17:28:25 +02:00
|
|
|
|
2017-01-26 22:36:08 +01:00
|
|
|
#include "wine/debug.h"
|
2019-09-19 17:28:25 +02:00
|
|
|
#include "wine/heap.h"
|
2019-09-20 16:22:39 +02:00
|
|
|
#include "wine/list.h"
|
2017-01-26 22:36:08 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(scrobj);
|
|
|
|
|
2019-09-20 16:24:04 +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
|
|
|
|
|
2017-01-26 22:36:08 +01:00
|
|
|
static HINSTANCE scrobj_instance;
|
|
|
|
|
2019-09-20 16:22:39 +02:00
|
|
|
struct scriptlet_member
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
WCHAR *name;
|
|
|
|
struct list parameters;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct method_parameter
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
WCHAR *name;
|
|
|
|
};
|
|
|
|
|
2019-09-20 16:22:49 +02:00
|
|
|
struct scriptlet_script
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
WCHAR *language;
|
|
|
|
WCHAR *body;
|
|
|
|
};
|
|
|
|
|
2019-09-23 17:55:25 +02:00
|
|
|
struct scriptlet_global
|
|
|
|
{
|
|
|
|
IDispatchEx IDispatchEx_iface;
|
|
|
|
LONG ref;
|
|
|
|
};
|
|
|
|
|
2019-09-19 17:28:25 +02:00
|
|
|
struct scriptlet_factory
|
|
|
|
{
|
|
|
|
IClassFactory IClassFactory_iface;
|
2019-09-19 17:28:44 +02:00
|
|
|
|
2019-09-19 17:28:25 +02:00
|
|
|
LONG ref;
|
2019-09-19 17:28:44 +02:00
|
|
|
|
|
|
|
IXmlReader *xml_reader;
|
|
|
|
IMoniker *moniker;
|
2019-09-19 17:28:54 +02:00
|
|
|
|
|
|
|
BOOL have_registration;
|
2019-09-20 16:22:39 +02:00
|
|
|
BOOL have_public;
|
2019-09-19 17:28:54 +02:00
|
|
|
WCHAR *description;
|
|
|
|
WCHAR *progid;
|
|
|
|
WCHAR *versioned_progid;
|
|
|
|
WCHAR *version;
|
|
|
|
WCHAR *classid_str;
|
|
|
|
CLSID classid;
|
2019-09-20 16:22:39 +02:00
|
|
|
|
2019-09-20 16:23:29 +02:00
|
|
|
struct list hosts;
|
2019-09-20 16:22:39 +02:00
|
|
|
struct list members;
|
2019-09-20 16:22:49 +02:00
|
|
|
struct list scripts;
|
2019-09-19 17:28:25 +02:00
|
|
|
};
|
|
|
|
|
2019-09-23 17:54:53 +02:00
|
|
|
struct scriptlet_instance
|
|
|
|
{
|
|
|
|
IDispatchEx IDispatchEx_iface;
|
|
|
|
LONG ref;
|
2019-09-23 17:55:13 +02:00
|
|
|
struct list hosts;
|
2019-09-23 17:55:25 +02:00
|
|
|
struct scriptlet_global *global;
|
2019-09-23 17:54:53 +02:00
|
|
|
};
|
|
|
|
|
2019-09-20 16:23:29 +02:00
|
|
|
struct script_host
|
|
|
|
{
|
|
|
|
IActiveScriptSite IActiveScriptSite_iface;
|
2019-09-20 16:23:36 +02:00
|
|
|
IActiveScriptSiteWindow IActiveScriptSiteWindow_iface;
|
2019-09-20 16:23:46 +02:00
|
|
|
IServiceProvider IServiceProvider_iface;
|
2019-09-20 16:24:04 +02:00
|
|
|
|
2019-09-20 16:23:29 +02:00
|
|
|
LONG ref;
|
|
|
|
struct list entry;
|
2019-09-20 16:24:04 +02:00
|
|
|
|
2019-09-20 16:23:29 +02:00
|
|
|
WCHAR *language;
|
2019-09-20 16:24:04 +02:00
|
|
|
|
|
|
|
IActiveScript *active_script;
|
|
|
|
IActiveScriptParse *parser;
|
2019-09-23 17:55:25 +02:00
|
|
|
struct scriptlet_instance *object;
|
2019-09-23 17:55:04 +02:00
|
|
|
SCRIPTSTATE state;
|
2019-09-20 16:24:04 +02:00
|
|
|
BOOL cloned;
|
2019-09-20 16:23:29 +02:00
|
|
|
};
|
|
|
|
|
2017-01-26 22:36:11 +01:00
|
|
|
typedef enum tid_t
|
|
|
|
{
|
|
|
|
NULL_tid,
|
|
|
|
IGenScriptletTLib_tid,
|
|
|
|
LAST_tid
|
|
|
|
} tid_t;
|
|
|
|
|
|
|
|
static ITypeLib *typelib;
|
|
|
|
static ITypeInfo *typeinfos[LAST_tid];
|
|
|
|
|
|
|
|
static REFIID tid_ids[] = {
|
|
|
|
&IID_NULL,
|
|
|
|
&IID_IGenScriptletTLib,
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT load_typelib(void)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
ITypeLib *tl;
|
|
|
|
|
|
|
|
if (typelib)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
hres = LoadRegTypeLib(&LIBID_Scriptlet, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
ERR("LoadRegTypeLib failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (InterlockedCompareExchangePointer((void **)&typelib, tl, NULL))
|
|
|
|
ITypeLib_Release(tl);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (FAILED(hres = load_typelib()))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if (!typeinfos[tid])
|
|
|
|
{
|
|
|
|
ITypeInfo *ti;
|
|
|
|
|
|
|
|
hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
|
|
|
|
if (FAILED(hres)) {
|
|
|
|
ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (InterlockedCompareExchangePointer((void **)(typeinfos+tid), ti, NULL))
|
|
|
|
ITypeInfo_Release(ti);
|
|
|
|
}
|
|
|
|
|
|
|
|
*typeinfo = typeinfos[tid];
|
|
|
|
ITypeInfo_AddRef(typeinfos[tid]);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void release_typelib(void)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
if (!typelib)
|
|
|
|
return;
|
|
|
|
|
2018-07-26 00:05:53 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(typeinfos); i++)
|
2017-01-26 22:36:11 +01:00
|
|
|
if (typeinfos[i])
|
|
|
|
ITypeInfo_Release(typeinfos[i]);
|
|
|
|
|
|
|
|
ITypeLib_Release(typelib);
|
|
|
|
}
|
|
|
|
|
2019-09-20 16:23:29 +02:00
|
|
|
static WCHAR *heap_strdupW(const WCHAR *str)
|
|
|
|
{
|
|
|
|
WCHAR *ret;
|
|
|
|
size_t size = (wcslen(str) + 1) * sizeof(WCHAR);
|
|
|
|
if (!(ret = heap_alloc(size))) return NULL;
|
|
|
|
memcpy(ret, str, size);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-09-23 17:55:25 +02:00
|
|
|
static inline struct scriptlet_global *global_from_IDispatchEx(IDispatchEx *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct scriptlet_global, IDispatchEx_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
|
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IDispatchEx_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&IID_IDispatch, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IDispatchEx_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&IID_IDispatchEx, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IDispatchEx_iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI global_AddRef(IDispatchEx *iface)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI global_Release(IDispatchEx *iface)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref) heap_free(This);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
UINT i;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
|
|
|
|
|
|
|
|
for(i=0; i < cNames; i++)
|
|
|
|
{
|
|
|
|
hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId + i);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_Invoke(IDispatchEx *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags,
|
|
|
|
pDispParams, pVarResult, pExcepInfo, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
|
|
|
|
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%x)\n", This, id);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%x %p)\n", This, id, pbstrName);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI global_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
|
|
|
|
{
|
|
|
|
struct scriptlet_global *This = global_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, ppunk);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IDispatchExVtbl global_vtbl = {
|
|
|
|
global_QueryInterface,
|
|
|
|
global_AddRef,
|
|
|
|
global_Release,
|
|
|
|
global_GetTypeInfoCount,
|
|
|
|
global_GetTypeInfo,
|
|
|
|
global_GetIDsOfNames,
|
|
|
|
global_Invoke,
|
|
|
|
global_GetDispID,
|
|
|
|
global_InvokeEx,
|
|
|
|
global_DeleteMemberByName,
|
|
|
|
global_DeleteMemberByDispID,
|
|
|
|
global_GetMemberProperties,
|
|
|
|
global_GetMemberName,
|
|
|
|
global_GetNextDispID,
|
|
|
|
global_GetNameSpaceParent
|
|
|
|
};
|
|
|
|
|
2019-09-23 17:55:04 +02:00
|
|
|
static HRESULT set_script_state(struct script_host *host, SCRIPTSTATE state)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
if (state == host->state) return S_OK;
|
|
|
|
hres = IActiveScript_SetScriptState(host->active_script, state);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
host->state = state;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-20 16:23:29 +02:00
|
|
|
static inline struct script_host *impl_from_IActiveScriptSite(IActiveScriptSite *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct script_host, IActiveScriptSite_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
|
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IActiveScriptSite_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&IID_IActiveScriptSite, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IActiveScriptSite %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IActiveScriptSite_iface;
|
|
|
|
}
|
2019-09-20 16:23:36 +02:00
|
|
|
else if (IsEqualGUID(&IID_IActiveScriptSiteWindow, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IActiveScriptSiteWindow %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IActiveScriptSiteWindow_iface;
|
|
|
|
}
|
2019-09-20 16:23:46 +02:00
|
|
|
else if(IsEqualGUID(&IID_IServiceProvider, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IServiceProvider_iface;
|
|
|
|
}
|
2019-09-20 16:23:29 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ActiveScriptSite_AddRef(IActiveScriptSite *iface)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
heap_free(This->language);
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_GetLCID(IActiveScriptSite *iface, LCID *lcid)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", This, lcid);
|
|
|
|
|
|
|
|
*lcid = GetUserDefaultLCID();
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR name, DWORD mask,
|
|
|
|
IUnknown **unk, ITypeInfo **ti)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSite(iface);
|
2019-09-23 17:55:25 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %s, %#x, %p, %p)\n", This, debugstr_w(name), mask, unk, ti);
|
|
|
|
|
|
|
|
if (mask != SCRIPTINFO_IUNKNOWN)
|
|
|
|
{
|
|
|
|
FIXME("mask %x not supported\n", mask);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wcscmp(name, L"scriptlet") && wcscmp(name, L"globals"))
|
|
|
|
{
|
|
|
|
FIXME("%s not supported\n", debugstr_w(name));
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!This->object) return E_UNEXPECTED;
|
|
|
|
|
|
|
|
*unk = (IUnknown *)&This->object->global->IDispatchEx_iface;
|
|
|
|
IUnknown_AddRef(*unk);
|
|
|
|
return S_OK;
|
2019-09-20 16:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *version)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
FIXME("(%p, %p)\n", This, version);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface, const VARIANT *result,
|
|
|
|
const EXCEPINFO *ei)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
FIXME("(%p, %s, %p)\n", This, debugstr_variant(result), ei);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE state)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
TRACE("(%p, %d)\n", This, state);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *script_error)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
FIXME("(%p, %p)\n", This, script_error);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSite(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl = {
|
|
|
|
ActiveScriptSite_QueryInterface,
|
|
|
|
ActiveScriptSite_AddRef,
|
|
|
|
ActiveScriptSite_Release,
|
|
|
|
ActiveScriptSite_GetLCID,
|
|
|
|
ActiveScriptSite_GetItemInfo,
|
|
|
|
ActiveScriptSite_GetDocVersionString,
|
|
|
|
ActiveScriptSite_OnScriptTerminate,
|
|
|
|
ActiveScriptSite_OnStateChange,
|
|
|
|
ActiveScriptSite_OnScriptError,
|
|
|
|
ActiveScriptSite_OnEnterScript,
|
|
|
|
ActiveScriptSite_OnLeaveScript
|
|
|
|
};
|
|
|
|
|
2019-09-20 16:23:36 +02:00
|
|
|
static inline struct script_host *impl_from_IActiveScriptSiteWindow(IActiveScriptSiteWindow *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct script_host, IActiveScriptSiteWindow_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSiteWindow_QueryInterface(IActiveScriptSiteWindow *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSiteWindow(iface);
|
|
|
|
return IActiveScriptSite_QueryInterface(&This->IActiveScriptSite_iface, riid, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ActiveScriptSiteWindow_AddRef(IActiveScriptSiteWindow *iface)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSiteWindow(iface);
|
|
|
|
return IActiveScriptSite_AddRef(&This->IActiveScriptSite_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ActiveScriptSiteWindow_Release(IActiveScriptSiteWindow *iface)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSiteWindow(iface);
|
|
|
|
return IActiveScriptSite_Release(&This->IActiveScriptSite_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSiteWindow_GetWindow(IActiveScriptSiteWindow *iface, HWND *hwnd)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSiteWindow(iface);
|
|
|
|
FIXME("(%p, %p)\n", This, hwnd);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSiteWindow_EnableModeless(IActiveScriptSiteWindow *iface, BOOL enable)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IActiveScriptSiteWindow(iface);
|
|
|
|
FIXME("(%p, %d)\n", This, enable);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IActiveScriptSiteWindowVtbl ActiveScriptSiteWindowVtbl = {
|
|
|
|
ActiveScriptSiteWindow_QueryInterface,
|
|
|
|
ActiveScriptSiteWindow_AddRef,
|
|
|
|
ActiveScriptSiteWindow_Release,
|
|
|
|
ActiveScriptSiteWindow_GetWindow,
|
|
|
|
ActiveScriptSiteWindow_EnableModeless
|
|
|
|
};
|
|
|
|
|
2019-09-20 16:23:46 +02:00
|
|
|
static inline struct script_host *impl_from_IServiceProvider(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct script_host, IServiceProvider_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IServiceProvider(iface);
|
|
|
|
return IActiveScriptSite_QueryInterface(&This->IActiveScriptSite_iface, riid, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IServiceProvider(iface);
|
|
|
|
return IActiveScriptSite_AddRef(&This->IActiveScriptSite_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IServiceProvider(iface);
|
|
|
|
return IActiveScriptSite_Release(&This->IActiveScriptSite_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID service,
|
|
|
|
REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct script_host *This = impl_from_IServiceProvider(iface);
|
|
|
|
FIXME("(%p)->(%s %s %p)\n", This, debugstr_guid(service), debugstr_guid(riid), obj);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IServiceProviderVtbl ServiceProviderVtbl = {
|
|
|
|
ServiceProvider_QueryInterface,
|
|
|
|
ServiceProvider_AddRef,
|
|
|
|
ServiceProvider_Release,
|
|
|
|
ServiceProvider_QueryService
|
|
|
|
};
|
|
|
|
|
2019-09-20 16:23:29 +02:00
|
|
|
static struct script_host *find_script_host(struct list *hosts, const WCHAR *language)
|
|
|
|
{
|
|
|
|
struct script_host *host;
|
|
|
|
LIST_FOR_EACH_ENTRY(host, hosts, struct script_host, entry)
|
|
|
|
{
|
|
|
|
if (!wcscmp(host->language, language)) return host;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-09-23 17:55:04 +02:00
|
|
|
static HRESULT parse_scripts(struct scriptlet_factory *factory, struct list *hosts, BOOL start)
|
|
|
|
{
|
|
|
|
DWORD parse_flags = SCRIPTTEXT_ISVISIBLE;
|
|
|
|
struct scriptlet_script *script;
|
|
|
|
struct script_host *host;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (!start) parse_flags |= SCRIPTITEM_ISPERSISTENT;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(script, &factory->scripts, struct scriptlet_script, entry)
|
|
|
|
{
|
|
|
|
host = find_script_host(hosts, script->language);
|
|
|
|
|
|
|
|
if (start && host->state != SCRIPTSTATE_STARTED)
|
|
|
|
{
|
|
|
|
hres = set_script_state(host, SCRIPTSTATE_STARTED);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (host->cloned) continue;
|
|
|
|
|
|
|
|
hres = IActiveScriptParse_ParseScriptText(host->parser, script->body, NULL, NULL, NULL, 0, 0 /* FIXME */,
|
|
|
|
parse_flags, NULL, NULL);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
WARN("ParseScriptText failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!start)
|
|
|
|
{
|
|
|
|
LIST_FOR_EACH_ENTRY(host, hosts, struct script_host, entry)
|
|
|
|
{
|
|
|
|
if (host->state != SCRIPTSTATE_UNINITIALIZED)
|
|
|
|
set_script_state(host, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-20 16:24:04 +02:00
|
|
|
static HRESULT init_script_host(struct script_host *host, IActiveScript *clone)
|
2019-09-20 16:23:29 +02:00
|
|
|
{
|
2019-09-20 16:24:04 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (!clone)
|
|
|
|
{
|
|
|
|
IClassFactoryEx *factory_ex;
|
|
|
|
IClassFactory *factory;
|
|
|
|
IUnknown *unk;
|
|
|
|
CLSID clsid;
|
|
|
|
|
|
|
|
if (FAILED(hres = CLSIDFromProgID(host->language, &clsid)))
|
|
|
|
{
|
|
|
|
WARN("Could not find script engine for %s\n", debugstr_w(host->language));
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, NULL,
|
|
|
|
&IID_IClassFactory, (void**)&factory);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
|
|
|
|
hres = IClassFactory_QueryInterface(factory, &IID_IClassFactoryEx, (void**)&factory_ex);
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
FIXME("Use IClassFactoryEx\n");
|
|
|
|
IClassFactoryEx_Release(factory_ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IClassFactory_CreateInstance(factory, NULL, &IID_IUnknown, (void**)&unk);
|
|
|
|
IClassFactory_Release(factory);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IActiveScript, (void**)&host->active_script);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IActiveScript_AddRef(clone);
|
|
|
|
host->active_script = clone;
|
|
|
|
host->cloned = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(host->active_script, &IID_IActiveScriptParse, (void**)&host->parser);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
|
|
|
|
if (!clone)
|
|
|
|
{
|
|
|
|
hres = IActiveScriptParse_InitNew(host->parser);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
IActiveScriptParse_Release(host->parser);
|
|
|
|
host->parser = NULL;
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return IActiveScript_SetScriptSite(host->active_script, &host->IActiveScriptSite_iface);
|
|
|
|
}
|
|
|
|
|
2019-09-23 17:55:25 +02:00
|
|
|
static HRESULT create_script_host(const WCHAR *language, IActiveScript *origin_script, struct list *hosts, struct script_host **ret)
|
2019-09-20 16:24:04 +02:00
|
|
|
{
|
|
|
|
IActiveScript *clone = NULL;
|
2019-09-20 16:23:29 +02:00
|
|
|
struct script_host *host;
|
2019-09-20 16:24:04 +02:00
|
|
|
HRESULT hres;
|
2019-09-20 16:23:29 +02:00
|
|
|
|
|
|
|
if (!(host = heap_alloc_zero(sizeof(*host)))) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
host->IActiveScriptSite_iface.lpVtbl = &ActiveScriptSiteVtbl;
|
2019-09-20 16:23:36 +02:00
|
|
|
host->IActiveScriptSiteWindow_iface.lpVtbl = &ActiveScriptSiteWindowVtbl;
|
2019-09-20 16:23:46 +02:00
|
|
|
host->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
|
2019-09-20 16:23:29 +02:00
|
|
|
host->ref = 1;
|
2019-09-23 17:55:04 +02:00
|
|
|
host->state = SCRIPTSTATE_CLOSED;
|
2019-09-20 16:23:29 +02:00
|
|
|
|
|
|
|
if (!(host->language = heap_strdupW(language)))
|
|
|
|
{
|
|
|
|
IActiveScriptSite_Release(&host->IActiveScriptSite_iface);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2019-09-20 16:24:04 +02:00
|
|
|
if (origin_script)
|
|
|
|
{
|
|
|
|
hres = IActiveScript_Clone(origin_script, &clone);
|
|
|
|
if (FAILED(hres)) clone = NULL;
|
|
|
|
}
|
|
|
|
|
2019-09-20 16:23:29 +02:00
|
|
|
list_add_tail(hosts, &host->entry);
|
2019-09-20 16:24:04 +02:00
|
|
|
hres = init_script_host(host, clone);
|
|
|
|
if (clone) IActiveScript_Release(clone);
|
2019-09-23 17:55:25 +02:00
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
if (ret) *ret = host;
|
|
|
|
return S_OK;
|
2019-09-20 16:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void detach_script_hosts(struct list *hosts)
|
|
|
|
{
|
|
|
|
while (!list_empty(hosts))
|
|
|
|
{
|
|
|
|
struct script_host *host = LIST_ENTRY(list_head(hosts), struct script_host, entry);
|
2019-09-23 17:55:04 +02:00
|
|
|
if (host->state != SCRIPTSTATE_UNINITIALIZED) set_script_state(host, SCRIPTSTATE_UNINITIALIZED);
|
2019-09-20 16:23:29 +02:00
|
|
|
list_remove(&host->entry);
|
2019-09-23 17:55:25 +02:00
|
|
|
host->object = NULL;
|
2019-09-20 16:24:04 +02:00
|
|
|
if (host->parser)
|
|
|
|
{
|
|
|
|
IActiveScript_Close(host->active_script);
|
|
|
|
IActiveScriptParse_Release(host->parser);
|
|
|
|
host->parser = NULL;
|
|
|
|
}
|
|
|
|
if (host->active_script)
|
|
|
|
{
|
|
|
|
IActiveScript_Release(host->active_script);
|
|
|
|
host->active_script = NULL;
|
|
|
|
}
|
2019-09-20 16:23:29 +02:00
|
|
|
IActiveScriptSite_Release(&host->IActiveScriptSite_iface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT create_scriptlet_hosts(struct scriptlet_factory *factory, struct list *hosts)
|
|
|
|
{
|
|
|
|
struct scriptlet_script *script;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(script, &factory->scripts, struct scriptlet_script, entry)
|
|
|
|
{
|
|
|
|
if (find_script_host(hosts, script->language)) continue;
|
2019-09-23 17:55:25 +02:00
|
|
|
hres = create_script_host(script->language, NULL, hosts, NULL);
|
2019-09-20 16:23:29 +02:00
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
detach_script_hosts(hosts);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
2019-09-23 17:54:53 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct scriptlet_instance *impl_from_IDispatchEx(IDispatchEx *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct scriptlet_instance, IDispatchEx_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
|
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IDispatchEx_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&IID_IDispatch, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IDispatchEx_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&IID_IDispatchEx, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IDispatchEx_iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI scriptlet_AddRef(IDispatchEx *iface)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI scriptlet_Release(IDispatchEx *iface)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref)
|
2019-09-23 17:55:13 +02:00
|
|
|
{
|
|
|
|
detach_script_hosts(&This->hosts);
|
2019-09-23 17:55:25 +02:00
|
|
|
if (This->global) IDispatchEx_Release(&This->global->IDispatchEx_iface);
|
2019-09-23 17:54:53 +02:00
|
|
|
heap_free(This);
|
2019-09-23 17:55:13 +02:00
|
|
|
}
|
2019-09-23 17:54:53 +02:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
UINT i;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
|
|
|
|
|
|
|
for(i=0; i < cNames; i++)
|
|
|
|
{
|
|
|
|
hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId + i);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_Invoke(IDispatchEx *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags,
|
|
|
|
pDispParams, pVarResult, pExcepInfo, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *pdp,
|
|
|
|
VARIANT *res, EXCEPINFO *pei, IServiceProvider *caller)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, pdp, res, pei, caller);
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%x)\n", This, id);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%x %p)\n", This, id, pbstrName);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
|
|
|
|
{
|
|
|
|
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, ppunk);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IDispatchExVtbl DispatchExVtbl = {
|
|
|
|
scriptlet_QueryInterface,
|
|
|
|
scriptlet_AddRef,
|
|
|
|
scriptlet_Release,
|
|
|
|
scriptlet_GetTypeInfoCount,
|
|
|
|
scriptlet_GetTypeInfo,
|
|
|
|
scriptlet_GetIDsOfNames,
|
|
|
|
scriptlet_Invoke,
|
|
|
|
scriptlet_GetDispID,
|
|
|
|
scriptlet_InvokeEx,
|
|
|
|
scriptlet_DeleteMemberByName,
|
|
|
|
scriptlet_DeleteMemberByDispID,
|
|
|
|
scriptlet_GetMemberProperties,
|
|
|
|
scriptlet_GetMemberName,
|
|
|
|
scriptlet_GetNextDispID,
|
|
|
|
scriptlet_GetNameSpaceParent
|
|
|
|
};
|
|
|
|
|
2019-09-23 17:55:13 +02:00
|
|
|
static HRESULT create_scriptlet_instance(struct scriptlet_factory *factory, IDispatchEx **disp)
|
2019-09-23 17:54:53 +02:00
|
|
|
{
|
2019-09-23 17:55:25 +02:00
|
|
|
struct script_host *factory_host, *host;
|
2019-09-23 17:54:53 +02:00
|
|
|
struct scriptlet_instance *obj;
|
2019-09-23 17:55:13 +02:00
|
|
|
HRESULT hres;
|
2019-09-23 17:54:53 +02:00
|
|
|
|
|
|
|
if (!(obj = heap_alloc(sizeof(*obj)))) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
obj->IDispatchEx_iface.lpVtbl = &DispatchExVtbl;
|
|
|
|
obj->ref = 1;
|
2019-09-23 17:55:13 +02:00
|
|
|
list_init(&obj->hosts);
|
|
|
|
|
2019-09-23 17:55:25 +02:00
|
|
|
if (!(obj->global = heap_alloc(sizeof(*obj->global))))
|
|
|
|
{
|
|
|
|
IDispatchEx_Release(&obj->IDispatchEx_iface);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
obj->global->IDispatchEx_iface.lpVtbl = &global_vtbl;
|
|
|
|
obj->global->ref = 1;
|
|
|
|
|
2019-09-23 17:55:13 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(factory_host, &factory->hosts, struct script_host, entry)
|
|
|
|
{
|
2019-09-23 17:55:25 +02:00
|
|
|
hres = create_script_host(factory_host->language, factory_host->active_script, &obj->hosts, &host);
|
2019-09-23 17:55:13 +02:00
|
|
|
if (FAILED(hres)) break;
|
2019-09-23 17:55:25 +02:00
|
|
|
host->object = obj;
|
2019-09-23 17:55:40 +02:00
|
|
|
|
|
|
|
hres = IActiveScript_AddNamedItem(host->active_script, L"scriptlet",
|
|
|
|
SCRIPTITEM_ISVISIBLE | SCRIPTITEM_GLOBALMEMBERS);
|
|
|
|
if (FAILED(hres)) break;
|
|
|
|
|
|
|
|
hres = IActiveScript_AddNamedItem(host->active_script, L"globals", SCRIPTITEM_ISVISIBLE);
|
|
|
|
if (FAILED(hres)) break;
|
2019-09-23 17:55:13 +02:00
|
|
|
}
|
|
|
|
|
2019-09-23 17:55:40 +02:00
|
|
|
if (SUCCEEDED(hres)) hres = parse_scripts(factory, &obj->hosts, TRUE);
|
2019-09-23 17:55:13 +02:00
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
IDispatchEx_Release(&obj->IDispatchEx_iface);
|
|
|
|
return hres;
|
|
|
|
}
|
2019-09-23 17:54:53 +02:00
|
|
|
|
|
|
|
*disp = &obj->IDispatchEx_iface;
|
2019-09-20 16:23:29 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-19 17:28:44 +02:00
|
|
|
static const char *debugstr_xml_name(struct scriptlet_factory *factory)
|
|
|
|
{
|
|
|
|
const WCHAR *str;
|
|
|
|
UINT len;
|
|
|
|
HRESULT hres;
|
|
|
|
hres = IXmlReader_GetLocalName(factory->xml_reader, &str, &len);
|
|
|
|
if (FAILED(hres)) return "#err";
|
|
|
|
return debugstr_wn(str, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT next_xml_node(struct scriptlet_factory *factory, XmlNodeType *node_type)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
do hres = IXmlReader_Read(factory->xml_reader, node_type);
|
|
|
|
while (hres == S_OK && *node_type == XmlNodeType_Whitespace);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_xml_name(struct scriptlet_factory *factory, const WCHAR *name)
|
|
|
|
{
|
|
|
|
const WCHAR *qname;
|
|
|
|
UINT len;
|
|
|
|
HRESULT hres;
|
|
|
|
hres = IXmlReader_GetQualifiedName(factory->xml_reader, &qname, &len);
|
|
|
|
return hres == S_OK && len == wcslen(name) && !memcmp(qname, name, len * sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
|
2019-09-19 17:28:54 +02:00
|
|
|
static HRESULT expect_end_element(struct scriptlet_factory *factory)
|
|
|
|
{
|
|
|
|
XmlNodeType node_type;
|
|
|
|
HRESULT hres;
|
|
|
|
hres = next_xml_node(factory, &node_type);
|
|
|
|
if (hres != S_OK || node_type != XmlNodeType_EndElement)
|
|
|
|
{
|
|
|
|
FIXME("Unexpected node %u %s\n", node_type, debugstr_xml_name(factory));
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-19 17:28:44 +02:00
|
|
|
static HRESULT expect_no_attributes(struct scriptlet_factory *factory)
|
|
|
|
{
|
|
|
|
UINT count;
|
|
|
|
HRESULT hres;
|
|
|
|
hres = IXmlReader_GetAttributeCount(factory->xml_reader, &count);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
if (!count) return S_OK;
|
|
|
|
FIXME("Unexpected attributes\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2019-09-19 17:28:54 +02:00
|
|
|
static BOOL is_case_xml_name(struct scriptlet_factory *factory, const WCHAR *name)
|
|
|
|
{
|
|
|
|
const WCHAR *qname;
|
|
|
|
UINT len;
|
|
|
|
HRESULT hres;
|
|
|
|
hres = IXmlReader_GetQualifiedName(factory->xml_reader, &qname, &len);
|
|
|
|
return hres == S_OK && len == wcslen(name) && !memicmp(qname, name, len * sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT read_xml_value(struct scriptlet_factory *factory, WCHAR **ret)
|
|
|
|
{
|
|
|
|
const WCHAR *str;
|
|
|
|
UINT len;
|
|
|
|
HRESULT hres;
|
|
|
|
hres = IXmlReader_GetValue(factory->xml_reader, &str, &len);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
if (!(*ret = heap_alloc((len + 1) * sizeof(WCHAR)))) return E_OUTOFMEMORY;
|
|
|
|
memcpy(*ret, str, len * sizeof(WCHAR));
|
|
|
|
(*ret)[len] = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-19 17:28:44 +02:00
|
|
|
static HRESULT parse_scriptlet_registration(struct scriptlet_factory *factory)
|
|
|
|
{
|
2019-09-19 17:28:54 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (factory->have_registration)
|
|
|
|
{
|
|
|
|
FIXME("duplicated registration element\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
factory->have_registration = TRUE;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hres = IXmlReader_MoveToNextAttribute(factory->xml_reader);
|
|
|
|
if (hres != S_OK) break;
|
|
|
|
|
|
|
|
if (is_xml_name(factory, L"description"))
|
|
|
|
{
|
|
|
|
if (factory->description)
|
|
|
|
{
|
|
|
|
FIXME("Duplicated description\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
hres = read_xml_value(factory, &factory->description);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
else if (is_case_xml_name(factory, L"progid"))
|
|
|
|
{
|
|
|
|
if (factory->progid)
|
|
|
|
{
|
|
|
|
FIXME("Duplicated progid\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
hres = read_xml_value(factory, &factory->progid);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
else if (is_xml_name(factory, L"version"))
|
|
|
|
{
|
|
|
|
if (factory->version)
|
|
|
|
{
|
|
|
|
FIXME("Duplicated version\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
hres = read_xml_value(factory, &factory->version);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
else if (is_xml_name(factory, L"classid"))
|
|
|
|
{
|
|
|
|
if (factory->classid_str)
|
|
|
|
{
|
|
|
|
FIXME("Duplicated classid attribute\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
hres = read_xml_value(factory, &factory->classid_str);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
hres = IIDFromString(factory->classid_str, &factory->classid);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
FIXME("Invalid classid %s\n", debugstr_w(factory->classid_str));
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Unexpected attribute\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!factory->progid && !factory->classid_str)
|
|
|
|
{
|
|
|
|
FIXME("Incomplet registration element\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (factory->progid)
|
|
|
|
{
|
|
|
|
size_t progid_len = wcslen(factory->progid);
|
|
|
|
size_t version_len = wcslen(factory->version);
|
|
|
|
|
|
|
|
if (!(factory->versioned_progid = heap_alloc((progid_len + version_len + 2) * sizeof(WCHAR))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
memcpy(factory->versioned_progid, factory->progid, (progid_len + 1) * sizeof(WCHAR));
|
|
|
|
if (version_len)
|
|
|
|
{
|
|
|
|
factory->versioned_progid[progid_len++] = '.';
|
|
|
|
wcscpy(factory->versioned_progid + progid_len, factory->version);
|
|
|
|
}
|
|
|
|
else factory->versioned_progid[progid_len] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return expect_end_element(factory);
|
2019-09-19 17:28:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT parse_scriptlet_public(struct scriptlet_factory *factory)
|
|
|
|
{
|
2019-09-20 16:22:39 +02:00
|
|
|
struct scriptlet_member *member;
|
|
|
|
XmlNodeType node_type;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (factory->have_public)
|
|
|
|
{
|
|
|
|
FIXME("duplicated public element\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
factory->have_public = TRUE;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hres = next_xml_node(factory, &node_type);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
if (node_type == XmlNodeType_EndElement) break;
|
|
|
|
if (node_type != XmlNodeType_Element)
|
|
|
|
{
|
|
|
|
FIXME("Unexpected node type %u\n", node_type);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_xml_name(factory, L"method"))
|
|
|
|
{
|
|
|
|
hres = IXmlReader_MoveToAttributeByName(factory->xml_reader, L"name", NULL);
|
|
|
|
if (hres != S_OK)
|
|
|
|
{
|
|
|
|
FIXME("Missing method name\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(member = heap_alloc(sizeof(*member)))) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hres = read_xml_value(factory, &member->name);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
heap_free(member);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
list_init(&member->parameters);
|
|
|
|
list_add_tail(&factory->members, &member->entry);
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
struct method_parameter *parameter;
|
|
|
|
BOOL empty;
|
|
|
|
|
|
|
|
hres = next_xml_node(factory, &node_type);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
if (node_type == XmlNodeType_EndElement) break;
|
|
|
|
if (node_type != XmlNodeType_Element)
|
|
|
|
{
|
|
|
|
FIXME("Unexpected node type %u\n", node_type);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
if (!is_case_xml_name(factory, L"parameter"))
|
|
|
|
{
|
|
|
|
FIXME("Unexpected method element\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
empty = IXmlReader_IsEmptyElement(factory->xml_reader);
|
|
|
|
|
|
|
|
hres = IXmlReader_MoveToAttributeByName(factory->xml_reader, L"name", NULL);
|
|
|
|
if (hres != S_OK)
|
|
|
|
{
|
|
|
|
FIXME("Missing parameter name\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(parameter = heap_alloc(sizeof(*parameter)))) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hres = read_xml_value(factory, ¶meter->name);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
list_add_tail(&member->parameters, ¶meter->entry);
|
|
|
|
if (!empty && FAILED(hres = expect_end_element(factory))) return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Unexpected element %s\n", debugstr_xml_name(factory));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2019-09-19 17:28:44 +02:00
|
|
|
}
|
|
|
|
|
2019-09-20 16:22:49 +02:00
|
|
|
static HRESULT parse_scriptlet_script(struct scriptlet_factory *factory, struct scriptlet_script *script)
|
2019-09-19 17:28:44 +02:00
|
|
|
{
|
2019-09-20 16:22:49 +02:00
|
|
|
XmlNodeType node_type;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hres = IXmlReader_MoveToNextAttribute(factory->xml_reader);
|
|
|
|
if (hres != S_OK) break;
|
|
|
|
|
|
|
|
if (is_xml_name(factory, L"language"))
|
|
|
|
{
|
|
|
|
if (script->language)
|
|
|
|
{
|
|
|
|
FIXME("Duplicated language\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
hres = read_xml_value(factory, &script->language);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Unexpected attribute\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!script->language)
|
|
|
|
{
|
|
|
|
FIXME("Language not specified\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hres = next_xml_node(factory, &node_type))) return hres;
|
|
|
|
|
|
|
|
if (node_type != XmlNodeType_Text && node_type != XmlNodeType_CDATA)
|
|
|
|
{
|
|
|
|
FIXME("Unexpected node type %u\n", node_type);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = read_xml_value(factory, &script->body);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
|
|
|
|
return expect_end_element(factory);
|
2019-09-19 17:28:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT parse_scriptlet_file(struct scriptlet_factory *factory, const WCHAR *url)
|
|
|
|
{
|
|
|
|
XmlNodeType node_type;
|
|
|
|
IBindCtx *bind_ctx;
|
|
|
|
IStream *stream;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CreateURLMoniker(NULL, url, &factory->moniker);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
WARN("CreateURLMoniker failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = CreateBindCtx(0, &bind_ctx);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IMoniker_BindToStorage(factory->moniker, bind_ctx, NULL, &IID_IStream, (void**)&stream);
|
|
|
|
IBindCtx_Release(bind_ctx);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = CreateXmlReader(&IID_IXmlReader, (void**)&factory->xml_reader, NULL);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = IXmlReader_SetInput(factory->xml_reader, (IUnknown*)stream);
|
|
|
|
IStream_Release(stream);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = next_xml_node(factory, &node_type);
|
|
|
|
if (hres == S_OK && node_type == XmlNodeType_XmlDeclaration)
|
|
|
|
hres = next_xml_node(factory, &node_type);
|
|
|
|
|
|
|
|
if (node_type != XmlNodeType_Element || !is_xml_name(factory, L"component"))
|
|
|
|
{
|
|
|
|
FIXME("Unexpected %s element\n", debugstr_xml_name(factory));
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = expect_no_attributes(factory);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hres = next_xml_node(factory, &node_type);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
if (node_type == XmlNodeType_EndElement) break;
|
|
|
|
if (node_type != XmlNodeType_Element)
|
|
|
|
{
|
|
|
|
FIXME("Unexpected node type %u\n", node_type);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_xml_name(factory, L"registration"))
|
|
|
|
hres = parse_scriptlet_registration(factory);
|
|
|
|
else if (is_xml_name(factory, L"public"))
|
|
|
|
hres = parse_scriptlet_public(factory);
|
|
|
|
else if (is_xml_name(factory, L"script"))
|
2019-09-20 16:22:49 +02:00
|
|
|
{
|
|
|
|
struct scriptlet_script *script;
|
|
|
|
if (!(script = heap_alloc_zero(sizeof(*script)))) return E_OUTOFMEMORY;
|
|
|
|
list_add_tail(&factory->scripts, &script->entry);
|
|
|
|
hres = parse_scriptlet_script(factory, script);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
}
|
2019-09-19 17:28:44 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Unexpected element %s\n", debugstr_xml_name(factory));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = next_xml_node(factory, &node_type);
|
|
|
|
if (hres != S_FALSE)
|
|
|
|
{
|
|
|
|
FIXME("Unexpected node type %u\n", node_type);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-19 17:28:25 +02:00
|
|
|
static inline struct scriptlet_factory *impl_from_IClassFactory(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct scriptlet_factory, IClassFactory_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_factory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
struct scriptlet_factory *This = impl_from_IClassFactory(iface);
|
|
|
|
|
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
|
|
|
|
*ppv = &This->IClassFactory_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&IID_IClassFactory, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
|
|
|
|
*ppv = &This->IClassFactory_iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown *)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI scriptlet_factory_AddRef(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
struct scriptlet_factory *This = impl_from_IClassFactory(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI scriptlet_factory_Release(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
struct scriptlet_factory *This = impl_from_IClassFactory(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref)
|
2019-09-19 17:28:44 +02:00
|
|
|
{
|
|
|
|
if (This->moniker) IMoniker_Release(This->moniker);
|
|
|
|
if (This->xml_reader) IXmlReader_Release(This->xml_reader);
|
2019-09-20 16:23:29 +02:00
|
|
|
detach_script_hosts(&This->hosts);
|
2019-09-20 16:22:39 +02:00
|
|
|
while (!list_empty(&This->members))
|
|
|
|
{
|
|
|
|
struct scriptlet_member *member = LIST_ENTRY(list_head(&This->members), struct scriptlet_member, entry);
|
|
|
|
list_remove(&member->entry);
|
|
|
|
heap_free(member->name);
|
|
|
|
while (!list_empty(&member->parameters))
|
|
|
|
{
|
|
|
|
struct method_parameter *parameter = LIST_ENTRY(list_head(&member->parameters), struct method_parameter, entry);
|
|
|
|
list_remove(¶meter->entry);
|
|
|
|
heap_free(parameter->name);
|
|
|
|
heap_free(parameter);
|
|
|
|
}
|
|
|
|
heap_free(member);
|
|
|
|
}
|
2019-09-20 16:22:49 +02:00
|
|
|
while (!list_empty(&This->scripts))
|
|
|
|
{
|
|
|
|
struct scriptlet_script *script = LIST_ENTRY(list_head(&This->scripts), struct scriptlet_script, entry);
|
|
|
|
list_remove(&script->entry);
|
|
|
|
heap_free(script->language);
|
|
|
|
heap_free(script->body);
|
|
|
|
heap_free(script);
|
|
|
|
}
|
2019-09-19 17:28:54 +02:00
|
|
|
heap_free(This->classid_str);
|
|
|
|
heap_free(This->description);
|
|
|
|
heap_free(This->versioned_progid);
|
|
|
|
heap_free(This->progid);
|
|
|
|
heap_free(This->version);
|
2019-09-19 17:28:25 +02:00
|
|
|
heap_free(This);
|
2019-09-19 17:28:44 +02:00
|
|
|
}
|
2019-09-19 17:28:25 +02:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
struct scriptlet_factory *This = impl_from_IClassFactory(iface);
|
2019-09-23 17:54:53 +02:00
|
|
|
IDispatchEx *disp;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %s %p)\n", This, outer, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
if (outer) FIXME("outer not supported\n");
|
|
|
|
|
2019-09-23 17:55:13 +02:00
|
|
|
if (list_empty(&This->hosts))
|
|
|
|
{
|
|
|
|
hres = create_scriptlet_hosts(This, &This->hosts);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
|
|
|
|
hres = parse_scripts(This, &This->hosts, FALSE);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
detach_script_hosts(&This->hosts);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = create_scriptlet_instance(This, &disp);
|
2019-09-23 17:54:53 +02:00
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
|
|
|
|
hres = IDispatchEx_QueryInterface(disp, riid, ppv);
|
|
|
|
IDispatchEx_Release(disp);
|
|
|
|
return hres;
|
2019-09-19 17:28:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_factory_LockServer(IClassFactory *iface, BOOL fLock)
|
|
|
|
{
|
|
|
|
struct scriptlet_factory *This = impl_from_IClassFactory(iface);
|
|
|
|
TRACE("(%p)->(%x)\n", This, fLock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IClassFactoryVtbl scriptlet_factory_vtbl =
|
|
|
|
{
|
|
|
|
scriptlet_factory_QueryInterface,
|
|
|
|
scriptlet_factory_AddRef,
|
|
|
|
scriptlet_factory_Release,
|
|
|
|
scriptlet_factory_CreateInstance,
|
|
|
|
scriptlet_factory_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT create_scriptlet_factory(const WCHAR *url, struct scriptlet_factory **ret)
|
|
|
|
{
|
|
|
|
struct scriptlet_factory *factory;
|
2019-09-19 17:28:44 +02:00
|
|
|
HRESULT hres;
|
2019-09-19 17:28:25 +02:00
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(url));
|
|
|
|
|
|
|
|
if (!(factory = heap_alloc_zero(sizeof(*factory))))
|
|
|
|
{
|
|
|
|
IClassFactory_Release(&factory->IClassFactory_iface);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
factory->IClassFactory_iface.lpVtbl = &scriptlet_factory_vtbl;
|
|
|
|
factory->ref = 1;
|
2019-09-20 16:23:29 +02:00
|
|
|
list_init(&factory->hosts);
|
2019-09-20 16:22:39 +02:00
|
|
|
list_init(&factory->members);
|
2019-09-20 16:22:49 +02:00
|
|
|
list_init(&factory->scripts);
|
2019-09-19 17:28:25 +02:00
|
|
|
|
2019-09-19 17:28:44 +02:00
|
|
|
hres = parse_scriptlet_file(factory, url);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
IClassFactory_Release(&factory->IClassFactory_iface);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2019-09-19 17:28:25 +02:00
|
|
|
*ret = factory;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-20 16:23:15 +02:00
|
|
|
static HRESULT register_scriptlet(struct scriptlet_factory *factory)
|
|
|
|
{
|
|
|
|
HKEY key, clsid_key, obj_key;
|
|
|
|
LSTATUS status;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (factory->classid_str)
|
|
|
|
{
|
|
|
|
WCHAR *url;
|
|
|
|
|
|
|
|
status = RegCreateKeyW(HKEY_CLASSES_ROOT, L"CLSID", &clsid_key);
|
|
|
|
if (status) return E_ACCESSDENIED;
|
|
|
|
|
|
|
|
status = RegCreateKeyW(clsid_key, factory->classid_str, &obj_key);
|
|
|
|
RegCloseKey(clsid_key);
|
|
|
|
if (status) return E_ACCESSDENIED;
|
|
|
|
|
|
|
|
hres = IMoniker_GetDisplayName(factory->moniker, NULL, NULL, &url);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
RegCloseKey(obj_key);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
status = RegCreateKeyW(obj_key, L"ScriptletURL", &key);
|
|
|
|
if (!status)
|
|
|
|
{
|
|
|
|
status = RegSetValueExW(key, NULL, 0, REG_SZ, (BYTE*)url,
|
|
|
|
(wcslen(url) + 1) * sizeof(WCHAR));
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
|
|
|
CoTaskMemFree(url);
|
|
|
|
|
|
|
|
if (factory->description)
|
|
|
|
status = RegSetValueExW(obj_key, NULL, 0, REG_SZ, (BYTE*)factory->description,
|
|
|
|
(wcslen(factory->description) + 1) * sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (!status)
|
|
|
|
{
|
|
|
|
status = RegCreateKeyW(obj_key, L"InprocServer32", &key);
|
|
|
|
if (!status)
|
|
|
|
{
|
|
|
|
WCHAR str[MAX_PATH];
|
|
|
|
GetModuleFileNameW(scrobj_instance, str, MAX_PATH);
|
|
|
|
status = RegSetValueExW(key, NULL, 0, REG_SZ, (BYTE*)str, (wcslen(str) + 1) * sizeof(WCHAR));
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!status && factory->versioned_progid)
|
|
|
|
{
|
|
|
|
status = RegCreateKeyW(obj_key, L"ProgID", &key);
|
|
|
|
if (!status)
|
|
|
|
{
|
|
|
|
status = RegSetValueExW(key, NULL, 0, REG_SZ, (BYTE*)factory->versioned_progid,
|
|
|
|
(wcslen(factory->versioned_progid) + 1) * sizeof(WCHAR));
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!status && factory->progid)
|
|
|
|
{
|
|
|
|
status = RegCreateKeyW(obj_key, L"VersionIndependentProgID", &key);
|
|
|
|
if (!status)
|
|
|
|
{
|
|
|
|
status = RegSetValueExW(key, NULL, 0, REG_SZ, (BYTE*)factory->progid,
|
|
|
|
(wcslen(factory->progid) + 1) * sizeof(WCHAR));
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(obj_key);
|
|
|
|
if (status) return E_ACCESSDENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (factory->progid)
|
|
|
|
{
|
|
|
|
status = RegCreateKeyW(HKEY_CLASSES_ROOT, factory->progid, &key);
|
|
|
|
if (status) return E_ACCESSDENIED;
|
|
|
|
|
|
|
|
if (factory->description)
|
|
|
|
status = RegSetValueExW(key, NULL, 0, REG_SZ, (BYTE*)factory->description,
|
|
|
|
(wcslen(factory->description) + 1) * sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (!status && factory->classid_str)
|
|
|
|
{
|
|
|
|
status = RegCreateKeyW(key, L"CLSID", &clsid_key);
|
|
|
|
if (!status)
|
|
|
|
{
|
|
|
|
status = RegSetValueExW(clsid_key, NULL, 0, REG_SZ, (BYTE*)factory->classid_str,
|
|
|
|
(wcslen(factory->classid_str) + 1) * sizeof(WCHAR));
|
|
|
|
RegCloseKey(clsid_key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(key);
|
|
|
|
if (status) return E_ACCESSDENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (factory->versioned_progid)
|
|
|
|
{
|
|
|
|
status = RegCreateKeyW(HKEY_CLASSES_ROOT, factory->versioned_progid, &key);
|
|
|
|
if (status) return E_ACCESSDENIED;
|
|
|
|
|
|
|
|
if (factory->description)
|
|
|
|
status = RegSetValueExW(key, NULL, 0, REG_SZ, (BYTE*)factory->description,
|
|
|
|
(wcslen(factory->description) + 1) * sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (!status && factory->classid_str)
|
|
|
|
{
|
|
|
|
status = RegCreateKeyW(key, L"CLSID", &clsid_key);
|
|
|
|
if (!status)
|
|
|
|
{
|
|
|
|
status = RegSetValueExW(clsid_key, NULL, 0, REG_SZ, (BYTE*)factory->classid_str,
|
|
|
|
(wcslen(factory->classid_str) + 1) * sizeof(WCHAR));
|
|
|
|
RegCloseKey(clsid_key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(key);
|
|
|
|
if (status) return E_ACCESSDENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT unregister_scriptlet(struct scriptlet_factory *factory)
|
|
|
|
{
|
|
|
|
LSTATUS status;
|
|
|
|
|
|
|
|
if (factory->classid_str)
|
|
|
|
{
|
|
|
|
HKEY clsid_key;
|
|
|
|
status = RegCreateKeyW(HKEY_CLASSES_ROOT, L"CLSID", &clsid_key);
|
|
|
|
if (!status)
|
|
|
|
{
|
|
|
|
RegDeleteTreeW(clsid_key, factory->classid_str);
|
|
|
|
RegCloseKey(clsid_key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (factory->progid) RegDeleteTreeW(HKEY_CLASSES_ROOT, factory->progid);
|
|
|
|
if (factory->versioned_progid) RegDeleteTreeW(HKEY_CLASSES_ROOT, factory->versioned_progid);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-01-26 22:36:10 +01:00
|
|
|
struct scriptlet_typelib
|
|
|
|
{
|
|
|
|
IGenScriptletTLib IGenScriptletTLib_iface;
|
|
|
|
LONG ref;
|
2017-01-26 22:36:12 +01:00
|
|
|
|
|
|
|
BSTR guid;
|
2017-01-26 22:36:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct scriptlet_typelib *impl_from_IGenScriptletTLib(IGenScriptletTLib *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct scriptlet_typelib, IGenScriptletTLib_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_QueryInterface(IGenScriptletTLib *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IGenScriptletTLib) ||
|
|
|
|
IsEqualIID(riid, &IID_IDispatch) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IGenScriptletTLib_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI scriptlet_typelib_AddRef(IGenScriptletTLib *iface)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%u)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI scriptlet_typelib_Release(IGenScriptletTLib *iface)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u)\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref)
|
2017-01-26 22:36:12 +01:00
|
|
|
{
|
|
|
|
SysFreeString(This->guid);
|
2017-01-26 22:36:10 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2017-01-26 22:36:12 +01:00
|
|
|
}
|
2017-01-26 22:36:10 +01:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_GetTypeInfoCount(IGenScriptletTLib *iface, UINT *count)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
2017-01-26 22:36:11 +01:00
|
|
|
TRACE("(%p, %p)\n", This, count);
|
2017-01-26 22:36:10 +01:00
|
|
|
|
2017-01-26 22:36:11 +01:00
|
|
|
*count = 1;
|
|
|
|
return S_OK;
|
2017-01-26 22:36:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_GetTypeInfo(IGenScriptletTLib *iface, UINT index, LCID lcid,
|
|
|
|
ITypeInfo **tinfo)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
2017-01-26 22:36:11 +01:00
|
|
|
TRACE("(%p, %u, %x, %p)\n", This, index, lcid, tinfo);
|
2017-01-26 22:36:10 +01:00
|
|
|
|
2017-01-26 22:36:11 +01:00
|
|
|
return get_typeinfo(IGenScriptletTLib_tid, tinfo);
|
2017-01-26 22:36:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_GetIDsOfNames(IGenScriptletTLib *iface, REFIID riid, LPOLESTR *names,
|
|
|
|
UINT cNames, LCID lcid, DISPID *dispid)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
2017-01-26 22:36:11 +01:00
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
2017-01-26 22:36:10 +01:00
|
|
|
|
2017-01-26 22:36:11 +01:00
|
|
|
TRACE("(%p, %s, %p, %u, %x, %p)\n", This, debugstr_guid(riid), names, cNames, lcid, dispid);
|
2017-01-26 22:36:10 +01:00
|
|
|
|
2017-01-26 22:36:11 +01:00
|
|
|
hr = get_typeinfo(IGenScriptletTLib_tid, &typeinfo);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, names, cNames, dispid);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2017-01-26 22:36:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_Invoke(IGenScriptletTLib *iface, DISPID dispid, REFIID riid,
|
|
|
|
LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *ei, UINT *argerr)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
2017-01-26 22:36:11 +01:00
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
2017-01-26 22:36:10 +01:00
|
|
|
|
2017-01-26 22:36:11 +01:00
|
|
|
TRACE("(%p, %d, %s, %x, %x, %p, %p, %p, %p)\n", This, dispid, debugstr_guid(riid), lcid, flags,
|
2017-01-26 22:36:10 +01:00
|
|
|
params, result, ei, argerr);
|
|
|
|
|
2017-01-26 22:36:11 +01:00
|
|
|
hr = get_typeinfo(IGenScriptletTLib_tid, &typeinfo);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_Invoke(typeinfo, &This->IGenScriptletTLib_iface, dispid, flags,
|
|
|
|
params, result, ei, argerr);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2017-01-26 22:36:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_AddURL(IGenScriptletTLib *iface, BSTR url)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p, %s): stub\n", This, debugstr_w(url));
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_put_Path(IGenScriptletTLib *iface, BSTR path)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p, %s): stub\n", This, debugstr_w(path));
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_get_Path(IGenScriptletTLib *iface, BSTR *path)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p, %p): stub\n", This, path);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_put_Doc(IGenScriptletTLib *iface, BSTR doc)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p, %s): stub\n", This, debugstr_w(doc));
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_get_Doc(IGenScriptletTLib *iface, BSTR *doc)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p, %p): stub\n", This, doc);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_put_Name(IGenScriptletTLib *iface, BSTR name)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p, %s): stub\n", This, debugstr_w(name));
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_get_Name(IGenScriptletTLib *iface, BSTR *name)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p, %p): stub\n", This, name);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_put_MajorVersion(IGenScriptletTLib *iface, WORD version)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p, %x): stub\n", This, version);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_get_MajorVersion(IGenScriptletTLib *iface, WORD *version)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p, %p): stub\n", This, version);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_put_MinorVersion(IGenScriptletTLib *iface, WORD version)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p, %x): stub\n", This, version);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_get_MinorVersion(IGenScriptletTLib *iface, WORD *version)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p, %p): stub\n", This, version);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_Write(IGenScriptletTLib *iface)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_Reset(IGenScriptletTLib *iface)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scriptlet_typelib_put_GUID(IGenScriptletTLib *iface, BSTR guid)
|
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
|
|
|
FIXME("(%p, %s): stub\n", This, debugstr_w(guid));
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-26 22:36:12 +01:00
|
|
|
static HRESULT WINAPI scriptlet_typelib_get_GUID(IGenScriptletTLib *iface, BSTR *ret)
|
2017-01-26 22:36:10 +01:00
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This = impl_from_IGenScriptletTLib(iface);
|
|
|
|
|
2017-01-26 22:36:12 +01:00
|
|
|
TRACE("(%p, %p)\n", This, ret);
|
2017-01-26 22:36:10 +01:00
|
|
|
|
2017-01-26 22:36:12 +01:00
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
if (!This->guid)
|
|
|
|
{
|
|
|
|
WCHAR guidW[39];
|
|
|
|
GUID guid;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateGuid(&guid);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2018-07-26 00:05:53 +02:00
|
|
|
hr = StringFromGUID2(&guid, guidW, ARRAY_SIZE(guidW));
|
2017-01-26 22:36:12 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (!(This->guid = SysAllocString(guidW)))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret = SysAllocString(This->guid);
|
|
|
|
return *ret ? S_OK : E_OUTOFMEMORY;
|
2017-01-26 22:36:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IGenScriptletTLibVtbl scriptlet_typelib_vtbl =
|
|
|
|
{
|
|
|
|
scriptlet_typelib_QueryInterface,
|
|
|
|
scriptlet_typelib_AddRef,
|
|
|
|
scriptlet_typelib_Release,
|
|
|
|
scriptlet_typelib_GetTypeInfoCount,
|
|
|
|
scriptlet_typelib_GetTypeInfo,
|
|
|
|
scriptlet_typelib_GetIDsOfNames,
|
|
|
|
scriptlet_typelib_Invoke,
|
|
|
|
scriptlet_typelib_AddURL,
|
|
|
|
scriptlet_typelib_put_Path,
|
|
|
|
scriptlet_typelib_get_Path,
|
|
|
|
scriptlet_typelib_put_Doc,
|
|
|
|
scriptlet_typelib_get_Doc,
|
|
|
|
scriptlet_typelib_put_Name,
|
|
|
|
scriptlet_typelib_get_Name,
|
|
|
|
scriptlet_typelib_put_MajorVersion,
|
|
|
|
scriptlet_typelib_get_MajorVersion,
|
|
|
|
scriptlet_typelib_put_MinorVersion,
|
|
|
|
scriptlet_typelib_get_MinorVersion,
|
|
|
|
scriptlet_typelib_Write,
|
|
|
|
scriptlet_typelib_Reset,
|
|
|
|
scriptlet_typelib_put_GUID,
|
|
|
|
scriptlet_typelib_get_GUID
|
|
|
|
};
|
|
|
|
|
2017-01-26 22:36:08 +01:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *reserved)
|
|
|
|
{
|
|
|
|
TRACE("%p, %u, %p\n", hinst, reason, reserved);
|
|
|
|
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case DLL_WINE_PREATTACH:
|
|
|
|
return FALSE; /* prefer native version */
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(hinst);
|
|
|
|
scrobj_instance = hinst;
|
|
|
|
break;
|
2017-01-26 22:36:11 +01:00
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
if (reserved) break;
|
|
|
|
release_typelib();
|
|
|
|
break;
|
2017-01-26 22:36:08 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllRegisterServer (scrobj.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllRegisterServer(void)
|
|
|
|
{
|
|
|
|
TRACE("()\n");
|
|
|
|
return __wine_register_resources(scrobj_instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllUnregisterServer (scrobj.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllUnregisterServer(void)
|
|
|
|
{
|
|
|
|
TRACE("()\n");
|
|
|
|
return __wine_unregister_resources(scrobj_instance);
|
|
|
|
}
|
|
|
|
|
2019-09-18 15:25:04 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DllInstall (scrobj.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllInstall(BOOL install, const WCHAR *arg)
|
|
|
|
{
|
2019-09-20 16:23:15 +02:00
|
|
|
struct scriptlet_factory *factory;
|
2019-09-18 15:25:04 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (install)
|
|
|
|
{
|
|
|
|
hres = DllRegisterServer();
|
|
|
|
if (!arg || FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
else if (!arg)
|
|
|
|
return DllUnregisterServer();
|
|
|
|
|
2019-09-20 16:23:15 +02:00
|
|
|
hres = create_scriptlet_factory(arg, &factory);
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
if (factory->have_registration)
|
|
|
|
{
|
2019-09-20 16:23:29 +02:00
|
|
|
/* validate scripts */
|
|
|
|
hres = create_scriptlet_hosts(factory, &factory->hosts);
|
2019-09-23 17:55:04 +02:00
|
|
|
if (SUCCEEDED(hres)) hres = parse_scripts(factory, &factory->hosts, FALSE);
|
2019-09-20 16:23:15 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("No registration info\n");
|
|
|
|
hres = E_FAIL;
|
|
|
|
}
|
2019-09-20 16:23:29 +02:00
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
if (install)
|
|
|
|
hres = register_scriptlet(factory);
|
|
|
|
else
|
|
|
|
hres = unregister_scriptlet(factory);
|
|
|
|
}
|
2019-09-20 16:23:15 +02:00
|
|
|
IClassFactory_Release(&factory->IClassFactory_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hres;
|
2019-09-18 15:25:04 +02:00
|
|
|
}
|
|
|
|
|
2017-03-12 20:46:40 +01:00
|
|
|
static HRESULT WINAPI scriptlet_typelib_CreateInstance(IClassFactory *factory, IUnknown *outer, REFIID riid, void **obj)
|
2017-01-26 22:36:10 +01:00
|
|
|
{
|
|
|
|
struct scriptlet_typelib *This;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %s, %p)\n", factory, outer, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->IGenScriptletTLib_iface.lpVtbl = &scriptlet_typelib_vtbl;
|
|
|
|
This->ref = 1;
|
2017-01-26 22:36:12 +01:00
|
|
|
This->guid = NULL;
|
2017-01-26 22:36:10 +01:00
|
|
|
|
|
|
|
hr = IGenScriptletTLib_QueryInterface(&This->IGenScriptletTLib_iface, riid, obj);
|
|
|
|
IGenScriptletTLib_Release(&This->IGenScriptletTLib_iface);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scrruncf_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
|
|
|
|
*ppv = iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&IID_IClassFactory, riid))
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
|
|
|
|
*ppv = iface;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*ppv)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef((IUnknown *)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI scrruncf_AddRef(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI scrruncf_Release(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI scrruncf_LockServer(IClassFactory *iface, BOOL fLock)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%x)\n", iface, fLock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IClassFactoryVtbl scriptlet_typelib_factory_vtbl =
|
|
|
|
{
|
|
|
|
scrruncf_QueryInterface,
|
|
|
|
scrruncf_AddRef,
|
|
|
|
scrruncf_Release,
|
|
|
|
scriptlet_typelib_CreateInstance,
|
|
|
|
scrruncf_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static IClassFactory scriptlet_typelib_factory = { &scriptlet_typelib_factory_vtbl };
|
|
|
|
|
2017-01-26 22:36:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* DllGetClassObject (scrobj.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
|
|
|
|
{
|
2019-09-19 17:28:25 +02:00
|
|
|
WCHAR key_name[128], *p;
|
|
|
|
LONG size = 0;
|
|
|
|
LSTATUS status;
|
|
|
|
|
2017-01-26 22:36:10 +01:00
|
|
|
if (IsEqualGUID(&CLSID_TypeLib, rclsid))
|
|
|
|
{
|
|
|
|
TRACE("(Scriptlet.TypeLib %s %p)\n", debugstr_guid(riid), ppv);
|
|
|
|
return IClassFactory_QueryInterface(&scriptlet_typelib_factory, riid, ppv);
|
|
|
|
}
|
|
|
|
|
2019-09-19 17:28:25 +02:00
|
|
|
wcscpy(key_name, L"CLSID\\");
|
|
|
|
p = key_name + wcslen(key_name);
|
|
|
|
p += StringFromGUID2(rclsid, p, ARRAY_SIZE(key_name) - (p - key_name)) - 1;
|
|
|
|
wcscpy(p, L"\\ScriptletURL");
|
|
|
|
status = RegQueryValueW(HKEY_CLASSES_ROOT, key_name, NULL, &size);
|
|
|
|
if (!status)
|
|
|
|
{
|
|
|
|
struct scriptlet_factory *factory;
|
|
|
|
WCHAR *url;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (!(url = heap_alloc(size * sizeof(WCHAR)))) return E_OUTOFMEMORY;
|
|
|
|
status = RegQueryValueW(HKEY_CLASSES_ROOT, key_name, url, &size);
|
|
|
|
|
|
|
|
hres = create_scriptlet_factory(url, &factory);
|
|
|
|
heap_free(url);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
|
|
|
|
hres = IClassFactory_QueryInterface(&factory->IClassFactory_iface, riid, ppv);
|
|
|
|
IClassFactory_Release(&factory->IClassFactory_iface);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2017-01-26 22:36:08 +01:00
|
|
|
FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllCanUnloadNow (scrobj.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
|
|
|
{
|
|
|
|
return S_FALSE;
|
|
|
|
}
|