TmpMenu/src/memory/byte_patch.cpp
maybegreat48 97a8c5d60b Add more spoofing options and added clang-format (#1020)
* feat(Spoofing): add spoofing
* feat(Spoofing): prepare code for player attach
* remove(PlayerAttach): isn't going to work due to netsync architecture
* fix(GUI): fix scaling
* feat(Project): add clang-format file
* feat(Classes): update classes
* fix(BlackHole): remove unnecessary cleanup
* fix(Formatting): fix formatting for initializer lists
* feat(clang-format): Set tab width and 1 space before comment

Co-authored-by: Yimura <24669514+Yimura@users.noreply.github.com>
2023-03-01 21:27:15 +00:00

38 lines
623 B
C++

#include "byte_patch.hpp"
namespace memory
{
byte_patch::~byte_patch()
{
restore();
}
void byte_patch::apply() const
{
memcpy(m_address, m_value.get(), m_size);
}
void byte_patch::restore() const
{
memcpy(m_address, m_original_bytes.get(), m_size);
}
void byte_patch::remove() const
{
if (const auto it = std::find(m_patches.begin(), m_patches.end(), this); it != m_patches.end())
{
m_patches.erase(it);
}
}
void byte_patch::restore_all()
{
m_patches.clear();
}
bool operator==(const std::unique_ptr<byte_patch>& a, const byte_patch* b)
{
return a->m_address == b->m_address;
}
}