Remove pendding record after hooking

This commit is contained in:
LoveSy 2021-01-29 13:40:30 +08:00
parent 126c88ab02
commit 583e24b757
4 changed files with 12 additions and 3 deletions

View File

@ -34,6 +34,7 @@ namespace art {
LOGD("Pending hook for %p (%s)", clazz_ptr,
art::mirror::Class(clazz_ptr).GetDescriptor().c_str());
lspd::Context::GetInstance()->CallOnPostFixupStaticTrampolines(clazz_ptr);
lspd::DonePendingHook(class_def);
}
}

View File

@ -10,15 +10,20 @@
#include "art/runtime/mirror/class.h"
namespace lspd {
namespace {
std::unordered_set<const void *> pending_classes_;
static std::unordered_set<const void *> pending_classes_;
static std::unordered_set<const void *> hooked_methods_;
std::unordered_set<const void *> hooked_methods_;
}
bool IsClassPending(void *clazz) {
return pending_classes_.count(clazz);
}
void DonePendingHook(void *clazz) {
pending_classes_.erase(clazz);
}
static void PendingHooks_recordPendingMethodNative(JNI_START, jobject method_ref, jclass class_ref) {
auto *class_ptr = art::Thread::Current().DecodeJObject(class_ref);
auto *method = getArtMethod(env, method_ref);

View File

@ -13,4 +13,6 @@ namespace lspd {
void recordHooked(void* art_method);
void DonePendingHook(void *clazz);
} // namespace lspd

View File

@ -18,6 +18,7 @@ public final class PendingHooks {
for (Map.Entry<Member, XposedBridge.AdditionalHookInfo> hook : sPendingHooks.get(clazz).entrySet()) {
hookMethodNative(hook.getKey(), clazz, 0, hook.getValue());
}
sPendingHooks.remove(clazz);
}
}