From eac27cf36a62258f3b6bd5b779cd3f54f0a6942e Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Thu, 28 Jul 2022 03:47:30 +0800 Subject: [PATCH] Fix hookAllMethods/hookedAllConstructors unhook problem --- .../hook/xposed/bridge/YukiHookBridge.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/bridge/YukiHookBridge.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/bridge/YukiHookBridge.kt index 55490f15..973ef9b6 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/bridge/YukiHookBridge.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/bridge/YukiHookBridge.kt @@ -659,12 +659,16 @@ object YukiHookBridge { /** 解除 Hook */ internal fun unhook() { - instance.unhook() - runCatching { - if (tag.isNotBlank()) { - hookedAllMethods.remove(tag) - hookedAllConstructors.remove(tag) - } else hookedMembers.remove(this) + if (tag.isNotBlank()) runCatching { + if (hookedAllMethods.contains(tag)) + hookedAllMethods[tag]?.takeIf { it.isNotEmpty() }?.forEach { it.instance.unhook() } + if (hookedAllConstructors.contains(tag)) + hookedAllConstructors[tag]?.takeIf { it.isNotEmpty() }?.forEach { it.instance.unhook() } + hookedAllMethods.remove(tag) + hookedAllConstructors.remove(tag) + } else { + instance.unhook() + runCatching { hookedMembers.remove(this) } } } }