Hex-Rays logo State-of-the-art binary code analysis tools
email icon

Information about the pseudocode window. More...

#include <hexrays.hpp>

Public Member Functions

bool visible (void) const
 Is the pseudocode window visible? if not, it might be invisible or destroyed. More...
 
bool valid (void) const
 Does the pseudocode window contain valid code? It can become invalid if the function type gets changed in IDA. More...
 
bool locked (void) const
 Does the pseudocode window contain valid code? We lock windows before modifying them, to avoid recursion due to the events generated by the IDA kernel. More...
 
void set_visible (bool v)
 
void set_valid (bool v)
 
bool set_locked (bool v)
 
void refresh_view (bool redo_mba)
 Refresh pseudocode window. More...
 
void refresh_ctext (bool activate=true)
 Refresh pseudocode window. More...
 
void switch_to (cfuncptr_t f, bool activate)
 Display the specified pseudocode. More...
 
bool in_ctree (void) const
 Is the current item a statement? More...
 
cnumber_tget_number (void)
 Get current number. More...
 
int get_current_label (void)
 Get current label. More...
 
void clear (void)
 Clear the pseudocode window. More...
 
bool refresh_cpos (input_device_t idv)
 Refresh the current position. More...
 
bool get_current_item (input_device_t idv)
 Get current item. More...
 
bool ui_rename_lvar (lvar_t *v)
 Rename local variable. More...
 
bool rename_lvar (lvar_t *v, const char *name, bool is_user_name)
 Rename local variable. More...
 
bool ui_set_call_type (const cexpr_t *e)
 Set type of a function call This function displays a dialog box and allows the user to change the type of a function call. More...
 
bool ui_set_lvar_type (lvar_t *v)
 Set local variable type. More...
 
bool set_lvar_type (lvar_t *v, const tinfo_t &type)
 Set local variable type. More...
 
bool set_noptr_lvar (lvar_t *v)
 Inform that local variable should have a non-pointer type This function permanently sets a corresponding variable flag (NOPTR) and removes type if it was set before by function 'set_lvar_type'. More...
 
bool ui_edit_lvar_cmt (lvar_t *v)
 Set local variable comment. More...
 
bool set_lvar_cmt (lvar_t *v, const char *cmt)
 Set local variable comment. More...
 
bool ui_map_lvar (lvar_t *v)
 Map a local variable to another. More...
 
bool ui_unmap_lvar (lvar_t *v)
 Unmap a local variable. More...
 
bool map_lvar (lvar_t *from, lvar_t *to)
 Map a local variable to another. More...
 
bool set_strmem_type (struc_t *sptr, member_t *mptr)
 Set structure field type. More...
 
bool rename_strmem (struc_t *sptr, member_t *mptr)
 Rename structure field. More...
 
bool set_global_type (ea_t ea)
 Set global item type. More...
 
bool rename_global (ea_t ea)
 Rename global item. More...
 
bool rename_label (int label)
 Rename a label. More...
 
bool jump_enter (input_device_t idv, int omflags)
 Process the Enter key. More...
 
bool ctree_to_disasm (void)
 Jump to disassembly. More...
 
cmt_type_t calc_cmt_type (size_t lnnum, cmt_type_t cmttype) const
 Check if the specified line can have a comment. More...
 
bool edit_cmt (const treeloc_t &loc)
 Edit an indented comment. More...
 
bool edit_func_cmt (void)
 Edit a function comment. More...
 
bool del_orphan_cmts (void)
 Delete all orphan comments. More...
 
bool set_num_radix (int base)
 Change number base. More...
 
bool set_num_enum (void)
 Convert number to symbolic constant. More...
 
bool set_num_stroff (void)
 Convert number to structure field offset. More...
 
bool invert_sign (void)
 Negate a number. More...
 
bool invert_bits (void)
 Bitwise negate a number. More...
 
bool collapse_item (bool hide)
 Collapse/uncollapse item. More...
 
bool collapse_lvars (bool hide)
 Collapse/uncollapse local variable declarations. More...
 
bool split_item (bool split)
 Split/unsplit item. More...
 

