plugify 1.2.6
Loading...
Searching...
No Matches
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

constexpr MemAddr () noexcept
 Default constructor initializing the pointer to 0.
 
constexpr MemAddr (const uintptr_t ptr) noexcept
 Constructor initializing the pointer with a uintptr_t value.
 
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.
 
constexpr MemAddr (const MemAddr &other) noexcept=default
 Constructor initializing the pointer with a void pointer.
 
constexpr MemAddr (MemAddr &&other) noexcept=default
 Move constructor initializing the pointer with another MemAddr.
 
constexpr MemAddroperator= (const MemAddr &other) noexcept=default
 Assignment operator to copy another MemAddr.
 
constexpr MemAddroperator= (MemAddr &&other) noexcept=default
 Move assignment operator to move another MemAddr.
 
constexpr operator uintptr_t () const noexcept
 Converts the MemAddr object to a uintptr_t.
 
constexpr operator void * () const noexcept
 Converts the MemAddr object to a void pointer.
 
constexpr operator bool () const noexcept
 Explicit conversion operator to bool, indicating if the pointer is non-zero.
 
constexpr bool operator!= (const MemAddr addr) const noexcept
 Inequality operator.
 
constexpr bool operator< (const MemAddr addr) const noexcept
 Less-than comparison operator.
 
constexpr bool operator== (const MemAddr addr) const noexcept
 Equality operator.
 
constexpr bool operator== (const uintptr_t addr) const noexcept
 Equality operator for comparing with uintptr_t.
 
constexpr uintptr_t GetPtr () const noexcept
 Returns the uintptr_t representation of the pointer.
 
template<class T >
constexpr T GetValue () const noexcept
 Retrieves the value at the memory address.
 
template<typename T >
constexpr T CCast () const noexcept
 Casts the pointer to a specified type using C-style cast.
 
template<typename T >
constexpr T RCast () const noexcept
 Casts the pointer to a specified type using reinterpret_cast.
 
template<typename T >
constexpr T UCast () const noexcept
 Casts the pointer to a specified type using a union cast.
 
constexpr MemAddr Offset (const ptrdiff_t offset) const noexcept
 Offsets the memory address by a specified amount.
 
constexpr MemAddrOffsetSelf (const ptrdiff_t offset) noexcept
 Offsets the memory address by a specified amount in-place.
 
constexpr MemAddr Deref (ptrdiff_t deref=1) const
 Dereferences the memory address a specified number of times.
 
constexpr MemAddrDerefSelf (ptrdiff_t deref=1)
 Dereferences the memory address a specified number of times in-place.
 
MemAddr FollowNearCall (const ptrdiff_t opcodeOffset=0x1, const ptrdiff_t nextInstructionOffset=0x5) const
 Follows a near call to resolve the address.
 
MemAddrFollowNearCallSelf (const ptrdiff_t opcodeOffset=0x1, const ptrdiff_t nextInstructionOffset=0x5)
 Follows a near call to resolve the address in-place.
 
MemAddr ResolveRelativeAddress (const ptrdiff_t registerOffset=0x0, const ptrdiff_t nextInstructionOffset=0x4) const
 Resolves a relative address.
 
MemAddrResolveRelativeAddressSelf (const ptrdiff_t registerOffset=0x0, const ptrdiff_t nextInstructionOffset=0x4)
 Resolves a relative address in-place.
 

Detailed Description

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

Definition at line 10 of file mem_addr.hpp.

Constructor & Destructor Documentation

◆ MemAddr() [1/5]

constexpr plugify::MemAddr::MemAddr ( )
inlineconstexprnoexcept

Default constructor initializing the pointer to 0.

Definition at line 15 of file mem_addr.hpp.

◆ MemAddr() [2/5]

constexpr plugify::MemAddr::MemAddr ( const uintptr_t  ptr)
inlineconstexprnoexcept

Constructor initializing the pointer with a uintptr_t value.

Parameters
ptrThe uintptr_t value to initialize the pointer with.

Definition at line 21 of file mem_addr.hpp.

◆ MemAddr() [3/5]

template<typename T >
requires (std::is_pointer_v<T> or std::is_null_pointer_v<T>)
plugify::MemAddr::MemAddr ( ptr)
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.

◆ MemAddr() [4/5]

constexpr plugify::MemAddr::MemAddr ( const MemAddr other)
constexprdefaultnoexcept

Constructor initializing the pointer with a void pointer.

Parameters
otherThe void pointer to initialize with.

◆ MemAddr() [5/5]

constexpr plugify::MemAddr::MemAddr ( MemAddr &&  other)
constexprdefaultnoexcept

Move constructor initializing the pointer with another MemAddr.

Parameters
otherThe MemAddr to move from.

Member Function Documentation

◆ CCast()

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

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 141 of file mem_addr.hpp.

◆ Deref()

constexpr MemAddr plugify::MemAddr::Deref ( ptrdiff_t  deref = 1) const
inlineconstexpr

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 193 of file mem_addr.hpp.

◆ DerefSelf()

constexpr MemAddr & plugify::MemAddr::DerefSelf ( ptrdiff_t  deref = 1)
inlineconstexpr

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 209 of file mem_addr.hpp.

◆ FollowNearCall()

MemAddr plugify::MemAddr::FollowNearCall ( const ptrdiff_t  opcodeOffset = 0x1,
const 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 224 of file mem_addr.hpp.

◆ FollowNearCallSelf()

MemAddr & plugify::MemAddr::FollowNearCallSelf ( const ptrdiff_t  opcodeOffset = 0x1,
const 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 234 of file mem_addr.hpp.

◆ GetPtr()

constexpr uintptr_t plugify::MemAddr::GetPtr ( ) const
inlineconstexprnoexcept

Returns the uintptr_t representation of the pointer.

Returns
The uintptr_t value of the pointer.

Definition at line 121 of file mem_addr.hpp.

◆ GetValue()

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

Retrieves the value at the memory address.

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

Definition at line 131 of file mem_addr.hpp.

◆ Offset()

constexpr MemAddr plugify::MemAddr::Offset ( const ptrdiff_t  offset) const
inlineconstexprnoexcept

Offsets the memory address by a specified amount.

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

Definition at line 174 of file mem_addr.hpp.

◆ OffsetSelf()

constexpr MemAddr & plugify::MemAddr::OffsetSelf ( const ptrdiff_t  offset)
inlineconstexprnoexcept

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 183 of file mem_addr.hpp.

◆ operator bool()

constexpr plugify::MemAddr::operator bool ( ) const
inlineexplicitconstexprnoexcept

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 77 of file mem_addr.hpp.

◆ operator uintptr_t()

constexpr plugify::MemAddr::operator uintptr_t ( ) const
inlineconstexprnoexcept

Converts the MemAddr object to a uintptr_t.

Returns
The uintptr_t representation of the memory address.

Definition at line 61 of file mem_addr.hpp.

◆ operator void *()

constexpr plugify::MemAddr::operator void * ( ) const
inlineconstexprnoexcept

Converts the MemAddr object to a void pointer.

Returns
The void pointer representation of the memory address.

Definition at line 69 of file mem_addr.hpp.

◆ operator!=()

constexpr bool plugify::MemAddr::operator!= ( const MemAddr  addr) const
inlineconstexprnoexcept

Inequality operator.

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

Definition at line 86 of file mem_addr.hpp.

◆ operator<()

constexpr bool plugify::MemAddr::operator< ( const MemAddr  addr) const
inlineconstexprnoexcept

Less-than comparison operator.

Parameters
addrThe MemAddr object to compare with.
Returns
True if this pointer is less than the other, false otherwise.

Definition at line 95 of file mem_addr.hpp.

◆ operator=() [1/2]

constexpr MemAddr & plugify::MemAddr::operator= ( const MemAddr other)
constexprdefaultnoexcept

Assignment operator to copy another MemAddr.

Parameters
otherThe MemAddr to copy from.
Returns
A reference to the current MemAddr object.

◆ operator=() [2/2]

constexpr MemAddr & plugify::MemAddr::operator= ( MemAddr &&  other)
constexprdefaultnoexcept

Move assignment operator to move another MemAddr.

Parameters
otherThe MemAddr to move from.
Returns
A reference to the current MemAddr object.

◆ operator==() [1/2]

constexpr bool plugify::MemAddr::operator== ( const MemAddr  addr) const
inlineconstexprnoexcept

Equality operator.

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

Definition at line 104 of file mem_addr.hpp.

◆ operator==() [2/2]

constexpr bool plugify::MemAddr::operator== ( const uintptr_t  addr) const
inlineconstexprnoexcept

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 113 of file mem_addr.hpp.

◆ RCast()

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

Casts the pointer to a specified type using reinterpret_cast.

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

Definition at line 151 of file mem_addr.hpp.

◆ ResolveRelativeAddress()

MemAddr plugify::MemAddr::ResolveRelativeAddress ( const ptrdiff_t  registerOffset = 0x0,
const 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 244 of file mem_addr.hpp.

◆ ResolveRelativeAddressSelf()

MemAddr & plugify::MemAddr::ResolveRelativeAddressSelf ( const ptrdiff_t  registerOffset = 0x0,
const 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 257 of file mem_addr.hpp.

◆ UCast()

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

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 161 of file mem_addr.hpp.

Member Data Documentation

◆ _addr

void* plugify::MemAddr::_addr

Definition at line 267 of file mem_addr.hpp.

◆ _ptr

uintptr_t plugify::MemAddr::_ptr

Definition at line 268 of file mem_addr.hpp.


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