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]
|
* @return [Constructor]
|
||||||
* @throws IllegalStateException 如果 [classSet] 为 null
|
|
||||||
* @throws NoSuchMethodError 如果找不到构造方法
|
* @throws NoSuchMethodError 如果找不到构造方法
|
||||||
*/
|
*/
|
||||||
private val result get() = ReflectionTool.findConstructor(classSet, index, modifiers, paramCount, paramTypes)
|
private val result get() = ReflectionTool.findConstructor(classSet, index, modifiers, paramCount, paramTypes)
|
||||||
@@ -148,11 +147,13 @@ class ConstructorFinder(
|
|||||||
*/
|
*/
|
||||||
@DoNotUseMethod
|
@DoNotUseMethod
|
||||||
override fun build(isBind: Boolean) = try {
|
override fun build(isBind: Boolean) = try {
|
||||||
runBlocking {
|
if (classSet != null) {
|
||||||
isBindToHooker = isBind
|
runBlocking {
|
||||||
setInstance(isBind, result)
|
isBindToHooker = isBind
|
||||||
}.result { onHookLogMsg(msg = "Find Constructor [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
setInstance(isBind, result)
|
||||||
Result()
|
}.result { onHookLogMsg(msg = "Find Constructor [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
||||||
|
Result()
|
||||||
|
} else Result(isNoSuch = true, Throwable("classSet is null"))
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
onFailureMsg(throwable = e)
|
onFailureMsg(throwable = e)
|
||||||
Result(isNoSuch = true, e)
|
Result(isNoSuch = true, e)
|
||||||
@@ -196,6 +197,7 @@ class ConstructorFinder(
|
|||||||
*/
|
*/
|
||||||
@DoNotUseMethod
|
@DoNotUseMethod
|
||||||
internal fun build() {
|
internal fun build() {
|
||||||
|
if (classSet == null) return
|
||||||
if (remedyPlans.isNotEmpty()) run {
|
if (remedyPlans.isNotEmpty()) run {
|
||||||
var isFindSuccess = false
|
var isFindSuccess = false
|
||||||
var lastError: Throwable? = null
|
var lastError: Throwable? = null
|
||||||
|
@@ -110,10 +110,12 @@ class FieldFinder(
|
|||||||
*/
|
*/
|
||||||
@DoNotUseMethod
|
@DoNotUseMethod
|
||||||
override fun build(isBind: Boolean) = try {
|
override fun build(isBind: Boolean) = try {
|
||||||
runBlocking {
|
if (classSet != null) {
|
||||||
memberInstance = ReflectionTool.findField(classSet, index, name, modifiers, type)
|
runBlocking {
|
||||||
}.result { onHookLogMsg(msg = "Find Field [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
memberInstance = ReflectionTool.findField(classSet, index, name, modifiers, type)
|
||||||
Result()
|
}.result { onHookLogMsg(msg = "Find Field [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
||||||
|
Result()
|
||||||
|
} else Result(isNoSuch = true, Throwable("classSet is null"))
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
Thread {
|
Thread {
|
||||||
SystemClock.sleep(10)
|
SystemClock.sleep(10)
|
||||||
|
@@ -139,7 +139,6 @@ class MethodFinder(
|
|||||||
/**
|
/**
|
||||||
* 得到方法
|
* 得到方法
|
||||||
* @return [Method]
|
* @return [Method]
|
||||||
* @throws IllegalStateException 如果 [classSet] 为 null
|
|
||||||
* @throws NoSuchMethodError 如果找不到方法
|
* @throws NoSuchMethodError 如果找不到方法
|
||||||
*/
|
*/
|
||||||
private val result get() = ReflectionTool.findMethod(classSet, index, name, modifiers, returnType, paramCount, paramTypes)
|
private val result get() = ReflectionTool.findMethod(classSet, index, name, modifiers, returnType, paramCount, paramTypes)
|
||||||
@@ -163,11 +162,13 @@ class MethodFinder(
|
|||||||
*/
|
*/
|
||||||
@DoNotUseMethod
|
@DoNotUseMethod
|
||||||
override fun build(isBind: Boolean) = try {
|
override fun build(isBind: Boolean) = try {
|
||||||
runBlocking {
|
if (classSet != null) {
|
||||||
isBindToHooker = isBind
|
runBlocking {
|
||||||
setInstance(isBind, result)
|
isBindToHooker = isBind
|
||||||
}.result { onHookLogMsg(msg = "Find Method [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
setInstance(isBind, result)
|
||||||
Result()
|
}.result { onHookLogMsg(msg = "Find Method [${memberInstance}] takes ${it}ms [${hookTag}]") }
|
||||||
|
Result()
|
||||||
|
} else Result(isNoSuch = true, Throwable("classSet is null"))
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
onFailureMsg(throwable = e)
|
onFailureMsg(throwable = e)
|
||||||
Result(isNoSuch = true, e)
|
Result(isNoSuch = true, e)
|
||||||
@@ -212,6 +213,7 @@ class MethodFinder(
|
|||||||
*/
|
*/
|
||||||
@DoNotUseMethod
|
@DoNotUseMethod
|
||||||
internal fun build() {
|
internal fun build() {
|
||||||
|
if (classSet == null) return
|
||||||
if (remedyPlans.isNotEmpty()) run {
|
if (remedyPlans.isNotEmpty()) run {
|
||||||
var isFindSuccess = false
|
var isFindSuccess = false
|
||||||
var lastError: Throwable? = null
|
var lastError: Throwable? = null
|
||||||
|
Reference in New Issue
Block a user