Compare more than just the pops, but the entire stack, and compare
the instructions not the contexts
This commit is contained in:
@@ -1,14 +1,11 @@
|
|||||||
package info.sigterm.deob;
|
package info.sigterm.deob;
|
||||||
|
|
||||||
import info.sigterm.deob.deobfuscators.IllegalStateExceptions;
|
|
||||||
import info.sigterm.deob.deobfuscators.RuntimeExceptions;
|
|
||||||
import info.sigterm.deob.deobfuscators.UnusedFields;
|
|
||||||
import info.sigterm.deob.deobfuscators.UnusedMethods;
|
|
||||||
import info.sigterm.deob.deobfuscators.UnusedParameters;
|
|
||||||
import info.sigterm.deob.deobfuscators.ConstantParameter;
|
import info.sigterm.deob.deobfuscators.ConstantParameter;
|
||||||
import info.sigterm.deob.deobfuscators.MethodInliner;
|
import info.sigterm.deob.deobfuscators.IllegalStateExceptions;
|
||||||
import info.sigterm.deob.deobfuscators.RenameUnique;
|
import info.sigterm.deob.deobfuscators.RenameUnique;
|
||||||
|
import info.sigterm.deob.deobfuscators.RuntimeExceptions;
|
||||||
import info.sigterm.deob.deobfuscators.UnreachedCode;
|
import info.sigterm.deob.deobfuscators.UnreachedCode;
|
||||||
|
import info.sigterm.deob.deobfuscators.UnusedMethods;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import info.sigterm.deob.attributes.code.Instructions;
|
|||||||
import info.sigterm.deob.attributes.code.instructions.LookupSwitch;
|
import info.sigterm.deob.attributes.code.instructions.LookupSwitch;
|
||||||
import info.sigterm.deob.attributes.code.instructions.TableSwitch;
|
import info.sigterm.deob.attributes.code.instructions.TableSwitch;
|
||||||
import info.sigterm.deob.pool.NameAndType;
|
import info.sigterm.deob.pool.NameAndType;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import org.apache.commons.collections4.MultiMap;
|
import org.apache.commons.collections4.MultiMap;
|
||||||
import org.apache.commons.collections4.map.MultiValueMap;
|
import org.apache.commons.collections4.map.MultiValueMap;
|
||||||
|
|
||||||
@@ -60,11 +62,7 @@ public class Frame
|
|||||||
this.cur = other.cur;
|
this.cur = other.cur;
|
||||||
this.stack = new Stack(other.stack);
|
this.stack = new Stack(other.stack);
|
||||||
this.variables = new Variables(other.variables);
|
this.variables = new Variables(other.variables);
|
||||||
//this.instructions = new ArrayList<>(other.instructions); // deep?
|
|
||||||
this.visited = other.visited;
|
this.visited = other.visited;
|
||||||
|
|
||||||
// for (InstructionContext ctx : other.instructions)
|
|
||||||
// instructions.add(new InstructionContext(other, ctx));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Frame dup()
|
public Frame dup()
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public class InstructionContext
|
|||||||
{
|
{
|
||||||
private Instruction ins;
|
private Instruction ins;
|
||||||
private Frame frame;
|
private Frame frame;
|
||||||
|
private Stack stack; // stack at time ins was executed
|
||||||
private List<StackContext> pops = new ArrayList<>(); // stack contexts popped by instruction execution
|
private List<StackContext> pops = new ArrayList<>(); // stack contexts popped by instruction execution
|
||||||
private List<StackContext> pushes = new ArrayList<>(); // stack contexts pushed by instruction execution
|
private List<StackContext> pushes = new ArrayList<>(); // stack contexts pushed by instruction execution
|
||||||
private List<VariableContext> reads = new ArrayList<>(); // lvt reads
|
private List<VariableContext> reads = new ArrayList<>(); // lvt reads
|
||||||
@@ -20,6 +21,7 @@ public class InstructionContext
|
|||||||
{
|
{
|
||||||
ins = i;
|
ins = i;
|
||||||
frame = f;
|
frame = f;
|
||||||
|
stack = new Stack(frame.getStack());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pop(StackContext... ctx)
|
public void pop(StackContext... ctx)
|
||||||
@@ -53,6 +55,11 @@ public class InstructionContext
|
|||||||
return ins;
|
return ins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Stack getStack()
|
||||||
|
{
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
public List<StackContext> getPops()
|
public List<StackContext> getPops()
|
||||||
{
|
{
|
||||||
return pops;
|
return pops;
|
||||||
@@ -90,15 +97,18 @@ public class InstructionContext
|
|||||||
if (ins != ic.ins)
|
if (ins != ic.ins)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (getPops().size() != ic.getPops().size())
|
// check if stack at time of execution is equal
|
||||||
|
Stack ours = new Stack(this.getStack()), // copy stacks since we destroy them
|
||||||
|
theirs = new Stack(ic.getStack());
|
||||||
|
|
||||||
|
if (ours.getSize() != theirs.getSize())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int i = 0; i < getPops().size(); ++i)
|
while (ours.getSize() > 0)
|
||||||
{
|
{
|
||||||
StackContext ours = getPops().get(i),
|
StackContext s1 = ours.pop(), s2 = theirs.pop();
|
||||||
theirs = ic.getPops().get(i);
|
|
||||||
|
|
||||||
if (!ours.getPushed().equals(theirs.getPushed()))
|
if (s1.getPushed().getInstruction() != s2.getPushed().getInstruction())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user