diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-09-09 17:11:29 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-09-09 17:11:29 +0200 |
| commit | 362402ffbf09d4eefde80b6d15b7d73c9b6a377a (patch) | |
| tree | 155b38519f3544c090d08a65ce09601bd2f90a1c /src | |
| parent | 5ce868b10092ec2bef678c6ebbbf22dde8d62032 (diff) | |
| download | box64-362402ffbf09d4eefde80b6d15b7d73c9b6a377a.tar.gz box64-362402ffbf09d4eefde80b6d15b7d73c9b6a377a.zip | |
Improved wrapped function clone handling of CLONE_NEWUSER flag
Diffstat (limited to 'src')
| -rw-r--r-- | src/box64context.c | 2 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibc.c | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/box64context.c b/src/box64context.c index d2cd150a..27da6aca 100644 --- a/src/box64context.c +++ b/src/box64context.c @@ -138,7 +138,7 @@ void relockMutex(int locks) #undef GO } -static void init_mutexes(box64context_t* context) +void init_mutexes(box64context_t* context) { #ifndef DYNAREC pthread_mutexattr_t attr; diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 5333b90b..fd0eb377 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -3598,8 +3598,10 @@ typedef struct clone_arg_s { uintptr_t fnc; void* args; int stack_clone_used; + int flags; void* tls; } clone_arg_t; +void init_mutexes(box64context_t* context); static int clone_fn(void* p) { clone_arg_t* arg = (clone_arg_t*)p; @@ -3608,6 +3610,10 @@ static int clone_fn(void* p) R_RSP = arg->stack; emu->flags.quitonexit = 1; thread_set_emu(emu); + if(arg->flags&CLONE_NEWUSER) { + init_mutexes(my_context); + ResetSegmentsCache(emu); + } int ret = RunFunctionWithEmu(emu, 0, arg->fnc, 1, arg->args); int exited = (emu->flags.quitonexit==2); thread_set_emu(NULL); @@ -3644,6 +3650,7 @@ EXPORT int my_clone(x64emu_t* emu, void* fn, void* stack, int flags, void* args, arg->fnc = (uintptr_t)fn; arg->tls = tls; arg->emu = newemu; + arg->flags = flags; if((flags|(CLONE_VM|CLONE_VFORK|CLONE_SETTLS))==flags) // that's difficult to setup, so lets ignore all those flags :S flags&=~(CLONE_VM|CLONE_VFORK|CLONE_SETTLS); int64_t ret = clone(clone_fn, (void*)((uintptr_t)mystack+1024*1024), flags, arg, parent, NULL, child); |