mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 09:45:19 +08:00
Fix when the hook classSet is null,stop finding any member
This commit is contained in:
@@ -125,7 +125,6 @@ class ConstructorFinder(
|
||||
/**
|
||||
* 得到构造方法
|
||||
* @return [Constructor]
|
||||
* @throws IllegalStateException 如果 [classSet] 为 null
|
||||
* @throws NoSuchMethodError 如果找不到构造方法
|
||||
*/
|
||||
private val result get() = ReflectionTool.findConstructor(classSet, index, modifiers, paramCount, paramTypes)
|
||||
@@ -148,11 +147,13 @@ class ConstructorFinder(
|
||||
*/
|
||||
@DoNotUseMethod
|
||||
override fun build(isBind: Boolean) = try {
|
||||
runBlocking {
|
||||
isBindToHooker = isBind
|
||||
setInstance(isBind, result)
|
||||
}.result { onHookLogMsg(msg = "Find Constructor [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
||||
Result()
|
||||
if (classSet != null) {
|
||||
runBlocking {
|
||||
isBindToHooker = isBind
|
||||
setInstance(isBind, result)
|
||||
}.result { onHookLogMsg(msg = "Find Constructor [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
||||
Result()
|
||||
} else Result(isNoSuch = true, Throwable("classSet is null"))
|
||||
} catch (e: Throwable) {
|
||||
onFailureMsg(throwable = e)
|
||||
Result(isNoSuch = true, e)
|
||||
@@ -196,6 +197,7 @@ class ConstructorFinder(
|
||||
*/
|
||||
@DoNotUseMethod
|
||||
internal fun build() {
|
||||
if (classSet == null) return
|
||||
if (remedyPlans.isNotEmpty()) run {
|
||||
var isFindSuccess = false
|
||||
var lastError: Throwable? = null
|
||||
|
@@ -110,10 +110,12 @@ class FieldFinder(
|
||||
*/
|
||||
@DoNotUseMethod
|
||||
override fun build(isBind: Boolean) = try {
|
||||
runBlocking {
|
||||
memberInstance = ReflectionTool.findField(classSet, index, name, modifiers, type)
|
||||
}.result { onHookLogMsg(msg = "Find Field [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
||||
Result()
|
||||
if (classSet != null) {
|
||||
runBlocking {
|
||||
memberInstance = ReflectionTool.findField(classSet, index, name, modifiers, type)
|
||||
}.result { onHookLogMsg(msg = "Find Field [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
||||
Result()
|
||||
} else Result(isNoSuch = true, Throwable("classSet is null"))
|
||||
} catch (e: Throwable) {
|
||||
Thread {
|
||||
SystemClock.sleep(10)
|
||||
|
@@ -139,7 +139,6 @@ class MethodFinder(
|
||||
/**
|
||||
* 得到方法
|
||||
* @return [Method]
|
||||
* @throws IllegalStateException 如果 [classSet] 为 null
|
||||
* @throws NoSuchMethodError 如果找不到方法
|
||||
*/
|
||||
private val result get() = ReflectionTool.findMethod(classSet, index, name, modifiers, returnType, paramCount, paramTypes)
|
||||
@@ -163,11 +162,13 @@ class MethodFinder(
|
||||
*/
|
||||
@DoNotUseMethod
|
||||
override fun build(isBind: Boolean) = try {
|
||||
runBlocking {
|
||||
isBindToHooker = isBind
|
||||
setInstance(isBind, result)
|
||||
}.result { onHookLogMsg(msg = "Find Method [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
||||
Result()
|
||||
if (classSet != null) {
|
||||
runBlocking {
|
||||
isBindToHooker = isBind
|
||||
setInstance(isBind, result)
|
||||
}.result { onHookLogMsg(msg = "Find Method [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
||||
Result()
|
||||
} else Result(isNoSuch = true, Throwable("classSet is null"))
|
||||
} catch (e: Throwable) {
|
||||
onFailureMsg(throwable = e)
|
||||
Result(isNoSuch = true, e)
|
||||
@@ -212,6 +213,7 @@ class MethodFinder(
|
||||
*/
|
||||
@DoNotUseMethod
|
||||
internal fun build() {
|
||||
if (classSet == null) return
|
||||
if (remedyPlans.isNotEmpty()) run {
|
||||
var isFindSuccess = false
|
||||
var lastError: Throwable? = null
|
||||
|
Reference in New Issue
Block a user