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>
|
|
|
|
|
|
|
|
#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"
|
2011-09-02 13:16:27 +02:00
|
|
|
|
2011-07-18 16:57:27 +02:00
|
|
|
#include "vbscript_classes.h"
|
|
|
|
|
2011-09-05 11:14:55 +02:00
|
|
|
#include "wine/list.h"
|
|
|
|
#include "wine/unicode.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-05 11:14:55 +02:00
|
|
|
typedef struct named_item_t {
|
|
|
|
IDispatch *disp;
|
|
|
|
DWORD flags;
|
|
|
|
LPWSTR name;
|
|
|
|
|
|
|
|
struct list entry;
|
|
|
|
} named_item_t;
|
|
|
|
|
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-19 14:08:38 +02:00
|
|
|
#define BP_GET 1
|
|
|
|
#define BP_GETPUT 2
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DISPID id;
|
|
|
|
HRESULT (*proc)(vbdisp_t*,VARIANT*,unsigned,VARIANT*);
|
|
|
|
DWORD flags;
|
|
|
|
unsigned min_args;
|
2013-02-27 12:56:05 +01:00
|
|
|
UINT_PTR max_args;
|
2011-09-19 14:08:38 +02:00
|
|
|
} builtin_prop_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;
|
|
|
|
|
2011-09-19 14:08:38 +02:00
|
|
|
unsigned builtin_prop_cnt;
|
|
|
|
const builtin_prop_t *builtin_props;
|
|
|
|
ITypeInfo *typeinfo;
|
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
|
|
|
|
2012-09-07 15:09:59 +02:00
|
|
|
typedef struct _ident_map_t ident_map_t;
|
|
|
|
|
2012-09-07 15:09:34 +02:00
|
|
|
typedef struct {
|
|
|
|
IDispatchEx IDispatchEx_iface;
|
|
|
|
LONG ref;
|
2012-09-07 15:09:59 +02:00
|
|
|
|
|
|
|
ident_map_t *ident_map;
|
|
|
|
unsigned ident_map_cnt;
|
|
|
|
unsigned ident_map_size;
|
|
|
|
|
2012-09-07 15:09:34 +02:00
|
|
|
script_ctx_t *ctx;
|
|
|
|
} ScriptDisp;
|
|
|
|
|
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-06 11:57:33 +02:00
|
|
|
HRESULT create_procedure_disp(script_ctx_t*,vbscode_t*,IDispatch**) 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-13 11:36:47 +02:00
|
|
|
typedef struct _dynamic_var_t {
|
|
|
|
struct _dynamic_var_t *next;
|
|
|
|
VARIANT v;
|
|
|
|
const WCHAR *name;
|
2011-09-21 14:04:16 +02:00
|
|
|
BOOL is_const;
|
2011-09-13 11:36:47 +02:00
|
|
|
} dynamic_var_t;
|
|
|
|
|
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;
|
|
|
|
|
2011-09-05 11:14:55 +02:00
|
|
|
IDispatch *host_global;
|
|
|
|
|
2012-09-07 15:09:34 +02:00
|
|
|
ScriptDisp *script_obj;
|
2011-09-05 11:14:55 +02:00
|
|
|
|
2011-09-19 14:08:38 +02:00
|
|
|
class_desc_t global_desc;
|
|
|
|
vbdisp_t *global_obj;
|
|
|
|
|
2011-09-19 14:09:21 +02:00
|
|
|
class_desc_t err_desc;
|
|
|
|
vbdisp_t *err_obj;
|
|
|
|
|
2014-03-21 14:37:39 +01:00
|
|
|
HRESULT err_number;
|
|
|
|
|
2011-09-13 11:36:47 +02:00
|
|
|
dynamic_var_t *global_vars;
|
2011-09-14 12:55:32 +02:00
|
|
|
function_t *global_funcs;
|
2011-09-15 14:17:17 +02:00
|
|
|
class_desc_t *classes;
|
2012-09-06 11:57:33 +02:00
|
|
|
class_desc_t *procs;
|
2011-09-13 11:36:47 +02:00
|
|
|
|
2013-02-15 15:11:13 +01:00
|
|
|
heap_pool_t heap;
|
2011-09-20 14:59:53 +02: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,
|
2011-09-12 12:30:11 +02:00
|
|
|
ARG_DOUBLE
|
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) \
|
2014-03-21 14:37:39 +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) \
|
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) \
|
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) \
|
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-12 12:30:11 +02:00
|
|
|
X(long, 1, ARG_INT, 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) \
|
2011-09-08 14:57:31 +02:00
|
|
|
X(ret, 0, 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) \
|
2011-09-12 12:30:11 +02:00
|
|
|
X(short, 1, ARG_INT, 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) \
|
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;
|
2011-09-07 14:08:47 +02:00
|
|
|
} instr_arg_t;
|
|
|
|
|
2011-09-07 14:07:12 +02:00
|
|
|
typedef struct {
|
|
|
|
vbsop_t op;
|
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,
|
|
|
|
FUNC_DEFGET
|
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;
|
|
|
|
WCHAR *source;
|
|
|
|
|
2011-09-09 14:47:00 +02:00
|
|
|
BOOL option_explicit;
|
|
|
|
|
2012-09-06 11:57:15 +02:00
|
|
|
BOOL pending_exec;
|
|
|
|
function_t main_code;
|
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
|
|
|
|
2011-09-07 14:07:12 +02:00
|
|
|
struct list entry;
|
|
|
|
};
|
|
|
|
|
|
|
|
void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN;
|
2012-10-18 11:49:17 +02:00
|
|
|
HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,vbscode_t**) DECLSPEC_HIDDEN;
|
2014-03-07 14:27:35 +01:00
|
|
|
HRESULT exec_script(script_ctx_t*,function_t*,vbdisp_t*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
|
2011-10-14 16:22:18 +02:00
|
|
|
void release_dynamic_vars(dynamic_var_t*) DECLSPEC_HIDDEN;
|
2011-09-07 14:07:12 +02:00
|
|
|
|
2013-02-27 12:56:05 +01:00
|
|
|
typedef struct {
|
|
|
|
UINT16 len;
|
|
|
|
WCHAR buf[7];
|
|
|
|
} string_constant_t;
|
|
|
|
|
2011-09-19 14:08:38 +02:00
|
|
|
#define TID_LIST \
|
|
|
|
XDIID(ErrObj) \
|
|
|
|
XDIID(GlobalObj)
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
#define XDIID(iface) iface ## _tid,
|
|
|
|
TID_LIST
|
|
|
|
#undef XDIID
|
|
|
|
LAST_tid
|
|
|
|
} tid_t;
|
|
|
|
|
2011-10-03 13:28:46 +02:00
|
|
|
HRESULT get_typeinfo(tid_t,ITypeInfo**) DECLSPEC_HIDDEN;
|
2013-02-15 15:10:27 +01:00
|
|
|
void release_regexp_typelib(void) DECLSPEC_HIDDEN;
|
2011-09-19 14:08:38 +02:00
|
|
|
|
2012-09-26 14:36:15 +02:00
|
|
|
#ifndef INT32_MIN
|
|
|
|
#define INT32_MIN (-2147483647-1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef INT32_MAX
|
|
|
|
#define INT32_MAX (2147483647)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline BOOL is_int32(double d)
|
|
|
|
{
|
|
|
|
return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d;
|
|
|
|
}
|
|
|
|
|
2014-03-18 15:52:13 +01:00
|
|
|
HRESULT create_regexp(IDispatch**) DECLSPEC_HIDDEN;
|
|
|
|
|
2014-03-27 14:44:12 +01:00
|
|
|
HRESULT map_hres(HRESULT) DECLSPEC_HIDDEN;
|
|
|
|
|
|
|
|
#define FACILITY_VBS 0xa
|
|
|
|
#define MAKE_VBSERROR(code) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_VBS, code)
|
|
|
|
|
|
|
|
#define VBSE_ILLEGAL_FUNC_CALL 5
|
|
|
|
#define VBSE_OVERFLOW 6
|
|
|
|
#define VBSE_OUT_OF_MEMORY 7
|
|
|
|
#define VBSE_OUT_OF_BOUNDS 9
|
|
|
|
#define VBSE_ARRAY_LOCKED 10
|
|
|
|
#define VBSE_TYPE_MISMATCH 13
|
|
|
|
#define VBSE_FILE_NOT_FOUND 53
|
|
|
|
#define VBSE_IO_ERROR 57
|
|
|
|
#define VBSE_FILE_ALREADY_EXISTS 58
|
|
|
|
#define VBSE_DISK_FULL 61
|
|
|
|
#define VBSE_TOO_MANY_FILES 67
|
|
|
|
#define VBSE_PERMISSION_DENIED 70
|
|
|
|
#define VBSE_PATH_FILE_ACCESS 75
|
|
|
|
#define VBSE_PATH_NOT_FOUND 76
|
2014-07-11 05:47:45 +02:00
|
|
|
#define VBSE_ILLEGAL_NULL_USE 94
|
2014-03-27 14:44:12 +01:00
|
|
|
#define VBSE_OLE_NOT_SUPPORTED 430
|
|
|
|
#define VBSE_OLE_NO_PROP_OR_METHOD 438
|
|
|
|
#define VBSE_ACTION_NOT_SUPPORTED 445
|
|
|
|
#define VBSE_NAMED_ARGS_NOT_SUPPORTED 446
|
|
|
|
#define VBSE_LOCALE_SETTING_NOT_SUPPORTED 447
|
|
|
|
#define VBSE_NAMED_PARAM_NOT_FOUND 448
|
|
|
|
#define VBSE_INVALID_TYPELIB_VARIABLE 458
|
|
|
|
#define VBSE_FUNC_ARITY_MISMATCH 450
|
|
|
|
#define VBSE_PARAMETER_NOT_OPTIONAL 449
|
|
|
|
#define VBSE_NOT_ENUM 451
|
|
|
|
#define VBSE_INVALID_DLL_FUNCTION_NAME 453
|
|
|
|
#define VBSE_CANT_CREATE_TMP_FILE 322
|
|
|
|
#define VBSE_OLE_FILE_NOT_FOUND 432
|
|
|
|
#define VBSE_CANT_CREATE_OBJECT 429
|
|
|
|
#define VBSE_SERVER_NOT_FOUND 462
|
|
|
|
|
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
|
|
|
|
2017-02-22 11:25:25 +01:00
|
|
|
static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size)
|
2011-07-18 16:57:27 +02:00
|
|
|
{
|
2017-02-22 11:25:25 +01:00
|
|
|
return HeapAlloc(GetProcessHeap(), 0, size);
|
2011-07-18 16:57:27 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 11:25:25 +01:00
|
|
|
static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t size)
|
2011-07-18 16:57:27 +02:00
|
|
|
{
|
2017-02-22 11:25:25 +01:00
|
|
|
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
2011-07-18 16:57:27 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 11:25:25 +01:00
|
|
|
static inline void* __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t size)
|
2011-09-07 14:07:12 +02:00
|
|
|
{
|
2017-02-22 11:25:25 +01:00
|
|
|
return HeapReAlloc(GetProcessHeap(), 0, mem, size);
|
2011-09-07 14:07:12 +02:00
|
|
|
}
|
|
|
|
|
2011-07-18 16:57:27 +02:00
|
|
|
static inline BOOL heap_free(void *mem)
|
|
|
|
{
|
|
|
|
return HeapFree(GetProcessHeap(), 0, mem);
|
|
|
|
}
|
2011-09-05 11:14:55 +02:00
|
|
|
|
|
|
|
static inline LPWSTR heap_strdupW(LPCWSTR str)
|
|
|
|
{
|
|
|
|
LPWSTR ret = NULL;
|
|
|
|
|
|
|
|
if(str) {
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
size = (strlenW(str)+1)*sizeof(WCHAR);
|
|
|
|
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
|