Executor work

This commit is contained in:
Adam
2015-01-26 00:40:54 -05:00
parent a998491133
commit 55dca4fa9b
148 changed files with 512 additions and 194 deletions

View File

@@ -22,6 +22,6 @@ public class AALoad extends Instruction
int index = (int) stack.pop();
ArrayInstance array = (ArrayInstance) stack.pop();
stack.push(array.get(index));
stack.push(this, array.get(index));
}
}

View File

@@ -19,6 +19,6 @@ public class AConstNull extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(null);
stack.push(this, null);
}
}

View File

@@ -25,6 +25,6 @@ public class ALoad extends Instruction
public void execute(Frame frame)
{
Object obj = frame.getVariables().get(index);
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -19,6 +19,6 @@ public class ALoad_0 extends Instruction
{
Object obj = frame.getVariables().get(0);
assert obj != null;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -18,7 +18,6 @@ public class ALoad_1 extends Instruction
public void execute(Frame frame)
{
Object obj = frame.getVariables().get(1);
assert obj != null;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -18,7 +18,6 @@ public class ALoad_2 extends Instruction
public void execute(Frame frame)
{
Object obj = frame.getVariables().get(2);
assert obj != null;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -19,6 +19,6 @@ public class ALoad_3 extends Instruction
{
Object obj = frame.getVariables().get(3);
assert obj != null;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -36,13 +36,13 @@ public class ANewArray extends Instruction
ClassFile cf = thisClass.getGroup().findClass(clazz.getName());
if (cf == null)
{
frame.getStack().push(null);
frame.getStack().push(this, null);
return;
}
ClassInstance type = frame.getPath().getClassInstance(cf);
ArrayInstance array = frame.getPath().createArray(type, count);
frame.getStack().push(array);
frame.getStack().push(this, array);
}
}

View File

@@ -18,7 +18,6 @@ public class AStore_1 extends Instruction
public void execute(Frame frame)
{
Object obj = frame.getStack().pop();
assert obj != null;
frame.getVariables().set(1, obj);
}
}

View File

@@ -18,7 +18,6 @@ public class AStore_2 extends Instruction
public void execute(Frame frame)
{
Object obj = frame.getStack().pop();
assert obj != null;
frame.getVariables().set(2, obj);
}
}

View File

@@ -0,0 +1,24 @@
package info.sigterm.deob.attributes.code.instructions;
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.ObjectInstance;
import java.io.IOException;
public class AThrow extends Instruction
{
public AThrow(Instructions instructions, InstructionType type, int pc) throws IOException
{
super(instructions, type, pc);
}
@Override
public void execute(Frame e)
{
ObjectInstance exception = (ObjectInstance) e.getStack().pop();
e.getPath().throwException(exception);
}
}

View File

@@ -3,6 +3,7 @@ package info.sigterm.deob.attributes.code.instructions;
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.ArrayInstance;
import info.sigterm.deob.execution.Frame;
import java.io.IOException;
@@ -17,7 +18,7 @@ public class ArrayLength extends Instruction
@Override
public void execute(Frame frame)
{
Object[] array = (Object[]) frame.getStack().pop();
frame.getStack().push(array.length);
ArrayInstance array = (ArrayInstance) frame.getStack().pop();
frame.getStack().push(this, array.getLength());
}
}

View File

@@ -21,6 +21,6 @@ public class BALoad extends Instruction
int index = (int) stack.pop();
boolean[] array = (boolean[]) stack.pop();
stack.push(array[index]);
stack.push(this, array[index]);
}
}

View File

@@ -24,6 +24,6 @@ public class BiPush extends Instruction
@Override
public void execute(Frame frame)
{
frame.getStack().push((int) b);
frame.getStack().push(this, (int) b);
}
}

View File

@@ -21,6 +21,6 @@ public class CALoad extends Instruction
int index = (int) stack.pop();
char[] array = (char[]) stack.pop();
stack.push(array[index]);
stack.push(this, array[index]);
}
}

View File

@@ -36,7 +36,7 @@ public class CheckCast extends Instruction
ObjectInstance obj = (ObjectInstance) e.getStack().pop();
if (obj == null)
{
e.getStack().push(null);
e.getStack().push(this, null);
return;
}
@@ -48,7 +48,7 @@ public class CheckCast extends Instruction
// XXX throw
}
e.getStack().push(obj);
e.getStack().push(this, obj);
}
}

