Added type function in YukiHookAPI.Status.Executor and add ExecutorType

This commit is contained in:
2023-04-16 20:21:35 +08:00
parent 3b8eba21b0
commit 404bbfa4eb
8 changed files with 359 additions and 0 deletions

View File

@@ -53,6 +53,7 @@ const navigationLinks = {
baseApiPath + 'hook/factory/ReflectionFactory',
baseApiPath + 'hook/factory/YukiHookFactory',
baseApiPath + 'hook/entity/YukiBaseHooker',
baseApiPath + 'hook/core/api/compat/type/ExecutorType',
baseApiPath + 'hook/core/YukiMemberHookCreator',
baseApiPath + 'hook/core/YukiResourcesHookCreator',
baseApiPath + 'hook/core/finder/members/MethodFinder',

View File

@@ -260,6 +260,26 @@ val name: String
:::
#### type <span class="symbol">- field</span>
```kotlin:no-line-numbers
val type: ExecutorType
```
**Change Records**
`v1.1.9` `added`
**Function Illustrate**
> 获取当前 Hook Framework 类型。
::: warning
在模块环境中需要启用 **Configs.isEnableHookModuleStatus**。
:::
#### apiLevel <span class="symbol">- field</span>
```kotlin:no-line-numbers

View File

@@ -0,0 +1,115 @@
---
pageClass: code-page
---
::: warning
The English translation of this page has not been completed, you are welcome to contribute translations to us.
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
:::
# ExecutorType <span class="symbol">- class</span>
```kotlin:no-line-numbers
enum class ExecutorType
```
**Change Records**
`v1.1.9` `added`
**Function Illustrate**
> Hook Framework 类型定义。
定义了目前已知使用频率较高的 Hook Framework。
后期根据 Hook Framework 特征和使用情况将会继续添加新的类型。
无法识别的 Hook Framework 将被定义为 `UNKNOWN`。
## UNKNOWN <span class="symbol">- enum</span>
```kotlin:no-line-numbers
UNKNOWN
```
**Change Records**
`v1.1.9` `added`
**Function Illustrate**
> 未知类型。
## XPOSED <span class="symbol">- enum</span>
```kotlin:no-line-numbers
XPOSED
```
**Change Records**
`v1.1.9` `added`
**Function Illustrate**
> 原版、第三方 Xposed。
## LSPOSED_LSPATCH <span class="symbol">- enum</span>
```kotlin:no-line-numbers
LSPOSED_LSPATCH
```
**Change Records**
`v1.1.9` `added`
**Function Illustrate**
> LSPosed、LSPatch。
## ED_XPOSED <span class="symbol">- enum</span>
```kotlin:no-line-numbers
ED_XPOSED
```
**Change Records**
`v1.1.9` `added`
**Function Illustrate**
> EdXposed。
## TAICHI_XPOSED <span class="symbol">- enum</span>
```kotlin:no-line-numbers
TAICHI_XPOSED
```
**Change Records**
`v1.1.9` `added`
**Function Illustrate**
> TaiChi (太极)。
## BUG_XPOSED <span class="symbol">- enum</span>
```kotlin:no-line-numbers
BUG_XPOSED
```
**Change Records**
`v1.1.9` `added`
**Function Illustrate**
> BugXposed (应用转生)。

View File

@@ -252,6 +252,26 @@ val name: String
:::
#### type <span class="symbol">- field</span>
```kotlin:no-line-numbers
val type: ExecutorType
```
**变更记录**
`v1.1.9` `新增`
**功能描述**
> 获取当前 Hook Framework 类型。
::: warning
在模块环境中需要启用 **Configs.isEnableHookModuleStatus**。
:::
#### apiLevel <span class="symbol">- field</span>
```kotlin:no-line-numbers

View File

@@ -0,0 +1,107 @@
---
pageClass: code-page
---
# ExecutorType <span class="symbol">- class</span>
```kotlin:no-line-numbers
enum class ExecutorType
```
**变更记录**
`v1.1.9` `新增`
**功能描述**
> Hook Framework 类型定义。
定义了目前已知使用频率较高的 Hook Framework。
后期根据 Hook Framework 特征和使用情况将会继续添加新的类型。
无法识别的 Hook Framework 将被定义为 `UNKNOWN`。
## UNKNOWN <span class="symbol">- enum</span>
```kotlin:no-line-numbers
UNKNOWN
```
**变更记录**
`v1.1.9` `新增`
**功能描述**
> 未知类型。
## XPOSED <span class="symbol">- enum</span>
```kotlin:no-line-numbers
XPOSED
```
**变更记录**
`v1.1.9` `新增`
**功能描述**
> 原版、第三方 Xposed。
## LSPOSED_LSPATCH <span class="symbol">- enum</span>
```kotlin:no-line-numbers
LSPOSED_LSPATCH
```
**变更记录**
`v1.1.9` `新增`
**功能描述**
> LSPosed、LSPatch。
## ED_XPOSED <span class="symbol">- enum</span>
```kotlin:no-line-numbers
ED_XPOSED
```
**变更记录**
`v1.1.9` `新增`
**功能描述**
> EdXposed。
## TAICHI_XPOSED <span class="symbol">- enum</span>
```kotlin:no-line-numbers
TAICHI_XPOSED
```
**变更记录**
`v1.1.9` `新增`
**功能描述**
> TaiChi (太极)。
## BUG_XPOSED <span class="symbol">- enum</span>
```kotlin:no-line-numbers
BUG_XPOSED
```
**变更记录**
`v1.1.9` `新增`
**功能描述**
> BugXposed (应用转生)。

View File

@@ -39,6 +39,7 @@ import com.highcapable.yukihookapi.YukiHookAPI.encase
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
import com.highcapable.yukihookapi.hook.core.api.compat.HookApiCategoryHelper
import com.highcapable.yukihookapi.hook.core.api.compat.HookApiProperty
import com.highcapable.yukihookapi.hook.core.api.compat.type.ExecutorType
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
@@ -193,6 +194,14 @@ object YukiHookAPI {
else -> YukiXposedModuleStatus.executorName
}
/**
* 获取当前 Hook Framework 类型
*
* - ❗在模块环境中需要启用 [Configs.isEnableHookModuleStatus]
* @return [ExecutorType]
*/
val type get() = HookApiProperty.type.takeIf { isXposedEnvironment } ?: HookApiProperty.type(YukiXposedModuleStatus.executorName)
/**
* 获取当前 Hook Framework 的 API 版本
*

View File

@@ -29,6 +29,7 @@
package com.highcapable.yukihookapi.hook.core.api.compat
import com.highcapable.yukihookapi.hook.core.api.compat.type.ExecutorType
import com.highcapable.yukihookapi.hook.factory.classOf
import com.highcapable.yukihookapi.hook.factory.field
import com.highcapable.yukihookapi.hook.factory.hasClass
@@ -40,6 +41,15 @@ import de.robv.android.xposed.XposedBridge
*/
internal object HookApiProperty {
/** Xposed 框架名称 */
internal const val XPOSED_NAME = "Xposed"
/** LSPosed 框架名称 */
internal const val LSPOSED_NAME = "LSPosed"
/** EdXposed 框架名称 */
internal const val ED_XPOSED_NAME = "EdXposed"
/** TaiChi (太极) Xposed 框架名称 */
internal const val TAICHI_XPOSED_NAME = "TaiChi"
@@ -69,6 +79,26 @@ internal object HookApiProperty {
HookApiCategory.UNKNOWN -> "unknown"
}
/**
* 获取当前 Hook Framework 类型
* @return [ExecutorType]
*/
internal val type get() = type()
/**
* 获取当前 Hook Framework 类型
* @param executorName Hook Framework 名称 - 默认为 [name]
* @return [ExecutorType]
*/
internal fun type(executorName: String = name) = when (executorName) {
BUG_XPOSED_NAME -> ExecutorType.BUG_XPOSED
TAICHI_XPOSED_NAME -> ExecutorType.TAICHI_XPOSED
ED_XPOSED_NAME -> ExecutorType.ED_XPOSED
LSPOSED_NAME -> ExecutorType.LSPOSED_LSPATCH
XPOSED_NAME -> ExecutorType.XPOSED
else -> ExecutorType.UNKNOWN
}
/**
* 获取当前 Hook Framework 的 API 版本
* @return [Int] 无法获取会返回 -1

View File

@@ -0,0 +1,57 @@
/*
* YukiHookAPI - An efficient Hook API and Xposed Module solution built in Kotlin.
* Copyright (C) 2019-2023 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 2023/4/16.
*/
package com.highcapable.yukihookapi.hook.core.api.compat.type
/**
* Hook Framework 类型定义
*
* 定义了目前已知使用频率较高的 Hook Framework
*
* 后期根据 Hook Framework 特征和使用情况将会继续添加新的类型
*
* 无法识别的 Hook Framework 将被定义为 [UNKNOWN]
*/
enum class ExecutorType {
/** 未知类型 */
UNKNOWN,
/** 原版、第三方 Xposed */
XPOSED,
/** LSPosed、LSPatch */
LSPOSED_LSPATCH,
/** EdXposed */
ED_XPOSED,
/** TaiChi (太极) */
TAICHI_XPOSED,
/** BugXposed (应用转生) */
BUG_XPOSED
}