From c01d203f6eaeb9c09c6d6bb2d22f5742eb785ecd Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Wed, 7 Sep 2022 22:58:23 +0800 Subject: [PATCH] Fix bug when nameConditions not null by findFields, findMethods, findConstructors in ReflectionTool --- .../hook/core/reflex/tools/ReflectionTool.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/reflex/tools/ReflectionTool.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/reflex/tools/ReflectionTool.kt index 3d2aa9e0..0eeb961d 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/reflex/tools/ReflectionTool.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/reflex/tools/ReflectionTool.kt @@ -97,8 +97,10 @@ internal object ReflectionTool { rulesData: FieldRulesData ): HashSet { if (rulesData.type == UndefinedType) error("Field match type class is not found") - if (orderIndex == null && matchIndex == null && rulesData.name.isBlank() && rulesData.modifiers == null && rulesData.type == null) - error("You must set a condition when finding a Field") + if (orderIndex == null && matchIndex == null && + rulesData.name.isBlank() && rulesData.nameConditions == null && + rulesData.modifiers == null && rulesData.type == null + ) error("You must set a condition when finding a Field") val hashCode = ("[$orderIndex][$matchIndex][${rulesData.name}][${rulesData.type}][${rulesData.modifiers}][$classSet]").hashCode() return ReflectsCacheStore.findFields(hashCode) ?: let { val fields = HashSet() @@ -213,9 +215,10 @@ internal object ReflectionTool { rulesData.paramTypes?.takeIf { it.isNotEmpty() } ?.forEachIndexed { p, it -> if (it == UndefinedType) error("Method match paramType[$p] class is not found") } if (orderIndex == null && matchIndex == null && - rulesData.name.isBlank() && rulesData.modifiers == null && - rulesData.paramCount < 0 && rulesData.paramCountRange.isEmpty() && - rulesData.paramTypes == null && rulesData.returnType == null + rulesData.name.isBlank() && rulesData.nameConditions == null && + rulesData.modifiers == null && rulesData.paramCount < 0 && + rulesData.paramCountRange.isEmpty() && rulesData.paramTypes == null && + rulesData.returnType == null ) error("You must set a condition when finding a Method") val hashCode = ("[$orderIndex][$matchIndex][${rulesData.name}][${rulesData.paramCount}][${rulesData.paramTypes.typeOfString()}]" +