Skip to content

Commit

Permalink
fix: wrong opcode pattern for enable-seekbar-tapping-signature
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Apr 15, 2022
1 parent 0924ca2 commit 1d83395
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class EnableSeekbarTappingPatch : Patch(
MethodSignature(
MethodSignatureMetadata(
"enable-seekbar-tapping-parent-signature",
MethodMetadata(null, null), // unknown
MethodMetadata("Lesa;", "<init>"), // unknown
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
"Signature for a parent method, which is needed to find the actual method required to be patched.",
Expand Down Expand Up @@ -75,7 +75,7 @@ class EnableSeekbarTappingPatch : Patch(
MethodSignature(
MethodSignatureMetadata(
"enable-seekbar-tapping-signature",
MethodMetadata(null, null), // unknown
MethodMetadata("Lesa;", "onTouchEvent"), // unknown
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
"Signature for the method required to be patched.",
Expand All @@ -85,17 +85,6 @@ class EnableSeekbarTappingPatch : Patch(
AccessFlags.PUBLIC or AccessFlags.FINAL,
listOf("L"),
listOf(
Opcode.CMPG_DOUBLE,
Opcode.IF_GTZ,
Opcode.GOTO,
Opcode.INT_TO_FLOAT,
Opcode.INT_TO_FLOAT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.IF_NEZ,
Opcode.RETURN,
Opcode.IGET_OBJECT,
Opcode.IF_EQZ,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_WIDE,
Opcode.INT_TO_FLOAT,
Expand All @@ -116,6 +105,15 @@ class EnableSeekbarTappingPatch : Patch(
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.FLOAT_TO_INT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.FLOAT_TO_INT,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.INVOKE_VIRTUAL
)
)
Expand Down Expand Up @@ -156,7 +154,7 @@ class EnableSeekbarTappingPatch : Patch(
val oMethod = tapSeekMethods["O"]!!

// get the required register
val instruction = implementation.instructions[result.scanData.endIndex + 1]
val instruction = implementation.instructions[result.scanData.endIndex - 1]
if (instruction.opcode != Opcode.INVOKE_VIRTUAL)
return PatchResultError("Could not find the correct register")
val register = (instruction as Instruction35c).registerC
Expand Down
23 changes: 8 additions & 15 deletions src/test/kotlin/app/revanced/patches/SignatureChecker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java.io.File
internal class SignatureChecker {
@Test
fun checkSignatures() {
val file = File("stock.apk")
val file = File("newest.apk")
if (!file.exists()) {
throw IllegalStateException("Missing stock.apk! To run this test, please place stock.apk here: ${file.absolutePath}")
}
Expand All @@ -26,21 +26,14 @@ internal class SignatureChecker {
val patternScanMethod = signature.metadata.patternScanMethod
if (patternScanMethod is PatternScanMethod.Fuzzy) {
val warnings = patternScanMethod.warnings!!
println("Signature ${signature.metadata.name} had ${warnings.size} warnings!")
val method = signature.result!!.method
val instructions = method.implementation!!.instructions
println("class = ${method.definingClass}, method = ${printMethod(method)}")

println("Signature: ${signature.metadata.name}.\nMethod: ${method.definingClass}->${method.toStr()}\nWarnings: ${warnings.count()}")
for (warning in warnings) {
println("-".repeat(10))
for (i in (warning.actualIndex - 5).coerceAtLeast(0) until warning.actualIndex) {
println("$i: ${instructions[i].opcode}")
}
println("${warning.actualIndex}: $warning")
for (i in warning.actualIndex + 1 until (warning.actualIndex + 5).coerceAtMost(instructions.size)) {
println("$i: ${instructions[i].opcode}")
}
println("${warning.instructionIndex} / ${warning.patternIndex}: ${warning.current} (expected: ${warning.expected})")
}
println("=".repeat(20))

println("=".repeat(20) + "\n")
}
}
if (unresolved.isNotEmpty()) {
Expand All @@ -52,7 +45,7 @@ internal class SignatureChecker {
}
}

private fun printMethod(method: Method): String {
return "${method.name}(${method.parameterTypes.joinToString("")})${method.returnType}"
private fun Method.toStr(): String {
return "${this.name}(${this.parameterTypes.joinToString("")})${this.returnType}"
}
}

0 comments on commit 1d83395

Please sign in to comment.