इस तुलना का शेष भाग लोड हो रहा है।

ReVanced removing licenses and copyright notices

बनाया गया Diff कभी समाप्त नहीं होता
47 हटाए गए
535 लाइनें
45 जोड़े गए
537 लाइनें
/*
* Copyright 2025 Morphe.
* https://github.com/MorpheApp/morphe-patches
*
* File-Specific License Notice (GPLv3 Section 7 Terms)
*
* This file is part of the Morphe patches project and is licensed under
* the GNU General Public License version 3 (GPLv3), with the Additional
* Terms under Section 7 described in the Morphe patches
* LICENSE file: https://github.com/MorpheApp/morphe-patches/blob/main/NOTICE
*
* https://www.gnu.org/licenses/gpl-3.0.html
*
* File-Specific Exception to Section 7b:
* -------------------------------------
* Section 7b (Attribution Requirement) of the Morphe patches LICENSE
* does not apply to THIS FILE. Use of this file does NOT require any
* user-facing, in-application, or UI-visible attribution.
*
* For this file only, attribution under Section 7b is satisfied by
* retaining this comment block in the source code of this file.
*
* Distribution and Derivative Works:
* ----------------------------------
* This comment block MUST be preserved in all copies, distributions,
* and derivative works of this file, whether in source or modified
* form.
*
* All other terms of the Morphe Patches LICENSE, including Section 7c
* (Project Name Restriction) and the GPLv3 itself, remain fully
* applicable to this file.
*/

package app.morphe.util
package app.revanced.util


import app.morphe.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.getInstruction
import app.morphe.patcher.extensions.InstructionExtensions.instructions
import app.revanced.patcher.extensions.instructions
import app.morphe.util.FreeRegisterProvider.Companion.conditionalBranchOpcodes
import app.revanced.util.FreeRegisterProvider.Companion.conditionalBranchOpcodes
import app.morphe.util.FreeRegisterProvider.Companion.logFreeRegisterSearch
import app.revanced.util.FreeRegisterProvider.Companion.logFreeRegisterSearch
import app.morphe.util.FreeRegisterProvider.Companion.returnOpcodes
import app.revanced.util.FreeRegisterProvider.Companion.returnOpcodes
import app.morphe.util.FreeRegisterProvider.Companion.switchOpcodes
import app.revanced.util.FreeRegisterProvider.Companion.switchOpcodes
import app.morphe.util.FreeRegisterProvider.Companion.unconditionalBranchOpcodes
import app.revanced.util.FreeRegisterProvider.Companion.unconditionalBranchOpcodes
import app.morphe.util.FreeRegisterProvider.Companion.writeOpcodes
import app.revanced.util.FreeRegisterProvider.Companion.writeOpcodes
import com.android.tools.smali.dexlib2.Format
import com.android.tools.smali.dexlib2.Format
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.Opcode.*
import com.android.tools.smali.dexlib2.Opcode.*
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
import com.android.tools.smali.dexlib2.iface.instruction.OffsetInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OffsetInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.RegisterRangeInstruction
import com.android.tools.smali.dexlib2.iface.instruction.RegisterRangeInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ThreeRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ThreeRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import java.util.EnumSet
import java.util.EnumSet
import java.util.LinkedList
import java.util.LinkedList


/**
/**
* Finds free registers at a specific index in a method.
* Finds free registers at a specific index in a method.
* Allows allocating multiple free registers for a given index.
* Allows allocating multiple free registers for a given index.
*
*
* If you only need a single free register, instead use [findFreeRegister].
* If you only need a single free register, instead use [findFreeRegister].
*
*
* @param index Index you need a use a free register at.
* @param index Index you need a use a free register at.
* @param numberOfFreeRegistersNeeded The maximum number of free registers you may get using
* @param numberOfFreeRegistersNeeded The maximum number of free registers you may get using
* [FreeRegisterProvider.getFreeRegister].
* [FreeRegisterProvider.getFreeRegister].
* @param registersToExclude Registers to exclude, and consider as used. For most use cases,
* @param registersToExclude Registers to exclude, and consider as used. For most use cases,
* all registers used in injected code should be specified.
* all registers used in injected code should be specified.
*
*
* @throws IllegalArgumentException If no free registers can be found at the given index.
* @throws IllegalArgumentException If no free registers can be found at the given index.
* This includes unusual method indexes that read from every register
* This includes unusual method indexes that read from every register
* before any registers are wrote to, or if a switch statement is
* before any registers are wrote to, or if a switch statement is
* encountered before any free registers are found.
* encountered before any free registers are found.
*/
*/
fun Method.getFreeRegisterProvider(index: Int, numberOfFreeRegistersNeeded: Int, registersToExclude: List<Int>) =
fun Method.getFreeRegisterProvider(index: Int, numberOfFreeRegistersNeeded: Int, registersToExclude: List<Int>) =
FreeRegisterProvider(this, index, numberOfFreeRegistersNeeded, registersToExclude)
FreeRegisterProvider(this, index, numberOfFreeRegistersNeeded, registersToExclude)


/**
/**
* Finds free registers at a specific index in a method.
* Finds free registers at a specific index in a method.
* Allows allocating multiple free registers for a given index.
* Allows allocating multiple free registers for a given index.
*
*
* If you only need a single free register, instead use [findFreeRegister].
* If you only need a single free register, instead use [findFreeRegister].
*
*
* @param index Index you need a use a free register at.
* @param index Index you need a use a free register at.
* @param numberOfFreeRegistersNeeded The minimum free registers to find.
* @param numberOfFreeRegistersNeeded The minimum free registers to find.
* @param registersToExclude Registers to exclude, and consider as used. For most use cases,
* @param registersToExclude Registers to exclude, and consider as used. For most use cases,
* all registers used in injected code should be specified.
* all registers used in injected code should be specified.
*
*
* @throws IllegalArgumentException If no free registers can be found at the given index.
* @throws IllegalArgumentException If no free registers can be found at the given index.
* This includes unusual method indexes that read from every register
* This includes unusual method indexes that read from every register
* before any registers are wrote to, or if a switch statement is
* before any registers are wrote to, or if a switch statement is
* encountered before any free registers are found.
* encountered before any free registers are found.
*/
*/
fun Method.getFreeRegisterProvider(index: Int, numberOfFreeRegistersNeeded: Int, vararg registersToExclude: Int) =
fun Method.getFreeRegisterProvider(index: Int, numberOfFreeRegistersNeeded: Int, vararg registersToExclude: Int) =
FreeRegisterProvider(this, index, numberOfFreeRegistersNeeded, *registersToExclude)
FreeRegisterProvider(this, index, numberOfFreeRegistersNeeded, *registersToExclude)


class FreeRegisterProvider internal constructor(
class FreeRegisterProvider internal constructor(
val method: Method,
val method: Method,
index: Int,
index: Int,
numberOfFreeRegistersNeeded: Int,
numberOfFreeRegistersNeeded: Int,