Struct machina::memory::Memory [] [src]

pub struct Memory {
    pub memory_ptr: *mut (),
    // some fields omitted
}

Handles memory management.

Fields

Methods

impl Memory
[src]

[src]

Constructs a new Memory.

  • amount_pages - Amount pages to allocate

Examples

use machina::memory::Memory;

let memory = Memory::new(1);

[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

[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();

[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

[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

[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);

[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);

[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]

[src]

Formats the value using the given formatter.

impl Index<usize> for Memory
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl IndexMut<usize> for Memory
[src]

[src]

Performs the mutable indexing (container[index]) operation.

impl Drop for Memory
[src]

[src]

Executes the destructor for this type. Read more