diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-02-16 13:44:54 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-02-16 13:44:54 +0100 |
| commit | 65f75b0cc0ead29db622afc790b6167c476e4960 (patch) | |
| tree | f4a2ab63e4f12ba67995a25c029468807d5e83fe /src/wrapped | |
| parent | c50b0ef9e8342b634af873134a52ec3b7b889f42 (diff) | |
| download | box64-65f75b0cc0ead29db622afc790b6167c476e4960.tar.gz box64-65f75b0cc0ead29db622afc790b6167c476e4960.zip | |
[ELFLOADER] Better handling of STB_GNU_UNIQUE binded symbol (prevent dlclose)
Diffstat (limited to 'src/wrapped')
| -rw-r--r-- | src/wrapped/wrappedlibdl.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/wrapped/wrappedlibdl.c b/src/wrapped/wrappedlibdl.c index f85b007d..b781b9cb 100644 --- a/src/wrapped/wrappedlibdl.c +++ b/src/wrapped/wrappedlibdl.c @@ -386,6 +386,7 @@ void* my_dlsym(x64emu_t* emu, void *handle, void *symbol) pthread_mutex_unlock(&mutex); return (void*)start; } +static int actualy_closing = 0; int my_dlclose(x64emu_t* emu, void *handle) { (void)emu; @@ -410,7 +411,9 @@ int my_dlclose(x64emu_t* emu, void *handle) return -1; } --dl->dllibs[nlib].count; - DecRefCount(&dl->dllibs[nlib].lib, emu); + elfheader_t* h = GetElf(dl->dllibs[nlib].lib); + if(!h || !h->gnuunique || actualy_closing) + DecRefCount(&dl->dllibs[nlib].lib, emu); return 0; } #ifdef ANDROID @@ -597,6 +600,7 @@ EXPORT int my__dl_find_object(x64emu_t* emu, void* addr, my_dl_find_object_t* re void closeAllDLOpenned() { dlprivate_t *dl = my_context->dlprivate; + actualy_closing = 1; if(dl) { x64emu_t* emu = thread_get_emu(); for(size_t i=0; i<dl->lib_sz; ++i) |