Fix hookAllMembers failed but no error throws

This commit is contained in:
2022-04-01 23:11:01 +08:00
parent bf3a754b67
commit c66705c77b
2 changed files with 6 additions and 2 deletions

View File

@@ -461,18 +461,22 @@ class YukiHookCreater(private val packageParam: PackageParam, private val hookCl
HookMemberMode.HOOK_ALL_METHODS -> HookMemberMode.HOOK_ALL_METHODS ->
if (isReplaceHookMode) if (isReplaceHookMode)
XposedBridge.hookAllMethods(hookClass.instance, allMethodsName, replaceMent) XposedBridge.hookAllMethods(hookClass.instance, allMethodsName, replaceMent)
.also { if (it.size <= 0) throw NoSuchMethodError("No method name \"$allMethodsName\" matched") }
else XposedBridge.hookAllMethods(hookClass.instance, allMethodsName, beforeAfterHook) else XposedBridge.hookAllMethods(hookClass.instance, allMethodsName, beforeAfterHook)
.also { if (it.size <= 0) throw NoSuchMethodError("No method name \"$allMethodsName\" matched") }
HookMemberMode.HOOK_ALL_CONSTRUCTORS -> HookMemberMode.HOOK_ALL_CONSTRUCTORS ->
if (isReplaceHookMode) if (isReplaceHookMode)
XposedBridge.hookAllConstructors(hookClass.instance, replaceMent) XposedBridge.hookAllConstructors(hookClass.instance, replaceMent)
.also { if (it.size <= 0) throw NoSuchMethodError("No constructor matched") }
else XposedBridge.hookAllConstructors(hookClass.instance, beforeAfterHook) else XposedBridge.hookAllConstructors(hookClass.instance, beforeAfterHook)
.also { if (it.size <= 0) throw NoSuchMethodError("No constructor matched") }
else -> error("Hooked got a no error possible") else -> error("Hooked got a no error possible")
} }
}.onFailure { }.onFailure {
val isMemberNotFound = it.message?.lowercase()?.contains(other = "nosuch") == true val isMemberNotFound = it.message?.lowercase()?.contains(other = "nosuch") == true
if (isMemberNotFound) onNoSuchMemberFailureCallback?.invoke(it) if (isMemberNotFound) onNoSuchMemberFailureCallback?.invoke(it)
onAllFailureCallback?.invoke(it) onAllFailureCallback?.invoke(it)
if ((isNotIgnoredHookingFailure && !isMemberNotFound) || (isNotIgnoredNoSuchMemberFailure && isMemberNotFound)) 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]")
} }
} }

View File

@@ -80,7 +80,7 @@ abstract class BaseFinder(
else Thread { else Thread {
/** 延迟使得方法取到返回值 */ /** 延迟使得方法取到返回值 */
SystemClock.sleep(1) SystemClock.sleep(1)
if (isNotIgnoredNoSuchMemberFailure && !isUsingRemedyPlan && !isShutErrorPrinting) print() if (isNotIgnoredNoSuchMemberFailure && isUsingRemedyPlan.not() && isShutErrorPrinting.not()) print()
}.start() }.start()
} }