diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/bean/CurrentClass.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/bean/CurrentClass.kt index fa1dd9b5..160bfc57 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/bean/CurrentClass.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/bean/CurrentClass.kt @@ -31,8 +31,8 @@ package com.highcapable.yukihookapi.hook.bean import com.highcapable.yukihookapi.hook.core.finder.members.FieldFinder import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder -import com.highcapable.yukihookapi.hook.factory.FieldConditions -import com.highcapable.yukihookapi.hook.factory.MethodConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.FieldConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.MethodConditions import com.highcapable.yukihookapi.hook.factory.field import com.highcapable.yukihookapi.hook.factory.method diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator.kt index 31853d67..bab39c30 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator.kt @@ -36,6 +36,9 @@ import com.highcapable.yukihookapi.hook.core.finder.base.MemberBaseFinder import com.highcapable.yukihookapi.hook.core.finder.members.ConstructorFinder import com.highcapable.yukihookapi.hook.core.finder.members.FieldFinder import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder +import com.highcapable.yukihookapi.hook.core.finder.type.factory.ConstructorConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.FieldConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.MethodConditions import com.highcapable.yukihookapi.hook.factory.* import com.highcapable.yukihookapi.hook.log.yLoggerE import com.highcapable.yukihookapi.hook.log.yLoggerI diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder.kt index 4d2aa1ec..e978498f 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder.kt @@ -37,13 +37,13 @@ import com.highcapable.yukihookapi.hook.core.finder.base.MemberBaseFinder import com.highcapable.yukihookapi.hook.core.finder.members.data.ConstructorRulesData import com.highcapable.yukihookapi.hook.core.finder.type.ModifierRules import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool -import com.highcapable.yukihookapi.hook.factory.ConstructorConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.ConstructorConditions import com.highcapable.yukihookapi.hook.factory.checkingInternal import com.highcapable.yukihookapi.hook.factory.hasExtends import com.highcapable.yukihookapi.hook.log.yLoggerW import com.highcapable.yukihookapi.hook.type.defined.UndefinedType import com.highcapable.yukihookapi.hook.type.defined.VagueType -import com.highcapable.yukihookapi.hook.utils.IntConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.IntConditions import com.highcapable.yukihookapi.hook.utils.runBlocking import com.highcapable.yukihookapi.hook.utils.unit import java.lang.reflect.Constructor diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder.kt index df7afc37..edb366db 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder.kt @@ -39,7 +39,7 @@ import com.highcapable.yukihookapi.hook.core.finder.members.data.FieldRulesData import com.highcapable.yukihookapi.hook.core.finder.type.ModifierRules import com.highcapable.yukihookapi.hook.core.finder.type.NameConditions import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool -import com.highcapable.yukihookapi.hook.factory.FieldConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.FieldConditions import com.highcapable.yukihookapi.hook.factory.checkingInternal import com.highcapable.yukihookapi.hook.factory.current import com.highcapable.yukihookapi.hook.factory.hasExtends diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder.kt index 2199f337..fe6ae116 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder.kt @@ -38,13 +38,13 @@ import com.highcapable.yukihookapi.hook.core.finder.members.data.MethodRulesData import com.highcapable.yukihookapi.hook.core.finder.type.ModifierRules import com.highcapable.yukihookapi.hook.core.finder.type.NameConditions import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool -import com.highcapable.yukihookapi.hook.factory.MethodConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.MethodConditions import com.highcapable.yukihookapi.hook.factory.checkingInternal import com.highcapable.yukihookapi.hook.factory.hasExtends import com.highcapable.yukihookapi.hook.log.yLoggerW import com.highcapable.yukihookapi.hook.type.defined.UndefinedType import com.highcapable.yukihookapi.hook.type.defined.VagueType -import com.highcapable.yukihookapi.hook.utils.IntConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.IntConditions import com.highcapable.yukihookapi.hook.utils.runBlocking import com.highcapable.yukihookapi.hook.utils.unit import com.highcapable.yukihookapi.hook.xposed.bridge.factory.YukiHookHelper diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/data/ConstructorRulesData.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/data/ConstructorRulesData.kt index 14b2c3f1..66d53134 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/data/ConstructorRulesData.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/data/ConstructorRulesData.kt @@ -27,7 +27,7 @@ */ package com.highcapable.yukihookapi.hook.core.finder.members.data -import com.highcapable.yukihookapi.hook.utils.IntConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.IntConditions import java.lang.reflect.Constructor /** diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/data/MemberRulesData.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/data/MemberRulesData.kt index ac3ee68c..4c72fe1b 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/data/MemberRulesData.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/data/MemberRulesData.kt @@ -28,7 +28,7 @@ package com.highcapable.yukihookapi.hook.core.finder.members.data import com.highcapable.yukihookapi.hook.core.finder.base.data.BaseRulesData -import com.highcapable.yukihookapi.hook.utils.IntConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.IntConditions import java.lang.reflect.Member /** diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/data/MethodRulesData.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/data/MethodRulesData.kt index 8a772453..04b4ba1b 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/data/MethodRulesData.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/members/data/MethodRulesData.kt @@ -28,7 +28,7 @@ package com.highcapable.yukihookapi.hook.core.finder.members.data import com.highcapable.yukihookapi.hook.core.finder.type.NameConditions -import com.highcapable.yukihookapi.hook.utils.IntConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.IntConditions import java.lang.reflect.Method /** diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/type/NameConditions.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/type/NameConditions.kt index 6bb8167f..f2078d3f 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/type/NameConditions.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/type/NameConditions.kt @@ -29,7 +29,7 @@ package com.highcapable.yukihookapi.hook.core.finder.type -import com.highcapable.yukihookapi.hook.utils.IntConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.IntConditions import java.lang.reflect.Field import java.lang.reflect.Member import java.lang.reflect.Method diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/type/factory/TypeAliasFactory.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/type/factory/TypeAliasFactory.kt new file mode 100644 index 00000000..d0897ed6 --- /dev/null +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/type/factory/TypeAliasFactory.kt @@ -0,0 +1,44 @@ +/* + * YukiHookAPI - An efficient Kotlin version of the Xposed Hook API. + * Copyright (C) 2019-2022 HighCapable + * https://github.com/fankes/YukiHookAPI + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * This file is Created by fankes on 2022/9/14. + */ +package com.highcapable.yukihookapi.hook.core.finder.type.factory + +import com.highcapable.yukihookapi.hook.core.finder.members.ConstructorFinder +import com.highcapable.yukihookapi.hook.core.finder.members.FieldFinder +import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder + +/** 定义 [FieldFinder] 方法体类型 */ +internal typealias FieldConditions = FieldFinder.() -> Unit + +/** 定义 [MethodFinder] 方法体类型 */ +internal typealias MethodConditions = MethodFinder.() -> Unit + +/** 定义 [ConstructorFinder] 方法体类型 */ +internal typealias ConstructorConditions = ConstructorFinder.() -> Unit + +/** 定义 [Int] 方法体类型 */ +internal typealias IntConditions = (Int) -> Boolean \ No newline at end of file diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt index b9fdc60b..e746996d 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt @@ -36,6 +36,9 @@ import com.highcapable.yukihookapi.hook.core.finder.members.FieldFinder import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool import com.highcapable.yukihookapi.hook.core.finder.type.ModifierRules +import com.highcapable.yukihookapi.hook.core.finder.type.factory.ConstructorConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.FieldConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.MethodConditions import com.highcapable.yukihookapi.hook.xposed.bridge.status.YukiHookModuleStatus import com.highcapable.yukihookapi.hook.xposed.parasitic.AppParasitics import java.lang.reflect.Constructor @@ -43,15 +46,6 @@ import java.lang.reflect.Field import java.lang.reflect.Member import java.lang.reflect.Method -/** 定义 [FieldFinder] 方法体类型 */ -internal typealias FieldConditions = FieldFinder.() -> Unit - -/** 定义 [MethodFinder] 方法体类型 */ -internal typealias MethodConditions = MethodFinder.() -> Unit - -/** 定义 [ConstructorFinder] 方法体类型 */ -internal typealias ConstructorConditions = ConstructorFinder.() -> Unit - /** * 定义一个 [Class] 中的 [Member] 类型 */ @@ -144,6 +138,7 @@ inline fun Class<*>.hasConstructor(initiate: ConstructorConditions = { emptyPara * 查询 [Member] 中匹配的描述符 * @param initiate 方法体 * @return [Boolean] 是否存在 + * todo 这个也要改 */ inline fun Member.hasModifiers(initiate: ModifierRules.() -> Unit) = ModifierRules().apply(initiate).contains(this) @@ -151,6 +146,7 @@ inline fun Member.hasModifiers(initiate: ModifierRules.() -> Unit) = ModifierRul * 查询 [Class] 中匹配的描述符 * @param initiate 方法体 * @return [Boolean] 是否存在 + * todo 这个也要改 */ inline fun Class<*>.hasModifiers(initiate: ModifierRules.() -> Unit) = ModifierRules().apply(initiate).contains(this) diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt index 3b433c0a..1e1ded28 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt @@ -31,9 +31,6 @@ import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.TimeUnit -/** 定义 [Int] 方法体类型 */ -internal typealias IntConditions = (Int) -> Boolean - /** * 创建当前线程池服务 * @return [ExecutorService]