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-2025 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
435
444
445typedef error_t idaapi idc_func_t(idc_value_t *argv, idc_value_t *r);
446
447#define eExecThrow 90
448
451{
452 const char *name;
454 const char *args;
462 int flags;
466#define EXTFUN_BASE 0x0001
467#define EXTFUN_NORET 0x0002
469#define EXTFUN_SAFE 0x0004
472};
473
476{
477 size_t qnty;
479
483
485 error_t (idaapi *startup)(void);
486
489 error_t (idaapi *shutdown)(void);
490
493 void (idaapi *init_idc)(void);
494
496 void (idaapi *term_idc)(void);
497
500 bool (idaapi *is_database_open)(void);
501
504 size_t (idaapi *ea2str)(char *buf, size_t bufsize, ea_t ea);
505
515 bool (idaapi *undeclared_variable_ok)(const char *name);
516
518
522
526
530
537
545
554
556};
557
558// Our idc_value_t and idc_global_t classes are freely movable with memcpy()
561
562//------------------------------------------------------------------------
586
587idaman THREAD_SAFE bool ida_export add_idc_func(const ext_idcfunc_t &func);
588
589
592idaman THREAD_SAFE bool ida_export del_idc_func(const char *name);
593
594
595// Find an idc function that starts with the given prefix.
596// \param out buffer for the output name
597// \param prefix prefix to search for
598// \param n how many matches to skip
599// Returns: success
600idaman THREAD_SAFE bool ida_export find_idc_func(
601 qstring *out,
602 const char *prefix,
603 int n=0);
604
605
624#define HF_FIRST HF_KEYWORD1
625
627{
629 virtual void idaapi set_style(int32 /*start*/, int32 /*len*/, syntax_highlight_style /*style*/) {}
630 virtual int32 idaapi prev_block_state() { return 0; }
631 virtual int32 idaapi cur_block_state() { return 0; }
632 virtual void idaapi set_block_state(int32 /*state*/) {}
633};
634
637{
642 typedef void idaapi block_highlighter_t(
643 void *context,
644 highlighter_cbs_t *highlighter_cbs,
645 const qstring &text);
649};
650
651
652//------------------------------------------------------------------------
655{
656 size_t size;
658#define EXTLANG_IDC 0x01
659#define EXTLANG_NS_AWARE 0x02
661 const char *name;
662 const char *fileext;
663 syntax_highlighter_t *highlighter; // Language syntax highlighter
664
672 bool (idaapi *compile_expr)(
673 const char *name,
675 const char *expr,
677
694 bool (idaapi *compile_file)(const char *file, const char *requested_namespace, qstring *errbuf);
695
703 bool (idaapi *call_func)(
705 const char *name,
707 size_t nargs,
709
716 bool (idaapi *eval_expr)(
717 idc_value_t *rv,
719 const char *expr,
720 qstring *errbuf);
721
727 bool (idaapi *eval_snippet)(
728 const char *str,
730
738 bool (idaapi *create_object)(
740 const char *name,
741 const idc_value_t args[],
742 size_t nargs,
743 qstring *errbuf);
744
752 bool (idaapi *get_attr)(
755 const char *attr);
756
762 bool (idaapi *set_attr)(
764 const char *attr,
766
775 bool (idaapi *call_method)(
777 const idc_value_t *obj,
778 const char *name,
780 size_t nargs,
782
794 bool (idaapi *load_procmod)(
795 idc_value_t *procobj,
796 const char *path,
797 qstring *errbuf);
798
803 bool (idaapi *unload_procmod)(
804 const char *path,
805 qstring *errbuf);
806
807 bool is_idc(void) const { return (flags & EXTLANG_IDC) != 0; }
808 bool is_namespace_aware(void) const { return (flags & EXTLANG_NS_AWARE) != 0; }
809 void release(void) {}
810};
811
814
816
817idaman void *ida_export get_current_extlang(void); // do not use
818
819inline const extlang_object_t get_extlang(void) // use this function
820{
822}
823
824
831
832idaman ssize_t ida_export install_extlang(extlang_t *el);
833
834
837
838idaman bool ida_export remove_extlang(extlang_t *el);
839
840
846
847idaman bool ida_export select_extlang(extlang_t *el);
848
849
851{
852 virtual ssize_t idaapi visit_extlang(extlang_t *extlang) = 0;
853};
854
856// \param ev visitor object
857// \param select temporarily select extlang for the duration of the visit
858// \return 0 or the first non-zero value returned by visit_extlang()
859
860idaman ssize_t ida_export for_all_extlangs(extlang_visitor_t &ev, bool select=false);
861
862
863// Helper function to search for extlang
870
871// do not use
872idaman void *ida_export find_extlang(const void *str, find_extlang_kind_t kind);
873
874
876
881
883
888
890
895
896
897
898//------------------------------------------------------------------------
908
909idaman THREAD_SAFE bool ida_export set_header_path(const char *path, bool add);
910
911
920
921idaman THREAD_SAFE char *ida_export get_idc_filename(
922 char *buf,
923 size_t bufsize,
924 const char *file);
925
926
935
936idaman THREAD_SAFE bool ida_export exec_system_script(
937 const char *file,
938 bool complain_if_no_file=true);
939
940
953
954idaman bool ida_export eval_expr_long(
955 sval_t *res,
956 ea_t where,
957 const char *line,
958 qstring *errbuf=nullptr);
959
961
962inline bool idaapi eval_expr_long(
963 uval_t *res,
964 ea_t where,
965 const char *line,
966 qstring *errbuf=nullptr)
967{
968 return eval_expr_long((sval_t *)res, where, line, errbuf);
969}
970
971
982
983idaman bool ida_export eval_expr(
984 idc_value_t *rv,
985 ea_t where,
986 const char *line,
987 qstring *errbuf=nullptr);
988
989
992
993idaman bool ida_export eval_idc_expr(
994 idc_value_t *rv,
995 ea_t where,
996 const char *buf,
997 qstring *errbuf=nullptr);
998
999
1007
1010#define CPL_DEL_MACROS 0x0001
1011#define CPL_USE_LABELS 0x0002
1012#define CPL_ONLY_SAFE 0x0004
1014
1015idaman THREAD_SAFE bool ida_export compile_idc_file(
1016 const char *file,
1017 qstring *errbuf=nullptr,
1018 int cpl_flags = CPL_DEL_MACROS|CPL_USE_LABELS);
1019
1020
1031
1033{
1034 virtual uval_t idaapi resolve_name(const char *name) = 0;
1035};
1036
1037idaman THREAD_SAFE bool ida_export compile_idc_text(
1038 const char *line,
1039 qstring *errbuf=nullptr,
1040 idc_resolver_t *resolver=nullptr,
1041 bool only_safe_funcs=false);
1042
1043
1055
1056idaman bool ida_export compile_idc_snippet(
1057 const char *func,
1058 const char *text,
1059 qstring *errbuf=nullptr,
1060 idc_resolver_t *resolver=nullptr,
1061 bool only_safe_funcs=false);
1062
1063
1064// Execution of IDC code can generate exceptions. Exception objects
1065// will have the following attributes:
1066// file - the source file name
1067// line - the line number that was executing when the exception occurred
1068// func - the function name
1069// pc - bytecode program counter
1070// For runtime errors, the following additional attributes exist:
1071// qerrno - runtime error code
1072// description - text description of the runtime error
1073
1091
1092idaman bool ida_export call_idc_func(
1094 const char *fname,
1095 const idc_value_t args[],
1096 size_t argsnum,
1097 qstring *errbuf=nullptr,
1098 idc_resolver_t *resolver=nullptr);
1099
1100
1116
1117THREAD_SAFE inline bool exec_idc_script(
1119 const char *path,
1120 const char *func,
1121 const idc_value_t args[],
1122 size_t argsnum,
1123 qstring *errbuf=nullptr)
1124{
1125 if ( !compile_idc_file(path, errbuf) )
1126 return false;
1127 return call_idc_func(result, func, args, argsnum, errbuf);
1128}
1129
1130
1144
1145
1146idaman bool ida_export eval_idc_snippet(
1148 const char *line,
1149 qstring *errbuf=nullptr,
1150 idc_resolver_t *resolver=nullptr);
1151
1152
1153//------------------------------------------------------------------------
1157
1158idaman void ida_export setup_lowcnd_regfuncs(idc_func_t *getreg, idc_func_t *setreg);
1159
1160//------------------------------------------------------------------------
1169inline THREAD_SAFE bool get_idptype_and_data(int *vtype, const void **vdata, const idc_value_t &v)
1170{
1171 switch ( v.vtype )
1172 {
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;
1179 }
1180 return true;
1181}
1182
1190
1191idaman error_t ida_export throw_idc_exception(idc_value_t *r, const char *desc);
1192
1193
1194#endif /* _EXPR_H */
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
Definition expr.hpp:851
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:627
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