diff options
Diffstat (limited to 'src/tools')
| -rwxr-xr-x | src/tools/bridge.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/tools/bridge.c b/src/tools/bridge.c index 3bc7ca22..16aaaf74 100755 --- a/src/tools/bridge.c +++ b/src/tools/bridge.c @@ -60,6 +60,9 @@ brick_t* NewBrick(void* old) if(ptr == MAP_FAILED) { printf_log(LOG_NONE, "Warning, cannot allocate 0x%lx aligned bytes for bridge, will probably crash later\n", NBRICK*sizeof(onebridge_t)); } + #ifdef DYNAREC + setProtection((uintptr_t)ptr, NBRICK * sizeof(onebridge_t), PROT_READ | PROT_WRITE | PROT_EXEC | PROT_NOPROT); + #endif dynarec_log(LOG_INFO, "New Bridge brick at %p (size 0x%zx)\n", ptr, NBRICK*sizeof(onebridge_t)); ret->b = ptr; return ret; @@ -82,10 +85,6 @@ void FreeBridge(bridge_t** bridge) x64emu_t* emu = thread_get_emu(); while(b) { brick_t *n = b->next; - #ifdef DYNAREC - if(getProtection((uintptr_t)b->b)&(PROT_DYNAREC|PROT_DYNAREC_R)) - unprotectDB((uintptr_t)b->b, NBRICK*sizeof(onebridge_t), 0); - #endif my_munmap(emu, b->b, NBRICK*sizeof(onebridge_t)); box_free(b); b = n; @@ -119,24 +118,12 @@ uintptr_t AddBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char* kh_value(bridge->bridgemap, k) = (uintptr_t)&b->b[sz].CC; mutex_unlock(&my_context->mutex_bridge); - #ifdef DYNAREC - int prot = 0; - if(box64_dynarec) { - prot=(getProtection((uintptr_t)b->b)&(PROT_DYNAREC|PROT_DYNAREC_R))?1:0; - if(prot) - unprotectDB((uintptr_t)b->b, NBRICK*sizeof(onebridge_t), 0); // don't mark blocks, it's only new one - } - #endif b->b[sz].CC = 0xCC; b->b[sz].S = 'S'; b->b[sz].C='C'; b->b[sz].w = w; b->b[sz].f = (uintptr_t)fnc; b->b[sz].C3 = N?0xC2:0xC3; b->b[sz].N = N; - #ifdef DYNAREC - if(box64_dynarec) - protectDB((uintptr_t)b->b, NBRICK*sizeof(onebridge_t)); - #endif #ifdef HAVE_TRACE if(name) addBridgeName(fnc, name); |