mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-13 06:47:27 +08:00
[O] Read everything from aimedb
This commit is contained in:
@@ -13,7 +13,7 @@ import io.netty.channel.ChannelHandler
|
|||||||
import io.netty.channel.ChannelHandlerContext
|
import io.netty.channel.ChannelHandlerContext
|
||||||
import io.netty.channel.ChannelInboundHandlerAdapter
|
import io.netty.channel.ChannelInboundHandlerAdapter
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets.US_ASCII
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import kotlin.jvm.optionals.getOrNull
|
import kotlin.jvm.optionals.getOrNull
|
||||||
|
|
||||||
@@ -29,13 +29,24 @@ class AimeDB(
|
|||||||
): ChannelInboundHandlerAdapter() {
|
): ChannelInboundHandlerAdapter() {
|
||||||
val logger = logger()
|
val logger = logger()
|
||||||
|
|
||||||
data class AimeBaseInfo(val gameId: String, val keychipId: String)
|
data class AimeBaseInfo(
|
||||||
|
val magic: UInt, val version: UInt, val responseCode: UInt, val length: UInt,
|
||||||
fun getBaseInfo(input: ByteBuf) = AimeBaseInfo(
|
val status: UInt, val gameId: String, val storeId: UInt, val keychipId: String
|
||||||
gameId = input.toString(0x0a, 0x0e - 0x0a, StandardCharsets.US_ASCII),
|
|
||||||
keychipId = input.toString(0x14, 0x1f - 0x14, StandardCharsets.US_ASCII)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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?)
|
data class Handler(val name: String, val fn: (ByteBuf) -> ByteBuf?)
|
||||||
|
|
||||||
final val handlers = mapOf(
|
final val handlers = mapOf(
|
||||||
@@ -60,10 +71,10 @@ class AimeDB(
|
|||||||
try {
|
try {
|
||||||
val type = msg["type"] as Int
|
val type = msg["type"] as Int
|
||||||
val data = msg["data"] as ByteBuf
|
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)}")
|
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
|
// Check keychip
|
||||||
// We do not check for type 0x13 because of a bug in duolinguo.dll
|
// We do not check for type 0x13 because of a bug in duolinguo.dll
|
||||||
|
|||||||
Reference in New Issue
Block a user