ReactOS 0.4.15-dev-8119-g4fb2fdb
vbscript.c
Go to the documentation of this file.
1/*
2 * Copyright 2011 Jacek Caban for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19
20#include <assert.h>
21
22#include "vbscript.h"
23#include "objsafe.h"
24
25#include "wine/debug.h"
26
28
29#ifdef _WIN64
30
31#define CTXARG_T DWORDLONG
32#define IActiveScriptDebugVtbl IActiveScriptDebug64Vtbl
33#define IActiveScriptParseVtbl IActiveScriptParse64Vtbl
34#define IActiveScriptParseProcedure2Vtbl IActiveScriptParseProcedure2_64Vtbl
35
36#else
37
38#define CTXARG_T DWORD
39#define IActiveScriptDebugVtbl IActiveScriptDebug32Vtbl
40#define IActiveScriptParseVtbl IActiveScriptParse32Vtbl
41#define IActiveScriptParseProcedure2Vtbl IActiveScriptParseProcedure2_32Vtbl
42
43#endif
44
45struct VBScript {
47 IActiveScriptDebug IActiveScriptDebug_iface;
48 IActiveScriptParse IActiveScriptParse_iface;
49 IActiveScriptParseProcedure2 IActiveScriptParseProcedure2_iface;
51
53
58};
59
60typedef struct {
63 EXCEPINFO ei;
65
67{
68 if(This->state == state)
69 return;
70
71 This->state = state;
72 if(This->ctx->site)
73 IActiveScriptSite_OnStateChange(This->ctx->site, state);
74}
75
77{
78 return This->state == SCRIPTSTATE_STARTED
79 || This->state == SCRIPTSTATE_CONNECTED
80 || This->state == SCRIPTSTATE_DISCONNECTED;
81}
82
84{
85 code->pending_exec = FALSE;
86 return exec_script(ctx, TRUE, &code->main_code, NULL, NULL, res);
87}
88
90{
91 vbscode_t *iter;
92
93 LIST_FOR_EACH_ENTRY(iter, &ctx->code_list, vbscode_t, entry) {
94 if(iter->pending_exec)
96 }
97}
98
100{
103
104 LIST_FOR_EACH_ENTRY(item, &ctx->named_items, named_item_t, entry) {
105 if((item->flags & flags) == flags && !wcsicmp(item->name, name)) {
106 if(!item->disp) {
107 IUnknown *unk;
108
109 hres = IActiveScriptSite_GetItemInfo(ctx->site, item->name,
110 SCRIPTINFO_IUNKNOWN, &unk, NULL);
111 if(FAILED(hres)) {
112 WARN("GetItemInfo failed: %08x\n", hres);
113 continue;
114 }
115
116 hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&item->disp);
117 IUnknown_Release(unk);
118 if(FAILED(hres)) {
119 WARN("object does not implement IDispatch\n");
120 continue;
121 }
122 }
123
124 return item->disp;
125 }
126 }
127
128 return NULL;
129}
130
132{
133 class_desc_t *class_desc;
134
136 clear_ei(&ctx->ei);
137
138 release_dynamic_vars(ctx->global_vars);
139 ctx->global_vars = NULL;
140
141 while(!list_empty(&ctx->named_items)) {
142 named_item_t *iter = LIST_ENTRY(list_head(&ctx->named_items), named_item_t, entry);
143
144 list_remove(&iter->entry);
145 if(iter->disp)
146 IDispatch_Release(iter->disp);
147 heap_free(iter->name);
148 heap_free(iter);
149 }
150
151 while(ctx->procs) {
152 class_desc = ctx->procs;
153 ctx->procs = class_desc->next;
154
155 heap_free(class_desc);
156 }
157
158 if(ctx->host_global) {
159 IDispatch_Release(ctx->host_global);
160 ctx->host_global = NULL;
161 }
162
163 if(ctx->secmgr) {
164 IInternetHostSecurityManager_Release(ctx->secmgr);
165 ctx->secmgr = NULL;
166 }
167
168 if(ctx->site) {
169 IActiveScriptSite_Release(ctx->site);
170 ctx->site = NULL;
171 }
172
173 if(ctx->script_obj) {
174 ScriptDisp *script_obj = ctx->script_obj;
175
176 ctx->script_obj = NULL;
177 script_obj->ctx = NULL;
178 IDispatchEx_Release(&script_obj->IDispatchEx_iface);
179 }
180
182 heap_pool_free(&ctx->heap);
183 heap_pool_init(&ctx->heap);
184}
185
187{
188 while(!list_empty(&ctx->code_list))
190
192 heap_free(ctx);
193}
194
196{
197 switch(This->state) {
201 return;
202 /* FALLTHROUGH */
205 if(This->state == SCRIPTSTATE_DISCONNECTED)
208 break;
209 /* FALLTHROUGH */
213 release_script(This->ctx);
214 This->thread_id = 0;
215 break;
217 break;
219 }
220}
221
223{
224 return CONTAINING_RECORD(iface, VBScriptError, IActiveScriptError_iface);
225}
226
228{
230
232 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
233 *ppv = &This->IActiveScriptError_iface;
234 }else if(IsEqualGUID(riid, &IID_IActiveScriptError)) {
235 TRACE("(%p)->(IID_IActiveScriptError %p)\n", This, ppv);
236 *ppv = &This->IActiveScriptError_iface;
237 }else {
238 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
239 *ppv = NULL;
240 return E_NOINTERFACE;
241 }
242
243 IUnknown_AddRef((IUnknown*)*ppv);
244 return S_OK;
245}
246
248{
251
252 TRACE("(%p) ref=%d\n", This, ref);
253
254 return ref;
255}
256
258{
261
262 TRACE("(%p) ref=%d\n", This, ref);
263
264 if(!ref) {
266 }
267
268 return ref;
269}
270
272{
274
275 TRACE("(%p)->(%p)\n", This, excepinfo);
276
277 *excepinfo = This->ei;
278 excepinfo->bstrSource = SysAllocString(This->ei.bstrSource);
279 excepinfo->bstrDescription = SysAllocString(This->ei.bstrDescription);
280 excepinfo->bstrHelpFile = SysAllocString(This->ei.bstrHelpFile);
281 return S_OK;
282}
283
285{
287
288 FIXME("(%p)->(%p %p %p)\n", This, source_context, line, character);
289
290 if(source_context)
291 *source_context = 0;
292 if(line)
293 *line = 0;
294 if(character)
295 *character = 0;
296 return S_OK;
297}
298
300{
302 FIXME("(%p)->(%p)\n", This, source);
303 return E_NOTIMPL;
304}
305
306static const IActiveScriptErrorVtbl VBScriptErrorVtbl = {
313};
314
316{
319
320 if(!(error = heap_alloc(sizeof(*error))))
321 return E_OUTOFMEMORY;
322 error->IActiveScriptError_iface.lpVtbl = &VBScriptErrorVtbl;
323
324 error->ref = 1;
325 error->ei = ctx->ei;
326 memset(&ctx->ei, 0, sizeof(ctx->ei));
327 result = error->ei.scode;
328
329 hres = IActiveScriptSite_OnScriptError(ctx->site, &error->IActiveScriptError_iface);
330 IActiveScriptError_Release(&error->IActiveScriptError_iface);
331 return hres == S_OK ? SCRIPT_E_REPORTED : result;
332}
333
335{
336 return CONTAINING_RECORD(iface, VBScript, IActiveScript_iface);
337}
338
340{
342
344 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
345 *ppv = &This->IActiveScript_iface;
346 }else if(IsEqualGUID(riid, &IID_IActiveScript)) {
347 TRACE("(%p)->(IID_IActiveScript %p)\n", This, ppv);
348 *ppv = &This->IActiveScript_iface;
349 }else if(IsEqualGUID(riid, &IID_IActiveScriptDebug)) {
350 TRACE("(%p)->(IID_IActiveScriptDebug %p)\n", This, ppv);
351 *ppv = &This->IActiveScriptDebug_iface;
352 }else if(IsEqualGUID(riid, &IID_IActiveScriptParse)) {
353 TRACE("(%p)->(IID_IActiveScriptParse %p)\n", This, ppv);
354 *ppv = &This->IActiveScriptParse_iface;
355 }else if(IsEqualGUID(riid, &IID_IActiveScriptParseProcedure2)) {
356 TRACE("(%p)->(IID_IActiveScriptParseProcedure2 %p)\n", This, ppv);
357 *ppv = &This->IActiveScriptParseProcedure2_iface;
358 }else if(IsEqualGUID(riid, &IID_IObjectSafety)) {
359 TRACE("(%p)->(IID_IObjectSafety %p)\n", This, ppv);
360 *ppv = &This->IObjectSafety_iface;
361 }else {
362 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
363 *ppv = NULL;
364 return E_NOINTERFACE;
365 }
366
367 IUnknown_AddRef((IUnknown*)*ppv);
368 return S_OK;
369}
370
372{
375
376 TRACE("(%p) ref=%d\n", This, ref);
377
378 return ref;
379}
380
382{
385
386 TRACE("(%p) ref=%d\n", iface, ref);
387
388 if(!ref) {
390 destroy_script(This->ctx);
392 }
393
394 return ref;
395}
396
398{
400 LCID lcid;
402
403 TRACE("(%p)->(%p)\n", This, pass);
404
405 if(!pass)
406 return E_POINTER;
407
408 if(This->ctx->site)
409 return E_UNEXPECTED;
410
412 return E_UNEXPECTED;
413
414 hres = create_script_disp(This->ctx, &This->ctx->script_obj);
415 if(FAILED(hres))
416 return hres;
417
418 This->ctx->site = pass;
419 IActiveScriptSite_AddRef(This->ctx->site);
420
421 hres = IActiveScriptSite_GetLCID(This->ctx->site, &lcid);
422 if(hres == S_OK)
423 This->ctx->lcid = lcid;
424
425 if(This->is_initialized)
427 return S_OK;
428}
429
431 void **ppvObject)
432{
434 FIXME("(%p)->()\n", This);
435 return E_NOTIMPL;
436}
437
439{
441
442 TRACE("(%p)->(%d)\n", This, ss);
443
444 if(This->thread_id && GetCurrentThreadId() != This->thread_id)
445 return E_UNEXPECTED;
446
448 if(This->state == SCRIPTSTATE_CLOSED)
449 return E_UNEXPECTED;
450
452 return S_OK;
453 }
454
455 if(!This->is_initialized)
456 return E_UNEXPECTED;
457
458 switch(ss) {
460 case SCRIPTSTATE_CONNECTED: /* FIXME */
461 if(This->state == SCRIPTSTATE_CLOSED)
462 return E_UNEXPECTED;
463
465 break;
467 FIXME("unimplemented SCRIPTSTATE_INITIALIZED\n");
468 return S_OK;
470 FIXME("unimplemented SCRIPTSTATE_DISCONNECTED\n");
471 return S_OK;
472 default:
473 FIXME("unimplemented state %d\n", ss);
474 return E_NOTIMPL;
475 }
476
478 return S_OK;
479}
480
482{
484
485 TRACE("(%p)->(%p)\n", This, pssState);
486
487 if(!pssState)
488 return E_POINTER;
489
490 if(This->thread_id && This->thread_id != GetCurrentThreadId())
491 return E_UNEXPECTED;
492
493 *pssState = This->state;
494 return S_OK;
495}
496
498{
500
501 TRACE("(%p)->()\n", This);
502
503 if(This->thread_id && This->thread_id != GetCurrentThreadId())
504 return E_UNEXPECTED;
505
507 return S_OK;
508}
509
511{
514 IDispatch *disp = NULL;
516
517 TRACE("(%p)->(%s %x)\n", This, debugstr_w(pstrName), dwFlags);
518
519 if(This->thread_id != GetCurrentThreadId() || !This->ctx->site)
520 return E_UNEXPECTED;
521
522 if(dwFlags & SCRIPTITEM_GLOBALMEMBERS) {
523 IUnknown *unk;
524
525 hres = IActiveScriptSite_GetItemInfo(This->ctx->site, pstrName, SCRIPTINFO_IUNKNOWN, &unk, NULL);
526 if(FAILED(hres)) {
527 WARN("GetItemInfo failed: %08x\n", hres);
528 return hres;
529 }
530
531 hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&disp);
532 IUnknown_Release(unk);
533 if(FAILED(hres)) {
534 WARN("object does not implement IDispatch\n");
535 return hres;
536 }
537
538 if(This->ctx->host_global)
539 IDispatch_Release(This->ctx->host_global);
540 IDispatch_AddRef(disp);
541 This->ctx->host_global = disp;
542 }
543
544 item = heap_alloc(sizeof(*item));
545 if(!item) {
546 if(disp)
547 IDispatch_Release(disp);
548 return E_OUTOFMEMORY;
549 }
550
551 item->disp = disp;
552 item->flags = dwFlags;
553 item->name = heap_strdupW(pstrName);
554 if(!item->name) {
555 if(disp)
556 IDispatch_Release(disp);
558 return E_OUTOFMEMORY;
559 }
560
561 list_add_tail(&This->ctx->named_items, &item->entry);
562 return S_OK;
563}
564
566 DWORD dwMajor, DWORD dwMinor, DWORD dwFlags)
567{
569 FIXME("(%p)->()\n", This);
570 return E_NOTIMPL;
571}
572
573static HRESULT WINAPI VBScript_GetScriptDispatch(IActiveScript *iface, LPCOLESTR pstrItemName, IDispatch **ppdisp)
574{
576
577 TRACE("(%p)->(%p)\n", This, ppdisp);
578
579 if(!ppdisp)
580 return E_POINTER;
581
582 if(This->thread_id != GetCurrentThreadId() || !This->ctx->script_obj) {
583 *ppdisp = NULL;
584 return E_UNEXPECTED;
585 }
586
587 *ppdisp = (IDispatch*)&This->ctx->script_obj->IDispatchEx_iface;
588 IDispatch_AddRef(*ppdisp);
589 return S_OK;
590}
591
593 SCRIPTTHREADID *pstridThread)
594{
596 FIXME("(%p)->()\n", This);
597 return E_NOTIMPL;
598}
599
601 DWORD dwWin32ThreadId, SCRIPTTHREADID *pstidThread)
602{
604 FIXME("(%p)->()\n", This);
605 return E_NOTIMPL;
606}
607
609 SCRIPTTHREADID stidThread, SCRIPTTHREADSTATE *pstsState)
610{
612 FIXME("(%p)->()\n", This);
613 return E_NOTIMPL;
614}
615
617 SCRIPTTHREADID stidThread, const EXCEPINFO *pexcepinfo, DWORD dwFlags)
618{
620 FIXME("(%p)->()\n", This);
621 return E_NOTIMPL;
622}
623
625{
627 FIXME("(%p)->()\n", This);
628 return E_NOTIMPL;
629}
630
631static const IActiveScriptVtbl VBScriptVtbl = {
648};
649
650static inline VBScript *impl_from_IActiveScriptDebug(IActiveScriptDebug *iface)
651{
652 return CONTAINING_RECORD(iface, VBScript, IActiveScriptDebug_iface);
653}
654
655static HRESULT WINAPI VBScriptDebug_QueryInterface(IActiveScriptDebug *iface, REFIID riid, void **ppv)
656{
658 return IActiveScript_QueryInterface(&This->IActiveScript_iface, riid, ppv);
659}
660
661static ULONG WINAPI VBScriptDebug_AddRef(IActiveScriptDebug *iface)
662{
664 return IActiveScript_AddRef(&This->IActiveScript_iface);
665}
666
667static ULONG WINAPI VBScriptDebug_Release(IActiveScriptDebug *iface)
668{
670 return IActiveScript_Release(&This->IActiveScript_iface);
671}
672
673static HRESULT WINAPI VBScriptDebug_GetScriptTextAttributes(IActiveScriptDebug *iface,
674 LPCOLESTR code, ULONG len, LPCOLESTR delimiter, DWORD flags, SOURCE_TEXT_ATTR *attr)
675{
677 FIXME("(%p)->(%s %u %s %#x %p)\n", This, debugstr_w(code), len,
679 return E_NOTIMPL;
680}
681
683 LPCOLESTR code, ULONG len, LPCOLESTR delimiter, DWORD flags, SOURCE_TEXT_ATTR *attr)
684{
686 FIXME("(%p)->(%s %u %s %#x %p)\n", This, debugstr_w(code), len,
688 return E_NOTIMPL;
689}
690
693{
695 FIXME("(%p)->(%s %u %u %p)\n", This, wine_dbgstr_longlong(source), offset, len, ret);
696 return E_NOTIMPL;
697}
698
706};
707
708static inline VBScript *impl_from_IActiveScriptParse(IActiveScriptParse *iface)
709{
710 return CONTAINING_RECORD(iface, VBScript, IActiveScriptParse_iface);
711}
712
713static HRESULT WINAPI VBScriptParse_QueryInterface(IActiveScriptParse *iface, REFIID riid, void **ppv)
714{
716 return IActiveScript_QueryInterface(&This->IActiveScript_iface, riid, ppv);
717}
718
719static ULONG WINAPI VBScriptParse_AddRef(IActiveScriptParse *iface)
720{
722 return IActiveScript_AddRef(&This->IActiveScript_iface);
723}
724
725static ULONG WINAPI VBScriptParse_Release(IActiveScriptParse *iface)
726{
728 return IActiveScript_Release(&This->IActiveScript_iface);
729}
730
731static HRESULT WINAPI VBScriptParse_InitNew(IActiveScriptParse *iface)
732{
734
735 TRACE("(%p)\n", This);
736
737 if(This->is_initialized)
738 return E_UNEXPECTED;
739 This->is_initialized = TRUE;
740
741 if(This->ctx->site)
743 return S_OK;
744}
745
746static HRESULT WINAPI VBScriptParse_AddScriptlet(IActiveScriptParse *iface,
747 LPCOLESTR pstrDefaultName, LPCOLESTR pstrCode, LPCOLESTR pstrItemName,
748 LPCOLESTR pstrSubItemName, LPCOLESTR pstrEventName, LPCOLESTR pstrDelimiter,
749 CTXARG_T dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags,
750 BSTR *pbstrName, EXCEPINFO *pexcepinfo)
751{
753 FIXME("(%p)->(%s %s %s %s %s %s %s %u %x %p %p)\n", This, debugstr_w(pstrDefaultName),
754 debugstr_w(pstrCode), debugstr_w(pstrItemName), debugstr_w(pstrSubItemName),
755 debugstr_w(pstrEventName), debugstr_w(pstrDelimiter), wine_dbgstr_longlong(dwSourceContextCookie),
756 ulStartingLineNumber, dwFlags, pbstrName, pexcepinfo);
757 return E_NOTIMPL;
758}
759
760static HRESULT WINAPI VBScriptParse_ParseScriptText(IActiveScriptParse *iface,
761 LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext,
762 LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLine,
763 DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
764{
769
770 TRACE("(%p)->(%s %s %p %s %s %u %x %p %p)\n", This, debugstr_w(pstrCode),
771 debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter),
772 wine_dbgstr_longlong(dwSourceContextCookie), ulStartingLine, dwFlags, pvarResult, pexcepinfo);
773
774 if(This->thread_id != GetCurrentThreadId() || This->state == SCRIPTSTATE_CLOSED)
775 return E_UNEXPECTED;
776
777 if(pstrItemName) {
778 context = lookup_named_item(This->ctx, pstrItemName, 0);
779 if(!context) {
780 WARN("Inknown context %s\n", debugstr_w(pstrItemName));
781 return E_INVALIDARG;
782 }
783 }
784
785 hres = compile_script(This->ctx, pstrCode, pstrDelimiter, dwFlags, &code);
786 if(FAILED(hres))
787 return hres;
788
789 if(context)
790 IDispatch_AddRef(code->context = context);
791
792 if(!(dwFlags & SCRIPTTEXT_ISEXPRESSION) && !is_started(This)) {
793 code->pending_exec = TRUE;
794 return S_OK;
795 }
796
797 return exec_global_code(This->ctx, code, pvarResult);
798}
799
807};
808
809static inline VBScript *impl_from_IActiveScriptParseProcedure2(IActiveScriptParseProcedure2 *iface)
810{
811 return CONTAINING_RECORD(iface, VBScript, IActiveScriptParseProcedure2_iface);
812}
813
814static HRESULT WINAPI VBScriptParseProcedure_QueryInterface(IActiveScriptParseProcedure2 *iface, REFIID riid, void **ppv)
815{
817 return IActiveScript_QueryInterface(&This->IActiveScript_iface, riid, ppv);
818}
819
820static ULONG WINAPI VBScriptParseProcedure_AddRef(IActiveScriptParseProcedure2 *iface)
821{
823 return IActiveScript_AddRef(&This->IActiveScript_iface);
824}
825
826static ULONG WINAPI VBScriptParseProcedure_Release(IActiveScriptParseProcedure2 *iface)
827{
829 return IActiveScript_Release(&This->IActiveScript_iface);
830}
831
832static HRESULT WINAPI VBScriptParseProcedure_ParseProcedureText(IActiveScriptParseProcedure2 *iface,
833 LPCOLESTR pstrCode, LPCOLESTR pstrFormalParams, LPCOLESTR pstrProcedureName,
834 LPCOLESTR pstrItemName, IUnknown *punkContext, LPCOLESTR pstrDelimiter,
835 CTXARG_T dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags, IDispatch **ppdisp)
836{
839 vbdisp_t *vbdisp;
841
842 TRACE("(%p)->(%s %s %s %s %p %s %s %u %x %p)\n", This, debugstr_w(pstrCode), debugstr_w(pstrFormalParams),
843 debugstr_w(pstrProcedureName), debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter),
844 wine_dbgstr_longlong(dwSourceContextCookie), ulStartingLineNumber, dwFlags, ppdisp);
845
846 if(This->thread_id != GetCurrentThreadId() || This->state == SCRIPTSTATE_CLOSED)
847 return E_UNEXPECTED;
848
849 hres = compile_procedure(This->ctx, pstrCode, pstrDelimiter, dwFlags, &desc);
850 if(FAILED(hres))
851 return hres;
852
853 hres = create_vbdisp(desc, &vbdisp);
854 if(FAILED(hres))
855 return hres;
856
857 *ppdisp = (IDispatch*)&vbdisp->IDispatchEx_iface;
858 return S_OK;
859}
860
866};
867
869{
870 return CONTAINING_RECORD(iface, VBScript, IObjectSafety_iface);
871}
872
874{
876 return IActiveScript_QueryInterface(&This->IActiveScript_iface, riid, ppv);
877}
878
880{
882 return IActiveScript_AddRef(&This->IActiveScript_iface);
883}
884
886{
888 return IActiveScript_Release(&This->IActiveScript_iface);
889}
890
891#define SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER)
892
894 DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
895{
897
898 TRACE("(%p)->(%s %p %p)\n", This, debugstr_guid(riid), pdwSupportedOptions, pdwEnabledOptions);
899
900 if(!pdwSupportedOptions || !pdwEnabledOptions)
901 return E_POINTER;
902
903 *pdwSupportedOptions = SUPPORTED_OPTIONS;
904 *pdwEnabledOptions = This->ctx->safeopt;
905 return S_OK;
906}
907
909 DWORD dwOptionSetMask, DWORD dwEnabledOptions)
910{
912
913 TRACE("(%p)->(%s %x %x)\n", This, debugstr_guid(riid), dwOptionSetMask, dwEnabledOptions);
914
915 if(dwOptionSetMask & ~SUPPORTED_OPTIONS)
916 return E_FAIL;
917
918 This->ctx->safeopt = (dwEnabledOptions & dwOptionSetMask) | (This->ctx->safeopt & ~dwOptionSetMask) | INTERFACE_USES_DISPEX;
919 return S_OK;
920}
921
922static const IObjectSafetyVtbl VBScriptSafetyVtbl = {
928};
929
931{
933 VBScript *ret;
935
936 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppv);
937
938 ret = heap_alloc_zero(sizeof(*ret));
939 if(!ret)
940 return E_OUTOFMEMORY;
941
942 ret->IActiveScript_iface.lpVtbl = &VBScriptVtbl;
943 ret->IActiveScriptDebug_iface.lpVtbl = &VBScriptDebugVtbl;
944 ret->IActiveScriptParse_iface.lpVtbl = &VBScriptParseVtbl;
945 ret->IActiveScriptParseProcedure2_iface.lpVtbl = &VBScriptParseProcedureVtbl;
946 ret->IObjectSafety_iface.lpVtbl = &VBScriptSafetyVtbl;
947
948 ret->ref = 1;
950
951 ctx = ret->ctx = heap_alloc_zero(sizeof(*ctx));
952 if(!ctx) {
953 heap_free(ret);
954 return E_OUTOFMEMORY;
955 }
956
957 ctx->safeopt = INTERFACE_USES_DISPEX;
958 heap_pool_init(&ctx->heap);
959 list_init(&ctx->objects);
960 list_init(&ctx->code_list);
961 list_init(&ctx->named_items);
962
964 if(FAILED(hres)) {
965 IActiveScript_Release(&ret->IActiveScript_iface);
966 return hres;
967 }
968
969 hres = IActiveScript_QueryInterface(&ret->IActiveScript_iface, riid, ppv);
970 IActiveScript_Release(&ret->IActiveScript_iface);
971 return hres;
972}
973
974typedef struct {
975 IServiceProvider IServiceProvider_iface;
976
977 LONG ref;
978
980} AXSite;
981
983{
984 return CONTAINING_RECORD(iface, AXSite, IServiceProvider_iface);
985}
986
988{
990
992 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
993 *ppv = &This->IServiceProvider_iface;
994 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
995 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
996 *ppv = &This->IServiceProvider_iface;
997 }else {
998 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
999 *ppv = NULL;
1000 return E_NOINTERFACE;
1001 }
1002
1003 IUnknown_AddRef((IUnknown*)*ppv);
1004 return S_OK;
1005}
1006
1008{
1011
1012 TRACE("(%p) ref=%d\n", This, ref);
1013
1014 return ref;
1015}
1016
1018{
1021
1022 TRACE("(%p) ref=%d\n", This, ref);
1023
1024 if(!ref)
1025 heap_free(This);
1026
1027 return ref;
1028}
1029
1031 REFGUID guidService, REFIID riid, void **ppv)
1032{
1034
1035 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1036
1037 return IServiceProvider_QueryService(This->sp, guidService, riid, ppv);
1038}
1039
1040static IServiceProviderVtbl AXSiteVtbl = {
1045};
1046
1048{
1050 AXSite *ret;
1051 HRESULT hres;
1052
1053 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IServiceProvider, (void**)&sp);
1054 if(FAILED(hres)) {
1055 ERR("Could not get IServiceProvider iface: %08x\n", hres);
1056 return NULL;
1057 }
1058
1059 ret = heap_alloc(sizeof(*ret));
1060 if(!ret) {
1061 IServiceProvider_Release(sp);
1062 return NULL;
1063 }
1064
1065 ret->IServiceProvider_iface.lpVtbl = &AXSiteVtbl;
1066 ret->ref = 1;
1067 ret->sp = sp;
1068
1069 return (IUnknown*)&ret->IServiceProvider_iface;
1070}
WORD SOURCE_TEXT_ATTR
Definition: activdbg.idl:83
enum tagSCRIPTTHREADSTATE SCRIPTTHREADSTATE
DWORD SCRIPTTHREADID
Definition: activscp.idl:86
@ SCRIPTSTATE_INITIALIZED
Definition: activscp.idl:62
@ SCRIPTSTATE_DISCONNECTED
Definition: activscp.idl:60
@ SCRIPTSTATE_STARTED
Definition: activscp.idl:58
@ SCRIPTSTATE_UNINITIALIZED
Definition: activscp.idl:57
@ SCRIPTSTATE_CLOSED
Definition: activscp.idl:61
@ SCRIPTSTATE_CONNECTED
Definition: activscp.idl:59
enum tagSCRIPTSTATE SCRIPTSTATE
static int state
Definition: maze.c:121
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static int list_empty(struct list_entry *head)
Definition: list.h:58
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_init(struct list_entry *head)
Definition: list.h:51
const GUID IID_IUnknown
#define FIXME(fmt,...)
Definition: debug.h:114
#define WARN(fmt,...)
Definition: debug.h:115
#define ERR(fmt,...)
Definition: debug.h:113
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static BOOL CALLBACK collect_objects(LPCDIDEVICEOBJECTINSTANCEW lpddo, LPVOID pvRef)
Definition: config.c:57
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
OLECHAR * BSTR
Definition: compat.h:2293
#define wcsicmp
Definition: compat.h:15
static HRESULT WINAPI VBScriptError_QueryInterface(IActiveScriptError *iface, REFIID riid, void **ppv)
Definition: vbscript.c:227
static HRESULT WINAPI VBScriptDebug_GetScriptletTextAttributes(IActiveScriptDebug *iface, LPCOLESTR code, ULONG len, LPCOLESTR delimiter, DWORD flags, SOURCE_TEXT_ATTR *attr)
Definition: vbscript.c:682
static HRESULT WINAPI VBScriptParseProcedure_ParseProcedureText(IActiveScriptParseProcedure2 *iface, LPCOLESTR pstrCode, LPCOLESTR pstrFormalParams, LPCOLESTR pstrProcedureName, LPCOLESTR pstrItemName, IUnknown *punkContext, LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags, IDispatch **ppdisp)
Definition: vbscript.c:832
static HRESULT WINAPI VBScript_Clone(IActiveScript *iface, IActiveScript **ppscript)
Definition: vbscript.c:624
static ULONG WINAPI VBScriptDebug_AddRef(IActiveScriptDebug *iface)
Definition: vbscript.c:661
static HRESULT WINAPI VBScriptParse_ParseScriptText(IActiveScriptParse *iface, LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext, LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLine, DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
Definition: vbscript.c:760
static HRESULT WINAPI VBScriptSafety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv)
Definition: vbscript.c:873
static HRESULT WINAPI VBScriptDebug_EnumCodeContextsOfPosition(IActiveScriptDebug *iface, CTXARG_T source, ULONG offset, ULONG len, IEnumDebugCodeContexts **ret)
Definition: vbscript.c:691
static HRESULT WINAPI VBScriptError_GetExceptionInfo(IActiveScriptError *iface, EXCEPINFO *excepinfo)
Definition: vbscript.c:271
static HRESULT WINAPI VBScript_GetCurrentScriptThreadID(IActiveScript *iface, SCRIPTTHREADID *pstridThread)
Definition: vbscript.c:592
static HRESULT WINAPI VBScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE ss)
Definition: vbscript.c:438
HRESULT report_script_error(script_ctx_t *ctx)
Definition: vbscript.c:315
static void exec_queued_code(script_ctx_t *ctx)
Definition: vbscript.c:89
#define SUPPORTED_OPTIONS
Definition: vbscript.c:891
static HRESULT WINAPI VBScript_GetScriptState(IActiveScript *iface, SCRIPTSTATE *pssState)
Definition: vbscript.c:481
static HRESULT exec_global_code(script_ctx_t *ctx, vbscode_t *code, VARIANT *res)
Definition: vbscript.c:83
static HRESULT WINAPI VBScriptDebug_QueryInterface(IActiveScriptDebug *iface, REFIID riid, void **ppv)
Definition: vbscript.c:655
static HRESULT WINAPI VBScriptSafety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
Definition: vbscript.c:893
static ULONG WINAPI VBScriptParse_Release(IActiveScriptParse *iface)
Definition: vbscript.c:725
static HRESULT WINAPI VBScriptError_GetSourceLineText(IActiveScriptError *iface, BSTR *source)
Definition: vbscript.c:299
static HRESULT WINAPI VBScript_QueryInterface(IActiveScript *iface, REFIID riid, void **ppv)
Definition: vbscript.c:339
#define IActiveScriptParseProcedure2Vtbl
Definition: vbscript.c:41
static ULONG WINAPI VBScriptParseProcedure_AddRef(IActiveScriptParseProcedure2 *iface)
Definition: vbscript.c:820
static HRESULT WINAPI VBScript_SetScriptSite(IActiveScript *iface, IActiveScriptSite *pass)
Definition: vbscript.c:397
static const IActiveScriptParseProcedure2Vtbl VBScriptParseProcedureVtbl
Definition: vbscript.c:861
static HRESULT WINAPI VBScript_GetScriptSite(IActiveScript *iface, REFIID riid, void **ppvObject)
Definition: vbscript.c:430
static const IActiveScriptDebugVtbl VBScriptDebugVtbl
Definition: vbscript.c:699
static ULONG WINAPI VBScriptError_AddRef(IActiveScriptError *iface)
Definition: vbscript.c:247
static HRESULT WINAPI VBScript_InterruptScriptThread(IActiveScript *iface, SCRIPTTHREADID stidThread, const EXCEPINFO *pexcepinfo, DWORD dwFlags)
Definition: vbscript.c:616
static HRESULT WINAPI VBScript_Close(IActiveScript *iface)
Definition: vbscript.c:497
static HRESULT WINAPI VBScript_GetScriptThreadState(IActiveScript *iface, SCRIPTTHREADID stidThread, SCRIPTTHREADSTATE *pstsState)
Definition: vbscript.c:608
static ULONG WINAPI AXSite_Release(IServiceProvider *iface)
Definition: vbscript.c:1017
static HRESULT WINAPI VBScript_GetScriptDispatch(IActiveScript *iface, LPCOLESTR pstrItemName, IDispatch **ppdisp)
Definition: vbscript.c:573
static IServiceProviderVtbl AXSiteVtbl
Definition: vbscript.c:1040
#define IActiveScriptDebugVtbl
Definition: vbscript.c:39
#define IActiveScriptParseVtbl
Definition: vbscript.c:40
static HRESULT WINAPI VBScriptDebug_GetScriptTextAttributes(IActiveScriptDebug *iface, LPCOLESTR code, ULONG len, LPCOLESTR delimiter, DWORD flags, SOURCE_TEXT_ATTR *attr)
Definition: vbscript.c:673
static HRESULT WINAPI VBScriptParse_QueryInterface(IActiveScriptParse *iface, REFIID riid, void **ppv)
Definition: vbscript.c:713
IUnknown * create_ax_site(script_ctx_t *ctx)
Definition: vbscript.c:1047
static const IObjectSafetyVtbl VBScriptSafetyVtbl
Definition: vbscript.c:922
static ULONG WINAPI VBScriptDebug_Release(IActiveScriptDebug *iface)
Definition: vbscript.c:667
static void destroy_script(script_ctx_t *ctx)
Definition: vbscript.c:186
static void decrease_state(VBScript *This, SCRIPTSTATE state)
Definition: vbscript.c:195
static AXSite * impl_from_IServiceProvider(IServiceProvider *iface)
Definition: vbscript.c:982
static HRESULT WINAPI VBScript_AddNamedItem(IActiveScript *iface, LPCOLESTR pstrName, DWORD dwFlags)
Definition: vbscript.c:510
static VBScript * impl_from_IActiveScriptParse(IActiveScriptParse *iface)
Definition: vbscript.c:708
static ULONG WINAPI VBScriptParseProcedure_Release(IActiveScriptParseProcedure2 *iface)
Definition: vbscript.c:826
static ULONG WINAPI VBScriptSafety_Release(IObjectSafety *iface)
Definition: vbscript.c:885
static HRESULT WINAPI VBScriptParse_AddScriptlet(IActiveScriptParse *iface, LPCOLESTR pstrDefaultName, LPCOLESTR pstrCode, LPCOLESTR pstrItemName, LPCOLESTR pstrSubItemName, LPCOLESTR pstrEventName, LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags, BSTR *pbstrName, EXCEPINFO *pexcepinfo)
Definition: vbscript.c:746
static ULONG WINAPI AXSite_AddRef(IServiceProvider *iface)
Definition: vbscript.c:1007
static ULONG WINAPI VBScriptSafety_AddRef(IObjectSafety *iface)
Definition: vbscript.c:879
static HRESULT WINAPI VBScriptParse_InitNew(IActiveScriptParse *iface)
Definition: vbscript.c:731
static HRESULT WINAPI VBScript_AddTypeLib(IActiveScript *iface, REFGUID rguidTypeLib, DWORD dwMajor, DWORD dwMinor, DWORD dwFlags)
Definition: vbscript.c:565
#define CTXARG_T
Definition: vbscript.c:38
static HRESULT WINAPI VBScriptParseProcedure_QueryInterface(IActiveScriptParseProcedure2 *iface, REFIID riid, void **ppv)
Definition: vbscript.c:814
static const IActiveScriptParseVtbl VBScriptParseVtbl
Definition: vbscript.c:800
static BOOL is_started(VBScript *This)
Definition: vbscript.c:76
static VBScript * impl_from_IActiveScriptParseProcedure2(IActiveScriptParseProcedure2 *iface)
Definition: vbscript.c:809
static ULONG WINAPI VBScript_Release(IActiveScript *iface)
Definition: vbscript.c:381
static ULONG WINAPI VBScriptParse_AddRef(IActiveScriptParse *iface)
Definition: vbscript.c:719
static VBScript * impl_from_IActiveScript(IActiveScript *iface)
Definition: vbscript.c:334
static HRESULT WINAPI VBScript_GetScriptThreadID(IActiveScript *iface, DWORD dwWin32ThreadId, SCRIPTTHREADID *pstidThread)
Definition: vbscript.c:600
static ULONG WINAPI VBScript_AddRef(IActiveScript *iface)
Definition: vbscript.c:371
static VBScript * impl_from_IActiveScriptDebug(IActiveScriptDebug *iface)
Definition: vbscript.c:650
static void change_state(VBScript *This, SCRIPTSTATE state)
Definition: vbscript.c:66
static ULONG WINAPI VBScriptError_Release(IActiveScriptError *iface)
Definition: vbscript.c:257
static HRESULT WINAPI VBScriptSafety_SetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid, DWORD dwOptionSetMask, DWORD dwEnabledOptions)
Definition: vbscript.c:908
static HRESULT WINAPI AXSite_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
Definition: vbscript.c:987
static HRESULT WINAPI VBScriptError_GetSourcePosition(IActiveScriptError *iface, DWORD *source_context, ULONG *line, LONG *character)
Definition: vbscript.c:284
static const IActiveScriptVtbl VBScriptVtbl
Definition: vbscript.c:631
static const IActiveScriptErrorVtbl VBScriptErrorVtbl
Definition: vbscript.c:306
static HRESULT WINAPI AXSite_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, void **ppv)
Definition: vbscript.c:1030
static void release_script(script_ctx_t *ctx)
Definition: vbscript.c:131
IDispatch * lookup_named_item(script_ctx_t *ctx, const WCHAR *name, unsigned flags)
Definition: vbscript.c:99
HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, void **ppv)
Definition: vbscript.c:930
static VBScriptError * impl_from_IActiveScriptError(IActiveScriptError *iface)
Definition: vbscript.c:222
static VBScript * impl_from_IObjectSafety(IObjectSafety *iface)
Definition: vbscript.c:868
void clear_ei(script_ctx_t *ctx)
Definition: engine.c:430
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
GLuint64EXT * result
Definition: glext.h:11304
GLintptr offset
Definition: glext.h:5920
HRESULT exec_script(HTMLInnerWindow *, const WCHAR *, const WCHAR *, VARIANT *) DECLSPEC_HIDDEN
Definition: script.c:1245
#define ss
Definition: i386-dis.c:441
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define InterlockedCompareExchange
Definition: interlocked.h:104
void release_dynamic_vars(dynamic_var_t *var)
Definition: interp.c:2044
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
uint32_t entry
Definition: isohybrid.c:63
HRESULT compile_script(script_ctx_t *ctx, const WCHAR *code, const WCHAR *args, const WCHAR *delimiter, BOOL from_eval, BOOL use_decode, bytecode_t **ret)
Definition: compile.c:2461
HRESULT init_global(script_ctx_t *ctx)
Definition: global.c:1105
void heap_pool_free(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:169
void heap_pool_init(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:71
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
#define error(str)
Definition: mkdosfs.c:1605
static const WCHAR desc[]
Definition: protectdata.c:36
HRESULT hres
Definition: protocol.c:465
static EXCEPINFO excepinfo
Definition: automation.c:50
static const WCHAR sp[]
Definition: suminfo.c:287
const char * delimiter
Definition: string.c:1566
static ATOM item
Definition: dde.c:856
#define DEFAULT_UNREACHABLE
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
const GUID IID_IDispatch
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
DWORD LCID
Definition: nls.h:13
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
script_ctx_t * ctx
Definition: vbscript.h:138
IDispatchEx IDispatchEx_iface
Definition: vbscript.h:131
EXCEPINFO ei
Definition: vbscript.c:63
IActiveScriptError IActiveScriptError_iface
Definition: vbscript.c:61
LONG thread_id
Definition: vbscript.c:56
IActiveScriptParseProcedure2 IActiveScriptParseProcedure2_iface
Definition: vbscript.c:49
script_ctx_t * ctx
Definition: vbscript.c:55
BOOL is_initialized
Definition: vbscript.c:57
SCRIPTSTATE state
Definition: vbscript.c:54
IActiveScriptDebug IActiveScriptDebug_iface
Definition: vbscript.c:47
LONG ref
Definition: vbscript.c:52
IActiveScriptParse IActiveScriptParse_iface
Definition: vbscript.c:48
IActiveScript IActiveScript_iface
Definition: vbscript.c:46
IObjectSafety IObjectSafety_iface
Definition: vbscript.c:50
Definition: scsiwmi.h:51
struct _class_desc_t * next
Definition: vbscript.h:113
IDispatchEx IDispatchEx_iface
Definition: vbscript.h:117
BOOL pending_exec
Definition: vbscript.h:342
Definition: cookie.c:202
Definition: inflate.c:139
Definition: http.c:7252
Definition: parser.c:49
Definition: list.h:15
Definition: name.c:39
struct list entry
Definition: vbscript.h:68
LPWSTR name
Definition: jscript.h:365
IDispatch * disp
Definition: jscript.h:363
Definition: send.c:48
#define LIST_ENTRY(type)
Definition: queue.h:175
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
pass
Definition: typegen.h:25
HRESULT create_vbdisp(const class_desc_t *desc, vbdisp_t **ret)
Definition: vbdisp.c:470
HRESULT create_script_disp(script_ctx_t *ctx, ScriptDisp **ret)
Definition: vbdisp.c:819
HRESULT compile_procedure(script_ctx_t *script, const WCHAR *src, const WCHAR *delimiter, DWORD flags, class_desc_t **ret)
Definition: compile.c:1930
void release_vbscode(vbscode_t *code)
Definition: compile.c:1768
void detach_global_objects(script_ctx_t *ctx)
Definition: global.c:2855
int ret
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_UNEXPECTED
Definition: winerror.h:2456
#define E_POINTER
Definition: winerror.h:2365
__wchar_t WCHAR
Definition: xmlstorage.h:180