plugify  1.0.0.0
Public Member Functions | List of all members
plugify::MemAddr Class Reference

A wrapper class for memory addresses, providing utility functions for pointer manipulation. More...

#include <mem_addr.hpp>

Public Member Functions

 MemAddr () noexcept
 Default constructor initializing the pointer to 0.
 
 MemAddr (uintptr_t ptr) noexcept
 Constructor initializing the pointer with a uintptr_t value. More...
 
template<typename T >
 requires (std::is_pointer_v< T > or std::is_null_pointer_v< T >) MemAddr(T ptr) noexcept
 Template constructor initializing the pointer with a typed pointer. More...
 
 operator uintptr_t () const noexcept
 Converts the MemAddr object to a uintptr_t. More...
 
 operator void * () const noexcept
 Converts the MemAddr object to a void pointer. More...
 
 operator bool () const noexcept
 Explicit conversion operator to bool, indicating if the pointer is non-zero. More...
 
bool operator!= (const MemAddr &addr) const noexcept
 Inequality operator. More...
 
bool operator== (const MemAddr &addr) const noexcept
 Equality operator. More...
 
bool operator== (const uintptr_t &addr) const noexcept
 Equality operator for comparing with uintptr_t. More...
 
uintptr_t GetPtr () const noexcept
 Returns the uintptr_t representation of the pointer. More...
 
template<class T >
GetValue () const noexcept
 Retrieves the value at the memory address. More...
 
template<typename T >
CCast () const noexcept
 Casts the pointer to a specified type using C-style cast. More...
 
template<typename T >
RCast () const noexcept
 Casts the pointer to a specified type using reinterpret_cast. More...
 
template<typename T >
UCast () const noexcept
 Casts the pointer to a specified type using a union cast. More...
 
MemAddr Offset (ptrdiff_t offset) const noexcept
 Offsets the memory address by a specified amount. More...
 
MemAddrOffsetSelf (ptrdiff_t offset) noexcept
 Offsets the memory address by a specified amount in-place. More...
 
MemAddr Deref (ptrdiff_t deref=1) const
 Dereferences the memory address a specified number of times. More...
 
MemAddrDerefSelf (ptrdiff_t deref=1)
 Dereferences the memory address a specified number of times in-place. More...
 
MemAddr FollowNearCall (ptrdiff_t opcodeOffset=0x1, ptrdiff_t nextInstructionOffset=0x5) const
 Follows a near call to resolve the address. More...
 
MemAddrFollowNearCallSelf (ptrdiff_t opcodeOffset=0x1, ptrdiff_t nextInstructionOffset=0x5)
 Follows a near call to resolve the address in-place. More...
 
MemAddr ResolveRelativeAddress (ptrdiff_t registerOffset=0x0, ptrdiff_t nextInstructionOffset=0x4) const
 Resolves a relative address. More...
 
MemAddrResolveRelativeAddressSelf (ptrdiff_t registerOffset=0x0, ptrdiff_t nextInstructionOffset=0x4)
 Resolves a relative address in-place. More...
 

Detailed Description

A wrapper class for memory addresses, providing utility functions for pointer manipulation.

Definition at line 11 of file mem_addr.hpp.

Constructor & Destructor Documentation

◆ MemAddr()

plugify::MemAddr::MemAddr ( uintptr_t  ptr)
inlinenoexcept

Constructor initializing the pointer with a uintptr_t value.

Parameters
ptrThe uintptr_t value to initialize the pointer with.

Definition at line 22 of file mem_addr.hpp.

Member Function Documentation

◆ CCast()

template<typename T >
T plugify::MemAddr::CCast ( ) const
inlinenoexcept

Casts the pointer to a specified type using C-style cast.

Template Parameters
TThe type to cast to.
Returns
The casted pointer.

Definition at line 107 of file mem_addr.hpp.

◆ Deref()

MemAddr plugify::MemAddr::Deref ( ptrdiff_t  deref = 1) const
inline

Dereferences the memory address a specified number of times.

Parameters
derefThe number of times to dereference.
Returns
A new MemAddr object after dereferencing.

Definition at line 159 of file mem_addr.hpp.

◆ DerefSelf()

MemAddr& plugify::MemAddr::DerefSelf ( ptrdiff_t  deref = 1)
inline

Dereferences the memory address a specified number of times in-place.

Parameters
derefThe number of times to dereference.
Returns
A reference to the current MemAddr object.

Definition at line 175 of file mem_addr.hpp.

◆ FollowNearCall()

MemAddr plugify::MemAddr::FollowNearCall ( ptrdiff_t  opcodeOffset = 0x1,
ptrdiff_t  nextInstructionOffset = 0x5 
) const
inline

Follows a near call to resolve the address.

Parameters
opcodeOffsetThe offset to the opcode.
nextInstructionOffsetThe offset to the next instruction.
Returns
A new MemAddr object with the resolved address.

Definition at line 190 of file mem_addr.hpp.

◆ FollowNearCallSelf()

MemAddr& plugify::MemAddr::FollowNearCallSelf ( ptrdiff_t  opcodeOffset = 0x1,
ptrdiff_t  nextInstructionOffset = 0x5 
)
inline

