Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
Shamrock: fix #61
Browse files Browse the repository at this point in the history
  • Loading branch information
whitechi73 committed Nov 21, 2023
1 parent 2af8d6d commit 98c6316
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
15 changes: 11 additions & 4 deletions xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/BaseSvc.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.withTimeoutOrNull
import moe.fuqiuluo.proto.protobufOf
import moe.fuqiuluo.shamrock.utils.PlatformUtils
Expand All @@ -37,9 +38,9 @@ internal abstract class BaseSvc {
}

suspend fun sendOidbAW(cmd: String, cmdId: Int, serviceId: Int, data: ByteArray, trpc: Boolean = false, timeout: Long = 5000L): ByteArray? {
val seq = MsfCore.getNextSeq()
return withTimeoutOrNull(timeout) {
suspendCoroutine { continuation ->
val seq = MsfCore.getNextSeq()
suspendCancellableCoroutine { continuation ->
GlobalScope.launch(Dispatchers.Default) {
DynamicReceiver.register(IPCRequest(cmd, seq) {
val buffer = it.getByteArrayExtra("buffer")!!
Expand All @@ -49,13 +50,16 @@ internal abstract class BaseSvc {
if (trpc) sendTrpcOidb(cmd, cmdId, serviceId, data, seq)
else sendOidb(cmd, cmdId, serviceId, data, seq)
}
}.also {
if (it == null)
DynamicReceiver.unregister(seq)
}?.copyOf()
}

suspend fun sendBufferAW(cmd: String, isPb: Boolean, data: ByteArray, timeout: Long = 5000L): ByteArray? {
val seq = MsfCore.getNextSeq()
return withTimeoutOrNull<ByteArray?>(timeout) {
suspendCoroutine { continuation ->
val seq = MsfCore.getNextSeq()
suspendCancellableCoroutine { continuation ->
GlobalScope.launch(Dispatchers.Default) {
DynamicReceiver.register(IPCRequest(cmd, seq) {
val buffer = it.getByteArrayExtra("buffer")!!
Expand All @@ -64,6 +68,9 @@ internal abstract class BaseSvc {
sendBuffer(cmd, isPb, data, seq)
}
}
}.also {
if (it == null)
DynamicReceiver.unregister(seq)
}?.copyOf()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,30 @@ internal object RichProtoSvc: BaseSvc() {
suspend fun getC2CFileDownUrl(
fileId: String,
subId: String,
retryCnt: Int = 0
): String {
val uid = ContactHelper.getUidByUinAsync(app.currentUin.toLong())
val buffer = sendOidbAW("OidbSvcTrpcTcp.0xe37_1200", 3639, 1200, protobufOf(
val buffer = sendOidbAW("OidbSvc.0xe37_1200", 3639, 1200, protobufOf(
1 to 1200,
2 to 1 /* QRoute.api(IAudioHelperApi::class.java).genDebugSeq().toInt() */, /* seq */
14 to mapOf(
10 to uid,
10 to app.longAccountUin,
20 to fileId,
30 to 2, /* ver */
60 to subId,
601 to 0
),
101 to 3,
101 to 3, // uint32_business_id
102 to 104, /* client_type */
200 to 1, /* url_type */
99999 to 90200 to 1
).toByteArray(), trpc = true)
200 to 1, /* uint32_flag_support_mediaplatform */
99999 to mapOf(
90200 to 1 // uint32_download_url_type
)
).toByteArray())

if (buffer == null) {
if (retryCnt < 3) {
return getC2CFileDownUrl(fileId, subId, retryCnt + 1)
}
return ""
} else {
val body = oidb_sso.OIDBSSOPkg()
Expand Down

0 comments on commit 98c6316

Please sign in to comment.