Hex-Rays logo State-of-the-art binary code analysis tools
email icon
expr.hpp File Reference

Functions that deal with C-like expressions and built-in IDC language. More...

Classes

class  idc_value_t
 Class to hold idc values. More...
 
struct  idc_global_t
 Global idc variable. More...
 
struct  ext_idcfunc_t
 Element of functions table. See idcfuncs_t::funcs. More...
 
struct  idcfuncs_t
 Describes an array of IDC functions. More...
 
struct  highlighter_cbs_t
 
struct  syntax_highlighter_t
 Base class for syntax highligters. More...
 
struct  extlang_t
 External language (to support third party language interpreters) More...
 
struct  extlang_visitor_t
 
struct  idc_resolver_t
 Compile text with IDC function(s). More...
 

Macros

#define IDC_LANG_EXT   "idc"
 IDC script extension.
 
#define VT_LONG   2
 Integer (see idc_value_t::num)
 
#define VT_FLOAT   3
 Floating point (see idc_value_t::e)
 
#define VT_WILD   4
 Function with arbitrary number of arguments. More...
 
#define VT_OBJ   5
 Object (see idc_value_t::obj)
 
#define VT_FUNC   6
 Function (see idc_value_t::funcidx)
 
#define VT_STR   7
 String (see qstr() and similar functions)
 
#define VT_PVOID   8
 void *
 
#define VT_INT64   9
 i64
 
#define VT_REF   10
 Reference.
 
#define EXTFUN_BASE   0x0001
 requires open database.
 
#define EXTFUN_NORET   0x0002
 does not return. More...
 
#define EXTFUN_SAFE   0x0004
 thread safe function. More...
 
#define EXTLANG_IDC   0x01
 
#define EXTLANG_NS_AWARE   0x02
 Namespace-aware (see above.)
 

Functions

idaman THREAD_SAFE error_t ida_export idcv_long (idc_value_t *v)
 Convert IDC variable to a long (32/64bit) number. More...
 
idaman THREAD_SAFE error_t ida_export idcv_int64 (idc_value_t *v)
 Convert IDC variable to a 64bit number. More...
 
idaman THREAD_SAFE error_t ida_export idcv_num (idc_value_t *v)
 Convert IDC variable to a long number. More...
 
idaman THREAD_SAFE error_t ida_export idcv_string (idc_value_t *v)
 Convert IDC variable to a text string.
 
idaman THREAD_SAFE error_t ida_export idcv_float (idc_value_t *v)
 Convert IDC variable to a floating point.
 
idaman THREAD_SAFE error_t ida_export idcv_object (idc_value_t *v, const idc_class_t *icls=nullptr)
 Create an IDC object. More...
 
idaman THREAD_SAFE error_t ida_export move_idcv (idc_value_t *dst, idc_value_t *src)
 Move 'src' to 'dst'. More...
 
idaman THREAD_SAFE error_t ida_export copy_idcv (idc_value_t *dst, const idc_value_t &src)
 Copy 'src' to 'dst'. More...
 
idaman THREAD_SAFE error_t ida_export deep_copy_idcv (idc_value_t *dst, const idc_value_t &src)
 Deep copy an IDC object. More...
 
idaman THREAD_SAFE void ida_export free_idcv (idc_value_t *v)
 Free storage used by VT_STR/VT_OBJ IDC variables. More...
 
idaman THREAD_SAFE void ida_export swap_idcvs (idc_value_t *v1, idc_value_t *v2)
 Swap 2 variables.
 
idaman THREAD_SAFE error_t ida_export get_idcv_class_name (qstring *out, const idc_value_t *obj)
 Retrieves the IDC object class name. More...
 
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. More...
 
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. More...
 
idaman THREAD_SAFE error_t ida_export del_idcv_attr (idc_value_t *obj, const char *attr)
 Delete an object attribute. More...
 

Enumerate object attributes

#define VARSLICE_SINGLE   0x0001
 return single index (i2 is ignored)
 
idaman THREAD_SAFE const char *ida_export first_idcv_attr (const idc_value_t *obj)
 
idaman THREAD_SAFE const char *ida_export last_idcv_attr (const idc_value_t *obj)
 
idaman THREAD_SAFE const char *ida_export next_idcv_attr (const idc_value_t *obj, const char *attr)
 
