Links
Comment on page

mem

Library for doing raw memory accesses and other low-level operations.

Types

std::mem::AlignTo

Aligns the cursor to the given alignment
  • <alignment>: The alignment to align to
struct AlignTo<auto Alignment> { ... } [[hidden, sealed]];

std::mem::Bytes

A type representing a sequence of bytes without any specific meaning
  • <Size>: The size of the sequence
struct Bytes<auto Size> { ... } [[sealed, format]];

std::mem::Endian

The Endianess of a value
enum Endian : u8 {
Big,
Little,
Native
};

std::mem::MagicSearch

Searches for a sequence of bytes and places the given type at that address
  • <Magic>: The magic sequence to search for
  • <T>: The type to place at the address
struct MagicSearch<auto Magic, T> { ... };

std::mem::Reinterpreter

Reinterprets a value as a different one
  • <From>: The type to reinterpret from
  • <To>: The type to reinterpret to
union Reinterpreter<From, To> { ... };

std::mem::Section

A Handle for a custom Section
using Section = u128;

Functions

std::mem::eof

Function that returns true if the cursor position is at the end of the memory This is usually used in while-sized arrays in the form of u8 array[while(!std::mem::eof())]
  • return: True if the cursor is at the end of the memory
fn eof();

std::mem::align_to

Aligns the given value to the given alignment
  • alignment: The alignment to align to
  • value: The value to align
  • return: The aligned value
fn align_to(u128 alignment, u128 value);

std::mem::base_address

Gets the base address of the memory
  • return: The base address of the memory
fn base_address();

std::mem::size

Gets the size of the memory
  • return: The size of the memory
fn size();

std::mem::find_sequence

Finds a sequence of bytes in the memory
  • occurrence_index: The index of the occurrence to find
  • bytes: The bytes to find
  • return: The address of the sequence
fn find_sequence(u128 occurrence_index, auto ... bytes);

std::mem::find_sequence_in_range

Finds a sequence of bytes in a specific region of the memory
  • occurrence_index: The index of the occurrence to find
  • offsetFrom: The offset from which to start searching
  • offsetTo: The offset to which to search
  • bytes: The bytes to find
  • return: The address of the sequence
fn find_sequence_in_range(u128 occurrence_index, u128 offsetFrom, u128 offsetTo, auto ... bytes);

std::mem::read_unsigned

Reads a unsigned value from the memory
  • address: The address to read from
  • size: The size of the value to read
  • endian: The endianess of the value to read
  • return: The value read
fn read_unsigned(u128 address, u8 size, std::mem::Endian endian);

std::mem::read_signed

Reads a signed value from the memory
  • address: The address to read from
  • size: The size of the value to read
  • endian: The endianess of the value to read
  • return: The value read
fn read_signed(u128 address, u8 size, std::mem::Endian endian);

std::mem::read_string

Reads a string value from the memory
  • address: The address to read from
  • size: The size of the value to read
  • return: The value read
fn read_string(u128 address, u8 size);

std::mem::current_bit_offset

Gets the current bit offset within the current byte that a bitfield will read.
fn current_bit_offset();

std::mem::read_bits

Reads a number of bits from the specified bit offset within the specified byte
  • byteOffset: The byte offset within the data
  • bitOffset: The bit offset to start the read at within the current byte
  • bitSize: The total number of bits to read
  • return: A u128 containing the value read
fn read_bits(u128 byteOffset, u128 bitOffset, u64 bitSize);

std::mem::create_section

Creates a new custom section with the given name
  • name: The name of the section
  • return: The handle to the section
fn create_section(str name);

std::mem::delete_section

Deletes a custom section
  • section: The handle to the section
fn delete_section(std::mem::Section section);

std::mem::get_section_size

Gets the size of a custom section
  • section: The handle to the section
  • return: The size of the section
fn get_section_size(std::mem::Section section);

std::mem::set_section_size

Changes the size of a custom section
  • section: The handle to the section
  • size: The new size of the section
fn set_section_size(std::mem::Section section, u128 size);

std::mem::copy_section_to_section

Copies a range of bytes from one section into another
  • from_section: The section to copy from
  • from_address: The address to copy from
  • to_section: The section to copy to
  • to_address: The address to copy to
  • size: The size of the range to copy
fn copy_section_to_section(std::mem::Section from_section, u64 from_address, std::mem::Section to_section, u64 to_address, u64 size);

std::mem::copy_value_to_section

Copies a range of bytes from the main section into a custom section
  • value: The pattern whose bytes should be copied
  • to_section: The section to copy to
  • to_address: The address to copy to
fn copy_value_to_section(auto value, std::mem::Section to_section, u64 to_address);
Last modified 1mo ago