Some thinking about execution
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package info.sigterm.deob;
|
package info.sigterm.deob;
|
||||||
|
|
||||||
|
import info.sigterm.deob.attributes.Attributes;
|
||||||
import info.sigterm.deob.pool.Class;
|
import info.sigterm.deob.pool.Class;
|
||||||
import info.sigterm.deob.pool.UTF8;
|
import info.sigterm.deob.pool.UTF8;
|
||||||
|
|
||||||
@@ -81,7 +82,6 @@ public class ClassFile
|
|||||||
if (other == null)
|
if (other == null)
|
||||||
return; // inherits from a class not in my group
|
return; // inherits from a class not in my group
|
||||||
|
|
||||||
assert other != null;
|
|
||||||
assert other != this;
|
assert other != this;
|
||||||
|
|
||||||
this.parent = other;
|
this.parent = other;
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package info.sigterm.deob;
|
package info.sigterm.deob;
|
||||||
|
|
||||||
|
import info.sigterm.deob.attributes.Attributes;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class Field
|
public class Field
|
||||||
{
|
{
|
||||||
private Fields fields;
|
private Fields fields;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package info.sigterm.deob;
|
package info.sigterm.deob;
|
||||||
|
|
||||||
|
import info.sigterm.deob.attributes.AttributeType;
|
||||||
|
import info.sigterm.deob.attributes.Attributes;
|
||||||
|
import info.sigterm.deob.attributes.Code;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class Method
|
public class Method
|
||||||
{
|
{
|
||||||
private Methods methods;
|
private Methods methods;
|
||||||
|
|
||||||
@@ -28,4 +32,9 @@ class Method
|
|||||||
{
|
{
|
||||||
return methods;
|
return methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Code getCode()
|
||||||
|
{
|
||||||
|
return (Code) attributes.findType(AttributeType.CODE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package info.sigterm.deob.attributes;
|
package info.sigterm.deob.attributes;
|
||||||
|
|
||||||
import info.sigterm.deob.Attributes;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@@ -25,6 +23,11 @@ public class Attribute
|
|||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AttributeType getType()
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
public int getLength()
|
public int getLength()
|
||||||
{
|
{
|
||||||
return length;
|
return length;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package info.sigterm.deob;
|
package info.sigterm.deob.attributes;
|
||||||
|
|
||||||
import info.sigterm.deob.attributes.Attribute;
|
import info.sigterm.deob.ClassFile;
|
||||||
import info.sigterm.deob.attributes.AttributeType;
|
import info.sigterm.deob.Field;
|
||||||
import info.sigterm.deob.attributes.Code;
|
import info.sigterm.deob.Method;
|
||||||
import info.sigterm.deob.pool.UTF8;
|
import info.sigterm.deob.pool.UTF8;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
@@ -19,21 +19,21 @@ public class Attributes
|
|||||||
private int count;
|
private int count;
|
||||||
private Attribute[] attributes;
|
private Attribute[] attributes;
|
||||||
|
|
||||||
Attributes(ClassFile cf) throws IOException
|
public Attributes(ClassFile cf) throws IOException
|
||||||
{
|
{
|
||||||
classFile = cf;
|
classFile = cf;
|
||||||
|
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
Attributes(Field f) throws IOException
|
public Attributes(Field f) throws IOException
|
||||||
{
|
{
|
||||||
field = f;
|
field = f;
|
||||||
|
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
Attributes(Method m) throws IOException
|
public Attributes(Method m) throws IOException
|
||||||
{
|
{
|
||||||
method = m;
|
method = m;
|
||||||
|
|
||||||
@@ -47,6 +47,14 @@ public class Attributes
|
|||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Attribute findType(AttributeType type)
|
||||||
|
{
|
||||||
|
for (Attribute a : attributes)
|
||||||
|
if (a.getType() == type)
|
||||||
|
return a;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public ClassFile getClassFile()
|
public ClassFile getClassFile()
|
||||||
{
|
{
|
||||||
if (classFile != null)
|
if (classFile != null)
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package info.sigterm.deob.attributes;
|
package info.sigterm.deob.attributes;
|
||||||
|
|
||||||
import info.sigterm.deob.Attributes;
|
|
||||||
import info.sigterm.deob.attributes.code.Exceptions;
|
import info.sigterm.deob.attributes.code.Exceptions;
|
||||||
import info.sigterm.deob.attributes.code.Instructions;
|
import info.sigterm.deob.attributes.code.Instructions;
|
||||||
|
|
||||||
@@ -29,4 +28,14 @@ public class Code extends Attribute
|
|||||||
exceptions = new Exceptions(this);
|
exceptions = new Exceptions(this);
|
||||||
attributes = new Attributes(this);
|
attributes = new Attributes(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxStack()
|
||||||
|
{
|
||||||
|
return getMaxStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxLocals()
|
||||||
|
{
|
||||||
|
return maxLocals;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package info.sigterm.deob.attributes;
|
package info.sigterm.deob.attributes;
|
||||||
|
|
||||||
import info.sigterm.deob.Attributes;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package info.sigterm.deob.attributes;
|
package info.sigterm.deob.attributes;
|
||||||
|
|
||||||
import info.sigterm.deob.Attributes;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package info.sigterm.deob.attributes.code;
|
package info.sigterm.deob.attributes.code;
|
||||||
|
|
||||||
|
import info.sigterm.deob.execution.Execution;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Instruction
|
public class Instruction
|
||||||
@@ -43,4 +45,8 @@ public class Instruction
|
|||||||
public void buildJumpGraph()
|
public void buildJumpGraph()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void execute(Execution e)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,5 +19,4 @@ public class InvokeStatic extends Instruction
|
|||||||
index = is.readUnsignedShort();
|
index = is.readUnsignedShort();
|
||||||
length += 2;
|
length += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/main/java/info/sigterm/deob/execution/Execution.java
Normal file
19
src/main/java/info/sigterm/deob/execution/Execution.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package info.sigterm.deob.execution;
|
||||||
|
|
||||||
|
import info.sigterm.deob.ClassGroup;
|
||||||
|
import info.sigterm.deob.pool.Method;
|
||||||
|
|
||||||
|
public class Execution
|
||||||
|
{
|
||||||
|
private ClassGroup group;
|
||||||
|
private java.util.Stack<Frame> frames = new java.util.Stack<Frame>();
|
||||||
|
|
||||||
|
public Execution(ClassGroup group)
|
||||||
|
{
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(Method method, Object... args)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/main/java/info/sigterm/deob/execution/Frame.java
Normal file
23
src/main/java/info/sigterm/deob/execution/Frame.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package info.sigterm.deob.execution;
|
||||||
|
|
||||||
|
import info.sigterm.deob.Method;
|
||||||
|
import info.sigterm.deob.attributes.Code;
|
||||||
|
|
||||||
|
public class Frame
|
||||||
|
{
|
||||||
|
private Execution execution;
|
||||||
|
private Method method;
|
||||||
|
private Stack stack;
|
||||||
|
private Variables variables;
|
||||||
|
|
||||||
|
public Frame(Execution execution, Method method)
|
||||||
|
{
|
||||||
|
Code code = method.getCode();
|
||||||
|
|
||||||
|
this.execution = execution;
|
||||||
|
this.method = method;
|
||||||
|
|
||||||
|
stack = new Stack(code.getMaxStack());
|
||||||
|
variables = new Variables(code.getMaxLocals());
|
||||||
|
}
|
||||||
|
}
|
||||||
28
src/main/java/info/sigterm/deob/execution/Stack.java
Normal file
28
src/main/java/info/sigterm/deob/execution/Stack.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package info.sigterm.deob.execution;
|
||||||
|
|
||||||
|
public class Stack
|
||||||
|
{
|
||||||
|
private int size;
|
||||||
|
private Object[] stack;
|
||||||
|
|
||||||
|
public Stack(int sz)
|
||||||
|
{
|
||||||
|
stack = new Object[sz];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void push(Object obj)
|
||||||
|
{
|
||||||
|
if (size == stack.length)
|
||||||
|
throw new RuntimeException("Stack overflow");
|
||||||
|
|
||||||
|
stack[size++] = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object pop()
|
||||||
|
{
|
||||||
|
if (size <= 0)
|
||||||
|
throw new RuntimeException("Stack underflow");
|
||||||
|
|
||||||
|
return stack[--size];
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/main/java/info/sigterm/deob/execution/Variables.java
Normal file
11
src/main/java/info/sigterm/deob/execution/Variables.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package info.sigterm.deob.execution;
|
||||||
|
|
||||||
|
public class Variables
|
||||||
|
{
|
||||||
|
private Object variables;
|
||||||
|
|
||||||
|
public Variables(int sz)
|
||||||
|
{
|
||||||
|
variables = new Object[sz];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user