IDA C++ SDK 9.2
Loading...
Searching...
No Matches
funcs.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 FUNCS_HPP
9#define FUNCS_HPP
10#include <functional>
11#include <range.hpp>
12#include <bytes.hpp>
13
38
39struct stkpnt_t; // #include <frame.hpp>
40struct regvar_t; // #include <frame.hpp>
41struct llabel_core_t;
42class insn_t; // #include <ua.hpp>
43
44idaman void ida_export free_regarg(struct regarg_t *v);
45
46struct regarg_t;
47#define DECLARE_REGARG_T_HELPERS(decl)\
48decl int ida_export regarg_t__compare(const regarg_t &l, const regarg_t &r); \
49
51
52
54struct regarg_t
55{
56 int reg = 0;
57 type_t *type = nullptr;
58 char *name = nullptr;
59
60 regarg_t() {}
61 regarg_t(const regarg_t &r) : reg(r.reg)
62 {
63 type = (type_t *)::qstrdup((char *)r.type);
64 name = ::qstrdup(r.name);
65 }
66 ~regarg_t() { free_regarg(this); }
67 regarg_t &operator=(const regarg_t &r)
68 {
69 if ( this != &r )
70 {
71 free_regarg(this);
72 new (this) regarg_t(r);
73 }
74 return *this;
75 }
76 void swap(regarg_t &r)
77 {
78 std::swap(reg, r.reg);
79 std::swap(type, r.type);
80 std::swap(name, r.name);
81 }
82
83 DECLARE_COMPARISONS(regarg_t) { return regarg_t__compare(*this, r); }
84
85 void serialize(bytevec_t *out) const
86 {
87 out->pack_dd(reg);
88 out->pack_ds((char*)type);
89 out->pack_ds(name);
90 }
91 bool deserialize(memory_deserializer_t &mmdsr)
92 {
93 reg = mmdsr.unpack_dd();
94 type = (type_t*)mmdsr.unpack_ds(true);
95 name = mmdsr.unpack_ds(true);
96 return true;
97 }
99};
102
103//------------------------------------------------------------------------
105class func_t : public range_t
106{
107public:
112#define FUNC_NORET 0x00000001
113#define FUNC_FAR 0x00000002
114#define FUNC_LIB 0x00000004
115
116#define FUNC_STATICDEF 0x00000008
117
118#define FUNC_FRAME 0x00000010
119#define FUNC_USERFAR 0x00000020
121#define FUNC_HIDDEN 0x00000040
122#define FUNC_THUNK 0x00000080
123#define FUNC_BOTTOMBP 0x00000100
124#define FUNC_NORET_PENDING 0x00200
126#define FUNC_SP_READY 0x00000400
131#define FUNC_FUZZY_SP 0x00000800
133#define FUNC_PROLOG_OK 0x00001000
135#define FUNC_PURGED_OK 0x00004000
141#define FUNC_TAIL 0x00008000
144#define FUNC_LUMINA 0x00010000
145#define FUNC_OUTLINE 0x00020000
146#define FUNC_REANALYZE 0x00040000
149#define FUNC_UNWIND 0x00080000
150#define FUNC_CATCH 0x00100000
151
152#define FUNC_RESERVED 0x8000000000000000LL
154
156 bool is_far(void) const { return (flags & FUNC_FAR) != 0; }
158 bool does_return(void) const { return (flags & FUNC_NORET) == 0; }
160 bool analyzed_sp(void) const { return (flags & FUNC_SP_READY) != 0; }
162 bool need_prolog_analysis(void) const { return (flags & FUNC_PROLOG_OK) == 0; }
163#ifndef SWIG
164 union
165 {
167 struct
168 {
169#endif // SWIG
170 //
171 // Stack frame of the function. It is represented as a structure:
172 //
173 // +------------------------------------------------+
174 // | function arguments |
175 // +------------------------------------------------+
176 // | return address (isn't stored in func_t) |
177 // +------------------------------------------------+
178 // | saved registers (SI, DI, etc - func_t::frregs) |
179 // +------------------------------------------------+ <- typical BP
180 // | | |
181 // | | | func_t::fpd
182 // | | |
183 // | | <- real BP
184 // | local variables (func_t::frsize) |
185 // | |
186 // | |
187 // +------------------------------------------------+ <- SP
188 //
200
202
203 // the following fields should not be accessed directly:
204
208
214
216 llabel_core_t *llabels;
219
225 regarg_t *regargs;
229
233#ifndef SWIG
234 };
236 struct
237 {
238#endif // SWIG
240 int refqty;
243#ifndef SWIG
244 };
245 };
246#endif // SWIG
247
248 func_t(ea_t start=0, ea_t end=0, flags64_t f=0)
249 : range_t(start, end), flags(f|FUNC_NORET_PENDING), frame(BADNODE),
250 frsize(0), frregs(0), argsize(0), fpd(0), color(DEFCOLOR),
251 pntqty(0), points(nullptr),
252 regvarqty(0), regvars(nullptr),
253 llabelqty(0), llabels(nullptr),
254 regargqty(0), regargs(nullptr),
255 tailqty(0), tails(nullptr)
256 {
257 }
258#ifndef SWIG
260#endif
261};
263
266DEPRECATED inline bool is_func_entry(const func_t *pfn) { return pfn != nullptr && (pfn->flags & FUNC_TAIL) == 0; }
269DEPRECATED inline bool is_func_tail(const func_t *pfn) { return pfn != nullptr && (pfn->flags & FUNC_TAIL) != 0; }
270
271
276
277idaman DEPRECATED void ida_export lock_func_range(const func_t *pfn, bool lock);
278
281
282idaman DEPRECATED bool ida_export is_func_locked(const func_t *pfn);
283
284//--------------------------------------------------------------------
285// F U N C T I O N S
286//--------------------------------------------------------------------
292
293idaman DEPRECATED func_t *ida_export get_func(ea_t ea);
294
295
301
302idaman DEPRECATED int ida_export get_func_chunknum(func_t *pfn, ea_t ea);
303
309
310idaman DEPRECATED func_t *ida_export getn_func(size_t n);
311
312
314
315idaman size_t ida_export get_func_qty(void);
316
317
322
323idaman int ida_export get_func_num(ea_t ea);
324
325
330
331idaman DEPRECATED func_t *ida_export get_prev_func(ea_t ea);
332
333
338
339idaman DEPRECATED func_t *ida_export get_next_func(ea_t ea);
340
341
347
348idaman DEPRECATED ea_t ida_export get_func_ranges(rangeset_t *ranges, func_t *pfn);
349
350
358
359idaman DEPRECATED ssize_t ida_export get_func_cmt(qstring *buf, const func_t *pfn, bool repeatable);
360
361
369
370idaman DEPRECATED bool ida_export set_func_cmt(const func_t *pfn, const char *cmt, bool repeatable);
371
372
379
380idaman DEPRECATED bool ida_export update_func(func_t *pfn);
381
382
389
390idaman DEPRECATED bool ida_export add_func_ex(func_t *pfn);
391
392
396
397idaman bool ida_export del_func(ea_t ea);
398
399
404
405idaman int ida_export set_func_start(ea_t ea, ea_t newstart);
409#define MOVE_FUNC_OK 0
410#define MOVE_FUNC_NOCODE 1
411#define MOVE_FUNC_BADSTART 2
412#define MOVE_FUNC_NOFUNC 3
413#define MOVE_FUNC_REFUSED 4
415
416
421
422idaman bool ida_export set_func_end(ea_t ea, ea_t newend);
423
424
435
436idaman DEPRECATED void ida_export reanalyze_function(
437 func_t *pfn,
438 ea_t ea1=0,
439 ea_t ea2=BADADDR,
440 bool analyze_parents=false);
441
442
452
453idaman DEPRECATED int ida_export find_func_bounds(func_t *nfn, int flags);
454
458#define FIND_FUNC_NORMAL 0x0000
459#define FIND_FUNC_DEFINE 0x0001
460#define FIND_FUNC_IGNOREFN 0x0002
463#define FIND_FUNC_KEEPBD 0x0004
466
470#define FIND_FUNC_UNDEF 0
472#define FIND_FUNC_OK 1
473#define FIND_FUNC_EXIST 2
476
477
482
483idaman ssize_t ida_export get_func_name(qstring *out, ea_t ea);
484
485
490
491idaman DEPRECATED asize_t ida_export calc_func_size(func_t *pfn);
492
493
500
501idaman DEPRECATED int ida_export get_func_bitness(const func_t *pfn);
502
505
506idaman DEPRECATED void ida_export set_visible_func(func_t *pfn, bool visible);
507
508
517
518idaman DEPRECATED int ida_export set_func_name_if_jumpfunc(func_t *pfn, const char *oldname);
519
520
526
527idaman DEPRECATED ea_t ida_export calc_thunk_func_target(func_t *pfn, ea_t *fptr);
528
529
535
536idaman bool ida_export func_does_return(ea_t callee);
537
538
542
543idaman bool ida_export reanalyze_noret_flag(ea_t ea);
544
545
552
553idaman bool ida_export set_noret_insn(ea_t insn_ea, bool noret);
554
555
556//--------------------------------------------------------------------
557// F U N C T I O N C H U N K S
558//--------------------------------------------------------------------
564
565idaman DEPRECATED func_t *ida_export get_fchunk(ea_t ea);
566
567
573
574idaman DEPRECATED func_t *ida_export getn_fchunk(int n);
575
576
578
579idaman size_t ida_export get_fchunk_qty(void);
580
581
586
587idaman int ida_export get_fchunk_num(ea_t ea);
588
589
594
595idaman DEPRECATED func_t *ida_export get_prev_fchunk(ea_t ea);
596
597
602
603idaman DEPRECATED func_t *ida_export get_next_fchunk(ea_t ea);
604
605
606//--------------------------------------------------------------------
607// Functions to manipulate function chunks
608
620
621idaman DEPRECATED bool ida_export append_func_tail(func_t *pfn, ea_t ea1, ea_t ea2);
622
623
631
632idaman DEPRECATED bool ida_export remove_func_tail(func_t *pfn, ea_t tail_ea);
633
634
640
641idaman DEPRECATED bool ida_export set_tail_owner(func_t *fnt, ea_t new_owner);
642
643
644//--------------------------------------------------------------------
648idaman void ida_export read_regargs(func_t *pfn);
650idaman DEPRECATED void ida_export add_regarg(func_t *pfn, int reg, const tinfo_t &tif, const char *name);
652
653//--------------------------------------------------------------------
654// L I B R A R Y M O D U L E S I G N A T U R E S
655//--------------------------------------------------------------------
656
660#define IDASGN_OK 0
661#define IDASGN_BADARG 1
662#define IDASGN_APPLIED 2
663#define IDASGN_CURRENT 3
664#define IDASGN_PLANNED 4
666
670
671idaman int ida_export plan_to_apply_idasgn(const char *fname); // plan to use library
672
673
681
682idaman int ida_export apply_idasgn_to(const char *signame, ea_t ea, bool is_startup);
683
684
687
688idaman int ida_export get_idasgn_qty(void);
689
690
693
694idaman int ida_export get_current_idasgn(void);
695
696
700
701idaman int ida_export calc_idasgn_state(int n);
702
703
707
708idaman int ida_export del_idasgn(int n);
709
710
722
723idaman int32 ida_export get_idasgn_desc(
724 qstring *signame,
725 qstring *optlibs,
726 int n);
727
732
733idaman ssize_t ida_export get_idasgn_title(
734 qstring *buf,
735 const char *name);
736
740
741idaman void ida_export determine_rtl(void);
742
743
748
749idaman bool ida_export apply_startup_sig(ea_t ea, const char *startup);
750
751
757
758idaman int ida_export try_to_add_libfunc(ea_t ea);
759
760
764#define LIBFUNC_FOUND 0
765#define LIBFUNC_NONE 1
766#define LIBFUNC_DELAY 2
768
769//--------------------------------------------------------------------
770// E A - B A S E D F U N C T I O N A P I
771//--------------------------------------------------------------------
772
779
783
788
789idaman ea_t ida_export get_func_start(ea_t ea);
790
791
795
796idaman ea_t ida_export get_prev_func_ea(ea_t ea);
797
798
802
803idaman ea_t ida_export get_next_func_ea(ea_t ea);
804
805
810
811idaman ea_t ida_export get_fchunk_start(ea_t ea);
812
813
817
818idaman ea_t ida_export get_prev_fchunk_ea(ea_t ea);
819
820
824
825idaman ea_t ida_export get_next_fchunk_ea(ea_t ea);
826
827
831
832idaman ea_t ida_export get_func_ea_by_num(size_t n);
833
834
838
839idaman ea_t ida_export get_fchunk_ea_by_num(int n);
840
842
846
850
851idaman uint64 ida_export get_func_flags(ea_t ea);
852
853
855
856inline bool is_visible_func(ea_t ea)
857{
858 return get_func_start(ea) != BADADDR && (get_func_flags(ea) & FUNC_HIDDEN) == 0;
859}
860
861
864{
865 return (inf_get_cmtflg() & SCF_SHHID_FUNC) != 0 || is_visible_func(ea);
866}
867
868
871DEPRECATED inline bool is_visible_func(func_t *pfn) { return pfn != nullptr && is_visible_func(pfn->start_ea); }
872
873
876DEPRECATED inline bool is_finally_visible_func(func_t *pfn) { return pfn != nullptr && is_finally_visible_func(pfn->start_ea); }
877
878
883
884idaman bool ida_export set_func_flags(ea_t ea, uint64 flags);
885
886
892
893idaman bool ida_export set_func_flag(ea_t ea, uint64 flag, bool on_off=true);
894
895
897
898idaman bool ida_export is_function_entry(ea_t ea);
899
900
902
903idaman bool ida_export is_function_tail(ea_t ea);
904
905
909
910idaman ea_t ida_export get_tail_owner(ea_t tail_ea);
911
912
914
918
924
925idaman ssize_t ida_export get_func_cmt_ea(qstring *buf, ea_t ea, bool repeatable);
926
927
934
935idaman bool ida_export set_func_cmt_ea(ea_t ea, const char *cmt, bool repeatable);
936
937
943
944idaman int ida_export get_func_bitness_ea(ea_t ea);
945
946
948inline int idaapi get_func_bits_ea(ea_t ea)
949{
950 return 1 << (get_func_bitness_ea(ea)+4);
951}
952
953
955inline int idaapi get_func_bytes_ea(ea_t ea)
956{
957 return get_func_bits_ea(ea)/8;
958}
959
960
963DEPRECATED inline int idaapi get_func_bits(const func_t *pfn) { return pfn != nullptr ? get_func_bits_ea(pfn->start_ea) : 16; }
964
965
968DEPRECATED inline int idaapi get_func_bytes(const func_t *pfn) { return pfn != nullptr ? get_func_bytes_ea(pfn->start_ea) : 2; }
969
970
975
976idaman asize_t ida_export calc_func_size_ea(ea_t ea);
977
978
983
984idaman ea_t ida_export get_func_ranges_ea(rangeset_t *ranges, ea_t ea);
985
986
990
991idaman void ida_export set_visible_func_ea(ea_t ea, bool visible);
992
993
1001
1002idaman bool ida_export set_function_name_if_jumpfunc(ea_t func_ea, const char *oldname);
1003
1004
1014
1015idaman void ida_export reanalyze_function_ea(
1016 ea_t func_ea,
1017 ea_t ea1=0,
1018 ea_t ea2=BADADDR,
1019 bool analyze_parents=false);
1020
1021
1027
1028idaman void ida_export add_func_regarg(ea_t func_ea, int reg, const tinfo_t &tif, const char *name);
1029
1030
1036
1037idaman size_t ida_export get_func_regarg_qty(ea_t func_ea);
1038
1039
1047
1048idaman bool ida_export get_func_regarg(regarg_t *out, ea_t func_ea, size_t n);
1049
1050
1057
1058idaman bool ida_export get_func_regargs(regargs_t *out, ea_t func_ea);
1059
1061
1065
1073
1074idaman bool ida_export append_func_tail_ea(ea_t func_ea, ea_t ea1, ea_t ea2);
1075
1076
1083
1084idaman bool ida_export remove_func_tail_ea(ea_t func_ea, ea_t tail_ea);
1085
1086
1091
1092idaman bool ida_export set_tail_owner_ea(ea_t tail_ea, ea_t new_owner);
1093
1094
1101
1102idaman int ida_export get_func_chunknum_ea(ea_t func_ea, ea_t ea);
1103
1104
1108
1109idaman size_t ida_export get_func_tail_qty(ea_t func_ea);
1110
1111
1116
1117idaman bool ida_export get_func_tails(rangevec_t *out, ea_t func_ea);
1118
1119
1121inline bool function_contains(ea_t func_ea, ea_t ea)
1122{
1123 return get_func_chunknum_ea(func_ea, ea) >= 0;
1124}
1125
1126
1128inline bool is_same_func(ea_t ea1, ea_t ea2) { return function_contains(ea1, ea2); }
1129
1130
1135
1136idaman bool ida_export is_same_fchunk(ea_t ea1, ea_t ea2);
1137
1138
1141DEPRECATED inline bool func_contains(func_t *pfn, ea_t ea) { return pfn != nullptr && function_contains(pfn->start_ea, ea); }
1142
1143
1147typedef std::function<void(ea_t chunk_start, ea_t chunk_end)> func_chunk_visitor_t;
1148
1149
1156
1157idaman void ida_export iterate_func_chunks_ea(
1158 ea_t fchunk_ea,
1159 const func_chunk_visitor_t &visitor,
1160 bool include_parents=false);
1161
1162
1169
1170idaman ea_t ida_export get_prev_function_addr(ea_t func_ea, ea_t ea);
1171
1172
1179
1180idaman ea_t ida_export get_next_function_addr(ea_t func_ea, ea_t ea);
1181
1183
1187
1193
1194idaman void ida_export lock_func_range_ea(ea_t ea, bool lock);
1195
1196
1199
1200idaman bool ida_export is_func_locked_ea(ea_t ea);
1201
1202
1205{
1206 ea_t func_ea;
1207public:
1208 lock_func_ea(ea_t ea) : func_ea(ea) { lock_func_range_ea(ea, true); }
1209 ~lock_func_ea() { lock_func_range_ea(func_ea, false); }
1210};
1211
1214class DEPRECATED lock_func
1215{
1216 ea_t ea = BADADDR;
1217public:
1218 lock_func(const func_t *pfn)
1219 {
1220 if ( pfn != nullptr )
1221 {
1222 ea = pfn->start_ea;
1223 lock_func_range_ea(ea, true);
1224 }
1225 }
1227 {
1228 if ( ea != BADADDR )
1229 lock_func_range_ea(ea, false);
1230 }
1231};
1232
1233//lint -esym(1788, lock_func_with_tails_t) referenced only by ctr/dtr
1235{
1236 rangeset_t func_ranges;
1237 void lock_ranges(bool lock)
1238 {
1239 for ( const auto &r : func_ranges )
1240 lock_func_range_ea(r.start_ea, lock);
1241 }
1242
1243public:
1246 {
1247 if ( pfn != nullptr )
1248 {
1249 get_func_ranges_ea(&func_ranges, pfn->start_ea);
1250 lock_ranges(true);
1251 }
1252 }
1254 {
1255 get_func_ranges_ea(&func_ranges, ea);
1256 lock_ranges(true);
1257 }
1258 ~lock_func_with_tails_t() { lock_ranges(false); }
1259};
1260
1262
1263
1264//--------------------------------------------------------------------
1265// I T E R A T O R S
1266
1267// Auxiliary function(s) to be used in func_..._iterator_t
1268
1275
1277#define DECLARE_FUNC_ITERATORS(prefix) \
1278prefix bool ida_export func_tail_iterator_set(func_tail_iterator_t *fti, func_t *pfn, ea_t ea);\
1279prefix bool ida_export func_tail_iterator_set_ea(func_tail_iterator_t *fti, ea_t ea);\
1280prefix bool ida_export func_parent_iterator_set(func_parent_iterator_t *fpi, func_t *pfn);\
1281prefix bool ida_export func_item_iterator_next(func_item_iterator_t *fii, testf_t *testf, void *ud);\
1282prefix bool ida_export func_item_iterator_prev(func_item_iterator_t *fii, testf_t *testf, void *ud);\
1283prefix bool ida_export func_item_iterator_decode_prev_insn(func_item_iterator_t *fii, insn_t *out); \
1284prefix bool ida_export func_item_iterator_decode_preceding_insn(func_item_iterator_t *fii, eavec_t *visited, bool *p_farref, insn_t *out); \
1285prefix bool ida_export func_item_iterator_succ(func_item_iterator_t *fii, testf_t *testf, void *ud); \
1286prefix bool ida_export function_tail_iterator_set(function_tail_iterator_t *fti, ea_t func_ea, ea_t ea); \
1287prefix bool ida_export function_tail_iterator_set_ea(function_tail_iterator_t *fti, ea_t ea); \
1288prefix bool ida_export function_tail_iterator_set_range(function_tail_iterator_t *fti, ea_t ea1, ea_t ea2); \
1289prefix void ida_export function_tail_iterator_chunk(range_t *out, const function_tail_iterator_t *fti); \
1290prefix bool ida_export function_tail_iterator_first(function_tail_iterator_t *fti); \
1291prefix bool ida_export function_tail_iterator_last(function_tail_iterator_t *fti); \
1292prefix bool ida_export function_tail_iterator_next(function_tail_iterator_t *fti); \
1293prefix bool ida_export function_tail_iterator_prev(function_tail_iterator_t *fti); \
1294prefix bool ida_export function_tail_iterator_main(function_tail_iterator_t *fti); \
1295prefix bool ida_export function_parent_iterator_set(function_parent_iterator_t *fpi, ea_t tail_ea); \
1296prefix ea_t ida_export function_parent_iterator_parent(const function_parent_iterator_t *fpi); \
1297prefix bool ida_export function_parent_iterator_first(function_parent_iterator_t *fpi); \
1298prefix bool ida_export function_parent_iterator_last(function_parent_iterator_t *fpi); \
1299prefix bool ida_export function_parent_iterator_next(function_parent_iterator_t *fpi); \
1300prefix bool ida_export function_parent_iterator_prev(function_parent_iterator_t *fpi); \
1301prefix bool ida_export function_item_iterator_next(function_item_iterator_t *fii, testf_t *testf, void *ud); \
1302prefix bool ida_export function_item_iterator_prev(function_item_iterator_t *fii, testf_t *testf, void *ud); \
1303prefix bool ida_export function_item_iterator_succ(function_item_iterator_t *fii, testf_t *testf, void *ud); \
1304prefix bool ida_export function_item_iterator_decode_prev_insn(function_item_iterator_t *fii, insn_t *out); \
1305prefix bool ida_export function_item_iterator_decode_preceding_insn(function_item_iterator_t *fii, eavec_t *visited, bool *p_farref, insn_t *out); \
1306
1308
1309
1310inline THREAD_SAFE bool idaapi f_any(flags64_t, void *) { return true; }
1311
1338class DEPRECATED func_tail_iterator_t
1339{
1340 friend struct kdata_t;
1342 func_t *pfn;
1343 int idx;
1344 range_t seglim; // valid and used only if pfn == nullptr
1345public:
1346 func_tail_iterator_t(void) : pfn(nullptr), idx(-1) {}
1347 func_tail_iterator_t(func_t *_pfn, ea_t ea=BADADDR) : pfn(nullptr) { set(_pfn, ea); }
1349 {
1350 // if was iterating over function chunks, unlock the main chunk
1351 if ( pfn != nullptr )
1352 lock_func_range_ea(pfn->start_ea, false);
1353 }
1354 bool set(func_t *_pfn, ea_t ea=BADADDR) { return func_tail_iterator_set(this, _pfn, ea); }
1355 bool set_ea(ea_t ea) { return func_tail_iterator_set_ea(this, ea); }
1356 // set an arbitrary range
1357 bool set_range(ea_t ea1, ea_t ea2)
1358 {
1359 this->~func_tail_iterator_t();
1360 pfn = nullptr;
1361 idx = -1;
1362 seglim = range_t(ea1, ea2);
1363 return !seglim.empty();
1364 }
1365 const range_t &chunk(void) const
1366 {
1367 if ( pfn == nullptr )
1368 return seglim;
1369 return idx >= 0 && idx < pfn->tailqty ? pfn->tails[idx] : *(range_t*)pfn;
1370 }
1371 bool first(void) { if ( pfn != nullptr ) { idx = 0; return pfn->tailqty > 0; } return false; } // get only tail chunks
1372 bool last(void) { if ( pfn != nullptr ) { idx = pfn->tailqty - 1; return true; } return false; } // get all chunks (the entry chunk last)
1373 bool next(void) { if ( pfn != nullptr && idx+1 < pfn->tailqty ) { idx++; return true; } return false; }
1374 bool prev(void) { if ( idx >= 0 ) { idx--; return true; } return false; }
1375 bool main(void) { idx = -1; return pfn != nullptr; } // get all chunks (the entry chunk first)
1376};
1377
1378
1387
1388idaman DEPRECATED void ida_export iterate_func_chunks(
1389 func_t *pfn,
1390 void (idaapi *func)(ea_t ea1, ea_t ea2, void *ud),
1391 void *ud=nullptr,
1392 bool include_parents=false);
1393
1394
1413class DEPRECATED func_item_iterator_t
1414{
1415 friend struct kdata_t;
1416 GCC_DIAG_OFF(deprecated-declarations)
1417 MSC_DIAG_OFF(4996) // member type and methods are deprecated; suppress
1418 // C4996 across the whole class body -- external uses of
1419 // the class still emit the deprecation warning.
1421 ea_t ea;
1422public:
1423 func_item_iterator_t(void) : ea(BADADDR) {}
1424 func_item_iterator_t(func_t *pfn, ea_t _ea=BADADDR) { set(pfn, _ea); }
1426 bool set(func_t *pfn, ea_t _ea=BADADDR)
1427 {
1428 ea = (_ea != BADADDR || pfn == nullptr) ? _ea : pfn->start_ea;
1429 return fti.set(pfn, _ea);
1430 }
1431
1432 bool set_range(ea_t ea1, ea_t ea2) { ea = ea1; return fti.set_range(ea1, ea2); }
1433 bool first(void) { if ( !fti.main() ) return false; ea=fti.chunk().start_ea; return true; }
1434 bool last(void) { if ( !fti.last() ) return false; ea=fti.chunk().end_ea; return true; }
1435 ea_t current(void) const { return ea; }
1436 bool set_ea(ea_t _ea)
1437 {
1438 if ( !fti.set_ea(_ea) )
1439 return false;
1440 ea = _ea;
1441 return true;
1442 }
1443 const range_t &chunk(void) const { return fti.chunk(); }
1444 bool next(testf_t *func, void *ud) { return func_item_iterator_next(this, func, ud); }
1445 bool prev(testf_t *func, void *ud) { return func_item_iterator_prev(this, func, ud); }
1446 bool next_addr(void) { return next(f_any, nullptr); }
1447 bool next_head(void) { return next(f_is_head, nullptr); }
1448 bool next_code(void) { return next(f_is_code, nullptr); }
1449 bool next_data(void) { return next(f_is_data, nullptr); }
1450 bool next_not_tail(void) { return next(f_is_not_tail, nullptr); }
1451 bool prev_addr(void) { return prev(f_any, nullptr); }
1452 bool prev_head(void) { return prev(f_is_head, nullptr); }
1453 bool prev_code(void) { return prev(f_is_code, nullptr); }
1454 bool prev_data(void) { return prev(f_is_data, nullptr); }
1455 bool prev_not_tail(void) { return prev(f_is_not_tail, nullptr); }
1456 bool decode_prev_insn(insn_t *out) { return func_item_iterator_decode_prev_insn(this, out); }
1457 bool decode_preceding_insn(eavec_t *visited, bool *p_farref, insn_t *out)
1458 { return func_item_iterator_decode_preceding_insn(this, visited, p_farref, out); }
1459
1462 bool succ(testf_t *func, void *ud) { return func_item_iterator_succ(this, func, ud); }
1463 bool succ_code(void) { return succ(f_is_code, nullptr); }
1464 MSC_DIAG_ON(4996)
1465 GCC_DIAG_ON(deprecated-declarations)
1466};
1467
1483{
1484 friend struct kdata_t;
1485 func_t *fnt;
1486 int idx;
1487public:
1488 func_parent_iterator_t(void) : fnt(nullptr), idx(0) {}
1489 func_parent_iterator_t(func_t *_fnt) : fnt(nullptr) { set(_fnt); }
1491 {
1492 if ( fnt != nullptr )
1493 lock_func_range_ea(fnt->start_ea, false);
1494 }
1495 bool set(func_t *_fnt) { return func_parent_iterator_set(this, _fnt); }
1496 ea_t parent(void) const { return fnt->referers[idx]; }
1497 bool first(void) { idx = 0; return fnt != nullptr && is_function_tail(fnt->start_ea) && fnt->refqty > 0; }
1498 bool last(void) { idx = fnt->refqty - 1; return idx >= 0; }
1499 bool next(void) { if ( idx+1 < fnt->refqty ) { idx++; return true; } return false; }
1500 bool prev(void) { if ( idx > 0 ) { idx--; return true; } return false; }
1501 void reset_fnt(func_t *_fnt) { fnt = _fnt; } // for internal use only!
1502};
1503
1504
1509
1511idaman DEPRECATED ea_t ida_export get_prev_func_addr(func_t *pfn, ea_t ea);
1512
1514idaman DEPRECATED ea_t ida_export get_next_func_addr(func_t *pfn, ea_t ea);
1516
1517//--------------------------------------------------------------------
1518// C O P Y - B A S E D F U N C T I O N I N F O T Y P E S
1519//--------------------------------------------------------------------
1520
1524#define GFI_NAME 0x0001
1525#define GFI_CMT 0x0002
1526#define GFI_CMT_RPT 0x0004
1527#define GFI_COMMENTS (GFI_CMT|GFI_CMT_RPT)
1528#define GFI_ALL (GFI_NAME|GFI_COMMENTS)
1530
1535{
1536public:
1538 : range_t(start, end)
1539 {}
1540
1542 bool is_valid() const { return !empty(); }
1543
1545 bool is_tail() const { return (flags_ & FUNC_TAIL) != 0; }
1546
1548 bool is_entry() const { return !is_tail(); }
1549
1551 uint64 get_flags() const { return flags_; }
1552 void set_flags(uint64 v) { flags_ = v; }
1553
1555 bool is_far() const { return (flags_ & FUNC_FAR) != 0; }
1557 bool does_return() const { return (flags_ & FUNC_NORET) == 0; }
1559 bool analyzed_sp() const { return (flags_ & FUNC_SP_READY) != 0; }
1561 bool need_prolog_analysis() const { return (flags_ & FUNC_PROLOG_OK) == 0; }
1562
1563protected:
1565
1566 friend struct kdata_t;
1567};
1568
1569
1574
1575idaman bool ida_export get_fchunk_info(fchunk_info_t *out, ea_t ea);
1576
1577
1582
1583idaman bool ida_export get_prev_fchunk_info(fchunk_info_t *out, ea_t ea);
1584
1585
1590
1591idaman bool ida_export get_next_fchunk_info(fchunk_info_t *out, ea_t ea);
1592
1593
1597{
1598public:
1600 : fchunk_info_t(start, end)
1601 { flags_ = FUNC_NORET_PENDING; }
1602
1606 bool has(int gfi_flags) const { return (filled_ & gfi_flags) == gfi_flags; }
1607
1609 void set_flags(uint64 v) { flags_ = v; updated_ |= FEI_FLAGS; }
1610
1612 void set_flag(uint64 v, bool cnd=true) { setflag(flags_, v, cnd); updated_ |= FEI_FLAGS; }
1613
1615 uval_t get_frame_id() const { return frame_; }
1616
1618 asize_t get_frsize() const { return frsize_; }
1619 void set_frsize(asize_t v) { frsize_ = v; updated_ |= FEI_FRSIZE; }
1620
1622 ushort get_frregs() const { return frregs_; }
1623 void set_frregs(ushort v) { frregs_ = v; updated_ |= FEI_FRREGS; }
1624
1626 asize_t get_argsize() const { return argsize_; }
1627 void set_argsize(asize_t v) { argsize_ = v; updated_ |= FEI_ARGSIZE; }
1628
1630 asize_t get_fpd() const { return fpd_; }
1631 void set_fpd(asize_t v) { fpd_ = v; updated_ |= FEI_FPD; }
1632
1634 bgcolor_t get_color() const { return color_; }
1635 void set_color(bgcolor_t v) { color_ = v; updated_ |= FEI_COLOR; }
1636
1638 const char *get_name() const { return name_.c_str(); }
1639
1641 const char *get_cmt() const { return cmt_.c_str(); }
1642
1644 const char *get_cmt_rpt() const { return cmt_rpt_.c_str(); }
1645
1646private:
1647 uint64 updated_ = 0;
1648 int filled_ = 0;
1649 uval_t frame_ = BADNODE;
1650 asize_t frsize_ = 0;
1651 ushort frregs_ = 0;
1652 asize_t argsize_ = 0;
1653 asize_t fpd_ = 0;
1654 bgcolor_t color_ = DEFCOLOR;
1655 qstring name_;
1656 qstring cmt_;
1657 qstring cmt_rpt_;
1658
1659 friend struct kdata_t;
1660
1664 enum
1665 {
1666 FEI_FLAGS = 0x01,
1667 FEI_FRSIZE = 0x02,
1668 FEI_FRREGS = 0x04,
1669 FEI_ARGSIZE = 0x08,
1670 FEI_FPD = 0x10,
1671 FEI_COLOR = 0x20,
1672 FEI_ENTIRE = 0x3F,
1673 };
1675};
1676
1677
1684
1685idaman bool ida_export get_func_entry_info(func_entry_info_t *out, ea_t ea, int flags=0);
1686
1687
1693
1694idaman bool ida_export get_func_entry_info_by_num(func_entry_info_t *out, size_t n, int flags=0);
1695
1696
1702
1703idaman bool ida_export set_func_entry_info(const func_entry_info_t *fi);
1704
1705
1713
1714idaman bool ida_export add_function_ex(func_entry_info_t *fi);
1715
1716
1723
1724inline bool add_func(ea_t ea1, ea_t ea2=BADADDR)
1725{
1726 func_entry_info_t fn(ea1, ea2);
1727 return add_function_ex(&fn);
1728}
1729
1730
1740
1741idaman int ida_export find_function_bounds(func_entry_info_t *fi, int flags);
1742
1743
1748
1750
1751
1756{
1757public:
1759 : fchunk_info_t(start, end)
1760 {}
1761
1763 ea_t get_owner() const { return owner_; }
1764
1766 int get_refqty() const { return refqty_; }
1767
1768private:
1770 ea_t owner_ = BADADDR;
1771 int refqty_ = 0;
1772
1773 friend struct kdata_t;
1774};
1775
1776
1781
1782idaman bool ida_export get_func_tail_info(func_tail_info_t *out, ea_t ea);
1783
1784
1788
1789idaman size_t ida_export get_tail_referer_qty(ea_t tail_ea);
1790
1791
1796
1797idaman ea_t ida_export get_tail_referer(ea_t tail_ea, size_t n);
1798
1799
1804
1805idaman bool ida_export get_tail_referers(eavec_t *out, ea_t tail_ea);
1806
1807
1837{
1838 ea_t func_ea_ = BADADDR;
1839 int idx_ = -1;
1840 range_t seglim_;
1841 range_t main_;
1842 rangevec_t tails_;
1843 friend struct kdata_t;
1844
1845public:
1847 function_tail_iterator_t(ea_t func_ea, ea_t ea=BADADDR) { set(func_ea, ea); }
1849 {
1850 if ( func_ea_ != BADADDR )
1851 lock_func_range_ea(func_ea_, false);
1852 }
1853 bool set(ea_t func_ea, ea_t ea=BADADDR) { return function_tail_iterator_set(this, func_ea, ea); }
1854 bool set_ea(ea_t ea) { return function_tail_iterator_set_ea(this, ea); }
1855 bool set_range(ea_t ea1, ea_t ea2) { return function_tail_iterator_set_range(this, ea1, ea2); }
1856 void chunk(range_t *out) const { function_tail_iterator_chunk(out, this); }
1857 bool first() { return function_tail_iterator_first(this); }
1858 bool last() { return function_tail_iterator_last(this); }
1859 bool next() { return function_tail_iterator_next(this); }
1860 bool prev() { return function_tail_iterator_prev(this); }
1861 bool main() { return function_tail_iterator_main(this); }
1862};
1863
1864
1879{
1880 ea_t tail_ea_ = BADADDR;
1881 int idx_ = 0;
1882 eavec_t parents_;
1883 friend struct kdata_t;
1884
1885public:
1887 function_parent_iterator_t(ea_t tail_ea) { set(tail_ea); }
1889 {
1890 if ( tail_ea_ != BADADDR )
1891 lock_func_range_ea(tail_ea_, false);
1892 }
1893 bool set(ea_t tail_ea) { return function_parent_iterator_set(this, tail_ea); }
1894 ea_t parent() const { return function_parent_iterator_parent(this); }
1895 bool first() { return function_parent_iterator_first(this); }
1896 bool last() { return function_parent_iterator_last(this); }
1897 bool next() { return function_parent_iterator_next(this); }
1898 bool prev() { return function_parent_iterator_prev(this); }
1899};
1900
1901
1919{
1921 ea_t ea_ = BADADDR;
1922 friend struct kdata_t;
1923
1924public:
1926 function_item_iterator_t(ea_t func_ea, ea_t ea=BADADDR) { set(func_ea, ea); }
1928 bool set(ea_t func_ea, ea_t ea=BADADDR)
1929 {
1930 func_ea = get_func_start(func_ea);
1931 ea_ = (ea != BADADDR || func_ea == BADADDR) ? ea : func_ea;
1932 return fti_.set(func_ea, ea_);
1933 }
1934
1935 bool set_range(ea_t ea1, ea_t ea2) { ea_ = ea1; return fti_.set_range(ea1, ea2); }
1936 bool first()
1937 {
1938 if ( !fti_.main() )
1939 return false;
1940 range_t r;
1941 fti_.chunk(&r);
1942 ea_ = r.start_ea;
1943 return true;
1944 }
1945 bool last()
1946 {
1947 if ( !fti_.last() )
1948 return false;
1949 range_t r;
1950 fti_.chunk(&r);
1951 ea_ = r.end_ea;
1952 return true;
1953 }
1954 ea_t current() const { return ea_; }
1955 bool set_ea(ea_t ea)
1956 {
1957 if ( !fti_.set_ea(ea) )
1958 return false;
1959 ea_ = ea;
1960 return true;
1961 }
1962 void chunk(range_t *out) const { fti_.chunk(out); }
1963 bool next(testf_t *func, void *ud) { return function_item_iterator_next(this, func, ud); }
1964 bool prev(testf_t *func, void *ud) { return function_item_iterator_prev(this, func, ud); }
1965 bool next_addr() { return next(f_any, nullptr); }
1966 bool next_head() { return next(f_is_head, nullptr); }
1967 bool next_code() { return next(f_is_code, nullptr); }
1968 bool next_data() { return next(f_is_data, nullptr); }
1969 bool next_not_tail() { return next(f_is_not_tail, nullptr); }
1970 bool prev_addr() { return prev(f_any, nullptr); }
1971 bool prev_head() { return prev(f_is_head, nullptr); }
1972 bool prev_code() { return prev(f_is_code, nullptr); }
1973 bool prev_data() { return prev(f_is_data, nullptr); }
1974 bool prev_not_tail() { return prev(f_is_not_tail, nullptr); }
1975 bool decode_prev_insn(insn_t *out) { return function_item_iterator_decode_prev_insn(this, out); }
1976 bool decode_preceding_insn(eavec_t *visited, bool *p_farref, insn_t *out)
1977 { return function_item_iterator_decode_preceding_insn(this, visited, p_farref, out); }
1978
1981 bool succ(testf_t *func, void *ud) { return function_item_iterator_succ(this, func, ud); }
1982 bool succ_code() { return succ(f_is_code, nullptr); }
1983};
1984
1986
1987#endif
Contains functions that deal with individual byte characteristics.
idaman ea_t ida_export chunk_start(ea_t ea)
Get start of the contiguous address block containing 'ea'.
bool idaapi testf_t(flags64_t flags, void *ud)
Flag tester - see next_that(), prev_that()
Definition bytes.hpp:109
Vector of bytes (use for dynamic memory)
Definition pro.h:3850
void pack_dd(uint32 x)
Pack a dword and append the result to the bytevec.
Definition pro.h:3882
void pack_ds(const char *x)
Pack a string (length+contents) and append the result to the bytevec.
Definition pro.h:3916
Describes a function chunk (entry or tail).
Definition funcs.hpp:1535
bool analyzed_sp() const
Has SP-analysis been performed?
Definition funcs.hpp:1559
fchunk_info_t(ea_t start=0, ea_t end=0)
Definition funcs.hpp:1537
bool is_far() const
Is a far function?
Definition funcs.hpp:1555
bool is_valid() const
Is the function chunk info valid?
Definition funcs.hpp:1542
uint64 flags_
Definition funcs.hpp:1564
bool does_return() const
Does function return?
Definition funcs.hpp:1557
void set_flags(uint64 v)
Definition funcs.hpp:1552
bool is_tail() const
Is this a tail chunk?
Definition funcs.hpp:1545
bool need_prolog_analysis() const
Needs prolog analysis?
Definition funcs.hpp:1561
friend struct kdata_t
Definition funcs.hpp:1566
uint64 get_flags() const
Function chunk flags Function flags.
Definition funcs.hpp:1551
bool is_entry() const
Is this an entry chunk?
Definition funcs.hpp:1548
Describes a function entry chunk.
Definition funcs.hpp:1597
ushort get_frregs() const
Size of saved registers in frame.
Definition funcs.hpp:1622
void set_frregs(ushort v)
Definition funcs.hpp:1623
void set_fpd(asize_t v)
Definition funcs.hpp:1631
const char * get_cmt_rpt() const
Repeatable function comment (requires GFI_CMT_RPT flag)
Definition funcs.hpp:1644
asize_t get_argsize() const
Number of bytes purged from the stack upon returning.
Definition funcs.hpp:1626
uval_t get_frame_id() const
Netnode id of frame structure.
Definition funcs.hpp:1615
bgcolor_t get_color() const
User defined function color.
Definition funcs.hpp:1634
asize_t get_frsize() const
Size of local variables part of frame in bytes.
Definition funcs.hpp:1618
func_entry_info_t(ea_t start=0, ea_t end=0)
Definition funcs.hpp:1599
const char * get_cmt() const
Function comment (requires GFI_CMT flag)
Definition funcs.hpp:1641
void set_frsize(asize_t v)
Definition funcs.hpp:1619
void set_argsize(asize_t v)
Definition funcs.hpp:1627
const char * get_name() const
Function name (requires GFI_NAME flag)
Definition funcs.hpp:1638
asize_t get_fpd() const
Frame pointer delta.
Definition funcs.hpp:1630
void set_color(bgcolor_t v)
Definition funcs.hpp:1635
bool has(int gfi_flags) const
Check if a string field was populated by get_func_entry_info().
Definition funcs.hpp:1606
void set_flag(uint64 v, bool cnd=true)
Set or clear function flag Function flags.
Definition funcs.hpp:1612
friend struct kdata_t
Definition funcs.hpp:1659
void set_flags(uint64 v)
Function flags Function flags.
Definition funcs.hpp:1609
Class to enumerate all function instructions and data sorted by addresses.
Definition funcs.hpp:1414
bool prev_data(void)
Definition funcs.hpp:1454
bool prev_code(void)
Definition funcs.hpp:1453
bool decode_preceding_insn(eavec_t *visited, bool *p_farref, insn_t *out)
Definition funcs.hpp:1457
bool first(void)
Definition funcs.hpp:1433
bool set_ea(ea_t _ea)
Definition funcs.hpp:1436
ea_t current(void) const
Definition funcs.hpp:1435
bool prev(testf_t *func, void *ud)
Definition funcs.hpp:1445
bool set(func_t *pfn, ea_t _ea=BADADDR)
Set a function range. if pfn == nullptr then a segment range will be set.
Definition funcs.hpp:1426
bool last(void)
Definition funcs.hpp:1434
bool next_head(void)
Definition funcs.hpp:1447
const range_t & chunk(void) const
Definition funcs.hpp:1443
bool prev_addr(void)
Definition funcs.hpp:1451
func_item_iterator_t(void)
Definition funcs.hpp:1423
bool next_addr(void)
Definition funcs.hpp:1446
bool next_not_tail(void)
Definition funcs.hpp:1450
bool decode_prev_insn(insn_t *out)
Definition funcs.hpp:1456
bool prev_head(void)
Definition funcs.hpp:1452
bool next_data(void)
Definition funcs.hpp:1449
bool next(testf_t *func, void *ud)
Definition funcs.hpp:1444
func_item_iterator_t(func_t *pfn, ea_t _ea=BADADDR)
Definition funcs.hpp:1424
bool set_range(ea_t ea1, ea_t ea2)
Set an arbitrary range.
Definition funcs.hpp:1432
bool next_code(void)
Definition funcs.hpp:1448
bool prev_not_tail(void)
Definition funcs.hpp:1455
friend struct kdata_t
Definition funcs.hpp:1415
bool succ(testf_t *func, void *ud)
Similar to next(), but succ() iterates the chunks from low to high addresses, while next() iterates t...
Definition funcs.hpp:1462
bool succ_code(void)
Definition funcs.hpp:1463
Class to enumerate all function parents sorted by addresses.
Definition funcs.hpp:1483
bool last(void)
Definition funcs.hpp:1498
void reset_fnt(func_t *_fnt)
Definition funcs.hpp:1501
func_parent_iterator_t(void)
Definition funcs.hpp:1488
bool prev(void)
Definition funcs.hpp:1500
bool set(func_t *_fnt)
Definition funcs.hpp:1495
bool next(void)
Definition funcs.hpp:1499
~func_parent_iterator_t(void)
Definition funcs.hpp:1490
func_parent_iterator_t(func_t *_fnt)
Definition funcs.hpp:1489
ea_t parent(void) const
Definition funcs.hpp:1496
friend struct kdata_t
Definition funcs.hpp:1484
bool first(void)
Definition funcs.hpp:1497
A function is a set of continuous ranges of addresses with characteristics.
Definition funcs.hpp:106
int tailqty
number of function tails
Definition funcs.hpp:230
range_t * tails
array of tails, sorted by ea.
Definition funcs.hpp:231
func_t(ea_t start=0, ea_t end=0, flags64_t f=0)
Definition funcs.hpp:248
uint64 flags
Function flags
Definition funcs.hpp:108
regarg_t * regargs
unsorted array of register arguments.
Definition funcs.hpp:225
uval_t frame
netnode id of frame structure - see frame.hpp
Definition funcs.hpp:189
stkpnt_t * points
array of SP change points.
Definition funcs.hpp:206
DECLARE_COMPARISONS(func_t)
int refqty
number of referers
Definition funcs.hpp:240
bool need_prolog_analysis(void) const
Needs prolog analysis?
Definition funcs.hpp:162
asize_t fpd
frame pointer delta.
Definition funcs.hpp:198
bool analyzed_sp(void) const
Has SP-analysis been performed?
Definition funcs.hpp:160
asize_t argsize
number of bytes purged from the stack upon returning
Definition funcs.hpp:196
int regargqty
number of register arguments.
Definition funcs.hpp:220
bgcolor_t color
user defined function color
Definition funcs.hpp:201
int llabelqty
number of local labels
Definition funcs.hpp:215
int regvarqty
number of register variables (-1-not read in yet) use find_regvar() to read register variables
Definition funcs.hpp:209
bool does_return(void) const
Does function return?
Definition funcs.hpp:158
regvar_t * regvars
array of register variables.
Definition funcs.hpp:211
uint32 pntqty
number of SP change points
Definition funcs.hpp:205
ushort frregs
size of saved registers in frame.
Definition funcs.hpp:194
llabel_core_t * llabels
local labels array.
Definition funcs.hpp:216
bool is_far(void) const
Is a far function?
Definition funcs.hpp:156
asize_t frsize
size of local variables part of frame in bytes.
Definition funcs.hpp:190
ea_t * referers
array of referers (function start addresses).
Definition funcs.hpp:241
ea_t owner
the address of the main function possessing this tail
Definition funcs.hpp:239
Describes a function tail chunk.
Definition funcs.hpp:1756
func_tail_info_t(ea_t start=0, ea_t end=0)
Definition funcs.hpp:1758
ea_t get_owner() const
Primary owner function start_ea.
Definition funcs.hpp:1763
int get_refqty() const
Number of refering functions (for quick checks without iterating)
Definition funcs.hpp:1766
friend struct kdata_t
Definition funcs.hpp:1773
Class to enumerate all function tails sorted by addresses.
Definition funcs.hpp:1339
bool set_ea(ea_t ea)
Definition funcs.hpp:1355
bool set_range(ea_t ea1, ea_t ea2)
Definition funcs.hpp:1357
bool last(void)
Definition funcs.hpp:1372
bool prev(void)
Definition funcs.hpp:1374
bool main(void)
Definition funcs.hpp:1375
~func_tail_iterator_t(void)
Definition funcs.hpp:1348
bool next(void)
Definition funcs.hpp:1373
friend class func_item_iterator_t
Definition funcs.hpp:1341
bool first(void)
Definition funcs.hpp:1371
func_tail_iterator_t(void)
Definition funcs.hpp:1346
bool set(func_t *_pfn, ea_t ea=BADADDR)
Definition funcs.hpp:1354
const range_t & chunk(void) const
Definition funcs.hpp:1365
func_tail_iterator_t(func_t *_pfn, ea_t ea=BADADDR)
Definition funcs.hpp:1347
friend struct kdata_t
Definition funcs.hpp:1340
Class to enumerate all function instructions and data sorted by addresses.
Definition funcs.hpp:1919
ea_t current() const
Definition funcs.hpp:1954
bool next_addr()
Definition funcs.hpp:1965
bool succ_code()
Definition funcs.hpp:1982
bool next_not_tail()
Definition funcs.hpp:1969
bool next_code()
Definition funcs.hpp:1967
void chunk(range_t *out) const
Definition funcs.hpp:1962
bool prev(testf_t *func, void *ud)
Definition funcs.hpp:1964
bool set_range(ea_t ea1, ea_t ea2)
Set an arbitrary range.
Definition funcs.hpp:1935
bool next_data()
Definition funcs.hpp:1968
bool prev_not_tail()
Definition funcs.hpp:1974
bool decode_preceding_insn(eavec_t *visited, bool *p_farref, insn_t *out)
Definition funcs.hpp:1976
bool prev_code()
Definition funcs.hpp:1972
bool next_head()
Definition funcs.hpp:1966
bool first()
Definition funcs.hpp:1936
bool last()
Definition funcs.hpp:1945
bool prev_data()
Definition funcs.hpp:1973
bool succ(testf_t *func, void *ud)
Similar to next(), but succ() iterates the chunks from low to high addresses, while next() iterates t...
Definition funcs.hpp:1981
bool set_ea(ea_t ea)
Definition funcs.hpp:1955
function_item_iterator_t()
Definition funcs.hpp:1925
bool prev_addr()
Definition funcs.hpp:1970
bool prev_head()
Definition funcs.hpp:1971
bool decode_prev_insn(insn_t *out)
Definition funcs.hpp:1975
bool set(ea_t func_ea, ea_t ea=BADADDR)
Set a function range. if func_ea == BADADDR then a segment range will be set.
Definition funcs.hpp:1928
friend struct kdata_t
Definition funcs.hpp:1922
bool next(testf_t *func, void *ud)
Definition funcs.hpp:1963
function_item_iterator_t(ea_t func_ea, ea_t ea=BADADDR)
Definition funcs.hpp:1926
Class to enumerate all function parents sorted by addresses.
Definition funcs.hpp:1879
function_parent_iterator_t(ea_t tail_ea)
Definition funcs.hpp:1887
bool prev()
Definition funcs.hpp:1898
~function_parent_iterator_t()
Definition funcs.hpp:1888
bool set(ea_t tail_ea)
Definition funcs.hpp:1893
function_parent_iterator_t()
Definition funcs.hpp:1886
bool first()
Definition funcs.hpp:1895
ea_t parent() const
Definition funcs.hpp:1894
bool last()
Definition funcs.hpp:1896
friend struct kdata_t
Definition funcs.hpp:1883
bool next()
Definition funcs.hpp:1897
Class to enumerate all function tails sorted by addresses.
Definition funcs.hpp:1837
bool set_ea(ea_t ea)
Definition funcs.hpp:1854
bool set_range(ea_t ea1, ea_t ea2)
Definition funcs.hpp:1855
bool last()
Definition funcs.hpp:1858
bool main()
Definition funcs.hpp:1861
bool next()
Definition funcs.hpp:1859
function_tail_iterator_t(ea_t func_ea, ea_t ea=BADADDR)
Definition funcs.hpp:1847
bool first()
Definition funcs.hpp:1857
void chunk(range_t *out) const
Definition funcs.hpp:1856
~function_tail_iterator_t()
Definition funcs.hpp:1848
function_tail_iterator_t()
Definition funcs.hpp:1846
bool set(ea_t func_ea, ea_t ea=BADADDR)
Definition funcs.hpp:1853
bool prev()
Definition funcs.hpp:1860
friend struct kdata_t
Definition funcs.hpp:1843
lock_func_ea(ea_t ea)
Definition funcs.hpp:1208
~lock_func_ea()
Definition funcs.hpp:1209
~lock_func_with_tails_t()
Definition funcs.hpp:1258
lock_func_with_tails_t(ea_t ea)
Definition funcs.hpp:1253
DEPRECATED lock_func_with_tails_t(func_t *pfn)
Definition funcs.hpp:1245
~lock_func(void)
Definition funcs.hpp:1226
lock_func(const func_t *pfn)
Definition funcs.hpp:1218
Reimplementation of vector class from STL.
Definition pro.h:2262
Primary mechanism for managing type information.
Definition typeinf.hpp:3077
idaman int ida_export get_idasgn_qty(void)
Get number of signatures in the list of planned and applied signatures.
idaman DEPRECATED func_t *ida_export get_prev_fchunk(ea_t ea)
Get pointer to the previous function chunk in the global list.
idaman int ida_export apply_idasgn_to(const char *signame, ea_t ea, bool is_startup)
Apply a signature file to the specified address.
idaman DEPRECATED func_t *ida_export get_func(ea_t ea)
Get pointer to function structure by address.
idaman DEPRECATED func_t *ida_export getn_fchunk(int n)
Get pointer to function chunk structure by number.
idaman int ida_export get_current_idasgn(void)
Get number of the current signature.
idaman DEPRECATED bool ida_export set_tail_owner(func_t *fnt, ea_t new_owner)
Set a new owner of a function tail.
idaman bool ida_export set_noret_insn(ea_t insn_ea, bool noret)
Signal a non-returning instruction.
idaman int ida_export plan_to_apply_idasgn(const char *fname)
Add a signature file to the list of planned signature files.
idaman size_t ida_export get_func_qty(void)
Get total number of functions in the program.
idaman int32 ida_export get_idasgn_desc(qstring *signame, qstring *optlibs, int n)
Get information about a signature in the list.
idaman DEPRECATED int ida_export get_func_chunknum(func_t *pfn, ea_t ea)
Get the containing tail chunk of 'ea'.
idaman DEPRECATED void ida_export lock_func_range(const func_t *pfn, bool lock)
Lock function pointer Locked pointers are guaranteed to remain valid until they are unlocked.
idaman DEPRECATED func_t *ida_export get_next_func(ea_t ea)
Get pointer to the next function.
idaman bool ida_export apply_startup_sig(ea_t ea, const char *startup)
Apply a startup signature file to the specified address.
idaman DEPRECATED bool ida_export update_func(func_t *pfn)
Update information about a function in the database (func_t).
idaman DEPRECATED func_t *ida_export get_next_fchunk(ea_t ea)
Get pointer to the next function chunk in the global list.
idaman int ida_export del_idasgn(int n)
Remove signature from the list of planned signatures.
idaman DEPRECATED func_t *ida_export getn_func(size_t n)
Get pointer to function structure by number.
idaman DEPRECATED ea_t ida_export get_func_ranges(rangeset_t *ranges, func_t *pfn)
Get function ranges.
DECLARE_TYPE_AS_MOVABLE(regarg_t)
idaman void ida_export read_regargs(func_t *pfn)
DECLARE_REGARG_T_HELPERS(idaman) struct regarg_t
Register argument description.
Definition funcs.hpp:50
idaman bool ida_export reanalyze_noret_flag(ea_t ea)
Plan to reanalyze noret flag.
qvector< regarg_t > regargs_t
Definition funcs.hpp:101
idaman DEPRECATED bool ida_export remove_func_tail(func_t *pfn, ea_t tail_ea)
Remove a function tail.
idaman DEPRECATED bool ida_export append_func_tail(func_t *pfn, ea_t ea1, ea_t ea2)
Append a new tail chunk to the function definition.
idaman bool ida_export set_func_end(ea_t ea, ea_t newend)
Move function chunk end address.
idaman DEPRECATED ea_t ida_export calc_thunk_func_target(func_t *pfn, ea_t *fptr)
Calculate target of a thunk function.
idaman DEPRECATED ssize_t ida_export get_func_cmt(qstring *buf, const func_t *pfn, bool repeatable)
Get function comment.
idaman void ida_export free_regarg(struct regarg_t *v)
DEPRECATED bool is_func_tail(const func_t *pfn)
Does function describe a function tail chunk?
Definition funcs.hpp:269
idaman DEPRECATED bool ida_export is_func_locked(const func_t *pfn)
Is the function pointer locked?
idaman DEPRECATED asize_t ida_export calc_func_size(func_t *pfn)
Calculate function size.
idaman size_t ida_export get_fchunk_qty(void)
Get total number of function chunks in the program.
idaman int ida_export get_func_num(ea_t ea)
Get ordinal number of a function.
idaman int ida_export get_fchunk_num(ea_t ea)
Get ordinal number of a function chunk in the global list of function chunks.
idaman DEPRECATED bool ida_export set_func_cmt(const func_t *pfn, const char *cmt, bool repeatable)
Set function comment.
idaman ssize_t ida_export get_func_name(qstring *out, ea_t ea)
Get function name.
DEPRECATED bool is_func_entry(const func_t *pfn)
Does function describe a function entry chunk?
Definition funcs.hpp:266
idaman DEPRECATED void ida_export add_regarg(func_t *pfn, int reg, const tinfo_t &tif, const char *name)
idaman bool ida_export del_func(ea_t ea)
Delete a function.
idaman DEPRECATED bool ida_export add_func_ex(func_t *pfn)
Add a new function.
idaman DEPRECATED func_t *ida_export get_prev_func(ea_t ea)
Get pointer to the previous function.
idaman DEPRECATED void ida_export set_visible_func(func_t *pfn, bool visible)
Set visibility of function.
idaman DEPRECATED void ida_export reanalyze_function(func_t *pfn, ea_t ea1=0, ea_t ea2=BADADDR, bool analyze_parents=false)
Reanalyze a function.
idaman ssize_t ida_export get_idasgn_title(qstring *buf, const char *name)
Get full description of the signature by its short name.
idaman int ida_export calc_idasgn_state(int n)
Get state of a signature in the list of planned signatures.
idaman DEPRECATED func_t *ida_export get_fchunk(ea_t ea)
Get pointer to function chunk structure by address.
idaman DEPRECATED int ida_export find_func_bounds(func_t *nfn, int flags)
Determine the boundaries of a new function.
idaman bool ida_export func_does_return(ea_t callee)
Does the function return?
idaman DEPRECATED int ida_export get_func_bitness(const func_t *pfn)
Get function bitness (which is equal to the function segment bitness).
idaman int ida_export set_func_start(ea_t ea, ea_t newstart)
Move function chunk start address.
idaman DEPRECATED int ida_export set_func_name_if_jumpfunc(func_t *pfn, const char *oldname)
Give a meaningful name to function if it consists of only 'jump' instruction.
idaman void ida_export determine_rtl(void)
Determine compiler/vendor using the startup signatures.
idaman int ida_export try_to_add_libfunc(ea_t ea)
Apply the currently loaded signature file to the specified address.
THREAD_SAFE constexpr bool idaapi is_tail(flags64_t F)
Does flag denote tail byte?
Definition bytes.hpp:777
THREAD_SAFE constexpr bool idaapi f_is_head(flags64_t F, void *)
Does flag denote start of instruction OR data?
Definition bytes.hpp:794
THREAD_SAFE constexpr bool idaapi f_is_data(flags64_t F, void *)
Does flag denote start of data?
Definition bytes.hpp:772
THREAD_SAFE constexpr bool idaapi f_is_code(flags64_t F, void *)
Does flag denote start of an instruction?
Definition bytes.hpp:765
THREAD_SAFE constexpr bool idaapi f_is_not_tail(flags64_t F, void *)
Does flag denote tail byte?
Definition bytes.hpp:781
idaman DEPRECATED ea_t ida_export get_next_func_addr(func_t *pfn, ea_t ea)
idaman bool ida_export get_func_tails(rangevec_t *out, ea_t func_ea)
Get all function tail ranges.
idaman void ida_export set_visible_func_ea(ea_t ea, bool visible)
Set function visibility by address.
idaman bool ida_export append_func_tail_ea(ea_t func_ea, ea_t ea1, ea_t ea2)
Append a new tail chunk to the function at func_ea.
idaman bool ida_export get_tail_referers(eavec_t *out, ea_t tail_ea)
Get all referers (parent functions) for a tail chunk.
idaman bool ida_export get_func_entry_info_by_num(func_entry_info_t *out, size_t n, int flags=0)
Get function entry info by ordinal number.
idaman DEPRECATED void ida_export iterate_func_chunks(func_t *pfn, void(idaapi *func)(ea_t ea1, ea_t ea2, void *ud), void *ud=nullptr, bool include_parents=false)
Function to iterate function chunks (all of them including the entry chunk)
idaman bool ida_export remove_func_tail_ea(ea_t func_ea, ea_t tail_ea)
Remove a function tail.
idaman bool ida_export get_func_entry_info(func_entry_info_t *out, ea_t ea, int flags=0)
Get function entry info by address.
idaman bool ida_export is_func_locked_ea(ea_t ea)
Is the function at ea locked?
bool add_func(ea_t ea1, ea_t ea2=BADADDR)
Add a new function.
Definition funcs.hpp:1724
idaman void ida_export reanalyze_function_ea(ea_t func_ea, ea_t ea1=0, ea_t ea2=BADADDR, bool analyze_parents=false)
Reanalyze function by address.
idaman bool ida_export set_func_flags(ea_t ea, uint64 flags)
Set function chunk flags.
std::function< void(ea_t chunk_start, ea_t chunk_end)> func_chunk_visitor_t
Callback type for iterate_func_chunks_ea().
Definition funcs.hpp:1147
idaman ea_t ida_export get_tail_referer(ea_t tail_ea, size_t n)
Get a tail chunk referer by index.
idaman bool ida_export get_func_regarg(regarg_t *out, ea_t func_ea, size_t n)
Get a register argument by index.
idaman int ida_export find_function_bounds(func_entry_info_t *fi, int flags)
Determine the boundaries of a new function.
idaman size_t ida_export get_func_regarg_qty(ea_t func_ea)
Get the number of register arguments for a function.
idaman uint64 ida_export get_func_flags(ea_t ea)
Get function chunk flags.
idaman asize_t ida_export calc_func_size_ea(ea_t ea)
Calculate function size by address.
bool is_visible_func(ea_t ea)
Is the function visible (not hidden)?
Definition funcs.hpp:856
idaman bool ida_export set_func_entry_info(const func_entry_info_t *fi)
Update function entry info in the database.
idaman int ida_export get_func_bitness_ea(ea_t ea)
Get function bitness by address.
idaman void ida_export iterate_func_chunks_ea(ea_t fchunk_ea, const func_chunk_visitor_t &visitor, bool include_parents=false)
Function to iterate function chunks (all of them including the entry chunk)
idaman bool ida_export set_func_flag(ea_t ea, uint64 flag, bool on_off=true)
Set or clear a single function chunk flag.
idaman bool ida_export set_tail_owner_ea(ea_t tail_ea, ea_t new_owner)
Set a new owner of a function tail.
DEPRECATED int idaapi get_func_bits(const func_t *pfn)
Get number of bits in the function addressing.
Definition funcs.hpp:963
idaman ssize_t ida_export get_func_cmt_ea(qstring *buf, ea_t ea, bool repeatable)
Get function comment by address.
idaman bool ida_export is_same_fchunk(ea_t ea1, ea_t ea2)
Do two addresses belong to the same function chunk?
idaman ea_t ida_export get_func_start(ea_t ea)
Get start address of the function containing 'ea'.
idaman bool ida_export is_function_entry(ea_t ea)
Is there a function entry chunk at 'ea'?
idaman ea_t ida_export get_tail_owner(ea_t tail_ea)
Get the owner function of a tail chunk.
idaman bool ida_export get_prev_fchunk_info(fchunk_info_t *out, ea_t ea)
Get the previous function chunk before the one containing 'ea'.
idaman ea_t ida_export calc_thunk_function_target(func_entry_info_t *fi, ea_t *fptr)
Calculate thunk function target.
idaman ea_t ida_export get_prev_fchunk_ea(ea_t ea)
Get start address of the previous function chunk.
int idaapi get_func_bytes_ea(ea_t ea)
Get number of bytes in the function addressing.
Definition funcs.hpp:955
idaman size_t ida_export get_tail_referer_qty(ea_t tail_ea)
Get the number of referers (parent functions) for a tail chunk.
idaman ea_t ida_export get_func_ea_by_num(size_t n)
Get function start address by ordinal number.
idaman bool ida_export get_func_regargs(regargs_t *out, ea_t func_ea)
Get all register arguments for a function.
DEPRECATED bool func_contains(func_t *pfn, ea_t ea)
Does the given function contain the given address?
Definition funcs.hpp:1141
idaman ea_t ida_export get_prev_function_addr(ea_t func_ea, ea_t ea)
Get previous address belonging to the function, respecting linear ordering.
idaman bool ida_export is_function_tail(ea_t ea)
Is there a function tail chunk at 'ea'?
idaman DEPRECATED ea_t ida_export get_prev_func_addr(func_t *pfn, ea_t ea)
bool function_contains(ea_t func_ea, ea_t ea)
Does the function at func_ea contain ea?
Definition funcs.hpp:1121
idaman bool ida_export get_next_fchunk_info(fchunk_info_t *out, ea_t ea)
Get the next function chunk after the one containing 'ea'.
idaman ea_t ida_export get_next_func_ea(ea_t ea)
Get start address of the next function.
idaman size_t ida_export get_func_tail_qty(ea_t func_ea)
Get the number of function tail chunks.
idaman bool ida_export get_func_tail_info(func_tail_info_t *out, ea_t ea)
Get function tail info by address.
idaman ea_t ida_export get_next_fchunk_ea(ea_t ea)
Get start address of the next function chunk.
idaman bool ida_export set_function_name_if_jumpfunc(ea_t func_ea, const char *oldname)
Give a meaningful name to function if it consists of only 'jump' instruction.
idaman int ida_export get_func_chunknum_ea(ea_t func_ea, ea_t ea)
Get the containing chunk number.
idaman ea_t ida_export get_func_ranges_ea(rangeset_t *ranges, ea_t ea)
Get function ranges by address.
idaman bool ida_export add_function_ex(func_entry_info_t *fi)
Add a new function using func_entry_info_t.
bool is_same_func(ea_t ea1, ea_t ea2)
Do two addresses belong to the same function?
Definition funcs.hpp:1128
DEPRECATED int idaapi get_func_bytes(const func_t *pfn)
Get number of bytes in the function addressing.
Definition funcs.hpp:968
idaman ea_t ida_export get_prev_func_ea(ea_t ea)
Get start address of the previous function.
idaman void ida_export add_func_regarg(ea_t func_ea, int reg, const tinfo_t &tif, const char *name)
Add a temporary register argument definition.
DECLARE_FUNC_ITERATORS(idaman) inline THREAD_SAFE bool idaapi f_any(flags64_t
Helper function to accept any address.
idaman void ida_export lock_func_range_ea(ea_t ea, bool lock)
Lock function range by address.
idaman ea_t ida_export get_next_function_addr(ea_t func_ea, ea_t ea)
Get next address belonging to the function, respecting linear ordering.
bool is_finally_visible_func(ea_t ea)
Is the function visible (event after considering SCF_SHHID_FUNC)?
Definition funcs.hpp:863
idaman bool ida_export set_func_cmt_ea(ea_t ea, const char *cmt, bool repeatable)
Set function comment by address.
idaman ea_t ida_export get_fchunk_start(ea_t ea)
Get start address of the function chunk containing 'ea'.
idaman ea_t ida_export get_fchunk_ea_by_num(int n)
Get function chunk start address by ordinal number.
int idaapi get_func_bits_ea(ea_t ea)
Get number of bits in the function addressing.
Definition funcs.hpp:948
idaman bool ida_export get_fchunk_info(fchunk_info_t *out, ea_t ea)
Get the range of the function chunk (entry or tail) containing 'ea'.
idaman const char * end
Definition pro.h:1004
idaman size_t n
Definition pro.h:1000
GCC_DIAG_OFF(format-nonliteral)
GCC_DIAG_ON(format-nonliteral)
MSC_DIAG_ON(4996) GCC_DIAG_ON(deprecated-declarations) struct decomp_item_iterator_t
Item iterator for decomp_ranges_t.
Definition hexrays.hpp:5068
const tinfo_t & type
Definition hexrays.hpp:7698
uchar inf_get_cmtflg()
Definition ida.hpp:905
uval_t uval_t
Definition kernwin.hpp:1926
void(idaapi *range_marker)(ea_t ea
Pointer to range marker function (for idaviews and hexviews) This pointer is initialized by setup_ran...
MSC_DIAG_OFF(4826) struct cast_t
Preprocessor cast.
Definition lex.hpp:78
unsigned __int64 uint64
Definition llong.hpp:13
uchar type_t
In serialized form, a type is represented by a byte sequence.
Definition nalt.hpp:1312
unsigned int uint32
unsigned 32 bit value
Definition pro.h:352
uint64 asize_t
Definition pro.h:427
uint32 bgcolor_t
background color in RGB
Definition pro.h:5109
uint64 ea_t
Definition pro.h:425
int int32
signed 32 bit value
Definition pro.h:351
idaman THREAD_SAFE char *ida_export qstrdup(const char *string)
System independent strdup.
qvector< ea_t > eavec_t
vector of addresses
Definition pro.h:2838
uint64 flags64_t
64-bit flags for each address
Definition pro.h:5106
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:385
unsigned short ushort
unsigned 16 bit value
Definition pro.h:342
void idaapi setflag(T &where, U bit, bool cnd)
Set a 'bit' in 'where' if 'value' is not zero.
Definition pro.h:1530
_qstring< char > qstring
regular string
Definition pro.h:3771
void swap(qpair< F, S > &a, qpair< F, S > &b) noexcept(noexcept(a.swap(b)))
Definition qpair.hpp:78
Contains the definition of range_t.
Definition pro.h:4475
uint32 unpack_dd()
Definition pro.h:4488
char * unpack_ds(bool empty_null=false)
Definition pro.h:4496
Base class for an range.
Definition range.hpp:35
bool empty() const
Is the size of the range_t <= 0?
Definition range.hpp:60
ea_t end_ea
end_ea excluded
Definition range.hpp:38
ea_t start_ea
start_ea included
Definition range.hpp:37
range_t(ea_t ea1=0, ea_t ea2=0)
Definition range.hpp:39
Vector of range_t instances.
Definition range.hpp:93
A register variable allows the user to rename a general processor register to a meaningful name.
Definition frame.hpp:426
Definition frame.hpp:59