Fix #747
This commit is contained in:
parent
de2f65d17b
commit
27f1abfb3c
|
|
@ -35,10 +35,13 @@ namespace art {
|
|||
}
|
||||
|
||||
CREATE_HOOK_STUB_ENTRIES(void, FixupStaticTrampolines, void *thiz, void *clazz_ptr) {
|
||||
bool should_intercept = edxp::IsClassPending(clazz_ptr);
|
||||
FixupStaticTrampolinesBackup(thiz, clazz_ptr);
|
||||
art::mirror::Class mirror_class(clazz_ptr);
|
||||
auto class_def = mirror_class.GetClassDef();
|
||||
bool should_intercept = class_def && edxp::IsClassPending(class_def);
|
||||
if (UNLIKELY(should_intercept)) {
|
||||
LOGD("Pending hook for %p (%s)", clazz_ptr, art::mirror::Class(clazz_ptr).GetDescriptor(nullptr));
|
||||
LOGD("Pending hook for %p (%s)", clazz_ptr,
|
||||
art::mirror::Class(clazz_ptr).GetDescriptor().c_str());
|
||||
edxp::Context::GetInstance()->CallOnPostFixupStaticTrampolines(clazz_ptr);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,12 @@ namespace art {
|
|||
return IsInSamePackageBackup(thiz, that);
|
||||
}
|
||||
|
||||
CREATE_FUNC_SYMBOL_ENTRY(void*, GetClassDef, void* thiz) {
|
||||
if (LIKELY(GetClassDefSym))
|
||||
return GetClassDefSym(thiz);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
Class(void *thiz) : HookedObject(thiz) {}
|
||||
|
||||
|
|
@ -51,6 +57,8 @@ namespace art {
|
|||
RETRIEVE_FUNC_SYMBOL(GetDescriptor, "_ZN3art6mirror5Class13GetDescriptorEPNSt3__112"
|
||||
"basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE");
|
||||
|
||||
RETRIEVE_FUNC_SYMBOL(GetClassDef, "_ZN3art6mirror5Class11GetClassDefEv");
|
||||
|
||||
// RETRIEVE_FIELD_SYMBOL(mutator_lock_, "_ZN3art5Locks13mutator_lock_E");
|
||||
// LOGE("mutator_lock_: %p", mutator_lock_);
|
||||
|
||||
|
|
@ -64,15 +72,21 @@ namespace art {
|
|||
|
||||
const char *GetDescriptor(std::string *storage) {
|
||||
if (thiz_ && GetDescriptorSym) {
|
||||
if (storage == nullptr) {
|
||||
std::string str;
|
||||
return GetDescriptor(thiz_, &str);
|
||||
} else {
|
||||
return GetDescriptor(thiz_, storage);
|
||||
}
|
||||
return GetDescriptor(thiz_, storage);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string GetDescriptor() {
|
||||
std::string storage;
|
||||
return GetDescriptor(&storage);
|
||||
}
|
||||
|
||||
void *GetClassDef() {
|
||||
if(thiz_ && GetClassDefSym)
|
||||
return GetClassDef(thiz_);
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mirror
|
||||
|
|
|
|||
|
|
@ -22,8 +22,14 @@ namespace edxp {
|
|||
static void PendingHooks_recordPendingMethodNative(JNI_START, jlong thread, jclass class_ref) {
|
||||
art::Thread current_thread(reinterpret_cast<void *>(thread));
|
||||
auto *class_ptr = current_thread.DecodeJObject(class_ref);
|
||||
LOGD("record pending: %p (%s)", class_ptr, art::mirror::Class(class_ptr).GetDescriptor(nullptr));
|
||||
pending_classes_.insert(class_ptr);
|
||||
art::mirror::Class mirror_class(class_ptr);
|
||||
if (auto def = mirror_class.GetClassDef(); LIKELY(def)) {
|
||||
LOGD("record pending: %p (%s)", class_ptr, mirror_class.GetDescriptor().c_str());
|
||||
pending_classes_.insert(def);
|
||||
} else {
|
||||
LOGW("fail to record pending for : %p (%s)", class_ptr,
|
||||
mirror_class.GetDescriptor().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
static JNINativeMethod gMethods[] = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue