@@ -90,8 +90,9 @@ class CMemory
9090public:
9191 // Constructor ones.
9292 constexpr CMemory (const CMemory&) noexcept = default;
93+ constexpr CMemory (CMemory&&) noexcept = default;
9394 constexpr CMemory& operator =(const CMemory&) noexcept = default ;
94- constexpr CMemory (CMemory&& other) noexcept : m_addr(std::move(other.m_addr)) {}
95+ constexpr CMemory& operator = (CMemory&& other) noexcept = default ;
9596 constexpr CMemory (const std::uintptr_t addr) : m_addr(addr) {}
9697 constexpr CMemory (void * ptr = nullptr ) : m_ptr(ptr) {}
9798
@@ -117,12 +118,17 @@ class CMemory
117118 template <typename PTR> constexpr PTR RCast () const noexcept { return reinterpret_cast <PTR>(m_addr); }
118119 template <typename PTR> constexpr PTR UCast () const noexcept { union { PTR cptr; std::uintptr_t addr; } cast; cast.addr = m_addr; return cast.cptr ; }
119120
120- // / Access methods.
121+ // / Access methods (getters) .
121122 constexpr void * GetPtr () const noexcept { return m_ptr; }
122123 constexpr std::ptrdiff_t GetAddr () const noexcept { return m_addr; }
123124 template <typename T> constexpr T &GetRef () const noexcept { return *RCast<T*>(); }
124125 template <typename T> constexpr T Get () const { return GetRef<T>(); }
125126
127+ // / Access methods (setters).
128+ constexpr void * SetPtr (void * pNew) noexcept { return m_ptr = pNew; }
129+ constexpr std::ptrdiff_t SetAddr (std::ptrdiff_t nNew) noexcept { return m_addr = nNew; }
130+ template <typename T> constexpr T &Set (const T &other) noexcept { return &GetRef<T>() = other; }
131+
126132 // Checks methods.
127133 bool IsValid () const noexcept { return GetPtr () != nullptr ; }
128134
@@ -131,7 +137,7 @@ class CMemory
131137 CMemory& OffsetSelf (const std::ptrdiff_t offset) noexcept { m_addr += offset; return *this ; }
132138
133139 // Multi-level dereferencing methods.
134- CMemory Deref (std::uintptr_t deref = 1 , std::ptrdiff_t offset = 0 ) const
140+ CMemory Deref (std::uintptr_t deref = 1 , std::ptrdiff_t offset = 0 ) const noexcept
135141 {
136142 std::uintptr_t base = m_addr;
137143
@@ -142,20 +148,20 @@ class CMemory
142148
143149 return base;
144150 }
145- CMemory& DerefSelf (int deref = 1 , std::ptrdiff_t offset = 0 ) { while (m_addr && deref--) m_addr = *reinterpret_cast <std::uintptr_t *>(m_addr + offset); return *this ; }
151+ CMemory& DerefSelf (int deref = 1 , std::ptrdiff_t offset = 0 ) noexcept { while (m_addr && deref--) m_addr = *reinterpret_cast <std::uintptr_t *>(m_addr + offset); return *this ; }
146152
147- CMemory FollowNearCall (const std::ptrdiff_t opcodeOffset = 0x1 , const std::ptrdiff_t nextInstructionOffset = 0x5 ) const { return ResolveRelativeAddress (opcodeOffset, nextInstructionOffset); }
148- CMemory& FollowNearCallSelf (const std::ptrdiff_t opcodeOffset = 0x1 , const std::ptrdiff_t nextInstructionOffset = 0x5 ) { return ResolveRelativeAddressSelf (opcodeOffset, nextInstructionOffset); }
153+ CMemory FollowNearCall (const std::ptrdiff_t opcodeOffset = 0x1 , const std::ptrdiff_t nextInstructionOffset = 0x5 ) const noexcept { return ResolveRelativeAddress (opcodeOffset, nextInstructionOffset); }
154+ CMemory& FollowNearCallSelf (const std::ptrdiff_t opcodeOffset = 0x1 , const std::ptrdiff_t nextInstructionOffset = 0x5 ) noexcept { return ResolveRelativeAddressSelf (opcodeOffset, nextInstructionOffset); }
149155
150- CMemory ResolveRelativeAddress (const std::ptrdiff_t registerOffset = 0x0 , const std::ptrdiff_t nextInstructionOffset = 0x4 ) const
156+ CMemory ResolveRelativeAddress (const std::ptrdiff_t registerOffset = 0x0 , const std::ptrdiff_t nextInstructionOffset = 0x4 ) const noexcept
151157 {
152158 const std::uintptr_t skipRegister = m_addr + registerOffset;
153159 const std::uintptr_t nextInstruction = m_addr + nextInstructionOffset;
154160 const std::int32_t relativeAddress = *reinterpret_cast <std::int32_t *>(skipRegister);
155161
156162 return nextInstruction + relativeAddress;
157163 }
158- CMemory& ResolveRelativeAddressSelf (const std::ptrdiff_t registerOffset = 0x0 , const std::ptrdiff_t nextInstructionOffset = 0x4 )
164+ CMemory& ResolveRelativeAddressSelf (const std::ptrdiff_t registerOffset = 0x0 , const std::ptrdiff_t nextInstructionOffset = 0x4 ) noexcept
159165 {
160166 const std::uintptr_t skipRegister = m_addr + registerOffset;
161167 const std::uintptr_t nextInstruction = m_addr + nextInstructionOffset;
@@ -246,8 +252,6 @@ class CMemoryView : public CMemory
246252 CMemory operator +(const CMemory right) const noexcept { return Offset (static_cast <std::ptrdiff_t >(right.GetAddr ())); }
247253 CMemory operator -(const CMemory right) const noexcept { return Offset (static_cast <std::ptrdiff_t >(right.GetAddr ())); }
248254
249- using CMemory::IsValid;
250-
251255 // / Cast methods (view ones).
252256 constexpr T* CCastView () const noexcept { return CBase::CCast<T*>(); }
253257 constexpr T* RCastView () const noexcept { return CBase::RCast<T*>(); }
0 commit comments