mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-04-30 13:24:26 +02:00
TIL CodeWithMe is ass!
This commit is contained in:
parent
fc41a84aa1
commit
7b40d53bd3
@ -15,6 +15,9 @@ dependencies {
|
|||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
|
|
||||||
implementation("org.ow2.asm:asm:9.2")
|
implementation("org.ow2.asm:asm:9.2")
|
||||||
|
implementation("org.ow2.asm:asm-util:9.2")
|
||||||
|
implementation("org.ow2.asm:asm-tree:9.2")
|
||||||
|
implementation("org.ow2.asm:asm-commons:9.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package net.revanced.patcher
|
package net.revanced.patcher
|
||||||
|
|
||||||
import net.revanced.patcher.patch.Patch
|
import net.revanced.patcher.patch.Patch
|
||||||
import net.revanced.patcher.patch.PatchResult
|
|
||||||
import net.revanced.patcher.signature.Signature
|
import net.revanced.patcher.signature.Signature
|
||||||
import net.revanced.patcher.store.PatchStore
|
import net.revanced.patcher.store.PatchStore
|
||||||
import net.revanced.patcher.store.SignatureStore
|
import net.revanced.patcher.store.SignatureStore
|
||||||
|
import org.objectweb.asm.Opcodes
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
|
||||||
class Patcher(
|
class Patcher(
|
||||||
@ -17,9 +17,12 @@ class Patcher(
|
|||||||
PatchStore.addPatches(*patches)
|
PatchStore.addPatches(*patches)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun patch() {
|
fun patch(): String? {
|
||||||
PatchStore.patches.forEach {
|
for (patch in PatchStore.patches) {
|
||||||
|
val result = patch.execute()
|
||||||
|
if (result.isSuccess()) continue
|
||||||
|
return result.error()!!.errorMessage()
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,9 @@
|
|||||||
package net.revanced.patcher.patch
|
package net.revanced.patcher.patch
|
||||||
|
|
||||||
|
|
||||||
class Patch(val fn: () -> PatchResult) {
|
class Patch(val fn: () -> PatchResult) {
|
||||||
fun execute(): PatchResult {
|
fun execute(): PatchResult {
|
||||||
return fn()
|
return fn()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,12 +7,21 @@ interface PatchResult {
|
|||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun success(): PatchResultSuccess? {
|
fun success(): PatchResultSuccess? {
|
||||||
if (this is PatchResultSuccess) {
|
if (this is PatchResultSuccess) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isError(): Boolean {
|
||||||
|
return this is PatchResultError
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isSuccess(): Boolean {
|
||||||
|
return this is PatchResultSuccess
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PatchResultError(private val errorMessage: String) : PatchResult {
|
class PatchResultError(private val errorMessage: String) : PatchResult {
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package net.revanced.patcher.store
|
||||||
|
|
||||||
|
object MethodStore {
|
||||||
|
val methods: Map<String, MethodNode> = mutableMapOf()
|
||||||
|
}
|
@ -1,16 +1,15 @@
|
|||||||
package net.revanced.patcher
|
package net.revanced.patcher
|
||||||
|
|
||||||
import net.revanced.patcher.patch.Patch
|
import net.revanced.patcher.patch.Patch
|
||||||
import net.revanced.patcher.patch.PatchResult
|
|
||||||
import net.revanced.patcher.patch.PatchResultError
|
import net.revanced.patcher.patch.PatchResultError
|
||||||
import net.revanced.patcher.patch.PatchResultSuccess
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions.*
|
|
||||||
|
|
||||||
internal class PatcherTest {
|
internal class PatcherTest {
|
||||||
@Test
|
@Test
|
||||||
fun template() {
|
fun template() {
|
||||||
|
val adRemoverPatch = Patch {
|
||||||
|
|
||||||
|
PatchResultError("")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user