mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2024-11-10 01:02:22 +01:00
Add Sig data class, SigScanner class and Patcher class
SigScanner and Patcher are WIP. Patcher contains test/debug code.
This commit is contained in:
parent
7925496e28
commit
6a3e913a3c
3 changed files with 61 additions and 1 deletions
|
@ -1,4 +1,25 @@
|
|||
package net.revanced.patcher
|
||||
|
||||
import net.revanced.patcher.sigscan.Sig
|
||||
import net.revanced.patcher.sigscan.SigScanner
|
||||
import org.jf.dexlib2.Opcode
|
||||
import java.io.File
|
||||
import java.lang.reflect.Modifier
|
||||
|
||||
class Patcher {
|
||||
}
|
||||
companion object {
|
||||
/**
|
||||
* Invokes the patcher on the given input file.
|
||||
*
|
||||
* @param input the input file
|
||||
* @param output the output file
|
||||
*/
|
||||
fun invoke(input: File, output: File) {
|
||||
SigScanner(Sig(
|
||||
arrayOf(Opcode.ADD_INT),
|
||||
Modifier.PUBLIC or Modifier.STATIC,
|
||||
String.Companion::class
|
||||
)).scan(emptyArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
30
src/main/kotlin/net/revanced/patcher/sigscan/Sig.kt
Normal file
30
src/main/kotlin/net/revanced/patcher/sigscan/Sig.kt
Normal file
|
@ -0,0 +1,30 @@
|
|||
package net.revanced.patcher.sigscan
|
||||
|
||||
import org.jf.dexlib2.Opcode
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
data class Sig(
|
||||
val opcodes: Array<Opcode>,
|
||||
val attributes: Int,
|
||||
val returnType: KClass<*>
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Sig
|
||||
|
||||
if (!opcodes.contentEquals(other.opcodes)) return false
|
||||
if (attributes != other.attributes) return false
|
||||
if (returnType != other.returnType) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = opcodes.contentHashCode()
|
||||
result = 31 * result + attributes.hashCode()
|
||||
result = 31 * result + returnType.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package net.revanced.patcher.sigscan
|
||||
|
||||
import org.jf.dexlib2.iface.ClassDef
|
||||
|
||||
class SigScanner (sig: Sig) {
|
||||
fun scan(classes: Array<ClassDef>) {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue