Overview
Theemulator class is the base interface for all emulator implementations in Sogen. It combines three core interfaces:
cpu_interface- CPU register and execution controlmemory_interface- Memory read/write operationshook_interface- Event hooks for monitoring and control
Class Definition
Constructors and Assignment
The emulator class is non-copyable and non-movable:Pure Virtual Methods
get_name()
serialize_state()
Buffer to write the serialized state to
Whether this is a snapshot (for quick rollback) or full serialization
deserialize_state()
Buffer to read the serialized state from
Whether this is a snapshot (for quick rollback) or full deserialization
Inherited Interfaces
The emulator class inherits methods from three interfaces:From cpu_interface
start(size_t count)- Start CPU executionstop()- Stop CPU executionread_raw_register()- Read CPU register valueswrite_raw_register()- Write CPU register valuessave_registers()- Save all registers to a bufferrestore_registers()- Restore registers from a bufferread_descriptor_table()- Read descriptor table registers (GDTR, IDTR, etc.)has_violation()- Check if a memory violation occurred
From memory_interface
read_memory()- Read memory at an addresstry_read_memory()- Attempt to read memory without throwingwrite_memory()- Write memory at an addresstry_write_memory()- Attempt to write memory without throwingmove_memory()- Move memory from one location to another
From hook_interface
hook_memory_execution()- Hook memory executionhook_memory_read()- Hook memory read operationshook_memory_write()- Hook memory write operationshook_instruction()- Hook specific instruction typeshook_interrupt()- Hook interruptshook_memory_violation()- Hook memory access violationshook_basic_block()- Hook basic block executiondelete_hook()- Remove a hook
Usage Example
Implementation Notes
- Implementations must provide thread-safe state serialization
- The
is_snapshotparameter allows optimizations for temporary state saves - Snapshots may exclude persistent state like module mappings
- Full serialization should capture all state needed to resume execution
- The emulator name should be a unique, stable identifier for the backend
Related Types
See also:- memory_interface - Memory operations
- emulator_callbacks - Event callbacks for monitoring