IDA C++ SDK 9.2
Loading...
Searching...
No Matches
graph.hpp
Go to the documentation of this file.
1/*
2 * Interactive disassembler (IDA).
3 * Copyright (c) 1990-2025 Hex-Rays
4 * Graph type definitions
5 *
6 * Due to the use of STL and virtual functions, some parts of this
7 * interface might be incompatible with compilers other than Visual Studio
8 * on Windows and gcc on Unix systems
9 */
10
11#ifndef __GRAPH_DEF_HPP
12#define __GRAPH_DEF_HPP
13
14#include <math.h>
15#include <pro.h>
16#include <gdl.hpp>
17#include <idp.hpp>
18#include <kernwin.hpp>
19
25
26//-------------------------------------------------------------------------
31#define NIF_BG_COLOR (1 << 0)
32#define NIF_FRAME_COLOR (1 << 1)
33#define NIF_EA (1 << 2)
34#define NIF_TEXT (1 << 3)
35#define NIF_FLAGS (1 << 4)
36#define NIF_ALL (NIF_BG_COLOR | NIF_FRAME_COLOR | NIF_EA | NIF_TEXT | NIF_FLAGS)
38
39//-------------------------------------------------------------------------
43#define GLICTL_CENTER (1 << 0)
45
48{
49private:
50 size_t cb = sizeof(node_info_t);
51public:
52 bgcolor_t bg_color = DEFCOLOR;
54#define NIFF_SHOW_CONTENTS (1 << 0) //< force show contents of huge node
56 ea_t ea = BADADDR;
58
60 inline bool valid_bg_color() const { return bg_color != DEFCOLOR; }
62 inline bool valid_frame_color() const { return frame_color != DEFCOLOR; }
64 inline bool valid_ea() const { return ea != BADADDR; }
66 inline bool valid_text() const { return !text.empty(); }
68 inline bool valid_flags() const { return flags != 0; }
69
72 {
73 uint32 F = 0;
74 if ( valid_bg_color() )
75 F |= NIF_BG_COLOR;
76 if ( valid_frame_color() )
77 F |= NIF_FRAME_COLOR;
78 if ( valid_ea() )
79 F |= NIF_EA;
80 if ( valid_text() )
81 F |= NIF_TEXT;
82 if ( valid_flags() )
83 F |= NIF_FLAGS;
84 return F;
85 }
86};
87
90
91
97
98idaman bool ida_export get_node_info(node_info_t *out, graph_id_t gid, int node);
99
100
107
108idaman void ida_export set_node_info(graph_id_t gid, int node, const node_info_t &ni, uint32 flags);
109
110
112
113idaman void ida_export del_node_info(graph_id_t gid, int node);
114
115
122
123idaman void ida_export clr_node_info(graph_id_t gid, int node, uint32 flags);
124
125
126//-------------------------------------------------------------------------
129{
130 node_set_t visited;
131public:
133 void idaapi reinit(void) { visited.clear(); }
135 void idaapi set_visited(int n) { visited.add(n); }
137 bool idaapi is_visited(int n) const { return visited.has(n); }
138
140 virtual int idaapi visit_node(int /*node*/) { return 0; }
142 virtual bool idaapi is_forbidden_edge(int /*n*/, int /*m*/) const { return false; }
143
145};
146
147//-------------------------------------------------------------------------
150{
152 bool prune = false;
154
155
156 virtual int idaapi walk_forward(int /*node*/) { return 0; }
157 virtual int idaapi walk_backward(int /*node*/) { return 0; }
158
160};
161
162//-------------------------------------------------------------------------
165{
166 int x = 0;
167 int y = 0;
169 point_t(int _x, int _y) : x(_x), y(_y) {}
170 point_t &add(const point_t &r)
171 {
172 x += r.x;
173 y += r.y;
174 return *this;
175 }
176 point_t &sub(const point_t &r)
177 {
178 x -= r.x;
179 y -= r.y;
180 return *this;
181 }
182 template <class T> void div(T d)
183 {
184 x /= d;
185 y /= d;
186 }
187 void negate(void)
188 {
189 x = -x;
190 y = -y;
191 }
192#ifdef VCL_H
193 point_t(const TPoint &p) : x(p.x), y(p.y) {}
194#endif
195 bool operator ==(const point_t &r) const { return x == r.x && y == r.y; }
196 bool operator !=(const point_t &r) const { return !(*this == r); }
197 const char *idaapi dstr(void) const;
198 size_t idaapi print(char *buf, size_t bufsize) const;
199};
202
204inline THREAD_SAFE double calc_dist(point_t p, point_t q)
205{
206 double dx = q.x - p.x;
207 double dy = q.y - p.y;
208 return sqrt(dx*dx+dy*dy);
209}
210
212class pointseq_t : public pointvec_t
213{
214public:
215 const char *idaapi dstr(void) const;
216 size_t idaapi print(char *buf, size_t bufsize) const;
217};
218
223struct rect_t
224{
225 int left = 0;
226 int top = 0;
227 int right = 0;
228 int bottom = 0;
230 rect_t(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) { verify(); }
231 rect_t(const point_t &p0, const point_t &p1)
232 : left (qmin(p0.x, p1.x)),
233 top (qmin(p0.y, p1.y)),
234 right (qmax(p0.x, p1.x)),
235 bottom(qmax(p0.y, p1.y)) { verify(); }
236 void verify(void)
237 {
238 if ( left > right )
239 qswap(left, right);
240 if ( top > bottom )
241 qswap(top, bottom);
242 }
243 int width(void) const { return right - left; }
244 int height(void) const { return bottom - top; }
245 void move_to(const point_t &p)
246 {
247 int dx = p.x - left;
248 int dy = p.y - top;
249 move_by(point_t(dx, dy));
250 }
251 void move_by(const point_t &p)
252 {
253 left += p.x;
254 right += p.x;
255 top += p.y;
256 bottom += p.y;
257 }
258 point_t center(void) const
259 {
260 return point_t((left+right)/2, (top+bottom)/2);
261 }
262 point_t topleft(void) const
263 {
264 return point_t(left, top);
265 }
267 {
268 return point_t(right, bottom);
269 }
270 void grow(int delta)
271 {
272 left -= delta;
273 right += delta;
274 top -= delta;
275 bottom += delta;
276 }
277 void intersect(const rect_t &r)
278 {
279 if ( left < r.left )
280 left = r.left;
281 if ( right > r.right )
282 right = r.right;
283 if ( top < r.top )
284 top = r.top;
285 if ( bottom > r.bottom )
286 bottom = r.bottom;
287 }
288 void make_union(const rect_t &r)
289 {
290 if ( left > r.left )
291 left = r.left;
292 if ( right < r.right )
293 right = r.right;
294 if ( top > r.top )
295 top = r.top;
296 if ( bottom < r.bottom )
297 bottom = r.bottom;
298 }
299 bool empty(void) const
300 {
301 return left >= right || top >= bottom;
302 }
303 bool is_intersection_empty(const rect_t &r) const
304 {
305 return left >= r.right
306 || right <= r.left
307 || top >= r.bottom
308 || bottom <= r.top;
309 }
310 bool contains(const point_t &p) const
311 {
312 return left <= p.x
313 && right > p.x
314 && top <= p.y
315 && bottom > p.y;
316 }
317 int area(void) const { return width()*height(); }
318 bool idaapi operator == (const rect_t &r) const
319 {
320 return left == r.left
321 && right == r.right
322 && top == r.top
323 && bottom == r.bottom;
324 }
325 bool idaapi operator != (const rect_t &r) const { return !(*this == r); }
326 bool idaapi operator < (const rect_t &r) const;
327#ifdef VCL_H
328 const TRect &operator()(void) const { return *(TRect *)this; }
329 TRect &operator()(void) { return *(TRect *)this; }
330 rect_t(const TRect &r) : left(r.left), top(r.top), right(r.right), bottom(r.bottom) {}
331#endif
332};
334
335//---------------------------------------------------------------------------
338{
339 double x = 0.0;
340 double y = 0.0;
342 TPointDouble(double a, double b) : x(a), y(b) {}
343 TPointDouble(const point_t &r) : x(r.x), y(r.y) {}
344 void add(const TPointDouble &r)
345 {
346 x += r.x;
347 y += r.y;
348 }
349 void sub(const TPointDouble &r)
350 {
351 x -= r.x;
352 y -= r.y;
353 }
354 void negate(void)
355 {
356 x = -x;
357 y = -y;
358 }
359 template <class T> void div(T d)
360 {
361 x /= d;
362 y /= d;
363 }
364 bool operator ==(const TPointDouble &r) const { return x == r.x && y == r.y; }
365 bool operator !=(const TPointDouble &r) const { return !(*this == r); }
366};
367
368//---------------------------------------------------------------------------
369typedef int layout_type_t;
372const layout_type_t
381
384{
385 bgcolor_t color = DEFCOLOR;
386 int width = 1;
387 int srcoff = -1;
388 int dstoff = -1;
390#if !defined(_MSC_VER) || _MSC_VER >= 1600
391 void idaapi reverse_layout(void) { std::reverse(layout.begin(), layout.end()); }
392#endif
393 void idaapi add_layout_point(point_t p);
394};
395
398{
399 int pidx = -1;
400 edge_t e = edge_t(-1, -1);
402 idaapi edge_layout_point_t(const edge_t &_e, int _pidx) : pidx(_pidx), e(_e) {}
403 int idaapi compare(const edge_layout_point_t &r) const
404 {
405 if ( e < r.e )
406 return -1;
407 if ( r.e < e )
408 return 1;
409 return ::compare(pidx, r.pidx);
410 }
411 bool idaapi operator == (const edge_layout_point_t &r) const
412 {
413 return pidx == r.pidx && e == r.e;
414 }
415 bool idaapi operator != (const edge_layout_point_t &r) const
416 {
417 return !(*this == r);
418 }
419};
420
424{
425 bool is_node = false;
426 int node = -1;
429 idaapi selection_item_t(int n) : is_node(true), node(n) {}
431 : is_node(false), node(-1), elp(_elp) {}
432 idaapi selection_item_t(edge_t e, int idx)
433 : is_node(false), node(-1), elp(e, idx) {}
435 int idaapi compare(const selection_item_t &r) const
436 {
437 if ( is_node != r.is_node )
438 return is_node - r.is_node;
439 if ( is_node )
440 return ::compare(node, r.node);
441 return elp.compare(r.elp);
442 }
443 bool idaapi operator == (const selection_item_t &r) const
444 { return compare(r) == 0; }
445 bool idaapi operator != (const selection_item_t &r) const
446 { return compare(r) != 0; }
447 bool idaapi operator < (const selection_item_t &r) const
448 { return compare(r) < 0; }
449};
450
451
456
458{
459 bool idaapi has(const selection_item_t &item) const
460 { return (const_iterator)find(item) != end(); }
461 void idaapi add(const screen_graph_selection_t &s)
462 {
463 for ( screen_graph_selection_t::const_iterator p=s.begin(); p != s.end(); ++p )
464 add_unique(*p);
465 }
466 void idaapi sub(const screen_graph_selection_t &s)
467 {
468 for ( screen_graph_selection_t::const_iterator p=s.begin(); p != s.end(); ++p )
469 del(*p);
470 }
471 void idaapi add_node(int node) { add_unique(selection_item_t(node)); }
472 void idaapi del_node(int node) { del(selection_item_t(node)); }
473 void idaapi add_point(edge_t e, int idx) { add_unique(selection_item_t(e, idx)); }
474 void idaapi del_point(edge_t e, int idx) { del(selection_item_t(e, idx)); }
475
476 size_t idaapi nodes_count() const { return items_count(true); }
477 size_t idaapi points_count() const { return items_count(false); }
478 size_t idaapi items_count(bool look_for_nodes) const
479 {
480 size_t cnt = 0;
481 for ( size_t i = 0, sz = size(); i < sz; ++i )
482 if ( at(i).is_node == look_for_nodes )
483 ++cnt;
484 return cnt;
485 }
486};
487
490{
492 int nseg;
493 int x0, x1;
494 size_t idaapi length() const { return abs(x1-x0); }
495 bool idaapi toright() const { return x1 > x0; } // horizontal segment to the right
496 bool idaapi operator < (const edge_segment_t &r) const
497 {
498 return e < r.e;
499/* // longest edges first
500 int ll = x1 - x0; if ( ll < 0 ) ll = -ll;
501 int rl = r.x1 - r.x0; if ( rl < 0 ) rl = -rl;
502 if ( rl < ll )
503 return true;
504 if ( rl == ll )
505 return e < r.e;
506 return false;*/
507 }
508};
509
510//---------------------------------------------------------------------------
521
524{
525public:
528 int n;
529 int b;
532 bool operator == (const graph_item_t &r) const;
533 bool is_node(void) const { return type >= git_node && type <= git_text; }
534 bool is_edge(void) const { return type == git_edge || type == git_elp; }
535};
536
537//-------------------------------------------------------------------------
540{
541 int x0 = 0, x1 = 0; // x0 always <= x1, otherwise the interval is empty
542 bool empty(void) const { return x0 < x1; }
543 void intersect(const interval_t &r)
544 {
545 if ( x0 < r.x0 )
546 x0 = r.x0;
547 if ( x1 > r.x1 )
548 x1 = r.x1;
549 }
550 void make_union(const interval_t &r)
551 {
552 if ( x0 > r.x0 )
553 x0 = r.x0;
554 if ( x1 < r.x1 )
555 x1 = r.x1;
556 }
557 void move_by(int shift)
558 {
559 x0 += shift;
560 x1 += shift;
561 }
563 interval_t(int y0, int y1)
564 {
565 x0 = qmin(y0, y1);
566 x1 = qmax(y0, y1);
567 }
569 {
570 x0 = qmin(s.x0, s.x1);
571 x1 = qmax(s.x0, s.x1);
572 }
573 int length(void) const { return x1 - x0; }
574 bool contains(int x) const { return x0 <= x && x <= x1; }
575 bool operator ==(const interval_t &r) const { return x0 == r.x0 && x1 == r.x1; }
576 bool operator !=(const interval_t &r) const { return !(*this == r); }
577};
578
579//-------------------------------------------------------------------------
582{
584 int top = 0;
585 int bottom = 0;
586
587 int height(void) const { return bottom - top; }
588};
590
591static const int ygap = 30;
592static const int xgap = 10;
593static const int arrow_height = 10;
594static const int arrow_width = 8;
595
597class graph_visitor_t;
598class edge_typer_t;
599
600//-------------------------------------------------------------------------
602{
603 void idaapi find_entries(node_set_t &entries) const;
604 void idaapi depth_first(int root, struct depth_first_info_t &di) const;
605 size_t idaapi remove_reachable(int n, node_set_t *s) const;
606 int idaapi longest_path(int n, intvec_t &tops, int row_height) const;
607 size_t idaapi sort_layer_nodes(
608 const row_info_t &r1,
609 const intmap_t &lpi1,
610 row_info_t &r2,
611 intmap_t &lpi2,
612 bool ispred) const;
613 size_t idaapi calc_cross_num(
614 const intvec_t &r1,
615 const intvec_t &r2,
616 const intmap_t &lpi1,
617 bool ispred) const;
618 size_t idaapi num_crossings(const graph_row_info_t &gri, const array_of_intmap_t &nodepi) const;
619 int idaapi calc_x_coord(const row_info_t &ri, int idx, bool ispred, int first_added_node) const;
620 void idaapi try_move_down(intvec_t &tops, int n, int row_height) const;
621
622protected:
624 void idaapi get_connected_components(intvec_t &entries) const;
625
630 const node_set_t &entries,
631 intvec_t &tops,
632 int row_height) const;
633
635 void idaapi move_nodes_down(
636 intvec_t &tops,
637 const node_ordering_t &post,
638 int first_reverser_node,
639 int row_height) const;
640
643 const intvec_t &tops,
644 graph_row_info_t &gri,
645 int graph_height) const;
646
648 void idaapi calc_row_heights(graph_row_info_t &gri) const;
649
651 void idaapi minimize_crossings(graph_row_info_t &gri) const;
652
654 void idaapi set_x_coords(
655 const graph_row_info_t &gri,
656 const node_set_t &selfrefs,
657 int first_added_node);
658
661 const graph_row_info_t &gri,
662 edge_segs_vec_t &ges) const;
663
665 void idaapi make_rect_edges(
666 graph_row_info_t &gri,
667 const edge_segs_vec_t &ges,
668 int first_reverser_node);
669
671 void idaapi assign_edge_ports(
672 const graph_row_info_t &gri,
673 const node_set_t &selfrefs);
674
677 const edgeset_t &back_edges,
678 const edge_infos_t &self_edges);
679
681 void idaapi clear_layout_info(void);
682
683 void idaapi depth_first(
684 node_ordering_t *pre,
685 node_ordering_t *post,
686 edge_typer_t *et) const;
687
689 edge_typer_t *et,
690 node_set_t *entries,
691 edgeset_t *back_edges,
692 node_ordering_t *pre,
693 node_ordering_t *post) const;
694
695 void idaapi tree_layout(edge_typer_t &et, const node_set_t &entries);
696
698 bool idaapi path_back(const array_of_node_set_t &domin, int m, int n) const;
699 bool idaapi path_back(edge_typer_t &et, int m, int n) const;
700
702 int idaapi visit_nodes(int node, graph_node_visitor_t &gv) const;
703
706 int idaapi visit_paths(int node, graph_path_visitor_t &gv) const;
707
708public:
710 bool rect_edges_made = false;
714 hook_cb_t *callback = nullptr;
715 void *callback_ud = nullptr;
716
717 virtual ~drawable_graph_t() {}
718 void idaapi clear(void);
719 void idaapi dump_graph(const char *header) const;
720 bool idaapi calc_bounds(rect_t *r);
722 const rect_t &area,
723 const rect_t &r,
725 double max_zoom);
727 const rect_t &area,
729 double max_zoom);
731 // get edge ports - fills s, d arguments and returns edge_info_t
733 edge_t e,
734 point_t &s,
735 point_t &d) const;
736 // add edges from/to the node
737 void idaapi add_node_edges(edgevec_t &dlist, int node);
738 const rect_t &idaapi nrect(int n) const
739 { return (CONST_CAST(drawable_graph_t *)(this))->nrect(n); }
740 const edge_info_t *idaapi get_edge(edge_t e) const
741 { return (CONST_CAST(drawable_graph_t *)(this))->get_edge(e); }
742 virtual rect_t &idaapi nrect(int n) = 0;
743 virtual edge_info_t *idaapi get_edge(edge_t e) = 0;
744 virtual drawable_graph_t *idaapi clone(void) const = 0;
745
746 bool idaapi create_tree_layout(void);
747 bool idaapi create_circle_layout(point_t p, int radius);
748 bool idaapi create_polar_tree_layout(point_t p, int radius);
749 bool idaapi create_radial_tree_layout(point_t p, int radius);
750 bool idaapi create_orthogonal_layout(void);
751
752 void set_callback(hook_cb_t *_callback, void *_ud)
753 {
754 callback = _callback;
755 callback_ud = _ud;
756 }
757 ssize_t vgrcall(int code, va_list va)
758 {
759 if ( callback != nullptr )
760 return callback(callback_ud, code, va);
761 return 0;
762 }
764 {
765 va_list va;
766 va_start(va, code);
768 va_end(va);
769 return result;
770 }
771};
772
777#if defined(__GNUC__) && (defined(__KERNEL__) || !defined(__UI__)) // compiling a plugin or the kernel with gcc?
778#define GCC_PUREVIRT = 0
779#else
780#define GCC_PUREVIRT
781#endif
782
783//-------------------------------------------------------------------------
794
795#ifdef _DEBUG
796#define CHKNODEIDX(n) QASSERT(1385, int(n) >= 0)
797#else
798#define CHKNODEIDX(n)
799#endif
800
872//
877{
878 typedef drawable_graph_t inherited;
879 int idaapi _find_subgraph_node(int group, int n) const;
880 void idaapi collapse_edges(const intvec_t &nodes, int group);
881 void idaapi del_node_keep_edges(int n);
882 void idaapi add_dest(destset_t &ne, edge_t e, int g);
883 void idaapi reverse_edges(
884 const edgeset_t &back_edges,
885 edge_infos_t &self_edges,
886 node_set_t &entries);
887 void idaapi layout_self_reference_edges(const edge_infos_t &selfrefs);
888 void idaapi restore_edges(int first_reserver_node, bool failed);
889
890 void idaapi add_layer_nodes(graph_row_info_t &gri, intvec_t &tops);
891 void idaapi del_layer_nodes(graph_row_info_t &gri, int first_added_node);
892 void idaapi fix_collapsed_group_edges(void);
893
894public:
901#define MTG_GROUP_NODE 0x01
902#define MTG_DOT_NODE 0x02
903#define MTG_NON_DISPLAYABLE_NODE 0x08
906
907 // groups: original edges without considering any group info
910
916
920
927 virtual int idaapi size(void) const override { return int(succs.size()); }
928
935 virtual int idaapi node_qty(void) const override;
936
939 void idaapi clear(void);
940
943 virtual bool idaapi empty(void) const override;
944
949 virtual bool idaapi exists(int node) const override { return is_visible_node(node); }
950#define COLLAPSED_NODE 0x80000000
951
959 //
963 int idaapi get_node_representative(int node);
964
965 int idaapi get_node_group(int node) const { CHKNODEIDX(node); return (belongs[node] & ~COLLAPSED_NODE); }
966 void idaapi set_node_group(int node, int group) { CHKNODEIDX(node); belongs[node] = group | (belongs[node] & COLLAPSED_NODE); }
967 bool idaapi is_deleted_node(int node) const { CHKNODEIDX(node); return belongs[node] == INT_MAX; }
968 void idaapi set_deleted_node(int node) { CHKNODEIDX(node); belongs[node] = INT_MAX; }
969 bool idaapi is_subgraph_node(int node) const { return get_node_group(node) != node; }
970 bool idaapi is_dot_node(int node) const { CHKNODEIDX(node); return (node_flags[node] & MTG_DOT_NODE) != 0; }
971 bool idaapi is_group_node(int node) const { CHKNODEIDX(node); return (node_flags[node] & MTG_GROUP_NODE) != 0; }
972 bool idaapi is_displayable_node(int node) const { CHKNODEIDX(node); return (node_flags[node] & MTG_NON_DISPLAYABLE_NODE) == 0; }
973 bool idaapi is_simple_node(int node) const { return !is_group_node(node); }
974 bool idaapi is_collapsed_node(int node) const { CHKNODEIDX(node); return (belongs[node] & COLLAPSED_NODE) != 0; }
975 bool idaapi is_uncollapsed_node(int node) const { return is_group_node(node) && !is_collapsed_node(node); }
976
984 bool idaapi is_visible_node(int node) const;
985
989 bool idaapi groups_are_present(void) const;
990
991 // iterate subgraph nodes, return -1 at the end
992 int idaapi get_first_subgraph_node(int group) const { return _find_subgraph_node(group, 0); }
993 int idaapi get_next_subgraph_node(int group, int current) const { return _find_subgraph_node(group, current+1); }
994 void idaapi insert_visible_nodes(intvec_t &nodes, int group) const;
995 void idaapi insert_simple_nodes(intvec_t &nodes, int group) const;
996 bool idaapi check_new_group(const intvec_t &nodes, intvec_t &refined);
997
1003 int idaapi create_group(const intvec_t &nodes);
1004
1012 bool idaapi delete_group(int group);
1013
1019 bool idaapi change_group_visibility(int group, bool expand);
1020
1026 bool idaapi change_visibility(const intvec_t &nodes, bool expand);
1027
1028 virtual int idaapi nsucc(int b) const override { CHKNODEIDX(b); return (int)succs[b].size(); }
1029 virtual int idaapi npred(int b) const override { CHKNODEIDX(b); return (int)preds[b].size(); }
1030 virtual int idaapi succ(int b, int i) const override { CHKNODEIDX(b); return succs[b][i]; }
1031 virtual int idaapi pred(int b, int i) const override { CHKNODEIDX(b); return preds[b][i]; }
1032 const intvec_t &idaapi succset(int b) const { CHKNODEIDX(b); return succs[b]; }
1033 const intvec_t &idaapi predset(int b) const { CHKNODEIDX(b); return preds[b]; }
1034
1035 void idaapi reset(void) { resize(0); }
1036
1041 virtual bool idaapi redo_layout(void) GCC_PUREVIRT;
1042
1046 virtual void idaapi resize(int n) GCC_PUREVIRT;
1047
1052 virtual int idaapi add_node(const rect_t *r) GCC_PUREVIRT;
1053
1058 virtual ssize_t idaapi del_node(int n) GCC_PUREVIRT; // returns number of deleted edges
1059
1060 virtual bool idaapi add_edge(int i, int j, const edge_info_t *ei) GCC_PUREVIRT;
1061 virtual bool idaapi del_edge(int i, int j) GCC_PUREVIRT; // true: found and deleted the edge
1062 virtual bool idaapi replace_edge(int i, int j, int x, int y) GCC_PUREVIRT;
1063
1084 virtual bool idaapi refresh(void) GCC_PUREVIRT;
1085
1086 virtual interactive_graph_t *idaapi clone(void) const override GCC_PUREVIRT;
1087
1088 // get node rectangle
1089 const rect_t &idaapi nrect(int n) const
1090 { return (CONST_CAST(interactive_graph_t *)(this))->nrect(n); }
1091 virtual rect_t &idaapi nrect(int n) override;
1092 virtual edge_info_t *idaapi get_edge(edge_t e) override GCC_PUREVIRT;
1093
1094 virtual bool idaapi set_nrect(int n, const rect_t &r) GCC_PUREVIRT;
1095 virtual bool idaapi set_edge(edge_t e, const edge_info_t *ei) GCC_PUREVIRT;
1096
1097 bool idaapi create_digraph_layout(void);
1098
1099 void idaapi del_custom_layout(void);
1100 bool idaapi get_custom_layout(void);
1101 void idaapi set_custom_layout(void) const;
1102 bool idaapi get_graph_groups(void);
1103 void idaapi set_graph_groups(void) const;
1104 virtual ea_t idaapi calc_group_ea(const intvec_t & /*nodes*/) newapi { return BADADDR; }
1105
1106 point_t idaapi calc_center_of(const intvec_t &nodes) const;
1107 void idaapi move_to_same_place(const intvec_t &collapsing_nodes, point_t p);
1108 void idaapi move_grouped_nodes(const intvec_t &groups, const interactive_graph_t *ng);
1109
1110 virtual bool idaapi is_user_graph() newapi { return false; }
1111};
1112
1113//-------------------------------------------------------------------------
1116{
1117public:
1118 virtual ~graph_visitor_t() {}
1119protected:
1121 virtual int idaapi visit_node(int n, rect_t &r) = 0;
1122 virtual int idaapi visit_edge(edge_t e, edge_info_t *ei) = 0;
1123 friend int idaapi drawable_graph_t::for_all_nodes_edges(graph_visitor_t &nev, bool visit_nodes);
1124};
1125
1126//-------------------------------------------------------------------------
1129{
1130 // Callbacks called by IDA (plugins can hook to them):
1131
1136
1141
1145
1147
1159
1165
1176
1187
1199
1203
1207
1219
1221
1229
1237
1246
1255
1264
1277
1278 //-------------------------------------------------------------------------
1279 // Callbacks callable from plugins (see inline functions below):
1280 //-------------------------------------------------------------------------
1281
1282 // graph_viewer_t (or IDA View graph) manipulation.
1293
1294 // interactive_graph_t (and drawable_graph_t) manipulation.
1314
1315 // More graph_viewer_t manipulation.
1323
1324 // Deprecated. Those were meant to work with intset_t, that we now got rid of.
1328
1329 //
1336
1337 //
1339
1340 //
1343};
1344
1345
1346//-------------------------------------------------------------------------
1347#ifndef SWIG
1354
1355
1356inline ssize_t grentry(graph_notification_t event_code, ...)
1357{
1358 va_list va;
1359 va_start(va, event_code);
1360 ssize_t code = invoke_callbacks(HT_GRAPH, event_code, va);
1361 va_end(va);
1362 return code;
1363}
1364
1365#endif
1366
1367
1368//-------------------------------------------------------------------------
1375
1376#ifndef __UI__
1377
1379
1380
1390
1392 const char *title,
1393 uval_t id,
1394 hook_cb_t *callback,
1395 void *ud,
1396 int title_height,
1397 TWidget *parent=nullptr)
1398{
1399 graph_viewer_t *gv = nullptr;
1400 grentry(grcode_create_graph_viewer, title, &gv, id, callback, ud, title_height, parent);
1401 return gv;
1402}
1403
1404
1406
1407inline graph_viewer_t *idaapi get_graph_viewer(TWidget *parent) { graph_viewer_t *gv = nullptr; grentry(grcode_get_graph_viewer, parent, &gv); return gv; }
1408
1409
1411
1413
1414
1416
1418
1419
1421
1422inline interactive_graph_t *idaapi create_disasm_graph(const rangevec_t &ranges) { interactive_graph_t *g = nullptr; grentry(grcode_create_disasm_graph2, &ranges, &g); return g; }
1423
1424
1426
1428
1429
1431
1433
1434
1436
1438
1439
1441
1443
1444
1446
1447inline int idaapi viewer_get_curnode(graph_viewer_t *gv) { return grentry(grcode_get_curnode, gv); }
1448
1449
1451
1452inline void idaapi viewer_center_on(graph_viewer_t *gv, int node) { grentry(grcode_center_on, gv, node); }
1453
1457
1458inline void idaapi viewer_set_gli(
1459 graph_viewer_t *gv,
1460 const graph_location_info_t *gli,
1461 uint32 flags = 0)
1462{
1463 grentry(grcode_set_gli, gv, gli, flags);
1464}
1465
1466
1470
1471inline bool idaapi viewer_get_gli(
1473 graph_viewer_t *gv,
1474 uint32 flags = 0)
1475{
1476 return grentry(grcode_get_gli, out, gv, flags) == 0;
1477}
1478
1479
1481
1482inline void idaapi viewer_set_node_info(
1483 graph_viewer_t *gv,
1484 int n,
1485 const node_info_t &ni,
1486 uint32 flags)
1487{
1488 grentry(grcode_set_node_info, gv, n, &ni, flags);
1489}
1490
1491
1493
1494inline bool idaapi viewer_get_node_info(
1495 graph_viewer_t *gv,
1496 node_info_t *out,
1497 int n)
1498{
1499 return grentry(grcode_get_node_info, gv, out, n) == 1;
1500}
1501
1502
1504
1505inline void idaapi viewer_del_node_info(graph_viewer_t *gv, int n)
1506{
1508}
1509
1510
1522
1523inline bool idaapi viewer_create_groups(
1524 graph_viewer_t *gv,
1525 intvec_t *out_group_nodes,
1526 const groups_crinfos_t &gi)
1527{
1528 return grentry(grcode_viewer_create_groups_vec, gv, out_group_nodes, &gi) == 1;
1529}
1530
1531
1537
1538inline bool idaapi viewer_delete_groups(
1539 graph_viewer_t *gv,
1540 const intvec_t &groups,
1541 int new_current = -1)
1542{
1543 return grentry(grcode_viewer_delete_groups_vec, gv, &groups, new_current) == 1;
1544}
1545
1546
1552
1554 graph_viewer_t *gv,
1555 const intvec_t &groups,
1556 bool expand,
1557 int new_current = -1)
1558{
1559 return grentry(grcode_viewer_groups_visibility_vec, gv, &groups,
1560 expand, new_current) == 1;
1561}
1562
1563
1569
1570inline bool idaapi viewer_attach_menu_item(graph_viewer_t *g, const char *name)
1571{
1572 return grentry(grcode_attach_menu_item, g, name) != 0;
1573}
1574
1575
1577
1578inline bool idaapi viewer_get_selection(
1579 graph_viewer_t *gv,
1581{
1582 return grentry(grcode_get_selection, gv, sgs) != 0;
1583}
1584
1585
1587
1588inline int idaapi viewer_set_titlebar_height(graph_viewer_t *gv, int height)
1589{
1590 return grentry(grcode_set_titlebar_height, gv, height);
1591}
1592
1593
1600
1605
1606
1610inline void idaapi interactive_graph_t::clear(void) { grentry(grcode_clear, this); }
1612inline bool idaapi drawable_graph_t::create_tree_layout(void) { return grentry(grcode_create_tree_layout, this) != 0; }
1613inline bool idaapi drawable_graph_t::create_circle_layout(point_t c, int radius) { return grentry(grcode_create_circle_layout, this, c.x, c.y, radius) != 0; }
1615inline int idaapi interactive_graph_t::_find_subgraph_node(int gr, int n) const { return grentry(grcode_find_subgraph_node, this, gr, n); }
1616inline int idaapi interactive_graph_t::create_group(const intvec_t &_nodes) { return grentry(grcode_create_group, this, &_nodes); }
1617inline bool idaapi interactive_graph_t::get_custom_layout(void) { return grentry(grcode_get_custom_layout, this) != 0; }
1618inline bool idaapi interactive_graph_t::get_graph_groups(void) { return grentry(grcode_get_graph_groups, this) != 0; }
1619inline bool idaapi interactive_graph_t::empty(void) const { return grentry(grcode_empty, this) != 0; }
1620inline bool idaapi interactive_graph_t::is_visible_node(int node) const { return grentry(grcode_is_visible_node, this, node) != 0; }
1621inline bool idaapi interactive_graph_t::delete_group(int group) { return grentry(grcode_delete_group, this, group) != 0; }
1622inline bool idaapi interactive_graph_t::change_group_visibility(int gr, bool exp) { return grentry(grcode_change_group_visibility, this, gr, exp) != 0; }
1623inline bool idaapi interactive_graph_t::set_edge(edge_t e, const edge_info_t *ei) { return grentry(grcode_set_edge, this, e.src, e.dst, ei) != 0; }
1624inline int idaapi interactive_graph_t::node_qty(void) const { return grentry(grcode_node_qty, this); }
1625inline rect_t &idaapi interactive_graph_t::nrect(int n) { rect_t *r; grentry(grcode_nrect, this, n, &r); return *r; }
1626
1628 const edge_infos_wrapper_t &other)
1629{
1630 grentry(grcode_edge_infos_wrapper_copy, this, &other); return *this;
1631}
1632
1637
1638
1642{
1643 int node;
1644};
1645
1646
1648
1649inline user_graph_place_t *create_user_graph_place(int node, int lnnum) { user_graph_place_t *r; grentry(grcode_create_user_graph_place, node, lnnum, &r); return r; }
1650
1651#endif // UI
1652
1653#endif // __GRAPH_DEF_HPP
Vector of bytes (use for dynamic memory)
Definition pro.h:3773
Definition graph.hpp:602
qstring title
graph title
Definition graph.hpp:709
bool idaapi calc_fitting_params(const rect_t &area, graph_location_info_t *gli, double max_zoom)
void idaapi create_spanning_tree(edge_typer_t *et, node_set_t *entries, edgeset_t *back_edges, node_ordering_t *pre, node_ordering_t *post) const
virtual edge_info_t *idaapi get_edge(edge_t e)=0
void idaapi get_connected_components(intvec_t &entries) const
Returns one entry point for each connected component.
bool idaapi create_polar_tree_layout(point_t p, int radius)
bool rect_edges_made
have create rectangular edges?
Definition graph.hpp:710
void idaapi set_x_coords(const graph_row_info_t &gri, const node_set_t &selfrefs, int first_added_node)
Calculate x coords of all nodes.
int idaapi for_all_nodes_edges(graph_visitor_t &nev, bool visit_nodes=true)
int idaapi calc_longest_pathes(const node_set_t &entries, intvec_t &tops, int row_height) const
Find longest paths from the entries.
int idaapi visit_nodes(int node, graph_node_visitor_t &gv) const
Visit nodes starting from 'node', depth first.
bool idaapi path_back(edge_typer_t &et, int m, int n) const
int idaapi visit_paths(int node, graph_path_visitor_t &gv) const
Visit all possible paths starting from 'node'.
const rect_t &idaapi nrect(int n) const
Definition graph.hpp:738
bool idaapi create_orthogonal_layout(void)
const edge_info_t *idaapi get_edge(edge_t e) const
Definition graph.hpp:740
point_t circle_center
for layout_circle
Definition graph.hpp:712
void idaapi create_graph_row_info(const intvec_t &tops, graph_row_info_t &gri, int graph_height) const
Create graph row info from 'tops'.
void idaapi minimize_crossings(graph_row_info_t &gri) const
Minimize crossings.
void set_callback(hook_cb_t *_callback, void *_ud)
Definition graph.hpp:752
hook_cb_t * callback
user-defined callback
Definition graph.hpp:714
int circle_radius
for layout_circle
Definition graph.hpp:713
bool idaapi create_radial_tree_layout(point_t p, int radius)
void idaapi recalc_edge_widths(const edgeset_t &back_edges, const edge_infos_t &self_edges)
Recalculate width of all edges.
layout_type_t current_layout
see Proximity view layouts
Definition graph.hpp:711
const edge_info_t *idaapi get_edge_ports(edge_t e, point_t &s, point_t &d) const
void * callback_ud
user data for callback
Definition graph.hpp:715
void idaapi move_nodes_down(intvec_t &tops, const node_ordering_t &post, int first_reverser_node, int row_height) const
Move entry nodes down as much as possible.
bool idaapi calc_bounds(rect_t *r)
void idaapi clear_layout_info(void)
Clear layout information in the graph.
void idaapi assign_edge_ports(const graph_row_info_t &gri, const node_set_t &selfrefs)
Assign ports to edges.
void idaapi dump_graph(const char *header) const
virtual rect_t &idaapi nrect(int n)=0
void idaapi clear(void)
bool idaapi create_circle_layout(point_t p, int radius)
Definition graph.hpp:1613
ssize_t vgrcall(int code, va_list va)
Definition graph.hpp:757
void idaapi calc_fitting_params(const rect_t &area, const rect_t &r, graph_location_info_t *gli, double max_zoom)
virtual ~drawable_graph_t()
Definition graph.hpp:717
virtual drawable_graph_t *idaapi clone(void) const =0
void idaapi make_rect_edges(graph_row_info_t &gri, const edge_segs_vec_t &ges, int first_reverser_node)
Make all edges rectangular.
bool idaapi create_tree_layout(void)
Definition graph.hpp:1612
void idaapi depth_first(node_ordering_t *pre, node_ordering_t *post, edge_typer_t *et) const
void idaapi calc_row_heights(graph_row_info_t &gri) const
Calculate height of each row.
bool idaapi path_back(const array_of_node_set_t &domin, int m, int n) const
Is there a path from M to N which terminates with a back edge to N?
void idaapi add_node_edges(edgevec_t &dlist, int node)
void idaapi tree_layout(edge_typer_t &et, const node_set_t &entries)
ssize_t grcall(int code,...)
Definition graph.hpp:763
void idaapi gather_edge_segments(const graph_row_info_t &gri, edge_segs_vec_t &ges) const
Gather information about all edge segments.
gdl graph interface - includes only functions required to draw it
Definition gdl.hpp:248
Describes a sub-item of a graph.
Definition graph.hpp:524
graph_item_type_t type
type
Definition graph.hpp:526
int b
button number
Definition graph.hpp:529
point_t p
text coordinates in the node
Definition graph.hpp:530
int n
node number
Definition graph.hpp:528
edge_t e
edge source and destination
Definition graph.hpp:527
bool operator==(const graph_item_t &r) const
bool is_edge(void) const
Definition graph.hpp:534
edge_layout_point_t elp
edge layout point
Definition graph.hpp:531
bool is_node(void) const
Definition graph.hpp:533
Node visitor - see drawable_graph_t::visit_nodes()
Definition graph.hpp:129
void idaapi reinit(void)
Reset visited nodes.
Definition graph.hpp:133
virtual bool idaapi is_forbidden_edge(int, int) const
Should the edge between 'n' and 'm' be ignored?
Definition graph.hpp:142
bool idaapi is_visited(int n) const
Have we already visited the given node?
Definition graph.hpp:137
void idaapi set_visited(int n)
Mark node as visited.
Definition graph.hpp:135
virtual ~graph_node_visitor_t()
Definition graph.hpp:144
virtual int idaapi visit_node(int)
Implements action to take when a node is visited.
Definition graph.hpp:140
Visit all nodes and edges in a graph.
Definition graph.hpp:1116
virtual ~graph_visitor_t()
Definition graph.hpp:1118
virtual int idaapi visit_node(int n, rect_t &r)=0
drawable_graph_t * g
Definition graph.hpp:1120
virtual int idaapi visit_edge(edge_t e, edge_info_t *ei)=0
The base class used to display graphs in IDA.
Definition graph.hpp:877
virtual bool idaapi refresh(void) GCC_PUREVIRT
Refresh the graph.
const intvec_t &idaapi succset(int b) const
Definition graph.hpp:1032
idaapi interactive_graph_t(const drawable_graph_t &g, uval_t id)
virtual interactive_graph_t *idaapi clone(void) const override GCC_PUREVIRT
node_layout_t nodes
Definition graph.hpp:914
bool idaapi get_graph_groups(void)
Definition graph.hpp:1618
virtual int idaapi npred(int b) const override
Definition graph.hpp:1029
qvector< rect_t > node_layout_t
Definition graph.hpp:913
int idaapi create_group(const intvec_t &nodes)
Create a new group node, that will contain all the nodes in 'nodes'.
Definition graph.hpp:1616
bool idaapi get_custom_layout(void)
Definition graph.hpp:1617
bool idaapi is_collapsed_node(int node) const
Definition graph.hpp:974
virtual edge_info_t *idaapi get_edge(edge_t e) override GCC_PUREVIRT
idaapi interactive_graph_t(uval_t id)
edge_infos_wrapper_t edges
Definition graph.hpp:915
int idaapi get_node_representative(int node)
Get the node that currently visually represents 'node'.
Definition graph.hpp:1614
virtual int idaapi succ(int b, int i) const override
Definition graph.hpp:1030
virtual int idaapi add_node(const rect_t *r) GCC_PUREVIRT
Add a node, possibly with a specific geometry.
virtual bool idaapi redo_layout(void) GCC_PUREVIRT
Recompute the layout, according to the value of 'current_layout'.
virtual int idaapi pred(int b, int i) const override
Definition graph.hpp:1031
virtual void idaapi resize(int n) GCC_PUREVIRT
Resize the graph to 'n' nodes.
point_t idaapi calc_center_of(const intvec_t &nodes) const
virtual int idaapi nsucc(int b) const override
Definition graph.hpp:1028
uval_t gid
graph id - unique for the database for flowcharts it is equal to the function start_ea
Definition graph.hpp:895
virtual bool idaapi replace_edge(int i, int j, int x, int y) GCC_PUREVIRT
void idaapi set_deleted_node(int node)
Definition graph.hpp:968
virtual bool idaapi del_edge(int i, int j) GCC_PUREVIRT
bool idaapi is_simple_node(int node) const
Definition graph.hpp:973
void idaapi reset(void)
Definition graph.hpp:1035
int idaapi get_first_subgraph_node(int group) const
Definition graph.hpp:992
void idaapi insert_simple_nodes(intvec_t &nodes, int group) const
bool idaapi change_visibility(const intvec_t &nodes, bool expand)
Change visibility of multiple group nodes.
const intvec_t &idaapi predset(int b) const
Definition graph.hpp:1033
bool idaapi is_group_node(int node) const
Definition graph.hpp:971
void idaapi del_custom_layout(void)
Definition graph.hpp:1607
virtual int idaapi size(void) const override
Get the total number of nodes (including group nodes, and including hidden nodes.)
Definition graph.hpp:927
virtual bool idaapi set_edge(edge_t e, const edge_info_t *ei) GCC_PUREVIRT
Definition graph.hpp:1623
virtual bool idaapi empty(void) const override
Is the graph (visually) empty?
Definition graph.hpp:1619
virtual ssize_t idaapi del_node(int n) GCC_PUREVIRT
Delete a node.
bool idaapi is_visible_node(int node) const
Is the node currently visible?
Definition graph.hpp:1620
void idaapi set_node_group(int node, int group)
Definition graph.hpp:966
intvec_t belongs
the subgraph the node belongs to INT_MAX means that the node doesn't exist sign bit means collapsed n...
Definition graph.hpp:897
virtual bool idaapi is_user_graph() new api
Definition graph.hpp:1110
bool idaapi is_deleted_node(int node) const
Definition graph.hpp:967
bool idaapi change_group_visibility(int group, bool expand)
Expand/collapse a group node.
Definition graph.hpp:1622
bool idaapi is_displayable_node(int node) const
Definition graph.hpp:972
virtual int idaapi node_qty(void) const override
Get the number of visible nodes (the list can be retrieved using gdl.hpp's node_iterator)
Definition graph.hpp:1624
void idaapi move_to_same_place(const intvec_t &collapsing_nodes, point_t p)
bytevec_t node_flags
node flags
Definition graph.hpp:900
void idaapi set_graph_groups(void) const
Definition graph.hpp:1609
bool idaapi is_subgraph_node(int node) const
Definition graph.hpp:969
int idaapi get_next_subgraph_node(int group, int current) const
Definition graph.hpp:993
array_of_intvec_t succs
Definition graph.hpp:911
bool idaapi is_dot_node(int node) const
Definition graph.hpp:970
bool idaapi is_uncollapsed_node(int node) const
Definition graph.hpp:975
void idaapi move_grouped_nodes(const intvec_t &groups, const interactive_graph_t *ng)
void idaapi set_custom_layout(void) const
Definition graph.hpp:1608
bool idaapi groups_are_present(void) const
Is there any group node in the graph?
bool idaapi check_new_group(const intvec_t &nodes, intvec_t &refined)
bool idaapi create_digraph_layout(void)
Definition graph.hpp:1611
virtual bool idaapi exists(int node) const override
Is the node visible?
Definition graph.hpp:949
void idaapi insert_visible_nodes(intvec_t &nodes, int group) const
array_of_intvec_t org_preds
Definition graph.hpp:909
virtual ~interactive_graph_t()
Definition graph.hpp:919
virtual ea_t idaapi calc_group_ea(const intvec_t &) new api
Definition graph.hpp:1104
bool idaapi delete_group(int group)
Delete a group node.
Definition graph.hpp:1621
array_of_intvec_t org_succs
Definition graph.hpp:908
int idaapi get_node_group(int node) const
Definition graph.hpp:965
array_of_intvec_t preds
Definition graph.hpp:912
void idaapi clear(void)
Clears all nodes & edges information in this instance (does not remove node_info_t stored in the data...
Definition graph.hpp:1610
virtual bool idaapi add_edge(int i, int j, const edge_info_t *ei) GCC_PUREVIRT
const rect_t &idaapi nrect(int n) const
Definition graph.hpp:1089
virtual bool idaapi set_nrect(int n, const rect_t &r) GCC_PUREVIRT
Map of integer constants to integer constants.
Definition gdl.hpp:74
Node ordering in a graph.
Definition gdl.hpp:142
Set of graph nodes.
Definition gdl.hpp:121
place_t()
Constructor.
Definition kernwin.hpp:1421
Ordered sequence of points.
Definition graph.hpp:213
const char *idaapi dstr(void) const
size_t idaapi print(char *buf, size_t bufsize) const
Reimplementation of vector class from STL.
Definition pro.h:2250
const selection_item_t * const_iterator
Definition pro.h:2607
bool del(const selection_item_t &x)
Definition pro.h:2749
iterator end(void)
Definition pro.h:2610
const selection_item_t & at(size_t _idx) const
Definition pro.h:2427
iterator find(const selection_item_t &x)
Definition pro.h:2703
iterator begin(void)
Get an iterator that points to the first element in the qvector.
Definition pro.h:2609
size_t size(void) const
Definition pro.h:2423
bool add_unique(const selection_item_t &x)
Definition pro.h:2739
Low level graph drawing operations.
qvector< node_set_t > array_of_node_set_t
Definition gdl.hpp:135
qvector< intmap_t > array_of_intmap_t
Definition gdl.hpp:81
DECLARE_HELPER(idaman) class intset_t typedef qvector< intvec_t > array_of_intvec_t
Set of integer constants.
Definition gdl.hpp:52
DECLARE_TYPE_AS_MOVABLE(point_t)
graph_viewer_t *idaapi get_graph_viewer(TWidget *parent)
Get custom graph viewer for given form.
Definition graph.hpp:1407
void idaapi refresh_viewer(graph_viewer_t *gv)
Redraw the graph in the given view.
Definition graph.hpp:1437
bool idaapi viewer_delete_groups(graph_viewer_t *gv, const intvec_t &groups, int new_current=-1)
Wrapper around interactive_graph_t::delete_group.
Definition graph.hpp:1538
bool idaapi viewer_set_groups_visibility(graph_viewer_t *gv, const intvec_t &groups, bool expand, int new_current=-1)
Wrapper around interactive_graph_t::change_visibility.
Definition graph.hpp:1553
interactive_graph_t *idaapi create_disasm_graph(ea_t ea)
Create a graph for the function that contains 'ea'.
Definition graph.hpp:1417
void idaapi viewer_set_gli(graph_viewer_t *gv, const graph_location_info_t *gli, uint32 flags=0)
Set location info for given graph view If flags contains GLICTL_CENTER, then the gli will be set to b...
Definition graph.hpp:1458
qvector< group_crinfo_t > groups_crinfos_t
Definition graph.hpp:1374
int idaapi viewer_get_curnode(graph_viewer_t *gv)
Get number of currently selected node (-1 if none)
Definition graph.hpp:1447
bool idaapi viewer_attach_menu_item(graph_viewer_t *g, const char *name)
Attach a previously-registered action to the view's context menu.
Definition graph.hpp:1570
graph_notification_t
Graph notification codes.
Definition graph.hpp:1129
@ grcode_viewer_delete_groups_vec
use viewer_delete_groups()
Definition graph.hpp:1331
@ grcode_del_custom_layout
use interactive_graph_t::del_custom_layout()
Definition graph.hpp:1295
@ grcode_viewer_create_groups
Definition graph.hpp:1325
@ grcode_get_selection
use viewer_get_selection()
Definition graph.hpp:1292
@ grcode_nrect
use interactive_graph_t::nrect()
Definition graph.hpp:1313
@ grcode_create_disasm_graph2
use create_disasm_graph(const rangevec_t &ranges)
Definition graph.hpp:1319
@ grcode_viewer_groups_visibility_vec
use viewer_set_groups_visibility()
Definition graph.hpp:1332
@ grcode_gotfocus
a graph viewer got focus.
Definition graph.hpp:1200
@ grcode_get_graph_groups
use interactive_graph_t::get_graph_groups()
Definition graph.hpp:1306
@ grcode_create_disasm_graph1
use create_disasm_graph(ea_t ea)
Definition graph.hpp:1318
@ grcode_center_on
use viewer_center_on()
Definition graph.hpp:1291
@ grcode_change_group_visibility
use interactive_graph_t::change_group_visibility()
Definition graph.hpp:1310
@ grcode_reserved
Definition graph.hpp:1146
@ grcode_is_visible_node
use interactive_graph_t::is_visible_node()
Definition graph.hpp:1308
@ grcode_changed_graph
new graph has been set.
Definition graph.hpp:1142
@ grcode_create_user_graph_place
use create_user_graph_place()
Definition graph.hpp:1317
@ grcode_create_digraph_layout
use interactive_graph_t::create_digraph_layout()
Definition graph.hpp:1299
@ grcode_deleting_group
a group is being deleted.
Definition graph.hpp:1177
@ grcode_attach_menu_item
Definition graph.hpp:1338
@ grcode_delete_group
use interactive_graph_t::delete_group()
Definition graph.hpp:1309
@ grcode_creating_group
a group is being created.
Definition graph.hpp:1166
@ grcode_create_group
use interactive_graph_t::create_group()
Definition graph.hpp:1304
@ grcode_create_interactive_graph
use create_interactive_graph()
Definition graph.hpp:1286
@ grcode_viewer_groups_visibility
Definition graph.hpp:1327
@ grcode_get_node_representative
use interactive_graph_t::get_node_representative()
Definition graph.hpp:1302
@ grcode_get_custom_layout
use interactive_graph_t::get_custom_layout()
Definition graph.hpp:1305
@ grcode_fit_window
use viewer_fit_window()
Definition graph.hpp:1289
@ grcode_create_tree_layout
use drawable_graph_t::create_tree_layout()
Definition graph.hpp:1300
@ grcode_set_edge
use interactive_graph_t::set_edge()
Definition graph.hpp:1311
@ grcode_user_hint
retrieve hint for the user-defined graph.
Definition graph.hpp:1256
@ grcode_set_gli
use viewer_set_gli()
Definition graph.hpp:1341
@ grcode_group_visibility
a group is being collapsed/uncollapsed this provides an opportunity for the graph to forbid changing ...
Definition graph.hpp:1188
@ grcode_viewer_create_groups_vec
use viewer_create_groups()
Definition graph.hpp:1330
@ grcode_delete_interactive_graph
use delete_interactive_graph()
Definition graph.hpp:1333
@ grcode_find_subgraph_node
use interactive_graph_t::_find_subgraph_node()
Definition graph.hpp:1303
@ grcode_create_graph_viewer
use create_graph_viewer()
Definition graph.hpp:1283
@ grcode_empty
use interactive_graph_t::empty()
Definition graph.hpp:1307
@ grcode_user_title
render node title of a user-defined graph.
Definition graph.hpp:1238
@ grcode_set_viewer_graph
use set_viewer_graph()
Definition graph.hpp:1287
@ grcode_get_curnode
use viewer_get_curnode()
Definition graph.hpp:1290
@ grcode_set_titlebar_height
use viewer_set_titlebar_height()
Definition graph.hpp:1316
@ grcode_clicked
graph is being clicked.
Definition graph.hpp:1148
@ grcode_set_custom_layout
use interactive_graph_t::set_custom_layout()
Definition graph.hpp:1296
@ grcode_reserved2
Definition graph.hpp:1220
@ grcode_destroyed
graph is being destroyed.
Definition graph.hpp:1265
@ grcode_get_graph_viewer
use get_graph_viewer()
Definition graph.hpp:1284
@ grcode_user_draw
render node of a user-defined graph.
Definition graph.hpp:1247
@ grcode_user_text
retrieve text for user-defined graph node.
Definition graph.hpp:1222
@ grcode_user_size
calculate node size for user-defined graph.
Definition graph.hpp:1230
@ grcode_viewer_delete_groups
Definition graph.hpp:1326
@ grcode_edge_infos_wrapper_clear
use edge_infos_wrapper_t::clear()
Definition graph.hpp:1335
@ grcode_set_graph_groups
use interactive_graph_t::set_graph_groups()
Definition graph.hpp:1297
@ grcode_calculating_layout
calculating user-defined graph layout.
Definition graph.hpp:1132
@ grcode_lostfocus
a graph viewer lost focus.
Definition graph.hpp:1204
@ grcode_get_viewer_graph
use get_viewer_graph()
Definition graph.hpp:1285
@ grcode_set_node_info
use viewer_set_node_info()
Definition graph.hpp:1320
@ grcode_create_circle_layout
use drawable_graph_t::create_circle_layout()
Definition graph.hpp:1301
@ grcode_user_refresh
refresh user-defined graph nodes and edges This is called when the UI considers that it is necessary ...
Definition graph.hpp:1208
@ grcode_refresh_viewer
use refresh_viewer()
Definition graph.hpp:1288
@ grcode_del_node_info
use viewer_del_node_info()
Definition graph.hpp:1322
@ grcode_layout_calculated
graph layout calculated.
Definition graph.hpp:1137
@ grcode_node_qty
use interactive_graph_t::node_qty()
Definition graph.hpp:1312
@ grcode_get_gli
use viewer_get_gli()
Definition graph.hpp:1342
@ grcode_dblclicked
a graph node has been double clicked.
Definition graph.hpp:1160
@ grcode_clear
use interactive_graph_t::clear()
Definition graph.hpp:1298
@ grcode_edge_infos_wrapper_copy
use edge_infos_wrapper_t::operator=()
Definition graph.hpp:1334
@ grcode_get_node_info
use viewer_get_node_info()
Definition graph.hpp:1321
int layout_type_t
see Proximity view layouts
Definition graph.hpp:369
bool idaapi viewer_get_gli(graph_location_info_t *out, graph_viewer_t *gv, uint32 flags=0)
Get location info for given graph view If flags contains GLICTL_CENTER, then the gli that will be ret...
Definition graph.hpp:1471
interactive_graph_t *idaapi get_viewer_graph(graph_viewer_t *gv)
Get graph object for given custom graph viewer.
Definition graph.hpp:1427
TWidget graph_viewer_t
graph view opaque structure
Definition graph.hpp:1378
qvector< selection_item_t > screen_graph_selection_base_t
Selection in a graph.
Definition graph.hpp:455
bool idaapi viewer_get_node_info(graph_viewer_t *gv, node_info_t *out, int n)
Get node info for node in given viewer (see get_node_info())
Definition graph.hpp:1494
int idaapi viewer_set_titlebar_height(graph_viewer_t *gv, int height)
Set height of node title bars (grcode_set_titlebar_height)
Definition graph.hpp:1588
graph_item_type_t
See graph_item_t.
Definition graph.hpp:513
@ git_text
node text (graph_item_t::n, graph_item_t::p)
Definition graph.hpp:518
@ git_edge
edge (graph_item_t::e, graph_item_t::n. n is farthest edge endpoint)
Definition graph.hpp:515
@ git_none
nothing
Definition graph.hpp:514
@ git_node
node title (graph_item_t::n)
Definition graph.hpp:516
@ git_tool
node title button (graph_item_t::n, graph_item_t::b)
Definition graph.hpp:517
@ git_elp
edge layout point (graph_item_t::elp)
Definition graph.hpp:519
THREAD_SAFE double calc_dist(point_t p, point_t q)
Calculate distance between p and q.
Definition graph.hpp:204
idaman void ida_export del_node_info(graph_id_t gid, int node)
Delete the node_info_t for the given node.
bool idaapi viewer_create_groups(graph_viewer_t *gv, intvec_t *out_group_nodes, const groups_crinfos_t &gi)
This will perform an operation similar to what happens when a user manually selects a set of nodes,...
Definition graph.hpp:1523
void idaapi delete_interactive_graph(interactive_graph_t *g)
Delete graph object.
Definition graph.hpp:1601
ea_t graph_id_t
Graph instances have a unique id (see interactive_graph_t::gid)
Definition graph.hpp:89
idaman void ida_export clr_node_info(graph_id_t gid, int node, uint32 flags)
Clear node info for the given node.
idaman bool ida_export get_node_info(node_info_t *out, graph_id_t gid, int node)
Get node info.
user_graph_place_t * create_user_graph_place(int node, int lnnum)
Get a copy of a user_graph_place_t (returns a pointer to static storage)
Definition graph.hpp:1649
idaman void ida_export set_node_info(graph_id_t gid, int node, const node_info_t &ni, uint32 flags)
Set node info.
void idaapi viewer_set_node_info(graph_viewer_t *gv, int n, const node_info_t &ni, uint32 flags)
Set node info for node in given viewer (see set_node_info())
Definition graph.hpp:1482
bool idaapi viewer_get_selection(graph_viewer_t *gv, screen_graph_selection_t *sgs)
Get currently selected items for graph viewer.
Definition graph.hpp:1578
void idaapi viewer_center_on(graph_viewer_t *gv, int node)
Center the graph view on the given node.
Definition graph.hpp:1452
qvector< row_info_t > graph_row_info_t
vector of row infos
Definition graph.hpp:589
graph_viewer_t *idaapi create_graph_viewer(const char *title, uval_t id, hook_cb_t *callback, void *ud, int title_height, TWidget *parent=nullptr)
Create a custom graph viewer.
Definition graph.hpp:1391
ssize_t grentry(graph_notification_t event_code,...)
Definition graph.hpp:1356
void idaapi set_viewer_graph(graph_viewer_t *gv, interactive_graph_t *g)
Set the underlying graph object for the given viewer.
Definition graph.hpp:1432
void idaapi viewer_del_node_info(graph_viewer_t *gv, int n)
Delete node info for node in given viewer (see del_node_info())
Definition graph.hpp:1505
interactive_graph_t *idaapi create_interactive_graph(uval_t id)
Create a new empty graph with given id.
Definition graph.hpp:1412
qvector< point_t > pointvec_t
Definition graph.hpp:201
void idaapi viewer_fit_window(graph_viewer_t *gv)
Fit graph viewer to its parent form.
Definition graph.hpp:1442
const layout_type_t layout_digraph
Definition graph.hpp:374
const layout_type_t layout_tree
Definition graph.hpp:375
const layout_type_t layout_orthogonal
Definition graph.hpp:378
const layout_type_t layout_radial_tree
Definition graph.hpp:379
const layout_type_t layout_polar_tree
Definition graph.hpp:377
const layout_type_t layout_none
Definition graph.hpp:373
const layout_type_t layout_circle
Definition graph.hpp:376
idaman THREAD_SAFE va_list va
See qsscanf()
Definition err.h:21
va_end(va)
THREAD_SAFE va_start(va, format)
int code
Definition fpro.h:88
idaman size_t n
Definition pro.h:997
cexpr_t * e
Definition hexrays.hpp:7308
@ HT_GRAPH
Handling graph operations (graph_notification_t)
Definition ida.hpp:1309
ssize_t idaapi hook_cb_t(void *user_data, int notification_code, va_list va)
Callback provided to hook_to_notification_point().
Definition ida.hpp:1332
idaman ssize_t ida_export invoke_callbacks(hook_type_t hook_type, int notification_code, va_list va)
Generate event notification.
Contains definition of the interface to IDP modules.
Defines the interface between the kernel and the UI.
uval_t uval_t
Definition kernwin.hpp:1878
QT::QWidget TWidget
Definition kernwin.hpp:2024
bool result
Definition kernwin.hpp:7890
This is the first header included in the IDA project.
idaman size_t const char time_t t
Definition pro.h:602
unsigned int uint32
unsigned 32 bit value
Definition pro.h:348
qvector< int > intvec_t
vector of integers
Definition pro.h:2765
uint32 bgcolor_t
background color in RGB
Definition pro.h:5012
uint64 ea_t
Definition pro.h:421
THREAD_SAFE void qswap(T &a, T &b)
Swap 2 objects of the same type using memory copies.
Definition pro.h:1715
idaman size_t bufsize
Definition pro.h:600
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:381
_qstring< char > qstring
regular string
Definition pro.h:3694
bool operator!=(const TPointDouble &r) const
Definition graph.hpp:365
void sub(const TPointDouble &r)
Definition graph.hpp:349
TPointDouble()
Definition graph.hpp:341
void add(const TPointDouble &r)
Definition graph.hpp:344
void div(T d)
Definition graph.hpp:359
void negate(void)
Definition graph.hpp:354
double x
Definition graph.hpp:339
TPointDouble(const point_t &r)
Definition graph.hpp:343
TPointDouble(double a, double b)
Definition graph.hpp:342
double y
Definition graph.hpp:340
bool operator==(const TPointDouble &r) const
Definition graph.hpp:364
Attributes of a graph edge.
Definition graph.hpp:384
int width
edge width
Definition graph.hpp:386
int srcoff
source: edge port offset from the left
Definition graph.hpp:387
int dstoff
destination: edge port offset from the left
Definition graph.hpp:388
void idaapi add_layout_point(point_t p)
pointseq_t layout
describes geometry of edge
Definition graph.hpp:389
void idaapi reverse_layout(void)
Definition graph.hpp:391
bgcolor_t color
edge color
Definition graph.hpp:385
Definition graph.hpp:785
edge_infos_wrapper_t(const edge_infos_wrapper_t &other)
void clear()
Definition graph.hpp:1633
edge_infos_wrapper_t &idaapi operator=(const edge_infos_wrapper_t &other)
Definition graph.hpp:1627
edge_infos_t * ptr
Definition graph.hpp:792
~edge_infos_wrapper_t()
Definition graph.hpp:789
Edge layout point.
Definition graph.hpp:398
int pidx
index into edge_info_t::layout
Definition graph.hpp:399
edge_t e
parent edge
Definition graph.hpp:400
bool idaapi operator!=(const edge_layout_point_t &r) const
Definition graph.hpp:415
bool idaapi operator==(const edge_layout_point_t &r) const
Definition graph.hpp:411
idaapi edge_layout_point_t()
Definition graph.hpp:401
int idaapi compare(const edge_layout_point_t &r) const
Definition graph.hpp:403
idaapi edge_layout_point_t(const edge_t &_e, int _pidx)
Definition graph.hpp:402
Sub-segment of a graph edge.
Definition graph.hpp:490
edge_t e
Definition graph.hpp:491
bool idaapi toright() const
Definition graph.hpp:495
int nseg
Definition graph.hpp:492
size_t idaapi length() const
Definition graph.hpp:494
int x1
Definition graph.hpp:493
bool idaapi operator<(const edge_segment_t &r) const
Definition graph.hpp:496
int x0
Definition graph.hpp:493
Edge connecting two graph nodes.
Definition gdl.hpp:86
Definition gdl.hpp:100
Definition moves.hpp:17
Path visitor - see drawable_graph_t::visit_paths()
Definition graph.hpp:150
virtual int idaapi walk_forward(int)
Definition graph.hpp:156
intvec_t path
current path
Definition graph.hpp:151
virtual ~graph_path_visitor_t()
Definition graph.hpp:159
bool prune
walk_forward(): prune := true means to stop the current path
Definition graph.hpp:152
virtual int idaapi walk_backward(int)
Definition graph.hpp:157
Definition graph.hpp:1370
intvec_t nodes
Definition graph.hpp:1371
qstring text
Definition graph.hpp:1372
int length(void) const
Definition graph.hpp:573
int x0
Definition graph.hpp:541
bool operator!=(const interval_t &r) const
Definition graph.hpp:576
bool contains(int x) const
Definition graph.hpp:574
interval_t(const edge_segment_t &s)
Definition graph.hpp:568
int x1
Definition graph.hpp:541
bool operator==(const interval_t &r) const
Definition graph.hpp:575
interval_t()
Definition graph.hpp:562
void intersect(const interval_t &r)
Definition graph.hpp:543
void move_by(int shift)
Definition graph.hpp:557
bool empty(void) const
Definition graph.hpp:542
interval_t(int y0, int y1)
Definition graph.hpp:563
void make_union(const interval_t &r)
Definition graph.hpp:550
Information about a node in a graph.
Definition graph.hpp:48
bgcolor_t frame_color
color of enclosing frame
Definition graph.hpp:53
bool valid_flags() const
Has valid flags?
Definition graph.hpp:68
qstring text
node contents
Definition graph.hpp:57
ea_t ea
address
Definition graph.hpp:56
uint32 flags
flags
Definition graph.hpp:55
bgcolor_t bg_color
background color
Definition graph.hpp:52
uint32 get_flags_for_valid() const
Get combination of Node info flags describing which attributes are valid.
Definition graph.hpp:71
bool valid_text() const
Has non-empty text?
Definition graph.hpp:66
bool valid_ea() const
Has valid ea?
Definition graph.hpp:64
bool valid_frame_color() const
Has valid frame_color?
Definition graph.hpp:62
bool valid_bg_color() const
Has valid bg_color?
Definition graph.hpp:60
Coordinate in a graph view.
Definition graph.hpp:165
point_t(const TPoint &p)
Definition graph.hpp:193
void div(T d)
Definition graph.hpp:182
point_t()
Definition graph.hpp:168
point_t & add(const point_t &r)
Definition graph.hpp:170
const char *idaapi dstr(void) const
int x
Definition graph.hpp:166
bool operator!=(const point_t &r) const
Definition graph.hpp:196
point_t(int _x, int _y)
Definition graph.hpp:169
void negate(void)
Definition graph.hpp:187
bool operator==(const point_t &r) const
Definition graph.hpp:195
size_t idaapi print(char *buf, size_t bufsize) const
int y
Definition graph.hpp:167
point_t & sub(const point_t &r)
Definition graph.hpp:176
Vector of range_t instances.
Definition range.hpp:93
A rectangle in a graph view.
Definition graph.hpp:224
int top
Definition graph.hpp:226
void verify(void)
Definition graph.hpp:236
rect_t(const TRect &r)
Definition graph.hpp:330
point_t center(void) const
Definition graph.hpp:258
int area(void) const
Definition graph.hpp:317
point_t topleft(void) const
Definition graph.hpp:262
int height(void) const
Definition graph.hpp:244
void intersect(const rect_t &r)
Definition graph.hpp:277
bool idaapi operator!=(const rect_t &r) const
Definition graph.hpp:325
void move_to(const point_t &p)
Definition graph.hpp:245
void make_union(const rect_t &r)
Definition graph.hpp:288
rect_t()
Definition graph.hpp:229
int left
Definition graph.hpp:225
const TRect & operator()(void) const
Definition graph.hpp:328
int width(void) const
Definition graph.hpp:243
void grow(int delta)
Definition graph.hpp:270
bool is_intersection_empty(const rect_t &r) const
Definition graph.hpp:303
bool idaapi operator==(const rect_t &r) const
Definition graph.hpp:318
bool idaapi operator<(const rect_t &r) const
rect_t(const point_t &p0, const point_t &p1)
Definition graph.hpp:231
point_t bottomright(void) const
Definition graph.hpp:266
TRect & operator()(void)
Definition graph.hpp:329
rect_t(int l, int t, int r, int b)
Definition graph.hpp:230
bool empty(void) const
Definition graph.hpp:299
int bottom
Definition graph.hpp:228
bool contains(const point_t &p) const
Definition graph.hpp:310
void move_by(const point_t &p)
Definition graph.hpp:251
int right
Definition graph.hpp:227
Organize graph nodes by row.
Definition graph.hpp:582
int height(void) const
Definition graph.hpp:587
int bottom
bottom y coord of the row
Definition graph.hpp:585
intvec_t nodes
list of nodes at the row
Definition graph.hpp:583
int top
top y coord of the row
Definition graph.hpp:584
Definition graph.hpp:458
void idaapi sub(const screen_graph_selection_t &s)
Definition graph.hpp:466
size_t idaapi items_count(bool look_for_nodes) const
Definition graph.hpp:478
size_t idaapi nodes_count() const
Definition graph.hpp:476
size_t idaapi points_count() const
Definition graph.hpp:477
void idaapi del_node(int node)
Definition graph.hpp:472
void idaapi del_point(edge_t e, int idx)
Definition graph.hpp:474
void idaapi add(const screen_graph_selection_t &s)
Definition graph.hpp:461
void idaapi add_node(int node)
Definition graph.hpp:471
bool idaapi has(const selection_item_t &item) const
Definition graph.hpp:459
void idaapi add_point(edge_t e, int idx)
Definition graph.hpp:473
Element of a graph selection - could be a node or edge layout point.
Definition graph.hpp:424
bool is_node
represents a selected node?
Definition graph.hpp:425
idaapi selection_item_t(class graph_item_t &)
idaapi selection_item_t(edge_t e, int idx)
Definition graph.hpp:432
bool idaapi operator<(const selection_item_t &r) const
Definition graph.hpp:447
edge_layout_point_t elp
edge layout point (is_node = false)
Definition graph.hpp:427
idaapi selection_item_t()
Definition graph.hpp:428
bool idaapi operator!=(const selection_item_t &r) const
Definition graph.hpp:445
idaapi selection_item_t(edge_layout_point_t &_elp)
Definition graph.hpp:430
bool idaapi operator==(const selection_item_t &r) const
Definition graph.hpp:443
int node
node number (is_node = true)
Definition graph.hpp:426
int idaapi compare(const selection_item_t &r) const
Definition graph.hpp:435
idaapi selection_item_t(int n)
Definition graph.hpp:429
Structure returned by get_custom_viewer_place() if the first parameter is a graph viewer.
Definition graph.hpp:1642
int node
Definition graph.hpp:1643