diff --git a/src/memory/byte_patch.cpp b/src/memory/byte_patch.cpp index 158281c4..7e3ac5a8 100644 --- a/src/memory/byte_patch.cpp +++ b/src/memory/byte_patch.cpp @@ -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 diff --git a/src/memory/byte_patch.hpp b/src/memory/byte_patch.hpp index 8565d0f3..861abc4f 100644 --- a/src/memory/byte_patch.hpp +++ b/src/memory/byte_patch.hpp @@ -67,7 +67,6 @@ namespace memory std::unique_ptr m_value; std::unique_ptr m_original_bytes; std::size_t m_size; - DWORD m_old_protect; friend bool operator==(const std::unique_ptr& a, const byte_patch* b); };