91#define FUNC_NORET 0x00000001
92#define FUNC_FAR 0x00000002
93#define FUNC_LIB 0x00000004
95#define FUNC_STATICDEF 0x00000008
97#define FUNC_FRAME 0x00000010
98#define FUNC_USERFAR 0x00000020
100#define FUNC_HIDDEN 0x00000040
101#define FUNC_THUNK 0x00000080
102#define FUNC_BOTTOMBP 0x00000100
103#define FUNC_NORET_PENDING 0x00200
105#define FUNC_SP_READY 0x00000400
110#define FUNC_FUZZY_SP 0x00000800
112#define FUNC_PROLOG_OK 0x00001000
114#define FUNC_PURGED_OK 0x00004000
120#define FUNC_TAIL 0x00008000
123#define FUNC_LUMINA 0x00010000
124#define FUNC_OUTLINE 0x00020000
125#define FUNC_REANALYZE 0x00040000
128#define FUNC_UNWIND 0x00080000
129#define FUNC_CATCH 0x00100000
131#define FUNC_RESERVED 0x8000000000000000LL
273 rangeset_t func_ranges;
274 void lock_ranges(
bool lock);
428#define MOVE_FUNC_OK 0
429#define MOVE_FUNC_NOCODE 1
430#define MOVE_FUNC_BADSTART 2
431#define MOVE_FUNC_NOFUNC 3
432#define MOVE_FUNC_REFUSED 4
458 bool analyze_parents=
false);
475#define FIND_FUNC_NORMAL 0x0000
476#define FIND_FUNC_DEFINE 0x0001
477#define FIND_FUNC_IGNOREFN 0x0002
480#define FIND_FUNC_KEEPBD 0x0004
487#define FIND_FUNC_UNDEF 0
489#define FIND_FUNC_OK 1
490#define FIND_FUNC_EXIST 2
673#define DECLARE_FUNC_ITERATORS(prefix) \
674prefix bool ida_export func_tail_iterator_set(func_tail_iterator_t *fti, func_t *pfn, ea_t ea);\
675prefix bool ida_export func_tail_iterator_set_ea(func_tail_iterator_t *fti, ea_t ea);\
676prefix bool ida_export func_parent_iterator_set(func_parent_iterator_t *fpi, func_t *pfn);\
677prefix bool ida_export func_item_iterator_next(func_item_iterator_t *fii, testf_t *testf, void *ud);\
678prefix bool ida_export func_item_iterator_prev(func_item_iterator_t *fii, testf_t *testf, void *ud);\
679prefix bool ida_export func_item_iterator_decode_prev_insn(func_item_iterator_t *fii, insn_t *out); \
680prefix bool ida_export func_item_iterator_decode_preceding_insn(func_item_iterator_t *fii, eavec_t *visited, bool *p_farref, insn_t *out); \
681prefix bool ida_export func_item_iterator_succ(func_item_iterator_t *fii, testf_t *testf, void *ud);
685inline THREAD_SAFE
bool idaapi f_any(
flags64_t,
void *) {
return true; }
723 if ( pfn !=
nullptr )
726 bool set(
func_t *_pfn,
ea_t ea=BADADDR) {
return func_tail_iterator_set(
this, _pfn, ea); }
727 bool set_ea(
ea_t ea) {
return func_tail_iterator_set_ea(
this, ea); }
735 return !seglim.empty();
739 if ( pfn ==
nullptr )
741 return idx >= 0 && idx < pfn->tailqty ? pfn->tails[idx] : *(
range_t*)pfn;
743 bool first(
void) {
if ( pfn !=
nullptr ) { idx = 0;
return pfn->tailqty > 0; }
return false; }
744 bool last(
void) {
if ( pfn !=
nullptr ) { idx = pfn->tailqty - 1;
return true; }
return false; }
745 bool next(
void) {
if ( pfn !=
nullptr && idx+1 < pfn->tailqty ) { idx++;
return true; }
return false; }
746 bool prev(
void) {
if ( idx >= 0 ) { idx--;
return true; }
return false; }
747 bool main(
void) { idx = -1;
return pfn !=
nullptr; }
761 void (idaapi *func)(
ea_t ea1,
ea_t ea2,
void *ud),
763 bool include_parents=
false);
793 ea = (_ea != BADADDR || pfn ==
nullptr) ? _ea : pfn->
start_ea;
794 return fti.set(pfn, _ea);
798 bool first(
void) {
if ( !fti.main() )
return false; ea=fti.chunk().start_ea;
return true; }
799 bool last(
void) {
if ( !fti.last() )
return false; ea=fti.chunk().end_ea;
return true; }
803 if ( !fti.set_ea(_ea) )
809 bool next(
testf_t *func,
void *ud) {
return func_item_iterator_next(
this, func, ud); }
810 bool prev(
testf_t *func,
void *ud) {
return func_item_iterator_prev(
this, func, ud); }
821 bool decode_prev_insn(insn_t *out) {
return func_item_iterator_decode_prev_insn(
this, out); }
823 {
return func_item_iterator_decode_preceding_insn(
this, visited, p_farref, out); }
827 bool succ(
testf_t *func,
void *ud) {
return func_item_iterator_succ(
this, func, ud); }
853 if ( fnt !=
nullptr )
856 bool set(
func_t *_fnt) {
return func_parent_iterator_set(
this, _fnt); }
859 bool last(
void) { idx = fnt->refqty - 1;
return idx >= 0; }
860 bool next(
void) {
if ( idx+1 < fnt->refqty ) { idx++;
return true; }
return false; }
861 bool prev(
void) {
if ( idx > 0 ) { idx--;
return true; }
return false; }
890#define IDASGN_BADARG 1
891#define IDASGN_APPLIED 2
892#define IDASGN_CURRENT 3
893#define IDASGN_PLANNED 4
993#define LIBFUNC_FOUND 0
994#define LIBFUNC_NONE 1
995#define LIBFUNC_DELAY 2
1004inline void lock_func_with_tails_t::lock_ranges(
bool lock)
1006 for (
const auto &r : func_ranges )
Contains functions that deal with individual byte characteristics.
bool idaapi testf_t(flags64_t flags, void *ud)
Flag tester - see next_that(), prev_that()
Definition bytes.hpp:109
Class to enumerate all function instructions and data sorted by addresses.
Definition funcs.hpp:784
bool prev_data(void)
Definition funcs.hpp:819
bool prev_code(void)
Definition funcs.hpp:818
bool decode_preceding_insn(eavec_t *visited, bool *p_farref, insn_t *out)
Definition funcs.hpp:822
bool first(void)
Definition funcs.hpp:798
bool set_ea(ea_t _ea)
Definition funcs.hpp:801
ea_t current(void) const
Definition funcs.hpp:800
bool prev(testf_t *func, void *ud)
Definition funcs.hpp:810
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:791
bool last(void)
Definition funcs.hpp:799
bool next_head(void)
Definition funcs.hpp:812
const range_t & chunk(void) const
Definition funcs.hpp:808
bool prev_addr(void)
Definition funcs.hpp:816
func_item_iterator_t(void)
Definition funcs.hpp:788
bool next_addr(void)
Definition funcs.hpp:811
bool next_not_tail(void)
Definition funcs.hpp:815
bool decode_prev_insn(insn_t *out)
Definition funcs.hpp:821
bool prev_head(void)
Definition funcs.hpp:817
bool next_data(void)
Definition funcs.hpp:814
bool next(testf_t *func, void *ud)
Definition funcs.hpp:809
func_item_iterator_t(func_t *pfn, ea_t _ea=BADADDR)
Definition funcs.hpp:789
bool set_range(ea_t ea1, ea_t ea2)
Set an arbitrary range.
Definition funcs.hpp:797
bool next_code(void)
Definition funcs.hpp:813
bool prev_not_tail(void)
Definition funcs.hpp:820
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:827
bool succ_code(void)
Definition funcs.hpp:828
Class to enumerate all function parents sorted by addresses.
Definition funcs.hpp:845
bool last(void)
Definition funcs.hpp:859
void reset_fnt(func_t *_fnt)
Definition funcs.hpp:862
func_parent_iterator_t(void)
Definition funcs.hpp:849
bool prev(void)
Definition funcs.hpp:861
bool set(func_t *_fnt)
Definition funcs.hpp:856
bool next(void)
Definition funcs.hpp:860
~func_parent_iterator_t(void)
Definition funcs.hpp:851
func_parent_iterator_t(func_t *_fnt)
Definition funcs.hpp:850
ea_t parent(void) const
Definition funcs.hpp:857
bool first(void)
Definition funcs.hpp:858
A function is a set of continuous ranges of addresses with characteristics.
Definition funcs.hpp:85
int tailqty
number of function tails
Definition funcs.hpp:209
range_t * tails
array of tails, sorted by ea.
Definition funcs.hpp:210
func_t(ea_t start=0, ea_t end=0, flags64_t f=0)
Definition funcs.hpp:227
uint64 flags
Function flags
Definition funcs.hpp:87
regarg_t * regargs
unsorted array of register arguments.
Definition funcs.hpp:204
uval_t frame
netnode id of frame structure - see frame.hpp
Definition funcs.hpp:168
stkpnt_t * points
array of SP change points.
Definition funcs.hpp:185
DECLARE_COMPARISONS(func_t)
int refqty
number of referers
Definition funcs.hpp:219
bool need_prolog_analysis(void) const
Needs prolog analysis?
Definition funcs.hpp:141
llabel_t * llabels
local labels array.
Definition funcs.hpp:195
asize_t fpd
frame pointer delta.
Definition funcs.hpp:177
bool analyzed_sp(void) const
Has SP-analysis been performed?
Definition funcs.hpp:139
asize_t argsize
number of bytes purged from the stack upon returning
Definition funcs.hpp:175
int regargqty
number of register arguments.
Definition funcs.hpp:199
bgcolor_t color
user defined function color
Definition funcs.hpp:180
int llabelqty
number of local labels
Definition funcs.hpp:194
int regvarqty
number of register variables (-1-not read in yet) use find_regvar() to read register variables
Definition funcs.hpp:188
bool does_return(void) const
Does function return?
Definition funcs.hpp:137
regvar_t * regvars
array of register variables.
Definition funcs.hpp:190
uint32 pntqty
number of SP change points
Definition funcs.hpp:184
ushort frregs
size of saved registers in frame.
Definition funcs.hpp:173
bool is_far(void) const
Is a far function?
Definition funcs.hpp:135
asize_t frsize
size of local variables part of frame in bytes.
Definition funcs.hpp:169
ea_t * referers
array of referers (function start addresses).
Definition funcs.hpp:220
ea_t owner
the address of the main function possessing this tail
Definition funcs.hpp:218
Class to enumerate all function tails sorted by addresses.
Definition funcs.hpp:713
bool set_ea(ea_t ea)
Definition funcs.hpp:727
bool set_range(ea_t ea1, ea_t ea2)
Definition funcs.hpp:729
bool last(void)
Definition funcs.hpp:744
bool prev(void)
Definition funcs.hpp:746
bool main(void)
Definition funcs.hpp:747
~func_tail_iterator_t(void)
Definition funcs.hpp:720
bool next(void)
Definition funcs.hpp:745
bool first(void)
Definition funcs.hpp:743
func_tail_iterator_t(void)
Definition funcs.hpp:718
bool set(func_t *_pfn, ea_t ea=BADADDR)
Definition funcs.hpp:726
const range_t & chunk(void) const
Definition funcs.hpp:737
func_tail_iterator_t(func_t *_pfn, ea_t ea=BADADDR)
Definition funcs.hpp:719
lock_func_with_tails_t(func_t *pfn)
Definition funcs.hpp:998
~lock_func_with_tails_t()
Definition funcs.hpp:278
~lock_func(void)
Definition funcs.hpp:264
lock_func(const func_t *_pfn)
Definition funcs.hpp:260
Primary mechanism for managing type information.
Definition typeinf.hpp:3046
idaman func_t *ida_export getn_func(size_t n)
Get pointer to function structure by number.
idaman int ida_export get_idasgn_qty(void)
Get number of signatures in the list of planned and applied signatures.
idaman ea_t ida_export get_next_func_addr(func_t *pfn, ea_t ea)
idaman 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 apply_idasgn_to(const char *signame, ea_t ea, bool is_startup)
Apply a signature file to the specified address.
idaman ea_t ida_export get_func_ranges(rangeset_t *ranges, func_t *pfn)
Get function ranges.
idaman bool ida_export update_func(func_t *pfn)
Update information about a function in the database (func_t).
idaman int ida_export get_current_idasgn(void)
Get number of the the current signature.
idaman 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 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 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 apply_startup_sig(ea_t ea, const char *startup)
Apply a startup signature file to the specified address.
idaman void ida_export add_regarg(func_t *pfn, int reg, const tinfo_t &tif, const char *name)
idaman ea_t ida_export get_prev_func_addr(func_t *pfn, ea_t ea)
idaman int ida_export del_idasgn(int n)
Remove signature from the list of planned signatures.
idaman ea_t ida_export calc_thunk_func_target(func_t *pfn, ea_t *fptr)
Calculate target of a thunk function.
idaman 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 int ida_export get_func_chunknum(func_t *pfn, ea_t ea)
Get the containing tail chunk of 'ea'.
bool add_func(ea_t ea1, ea_t ea2=BADADDR)
Add a new function.
Definition funcs.hpp:405
idaman bool ida_export set_func_cmt(const func_t *pfn, const char *cmt, bool repeatable)
Set function comment.
DECLARE_TYPE_AS_MOVABLE(regarg_t)
idaman 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 add_func_ex(func_t *pfn)
Add a new function.
idaman void ida_export read_regargs(func_t *pfn)
idaman func_t *ida_export get_prev_fchunk(ea_t ea)
Get pointer to the previous function chunk in the global list.
idaman bool ida_export is_func_locked(const func_t *pfn)
Is the function pointer locked?
idaman bool ida_export reanalyze_noret_flag(ea_t ea)
Plan to reanalyze noret flag.
idaman func_t *ida_export get_func(ea_t ea)
Get pointer to function structure by address.
idaman bool ida_export set_func_end(ea_t ea, ea_t newend)
Move function chunk end address.
idaman func_t *ida_export getn_fchunk(int n)
Get pointer to function chunk structure by number.
idaman void ida_export free_regarg(struct regarg_t *v)
idaman func_t *ida_export get_prev_func(ea_t ea)
Get pointer to the previous function.
int idaapi get_func_bits(const func_t *pfn)
Get number of bits in the function addressing.
Definition funcs.hpp:519
bool func_contains(func_t *pfn, ea_t ea)
Does the given function contain the given address?
Definition funcs.hpp:305
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 ssize_t ida_export get_func_name(qstring *out, ea_t ea)
Get function name.
bool is_func_entry(const func_t *pfn)
Does function describe a function entry chunk?
Definition funcs.hpp:244
idaman int ida_export get_func_bitness(const func_t *pfn)
Get function bitness (which is equal to the function segment bitness).
idaman func_t *ida_export get_fchunk(ea_t ea)
Get pointer to function chunk structure by address.
bool is_func_tail(const func_t *pfn)
Does function describe a function tail chunk?
Definition funcs.hpp:246
idaman 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 del_func(ea_t ea)
Delete a function.
idaman asize_t ida_export calc_func_size(func_t *pfn)
Calculate function size.
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.
bool is_finally_visible_func(func_t *pfn)
Is the function visible (event after considering SCF_SHHID_FUNC)?
Definition funcs.hpp:530
bool is_same_func(ea_t ea1, ea_t ea2)
Do two addresses belong to the same function?
Definition funcs.hpp:311
idaman bool ida_export func_does_return(ea_t callee)
Does the function return?
idaman void ida_export set_visible_func(func_t *pfn, bool visible)
Set visibility of function.
DECLARE_FUNC_ITERATORS(idaman) inline THREAD_SAFE bool idaapi f_any(flags64_t
Helper function to accept any address.
idaman bool ida_export remove_func_tail(func_t *pfn, ea_t tail_ea)
Remove a function tail.
idaman int ida_export set_func_start(ea_t ea, ea_t newstart)
Move function chunk start address.
idaman ssize_t ida_export get_func_cmt(qstring *buf, const func_t *pfn, bool repeatable)
Get function comment.
idaman func_t *ida_export get_next_func(ea_t ea)
Get pointer to the next function.
idaman void ida_export determine_rtl(void)
Determine compiler/vendor using the startup signatures.
idaman int ida_export find_func_bounds(func_t *nfn, int flags)
Determine the boundaries of a new function.
bool is_visible_func(func_t *pfn)
Is the function visible (not hidden)?
Definition funcs.hpp:527
int idaapi get_func_bytes(const func_t *pfn)
Get number of bytes in the function addressing.
Definition funcs.hpp:522
idaman void ida_export reanalyze_function(func_t *pfn, ea_t ea1=0, ea_t ea2=BADADDR, bool analyze_parents=false)
Reanalyze a function.
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 f_is_head(flags64_t F, void *)
Does flag denote start of instruction OR data?
Definition bytes.hpp:811
THREAD_SAFE constexpr bool idaapi f_is_data(flags64_t F, void *)
Does flag denote start of data?
Definition bytes.hpp:792
THREAD_SAFE constexpr bool idaapi f_is_code(flags64_t F, void *)
Does flag denote start of an instruction?
Definition bytes.hpp:786
THREAD_SAFE constexpr bool idaapi f_is_not_tail(flags64_t F, void *)
Does flag denote tail byte?
Definition bytes.hpp:800
idaman const char * end
Definition pro.h:1001
idaman size_t n
Definition pro.h:997
uchar inf_get_cmtflg()
Definition ida.hpp:889
uval_t uval_t
Definition kernwin.hpp:1878
unsigned __int64 uint64
Definition llong.hpp:13
uchar type_t
In serialized form, a type is represented by a byte sequence.
Definition nalt.hpp:1317
unsigned int uint32
unsigned 32 bit value
Definition pro.h:348
uint64 asize_t
Definition pro.h:423
uint32 bgcolor_t
background color in RGB
Definition pro.h:5012
uint64 ea_t
Definition pro.h:421
int int32
signed 32 bit value
Definition pro.h:347
idaman THREAD_SAFE char *ida_export qstrdup(const char *string)
System independent strdup.
qvector< ea_t > eavec_t
vector of addresses
Definition pro.h:2764
uint64 flags64_t
64-bit flags for each address
Definition pro.h:5009
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:381
unsigned short ushort
unsigned 16 bit value
Definition pro.h:338
_qstring< char > qstring
regular string
Definition pro.h:3694
Contains the definition of range_t.
Base class for an range.
Definition range.hpp:35
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
Register argument description.
Definition funcs.hpp:48
regarg_t()
Definition funcs.hpp:53
int reg
Definition funcs.hpp:49
char * name
Definition funcs.hpp:51
DECLARE_COMPARISONS(regarg_t)
type_t * type
Definition funcs.hpp:50
void swap(regarg_t &r)
Definition funcs.hpp:69
~regarg_t()
Definition funcs.hpp:59
regarg_t(const regarg_t &r)
Definition funcs.hpp:54
regarg_t & operator=(const regarg_t &r)
Definition funcs.hpp:60
A register variable allows the user to rename a general processor register to a meaningful name.
Definition frame.hpp:440