ida_gdl

Low level graph drawing operations.

Attributes

SWIG_PYTHON_LEGACY_BOOL

fcb_normal

normal block

fcb_indjump

block ends with indirect jump

fcb_ret

return block

fcb_cndret

conditional return block

fcb_noret

noreturn block

fcb_enoret

external noreturn block (does not belong to the function)

fcb_extern

external normal block

fcb_error

block passes execution past the function end

EDGE_NONE

EDGE_TREE

EDGE_FORWARD

EDGE_BACK

EDGE_CROSS

EDGE_SUBGRAPH

CHART_PRINT_NAMES

print labels for each block?

CHART_GEN_DOT

generate .dot file (file extension is forced to .dot)

CHART_GEN_GDL

generate .gdl file (file extension is forced to .gdl)

CHART_WINGRAPH

call grapher to display the graph

CHART_NOLIBFUNCS

don't include library functions in the graph

CHART_REFERENCING

references to the addresses in the list

CHART_REFERENCED

references from the addresses in the list

CHART_RECURSIVE

analyze added blocks

CHART_FOLLOW_DIRECTION

analyze references to added blocks only in the direction of the reference who discovered the current block

CHART_IGNORE_XTRN

CHART_IGNORE_DATA_BSS

CHART_IGNORE_LIB_TO

ignore references to library functions

CHART_IGNORE_LIB_FROM

ignore references from library functions

CHART_PRINT_COMMENTS

CHART_PRINT_DOTS

print dots if xrefs exist outside of the range recursion depth

FC_PRINT

print names (used only by display_flow_chart())

FC_NOEXT

do not compute external blocks. Use this to prevent jumps leaving the function from appearing in the flow chart. Unless specified, the targets of those outgoing jumps will be present in the flow chart under the form of one-instruction blocks

FC_RESERVED

former FC_PREDS

FC_APPND

multirange flowchart (set by append_to_flowchart)

FC_CHKBREAK

build_qflow_chart() may be aborted by user

FC_CALL_ENDS

call instructions terminate basic blocks

FC_NOPREDS

do not compute predecessor lists

FC_OUTLINES

include outlined code (with FUNC_OUTLINE)

FC_PREDS

Classes

edge_t

edgevec_t

node_ordering_t

node_iterator

gdl_graph_t

cancellable_graph_t

qbasic_block_t

qflow_chart_t

BasicBlock

Basic block class. It is returned by the Flowchart class

FlowChart

Flowchart class used to determine basic blocks.

Functions

gen_gdl(→ None)

Create GDL file for graph.

display_gdl(→ int)

Display GDL file by calling wingraph32. The exact name of the grapher is taken from the configuration file and set up by setup_graph_subsystem(). The path should point to a temporary file: when wingraph32 succeeds showing the graph, the input file will be deleted.

gen_flow_graph(→ bool)

Build and display a flow graph.

gen_simple_call_chart(→ bool)

Build and display a simple function call graph.

gen_complex_call_chart(→ bool)

Build and display a complex xref graph.

is_noret_block(→ bool)

Does this block never return?

is_ret_block(→ bool)

Does this block return?

Module Contents

ida_gdl.SWIG_PYTHON_LEGACY_BOOL
ida_gdl.fcb_normal

normal block

ida_gdl.fcb_indjump

block ends with indirect jump

ida_gdl.fcb_ret

return block

ida_gdl.fcb_cndret

conditional return block

ida_gdl.fcb_noret

noreturn block

ida_gdl.fcb_enoret

external noreturn block (does not belong to the function)

ida_gdl.fcb_extern

external normal block

ida_gdl.fcb_error

block passes execution past the function end

class ida_gdl.edge_t(x: int = 0, y: int = 0)

Bases: object

thisown
src: int

source node number

dst: int

destination node number

class ida_gdl.edgevec_t

Bases: object

thisown
ida_gdl.EDGE_NONE
ida_gdl.EDGE_TREE
ida_gdl.EDGE_FORWARD
ida_gdl.EDGE_BACK
ida_gdl.EDGE_CROSS
ida_gdl.EDGE_SUBGRAPH
class ida_gdl.node_ordering_t

