mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: Adjusting the xposed API for KSP
This commit is contained in:
parent
c7265ba628
commit
a485e72ddf
13
annotations/src/main/java/moe/fuqiuluo/symbols/XposedHook.kt
Normal file
13
annotations/src/main/java/moe/fuqiuluo/symbols/XposedHook.kt
Normal file
@ -0,0 +1,13 @@
|
||||
package moe.fuqiuluo.symbols
|
||||
|
||||
enum class Process {
|
||||
ALL,
|
||||
MAIN,
|
||||
MSF
|
||||
}
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
annotation class XposedHook(
|
||||
val process: Process = Process.ALL,
|
||||
val priority: Int = 10
|
||||
)
|
@ -12,7 +12,7 @@
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_moe_fuqiuluo_shamrock_xposed_actions_PullConfig_testNativeLibrary(JNIEnv *env, jobject thiz) {
|
||||
Java_moe_fuqiuluo_shamrock_xposed_hooks_PullConfig_testNativeLibrary(JNIEnv *env, jobject thiz) {
|
||||
return env->NewStringUTF("加载Shamrock库成功~");
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.request.header
|
||||
import io.ktor.client.request.parameter
|
||||
import io.ktor.client.request.url
|
||||
import io.ktor.client.statement.bodyAsText
|
||||
@ -17,9 +16,9 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.json.Json
|
||||
import moe.fuqiuluo.shamrock.remote.entries.CommonResult
|
||||
import moe.fuqiuluo.shamrock.remote.entries.CurrentAccount
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.CommonResult
|
||||
import moe.fuqiuluo.shamrock.remote.structures.CurrentAccount
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.tools.GlobalClient
|
||||
import moe.fuqiuluo.shamrock.ui.app.AppRuntime.AccountInfo
|
||||
import moe.fuqiuluo.shamrock.ui.app.AppRuntime.log
|
||||
|
@ -66,7 +66,7 @@ class OneBotHandlerProcessor(
|
||||
}.build()).apply {
|
||||
addImport("moe.fuqiuluo.shamrock.remote.action.ActionManager", "actionMap")
|
||||
actionHandlers.forEach {
|
||||
addImport("moe.fuqiuluo.shamrock.remote.action.handlers", it.simpleName.asString())
|
||||
addImport(it.packageName.asString(), it.simpleName.asString())
|
||||
}
|
||||
}.build()
|
||||
|
||||
|
@ -0,0 +1,111 @@
|
||||
@file:Suppress("UNCHECKED_CAST", "LocalVariableName", "PrivatePropertyName")
|
||||
@file:OptIn(KspExperimental::class)
|
||||
|
||||
package moe.fuqiuluo.ksp.impl
|
||||
|
||||
import com.google.devtools.ksp.KspExperimental
|
||||
import com.google.devtools.ksp.getAnnotationsByType
|
||||
import com.google.devtools.ksp.getClassDeclarationByName
|
||||
import com.google.devtools.ksp.processing.CodeGenerator
|
||||
import com.google.devtools.ksp.processing.Dependencies
|
||||
import com.google.devtools.ksp.processing.KSPLogger
|
||||
import com.google.devtools.ksp.processing.Resolver
|
||||
import com.google.devtools.ksp.processing.SymbolProcessor
|
||||
import com.google.devtools.ksp.symbol.ClassKind
|
||||
import com.google.devtools.ksp.symbol.KSAnnotated
|
||||
import com.google.devtools.ksp.symbol.KSClassDeclaration
|
||||
import com.google.devtools.ksp.symbol.KSVisitorVoid
|
||||
import com.google.devtools.ksp.validate
|
||||
import com.squareup.kotlinpoet.ClassName
|
||||
import com.squareup.kotlinpoet.FileSpec
|
||||
import com.squareup.kotlinpoet.FunSpec
|
||||
import moe.fuqiuluo.symbols.Process
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
|
||||
class XposedHookProcessor(
|
||||
private val codeGenerator: CodeGenerator,
|
||||
private val logger: KSPLogger
|
||||
): SymbolProcessor {
|
||||
override fun process(resolver: Resolver): List<KSAnnotated> {
|
||||
val symbols = resolver.getSymbolsWithAnnotation(XposedHook::class.qualifiedName!!)
|
||||
val unableToProcess = symbols.filterNot { it.validate() }
|
||||
val actions = (symbols.filter {
|
||||
it is KSClassDeclaration && it.validate() && it.classKind == ClassKind.CLASS
|
||||
} as Sequence<KSClassDeclaration>).toList()
|
||||
|
||||
if (actions.isNotEmpty()) {
|
||||
val firstActions = arrayListOf<KSClassDeclaration>()
|
||||
val serviceActions = arrayListOf<KSClassDeclaration>()
|
||||
actions.forEach {
|
||||
val priority = it.getAnnotationsByType(XposedHook::class).first().priority
|
||||
if (priority >= 10) {
|
||||
serviceActions.add(it)
|
||||
} else {
|
||||
firstActions.add(it)
|
||||
}
|
||||
}
|
||||
|
||||
val context = ClassName("android.content", "Context")
|
||||
val packageName = "moe.fuqiuluo.shamrock.xposed.hooks"
|
||||
val fileSpec = FileSpec.builder(packageName, "AutoActionLoader").addFunction(FunSpec.builder("runFirstActions")
|
||||
.addParameter("ctx", context)
|
||||
.apply {
|
||||
firstActions.forEach { handler ->
|
||||
val annotation = handler.getAnnotationsByType(XposedHook::class).first()
|
||||
val process = annotation.process
|
||||
val className = handler.simpleName.asString()
|
||||
if (process == Process.MAIN) {
|
||||
addStatement("if (PlatformUtils.isMainProcess()) ")
|
||||
} else if (process == Process.MSF) {
|
||||
addStatement("if (PlatformUtils.isMsfProcess()) ")
|
||||
}
|
||||
addStatement("$className().invoke(ctx)")
|
||||
}
|
||||
}.build()
|
||||
).addFunction(FunSpec.builder("runServiceActions")
|
||||
.addParameter("ctx", context).apply {
|
||||
serviceActions.forEach { handler ->
|
||||
val annotation = handler.getAnnotationsByType(XposedHook::class).first()
|
||||
val process = annotation.process
|
||||
val className = handler.simpleName.asString()
|
||||
if (process == Process.MAIN) {
|
||||
addStatement("if (PlatformUtils.isMainProcess()) ")
|
||||
} else if (process == Process.MSF) {
|
||||
addStatement("if (PlatformUtils.isMsfProcess()) ")
|
||||
}
|
||||
addStatement("$className().invoke(ctx)")
|
||||
}
|
||||
}.build()
|
||||
).apply {
|
||||
firstActions.forEach {
|
||||
addImport(it.packageName.asString(), it.simpleName.asString())
|
||||
}
|
||||
serviceActions.forEach {
|
||||
addImport(it.packageName.asString(), it.simpleName.asString())
|
||||
}
|
||||
addImport("moe.fuqiuluo.shamrock.utils", "PlatformUtils")
|
||||
}.build()
|
||||
|
||||
codeGenerator.createNewFile(
|
||||
dependencies = Dependencies(aggregating = false),
|
||||
packageName = packageName,
|
||||
fileName = "AutoActionLoader"
|
||||
).use { outputStream ->
|
||||
outputStream.writer().use {
|
||||
fileSpec.writeTo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return unableToProcess.toList()
|
||||
}
|
||||
|
||||
inner class ActionLoaderVisitor(
|
||||
private val firstActions: List<KSClassDeclaration>,
|
||||
private val serviceActions: List<KSClassDeclaration>,
|
||||
): KSVisitorVoid() {
|
||||
override fun visitClassDeclaration(classDeclaration: KSClassDeclaration, data: Unit) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package moe.fuqiuluo.ksp.providers
|
||||
|
||||
import com.google.auto.service.AutoService
|
||||
import com.google.devtools.ksp.processing.SymbolProcessor
|
||||
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
|
||||
import com.google.devtools.ksp.processing.SymbolProcessorProvider
|
||||
import moe.fuqiuluo.ksp.impl.XposedHookProcessor
|
||||
|
||||
@AutoService(SymbolProcessorProvider::class)
|
||||
class XposedHookProcessorProvider: SymbolProcessorProvider {
|
||||
override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {
|
||||
return XposedHookProcessor(environment.codeGenerator, environment.logger)
|
||||
}
|
||||
}
|
@ -165,7 +165,7 @@ NativeOnModuleLoaded native_init(const NativeAPIEntries *entries) {
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_moe_fuqiuluo_shamrock_xposed_actions_AntiDetection_antiNativeDetections(JNIEnv *env,
|
||||
Java_moe_fuqiuluo_shamrock_xposed_hooks_AntiDetection_antiNativeDetections(JNIEnv *env,
|
||||
jobject thiz) {
|
||||
if (hook_function == nullptr) return false;
|
||||
hook_function((void*) __system_property_get, (void *)fake_system_property_get, (void **) &backup_system_property_get);
|
||||
|
@ -9,8 +9,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import moe.fuqiuluo.shamrock.remote.service.config.ShamrockConfig
|
||||
import moe.fuqiuluo.shamrock.utils.FileUtils
|
||||
import moe.fuqiuluo.shamrock.xposed.actions.toast
|
||||
import moe.fuqiuluo.shamrock.xposed.hooks.toast
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.internal.DataRequester
|
||||
import mqq.app.MobileQQ
|
||||
import java.io.File
|
||||
|
@ -4,10 +4,9 @@ import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.JsonPrimitive
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.*
|
||||
import moe.fuqiuluo.shamrock.remote.entries.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.entries.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.structures.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.resultToString
|
||||
import moe.fuqiuluo.shamrock.tools.*
|
||||
import moe.fuqiuluo.shamrock.tools.json
|
||||
|
||||
|
@ -2,9 +2,9 @@ package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||
|
||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.entries.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.entries.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.structures.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.resultToString
|
||||
import moe.fuqiuluo.symbols.OneBotHandler
|
||||
|
||||
@OneBotHandler("get_latest_events")
|
||||
|
@ -4,7 +4,7 @@ import com.tencent.mobileqq.app.QQAppInterface
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
import moe.fuqiuluo.shamrock.remote.entries.StdAccount
|
||||
import moe.fuqiuluo.shamrock.remote.structures.StdAccount
|
||||
import moe.fuqiuluo.shamrock.tools.EmptyJsonString
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.AppRuntimeFetcher
|
||||
import moe.fuqiuluo.symbols.OneBotHandler
|
||||
@ -24,7 +24,8 @@ internal object GetLoginInfo: IActionHandler() {
|
||||
return if (account == null || !account.isLogined) {
|
||||
error("当前不处于已登录状态", echo = echo)
|
||||
} else {
|
||||
ok(StdAccount(
|
||||
ok(
|
||||
StdAccount(
|
||||
curUin.toLong(),if (runtime is QQAppInterface) runtime.currentNickname else "unknown"
|
||||
), echo = echo)
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import com.tencent.mobileqq.data.Card
|
||||
import moe.fuqiuluo.qqinterface.servlet.CardSvc
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.entries.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.VipInfo
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.VipType
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.profile.Location
|
||||
|
@ -3,12 +3,11 @@ package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||
import com.tencent.mobileqq.app.QQAppInterface
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.entries.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.UserDetail
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.AppRuntimeFetcher
|
||||
import moe.fuqiuluo.symbols.OneBotHandler
|
||||
import mqq.app.MobileQQ
|
||||
|
||||
@OneBotHandler("get_self_info")
|
||||
internal object GetSelfInfo: IActionHandler() {
|
||||
|
@ -2,13 +2,12 @@ package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||
|
||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.entries.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.BotStatus
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.Self
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.AppRuntimeFetcher
|
||||
import moe.fuqiuluo.symbols.OneBotHandler
|
||||
import mqq.app.MobileQQ
|
||||
|
||||
@OneBotHandler("get_status", ["status"])
|
||||
internal object GetStatus: IActionHandler() {
|
||||
|
@ -3,8 +3,8 @@ package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionManager
|
||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.entries.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.resultToString
|
||||
import moe.fuqiuluo.symbols.OneBotHandler
|
||||
|
||||
@OneBotHandler("get_supported_actions")
|
||||
|
@ -3,8 +3,8 @@ package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.entries.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.resultToString
|
||||
import moe.fuqiuluo.shamrock.tools.asString
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.NTServiceFetcher
|
||||
import moe.fuqiuluo.symbols.OneBotHandler
|
||||
|
@ -3,8 +3,8 @@ package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.entries.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.resultToString
|
||||
import moe.fuqiuluo.shamrock.tools.asString
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.NTServiceFetcher
|
||||
import moe.fuqiuluo.symbols.OneBotHandler
|
||||
|
@ -4,8 +4,8 @@ import kotlinx.serialization.Serializable
|
||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import de.robv.android.xposed.XposedBridge.log
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.entries.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.resultToString
|
||||
import moe.fuqiuluo.symbols.OneBotHandler
|
||||
|
||||
@OneBotHandler("test")
|
||||
|
@ -5,7 +5,7 @@ import com.tencent.mobileqq.transfile.TransferRequest
|
||||
import com.tencent.mobileqq.transfile.api.ITransFileController
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.routing.post
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.tools.fetchPost
|
||||
import moe.fuqiuluo.shamrock.tools.respond
|
||||
import moe.fuqiuluo.shamrock.utils.MD5
|
||||
|
@ -27,7 +27,7 @@ import kotlinx.io.core.BytePacketBuilder
|
||||
import kotlinx.io.core.readBytes
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.tools.EMPTY_BYTE_ARRAY
|
||||
import moe.fuqiuluo.shamrock.tools.EmptyJsonObject
|
||||
import moe.fuqiuluo.shamrock.tools.fetchGetOrThrow
|
||||
|
@ -3,7 +3,7 @@ package moe.fuqiuluo.shamrock.remote.api
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.routing.get
|
||||
import kotlinx.coroutines.delay
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.tools.getOrPost
|
||||
import moe.fuqiuluo.shamrock.tools.respond
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
|
@ -1,21 +1,14 @@
|
||||
package moe.fuqiuluo.shamrock.remote.api
|
||||
|
||||
import com.tencent.mobileqq.qqguildsdk.api.IGPSService
|
||||
import com.tencent.qqnt.kernel.nativeinterface.GProRetentionGuildListRsp
|
||||
import com.tencent.qqnt.kernel.nativeinterface.IGProFetchRetentionGuildListCallback
|
||||
import com.tencent.qqnt.kernel.nativeinterface.IKernelGuildListener
|
||||
import io.ktor.server.application.call
|
||||
import io.ktor.server.response.respondText
|
||||
import io.ktor.server.routing.Routing
|
||||
import moe.fuqiuluo.shamrock.helper.Level
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.shamrock.remote.entries.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.service.listener.KernelGuildListener
|
||||
import moe.fuqiuluo.shamrock.remote.structures.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.tools.getOrPost
|
||||
import moe.fuqiuluo.shamrock.tools.respond
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.AppRuntimeFetcher
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.NTServiceFetcher
|
||||
import mqq.app.MobileQQ
|
||||
|
||||
fun Routing.guildAction() {
|
||||
getOrPost("/get_guild_service_profile") {
|
||||
|
@ -19,9 +19,9 @@ import moe.fuqiuluo.shamrock.remote.HTTPServer
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionManager
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.config.ECHO_KEY
|
||||
import moe.fuqiuluo.shamrock.remote.entries.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.entries.IndexData
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.structures.IndexData
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.tools.EmptyJsonObject
|
||||
import moe.fuqiuluo.shamrock.tools.EmptyJsonString
|
||||
import moe.fuqiuluo.shamrock.tools.asJsonObjectOrNull
|
||||
@ -30,12 +30,9 @@ import moe.fuqiuluo.shamrock.tools.fetchOrNull
|
||||
import moe.fuqiuluo.shamrock.tools.fetchOrThrow
|
||||
import moe.fuqiuluo.shamrock.tools.fetchPostJsonElement
|
||||
import moe.fuqiuluo.shamrock.tools.fetchPostJsonElementOrNull
|
||||
import moe.fuqiuluo.shamrock.tools.fetchPostJsonObject
|
||||
import moe.fuqiuluo.shamrock.tools.fetchPostJsonObjectOrNull
|
||||
import moe.fuqiuluo.shamrock.tools.isJsonArray
|
||||
import moe.fuqiuluo.shamrock.tools.isJsonData
|
||||
import moe.fuqiuluo.shamrock.tools.isJsonObject
|
||||
import moe.fuqiuluo.shamrock.tools.isJsonString
|
||||
import moe.fuqiuluo.shamrock.tools.json
|
||||
import moe.fuqiuluo.shamrock.tools.respond
|
||||
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||
|
@ -11,7 +11,7 @@ import io.ktor.server.routing.post
|
||||
import io.ktor.server.routing.route
|
||||
import moe.fuqiuluo.shamrock.helper.db.MessageDB
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.*
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.tools.fetchGetOrNull
|
||||
import moe.fuqiuluo.shamrock.tools.fetchGetOrThrow
|
||||
import moe.fuqiuluo.shamrock.tools.fetchOrNull
|
||||
|
@ -4,7 +4,6 @@ import io.ktor.http.ContentType
|
||||
import io.ktor.http.content.PartData
|
||||
import io.ktor.http.content.forEachPart
|
||||
import io.ktor.http.content.streamProvider
|
||||
import io.ktor.server.application.Application
|
||||
import io.ktor.server.application.call
|
||||
import io.ktor.server.request.receiveMultipart
|
||||
import io.ktor.server.response.respondText
|
||||
@ -12,7 +11,6 @@ import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.routing.post
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import kotlinx.coroutines.withTimeoutOrNull
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.CleanCache
|
||||
@ -20,7 +18,7 @@ import moe.fuqiuluo.shamrock.remote.action.handlers.DownloadFile
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.GetDeviceBattery
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.GetVersionInfo
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.RestartMe
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.remote.service.config.ShamrockConfig
|
||||
import moe.fuqiuluo.shamrock.tools.asString
|
||||
import moe.fuqiuluo.shamrock.tools.fetchOrNull
|
||||
@ -33,7 +31,6 @@ import moe.fuqiuluo.shamrock.tools.respond
|
||||
import moe.fuqiuluo.shamrock.utils.FileUtils
|
||||
import moe.fuqiuluo.shamrock.utils.MD5
|
||||
import java.io.File
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
fun Routing.otherAction() {
|
||||
|
||||
|
@ -9,9 +9,9 @@ import io.ktor.server.routing.Routing
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionManager
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.GetLoginInfo
|
||||
import moe.fuqiuluo.shamrock.remote.entries.CommonResult
|
||||
import moe.fuqiuluo.shamrock.remote.entries.CurrentAccount
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.CommonResult
|
||||
import moe.fuqiuluo.shamrock.remote.structures.CurrentAccount
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.tools.*
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.AppRuntimeFetcher
|
||||
import mqq.app.MobileQQ
|
||||
|
@ -3,9 +3,9 @@ package moe.fuqiuluo.shamrock.remote.api
|
||||
import com.tencent.mobileqq.dt.model.FEBound
|
||||
import io.ktor.server.routing.Routing
|
||||
import moe.fuqiuluo.qqinterface.servlet.BaseSvc
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Protocol
|
||||
import moe.fuqiuluo.shamrock.remote.entries.QSignDtConfig
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Protocol
|
||||
import moe.fuqiuluo.shamrock.remote.structures.QSignDtConfig
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.tools.*
|
||||
import moe.fuqiuluo.shamrock.utils.MMKVFetcher
|
||||
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||
|
@ -6,7 +6,7 @@ import io.ktor.server.application.call
|
||||
import io.ktor.server.response.respondText
|
||||
import io.ktor.server.routing.Routing
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.*
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.tools.*
|
||||
|
||||
fun Routing.ticketActions() {
|
||||
|
@ -12,9 +12,9 @@ import io.ktor.util.AttributeKey
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import moe.fuqiuluo.shamrock.helper.Level
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.shamrock.remote.entries.CommonResult
|
||||
import moe.fuqiuluo.shamrock.remote.entries.ErrorCatch
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.CommonResult
|
||||
import moe.fuqiuluo.shamrock.remote.structures.ErrorCatch
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
|
||||
val ECHO_KEY = AttributeKey<JsonElement>("echo")
|
||||
|
||||
@ -24,46 +24,54 @@ fun Application.statusPages() {
|
||||
val echo = if (call.attributes.contains(ECHO_KEY)) {
|
||||
call.attributes[ECHO_KEY]
|
||||
} else null
|
||||
call.respond(CommonResult(
|
||||
call.respond(
|
||||
CommonResult(
|
||||
status = "failed",
|
||||
retcode = Status.BadParam.code,
|
||||
data = ErrorCatch(call.request.uri, cause.message ?: ""),
|
||||
echo = echo
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
exception<LogicException> { call, cause ->
|
||||
val echo = if (call.attributes.contains(ECHO_KEY)) {
|
||||
call.attributes[ECHO_KEY]
|
||||
} else null
|
||||
call.respond(CommonResult(
|
||||
call.respond(
|
||||
CommonResult(
|
||||
status = "failed",
|
||||
retcode = Status.LogicError.code,
|
||||
data = ErrorCatch(call.request.uri, cause.message ?: ""),
|
||||
echo = echo
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
exception<ErrorTokenException> { call, cause ->
|
||||
val echo = if (call.attributes.contains(ECHO_KEY)) {
|
||||
call.attributes[ECHO_KEY]
|
||||
} else null
|
||||
call.respond(CommonResult(
|
||||
call.respond(
|
||||
CommonResult(
|
||||
status = "failed",
|
||||
retcode = Status.ErrorToken.code,
|
||||
data = ErrorCatch(call.request.uri, cause.message ?: ""),
|
||||
echo = echo
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
exception<Throwable> { call, cause ->
|
||||
val echo = if (call.attributes.contains(ECHO_KEY)) {
|
||||
call.attributes[ECHO_KEY]
|
||||
} else null
|
||||
LogCenter.log(cause.stackTraceToString(), Level.ERROR)
|
||||
call.respond(CommonResult(
|
||||
call.respond(
|
||||
CommonResult(
|
||||
status = "failed",
|
||||
retcode = Status.InternalHandlerError.code,
|
||||
data = ErrorCatch(call.request.uri, cause.message ?: ""),
|
||||
echo = echo
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -7,9 +7,6 @@ import com.tencent.qqnt.kernel.nativeinterface.MsgRecord
|
||||
import moe.fuqiuluo.qqinterface.servlet.GroupSvc
|
||||
import moe.fuqiuluo.qqinterface.servlet.MsgSvc
|
||||
import io.ktor.client.statement.bodyAsText
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.server.application.call
|
||||
import io.ktor.server.response.respondText
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.Job
|
||||
@ -19,18 +16,13 @@ import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.JsonPrimitive
|
||||
import moe.fuqiuluo.qqinterface.servlet.msg.*
|
||||
import moe.fuqiuluo.shamrock.remote.service.api.HttpTransmitServlet
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.push.*
|
||||
import moe.fuqiuluo.shamrock.tools.*
|
||||
import moe.fuqiuluo.shamrock.helper.Level
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionManager
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.QuickOperation.quicklyReply
|
||||
import moe.fuqiuluo.shamrock.remote.config.ECHO_KEY
|
||||
import moe.fuqiuluo.shamrock.remote.entries.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.service.api.GlobalEventTransmitter
|
||||
|
||||
internal object HttpService: HttpTransmitServlet() {
|
||||
|
@ -2,10 +2,8 @@
|
||||
|
||||
package moe.fuqiuluo.shamrock.remote.service.api
|
||||
|
||||
import io.ktor.client.statement.bodyAsText
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
@ -13,14 +11,13 @@ import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionManager
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.entries.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.entries.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.structures.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.service.config.ShamrockConfig
|
||||
import moe.fuqiuluo.shamrock.tools.*
|
||||
import moe.fuqiuluo.shamrock.helper.Level
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.shamrock.remote.service.HttpService
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.BotStatus
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.Self
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.push.MetaEventType
|
||||
|
@ -11,9 +11,9 @@ import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionManager
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.entries.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.entries.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.structures.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.resultToString
|
||||
import moe.fuqiuluo.shamrock.remote.service.config.ShamrockConfig
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.BotStatus
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.Self
|
||||
|
@ -1,12 +1,10 @@
|
||||
package moe.fuqiuluo.shamrock.remote.entries
|
||||
package moe.fuqiuluo.shamrock.remote.structures
|
||||
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import moe.fuqiuluo.shamrock.remote.service.config.ShamrockConfig
|
||||
import moe.fuqiuluo.shamrock.tools.json
|
||||
|
||||
enum class Status(
|
||||
val code: Int
|
@ -1,4 +1,4 @@
|
||||
package moe.fuqiuluo.shamrock.remote.entries
|
||||
package moe.fuqiuluo.shamrock.remote.structures
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
@ -1,4 +1,4 @@
|
||||
package moe.fuqiuluo.shamrock.remote.entries
|
||||
package moe.fuqiuluo.shamrock.remote.structures
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -1,4 +1,4 @@
|
||||
package moe.fuqiuluo.shamrock.remote.entries
|
||||
package moe.fuqiuluo.shamrock.remote.structures
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
@ -1,4 +1,4 @@
|
||||
package moe.fuqiuluo.shamrock.remote.entries
|
||||
package moe.fuqiuluo.shamrock.remote.structures
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
@ -24,9 +24,9 @@ import io.ktor.http.parseUrlEncodedParameters
|
||||
import io.ktor.server.request.httpMethod
|
||||
import io.ktor.server.routing.route
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import moe.fuqiuluo.shamrock.remote.entries.CommonResult
|
||||
import moe.fuqiuluo.shamrock.remote.entries.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.entries.Status
|
||||
import moe.fuqiuluo.shamrock.remote.structures.CommonResult
|
||||
import moe.fuqiuluo.shamrock.remote.structures.EmptyObject
|
||||
import moe.fuqiuluo.shamrock.remote.structures.Status
|
||||
|
||||
@DslMarker
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS, AnnotationTarget.TYPEALIAS, AnnotationTarget.TYPE)
|
||||
@ -316,13 +316,15 @@ internal suspend inline fun PipelineContext<Unit, ApplicationCall>.respond(
|
||||
msg: String = "",
|
||||
echo: JsonElement = EmptyJsonString
|
||||
) {
|
||||
call.respond(CommonResult(
|
||||
call.respond(
|
||||
CommonResult(
|
||||
if (isOk) "ok" else "failed",
|
||||
code.code,
|
||||
EmptyObject,
|
||||
msg,
|
||||
echo
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@ShamrockDsl
|
||||
@ -333,13 +335,15 @@ internal suspend inline fun <reified T : Any> PipelineContext<Unit, ApplicationC
|
||||
msg: String = "",
|
||||
echo: JsonElement = EmptyJsonString
|
||||
) {
|
||||
call.respond(CommonResult(
|
||||
call.respond(
|
||||
CommonResult(
|
||||
if (isOk) "ok" else "failed",
|
||||
code.code,
|
||||
data,
|
||||
msg,
|
||||
echo
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@ShamrockDsl
|
||||
@ -350,11 +354,13 @@ internal suspend inline fun <reified T : Any> PipelineContext<Unit, ApplicationC
|
||||
msg: String = "",
|
||||
echo: JsonElement = EmptyJsonString
|
||||
) {
|
||||
call.respond(CommonResult(
|
||||
call.respond(
|
||||
CommonResult(
|
||||
if (isOk) "ok" else "failed",
|
||||
code,
|
||||
data,
|
||||
msg,
|
||||
echo
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
@ -6,12 +6,12 @@ import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import de.robv.android.xposed.XposedBridge.log
|
||||
import moe.fuqiuluo.shamrock.utils.MMKVFetcher
|
||||
import moe.fuqiuluo.shamrock.xposed.loader.ActionLoader
|
||||
import moe.fuqiuluo.shamrock.xposed.loader.KeepAlive
|
||||
import moe.fuqiuluo.shamrock.xposed.loader.LuoClassloader
|
||||
import moe.fuqiuluo.shamrock.tools.FuzzySearchClass
|
||||
import moe.fuqiuluo.shamrock.tools.afterHook
|
||||
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||
import moe.fuqiuluo.shamrock.xposed.hooks.runFirstActions
|
||||
import mqq.app.MobileQQ
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Modifier
|
||||
@ -134,7 +134,7 @@ internal class XposedEntry: IXposedHookLoadPackage {
|
||||
MMKVFetcher.initMMKV(ctx)
|
||||
}
|
||||
|
||||
ActionLoader.runFirst(ctx)
|
||||
runFirstActions(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
@file:Suppress("UNCHECKED_CAST", "LocalVariableName")
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
@ -17,12 +17,11 @@ import moe.fuqiuluo.shamrock.tools.hookMethod
|
||||
import moe.fuqiuluo.shamrock.xposed.XposedEntry
|
||||
import moe.fuqiuluo.shamrock.xposed.loader.LuoClassloader
|
||||
import moe.fuqiuluo.shamrock.xposed.loader.NativeLoader
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
|
||||
/**
|
||||
* 反检测
|
||||
*/
|
||||
@XposedHook(priority = 0)
|
||||
class AntiDetection: IAction {
|
||||
external fun antiNativeDetections(): Boolean
|
||||
private external fun antiNativeDetections(): Boolean
|
||||
|
||||
override fun invoke(ctx: Context) {
|
||||
antiFindPackage(ctx)
|
@ -1,5 +1,5 @@
|
||||
@file:OptIn(DelicateCoroutinesApi::class)
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
@ -13,6 +13,7 @@ import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.internal.DynamicReceiver
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
import mqq.app.MobileQQ
|
||||
|
||||
internal lateinit var GlobalUi: Handler
|
||||
@ -25,6 +26,7 @@ internal fun Context.toast(msg: String, flag: Int = Toast.LENGTH_SHORT) {
|
||||
GlobalUi.post { Toast.makeText(this, msg, flag).show() }
|
||||
}
|
||||
|
||||
@XposedHook(priority = 0)
|
||||
internal class DataReceiver: IAction {
|
||||
@SuppressLint("UnspecifiedRegisterReceiverFlag")
|
||||
override fun invoke(ctx: Context) {
|
@ -1,5 +1,5 @@
|
||||
@file:OptIn(DelicateCoroutinesApi::class)
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.Context
|
||||
import com.tencent.qqnt.kernel.api.IKernelService
|
||||
@ -13,7 +13,9 @@ import moe.fuqiuluo.shamrock.helper.Level
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.NTServiceFetcher
|
||||
import moe.fuqiuluo.shamrock.xposed.loader.NativeLoader
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
|
||||
@XposedHook(priority = 2)
|
||||
internal class FetchService: IAction {
|
||||
override fun invoke(ctx: Context) {
|
||||
NativeLoader.load("shamrock")
|
@ -1,9 +1,11 @@
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.Context
|
||||
import moe.fuqiuluo.shamrock.tools.hookMethod
|
||||
import moe.fuqiuluo.shamrock.xposed.loader.NativeLoader
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
|
||||
@XposedHook(priority = 0)
|
||||
internal class FixLibraryLoad: IAction {
|
||||
val redirectedLibrary =arrayOf(
|
||||
"ffmpegkit_abidetect",
|
@ -1,11 +1,9 @@
|
||||
@file:Suppress("UNUSED_VARIABLE", "LocalVariableName")
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.Context
|
||||
import com.tencent.common.config.pad.DeviceType
|
||||
import com.tencent.qqnt.kernel.nativeinterface.InitSessionConfig
|
||||
import com.tencent.qqnt.kernel.nativeinterface.PlatformType
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import moe.fuqiuluo.shamrock.remote.service.config.ShamrockConfig
|
||||
import moe.fuqiuluo.shamrock.tools.FuzzySearchClass
|
||||
@ -14,7 +12,9 @@ import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.shamrock.tools.afterHook
|
||||
import moe.fuqiuluo.shamrock.tools.hookMethod
|
||||
import moe.fuqiuluo.shamrock.xposed.loader.LuoClassloader
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
|
||||
@XposedHook(priority = 0)
|
||||
internal class ForceTablet: IAction {
|
||||
override fun invoke(ctx: Context) {
|
||||
//if (!PlatformUtils.isMqqPackage()) return
|
@ -1,4 +1,4 @@
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.Context
|
||||
import com.tencent.beacon.event.open.BeaconReport
|
||||
@ -8,10 +8,10 @@ import moe.fuqiuluo.shamrock.tools.hex2ByteArray
|
||||
import moe.fuqiuluo.shamrock.tools.hookMethod
|
||||
import moe.fuqiuluo.shamrock.utils.MMKVFetcher
|
||||
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
import oicq.wlogin_sdk.tools.util
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.reflect.jvm.javaMethod
|
||||
|
||||
@XposedHook(priority = 10)
|
||||
internal class GuidLock: IAction {
|
||||
companion object {
|
||||
var qimei: String = ""
|
@ -1,19 +1,9 @@
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.Context
|
||||
import com.tencent.mobileqq.profilecard.api.IProfileProtocolService
|
||||
import com.tencent.mobileqq.qroute.QRoute
|
||||
import com.tencent.mobileqq.qroute.QRouteApi
|
||||
import com.tencent.mobileqq.transfile.HttpNetReq
|
||||
import com.tencent.mobileqq.transfile.NetReq
|
||||
import com.tencent.mobileqq.transfile.api.IHttpEngineService
|
||||
import com.tencent.mobileqq.transfile.api.IOldHttpEngineProcessor
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.shamrock.tools.hookMethod
|
||||
import moe.fuqiuluo.shamrock.tools.toInnerValuesString
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.AppRuntimeFetcher
|
||||
import mqq.app.MobileQQ
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
|
||||
@XposedHook(priority = -1)
|
||||
internal class HookForDebug: IAction {
|
||||
override fun invoke(ctx: Context) {
|
||||
/*
|
@ -1,5 +1,5 @@
|
||||
@file:OptIn(DelicateCoroutinesApi::class)
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.Context
|
||||
import com.tencent.msf.service.protocol.pb.SSOLoginMerge
|
||||
@ -8,7 +8,6 @@ import com.tencent.qphone.base.remote.ToServiceMsg
|
||||
import com.tencent.qphone.base.util.CodecWarpper
|
||||
import kotlinx.atomicfu.atomic
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import moe.fuqiuluo.qqinterface.servlet.TicketSvc
|
||||
import moe.fuqiuluo.shamrock.remote.service.PacketReceiver
|
||||
import moe.fuqiuluo.shamrock.remote.service.config.ShamrockConfig
|
||||
import moe.fuqiuluo.shamrock.tools.EMPTY_BYTE_ARRAY
|
||||
@ -18,9 +17,11 @@ import moe.fuqiuluo.shamrock.helper.Level
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.internal.DynamicReceiver
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.internal.IPCRequest
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
|
||||
private const val MAGIC_APP_ID = 114514
|
||||
|
||||
@XposedHook(priority = 2)
|
||||
internal class HookWrapperCodec: IAction {
|
||||
private val IgnoredCmd = arrayOf(
|
||||
"trpc.sq_adv.official_account_adv_push.OfficialAccountAdvPush.AdvPush",
|
@ -1,4 +1,4 @@
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.Context
|
||||
|
@ -1,6 +1,6 @@
|
||||
@file:OptIn(DelicateCoroutinesApi::class)
|
||||
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
@ -16,12 +16,15 @@ import moe.fuqiuluo.shamrock.remote.HTTPServer
|
||||
import moe.fuqiuluo.shamrock.remote.service.HttpService
|
||||
import moe.fuqiuluo.shamrock.tools.ShamrockVersion
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.AppRuntimeFetcher
|
||||
import moe.fuqiuluo.symbols.Process
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
import mqq.app.MobileQQ
|
||||
import kotlin.concurrent.timer
|
||||
|
||||
@XposedHook(Process.MAIN, priority = 10)
|
||||
internal class InitRemoteService : IAction {
|
||||
override fun invoke(ctx: Context) {
|
||||
if (!PlatformUtils.isMainProcess()) return
|
||||
//if (!PlatformUtils.isMainProcess()) return
|
||||
|
||||
GlobalScope.launch {
|
||||
try {
|
@ -1,6 +1,6 @@
|
||||
@file:OptIn(DelicateCoroutinesApi::class)
|
||||
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
@ -13,7 +13,10 @@ import moe.fuqiuluo.shamrock.helper.Level
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.internal.*
|
||||
import moe.fuqiuluo.shamrock.xposed.ipc.ShamrockIpc
|
||||
import moe.fuqiuluo.symbols.Process
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
|
||||
@XposedHook(Process.MSF, 0)
|
||||
internal class IpcService: IAction {
|
||||
override fun invoke(ctx: Context) {
|
||||
if (!PlatformUtils.isMsfProcess()) return
|
@ -1,4 +1,4 @@
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
@ -6,8 +6,10 @@ import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.os.Process
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
@XposedHook(priority = 20)
|
||||
internal class ListenShamrockUpdate: IAction {
|
||||
override fun invoke(ctx: Context) {
|
||||
val intent = IntentFilter()
|
@ -1,4 +1,4 @@
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.Context
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
@ -6,8 +6,10 @@ import moe.fuqiuluo.shamrock.tools.hookMethod
|
||||
import moe.fuqiuluo.shamrock.helper.Level
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.shamrock.xposed.loader.LuoClassloader
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
import mqq.app.MobileQQ
|
||||
|
||||
@XposedHook(priority = 10)
|
||||
internal class NoBackGround: IAction {
|
||||
override fun invoke(ctx: Context) {
|
||||
kotlin.runCatching {
|
@ -1,6 +1,6 @@
|
||||
@file:OptIn(DelicateCoroutinesApi::class)
|
||||
|
||||
package moe.fuqiuluo.shamrock.xposed.actions
|
||||
package moe.fuqiuluo.shamrock.xposed.hooks
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
@ -13,12 +13,14 @@ import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.internal.DataRequester
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.internal.DynamicReceiver
|
||||
import moe.fuqiuluo.shamrock.xposed.helper.internal.IPCRequest
|
||||
import moe.fuqiuluo.shamrock.xposed.loader.ActionLoader
|
||||
import moe.fuqiuluo.shamrock.xposed.loader.NativeLoader
|
||||
import moe.fuqiuluo.symbols.Process
|
||||
import moe.fuqiuluo.symbols.XposedHook
|
||||
import mqq.app.MobileQQ
|
||||
import kotlin.concurrent.thread
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
@XposedHook(Process.MAIN, priority = 1)
|
||||
class PullConfig: IAction {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@ -87,6 +89,6 @@ class PullConfig: IAction {
|
||||
private fun initAppService(ctx: Context) {
|
||||
NativeLoader.load("shamrock")
|
||||
ctx.toast(testNativeLibrary())
|
||||
ActionLoader.runService(ctx)
|
||||
runServiceActions(ctx)
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import com.tencent.mobileqq.qsec.qsecurity.QSec
|
||||
import com.tencent.qphone.base.util.BaseApplication
|
||||
import moe.fuqiuluo.shamrock.tools.toHexString
|
||||
import moe.fuqiuluo.shamrock.utils.MMKVFetcher
|
||||
import moe.fuqiuluo.shamrock.xposed.actions.GuidLock
|
||||
import moe.fuqiuluo.shamrock.xposed.hooks.GuidLock
|
||||
import mqq.app.MobileQQ
|
||||
import oicq.wlogin_sdk.tools.util
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
package moe.fuqiuluo.shamrock.xposed.loader
|
||||
|
||||
import android.content.Context
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import moe.fuqiuluo.shamrock.xposed.actions.*
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.createInstance
|
||||
|
||||
object ActionLoader {
|
||||
private val ACTION_FIRST_LIST = arrayOf(
|
||||
AntiDetection::class,
|
||||
DataReceiver::class, // 注册一个接收数据的动态广播
|
||||
IpcService::class,
|
||||
PullConfig::class, // 从APP进程拉扯配置文件
|
||||
ForceTablet::class, // 强制平板模式
|
||||
HookWrapperCodec::class, // 注册服务处理器
|
||||
HookForDebug::class,
|
||||
FixLibraryLoad::class,
|
||||
FetchService::class, // 获取服务实例
|
||||
)
|
||||
|
||||
private val ACTION_LIST = arrayOf<KClass<*>>(
|
||||
InitRemoteService::class, // 创建HTTP API
|
||||
NoBackGround::class, // 反QQ后台模式
|
||||
GuidLock::class,
|
||||
ListenShamrockUpdate::class
|
||||
)
|
||||
|
||||
// 先从APP拉取配置文件,再执行其他操作
|
||||
fun runFirst(ctx: Context) {
|
||||
kotlin.runCatching {
|
||||
ACTION_FIRST_LIST.forEach {
|
||||
val action = it.createInstance()
|
||||
action.invoke(ctx)
|
||||
}
|
||||
}.onFailure {
|
||||
XposedBridge.log(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun runService(ctx: Context) {
|
||||
ACTION_LIST.forEach {
|
||||
if (it.java != DataReceiver::class.java) {
|
||||
val action = it.createInstance() as IAction
|
||||
action.invoke(ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user