View File

@@ -24,6 +24,6 @@ public class D2F extends Instruction
assert obj instanceof Double;
Double d = (Double) obj;
stack.push(d.floatValue());
stack.push(this, d.floatValue());
}
}

View File

@@ -24,6 +24,6 @@ public class D2I extends Instruction
assert obj instanceof Double;
Double d = (Double) obj;
stack.push(d.intValue());
stack.push(this, d.intValue());
}
}

View File

@@ -24,6 +24,6 @@ public class D2L extends Instruction
assert obj instanceof Double;
Double d = (Double) obj;
stack.push(d.longValue());
stack.push(this, d.longValue());
}
}

View File

@@ -21,6 +21,6 @@ public class DALoad extends Instruction
int index = (int) stack.pop();
double[] array = (double[]) stack.pop();
stack.push(array[index]);
stack.push(this, array[index]);
}
}

View File

@@ -21,6 +21,6 @@ public class DAdd extends Instruction
Double two = (Double) stack.pop();
Double one = (Double) stack.pop();
stack.push(one + two);
stack.push(this, one + two);
}
}

View File

@@ -24,12 +24,12 @@ public class DCmpG extends Instruction
Double two = (Double) stack.pop();
if (one.isNaN() || two.isNaN())
stack.push(1);
stack.push(this, 1);
else if (one > two)
stack.push(1);
stack.push(this, 1);
else if (one < two)
stack.push(-1);
stack.push(this, -1);
else
stack.push(0);
stack.push(this, 0);
}
}

View File

@@ -24,12 +24,12 @@ public class DCmpL extends Instruction
Double two = (Double) stack.pop();
if (one.isNaN() || two.isNaN())
stack.push(-1);
stack.push(this, -1);
else if (one > two)
stack.push(1);
stack.push(this, 1);
else if (one < two)
stack.push(-1);
stack.push(this, -1);
else
stack.push(0);
stack.push(this, 0);
}
}

View File

@@ -19,6 +19,6 @@ public class DConst_0 extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(0d);
stack.push(this, 0d);
}
}

View File

@@ -19,6 +19,6 @@ public class DConst_1 extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(1d);
stack.push(this, 1d);
}
}

View File

@@ -21,6 +21,6 @@ public class DDiv extends Instruction
Double two = (Double) stack.pop();
Double one = (Double) stack.pop();
stack.push(one / two);
stack.push(this, one / two);
}
}

View File

@@ -25,6 +25,6 @@ public class DLoad extends Instruction
public void execute(Frame frame)
{
double d = (double) frame.getVariables().get(index);
frame.getStack().push(d);
frame.getStack().push(this, d);
}
}

View File

@@ -19,6 +19,6 @@ public class DLoad_0 extends Instruction
{
Object obj = frame.getVariables().get(0);
assert obj instanceof Double;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -19,6 +19,6 @@ public class DLoad_1 extends Instruction
{
Object obj = frame.getVariables().get(1);
assert obj instanceof Double;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -19,6 +19,6 @@ public class DLoad_2 extends Instruction
{
Object obj = frame.getVariables().get(2);
assert obj instanceof Double;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -19,6 +19,6 @@ public class DLoad_3 extends Instruction
{
Object obj = frame.getVariables().get(3);
assert obj instanceof Double;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -21,6 +21,6 @@ public class DMul extends Instruction
Double two = (Double) stack.pop();
Double one = (Double) stack.pop();
stack.push(one * two);
stack.push(this, one * two);
}
}

View File

@@ -19,6 +19,6 @@ public class DNeg extends Instruction
Stack stack = frame.getStack();
Double value = (Double) stack.pop();
stack.push(-value);
stack.push(this, -value);
}
}

View File

@@ -21,6 +21,6 @@ public class DRem extends Instruction
Double two = (Double) stack.pop();
Double one = (Double) stack.pop();
stack.push(one % two);
stack.push(this, one % two);
}
}

View File

@@ -21,6 +21,6 @@ public class DSub extends Instruction
Double two = (Double) stack.pop();
Double one = (Double) stack.pop();
stack.push(one - two);
stack.push(this, one - two);
}
}

View File

