From ec705fb26093702ff6af7bb63bde9edc7ebd79ef Mon Sep 17 00:00:00 2001 From: ThePedroo Date: Fri, 6 Jun 2025 03:00:05 -0300 Subject: [PATCH] fix: removal of all PLT hooks unconditionally This commit fixes the issue where due to a confusion, ReZygisk was coded so that it would remove all PLT hooks, even if they were meant to be kept. This has been fixed appropriately in LSPlt side, allowing to revert back to how it was before. --- loader/src/external/lsplt | 2 +- loader/src/injector/hook.cpp | 34 ++++++++++++++++------------------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/loader/src/external/lsplt b/loader/src/external/lsplt index 86c228c..dc62fbe 160000 --- a/loader/src/external/lsplt +++ b/loader/src/external/lsplt @@ -1 +1 @@ -Subproject commit 86c228cff56548584f9c41011430a77e73a8f1ff +Subproject commit dc62fbe05e9e420df0171ca5b6540af66c8a2d8c diff --git a/loader/src/injector/hook.cpp b/loader/src/injector/hook.cpp index d135aa0..cd88f25 100644 --- a/loader/src/injector/hook.cpp +++ b/loader/src/injector/hook.cpp @@ -31,6 +31,7 @@ using namespace std; static void hook_unloader(); +static void unhook_functions(); namespace { @@ -219,14 +220,8 @@ DCL_HOOK_FUNC(int, pthread_attr_setstacksize, void *target, size_t size) { if (gettid() != getpid()) return res; - delete plt_hook_list; - if (should_unmap_zygisk) { - if (!lsplt::InvalidateBackup()) { - LOGE("Failed to invalidate backup for plt_hook"); - - should_unmap_zygisk = false; - } + unhook_functions(); cached_map_infos.clear(); if (should_unmap_zygisk) { @@ -237,17 +232,6 @@ DCL_HOOK_FUNC(int, pthread_attr_setstacksize, void *target, size_t size) { [[clang::musttail]] return munmap(start_addr, block_size); } - } else { - for (const auto &[dev, inode, sym, old_func] : *plt_hook_list) { - if (!lsplt::RegisterHook(dev, inode, sym, *old_func, nullptr)) { - LOGE("Failed to register plt_hook [%s]", sym); - } - } - - if (!lsplt::CommitHook(cached_map_infos)) { - LOGE("Failed to restore plt_hook"); - should_unmap_zygisk = false; - } } return res; @@ -966,3 +950,17 @@ static void hook_unloader() { PLT_HOOK_REGISTER(art_dev, art_inode, pthread_attr_setstacksize); hook_commit(); } + +static void unhook_functions() { + // Unhook plt_hook + for (const auto &[dev, inode, sym, old_func] : *plt_hook_list) { + if (!lsplt::RegisterHook(dev, inode, sym, *old_func, nullptr)) { + LOGE("Failed to register plt_hook [%s]", sym); + } + } + delete plt_hook_list; + if (!hook_commit()) { + LOGE("Failed to restore plt_hook"); + should_unmap_zygisk = false; + } +}