hm this assert fails

This commit is contained in:
Adam
2015-08-19 21:23:00 -04:00
parent 7fb5f3e721
commit 35d8a98365
9 changed files with 72 additions and 71 deletions

View File

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

View File

@@ -17,12 +17,15 @@ public abstract class Attribute
this.type = type;
}
public void load() throws IOException
public final void load() throws IOException
{
DataInputStream is = attributes.getStream();
this.length = is.readInt();
this.loadAttribute();
}
public abstract void loadAttribute() throws IOException;
public final void write(DataOutputStream out) throws IOException
{
ByteArrayOutputStream bout = new ByteArrayOutputStream();

View File

@@ -23,10 +23,8 @@ public class Code extends Attribute
}
@Override
public void load() throws IOException
public void loadAttribute() throws IOException
{
super.load();
DataInputStream is = this.getAttributes().getStream();
maxStack = is.readUnsignedShort();

View File

@@ -23,10 +23,8 @@ public class ConstantValue extends Attribute
}
@Override
public void load() throws IOException
public void loadAttribute() throws IOException
{
super.load();
DataInputStream is = this.getAttributes().getStream();
value = this.getAttributes().getClassFile().getPool().getEntry(is.readUnsignedShort());
}

View File

@@ -19,10 +19,8 @@ public class Exceptions extends Attribute
}
@Override
public void load() throws IOException
public void loadAttribute() throws IOException
{
super.load();
DataInputStream is = this.getAttributes().getStream();
int count = is.readUnsignedShort();

View File

@@ -14,10 +14,8 @@ public class Unknown extends Attribute
}
@Override
public void load() throws IOException
public void loadAttribute() throws IOException
{
super.load();
int len = this.getLength();
DataInputStream is = this.getAttributes().getStream();

View File

@@ -114,7 +114,7 @@ public class UnusedParameters implements Deobfuscator
for (InstructionContext ins : f.getInstructions())
if (!ins.getInvokes().isEmpty() && methods.containsAll(ins.getInvokes()))
{
int pops = signature.size() - paramIndex - 1; // index from top of stack of parameter
int pops = signature.size() - paramIndex - 1; // index from top of stack of parameter. 0 is the last parameter
ins.removeStack(pops); // remove parameter from stack
if (done.contains(ins.getInstruction()))
@@ -235,7 +235,10 @@ public class UnusedParameters implements Deobfuscator
int[] lvtIndexes = getLvtIndexes(signature, offset);
for (Method m2 : methods)
{
assert !done.contains(m2);
done.add(m2);
}
/* removing the parameter can't cause collisions on other (overloaded) methods because prior to this we rename
* all classes/fields/methods to have unique names.

View File

@@ -80,6 +80,8 @@ public class InstructionContext
// idx 0 is top of the stack, 1 is one under
// stack contexts are added to 'pops' in the order that they are popped from the stack,
StackContext ctx = pops.get(idx);
assert !ctx.removed;
ctx.removed = true;
// start recursively removing
return ctx.removeStack();

View File

@@ -8,6 +8,7 @@ public class StackContext
public InstructionContext pushed; // instruction which pushed this
public InstructionContext popped; // instruction which popped this
public Type type; // type of this
public boolean removed;
public StackContext(InstructionContext pushed, Type type)
{