IDA C++ SDK 9.2
Loading...
Searching...
No Matches
cfunc_t Struct Reference

Decompiled function. Decompilation result is kept here. More...

#include <hexrays.hpp>

Public Member Functions

 cfunc_t (mba_t *mba)
 ~cfunc_t ()
void release ()
 HEXRAYS_MEMORY_ALLOCATION_FUNCS () void hexapi build_c_tree()
 Generate the function body.
void hexapi verify (allow_unused_labels_t aul, bool even_without_debugger) const
 Verify the ctree.
void hexapi print_dcl (qstring *vout) const
 Print function prototype.
void hexapi print_func (vc_printer_t &vp) const
 Print function text.
bool hexapi get_func_type (tinfo_t *type) const
 Get the function type.
lvars_t *hexapi get_lvars ()
 Get vector of local variables.
sval_t hexapi get_stkoff_delta ()
 Get stack offset delta.
citem_t *hexapi find_label (int label)
 Find the label.
void hexapi remove_unused_labels ()
 Remove unused labels.
const char *hexapi get_user_cmt (const treeloc_t &loc, cmt_retrieval_type_t rt) const
 Retrieve a user defined comment.
void hexapi set_user_cmt (const treeloc_t &loc, const char *cmt)
 Set a user defined comment.
int32 hexapi get_user_iflags (const citem_locator_t &loc) const
 Retrieve citem iflags.
void hexapi set_user_iflags (const citem_locator_t &loc, int32 iflags)
 Set citem iflags.
bool hexapi has_orphan_cmts () const
 Check if there are orphan comments.
int hexapi del_orphan_cmts ()
 Delete all orphan comments.
bool hexapi get_user_union_selection (ea_t ea, intvec_t *path)
 Retrieve a user defined union field selection.
void hexapi set_user_union_selection (ea_t ea, const intvec_t &path)
 Set a union field selection.
void hexapi save_user_labels () const
 Save user-defined labels into the database.
void hexapi save_user_cmts () const
 Save user-defined comments into the database.
void hexapi save_user_numforms () const
 Save user-defined number formats into the database.
void hexapi save_user_iflags () const
 Save user-defined iflags into the database.
void hexapi save_user_unions () const
 Save user-defined union field selections into the database.
bool hexapi get_line_item (const char *line, int x, bool is_ctree_line, ctree_item_t *phead, ctree_item_t *pitem, ctree_item_t *ptail)
 Get ctree item for the specified cursor position.
hexwarns_t &hexapi get_warnings ()
 Get information about decompilation warnings.
eamap_t &hexapi get_eamap ()
 Get pointer to ea->insn map.
boundaries_t &hexapi get_boundaries ()
 Get pointer to map of instruction boundaries.
const strvec_t &hexapi get_pseudocode ()
 Get pointer to decompilation output: the pseudocode.
void hexapi refresh_func_ctext ()
 Refresh ctext after a ctree modification.
void hexapi recalc_item_addresses ()
 Recalculate item adresses.
bool hexapi gather_derefs (const ctree_item_t &ci, udt_type_data_t *udm=nullptr) const
bool hexapi find_item_coords (const citem_t *item, int *px, int *py)
bool locked () const

Public Attributes

ea_t entry_ea
 function entry address
mba_tmba
 underlying microcode
cinsn_t body
 function body, must be a block
intvec_targidx
 list of arguments (indexes into vars)
ctree_maturity_t maturity
 maturity level
user_labels_tuser_labels
 user-defined labels.
user_cmts_tuser_cmts
 user-defined comments.
user_numforms_tnumforms
 user-defined number formats.
user_iflags_tuser_iflags
 user-defined item flags ctree item iflags bits
user_unions_tuser_unions
 user-defined union field selections.
int refcnt
 reference count to this object. use cfuncptr_t
int statebits
 current cfunc_t state.
eamap_teamap
 ea->insn map. use get_eamap
boundaries_tboundaries
 map of instruction boundaries. use get_boundaries
strvec_t sv
 decompilation output: function text. use get_pseudocode
int hdrlines
 number of lines in the declaration area
citem_pointers_t treeitems
 vector of pointers to citem_t objects (nodes constituting the ctree)
char reserved []

Detailed Description

Decompiled function. Decompilation result is kept here.

Constructor & Destructor Documentation

◆ cfunc_t()

cfunc_t::cfunc_t ( mba_t * mba)

◆ ~cfunc_t()

