|
|
@ -3,21 +3,43 @@ package app.revanced.patches.reddit.customclients.relayforreddit.api.patch
|
|
|
|
import app.revanced.patcher.annotation.Compatibility
|
|
|
|
import app.revanced.patcher.annotation.Compatibility
|
|
|
|
import app.revanced.patcher.annotation.Package
|
|
|
|
import app.revanced.patcher.annotation.Package
|
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
|
|
|
|
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
|
|
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
|
|
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
|
|
|
import app.revanced.patcher.patch.PatchResult
|
|
|
|
import app.revanced.patcher.patch.PatchResult
|
|
|
|
import app.revanced.patcher.patch.PatchResultSuccess
|
|
|
|
import app.revanced.patcher.patch.PatchResultSuccess
|
|
|
|
import app.revanced.patches.reddit.customclients.AbstractChangeOAuthClientIdPatch
|
|
|
|
import app.revanced.patches.reddit.customclients.AbstractChangeOAuthClientIdPatch
|
|
|
|
import app.revanced.patches.reddit.customclients.ChangeOAuthClientIdPatchAnnotation
|
|
|
|
import app.revanced.patches.reddit.customclients.ChangeOAuthClientIdPatchAnnotation
|
|
|
|
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.GetClientIdFingerprint
|
|
|
|
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.GetLoggedInBearerTokenFingerprint
|
|
|
|
|
|
|
|
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.GetLoggedOutBearerTokenFingerprint
|
|
|
|
|
|
|
|
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.LoginActivityClientIdFingerprint
|
|
|
|
|
|
|
|
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.GetRefreshTokenFingerprint
|
|
|
|
|
|
|
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
|
|
|
|
|
|
|
|
|
|
|
@ChangeOAuthClientIdPatchAnnotation
|
|
|
|
@ChangeOAuthClientIdPatchAnnotation
|
|
|
|
@Compatibility([Package("free.reddit.news"), Package("reddit.news")])
|
|
|
|
@Compatibility([Package("free.reddit.news"), Package("reddit.news")])
|
|
|
|
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
|
|
|
|
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
|
|
|
|
"dbrady://relay", Options, listOf(GetClientIdFingerprint)
|
|
|
|
"dbrady://relay",
|
|
|
|
|
|
|
|
Options,
|
|
|
|
|
|
|
|
listOf(
|
|
|
|
|
|
|
|
LoginActivityClientIdFingerprint,
|
|
|
|
|
|
|
|
GetLoggedInBearerTokenFingerprint,
|
|
|
|
|
|
|
|
GetLoggedOutBearerTokenFingerprint,
|
|
|
|
|
|
|
|
GetRefreshTokenFingerprint
|
|
|
|
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
override fun List<MethodFingerprintResult>.patch(context: BytecodeContext): PatchResult {
|
|
|
|
override fun List<MethodFingerprintResult>.patch(context: BytecodeContext): PatchResult {
|
|
|
|
first().mutableMethod.replaceInstruction(0, "const-string v0, \"$clientId\"")
|
|
|
|
forEach {
|
|
|
|
|
|
|
|
val clientIdIndex = it.scanResult.stringsScanResult!!.matches.first().index
|
|
|
|
|
|
|
|
it.mutableMethod.apply {
|
|
|
|
|
|
|
|
val clientIdRegister = getInstruction<OneRegisterInstruction>(clientIdIndex).registerA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it.mutableMethod.replaceInstruction(
|
|
|
|
|
|
|
|
clientIdIndex,
|
|
|
|
|
|
|
|
"const-string v$clientIdRegister, \"$clientId\""
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return PatchResultSuccess()
|
|
|
|
return PatchResultSuccess()
|
|
|
|
}
|
|
|
|
}
|
|
|
|