memex
Loading...
Searching...
No Matches
MemoryIO Class Reference

This class provides an interface for reading and writing memory in a remote process. More...

#include <MemoryIO.hpp>

Public Member Functions

 MemoryIO (const ProcessHandle &process)
 Construct a new MemoryIO object.
 
 MemoryIO (const MemoryIO &)=delete
 
MemoryIOoperator= (const MemoryIO &)=delete
 
 MemoryIO (MemoryIO &&) noexcept=default
 
MemoryIOoperator= (MemoryIO &&) noexcept=default
 
std::uint8_t pointerSize () const
 Getter for the pointer size.
 
bool isAttached () const
 This function determines if the process is attached.
 
template<typename T >
Read (RemotePtr< T > address)
 Wrapper for ReadProcessMemory.
 
template<typename T >
std::size_t Read (void *dst, RemotePtr< T > src, std::size_t size)
 Wrapper for ReadProcessMemory. Similar to memcpy.
 
template<typename T >
void Write (RemotePtr< T > address, const T &value)
 Wrapper for WriteProcessMemory.
 
template<typename T >
std::size_t Write (RemotePtr< T > dst, const void *src, std::size_t size)
 Wrapper for WriteProcessMemory. Writes a buffer to the target process.
 
template<typename T >
RemotePtr< T > ResolvePointerChain (RemotePtr< void > base, std::span< const std::ptrdiff_t > offsets)
 Resolves a pointer chain in the target process.
 
void Fill (RemotePtr< void > dst, std::uint8_t value, std::size_t size)
 Fills a buffer in the target process with a specified byte (opcode).
 
template<typename T >
RemotePtr< T > ResolvePointerChain (RemotePtr< void > base, std::initializer_list< std::ptrdiff_t > offsets)
 Overload of ResolvePointerChain for std::initializer_list.
 

Detailed Description

This class provides an interface for reading and writing memory in a remote process.

Note
Copy constructor and assignment operator are deleted to prevent copying.
Move constructor and assignment operator are defaulted to allow moving.

Constructor & Destructor Documentation

◆ MemoryIO() [1/3]

MemoryIO::MemoryIO ( const ProcessHandle & process)
explicit

Construct a new MemoryIO object.

Parameters
processThe process handle to the target process.
Here is the call graph for this function:

◆ MemoryIO() [2/3]

MemoryIO::MemoryIO ( const MemoryIO & )
delete

◆ MemoryIO() [3/3]

MemoryIO::MemoryIO ( MemoryIO && )
defaultnoexcept

Member Function Documentation

◆ Fill()

void MemoryIO::Fill ( RemotePtr< void > dst,
std::uint8_t value,
std::size_t size )

Fills a buffer in the target process with a specified byte (opcode).

Parameters
dstThe address to fill.
valueThe byte value to fill the buffer with.
sizeThe size of the buffer to fill.
Here is the call graph for this function:

◆ isAttached()

bool MemoryIO::isAttached ( ) const
inlinenodiscard

This function determines if the process is attached.

Returns
true if the process is attached
false if the process is not attached
Here is the call graph for this function:

◆ operator=() [1/2]

MemoryIO & MemoryIO::operator= ( const MemoryIO & )
delete

◆ operator=() [2/2]

MemoryIO & MemoryIO::operator= ( MemoryIO && )
defaultnoexcept

◆ pointerSize()

std::uint8_t MemoryIO::pointerSize ( ) const
inlinenodiscard

Getter for the pointer size.

Note
The pointer size is determined by the architecture of the target process.
Returns
std::uint8_t The size of the pointer in bytes.

◆ Read() [1/2]

template<typename T >
T MemoryIO::Read ( RemotePtr< T > address)
inlinenodiscard

Wrapper for ReadProcessMemory.

Parameters
addressThe address to read from.
Template Parameters
TThe type of the value to read.
Returns
T The value read from the address.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Read() [2/2]

template<typename T >
std::size_t MemoryIO::Read ( void * dst,
RemotePtr< T > src,
std::size_t size )
inline

Wrapper for ReadProcessMemory. Similar to memcpy.

Parameters
dstPointer to the destination buffer.
srcThe address to read from.
sizeThe size of the buffer to read.
Returns
std::size_t The number of bytes read.
Note
This function is not type-safe. It is the caller's responsibility to ensure that the size of the buffer is correct.
Here is the call graph for this function:

◆ ResolvePointerChain() [1/2]

template<typename T >
RemotePtr< T > MemoryIO::ResolvePointerChain ( RemotePtr< void > base,
std::initializer_list< std::ptrdiff_t > offsets )
inlinenodiscard

Overload of ResolvePointerChain for std::initializer_list.

Parameters
baseThe base address of the pointer chain.
offsetsA list of offsets to resolve the pointer chain.
Returns
RemotePtr<T> The resolved pointer.
Here is the call graph for this function:

◆ ResolvePointerChain() [2/2]

template<typename T >
RemotePtr< T > MemoryIO::ResolvePointerChain ( RemotePtr< void > base,
std::span< const std::ptrdiff_t > offsets )
inlinenodiscard

Resolves a pointer chain in the target process.

Parameters
baseThe base address of the pointer chain.
offsetsA span of offsets to resolve the pointer chain.
Returns
RemotePtr<T> The resolved pointer.
Note
This function is not type-safe. It is the caller's responsibility to ensure that the offsets are correct.
This function assumes that the base address is a valid pointer in the target process.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Write() [1/2]

template<typename T >
void MemoryIO::Write ( RemotePtr< T > address,
const T & value )
inline

Wrapper for WriteProcessMemory.

Parameters
addressThe address to write to.
valueThe value to write.
Template Parameters
TThe type of the value to write.
Note
This function is not type-safe. It is the caller's responsibility to ensure that the size of the value is correct.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Write() [2/2]

template<typename T >
std::size_t MemoryIO::Write ( RemotePtr< T > dst,
const void * src,
std::size_t size )
inline

Wrapper for WriteProcessMemory. Writes a buffer to the target process.

Parameters
dstThe address to write to.
srcPointer to the source buffer.
sizeThe size of the buffer to write.
Returns
std::size_t The number of bytes written.
Note
This function is not type-safe. It is the caller's responsibility to ensure that the size of the buffer is correct.
Here is the call graph for this function:

The documentation for this class was generated from the following files: