ReactOS 0.4.16-dev-297-gc569aee
vbscript.h
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#pragma once
20
21#include <stdarg.h>
22#include <stdint.h>
23
24#define COBJMACROS
25
26#include "windef.h"
27#include "winbase.h"
28#include "ole2.h"
29#include "dispex.h"
30#include "activscp.h"
31#include "activdbg.h"
32
33#ifdef __REACTOS__
34#include <initguid.h>
35#endif
36#include "vbscript_classes.h"
37#include "vbscript_defs.h"
38
39#include "wine/heap.h"
40#include "wine/list.h"
41
42typedef struct {
43 void **blocks;
44 DWORD block_cnt;
45 DWORD last_block;
47 BOOL mark;
48 struct list custom_blocks;
50
57
62
63typedef struct named_item_t {
64 IDispatch *disp;
67
68 struct list entry;
70
71typedef enum {
77
78typedef struct {
79 unsigned dim_cnt;
82
83typedef struct {
86 const WCHAR *name;
88
89typedef struct {
90 const WCHAR *name;
95
96typedef struct _class_desc_t {
97 const WCHAR *name;
99
102 unsigned func_cnt;
104
105 unsigned prop_cnt;
107
108 unsigned array_cnt;
110
112
115
116struct _vbdisp_t {
118
121 struct list entry;
122
126};
127
129
130typedef struct {
133
137
139} ScriptDisp;
140
142
143typedef struct {
150
159
161
162static inline unsigned arg_cnt(const DISPPARAMS *dp)
163{
164 return dp->cArgs - dp->cNamedArgs;
165}
166
167static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i)
168{
169 return dp->rgvarg + dp->cArgs-i-1;
170}
171
172typedef struct _dynamic_var_t {
175 const WCHAR *name;
178
179struct _script_ctx_t {
181 LCID lcid;
182
185
187
189
192
193 EXCEPINFO ei;
194
199
201
202 struct list objects;
205};
206
209
211
212typedef enum {
221
222#define OP_LIST \
223 X(add, 1, 0, 0) \
224 X(and, 1, 0, 0) \
225 X(assign_ident, 1, ARG_BSTR, ARG_UINT) \
226 X(assign_member, 1, ARG_BSTR, ARG_UINT) \
227 X(bool, 1, ARG_INT, 0) \
228 X(catch, 1, ARG_ADDR, ARG_UINT) \
229 X(case, 0, ARG_ADDR, 0) \
230 X(concat, 1, 0, 0) \
231 X(const, 1, ARG_BSTR, 0) \
232 X(dim, 1, ARG_BSTR, ARG_UINT) \
233 X(div, 1, 0, 0) \
234 X(double, 1, ARG_DOUBLE, 0) \
235 X(empty, 1, 0, 0) \
236 X(enumnext, 0, ARG_ADDR, ARG_BSTR) \
237 X(equal, 1, 0, 0) \
238 X(hres, 1, ARG_UINT, 0) \
239 X(errmode, 1, ARG_INT, 0) \
240 X(eqv, 1, 0, 0) \
241 X(exp, 1, 0, 0) \
242 X(gt, 1, 0, 0) \
243 X(gteq, 1, 0, 0) \
244 X(icall, 1, ARG_BSTR, ARG_UINT) \
245 X(icallv, 1, ARG_BSTR, ARG_UINT) \
246 X(idiv, 1, 0, 0) \
247 X(imp, 1, 0, 0) \
248 X(incc, 1, ARG_BSTR, 0) \
249 X(int, 1, ARG_INT, 0) \
250 X(is, 1, 0, 0) \
251 X(jmp, 0, ARG_ADDR, 0) \
252 X(jmp_false, 0, ARG_ADDR, 0) \
253 X(jmp_true, 0, ARG_ADDR, 0) \
254 X(lt, 1, 0, 0) \
255 X(lteq, 1, 0, 0) \
256 X(mcall, 1, ARG_BSTR, ARG_UINT) \
257 X(mcallv, 1, ARG_BSTR, ARG_UINT) \
258 X(me, 1, 0, 0) \
259 X(mod, 1, 0, 0) \
260 X(mul, 1, 0, 0) \
261 X(neg, 1, 0, 0) \
262 X(nequal, 1, 0, 0) \
263 X(new, 1, ARG_STR, 0) \
264 X(newenum, 1, 0, 0) \
265 X(not, 1, 0, 0) \
266 X(nothing, 1, 0, 0) \
267 X(null, 1, 0, 0) \
268 X(or, 1, 0, 0) \
269 X(pop, 1, ARG_UINT, 0) \
270 X(ret, 0, 0, 0) \
271 X(retval, 1, 0, 0) \
272 X(set_ident, 1, ARG_BSTR, ARG_UINT) \
273 X(set_member, 1, ARG_BSTR, ARG_UINT) \
274 X(step, 0, ARG_ADDR, ARG_BSTR) \
275 X(stop, 1, 0, 0) \
276 X(string, 1, ARG_STR, 0) \
277 X(sub, 1, 0, 0) \
278 X(val, 1, 0, 0) \
279 X(xor, 1, 0, 0)
280
281typedef enum {
282#define X(x,n,a,b) OP_##x,
284#undef X
285 OP_LAST
287
288typedef union {
289 const WCHAR *str;
290 BSTR bstr;
291 unsigned uint;
292 LONG lng;
293 double *dbl;
295
296typedef struct {
300} instr_t;
301
302typedef struct {
303 const WCHAR *name;
305} arg_desc_t;
306
307typedef enum {
316
317typedef struct {
318 const WCHAR *name;
319} var_desc_t;
320
323 const WCHAR *name;
326 unsigned arg_cnt;
328 unsigned var_cnt;
330 unsigned array_cnt;
331 unsigned code_off;
334};
335
339
341
345
348 unsigned bstr_cnt;
350
351 struct list entry;
352};
353
360void clear_ei(EXCEPINFO*) DECLSPEC_HIDDEN;
364
366
367static inline BOOL is_int32(double d)
368{
369 return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d;
370}
371
373
375
377
378#define FACILITY_VBS 0xa
379#define MAKE_VBSERROR(code) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_VBS, code)
380
383
386
388{
389 LPWSTR ret = NULL;
390
391 if(str) {
392 DWORD size;
393
394 size = (lstrlenW(str)+1)*sizeof(WCHAR);
396 if(ret)
397 memcpy(ret, str, size);
398 }
399
400 return ret;
401}
402
403#define VBSCRIPT_BUILD_VERSION 16978
404#define VBSCRIPT_MAJOR_VERSION 5
405#define VBSCRIPT_MINOR_VERSION 8
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
Definition: list.h:37
#define NULL
Definition: types.h:112
UINT32 uint
Definition: types.h:83
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
OLECHAR * BSTR
Definition: compat.h:2293
#define lstrlenW
Definition: compat.h:750
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
GLintptr offset
Definition: glext.h:5920
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define INT32_MAX
Definition: intsafe.h:151
#define INT32_MIN
Definition: intsafe.h:124
uint32_t entry
Definition: isohybrid.c:63
#define d
Definition: ke_i.h:81
static int blocks
Definition: mkdosfs.c:527
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
static VARIANTARG static DISPID
Definition: ordinal.c:52
HRESULT map_hres
Definition: sec_mgr.c:1753
long LONG
Definition: pedump.c:60
#define REFIID
Definition: guiddef.h:118
const WCHAR * str
DWORD LCID
Definition: nls.h:13
size_t member_cnt
Definition: vbscript.h:146
LONG ref
Definition: vbscript.h:145
const builtin_prop_t * members
Definition: vbscript.h:147
IDispatch IDispatch_iface
Definition: vbscript.h:144
script_ctx_t * ctx
Definition: vbscript.h:148
unsigned ident_map_size
Definition: vbscript.h:136
LONG ref
Definition: vbscript.h:132
ident_map_t * ident_map
Definition: vbscript.h:134
script_ctx_t * ctx
Definition: vbscript.h:138
unsigned ident_map_cnt
Definition: vbscript.h:135
IDispatchEx IDispatchEx_iface
Definition: vbscript.h:131
array_desc_t * array_descs
Definition: vbscript.h:109
unsigned prop_cnt
Definition: vbscript.h:105
vbdisp_prop_desc_t * props
Definition: vbscript.h:106
vbdisp_funcprop_desc_t * funcs
Definition: vbscript.h:103
unsigned class_terminate_id
Definition: vbscript.h:101
script_ctx_t * ctx
Definition: vbscript.h:98
unsigned class_initialize_id
Definition: vbscript.h:100
unsigned func_cnt
Definition: vbscript.h:102
struct _class_desc_t * next
Definition: vbscript.h:113
const WCHAR * name
Definition: vbscript.h:97
unsigned array_cnt
Definition: vbscript.h:108
function_t * value_func
Definition: vbscript.h:111
VARIANT v
Definition: vbscript.h:174
const WCHAR * name
Definition: vbscript.h:175
struct _dynamic_var_t * next
Definition: vbscript.h:173
unsigned arg_cnt
Definition: vbscript.h:326
unsigned code_off
Definition: vbscript.h:331
function_type_t type
Definition: vbscript.h:322
vbscode_t * code_ctx
Definition: vbscript.h:332
BOOL is_public
Definition: vbscript.h:324
var_desc_t * vars
Definition: vbscript.h:327
array_desc_t * array_descs
Definition: vbscript.h:329
unsigned var_cnt
Definition: vbscript.h:328
arg_desc_t * args
Definition: vbscript.h:325
const WCHAR * name
Definition: vbscript.h:323
unsigned array_cnt
Definition: vbscript.h:330
function_t * next
Definition: vbscript.h:333
ScriptDisp * script_obj
Definition: vbscript.h:188
EXCEPINFO ei
Definition: vbscript.h:193
class_desc_t * classes
Definition: vbscript.h:197
IActiveScriptSite * site
Definition: jscript.h:417
dynamic_var_t * global_vars
Definition: vbscript.h:195
struct list code_list
Definition: vbscript.h:203
IDispatch * host_global
Definition: jscript.h:429
heap_pool_t heap
Definition: vbscript.h:200
BuiltinDisp * err_obj
Definition: vbscript.h:191
class_desc_t * procs
Definition: vbscript.h:198
struct list objects
Definition: vbscript.h:202
named_item_t * named_items
Definition: jscript.h:416
DWORD safeopt
Definition: jscript.h:419
IInternetHostSecurityManager * secmgr
Definition: jscript.h:418
BuiltinDisp * global_obj
Definition: vbscript.h:190
function_t * global_funcs
Definition: vbscript.h:196
SAFEARRAY ** arrays
Definition: vbscript.h:124
IDispatchEx IDispatchEx_iface
Definition: vbscript.h:117
struct list entry
Definition: vbscript.h:121
const class_desc_t * desc
Definition: vbscript.h:123
BOOL terminator_ran
Definition: vbscript.h:120
LONG ref
Definition: vbscript.h:119
VARIANT props[1]
Definition: vbscript.h:125
heap_pool_t heap
Definition: vbscript.h:349
instr_t * instrs
Definition: vbscript.h:337
function_t main_code
Definition: vbscript.h:343
BOOL pending_exec
Definition: vbscript.h:342
IDispatch * context
Definition: vbscript.h:344
unsigned bstr_cnt
Definition: vbscript.h:348
BSTR * bstr_pool
Definition: vbscript.h:346
unsigned bstr_pool_size
Definition: vbscript.h:347
WCHAR * source
Definition: vbscript.h:338
struct list entry
Definition: vbscript.h:351
BOOL option_explicit
Definition: vbscript.h:340
const WCHAR * name
Definition: vbscript.h:303
BOOL by_ref
Definition: vbscript.h:304
unsigned dim_cnt
Definition: vbscript.h:79
SAFEARRAYBOUND * bounds
Definition: vbscript.h:80
instr_arg_t arg2
Definition: vbscript.h:299
vbsop_t op
Definition: vbscript.h:297
instr_arg_t arg1
Definition: vbscript.h:298
Definition: name.c:39
const WCHAR * name
Definition: vbscript.h:318
const WCHAR * name
Definition: vbscript.h:90
const WCHAR * name
Definition: vbscript.h:86
double * dbl
Definition: vbscript.h:293
const WCHAR * str
Definition: vbscript.h:289
HRESULT create_regexp(IDispatch **) DECLSPEC_HIDDEN
Definition: vbregexp.c:1596
void heap_pool_clear(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:146
void detach_global_objects(script_ctx_t *) DECLSPEC_HIDDEN
Definition: global.c:2855
HRESULT init_global(script_ctx_t *) DECLSPEC_HIDDEN
Definition: global.c:1105
void heap_pool_free(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:169
HRESULT init_err(script_ctx_t *) DECLSPEC_HIDDEN
HRESULT create_script_disp(script_ctx_t *, ScriptDisp **) DECLSPEC_HIDDEN
Definition: vbdisp.c:819
vbdisp_invoke_type_t
Definition: vbscript.h:71
@ VBDISP_LET
Definition: vbscript.h:73
@ VBDISP_SET
Definition: vbscript.h:74
@ VBDISP_CALLGET
Definition: vbscript.h:72
@ VBDISP_ANY
Definition: vbscript.h:75
BSTR get_vbscript_error_string(HRESULT) DECLSPEC_HIDDEN
Definition: vbscript_main.c:45
void release_dynamic_vars(dynamic_var_t *) DECLSPEC_HIDDEN
Definition: interp.c:2044
heap_pool_t * heap_pool_mark(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:182
void * heap_pool_alloc(heap_pool_t *, size_t) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN
Definition: vbscript_main.c:67
HRESULT WINAPI VBScriptRegExpFactory_CreateInstance(IClassFactory *, IUnknown *, REFIID, void **) DECLSPEC_HIDDEN
Definition: vbregexp.c:1618
HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory *, IUnknown *, REFIID, void **) DECLSPEC_HIDDEN
Definition: vbscript.c:930
IUnknown * create_ax_site(script_ctx_t *) DECLSPEC_HIDDEN
Definition: jscript.c:324
HRESULT compile_script(script_ctx_t *, const WCHAR *, const WCHAR *, DWORD, vbscode_t **) DECLSPEC_HIDDEN
Definition: compile.c:1828
vbsop_t
Definition: vbscript.h:281
@ OP_LAST
Definition: vbscript.h:285
HRESULT create_vbdisp(const class_desc_t *, vbdisp_t **) DECLSPEC_HIDDEN
Definition: vbdisp.c:470
static LPWSTR heap_strdupW(LPCWSTR str)
Definition: vbscript.h:387
#define OP_LIST
Definition: vbscript.h:222
HRESULT get_disp_value(script_ctx_t *, IDispatch *, VARIANT *) DECLSPEC_HIDDEN
Definition: vbdisp.c:967
static unsigned arg_cnt(const DISPPARAMS *dp)
Definition: vbscript.h:162
void * heap_pool_grow(heap_pool_t *, void *, DWORD, DWORD) DECLSPEC_HIDDEN
Definition: jsutils.c:130
BSTR get_vbscript_string(int) DECLSPEC_HIDDEN
Definition: vbscript_main.c:38
struct _dynamic_var_t dynamic_var_t
struct _class_desc_t class_desc_t
static BOOL is_int32(double d)
Definition: vbscript.h:367
HRESULT to_int(VARIANT *, int *) DECLSPEC_HIDDEN
Definition: global.c:410
HRESULT create_safearray_iter(SAFEARRAY *sa, IEnumVARIANT **ev) DECLSPEC_HIDDEN
Definition: utils.c:163
function_type_t
Definition: vbscript.h:307
@ FUNC_PROPLET
Definition: vbscript.h:312
@ FUNC_PROPSET
Definition: vbscript.h:313
@ FUNC_SUB
Definition: vbscript.h:310
@ FUNC_PROPGET
Definition: vbscript.h:311
@ FUNC_GLOBAL
Definition: vbscript.h:308
@ FUNC_DEFGET
Definition: vbscript.h:314
@ FUNC_FUNCTION
Definition: vbscript.h:309
HRESULT disp_call(script_ctx_t *, IDispatch *, DISPID, DISPPARAMS *, VARIANT *) DECLSPEC_HIDDEN
Definition: vbdisp.c:938
HRESULT vbdisp_get_id(vbdisp_t *, BSTR, vbdisp_invoke_type_t, BOOL, DISPID *) DECLSPEC_HIDDEN
Definition: vbdisp.c:59
HRESULT disp_propput(script_ctx_t *, IDispatch *, DISPID, WORD, DISPPARAMS *) DECLSPEC_HIDDEN
Definition: vbdisp.c:975
void clear_ei(EXCEPINFO *) DECLSPEC_HIDDEN
Definition: interp.c:242
instr_arg_type_t
Definition: vbscript.h:212
@ ARG_INT
Definition: vbscript.h:216
@ ARG_ADDR
Definition: vbscript.h:218
@ ARG_BSTR
Definition: vbscript.h:215
@ ARG_NONE
Definition: vbscript.h:213
@ ARG_DOUBLE
Definition: vbscript.h:219
@ ARG_STR
Definition: vbscript.h:214
@ ARG_UINT
Definition: vbscript.h:217
HRESULT compile_procedure(script_ctx_t *, const WCHAR *, const WCHAR *, DWORD, class_desc_t **) DECLSPEC_HIDDEN
Definition: compile.c:1930
void heap_pool_init(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:71
void release_regexp_typelib(void) DECLSPEC_HIDDEN
Definition: vbregexp.c:1634
HRESULT report_script_error(script_ctx_t *) DECLSPEC_HIDDEN
Definition: vbscript.c:315
HRESULT get_builtin_id(BuiltinDisp *, const WCHAR *, DISPID *) DECLSPEC_HIDDEN
Definition: global.c:128
IDispatch * lookup_named_item(script_ctx_t *, const WCHAR *, unsigned) DECLSPEC_HIDDEN
Definition: vbscript.c:99
HRESULT exec_script(script_ctx_t *, BOOL, function_t *, vbdisp_t *, DISPPARAMS *, VARIANT *) DECLSPEC_HIDDEN
Definition: interp.c:2086
HRESULT disp_get_id(IDispatch *, BSTR, vbdisp_invoke_type_t, BOOL, DISPID *) DECLSPEC_HIDDEN
Definition: vbdisp.c:854
void release_vbscode(vbscode_t *) DECLSPEC_HIDDEN
Definition: compile.c:1768
static VARIANT * get_arg(DISPPARAMS *dp, DWORD i)
Definition: vbscript.h:167
void collect_objects(script_ctx_t *) DECLSPEC_HIDDEN
Definition: vbdisp.c:835
int ret
#define WINAPI
Definition: msvc.h:6
#define __WINE_ALLOC_SIZE(x)
Definition: winnt_old.h:84
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185