cfunc_t::~cfunc_t ( )
inline

Member Function Documentation

◆ release()

void cfunc_t::release ( )
inline

◆ HEXRAYS_MEMORY_ALLOCATION_FUNCS()

cfunc_t::HEXRAYS_MEMORY_ALLOCATION_FUNCS ( )

Generate the function body.

This function (re)generates the function body from the underlying microcode.

◆ verify()

void cfunc_t::verify ( allow_unused_labels_t aul,
bool even_without_debugger ) const
inline

Verify the ctree.

This function verifies the ctree. If the ctree is malformed, an internal error is generated. Use it to verify the ctree after your modifications.

Parameters
aulAre unused labels acceptable?
even_without_debuggerif false and there is no debugger, the verification will be skipped

◆ print_dcl()

void cfunc_t::print_dcl ( qstring * vout) const
inline

Print function prototype.

Parameters
voutoutput buffer

◆ print_func()

void cfunc_t::print_func ( vc_printer_t & vp) const
inline

Print function text.

Parameters
vpprinter helper class to receive the generated text.

◆ get_func_type()

bool cfunc_t::get_func_type ( tinfo_t * type) const
inline

Get the function type.

Parameters
typevariable where the function type is returned
Returns
false if failure

◆ get_lvars()

lvars_t * cfunc_t::get_lvars ( )
inline

Get vector of local variables.

Returns
pointer to the vector of local variables. If you modify this vector, the ctree must be regenerated in order to have correct cast operators. Use build_c_tree() for that. Removing lvars should be done carefully: all references in ctree and microcode must be corrected after that.

◆ get_stkoff_delta()

sval_t cfunc_t::get_stkoff_delta ( )
inline

Get stack offset delta.

The local variable stack offsets retrieved by v.location.stkoff() should be adjusted before being used as stack frame offsets in IDA.

Returns
the delta to apply. example: ida_stkoff = v.location.stkoff() - f->get_stkoff_delta()

◆ find_label()

citem_t * cfunc_t::find_label ( int label)
inline

Find the label.

Returns
pointer to the ctree item with the specified label number.

◆ remove_unused_labels()

void cfunc_t::remove_unused_labels ( )
inline

Remove unused labels.

This function checks what labels are really used by the function and removes the unused ones. You must call it after deleting a goto statement.

◆ get_user_cmt()

const char * cfunc_t::get_user_cmt ( const treeloc_t & loc,
cmt_retrieval_type_t rt ) const
inline

Retrieve a user defined comment.

Parameters
locctree location
rtshould already retrieved comments retrieved again?
Returns
pointer to the comment string or nullptr

◆ set_user_cmt()

void cfunc_t::set_user_cmt ( const treeloc_t & loc,
const char * cmt )
inline

Set a user defined comment.

This function stores the specified comment in the cfunc_t structure. The save_user_cmts() function must be called after it.

Parameters
locctree location
cmtnew comment. if empty or nullptr, then an existing comment is deleted.

◆ get_user_iflags()

int32 cfunc_t::get_user_iflags ( const citem_locator_t & loc) const
inline

Retrieve citem iflags.

Parameters
loccitem locator
Returns
ctree item iflags bits or 0

◆ set_user_iflags()

void cfunc_t::set_user_iflags ( const citem_locator_t & loc,
int32 iflags )
inline

Set citem iflags.

Parameters
loccitem locator
iflagsnew iflags

◆ has_orphan_cmts()

bool cfunc_t::has_orphan_cmts ( ) const
inline

Check if there are orphan comments.

◆ del_orphan_cmts()

int cfunc_t::del_orphan_cmts ( )
inline

Delete all orphan comments.

The save_user_cmts() function must be called after this call.

◆ get_user_union_selection()

bool cfunc_t::get_user_union_selection ( ea_t ea,
intvec_t * path )
inline

Retrieve a user defined union field selection.

Parameters
eaaddress
pathout: path describing the union selection.
Returns
pointer to the path or nullptr

◆ set_user_union_selection()

void cfunc_t::set_user_union_selection ( ea_t ea,
const intvec_t & path )
inline

Set a union field selection.

The save_user_unions() function must be called after calling this function.

Parameters
eaaddress
pathin: path describing the union selection.

◆ save_user_labels()

void cfunc_t::save_user_labels ( ) const
inline

Save user-defined labels into the database.

◆ save_user_cmts()

void cfunc_t::save_user_cmts ( ) const
inline

