From 9789ad30ff82d9bb99e870dc8053775dc222a010 Mon Sep 17 00:00:00 2001 From: nik2143 <44278678+nik2143@users.noreply.github.com> Date: Fri, 26 May 2023 19:24:19 +0200 Subject: [PATCH] feat(nfctoolsse): add `unlock-pro` patch (#2272) Co-authored-by: oSumAtrIX --- .../pro/annotations/UnlockProCompatibility.kt | 8 ++++ .../IsLicenseRegisteredFingerprint.kt | 10 +++++ .../misc/pro/patch/UnlockProPatch.kt | 41 +++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/annotations/UnlockProCompatibility.kt create mode 100644 src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/fingerprints/IsLicenseRegisteredFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/patch/UnlockProPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/annotations/UnlockProCompatibility.kt b/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/annotations/UnlockProCompatibility.kt new file mode 100644 index 000000000..0fdf6ac06 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/annotations/UnlockProCompatibility.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.nfctoolsse.misc.pro.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility([Package("com.wakdev.apps.nfctools.se")]) +@Target(AnnotationTarget.CLASS) +internal annotation class UnlockProCompatibility diff --git a/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/fingerprints/IsLicenseRegisteredFingerprint.kt b/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/fingerprints/IsLicenseRegisteredFingerprint.kt new file mode 100644 index 000000000..fd6089e39 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/fingerprints/IsLicenseRegisteredFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.nfctoolsse.misc.pro.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags + +object IsLicenseRegisteredFingerprint : MethodFingerprint( + returnType = "Z", + accessFlags = AccessFlags.PUBLIC.value, + strings = listOf("kLicenseCheck") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/patch/UnlockProPatch.kt new file mode 100644 index 000000000..d49d19d67 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/patch/UnlockProPatch.kt @@ -0,0 +1,41 @@ +package app.revanced.patches.nfctoolsse.misc.pro.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.Patch +import app.revanced.patches.nfctoolsse.misc.pro.annotations.UnlockProCompatibility +import app.revanced.patches.nfctoolsse.misc.pro.fingerprints.IsLicenseRegisteredFingerprint + + +@Patch +@Name("unlock-pro") +@Description("Unlocks all pro features.") +@Version("0.0.1") +@UnlockProCompatibility +class UnlockProPatch : BytecodePatch( + listOf( + IsLicenseRegisteredFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + IsLicenseRegisteredFingerprint.result?.mutableMethod?.apply { + addInstructions( + 0, + """ + const/4 v0, 0x1 + return v0 + """ + ) + } ?: return IsLicenseRegisteredFingerprint.toErrorResult() + + return PatchResultSuccess() + } + +} \ No newline at end of file