2011-07-18 16:57:27 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-09-02 13:16:27 +02:00
|
|
|
#include <stdarg.h>
|
2019-06-25 08:38:01 +02:00
|
|
|
#include <stdint.h>
|
2011-09-02 13:16:27 +02:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "ole2.h"
|
2011-09-05 11:14:14 +02:00
|
|
|
#include "dispex.h"
|
2011-07-18 16:57:27 +02:00
|
|
|
#include "activscp.h"
|
2018-05-22 03:32:40 +02:00
|
|
|
#include "activdbg.h"
|
2011-09-02 13:16:27 +02:00
|
|
|
|
2011-07-18 16:57:27 +02:00
|
|
|
#include "vbscript_classes.h"
|
2019-10-03 18:18:51 +02:00
|
|
|
#include "vbscript_defs.h"
|
2011-07-18 16:57:27 +02:00
|
|
|
|
2018-01-25 20:55:40 +01:00
|
|
|
#include "wine/heap.h"
|
2011-09-05 11:14:55 +02:00
|
|
|
#include "wine/list.h"
|
|
|
|
|
2011-09-12 12:29:14 +02:00
|
|
|
typedef struct {
|
|
|
|
void **blocks;
|
|
|
|
DWORD block_cnt;
|
|
|
|
DWORD last_block;
|
|
|
|
DWORD offset;
|
2013-02-19 12:39:47 +01:00
|
|
|
BOOL mark;
|
2011-09-12 12:29:14 +02:00
|
|
|
struct list custom_blocks;
|
2013-02-15 15:11:13 +01:00
|
|
|
} heap_pool_t;
|
2011-09-12 12:29:14 +02:00
|
|
|
|
2013-02-15 15:11:13 +01:00
|
|
|
void heap_pool_init(heap_pool_t*) DECLSPEC_HIDDEN;
|
|
|
|
void *heap_pool_alloc(heap_pool_t*,size_t) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN;
|
2013-02-19 12:39:47 +01:00
|
|
|
void *heap_pool_grow(heap_pool_t*,void*,DWORD,DWORD) DECLSPEC_HIDDEN;
|
|
|
|
void heap_pool_clear(heap_pool_t*) DECLSPEC_HIDDEN;
|
2013-02-15 15:11:13 +01:00
|
|
|
void heap_pool_free(heap_pool_t*) DECLSPEC_HIDDEN;
|
2013-02-19 12:39:47 +01:00
|
|
|
heap_pool_t *heap_pool_mark(heap_pool_t*) DECLSPEC_HIDDEN;
|
2011-09-12 12:29:14 +02:00
|
|
|
|
2011-09-07 14:07:12 +02:00
|
|
|
typedef struct _function_t function_t;
|
|
|
|
typedef struct _vbscode_t vbscode_t;
|
2011-09-08 14:54:37 +02:00
|
|
|
typedef struct _script_ctx_t script_ctx_t;
|
2011-09-19 14:08:38 +02:00
|
|
|
typedef struct _vbdisp_t vbdisp_t;
|
2011-09-07 14:07:12 +02:00
|
|
|
|
2011-09-15 14:20:46 +02:00
|
|
|
typedef enum {
|
|
|
|
VBDISP_CALLGET,
|
|
|
|
VBDISP_LET,
|
|
|
|
VBDISP_SET,
|
|
|
|
VBDISP_ANY
|
|
|
|
} vbdisp_invoke_type_t;
|
|
|
|
|
2014-03-07 14:27:12 +01:00
|
|
|
typedef struct {
|
|
|
|
unsigned dim_cnt;
|
|
|
|
SAFEARRAYBOUND *bounds;
|
|
|
|
} array_desc_t;
|
|
|
|
|
2011-09-16 13:27:22 +02:00
|
|
|
typedef struct {
|
|
|
|
BOOL is_public;
|
2014-03-07 14:27:12 +01:00
|
|
|
BOOL is_array;
|
2011-09-16 13:27:22 +02:00
|
|
|
const WCHAR *name;
|
|
|
|
} vbdisp_prop_desc_t;
|
|
|
|
|
2011-09-15 14:20:46 +02:00
|
|
|
typedef struct {
|
|
|
|
const WCHAR *name;
|
|
|
|
BOOL is_public;
|
2014-03-07 14:27:12 +01:00
|
|
|
BOOL is_array;
|
2011-09-15 14:20:46 +02:00
|
|
|
function_t *entries[VBDISP_ANY];
|
|
|
|
} vbdisp_funcprop_desc_t;
|
|
|
|
|
2011-09-15 14:17:17 +02:00
|
|
|
typedef struct _class_desc_t {
|
|
|
|
const WCHAR *name;
|
|
|
|
script_ctx_t *ctx;
|
2011-09-19 14:08:38 +02:00
|
|
|
|
2011-09-16 13:29:25 +02:00
|
|
|
unsigned class_initialize_id;
|
2011-09-16 13:29:37 +02:00
|
|
|
unsigned class_terminate_id;
|
2011-09-15 14:20:46 +02:00
|
|
|
unsigned func_cnt;
|
|
|
|
vbdisp_funcprop_desc_t *funcs;
|
2011-09-19 14:08:38 +02:00
|
|
|
|
2011-09-16 13:27:22 +02:00
|
|
|
unsigned prop_cnt;
|
|
|
|
vbdisp_prop_desc_t *props;
|
2011-09-19 14:08:38 +02:00
|
|
|
|
2014-03-07 14:27:12 +01:00
|
|
|
unsigned array_cnt;
|
|
|
|
array_desc_t *array_descs;
|
|
|
|
|
2012-09-06 11:57:33 +02:00
|
|
|
function_t *value_func;
|
2011-09-19 14:08:38 +02:00
|
|
|
|
2011-09-15 14:17:17 +02:00
|
|
|
struct _class_desc_t *next;
|
|
|
|
} class_desc_t;
|
|
|
|
|
2011-09-19 14:08:38 +02:00
|
|
|
struct _vbdisp_t {
|
2011-09-05 11:14:14 +02:00
|
|
|
IDispatchEx IDispatchEx_iface;
|
|
|
|
|
|
|
|
LONG ref;
|
2011-09-16 13:29:37 +02:00
|
|
|
BOOL terminator_ran;
|
2011-09-16 13:29:47 +02:00
|
|
|
struct list entry;
|
2011-09-15 14:18:43 +02:00
|
|
|
|
|
|
|
const class_desc_t *desc;
|
2014-03-07 14:27:12 +01:00
|
|
|
SAFEARRAY **arrays;
|
2011-09-16 13:27:48 +02:00
|
|
|
VARIANT props[1];
|
2011-09-19 14:08:38 +02:00
|
|
|
};
|
2011-09-05 11:14:14 +02:00
|
|
|
|
2019-12-06 13:45:21 +01:00
|
|
|
typedef struct _dynamic_var_t {
|
|
|
|
struct _dynamic_var_t *next;
|
|
|
|
VARIANT v;
|
|
|
|
const WCHAR *name;
|
|
|
|
BOOL is_const;
|
|
|
|
SAFEARRAY *array;
|
|
|
|
} dynamic_var_t;
|
|
|
|
|
2012-09-07 15:09:34 +02:00
|
|
|
typedef struct {
|
|
|
|
IDispatchEx IDispatchEx_iface;
|
|
|
|
LONG ref;
|
2012-09-07 15:09:59 +02:00
|
|
|
|
2019-12-06 13:45:21 +01:00
|
|
|
dynamic_var_t **global_vars;
|
|
|
|
size_t global_vars_cnt;
|
|
|
|
size_t global_vars_size;
|
|
|
|
|
|
|
|
function_t **global_funcs;
|
|
|
|
size_t global_funcs_cnt;
|
|
|
|
size_t global_funcs_size;
|
|
|
|
|
|
|
|
class_desc_t *classes;
|
|
|
|
|
2012-09-07 15:09:34 +02:00
|
|
|
script_ctx_t *ctx;
|
2019-12-06 13:45:21 +01:00
|
|
|
heap_pool_t heap;
|
2012-09-07 15:09:34 +02:00
|
|
|
} ScriptDisp;
|
|
|
|
|
2019-10-17 22:46:45 +02:00
|
|
|
typedef struct _builtin_prop_t builtin_prop_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
IDispatch IDispatch_iface;
|
|
|
|
LONG ref;
|
|
|
|
size_t member_cnt;
|
|
|
|
const builtin_prop_t *members;
|
|
|
|
script_ctx_t *ctx;
|
|
|
|
} BuiltinDisp;
|
2019-10-17 22:46:25 +02:00
|
|
|
|
2020-02-14 14:57:13 +01:00
|
|
|
typedef struct named_item_t {
|
2020-02-14 14:57:14 +01:00
|
|
|
ScriptDisp *script_obj;
|
2020-02-14 14:57:13 +01:00
|
|
|
IDispatch *disp;
|
2020-02-14 14:57:14 +01:00
|
|
|
unsigned ref;
|
2020-02-14 14:57:13 +01:00
|
|
|
DWORD flags;
|
|
|
|
LPWSTR name;
|
|
|
|
|
|
|
|
struct list entry;
|
|
|
|
} named_item_t;
|
|
|
|
|
2011-10-03 13:28:46 +02:00
|
|
|
HRESULT create_vbdisp(const class_desc_t*,vbdisp_t**) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT disp_get_id(IDispatch*,BSTR,vbdisp_invoke_type_t,BOOL,DISPID*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT vbdisp_get_id(vbdisp_t*,BSTR,vbdisp_invoke_type_t,BOOL,DISPID*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
|
2015-03-03 14:40:36 +01:00
|
|
|
HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,WORD,DISPPARAMS*) DECLSPEC_HIDDEN;
|
2015-03-05 15:49:02 +01:00
|
|
|
HRESULT get_disp_value(script_ctx_t*,IDispatch*,VARIANT*) DECLSPEC_HIDDEN;
|
2011-10-03 13:28:46 +02:00
|
|
|
void collect_objects(script_ctx_t*) DECLSPEC_HIDDEN;
|
2012-09-07 15:09:34 +02:00
|
|
|
HRESULT create_script_disp(script_ctx_t*,ScriptDisp**) DECLSPEC_HIDDEN;
|
2011-09-08 14:54:37 +02:00
|
|
|
|
2013-11-13 16:29:39 +01:00
|
|
|
HRESULT to_int(VARIANT*,int*) DECLSPEC_HIDDEN;
|
|
|
|
|
2011-09-14 12:56:01 +02:00
|
|
|
static inline unsigned arg_cnt(const DISPPARAMS *dp)
|
|
|
|
{
|
|
|
|
return dp->cArgs - dp->cNamedArgs;
|
|
|
|
}
|
|
|
|
|
2011-09-14 12:56:45 +02:00
|
|
|
static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i)
|
|
|
|
{
|
|
|
|
return dp->rgvarg + dp->cArgs-i-1;
|
|
|
|
}
|
|
|
|
|
2011-09-08 14:54:37 +02:00
|
|
|
struct _script_ctx_t {
|
2011-08-31 11:22:05 +02:00
|
|
|
IActiveScriptSite *site;
|
|
|
|
LCID lcid;
|
2011-09-05 11:14:14 +02:00
|
|
|
|
2011-09-22 14:25:27 +02:00
|
|
|
IInternetHostSecurityManager *secmgr;
|
|
|
|
DWORD safeopt;
|
|
|
|
|
2012-09-07 15:09:34 +02:00
|
|
|
ScriptDisp *script_obj;
|
2011-09-05 11:14:55 +02:00
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
BuiltinDisp *global_obj;
|
|
|
|
BuiltinDisp *err_obj;
|
2011-09-19 14:09:21 +02:00
|
|
|
|
2019-10-03 18:18:37 +02:00
|
|
|
EXCEPINFO ei;
|
2020-01-22 23:28:01 +01:00
|
|
|
vbscode_t *error_loc_code;
|
|
|
|
unsigned error_loc_offset;
|
2014-03-21 14:37:39 +01:00
|
|
|
|
2011-09-16 13:29:47 +02:00
|
|
|
struct list objects;
|
2011-09-07 14:07:12 +02:00
|
|
|
struct list code_list;
|
2011-09-05 11:14:55 +02:00
|
|
|
struct list named_items;
|
2011-09-08 14:54:37 +02:00
|
|
|
};
|
2011-08-31 11:22:05 +02:00
|
|
|
|
2011-10-03 13:28:46 +02:00
|
|
|
HRESULT init_global(script_ctx_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT init_err(script_ctx_t*) DECLSPEC_HIDDEN;
|
2011-09-05 11:14:14 +02:00
|
|
|
|
2011-09-22 14:25:50 +02:00
|
|
|
IUnknown *create_ax_site(script_ctx_t*) DECLSPEC_HIDDEN;
|
|
|
|
|
2011-09-07 14:08:47 +02:00
|
|
|
typedef enum {
|
|
|
|
ARG_NONE = 0,
|
2011-09-08 14:54:23 +02:00
|
|
|
ARG_STR,
|
2011-09-08 14:57:16 +02:00
|
|
|
ARG_BSTR,
|
|
|
|
ARG_INT,
|
2011-09-12 12:30:11 +02:00
|
|
|
ARG_UINT,
|
2011-09-13 11:38:38 +02:00
|
|
|
ARG_ADDR,
|
2021-09-14 13:18:41 +02:00
|
|
|
ARG_DOUBLE,
|
|
|
|
ARG_DATE
|
2011-09-07 14:08:47 +02:00
|
|
|
} instr_arg_type_t;
|
|
|
|
|
|
|
|
#define OP_LIST \
|
2011-09-12 12:31:58 +02:00
|
|
|
X(add, 1, 0, 0) \
|
2011-09-14 12:59:02 +02:00
|
|
|
X(and, 1, 0, 0) \
|
2011-12-27 16:17:21 +01:00
|
|
|
X(assign_ident, 1, ARG_BSTR, ARG_UINT) \
|
|
|
|
X(assign_member, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-08 14:57:16 +02:00
|
|
|
X(bool, 1, ARG_INT, 0) \
|
2019-10-28 18:40:18 +01:00
|
|
|
X(catch, 1, ARG_ADDR, ARG_UINT) \
|
2012-07-20 16:28:45 +02:00
|
|
|
X(case, 0, ARG_ADDR, 0) \
|
2011-09-12 12:30:47 +02:00
|
|
|
X(concat, 1, 0, 0) \
|
2011-09-21 14:03:38 +02:00
|
|
|
X(const, 1, ARG_BSTR, 0) \
|
2021-09-14 13:18:41 +02:00
|
|
|
X(date, 1, ARG_DATE, 0) \
|
2019-10-28 18:41:05 +01:00
|
|
|
X(deref, 1, 0, 0) \
|
2013-11-13 16:29:18 +01:00
|
|
|
X(dim, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-13 11:40:39 +02:00
|
|
|
X(div, 1, 0, 0) \
|
2011-09-12 12:30:11 +02:00
|
|
|
X(double, 1, ARG_DOUBLE, 0) \
|
2011-09-09 14:49:26 +02:00
|
|
|
X(empty, 1, 0, 0) \
|
2012-07-03 17:05:32 +02:00
|
|
|
X(enumnext, 0, ARG_ADDR, ARG_BSTR) \
|
2011-09-09 14:48:25 +02:00
|
|
|
X(equal, 1, 0, 0) \
|
2015-01-28 19:28:17 +01:00
|
|
|
X(hres, 1, ARG_UINT, 0) \
|
2011-09-19 14:10:19 +02:00
|
|
|
X(errmode, 1, ARG_INT, 0) \
|
2011-09-14 12:59:49 +02:00
|
|
|
X(eqv, 1, 0, 0) \
|
2011-09-13 11:41:15 +02:00
|
|
|
X(exp, 1, 0, 0) \
|
2011-09-19 14:07:12 +02:00
|
|
|
X(gt, 1, 0, 0) \
|
|
|
|
X(gteq, 1, 0, 0) \
|
2011-09-09 14:48:48 +02:00
|
|
|
X(icall, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-08 14:57:16 +02:00
|
|
|
X(icallv, 1, ARG_BSTR, ARG_UINT) \
|
2021-10-08 19:13:59 +02:00
|
|
|
X(ident, 1, ARG_BSTR, 0) \
|
2011-09-13 11:40:14 +02:00
|
|
|
X(idiv, 1, 0, 0) \
|
2011-09-14 12:59:49 +02:00
|
|
|
X(imp, 1, 0, 0) \
|
2011-09-22 14:23:10 +02:00
|
|
|
X(incc, 1, ARG_BSTR, 0) \
|
2019-08-22 19:31:49 +02:00
|
|
|
X(int, 1, ARG_INT, 0) \
|
2011-09-19 14:08:02 +02:00
|
|
|
X(is, 1, 0, 0) \
|
2011-09-13 11:38:38 +02:00
|
|
|
X(jmp, 0, ARG_ADDR, 0) \
|
|
|
|
X(jmp_false, 0, ARG_ADDR, 0) \
|
2011-09-16 13:30:31 +02:00
|
|
|
X(jmp_true, 0, ARG_ADDR, 0) \
|
2011-09-19 14:07:12 +02:00
|
|
|
X(lt, 1, 0, 0) \
|
|
|
|
X(lteq, 1, 0, 0) \
|
2011-09-15 14:19:41 +02:00
|
|
|
X(mcall, 1, ARG_BSTR, ARG_UINT) \
|
|
|
|
X(mcallv, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-19 14:09:57 +02:00
|
|
|
X(me, 1, 0, 0) \
|
2011-09-13 11:39:53 +02:00
|
|
|
X(mod, 1, 0, 0) \
|
2011-09-13 11:40:39 +02:00
|
|
|
X(mul, 1, 0, 0) \
|
2011-09-12 12:31:37 +02:00
|
|
|
X(neg, 1, 0, 0) \
|
2011-09-12 12:32:27 +02:00
|
|
|
X(nequal, 1, 0, 0) \
|
2011-09-15 14:18:12 +02:00
|
|
|
X(new, 1, ARG_STR, 0) \
|
2012-07-03 17:05:32 +02:00
|
|
|
X(newenum, 1, 0, 0) \
|
2011-09-09 14:47:45 +02:00
|
|
|
X(not, 1, 0, 0) \
|
2011-09-15 14:18:56 +02:00
|
|
|
X(nothing, 1, 0, 0) \
|
2011-09-09 14:49:36 +02:00
|
|
|
X(null, 1, 0, 0) \
|
2011-09-14 12:59:26 +02:00
|
|
|
X(or, 1, 0, 0) \
|
2011-09-22 14:23:10 +02:00
|
|
|
X(pop, 1, ARG_UINT, 0) \
|
2019-11-01 17:51:11 +01:00
|
|
|
X(redim, 1, ARG_BSTR, ARG_UINT) \
|
2020-09-30 17:27:38 +02:00
|
|
|
X(redim_preserve, 1, ARG_BSTR, ARG_UINT) \
|
2011-09-08 14:57:31 +02:00
|
|
|
X(ret, 0, 0, 0) \
|
2019-09-17 14:54:31 +02:00
|
|
|
X(retval, 1, 0, 0) \
|
2011-12-27 16:17:21 +01:00
|
|
|
X(set_ident, 1, ARG_BSTR, ARG_UINT) \
|
|
|
|
X(set_member, 1, ARG_BSTR, ARG_UINT) \
|
2019-10-29 19:01:23 +01:00
|
|
|
X(stack, 1, ARG_UINT, 0) \
|
2011-09-22 14:23:10 +02:00
|
|
|
X(step, 0, ARG_ADDR, ARG_BSTR) \
|
2011-09-15 14:22:27 +02:00
|
|
|
X(stop, 1, 0, 0) \
|
2011-09-12 12:31:58 +02:00
|
|
|
X(string, 1, ARG_STR, 0) \
|
2011-09-14 12:59:49 +02:00
|
|
|
X(sub, 1, 0, 0) \
|
2011-09-22 14:23:10 +02:00
|
|
|
X(val, 1, 0, 0) \
|
2019-10-28 18:40:18 +01:00
|
|
|
X(vcall, 1, ARG_UINT, 0) \
|
|
|
|
X(vcallv, 1, ARG_UINT, 0) \
|
2011-09-14 12:59:49 +02:00
|
|
|
X(xor, 1, 0, 0)
|
2011-09-07 14:07:12 +02:00
|
|
|
|
|
|
|
typedef enum {
|
2011-09-07 14:08:47 +02:00
|
|
|
#define X(x,n,a,b) OP_##x,
|
2011-09-07 14:07:12 +02:00
|
|
|
OP_LIST
|
|
|
|
#undef X
|
|
|
|
OP_LAST
|
|
|
|
} vbsop_t;
|
|
|
|
|
2011-09-07 14:08:47 +02:00
|
|
|
typedef union {
|
|
|
|
const WCHAR *str;
|
2011-09-08 14:54:23 +02:00
|
|
|
BSTR bstr;
|
2011-09-08 14:57:16 +02:00
|
|
|
unsigned uint;
|
|
|
|
LONG lng;
|
2011-09-12 12:30:11 +02:00
|
|
|
double *dbl;
|
2021-09-14 13:18:41 +02:00
|
|
|
DATE *date;
|
2011-09-07 14:08:47 +02:00
|
|
|
} instr_arg_t;
|
|
|
|
|
2011-09-07 14:07:12 +02:00
|
|
|
typedef struct {
|
|
|
|
vbsop_t op;
|
2020-01-22 23:27:20 +01:00
|
|
|
unsigned loc;
|
2011-09-07 14:08:47 +02:00
|
|
|
instr_arg_t arg1;
|
|
|
|
instr_arg_t arg2;
|
2011-09-07 14:07:12 +02:00
|
|
|
} instr_t;
|
|
|
|
|
2011-09-14 13:55:57 +02:00
|
|
|
typedef struct {
|
|
|
|
const WCHAR *name;
|
|
|
|
BOOL by_ref;
|
|
|
|
} arg_desc_t;
|
|
|
|
|
2011-09-14 12:54:50 +02:00
|
|
|
typedef enum {
|
|
|
|
FUNC_GLOBAL,
|
2011-09-14 16:55:51 +02:00
|
|
|
FUNC_FUNCTION,
|
2011-09-16 13:28:00 +02:00
|
|
|
FUNC_SUB,
|
|
|
|
FUNC_PROPGET,
|
|
|
|
FUNC_PROPLET,
|
2011-09-16 13:28:52 +02:00
|
|
|
FUNC_PROPSET,
|
2011-09-14 12:54:50 +02:00
|
|
|
} function_type_t;
|
|
|
|
|
2011-09-14 12:57:37 +02:00
|
|
|
typedef struct {
|
|
|
|
const WCHAR *name;
|
|
|
|
} var_desc_t;
|
|
|
|
|
2011-09-07 14:07:12 +02:00
|
|
|
struct _function_t {
|
2011-09-14 12:55:07 +02:00
|
|
|
function_type_t type;
|
|
|
|
const WCHAR *name;
|
2011-09-15 14:20:05 +02:00
|
|
|
BOOL is_public;
|
2011-09-14 13:55:57 +02:00
|
|
|
arg_desc_t *args;
|
|
|
|
unsigned arg_cnt;
|
2011-09-14 12:57:37 +02:00
|
|
|
var_desc_t *vars;
|
|
|
|
unsigned var_cnt;
|
2013-11-13 16:29:18 +01:00
|
|
|
array_desc_t *array_descs;
|
|
|
|
unsigned array_cnt;
|
2011-09-07 14:07:12 +02:00
|
|
|
unsigned code_off;
|
|
|
|
vbscode_t *code_ctx;
|
2011-09-14 12:55:07 +02:00
|
|
|
function_t *next;
|
2011-09-07 14:07:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _vbscode_t {
|
|
|
|
instr_t *instrs;
|
2019-12-06 13:45:28 +01:00
|
|
|
unsigned ref;
|
2011-09-07 14:07:12 +02:00
|
|
|
|
2020-01-22 23:27:25 +01:00
|
|
|
WCHAR *source;
|
|
|
|
DWORD_PTR cookie;
|
|
|
|
unsigned start_line;
|
|
|
|
|
2011-09-09 14:47:00 +02:00
|
|
|
BOOL option_explicit;
|
|
|
|
|
2012-09-06 11:57:15 +02:00
|
|
|
BOOL pending_exec;
|
2019-11-08 18:19:06 +01:00
|
|
|
BOOL is_persistent;
|
2012-09-06 11:57:15 +02:00
|
|
|
function_t main_code;
|
2020-02-14 14:57:14 +01:00
|
|
|
named_item_t *named_item;
|
2011-09-07 14:07:12 +02:00
|
|
|
|
2011-09-08 14:54:23 +02:00
|
|
|
BSTR *bstr_pool;
|
|
|
|
unsigned bstr_pool_size;
|
|
|
|
unsigned bstr_cnt;
|
2013-02-15 15:11:13 +01:00
|
|
|
heap_pool_t heap;
|
2011-09-08 14:54:23 +02:00
|
|
|
|
2019-11-11 13:34:23 +01:00
|
|
|
function_t *funcs;
|
2019-11-11 13:34:22 +01:00
|
|
|
class_desc_t *classes;
|
2019-11-08 18:19:06 +01:00
|
|
|
class_desc_t *last_class;
|
|
|
|
|
2011-09-07 14:07:12 +02:00
|
|
|
struct list entry;
|
|
|
|
};
|
|
|
|
|
2019-12-06 13:45:44 +01:00
|
|
|
static inline void grab_vbscode(vbscode_t *code)
|
|
|
|
{
|
|
|
|
code->ref++;
|
|
|
|
}
|
|
|
|
|
2011-09-07 14:07:12 +02:00
|
|
|
void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN;
|
2020-01-31 14:28:59 +01:00
|
|
|
HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,const WCHAR*,DWORD_PTR,unsigned,DWORD,vbscode_t**) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT compile_procedure(script_ctx_t*,const WCHAR*,const WCHAR*,const WCHAR*,DWORD_PTR,unsigned,DWORD,class_desc_t**) DECLSPEC_HIDDEN;
|
2019-10-04 16:30:20 +02:00
|
|
|
HRESULT exec_script(script_ctx_t*,BOOL,function_t*,vbdisp_t*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
|
2019-11-11 13:34:25 +01:00
|
|
|
void release_dynamic_var(dynamic_var_t*) DECLSPEC_HIDDEN;
|
2020-01-31 14:28:58 +01:00
|
|
|
named_item_t *lookup_named_item(script_ctx_t*,const WCHAR*,unsigned) DECLSPEC_HIDDEN;
|
2020-02-14 14:57:14 +01:00
|
|
|
void release_named_item(named_item_t*) DECLSPEC_HIDDEN;
|
2019-10-03 18:18:37 +02:00
|
|
|
void clear_ei(EXCEPINFO*) DECLSPEC_HIDDEN;
|
2020-01-22 23:28:01 +01:00
|
|
|
HRESULT report_script_error(script_ctx_t*,const vbscode_t*,unsigned) DECLSPEC_HIDDEN;
|
2019-10-17 22:46:27 +02:00
|
|
|
void detach_global_objects(script_ctx_t*) DECLSPEC_HIDDEN;
|
2019-10-17 22:46:33 +02:00
|
|
|
HRESULT get_builtin_id(BuiltinDisp*,const WCHAR*,DISPID*) DECLSPEC_HIDDEN;
|
2011-09-07 14:07:12 +02:00
|
|
|
|
2013-02-15 15:10:27 +01:00
|
|
|
void release_regexp_typelib(void) DECLSPEC_HIDDEN;
|
2019-12-06 13:46:13 +01:00
|
|
|
HRESULT get_dispatch_typeinfo(ITypeInfo**) DECLSPEC_HIDDEN;
|
2011-09-19 14:08:38 +02:00
|
|
|
|
2012-09-26 14:36:15 +02:00
|
|
|
static inline BOOL is_int32(double d)
|
|
|
|
{
|
|
|
|
return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d;
|
|
|
|
}
|
|
|
|
|
2019-11-08 21:28:32 +01:00
|
|
|
static inline BOOL is_digit(WCHAR c)
|
|
|
|
{
|
|
|
|
return '0' <= c && c <= '9';
|
|
|
|
}
|
|
|
|
|
2014-03-18 15:52:13 +01:00
|
|
|
HRESULT create_regexp(IDispatch**) DECLSPEC_HIDDEN;
|
2020-08-25 19:47:17 +02:00
|
|
|
BSTR string_replace(BSTR,BSTR,BSTR,int,int,int) DECLSPEC_HIDDEN;
|
2014-03-18 15:52:13 +01:00
|
|
|
|
2014-03-27 14:44:12 +01:00
|
|
|
HRESULT map_hres(HRESULT) DECLSPEC_HIDDEN;
|
|
|
|
|
2017-11-08 15:05:01 +01:00
|
|
|
HRESULT create_safearray_iter(SAFEARRAY *sa, IEnumVARIANT **ev) DECLSPEC_HIDDEN;
|
|
|
|
|
2014-03-27 14:44:12 +01:00
|
|
|
#define FACILITY_VBS 0xa
|
|
|
|
#define MAKE_VBSERROR(code) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_VBS, code)
|
|
|
|
|
2011-10-03 13:28:46 +02:00
|
|
|
HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
|
2013-02-15 15:09:28 +01:00
|
|
|
HRESULT WINAPI VBScriptRegExpFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
|
2011-07-18 16:57:27 +02:00
|
|
|
|
2019-10-03 18:18:51 +02:00
|
|
|
BSTR get_vbscript_string(int) DECLSPEC_HIDDEN;
|
|
|
|
BSTR get_vbscript_error_string(HRESULT) DECLSPEC_HIDDEN;
|
|
|
|
|
2011-09-05 11:14:55 +02:00
|
|
|
static inline LPWSTR heap_strdupW(LPCWSTR str)
|
|
|
|
{
|
|
|
|
LPWSTR ret = NULL;
|
|
|
|
|
|
|
|
if(str) {
|
|
|
|
DWORD size;
|
|
|
|
|
2019-06-25 08:38:01 +02:00
|
|
|
size = (lstrlenW(str)+1)*sizeof(WCHAR);
|
2011-09-05 11:14:55 +02:00
|
|
|
ret = heap_alloc(size);
|
|
|
|
if(ret)
|
|
|
|
memcpy(ret, str, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2014-08-08 18:49:05 +02:00
|
|
|
|
|
|
|
#define VBSCRIPT_BUILD_VERSION 16978
|
2014-08-08 18:49:52 +02:00
|
|
|
#define VBSCRIPT_MAJOR_VERSION 5
|
2014-08-08 18:52:28 +02:00
|
|
|
#define VBSCRIPT_MINOR_VERSION 8
|