mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 01:01:56 +01:00
refactor: finalize Signature Checker
This commit is contained in:
parent
0077e26d23
commit
e5a609f716
1 changed files with 14 additions and 5 deletions
|
@ -3,6 +3,7 @@ package app.revanced.patches
|
|||
import app.revanced.patcher.Patcher
|
||||
import app.revanced.patcher.signature.MethodSignature
|
||||
import app.revanced.patcher.signature.PatternScanMethod
|
||||
import org.jf.dexlib2.iface.Method
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
|
@ -26,16 +27,20 @@ internal class SignatureChecker {
|
|||
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)}")
|
||||
for (warning in warnings) {
|
||||
val instructions = signature.result!!.method.implementation!!.instructions
|
||||
for (i in warning.expectedIndex - 5 until warning.expectedIndex) {
|
||||
println(instructions[i].opcode)
|
||||
println("-".repeat(10))
|
||||
for (i in (warning.actualIndex - 5).coerceAtLeast(0) until warning.actualIndex) {
|
||||
println("$i: ${instructions[i].opcode}")
|
||||
}
|
||||
println(warning.toString())
|
||||
for (i in warning.expectedIndex - 5 .. warning.expectedIndex + 1) {
|
||||
println(instructions[i].opcode)
|
||||
for (i in warning.actualIndex + 1 until (warning.actualIndex + 5).coerceAtMost(instructions.size)) {
|
||||
println("$i: ${instructions[i].opcode}")
|
||||
}
|
||||
}
|
||||
println("=".repeat(20))
|
||||
}
|
||||
}
|
||||
if (unresolved.isNotEmpty()) {
|
||||
|
@ -46,4 +51,8 @@ internal class SignatureChecker {
|
|||
throw base
|
||||
}
|
||||
}
|
||||
|
||||
private fun printMethod(method: Method): String {
|
||||
return "${method.name}(${method.parameterTypes.joinToString("")})${method.returnType}"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue