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.
Examples
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
| Static Method | from |
Get the register from its name or None if reg_name doesn't represent a valid register. |
| Method | __eq__ |
Compares the instance for equality with an object. |
| Method | __getitem__ |
Returns the reven2.RegisterSlice corresponding to the indexed register, in bits. |
| Method | __hash__ |
Returns the hash for this value. |
| Method | __init__ |
Initializes a Register from a low-level object. Not meant to be called directly. |
| Method | __ne__ |
Compares the instance for equality with an object. |
| Method | __repr__ |
Undocumented |
| Method | children |
An iterator over the children of this register, if any. |
| Method | parent |
The parent register of this register, if exists. Otherwise, None |
| Method | root |
The root register of this register. |
| Property | arch |
Property: The architecture of the register, as a string. |
| Property | bit |
Property: The offset in bits from the parent register. |
| Property | category |
Property: The category of the register. |
| Property | name |
Property: The name of this register as a string. |
| Property | root |
Property: The offset in bits from the root register. |
| Property | size |
Property: The exact size of the register, in bits |
| Property | size |
Property: The smallest number of bytes required to contain the register |
| Instance Variable | _arch |
Undocumented |
| Instance Variable | _rvn |
Undocumented |
| Instance Variable | _rvn |
Undocumented |
Compares the instance for equality with an object.
- if the object is not a
Register, it will never be equal to this instance.
Returns the reven2.RegisterSlice corresponding to the indexed register, in bits.
Information
| Parameters | |
item:_Union[ | Undocumented |
| Returns | |
_RegisterSlice | Undocumented |
| Raises | |
IndexError | if the specified index would be out of bounds. |
ValueError | if the specified slice index contains a step, which is not supported. |
Initializes a Register from a low-level object. Not meant to be called directly.
Use registers defined in the reven2.arch modules instead.
Information
| Parameters | |
_rvn_rvn_api.Register | low-level representation of a register |
arch:str | string representing the architecture of that register |
Compares the instance for equality with an object.
- if the object is not a
Register, it will never be equal to this instance.
An iterator over the children of this register, if any.
| Returns | |
_Iterator[ | Undocumented |
arch:
str =
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:
- x64: GPR + flags + rip registers
- sse2: SIMD registers
- x87: floating point registers
- msr: msr registers
Examples
>>> arch.x64.iopl.arch 'x64' >>> arch.sse2.xmm0.arch 'sse2' >>> arch.x87.fp0.arch 'x87' >>> arch.msr.aperf.arch 'msr'
Information
| Returns | |
| A string. |
bit_offset:
int =
Property: The offset in bits from the parent register.
If there is no parent register (e.g., rax), returns 0.
Examples
>>> 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
Information
| Returns | |
| An integer. |
Property: The category of the register.
Examples
>>> 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)
Information
| Returns | |
A Category instance. |
name:
str =
Property: The name of this register as a string.
Examples
>>> arch.x64.rax.name 'rax' >>> arch.x87.fp0.name 'fp0'
Information
| Returns | |
| A string. |
root_bit_offset:
int =
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.
Examples
>>> 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
Information
| Returns | |
| An integer. |
size_bits:
int =
Property: The exact size of the register, in bits
Examples
>>> arch.sse2.zmm0.size_bits 512 >>> arch.x64.rax.size_bits 64 >>> arch.x64.iopl.size_bits 2 >>> arch.x64.cf.size_bits 1
Information
| Returns | |
| An integer. |