Comment on page
mem
Library for doing raw memory accesses and other low-level operations.
Aligns the cursor to the given alignment
<alignment>
: The alignment to align to
struct AlignTo<auto Alignment> { ... } [[hidden, sealed]];
A type representing a sequence of bytes without any specific meaning
<Size>
: The size of the sequence
struct Bytes<auto Size> { ... } [[sealed, format]];
The Endianess of a value
enum Endian : u8 {
Big,
Little,
Native
};
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> { ... };
Reinterprets a value as a different one
<From>
: The type to reinterpret from<To>
: The type to reinterpret to
union Reinterpreter<From, To> { ... };
A Handle for a custom Section
using Section = u128;
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();
Aligns the given value to the given alignment
alignment
: The alignment to align tovalue
: The value to alignreturn
: The aligned value
fn align_to(u128 alignment, u128 value);
Gets the base address of the memory
return
: The base address of the memory
fn base_address();
Gets the size of the memory
return
: The size of the memory
fn size();
Finds a sequence of bytes in the memory
occurrence_index
: The index of the occurrence to findbytes
: The bytes to findreturn
: The address of the sequence
fn find_sequence(u128 occurrence_index, auto ... bytes);
Finds a sequence of bytes in a specific region of the memory
occurrence_index
: The index of the occurrence to findoffsetFrom
: The offset from which to start searchingoffsetTo
: The offset to which to searchbytes
: The bytes to findreturn
: The address of the sequence
fn find_sequence_in_range(u128 occurrence_index, u128 offsetFrom, u128 offsetTo, auto ... bytes);
Reads a unsigned value from the memory
address
: The address to read fromsize
: The size of the value to readendian
: The endianess of the value to readreturn
: The value read
fn read_unsigned(u128 address, u8 size, std::mem::Endian endian);
Reads a signed value from the memory
address
: The address to read fromsize
: The size of the value to readendian
: The endianess of the value to readreturn
: The value read
fn read_signed(u128 address, u8 size, std::mem::Endian endian);
Reads a string value from the memory
address
: The address to read fromsize
: The size of the value to readreturn
: The value read
fn read_string(u128 address, u8 size);
Gets the current bit offset within the current byte that a bitfield will read.
fn current_bit_offset();
Reads a number of bits from the specified bit offset within the specified byte
byteOffset
: The byte offset within the databitOffset
: The bit offset to start the read at within the current bytebitSize
: The total number of bits to readreturn
: A u128 containing the value read
fn read_bits(u128 byteOffset, u128 bitOffset, u64 bitSize);
Creates a new custom section with the given name
name
: The name of the sectionreturn
: The handle to the section
fn create_section(str name);
Deletes a custom section
section
: The handle to the section
fn delete_section(std::mem::Section section);
Gets the size of a custom section
section
: The handle to the sectionreturn
: The size of the section
fn get_section_size(std::mem::Section section);
Changes the size of a custom section
section
: The handle to the sectionsize
: The new size of the section
fn set_section_size(std::mem::Section section, u128 size);
Copies a range of bytes from one section into another
from_section
: The section to copy fromfrom_address
: The address to copy fromto_section
: The section to copy toto_address
: The address to copy tosize
: 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);
Copies a range of bytes from the main section into a custom section
value
: The pattern whose bytes should be copiedto_section
: The section to copy toto_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