mem
Library for doing raw memory accesses and other low-level operations.
Types
std::mem::AlignTo
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
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
std::mem::Endian
The endianness of a value
enum Endian : u8 {
Big,
Little,
Native
};
std::mem::MagicSearch
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
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
std::mem::Section
A Handle for a custom Section
using Section = u128;
Functions
std::mem::eof
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::reached
std::mem::reached
Function that returns true if the cursor position is at or beyond the given address
address
: The address to compare againstreturn
: True if the cursor is at or beyond the given address
fn reached(u128 address);
std::mem::align_to
std::mem::align_to
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);
std::mem::base_address
std::mem::base_address
Gets the base address of the data
return
: The base address of the memory
fn base_address();
std::mem::size
std::mem::size
Gets the size of the data
return
: The size of the memory
fn size();
std::mem::find_sequence
std::mem::find_sequence
Finds a sequence of bytes in the data
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);
std::mem::find_sequence_in_range
std::mem::find_sequence_in_range
Finds a sequence of bytes in a specific region of the data
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);
std::mem::find_string
std::mem::find_string
Finds a string in the data
occurrence_index
: The index of the occurrence to findstring
: The string to findreturn
: The address of the sequence
fn find_string(u128 occurrence_index, str string);
std::mem::find_string_in_range
std::mem::find_string_in_range
Finds a string in a specific region of the data
occurrence_index
: The index of the occurrence to findoffsetFrom
: The offset from which to start searchingoffsetTo
: The offset to which to searchstring
: The string to findreturn
: The address of the sequence
fn find_string_in_range(u128 occurrence_index, u128 offsetFrom, u128 offsetTo, str string);
std::mem::read_unsigned
std::mem::read_unsigned
Reads a unsigned value from the memory
address
: The address to read fromsize
: The size of the value to read[endian]
: The endianness of the value to read. Defaults to nativereturn
: The value read
fn read_unsigned(u128 address, u8 size, std::mem::Endian endian);
std::mem::read_signed
std::mem::read_signed
Reads a signed value from the memory
address
: The address to read fromsize
: The size of the value to read[endian]
: The endianness of the value to read. Defaults to nativereturn
: The value read
fn read_signed(u128 address, u8 size, std::mem::Endian endian);
std::mem::read_string
std::mem::read_string
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, u128 size);
std::mem::read_bits
std::mem::read_bits
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);
std::mem::create_section
std::mem::create_section
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);
std::mem::delete_section
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
std::mem::get_section_size
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);
std::mem::set_section_size
std::mem::set_section_size
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);
std::mem::copy_section_to_section
std::mem::copy_section_to_section
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);
std::mem::copy_value_to_section
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 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);
std::mem::current_bit_offset
std::mem::current_bit_offset
Returns the current bit offset when inside of a bitfield.
return
: The current bit offset between 0 and 7
fn current_bit_offset();
Last updated
Was this helpful?