Skip to content

Commit

Permalink
Update ARMPatch.cpp
Browse files Browse the repository at this point in the history
Fixes Reprotection for the memory chunk flagged as a special memory (errno=EACCES)
  • Loading branch information
RusJJ committed Jun 30, 2023
1 parent f1420b2 commit f63e785
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions armpatch_src/ARMPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ namespace ARMPatch
int Unprotect(uintptr_t addr, size_t len)
{
#ifdef __32BIT
return mprotect((void*)(addr & 0xFFFFF000), len, PROT_READ | PROT_WRITE | PROT_EXEC);
if(mprotect((void*)(addr & 0xFFFFF000), len, PROT_READ | PROT_WRITE | PROT_EXEC) == 0) return 0;
return mprotect((void*)(addr & 0xFFFFF000), len, PROT_READ | PROT_WRITE);
#elif defined __64BIT
return mprotect((void*)(addr & 0xFFFFFFFFFFFFF000), len, PROT_READ | PROT_WRITE | PROT_EXEC);
if(mprotect((void*)(addr & 0xFFFFFFFFFFFFF000), len, PROT_READ | PROT_WRITE | PROT_EXEC) == 0) return 0;
return mprotect((void*)(addr & 0xFFFFFFFFFFFFF000), len, PROT_READ | PROT_WRITE);
#endif
}
void Write(uintptr_t dest, uintptr_t src, size_t size)
Expand Down

0 comments on commit f63e785

Please sign in to comment.