Skip to content

Commit

Permalink
feat(photomath): bump compatibility up to 8.21.0 (ReVanced#1886)
Browse files Browse the repository at this point in the history
  • Loading branch information
badawoll authored and oSumAtrIX committed Apr 16, 2023
1 parent d86b6a4 commit 43464fd
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
internal annotation class DisableSignatureDetectionCompatibility
Original file line number Diff line number Diff line change
@@ -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"
),
Expand All @@ -18,4 +27,4 @@ object CheckSignatureFingerprint : MethodFingerprint(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,
)
)
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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()
}

}
}

0 comments on commit 43464fd

Please sign in to comment.