mirror of
https://github.com/LSPosed/LSPlant.git
synced 2025-05-05 14:06:37 +08:00
Search accessFlags & remove declaringClass
This commit is contained in:
parent
b2e1065452
commit
89f10845c3
@ -79,11 +79,6 @@ public:
|
|||||||
return PrettyMethod(this, with_signature);
|
return PrettyMethod(this, with_signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
mirror::Class *GetDeclaringClass() {
|
|
||||||
return *reinterpret_cast<mirror::Class **>(reinterpret_cast<uintptr_t>(this) +
|
|
||||||
declaring_class_offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
static art::ArtMethod *FromReflectedMethod(JNIEnv *env, jobject method) {
|
static art::ArtMethod *FromReflectedMethod(JNIEnv *env, jobject method) {
|
||||||
return reinterpret_cast<art::ArtMethod *>(JNI_GetLongField(env, method, art_method_field));
|
return reinterpret_cast<art::ArtMethod *>(JNI_GetLongField(env, method, art_method_field));
|
||||||
}
|
}
|
||||||
@ -117,10 +112,10 @@ public:
|
|||||||
LOGE("Throwable has less than 2 constructors");
|
LOGE("Throwable has less than 2 constructors");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto *first = FromReflectedMethod(env,
|
auto first_ctor = JNI_GetObjectArrayElement(env, constructors, 0);
|
||||||
JNI_GetObjectArrayElement(env, constructors, 0).get());
|
auto second_ctor = JNI_GetObjectArrayElement(env, constructors, 1);
|
||||||
auto *second = FromReflectedMethod(env,
|
auto *first = FromReflectedMethod(env, first_ctor.get());
|
||||||
JNI_GetObjectArrayElement(env, constructors, 1).get());
|
auto *second = FromReflectedMethod(env, second_ctor.get());
|
||||||
art_method_size = reinterpret_cast<uintptr_t>(second) - reinterpret_cast<uintptr_t>(first);
|
art_method_size = reinterpret_cast<uintptr_t>(second) - reinterpret_cast<uintptr_t>(first);
|
||||||
LOGD("ArtMethod size: %zu", art_method_size);
|
LOGD("ArtMethod size: %zu", art_method_size);
|
||||||
|
|
||||||
@ -134,11 +129,22 @@ public:
|
|||||||
data_offset = entry_point_offset - sizeof(void *);
|
data_offset = entry_point_offset - sizeof(void *);
|
||||||
LOGD("ArtMethod::data offset: %zu", data_offset);
|
LOGD("ArtMethod::data offset: %zu", data_offset);
|
||||||
|
|
||||||
declaring_class_offset = 0U;
|
if (auto access_flags_field = JNI_GetFieldID(env, executable, "accessFlags", "I");
|
||||||
LOGD("ArtMethod::declaring_class offset: %zu", declaring_class_offset);
|
access_flags_field) {
|
||||||
|
uint32_t real_flags = JNI_GetIntField(env, first_ctor, access_flags_field);
|
||||||
access_flags_offset = 4U;
|
for (size_t i = 0; i < art_method_size; i += sizeof(uint32_t)) {
|
||||||
|
if (*reinterpret_cast<uint32_t *>(reinterpret_cast<uintptr_t>(first) + i) ==
|
||||||
|
real_flags) {
|
||||||
|
access_flags_offset = i;
|
||||||
LOGD("ArtMethod::access_flags offset: %zu", access_flags_offset);
|
LOGD("ArtMethod::access_flags offset: %zu", access_flags_offset);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (access_flags_offset == 0) {
|
||||||
|
LOGW("Failed to find accessFlags field. Fallback to 4.");
|
||||||
|
access_flags_offset = 4U;
|
||||||
|
}
|
||||||
auto sdk_int = GetAndroidApiLevel();
|
auto sdk_int = GetAndroidApiLevel();
|
||||||
|
|
||||||
if (sdk_int < __ANDROID_API_R__) kAccPreCompiled = 0;
|
if (sdk_int < __ANDROID_API_R__) kAccPreCompiled = 0;
|
||||||
@ -171,7 +177,6 @@ private:
|
|||||||
inline static size_t art_method_size = 0;
|
inline static size_t art_method_size = 0;
|
||||||
inline static size_t entry_point_offset = 0;
|
inline static size_t entry_point_offset = 0;
|
||||||
inline static size_t data_offset = 0;
|
inline static size_t data_offset = 0;
|
||||||
inline static size_t declaring_class_offset = 0;
|
|
||||||
inline static size_t access_flags_offset = 0;
|
inline static size_t access_flags_offset = 0;
|
||||||
inline static uint32_t kAccFastInterpreterToInterpreterInvoke = 0x40000000;
|
inline static uint32_t kAccFastInterpreterToInterpreterInvoke = 0x40000000;
|
||||||
inline static uint32_t kAccPreCompiled = 0x00200000;
|
inline static uint32_t kAccPreCompiled = 0x00200000;
|
||||||
|
@ -53,7 +53,7 @@ struct tstring : public std::integer_sequence<char, chars...> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
constexpr static char str_[]{ chars..., '\0' };
|
inline static constexpr char str_[]{ chars..., '\0' };
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, T... chars>
|
template<typename T, T... chars>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user