Added unprotectExecutableMemory for future use.

This commit is contained in:
XMRig 2019-06-04 15:48:32 +07:00
parent f620ffe899
commit ac43cd4f9c
3 changed files with 14 additions and 0 deletions

View file

@ -43,6 +43,7 @@ public:
static void flushInstructionCache(void *p, size_t size);
static void freeLargePagesMemory(void *p, size_t size);
static void protectExecutableMemory(void *p, size_t size);
static void unprotectExecutableMemory(void *p, size_t size);
};

View file

@ -82,3 +82,9 @@ void xmrig::VirtualMemory::protectExecutableMemory(void *p, size_t size)
{
mprotect(p, size, PROT_READ | PROT_EXEC);
}
void xmrig::VirtualMemory::unprotectExecutableMemory(void *p, size_t size)
{
mprotect(p, size, PROT_WRITE | PROT_EXEC);
}

View file

@ -77,3 +77,10 @@ void xmrig::VirtualMemory::protectExecutableMemory(void *p, size_t size)
DWORD oldProtect;
VirtualProtect(p, size, PAGE_EXECUTE_READ, &oldProtect);
}
void xmrig::VirtualMemory::unprotectExecutableMemory(void *p, size_t size)
{
DWORD oldProtect;
VirtualProtect(p, size, PAGE_EXECUTE_READWRITE, &oldProtect);
}