mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-09-22 22:38:14 +03:00
@@ -46,7 +46,7 @@ class AimeDB(
|
|||||||
keychipId = readPaddedString(12u) // 14 12b
|
keychipId = readPaddedString(12u) // 14 12b
|
||||||
)
|
)
|
||||||
|
|
||||||
fun ByteBuf.readPaddedString(maxLen: UInt) = readBytes(maxLen.toInt()).toString(US_ASCII).trimEnd('\u0000')
|
fun ByteBuf.readPaddedString(maxLen: UInt) = readCharSequence(maxLen.toInt(), US_ASCII).toString().trimEnd('\u0000')
|
||||||
|
|
||||||
data class Handler(val name: String, val fn: (ByteBuf) -> ByteBuf?)
|
data class Handler(val name: String, val fn: (ByteBuf) -> ByteBuf?)
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,11 @@ class AimeDbDecoder : ByteToMessageDecoder() {
|
|||||||
|
|
||||||
// Create a byte array to store the encrypted data
|
// Create a byte array to store the encrypted data
|
||||||
val d = input.readBytes(length)
|
val d = input.readBytes(length)
|
||||||
val result = AimeDbEncryption.decrypt(d)
|
val result = try {
|
||||||
d.release()
|
AimeDbEncryption.decrypt(d)
|
||||||
|
} finally {
|
||||||
|
d.release()
|
||||||
|
}
|
||||||
|
|
||||||
val resultMap = mapOf(
|
val resultMap = mapOf(
|
||||||
"type" to result.getShortLE(0x04).toInt(),
|
"type" to result.getShortLE(0x04).toInt(),
|
||||||
@@ -50,13 +53,16 @@ class AimeDbDecoder : ByteToMessageDecoder() {
|
|||||||
private fun getLength(input: ByteBuf): Int = try {
|
private fun getLength(input: ByteBuf): Int = try {
|
||||||
val currentPos = input.readerIndex()
|
val currentPos = input.readerIndex()
|
||||||
val result = AimeDbEncryption.decrypt(input)
|
val result = AimeDbEncryption.decrypt(input)
|
||||||
|
try {
|
||||||
|
// Check the header
|
||||||
|
val header = result.getByte(0).toInt()
|
||||||
|
assert(header == 0x3e) { "AimeDB: Invalid header $header" }
|
||||||
|
|
||||||
// Check the header
|
// Read the length from offset 6
|
||||||
val header = result.getByte(0).toInt()
|
result.getShortLE(currentPos + 6).toInt()
|
||||||
assert(header == 0x3e) { "AimeDB: Invalid header $header" }
|
} finally {
|
||||||
|
result.release()
|
||||||
// Read the length from offset 6
|
}
|
||||||
result.getShortLE(currentPos + 6).toInt()
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logger.info("AimeDB: Invalid request received")
|
logger.info("AimeDB: Invalid request received")
|
||||||
logger.debug("AimeDB: Invalid request received: ${input.toString(Charsets.UTF_8)}")
|
logger.debug("AimeDB: Invalid request received: ${input.toString(Charsets.UTF_8)}")
|
||||||
|
|||||||
Reference in New Issue
Block a user