More execution, including getstatic

This commit is contained in:
Adam
2014-12-02 15:36:06 -05:00
parent 37dac95ee0
commit 81095be5da
44 changed files with 1091 additions and 26 deletions

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

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 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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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()
{

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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);
}
}