@@ -18,7 +18,7 @@ public class Dup extends Instruction
public void execute(Frame frame)
{
Object obj = frame.getStack().pop();
frame.getStack().push(obj);
frame.getStack().push(obj);
frame.getStack().push(this, obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -26,11 +26,11 @@ public class Dup2 extends Instruction
two = stack.pop();
if (!(one instanceof Double) && !(one instanceof Long))
stack.push(two);
stack.push(one);
stack.push(this, two);
stack.push(this, one);
if (!(one instanceof Double) && !(one instanceof Long))
stack.push(two);
stack.push(one);
stack.push(this, two);
stack.push(this, one);
}
}

View File

@@ -27,13 +27,13 @@ public class Dup2_X1 extends Instruction
Object three = stack.pop();
if (!(one instanceof Double) && !(one instanceof Long))
stack.push(two);
stack.push(one);
stack.push(this, two);
stack.push(this, one);
stack.push(three);
stack.push(this, three);
if (!(one instanceof Double) && !(one instanceof Long))
stack.push(two);
stack.push(one);
stack.push(this, two);
stack.push(this, one);
}
}

View File

@@ -30,15 +30,15 @@ public class Dup2_X2 extends Instruction
four = stack.pop();
if (!(one instanceof Double) && !(one instanceof Long))
stack.push(two);
stack.push(one);
stack.push(this, two);
stack.push(this, one);
if (!(three instanceof Double) && !(three instanceof Long))
stack.push(four);
stack.push(three);
stack.push(this, four);
stack.push(this, three);
if (!(one instanceof Double) && !(one instanceof Long))
stack.push(two);
stack.push(one);
stack.push(this, two);
stack.push(this, one);
}
}

View File

@@ -23,8 +23,8 @@ public class Dup_X1 extends Instruction
Object one = stack.pop();
Object two = stack.pop();
stack.push(one);
stack.push(two);
stack.push(one);
stack.push(this, one);
stack.push(this, two);
stack.push(this, one);
}
}

View File

@@ -26,10 +26,10 @@ public class Dup_X2 extends Instruction
if (!(two instanceof Double) && !(two instanceof Long))
three = stack.pop();
stack.push(one);
stack.push(this, one);
if (!(two instanceof Double) && !(two instanceof Long))
stack.push(three);
stack.push(two);
stack.push(one);
stack.push(this, three);
stack.push(this, two);
stack.push(this, one);
}
}

View File

@@ -24,6 +24,6 @@ public class F2D extends Instruction
assert obj instanceof Float;
Float f = (Float) obj;
stack.push(f.doubleValue());
stack.push(this, f.doubleValue());
}
}

View File

@@ -24,6 +24,6 @@ public class F2I extends Instruction
assert obj instanceof Float;
Float f = (Float) obj;
stack.push(f.intValue());
stack.push(this, f.intValue());
}
}

View File

@@ -24,6 +24,6 @@ public class F2L extends Instruction
assert obj instanceof Float;
Float f = (Float) obj;
stack.push(f.longValue());
stack.push(this, f.longValue());
}
}

View File

@@ -21,6 +21,6 @@ public class FALoad extends Instruction
int index = (int) stack.pop();
float[] array = (float[]) stack.pop();
stack.push(array[index]);
stack.push(this, array[index]);
}
}

View File

@@ -21,6 +21,6 @@ public class FAdd extends Instruction
Float one = (Float) stack.pop();
Float two = (Float) stack.pop();
stack.push(one + two);
stack.push(this, one + two);
}
}

View File

@@ -24,12 +24,12 @@ public class FCmpG extends Instruction
Float two = (Float) stack.pop();
if (one.isNaN() || two.isNaN())
stack.push(1);
stack.push(this, 1);
else if (one > two)
stack.push(1);
stack.push(this, 1);
else if (one < two)
stack.push(-1);
stack.push(this, -1);
else
stack.push(0);
stack.push(this, 0);
}
}

View File

@@ -24,12 +24,12 @@ public class FCmpL extends Instruction
Float two = (Float) stack.pop();
if (one.isNaN() || two.isNaN())
stack.push(-1);
stack.push(this, -1);
else if (one > two)
stack.push(1);
stack.push(this, 1);
else if (one < two)
stack.push(-1);
stack.push(this, -1);
else
stack.push(0);
stack.push(this, 0);
}
}

View File

@@ -19,6 +19,6 @@ public class FConst_0 extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(0f);
stack.push(this, 0f);
}
}

View File

@@ -19,6 +19,6 @@ public class FConst_1 extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(1f);
stack.push(this, 1f);
}
}

View File

