State-of-the-art binary code analysis tools

Definition of a local variable (register or stack) #var #lvar. More...

Inheritance diagram for lvar_t:

Public Member Functions

 lvar_t (const qstring &n, const vdloc_t &l, ea_t e, const tinfo_t &t, int w, int db)
const char * dstr (void) const
bool used (void) const
 Is the variable used in the code?
bool typed (void) const
 Has the variable a type?
bool mreg_done (void) const
 Have corresponding microregs been replaced by references to this variable?
bool has_nice_name (void) const
 Does the variable have a nice name?
bool is_unknown_width (void) const
 Do we know the width of the variable?
bool has_user_info (void) const
 Has any user-defined information?
bool has_user_name (void) const
 Has user-defined name?
bool has_user_type (void) const
 Has user-defined type?
bool is_result_var (void) const
 Is the function result?
bool is_arg_var (void) const
 Is the function argument?
bool is_promoted_arg (void) const
 Is the promoted function argument?
bool is_fake_var (void) const
 Is fake return variable?
bool is_overlapped_var (void) const
 Is overlapped variable?
bool is_floating_var (void) const
 Used by a fpu insn?
bool is_spoiled_var (void) const
 Is spoiled var? (meaningful only during lvar allocation)
bool is_partialy_typed (void) const
 Variable type should be handled as a partial one.
bool is_noptr_var (void) const
 Variable type should not be a pointer.
bool is_mapdst_var (void) const
 Other variable(s) map to this var?
bool is_thisarg (void) const
 Is 'this' argument of a C++ member function?
bool is_forced_var (void) const
 Is a forced variable?
bool has_regname (void) const
 Has a register name? (like _RAX)
bool in_asm (void) const
 Is variable used in an instruction translated into __asm?
bool is_dummy_arg (void) const
 Is a dummy argument (added to fill a hole in the argument list)
bool is_notarg (void) const
 Is a local variable? (local variable cannot be an input argument)
bool is_automapped (void) const
 Was the variable automatically mapped to another variable?
bool is_used_byref (void) const
 Was the address of the variable taken?
bool is_decl_unused (void) const
 Was declared as __unused by the user? See CVAR_UNUSED.
void set_used (void)
void clear_used (void)
void set_typed (void)
void set_non_typed (void)
void clr_user_info (void)
void set_user_name (void)
void set_user_type (void)
void clr_user_type (void)
void clr_user_name (void)
void set_mreg_done (void)
void clr_mreg_done (void)
void set_unknown_width (void)
void clr_unknown_width (void)
void set_arg_var (void)
void clr_arg_var (void)
void set_fake_var (void)
void clr_fake_var (void)
void set_overlapped_var (void)
void clr_overlapped_var (void)
void set_floating_var (void)
void clr_floating_var (void)
void set_spoiled_var (void)
void clr_spoiled_var (void)
void set_mapdst_var (void)
void clr_mapdst_var (void)
void set_partialy_typed (void)
void clr_partialy_typed (void)
void set_noptr_var (void)
void clr_noptr_var (void)
void set_thisarg (void)
void clr_thisarg (void)
void set_forced_var (void)
void clr_forced_var (void)
void set_dummy_arg (void)
void clr_dummy_arg (void)
void set_notarg (void)
void clr_notarg (void)
void set_automapped (void)
void clr_automapped (void)
void set_used_byref (void)
void clr_used_byref (void)
void set_decl_unused (void)
void clr_decl_unused (void)
bool has_common (const lvar_t &v) const
 Do variables overlap?
bool has_common_bit (const vdloc_t &loc, asize_t width2) const
 Does the variable overlap with the specified location?
const tinfo_t & type (void) const
 Get variable type.
tinfo_t & type (void)
bool accepts_type (const tinfo_t &t, bool may_change_thisarg=false)
 Check if the variable accept the specified type. More...
bool set_lvar_type (const tinfo_t &t, bool may_fail=false)
 Set variable type Note: this function does not modify the idb, only the lvar instance in the memory. More...
