IDA C++ SDK 9.2
Loading...
Searching...
No Matches
expr.hpp
Go to the documentation of this file.
1/*
2 * Interactive disassembler (IDA).
3 * Copyright (c) 1990-2026 Hex-Rays
4 * ALL RIGHTS RESERVED.
5 *
6 */
7
8#ifndef _EXPR_H
9#define _EXPR_H
10
11#include <ieee.h>
12#include <idp.hpp>
13
23
24//------------------------------------------------------------------------
25
26// Forward declarations
27class idc_value_t;
28class idc_class_t;
29class idc_object_t;
30
32#define IDC_LANG_EXT "idc"
33
36
37idaman THREAD_SAFE error_t ida_export idcv_long(idc_value_t *v);
38
39
42
43idaman THREAD_SAFE error_t ida_export idcv_int64(idc_value_t *v);
44
45
52
53idaman THREAD_SAFE error_t ida_export idcv_num(idc_value_t *v);
54
55
57
58idaman THREAD_SAFE error_t ida_export idcv_string(idc_value_t *v);
59
60
62
63idaman THREAD_SAFE error_t ida_export idcv_float(idc_value_t *v);
64
65
71
72idaman THREAD_SAFE error_t ida_export idcv_object(
73 idc_value_t *v,
74 const idc_class_t *icls=nullptr);
75
76
80
81idaman THREAD_SAFE error_t ida_export move_idcv(
82 idc_value_t *dst,
83 idc_value_t *src);
84
85
88
89idaman THREAD_SAFE error_t ida_export copy_idcv(
90 idc_value_t *dst,
91 const idc_value_t &src);
92
93
97
98idaman THREAD_SAFE error_t ida_export deep_copy_idcv(
99 idc_value_t *dst,
100 const idc_value_t &src);
101
102
105
106idaman THREAD_SAFE void ida_export free_idcv(idc_value_t *v);
107
108
110
111idaman THREAD_SAFE void ida_export swap_idcvs(
112 idc_value_t *v1,
113 idc_value_t *v2);
114
115
120
121idaman THREAD_SAFE error_t ida_export get_idcv_class_name(
122 qstring *out,
123 const idc_value_t *obj);
124
125
133
134idaman THREAD_SAFE error_t ida_export get_idcv_attr(
135 idc_value_t *res,
136 const idc_value_t *obj,
137 const char *attr,
138 bool may_use_getattr=false);
139
140
148
149idaman THREAD_SAFE error_t ida_export set_idcv_attr(
150 idc_value_t *obj,
151 const char *attr,
152 const idc_value_t &value,
153 bool may_use_setattr=false);
154
155
160
161idaman THREAD_SAFE error_t ida_export del_idcv_attr(
162 idc_value_t *obj,
163 const char *attr);
164
165
168idaman THREAD_SAFE const char *ida_export first_idcv_attr(const idc_value_t *obj);
169idaman THREAD_SAFE const char *ida_export last_idcv_attr(const idc_value_t *obj);
170idaman THREAD_SAFE const char *ida_export next_idcv_attr(const idc_value_t *obj, const char *attr);
171idaman THREAD_SAFE const char *ida_export prev_idcv_attr(const idc_value_t *obj, const char *attr);
173
174
176
177idaman bool ida_export print_idcv(
178 qstring *out,
179 const idc_value_t &v,
180 const char *name=nullptr,
181 int indent=0);
182
183
191
192idaman THREAD_SAFE error_t ida_export get_idcv_slice(
193 idc_value_t *res,
194 const idc_value_t *v,
195 uval_t i1,
196 uval_t i2,
197 int flags=0);
198
202#define VARSLICE_SINGLE 0x0001
204
212
213idaman THREAD_SAFE error_t ida_export set_idcv_slice(
214 idc_value_t *v,
215 uval_t i1,
216 uval_t i2,
217 const idc_value_t &in,
218 int flags=0);
219
220
221//-------------------------------------------------------------------------
222// IDC class related functions
223
231
232idaman THREAD_SAFE idc_class_t *ida_export add_idc_class(
233 const char *name,
234 const idc_class_t *super=nullptr);
235
236
241
242idaman THREAD_SAFE idc_class_t *ida_export find_idc_class(const char *name);
243
244
250
251idaman THREAD_SAFE bool ida_export set_idc_method(idc_class_t *icls, const char *fullfuncname);
252
253
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);
261
265
266idaman THREAD_SAFE const char *ida_export set_idc_dtor(idc_class_t *icls, const char *fullfuncname);
267
268
274
275idaman THREAD_SAFE idc_value_t *ida_export deref_idcv(idc_value_t *v, int vref_flags);
276
280#define VREF_LOOP 0x0000
281#define VREF_ONCE 0x0001
282#define VREF_COPY 0x0002
284
285
291
292idaman THREAD_SAFE bool ida_export create_idcv_ref(idc_value_t *ref, const idc_value_t *v);
293
294
299
300idaman THREAD_SAFE idc_value_t *ida_export add_idc_gvar(const char *name);
301
302
308
309idaman THREAD_SAFE idc_value_t *ida_export find_idc_gvar(const char *name);
310
311
312//-------------------------------------------------------------------------
315{
316public:
320#define VT_LONG 2
321#define VT_FLOAT 3
322#define VT_WILD 4
325#define VT_OBJ 5
326#define VT_FUNC 6
327#define VT_STR 7
328#define VT_PVOID 8
329#define VT_INT64 9
330#define VT_REF 10
332 char vtype = VT_LONG;
333
334#ifndef SWIG
335 // this union must be the last member (see memset below)
336 union
337 {
338#endif // SWIG
341 idc_object_t *obj;
343 void *pvoid;
346#ifndef SWIG
347 };
348#endif // SWIG
349
352 {
353 memset(reserve, 0, sizeof(idc_value_t) - qoffsetof(idc_value_t, reserve));
354 num = n;
355 }
356
358 {
359 memset(reserve, 0, sizeof(idc_value_t) - qoffsetof(idc_value_t, reserve));
360 copy_idcv(this, r);
361 }
362
363 idc_value_t(const char *_str) : vtype(VT_STR) { new(&qstr()) qstring(_str); }
365 idc_value_t(const qstring &_str) : vtype(VT_STR) { new(&qstr()) qstring(_str); }
367 ~idc_value_t(void) { clear(); }
369 void clear(void) { free_idcv(this); } // put num 0
372 {
373 copy_idcv(this, r);
374 return *this;
375 }
376 qstring &qstr(void) { return *(qstring *)&num; }
377 const qstring &qstr(void) const { return *(qstring *)&num; }
378 const char *c_str(void) const { return qstr().c_str(); }
379 const uchar *u_str(void) const { return (const uchar *)c_str(); }
380 void swap(idc_value_t &v) { swap_idcvs(this, &v); }
381 bool is_zero(void) const { return vtype == VT_LONG && num == 0; }
382 bool is_integral(void) { return vtype == VT_LONG || vtype == VT_INT64; }
384 bool is_convertible(void) const { return (vtype >= 1 && vtype <= VT_FLOAT) || vtype == VT_STR || vtype == VT_INT64; }
385
390 void _create_empty_string(void) { vtype = VT_STR; new (&qstr()) qstring; }
391 void _set_string(const qstring &_str)
392 {
393 vtype = VT_STR;
394 new (&qstr()) qstring(_str);
395 }
396 void _set_string(const char *_str, size_t len)
397 {
398 vtype = VT_STR;
399 new (&qstr()) qstring(_str, len);
400 }
401 void _set_string(const char *_str)
402 {
403 size_t len = _str == nullptr ? 0 : strlen(_str);
404 _set_string(_str, len);
405 }
406 void _set_long(sval_t v) { vtype = VT_LONG; num = v; }
407 void _set_pvoid(void *p) { vtype = VT_PVOID; pvoid = p; }
408 void _set_int64(int64 v) { vtype = VT_INT64; i64 = v; }
409 void _set_float(const fpvalue_t &f) { vtype = VT_FLOAT; e = f; }
411
416 void set_string(const char *_str, size_t len) { clear(); _set_string(_str, len); }
417 void set_string(const char *_str) { clear(); _set_string(_str); }
418 void set_string(const qstring &_str) { clear(); _set_string(_str); }
419 void set_long(sval_t v) { clear(); _set_long(v); }
420 void set_pvoid(void *p) { clear(); vtype = VT_PVOID; pvoid = p; }
421 void set_int64(int64 v) { clear(); vtype = VT_INT64; i64 = v; }
422 void set_float(const fpvalue_t &f) { clear(); vtype = VT_FLOAT; e = f; }
424};
425
434
443
444typedef error_t idaapi idc_func_t(idc_value_t *argv, idc_value_t *r);
445
446#define eExecThrow 90
447
450{
451 const char *name;
453 const char *args;
461 int flags;
465#define EXTFUN_BASE 0x0001
466#define EXTFUN_NORET 0x0002
468#define EXTFUN_SAFE 0x0004
471};
472
475{
476 size_t qnty;
478
482
484 error_t (idaapi *startup)(void);
485
488 error_t (idaapi *shutdown)(void);
489
492 void (idaapi *init_idc)(void);
493
495 void (idaapi *term_idc)(void);
496
499 bool (idaapi *is_database_open)(void);
500
503 size_t (idaapi *ea2str)(char *buf, size_t bufsize, ea_t ea);
504
514 bool (idaapi *undeclared_variable_ok)(const char *name);
515
517
521
525
529
536
544
553
555};
556
557// Our idc_value_t and idc_global_t classes are freely movable with memcpy()
560
561//------------------------------------------------------------------------
585
586idaman THREAD_SAFE bool ida_export add_idc_func(const ext_idcfunc_t &func);
587
588
591idaman THREAD_SAFE bool ida_export del_idc_func(const char *name);
592
593
594// Find an idc function that starts with the given prefix.
595// \param out buffer for the output name
596// \param prefix prefix to search for
597// \param n how many matches to skip
598// Returns: success
599idaman THREAD_SAFE bool ida_export find_idc_func(
600 qstring *out,
601 const char *prefix,
602 int n=0);
603
604
623#define HF_FIRST HF_KEYWORD1
624
626{
628 virtual void idaapi set_style(int32 /*start*/, int32 /*len*/, syntax_highlight_style /*style*/) {}
629 virtual int32 idaapi prev_block_state() { return 0; }
630 virtual int32 idaapi cur_block_state() { return 0; }
631 virtual void idaapi set_block_state(int32 /*state*/) {}
632};
633
636{
641 typedef void idaapi block_highlighter_t(
642 void *context,
643 highlighter_cbs_t *highlighter_cbs,
644 const qstring &text);
648};
649
650
651//------------------------------------------------------------------------
654{
655 size_t size;
657#define EXTLANG_IDC 0x01
658#define EXTLANG_NS_AWARE 0x02
660 const char *name;
661 const char *fileext;
662 syntax_highlighter_t *highlighter; // Language syntax highlighter
663
671 bool (idaapi *compile_expr)(
672 const char *name,
674 const char *expr,
676
693 bool (idaapi *compile_file)(const char *file, const char *requested_namespace, qstring *errbuf);
694
702 bool (idaapi *call_func)(
704 const char *name,
706 size_t nargs,
708
715 bool (idaapi *eval_expr)(
716 idc_value_t *rv,
718 const char *expr,
719 qstring *errbuf);
720
726 bool (idaapi *eval_snippet)(
727 const char *str,
729
737 bool (idaapi *create_object)(
739 const char *name,
740 const idc_value_t args[],
741 size_t nargs,
742 qstring *errbuf);
743
751 bool (idaapi *get_attr)(
754 const char *attr);
755
761 bool (idaapi *set_attr)(
763 const char *attr,
765
774 bool (idaapi *call_method)(
776 const idc_value_t *obj,
777 const char *name,
779 size_t nargs,
781
793 bool (idaapi *load_procmod)(
794 idc_value_t *procobj,
795 const char *path,
796 qstring *errbuf);
797
802 bool (idaapi *unload_procmod)(
803 const char *path,
804 qstring *errbuf);
805
806 int icon;
807
808 bool is_idc(void) const { return (flags & EXTLANG_IDC) != 0; }
809 bool is_namespace_aware(void) const { return (flags & EXTLANG_NS_AWARE) != 0; }
810 int get_icon(void) const
811 {
812 return size > qoffsetof(extlang_t, icon) ? icon : 0;
813 }
814 void set_icon(int id)
815 {
816 if ( size > qoffsetof(extlang_t, icon) )
817 icon = id;
818 }
819 void release(void) {}
820};
821
824
826
827idaman void *ida_export get_current_extlang(void); // do not use
828
829inline const extlang_object_t get_extlang(void) // use this function
830{
832}
833
834
841
842idaman ssize_t ida_export install_extlang(extlang_t *el);
843
844
847
848idaman bool ida_export remove_extlang(extlang_t *el);
849
850
856
857idaman bool ida_export select_extlang(extlang_t *el);
858
859
861{
862 virtual ssize_t idaapi visit_extlang(extlang_t *extlang) = 0;
863};
864
866// \param ev visitor object
867// \param select temporarily select extlang for the duration of the visit
868// \return 0 or the first non-zero value returned by visit_extlang()
869
870idaman ssize_t ida_export for_all_extlangs(extlang_visitor_t &ev, bool select=false);
871
872
873// Helper function to search for extlang
880
881// do not use
882idaman void *ida_export find_extlang(const void *str, find_extlang_kind_t kind);
883
884
886
891
893
898
900
905
906
907
908//------------------------------------------------------------------------
918
919idaman THREAD_SAFE bool ida_export set_header_path(const char *path, bool add);
920
921
930
931idaman THREAD_SAFE char *ida_export get_idc_filename(
932 char *buf,
933 size_t bufsize,
934 const char *file);
935
936
945
946idaman THREAD_SAFE bool ida_export exec_system_script(
947 const char *file,
948 bool complain_if_no_file=true);
949
950
963
964idaman bool ida_export eval_expr_long(
965 sval_t *res,
966 ea_t where,
967 const char *line,
968 qstring *errbuf=nullptr);
969
971
972inline bool idaapi eval_expr_long(
973 uval_t *res,
974 ea_t where,
975 const char *line,
976 qstring *errbuf=nullptr)
977{
978 return eval_expr_long((sval_t *)res, where, line, errbuf);
979}
980
981
992
993idaman bool ida_export eval_expr(
994 idc_value_t *rv,
995 ea_t where,
996 const char *line,
997 qstring *errbuf=nullptr);
998
999
1002
1003idaman bool ida_export eval_idc_expr(
1004 idc_value_t *rv,
1005 ea_t where,
1006 const char *buf,
1007 qstring *errbuf=nullptr);
1008
1009
1017
1020#define CPL_DEL_MACROS 0x0001
1021#define CPL_USE_LABELS 0x0002
1022#define CPL_ONLY_SAFE 0x0004
1024
1025idaman THREAD_SAFE bool ida_export compile_idc_file(
1026 const char *file,
1027 qstring *errbuf=nullptr,
1028 int cpl_flags = CPL_DEL_MACROS|CPL_USE_LABELS);
1029
1030
1041
1043{
1044 virtual uval_t idaapi resolve_name(const char *name) = 0;
1045};
1046
1047idaman THREAD_SAFE bool ida_export compile_idc_text(
1048 const char *line,
1049 qstring *errbuf=nullptr,
1050 idc_resolver_t *resolver=nullptr,
1051 bool only_safe_funcs=false);
1052
1053
1065
1066idaman bool ida_export compile_idc_snippet(
1067 const char *func,
1068 const char *text,
1069 qstring *errbuf=nullptr,
1070 idc_resolver_t *resolver=nullptr,
1071 bool only_safe_funcs=false);
1072
1073
1074// Execution of IDC code can generate exceptions. Exception objects
1075// will have the following attributes:
1076// file - the source file name
1077// line - the line number that was executing when the exception occurred
1078// func - the function name
1079// pc - bytecode program counter
1080// For runtime errors, the following additional attributes exist:
1081// qerrno - runtime error code
1082// description - text description of the runtime error
1083
1101
1102idaman bool ida_export call_idc_func(
1104 const char *fname,
1105 const idc_value_t args[],
1106 size_t argsnum,
1107 qstring *errbuf=nullptr,
1108 idc_resolver_t *resolver=nullptr);
1109
1110
1126
1127THREAD_SAFE inline bool exec_idc_script(
1129 const char *path,
1130 const char *func,
1131 const idc_value_t args[],
1132 size_t argsnum,
1133 qstring *errbuf=nullptr)
1134{
1135 if ( !compile_idc_file(path, errbuf) )
1136 return false;
1137 return call_idc_func(result, func, args, argsnum, errbuf);
1138}
1139
1140
1154
1155
1156idaman bool ida_export eval_idc_snippet(
1158 const char *line,
1159 qstring *errbuf=nullptr,
1160 idc_resolver_t *resolver=nullptr);
1161
1162
1163//------------------------------------------------------------------------
1167
1168idaman void ida_export setup_lowcnd_regfuncs(idc_func_t *getreg, idc_func_t *setreg);
1169
1170//------------------------------------------------------------------------
1179inline THREAD_SAFE bool get_idptype_and_data(int *vtype, const void **vdata, const idc_value_t &v)
1180{
1181 switch ( v.vtype )
1182 {
1183 case VT_STR: *vtype = IDPOPT_STR, *vdata = v.c_str(); break;
1184 case VT_LONG: *vtype = IDPOPT_NUM; *vdata = &v.num; break;
1185 case VT_WILD: *vtype = IDPOPT_BIT; *vdata = &v.num; break;
1186 case VT_INT64: *vtype = IDPOPT_I64; *vdata = &v.i64; break;
1187 case VT_PVOID: *vtype = IDPOPT_CST; *vdata = v.pvoid; break;
1188 default: return false;
1189 }
1190 return true;
1191}
1192
1200
1201idaman error_t ida_export throw_idc_exception(idc_value_t *r, const char *desc);
1202
1203
1204#endif /* _EXPR_H */
const qchar * c_str(void) const
Convert the qstring to a char *.
Definition pro.h:3246
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:2996
Reimplementation of vector class from STL.
Definition pro.h:2262
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/64-bit) 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:901
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:444
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:822
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:1179
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:894
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 64-bit 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:887
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:823
syntax_highlight_style
Possible syntax element highlighting style names.
Definition expr.hpp:607
@ HF_KEYWORD1
Definition expr.hpp:609
@ HF_NUMBER
Definition expr.hpp:615
@ HF_USER2
Definition expr.hpp:617
@ HF_PREPROC
Definition expr.hpp:614
@ HF_USER4
Definition expr.hpp:619
@ HF_DEFAULT
Definition expr.hpp:608
@ HF_STRING
Definition expr.hpp:612
@ HF_USER3
Definition expr.hpp:618
@ HF_COMMENT
Definition expr.hpp:613
@ HF_KEYWORD3
Definition expr.hpp:611
@ HF_KEYWORD2
Definition expr.hpp:610
@ HF_MAX
Definition expr.hpp:621
@ HF_USER1
Definition expr.hpp:616
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:1127
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:829
find_extlang_kind_t
Definition expr.hpp:875
@ FIND_EXTLANG_BY_IDX
Definition expr.hpp:878
@ FIND_EXTLANG_BY_NAME
Definition expr.hpp:877
@ FIND_EXTLANG_BY_EXT
Definition expr.hpp:876
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:1000
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:7720
Contains definition of the interface to IDP modules.
IEEE floating point functions.
uval_t uval_t
Definition kernwin.hpp:1926
idaman size_t len
Definition kernwin.hpp:1389
bool result
Definition kernwin.hpp:8332
__int64 int64
Definition llong.hpp:14
unsigned int uint32
unsigned 32 bit value
Definition pro.h:352
adiff_t sval_t
signed value used by the processor.
Definition pro.h:450
uint64 ea_t
Definition pro.h:425
int int32
signed 32 bit value
Definition pro.h:351
unsigned char uchar
unsigned 8 bit value
Definition pro.h:341
idaman size_t bufsize
Definition pro.h:604
int error_t
Error code (errno)
Definition pro.h:462
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:385
_qstring< char > qstring
regular string
Definition pro.h:3771
Element of functions table. See idcfuncs_t::funcs.
Definition expr.hpp:450
const idc_value_t * defvals
Default argument values.
Definition expr.hpp:457
const char * args
Type of arguments.
Definition expr.hpp:453
const char * name
Name of function.
Definition expr.hpp:451
idc_func_t * fptr
Pointer to the Function.
Definition expr.hpp:452
int flags
Function description flags
Definition expr.hpp:461
int ndefvals
Number of default values.
Definition expr.hpp:460
External language (to support third party language interpreters)
Definition expr.hpp:654
bool(idaapi *call_func)(idc_value_t *result
Evaluate a previously compiled expression.
const idc_value_t * obj
Definition expr.hpp:753
ea_t const char qstring * errbuf
Definition expr.hpp:675
const char const idc_value_t & value
Definition expr.hpp:764
void set_icon(int id)
Definition expr.hpp:814
bool(idaapi *load_procmod)(idc_value_t *procobj
Compile (load) a file with processor module.
int32 refcnt
Reference count.
Definition expr.hpp:659
const char * requested_namespace
Definition expr.hpp:693
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:661
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.
int icon
Icon ID for the language (0 = no icon)
Definition expr.hpp:806
ea_t current_ea
Definition expr.hpp:673
bool(idaapi *unload_procmod)(const char *path
Unload previously loaded processor module.
bool is_namespace_aware(void) const
Definition expr.hpp:809
syntax_highlighter_t * highlighter
Definition expr.hpp:662
const char * name
Language name.
Definition expr.hpp:660
uint32 flags
Language features.
Definition expr.hpp:656
const char const idc_value_t size_t nargs
Definition expr.hpp:706
bool(idaapi *create_object)(idc_value_t *result
Create an object instance.
size_t size
Size of this structure.
Definition expr.hpp:655
ea_t const char * expr
Definition expr.hpp:674
int get_icon(void) const
Definition expr.hpp:810
const char const idc_value_t args[]
Definition expr.hpp:705
const char * path
Definition expr.hpp:795
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:754
bool(idaapi *eval_snippet)(const char *str
Compile and execute a string with statements.
bool is_idc(void) const
Definition expr.hpp:808
void release(void)
Definition expr.hpp:819
Definition expr.hpp:861
virtual ssize_t idaapi visit_extlang(extlang_t *extlang)=0
Processor-independent representation of a floating point value.
Definition ieee.h:98
Definition expr.hpp:626
virtual void idaapi set_block_state(int32)
Definition expr.hpp:631
virtual int32 idaapi prev_block_state()
Definition expr.hpp:629
virtual int32 idaapi cur_block_state()
Definition expr.hpp:630
virtual ~highlighter_cbs_t()
Definition expr.hpp:627
virtual void idaapi set_style(int32, int32, syntax_highlight_style)
Definition expr.hpp:628
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:1043
virtual uval_t idaapi resolve_name(const char *name)=0
Describes an array of IDC functions.
Definition expr.hpp:475
void(idaapi *init_idc)(void)
Initialize IDC engine.
size_t qnty
Number of functions.
Definition expr.hpp:476
size_t ea_t ea
Definition expr.hpp:503
int calc_sizeof
Calculate sizeof(type).
Definition expr.hpp:543
size_t bufsize
Definition expr.hpp:503
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:477
int set_unkvar
Store a value to an undeclared variable.
Definition expr.hpp:528
int exec_resolved_func
Execute resolved function.
Definition expr.hpp:535
int get_unkvar
Retrieve value of an undeclared variable.
Definition expr.hpp:524
int get_field_ea
Get address of the specified field using the type information from the idb.
Definition expr.hpp:552
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:636
block_highlighter_t * highlight_block
Definition expr.hpp:647
void idaapi block_highlighter_t(void *context, highlighter_cbs_t *highlighter_cbs, const qstring &text)
Function for extlang syntax highlighting.
Definition expr.hpp:641
syntax_highlighter_t(block_highlighter_t *bh=nullptr)
Definition expr.hpp:645
virtual ~syntax_highlighter_t()
Definition expr.hpp:646