ReactOS 0.4.16-dev-197-g92996da
activex.c File Reference
#include "jscript.h"
#include "objsafe.h"
#include "mshtmhst.h"
#include "wine/debug.h"
Include dependency graph for activex.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (jscript)
 
static IInternetHostSecurityManagerget_sec_mgr (script_ctx_t *ctx)
 
static IUnknowncreate_activex_object (script_ctx_t *ctx, const WCHAR *progid)
 
static HRESULT ActiveXObject_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
HRESULT create_activex_constr (script_ctx_t *ctx, jsdisp_t **ret)
 

Variables

const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
 

Function Documentation

◆ ActiveXObject_value()

static HRESULT ActiveXObject_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 141 of file activex.c.

143{
144 jsstr_t * progid_str;
145 const WCHAR *progid;
146 IDispatch *disp;
147 IUnknown *obj;
149
150 TRACE("\n");
151
152 if(flags != DISPATCH_CONSTRUCT) {
153 FIXME("unsupported flags %x\n", flags);
154 return E_NOTIMPL;
155 }
156
157 if(ctx->safeopt != (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER)
158 && ctx->safeopt != INTERFACE_USES_DISPEX) {
159 FIXME("Unsupported safeopt %x\n", ctx->safeopt);
160 return E_NOTIMPL;
161 }
162
163 if(argc != 1) {
164 FIXME("unsupported argc %d\n", argc);
165 return E_NOTIMPL;
166 }
167
168 hres = to_flat_string(ctx, argv[0], &progid_str, &progid);
169 if(FAILED(hres))
170 return hres;
171
173 jsstr_release(progid_str);
174 if(!obj)
176
177 hres = IUnknown_QueryInterface(obj, &IID_IDispatch, (void**)&disp);
178 IUnknown_Release(obj);
179 if(FAILED(hres)) {
180 FIXME("Object does not support IDispatch\n");
181 return E_NOTIMPL;
182 }
183
184 *r = jsval_disp(disp);
185 return S_OK;
186}
static int argc
Definition: ServiceArgs.c:12
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
static IUnknown * create_activex_object(script_ctx_t *ctx, const WCHAR *progid)
Definition: activex.c:57
HRESULT throw_generic_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:415
#define progid(str)
Definition: exdisp.idl:31
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLbitfield flags
Definition: glext.h:7161
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define JS_E_CANNOT_CREATE_OBJ
Definition: jscript.h:532
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
static jsval_t jsval_disp(IDispatch *obj)
Definition: jsval.h:117
HRESULT hres
Definition: protocol.c:465
#define argv
Definition: mplay32.c:18
const GUID IID_IDispatch
#define TRACE(s)
Definition: solgame.cpp:4
Definition: jsstr.h:39
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by create_activex_constr().

◆ create_activex_constr()

HRESULT create_activex_constr ( script_ctx_t ctx,
jsdisp_t **  ret 
)

Definition at line 188 of file activex.c.