Follows a near call to resolve the address in-place.

Parameters
opcodeOffsetThe offset to the opcode.
nextInstructionOffsetThe offset to the next instruction.
Returns
A reference to the current MemAddr object with the resolved address.

Definition at line 200 of file mem_addr.hpp.

◆ GetPtr()

uintptr_t plugify::MemAddr::GetPtr ( ) const
inlinenoexcept

Returns the uintptr_t representation of the pointer.

Returns
The uintptr_t value of the pointer.

Definition at line 87 of file mem_addr.hpp.

◆ GetValue()

template<class T >
T plugify::MemAddr::GetValue ( ) const
inlinenoexcept

Retrieves the value at the memory address.

Template Parameters
TThe type of the value.
Returns
The value at the memory address.

Definition at line 97 of file mem_addr.hpp.

◆ Offset()

MemAddr plugify::MemAddr::Offset ( ptrdiff_t  offset) const
inlinenoexcept

Offsets the memory address by a specified amount.

Parameters
offsetThe offset value.
Returns
A new MemAddr object with the offset applied.

Definition at line 140 of file mem_addr.hpp.

◆ OffsetSelf()

MemAddr& plugify::MemAddr::OffsetSelf ( ptrdiff_t  offset)
inlinenoexcept

Offsets the memory address by a specified amount in-place.

Parameters
offsetThe offset value.
Returns
A reference to the current MemAddr object.

Definition at line 149 of file mem_addr.hpp.

◆ operator bool()

plugify::MemAddr::operator bool ( ) const
inlineexplicitnoexcept

Explicit conversion operator to bool, indicating if the pointer is non-zero.

Returns
True if the pointer is non-zero, false otherwise.

Definition at line 52 of file mem_addr.hpp.

◆ operator uintptr_t()

plugify::MemAddr::operator uintptr_t ( ) const
inlinenoexcept

Converts the MemAddr object to a uintptr_t.

Returns
The uintptr_t representation of the memory address.

Definition at line 36 of file mem_addr.hpp.

◆ operator void *()

plugify::MemAddr::operator void * ( ) const
inlinenoexcept

Converts the MemAddr object to a void pointer.

Returns
The void pointer representation of the memory address.

Definition at line 44 of file mem_addr.hpp.

◆ operator!=()

bool plugify::MemAddr::operator!= ( const MemAddr addr) const
inlinenoexcept

Inequality operator.

Parameters
addrThe MemAddr object to compare with.
Returns
True if the pointers are not equal, false otherwise.

Definition at line 61 of file mem_addr.hpp.

◆ operator==() [1/2]

bool plugify::MemAddr::operator== ( const MemAddr addr) const
inlinenoexcept

Equality operator.

Parameters
addrThe MemAddr object to compare with.
Returns
True if the pointers are equal, false otherwise.

Definition at line 70 of file mem_addr.hpp.

◆ operator==() [2/2]

bool plugify::MemAddr::operator== ( const uintptr_t &  addr) const
inlinenoexcept

Equality operator for comparing with uintptr_t.

Parameters
addrThe uintptr_t value to compare with.
Returns
True if the pointer is equal to the uintptr_t value, false otherwise.

Definition at line 79 of file mem_addr.hpp.

◆ RCast()

template<typename T >
T plugify::MemAddr::RCast ( ) const
inlinenoexcept

Casts the pointer to a specified type using reinterpret_cast.

Template Parameters
TThe type to cast to.
Returns
The casted pointer.

Definition at line 117 of file mem_addr.hpp.

◆ requires()

template<typename T >
plugify::MemAddr::requires ( std::is_pointer_v< T > or std::is_null_pointer_v< T >  )
inlinenoexcept

Template constructor initializing the pointer with a typed pointer.

Template Parameters
TThe type of the pointer.
Parameters
ptrThe typed pointer to initialize with.

Definition at line 29 of file mem_addr.hpp.

◆ ResolveRelativeAddress()

MemAddr plugify::MemAddr::ResolveRelativeAddress ( ptrdiff_t  registerOffset = 0x0,
ptrdiff_t  nextInstructionOffset = 0x4 
) const
inline

Resolves a relative address.

Parameters
registerOffsetThe offset to the register.
nextInstructionOffsetThe offset to the next instruction.
Returns
A new MemAddr object with the resolved address.

Definition at line 210 of file mem_addr.hpp.

◆ ResolveRelativeAddressSelf()

MemAddr& plugify::MemAddr::ResolveRelativeAddressSelf ( ptrdiff_t  registerOffset = 0x0,
ptrdiff_t  nextInstructionOffset = 0x4 
)
inline

Resolves a relative address in-place.

Parameters
registerOffsetThe offset to the register.
nextInstructionOffsetThe offset to the next instruction.
Returns
A reference to the current MemAddr object with the resolved address.

Definition at line 223 of file mem_addr.hpp.

◆ UCast()

template<typename T >
T plugify::MemAddr::UCast ( ) const
inlinenoexcept

Casts the pointer to a specified type using a union cast.

Template Parameters
TThe type to cast to.
Returns
The casted pointer.

Definition at line 127 of file mem_addr.hpp.


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