mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2024-11-10 01:02:22 +01:00
feat: Allow unknown opcodes using null
This is the same as `??` in IDA signatures.
This commit is contained in:
parent
3bfc24fc16
commit
f4a47d4dc8
2 changed files with 11 additions and 3 deletions
|
@ -10,13 +10,14 @@ import org.jf.dexlib2.Opcode
|
|||
* @param accessFlags The access flags of the method.
|
||||
* @param methodParameters The parameters of the method.
|
||||
* @param opcodes The list of opcodes of the method.
|
||||
* A `null` opcode is equals to an unknown opcode.
|
||||
*/
|
||||
class MethodSignature(
|
||||
val metadata: MethodSignatureMetadata,
|
||||
internal val returnType: String?,
|
||||
internal val accessFlags: Int?,
|
||||
internal val methodParameters: Iterable<String>?,
|
||||
internal val opcodes: Iterable<Opcode>?
|
||||
internal val opcodes: Iterable<Opcode?>?
|
||||
) {
|
||||
/**
|
||||
* The result of the signature
|
||||
|
|
|
@ -93,7 +93,11 @@ internal class SignatureResolver(
|
|||
while (instructionIndex + patternIndex < count) {
|
||||
val originalOpcode = instructions.elementAt(instructionIndex + patternIndex).opcode
|
||||
val patternOpcode = pattern.elementAt(patternIndex)
|
||||
if (originalOpcode != patternOpcode && currentThreshold-- == 0) break
|
||||
if (
|
||||
patternOpcode != null && // unknown opcode
|
||||
originalOpcode != patternOpcode &&
|
||||
currentThreshold-- == 0
|
||||
) break
|
||||
if (++patternIndex < size) continue
|
||||
|
||||
val result = PatternScanResult(instructionIndex, instructionIndex + patternIndex)
|
||||
|
@ -125,7 +129,10 @@ internal class SignatureResolver(
|
|||
for ((patternIndex, originalIndex) in (scanResult.startIndex until scanResult.endIndex).withIndex()) {
|
||||
val originalOpcode = instructions.elementAt(originalIndex).opcode
|
||||
val patternOpcode = pattern.elementAt(patternIndex)
|
||||
if (originalOpcode != patternOpcode) {
|
||||
if (
|
||||
patternOpcode != null && // unknown opcode
|
||||
originalOpcode != patternOpcode
|
||||
) {
|
||||
this.add(
|
||||
PatternScanMethod.Fuzzy.Warning(
|
||||
originalOpcode, patternOpcode,
|
||||
|
|
Loading…
Reference in a new issue