29 template <MemoryReadSupported T>
34 template <MemoryReadSupported T>
35 requires std::is_trivial_v<T>
37 std::vector<T> result;
40 for (std::uintptr_t current_address = address; size > 0; current_address +=
sizeof(T), --size) {
47 template <MemoryReadSupported T>
48 requires std::is_trivial_v<T>
50 std::vector<T> result;
52 for (std::uintptr_t current_address = address;; current_address +=
sizeof(T)) {
55 if (!until_predicate(elem)) {
59 result.push_back(std::move(elem));
66 return this->read_block_impl(address, length);
70 template <MemoryReadSupported T>
72 if constexpr (std::is_pointer_v<T>) {
73 using NextType = std::remove_pointer_t<T>;
76 auto next_address =
reinterpret_cast<std::uintptr_t
>(
TRY(
read<T>(address)));
84 template <MemoryWriteSupported T>
87 TRY(this->write_block_impl(address, bytes));
99 virtual Result<ByteVector> read_until(std::uintptr_t address,
const std::function<
bool(std::byte)>& predicate);
101 const std::function<
bool(std::span<const std::byte>)>& predicate,
102 std::size_t block_size);
104 virtual Result<ByteVector> read_block_impl(std::uintptr_t address, std::size_t length) = 0;
Definition byte_vector.hpp:32
size_t size() const
Definition byte_vector.hpp:100
std::variant wrapper for a partial implementation of C++23's expected type
Definition expected.hpp:34
Base class for interacting with a tracee's memory in a variety of ways at a (relatively) high-level F...
Definition memory_io_base.hpp:23
pid_t get_pid() const
Definition memory_io_base.hpp:91
Result< std::size_t > write(std::uintptr_t address, const T &data)
Definition memory_io_base.hpp:85
MemoryIOBase(pid_t pid)
Definition memory_io_base.hpp:25
Result< std::vector< T > > read_array(std::uintptr_t address, std::function< bool(const T &)> until_predicate)
Definition memory_io_base.hpp:49
Result< remove_all_pointers_t< T > > read_deref_all(std::uintptr_t address)
Definition memory_io_base.hpp:71
Result< ByteVector > read_bytes(std::uintptr_t address, std::size_t length)
Definition memory_io_base.hpp:65
virtual ~MemoryIOBase()=default
Result< std::vector< T > > read_array(std::uintptr_t address, std::size_t size)
Definition memory_io_base.hpp:36
Result< T > read(std::uintptr_t address)
Definition memory_io_base.hpp:30
#define TRY(val)
If the supplied argument is an error (unexpected) type, then propegate it up the call stack....
Definition error_types.hpp:46
Definition asm_buffer.hpp:19
Example class implementation:
Definition memory_io_serde.hpp:31