You've already forked revanced-patcher
mirror of
https://github.com/revanced/revanced-patcher
synced 2025-09-10 05:30:49 +02:00
Compare commits
21 Commits
v7.1.0-dev
...
v10.0.0-de
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b7eb2d2249 | ||
![]() |
b6d6a7591b | ||
![]() |
8f1c835299 | ||
![]() |
a188c16a99 | ||
![]() |
3e6804f06c | ||
![]() |
526a3d7c35 | ||
![]() |
28fc6a2ddd | ||
![]() |
d4f08d7bff | ||
![]() |
ca9fe322eb | ||
![]() |
239ea0bcaa | ||
![]() |
7f02b8df48 | ||
![]() |
a2052202b2 | ||
![]() |
223cea7021 | ||
![]() |
ac9337f694 | ||
![]() |
549651d04a | ||
![]() |
966bbd902e | ||
![]() |
81e6f8784e | ||
![]() |
9c53877888 | ||
![]() |
98f8eedecd | ||
![]() |
4ed429d25c | ||
![]() |
119d05f469 |
72
CHANGELOG.md
72
CHANGELOG.md
@@ -1,3 +1,75 @@
|
|||||||
|
# [10.0.0-dev.1](https://github.com/revanced/revanced-patcher/compare/v9.0.0...v10.0.0-dev.1) (2023-06-07)
|
||||||
|
|
||||||
|
|
||||||
|
* fix!: check for two methods parameters orders (#183) ([b6d6a75](https://github.com/revanced/revanced-patcher/commit/b6d6a7591ba1c0b48ffdef52352709564da8d9be)), closes [#183](https://github.com/revanced/revanced-patcher/issues/183)
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This requires changes to `MethodFingerprint`
|
||||||
|
|
||||||
|
# [9.0.0](https://github.com/revanced/revanced-patcher/compare/v8.0.0...v9.0.0) (2023-05-23)
|
||||||
|
|
||||||
|
|
||||||
|
* refactor!: rename parameter ([526a3d7](https://github.com/revanced/revanced-patcher/commit/526a3d7c359e2d95d26756da0f88d5ce975f5d9b))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This changes named parameters.
|
||||||
|
|
||||||
|
# [9.0.0-dev.1](https://github.com/revanced/revanced-patcher/compare/v8.0.0...v9.0.0-dev.1) (2023-05-23)
|
||||||
|
|
||||||
|
|
||||||
|
* refactor!: rename parameter ([526a3d7](https://github.com/revanced/revanced-patcher/commit/526a3d7c359e2d95d26756da0f88d5ce975f5d9b))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This changes named parameters.
|
||||||
|
|
||||||
|
# [8.0.0](https://github.com/revanced/revanced-patcher/compare/v7.1.1...v8.0.0) (2023-05-13)
|
||||||
|
|
||||||
|
|
||||||
|
* feat!: add `classDef` parameter to `MethodFingerprint` (#175) ([a205220](https://github.com/revanced/revanced-patcher/commit/a2052202b23037150df6aadc47f6e91efcd481cf)), closes [#175](https://github.com/revanced/revanced-patcher/issues/175)
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This changes the signature of the `customFingerprint` function.
|
||||||
|
|
||||||
|
# [8.0.0-dev.1](https://github.com/revanced/revanced-patcher/compare/v7.1.1...v8.0.0-dev.1) (2023-05-10)
|
||||||
|
|
||||||
|
|
||||||
|
* feat!: add `classDef` parameter to `MethodFingerprint` (#175) ([a205220](https://github.com/revanced/revanced-patcher/commit/a2052202b23037150df6aadc47f6e91efcd481cf)), closes [#175](https://github.com/revanced/revanced-patcher/issues/175)
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This changes the signature of the `customFingerprint` function.
|
||||||
|
|
||||||
|
## [7.1.1](https://github.com/revanced/revanced-patcher/compare/v7.1.0...v7.1.1) (2023-05-07)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* remove `count` instead of `count + 1` instructions with `removeInstructions` ([#167](https://github.com/revanced/revanced-patcher/issues/167)) ([98f8eed](https://github.com/revanced/revanced-patcher/commit/98f8eedecd72b0afe6a0f099a3641a1cc6be2698))
|
||||||
|
|
||||||
|
## [7.1.1-dev.1](https://github.com/revanced/revanced-patcher/compare/v7.1.0...v7.1.1-dev.1) (2023-05-07)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* remove `count` instead of `count + 1` instructions with `removeInstructions` ([#167](https://github.com/revanced/revanced-patcher/issues/167)) ([98f8eed](https://github.com/revanced/revanced-patcher/commit/98f8eedecd72b0afe6a0f099a3641a1cc6be2698))
|
||||||
|
|
||||||
|
# [7.1.0](https://github.com/revanced/revanced-patcher/compare/v7.0.0...v7.1.0) (2023-05-05)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add appreciation message for new contributors ([d674362](https://github.com/revanced/revanced-patcher/commit/d67436271ddca9ccfe008272c1ca82c6123ae7ee))
|
||||||
|
* add overload to get instruction as type ([49c173d](https://github.com/revanced/revanced-patcher/commit/49c173dc14137ddd198a611e9882dc71300831ee))
|
||||||
|
|
||||||
# [7.1.0-dev.2](https://github.com/revanced/revanced-patcher/compare/v7.1.0-dev.1...v7.1.0-dev.2) (2023-05-05)
|
# [7.1.0-dev.2](https://github.com/revanced/revanced-patcher/compare/v7.1.0-dev.1...v7.1.0-dev.2) (2023-05-05)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,2 +1,3 @@
|
|||||||
# Patcher
|
# 💉 ReVanced Patcher
|
||||||
Patcher framework used in the ReVanced project.
|
|
||||||
|
ReVanced Patcher used to patch Android applications.
|
||||||
|
@@ -45,6 +45,10 @@ java {
|
|||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain(11)
|
||||||
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
repositories {
|
||||||
if (System.getenv("GITHUB_ACTOR") != null)
|
if (System.getenv("GITHUB_ACTOR") != null)
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
version = 7.1.0-dev.2
|
version = 10.0.0-dev.1
|
||||||
|
@@ -54,17 +54,6 @@ class BytecodeContext internal constructor(classes: MutableList<ClassDef>) : Con
|
|||||||
}
|
}
|
||||||
return proxy
|
return proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
|
||||||
inline fun <reified T> Iterable<T>.find(predicate: (T) -> Boolean): T? {
|
|
||||||
for (element in this) {
|
|
||||||
if (predicate(element)) {
|
|
||||||
return element
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -39,7 +39,7 @@ fun MutableMethodImplementation.replaceInstructions(index: Int, instructions: Li
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun MutableMethodImplementation.removeInstructions(index: Int, count: Int) {
|
fun MutableMethodImplementation.removeInstructions(index: Int, count: Int) {
|
||||||
for (i in count downTo 0) {
|
for (i in count - 1 downTo 0) {
|
||||||
this.removeInstruction(index + i)
|
this.removeInstruction(index + i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,17 +220,15 @@ private fun replaceOffset(
|
|||||||
*/
|
*/
|
||||||
internal fun Method.cloneMutable(registerCount: Int = 0) = clone(registerCount).toMutable()
|
internal fun Method.cloneMutable(registerCount: Int = 0) = clone(registerCount).toMutable()
|
||||||
|
|
||||||
// FIXME: also check the order of parameters as different order equals different method overload
|
|
||||||
internal fun parametersEqual(
|
internal fun parametersEqual(
|
||||||
parameters1: Iterable<CharSequence>, parameters2: Iterable<CharSequence>
|
parameters1: Iterable<CharSequence>, parameters2: Iterable<CharSequence>
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return parameters1.count() == parameters2.count() && parameters1.all { parameter ->
|
if (parameters1.count() != parameters2.count()) return false
|
||||||
parameters2.any {
|
val iterator1 = parameters1.iterator()
|
||||||
it.startsWith(
|
parameters2.forEach {
|
||||||
parameter
|
if (!it.startsWith(iterator1.next())) return false
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val nullOutputStream = object : OutputStream() {
|
internal val nullOutputStream = object : OutputStream() {
|
||||||
|
@@ -15,10 +15,13 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
|||||||
import org.jf.dexlib2.iface.reference.StringReference
|
import org.jf.dexlib2.iface.reference.StringReference
|
||||||
import org.jf.dexlib2.util.MethodUtil
|
import org.jf.dexlib2.util.MethodUtil
|
||||||
|
|
||||||
|
private typealias StringMatch = MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult.StringMatch
|
||||||
|
private typealias StringsScanResult = MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the [MethodFingerprint] for a method.
|
* Represents the [MethodFingerprint] for a method.
|
||||||
* @param returnType The return type of the method.
|
* @param returnType The return type of the method.
|
||||||
* @param access The access flags of the method.
|
* @param accessFlags The access flags of the method.
|
||||||
* @param parameters The parameters of the method.
|
* @param parameters The parameters of the method.
|
||||||
* @param opcodes The list of opcodes of the method.
|
* @param opcodes The list of opcodes of the method.
|
||||||
* @param strings A list of strings which a method contains.
|
* @param strings A list of strings which a method contains.
|
||||||
@@ -27,14 +30,14 @@ import org.jf.dexlib2.util.MethodUtil
|
|||||||
*/
|
*/
|
||||||
abstract class MethodFingerprint(
|
abstract class MethodFingerprint(
|
||||||
internal val returnType: String? = null,
|
internal val returnType: String? = null,
|
||||||
internal val access: Int? = null,
|
internal val accessFlags: Int? = null,
|
||||||
internal val parameters: Iterable<String>? = null,
|
internal val parameters: Iterable<String>? = null,
|
||||||
internal val opcodes: Iterable<Opcode?>? = null,
|
internal val opcodes: Iterable<Opcode?>? = null,
|
||||||
internal val strings: Iterable<String>? = null,
|
internal val strings: Iterable<String>? = null,
|
||||||
internal val customFingerprint: ((methodDef: Method) -> Boolean)? = null
|
internal val customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null
|
||||||
) : Fingerprint {
|
) : Fingerprint {
|
||||||
/**
|
/**
|
||||||
* The result of the [MethodFingerprint] the [Method].
|
* The result of the [MethodFingerprint].
|
||||||
*/
|
*/
|
||||||
var result: MethodFingerprintResult? = null
|
var result: MethodFingerprintResult? = null
|
||||||
|
|
||||||
@@ -83,7 +86,7 @@ abstract class MethodFingerprint(
|
|||||||
if (methodFingerprint.returnType != null && !method.returnType.startsWith(methodFingerprint.returnType))
|
if (methodFingerprint.returnType != null && !method.returnType.startsWith(methodFingerprint.returnType))
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if (methodFingerprint.access != null && methodFingerprint.access != method.accessFlags)
|
if (methodFingerprint.accessFlags != null && methodFingerprint.accessFlags != method.accessFlags)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
||||||
@@ -94,7 +97,7 @@ abstract class MethodFingerprint(
|
|||||||
) return false
|
) return false
|
||||||
|
|
||||||
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
|
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
|
||||||
if (methodFingerprint.customFingerprint != null && !methodFingerprint.customFingerprint!!(method))
|
if (methodFingerprint.customFingerprint != null && !methodFingerprint.customFingerprint!!(method, forClass))
|
||||||
return false
|
return false
|
||||||
|
|
||||||
val stringsScanResult: StringsScanResult? =
|
val stringsScanResult: StringsScanResult? =
|
||||||
@@ -216,9 +219,6 @@ abstract class MethodFingerprint(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private typealias StringMatch = MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult.StringMatch
|
|
||||||
private typealias StringsScanResult = MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the result of a [MethodFingerprintResult].
|
* Represents the result of a [MethodFingerprintResult].
|
||||||
*
|
*
|
||||||
@@ -233,6 +233,26 @@ data class MethodFingerprintResult(
|
|||||||
val scanResult: MethodFingerprintScanResult,
|
val scanResult: MethodFingerprintScanResult,
|
||||||
internal val context: BytecodeContext
|
internal val context: BytecodeContext
|
||||||
) {
|
) {
|
||||||
|
/**
|
||||||
|
* Returns a mutable clone of [classDef]
|
||||||
|
*
|
||||||
|
* Please note, this method allocates a [ClassProxy].
|
||||||
|
* Use [classDef] where possible.
|
||||||
|
*/
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
val mutableClass by lazy { context.proxy(classDef).mutableClass }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a mutable clone of [method]
|
||||||
|
*
|
||||||
|
* Please note, this method allocates a [ClassProxy].
|
||||||
|
* Use [method] where possible.
|
||||||
|
*/
|
||||||
|
val mutableMethod by lazy {
|
||||||
|
mutableClass.methods.first {
|
||||||
|
MethodUtil.methodSignaturesMatch(it, this.method)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The result of scanning on the [MethodFingerprint].
|
* The result of scanning on the [MethodFingerprint].
|
||||||
@@ -282,25 +302,4 @@ data class MethodFingerprintResult(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a mutable clone of [classDef]
|
|
||||||
*
|
|
||||||
* Please note, this method allocates a [ClassProxy].
|
|
||||||
* Use [classDef] where possible.
|
|
||||||
*/
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
|
||||||
val mutableClass by lazy { context.proxy(classDef).mutableClass }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a mutable clone of [method]
|
|
||||||
*
|
|
||||||
* Please note, this method allocates a [ClassProxy].
|
|
||||||
* Use [method] where possible.
|
|
||||||
*/
|
|
||||||
val mutableMethod by lazy {
|
|
||||||
mutableClass.methods.first {
|
|
||||||
MethodUtil.methodSignaturesMatch(it, this.method)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -41,18 +41,13 @@ sealed class PatchBundle(path: String) : File(path) {
|
|||||||
arrayOf(this.toURI().toURL()),
|
arrayOf(this.toURI().toURL()),
|
||||||
Thread.currentThread().contextClassLoader // TODO: find out why this is required
|
Thread.currentThread().contextClassLoader // TODO: find out why this is required
|
||||||
),
|
),
|
||||||
StringIterator(
|
JarFile(this)
|
||||||
JarFile(this)
|
.stream()
|
||||||
.entries()
|
.filter {it.name.endsWith(".class") && !it.name.contains("$")}
|
||||||
.toList() // TODO: find a cleaner solution than that to filter non class files
|
.map({it -> it.realName.replace('/', '.').replace(".class", "")}).iterator()
|
||||||
.filter {
|
)
|
||||||
it.name.endsWith(".class") && !it.name.contains("$")
|
|
||||||
}
|
|
||||||
.iterator()
|
|
||||||
) {
|
|
||||||
it.realName.replace('/', '.').replace(".class", "")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,8 +63,8 @@ sealed class PatchBundle(path: String) : File(path) {
|
|||||||
* Patches will be loaded to the provided [dexClassLoader].
|
* Patches will be loaded to the provided [dexClassLoader].
|
||||||
*/
|
*/
|
||||||
fun loadPatches() = loadPatches(dexClassLoader,
|
fun loadPatches() = loadPatches(dexClassLoader,
|
||||||
StringIterator(DexFileFactory.loadDexFile(path, null).classes.iterator()) { classDef ->
|
DexFileFactory.loadDexFile(path, null).classes.asSequence().map({ classDef ->
|
||||||
classDef.type.substring(1, classDef.length - 1).replace('/', '.')
|
classDef.type.substring(1, classDef.length - 1).replace('/', '.')
|
||||||
})
|
}).iterator())
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,10 +0,0 @@
|
|||||||
package app.revanced.patcher.util.patch
|
|
||||||
|
|
||||||
internal class StringIterator<T, I : Iterator<T>>(
|
|
||||||
private val iterator: I,
|
|
||||||
private val _next: (T) -> String
|
|
||||||
) : Iterator<String> {
|
|
||||||
override fun hasNext() = iterator.hasNext()
|
|
||||||
|
|
||||||
override fun next() = _next(iterator.next())
|
|
||||||
}
|
|
Reference in New Issue
Block a user