diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/Fingerprints.kt index 90c0bbb91..08b38930b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/Fingerprints.kt @@ -1,21 +1,26 @@ package app.revanced.patches.photomath.detection.deviceid +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.Opcode -import app.revanced.patcher.fingerprint -internal val getDeviceIdFingerprint = fingerprint { - returns("Ljava/lang/String;") - parameters() - opcodes( - Opcode.SGET_OBJECT, - Opcode.IGET_OBJECT, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.IF_NEZ, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_VIRTUAL, +internal val BytecodePatchContext.getDeviceIdMethod by gettingFirstMutableMethodDeclaratively { + returnType("Ljava/lang/String;") + parameterTypes() + instructions( + Opcode.SGET_OBJECT(), + Opcode.IGET_OBJECT(), + Opcode.INVOKE_STATIC(), + Opcode.MOVE_RESULT_OBJECT(), + Opcode.IF_NEZ(), + Opcode.INVOKE_STATIC(), + Opcode.MOVE_RESULT_OBJECT(), + Opcode.INVOKE_VIRTUAL(), + Opcode.MOVE_RESULT_OBJECT(), + Opcode.INVOKE_VIRTUAL(), ) -} \ No newline at end of file +} diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt index 44d4df42c..8e955ed28 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt @@ -1,13 +1,12 @@ package app.revanced.patches.photomath.detection.deviceid -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.photomath.detection.signature.signatureDetectionPatch import app.revanced.util.returnEarly import kotlin.random.Random @Suppress("unused") -val getDeviceIdPatch = bytecodePatch( - name = "Spoof device ID", +val `Spoof device ID` by creatingBytecodePatch( description = "Spoofs device ID to mitigate manual bans by developers.", ) { dependsOn(signatureDetectionPatch) @@ -15,6 +14,6 @@ val getDeviceIdPatch = bytecodePatch( compatibleWith("com.microblink.photomath") apply { - getDeviceIdFingerprint.method.returnEarly(Random.nextLong().toString(16)) + getDeviceIdMethod.returnEarly(Random.nextLong().toString(16)) } }