Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into fix/yt-shorts-pip
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Oct 26, 2024
2 parents 9a4e65f + f4d65fd commit 873fe81
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal val startActivityInitHook = extensionHook(
contextRegisterResolver = { method ->
val moveResultInstruction = method.implementation!!.instructions.elementAt(getApplicationContextIndex + 1)
as OneRegisterInstruction
moveResultInstruction.registerA
"v${moveResultInstruction.registerA}"
},
) {
opcodes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal val homeActivityInitHook = extensionHook(
contextRegisterResolver = { method ->
val moveResultInstruction = method.implementation!!.instructions.elementAt(getApplicationContextIndex + 1)
as OneRegisterInstruction
moveResultInstruction.registerA
"v${moveResultInstruction.registerA}"
},
) {
opcodes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.util.exception
import app.revanced.util.matchOrThrow
import com.android.tools.smali.dexlib2.iface.Method
import java.net.URLDecoder
import java.util.jar.JarFile
Expand Down Expand Up @@ -77,24 +77,24 @@ fun sharedExtensionPatch(
class ExtensionHook internal constructor(
val fingerprint: Fingerprint,
private val insertIndexResolver: ((Method) -> Int),
private val contextRegisterResolver: (Method) -> Int,
private val contextRegisterResolver: (Method) -> String,
) {
operator fun invoke(extensionClassDescriptor: String) {
fingerprint.match?.mutableMethod?.let { method ->
fingerprint.matchOrThrow.mutableMethod.let { method ->
val insertIndex = insertIndexResolver(method)
val contextRegister = contextRegisterResolver(method)

method.addInstruction(
insertIndex,
"invoke-static/range { v$contextRegister .. v$contextRegister }, " +
"invoke-static/range { $contextRegister .. $contextRegister }, " +
"$extensionClassDescriptor->setContext(Landroid/content/Context;)V",
)
} ?: throw fingerprint.exception
}
}
}

fun extensionHook(
insertIndexResolver: ((Method) -> Int) = { 0 },
contextRegisterResolver: (Method) -> Int = { it.implementation!!.registerCount - 1 },
contextRegisterResolver: (Method) -> String = { "p0" },
fingerprintBuilderBlock: FingerprintBuilder.() -> Unit,
) = ExtensionHook(fingerprint(block = fingerprintBuilderBlock), insertIndexResolver, contextRegisterResolver)

0 comments on commit 873fe81

Please sign in to comment.