32#define IDC_LANG_EXT "idc"
74 const idc_class_t *icls=
nullptr);
138 bool may_use_getattr=
false);
153 bool may_use_setattr=
false);
180 const char *name=
nullptr,
202#define VARSLICE_SINGLE 0x0001
234 const idc_class_t *super=
nullptr);
251idaman THREAD_SAFE
bool ida_export
set_idc_method(idc_class_t *icls,
const char *fullfuncname);
258idaman THREAD_SAFE
const char *ida_export
set_idc_getattr(idc_class_t *icls,
const char *fullfuncname);
259idaman THREAD_SAFE
const char *ida_export
set_idc_setattr(idc_class_t *icls,
const char *fullfuncname);
266idaman THREAD_SAFE
const char *ida_export
set_idc_dtor(idc_class_t *icls,
const char *fullfuncname);
280#define VREF_LOOP 0x0000
281#define VREF_ONCE 0x0001
282#define VREF_COPY 0x0002
403 size_t len = _str ==
nullptr ? 0 : strlen(_str);
466#define EXTFUN_BASE 0x0001
467#define EXTFUN_NORET 0x0002
469#define EXTFUN_SAFE 0x0004
515 bool (idaapi *undeclared_variable_ok)(
const char *name);
624#define HF_FIRST HF_KEYWORD1
658#define EXTLANG_IDC 0x01
659#define EXTLANG_NS_AWARE 0x02
938 bool complain_if_no_file=
true);
1010#define CPL_DEL_MACROS 0x0001
1011#define CPL_USE_LABELS 0x0002
1012#define CPL_ONLY_SAFE 0x0004
1018 int cpl_flags = CPL_DEL_MACROS|CPL_USE_LABELS);
1041 bool only_safe_funcs=
false);
1061 bool only_safe_funcs=
false);
1173 case VT_STR: *vtype = IDPOPT_STR, *vdata = v.
c_str();
break;
1174 case VT_LONG: *vtype = IDPOPT_NUM; *vdata = &v.
num;
break;
1175 case VT_WILD: *vtype = IDPOPT_BIT; *vdata = &v.
num;
break;
1176 case VT_INT64: *vtype = IDPOPT_I64; *vdata = &v.
i64;
break;
1177 case VT_PVOID: *vtype = IDPOPT_CST; *vdata = v.
pvoid;
break;
1178 default:
return false;
const qchar * c_str(void) const
Convert the qstring to a char *.
Definition pro.h:3170
Class to hold idc values.
Definition expr.hpp:315
void _set_string(const char *_str, size_t len)
Definition expr.hpp:396
void set_pvoid(void *p)
Definition expr.hpp:420
void clear(void)
See free_idcv()
Definition expr.hpp:369
bool is_integral(void)
Does value represent a whole number?
Definition expr.hpp:382
idc_value_t(const idc_value_t &r)
Create a $VT_LONG with an existing idc value.
Definition expr.hpp:357
void set_string(const qstring &_str)
Definition expr.hpp:418
fpvalue_t e
VT_FLOAT
Definition expr.hpp:340
char vtype
IDC value types
Definition expr.hpp:332
void create_empty_string(void)
Definition expr.hpp:415
~idc_value_t(void)
Destructor.
Definition expr.hpp:367
int64 i64
VT_INT64
Definition expr.hpp:344
void set_float(const fpvalue_t &f)
Definition expr.hpp:422
void set_int64(int64 v)
Definition expr.hpp:421
void _set_pvoid(void *p)
Definition expr.hpp:407
qstring & qstr(void)
VT_STR
Definition expr.hpp:376
void swap(idc_value_t &v)
Set this = r and v = this.
Definition expr.hpp:380
int funcidx
VT_FUNC
Definition expr.hpp:342
void _set_long(sval_t v)
Definition expr.hpp:406
void set_long(sval_t v)
Definition expr.hpp:419
const char * c_str(void) const
VT_STR
Definition expr.hpp:378
void _set_string(const char *_str)
Definition expr.hpp:401
sval_t num
VT_LONG
Definition expr.hpp:339
idc_value_t(sval_t n=0)
Create a VT_LONG value.
Definition expr.hpp:351
const uchar * u_str(void) const
VT_STR
Definition expr.hpp:379
bool is_zero(void) const
Does value represent the integer 0?
Definition expr.hpp:381
void _set_int64(int64 v)
Definition expr.hpp:408
void set_string(const char *_str)
Definition expr.hpp:417
bool is_convertible(void) const
Convertible types are VT_LONG, VT_FLOAT, VT_INT64, and VT_STR.
Definition expr.hpp:384
void set_string(const char *_str, size_t len)
Definition expr.hpp:416
const qstring & qstr(void) const
VT_STR
Definition expr.hpp:377
idc_value_t(const char *_str)
Create a VT_STR value.
Definition expr.hpp:363
idc_value_t & operator=(const idc_value_t &r)
Assign this value to an existing value.
Definition expr.hpp:371
void _set_float(const fpvalue_t &f)
Definition expr.hpp:409
idc_value_t(const qstring &_str)
Create a VT_STR value.
Definition expr.hpp:365
void _set_string(const qstring &_str)
Definition expr.hpp:391
void _create_empty_string(void)
Definition expr.hpp:390
idc_object_t * obj
Definition expr.hpp:341
void * pvoid
VT_PVOID
Definition expr.hpp:343
uchar reserve[sizeof(qstring)]
VT_STR.
Definition expr.hpp:345
Smart pointer to objects derived from qrefcnt_obj_t.
Definition pro.h:2920
Reimplementation of vector class from STL.
Definition pro.h:2250
idaman THREAD_SAFE error_t ida_export get_idcv_class_name(qstring *out, const idc_value_t *obj)
Retrieves the IDC object class name.
idaman THREAD_SAFE error_t ida_export set_idcv_slice(idc_value_t *v, uval_t i1, uval_t i2, const idc_value_t &in, int flags=0)
Set slice.
idaman THREAD_SAFE error_t ida_export idcv_long(idc_value_t *v)
Convert IDC variable to a long (32/64bit) number.
idaman THREAD_SAFE void ida_export swap_idcvs(idc_value_t *v1, idc_value_t *v2)
Swap 2 variables.
idaman THREAD_SAFE bool ida_export exec_system_script(const char *file, bool complain_if_no_file=true)
Compile and execute "main" function from system file.
idaman bool ida_export compile_idc_snippet(const char *func, const char *text, qstring *errbuf=nullptr, idc_resolver_t *resolver=nullptr, bool only_safe_funcs=false)
Compile text with IDC statements.
idaman THREAD_SAFE error_t ida_export idcv_float(idc_value_t *v)
Convert IDC variable to a floating point.
idaman bool ida_export eval_expr_long(sval_t *res, ea_t where, const char *line, qstring *errbuf=nullptr)
Compile and calculate an expression.
idaman bool ida_export select_extlang(extlang_t *el)
Selects the external language interpreter.
idaman bool ida_export eval_idc_expr(idc_value_t *rv, ea_t where, const char *buf, qstring *errbuf=nullptr)
Same as eval_expr(), but will always use the IDC interpreter regardless of the currently installed ex...
idaman THREAD_SAFE idc_value_t *ida_export find_idc_gvar(const char *name)
Find an existing global IDC variable by its name.
idaman ssize_t ida_export for_all_extlangs(extlang_visitor_t &ev, bool select=false)
Process all registered extlangs.
idaman THREAD_SAFE idc_class_t *ida_export add_idc_class(const char *name, const idc_class_t *super=nullptr)
Create a new IDC class.
extlang_object_t find_extlang_by_index(size_t idx)
Find an extlang by index.
Definition expr.hpp:891
DECLARE_TYPE_AS_MOVABLE(idc_value_t)
idaman THREAD_SAFE const char *ida_export prev_idcv_attr(const idc_value_t *obj, const char *attr)
idaman THREAD_SAFE bool ida_export set_header_path(const char *path, bool add)
Set or append a header path.
error_t idaapi idc_func_t(idc_value_t *argv, idc_value_t *r)
Prototype of an external IDC function (implemented in C).
Definition expr.hpp:445
idaman THREAD_SAFE error_t ida_export idcv_object(idc_value_t *v, const idc_class_t *icls=nullptr)
Create an IDC object.
idaman THREAD_SAFE const char *ida_export last_idcv_attr(const idc_value_t *obj)
idaman THREAD_SAFE idc_value_t *ida_export deref_idcv(idc_value_t *v, int vref_flags)
Dereference a VT_REF variable.
qvector< extlang_t * > extlangs_t
vector of external language descriptions
Definition expr.hpp:812
idaman THREAD_SAFE idc_value_t *ida_export add_idc_gvar(const char *name)
Add global IDC variable.
idaman THREAD_SAFE bool ida_export create_idcv_ref(idc_value_t *ref, const idc_value_t *v)
Create a variable reference.
THREAD_SAFE bool get_idptype_and_data(int *vtype, const void **vdata, const idc_value_t &v)
Extract type & data from the idc_value_t instance that was passed to parse_config_value().
Definition expr.hpp:1169
idaman THREAD_SAFE error_t ida_export del_idcv_attr(idc_value_t *obj, const char *attr)
Delete an object attribute.
extlang_object_t find_extlang_by_name(const char *name)
Find an extlang by name.
Definition expr.hpp:884
idaman THREAD_SAFE char *ida_export get_idc_filename(char *buf, size_t bufsize, const char *file)
Get full name of IDC file name.
idaman THREAD_SAFE bool ida_export add_idc_func(const ext_idcfunc_t &func)
Add an IDC function.
idaman THREAD_SAFE error_t ida_export get_idcv_attr(idc_value_t *res, const idc_value_t *obj, const char *attr, bool may_use_getattr=false)
Get an object attribute.
idaman bool ida_export print_idcv(qstring *out, const idc_value_t &v, const char *name=nullptr, int indent=0)
Get text representation of idc_value_t.
idaman THREAD_SAFE error_t ida_export set_idcv_attr(idc_value_t *obj, const char *attr, const idc_value_t &value, bool may_use_setattr=false)
Set an object attribute.
idaman THREAD_SAFE bool ida_export compile_idc_text(const char *line, qstring *errbuf=nullptr, idc_resolver_t *resolver=nullptr, bool only_safe_funcs=false)
idaman THREAD_SAFE const char *ida_export first_idcv_attr(const idc_value_t *obj)
idaman error_t ida_export throw_idc_exception(idc_value_t *r, const char *desc)
Create an idc execution exception object.
idaman THREAD_SAFE error_t ida_export copy_idcv(idc_value_t *dst, const idc_value_t &src)
Copy 'src' to 'dst'.
idaman THREAD_SAFE error_t ida_export idcv_int64(idc_value_t *v)
Convert IDC variable to a 64bit number.
idaman bool ida_export eval_expr(idc_value_t *rv, ea_t where, const char *line, qstring *errbuf=nullptr)
Compile and calculate an expression.
idaman void *ida_export find_extlang(const void *str, find_extlang_kind_t kind)
idaman THREAD_SAFE const char *ida_export set_idc_setattr(idc_class_t *icls, const char *fullfuncname)
idaman ssize_t ida_export install_extlang(extlang_t *el)
Install an external language interpreter.
idaman void *ida_export get_current_extlang(void)
Get current active external language.
idaman THREAD_SAFE bool ida_export del_idc_func(const char *name)
Delete an IDC function.
idaman THREAD_SAFE bool ida_export set_idc_method(idc_class_t *icls, const char *fullfuncname)
Set an IDC class method.
idaman THREAD_SAFE void ida_export free_idcv(idc_value_t *v)
Free storage used by VT_STR/VT_OBJ IDC variables.
idaman THREAD_SAFE error_t ida_export deep_copy_idcv(idc_value_t *dst, const idc_value_t &src)
Deep copy an IDC object.
idaman THREAD_SAFE error_t ida_export move_idcv(idc_value_t *dst, idc_value_t *src)
Move 'src' to 'dst'.
idaman bool ida_export call_idc_func(idc_value_t *result, const char *fname, const idc_value_t args[], size_t argsnum, qstring *errbuf=nullptr, idc_resolver_t *resolver=nullptr)
Execute an IDC function.
extlang_object_t find_extlang_by_ext(const char *ext)
Get the extlang that can handle the given file extension.
Definition expr.hpp:877
idaman bool ida_export remove_extlang(extlang_t *el)
Uninstall an external language interpreter.
idaman THREAD_SAFE const char *ida_export set_idc_getattr(idc_class_t *icls, const char *fullfuncname)
idaman bool ida_export eval_idc_snippet(idc_value_t *result, const char *line, qstring *errbuf=nullptr, idc_resolver_t *resolver=nullptr)
Compile and execute IDC statements or expressions.
idaman THREAD_SAFE error_t ida_export get_idcv_slice(idc_value_t *res, const idc_value_t *v, uval_t i1, uval_t i2, int flags=0)
Get slice.
qrefcnt_t< extlang_t > extlang_object_t
Definition expr.hpp:813
qvector< idc_global_t > idc_vars_t
vector of global idc variables
Definition expr.hpp:434
syntax_highlight_style
Possible syntax element highlighting style names.
Definition expr.hpp:608
@ HF_KEYWORD1
Definition expr.hpp:610
@ HF_NUMBER
Definition expr.hpp:616
@ HF_USER2
Definition expr.hpp:618
@ HF_PREPROC
Definition expr.hpp:615
@ HF_USER4
Definition expr.hpp:620
@ HF_DEFAULT
Definition expr.hpp:609
@ HF_STRING
Definition expr.hpp:613
@ HF_USER3
Definition expr.hpp:619
@ HF_COMMENT
Definition expr.hpp:614
@ HF_KEYWORD3
Definition expr.hpp:612
@ HF_KEYWORD2
Definition expr.hpp:611
@ HF_MAX
Definition expr.hpp:622
@ HF_USER1
Definition expr.hpp:617
THREAD_SAFE bool exec_idc_script(idc_value_t *result, const char *path, const char *func, const idc_value_t args[], size_t argsnum, qstring *errbuf=nullptr)
Compile and execute IDC function(s) from file.
Definition expr.hpp:1117
idaman THREAD_SAFE error_t ida_export idcv_num(idc_value_t *v)
Convert IDC variable to a long number.
idaman THREAD_SAFE const char *ida_export next_idcv_attr(const idc_value_t *obj, const char *attr)
const extlang_object_t get_extlang(void)
Definition expr.hpp:819
find_extlang_kind_t
Definition expr.hpp:865
@ FIND_EXTLANG_BY_IDX
Definition expr.hpp:868
@ FIND_EXTLANG_BY_NAME
Definition expr.hpp:867
@ FIND_EXTLANG_BY_EXT
Definition expr.hpp:866
idaman THREAD_SAFE bool ida_export find_idc_func(qstring *out, const char *prefix, int n=0)
idaman THREAD_SAFE idc_class_t *ida_export find_idc_class(const char *name)
Find an existing IDC class by its name.
idaman THREAD_SAFE error_t ida_export idcv_string(idc_value_t *v)
Convert IDC variable to a text string.
idaman THREAD_SAFE bool ida_export compile_idc_file(const char *file, qstring *errbuf=nullptr, int cpl_flags=CPL_DEL_MACROS|CPL_USE_LABELS)
idaman void ida_export setup_lowcnd_regfuncs(idc_func_t *getreg, idc_func_t *setreg)
Setup lowcnd callbacks to read/write registers.
idaman THREAD_SAFE const char *ida_export set_idc_dtor(idc_class_t *icls, const char *fullfuncname)
Set a destructor for an idc class.
idaman size_t n
Definition pro.h:997
idaman size_t ida_export ea2str(char *buf, size_t bufsize, ea_t ea)
Convert linear address to UTF-8 string.
carglist_t * args
Definition hexrays.hpp:7323
Contains definition of the interface to IDP modules.
IEEE floating point functions.
uval_t uval_t
Definition kernwin.hpp:1878
idaman size_t len
Definition kernwin.hpp:1356
bool result
Definition kernwin.hpp:7890
__int64 int64
Definition llong.hpp:14
unsigned int uint32
unsigned 32 bit value
Definition pro.h:348
adiff_t sval_t
signed value used by the processor.
Definition pro.h:446
uint64 ea_t
Definition pro.h:421
int int32
signed 32 bit value
Definition pro.h:347
unsigned char uchar
unsigned 8 bit value
Definition pro.h:337
idaman size_t bufsize
Definition pro.h:600
int error_t
Error code (errno)
Definition pro.h:458
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:381
_qstring< char > qstring
regular string
Definition pro.h:3694
Element of functions table. See idcfuncs_t::funcs.
Definition expr.hpp:451
const idc_value_t * defvals
Default argument values.
Definition expr.hpp:458
const char * args
Type of arguments.
Definition expr.hpp:454
const char * name
Name of function.
Definition expr.hpp:452
idc_func_t * fptr
Pointer to the Function.
Definition expr.hpp:453
int flags
Function description flags
Definition expr.hpp:462
int ndefvals
Number of default values.
Definition expr.hpp:461
External language (to support third party language interpreters)
Definition expr.hpp:655
bool(idaapi *call_func)(idc_value_t *result
Evaluate a previously compiled expression.
const idc_value_t * obj
Definition expr.hpp:754
ea_t const char qstring * errbuf
Definition expr.hpp:676
const char const idc_value_t & value
Definition expr.hpp:765
bool(idaapi *load_procmod)(idc_value_t *procobj
Compile (load) a file with processor module.
int32 refcnt
Reference count.
Definition expr.hpp:660
const char * requested_namespace
Definition expr.hpp:694
bool(idaapi *get_attr)(idc_value_t *result
Returns the attribute value of a given object from the global scope.
const char * fileext
File name extension for the language.
Definition expr.hpp:662
bool(idaapi *compile_expr)(const char *name
Compile an expression.
bool(idaapi *compile_file)(const char *file
Compile (load) a file.
bool(idaapi *call_method)(idc_value_t *result
Calls a member function.
ea_t current_ea
Definition expr.hpp:674
bool(idaapi *unload_procmod)(const char *path
Unload previously loaded processor module.
bool is_namespace_aware(void) const
Definition expr.hpp:808
syntax_highlighter_t * highlighter
Definition expr.hpp:663
const char * name
Language name.
Definition expr.hpp:661
uint32 flags
Language features.
Definition expr.hpp:657
const char const idc_value_t size_t nargs
Definition expr.hpp:707
bool(idaapi *create_object)(idc_value_t *result
Create an object instance.
size_t size
Size of this structure.
Definition expr.hpp:656
ea_t const char * expr
Definition expr.hpp:675
const char const idc_value_t args[]
Definition expr.hpp:706
const char * path
Definition expr.hpp:796
bool(idaapi *eval_expr)(idc_value_t *rv
Compile and evaluate an expression.
bool(idaapi *set_attr)(idc_value_t *obj
Sets the attribute value of a given object in the global scope.
const idc_value_t const char * attr
Definition expr.hpp:755
bool(idaapi *eval_snippet)(const char *str
Compile and execute a string with statements.
bool is_idc(void) const
Definition expr.hpp:807
void release(void)
Definition expr.hpp:809
virtual ssize_t idaapi visit_extlang(extlang_t *extlang)=0
Processor-independent representation of a floating point value.
Definition ieee.h:98
virtual void idaapi set_block_state(int32)
Definition expr.hpp:632
virtual int32 idaapi prev_block_state()
Definition expr.hpp:630
virtual int32 idaapi cur_block_state()
Definition expr.hpp:631
virtual ~highlighter_cbs_t()
Definition expr.hpp:628
virtual void idaapi set_style(int32, int32, syntax_highlight_style)
Definition expr.hpp:629
Global idc variable.
Definition expr.hpp:428
idc_value_t value
Definition expr.hpp:430
idc_global_t(const char *n)
Definition expr.hpp:432
idc_global_t(void)
Definition expr.hpp:431
qstring name
Definition expr.hpp:429
Compile text with IDC function(s).
Definition expr.hpp:1033
virtual uval_t idaapi resolve_name(const char *name)=0
Describes an array of IDC functions.
Definition expr.hpp:476
void(idaapi *init_idc)(void)
Initialize IDC engine.
size_t qnty
Number of functions.
Definition expr.hpp:477
size_t ea_t ea
Definition expr.hpp:504
int calc_sizeof
Calculate sizeof(type).
Definition expr.hpp:544
size_t bufsize
Definition expr.hpp:504
size_t(idaapi *ea2str)(char *buf
Convert an address to a string.
bool(idaapi *is_database_open)(void)
Is the database open?
bool(idaapi *undeclared_variable_ok)(const char *name)
Should a variable name be accepted without declaration?
ext_idcfunc_t * funcs
Function table.
Definition expr.hpp:478
int set_unkvar
Store a value to an undeclared variable.
Definition expr.hpp:529
int exec_resolved_func
Execute resolved function.
Definition expr.hpp:536
int get_unkvar
Retrieve value of an undeclared variable.
Definition expr.hpp:525
int get_field_ea
Get address of the specified field using the type information from the idb.
Definition expr.hpp:553
void(idaapi *term_idc)(void)
Terminate IDC engine. Called once at the very end of work.
error_t(idaapi *startup)(void)
Start IDC engine. Called before executing any IDC code.
error_t(idaapi *shutdown)(void)
Stop IDC engine.
Base class for syntax highligters.
Definition expr.hpp:637
block_highlighter_t * highlight_block
Definition expr.hpp:648
void idaapi block_highlighter_t(void *context, highlighter_cbs_t *highlighter_cbs, const qstring &text)
Function for extlang syntax highlighting.
Definition expr.hpp:642
syntax_highlighter_t(block_highlighter_t *bh=nullptr)
Definition expr.hpp:646
virtual ~syntax_highlighter_t()
Definition expr.hpp:647