hm
This commit is contained in:
@@ -2,21 +2,30 @@ package net.runelite.deob;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import net.runelite.deob.deobfuscators.ConstantParameter;
|
||||
import net.runelite.deob.deobfuscators.FieldInliner;
|
||||
import net.runelite.deob.deobfuscators.IllegalStateExceptions;
|
||||
import net.runelite.deob.deobfuscators.MethodInliner;
|
||||
import net.runelite.deob.deobfuscators.RenameUnique;
|
||||
import net.runelite.deob.deobfuscators.RuntimeExceptions;
|
||||
import net.runelite.deob.deobfuscators.UnreachedCode;
|
||||
import net.runelite.deob.deobfuscators.UnusedClass;
|
||||
import net.runelite.deob.deobfuscators.UnusedFields;
|
||||
import net.runelite.deob.deobfuscators.UnusedMethods;
|
||||
import net.runelite.deob.deobfuscators.UnusedParameters;
|
||||
import net.runelite.deob.deobfuscators.arithmetic.ModArith;
|
||||
import net.runelite.deob.deobfuscators.arithmetic.MultiplicationDeobfuscator;
|
||||
import net.runelite.deob.deobfuscators.arithmetic.MultiplyOneDeobfuscator;
|
||||
import net.runelite.deob.deobfuscators.arithmetic.MultiplyZeroDeobfuscator;
|
||||
import net.runelite.deob.deobfuscators.rename.Rename2;
|
||||
import net.runelite.deob.execution.Execution;
|
||||
import net.runelite.deob.util.JarUtil;
|
||||
|
||||
// XXX something to detect final fields and evaluate them
|
||||
// the problem is static functions which dup,
|
||||
// graph of method/field (not include static) relationships
|
||||
|
||||
public class Deob
|
||||
{
|
||||
public static void main(String[] args) throws IOException
|
||||
{
|
||||
merge(); if(true) return;
|
||||
//merge(); if(true) return;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
@@ -28,9 +37,8 @@ public class Deob
|
||||
// run(group, new RuntimeExceptions());
|
||||
//
|
||||
// // remove unused methods
|
||||
// run(group, new UnusedMethods());
|
||||
//
|
||||
// run(group, new UnreachedCode());
|
||||
// run(group, new UnusedMethods());
|
||||
//
|
||||
// // remove illegal state exceptions, frees up some parameters
|
||||
// run(group, new IllegalStateExceptions());
|
||||
@@ -45,50 +53,43 @@ public class Deob
|
||||
// // remove unused parameters
|
||||
// run(group, new UnusedParameters());
|
||||
//
|
||||
// // remove jump obfuscation
|
||||
// //new Jumps().run(group);
|
||||
//
|
||||
// // remove unused fields
|
||||
// run(group, new UnusedFields());
|
||||
//
|
||||
// // remove unused methods, again?
|
||||
// run(group, new UnusedMethods());
|
||||
|
||||
run(group, new MethodInliner());
|
||||
run(group, new UnusedMethods()); // inliner might leave unused methods
|
||||
|
||||
// // broken because rename was removed
|
||||
// //run(group, new MethodMover());
|
||||
//
|
||||
//// run(group, new MethodInliner());
|
||||
//// run(group, new UnusedMethods()); // inliner might leave unused methods
|
||||
//
|
||||
//// // broken because rename was removed
|
||||
//// //run(group, new MethodMover());
|
||||
//
|
||||
// run(group, new FieldInliner());
|
||||
//
|
||||
// // XXX this is broken because when moving clinit around, some fields can depend on other fields
|
||||
// // (like multianewarray)
|
||||
// //new FieldMover().run(group);
|
||||
//// // XXX this is broken because when moving clinit around, some fields can depend on other fields
|
||||
//// // (like multianewarray)
|
||||
//// //new FieldMover().run(group);
|
||||
//
|
||||
// run(group, new UnusedClass());
|
||||
//
|
||||
// ModArith mod = new ModArith();
|
||||
// mod.run(group);
|
||||
//
|
||||
// int last = -1, cur;
|
||||
// while ((cur = mod.runOnce()) > 0)
|
||||
// {
|
||||
// new MultiplicationDeobfuscator().run(group);
|
||||
//
|
||||
// new MultiplyOneDeobfuscator().run(group);
|
||||
//
|
||||
// new MultiplyZeroDeobfuscator().run(group);
|
||||
//
|
||||
// if (last == cur)
|
||||
// {
|
||||
// System.out.println("break");
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// last = cur;
|
||||
// //break;
|
||||
// }
|
||||
|
||||
ModArith mod = new ModArith();
|
||||
mod.run(group);
|
||||
|
||||
int last = -1, cur;
|
||||
while ((cur = mod.runOnce()) > 0)
|
||||
{
|
||||
new MultiplicationDeobfuscator().run(group);
|
||||
|
||||
new MultiplyOneDeobfuscator().run(group);
|
||||
|
||||
new MultiplyZeroDeobfuscator().run(group);
|
||||
|
||||
if (last == cur)
|
||||
break;
|
||||
|
||||
last = cur;
|
||||
}
|
||||
|
||||
// eval constant fields (only set once to a constant in ctor) maybe just inline them
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.runelite.deob.deobfuscators.rename;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -7,12 +9,15 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import net.runelite.deob.ClassFile;
|
||||
import net.runelite.deob.ClassGroup;
|
||||
import net.runelite.deob.Field;
|
||||
import net.runelite.deob.Method;
|
||||
import net.runelite.deob.attributes.code.instruction.types.SetFieldInstruction;
|
||||
import net.runelite.deob.deobfuscators.Renamer;
|
||||
import net.runelite.deob.deobfuscators.rename.graph.Graph;
|
||||
import net.runelite.deob.deobfuscators.rename.graph.Vertex;
|
||||
import net.runelite.deob.deobfuscators.rename.graph.VertexType;
|
||||
@@ -20,6 +25,7 @@ import net.runelite.deob.execution.Execution;
|
||||
import net.runelite.deob.execution.Frame;
|
||||
import net.runelite.deob.execution.InstructionContext;
|
||||
import net.runelite.deob.signature.Signature;
|
||||
import net.runelite.deob.util.JarUtil;
|
||||
import net.runelite.deob.util.NameMappings;
|
||||
|
||||
public class Rename2
|
||||
@@ -144,13 +150,11 @@ public class Rename2
|
||||
{
|
||||
Execution eone = new Execution(one);
|
||||
eone.setBuildGraph(true);
|
||||
//eone.setFollowInvokes(false);
|
||||
eone.populateInitialMethods();
|
||||
eone.run();
|
||||
|
||||
Execution etwo = new Execution(two);
|
||||
etwo.setBuildGraph(true);
|
||||
//etwo.setFollowInvokes(false);
|
||||
etwo.populateInitialMethods();
|
||||
etwo.run();
|
||||
|
||||
@@ -203,9 +207,20 @@ public class Rename2
|
||||
System.out.println("methods " +g1.solved(VertexType.METHOD));
|
||||
System.out.println("f " +g1.solved(VertexType.FIELD));
|
||||
|
||||
NameMappings mappings = rename(one, two); // two -> one
|
||||
NameMappings mappings = buildMappings(one, two); // two -> one
|
||||
|
||||
// show(mappings);
|
||||
show(mappings);
|
||||
|
||||
rename(mappings, two);
|
||||
|
||||
try
|
||||
{
|
||||
JarUtil.saveJar(two, new File("d:/rs/07/adamout.jar"));
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger(Rename2.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void show(NameMappings mappings)
|
||||
@@ -228,7 +243,7 @@ public class Rename2
|
||||
}
|
||||
}
|
||||
|
||||
private NameMappings rename(ClassGroup one, ClassGroup two)
|
||||
private NameMappings buildMappings(ClassGroup one, ClassGroup two)
|
||||
{
|
||||
NameMappings mappings = new NameMappings();
|
||||
|
||||
@@ -261,4 +276,10 @@ public class Rename2
|
||||
|
||||
return mappings;
|
||||
}
|
||||
|
||||
private void rename(NameMappings mappings, ClassGroup group)
|
||||
{
|
||||
Renamer renamer = new Renamer(mappings);
|
||||
renamer.run(group);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user