zelos.emulator.base module¶
-
class
zelos.emulator.base.
IEmuHelper
(unicorn_engine, state)¶ Bases:
object
This is a class that serves as a wrapper around Unicorn, providing some additional functionality surrounding stacks and commonly used registers. Each architecture will need to implement their own subclass to provide the additional register information that is needed.
Because there may be multiple threads sharing a single emu instance, prefer to access these methods through the Thread class.
We chose to use string names for registers rather than an enum for quality of life reasons.
-
property
regmap
¶
-
property
bytes
¶
-
getstack
(idx: int) → int¶
-
setstack
(idx: int, val: int) → None¶
-
popstack
() → int¶
-
pushstack
(data: int) → None¶
-
setSP
(val: int) → None¶
-
getSP
() → int¶
-
setFP
(val: int)¶
-
getFP
() → int¶
-
get_reg
(reg_name: str) → int¶
-
set_reg
(reg_name: str, val: int) → None¶
-
setIP
(val: int) → None¶
-
getIP
() → int¶
-
get_all_regs
() → List[str]¶ Gets all registers for this architecture. Order of returned values is consistent between calls.
-
get_all_reg_vals
() → Dict[str, int]¶ Returns a dict of {reg_name:reg_val} for all regs for the current architecture.
-
get_regs
(regs: Iterable[str] = None) → Dict[str, int]¶ Returns a dictionary of registers and their values. Defaults to important regs for the current architecture
-
dumpregs
(regs: Iterable[str] = None) → str¶
-
to_signed
(x, bytes=None)¶
-
pack
(x: int, bytes: int = None, little_endian: bool = None, signed: bool = False) → <property object at 0x7fab8a784b38>¶ Unpacks an integer from a byte format. Defaults to the current architecture bytes and endianness.
-
unpack
(x: <property object at 0x7fab8a784b38>, bytes: int = None, little_endian: bool = None, signed: bool = False) → int¶ Unpacks an integer from a byte format. Defaults to the current architecture bytes and endianness.
-
property
-
zelos.emulator.base.
create_emulator
(arch, mode, state) → zelos.emulator.base.IEmuHelper¶ Factory method for constructing the appropriate IEmuHelper