Package envi :: Module registers :: Class RegisterContext
[hide private]
[frames] | no frames]

Class RegisterContext

source code

Instance Methods [hide private]
 
__init__(self, regdef=(), metas=(), pcindex=None, spindex=None, srindex=None)
Hand in a register definition which consists of a list of (<name>, <width>) tuples.
source code
 
getRegisterSnap(self)
Use this to bulk save off the register state.
source code
 
setRegisterSnap(self, snap)
Use this to bulk restore the register state.
source code
 
isDirty(self)
Returns true if registers in this context have been modififed since their import.
source code
 
setIsDirty(self, bool) source code
 
setRegisterIndexes(self, pcindex, spindex, srindex=None) source code
 
loadRegDef(self, regdef, defval=0)
Load a register definition.
source code
 
getRegDef(self) source code
 
loadRegMetas(self, metas, statmetas=None)
Load a set of defined "meta" registers for this architecture.
source code
 
addMetaRegister(self, name, idx, offset, width)
Meta registers are registers which are really just directly addressable parts of already existing registers (eax -> al).
source code
 
isMetaRegister(self, index) source code
 
_rctx_Import(self, sobj)
Given an object with attributes with the same names as registers in our context, populate our values from it.
source code
 
_rctx_Export(self, sobj)
Given an object with attributes with the same names as registers in our context, set the ones he has to match our values.
source code
 
getRegisterInfo(self, meta=False)
Return an object which can be stored off, and restored to re-initialize a register context.
source code
 
setRegisterInfo(self, info) source code
 
getRegisterName(self, index) source code
 
getProgramCounter(self)
Get the value of the program counter for this register context.
source code
 
setProgramCounter(self, value)
Set the value of the program counter for this register context.
source code
 
getStackCounter(self) source code
 
setStackCounter(self, value) source code
 
hasStatusRegister(self)
Returns True if this context is aware of a status register.
source code
 
getStatusRegNameDesc(self)
Return a list of status register names and descriptions.
source code
 
getStatusRegister(self)
Gets the status register for this register context.
source code
 
setStatusRegister(self, value)
Sets the status register for this register context.
source code
 
getStatusFlags(self)
Return a dictionary of reg name and reg value for the meta registers that are part of the status register.
source code
 
getRegisterByName(self, name) source code
 
setRegisterByName(self, name, value) source code
 
getRegisterNames(self)
Returns a list of the 'real' (non meta) registers.
source code
 
getRegisterNameIndexes(self)
Return a list of all the 'real' (non meta) registers and their indexes.
source code
 
getRegisters(self)
Get all the *real* registers from this context as a dictionary of name value pairs.
source code
 
setRegisters(self, regdict)
For any name value pairs in the specified dictionary, set the current register values in this context.
source code
 
getRegisterIndex(self, name)
Get a register index by name.
source code
 
getRegisterWidth(self, index)
Return the width of the register which lives at the specified index (width is always in bits).
source code
 
getRegister(self, index)
Return the current value of the specified register index.
source code
 
getMetaRegInfo(self, index)
Return the appropriate realreg, shift, mask info for the specified metareg idx (or None if it's not meta).
source code
 
_xlateToMetaReg(self, index, value)
Translate a register value to the meta register value (used when getting a meta register)
source code
 
_xlateToNativeReg(self, index, value)
Translate a register value to the native register value (used when setting a meta register)
source code
 
setRegister(self, index, value)
Set a register value by index.
source code
Method Details [hide private]

setRegisterSnap(self, snap)

source code 

Use this to bulk restore the register state.

NOTE: This may only be used under the assumption that the
      RegisterContext has been initialized the same way
      (like context switches in tracers, or emulaction snaps)

loadRegDef(self, regdef, defval=0)

source code 

Load a register definition. A register definition consists of a list of tuples with the following format: (regname, regwidth)

NOTE: All widths in envi RegisterContexts are in bits.

loadRegMetas(self, metas, statmetas=None)

source code 

Load a set of defined "meta" registers for this architecture. Meta registers are defined as registers who exist as a subset of the bits in some other "real" register. The argument metas is a list of tuples with the following format: (regname, regidx, reg_shift_offset, reg_width) The given example is for the AX register in the i386 subsystem regname: "ax" reg_shift_offset: 0 reg_width: 16

Optionally a set of status meta registers can be loaded as well. The argument is a list of tuples with the following format: (regname, regidx, reg_shift_offset, reg_width, description)

addMetaRegister(self, name, idx, offset, width)

source code 

Meta registers are registers which are really just directly addressable parts of already existing registers (eax -> al).

To add a meta register, you give the name, the idx of the *real* register, the width of the meta reg, and it's left shifted (in bits) offset into the real register value. The RegisterContext will take care of accesses after that.

_rctx_Import(self, sobj)

source code 

Given an object with attributes with the same names as registers in our context, populate our values from it.

NOTE: This also clears the dirty flag

getRegisterInfo(self, meta=False)

source code 

Return an object which can be stored off, and restored to re-initialize a register context. (much like snapshot but it takes the definitions with it)

getRegisterNameIndexes(self)

source code 

Return a list of all the 'real' (non meta) registers and their indexes.

Example: for regname, regidx in x.getRegisterNameIndexes():

getRegisterIndex(self, name)

source code 

Get a register index by name. (faster to use the index multiple times)

getMetaRegInfo(self, index)

source code 

Return the appropriate realreg, shift, mask info
for the specified metareg idx (or None if it's not
meta).

Example:
    real_reg, lshift, mask = r.getMetaRegInfo(x)