Public Attributes

int flags
 Properties of pseudocode window More...
 
int view_idx
 pseudocode window index (0..) More...
 
TWidgetct
 pseudocode view More...
 
TWidgettoplevel
 
mba_tmba
 pointer to underlying microcode More...
 
cfuncptr_t cfunc
 pointer to function object More...
 
merror_t last_code
 result of the last user action. See Microcode error codes More...
 
ctext_position_t cpos
 Current ctext position. More...
 
ctree_item_t head
 First ctree item on the current line (for block comments) More...
 
ctree_item_t item
 Current ctree item. More...
 
ctree_item_t tail
 Tail ctree item on the current line (for indented comments) More...
 

Detailed Description

Information about the pseudocode window.

Examples
hexrays_sample17.cpp, hexrays_sample3.cpp, and hexrays_sample5.cpp.

Definition at line 7485 of file hexrays.hpp.

Member Function Documentation

◆ calc_cmt_type()

cmt_type_t vdui_t::calc_cmt_type ( size_t  lnnum,
cmt_type_t  cmttype 
) const

Check if the specified line can have a comment.

Due to the coordinate system for comments: (https://www.hex-rays.com/blog/coordinate-system-for-hex-rays) some function lines cannot have comments. This function checks if a comment can be attached to the specified line.

Returns
possible comment types
Parameters
lnnumline number (0 based)
cmttypecomment types to check

Definition at line 12278 of file hexrays.hpp.

◆ clear()

void vdui_t::clear ( void  )

Clear the pseudocode window.

It deletes the current function and microcode.

Definition at line 12152 of file hexrays.hpp.

◆ collapse_item()

bool vdui_t::collapse_item ( bool  hide)

Collapse/uncollapse item.

This function collapses the current item.

Returns
false if failed.

Definition at line 12332 of file hexrays.hpp.

◆ collapse_lvars()

bool vdui_t::collapse_lvars ( bool  hide)

Collapse/uncollapse local variable declarations.

Returns
false if failed.

Definition at line 12338 of file hexrays.hpp.

◆ ctree_to_disasm()

bool vdui_t::ctree_to_disasm ( void  )

Jump to disassembly.

This function jumps to the address in the disassembly window which corresponds to the current item. The current item is determined based on the current keyboard cursor position.

Returns
false if failed

Definition at line 12272 of file hexrays.hpp.

◆ del_orphan_cmts()

bool vdui_t::del_orphan_cmts ( void  )

Delete all orphan comments.

Delete all orphan comments and refresh the screen.

Returns
true

Definition at line 12296 of file hexrays.hpp.

◆ edit_cmt()

bool vdui_t::edit_cmt ( const treeloc_t loc)

Edit an indented comment.

This function displays a dialog box and allows the user to edit the comment for the specified ctree location.

Returns
false if failed or cancelled
Parameters
loccomment location

Definition at line 12284 of file hexrays.hpp.

◆ edit_func_cmt()

bool vdui_t::edit_func_cmt ( void  )

Edit a function comment.

This function displays a dialog box and allows the user to edit the function comment.

Returns
false if failed or cancelled

Definition at line 12290 of file hexrays.hpp.

◆ get_current_item()

bool vdui_t::get_current_item ( input_device_t  idv)

Get current item.

This function refreshes the cpos, item, tail fields.

Returns
false if failed
Parameters
idvkeyboard or mouse
See also
cfunc_t::get_line_item()
Examples
hexrays_sample17.cpp, and hexrays_sample5.cpp.

Definition at line 12164 of file hexrays.hpp.

◆ get_current_label()

int vdui_t::get_current_label ( void  )

Get current label.

If there is a label under the cursor, return its number.

Returns
-1 if there is no label under the cursor. prereq: get_current_item() has been called

Definition at line 12146 of file hexrays.hpp.

◆ get_number()

cnumber_t * vdui_t::get_number ( void  )

Get current number.

If the current item is a number, return pointer to it.

Returns
nullptr if the current item is not a number This function returns non-null for the cases of a 'switch' statement Also, if the current item is a casted number, then this function will succeed.

Definition at line 12140 of file hexrays.hpp.

◆ in_ctree()

bool vdui_t::in_ctree ( void  ) const

Is the current item a statement?

Returns
false if the cursor is in the local variable/type declaration area
true if the cursor is in the statement area

Definition at line 7553 of file hexrays.hpp.

References cfunc, cpos, and ctext_position_t::in_ctree().

◆ invert_bits()

bool vdui_t::invert_bits ( void  )

Bitwise negate a number.

This function inverts all bits of the current number.

Returns
false if failed.

Definition at line 12326 of file hexrays.hpp.

◆ invert_sign()

bool vdui_t::invert_sign ( void  )

Negate a number.

This function negates the current number.

Returns
false if failed.

Definition at line 12320 of file hexrays.hpp.

◆ jump_enter()

bool vdui_t::jump_enter ( input_device_t  idv,
int  omflags 
)

Process the Enter key.

This function jumps to the definition of the item under the cursor. If the current item is a function, it will be decompiled. If the current item is a global data, its disassemly text will be displayed.

Returns
false if failed
Parameters
idvwhat cursor must be used, the keyboard or the mouse
omflagsOM_NEWWIN: new pseudocode window will open, 0: reuse the existing window

Definition at line 12266 of file hexrays.hpp.

◆ locked()

bool vdui_t::locked ( void  ) const

Does the pseudocode window contain valid code? We lock windows before modifying them, to avoid recursion due to the events generated by the IDA kernel.

Return values
trueThe window is locked and may have stale info

Definition at line 7505 of file hexrays.hpp.

References cfunc.

◆ map_lvar()

bool vdui_t::map_lvar ( lvar_t from,
lvar_t to 
)

Map a local variable to another.

This function permanently maps one lvar to another. All occurrences of the mapped variable are replaced by the new variable

Returns
false if failed
Parameters
fromthe variable being mapped
tothe variable to map to. if nullptr, unmaps the variable

Definition at line 12230 of file hexrays.hpp.

◆ refresh_cpos()

bool vdui_t::refresh_cpos ( input_device_t  idv)

Refresh the current position.

This function refreshes the cpos field.

Returns
false if failed
Parameters
idvkeyboard or mouse

Definition at line 12158 of file hexrays.hpp.

◆ refresh_ctext()

void vdui_t::refresh_ctext ( bool  activate = true)

Refresh pseudocode window.

This function refreshes the pseudocode window by regenerating its text from cfunc_t. Instead of this function use refresh_func_ctext(), which refreshes all pseudocode windows for the function.

See also
refresh_view(), refresh_func_ctext()
Examples
hexrays_sample17.cpp, and hexrays_sample3.cpp.

Definition at line 12128 of file hexrays.hpp.

◆ refresh_view()

void vdui_t::refresh_view ( bool  redo_mba)

Refresh pseudocode window.

This is the highest level refresh function. It causes the most profound refresh possible and can lead to redecompilation of the current function. Please consider using refresh_ctext() if you need a more superficial refresh.

Parameters
redo_mbatrue means to redecompile the current function
false means to rebuild ctree without regenerating microcode
See also
refresh_ctext()

Definition at line 12122 of file hexrays.hpp.

◆ rename_global()

bool vdui_t::rename_global ( ea_t  ea)

Rename global item.

This function displays a dialog box and allows the user to rename a global item (data or function).

Returns
false if failed or cancelled
Parameters
eaaddress of the global item

Definition at line 12254 of file hexrays.hpp.

◆ rename_label()

bool vdui_t::rename_label ( int  label)

Rename a label.

This function displays a dialog box and allows the user to rename a statement label.

Returns
false if failed or cancelled
Parameters
labellabel number

Definition at line 12260 of file hexrays.hpp.

◆ rename_lvar()

bool vdui_t::rename_lvar ( lvar_t v,
const char *  name,
bool  is_user_name 
)

Rename local variable.

This function permanently renames a local variable.

Returns
false if failed
Parameters
vpointer to local variable
namenew variable name
is_user_nameuse true to save the new name into the database. use false to delete the saved name.
See also
rename_lvar()

Definition at line 12176 of file hexrays.hpp.

◆ rename_strmem()

bool vdui_t::rename_strmem ( struc_t *  sptr,
member_t *  mptr 
)

Rename structure field.

This function displays a dialog box and allows the user to rename a structure field.

Returns
false if failed or cancelled
Parameters
sptrpointer to structure
mptrpointer to structure member

Definition at line 12242 of file hexrays.hpp.

◆ set_global_type()

bool vdui_t::set_global_type ( ea_t  ea)

Set global item type.

This function displays a dialog box and allows the user to change the type of a global item (data or function).

Returns
false if failed or cancelled
Parameters
eaaddress of the global item

Definition at line 12248 of file hexrays.hpp.

◆ set_locked()

bool vdui_t::set_locked ( bool  v)

Definition at line 12116 of file hexrays.hpp.

◆ set_lvar_cmt()

bool vdui_t::set_lvar_cmt ( lvar_t v,
const char *  cmt 
)

Set local variable comment.

This function permanently sets a variable comment.

Returns
false if failed
Parameters
vpointer to local variable
cmtnew comment

Definition at line 12212 of file hexrays.hpp.

◆ set_lvar_type()

bool vdui_t::set_lvar_type ( lvar_t v,
const tinfo_t &  type 
)

Set local variable type.

This function permanently sets a local variable type and clears NOPTR flag if it was set before by function 'set_noptr_lvar'

Returns
false if failed
Parameters
vpointer to local variable
typenew variable type

Definition at line 12194 of file hexrays.hpp.

◆ set_noptr_lvar()

bool vdui_t::set_noptr_lvar ( lvar_t v)

Inform that local variable should have a non-pointer type This function permanently sets a corresponding variable flag (NOPTR) and removes type if it was set before by function 'set_lvar_type'.

Returns
false if failed
Parameters
vpointer to local variable

Definition at line 12200 of file hexrays.hpp.

◆ set_num_enum()

bool vdui_t::set_num_enum ( void  )

Convert number to symbolic constant.

This function displays a dialog box and allows the user to select a symbolic constant to represent the number.

Returns
false if failed or cancelled

Definition at line 12308 of file hexrays.hpp.

◆ set_num_radix()

bool vdui_t::set_num_radix ( int  base)

Change number base.

This function changes the current number representation.

Returns
false if failed
Parameters
basenumber radix (10 or 16)
0 means a character constant

Definition at line 12302 of file hexrays.hpp.

◆ set_num_stroff()

bool vdui_t::set_num_stroff ( void  )

Convert number to structure field offset.

Currently not implemented.

Returns
false if failed or cancelled

Definition at line 12314 of file hexrays.hpp.

◆ set_strmem_type()

bool vdui_t::set_strmem_type ( struc_t *  sptr,
member_t *  mptr 
)

Set structure field type.

This function displays a dialog box and allows the user to change the type of a structure field.

Returns
false if failed or cancelled
Parameters
sptrpointer to structure
mptrpointer to structure member

Definition at line 12236 of file hexrays.hpp.

◆ set_valid()

void vdui_t::set_valid ( bool  v)

Definition at line 7507 of file hexrays.hpp.

◆ set_visible()

void vdui_t::set_visible ( bool  v)

Definition at line 7506 of file hexrays.hpp.

◆ split_item()

bool vdui_t::split_item ( bool  split)

Split/unsplit item.

This function splits the current assignment expression.

Returns
false if failed.

Definition at line 12344 of file hexrays.hpp.

◆ switch_to()

void vdui_t::switch_to ( cfuncptr_t  f,
bool  activate 
)

Display the specified pseudocode.

This function replaces the pseudocode window contents with the specified cfunc_t.

Parameters
fpointer to the function to display.
activateshould the pseudocode window get focus?

Definition at line 12134 of file hexrays.hpp.

◆ ui_edit_lvar_cmt()

bool vdui_t::ui_edit_lvar_cmt ( lvar_t v)

Set local variable comment.

This function displays a dialog box and allows the user to edit the comment of a local variable.

Returns
false if failed or cancelled
Parameters
vpointer to local variable

Definition at line 12206 of file hexrays.hpp.

◆ ui_map_lvar()

bool vdui_t::ui_map_lvar ( lvar_t v)

Map a local variable to another.

This function displays a variable list and allows the user to select mapping.

Returns
false if failed or cancelled
Parameters
vpointer to local variable

Definition at line 12218 of file hexrays.hpp.

◆ ui_rename_lvar()

bool vdui_t::ui_rename_lvar ( lvar_t v)

Rename local variable.

This function displays a dialog box and allows the user to rename a local variable.

Returns
false if failed or cancelled
Parameters
vpointer to local variable

Definition at line 12170 of file hexrays.hpp.

◆ ui_set_call_type()

bool vdui_t::ui_set_call_type ( const cexpr_t e)

Set type of a function call This function displays a dialog box and allows the user to change the type of a function call.

Returns
false if failed or cancelled
Parameters
epointer to call expression

Definition at line 12182 of file hexrays.hpp.

◆ ui_set_lvar_type()

bool vdui_t::ui_set_lvar_type ( lvar_t v)

Set local variable type.

This function displays a dialog box and allows the user to change the type of a local variable.

Returns
false if failed or cancelled
Parameters
vpointer to local variable

Definition at line 12188 of file hexrays.hpp.

◆ ui_unmap_lvar()

bool vdui_t::ui_unmap_lvar ( lvar_t v)

Unmap a local variable.

This function displays list of variables mapped to the specified variable and allows the user to select a variable to unmap.

Returns
false if failed or cancelled
Parameters
vpointer to local variable

Definition at line 12224 of file hexrays.hpp.

◆ valid()

bool vdui_t::valid ( void  ) const

Does the pseudocode window contain valid code? It can become invalid if the function type gets changed in IDA.

Definition at line 7500 of file hexrays.hpp.

References flags, and VDUI_VALID.

◆ visible()

bool vdui_t::visible ( void  ) const

Is the pseudocode window visible? if not, it might be invisible or destroyed.

Definition at line 7497 of file hexrays.hpp.

References flags, and VDUI_VISIBLE.

Member Data Documentation

◆ cfunc

cfuncptr_t vdui_t::cfunc

pointer to function object

Examples
hexrays_sample17.cpp, hexrays_sample3.cpp, and hexrays_sample5.cpp.

Definition at line 7515 of file hexrays.hpp.

Referenced by in_ctree(), and locked().

◆ cpos

ctext_position_t vdui_t::cpos

Current ctext position.

Examples
hexrays_sample17.cpp.

Definition at line 7519 of file hexrays.hpp.

Referenced by in_ctree().

◆ ct

TWidget* vdui_t::ct

pseudocode view

Examples
hexrays_sample17.cpp, and hexrays_sample5.cpp.

Definition at line 7511 of file hexrays.hpp.

◆ flags

int vdui_t::flags

Properties of pseudocode window

Definition at line 7487 of file hexrays.hpp.

Referenced by valid(), and visible().

◆ head

ctree_item_t vdui_t::head

First ctree item on the current line (for block comments)

Definition at line 7520 of file hexrays.hpp.

◆ item

ctree_item_t vdui_t::item

Current ctree item.

Examples
hexrays_sample17.cpp, hexrays_sample3.cpp, and hexrays_sample5.cpp.

Definition at line 7521 of file hexrays.hpp.

◆ last_code

merror_t vdui_t::last_code

result of the last user action. See Microcode error codes

Definition at line 7516 of file hexrays.hpp.

◆ mba

mba_t* vdui_t::mba

pointer to underlying microcode

Definition at line 7514 of file hexrays.hpp.

◆ tail

ctree_item_t vdui_t::tail

Tail ctree item on the current line (for indented comments)

Examples
hexrays_sample3.cpp.

Definition at line 7522 of file hexrays.hpp.

◆ toplevel

TWidget* vdui_t::toplevel

Definition at line 7512 of file hexrays.hpp.

◆ view_idx

int vdui_t::view_idx

pseudocode window index (0..)

Definition at line 7510 of file hexrays.hpp.