From 050561ac9ae5e900c649896a1d3ddc6d2b1188de Mon Sep 17 00:00:00 2001 From: LoveSy Date: Mon, 21 Mar 2022 01:04:21 +0800 Subject: [PATCH] Fix make class inheritable --- lsplant/src/main/jni/include/utils/jni_helper.hpp | 4 ++-- lsplant/src/main/jni/lsplant.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lsplant/src/main/jni/include/utils/jni_helper.hpp b/lsplant/src/main/jni/include/utils/jni_helper.hpp index e1f9a8b..2d4a2a5 100644 --- a/lsplant/src/main/jni/include/utils/jni_helper.hpp +++ b/lsplant/src/main/jni/include/utils/jni_helper.hpp @@ -858,7 +858,7 @@ public: Iterator operator++(int) { return Iterator(e_++); } Iterator operator--(int) { return Iterator(e_--); } bool operator==(const Iterator &other) const { return other.e_ == e_; } - bool operator!=(const Iterator &other) const { return other.e_ == e_; } + bool operator!=(const Iterator &other) const { return other.e_ != e_; } }; class ConstIterator { @@ -874,7 +874,7 @@ public: ConstIterator operator++(int) { return ConstIterator(e_++); } ConstIterator operator--(int) { return ConstIterator(e_--); } bool operator==(const ConstIterator &other) const { return other.e_ == e_; } - bool operator!=(const ConstIterator &other) const { return other.e_ == e_; } + bool operator!=(const ConstIterator &other) const { return other.e_ != e_; } }; auto begin() { diff --git a/lsplant/src/main/jni/lsplant.cc b/lsplant/src/main/jni/lsplant.cc index e14c1c6..2eae474 100644 --- a/lsplant/src/main/jni/lsplant.cc +++ b/lsplant/src/main/jni/lsplant.cc @@ -669,14 +669,14 @@ using ::lsplant::IsHooked; LOGE("target class is null"); return false; } - auto constructors = + const auto constructors = JNI_Cast(JNI_CallObjectMethod(env, target, class_get_declared_constructors)); uint8_t access_flags = JNI_GetIntField(env, target, class_access_flags); constexpr static uint32_t kAccFinal = 0x0010; JNI_SetIntField(env, target, class_access_flags, static_cast(access_flags & ~kAccFinal)); for (auto &constructor : constructors) { auto *method = ArtMethod::FromReflectedMethod(env, constructor.get()); - if (method && (!method->IsPublic() || !method->IsProtected())) method->SetProtected(); + if (method && !method->IsPublic() && !method->IsProtected()) method->SetProtected(); if (method && method->IsFinal()) method->SetNonFinal(); } return true;