idaman THREAD_SAFE const char *ida_export prev_idcv_attr (const idc_value_t *obj, const char *attr)
 
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 get_idcv_slice (idc_value_t *res, const idc_value_t *v, uval_t i1, uval_t i2, int flags=0)
 Get slice. More...
 
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. More...
 
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. More...
 
idaman THREAD_SAFE idc_class_t *ida_export find_idc_class (const char *name)
 Find an existing IDC class by its name. More...
 
idaman THREAD_SAFE bool ida_export set_idc_method (idc_class_t *icls, const char *fullfuncname)
 Set an IDC class method. More...
 

Set user-defined functions to work with object attributes.

If the function name is nullptr, the definitions are removed.

Returns
name of the old attribute function. nullptr means error, "" means no previous attr func
#define VREF_LOOP   0x0000
 dereference until we get a non VT_REF
 
#define VREF_ONCE   0x0001
 dereference only once, do not loop
 
#define VREF_COPY   0x0002
 copy the result to the input var (v)
 
#define eExecThrow   90
 See return value of idc_func_t.
 
#define HF_FIRST   HF_KEYWORD1
 
#define CPL_DEL_MACROS   0x0001
 delete macros at the end of compilation
 
#define CPL_USE_LABELS   0x0002
 allow program labels in the script
 
#define CPL_ONLY_SAFE   0x0004
 allow calls of only thread-safe functions
 
enum  syntax_highlight_style {
  HF_DEFAULT = 0 , HF_KEYWORD1 = 1 , HF_KEYWORD2 = 2 , HF_KEYWORD3 = 3 ,
  HF_STRING = 4 , HF_COMMENT = 5 , HF_PREPROC = 6 , HF_NUMBER = 7 ,
  HF_MAX
}
 Possible syntax element highlighting style names.
 
enum  find_extlang_kind_t { FIND_EXTLANG_BY_EXT , FIND_EXTLANG_BY_NAME , FIND_EXTLANG_BY_IDX }
 
typedef qvector< idc_global_tidc_vars_t
 vector of global idc variables
 
typedef error_t idaapi idc_func_t(idc_value_t *argv, idc_value_t *r)
 Prototype of an external IDC function (implemented in C). More...
 
typedef qvector< extlang_t * > extlangs_t
 vector of external language descriptions
 
typedef qrefcnt_t< extlang_textlang_object_t
 
idaman THREAD_SAFE const char *ida_export set_idc_getattr (idc_class_t *icls, const char *fullfuncname)
 
idaman THREAD_SAFE const char *ida_export set_idc_setattr (idc_class_t *icls, const char *fullfuncname)
 
idaman THREAD_SAFE const char *ida_export set_idc_dtor (idc_class_t *icls, const char *fullfuncname)
 Set a destructor for an idc class. More...
 
idaman THREAD_SAFE idc_value_t *ida_export deref_idcv (idc_value_t *v, int vref_flags)
 Dereference a VT_REF variable. More...
 
idaman THREAD_SAFE bool ida_export create_idcv_ref (idc_value_t *ref, const idc_value_t *v)
 Create a variable reference. More...
 
idaman THREAD_SAFE idc_value_t *ida_export add_idc_gvar (const char *name)
 Add global IDC variable. More...
 
idaman THREAD_SAFE idc_value_t *ida_export find_idc_gvar (const char *name)
 Find an existing global IDC variable by its name. More...
 
idaman THREAD_SAFE bool ida_export add_idc_func (const ext_idcfunc_t &func)
 Add an IDC function. More...
 
idaman THREAD_SAFE bool ida_export del_idc_func (const char *name)
 Delete an IDC function.
 
idaman THREAD_SAFE bool ida_export find_idc_func (qstring *out, const char *prefix, int n=0)
 
idaman void *ida_export get_current_extlang (void)
 Get current active external language.
 
const extlang_object_t get_extlang (void)
 
idaman ssize_t ida_export install_extlang (extlang_t *el)
 Install an external language interpreter. More...
 
idaman bool ida_export remove_extlang (extlang_t *el)
 Uninstall an external language interpreter. More...
 
idaman bool ida_export select_extlang (extlang_t *el)
 Selects the external language interpreter. More...
 
idaman ssize_t ida_export for_all_extlangs (extlang_visitor_t &ev, bool select=false)
 Process all registered extlangs.
 
idaman void *ida_export find_extlang (const void *str, find_extlang_kind_t kind)
 
extlang_object_t find_extlang_by_ext (const char *ext)
 Get the extlang that can handle the given file extension.
 
extlang_object_t find_extlang_by_name (const char *name)
 Find an extlang by name.
 
extlang_object_t find_extlang_by_index (size_t idx)
 Find an extlang by index.
 
idaman THREAD_SAFE bool ida_export set_header_path (const char *path, bool add)
 Set or append a header path. More...
 
idaman THREAD_SAFE char *ida_export get_idc_filename (char *buf, size_t bufsize, const char *file)
 Get full name of IDC file name. More...
 
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. More...
 
idaman bool ida_export eval_expr_long (sval_t *res, ea_t where, const char *line, qstring *errbuf=nullptr)
 Compile and calculate an expression. More...
 
bool idaapi eval_expr_long (uval_t *res, ea_t where, const char *line, qstring *errbuf=nullptr)
 See eval_expr_long()
 
idaman bool ida_export eval_expr (idc_value_t *rv, ea_t where, const char *line, qstring *errbuf=nullptr)
 Compile and calculate an expression. More...
 
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 extlang. More...
 
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 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 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. More...
 
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. More...
 
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. More...
 
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. More...
 
idaman void ida_export setup_lowcnd_regfuncs (idc_func_t *getreg, idc_func_t *setreg)
 Setup lowcnd callbacks to read/write registers. More...
 
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(). More...
 
idaman error_t ida_export throw_idc_exception (idc_value_t *r, const char *desc)
 Create an idc execution exception object. More...
 

Detailed Description

Functions that deal with C-like expressions and built-in IDC language.

Functions marked THREAD_SAFE may be called from any thread. No simultaneous calls should be made for the same variable. We protect only global structures, individual variables must be protected manually.

Macro Definition Documentation

◆ VT_WILD

#define VT_WILD   4

Function with arbitrary number of arguments.

The actual number of arguments will be passed in idc_value_t::num. This value should not be used for idc_value_t.

◆ EXTFUN_NORET

#define EXTFUN_NORET   0x0002

does not return.

the interpreter may clean up its state before calling it.

◆ EXTFUN_SAFE

#define EXTFUN_SAFE   0x0004

thread safe function.

may be called from any thread.

Typedef Documentation

◆ idc_func_t

typedef error_t idaapi idc_func_t(idc_value_t *argv, idc_value_t *r)

Prototype of an external IDC function (implemented in C).

Parameters
argvvector of input arguments. IDA will convert all arguments to types specified by ext_idcfunc_t::args, except for VT_WILD
rreturn value of the function or exception
Returns
0 if ok, all other values indicate error. the error code must be set with set_qerrno():
  • eExecThrow - a new exception has been generated, see 'r'
  • other values - runtime error has occurred

Function Documentation

◆ idcv_long()

idaman THREAD_SAFE error_t ida_export idcv_long ( idc_value_t v)

Convert IDC variable to a long (32/64bit) number.

Returns
v = 0 if impossible to convert to long

◆ idcv_int64()

idaman THREAD_SAFE error_t ida_export idcv_int64 ( idc_value_t v)

Convert IDC variable to a 64bit number.

Returns
v = 0 if impossible to convert to int64

◆ idcv_num()

idaman THREAD_SAFE error_t ida_export idcv_num ( idc_value_t v)

Convert IDC variable to a long number.

Returns
  • v = 0 if IDC variable = "false" string
  • v = 1 if IDC variable = "true" string
  • v = number if IDC variable is number or string containing a number
  • eTypeConflict if IDC variable = empty string

◆ idcv_object()

idaman THREAD_SAFE error_t ida_export idcv_object ( idc_value_t v,
const idc_class_t *  icls = nullptr 
)

Create an IDC object.

The original value of 'v' is discarded (freed).

Parameters
vvariable to hold the object. any previous value will be cleaned
iclsptr to the desired class. nullptr means "object" class this ptr must be returned by add_idc_class() or find_idc_class()
Returns
always eOk

◆ move_idcv()

idaman THREAD_SAFE error_t ida_export move_idcv ( idc_value_t dst,
idc_value_t src 
)

