Invokeinterface, among others
This commit is contained in:
@@ -188,7 +188,6 @@ public enum InstructionType
|
||||
INVOKESPECIAL(0xb7, "invokespecial", InvokeSpecial.class),
|
||||
INVOKESTATIC(0xb8, "invokestatic", InvokeStatic.class),
|
||||
INVOKEINTERFACE(0xb9, "invokeinterface", InvokeInterface.class),
|
||||
INVOKEDYNAMIC(0xba, "invokedynamic", InvokeDynamic.class),
|
||||
NEW(0xbb, "new", New.class),
|
||||
NEWARRAY(0xbc, "newarray", NewArray.class),
|
||||
ANEWARRAY(0xbd, "anewarray", ANewArray.class),
|
||||
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -12,7 +11,6 @@ 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;
|
||||
@@ -51,10 +49,7 @@ public class GetStatic extends Instruction
|
||||
|
||||
ClassInstance ci = frame.getPath().getClassInstance(cf);
|
||||
StaticFieldInstance fi = ci.findStaticField(nat);
|
||||
ConstantValue value = fi.getValue();
|
||||
|
||||
PoolEntry pe = value.getValue();
|
||||
Object ovalue = pe.getObject();
|
||||
Object ovalue = fi.getValue();
|
||||
|
||||
frame.getStack().push(ovalue);
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
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 java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class InvokeDynamic extends Instruction
|
||||
{
|
||||
private int index;
|
||||
|
||||
public InvokeDynamic(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
|
||||
DataInputStream is = instructions.getCode().getAttributes().getStream();
|
||||
index = is.readUnsignedShort();
|
||||
is.skip(2);
|
||||
length += 4;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
package info.sigterm.deob.attributes.code.instructions;
|
||||
|
||||
import info.sigterm.deob.ClassFile;
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
import info.sigterm.deob.Method;
|
||||
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.InterfaceMethod;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -23,4 +30,24 @@ public class InvokeInterface extends Instruction
|
||||
length += 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame e)
|
||||
{
|
||||
ClassFile thisClass = this.getInstructions().getCode().getAttributes().getClassFile();
|
||||
|
||||
ConstantPool pool = thisClass.getPool();
|
||||
InterfaceMethod method = (InterfaceMethod) pool.getEntry(index);
|
||||
|
||||
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();
|
||||
|
||||
Method meth = objectType.getClassFile().findMethod(method.getNameAndType());
|
||||
e.getPath().invoke(meth, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.Frame;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -20,4 +21,38 @@ public class NewArray extends Instruction
|
||||
length += 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame e)
|
||||
{
|
||||
int count = (int) e.getStack().pop();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 4:
|
||||
e.getStack().push(new boolean[count]);
|
||||
break;
|
||||
case 5:
|
||||
e.getStack().push(new char[count]);
|
||||
break;
|
||||
case 6:
|
||||
e.getStack().push(new float[count]);
|
||||
break;
|
||||
case 7:
|
||||
e.getStack().push(new double[count]);
|
||||
break;
|
||||
case 8:
|
||||
e.getStack().push(new byte[count]);
|
||||
break;
|
||||
case 9:
|
||||
e.getStack().push(new short[count]);
|
||||
break;
|
||||
case 10:
|
||||
e.getStack().push(new int[count]);
|
||||
break;
|
||||
case 11:
|
||||
e.getStack().push(new long[count]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
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.FieldInstance;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
import info.sigterm.deob.execution.ObjectInstance;
|
||||
import info.sigterm.deob.pool.Field;
|
||||
import info.sigterm.deob.pool.NameAndType;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -20,4 +27,20 @@ public class PutField extends Instruction
|
||||
length += 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame e)
|
||||
{
|
||||
ClassFile thisClass = this.getInstructions().getCode().getAttributes().getClassFile();
|
||||
|
||||
ConstantPool pool = thisClass.getPool();
|
||||
Field entry = (Field) pool.getEntry(index);
|
||||
NameAndType nat = entry.getNameAndType();
|
||||
|
||||
ObjectInstance object = (ObjectInstance) e.getStack().pop();
|
||||
Object value = e.getStack().pop();
|
||||
|
||||
FieldInstance field = object.getField(nat);
|
||||
field.setValue(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
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.StaticFieldInstance;
|
||||
import info.sigterm.deob.pool.Class;
|
||||
import info.sigterm.deob.pool.Field;
|
||||
import info.sigterm.deob.pool.NameAndType;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -20,4 +28,25 @@ public class PutStatic extends Instruction
|
||||
length += 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame e)
|
||||
{
|
||||
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();
|
||||
|
||||
Object value = e.getStack().pop();
|
||||
|
||||
ClassFile cf = thisClass.getGroup().findClass(clazz.getName());
|
||||
if (cf == null)
|
||||
return;
|
||||
|
||||
ClassInstance ci = e.getPath().getClassInstance(cf);
|
||||
StaticFieldInstance fi = ci.findStaticField(nat);
|
||||
fi.setField(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user