void set_final_lvar_type (const tinfo_t &t)
 Set final variable type.
bool set_width (int w, int svw_flags=0)
 Change the variable width. More...
void append_list (const mba_t *mba, mlist_t *lst, bool pad_if_scattered=false) const
 Append local variable to mlist. More...
bool is_aliasable (const mba_t *mba) const
 Is the variable aliasable? More...
- Public Member Functions inherited from lvar_locator_t
 lvar_locator_t (const vdloc_t &loc, ea_t ea)
sval_t get_stkoff (void) const
 Get offset of the varialbe in the stack frame. More...
bool is_reg1 (void) const
 Is variable located on one register?
bool is_reg2 (void) const
 Is variable located on two registers?
bool is_reg_var (void) const
 Is variable located on register(s)?
bool is_stk_var (void) const
 Is variable located on the stack?
bool is_scattered (void) const
 Is variable scattered?
mreg_t get_reg1 (void) const
 Get the register number of the variable.
mreg_t get_reg2 (void) const
 Get the number of the second register (works only for ALOC_REG2 lvars)
const scattered_aloc_t & get_scattered (void) const
 Get information about scattered variable.
scattered_aloc_t & get_scattered (void)
 DECLARE_COMPARISONS (lvar_locator_t)
const char * dstr (void) const

Public Attributes

qstring name
 variable name. More...
qstring cmt
 variable comment string
tinfo_t tif
 variable type
int width = 0
 variable size in bytes
int defblk = -1
 first block defining the variable. More...
uint64 divisor = 0
 max known divisor of the variable
- Public Attributes inherited from lvar_locator_t
vdloc_t location
 Variable location.
ea_t defea
 Definition address. More...


class mba_t

Detailed Description

Definition of a local variable (register or stack) #var #lvar.


Definition at line 1166 of file hexrays.hpp.

Member Function Documentation

◆ accepts_type()

bool lvar_t::accepts_type ( const tinfo_t &  t,
bool  may_change_thisarg = false 

Check if the variable accept the specified type.

Some types are forbidden (void, function types, wrong arrays, etc)

Definition at line 9873 of file hexrays.hpp.

◆ append_list()

void lvar_t::append_list ( const mba_t mba,
mlist_t lst,
bool  pad_if_scattered = false 
) const

Append local variable to mlist.

mbaptr to the current mba_t
lstlist to append to
iftrue, append padding bytes in case of scattered lvar

Definition at line 9891 of file hexrays.hpp.

◆ is_aliasable()

bool lvar_t::is_aliasable ( const mba_t mba) const

Is the variable aliasable?

mbaptr to the current mba_t Aliasable variables may be modified indirectly (through a pointer)

Definition at line 1383 of file hexrays.hpp.

◆ set_lvar_type()

bool lvar_t::set_lvar_type ( const tinfo_t &  t,
bool  may_fail = false 

Set variable type Note: this function does not modify the idb, only the lvar instance in the memory.

For permanent changes see modify_user_lvars() Also, the variable type is not considered as final by the decompiler and may be modified later by the type derivation. In some cases set_final_var_type() may work better, but it does not do persistent changes to the database neither.

tnew type
may_failif false and type is bad, interr

Definition at line 9879 of file hexrays.hpp.

◆ set_width()

bool lvar_t::set_width ( int  w,
int  svw_flags = 0 

Change the variable width.

We call the variable size 'width', it is represents the number of bytes. This function may change the variable type using set_lvar_type().

wnew width
svw_flagscombination of SVW_... bits

Definition at line 9885 of file hexrays.hpp.

Member Data Documentation

◆ defblk

int lvar_t::defblk = -1

first block defining the variable.

0 for args, -1 if unknown

Definition at line 1212 of file hexrays.hpp.

◆ name

qstring lvar_t::name

variable name.

use mba_t::set_nice_lvar_name() and mba_t::set_user_lvar_name() to modify it

Definition at line 1206 of file hexrays.hpp.