diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-11-04 11:43:27 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-11-04 11:43:27 +0100 |
| commit | 3448e941710dbf11d2772d5782a0b2d44e7892b1 (patch) | |
| tree | 2c9ee9d17416e124b7baaa53eefafc2f0a0a7942 /src/custommem.c | |
| parent | 08085be36070ba22b9e2e99529826d60d5ba149f (diff) | |
| download | box64-3448e941710dbf11d2772d5782a0b2d44e7892b1.tar.gz box64-3448e941710dbf11d2772d5782a0b2d44e7892b1.zip | |
Improve handling of memory protection, and excution bit
Diffstat (limited to 'src/custommem.c')
| -rw-r--r-- | src/custommem.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/custommem.c b/src/custommem.c index 524e5f25..be9f39ed 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -1438,8 +1438,11 @@ void unprotectDB(uintptr_t addr, size_t size, int mark) if(mark) cleanDBFromAddressRange(cur, bend-cur, 0); mprotect((void*)cur, bend-cur, prot); - } else if(prot&PROT_DYNAREC_R) + } else if(prot&PROT_DYNAREC_R) { + if(mark) + cleanDBFromAddressRange(cur, bend-cur, 0); prot &= ~PROT_CUSTOM; + } } if (prot != oprot) rb_set(memprot, cur, bend, prot); @@ -1514,8 +1517,9 @@ void updateProtection(uintptr_t addr, size_t size, uint32_t prot) dyn = PROT_DYNAREC_R; } } - if ((prot|dyn) != oprot) - rb_set(memprot, cur, bend, prot|dyn); + uint32_t new_prot = prot?(prot|dyn):prot; + if (new_prot != oprot) + rb_set(memprot, cur, bend, new_prot); cur = bend; } UNLOCK_PROT(); |