generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(photomath):
unlock-plus
patch (#1633)
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de> Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
- Loading branch information
Showing
7 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...tches/photomath/detection/signature/annotations/DisableSignatureDetectionCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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")]) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class DisableSignatureDetectionCompatibility |
21 changes: 21 additions & 0 deletions
21
.../revanced/patches/photomath/detection/signature/fingerprints/CheckSignatureFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package app.revanced.patches.photomath.detection.signature.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import org.jf.dexlib2.Opcode | ||
|
||
object CheckSignatureFingerprint : MethodFingerprint( | ||
strings = listOf( | ||
"currentSignature" | ||
), | ||
opcodes = listOf( | ||
Opcode.CONST_STRING, | ||
Opcode.CONST_STRING, | ||
Opcode.INVOKE_STATIC, | ||
Opcode.INVOKE_STATIC, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.INVOKE_STATIC, | ||
Opcode.MOVE_RESULT, | ||
) | ||
) |
13 changes: 13 additions & 0 deletions
13
...pp/revanced/patches/photomath/detection/signature/fingerprints/MainOnCreateFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
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" | ||
} | ||
) |
42 changes: 42 additions & 0 deletions
42
...otlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package app.revanced.patches.photomath.detection.signature.patch | ||
|
||
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") | ||
class SignatureDetectionPatch : BytecodePatch( | ||
listOf( | ||
MainOnCreateFingerprint | ||
) | ||
) { | ||
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) | ||
val checkRegister = (signatureCheckInstruction as OneRegisterInstruction).registerA | ||
|
||
replaceInstruction(signatureCheckInstruction.location.index, "const/4 v$checkRegister, 0x1") | ||
} | ||
|
||
return PatchResultSuccess() | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...tlin/app/revanced/patches/photomath/misc/unlockplus/annotations/UnlockPlusCompatibilty.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package app.revanced.patches.photomath.misc.unlockplus.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility([Package("com.microblink.photomath")]) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class UnlockPlusCompatibilty |
16 changes: 16 additions & 0 deletions
16
.../app/revanced/patches/photomath/misc/unlockplus/fingerprints/IsPlusUnlockedFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package app.revanced.patches.photomath.misc.unlockplus.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import org.jf.dexlib2.AccessFlags | ||
|
||
object IsPlusUnlockedFingerprint : MethodFingerprint( | ||
returnType = "Z", | ||
access = AccessFlags.PUBLIC or AccessFlags.FINAL, | ||
strings = listOf( | ||
"genius" | ||
), | ||
customFingerprint = { | ||
methodDef -> methodDef.definingClass.endsWith("/User;") | ||
} | ||
) |
43 changes: 43 additions & 0 deletions
43
src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/patch/UnlockPlusPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package app.revanced.patches.photomath.misc.unlockplus.patch | ||
|
||
import app.revanced.extensions.toErrorResult | ||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.addInstructions | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.DependsOn | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patches.photomath.detection.signature.patch.SignatureDetectionPatch | ||
import app.revanced.patches.photomath.misc.unlockplus.annotations.UnlockPlusCompatibilty | ||
import app.revanced.patches.photomath.misc.unlockplus.fingerprints.IsPlusUnlockedFingerprint | ||
|
||
@Patch | ||
@Name("unlock-plus") | ||
@DependsOn([SignatureDetectionPatch::class]) | ||
@Description("Unlocks plus features.") | ||
@UnlockPlusCompatibilty | ||
@Version("0.0.1") | ||
class UnlockPlusPatch : BytecodePatch( | ||
listOf( | ||
IsPlusUnlockedFingerprint | ||
) | ||
) { | ||
override fun execute(context: BytecodeContext): PatchResult { | ||
IsPlusUnlockedFingerprint.result?.mutableMethod?.apply { | ||
addInstructions( | ||
0, | ||
""" | ||
const/4 v0, 0x1 | ||
return v0 | ||
""" | ||
) | ||
} ?: return IsPlusUnlockedFingerprint.toErrorResult() | ||
|
||
return PatchResultSuccess() | ||
} | ||
|
||
} |