hm this assert fails
This commit is contained in:
@@ -46,68 +46,68 @@ 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 ModularArithmeticDeobfuscation().run(group);
|
||||||
//
|
//
|
||||||
// new MethodMover().run(group);
|
// new MethodMover().run(group);
|
||||||
|
|
||||||
new FieldMover().run(group);
|
//new FieldMover().run(group);
|
||||||
//
|
//
|
||||||
// new FieldInliner().run(group);
|
// new FieldInliner().run(group);
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,15 @@ public abstract class Attribute
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() throws IOException
|
public final void load() throws IOException
|
||||||
{
|
{
|
||||||
DataInputStream is = attributes.getStream();
|
DataInputStream is = attributes.getStream();
|
||||||
this.length = is.readInt();
|
this.length = is.readInt();
|
||||||
|
this.loadAttribute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void loadAttribute() throws IOException;
|
||||||
|
|
||||||
public final void write(DataOutputStream out) throws IOException
|
public final void write(DataOutputStream out) throws IOException
|
||||||
{
|
{
|
||||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||||
|
|||||||
@@ -23,10 +23,8 @@ public class Code extends Attribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() throws IOException
|
public void loadAttribute() throws IOException
|
||||||
{
|
{
|
||||||
super.load();
|
|
||||||
|
|
||||||
DataInputStream is = this.getAttributes().getStream();
|
DataInputStream is = this.getAttributes().getStream();
|
||||||
|
|
||||||
maxStack = is.readUnsignedShort();
|
maxStack = is.readUnsignedShort();
|
||||||
|
|||||||
@@ -23,10 +23,8 @@ public class ConstantValue extends Attribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() throws IOException
|
public void loadAttribute() throws IOException
|
||||||
{
|
{
|
||||||
super.load();
|
|
||||||
|
|
||||||
DataInputStream is = this.getAttributes().getStream();
|
DataInputStream is = this.getAttributes().getStream();
|
||||||
value = this.getAttributes().getClassFile().getPool().getEntry(is.readUnsignedShort());
|
value = this.getAttributes().getClassFile().getPool().getEntry(is.readUnsignedShort());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,8 @@ public class Exceptions extends Attribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() throws IOException
|
public void loadAttribute() throws IOException
|
||||||
{
|
{
|
||||||
super.load();
|
|
||||||
|
|
||||||
DataInputStream is = this.getAttributes().getStream();
|
DataInputStream is = this.getAttributes().getStream();
|
||||||
|
|
||||||
int count = is.readUnsignedShort();
|
int count = is.readUnsignedShort();
|
||||||
|
|||||||
@@ -14,10 +14,8 @@ public class Unknown extends Attribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() throws IOException
|
public void loadAttribute() throws IOException
|
||||||
{
|
{
|
||||||
super.load();
|
|
||||||
|
|
||||||
int len = this.getLength();
|
int len = this.getLength();
|
||||||
DataInputStream is = this.getAttributes().getStream();
|
DataInputStream is = this.getAttributes().getStream();
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class UnusedParameters implements Deobfuscator
|
|||||||
for (InstructionContext ins : f.getInstructions())
|
for (InstructionContext ins : f.getInstructions())
|
||||||
if (!ins.getInvokes().isEmpty() && methods.containsAll(ins.getInvokes()))
|
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
|
ins.removeStack(pops); // remove parameter from stack
|
||||||
|
|
||||||
if (done.contains(ins.getInstruction()))
|
if (done.contains(ins.getInstruction()))
|
||||||
@@ -235,7 +235,10 @@ public class UnusedParameters implements Deobfuscator
|
|||||||
int[] lvtIndexes = getLvtIndexes(signature, offset);
|
int[] lvtIndexes = getLvtIndexes(signature, offset);
|
||||||
|
|
||||||
for (Method m2 : methods)
|
for (Method m2 : methods)
|
||||||
|
{
|
||||||
|
assert !done.contains(m2);
|
||||||
done.add(m2);
|
done.add(m2);
|
||||||
|
}
|
||||||
|
|
||||||
/* removing the parameter can't cause collisions on other (overloaded) methods because prior to this we rename
|
/* 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.
|
* all classes/fields/methods to have unique names.
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ public class InstructionContext
|
|||||||
// idx 0 is top of the stack, 1 is one under
|
// 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,
|
// stack contexts are added to 'pops' in the order that they are popped from the stack,
|
||||||
StackContext ctx = pops.get(idx);
|
StackContext ctx = pops.get(idx);
|
||||||
|
assert !ctx.removed;
|
||||||
|
ctx.removed = true;
|
||||||
|
|
||||||
// start recursively removing
|
// start recursively removing
|
||||||
return ctx.removeStack();
|
return ctx.removeStack();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public class StackContext
|
|||||||
public InstructionContext pushed; // instruction which pushed this
|
public InstructionContext pushed; // instruction which pushed this
|
||||||
public InstructionContext popped; // instruction which popped this
|
public InstructionContext popped; // instruction which popped this
|
||||||
public Type type; // type of this
|
public Type type; // type of this
|
||||||
|
public boolean removed;
|
||||||
|
|
||||||
public StackContext(InstructionContext pushed, Type type)
|
public StackContext(InstructionContext pushed, Type type)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user