Move 'src' to 'dst'.

This function is more effective than copy_idcv since it never copies big amounts of data.

◆ copy_idcv()

idaman THREAD_SAFE error_t ida_export copy_idcv ( idc_value_t dst,
const idc_value_t src 
)

Copy 'src' to 'dst'.

For idc objects only a reference is copied.

◆ deep_copy_idcv()

idaman THREAD_SAFE error_t ida_export deep_copy_idcv ( idc_value_t dst,
const idc_value_t src 
)

Deep copy an IDC object.

This function performs deep copy of idc objects. If 'src' is not an object, copy_idcv() will be called

◆ free_idcv()

idaman THREAD_SAFE void ida_export free_idcv ( idc_value_t v)

Free storage used by VT_STR/VT_OBJ IDC variables.

After this call the variable has a numeric value 0

◆ get_idcv_class_name()

idaman THREAD_SAFE error_t ida_export get_idcv_class_name ( qstring out,
const idc_value_t obj 
)

Retrieves the IDC object class name.

Parameters
outqstring ptr for the class name. Can be nullptr.
objclass instance variable
Returns
error code, eOk on success

◆ get_idcv_attr()

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.

Parameters
resbuffer for the attribute value
objvariable that holds an object reference. if obj is nullptr it searches global variables, then user functions
attrattribute name
may_use_getattrmay call getattr functions to calculate the attribute if it does not exist
Returns
error code, eOk on success

◆ set_idcv_attr()

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.

Parameters
objvariable that holds an object reference. if obj is nullptr then it tries to modify a global variable with the attribute name
attrattribute name
valuenew attribute value
may_use_setattrmay call setattr functions for the class
Returns
error code, eOk on success

◆ del_idcv_attr()

idaman THREAD_SAFE error_t ida_export del_idcv_attr ( idc_value_t obj,
const char *  attr 
)

Delete an object attribute.

Parameters
objvariable that holds an object reference
attrattribute name
Returns
error code, eOk on success

◆ get_idcv_slice()

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.

Parameters
resoutput variable that will contain the slice
vinput variable (string or object)
i1slice start index
i2slice end index (excluded)
flagsIDC variable slice flags or 0
Returns
eOk if success

◆ set_idcv_slice()

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.

Parameters
vvariable to modify (string or object)
i1slice start index
i2slice end index (excluded)
innew value for the slice
flagsIDC variable slice flags or 0
Returns
eOk on success

◆ add_idc_class()

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.

Parameters
namename of the new class
superthe base class for the new class. if the new class is not based on any other class, pass nullptr
Returns
pointer to the created class. If such a class already exists, a pointer to it will be returned. Pointers to other existing classes may be invalidated by this call.

◆ find_idc_class()

idaman THREAD_SAFE idc_class_t *ida_export find_idc_class ( const char *  name)

Find an existing IDC class by its name.

Parameters
namename of the class
Returns
pointer to the class or nullptr. The returned pointer is valid until a new call to add_idc_class()

◆ set_idc_method()

idaman THREAD_SAFE bool ida_export set_idc_method ( idc_class_t *  icls,
const char *  fullfuncname 
)

Set an IDC class method.

Parameters
iclspointer to the class
fullfuncnamename of the function to call. use full method name: classname.funcname
Return values
truesuccess
falsethe function could not be found

◆ set_idc_dtor()

idaman THREAD_SAFE const char *ida_export set_idc_dtor ( idc_class_t *  icls,
const char *  fullfuncname 
)

Set a destructor for an idc class.

The destructor is called before deleting any object of the specified class. Exceptions that escape the destructor are silently ignored, runtime errors too.

◆ deref_idcv()

idaman THREAD_SAFE idc_value_t *ida_export deref_idcv ( idc_value_t v,
int  vref_flags 
)

Dereference a VT_REF variable.

Parameters
vvariable to dereference
vref_flagsDereference IDC variable flags
Returns
pointer to the dereference result or nullptr. If returns nullptr, qerrno is set to eExecBadRef "Illegal variable reference"

◆ create_idcv_ref()

idaman THREAD_SAFE bool ida_export create_idcv_ref ( idc_value_t ref,
const idc_value_t v 
)

Create a variable reference.

Currently only references to global variables can be created.

