class Register(object):
Models an architecture register that can serve as key to designate that register.
Also provides useful information about the register, such as its size, category or parent register
A Register instance is not meant to be constructed directly. Use registers defined in the reven2.arch
modules instead.
Registers are predefined inside of the arch
submodules arch.x64
, arch.x87
, arch.msr
and arch.sse2
.
>>> arch.x64.rax Register(x64.rax)
The main use of registers is to pass them as keys to various methods:
>>> context.read(arch.x64.rax) # reads rax in the current context 42
You can also get some information about the registers:
>>> arch.x64.rax.category Category(general_purpose) >>> arch.x64.rax.size_bytes 8
Method | __init__ |
Initializes a Register from a low-level object. Not meant to be called directly. |
Property | name |
Property: The name of this register as a string. |
Method | parent |
The parent register of this register, if exists. Otherwise, None |
Property | size_bits |
Property: The exact size of the register, in bits |
Property | size_bytes |
Property: The smallest number of bytes required to contain the register |
Property | bit_offset |
Property: The offset in bits from the parent register. |
Property | root_bit_offset |
Property: The offset in bits from the root register. |
Property | category |
Property: The category of the register. |
Property | arch |
Property: The architecture of the register, as a string. |
Static Method | from_name |
Get the register from its name or None if reg_name doesn't represent a valid register. |
Method | __repr__ |
Undocumented |
Method | __eq__ |
Undocumented |
Method | __ne__ |
Undocumented |
Instance Variable | _rvn_reg |
Undocumented |
Instance Variable | _rvn_node |
Undocumented |
Instance Variable | _arch |
Undocumented |
Initializes a Register from a low-level object. Not meant to be called directly.
Use registers defined in the reven2.arch
modules instead.
Parameters | _rvn_reg | low-level representation of a register |
arch | string representing the architecture of that register |
Property: The name of this register as a string.
>>> arch.x64.rax.name 'rax' >>> arch.x87.fp0.name 'fp0'
Returns | A string . |
The parent register of this register, if exists. Otherwise, None
>>> arch.x64.ah.parent() Register(x64.eax) >>> arch.x64.ah.parent().parent() Register(x64.rax) >>> arch.x64.ah.parent().parent().parent() None
Returns | A Register . |
Property: The exact size of the register, in bits
>>> arch.sse2.zmm0.size_bits 512 >>> arch.x64.rax.size_bits 64 >>> arch.x64.iopl.size_bits 2 >>> arch.x64.cf.size_bits 1
Returns | An integer . |
Property: The smallest number of bytes required to contain the register
>>> arch.sse2.zmm0.size_bytes 64 >>> arch.x64.rax.size_bytes 8 >>> arch.x64.iopl.size_bytes 1 >>> arch.x64.cf.size_bytes 1
Returns | An integer . |
Property: The offset in bits from the parent register.
If there is no parent register (e.g., rax), returns 0.
>>> arch.x64.iopl.bit_offset 12 >>> arch.x64.pf.bit_offset 2 >>> arch.x64.rax.bit_offset 0 >>> arch.x87.top.bit_offset 11 >>> arch.msr.aperf.bit_offset 0
Returns | An integer . |
Property: The offset in bits from the root register.
If the current register is the root register (e.g. rax), returns 0.
Note: Most of the time, this returns the same as Register.bit_offset
.
>>> arch.x64.iopl.root_bit_offset 12 >>> arch.x64.pf.root_bit_offset 2 >>> arch.x64.rax.root_bit_offset 0 >>> arch.x87.top.root_bit_offset 11 >>> arch.msr.aperf.root_bit_offset 0
Returns | An integer . |
Property: The category of the register.
>>> arch.x64.iopl.category Category(flags) >>> arch.x64.rflags.category Category(condensed_flags) >>> arch.x64.rax.category Category(general_purpose) >>> arch.x64.rip.category Category(pc)
Returns | A Category instance. |
Property: The architecture of the register, as a string.
The architecture is always the same as the module name in which the register resides.
Note: "architectures" are currently defined somewhat arbitrarily:
>>> arch.x64.iopl.arch 'x64' >>> arch.sse2.xmm0.arch 'sse2' >>> arch.x87.fp0.arch 'x87' >>> arch.msr.aperf.arch 'msr'
Returns | A string . |
Get the register from its name or None if reg_name doesn't represent a valid register.
Parameters | reg_name | the name of register. |
Returns | A Register such that its name is equal to reg_name. |