fix: attempt on all patches

This commit is contained in:
oSumAtrIX
2022-04-09 22:59:51 +02:00
parent e088c67108
commit 3395d69747
8 changed files with 28 additions and 23 deletions

View File

@ -7,10 +7,10 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.smali.asInstructions
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction11n
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
import org.jf.dexlib2.iface.Method
import org.jf.dexlib2.iface.instruction.formats.Instruction11n
import org.jf.dexlib2.immutable.reference.ImmutableMethodReference
class EnableSeekbarTapping : Patch("enable-seekbar-tapping") {
@ -20,23 +20,26 @@ class EnableSeekbarTapping : Patch("enable-seekbar-tapping") {
val tapSeekMethods = mutableMapOf<String, Method>()
// find the methods which tap the seekbar
map.definingClassProxy.immutableClass.methods.forEach {
for (it in map.definingClassProxy.immutableClass.methods) {
if (it.implementation == null) continue
val instructions = it.implementation!!.instructions
// here we make sure we actually find the method because it has more then 7 instructions
if (instructions.count() < 7) return@forEach
if (instructions.count() < 7) continue
// we know that the 7th instruction has the opcode CONST_4
val instruction = instructions.elementAt(6)
if (instruction.opcode != Opcode.CONST_4) return@forEach
if (instruction.opcode != Opcode.CONST_4) continue
// the literal for this instruction has to be either 1 or 2
val literal = (instruction as BuilderInstruction11n).narrowLiteral
val literal = (instruction as Instruction11n).narrowLiteral
// method founds
if (literal == 1) tapSeekMethods["P"] = it
if (literal == 2) tapSeekMethods["O"] = it
}
val implementation = cache.methodMap["enable-seekbar-tapping"].resolveAndGetMethod().implementation!!
val implementation = cache.methodMap["enable-seekbar-tapping"].method.implementation!!
// if tap-seeking is enabled, do not invoke the two methods below
val pMethod = tapSeekMethods["P"]!!
@ -78,7 +81,7 @@ class EnableSeekbarTapping : Patch("enable-seekbar-tapping") {
)
// if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label
val elseLabel = implementation.instructions[7].location.labels.first()
val elseLabel = implementation.newLabelForIndex(map.scanData.endIndex)
implementation.addInstruction(
map.scanData.endIndex,
BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel)