pub struct Unicorn<'a, D: 'a> { /* private fields */ }
Expand description

A Unicorn emulator instance.

Implementations

Create a new instance of the unicorn engine for the specified architecture and hardware mode.

Create a new instance of the unicorn engine for the specified architecture and hardware mode.

Return whatever data was passed during initialization.

For an example, have a look at utils::init_emu_with_heap where a struct is passed which is used for a custom allocator.

Return a mutable reference to whatever data was passed during initialization.

Return the architecture of the current emulator.

Return the handle of the current emulator.

Returns a vector with the memory regions that are mapped in the emulator.

Read a range of bytes from memory at the specified address.

Return a range of bytes from memory at the specified address as vector.

Map an existing memory region in the emulator at the specified address.

Safety

This function is marked unsafe because it is the responsibility of the caller to ensure that size matches the size of the passed buffer, an invalid size value will likely cause a crash in unicorn.

address must be aligned to 4kb or this will return Error::ARG.

size must be a multiple of 4kb or this will return Error::ARG.

ptr is a pointer to the provided memory region that will be used by the emulator.

Map a memory region in the emulator at the specified address.

address must be aligned to 4kb or this will return Error::ARG. size must be a multiple of 4kb or this will return Error::ARG.

Map in am MMIO region backed by callbacks.

address must be aligned to 4kb or this will return Error::ARG. size must be a multiple of 4kb or this will return Error::ARG.

Map in a read-only MMIO region backed by a callback.

address must be aligned to 4kb or this will return Error::ARG. size must be a multiple of 4kb or this will return Error::ARG.

Map in a write-only MMIO region backed by a callback.

address must be aligned to 4kb or this will return Error::ARG. size must be a multiple of 4kb or this will return Error::ARG.

Unmap a memory region.

address must be aligned to 4kb or this will return Error::ARG. size must be a multiple of 4kb or this will return Error::ARG.

Set the memory permissions for an existing memory region.

address must be aligned to 4kb or this will return Error::ARG. size must be a multiple of 4kb or this will return Error::ARG.

Write an unsigned value from a register.

Write variable sized values into registers.

The user has to make sure that the buffer length matches the register size. This adds support for registers >64 bit (GDTR/IDTR, XMM, YMM, ZMM (x86); Q, V (arm64)).

Read an unsigned value from a register.

Not to be used with registers larger than 64 bit.

Read 128, 256 or 512 bit register value into heap allocated byte array.

This adds safe support for registers >64 bit (GDTR/IDTR, XMM, YMM, ZMM, ST (x86); Q, V (arm64)).

Read a signed 32-bit value from a register.

Add a code hook.

Add a block hook.

Add a memory hook.

Add an interrupt hook.

Add hook for invalid instructions

Add hook for x86 IN instruction.

Add hook for x86 OUT instruction.

Add hook for x86 SYSCALL or SYSENTER.

Remove a hook.

hook is the value returned by add_*_hook functions.

Allocate and return an empty Unicorn context.

To be populated via context_save.

Save current Unicorn context to previously allocated Context struct.

Allocate and return a Context struct initialized with the current CPU context.

This can be used for fast rollbacks with context_restore. In case of many non-concurrent context saves, use context_alloc and *_save individually to avoid unnecessary allocations.

Restore a previously saved Unicorn context.

Perform a quick rollback of the CPU context, including registers and some internal metadata. Contexts may not be shared across engine instances with differing arches or modes. Memory has to be restored manually, if needed.

Emulate machine code for a specified duration.

begin is the address where to start the emulation. The emulation stops if until is hit. timeout specifies a duration in microseconds after which the emulation is stopped (infinite execution if set to 0). count is the maximum number of instructions to emulate (emulate all the available instructions if set to 0).

Stop the emulation.

This is usually called from callback function in hooks. NOTE: For now, this will stop the execution only after the current block.

Query the internal status of the engine.

supported: MODE, PAGE_SIZE, ARCH

Gets the current program counter for this unicorn instance.

Sets the program counter for this unicorn instance.

Trait Implementations

Formats the value using the given formatter. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.