43#define DECLARE_HELPER(decl) \
44decl node_iterator *ida_export node_iterator_goup(node_iterator *); \
45decl void ida_export create_qflow_chart(qflow_chart_t &); \
46decl bool ida_export append_to_flowchart(qflow_chart_t &, ea_t, ea_t); \
47decl fc_block_type_t ida_export fc_calc_block_type(const qflow_chart_t &, size_t); \
48decl bool ida_export create_multirange_qflow_chart(qflow_chart_t &, const rangevec_t &);
50#define DECLARE_FC_HELPER(decl) \
51decl void ida_export create_func_flow_chart(qflow_chart_ea_t &); \
52decl bool ida_export append_to_func_flow_chart(qflow_chart_ea_t &, ea_t, ea_t); \
53decl fc_block_type_t ida_export fc_calc_func_block_type(const qflow_chart_ea_t &, size_t); \
54decl bool ida_export create_multirange_func_flow_chart(qflow_chart_ea_t &, const rangevec_t &);
56#define DECLARE_HELPER(decl)
57#define DECLARE_FC_HELPER(decl)
61DECLARE_FC_HELPER(idaman)
65class intset_t :
public std::set<int>
68 DEFINE_MEMORY_ALLOCATION_FUNCS()
69 size_t idaapi print(
char *buf,
size_t bufsize)
const;
70 const char *idaapi
dstr(
void)
const;
71 bool has(
int value)
const
73 const_iterator p = find(value);
74 const_iterator q =
end();
114struct edge_segs_vec_t;
136 bool idaapi
add(
int node) {
return insert(node).second; }
137 void idaapi
sub(
int node) { erase(node); }
142 int idaapi
first(
void)
const {
return empty() ? -1 : *begin(); }
156 void ensure_order_by_node()
158 if ( order_by_node.empty() )
161 order_by_node.resize(
n, -1);
162 for (
size_t i = 0; i <
n; i++ )
164 int idx = node_by_order[i];
166 order_by_node[idx] =
int(i);
173 void idaapi clear(
void)
175 node_by_order.clear();
176 order_by_node.clear();
183 node_by_order.resize(
n, -1);
188 return node_by_order.size();
191 void idaapi
set(
int _node,
int num)
193 ensure_order_by_node();
194 if ( num >= 0 && num < node_by_order.size()
195 && _node >= 0 && _node < order_by_node.size() )
197 node_by_order[num] = _node;
198 order_by_node[_node] = num;
202 bool idaapi
clr(
int _node)
206 ensure_order_by_node();
207 if ( _node >= order_by_node.size() )
209 int old = order_by_node[_node];
210 if ( old < 0 || old >= node_by_order.size() )
212 order_by_node[_node] = -1;
213 node_by_order[old] = -1;
216 for (
size_t i = 0; i <
n; i++ )
217 if ( order_by_node[i] > old )
219 int rest =
int(
n - old - 1);
221 memmove(&node_by_order[old], &node_by_order[old+1], rest*
sizeof(
int));
225 int idaapi
node(
size_t _order)
const
227 return _order < node_by_order.size() ? node_by_order[_order] : -1;
232 ensure_order_by_node();
233 return (_node >= 0 && _node < order_by_node.size()) ? order_by_node[_node] : -1;
241 DECLARE_HELPER(
friend)
247 node_iterator &goup(
void) {
return *node_iterator_goup(
this); }
261 bool idaapi path(
node_set_t &visited,
int m,
int n)
const;
265 virtual char *idaapi
get_node_label(
char *iobuf,
int iobufsize,
int n)
const { qnotused(iobufsize); qnotused(
n); iobuf[0] =
'\0';
return iobuf; }
267 virtual bool idaapi
print_node(FILE *fp,
int n)
const { qnotused(fp); qnotused(
n);
return false; }
268 virtual bool idaapi
print_edge(FILE *fp,
int i,
int j)
const { qnotused(fp); qnotused(i); qnotused(j);
return false; }
270 virtual int idaapi
size(
void)
const = 0;
272 virtual bool idaapi
exists(
int node)
const { qnotused(node);
return true; }
273 virtual int idaapi
entry(
void)
const {
return 0; }
274 virtual int idaapi
exit(
void)
const {
return size()-1; }
275 virtual int idaapi
nsucc(
int node)
const = 0;
276 virtual int idaapi
npred(
int node)
const = 0;
277 virtual int idaapi
succ(
int node,
int i)
const = 0;
278 virtual int idaapi
pred(
int node,
int i)
const = 0;
284 size_t idaapi
nedge(
int node,
bool ispred)
const {
return ispred ?
npred(node) :
nsucc(node); }
285 int idaapi
edge(
int node,
int i,
bool ispred)
const {
return ispred ?
pred(node, i) :
succ(node, i); }
327 const char *filename,
345 const char *filename,
359#define CHART_PRINT_NAMES 0x1000
360#define CHART_GEN_DOT 0x2000
361#define CHART_GEN_GDL 0x4000
362#define CHART_WINGRAPH 0x8000
376 const char *filename,
394 const char *filename,
400 int32 recursion_depth=-1);
405#define CHART_NOLIBFUNCS 0x0400
406#define CHART_REFERENCING 0x0001
407#define CHART_REFERENCED 0x0002
408#define CHART_RECURSIVE 0x0004
409#define CHART_FOLLOW_DIRECTION 0x0008
410#define CHART_IGNORE_XTRN 0x0010
411#define CHART_IGNORE_DATA_BSS 0x0020
412#define CHART_IGNORE_LIB_TO 0x0040
413#define CHART_IGNORE_LIB_FROM 0x0080
414#define CHART_PRINT_COMMENTS 0x0100
415#define CHART_PRINT_DOTS 0x0200
459#define FC_PRINT 0x0001
460#define FC_NOEXT 0x0002
464#define FC_RESERVED 0x0004
465#define FC_APPND 0x0008
466#define FC_CHKBREAK 0x0010
467#define FC_CALL_ENDS 0x0020
468#define FC_NOPREDS 0x0040
469#define FC_OUTLINES 0x0080
504 create_multirange_qflow_chart(*
this, ranges);
507 void idaapi
refresh(
void) { create_qflow_chart(*
this); }
509 {
return fc_calc_block_type(*
this, blknum); }
515 virtual int idaapi
succ(
int node,
int i)
const override {
return blocks[node].succ[i]; }
516 virtual int idaapi
pred(
int node,
int i)
const override {
return blocks[node].pred[i]; }
517 virtual char *idaapi
get_node_label(
char *iobuf,
int iobufsize,
int n)
const override { qnotused(iobuf); qnotused(iobufsize); qnotused(
n);
return nullptr; }
568 create_multirange_func_flow_chart(*
this, ranges);
571 void idaapi
refresh(
void) { create_func_flow_chart(*
this); }
573 {
return fc_calc_func_block_type(*
this, blknum); }
579 virtual int idaapi
succ(
int node,
int i)
const override {
return blocks[node].succ[i]; }
580 virtual int idaapi
pred(
int node,
int i)
const override {
return blocks[node].pred[i]; }
581 virtual char *idaapi
get_node_label(
char *iobuf,
int iobufsize,
int n)
const override { qnotused(iobuf); qnotused(iobufsize); qnotused(
n);
return nullptr; }
bool cancelled
Definition gdl.hpp:429
char padding[3]
Definition gdl.hpp:430
bool idaapi check_cancel(void) const
virtual ~cancellable_graph_t()
Definition gdl.hpp:432
A function is a set of continuous ranges of addresses with characteristics.
Definition funcs.hpp:106
gdl graph interface - includes only functions required to draw it
Definition gdl.hpp:259
virtual int idaapi npred(int node) const =0
void idaapi gen_gdl(const char *file) const
int idaapi edge(int node, int i, bool ispred) const
Definition gdl.hpp:285
size_t idaapi nedge(int node, bool ispred) const
Definition gdl.hpp:284
virtual bool idaapi exists(int node) const
Definition gdl.hpp:272
virtual void idaapi print_graph_attributes(FILE *fp) const
Definition gdl.hpp:266
virtual int idaapi pred(int node, int i) const =0
virtual char *idaapi get_node_label(char *iobuf, int iobufsize, int n) const
Definition gdl.hpp:265
virtual bool idaapi print_edge(FILE *fp, int i, int j) const
Definition gdl.hpp:268
virtual int idaapi exit(void) const
Definition gdl.hpp:274
node_iterator idaapi end(void) const
Definition gdl.hpp:288
virtual int idaapi node_qty(void) const
Definition gdl.hpp:271
void idaapi gen_dot(const char *file) const
virtual int idaapi nsucc(int node) const =0
virtual void idaapi print_node_attributes(FILE *fp, int n) const
Definition gdl.hpp:269
virtual bool idaapi print_node(FILE *fp, int n) const
Definition gdl.hpp:267
virtual int idaapi succ(int node, int i) const =0
DEFINE_MEMORY_ALLOCATION_FUNCS() virtual ~gdl_graph_t()
Definition gdl.hpp:263
void idaapi gen_dot(FILE *fp) const
virtual int idaapi size(void) const =0
virtual int idaapi entry(void) const
Definition gdl.hpp:273
virtual bgcolor_t idaapi get_edge_color(int i, int j) const
Definition gdl.hpp:281
bool idaapi path_exists(int m, int n) const
Definition gdl.hpp:290
virtual bgcolor_t idaapi get_node_color(int n) const
Definition gdl.hpp:280
node_iterator idaapi begin(void) const
Definition gdl.hpp:287
int idaapi front(void)
Definition gdl.hpp:286
virtual bool idaapi empty(void) const
Definition gdl.hpp:279
void idaapi gen_gdl(FILE *fp) const
Map of integer constants to integer constants.
Definition gdl.hpp:83
DEFINE_MEMORY_ALLOCATION_FUNCS() size_t idaapi print(char *buf
size_t bufsize const
Definition gdl.hpp:86
const char *idaapi dstr(void) const
Node iterator (used to draw graphs)
Definition gdl.hpp:240
node_iterator(const gdl_graph_t *_g, int n)
Definition gdl.hpp:249
bool operator==(const node_iterator &n) const
Definition gdl.hpp:251
node_iterator & operator++(void)
Definition gdl.hpp:250
int operator*(void) const
Definition gdl.hpp:253
friend struct kdata_t
Definition gdl.hpp:243
bool operator!=(const node_iterator &n) const
Definition gdl.hpp:252
Node ordering in a graph.
Definition gdl.hpp:152
bool idaapi clr(int _node)
Definition gdl.hpp:202
size_t idaapi size(void) const
Definition gdl.hpp:186
void idaapi resize(int n)
Definition gdl.hpp:179
int idaapi order(int _node)
Definition gdl.hpp:230
void idaapi set(int _node, int num)
Definition gdl.hpp:191
int idaapi node(size_t _order) const
Definition gdl.hpp:225
DEFINE_MEMORY_ALLOCATION_FUNCS() void idaapi clear(void)
Definition gdl.hpp:172
Set of graph nodes.
Definition gdl.hpp:131
bool idaapi add(int node)
Definition gdl.hpp:136
void idaapi sub(int node)
Definition gdl.hpp:137
int idaapi first(void) const
Definition gdl.hpp:142
idaapi node_set_t(void)
Definition gdl.hpp:133
void idaapi extract(intvec_t &out) const
void idaapi sub(const node_set_t &r)
idaapi node_set_t(const gdl_graph_t *g)
idaapi node_set_t(int node)
Definition gdl.hpp:134
void idaapi intersect(const node_set_t &r)
void idaapi add(const node_set_t &r)
A flow chart for a function (ea-based, no func_t pointers).
Definition gdl.hpp:527
bool idaapi print_names(void) const
Definition gdl.hpp:583
ea_t func_ea
start address of the function (BADADDR for range-based charts)
Definition gdl.hpp:533
int flags
flags. See Flow chart flags
Definition gdl.hpp:534
virtual int idaapi nsucc(int node) const override
Definition gdl.hpp:577
DECLARE_FC_HELPER(friend) qstring title
range_t bounds
overall bounds of the qflow_chart_ea_t instance
Definition gdl.hpp:532
bool is_noret_block(size_t blknum) const
Definition gdl.hpp:575
idaapi qflow_chart_ea_t(const char *_title, ea_t _func_ea, ea_t _ea1, ea_t _ea2, int _flags)
Definition gdl.hpp:539
bool is_ret_block(size_t blknum) const
Definition gdl.hpp:574
void idaapi create(const char *_title, const rangevec_t &ranges, int _flags)
Definition gdl.hpp:563
virtual int idaapi succ(int node, int i) const override
Definition gdl.hpp:579
blocks_t blocks
basic blocks
Definition gdl.hpp:535
virtual char *idaapi get_node_label(char *iobuf, int iobufsize, int n) const override
Definition gdl.hpp:581
virtual int idaapi size(void) const override
Definition gdl.hpp:582
idaapi qflow_chart_ea_t(void)
Definition gdl.hpp:538
void idaapi refresh(void)
Definition gdl.hpp:571
void idaapi append_to_flowchart(ea_t ea1, ea_t ea2)
Definition gdl.hpp:570
virtual ~qflow_chart_ea_t()
Definition gdl.hpp:549
virtual int idaapi pred(int node, int i) const override
Definition gdl.hpp:580
int nproper
number of basic blocks belonging to the specified range
Definition gdl.hpp:536
virtual int idaapi npred(int node) const override
Definition gdl.hpp:578
fc_block_type_t calc_block_type(size_t blknum) const
Definition gdl.hpp:572
qvector< qbasic_block_t > blocks_t
Definition gdl.hpp:529
virtual void idaapi print_node_attributes(FILE *fp, int n) const override
Definition gdl.hpp:576
void idaapi create(const char *_title, ea_t _func_ea, ea_t _ea1, ea_t _ea2, int _flags)
Definition gdl.hpp:550
void idaapi create(const char *_title, const rangevec_t &ranges, int _flags)
Definition gdl.hpp:500
idaapi qflow_chart_t(const char *_title, func_t *_pfn, ea_t _ea1, ea_t _ea2, int _flags)
Definition gdl.hpp:486
virtual void idaapi print_node_attributes(FILE *fp, int n) const override
Definition gdl.hpp:512
bool is_ret_block(size_t blknum) const
Definition gdl.hpp:510
virtual char *idaapi get_node_label(char *iobuf, int iobufsize, int n) const override
Definition gdl.hpp:517
idaapi qflow_chart_t(void)
Definition gdl.hpp:485
range_t bounds
overall bounds of the qflow_chart_t instance
Definition gdl.hpp:479
virtual int idaapi nsucc(int node) const override
Definition gdl.hpp:513
virtual int idaapi pred(int node, int i) const override
Definition gdl.hpp:516
virtual int idaapi succ(int node, int i) const override
Definition gdl.hpp:515
blocks_t blocks
basic blocks
Definition gdl.hpp:482
void idaapi create(const char *_title, func_t *_pfn, ea_t _ea1, ea_t _ea2, int _flags)
Definition gdl.hpp:492
virtual ~qflow_chart_t()
Definition gdl.hpp:491
func_t * pfn
the function this instance was built upon
Definition gdl.hpp:480
fc_block_type_t calc_block_type(size_t blknum) const
Definition gdl.hpp:508
void idaapi refresh(void)
Definition gdl.hpp:507
bool idaapi print_names(void) const
Definition gdl.hpp:519
DECLARE_HELPER(friend) qstring title
int flags
flags. See Flow chart flags
Definition gdl.hpp:481
bool is_noret_block(size_t blknum) const
Definition gdl.hpp:511
qvector< qbasic_block_t > blocks_t
Definition gdl.hpp:476
virtual int idaapi npred(int node) const override
Definition gdl.hpp:514
void idaapi append_to_flowchart(ea_t ea1, ea_t ea2)
Definition gdl.hpp:506
virtual int idaapi size(void) const override
Definition gdl.hpp:518
int nproper
number of basic blocks belonging to the specified range
Definition gdl.hpp:483
Reimplementation of vector class from STL.
Definition pro.h:2262
qvector(void)
Definition pro.h:2374
Routines for working with functions within the disassembled program.
DECLARE_HELPER(idaman) DECLARE_FC_HELPER(idaman) class intset_t typedef qvector< intvec_t > array_of_intvec_t
Set of integer constants.
Definition gdl.hpp:60
THREAD_SAFE bool is_noret_block(fc_block_type_t btype)
Does this block never return?
Definition gdl.hpp:445
idaman DEPRECATED bool ida_export gen_flow_graph(const char *filename, const char *title, func_t *pfn, ea_t ea1, ea_t ea2, int gflags)
Build and display a flow graph.
idaman void ida_export gen_gdl(const gdl_graph_t *g, const char *fname)
Create GDL file for graph.
qvector< node_set_t > array_of_node_set_t
Definition gdl.hpp:145
idaman bool ida_export gen_simple_call_chart(const char *filename, const char *wait, const char *title, int gflags)
Build and display a simple function call graph.
DECLARE_TYPE_AS_MOVABLE(edge_t)
idaman int ida_export display_gdl(const char *fname)
Display GDL file by calling wingraph32.
idaman void ida_export setup_graph_subsystem(const char *_grapher, bgcolor_t(idaapi *get_graph_color)(int color))
Setup the user-defined graph colors and graph viewer program.
idaman bool ida_export gen_complex_call_chart(const char *filename, const char *wait, const char *title, ea_t ea1, ea_t ea2, int flags, int32 recursion_depth=-1)
Build and display a complex xref graph.
qvector< intmap_t > array_of_intmap_t
Definition gdl.hpp:90
edge_type_t
Definition gdl.hpp:119
@ EDGE_FORWARD
Definition gdl.hpp:122
@ EDGE_NONE
Definition gdl.hpp:120
@ EDGE_CROSS
Definition gdl.hpp:124
@ EDGE_SUBGRAPH
Definition gdl.hpp:125
@ EDGE_BACK
Definition gdl.hpp:123
@ EDGE_TREE
Definition gdl.hpp:121
THREAD_SAFE bool is_ret_block(fc_block_type_t btype)
Does this block return?
Definition gdl.hpp:451
idaman bool ida_export gen_flow_graph_ea(const char *filename, const char *title, ea_t func_ea, ea_t ea1, ea_t ea2, int gflags)
Build and display a flow graph (ea-based).
fc_block_type_t
Flow chart block types.
Definition gdl.hpp:31
@ fcb_normal
normal block
Definition gdl.hpp:32
@ fcb_ret
return block
Definition gdl.hpp:34
@ fcb_noret
noreturn block
Definition gdl.hpp:36
@ fcb_enoret
external noreturn block (does not belong to the function)
Definition gdl.hpp:37
@ fcb_cndret
conditional return block
Definition gdl.hpp:35
@ fcb_error
block passes execution past the function end
Definition gdl.hpp:39
@ fcb_indjump
block ends with indirect jump
Definition gdl.hpp:33
@ fcb_extern
external normal block
Definition gdl.hpp:38
idaman const char * end
Definition pro.h:1004
idaman size_t n
Definition pro.h:1000
const char *hexapi dstr(const tinfo_t *tif)
Print the specified type info.
Definition hexrays.hpp:11173
asize_t size
Definition kernwin.hpp:6701
void(idaapi *range_marker)(ea_t ea
Pointer to range marker function (for idaviews and hexviews) This pointer is initialized by setup_ran...
qvector< int > intvec_t
vector of integers
Definition pro.h:2839
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 size_t bufsize
Definition pro.h:604
_qstring< char > qstring
regular string
Definition pro.h:3771
unsigned int
Definition pronet.h:99
constexpr bool operator<(qpair< F, S > const &a, qpair< F, S > const &b)
Definition qpair.hpp:108
constexpr bool operator!=(qpair< F, S > const &a, qpair< F, S > const &b)
Definition qpair.hpp:103
constexpr bool operator==(qpair< F, S > const &a, qpair< F, S > const &b)
Definition qpair.hpp:98
Edge connecting two graph nodes.
Definition gdl.hpp:95
edge_t(int x=0, int y=0)
Definition gdl.hpp:98
int dst
destination node number
Definition gdl.hpp:97
int src
source node number
Definition gdl.hpp:96
Information about a basic block of a qflow_chart_t.
Definition gdl.hpp:439
intvec_t pred
list of node predecessors
Definition gdl.hpp:441
intvec_t succ
list of node successors
Definition gdl.hpp:440
Base class for an range.
Definition range.hpp:35
range_t(ea_t ea1=0, ea_t ea2=0)
Definition range.hpp:39
Vector of range_t instances.
Definition range.hpp:93