Parameters
refptr to the result
vvariable to reference
Returns
success

◆ add_idc_gvar()

idaman THREAD_SAFE idc_value_t *ida_export add_idc_gvar ( const char *  name)

Add global IDC variable.

Parameters
namename of the global variable
Returns
pointer to the created variable or existing variable. NB: the returned pointer is valid until a new global var is added.

◆ find_idc_gvar()

idaman THREAD_SAFE idc_value_t *ida_export find_idc_gvar ( const char *  name)

Find an existing global IDC variable by its name.

Parameters
namename of the global variable
Returns
pointer to the variable or nullptr. NB: the returned pointer is valid until a new global var is added. FIXME: it is difficult to use this function in a thread safe manner

◆ add_idc_func()

idaman THREAD_SAFE bool ida_export add_idc_func ( const ext_idcfunc_t func)

Add an IDC function.

This function does not modify the predefined kernel functions. Example:

static error_t idaapi myfunc5(idc_value_t *argv, idc_value_t *res)
{
msg("myfunc is called with arg0=%a and arg1=%s\n", argv[0].num, argv[1].str);
res->num = 5; // let's return 5
return eOk;
}
static const char myfunc5_args[] = { VT_LONG, VT_STR, 0 };
static const ext_idcfunc_t myfunc_desc = { "MyFunc5", myfunc5, myfunc5_args, nullptr, 0, EXTFUN_BASE };
// after this:
add_idc_func(myfunc_desc);
// there is a new IDC function which can be called like this:
MyFunc5(0x123, "test");
Class to hold idc values.
Definition: expr.hpp:315
sval_t num
VT_LONG
Definition: expr.hpp:338
#define EXTFUN_BASE
requires open database.
Definition: expr.hpp:457
#define VT_STR
String (see qstr() and similar functions)
Definition: expr.hpp:327
idaman THREAD_SAFE bool ida_export add_idc_func(const ext_idcfunc_t &func)
Add an IDC function.
#define VT_LONG
Integer (see idc_value_t::num)
Definition: expr.hpp:320
#define eOk
no error
Definition: pro.h:671
int error_t
Error code (errno)
Definition: pro.h:440
Element of functions table. See idcfuncs_t::funcs.
Definition: expr.hpp:442
Parameters
funcfunction description block.
Note
If the function already exists, it will be replaced by the new function
Returns
success

◆ install_extlang()

idaman ssize_t ida_export install_extlang ( extlang_t el)

Install an external language interpreter.

Any previously registered interpreter will be automatically unregistered. The installed extlang can be used in select_extlang().

Parameters
eldescription of the new language. must point to static storage.
Returns
extlang id; -1 means failure and will happen if the extlang has already been installed

◆ remove_extlang()

idaman bool ida_export remove_extlang ( extlang_t el)

Uninstall an external language interpreter.

Returns
success

◆ select_extlang()

idaman bool ida_export select_extlang ( extlang_t el)

Selects the external language interpreter.

The specified extlang must be registered before selecting it. It will be used to evaluate expressions entered in dialog boxes. It will also replace the eval_expr() and eval_expr_long() functions.

Returns
success

◆ set_header_path()

idaman THREAD_SAFE bool ida_export set_header_path ( const char *  path,
bool  add 
)

Set or append a header path.

IDA looks for the include files in the appended header paths, then in the ida executable directory.

Parameters
pathlist of directories to add (separated by ';') may be nullptr, in this case nothing is added
addtrue: append. false: remove old paths.
Return values
truesuccess
falseno memory

◆ get_idc_filename()

idaman THREAD_SAFE char *ida_export get_idc_filename ( char *  buf,
size_t  bufsize,
const char *  file 
)

Get full name of IDC file name.

Search for file in list of include directories, IDCPATH directory and system directories.

Parameters
bufbuffer for the answer
bufsizesize of buffer
filefile name without full path
Returns
nullptr is file not found. otherwise returns pointer to buf

◆ exec_system_script()

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.

Parameters
filefile name with IDC function(s). The file will be searched using get_idc_filename().
complain_if_no_file
  • 1: display warning if the file is not found
  • 0: don't complain if file doesn't exist
Return values
1ok, file is compiled and executed
0failure, compilation or execution error, warning is displayed

◆ eval_expr_long()

