diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/ConstructorFinder.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/ConstructorFinder.kt index 4a777e8a..c4289b6c 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/ConstructorFinder.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/ConstructorFinder.kt @@ -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 diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/FieldFinder.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/FieldFinder.kt index 531256c3..caf3637d 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/FieldFinder.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/FieldFinder.kt @@ -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) diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/MethodFinder.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/MethodFinder.kt index 0f337ca3..f557b930 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/MethodFinder.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/MethodFinder.kt @@ -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