From be127c55cb34191d3777404ee0a783073834d248 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 5 Jul 2015 21:09:13 -0400 Subject: [PATCH] cleanup --- .../deob/deobfuscators/UnusedParameters.java | 63 +++++++++---------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/src/main/java/info/sigterm/deob/deobfuscators/UnusedParameters.java b/src/main/java/info/sigterm/deob/deobfuscators/UnusedParameters.java index 3037962189..e9984cedea 100644 --- a/src/main/java/info/sigterm/deob/deobfuscators/UnusedParameters.java +++ b/src/main/java/info/sigterm/deob/deobfuscators/UnusedParameters.java @@ -115,7 +115,6 @@ public class UnusedParameters for (InstructionContext ins : f.getInstructions()) if (!ins.getInvokes().isEmpty() && methods.containsAll(ins.getInvokes())) { - System.out.println("Removing from " + ins); int pops = signature.size() - paramIndex - 1; // index from top of stack of parameter ins.removeStack(pops); // remove parameter from stack @@ -128,48 +127,47 @@ public class UnusedParameters done.add(ins.getInstruction()); } - /* - // this double checks that all calls to this have been located - for (ClassFile cf : method.getMethods().getClassFile().getGroup().getClasses()) - for (Method m : cf.getMethods().getMethods()) - { - Code c = m.getCode(); - if (c == null) - continue; - - for (Instruction i : c.getInstructions().getInstructions()) + for (Method method : methods) + // this double checks that all calls to this have been located + for (ClassFile cf : method.getMethods().getClassFile().getGroup().getClasses()) + for (Method m : cf.getMethods().getMethods()) { - if (i instanceof InvokeInstruction) + Code c = m.getCode(); + if (c == null) + continue; + + for (Instruction i : c.getInstructions().getInstructions()) { - InvokeInstruction ii = (InvokeInstruction) i; - PoolEntry pool = ii.getMethod(); - - if (pool instanceof info.sigterm.deob.pool.Method) + if (i instanceof InvokeInstruction) { - info.sigterm.deob.pool.Method pm = (info.sigterm.deob.pool.Method) pool; + InvokeInstruction ii = (InvokeInstruction) i; + PoolEntry pool = ii.getMethod(); - if (pm.getClassEntry().getName().equals(method.getMethods().getClassFile().getName()) && pm.getNameAndType().equals(method.getNameAndType()) && !done.contains(i)) + if (pool instanceof info.sigterm.deob.pool.Method) { - // for some reason this wasn't removed above? - System.err.println("Method " + m.getName() + " in " + cf.getName() + " calls " + pm.getNameAndType().getName() + " in " + pm.getClassEntry().getName() + " at " + i.getPc() + ", but this instruction was not found during execution"); - //assert false; + info.sigterm.deob.pool.Method pm = (info.sigterm.deob.pool.Method) pool; + + if (pm.getClassEntry().getName().equals(method.getMethods().getClassFile().getName()) && pm.getNameAndType().equals(method.getNameAndType()) && !done.contains(i)) + { + // for some reason this wasn't removed above? + System.err.println("Method " + m.getName() + " in " + cf.getName() + " calls " + pm.getNameAndType().getName() + " in " + pm.getClassEntry().getName() + " at " + i.getPc() + ", but this instruction was not found during execution"); + //assert false; + } } - } - else if (pool instanceof info.sigterm.deob.pool.InterfaceMethod) - { - info.sigterm.deob.pool.InterfaceMethod pm = (info.sigterm.deob.pool.InterfaceMethod) pool; - - if (pm.getClassEntry().getName().equals(method.getMethods().getClassFile().getName()) && pm.getNameAndType().equals(method.getNameAndType()) && !done.contains(i)) + else if (pool instanceof info.sigterm.deob.pool.InterfaceMethod) { - // for some reason this wasn't removed above? - System.err.println("Method " + m.getName() + " in " + cf.getName() + " calls " + pm.getNameAndType().getName() + " in " + pm.getClassEntry().getName() + " at " + i.getPc() + ", but this instruction was not found during execution"); - //assert false; + info.sigterm.deob.pool.InterfaceMethod pm = (info.sigterm.deob.pool.InterfaceMethod) pool; + + if (pm.getClassEntry().getName().equals(method.getMethods().getClassFile().getName()) && pm.getNameAndType().equals(method.getNameAndType()) && !done.contains(i)) + { + // for some reason this wasn't removed above? + System.err.println("Method " + m.getName() + " in " + cf.getName() + " calls " + pm.getNameAndType().getName() + " in " + pm.getClassEntry().getName() + " at " + i.getPc() + ", but this instruction was not found during execution"); + //assert false; + } } } } } - } - */ for (Method method : methods) if (method.getCode() != null) @@ -243,7 +241,6 @@ public class UnusedParameters /* removing the parameter can cause collision of overriden methods, * we should first rename all methods to be unique? */ - System.out.println("Removing " + m.getName() + " on " + m.getMethods().getClassFile().getName()); removeParameter(methods, signature, execution, unusedParameter, lvtIndexes[unusedParameter]); ++count;