idaman bool ida_export eval_expr_long ( sval_t res,
ea_t  where,
const char *  line,
qstring errbuf = nullptr 
)

Compile and calculate an expression.

Parameters
respointer to result. The result will be converted to 32/64bit number. Use eval_expr() if you need the result of another type.
wherethe current linear address in the addressing space of the program being disassembled. it will be used to resolve names of local variables, etc. if not applicable, then should be BADADDR
linea text line with IDC expression
[out]errbufbuffer for the error message
Return values
trueok
falseerror, see errbuf

◆ eval_expr()

idaman bool ida_export eval_expr ( idc_value_t rv,
ea_t  where,
const char *  line,
qstring errbuf = nullptr 
)

Compile and calculate an expression.

Parameters
rvpointer to the result
wherethe current linear address in the addressing space of the program being disassembled. If will be used to resolve names of local variables etc. if not applicable, then should be BADADDR.
linethe expression to evaluate
[out]errbufbuffer for the error message
Return values
trueok
falseerror, see errbuf

◆ eval_idc_expr()

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 extlang.

◆ compile_idc_snippet()

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.

Parameters
funcname of the function to create out of the snippet
texttext to compile
[out]errbufbuffer for the error message
resolvercallback object to get values of undefined variables This object will be called if IDC function contains references to undefined variables. May be nullptr.
only_safe_funcsif true, any calls to functions without EXTFUN_SAFE flag will lead to a compilation error.
Return values
trueok
falseerror, see errbuf

◆ call_idc_func()

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.

Parameters
[out]resultpointer to idc_value_t to hold the return value of the function. If execution fails, this variable will contain the exception information. Can be nullptr if return value is not required.
fnamefunction name. User-defined functions, built-in functions, and plugin-defined functions are accepted.
argsarray of parameters
argsnumnumber of parameters to pass to 'fname'. This number should be equal to number of parameters the function expects.
[out]errbufbuffer for the error message
resolvercallback object to get values of undefined variables This object will be called if IDC function contains references to undefined variables. May be nullptr.
Return values
trueok
falseerror, see errbuf

◆ exec_idc_script()

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 
)
inline

Compile and execute IDC function(s) from file.

Parameters
resultptr to idc_value_t to hold result of the function. If execution fails, this variable will contain the exception information. You may pass nullptr if you are not interested in the returned value.
pathtext file containing text of IDC functions
funcfunction name to execute
argsarray of parameters
argsnumnumber of parameters to pass to 'fname' This number should be equal to number of parameters the function expects.
[out]errbufbuffer for the error message
Return values
trueok
falseerror, see errbuf

◆ eval_idc_snippet()

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.

Parameters
resultptr to idc_value_t to hold result of the function. If execution fails, this variable will contain the exception information. You may pass nullptr if you are not interested in the returned value.
linebody of IDC the function
[out]errbufbuffer for the error message
resolvercallback object to get values of undefined variables This object will be called if IDC function contains references to undefined variables. May be nullptr.
Returns
success
Note
see also eval_idc_expr()

◆ setup_lowcnd_regfuncs()

idaman void ida_export setup_lowcnd_regfuncs ( idc_func_t getreg,
idc_func_t setreg 
)

Setup lowcnd callbacks to read/write registers.

These callbacks will be used by the idc engine to read/write registers while calculating low level breakpoint conditions for local debuggers.

◆ get_idptype_and_data()

THREAD_SAFE bool get_idptype_and_data ( int *  vtype,
const void **  vdata,
const idc_value_t v 
)
inline

Extract type & data from the idc_value_t instance that was passed to parse_config_value().

Parameters
vtypepointer to storage that will hold the type (IDPOPT_T)
vdatapointer to storage that contains the value (see IDPOPT_T for what type of data is pointed to.)
vthe value holder
Returns
true in case of success, false if 'v' is of unexpected type

◆ throw_idc_exception()

idaman error_t ida_export throw_idc_exception ( idc_value_t r,
const char *  desc 
)

Create an idc execution exception object.

This helper function can be used to return an exception from C++ code to IDC. In other words this function can be called from idc_func_t() callbacks. Sample usage: if ( !ok ) return throw_idc_exception(r, "detailed error msg");

Parameters
robject to hold the exception object
descexception description
Returns
eExecThrow