Fix hookAllMethods/hookedAllConstructors unhook problem

This commit is contained in:
2022-07-28 03:47:30 +08:00
parent 25c2c313dc
commit eac27cf36a

View File

@@ -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) }
}
}
}