From 7160196173922315d6fe5b3e6a5b1252d02a52bd Mon Sep 17 00:00:00 2001 From: klxiaoniu Date: Wed, 12 Jul 2023 21:45:39 +0800 Subject: [PATCH] fix: optimize MultiForwardAvatarHook to prevent crash --- .../ioctl/hook/msg/MultiForwardAvatarHook.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/cc/ioctl/hook/msg/MultiForwardAvatarHook.kt b/app/src/main/java/cc/ioctl/hook/msg/MultiForwardAvatarHook.kt index 734dfbb79b..9019201710 100644 --- a/app/src/main/java/cc/ioctl/hook/msg/MultiForwardAvatarHook.kt +++ b/app/src/main/java/cc/ioctl/hook/msg/MultiForwardAvatarHook.kt @@ -98,14 +98,18 @@ object MultiForwardAvatarHook : CommonSwitchFunctionHook(arrayOf(CAIOUtils)), On it.type.name == "com.tencent.mobileqq.aio.msg.AIOMsgItem" }.let { it.isAccessible = true - (it.get(param.thisObject)!!.invoke("getMsgRecord")!! as MsgRecord).let { - val senderUin = it.senderUin //对方QQ - val peerUid = it.peerUid as String //对方,如果是群聊则是群号,如果是私聊则是u_串 - if (peerUid.startsWith("u_")) { - createAndShowDialogCommon(layout!!.context, it, senderUin, null) - } else { - createAndShowDialogCommon(layout!!.context, it, senderUin, peerUid.toLong()) + try { + (it.get(param.thisObject)!!.invoke("getMsgRecord")!! as MsgRecord).let { + val senderUin = it.senderUin //对方QQ + val troopUin = try { + it.peerUid.toLong() //对方,如果是群聊则是群号,如果是私聊则是u_串 + } catch (_: NumberFormatException) { + null + } + createAndShowDialogCommon(layout!!.context, it, senderUin, troopUin) } + } catch (e: Exception) { + FaultyDialog.show(layout!!.context, e) } } }