jscript: Added ActiveXObject constructor implementation.
This commit is contained in:
parent
90fadf84d9
commit
6d4533a8f8
|
@ -3,7 +3,7 @@ TOPOBJDIR = ../..
|
|||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
MODULE = jscript.dll
|
||||
IMPORTS = oleaut32 user32 advapi32 kernel32
|
||||
IMPORTS = oleaut32 ole32 user32 advapi32 kernel32
|
||||
|
||||
RC_SRCS = \
|
||||
jscript_De.rc \
|
||||
|
|
|
@ -20,16 +20,136 @@
|
|||
#include "wine/port.h"
|
||||
|
||||
#include "jscript.h"
|
||||
#include "objsafe.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
|
||||
|
||||
/* Defined as extern in urlmon.idl, but not exported by uuid.lib */
|
||||
const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY =
|
||||
{0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
|
||||
|
||||
static IInternetHostSecurityManager *get_sec_mgr(script_ctx_t *ctx)
|
||||
{
|
||||
IInternetHostSecurityManager *secmgr;
|
||||
IServiceProvider *sp;
|
||||
HRESULT hres;
|
||||
|
||||
if(!ctx->site)
|
||||
return NULL;
|
||||
|
||||
if(ctx->secmgr)
|
||||
return ctx->secmgr;
|
||||
|
||||
hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IServiceProvider, (void**)&sp);
|
||||
if(FAILED(hres))
|
||||
return NULL;
|
||||
|
||||
hres = IServiceProvider_QueryService(sp, &SID_SInternetHostSecurityManager, &IID_IInternetHostSecurityManager,
|
||||
(void**)&secmgr);
|
||||
IServiceProvider_Release(sp);
|
||||
if(FAILED(hres))
|
||||
return NULL;
|
||||
|
||||
return ctx->secmgr = secmgr;
|
||||
}
|
||||
|
||||
static IUnknown *create_activex_object(script_ctx_t *ctx, const WCHAR *progid)
|
||||
{
|
||||
IInternetHostSecurityManager *secmgr;
|
||||
struct CONFIRMSAFETY cs;
|
||||
DWORD policy_size;
|
||||
BYTE *bpolicy;
|
||||
IUnknown *obj;
|
||||
DWORD policy;
|
||||
GUID guid;
|
||||
HRESULT hres;
|
||||
|
||||
hres = CLSIDFromProgID(progid, &guid);
|
||||
if(FAILED(hres))
|
||||
return NULL;
|
||||
|
||||
TRACE("GUID %s\n", debugstr_guid(&guid));
|
||||
|
||||
secmgr = get_sec_mgr(ctx);
|
||||
if(!secmgr)
|
||||
return NULL;
|
||||
|
||||
policy = 0;
|
||||
hres = IInternetHostSecurityManager_ProcessUrlAction(secmgr, URLACTION_ACTIVEX_RUN, (BYTE*)&policy, sizeof(policy),
|
||||
(BYTE*)&guid, sizeof(GUID), 0, 0);
|
||||
if(FAILED(hres) || policy != URLPOLICY_ALLOW)
|
||||
return NULL;
|
||||
|
||||
/* FIXME: Use IClassFactoryEx */
|
||||
|
||||
hres = CoCreateInstance(&guid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, &IID_IUnknown, (void**)&obj);
|
||||
if(FAILED(hres))
|
||||
return NULL;
|
||||
|
||||
cs.clsid = guid;
|
||||
cs.pUnk = obj;
|
||||
cs.dwFlags = 0;
|
||||
hres = IInternetHostSecurityManager_QueryCustomPolicy(secmgr, &GUID_CUSTOM_CONFIRMOBJECTSAFETY, &bpolicy, &policy_size,
|
||||
(BYTE*)&cs, sizeof(cs), 0);
|
||||
if(SUCCEEDED(hres)) {
|
||||
policy = policy_size >= sizeof(DWORD) ? *(DWORD*)bpolicy : URLPOLICY_DISALLOW;
|
||||
CoTaskMemFree(bpolicy);
|
||||
}
|
||||
|
||||
if(FAILED(hres) || policy != URLPOLICY_ALLOW) {
|
||||
IUnknown_Release(obj);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,
|
||||
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
|
||||
{
|
||||
FIXME("\n");
|
||||
return E_NOTIMPL;
|
||||
IDispatch *disp;
|
||||
IUnknown *obj;
|
||||
BSTR progid;
|
||||
HRESULT hres;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
if(flags != DISPATCH_CONSTRUCT) {
|
||||
FIXME("unsupported flags %x\n", flags);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
if(ctx->safeopt != (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER)) {
|
||||
FIXME("Unsupported safeopt %x\n", ctx->safeopt);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
if(arg_cnt(dp) != 1) {
|
||||
FIXME("unsuported arg_cnt %d\n", arg_cnt(dp));
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
hres = to_string(ctx, get_arg(dp,0), ei, &progid);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
obj = create_activex_object(ctx, progid);
|
||||
SysFreeString(progid);
|
||||
if(!obj)
|
||||
return throw_generic_error(ctx, ei, IDS_CREATE_OBJ_ERROR, NULL);
|
||||
|
||||
hres = IUnknown_QueryInterface(obj, &IID_IDispatch, (void**)&disp);
|
||||
IUnknown_Release(obj);
|
||||
if(FAILED(hres)) {
|
||||
FIXME("Object does not support IDispatch\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
V_VT(retv) = VT_DISPATCH;
|
||||
V_DISPATCH(retv) = disp;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT create_activex_constr(script_ctx_t *ctx, DispatchEx **ret)
|
||||
|
|
|
@ -429,6 +429,11 @@ HRESULT throw_eval_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCHAR
|
|||
return throw_error(ctx, ei, id, str, ctx->eval_error_constr);
|
||||
}
|
||||
|
||||
HRESULT throw_generic_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCHAR *str)
|
||||
{
|
||||
return throw_error(ctx, ei, id, str, ctx->error_constr);
|
||||
}
|
||||
|
||||
HRESULT throw_range_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCHAR *str)
|
||||
{
|
||||
return throw_error(ctx, ei, id, str, ctx->range_error_constr);
|
||||
|
|
|
@ -351,6 +351,11 @@ static HRESULT WINAPI JScript_Close(IActiveScript *iface)
|
|||
This->ctx->named_items = NULL;
|
||||
}
|
||||
|
||||
if(This->ctx->secmgr) {
|
||||
IInternetHostSecurityManager_Release(This->ctx->secmgr);
|
||||
This->ctx->secmgr = NULL;
|
||||
}
|
||||
|
||||
if(This->ctx->site) {
|
||||
IActiveScriptSite_Release(This->ctx->site);
|
||||
This->ctx->site = NULL;
|
||||
|
@ -554,6 +559,7 @@ static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface)
|
|||
|
||||
ctx->ref = 1;
|
||||
ctx->state = SCRIPTSTATE_UNINITIALIZED;
|
||||
ctx->safeopt = This->safeopt;
|
||||
jsheap_init(&ctx->tmp_heap);
|
||||
|
||||
ctx = InterlockedCompareExchangePointer((void**)&This->ctx, ctx, NULL);
|
||||
|
|
|
@ -214,6 +214,7 @@ HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,cons
|
|||
HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*);
|
||||
|
||||
HRESULT throw_eval_error(script_ctx_t*,jsexcept_t*,UINT,const WCHAR*);
|
||||
HRESULT throw_generic_error(script_ctx_t*,jsexcept_t*,UINT,const WCHAR*);
|
||||
HRESULT throw_range_error(script_ctx_t*,jsexcept_t*,UINT,const WCHAR*);
|
||||
HRESULT throw_reference_error(script_ctx_t*,jsexcept_t*,UINT,const WCHAR*);
|
||||
HRESULT throw_regexp_error(script_ctx_t*,jsexcept_t*,UINT,const WCHAR*);
|
||||
|
@ -221,7 +222,6 @@ HRESULT throw_syntax_error(script_ctx_t*,jsexcept_t*,UINT,const WCHAR*);
|
|||
HRESULT throw_type_error(script_ctx_t*,jsexcept_t*,UINT,const WCHAR*);
|
||||
HRESULT throw_uri_error(script_ctx_t*,jsexcept_t*,UINT,const WCHAR*);
|
||||
|
||||
|
||||
HRESULT create_object(script_ctx_t*,DispatchEx*,DispatchEx**);
|
||||
HRESULT create_math(script_ctx_t*,DispatchEx**);
|
||||
HRESULT create_array(script_ctx_t*,DWORD,DispatchEx**);
|
||||
|
@ -260,6 +260,8 @@ struct _script_ctx_t {
|
|||
exec_ctx_t *exec_ctx;
|
||||
named_item_t *named_items;
|
||||
IActiveScriptSite *site;
|
||||
IInternetHostSecurityManager *secmgr;
|
||||
DWORD safeopt;
|
||||
LCID lcid;
|
||||
|
||||
jsheap_t tmp_heap;
|
||||
|
|
|
@ -24,6 +24,7 @@ STRINGTABLE DISCARDABLE
|
|||
{
|
||||
IDS_TO_PRIMITIVE "Error converting object to primitive type"
|
||||
IDS_INVALID_CALL_ARG "Invalid procedure call or argument"
|
||||
IDS_CREATE_OBJ_ERROR "Automation server can't create object"
|
||||
IDS_NO_PROPERTY "Object doesn't support this property or method"
|
||||
IDS_ARG_NOT_OPT "Argument not optional"
|
||||
IDS_SYNTAX_ERROR "Syntax error"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#define IDS_TO_PRIMITIVE 0x0001
|
||||
#define IDS_INVALID_CALL_ARG 0x0005
|
||||
#define IDS_CREATE_OBJ_ERROR 0x01AD
|
||||
#define IDS_NO_PROPERTY 0x01B6
|
||||
#define IDS_ARG_NOT_OPT 0x01c1
|
||||
#define IDS_SYNTAX_ERROR 0x03EA
|
||||
|
|
Loading…
Reference in New Issue