More execution, including getstatic
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user