Doesn't execute all paths correctly
This commit is contained in:
@@ -39,7 +39,7 @@ public abstract class Instruction
|
||||
|
||||
public String getDesc(Frame frame)
|
||||
{
|
||||
return type.getName();
|
||||
return type.getName() + " at pc " + frame.getPc() + " in " + frame.getMethod().getName() + " " + frame.getMethod().getDescriptor() + " class " + frame.getMethod().getCode().getAttributes().getClassFile().getName();
|
||||
}
|
||||
|
||||
protected void addJump(int offset)
|
||||
|
||||
@@ -22,6 +22,9 @@ public class AALoad extends Instruction
|
||||
int index = (int) stack.pop();
|
||||
ArrayInstance array = (ArrayInstance) stack.pop();
|
||||
|
||||
stack.push(this, array.get(index));
|
||||
if (index >= 0 && index < array.getLength())
|
||||
stack.push(this, array.get(index));
|
||||
else
|
||||
frame.getPath().throwException(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ public class ALoad_0 extends Instruction
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Object obj = frame.getVariables().get(0);
|
||||
assert obj != null;
|
||||
frame.getStack().push(this, obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ public class ALoad_3 extends Instruction
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Object obj = frame.getVariables().get(3);
|
||||
assert obj != null;
|
||||
frame.getStack().push(this, obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ public class AStore_0 extends Instruction
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Object obj = frame.getStack().pop();
|
||||
assert obj != null;
|
||||
frame.getVariables().set(0, obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ public class AStore_3 extends Instruction
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Object obj = frame.getStack().pop();
|
||||
assert obj != null;
|
||||
frame.getVariables().set(3, obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ILoad extends Instruction
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
int i = (int) frame.getVariables().get(index);
|
||||
Object i = frame.getVariables().get(index);
|
||||
frame.getStack().push(this, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ public class ILoad_1 extends Instruction
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Object obj = frame.getVariables().get(1);
|
||||
assert obj instanceof Integer;
|
||||
frame.getStack().push(this, obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ public class IMul extends Instruction
|
||||
Integer two = (Integer) stack.pop();
|
||||
Integer one = (Integer) stack.pop();
|
||||
|
||||
stack.push(this, one * two);
|
||||
if (one == null || two == null)
|
||||
stack.push(this, 0);
|
||||
else
|
||||
stack.push(this, one * two);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ public class IStore extends Instruction
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Object obj = frame.getStack().pop();
|
||||
assert obj instanceof Integer;
|
||||
frame.getVariables().set(index, obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class InvokeSpecial extends Instruction
|
||||
|
||||
if (object == null)
|
||||
{
|
||||
System.out.println("invokespecial for nonexistant function " + method.getNameAndType().getName() + " " + method.getNameAndType().getDescriptor() + " on " + method.getClassEntry().getName() + " (void: " + !method.getNameAndType().isNonVoid() + ")");
|
||||
//System.out.println("invokespecial for nonexistant function " + method.getNameAndType().getName() + " " + method.getNameAndType().getDescriptor() + " on " + method.getClassEntry().getName() + " (void: " + !method.getNameAndType().isNonVoid() + ")");
|
||||
if (method.getNameAndType().isNonVoid())
|
||||
e.getStack().push(this, null);
|
||||
return;
|
||||
|
||||
@@ -42,8 +42,9 @@ public class InvokeStatic extends Instruction
|
||||
|
||||
if (otherClass == null)
|
||||
{
|
||||
System.out.println("invokestatic for nonexistant class " + clazz.getName());
|
||||
e.getStack().push(this, null);
|
||||
//System.out.println("invokestatic for nonexistant class " + clazz.getName());
|
||||
if (method.getNameAndType().isNonVoid())
|
||||
e.getStack().push(this, null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class InvokeVirtual extends Instruction
|
||||
ObjectInstance object = (ObjectInstance) e.getStack().pop();
|
||||
if (object == null)
|
||||
{
|
||||
System.out.println("invokevirtual on null object for method " + method.getNameAndType().getName() + " " + method.getNameAndType().getDescriptor() + " on " + method.getClassEntry().getName());
|
||||
//System.out.println("invokevirtual on null object for method " + method.getNameAndType().getName() + " " + method.getNameAndType().getDescriptor() + " on " + method.getClassEntry().getName());
|
||||
e.getStack().push(this, null);
|
||||
return;
|
||||
}
|
||||
@@ -54,8 +54,9 @@ public class InvokeVirtual extends Instruction
|
||||
info.sigterm.deob.Method meth = objectType.getClassFile().findMethod(method.getNameAndType());
|
||||
if (meth == null)
|
||||
{
|
||||
System.out.println("Unknown method " + method.getNameAndType().getName() + " " + method.getNameAndType().getDescriptor() + " in " + objectType.getClassFile().getName());
|
||||
e.getStack().push(this, null);
|
||||
//System.out.println("Unknown method " + method.getNameAndType().getName() + " " + method.getNameAndType().getDescriptor() + " in " + objectType.getClassFile().getName());
|
||||
if (method.getNameAndType().isNonVoid())
|
||||
e.getStack().push(this, null);
|
||||
return;
|
||||
}
|
||||
e.getPath().invoke(meth, args);
|
||||
|
||||
@@ -4,6 +4,7 @@ import info.sigterm.deob.attributes.code.Instruction;
|
||||
import info.sigterm.deob.attributes.code.InstructionType;
|
||||
import info.sigterm.deob.attributes.code.Instructions;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
import info.sigterm.deob.execution.Path;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -51,15 +52,15 @@ public class LookupSwitch extends Instruction
|
||||
@Override
|
||||
public void execute(Frame e)
|
||||
{
|
||||
int key = (int) e.getStack().pop();
|
||||
e.getStack().pop();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (match[i] == key)
|
||||
{
|
||||
e.jump(branch[i]);
|
||||
return;
|
||||
}
|
||||
for (int i : branch)
|
||||
{
|
||||
Path p = e.getPath().dup();
|
||||
p.getCurrentFrame().jump(i);
|
||||
}
|
||||
|
||||
e.jump(def);
|
||||
Path p = e.getPath().dup();
|
||||
p.getCurrentFrame().jump(def);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,11 @@ public class PutField extends Instruction
|
||||
ObjectInstance object = (ObjectInstance) e.getStack().pop();
|
||||
Object value = e.getStack().pop();
|
||||
|
||||
if (object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FieldInstance field = object.getField(nat);
|
||||
field.setValue(value);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import info.sigterm.deob.attributes.code.Instruction;
|
||||
import info.sigterm.deob.attributes.code.InstructionType;
|
||||
import info.sigterm.deob.attributes.code.Instructions;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
import info.sigterm.deob.execution.Path;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -49,11 +50,15 @@ public class TableSwitch extends Instruction
|
||||
@Override
|
||||
public void execute(Frame e)
|
||||
{
|
||||
int index = (int) e.getStack().pop();
|
||||
e.getStack().pop();
|
||||
|
||||
if (index < low || index > high)
|
||||
e.jump(def);
|
||||
else
|
||||
e.jump(jumps[index - low]);
|
||||
for (int i : jumps)
|
||||
{
|
||||
Path p = e.getPath().dup();
|
||||
p.getCurrentFrame().jump(i);
|
||||
}
|
||||
|
||||
Path p = e.getPath().dup();
|
||||
p.getCurrentFrame().jump(def);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user