Field moving works

This commit is contained in:
Adam
2015-08-22 12:18:24 -04:00
parent 35d8a98365
commit 1853bb1be1
6 changed files with 79 additions and 70 deletions

View File

@@ -46,73 +46,73 @@ public class Deob
// bdur = System.currentTimeMillis() - bstart; // bdur = System.currentTimeMillis() - bstart;
// System.out.println("rename unique took " + bdur/1000L + " seconds"); // System.out.println("rename unique took " + bdur/1000L + " seconds");
// remove except RuntimeException // // remove except RuntimeException
bstart = System.currentTimeMillis(); // bstart = System.currentTimeMillis();
new RuntimeExceptions().run(group); // new RuntimeExceptions().run(group);
bdur = System.currentTimeMillis() - bstart; // bdur = System.currentTimeMillis() - bstart;
System.out.println("runtime exception took " + bdur/1000L + " seconds"); // System.out.println("runtime exception took " + bdur/1000L + " seconds");
//
// remove unused methods // // remove unused methods
bstart = System.currentTimeMillis(); // bstart = System.currentTimeMillis();
new UnusedMethods().run(group); // new UnusedMethods().run(group);
bdur = System.currentTimeMillis() - bstart; // bdur = System.currentTimeMillis() - bstart;
System.out.println("unused methods took " + bdur/1000L + " seconds"); // System.out.println("unused methods took " + bdur/1000L + " seconds");
//
new UnreachedCode().run(group); // new UnreachedCode().run(group);
//
// remove illegal state exceptions, frees up some parameters // // remove illegal state exceptions, frees up some parameters
bstart = System.currentTimeMillis(); // bstart = System.currentTimeMillis();
new IllegalStateExceptions().run(group); // new IllegalStateExceptions().run(group);
bdur = System.currentTimeMillis() - bstart; // bdur = System.currentTimeMillis() - bstart;
System.out.println("illegal state exception took " + bdur/1000L + " seconds"); // System.out.println("illegal state exception took " + bdur/1000L + " seconds");
//
// remove constant logically dead parameters // // remove constant logically dead parameters
bstart = System.currentTimeMillis(); // bstart = System.currentTimeMillis();
new ConstantParameter().run(group); // new ConstantParameter().run(group);
bdur = System.currentTimeMillis() - bstart; // bdur = System.currentTimeMillis() - bstart;
System.out.println("constant param took " + bdur/1000L + " seconds"); // System.out.println("constant param took " + bdur/1000L + " seconds");
//
// remove unhit blocks // // remove unhit blocks
bstart = System.currentTimeMillis(); // bstart = System.currentTimeMillis();
new UnreachedCode().run(group); // new UnreachedCode().run(group);
//new UnusedBlocks().run(group); // //new UnusedBlocks().run(group);
bdur = System.currentTimeMillis() - bstart; // bdur = System.currentTimeMillis() - bstart;
System.out.println("unused blocks took " + bdur/1000L + " seconds"); // System.out.println("unused blocks took " + bdur/1000L + " seconds");
//
// remove unused parameters // // remove unused parameters
bstart = System.currentTimeMillis(); // bstart = System.currentTimeMillis();
new UnusedParameters().run(group); // new UnusedParameters().run(group);
bdur = System.currentTimeMillis() - bstart; // bdur = System.currentTimeMillis() - bstart;
System.out.println("unused params took " + bdur/1000L + " seconds"); // System.out.println("unused params took " + bdur/1000L + " seconds");
//
// remove jump obfuscation // // remove jump obfuscation
//new Jumps().run(group); // //new Jumps().run(group);
//
// remove unused fields // // remove unused fields
bstart = System.currentTimeMillis(); // bstart = System.currentTimeMillis();
new UnusedFields().run(group); // new UnusedFields().run(group);
bdur = System.currentTimeMillis() - bstart; // bdur = System.currentTimeMillis() - bstart;
System.out.println("unused fields took " + bdur/1000L + " seconds"); // System.out.println("unused fields took " + bdur/1000L + " seconds");
//
// remove unused methods, again? // // remove unused methods, again?
bstart = System.currentTimeMillis(); // bstart = System.currentTimeMillis();
new UnusedMethods().run(group); // new UnusedMethods().run(group);
bdur = System.currentTimeMillis() - bstart; // bdur = System.currentTimeMillis() - bstart;
System.out.println("unused methods took " + bdur/1000L + " seconds"); // System.out.println("unused methods took " + bdur/1000L + " seconds");
//
//
new MethodInliner().run(group); // new MethodInliner().run(group);
// new ModularArithmeticDeobfuscation().run(group);
// //
// new MethodMover().run(group); // new MethodMover().run(group);
//new FieldMover().run(group);
// //
// new FieldInliner().run(group); // new FieldInliner().run(group);
new FieldMover().run(group);
//new UnusedClass().run(group); //new UnusedClass().run(group);
// new ModularArithmeticDeobfuscation().run(group);
saveJar(group, args[1]); saveJar(group, args[1]);
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();

View File

@@ -38,11 +38,9 @@ public class Attributes
method = m; method = m;
} }
public Attributes(Code c) throws IOException public Attributes(Code c)
{ {
code = c; code = c;
load();
} }
public Method getMethod() public Method getMethod()

View File

@@ -20,6 +20,9 @@ public class Code extends Attribute
public Code(Attributes attributes) public Code(Attributes attributes)
{ {
super(attributes, AttributeType.CODE); super(attributes, AttributeType.CODE);
exceptions = new Exceptions(this);
this.attributes = new Attributes(this);
} }
@Override @Override
@@ -34,7 +37,10 @@ public class Code extends Attribute
instructions.load(); instructions.load();
exceptions = new Exceptions(this); exceptions = new Exceptions(this);
exceptions.load();
this.attributes = new Attributes(this); this.attributes = new Attributes(this);
this.attributes.load();
instructions.buildBlocks(); instructions.buildBlocks();
instructions.buildJumpGraph(); instructions.buildJumpGraph();

View File

@@ -14,10 +14,13 @@ public class Exceptions
private Code code; private Code code;
private List<Exception> exceptions = new ArrayList<Exception>(); private List<Exception> exceptions = new ArrayList<Exception>();
public Exceptions(Code code) throws IOException public Exceptions(Code code)
{ {
this.code = code; this.code = code;
}
public void load() throws IOException
{
DataInputStream is = code.getAttributes().getStream(); DataInputStream is = code.getAttributes().getStream();
int count = is.readUnsignedShort(); int count = is.readUnsignedShort();

View File

@@ -200,6 +200,8 @@ public class FieldMover implements Deobfuscator
code.setInstructions(instructions); code.setInstructions(instructions);
instructions.getInstructions().add(new VReturn(instructions, InstructionType.RETURN, 0)); // add return instructions.getInstructions().add(new VReturn(instructions, InstructionType.RETURN, 0)); // add return
to.getMethods().getMethods().add(toClinit);
} }
moveInitializer(setField, toClinit); moveInitializer(setField, toClinit);

View File

@@ -256,14 +256,14 @@ public class UnusedParameters implements Deobfuscator
@Override @Override
public void run(ClassGroup group) public void run(ClassGroup group)
{ {
Execution execution = new Execution(group);
execution.populateInitialMethods();
execution.run();
int count = 0; int count = 0;
int[] i; int[] i;
do do
{ {
Execution execution = new Execution(group);
execution.populateInitialMethods();
execution.run();
i = checkParametersOnce(execution, group); i = checkParametersOnce(execution, group);
count += i[0]; count += i[0];