189{
190 jsdisp_t *prototype;
192
193 static const WCHAR ActiveXObjectW[] = {'A','c','t','i','v','e','X','O','b','j','e','c','t',0};
194
195 hres = create_object(ctx, NULL, &prototype);
196 if(FAILED(hres))
197 return hres;
198
200 PROPF_CONSTR|1, prototype, ret);
201
202 jsdisp_release(prototype);
203 return hres;
204}
static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: activex.c:141
HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, const builtin_info_t *builtin_info, DWORD flags, jsdisp_t *prototype, jsdisp_t **ret)
Definition: function.c:651
static const WCHAR ActiveXObjectW[]
Definition: global.c:52
#define PROPF_CONSTR
Definition: jscript.h:98
HRESULT create_object(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: object.c:731
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
int ret

Referenced by init_global().

◆ create_activex_object()

static IUnknown * create_activex_object ( script_ctx_t ctx,
const WCHAR progid 
)
static

Definition at line 57 of file activex.c.

58{
60 IObjectWithSite *obj_site;
61 struct CONFIRMSAFETY cs;
62 IClassFactoryEx *cfex;
64 DWORD policy_size;
65 BYTE *bpolicy;
68 GUID guid;
70
71 TRACE("%s\n", debugstr_w(progid));
72
74 if(FAILED(hres))
75 return NULL;
76
77 TRACE("GUID %s\n", debugstr_guid(&guid));
78
79 if(ctx->safeopt & INTERFACE_USES_SECURITY_MANAGER) {
80 secmgr = get_sec_mgr(ctx);
81 if(!secmgr)
82 return NULL;
83
84 policy = 0;
85 hres = IInternetHostSecurityManager_ProcessUrlAction(secmgr, URLACTION_ACTIVEX_RUN,
86 (BYTE*)&policy, sizeof(policy), (BYTE*)&guid, sizeof(GUID), 0, 0);
87 if(FAILED(hres) || policy != URLPOLICY_ALLOW)
88 return NULL;
89 }
90
91 hres = CoGetClassObject(&guid, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER, NULL, &IID_IClassFactory, (void**)&cf);
92 if(FAILED(hres))
93 return NULL;
94
95 hres = IClassFactory_QueryInterface(cf, &IID_IClassFactoryEx, (void**)&cfex);
96 if(SUCCEEDED(hres)) {
97 FIXME("Use IClassFactoryEx\n");
98 IClassFactoryEx_Release(cfex);
99 }
100
101 hres = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
102 if(FAILED(hres))
103 return NULL;
104
105 if(secmgr) {
106 cs.clsid = guid;
107 cs.pUnk = obj;
108 cs.dwFlags = 0;
109 hres = IInternetHostSecurityManager_QueryCustomPolicy(secmgr, &GUID_CUSTOM_CONFIRMOBJECTSAFETY,
110 &bpolicy, &policy_size, (BYTE*)&cs, sizeof(cs), 0);
111 if(SUCCEEDED(hres)) {
112 policy = policy_size >= sizeof(DWORD) ? *(DWORD*)bpolicy : URLPOLICY_DISALLOW;
113 CoTaskMemFree(bpolicy);
114 }
115
116 if(FAILED(hres) || policy != URLPOLICY_ALLOW) {
117 IUnknown_Release(obj);
118 return NULL;
119 }
120 }
121
122 hres = IUnknown_QueryInterface(obj, &IID_IObjectWithSite, (void**)&obj_site);
123 if(SUCCEEDED(hres)) {
124 IUnknown *ax_site;
125
126 ax_site = create_ax_site(ctx);
127 if(ax_site) {
128 hres = IObjectWithSite_SetSite(obj_site, ax_site);
129 IUnknown_Release(ax_site);
130 }
131 IObjectWithSite_Release(obj_site);
132 if(!ax_site || FAILED(hres)) {
133 IUnknown_Release(obj);
134 return NULL;
135 }
136 }
137
138 return obj;
139}
const GUID IID_IUnknown
const GUID IID_IClassFactory
static IInternetHostSecurityManager * get_sec_mgr(script_ctx_t *ctx)
Definition: activex.c:32
const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
Definition: activex.c:29
IUnknown * create_ax_site(script_ctx_t *ctx)
Definition: jscript.c:324
HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, LPCLSID clsid)
Definition: compobj.c:2602
HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3103
unsigned long DWORD
Definition: ntddk_ex.h:95
WDF_INTERRUPT_POLICY policy
#define cs
Definition: i386-dis.c:442
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
const GUID * guid
const IID IID_IObjectWithSite
#define DWORD
Definition: nt_native.h:44
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ActiveXObject_value().

◆ get_sec_mgr()

static IInternetHostSecurityManager * get_sec_mgr ( script_ctx_t ctx)
static

Definition at line 32 of file activex.c.

33{
37
38 if(!ctx->site)
39 return NULL;
40
41 if(ctx->secmgr)
42 return ctx->secmgr;
43
44 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IServiceProvider, (void**)&sp);
45 if(FAILED(hres))
46 return NULL;
47
48 hres = IServiceProvider_QueryService(sp, &SID_SInternetHostSecurityManager, &IID_IInternetHostSecurityManager,
49 (void**)&secmgr);
50 IServiceProvider_Release(sp);
51 if(FAILED(hres))
52 return NULL;
53
54 return ctx->secmgr = secmgr;
55}
static const WCHAR sp[]
Definition: suminfo.c:287

Referenced by create_activex_object().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( jscript  )

Variable Documentation

◆ GUID_CUSTOM_CONFIRMOBJECTSAFETY

const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
Initial value:
=
{0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}}

Definition at line 29 of file activex.c.

Referenced by check_load_safety(), check_script_safety(), create_activex_object(), and InternetHostSecurityManager_QueryCustomPolicy().