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