@@ -19,6 +19,6 @@ public class FConst_2 extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(2f);
stack.push(this, 2f);
}
}

View File

@@ -21,6 +21,6 @@ public class FDiv extends Instruction
Float two = (Float) stack.pop();
Float one = (Float) stack.pop();
stack.push(one / two);
stack.push(this, one / two);
}
}

View File

@@ -25,6 +25,6 @@ public class FLoad extends Instruction
public void execute(Frame frame)
{
float f = (float) frame.getVariables().get(index);
frame.getStack().push(f);
frame.getStack().push(this, f);
}
}

View File

@@ -19,6 +19,6 @@ public class FLoad_0 extends Instruction
{
Object obj = frame.getVariables().get(0);
assert obj instanceof Float;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -19,6 +19,6 @@ public class FLoad_1 extends Instruction
{
Object obj = frame.getVariables().get(1);
assert obj instanceof Float;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -19,6 +19,6 @@ public class FLoad_2 extends Instruction
{
Object obj = frame.getVariables().get(2);
assert obj instanceof Float;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -19,6 +19,6 @@ public class FLoad_3 extends Instruction
{
Object obj = frame.getVariables().get(3);
assert obj instanceof Float;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -21,6 +21,6 @@ public class FMul extends Instruction
Float two = (Float) stack.pop();
Float one = (Float) stack.pop();
stack.push(one * two);
stack.push(this, one * two);
}
}

View File

@@ -19,6 +19,6 @@ public class FNeg extends Instruction
Stack stack = frame.getStack();
Float value = (Float) stack.pop();
stack.push(-value);
stack.push(this, -value);
}
}

View File

@@ -21,6 +21,6 @@ public class FRem extends Instruction
Float two = (Float) stack.pop();
Float one = (Float) stack.pop();
stack.push(one % two);
stack.push(this, one % two);
}
}

View File

@@ -21,6 +21,6 @@ public class FSub extends Instruction
Float two = (Float) stack.pop();
Float one = (Float) stack.pop();
stack.push(one - two);
stack.push(this, one - two);
}
}

View File

@@ -39,7 +39,13 @@ public class GetField extends Instruction
NameAndType nat = entry.getNameAndType();
if (object == null)
{
frame.getStack().push(this, null);
return;
}
FieldInstance field = object.getField(nat);
frame.getStack().push(field.getValue());
frame.getStack().push(this, field.getValue());
}
}

View File

@@ -43,7 +43,7 @@ public class GetStatic extends Instruction
if (cf == null)
{
Object ovalue = nat.getStackObject();
frame.getStack().push(ovalue);
frame.getStack().push(this, ovalue);
return;
}
@@ -51,7 +51,7 @@ public class GetStatic extends Instruction
StaticFieldInstance fi = ci.findStaticField(nat);
Object ovalue = fi.getValue();
frame.getStack().push(ovalue);
frame.getStack().push(this, ovalue);
}
@Override

View File

@@ -24,6 +24,6 @@ public class I2B extends Instruction
assert obj instanceof Integer;
Integer i = (Integer) obj;
stack.push(i.byteValue());
stack.push(this, i.byteValue());
}
}

View File

@@ -24,6 +24,6 @@ public class I2C extends Instruction
assert obj instanceof Integer;
Integer i = (Integer) obj;
stack.push((char) i.intValue());
stack.push(this, (char) i.intValue());
}
}

View File

@@ -24,6 +24,6 @@ public class I2D extends Instruction
assert obj instanceof Integer;
Integer i = (Integer) obj;
stack.push(i.doubleValue());
stack.push(this, i.doubleValue());
}
}

View File

@@ -24,6 +24,6 @@ public class I2F extends Instruction
assert obj instanceof Integer;
Integer i = (Integer) obj;
stack.push(i.floatValue());
stack.push(this, i.floatValue());
}
}

View File

@@ -24,6 +24,6 @@ public class I2L extends Instruction
assert obj instanceof Integer;
Integer i = (Integer) obj;
stack.push(i.longValue());
stack.push(this, i.longValue());
}
}

View File

@@ -24,6 +24,6 @@ public class I2S extends Instruction
assert obj instanceof Integer;
Integer i = (Integer) obj;
stack.push(i.shortValue());
stack.push(this, i.shortValue());
}
}

View File

@@ -21,6 +21,6 @@ public class IALoad extends Instruction
int index = (int) stack.pop();
int[] array = (int[]) stack.pop();
stack.push(array[index]);
stack.push(this, array[index]);
}
}

