Enhance debugger tools

This commit is contained in:
Him188 2020-01-29 21:52:22 +08:00
parent 47e02cd2f1
commit fb1b37520b

View File

@ -97,6 +97,7 @@ private fun processFullPacketWithoutLength(packet: ByteReadPacket) {
PacketLogger.debug("Oicq Reuqest= " + bytes.toUHexString()) PacketLogger.debug("Oicq Reuqest= " + bytes.toUHexString())
try { try {
bytes.toReadPacket().parseOicqResponse { bytes.toReadPacket().parseOicqResponse {
debugIfFail {
if (it.packetFactory.commandName == "wtlogin.login") { if (it.packetFactory.commandName == "wtlogin.login") {
DebugLogger.info("服务器发来了 wtlogin.login. 正在解析 key") DebugLogger.info("服务器发来了 wtlogin.login. 正在解析 key")
try { try {
@ -104,10 +105,14 @@ private fun processFullPacketWithoutLength(packet: ByteReadPacket) {
println("subCommand=$subCommand") println("subCommand=$subCommand")
val type = readUByte().toInt() val type = readUByte().toInt()
println("type=$type") println("type=$type")
if (type == 0) {
discardExact(2) discardExact(2)
val tlvMap: Map<Int, ByteArray> = this.readTLVMap() val tlvMap: Map<Int, ByteArray> = this.readTLVMap()
println("tlvMap: ")
tlvMap.forEach {
println(it.key.toShort().toUHexString() + " = " + it.value.toUHexString())
}
tlvMap[0x119]?.let { t119Data -> tlvMap[0x119]?.let { t119Data ->
t119Data.decryptBy(tgtgtKey).toReadPacket().debugPrint("0x119data").apply { t119Data.decryptBy(tgtgtKey).toReadPacket().debugPrint("0x119data").apply {
discardExact(2) // always discarded. 00 1C discardExact(2) // always discarded. 00 1C
@ -123,12 +128,12 @@ private fun processFullPacketWithoutLength(packet: ByteReadPacket) {
DebugLogger.info("D2Key=${D2Key.toUHexString()}") DebugLogger.info("D2Key=${D2Key.toUHexString()}")
} }
} }
}
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
} }
} }
}
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }