mirror of https://github.com/hykilpikonna/AquaDX
[O] Read everything from aimedb
parent
e7085f7602
commit
3d93cc300a
|
@ -13,7 +13,7 @@ import io.netty.channel.ChannelHandler
|
|||
import io.netty.channel.ChannelHandlerContext
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter
|
||||
import org.springframework.stereotype.Component
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.nio.charset.StandardCharsets.US_ASCII
|
||||
import java.time.LocalDateTime
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
|
@ -29,13 +29,24 @@ class AimeDB(
|
|||
): ChannelInboundHandlerAdapter() {
|
||||
val logger = logger()
|
||||
|
||||
data class AimeBaseInfo(val gameId: String, val keychipId: String)
|
||||
|
||||
fun getBaseInfo(input: ByteBuf) = AimeBaseInfo(
|
||||
gameId = input.toString(0x0a, 0x0e - 0x0a, StandardCharsets.US_ASCII),
|
||||
keychipId = input.toString(0x14, 0x1f - 0x14, StandardCharsets.US_ASCII)
|
||||
data class AimeBaseInfo(
|
||||
val magic: UInt, val version: UInt, val responseCode: UInt, val length: UInt,
|
||||
val status: UInt, val gameId: String, val storeId: UInt, val keychipId: String
|
||||
)
|
||||
|
||||
fun ByteBuf.decodeHeader() = AimeBaseInfo(
|
||||
magic = readShortLE().toUInt(), // 00 2b
|
||||
version = readShortLE().toUInt(), // 02 2b
|
||||
responseCode = readShortLE().toUInt(), // 04 2b
|
||||
length = readShortLE().toUInt(), // 06 2b
|
||||
status = readShortLE().toUInt(), // 08 2b
|
||||
gameId = readPaddedString(6u), // 0a 6b
|
||||
storeId = readIntLE().toUInt(), // 10 4b
|
||||
keychipId = readPaddedString(12u) // 14 12b
|
||||
)
|
||||
|
||||
fun ByteBuf.readPaddedString(maxLen: UInt) = readBytes(maxLen.toInt()).toString(US_ASCII).trimEnd('\u0000')
|
||||
|
||||
data class Handler(val name: String, val fn: (ByteBuf) -> ByteBuf?)
|
||||
|
||||
final val handlers = mapOf(
|
||||
|
@ -60,10 +71,10 @@ class AimeDB(
|
|||
try {
|
||||
val type = msg["type"] as Int
|
||||
val data = msg["data"] as ByteBuf
|
||||
val base = getBaseInfo(data)
|
||||
val base = data.decodeHeader()
|
||||
val handler = handlers[type] ?: return logger.error("AimeDB: Unknown request type 0x${type.toString(16)}")
|
||||
|
||||
logger.info("AimeDB /${handler.name} : (game ${base.gameId}, keychip ${base.keychipId})")
|
||||
logger.info("AimeDB /${handler.name} : $base")
|
||||
|
||||
// Check keychip
|
||||
// We do not check for type 0x13 because of a bug in duolinguo.dll
|
||||
|
|
Loading…
Reference in New Issue