mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2024-11-10 01:02:22 +01:00
Adding more features to the patcher (unfinished)
This commit is contained in:
parent
7b40d53bd3
commit
d297a3dbf6
10 changed files with 60 additions and 24 deletions
|
@ -1 +0,0 @@
|
|||
patcher
|
10
.idea/codeStyles/Project.xml
Normal file
10
.idea/codeStyles/Project.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
10
.idea/runConfigurations.xml
Normal file
10
.idea/runConfigurations.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -2,23 +2,32 @@ package net.revanced.patcher
|
|||
|
||||
import net.revanced.patcher.patch.Patch
|
||||
import net.revanced.patcher.signature.Signature
|
||||
import net.revanced.patcher.store.MethodStore
|
||||
import net.revanced.patcher.store.PatchStore
|
||||
import net.revanced.patcher.store.SignatureStore
|
||||
import org.objectweb.asm.Opcodes
|
||||
import java.io.InputStream
|
||||
import java.lang.IllegalStateException
|
||||
|
||||
class Patcher(
|
||||
private val input: InputStream,
|
||||
signatures: Array<Signature>,
|
||||
private val signatures: Array<Signature>,
|
||||
patches: Array<Patch>,
|
||||
) {
|
||||
private val patchStore = PatchStore()
|
||||
private val methodStore = MethodStore()
|
||||
|
||||
private val scanned = false
|
||||
|
||||
init {
|
||||
SignatureStore.addSignatures(*signatures)
|
||||
PatchStore.addPatches(*patches)
|
||||
patchStore.addPatches(*patches)
|
||||
}
|
||||
|
||||
fun scan() {
|
||||
// methodStore.methods = PatternScanner(signatures).resolve()
|
||||
}
|
||||
|
||||
fun patch(): String? {
|
||||
for (patch in PatchStore.patches) {
|
||||
if (!scanned) throw IllegalStateException("Pattern scanner not yet ran")
|
||||
for (patch in patchStore.patches) {
|
||||
val result = patch.execute()
|
||||
if (result.isSuccess()) continue
|
||||
return result.error()!!.errorMessage()
|
||||
|
|
10
src/main/kotlin/net/revanced/patcher/PatternScanner.kt
Normal file
10
src/main/kotlin/net/revanced/patcher/PatternScanner.kt
Normal file
|
@ -0,0 +1,10 @@
|
|||
package net.revanced.patcher
|
||||
|
||||
import net.revanced.patcher.signature.Signature
|
||||
|
||||
class PatternScanner(signatures: Array<Signature>) {
|
||||
fun resolve() {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package net.revanced.patcher.patch
|
||||
|
||||
class Patch(val fn: () -> PatchResult) {
|
||||
class Patch(val name: String, val fn: () -> PatchResult) {
|
||||
fun execute(): PatchResult {
|
||||
return fn()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package net.revanced.patcher.store
|
||||
|
||||
object MethodStore {
|
||||
val methods: Map<String, MethodNode> = mutableMapOf()
|
||||
import org.objectweb.asm.tree.MethodNode
|
||||
|
||||
class MethodStore {
|
||||
val methods: MutableMap<String, MethodNode> = mutableMapOf()
|
||||
}
|
|
@ -2,10 +2,12 @@ package net.revanced.patcher.store
|
|||
|
||||
import net.revanced.patcher.patch.Patch
|
||||
|
||||
object PatchStore {
|
||||
val patches: MutableList<Patch> = mutableListOf()
|
||||
class PatchStore {
|
||||
val patches: MutableMap<String, Patch> = mutableMapOf()
|
||||
|
||||
fun addPatches(vararg patches: Patch) {
|
||||
this.patches.addAll(patches)
|
||||
for (patch in patches) {
|
||||
this.patches[patch.name] = patch
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package net.revanced.patcher.store
|
||||
|
||||
import net.revanced.patcher.signature.Signature
|
||||
|
||||
object SignatureStore {
|
||||
private val signatures: MutableList<Signature> = mutableListOf()
|
||||
|
||||
fun addSignatures(vararg signatures: Signature) {
|
||||
this.signatures.addAll(signatures)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue