Fix implementation of UnhookPLT
Currently, inline_unhooker is not used in the code. We still fix the logic to avoid confusion. There is no feasible way to determinate if the parameter original is a valid function pointer or a `const char` pointer. We suppose it as a char pointer in the first step.
This commit is contained in:
parent
e55ecdf67c
commit
bb869eac2d
|
|
@ -123,19 +123,19 @@ void MagiskLoader::InitializeZygiskApi(zygisk::Api *api) {
|
|||
};
|
||||
|
||||
auto UnhookPLT = [HookPLT, &plt_hook_saved](void *original) {
|
||||
Dl_info info;
|
||||
|
||||
if (!dladdr(original, &info) || info.dli_sname != nullptr) return 1;
|
||||
if (!GetArt()->isStripped()) return UnhookInline(original);
|
||||
|
||||
auto symbol = reinterpret_cast<const char *>(original);
|
||||
auto hook_iter =
|
||||
std::find_if(plt_hook_saved.begin(), plt_hook_saved.end(),
|
||||
[info](auto record) { return strcmp(record.first, info.dli_sname) == 0; });
|
||||
[symbol](auto record) { return strcmp(record.first, symbol) == 0; });
|
||||
void *stub = nullptr;
|
||||
if (hook_iter != plt_hook_saved.end() &&
|
||||
HookPLT(original, *(hook_iter->second), &stub, false)) {
|
||||
plt_hook_saved.erase(hook_iter);
|
||||
return 0;
|
||||
} else {
|
||||
return UnhookInline(original);
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue