From 78a43b8abd972172eab99519dfa636ce77d9e64f Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Thu, 22 Dec 2022 00:38:16 +0100 Subject: [PATCH] feat(tasker): `unlock-license` patch (#1339) --- .../annotations/UnlockLicenseCompatibility.kt | 9 ++++ .../fingerprints/CheckLicenseFingerprint.kt | 14 ++++++ .../unlock/patch/UnlockLicensePatch.kt | 46 +++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/tasker/license/unlock/annotations/UnlockLicenseCompatibility.kt create mode 100644 src/main/kotlin/app/revanced/patches/tasker/license/unlock/fingerprints/CheckLicenseFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/tasker/license/unlock/patch/UnlockLicensePatch.kt diff --git a/src/main/kotlin/app/revanced/patches/tasker/license/unlock/annotations/UnlockLicenseCompatibility.kt b/src/main/kotlin/app/revanced/patches/tasker/license/unlock/annotations/UnlockLicenseCompatibility.kt new file mode 100644 index 00000000..fd7439cb --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tasker/license/unlock/annotations/UnlockLicenseCompatibility.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.tasker.license.unlock.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility([Package("net.dinglisch.android.taskerm")]) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class UnlockLicenseCompatibility diff --git a/src/main/kotlin/app/revanced/patches/tasker/license/unlock/fingerprints/CheckLicenseFingerprint.kt b/src/main/kotlin/app/revanced/patches/tasker/license/unlock/fingerprints/CheckLicenseFingerprint.kt new file mode 100644 index 00000000..566a8389 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tasker/license/unlock/fingerprints/CheckLicenseFingerprint.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.tasker.license.unlock.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object CheckLicenseFingerprint : MethodFingerprint( + strings = listOf("just(IsLicensedResult(true))"), + opcodes = listOf( + Opcode.GOTO, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.INVOKE_VIRTUAL + ) +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tasker/license/unlock/patch/UnlockLicensePatch.kt b/src/main/kotlin/app/revanced/patches/tasker/license/unlock/patch/UnlockLicensePatch.kt new file mode 100644 index 00000000..458a4cc0 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tasker/license/unlock/patch/UnlockLicensePatch.kt @@ -0,0 +1,46 @@ +package app.revanced.patches.tasker.license.unlock.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.instruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.tasker.license.unlock.annotations.UnlockLicenseCompatibility +import app.revanced.patches.tasker.license.unlock.fingerprints.CheckLicenseFingerprint +import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction +import org.jf.dexlib2.iface.instruction.ReferenceInstruction +import org.jf.dexlib2.iface.reference.MethodReference +import org.jf.dexlib2.immutable.instruction.ImmutableInstruction35c + +@Patch +@Name("unlock-license") +@Description("Unlocks the trial version.") +@UnlockLicenseCompatibility +@Version("0.0.1") +class UnlockLicensePatch : BytecodePatch( + listOf( + CheckLicenseFingerprint + ) +) { + override fun execute(context: BytecodeContext) = CheckLicenseFingerprint.result?.let { result -> + val patchIndex = result.scanResult.patternScanResult!!.endIndex + + with(result.mutableMethod.instruction(patchIndex) as FiveRegisterInstruction) { + ImmutableInstruction35c( + opcode, + registerCount, + registerC, + 0, // registerE is 1, registerD is now 0 instead of 1 bypassing the license verification + registerE, + registerF, + registerG, + (this as ReferenceInstruction).reference as MethodReference + ) + } + PatchResultSuccess() + } ?: CheckLicenseFingerprint.toErrorResult() +} \ No newline at end of file