Overview
Thememory_interface class provides methods for reading and writing emulator memory. It supports both raw memory operations and templated type-safe operations.
Class Definition
Core Virtual Methods
read_memory()
uint64_t
required
Memory address to read from
void*
required
Pointer to buffer to store the read data
size_t
required
Number of bytes to read
try_read_memory()
uint64_t
required
Memory address to read from
void*
required
Pointer to buffer to store the read data
size_t
required
Number of bytes to read
true if read succeeded, false if memory is inaccessible
Source: memory_interface.hpp:20
write_memory()
uint64_t
required
Memory address to write to
const void*
required
Pointer to data to write
size_t
required
Number of bytes to write
try_write_memory()
uint64_t
required
Memory address to write to
const void*
required
Pointer to data to write
size_t
required
Number of bytes to write
true if write succeeded, false if memory is inaccessible
Source: memory_interface.hpp:22
Template Methods
read_memory<T>() - Single Value
uint64_t
required
Memory address to read from
T- Type of value to read (e.g.,uint32_t,int64_t, custom struct)
read_memory<T>() - From Pointer
const void*
required
Pointer to memory address
read_memory() - Vector
uint64_t
required
Memory address to read from
size_t
required
Number of bytes to read
write_memory<T>() - Single Value
uint64_t
required
Memory address to write to
const T&
required
Value to write
T- Type of value to write
write_memory<T>() - To Pointer
void*
required
Pointer to memory address
const T&
required
Value to write
write_memory() - Buffer to Pointer
void*
required
Pointer to memory address
const void*
required
Pointer to data to write
size_t
required
Number of bytes to write
Memory Operations
move_memory()
uint64_t
required
Destination address
uint64_t
required
Source address
size_t
required
Number of bytes to move
- Handles overlapping source and destination correctly
- Copies from end to start if
src < dstto prevent data corruption - No-op if
dst == srcorsize == 0
Private Virtual Methods
These methods are used internally bymemory_manager and not intended for direct use:
map_mmio()
map_memory()
unmap_memory()
apply_memory_protection()
Related Types
memory_permission
MMIO Callbacks
Usage Examples
Reading and Writing Values
Reading Buffers
Safe Memory Access
Moving Memory
Notes
- All addresses are 64-bit virtual addresses
- Memory reads/writes may throw if the memory is unmapped or protected
- Use
try_*variants for non-throwing operations - Template methods use
sizeof(T)to determine the size automatically - The
move_memory()function correctly handles overlapping regions - MMIO operations are typically managed by
memory_manager, not called directly