mirror of
https://github.com/YimMenu/YimMenuV2.git
synced 2026-10-10 11:53:14 +08:00
fix(byte_patches): rewrite byte patches to ensure clang support
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#include "BytePatches.hpp"
|
||||
|
||||
namespace YimMenu
|
||||
{
|
||||
BytePatches::Patch::~Patch()
|
||||
{
|
||||
Restore();
|
||||
}
|
||||
|
||||
void BytePatches::Patch::Apply()
|
||||
{
|
||||
if (m_Applied || !g_Running)
|
||||
return;
|
||||
memcpy(m_Address, m_Value.get(), m_Size);
|
||||
m_Applied = true;
|
||||
}
|
||||
|
||||
void BytePatches::Patch::Restore()
|
||||
{
|
||||
if (!m_Applied)
|
||||
return;
|
||||
memcpy(m_Address, m_OriginalBytes.get(), m_Size);
|
||||
m_Applied = false;
|
||||
}
|
||||
|
||||
bool operator==(const std::shared_ptr<BytePatches::Patch>& a, const BytePatches::Patch* b)
|
||||
{
|
||||
return a->m_Address == b->m_Address;
|
||||
}
|
||||
|
||||
void BytePatches::Remove(std::shared_ptr<Patch>& patch)
|
||||
{
|
||||
if (const auto it = std::find(m_Patches.begin(), m_Patches.end(), patch.get()); it != m_Patches.end())
|
||||
{
|
||||
m_Patches.erase(it);
|
||||
}
|
||||
patch.reset();
|
||||
}
|
||||
|
||||
void BytePatches::RestoreAll()
|
||||
{
|
||||
m_Patches.clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user