Public Member Functions | Public Attributes | List of all members
cfunc_t Struct Reference

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

Public Member Functions

 cfunc_t (mbl_array_t *mba)
 
void release (void)
 
void build_c_tree (void)
 Generate the function body. More...
 
void verify (allow_unused_labels_t aul, bool even_without_debugger) const
 Verify the ctree. More...
 
size_t print_dcl (char *buf, int bufsize) const
 Print function prototype. More...
 
size_t print_dcl2 (qstring *out) const
 
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 (void)
 Get vector of local variables. More...
 
sval_t get_stkoff_delta (void)
 Get stack offset delta. More...
 
citem_tfind_label (int label)
 Find the label. More...
 
void remove_unused_labels (void)
 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 (void) const
 Check if there are orphan comments.
 
int del_orphan_cmts (void)
 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 (void) const
 Save user-defined labels into the database.
 
void save_user_cmts (void) const
 Save user-defined comments into the database.
 
void save_user_numforms (void) const
 Save user-defined number formats into the database.
 
void save_user_iflags (void) const
 Save user-defined iflags into the database.
 
void save_user_unions (void) const
 Save user-defined union field selections into the database.
 
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 (void)
 Get information about decompilation warnings. More...
 
eamap_t & get_eamap (void)
 Get pointer to ea->insn map. More...
 
boundaries_t & get_boundaries (void)
 Get pointer to map of instruction boundaries. More...
 
strvec_tget_pseudocode (void)
 Get pointer to decompilation output: the pseudocode. More...
 
bool gather_derefs (const ctree_item_t &ci, udt_type_data_t *udm=NULL) const
 

Public Attributes

ea_t entry_ea
 function entry address
 
mbl_array_tmba
 underlying microcode
 
cinsn_t body
 function body, must be a block
 
intseq_t & argidx
 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_t * user_iflags
 user-defined item flags ctree item iflags bits
 
user_unions_t * user_unions
 user-defined union field selections. More...
 
int refcnt
 reference count to this object. use cfuncptr_t
 
int statebits
 current cfunc_t state. More...
 
eamap_t * eamap
 ea->insn map. use get_eamap
 
boundaries_t * boundaries
 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
 
ctree_items_t treeitems
 vector of ctree items
 

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 2426 of file hexrays.hpp.

Member Function Documentation

void cfunc_t::build_c_tree ( void  )

Generate the function body.

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

Definition at line 5296 of file hexrays.hpp.

References hexdsp.

int cfunc_t::del_orphan_cmts ( void  )

Delete all orphan comments.

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

Definition at line 5388 of file hexrays.hpp.

References hexdsp.

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 5346 of file hexrays.hpp.

References hexdsp.

boundaries_t & cfunc_t::get_boundaries ( void  )

Get pointer to map of instruction boundaries.

This function initializes the boundary map if not done yet.

Definition at line 5424 of file hexrays.hpp.

References hexdsp.

eamap_t & cfunc_t::get_eamap ( void  )

Get pointer to ea->insn map.

This function initializes eamap if not done yet.

Definition at line 5418 of file hexrays.hpp.

References hexdsp.

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 5326 of file hexrays.hpp.

References hexdsp.

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 NULL
pitemptr to the current item. May be NULL
ptailptr to the last item on the line (used to attach indented comments). May be NULL
See also
vdui_t::get_current_item()

Definition at line 5406 of file hexrays.hpp.

References hexdsp.

lvars_t * cfunc_t::get_lvars ( void  )

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 5332 of file hexrays.hpp.

References hexdsp.

strvec_t & cfunc_t::get_pseudocode ( void  )

Get pointer to decompilation output: the pseudocode.

This function generates pseudocode if not done yet.

Definition at line 5430 of file hexrays.hpp.

References hexdsp.

sval_t cfunc_t::get_stkoff_delta ( void  )

Get stack offset delta.

The local variable stack offsets retreived 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 5338 of file hexrays.hpp.

References hexdsp.

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 NULL

Definition at line 5358 of file hexrays.hpp.

References hexdsp.

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 5370 of file hexrays.hpp.

References hexdsp.

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 NULL

Definition at line 5394 of file hexrays.hpp.

References hexdsp.

hexwarns_t & cfunc_t::get_warnings ( void  )

Get information about decompilation warnings.

Returns
reference to the vector of warnings

Definition at line 5412 of file hexrays.hpp.

References hexdsp.

size_t cfunc_t::print_dcl ( char *  buf,
int  bufsize 
) const

Print function prototype.

Parameters
bufoutput buffer
bufsizesize of the output buffer
Returns
length of the generated text

Definition at line 5308 of file hexrays.hpp.

References hexdsp.

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 5320 of file hexrays.hpp.

References hexdsp.

void cfunc_t::remove_unused_labels ( void  )

Remove unused labels.

This function check what labels are really used by the function and removes the unused ones.

Definition at line 5352 of file hexrays.hpp.

References hexdsp.

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 NULL, then an existing comment is deleted.

Definition at line 5364 of file hexrays.hpp.

References hexdsp.

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

Set citem iflags.

Parameters
loccitem locator
iflagsnew iflags

Definition at line 5376 of file hexrays.hpp.

References hexdsp.

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 5400 of file hexrays.hpp.

References hexdsp.

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 5302 of file hexrays.hpp.

References hexdsp.

Member Data Documentation

int cfunc_t::statebits

current cfunc_t state.

see cfunc state bits

Definition at line 2445 of file hexrays.hpp.

user_unions_t* cfunc_t::user_unions

user-defined union field selections.

Definition at line 2439 of file hexrays.hpp.