View File

@@ -21,6 +21,6 @@ public class IAdd extends Instruction
Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop();
stack.push(one + two);
stack.push(this, one + two);
}
}

View File

@@ -20,6 +20,6 @@ public class IAnd extends Instruction
Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop();
stack.push(one & two);
stack.push(this, one & two);
}
}

View File

@@ -19,6 +19,6 @@ public class IConst_0 extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(0);
stack.push(this, 0);
}
}

View File

@@ -19,6 +19,6 @@ public class IConst_1 extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(1);
stack.push(this, 1);
}
}

View File

@@ -19,6 +19,6 @@ public class IConst_2 extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(2);
stack.push(this, 2);
}
}

View File

@@ -19,6 +19,6 @@ public class IConst_3 extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(3);
stack.push(this, 3);
}
}

View File

@@ -19,6 +19,6 @@ public class IConst_4 extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(4);
stack.push(this, 4);
}
}

View File

@@ -19,6 +19,6 @@ public class IConst_5 extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(5);
stack.push(this, 5);
}
}

View File

@@ -19,6 +19,6 @@ public class IConst_M1 extends Instruction
public void execute(Frame frame)
{
Stack stack = frame.getStack();
stack.push(-1);
stack.push(this, -1);
}
}

View File

@@ -21,6 +21,6 @@ public class IDiv extends Instruction
Double two = (Double) stack.pop();
Double one = (Double) stack.pop();
stack.push(one / two);
stack.push(this, one / two);
}
}

View File

@@ -25,6 +25,6 @@ public class ILoad extends Instruction
public void execute(Frame frame)
{
int i = (int) frame.getVariables().get(index);
frame.getStack().push(i);
frame.getStack().push(this, i);
}
}

View File

@@ -19,6 +19,6 @@ public class ILoad_0 extends Instruction
{
Object obj = frame.getVariables().get(0);
assert obj instanceof Integer;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -19,6 +19,6 @@ public class ILoad_1 extends Instruction
{
Object obj = frame.getVariables().get(1);
assert obj instanceof Integer;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -19,6 +19,6 @@ public class ILoad_2 extends Instruction
{
Object obj = frame.getVariables().get(2);
assert obj instanceof Integer;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -19,6 +19,6 @@ public class ILoad_3 extends Instruction
{
Object obj = frame.getVariables().get(3);
assert obj instanceof Integer;
frame.getStack().push(obj);
frame.getStack().push(this, obj);
}
}

View File

@@ -21,6 +21,6 @@ public class IMul extends Instruction
Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop();
stack.push(one * two);
stack.push(this, one * two);
}
}

View File

@@ -19,6 +19,6 @@ public class INeg extends Instruction
Stack stack = frame.getStack();
Integer value = (Integer) stack.pop();
stack.push(-value);
stack.push(this, -value);
}
}

View File

@@ -20,6 +20,6 @@ public class IOr extends Instruction
Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop();
stack.push(one | two);
stack.push(this, one | two);
}
}

View File

@@ -21,6 +21,6 @@ public class IRem extends Instruction
Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop();
stack.push(one % two);
stack.push(this, one % two);
}
}

View File

@@ -20,6 +20,6 @@ public class IShL extends Instruction
Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop();
stack.push(one << (two & 0x1F));
stack.push(this, one << (two & 0x1F));
}
}

View File

@@ -20,6 +20,6 @@ public class IShR extends Instruction
Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop();
stack.push(one >> (two & 0x1F));
stack.push(this, one >> (two & 0x1F));
}
}

View File

@@ -21,6 +21,6 @@ public class ISub extends Instruction
Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop();
stack.push(one - two);
stack.push(this, one - two);
}
}

View File

@@ -20,6 +20,6 @@ public class IUShR extends Instruction
Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop();
stack.push(one >>> (two & 0x1F));
stack.push(this, one >>> (two & 0x1F));
}
}

View File

@@ -20,6 +20,6 @@ public class IXor extends Instruction
Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop();
stack.push(one ^ two);
stack.push(this, one ^ two);
}
}

View File

