mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 09:45:19 +08:00
Fix Hooking failed no printing throwable bug
This commit is contained in:
@@ -162,7 +162,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
}
|
||||
// 注入要 Hook 的方法
|
||||
injectMember {
|
||||
allMethods(name = "getTestResultLast")
|
||||
allMethods(name = "getTestResultLast111111111111111111111111111111")
|
||||
// 执行替换 Hook
|
||||
replaceTo("I am hook all methods last")
|
||||
}
|
||||
|
@@ -473,11 +473,12 @@ class YukiHookCreater(private val packageParam: PackageParam, private val hookCl
|
||||
else -> error("Hooked got a no error possible")
|
||||
}
|
||||
}.onFailure {
|
||||
val isMemberNotFound = it.message?.lowercase()?.contains(other = "nosuch") == true
|
||||
val isMemberNotFound = it.message?.lowercase()?.contains(other = "nosuch") == true ||
|
||||
it is NoSuchMethodError || it is NoSuchFieldError
|
||||
if (isMemberNotFound) onNoSuchMemberFailureCallback?.invoke(it)
|
||||
onAllFailureCallback?.invoke(it)
|
||||
if ((isNotIgnoredHookingFailure && isMemberNotFound.not()) || (isNotIgnoredNoSuchMemberFailure && isMemberNotFound))
|
||||
yLoggerE(msg = "Hooked All Members with an error in Class [$hookClass] [$tag]")
|
||||
yLoggerE(msg = "Hooked All Members with an error in Class [$hookClass] [$tag]", e = it)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -53,20 +53,14 @@ class FieldFinder(
|
||||
/** [ModifierRules] 实例 */
|
||||
private var modifiers: ModifierRules? = null
|
||||
|
||||
/**
|
||||
* [Field] 在当前类中的位置
|
||||
*
|
||||
* - 设置后将筛选 [Class.getDeclaredFields] 的数组下标
|
||||
*
|
||||
* - ❗若你同时设置了 [type] 将仅过滤类型为 [type] 的数组下标
|
||||
*
|
||||
* - ❗受到字节码顺序影响 - 请勿完全依赖于此功能
|
||||
*
|
||||
* 若 index 小于零则忽略此条件 (等于 -2 为取最后一个)
|
||||
*
|
||||
* 可使用 [firstIndex] 和 [lastIndex] 设置首位和末位筛选条件
|
||||
*/
|
||||
var index = -1
|
||||
private object IndexConfig {
|
||||
|
||||
var orderIndex = -1
|
||||
|
||||
var nameIndex = -1
|
||||
|
||||
var typeIndex = -1
|
||||
}
|
||||
|
||||
/**
|
||||
* [Field] 名称
|
||||
@@ -82,23 +76,12 @@ class FieldFinder(
|
||||
*/
|
||||
var type: Class<*>? = null
|
||||
|
||||
/**
|
||||
* 设置 [Field] 在当前类中的位置为首位
|
||||
*
|
||||
* - ❗若你同时设置了 [type] 将仅过滤类型为 [type] 的数组下标
|
||||
*/
|
||||
fun firstIndex() {
|
||||
index = 0
|
||||
}
|
||||
/** 筛选字节码的顺序下标 */
|
||||
fun order() = IndexTypeCondition()
|
||||
|
||||
/**
|
||||
* 设置 [Field] 在当前类中的位置为末位
|
||||
*
|
||||
* - ❗若你同时设置了 [type] 将仅过滤类型为 [type] 的数组下标
|
||||
*/
|
||||
fun lastIndex() {
|
||||
index = -2
|
||||
}
|
||||
fun name(value: String) = IndexTypeCondition()
|
||||
|
||||
fun type(value: Class<*>) = IndexTypeCondition()
|
||||
|
||||
/**
|
||||
* [Field] 筛选条件
|
||||
@@ -122,6 +105,7 @@ class FieldFinder(
|
||||
override fun build(isBind: Boolean) = try {
|
||||
if (classSet != null) {
|
||||
runBlocking {
|
||||
val index=-1
|
||||
memberInstance = ReflectionTool.findField(classSet, index, name, modifiers, type)
|
||||
}.result { onHookLogMsg(msg = "Find Field [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
||||
Result()
|
||||
@@ -145,6 +129,30 @@ class FieldFinder(
|
||||
@DoNotUseMethod
|
||||
override fun failure(throwable: Throwable?) = Result(isNoSuch = true, throwable)
|
||||
|
||||
/**
|
||||
* 字节码下标筛选实现类
|
||||
*/
|
||||
inner class IndexTypeCondition {
|
||||
|
||||
/**
|
||||
* 设置下标
|
||||
* @param num 下标
|
||||
*/
|
||||
fun index(num: Int) {
|
||||
|
||||
}
|
||||
|
||||
/** 设置满足条件的第一个*/
|
||||
fun firstIndex() {
|
||||
|
||||
}
|
||||
|
||||
/** 设置满足条件的最后一个*/
|
||||
fun lastIndex() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [Field] 查找结果实现类
|
||||
*
|
||||
|
Reference in New Issue
Block a user