More execution work
This commit is contained in:
@@ -20,10 +20,13 @@ public class AAStore extends Instruction
|
||||
{
|
||||
Stack stack = frame.getStack();
|
||||
|
||||
ObjectInstance value = (ObjectInstance) stack.pop(); // Strings are objects too, so this cast fails
|
||||
Object value = stack.pop();
|
||||
int index = (int) stack.pop();
|
||||
ArrayInstance array = (ArrayInstance) stack.pop();
|
||||
|
||||
if (array == null)
|
||||
return;
|
||||
|
||||
array.put(value, index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ public class AStore extends Instruction
|
||||
public void execute(Frame frame)
|
||||
{
|
||||
Object obj = frame.getStack().pop();
|
||||
assert obj != null;
|
||||
frame.getVariables().set(index, obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import info.sigterm.deob.execution.ClassInstance;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
import info.sigterm.deob.execution.ObjectInstance;
|
||||
import info.sigterm.deob.pool.Method;
|
||||
import info.sigterm.deob.pool.PoolEntry;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -36,15 +37,31 @@ public class InvokeSpecial extends Instruction
|
||||
int count = method.getNameAndType().getNumberOfArgs();
|
||||
|
||||
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();
|
||||
|
||||
if (object == null)
|
||||
{
|
||||
System.out.println("invokespecial for nonexistant function " + method.getNameAndType().getName() + " " + method.getNameAndType().getDescriptor() + " on " + method.getClassEntry().getName() + " (void: " + !method.getNameAndType().isNonVoid() + ")");
|
||||
if (method.getNameAndType().isNonVoid())
|
||||
e.getStack().push(this, null);
|
||||
return;
|
||||
}
|
||||
|
||||
ClassInstance objectType = object.getType();
|
||||
info.sigterm.deob.Method meth = objectType.getClassFile().findMethod(method.getNameAndType());
|
||||
e.getPath().invoke(meth, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc(Frame frame)
|
||||
{
|
||||
ClassFile thisClass = this.getInstructions().getCode().getAttributes().getClassFile();
|
||||
Method method = (Method) thisClass.getPool().getEntry(index);
|
||||
|
||||
return "invokespecial " + method.getNameAndType().getDescriptor() + " on " + method.getClassEntry().getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class InvokeVirtual extends Instruction
|
||||
ObjectInstance object = (ObjectInstance) e.getStack().pop();
|
||||
if (object == null)
|
||||
{
|
||||
System.out.println("Invoke on a null object");
|
||||
System.out.println("invokevirtual on null object for method " + method.getNameAndType().getName() + " " + method.getNameAndType().getDescriptor() + " on " + method.getClassEntry().getName());
|
||||
e.getStack().push(this, null);
|
||||
return;
|
||||
}
|
||||
@@ -56,7 +56,6 @@ public class InvokeVirtual extends Instruction
|
||||
{
|
||||
System.out.println("Unknown method " + method.getNameAndType().getName() + " " + method.getNameAndType().getDescriptor() + " in " + objectType.getClassFile().getName());
|
||||
e.getStack().push(this, null);
|
||||
//meth.getDescriptor()
|
||||
return;
|
||||
}
|
||||
e.getPath().invoke(meth, args);
|
||||
|
||||
Reference in New Issue
Block a user