More execution, including getstatic
This commit is contained in:
@@ -70,6 +70,11 @@ public class ClassFile
|
||||
return pool;
|
||||
}
|
||||
|
||||
public Fields getFields()
|
||||
{
|
||||
return fields;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
Class entry = (Class) pool.getEntry(this_class);
|
||||
|
||||
@@ -10,6 +10,16 @@ import java.util.ArrayList;
|
||||
|
||||
public class Field
|
||||
{
|
||||
public static int ACC_PUBLIC = 0x0001;
|
||||
public static int ACC_PRIVATE = 0x0002;
|
||||
public static int ACC_PROTECTED = 0x0004;
|
||||
public static int ACC_STATIC = 0x0008;
|
||||
public static int ACC_FINAL = 0x0010;
|
||||
public static int ACC_VOLATILE = 0x0040;
|
||||
public static int ACC_TRANSIENT = 0x0080;
|
||||
public static int ACC_SYNTHETIC = 0x1000;
|
||||
public static int ACC_ENUM = 0x4000;
|
||||
|
||||
private Fields fields;
|
||||
|
||||
private short accessFlags;
|
||||
@@ -36,6 +46,11 @@ public class Field
|
||||
return fields;
|
||||
}
|
||||
|
||||
public short getAccessFlags()
|
||||
{
|
||||
return accessFlags;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
UTF8 u = (UTF8) fields.getClassFile().getPool().getEntry(nameIndex);
|
||||
@@ -48,6 +63,11 @@ public class Field
|
||||
return u.getValue();
|
||||
}
|
||||
|
||||
public Attributes getAttributes()
|
||||
{
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public void addReference(Instruction ins)
|
||||
{
|
||||
instructions.add(ins);
|
||||
|
||||
@@ -30,6 +30,11 @@ public class Fields
|
||||
return classFile;
|
||||
}
|
||||
|
||||
public Field[] getFields()
|
||||
{
|
||||
return fields;
|
||||
}
|
||||
|
||||
public Field findField(NameAndType nat)
|
||||
{
|
||||
for (Field f : fields)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package info.sigterm.deob.attributes;
|
||||
|
||||
import info.sigterm.deob.pool.PoolEntry;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -14,4 +16,9 @@ public class ConstantValue extends Attribute
|
||||
DataInputStream is = attributes.getStream();
|
||||
constantVlaueIndex = is.readUnsignedShort();
|
||||
}
|
||||
|
||||
public PoolEntry getValue()
|
||||
{
|
||||
return this.getAttributes().getClassFile().getPool().getEntry(constantVlaueIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,12 +93,12 @@ public enum InstructionType
|
||||
SASTORE(0x56, "sastore", Instruction.class),
|
||||
POP(0x57, "pop", Pop.class),
|
||||
POP2(0x58, "pop2", Pop2.class),
|
||||
DUP(0x59, "dup", Instruction.class),
|
||||
DUP_X1(0x5a, "dup_x1", Instruction.class),
|
||||
DUP_X2(0x5b, "dup_x2", Instruction.class),
|
||||
DUP2(0x5c, "dup2", Instruction.class),
|
||||
DUP2_X1(0x5d, "dup2_x1", Instruction.class),
|
||||
DUP2_X2(0x5e, "dup2_x2", Instruction.class),
|
||||
DUP(0x59, "dup", Dup.class),
|
||||
DUP_X1(0x5a, "dup_x1", Dup_X1.class),
|
||||
DUP_X2(0x5b, "dup_x2", Dup_X2.class),
|
||||
DUP2(0x5c, "dup2", Dup2.class),
|
||||
DUP2_X1(0x5d, "dup2_x1", Dup2_X1.class),
|
||||
DUP2_X2(0x5e, "dup2_x2", Dup2_X2.class),
|
||||
SWAP(0x5f, "swap", Instruction.class),
|
||||
IADD(0x60, "iadd", Instruction.class),
|
||||
LADD(0x61, "ladd", Instruction.class),
|
||||
@@ -137,26 +137,26 @@ public enum InstructionType
|
||||
IXOR(0x82, "ixor", Instruction.class),
|
||||
LXOR(0x83, "lxor", Instruction.class),
|
||||
IINC(0x84, "iinc", IInc.class),
|
||||
I2L(0x85, "i2l", Instruction.class),
|
||||
I2F(0x86, "i2f", Instruction.class),
|
||||
I2D(0x87, "i2d", Instruction.class),
|
||||
L2I(0x88, "l2i", Instruction.class),
|
||||
L2F(0x89, "l2f", Instruction.class),
|
||||
L2D(0x8a, "l2d", Instruction.class),
|
||||
F2I(0x8b, "f2i", Instruction.class),
|
||||
F2L(0x8c, "f2l", Instruction.class),
|
||||
F2D(0x8d, "f2d", Instruction.class),
|
||||
D2I(0x8e, "d2i", Instruction.class),
|
||||
D2L(0x8f, "d2l", Instruction.class),
|
||||
D2F(0x90, "d2f", Instruction.class),
|
||||
I2B(0x91, "i2b", Instruction.class),
|
||||
I2C(0x92, "i2c", Instruction.class),
|
||||
I2S(0x93, "i2s", Instruction.class),
|
||||
LCMP(0x94, "lcmp", Instruction.class),
|
||||
FCMPL(0x95, "fcmpl", Instruction.class),
|
||||
FCMPG(0x96, "fcmpg", Instruction.class),
|
||||
DCMPL(0x97, "dcmpl", Instruction.class),
|
||||
DCMPG(0x98, "dcmpg", Instruction.class),
|
||||
I2L(0x85, "i2l", I2L.class),
|
||||
I2F(0x86, "i2f", I2F.class),
|
||||
I2D(0x87, "i2d", I2D.class),
|
||||
L2I(0x88, "l2i", L2I.class),
|
||||
L2F(0x89, "l2f", L2F.class),
|
||||
L2D(0x8a, "l2d", L2D.class),
|
||||
F2I(0x8b, "f2i", F2I.class),
|
||||
F2L(0x8c, "f2l", F2L.class),
|
||||
F2D(0x8d, "f2d", F2D.class),
|
||||
D2I(0x8e, "d2i", D2I.class),
|
||||
D2L(0x8f, "d2l", D2L.class),
|
||||
D2F(0x90, "d2f", D2F.class),
|
||||
I2B(0x91, "i2b", I2B.class),
|
||||
I2C(0x92, "i2c", I2C.class),
|
||||
I2S(0x93, "i2s", I2S.class),
|
||||
LCMP(0x94, "lcmp", LCmp.class),
|
||||
FCMPL(0x95, "fcmpl", FCmpL.class),
|
||||
FCMPG(0x96, "fcmpg", FCmpG.class),
|
||||
DCMPL(0x97, "dcmpl", DCmpL.class),
|
||||
DCMPG(0x98, "dcmpg", DCmpG.class),
|
||||
IFEQ(0x99, "ifeq", Branch.class),
|
||||
IFNE(0x9a, "ifne", Branch.class),
|
||||
IFLT(0x9b, "iflt", Branch.class),
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class D2F extends Instruction
|
||||
{
|
||||
public D2F(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Double;
|
||||
|
||||
Double d = (Double) obj;
|
||||
stack.push(d.floatValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class D2I extends Instruction
|
||||
{
|
||||
public D2I(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Double;
|
||||
|
||||
Double d = (Double) obj;
|
||||
stack.push(d.intValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class D2L extends Instruction
|
||||
{
|
||||
public D2L(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Double;
|
||||
|
||||
Double d = (Double) obj;
|
||||
stack.push(d.longValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DCmpG extends Instruction
|
||||
{
|
||||
public DCmpG(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Double one = (Double) stack.pop();
|
||||
Double two = (Double) stack.pop();
|
||||
|
||||
if (one.isNaN() || two.isNaN())
|
||||
stack.push(1);
|
||||
else if (one > two)
|
||||
stack.push(1);
|
||||
else if (one < two)
|
||||
stack.push(-1);
|
||||
else
|
||||
stack.push(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DCmpL extends Instruction
|
||||
{
|
||||
public DCmpL(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Double one = (Double) stack.pop();
|
||||
Double two = (Double) stack.pop();
|
||||
|
||||
if (one.isNaN() || two.isNaN())
|
||||
stack.push(-1);
|
||||
else if (one > two)
|
||||
stack.push(1);
|
||||
else if (one < two)
|
||||
stack.push(-1);
|
||||
else
|
||||
stack.push(0);
|
||||
}
|
||||
}
|
||||
@@ -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 java.io.IOException;
|
||||
|
||||
public class Dup extends Instruction
|
||||
{
|
||||
public Dup(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Object obj = frame.getStack().pop();
|
||||
frame.getStack().push(obj);
|
||||
frame.getStack().push(obj);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Dup2 extends Instruction
|
||||
{
|
||||
public Dup2(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object one = stack.pop();
|
||||
Object two = null;
|
||||
if (!(one instanceof Double) && !(one instanceof Long))
|
||||
two = stack.pop();
|
||||
|
||||
if (!(one instanceof Double) && !(one instanceof Long))
|
||||
stack.push(two);
|
||||
stack.push(one);
|
||||
|
||||
if (!(one instanceof Double) && !(one instanceof Long))
|
||||
stack.push(two);
|
||||
stack.push(one);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Dup2_X1 extends Instruction
|
||||
{
|
||||
public Dup2_X1(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object one = stack.pop();
|
||||
Object two = null;
|
||||
if (!(one instanceof Double) && !(one instanceof Long))
|
||||
two = stack.pop();
|
||||
Object three = stack.pop();
|
||||
|
||||
if (!(one instanceof Double) && !(one instanceof Long))
|
||||
stack.push(two);
|
||||
stack.push(one);
|
||||
|
||||
stack.push(three);
|
||||
|
||||
if (!(one instanceof Double) && !(one instanceof Long))
|
||||
stack.push(two);
|
||||
stack.push(one);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Dup2_X2 extends Instruction
|
||||
{
|
||||
public Dup2_X2(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object one = stack.pop();
|
||||
Object two = null;
|
||||
if (!(one instanceof Double) && !(one instanceof Long))
|
||||
two = stack.pop();
|
||||
Object three = stack.pop();
|
||||
Object four = null;
|
||||
if (!(three instanceof Double) && !(three instanceof Long))
|
||||
four = stack.pop();
|
||||
|
||||
if (!(one instanceof Double) && !(one instanceof Long))
|
||||
stack.push(two);
|
||||
stack.push(one);
|
||||
|
||||
if (!(three instanceof Double) && !(three instanceof Long))
|
||||
stack.push(four);
|
||||
stack.push(three);
|
||||
|
||||
if (!(one instanceof Double) && !(one instanceof Long))
|
||||
stack.push(two);
|
||||
stack.push(one);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Dup_X1 extends Instruction
|
||||
{
|
||||
public Dup_X1(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object one = stack.pop();
|
||||
Object two = stack.pop();
|
||||
|
||||
stack.push(one);
|
||||
stack.push(two);
|
||||
stack.push(one);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Dup_X2 extends Instruction
|
||||
{
|
||||
public Dup_X2(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object one = stack.pop();
|
||||
Object two = stack.pop();
|
||||
Object three = null;
|
||||
if (!(two instanceof Double) && !(two instanceof Long))
|
||||
three = stack.pop();
|
||||
|
||||
stack.push(one);
|
||||
if (!(two instanceof Double) && !(two instanceof Long))
|
||||
stack.push(three);
|
||||
stack.push(two);
|
||||
stack.push(one);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class F2D extends Instruction
|
||||
{
|
||||
public F2D(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Float;
|
||||
|
||||
Float f = (Float) obj;
|
||||
stack.push(f.doubleValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class F2I extends Instruction
|
||||
{
|
||||
public F2I(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Float;
|
||||
|
||||
Float f = (Float) obj;
|
||||
stack.push(f.intValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class F2L extends Instruction
|
||||
{
|
||||
public F2L(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Float;
|
||||
|
||||
Float f = (Float) obj;
|
||||
stack.push(f.longValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class FCmpG extends Instruction
|
||||
{
|
||||
public FCmpG(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Float one = (Float) stack.pop();
|
||||
Float two = (Float) stack.pop();
|
||||
|
||||
if (one.isNaN() || two.isNaN())
|
||||
stack.push(1);
|
||||
else if (one > two)
|
||||
stack.push(1);
|
||||
else if (one < two)
|
||||
stack.push(-1);
|
||||
else
|
||||
stack.push(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class FCmpL extends Instruction
|
||||
{
|
||||
public FCmpL(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Float one = (Float) stack.pop();
|
||||
Float two = (Float) stack.pop();
|
||||
|
||||
if (one.isNaN() || two.isNaN())
|
||||
stack.push(-1);
|
||||
else if (one > two)
|
||||
stack.push(1);
|
||||
else if (one < two)
|
||||
stack.push(-1);
|
||||
else
|
||||
stack.push(0);
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,17 @@ package info.sigterm.deob.attributes.code.instructions;
|
||||
|
||||
import info.sigterm.deob.ClassFile;
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
import info.sigterm.deob.attributes.ConstantValue;
|
||||
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.StaticFieldInstance;
|
||||
import info.sigterm.deob.pool.Class;
|
||||
import info.sigterm.deob.pool.Field;
|
||||
import info.sigterm.deob.pool.NameAndType;
|
||||
import info.sigterm.deob.pool.PoolEntry;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -25,6 +30,35 @@ public class GetStatic extends Instruction
|
||||
length += 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
ClassFile thisClass = this.getInstructions().getCode().getAttributes().getClassFile();
|
||||
|
||||
ConstantPool pool = thisClass.getPool();
|
||||
Field entry = (Field) pool.getEntry(index);
|
||||
|
||||
Class clazz = entry.getClassEntry();
|
||||
NameAndType nat = entry.getNameAndType();
|
||||
|
||||
ClassFile cf = thisClass.getGroup().findClass(clazz.getName());
|
||||
if (cf == null)
|
||||
{
|
||||
Object ovalue = nat.getStackObject();
|
||||
frame.getStack().push(ovalue);
|
||||
return;
|
||||
}
|
||||
|
||||
ClassInstance ci = frame.getPath().getClassInstance(cf);
|
||||
StaticFieldInstance fi = ci.findStaticField(nat);
|
||||
ConstantValue value = fi.getValue();
|
||||
|
||||
PoolEntry pe = value.getValue();
|
||||
Object ovalue = pe.getObject();
|
||||
|
||||
frame.getStack().push(ovalue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildInstructionGraph()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class I2B extends Instruction
|
||||
{
|
||||
public I2B(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Integer;
|
||||
|
||||
Integer i = (Integer) obj;
|
||||
stack.push(i.byteValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class I2C extends Instruction
|
||||
{
|
||||
public I2C(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Integer;
|
||||
|
||||
Integer i = (Integer) obj;
|
||||
stack.push((char) i.intValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class I2D extends Instruction
|
||||
{
|
||||
public I2D(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Integer;
|
||||
|
||||
Integer i = (Integer) obj;
|
||||
stack.push(i.doubleValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class I2F extends Instruction
|
||||
{
|
||||
public I2F(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Integer;
|
||||
|
||||
Integer i = (Integer) obj;
|
||||
stack.push(i.floatValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class I2L extends Instruction
|
||||
{
|
||||
public I2L(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Integer;
|
||||
|
||||
Integer i = (Integer) obj;
|
||||
stack.push(i.longValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class I2S extends Instruction
|
||||
{
|
||||
public I2S(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Integer;
|
||||
|
||||
Integer i = (Integer) obj;
|
||||
stack.push(i.shortValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class L2D extends Instruction
|
||||
{
|
||||
public L2D(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Long;
|
||||
|
||||
Long l = (Long) obj;
|
||||
stack.push(l.doubleValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class L2F extends Instruction
|
||||
{
|
||||
public L2F(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Long;
|
||||
|
||||
Long l = (Long) obj;
|
||||
stack.push(l.floatValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class L2I extends Instruction
|
||||
{
|
||||
public L2I(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Object obj = stack.pop();
|
||||
assert obj instanceof Long;
|
||||
|
||||
Long l = (Long) obj;
|
||||
stack.push(l.intValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
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.Stack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class LCmp extends Instruction
|
||||
{
|
||||
public LCmp(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
Long one = (Long) stack.pop();
|
||||
Long two = (Long) stack.pop();
|
||||
|
||||
if (one > two)
|
||||
stack.push(1);
|
||||
else if (one < two)
|
||||
stack.push(-1);
|
||||
else
|
||||
stack.push(0);
|
||||
}
|
||||
}
|
||||
54
src/main/java/info/sigterm/deob/execution/ClassInstance.java
Normal file
54
src/main/java/info/sigterm/deob/execution/ClassInstance.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package info.sigterm.deob.execution;
|
||||
|
||||
import info.sigterm.deob.ClassFile;
|
||||
import info.sigterm.deob.Field;
|
||||
import info.sigterm.deob.Fields;
|
||||
import info.sigterm.deob.attributes.AttributeType;
|
||||
import info.sigterm.deob.attributes.Attributes;
|
||||
import info.sigterm.deob.attributes.ConstantValue;
|
||||
import info.sigterm.deob.pool.NameAndType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ClassInstance
|
||||
{
|
||||
private Path path;
|
||||
private ClassFile clazz;
|
||||
private ArrayList<StaticFieldInstance> fields = new ArrayList<StaticFieldInstance>();
|
||||
|
||||
public ClassInstance(Path path, ClassFile clazz)
|
||||
{
|
||||
this.path = path;
|
||||
this.clazz = clazz;
|
||||
|
||||
/* initialize static fields */
|
||||
Fields fields = clazz.getFields();
|
||||
for (Field field : fields.getFields())
|
||||
if ((field.getAccessFlags() & Field.ACC_STATIC) != 0)
|
||||
{
|
||||
Attributes attributes = field.getAttributes();
|
||||
ConstantValue cv = (ConstantValue) attributes.findType(AttributeType.CONSTANT_VALUE);
|
||||
|
||||
StaticFieldInstance fi = new StaticFieldInstance(field, cv);
|
||||
this.fields.add(fi);
|
||||
}
|
||||
}
|
||||
|
||||
public Path getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public ClassFile getClassFile()
|
||||
{
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public StaticFieldInstance findStaticField(NameAndType nat)
|
||||
{
|
||||
for (StaticFieldInstance f : fields)
|
||||
if (f.getField().getName().equals(nat.getName()) && f.getField().getDescriptor().equals(nat.getDescriptor()))
|
||||
return f;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,11 @@ public class Frame
|
||||
variables = new Variables(code.getMaxLocals());
|
||||
}
|
||||
|
||||
public Path getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public Stack getStack()
|
||||
{
|
||||
return stack;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package info.sigterm.deob.execution;
|
||||
|
||||
public class ObjectInstance
|
||||
{
|
||||
private ClassInstance type;
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
package info.sigterm.deob.execution;
|
||||
|
||||
import info.sigterm.deob.ClassFile;
|
||||
import info.sigterm.deob.Method;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Path
|
||||
{
|
||||
private Execution execution;
|
||||
private ArrayList<ClassInstance> classes = new ArrayList<ClassInstance>();
|
||||
private java.util.Stack<Frame> frames = new java.util.Stack<Frame>(); // current execution frames
|
||||
|
||||
public Path(Execution execution)
|
||||
@@ -12,6 +16,28 @@ public class Path
|
||||
this.execution = execution;
|
||||
}
|
||||
|
||||
public Execution getExecution()
|
||||
{
|
||||
return execution;
|
||||
}
|
||||
|
||||
public ClassInstance getClassInstance(ClassFile clazz)
|
||||
{
|
||||
for (ClassInstance cl : classes)
|
||||
if (cl.getClassFile() == clazz)
|
||||
return cl;
|
||||
|
||||
/* load parent */
|
||||
ClassFile parent = clazz.getParent();
|
||||
if (parent != null)
|
||||
getClassInstance(parent);
|
||||
|
||||
ClassInstance cl = new ClassInstance(this, clazz);
|
||||
classes.add(cl);
|
||||
|
||||
return cl;
|
||||
}
|
||||
|
||||
public void init(Method method, Object[] args)
|
||||
{
|
||||
Frame f = new Frame(this, method);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package info.sigterm.deob.execution;
|
||||
|
||||
import info.sigterm.deob.Field;
|
||||
import info.sigterm.deob.attributes.ConstantValue;
|
||||
|
||||
public class StaticFieldInstance
|
||||
{
|
||||
private Field field;
|
||||
private ConstantValue value;
|
||||
|
||||
public StaticFieldInstance(Field field, ConstantValue value)
|
||||
{
|
||||
this.field = field;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Field getField()
|
||||
{
|
||||
return field;
|
||||
}
|
||||
|
||||
public ConstantValue getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,10 @@ public class Double extends PoolEntry
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,10 @@ public class Float extends PoolEntry
|
||||
|
||||
value = is.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,10 @@ public class Integer extends PoolEntry
|
||||
|
||||
value = is.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,10 @@ public class Long extends PoolEntry
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,30 @@ public class NameAndType extends PoolEntry
|
||||
UTF8 u = (UTF8) this.getPool().getEntry(descriptorIndex);
|
||||
return u.getValue();
|
||||
}
|
||||
|
||||
public Object getStackObject()
|
||||
{
|
||||
java.lang.String desc = getDescriptor();
|
||||
switch (desc)
|
||||
{
|
||||
case "B":
|
||||
return (byte) 0;
|
||||
case "C":
|
||||
return (char) 0;
|
||||
case "I":
|
||||
return 0;
|
||||
case "S":
|
||||
return null;
|
||||
case "Z":
|
||||
return false;
|
||||
case "D":
|
||||
return 0d;
|
||||
case "F":
|
||||
return 0f;
|
||||
case "L":
|
||||
return 0L;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,4 +22,9 @@ public abstract class PoolEntry
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Object getObject()
|
||||
{
|
||||
throw new RuntimeException("No getObject implemented for " + this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,10 @@ public class String extends PoolEntry
|
||||
|
||||
stringIndex = is.readUnsignedShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject()
|
||||
{
|
||||
return stringIndex;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user