diff --git a/src/main/kotlin/app/revanced/patches/lightroom/misc/login/annotations/DisableMandatoryLoginCompatibility.kt b/src/main/kotlin/app/revanced/patches/lightroom/misc/login/annotations/DisableMandatoryLoginCompatibility.kt new file mode 100644 index 0000000000..edc9e68962 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/lightroom/misc/login/annotations/DisableMandatoryLoginCompatibility.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.lightroom.misc.login.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility([Package("com.adobe.lrmobile",)]) +@Target(AnnotationTarget.CLASS) +internal annotation class DisableMandatoryLoginCompatibility diff --git a/src/main/kotlin/app/revanced/patches/lightroom/misc/login/fingerprint/IsLoggedInFingerprint.kt b/src/main/kotlin/app/revanced/patches/lightroom/misc/login/fingerprint/IsLoggedInFingerprint.kt new file mode 100644 index 0000000000..2a57095a84 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/lightroom/misc/login/fingerprint/IsLoggedInFingerprint.kt @@ -0,0 +1,19 @@ +package app.revanced.patches.lightroom.misc.login.fingerprint + +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 IsLoggedInFingerprint : MethodFingerprint( + returnType = "Z", + accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC or AccessFlags.FINAL, + opcodes = listOf( + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, + Opcode.SGET_OBJECT, + Opcode.IF_NE, + Opcode.CONST_4, + Opcode.GOTO + ) +) diff --git a/src/main/kotlin/app/revanced/patches/lightroom/misc/login/patch/DisableMandatoryLoginPatch.kt b/src/main/kotlin/app/revanced/patches/lightroom/misc/login/patch/DisableMandatoryLoginPatch.kt new file mode 100644 index 0000000000..49d4f46a4f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/lightroom/misc/login/patch/DisableMandatoryLoginPatch.kt @@ -0,0 +1,27 @@ +package app.revanced.patches.lightroom.misc.login.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +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.lightroom.misc.login.annotations.DisableMandatoryLoginCompatibility +import app.revanced.patches.lightroom.misc.login.fingerprint.IsLoggedInFingerprint + +@Patch +@Name("Disable mandatory login") +@DisableMandatoryLoginCompatibility +class DisableMandatoryLoginPatch : BytecodePatch(listOf(IsLoggedInFingerprint)) { + override fun execute(context: BytecodeContext): PatchResult { + IsLoggedInFingerprint.result?.mutableMethod?.apply { + val index = implementation!!.instructions.lastIndex - 1 + // Set isLoggedIn = true. + replaceInstruction(index, "const/4 v0, 0x1") + } ?: throw IsLoggedInFingerprint.toErrorResult() + + return PatchResultSuccess() + } +} \ No newline at end of file