pub struct Emulator<'ctx, M = EmulatedMemory> { /* private fields */ }Implementations§
Source§impl<'ctx> Emulator<'ctx, EmulatedMemory>
impl<'ctx> Emulator<'ctx, EmulatedMemory>
Sourcepub fn new(ctx: &'ctx Context<'ctx>, entry: BlockId) -> Self
pub fn new(ctx: &'ctx Context<'ctx>, entry: BlockId) -> Self
Builds an emulator over the default flat memory.
pub fn from_function(ctx: &'ctx Context<'ctx>, func: FunctionId) -> Self
pub fn from_block(ctx: &'ctx Context<'ctx>, block: BlockId) -> Self
pub fn from_address(ctx: &'ctx Context<'ctx>, addr: u64) -> Self
Source§impl<'ctx, M: EmulatorMemory + Default> Emulator<'ctx, M>
impl<'ctx, M: EmulatorMemory + Default> Emulator<'ctx, M>
Sourcepub fn new_in(ctx: &'ctx Context<'ctx>, entry: BlockId) -> Self
pub fn new_in(ctx: &'ctx Context<'ctx>, entry: BlockId) -> Self
Builds an emulator over an explicit memory backend.
pub fn set_instruction_hook( &mut self, hook: impl Fn(&InstructionRef<'_, '_>, &StandaloneEmulator<M>) + Send + Sync + 'static, )
pub fn set_call_interceptor( &mut self, interceptor: impl FnMut(&Context<'_>, &mut StandaloneEmulator<M>, &CallSite) -> Result<CallInterception, Box<str>> + Send + Sync + 'static, )
pub fn clear_call_interceptor(&mut self)
Sourcepub fn from_function_in(ctx: &'ctx Context<'ctx>, func: FunctionId) -> Self
pub fn from_function_in(ctx: &'ctx Context<'ctx>, func: FunctionId) -> Self
Builds an emulator at a function’s root block, over an explicit backend.
Sourcepub fn from_address_in(ctx: &'ctx Context<'ctx>, addr: u64) -> Self
pub fn from_address_in(ctx: &'ctx Context<'ctx>, addr: u64) -> Self
Builds an emulator positioned at addr, over an explicit backend.
Sourcepub fn inspect_memory(
&mut self,
space: SpaceId,
addr: u64,
size: usize,
) -> Option<Vec<u8>>
pub fn inspect_memory( &mut self, space: SpaceId, addr: u64, size: usize, ) -> Option<Vec<u8>>
Debugging method to view a value at a given address
Sourcepub fn set_varnode(
&mut self,
id: VarnodeId,
value: u64,
) -> Result<(), EmulatorErrorKind>
pub fn set_varnode( &mut self, id: VarnodeId, value: u64, ) -> Result<(), EmulatorErrorKind>
Sets the value of a varnode
Sourcepub fn set_varnode_u128(
&mut self,
id: VarnodeId,
value: u128,
) -> Result<(), EmulatorErrorKind>
pub fn set_varnode_u128( &mut self, id: VarnodeId, value: u128, ) -> Result<(), EmulatorErrorKind>
Sets the value of a varnode using full 128-bit precision.
Sourcepub fn set_register(
&mut self,
id: RegisterId,
value: u64,
) -> Result<(), EmulatorErrorKind>
pub fn set_register( &mut self, id: RegisterId, value: u64, ) -> Result<(), EmulatorErrorKind>
Sets the value of a register
Sourcepub fn write_memory(
&mut self,
space: SpaceId,
addr: u64,
value: &[u8],
) -> Result<(), EmulatorErrorKind>
pub fn write_memory( &mut self, space: SpaceId, addr: u64, value: &[u8], ) -> Result<(), EmulatorErrorKind>
Writes a value to memory
pub fn read_memory( &mut self, space: SpaceId, addr: u64, size: usize, ) -> Result<Vec<u8>, EmulatorErrorKind>
Sourcepub fn set_register_u128(
&mut self,
id: RegisterId,
value: u128,
) -> Result<(), EmulatorErrorKind>
pub fn set_register_u128( &mut self, id: RegisterId, value: u128, ) -> Result<(), EmulatorErrorKind>
Sets the value of a register using full 128-bit precision.
pub fn read_varnode(&mut self, id: VarnodeId) -> Option<u64>
pub fn read_varnode_u128(&mut self, id: VarnodeId) -> Option<u128>
pub fn read_register(&mut self, id: RegisterId) -> Option<u64>
pub fn read_register_u128(&mut self, id: RegisterId) -> Option<u128>
Sourcepub fn set_register_lane(&mut self, id: RegisterId, lane: usize, value: u64)
pub fn set_register_lane(&mut self, id: RegisterId, lane: usize, value: u64)
Writes a single 64-bit lane of a wide register.
Lane n covers bytes [n*8 .. n*8+8] relative to the register’s base address.
Sourcepub fn read_register_lane(&mut self, id: RegisterId, lane: usize) -> u64
pub fn read_register_lane(&mut self, id: RegisterId, lane: usize) -> u64
Reads a single 64-bit lane of a wide register (little-endian).
Lane n covers bytes [n*8 .. n*8+8] relative to the register’s base address.
Sourcepub fn insn(&self) -> Option<InstructionRef<'ctx, 'ctx>>
pub fn insn(&self) -> Option<InstructionRef<'ctx, 'ctx>>
Gets the current instruction
Sourcepub fn run_block(&mut self) -> Result<()>
pub fn run_block(&mut self) -> Result<()>
Executes instructions until the end of the current block
Sourcepub fn run_until(&mut self, addr: u64) -> Result<()>
pub fn run_until(&mut self, addr: u64) -> Result<()>
Runs blocks until the current block starts at addr.
Sourcepub fn run_function(&mut self, func: FunctionId) -> Result<()>
pub fn run_function(&mut self, func: FunctionId) -> Result<()>
Runs the given function from its root block, stopping before the outermost Return.
Sourcepub fn call_stack(&self) -> &[FunctionId]
pub fn call_stack(&self) -> &[FunctionId]
Returns the current emulator call stack (outermost function first).
Only populated during run_function execution.