2017-01-26 22:36:08 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Nikolay Sivov
|
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
|
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"
|
2017-01-26 22:36:08 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(scrobj);
|
|
|
|
|
|
|
|
static HINSTANCE scrobj_instance;
|
|
|
|
|
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:25 +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-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));
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT parse_scriptlet_registration(struct scriptlet_factory *factory)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT parse_scriptlet_public(struct scriptlet_factory *factory)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT parse_scriptlet_script(struct scriptlet_factory *factory)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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"))
|
|
|
|
hres = parse_scriptlet_script(factory);
|
|
|
|
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-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);
|
|
|
|
FIXME("(%p)->(%p %s %p)\n", This, outer, debugstr_guid(riid), ppv);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-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;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (install)
|
|
|
|
{
|
|
|
|
hres = DllRegisterServer();
|
|
|
|
if (!arg || FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
else if (!arg)
|
|
|
|
return DllUnregisterServer();
|
|
|
|
|
|
|
|
FIXME("argument %s not supported\n", debugstr_w(arg));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|