Bases: object

thisown
clear() None
resize(n: int) None
size() size_t
set(_node: int, num: int) None
clr(_node: int) bool
node(_order: size_t) int
order(_node: int) int
class ida_gdl.node_iterator(_g: gdl_graph_t, n: int)

Bases: object

thisown
class ida_gdl.gdl_graph_t

Bases: object

thisown
get_node_label(n: int) char *
print_graph_attributes(fp: FILE *) None
print_node(fp: FILE *, n: int) bool
print_edge(fp: FILE *, i: int, j: int) bool
print_node_attributes(fp: FILE *, n: int) None
size() int
node_qty() int
exists(node: int) bool
entry() int
exit() int
nsucc(node: int) int
npred(node: int) int
succ(node: int, i: int) int
pred(node: int, i: int) int
empty() bool
get_node_color(n: int) bgcolor_t
get_edge_color(i: int, j: int) bgcolor_t
nedge(node: int, ispred: bool) size_t
edge(node: int, i: int, ispred: bool) int
front() int
begin() node_iterator
end() node_iterator
ida_gdl.gen_gdl(g: gdl_graph_t, fname: str) None

Create GDL file for graph.

ida_gdl.display_gdl(fname: str) int

Display GDL file by calling wingraph32. The exact name of the grapher is taken from the configuration file and set up by setup_graph_subsystem(). The path should point to a temporary file: when wingraph32 succeeds showing the graph, the input file will be deleted.

Returns:

error code from os, 0 if ok

ida_gdl.gen_flow_graph(filename: str, title: str, pfn: func_t *, ea1: ida_idaapi.ea_t, ea2: ida_idaapi.ea_t, gflags: int) bool

Build and display a flow graph.

Parameters:
  • filename – output file name. the file extension is not used. maybe nullptr.

  • title – graph title

  • pfn – function to graph

  • ea1 – if pfn == nullptr, then the address range

  • ea2 – if pfn == nullptr, then the address range

  • gflags – combination of Flow graph building flags. if none of CHART_GEN_DOT, CHART_GEN_GDL, CHART_WINGRAPH is specified, the function will return false

Returns:

success. if fails, a warning message is displayed on the screen

ida_gdl.CHART_PRINT_NAMES

print labels for each block?

ida_gdl.CHART_GEN_DOT

generate .dot file (file extension is forced to .dot)

ida_gdl.CHART_GEN_GDL

generate .gdl file (file extension is forced to .gdl)

ida_gdl.CHART_WINGRAPH

call grapher to display the graph

ida_gdl.gen_simple_call_chart(filename: str, wait: str, title: str, gflags: int) bool

Build and display a simple function call graph.

Parameters:
  • filename – output file name. the file extension is not used. maybe nullptr.

  • wait – message to display during graph building

  • title – graph title

  • gflags – combination of CHART_NOLIBFUNCS and Flow graph building flags. if none of CHART_GEN_DOT, CHART_GEN_GDL, CHART_WINGRAPH is specified, the function will return false.

Returns:

success. if fails, a warning message is displayed on the screen

ida_gdl.gen_complex_call_chart(filename: str, wait: str, title: str, ea1: ida_idaapi.ea_t, ea2: ida_idaapi.ea_t, flags: int, recursion_depth: int = -1) bool

Build and display a complex xref graph.

Parameters:
  • filename – output file name. the file extension is not used. maybe nullptr.

  • wait – message to display during graph building

  • title – graph title

  • ea1 – address range

  • ea2 – address range

  • flags – combination of Call chart building flags and Flow graph building flags. if none of CHART_GEN_DOT, CHART_GEN_GDL, CHART_WINGRAPH is specified, the function will return false.

  • recursion_depth – optional limit of recursion

Returns:

success. if fails, a warning message is displayed on the screen

ida_gdl.CHART_NOLIBFUNCS

