diff --git a/src/main/kotlin/app/revanced/patches/photomath/detection/signature/annotations/DisableSignatureDetectionCompatibility.kt b/src/main/kotlin/app/revanced/patches/photomath/detection/signature/annotations/DisableSignatureDetectionCompatibility.kt index 38ecde59..cd1eb5cc 100644 --- a/src/main/kotlin/app/revanced/patches/photomath/detection/signature/annotations/DisableSignatureDetectionCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/photomath/detection/signature/annotations/DisableSignatureDetectionCompatibility.kt @@ -3,6 +3,28 @@ package app.revanced.patches.photomath.detection.signature.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.microblink.photomath")]) +@Compatibility( + [Package( + "com.microblink.photomath", arrayOf( + "8.6.0", + "8.7.0", + "8.8.0", + "8.9.0", + "8.10.0", + "8.11.0", + "8.12.0", + "8.13.0", + "8.14.0", + "8.15.0", + "8.16.0", + "8.17.0", + "8.18.0", + "8.18.1", + "8.19.0", + "8.20.0", + "8.21.0", + ) + )] +) @Target(AnnotationTarget.CLASS) -internal annotation class DisableSignatureDetectionCompatibility \ No newline at end of file +internal annotation class DisableSignatureDetectionCompatibility diff --git a/src/main/kotlin/app/revanced/patches/photomath/detection/signature/fingerprints/CheckSignatureFingerprint.kt b/src/main/kotlin/app/revanced/patches/photomath/detection/signature/fingerprints/CheckSignatureFingerprint.kt index 26fb7265..2f460c69 100644 --- a/src/main/kotlin/app/revanced/patches/photomath/detection/signature/fingerprints/CheckSignatureFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/photomath/detection/signature/fingerprints/CheckSignatureFingerprint.kt @@ -1,9 +1,18 @@ package app.revanced.patches.photomath.detection.signature.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode object CheckSignatureFingerprint : MethodFingerprint( + returnType = "V", + access = AccessFlags.PUBLIC or AccessFlags.FINAL, + customFingerprint = { + (it.definingClass == "Lcom/microblink/photomath/main/activity/LauncherActivity;" || + it.definingClass == "Lcom/microblink/photomath/PhotoMath;") && + it.name == "onCreate" + }, strings = listOf( "currentSignature" ), @@ -18,4 +27,4 @@ object CheckSignatureFingerprint : MethodFingerprint( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT, ) -) \ No newline at end of file +) diff --git a/src/main/kotlin/app/revanced/patches/photomath/detection/signature/fingerprints/MainOnCreateFingerprint.kt b/src/main/kotlin/app/revanced/patches/photomath/detection/signature/fingerprints/MainOnCreateFingerprint.kt deleted file mode 100644 index f263f0b7..00000000 --- a/src/main/kotlin/app/revanced/patches/photomath/detection/signature/fingerprints/MainOnCreateFingerprint.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.revanced.patches.photomath.detection.signature.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags - -object MainOnCreateFingerprint : MethodFingerprint( - returnType = "V", - access = AccessFlags.PUBLIC or AccessFlags.FINAL, - customFingerprint = { methodDef -> - methodDef.definingClass == "Lcom/microblink/photomath/PhotoMath;" && methodDef.name == "onCreate" - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt index f8a07bd9..25d77a39 100644 --- a/src/main/kotlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt @@ -1,42 +1,35 @@ package app.revanced.patches.photomath.detection.signature.patch +import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.instruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.photomath.detection.signature.annotations.DisableSignatureDetectionCompatibility import app.revanced.patches.photomath.detection.signature.fingerprints.CheckSignatureFingerprint -import app.revanced.patches.photomath.detection.signature.fingerprints.MainOnCreateFingerprint import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Description("Disables detection of incorrect signature.") @DisableSignatureDetectionCompatibility -@Version("0.0.1") +@Version("0.0.2") class SignatureDetectionPatch : BytecodePatch( listOf( - MainOnCreateFingerprint + CheckSignatureFingerprint ) ) { override fun execute(context: BytecodeContext): PatchResult { - val mainOnCreate = MainOnCreateFingerprint.result!! - - val patternResult = CheckSignatureFingerprint.also { - it.resolve(context, mainOnCreate.method, mainOnCreate.classDef) - }.result!!.scanResult.patternScanResult!! - - mainOnCreate.mutableMethod.apply { - val signatureCheckInstruction = instruction(patternResult.endIndex) + CheckSignatureFingerprint.result?.apply { + val signatureCheckInstruction = mutableMethod.instruction(scanResult.patternScanResult!!.endIndex) val checkRegister = (signatureCheckInstruction as OneRegisterInstruction).registerA - replaceInstruction(signatureCheckInstruction.location.index, "const/4 v$checkRegister, 0x1") - } + mutableMethod.replaceInstruction(signatureCheckInstruction.location.index, "const/4 v$checkRegister, 0x1") + } ?: throw CheckSignatureFingerprint.toErrorResult() return PatchResultSuccess() } -} \ No newline at end of file +}