Save user-defined comments into the database.

◆ save_user_numforms()

void cfunc_t::save_user_numforms ( ) const
inline

Save user-defined number formats into the database.

◆ save_user_iflags()

void cfunc_t::save_user_iflags ( ) const
inline

Save user-defined iflags into the database.

◆ save_user_unions()

void cfunc_t::save_user_unions ( ) const
inline

Save user-defined union field selections into the database.

◆ get_line_item()

bool cfunc_t::get_line_item ( const char * line,
int x,
bool is_ctree_line,
ctree_item_t * phead,
ctree_item_t * pitem,
ctree_item_t * ptail )
inline

Get ctree item for the specified cursor position.

Returns
false if failed to get the current item
Parameters
lineline of decompilation text (element of sv)
xx cursor coordinate in the line
is_ctree_linedoes the line belong to statement area? (if not, it is assumed to belong to the declaration area)
pheadptr to the first item on the line (used to attach block comments). May be nullptr
pitemptr to the current item. May be nullptr
ptailptr to the last item on the line (used to attach indented comments). May be nullptr
See also
vdui_t::get_current_item()

◆ get_warnings()

hexwarns_t & cfunc_t::get_warnings ( )
inline

Get information about decompilation warnings.

Returns
reference to the vector of warnings

◆ get_eamap()

eamap_t & cfunc_t::get_eamap ( )
inline

Get pointer to ea->insn map.

This function initializes eamap if not done yet.

◆ get_boundaries()

boundaries_t & cfunc_t::get_boundaries ( )
inline

Get pointer to map of instruction boundaries.

This function initializes the boundary map if not done yet.

◆ get_pseudocode()

const strvec_t & cfunc_t::get_pseudocode ( )
inline

Get pointer to decompilation output: the pseudocode.

This function generates pseudocode if not done yet.

◆ refresh_func_ctext()

void cfunc_t::refresh_func_ctext ( )
inline

Refresh ctext after a ctree modification.

This function informs the decompiler that ctree (body) have been modified and ctext (sv) does not correspond to it anymore. It also refreshes the pseudocode windows if there is any.

◆ recalc_item_addresses()

void cfunc_t::recalc_item_addresses ( )
inline

Recalculate item adresses.

This function may be required after shuffling ctree items. For example, when adding or removing statements of a block, or changing 'if' statements.

◆ gather_derefs()

bool cfunc_t::gather_derefs ( const ctree_item_t & ci,
udt_type_data_t * udm = nullptr ) const
inline

◆ find_item_coords()

bool cfunc_t::find_item_coords ( const citem_t * item,
int * px,
int * py )
inline

◆ locked()

bool cfunc_t::locked ( ) const
inline

Member Data Documentation

◆ entry_ea

ea_t cfunc_t::entry_ea

function entry address

◆ mba

mba_t* cfunc_t::mba

underlying microcode

◆ body

cinsn_t cfunc_t::body

function body, must be a block

◆ argidx

intvec_t& cfunc_t::argidx

list of arguments (indexes into vars)

◆ maturity

ctree_maturity_t cfunc_t::maturity

maturity level

◆ user_labels

user_labels_t* cfunc_t::user_labels

user-defined labels.

◆ user_cmts

user_cmts_t* cfunc_t::user_cmts

user-defined comments.

◆ numforms

user_numforms_t* cfunc_t::numforms

user-defined number formats.

◆ user_iflags

user_iflags_t* cfunc_t::user_iflags

user-defined item flags ctree item iflags bits

◆ user_unions

user_unions_t* cfunc_t::user_unions

user-defined union field selections.

◆ refcnt

int cfunc_t::refcnt

reference count to this object. use cfuncptr_t

◆ statebits

int cfunc_t::statebits

current cfunc_t state.

see cfunc state bits

◆ eamap

eamap_t* cfunc_t::eamap

ea->insn map. use get_eamap

◆ boundaries

boundaries_t* cfunc_t::boundaries

map of instruction boundaries. use get_boundaries

◆ sv

strvec_t cfunc_t::sv

decompilation output: function text. use get_pseudocode

◆ hdrlines

int cfunc_t::hdrlines

number of lines in the declaration area

◆ treeitems

citem_pointers_t cfunc_t::treeitems
mutable

vector of pointers to citem_t objects (nodes constituting the ctree)

◆ reserved

char cfunc_t::reserved[]

The documentation for this struct was generated from the following file: