refactor(youtube-music/bypass-certificate-checks): use simpler patch

This commit is contained in:
LisoUseInAIKyrios 2023-07-02 17:37:16 +04:00
parent 4d9317fef0
commit f90d1a64ce

View file

@ -5,8 +5,7 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.PatchResultSuccess
@ -23,15 +22,13 @@ class BypassCertificateChecksPatch : BytecodePatch(
listOf(CheckCertificateFingerprint) listOf(CheckCertificateFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
CheckCertificateFingerprint.result?.let { result -> CheckCertificateFingerprint.result?.apply {
val noMatchIndex = result.scanResult.stringsScanResult!!.matches.first().index mutableMethod.addInstructions(
0, """
result.mutableMethod.apply { const/4 v0, 0x1
val isPartnerIndex = noMatchIndex + 2 return v0
"""
replaceInstruction(isPartnerIndex, "const/4 p1, 0x1") )
addInstruction(isPartnerIndex + 1, "return p1")
}
} ?: return CheckCertificateFingerprint.toErrorResult() } ?: return CheckCertificateFingerprint.toErrorResult()
return PatchResultSuccess() return PatchResultSuccess()