From 3978ee9ea03d0ac4548a8ad32528c5071d7d86a5 Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 3 Aug 2019 10:20:36 +0100 Subject: [PATCH] Allow Transformers to throw AnalyzerException --- .../main/java/dev/openrs2/asm/Transformer.java | 15 ++++++++------- .../java/dev/openrs2/deob/ClassNamePrefixer.java | 3 ++- .../main/java/dev/openrs2/deob/Deobfuscator.java | 5 +++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/asm/src/main/java/dev/openrs2/asm/Transformer.java b/asm/src/main/java/dev/openrs2/asm/Transformer.java index 18106c3f..82b89a85 100644 --- a/asm/src/main/java/dev/openrs2/asm/Transformer.java +++ b/asm/src/main/java/dev/openrs2/asm/Transformer.java @@ -4,9 +4,10 @@ import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.FieldNode; import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.analysis.AnalyzerException; public abstract class Transformer { - public final void transform(Library library) { + public void transform(Library library) throws AnalyzerException { preTransform(library); for (var clazz : library) { @@ -28,27 +29,27 @@ public abstract class Transformer { postTransform(library); } - public void preTransform(Library library) { + public void preTransform(Library library) throws AnalyzerException { /* empty */ } - public void transformClass(ClassNode clazz) { + public void transformClass(ClassNode clazz) throws AnalyzerException { /* empty */ } - public void transformField(ClassNode clazz, FieldNode field) { + public void transformField(ClassNode clazz, FieldNode field) throws AnalyzerException { /* empty */ } - public void transformMethod(ClassNode clazz, MethodNode method) { + public void transformMethod(ClassNode clazz, MethodNode method) throws AnalyzerException { /* empty */ } - public void transformCode(ClassNode clazz, MethodNode method) { + public void transformCode(ClassNode clazz, MethodNode method) throws AnalyzerException { /* empty */ } - public void postTransform(Library library) { + public void postTransform(Library library) throws AnalyzerException { /* empty */ } } diff --git a/deob/src/main/java/dev/openrs2/deob/ClassNamePrefixer.java b/deob/src/main/java/dev/openrs2/deob/ClassNamePrefixer.java index 4921619c..a4d200af 100644 --- a/deob/src/main/java/dev/openrs2/deob/ClassNamePrefixer.java +++ b/deob/src/main/java/dev/openrs2/deob/ClassNamePrefixer.java @@ -8,9 +8,10 @@ import dev.openrs2.deob.transform.ClassForNameTransformer; import org.objectweb.asm.commons.ClassRemapper; import org.objectweb.asm.commons.SimpleRemapper; import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.analysis.AnalyzerException; public final class ClassNamePrefixer { - public static void addPrefix(Library library, String prefix) { + public static void addPrefix(Library library, String prefix) throws AnalyzerException { var mapping = new HashMap(); for (var clazz : library) { if (TypedRemapper.EXCLUDED_CLASSES.contains(clazz.name)) { diff --git a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.java b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.java index 0329e3ec..afae732f 100644 --- a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.java +++ b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.java @@ -19,6 +19,7 @@ import dev.openrs2.deob.transform.ExceptionTracingTransformer; import dev.openrs2.deob.transform.FieldOrderTransformer; import dev.openrs2.deob.transform.OpaquePredicateTransformer; import dev.openrs2.deob.transform.OriginalNameTransformer; +import org.objectweb.asm.tree.analysis.AnalyzerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,7 +35,7 @@ public final class Deobfuscator { new FieldOrderTransformer() ); - public static void main(String[] args) throws IOException { + public static void main(String[] args) throws IOException, AnalyzerException { var deobfuscator = new Deobfuscator(Paths.get("nonfree/code"), Paths.get("nonfree/code/deob")); deobfuscator.run(); } @@ -46,7 +47,7 @@ public final class Deobfuscator { this.output = output; } - public void run() throws IOException { + public void run() throws IOException, AnalyzerException { /* read input jars/packs */ logger.info("Reading input jars"); var unpacker = Library.readJar(input.resolve("game_unpacker.dat"));