Latest available version: IDA and decompilers v8.4.240320sp1 see all releases
Hex-Rays logo State-of-the-art binary code analysis tools
email icon

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

#include <hexrays.hpp>

Public Member Functions

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

Public Attributes

ea_t entry_ea
 function entry address More...
 
mba_tmba
 underlying microcode More...
 
cinsn_t body
 function body, must be a block More...
 
intvec_t & argidx
 list of arguments (indexes into vars) More...
 
ctree_maturity_t maturity
 maturity level More...
 
user_labels_tuser_labels
 user-defined labels. More...
 
user_cmts_tuser_cmts
 user-defined comments. More...
 
user_numforms_tnumforms
 user-defined number formats. More...
 
user_iflags_t * user_iflags
 user-defined item flags ctree item iflags bits More...
 
user_unions_t * user_unions
 user-defined union field selections. More...
 
int refcnt
 reference count to this object. use cfuncptr_t More...
 
int statebits
 current cfunc_t state. More...
 
eamap_t * eamap
 ea->insn map. use get_eamap More...
 
boundaries_t * boundaries
 map of instruction boundaries. use get_boundaries More...
 
strvec_t sv
 decompilation output: function text. use get_pseudocode More...
 
int hdrlines
 number of lines in the declaration area More...
 
ctree_items_t treeitems
 vector of ctree items More...
 
char reserved []
 

Detailed Description

Decompiled function. Decompilation result is kept here.

Examples
hexrays_sample2.cpp, hexrays_sample3.cpp, hexrays_sample6.cpp, and hexrays_sample7.cpp.

Definition at line 6946 of file hexrays.hpp.

Constructor & Destructor Documentation

◆ ~cfunc_t()

cfunc_t::~cfunc_t ( )

Definition at line 6982 of file hexrays.hpp.

Member Function Documentation

◆ build_c_tree()

void cfunc_t::build_c_tree ( )

Generate the function body.

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

Definition at line 12119 of file hexrays.hpp.

◆ del_orphan_cmts()

int cfunc_t::del_orphan_cmts ( )

Delete all orphan comments.

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

Definition at line 12205 of file hexrays.hpp.

◆ find_item_coords()

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

Definition at line 12295 of file hexrays.hpp.

◆ find_label()

citem_t * cfunc_t::find_label ( int  label)

Find the label.

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

Definition at line 12163 of file hexrays.hpp.

◆ gather_derefs()

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

Definition at line 12289 of file hexrays.hpp.

◆ get_boundaries()

boundaries_t & cfunc_t::get_boundaries ( )

Get pointer to map of instruction boundaries.

This function initializes the boundary map if not done yet.

Definition at line 12271 of file hexrays.hpp.

◆ get_eamap()

eamap_t & cfunc_t::get_eamap ( )

Get pointer to ea->insn map.

This function initializes eamap if not done yet.

Definition at line 12265 of file hexrays.hpp.

◆ get_func_type()

bool cfunc_t::get_func_type ( tinfo_t *  type) const

Get the function type.

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

Definition at line 12143 of file hexrays.hpp.

◆ 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 
)

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()

Definition at line 12253 of file hexrays.hpp.

◆ get_lvars()

lvars_t * cfunc_t::get_lvars ( )

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.

Definition at line 12149 of file hexrays.hpp.

◆ get_pseudocode()

const strvec_t & cfunc_t::get_pseudocode ( )

Get pointer to decompilation output: the pseudocode.

This function generates pseudocode if not done yet.

Definition at line 12277 of file hexrays.hpp.

◆ get_stkoff_delta()

sval_t cfunc_t::get_stkoff_delta ( )

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()

Definition at line 12155 of file hexrays.hpp.

◆ get_user_cmt()

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

Retrieve a user defined comment.

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

Definition at line 12175 of file hexrays.hpp.

◆ get_user_iflags()

int32 cfunc_t::get_user_iflags ( const citem_locator_t loc) const

Retrieve citem iflags.

Parameters
loccitem locator
Returns
ctree item iflags bits or 0

Definition at line 12187 of file hexrays.hpp.

◆ get_user_union_selection()

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

Retrieve a user defined union field selection.

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

Definition at line 12211 of file hexrays.hpp.

◆ get_warnings()

hexwarns_t & cfunc_t::get_warnings ( )

Get information about decompilation warnings.

Returns
reference to the vector of warnings

Definition at line 12259 of file hexrays.hpp.

◆ has_orphan_cmts()

bool cfunc_t::has_orphan_cmts ( ) const

Check if there are orphan comments.

Definition at line 12199 of file hexrays.hpp.

◆ locked()

bool cfunc_t::locked ( ) const

Definition at line 7128 of file hexrays.hpp.

◆ print_dcl()