@@ -36,13 +36,13 @@ public class InstanceOf extends Instruction
ObjectInstanceBase obj = (ObjectInstanceBase) e.getStack().pop();
if (obj == null)
{
e.getStack().push(0);
e.getStack().push(this, 0);
return;
}
ClassFile otherClass = thisClass.getGroup().findClass(clazz.getName());
boolean instanceOf = obj.getType().getClassFile().instanceOf(otherClass);
e.getStack().push(instanceOf ? 1 : 0);
e.getStack().push(this, instanceOf ? 1 : 0);
}
}

View File

@@ -1,8 +1,14 @@
package info.sigterm.deob.attributes.code.instructions;
import info.sigterm.deob.ClassFile;
import info.sigterm.deob.ConstantPool;
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.ClassInstance;
import info.sigterm.deob.execution.Frame;
import info.sigterm.deob.execution.ObjectInstance;
import info.sigterm.deob.pool.Method;
import java.io.DataInputStream;
import java.io.IOException;
@@ -20,4 +26,25 @@ public class InvokeSpecial extends Instruction
length += 2;
}
@Override
public void execute(Frame e)
{
ClassFile thisClass = this.getInstructions().getCode().getAttributes().getClassFile();
ConstantPool pool = thisClass.getPool();
Method method = (Method) pool.getEntry(index);
int count = method.getNameAndType().getNumberOfArgs();
ObjectInstance object = (ObjectInstance) e.getStack().pop();
ClassInstance objectType = object.getType();
Object[] args = new Object[count + 1];
args[0] = object;
for (int i = 1; i < count + 1; ++i)
args[i] = e.getStack().pop();
info.sigterm.deob.Method meth = objectType.getClassFile().findMethod(method.getNameAndType());
e.getPath().invoke(meth, args);
}
}

View File

@@ -1,8 +1,12 @@
package info.sigterm.deob.attributes.code.instructions;
import info.sigterm.deob.ClassFile;
import info.sigterm.deob.ConstantPool;
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.pool.Method;
import java.io.DataInputStream;
import java.io.IOException;
@@ -19,4 +23,24 @@ public class InvokeStatic extends Instruction
index = is.readUnsignedShort();
length += 2;
}
@Override
public void execute(Frame e)
{
ClassFile thisClass = this.getInstructions().getCode().getAttributes().getClassFile();
ConstantPool pool = thisClass.getPool();
Method method = (Method) pool.getEntry(index);
info.sigterm.deob.pool.Class clazz = method.getClassEntry();
ClassFile otherClass = thisClass.getGroup().findClass(clazz.getName());
int count = method.getNameAndType().getNumberOfArgs();
Object[] args = new Object[count];
for (int i = count - 1; i >= 0; --i)
args[i] = e.getStack().pop();
info.sigterm.deob.Method meth = otherClass.findMethod(method.getNameAndType());
e.getPath().invoke(meth, args);
}
}

View File

@@ -1,8 +1,14 @@
package info.sigterm.deob.attributes.code.instructions;
import info.sigterm.deob.ClassFile;
import info.sigterm.deob.ConstantPool;
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.ClassInstance;
import info.sigterm.deob.execution.Frame;
import info.sigterm.deob.execution.ObjectInstance;
import info.sigterm.deob.pool.Method;
import java.io.DataInputStream;
import java.io.IOException;
@@ -20,4 +26,40 @@ public class InvokeVirtual extends Instruction
length += 2;
}
@Override
public void execute(Frame e)
{
ClassFile thisClass = this.getInstructions().getCode().getAttributes().getClassFile();
ConstantPool pool = thisClass.getPool();
Method method = (Method) pool.getEntry(index);
int count = method.getNameAndType().getNumberOfArgs();
Object[] args = new Object[count + 1];
for (int i = count; i > 0; --i)
args[i] = e.getStack().pop();
ObjectInstance object = (ObjectInstance) e.getStack().pop();
if (object == null)
{
System.out.println("Invoke on a null object");
e.getStack().push(this, null);
return;
}
ClassInstance objectType = object.getType();
args[0] = object;
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);
//meth.getDescriptor()
return;
}
e.getPath().invoke(meth, args);
}
}

View File

@@ -24,6 +24,6 @@ public class L2D extends Instruction
assert obj instanceof Long;
Long l = (Long) obj;
stack.push(l.doubleValue());
stack.push(this, l.doubleValue());
}
}

View File

@@ -24,6 +24,6 @@ public class L2F extends Instruction
assert obj instanceof Long;
Long l = (Long) obj;
stack.push(l.floatValue());
stack.push(this, l.floatValue());
}
}

Some files were not shown because too many files have changed in this diff Show More