don’t include library functions in the graph

ida_gdl.CHART_REFERENCING

references to the addresses in the list

ida_gdl.CHART_REFERENCED

references from the addresses in the list

ida_gdl.CHART_RECURSIVE

analyze added blocks

ida_gdl.CHART_FOLLOW_DIRECTION

analyze references to added blocks only in the direction of the reference who discovered the current block

ida_gdl.CHART_IGNORE_XTRN
ida_gdl.CHART_IGNORE_DATA_BSS
ida_gdl.CHART_IGNORE_LIB_TO

ignore references to library functions

ida_gdl.CHART_IGNORE_LIB_FROM

ignore references from library functions

ida_gdl.CHART_PRINT_COMMENTS
ida_gdl.CHART_PRINT_DOTS

print dots if xrefs exist outside of the range recursion depth

class ida_gdl.cancellable_graph_t

Bases: gdl_graph_t

thisown
cancelled: bool
class ida_gdl.qbasic_block_t

Bases: ida_range.range_t

thisown
ida_gdl.is_noret_block(btype: fc_block_type_t) bool

Does this block never return?

ida_gdl.is_ret_block(btype: fc_block_type_t) bool

Does this block return?

ida_gdl.FC_PRINT

print names (used only by display_flow_chart())

ida_gdl.FC_NOEXT

do not compute external blocks. Use this to prevent jumps leaving the function from appearing in the flow chart. Unless specified, the targets of those outgoing jumps will be present in the flow chart under the form of one-instruction blocks

ida_gdl.FC_RESERVED

former FC_PREDS

ida_gdl.FC_APPND

multirange flowchart (set by append_to_flowchart)

ida_gdl.FC_CHKBREAK

build_qflow_chart() may be aborted by user

ida_gdl.FC_CALL_ENDS

call instructions terminate basic blocks

ida_gdl.FC_NOPREDS

do not compute predecessor lists

ida_gdl.FC_OUTLINES

include outlined code (with FUNC_OUTLINE)

class ida_gdl.qflow_chart_t(*args)

Bases: cancellable_graph_t

thisown
title: str
bounds: range_t

overall bounds of the qflow_chart_t instance

pfn: func_t *

the function this instance was built upon

flags: int

flags. See Flow chart flags

nproper: int

number of basic blocks belonging to the specified range

create(*args) None

This function has the following signatures:

  1. create(_title: str, _pfn: func_t *, _ea1: ida_idaapi.ea_t, _ea2: ida_idaapi.ea_t, _flags: int) -> None

  2. create(_title: str, ranges: const rangevec_t &, _flags: int) -> None

# 0: create(_title: str, _pfn: func_t *, _ea1: ida_idaapi.ea_t, _ea2: ida_idaapi.ea_t, _flags: int) -> None

# 1: create(_title: str, ranges: const rangevec_t &, _flags: int) -> None

append_to_flowchart(ea1: ida_idaapi.ea_t, ea2: ida_idaapi.ea_t) None
refresh() None
calc_block_type(blknum: size_t) fc_block_type_t
is_ret_block(blknum: size_t) bool
is_noret_block(blknum: size_t) bool
print_node_attributes(fp: FILE *, n: int) None
nsucc(node: int) int
npred(node: int) int
succ(node: int, i: int) int
pred(node: int, i: int) int
get_node_label(*args) char *
size() int
print_names() bool
class ida_gdl.BasicBlock(id, bb, fc)

Bases: object

Basic block class. It is returned by the Flowchart class

id

Basic block ID

start_ea

start_ea of basic block

end_ea

end_ea of basic block

type

Block type (check fc_block_type_t enum)

preds()

Iterates the predecessors list

succs()

Iterates the successors list

class ida_gdl.FlowChart(f=None, bounds=None, flags=0)

Bases: object

Flowchart class used to determine basic blocks. Check ex_gdl_qflow_chart.py for sample usage.

size

Number of blocks in the flow chart

refresh()

Refreshes the flow chart

ida_gdl.FC_PREDS = 0