Skip to content

Commit 3ed2141

Browse files
committed
Fix Release build type with VirtualUnprotector
1 parent 822c020 commit 3ed2141

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

include/dynlibutils/vthook.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class VirtualUnprotector
3737
m_nLength = nLength;
3838
m_pTarget = pTarget;
3939

40-
assert(VirtualProtect(pTarget, nLength, PAGE_EXECUTE_READWRITE, &m_nOldProtect));
40+
bool bIsUnprotected = VirtualProtect(pTarget, nLength, PAGE_EXECUTE_READWRITE, &m_nOldProtect);
4141
#else
4242
long pageSize = sysconf(_SC_PAGESIZE);
4343

@@ -54,18 +54,22 @@ class VirtualUnprotector
5454
m_nLength = nAligned;
5555
m_pTarget = pPageStart;
5656

57-
assert(!mprotect(pPageStart, nAligned, PROT_READ | PROT_WRITE));
57+
bool bIsUnprotected = !mprotect(pPageStart, nAligned, PROT_READ | PROT_WRITE);
5858
#endif
59+
60+
assert(bIsUnprotected);
5961
}
6062

6163
~VirtualUnprotector()
6264
{
6365
#if _WIN32
6466
DWORD origProtect;
65-
assert(VirtualProtect(m_pTarget, m_nLength, m_nOldProtect, &origProtect));
67+
bool bIsUnprotected = VirtualProtect(m_pTarget, m_nLength, m_nOldProtect, &origProtect);
6668
#else
67-
assert(!mprotect(m_pTarget, m_nLength, m_nOldProtect));
69+
bool bIsUnprotected = !mprotect(m_pTarget, m_nLength, m_nOldProtect);
6870
#endif
71+
72+
assert(bIsUnprotected);
6973
}
7074

7175
private:

0 commit comments

Comments
 (0)