You've already forked revanced-patcher
mirror of
https://github.com/revanced/revanced-patcher
synced 2025-09-17 07:30:49 +02:00
Compare commits
6 Commits
v1.0.0-dev
...
v1.0.0-dev
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fa0412985c | ||
![]() |
0048788dd0 | ||
![]() |
47eb493f54 | ||
![]() |
6b1337e4fc | ||
![]() |
f4589db3a9 | ||
![]() |
1af31b2aa3 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,3 +1,17 @@
|
|||||||
|
# [1.0.0-dev.8](https://github.com/ReVancedTeam/revanced-patcher/compare/v1.0.0-dev.7...v1.0.0-dev.8) (2022-03-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* check type instead of class ([47eb493](https://github.com/ReVancedTeam/revanced-patcher/commit/47eb493f5425dc27a4d6e79e6b02a36ef760e8da))
|
||||||
|
|
||||||
|
# [1.0.0-dev.7](https://github.com/ReVancedTeam/revanced-patcher/compare/v1.0.0-dev.6...v1.0.0-dev.7) (2022-03-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **MethodResolver:** fix cd57a8c9a0db7e3ae5ad0bca202e5955930319ab ([1af31b2](https://github.com/ReVancedTeam/revanced-patcher/commit/1af31b2aa3772a7473c04d27bf835c8eae13438d))
|
||||||
|
|
||||||
# [1.0.0-dev.6](https://github.com/ReVancedTeam/revanced-patcher/compare/v1.0.0-dev.5...v1.0.0-dev.6) (2022-03-24)
|
# [1.0.0-dev.6](https://github.com/ReVancedTeam/revanced-patcher/compare/v1.0.0-dev.5...v1.0.0-dev.6) (2022-03-24)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
version = 1.0.0-dev.6
|
version = 1.0.0-dev.8
|
||||||
|
@@ -1,15 +1,13 @@
|
|||||||
package app.revanced.patcher.resolver
|
package app.revanced.patcher.resolver
|
||||||
|
|
||||||
import mu.KotlinLogging
|
|
||||||
import app.revanced.patcher.cache.MethodMap
|
import app.revanced.patcher.cache.MethodMap
|
||||||
import app.revanced.patcher.cache.PatchData
|
import app.revanced.patcher.cache.PatchData
|
||||||
import app.revanced.patcher.cache.PatternScanData
|
import app.revanced.patcher.cache.PatternScanData
|
||||||
import app.revanced.patcher.signature.Signature
|
import app.revanced.patcher.signature.Signature
|
||||||
import app.revanced.patcher.util.ExtraTypes
|
import app.revanced.patcher.util.ExtraTypes
|
||||||
|
import mu.KotlinLogging
|
||||||
import org.objectweb.asm.Type
|
import org.objectweb.asm.Type
|
||||||
import org.objectweb.asm.tree.*
|
import org.objectweb.asm.tree.*
|
||||||
import kotlin.reflect.KType
|
|
||||||
import kotlin.reflect.typeOf
|
|
||||||
|
|
||||||
private val logger = KotlinLogging.logger("MethodResolver")
|
private val logger = KotlinLogging.logger("MethodResolver")
|
||||||
|
|
||||||
@@ -131,13 +129,7 @@ private fun InsnList.scanFor(pattern: IntArray): ScanResult {
|
|||||||
var occurrence = 0
|
var occurrence = 0
|
||||||
while (i + occurrence < this.size()) {
|
while (i + occurrence < this.size()) {
|
||||||
val n = this[i + occurrence]
|
val n = this[i + occurrence]
|
||||||
if (
|
if (!n.shouldSkip() && n.opcode != pattern[occurrence]) break
|
||||||
!n.anyOf(
|
|
||||||
typeOf<LabelNode>(),
|
|
||||||
typeOf<LineNumberNode>()
|
|
||||||
) &&
|
|
||||||
n.opcode != pattern[occurrence]
|
|
||||||
) break
|
|
||||||
if (++occurrence >= pattern.size) {
|
if (++occurrence >= pattern.size) {
|
||||||
val current = i + occurrence
|
val current = i + occurrence
|
||||||
return ScanResult(true, current - pattern.size, current)
|
return ScanResult(true, current - pattern.size, current)
|
||||||
@@ -160,6 +152,5 @@ private fun Array<Type>.convertObjects(): Array<Type> {
|
|||||||
return this.map { it.convertObject() }.toTypedArray()
|
return this.map { it.convertObject() }.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun AbstractInsnNode.anyOf(vararg types: KType): Boolean {
|
private fun AbstractInsnNode.shouldSkip() =
|
||||||
return types.any { it.javaClass.isAssignableFrom(this.javaClass) }
|
type == AbstractInsnNode.LABEL || type == AbstractInsnNode.LINE
|
||||||
}
|
|
||||||
|
@@ -39,8 +39,10 @@ internal class PatcherTest {
|
|||||||
ACC_PUBLIC or ACC_STATIC,
|
ACC_PUBLIC or ACC_STATIC,
|
||||||
arrayOf(ExtraTypes.ArrayAny),
|
arrayOf(ExtraTypes.ArrayAny),
|
||||||
intArrayOf(
|
intArrayOf(
|
||||||
|
GETSTATIC,
|
||||||
LDC,
|
LDC,
|
||||||
INVOKEVIRTUAL
|
INVOKEVIRTUAL,
|
||||||
|
RETURN
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -66,7 +68,19 @@ internal class PatcherTest {
|
|||||||
// Get the start index of our opcode pattern.
|
// Get the start index of our opcode pattern.
|
||||||
// This will be the index of the LDC instruction.
|
// This will be the index of the LDC instruction.
|
||||||
val startIndex = mainMethod.scanData.startIndex
|
val startIndex = mainMethod.scanData.startIndex
|
||||||
TestUtil.assertNodeEqual(LdcInsnNode("Hello, world!"), instructions[startIndex]!!)
|
|
||||||
|
// Ignore this, just testing if the method resolver works :)
|
||||||
|
TestUtil.assertNodeEqual(
|
||||||
|
FieldInsnNode(
|
||||||
|
GETSTATIC,
|
||||||
|
Type.getInternalName(System::class.java),
|
||||||
|
"out",
|
||||||
|
// for whatever reason, it adds an "L" and ";" to the node string
|
||||||
|
"L${Type.getInternalName(PrintStream::class.java)};"
|
||||||
|
),
|
||||||
|
instructions[startIndex]!!
|
||||||
|
)
|
||||||
|
|
||||||
// Create a new LDC node and replace the LDC instruction.
|
// Create a new LDC node and replace the LDC instruction.
|
||||||
val stringNode = LdcInsnNode("Hello, ReVanced! Editing bytecode.")
|
val stringNode = LdcInsnNode("Hello, ReVanced! Editing bytecode.")
|
||||||
instructions.setAt(startIndex, stringNode)
|
instructions.setAt(startIndex, stringNode)
|
||||||
@@ -82,7 +96,7 @@ internal class PatcherTest {
|
|||||||
GETSTATIC,
|
GETSTATIC,
|
||||||
Type.getInternalName(System::class.java), // "java/lang/System"
|
Type.getInternalName(System::class.java), // "java/lang/System"
|
||||||
"out",
|
"out",
|
||||||
"L" + Type.getInternalName(PrintStream::class.java) // "Ljava/io/PrintStream"
|
Type.getInternalName(PrintStream::class.java) // "java/io/PrintStream"
|
||||||
),
|
),
|
||||||
LdcInsnNode("Hello, ReVanced! Adding bytecode."),
|
LdcInsnNode("Hello, ReVanced! Adding bytecode."),
|
||||||
MethodInsnNode(
|
MethodInsnNode(
|
||||||
@@ -143,7 +157,9 @@ internal class PatcherTest {
|
|||||||
fun `should not raise an exception if any signature member except the name is missing`() {
|
fun `should not raise an exception if any signature member except the name is missing`() {
|
||||||
val sigName = "testMethod"
|
val sigName = "testMethod"
|
||||||
|
|
||||||
assertDoesNotThrow("Should raise an exception because opcodes is empty") {
|
assertDoesNotThrow(
|
||||||
|
"Should not raise an exception if any signature member except the name is missing"
|
||||||
|
) {
|
||||||
Patcher(
|
Patcher(
|
||||||
PatcherTest::class.java.getResourceAsStream("/test1.jar")!!,
|
PatcherTest::class.java.getResourceAsStream("/test1.jar")!!,
|
||||||
ByteArrayOutputStream(),
|
ByteArrayOutputStream(),
|
||||||
|
Reference in New Issue
Block a user