diff --git a/src/main/kotlin/app/revanced/patcher/extensions/Extensions.kt b/src/main/kotlin/app/revanced/patcher/extensions/Extensions.kt index 67e3555..fc444fc 100644 --- a/src/main/kotlin/app/revanced/patcher/extensions/Extensions.kt +++ b/src/main/kotlin/app/revanced/patcher/extensions/Extensions.kt @@ -13,7 +13,6 @@ import org.jf.dexlib2.builder.MutableMethodImplementation import org.jf.dexlib2.builder.instruction.* import org.jf.dexlib2.iface.Method import org.jf.dexlib2.iface.instruction.Instruction -import org.jf.dexlib2.iface.reference.MethodReference import org.jf.dexlib2.immutable.ImmutableMethod import org.jf.dexlib2.immutable.ImmutableMethodImplementation import java.io.OutputStream @@ -45,17 +44,6 @@ fun MutableMethodImplementation.removeInstructions(index: Int, count: Int) { } } -/** - * Compare a method to another, considering name and parameters. - * @param otherMethod The method to compare against. - * @return True if the methods match given the conditions. - */ -fun Method.softCompareTo(otherMethod: MethodReference): Boolean { - return this.name == otherMethod.name && parametersEqual( - this.parameterTypes, otherMethod.parameterTypes - ) -} - /** * Clones the method. * @param registerCount This parameter allows you to change the register count of the method. diff --git a/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt b/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt index bdb3aac..f446b5b 100644 --- a/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt +++ b/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt @@ -4,7 +4,6 @@ import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.MethodFingerprintExtensions.fuzzyPatternScanMethod import app.revanced.patcher.extensions.MethodFingerprintExtensions.fuzzyScanThreshold import app.revanced.patcher.extensions.parametersEqual -import app.revanced.patcher.extensions.softCompareTo import app.revanced.patcher.fingerprint.Fingerprint import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.util.proxy.ClassProxy @@ -14,6 +13,7 @@ import org.jf.dexlib2.iface.Method import org.jf.dexlib2.iface.instruction.Instruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.reference.StringReference +import org.jf.dexlib2.util.MethodUtil /** * Represents the [MethodFingerprint] for a method. @@ -297,7 +297,7 @@ data class MethodFingerprintResult( */ val mutableMethod by lazy { mutableClass.methods.first { - it.softCompareTo(this.method) + MethodUtil.methodSignaturesMatch(it, this.method) } } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/util/method/MethodWalker.kt b/src/main/kotlin/app/revanced/patcher/util/method/MethodWalker.kt index a9406d3..70efa01 100644 --- a/src/main/kotlin/app/revanced/patcher/util/method/MethodWalker.kt +++ b/src/main/kotlin/app/revanced/patcher/util/method/MethodWalker.kt @@ -1,11 +1,11 @@ package app.revanced.patcher.util.method import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.softCompareTo import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import org.jf.dexlib2.iface.Method import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.reference.MethodReference +import org.jf.dexlib2.util.MethodUtil /** * Find a method from another method via instruction offsets. @@ -44,8 +44,8 @@ class MethodWalker internal constructor( val proxy = bytecodeContext.findClass(newMethod.definingClass)!! val methods = if (walkMutable) proxy.mutableClass.methods else proxy.immutableClass.methods - currentMethod = methods.first { it -> - return@first it.softCompareTo(newMethod) + currentMethod = methods.first { + return@first MethodUtil.methodSignaturesMatch(it, newMethod) } return this }