Add logging to the AST deobfuscator

Signed-off-by: Desetude <harry@desetude.com>
Desetude 5 years ago committed by Graham
parent 9c10df5e2c
commit c99ebcb355
  1. 6
      deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt

@ -9,6 +9,7 @@ import com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSol
import com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver import com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver
import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver
import com.github.javaparser.utils.SourceRoot import com.github.javaparser.utils.SourceRoot
import com.github.michaelbull.logging.InlineLogger
import dev.openrs2.deob.ast.transform.AddSubTransformer import dev.openrs2.deob.ast.transform.AddSubTransformer
import dev.openrs2.deob.ast.transform.BinaryExprOrderTransformer import dev.openrs2.deob.ast.transform.BinaryExprOrderTransformer
import dev.openrs2.deob.ast.transform.BitMaskTransformer import dev.openrs2.deob.ast.transform.BitMaskTransformer
@ -50,6 +51,7 @@ class AstDeobfuscator(private val modules: List<Path>) {
val units = mutableMapOf<String, CompilationUnit>() val units = mutableMapOf<String, CompilationUnit>()
for (root in roots) { for (root in roots) {
logger.info { "Parsing root ${root.root}" }
val results = root.tryToParseParallelized() val results = root.tryToParseParallelized()
for (result in results) { for (result in results) {
require(result.isSuccessful) { result } require(result.isSuccessful) { result }
@ -62,16 +64,20 @@ class AstDeobfuscator(private val modules: List<Path>) {
} }
for (transformer in TRANSFORMERS) { for (transformer in TRANSFORMERS) {
logger.info { "Running transformer ${transformer.javaClass.simpleName}" }
transformer.transform(units) transformer.transform(units)
} }
for (root in roots) { for (root in roots) {
logger.info { "Saving root ${root.root}" }
root.printer = Function<CompilationUnit, String>(printer::print).andThen(::stripNewlineAfterPcAnnotation) root.printer = Function<CompilationUnit, String>(printer::print).andThen(::stripNewlineAfterPcAnnotation)
root.saveAll() root.saveAll()
} }
} }
companion object { companion object {
private val logger = InlineLogger()
private val TRANSFORMERS = listOf( private val TRANSFORMERS = listOf(
UnencloseTransformer(), UnencloseTransformer(),
NegativeLiteralTransformer(), NegativeLiteralTransformer(),

Loading…
Cancel
Save