fix crash on reinject (#3409)

Co-authored-by: gir489 <100792176+gir489returns@users.noreply.github.com>
This commit is contained in:
Quentin 2024-07-23 18:19:39 +02:00 committed by GitHub
parent f6a6f5dd86
commit bba720f059
2 changed files with 10 additions and 7 deletions

View File

@ -9,20 +9,24 @@ namespace memory
void byte_patch::apply() const
{
DWORD temp;
DWORD old_protect;
VirtualProtect(m_address, m_size, PAGE_EXECUTE_READWRITE, (PDWORD)&old_protect);
VirtualProtect(m_address, m_size, PAGE_EXECUTE_READWRITE, (PDWORD)&m_old_protect);
memcpy(m_address, m_value.get(), m_size);
VirtualProtect(m_address, m_size, m_old_protect, &temp);
DWORD unused;
VirtualProtect(m_address, m_size, old_protect, &unused);
}
void byte_patch::restore() const
{
DWORD temp;
DWORD old_protect;
VirtualProtect(m_address, m_size, PAGE_EXECUTE_READWRITE, (PDWORD)&old_protect);
VirtualProtect(m_address, m_size, PAGE_EXECUTE_READWRITE, (PDWORD)&temp);
memcpy(m_address, m_original_bytes.get(), m_size);
VirtualProtect(m_address, m_size, m_old_protect, &temp);
DWORD unused;
VirtualProtect(m_address, m_size, old_protect, &unused);
}
void byte_patch::remove() const

View File

@ -67,7 +67,6 @@ namespace memory
std::unique_ptr<byte[]> m_value;
std::unique_ptr<byte[]> m_original_bytes;
std::size_t m_size;
DWORD m_old_protect;
friend bool operator==(const std::unique_ptr<byte_patch>& a, const byte_patch* b);
};