getObject on String should really just return the string

This commit is contained in:
Adam
2015-01-26 02:25:42 -05:00
parent 55dca4fa9b
commit cec4f0ac59
7 changed files with 34 additions and 2 deletions

View File

@@ -36,6 +36,11 @@ public abstract class Instruction
{
return length;
}
public String getDesc(Frame frame)
{
return null;
}
protected void addJump(int offset)
{

View File

@@ -20,7 +20,7 @@ public class AAStore extends Instruction
{
Stack stack = frame.getStack();
ObjectInstance value = (ObjectInstance) stack.pop();
ObjectInstance value = (ObjectInstance) stack.pop(); // Strings are objects too, so this cast fails
int index = (int) stack.pop();
ArrayInstance array = (ArrayInstance) stack.pop();

View File

@@ -40,6 +40,13 @@ public class InvokeStatic extends Instruction
for (int i = count - 1; i >= 0; --i)
args[i] = e.getStack().pop();
if (otherClass == null)
{
System.out.println("invokestatic for nonexistant class " + clazz.getName());
e.getStack().push(this, null);
return;
}
info.sigterm.deob.Method meth = otherClass.findMethod(method.getNameAndType());
e.getPath().invoke(meth, args);
}

View File

@@ -30,4 +30,14 @@ public class LDC_W extends Instruction
PoolEntry entry = thisClass.getPool().getEntry(index);
frame.getStack().push(this, entry.getObject());
}
@Override
public String getDesc(Frame frame)
{
ClassFile thisClass = this.getInstructions().getCode().getAttributes().getClassFile();
PoolEntry entry = thisClass.getPool().getEntry(index);
return "ldc_w " + entry.getObject();
}
}

View File

@@ -49,6 +49,10 @@ public class Frame
Instruction i = ins.findInstruction(pc);
String desc = i.getDesc(this);
if (desc != null)
System.out.println(desc);
try
{
i.execute(this);

View File

@@ -21,6 +21,6 @@ public class String extends PoolEntry
@Override
public Object getObject()
{
return stringIndex;
return this.getPool().getEntry(stringIndex).getObject();
}
}

View File

@@ -42,6 +42,12 @@ public class UTF8 extends PoolEntry
}
public java.lang.String getValue()
{
return (java.lang.String) getObject();
}
@Override
public Object getObject()
{
return sb.toString();
}