Struct machina::memory::Memory
[−]
[src]
pub struct Memory { pub memory_ptr: *mut (), // some fields omitted }
Handles memory management.
Fields
memory_ptr: *mut ()
Methods
impl Memory
[src]
fn new(amount_pages: usize) -> Memory
[src]
Constructs a new Memory
.
amount_pages
- Amount pages to allocate
Examples
use machina::memory::Memory; let memory = Memory::new(1);
fn fill(&mut self, asm: u8)
[src]
Fills the entire memory block with the same byte
asm
- The byte
Examples
use machina::memory::Memory; let mut memory = Memory::new(1); memory.fill(0xc3); // ret
fn reset(&mut self)
[src]
Resets the memory to its initial state, which is a block full of ret
instructions.
Examples
use machina::memory::Memory; let mut memory = Memory::new(1); memory.reset();
fn emit(&mut self, asm: u8)
[src]
Add 1 byte to the memory.
asm
- The byte
Examples
use machina::memory::Memory; let mut memory = Memory::new(1); memory.emit(0xc3); // ret
fn emit_bytes(&mut self, asm: Vec<u8>)
[src]
Appends all bytes to the memory.
asm
- The bytes
Examples
use machina::memory::Memory; let mut memory = Memory::new(1); memory.emit_bytes(vec![0x48, 0xff, 0xc0]); // mov rax, 3
fn emit32(&mut self, asm: u32)
[src]
Appends an u32. This will convert the value into Little Endian.
asm
- The value (for example an address)
Examples
use machina::memory::Memory; let mut memory = Memory::new(1); memory.emit32(0x12341234);
fn emit64(&mut self, asm: u64)
[src]
Appends an u64. This will convert the value into Little Endian.
asm
- The value (for example an address)
Examples
use machina::memory::Memory; let mut memory = Memory::new(1); memory.emit64(0x12341234);
fn execute(&self) -> usize
[src]
Executes the entire memory block and returns the value of the register rax
.
Examples
use machina::memory::Memory; let mut memory = Memory::new(1); let _ = memory.execute();
Trait Implementations
impl Debug for Memory
[src]
impl Index<usize> for Memory
[src]
type Output = u8
The returned type after indexing.
fn index(&self, _index: usize) -> &u8
[src]
Performs the indexing (container[index]
) operation.
impl IndexMut<usize> for Memory
[src]
fn index_mut(&mut self, _index: usize) -> &mut u8
[src]
Performs the mutable indexing (container[index]
) operation.