void cfunc_t::print_dcl ( qstring *  vout) const

Print function prototype.

Parameters
voutoutput buffer

Definition at line 12131 of file hexrays.hpp.

◆ print_func()

void cfunc_t::print_func ( vc_printer_t vp) const

Print function text.

Parameters
vpprinter helper class to receive the generated text.

Definition at line 12137 of file hexrays.hpp.

◆ refresh_func_ctext()

void cfunc_t::refresh_func_ctext ( )

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.

Definition at line 12283 of file hexrays.hpp.

◆ release()

void cfunc_t::release ( )

Definition at line 6983 of file hexrays.hpp.

◆ remove_unused_labels()

void cfunc_t::remove_unused_labels ( )

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.

Definition at line 12169 of file hexrays.hpp.

◆ save_user_cmts()

void cfunc_t::save_user_cmts ( ) const

Save user-defined comments into the database.

Definition at line 12229 of file hexrays.hpp.

◆ save_user_iflags()

void cfunc_t::save_user_iflags ( ) const

Save user-defined iflags into the database.

Definition at line 12241 of file hexrays.hpp.

◆ save_user_labels()

void cfunc_t::save_user_labels ( ) const

Save user-defined labels into the database.

Definition at line 12223 of file hexrays.hpp.

◆ save_user_numforms()

void cfunc_t::save_user_numforms ( ) const

Save user-defined number formats into the database.

Definition at line 12235 of file hexrays.hpp.

◆ save_user_unions()

void cfunc_t::save_user_unions ( ) const

Save user-defined union field selections into the database.

Definition at line 12247 of file hexrays.hpp.

◆ set_user_cmt()

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

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.

Definition at line 12181 of file hexrays.hpp.

◆ set_user_iflags()

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

Set citem iflags.

Parameters
loccitem locator
iflagsnew iflags

Definition at line 12193 of file hexrays.hpp.

◆ set_user_union_selection()

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

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.

Definition at line 12217 of file hexrays.hpp.

◆ verify()

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

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

Definition at line 12125 of file hexrays.hpp.

Member Data Documentation

◆ argidx

intvec_t& cfunc_t::argidx

list of arguments (indexes into vars)

Definition at line 6951 of file hexrays.hpp.

◆ body

cinsn_t cfunc_t::body

function body, must be a block

Examples
hexrays_sample2.cpp, hexrays_sample3.cpp, and hexrays_sample7.cpp.

Definition at line 6950 of file hexrays.hpp.

◆ boundaries

boundaries_t* cfunc_t::boundaries

map of instruction boundaries. use get_boundaries

Definition at line 6972 of file hexrays.hpp.

◆ eamap

eamap_t* cfunc_t::eamap

ea->insn map. use get_eamap

Definition at line 6971 of file hexrays.hpp.

◆ entry_ea

ea_t cfunc_t::entry_ea

function entry address

Definition at line 6948 of file hexrays.hpp.

◆ hdrlines

int cfunc_t::hdrlines

number of lines in the declaration area

Definition at line 6974 of file hexrays.hpp.

◆ maturity

ctree_maturity_t cfunc_t::maturity

maturity level

Definition at line 6952 of file hexrays.hpp.

◆ mba

mba_t* cfunc_t::mba

underlying microcode

Definition at line 6949 of file hexrays.hpp.

◆ numforms

user_numforms_t* cfunc_t::numforms

user-defined number formats.

Definition at line 6957 of file hexrays.hpp.

◆ refcnt

int cfunc_t::refcnt

reference count to this object. use cfuncptr_t

Definition at line 6964 of file hexrays.hpp.

◆ reserved

char cfunc_t::reserved[]

Definition at line 6978 of file hexrays.hpp.

◆ statebits

int cfunc_t::statebits

current cfunc_t state.

see cfunc state bits

Definition at line 6965 of file hexrays.hpp.

◆ sv

strvec_t cfunc_t::sv

decompilation output: function text. use get_pseudocode

Examples
hexrays_sample6.cpp.

Definition at line 6973 of file hexrays.hpp.

◆ treeitems

ctree_items_t cfunc_t::treeitems
mutable

vector of ctree items

Definition at line 6975 of file hexrays.hpp.

◆ user_cmts

user_cmts_t* cfunc_t::user_cmts

user-defined comments.

Definition at line 6956 of file hexrays.hpp.

◆ user_iflags

user_iflags_t* cfunc_t::user_iflags

user-defined item flags ctree item iflags bits

Definition at line 6958 of file hexrays.hpp.

◆ user_labels

user_labels_t* cfunc_t::user_labels

user-defined labels.

Definition at line 6955 of file hexrays.hpp.

◆ user_unions

user_unions_t* cfunc_t::user_unions

user-defined union field selections.

Definition at line 6959 of file hexrays.hpp.