From eb212cd27e104ce989e483536e8be6123c594255 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 25 Feb 2023 15:20:12 +0100 Subject: [DYNAREC] Small imrvment in managing memory protection --- src/custommem.c | 7 ++++--- src/wrapped/wrappedlibc.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/custommem.c b/src/custommem.c index b9abcc3d..e261b62f 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -968,11 +968,12 @@ void updateProtection(uintptr_t addr, size_t size, uint32_t prot) memprot[i].prot = newblock; } for (uintptr_t i=idx; i<=end; ++i) { - uint32_t dyn=(memprot[i>>16].prot[i&0xffff]&PROT_DYN); - uint32_t mapped=(memprot[i>>16].prot[i&0xffff]&PROT_MMAP); + uint32_t old_prot = memprot[i>>16].prot[i&0xffff]; + uint32_t dyn=(old_prot&PROT_DYN); + uint32_t mapped=(old_prot&PROT_MMAP); if(dyn && (prot&PROT_WRITE)) { // need to remove the write protection from this block dyn = PROT_DYNAREC; - mprotect((void*)(i<