Add Sig data class, SigScanner class and Patcher class

SigScanner and Patcher are WIP.
Patcher contains test/debug code.
This commit is contained in:
Lucaskyy 2022-03-16 22:58:55 +01:00
parent 7925496e28
commit 6a3e913a3c
No known key found for this signature in database
GPG key ID: 1530BFF96D1EEB89
3 changed files with 61 additions and 1 deletions

View file

@ -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())
}
}
}

View 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
}
}

View file

@ -0,0 +1,9 @@
package net.revanced.patcher.sigscan
import org.jf.dexlib2.iface.ClassDef
class SigScanner (sig: Sig) {
fun scan(classes: Array<ClassDef>) {
}
}