mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-23 04:27:25 +08:00
fix crash on reinject (#3409)
Co-authored-by: gir489 <100792176+gir489returns@users.noreply.github.com>
This commit is contained in:
parent
f6a6f5dd86
commit
bba720f059
@ -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
|
||||
|
@ -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);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user