Remove unused parameters
This commit is contained in:
@@ -19,6 +19,13 @@ import java.io.IOException;
|
||||
public class ALoad extends Instruction implements LVTInstruction, WideInstruction
|
||||
{
|
||||
private int index;
|
||||
|
||||
public ALoad(Instructions instructions, int index)
|
||||
{
|
||||
super(instructions, InstructionType.ALOAD, 0);
|
||||
this.index = index;
|
||||
++length;
|
||||
}
|
||||
|
||||
public ALoad(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
@@ -39,9 +46,9 @@ public class ALoad extends Instruction implements LVTInstruction, WideInstructio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(index);
|
||||
}
|
||||
|
||||
@@ -74,9 +81,16 @@ public class ALoad extends Instruction implements LVTInstruction, WideInstructio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWide(DataOutputStream out, int pc) throws IOException
|
||||
public void writeWide(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
index = idx;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,10 @@ public class ALoad_0 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new ALoad(this.getInstructions(), idx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,10 @@ public class ALoad_1 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new ALoad(this.getInstructions(), idx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,12 @@ public class ALoad_2 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new ALoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -39,7 +39,13 @@ public class ALoad_3 extends Instruction implements LVTInstruction
|
||||
@Override
|
||||
public int getVariableIndex()
|
||||
{
|
||||
return 0;
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new ALoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,9 +28,9 @@ public class ANewArray extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
|
||||
out.writeShort(this.getPool().make(clazz));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,13 @@ import java.io.IOException;
|
||||
public class AStore extends Instruction implements LVTInstruction, WideInstruction
|
||||
{
|
||||
private int index;
|
||||
|
||||
public AStore(Instructions instructions, int index)
|
||||
{
|
||||
super(instructions, InstructionType.ASTORE, 0);
|
||||
this.index = index;
|
||||
++length;
|
||||
}
|
||||
|
||||
public AStore(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
@@ -39,9 +46,9 @@ public class AStore extends Instruction implements LVTInstruction, WideInstructi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(index);
|
||||
}
|
||||
|
||||
@@ -73,9 +80,16 @@ public class AStore extends Instruction implements LVTInstruction, WideInstructi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWide(DataOutputStream out, int pc) throws IOException
|
||||
public void writeWide(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
index = idx;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,12 @@ public class AStore_0 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new AStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -40,6 +40,12 @@ public class AStore_1 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new AStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -40,6 +40,12 @@ public class AStore_2 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new AStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -40,6 +40,12 @@ public class AStore_3 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new AStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -26,9 +26,9 @@ public class BiPush extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(b);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ public class CheckCast extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(clazz));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,13 @@ import java.io.IOException;
|
||||
public class DLoad extends Instruction implements LVTInstruction, WideInstruction
|
||||
{
|
||||
private int index;
|
||||
|
||||
public DLoad(Instructions instructions, int index)
|
||||
{
|
||||
super(instructions, InstructionType.DLOAD, 0);
|
||||
this.index = index;
|
||||
++length;
|
||||
}
|
||||
|
||||
public DLoad(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
@@ -40,9 +47,9 @@ public class DLoad extends Instruction implements LVTInstruction, WideInstructio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(index);
|
||||
}
|
||||
|
||||
@@ -76,9 +83,16 @@ public class DLoad extends Instruction implements LVTInstruction, WideInstructio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWide(DataOutputStream out, int pc) throws IOException
|
||||
public void writeWide(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
index = idx;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,12 @@ public class DLoad_0 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new DLoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -43,6 +43,12 @@ public class DLoad_1 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new DLoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -43,6 +43,12 @@ public class DLoad_2 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new DLoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -43,6 +43,12 @@ public class DLoad_3 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new DLoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -19,6 +19,13 @@ import java.io.IOException;
|
||||
public class DStore extends Instruction implements LVTInstruction, WideInstruction
|
||||
{
|
||||
private int index;
|
||||
|
||||
public DStore(Instructions instructions, int index)
|
||||
{
|
||||
super(instructions, InstructionType.DSTORE, 0);
|
||||
this.index = index;
|
||||
++length;
|
||||
}
|
||||
|
||||
public DStore(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
@@ -39,9 +46,9 @@ public class DStore extends Instruction implements LVTInstruction, WideInstructi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(index);
|
||||
}
|
||||
|
||||
@@ -73,9 +80,16 @@ public class DStore extends Instruction implements LVTInstruction, WideInstructi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWide(DataOutputStream out, int pc) throws IOException
|
||||
public void writeWide(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
index = idx;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,12 @@ public class DStore_0 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new DStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -40,6 +40,12 @@ public class DStore_1 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new DStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -40,6 +40,12 @@ public class DStore_2 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new DStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -40,6 +40,12 @@ public class DStore_3 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new DStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -34,4 +34,21 @@ public class Dup extends Instruction
|
||||
|
||||
frame.addInstructionContext(ins);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeStack()
|
||||
{
|
||||
// removing something from the stack this pushed at index 'idx'
|
||||
// idx = 0 is top of the stack, goes up.
|
||||
//
|
||||
// the stack is relative to post-execute of this instruction
|
||||
|
||||
// for dup, to remove one of the things pushed by it you simply
|
||||
// remove the dup instruction
|
||||
super.removeStack();
|
||||
// do not continue as the other branch still uses what we left
|
||||
// usually this is for new dup invokespecial and we end up with
|
||||
// an unused new/invokesepcial
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,4 +53,10 @@ public class Dup2 extends Instruction
|
||||
|
||||
frame.addInstructionContext(ins);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeStack()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,4 +58,10 @@ public class Dup2_X1 extends Instruction
|
||||
|
||||
frame.addInstructionContext(ins);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeStack()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,4 +69,10 @@ public class Dup2_X2 extends Instruction
|
||||
|
||||
frame.addInstructionContext(ins);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeStack()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +39,10 @@ public class Dup_X1 extends Instruction
|
||||
|
||||
frame.addInstructionContext(ins);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeStack()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,4 +51,10 @@ public class Dup_X2 extends Instruction
|
||||
|
||||
frame.addInstructionContext(ins);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeStack()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,13 @@ import java.io.IOException;
|
||||
public class FLoad extends Instruction implements LVTInstruction, WideInstruction
|
||||
{
|
||||
private int index;
|
||||
|
||||
public FLoad(Instructions instructions, int index)
|
||||
{
|
||||
super(instructions, InstructionType.FLOAD, 0);
|
||||
this.index = index;
|
||||
++length;
|
||||
}
|
||||
|
||||
public FLoad(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
@@ -40,9 +47,9 @@ public class FLoad extends Instruction implements LVTInstruction, WideInstructio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(index);
|
||||
}
|
||||
|
||||
@@ -76,9 +83,16 @@ public class FLoad extends Instruction implements LVTInstruction, WideInstructio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWide(DataOutputStream out, int pc) throws IOException
|
||||
public void writeWide(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
index = idx;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,12 @@ public class FLoad_0 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new FLoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -43,6 +43,12 @@ public class FLoad_1 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new FLoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -43,6 +43,12 @@ public class FLoad_2 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new FLoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -43,6 +43,12 @@ public class FLoad_3 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new FLoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -19,6 +19,13 @@ import java.io.IOException;
|
||||
public class FStore extends Instruction implements LVTInstruction, WideInstruction
|
||||
{
|
||||
private int index;
|
||||
|
||||
public FStore(Instructions instructions, int index)
|
||||
{
|
||||
super(instructions, InstructionType.FSTORE, 0);
|
||||
this.index = index;
|
||||
++length;
|
||||
}
|
||||
|
||||
public FStore(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
@@ -39,9 +46,9 @@ public class FStore extends Instruction implements LVTInstruction, WideInstructi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(index);
|
||||
}
|
||||
|
||||
@@ -73,9 +80,16 @@ public class FStore extends Instruction implements LVTInstruction, WideInstructi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWide(DataOutputStream out, int pc) throws IOException
|
||||
public void writeWide(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
index = idx;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,12 @@ public class FStore_0 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new FStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -40,6 +40,12 @@ public class FStore_1 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new FStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -40,6 +40,12 @@ public class FStore_2 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new FStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -40,6 +40,12 @@ public class FStore_3 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new FStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -27,9 +27,9 @@ public class GetField extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(field));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ public class GetStatic extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(field));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,16 @@ 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.attributes.code.instruction.types.JumpingInstruction;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Goto extends Instruction
|
||||
public class Goto extends Instruction implements JumpingInstruction
|
||||
{
|
||||
private Instruction to;
|
||||
private short offset;
|
||||
|
||||
public Goto(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
@@ -23,16 +25,25 @@ public class Goto extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void resolve()
|
||||
{
|
||||
super.write(out, pc);
|
||||
to = this.getInstructions().findInstruction(this.getPc() + offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out);
|
||||
int offset = to.getPc() - this.getPc();
|
||||
assert offset <= Short.MAX_VALUE;
|
||||
assert offset >= Short.MIN_VALUE;
|
||||
out.writeShort(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildJumpGraph()
|
||||
{
|
||||
this.addJump(offset);
|
||||
this.addJump(to);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,4 +57,11 @@ public class Goto extends Instruction
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(Instruction oldi, Instruction newi)
|
||||
{
|
||||
if (to == oldi)
|
||||
to = newi;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,16 @@ 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.attributes.code.instruction.types.JumpingInstruction;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class GotoW extends Instruction
|
||||
public class GotoW extends Instruction implements JumpingInstruction
|
||||
{
|
||||
private Instruction to;
|
||||
private int offset;
|
||||
|
||||
public GotoW(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
@@ -23,16 +25,22 @@ public class GotoW extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void resolve()
|
||||
{
|
||||
super.write(out, pc);
|
||||
out.writeInt(offset);
|
||||
to = this.getInstructions().findInstruction(this.getPc() + offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out);
|
||||
out.writeInt(to.getPc() - this.getPc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildJumpGraph()
|
||||
{
|
||||
this.addJump(offset);
|
||||
this.addJump(to);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,4 +54,11 @@ public class GotoW extends Instruction
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(Instruction oldi, Instruction newi)
|
||||
{
|
||||
if (to == oldi)
|
||||
to = newi;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@ public class IInc extends Instruction implements LVTInstruction, WideInstruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(index);
|
||||
out.writeByte(inc);
|
||||
}
|
||||
@@ -77,10 +77,17 @@ public class IInc extends Instruction implements LVTInstruction, WideInstruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWide(DataOutputStream out, int pc) throws IOException
|
||||
public void writeWide(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(index);
|
||||
out.writeShort(inc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
index = (short) idx;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,13 @@ import java.io.IOException;
|
||||
public class ILoad extends Instruction implements LVTInstruction, WideInstruction
|
||||
{
|
||||
private int index;
|
||||
|
||||
public ILoad(Instructions instructions, int index)
|
||||
{
|
||||
super(instructions, InstructionType.ILOAD, 0);
|
||||
this.index = index;
|
||||
++length;
|
||||
}
|
||||
|
||||
public ILoad(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
@@ -40,9 +47,9 @@ public class ILoad extends Instruction implements LVTInstruction, WideInstructio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(index);
|
||||
}
|
||||
|
||||
@@ -76,9 +83,16 @@ public class ILoad extends Instruction implements LVTInstruction, WideInstructio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWide(DataOutputStream out, int pc) throws IOException
|
||||
public void writeWide(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
index = idx;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,12 @@ public class ILoad_0 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new ILoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -43,6 +43,12 @@ public class ILoad_1 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new ILoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -43,6 +43,12 @@ public class ILoad_2 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new ILoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -43,6 +43,12 @@ public class ILoad_3 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new ILoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -20,6 +20,13 @@ import java.io.IOException;
|
||||
public class IStore extends Instruction implements LVTInstruction, WideInstruction
|
||||
{
|
||||
private int index;
|
||||
|
||||
public IStore(Instructions instructions, int index)
|
||||
{
|
||||
super(instructions, InstructionType.ISTORE, 0);
|
||||
this.index = index;
|
||||
++length;
|
||||
}
|
||||
|
||||
public IStore(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
@@ -40,9 +47,9 @@ public class IStore extends Instruction implements LVTInstruction, WideInstructi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(index);
|
||||
}
|
||||
|
||||
@@ -75,9 +82,16 @@ public class IStore extends Instruction implements LVTInstruction, WideInstructi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWide(DataOutputStream out, int pc) throws IOException
|
||||
public void writeWide(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
index = idx;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,12 @@ public class IStore_0 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new IStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -42,6 +42,12 @@ public class IStore_1 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new IStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -42,6 +42,12 @@ public class IStore_2 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new IStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -42,6 +42,12 @@ public class IStore_3 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new IStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -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.attributes.code.instruction.types.JumpingInstruction;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
import info.sigterm.deob.execution.InstructionContext;
|
||||
import info.sigterm.deob.execution.Stack;
|
||||
@@ -12,8 +13,9 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class If extends Instruction
|
||||
public class If extends Instruction implements JumpingInstruction
|
||||
{
|
||||
private Instruction to;
|
||||
private short offset;
|
||||
|
||||
public If(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
@@ -26,16 +28,22 @@ public class If extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void resolve()
|
||||
{
|
||||
super.write(out, pc);
|
||||
out.writeShort(offset);
|
||||
to = this.getInstructions().findInstruction(this.getPc() + offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out);
|
||||
out.writeShort(to.getPc() - this.getPc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildJumpGraph()
|
||||
{
|
||||
this.addJump(offset);
|
||||
this.addJump(to);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,4 +60,11 @@ public class If extends Instruction
|
||||
Frame other = frame.dup();
|
||||
other.jump(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(Instruction oldi, Instruction newi)
|
||||
{
|
||||
if (to == oldi)
|
||||
to = newi;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.attributes.code.instruction.types.JumpingInstruction;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
import info.sigterm.deob.execution.InstructionContext;
|
||||
import info.sigterm.deob.execution.Stack;
|
||||
@@ -12,8 +13,9 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class If0 extends Instruction
|
||||
public class If0 extends Instruction implements JumpingInstruction
|
||||
{
|
||||
private Instruction to;
|
||||
private short offset;
|
||||
|
||||
public If0(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
@@ -26,16 +28,22 @@ public class If0 extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void resolve()
|
||||
{
|
||||
super.write(out, pc);
|
||||
out.writeShort(offset);
|
||||
to = this.getInstructions().findInstruction(this.getPc() + offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out);
|
||||
out.writeShort(to.getPc() - this.getPc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildJumpGraph()
|
||||
{
|
||||
this.addJump(offset);
|
||||
this.addJump(to);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,4 +59,11 @@ public class If0 extends Instruction
|
||||
Frame other = frame.dup();
|
||||
other.jump(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(Instruction oldi, Instruction newi)
|
||||
{
|
||||
if (to == oldi)
|
||||
to = newi;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ public class InstanceOf extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(clazz));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,19 +4,22 @@ import info.sigterm.deob.ClassFile;
|
||||
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.attributes.code.instruction.types.InvokeInstruction;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
import info.sigterm.deob.execution.InstructionContext;
|
||||
import info.sigterm.deob.execution.Stack;
|
||||
import info.sigterm.deob.execution.StackContext;
|
||||
import info.sigterm.deob.execution.Type;
|
||||
import info.sigterm.deob.pool.InterfaceMethod;
|
||||
import info.sigterm.deob.pool.Method;
|
||||
import info.sigterm.deob.pool.NameAndType;
|
||||
import info.sigterm.deob.signature.Signature;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class InvokeInterface extends Instruction
|
||||
public class InvokeInterface extends Instruction implements InvokeInstruction
|
||||
{
|
||||
private InterfaceMethod method;
|
||||
private int count;
|
||||
@@ -33,9 +36,9 @@ public class InvokeInterface extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(method));
|
||||
out.writeByte(count);
|
||||
out.writeByte(0);
|
||||
@@ -83,4 +86,17 @@ public class InvokeInterface extends Instruction
|
||||
frame.addInstructionContext(ins);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeParameter(int idx)
|
||||
{
|
||||
info.sigterm.deob.pool.Class clazz = method.getClassEntry();
|
||||
NameAndType nat = method.getNameAndType();
|
||||
|
||||
// create new signature
|
||||
Signature sig = new Signature(nat.getDescriptor());
|
||||
sig.remove(idx);
|
||||
|
||||
// create new method pool object
|
||||
method = new InterfaceMethod(method.getPool(), clazz, new NameAndType(nat.getPool(), nat.getName(), sig));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import info.sigterm.deob.ClassFile;
|
||||
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.attributes.code.instruction.types.InvokeInstruction;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
import info.sigterm.deob.execution.InstructionContext;
|
||||
import info.sigterm.deob.execution.Stack;
|
||||
@@ -11,12 +12,13 @@ import info.sigterm.deob.execution.StackContext;
|
||||
import info.sigterm.deob.execution.Type;
|
||||
import info.sigterm.deob.pool.Method;
|
||||
import info.sigterm.deob.pool.NameAndType;
|
||||
import info.sigterm.deob.signature.Signature;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class InvokeSpecial extends Instruction
|
||||
public class InvokeSpecial extends Instruction implements InvokeInstruction
|
||||
{
|
||||
private Method method;
|
||||
|
||||
@@ -30,9 +32,9 @@ public class InvokeSpecial extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(method));
|
||||
}
|
||||
|
||||
@@ -84,4 +86,18 @@ public class InvokeSpecial extends Instruction
|
||||
{
|
||||
return "invokespecial " + method.getNameAndType().getDescriptor() + " on " + method.getClassEntry().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeParameter(int idx)
|
||||
{
|
||||
info.sigterm.deob.pool.Class clazz = method.getClassEntry();
|
||||
NameAndType nat = method.getNameAndType();
|
||||
|
||||
// create new signature
|
||||
Signature sig = new Signature(nat.getDescriptor());
|
||||
sig.remove(idx);
|
||||
|
||||
// create new method pool object
|
||||
method = new Method(method.getPool(), clazz, new NameAndType(nat.getPool(), nat.getName(), sig));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import info.sigterm.deob.ClassFile;
|
||||
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.attributes.code.instruction.types.InvokeInstruction;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
import info.sigterm.deob.execution.InstructionContext;
|
||||
import info.sigterm.deob.execution.Stack;
|
||||
@@ -11,12 +12,13 @@ import info.sigterm.deob.execution.StackContext;
|
||||
import info.sigterm.deob.execution.Type;
|
||||
import info.sigterm.deob.pool.Method;
|
||||
import info.sigterm.deob.pool.NameAndType;
|
||||
import info.sigterm.deob.signature.Signature;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class InvokeStatic extends Instruction
|
||||
public class InvokeStatic extends Instruction implements InvokeInstruction
|
||||
{
|
||||
private Method method;
|
||||
|
||||
@@ -30,9 +32,9 @@ public class InvokeStatic extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(method));
|
||||
}
|
||||
|
||||
@@ -81,4 +83,18 @@ public class InvokeStatic extends Instruction
|
||||
{
|
||||
return "invokestatic " + method.getNameAndType().getDescriptor() + " on " + method.getClassEntry().getName() + " return value " + method.getNameAndType().getDescriptor().getReturnValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeParameter(int idx)
|
||||
{
|
||||
info.sigterm.deob.pool.Class clazz = method.getClassEntry();
|
||||
NameAndType nat = method.getNameAndType();
|
||||
|
||||
// create new signature
|
||||
Signature sig = new Signature(nat.getDescriptor());
|
||||
sig.remove(idx);
|
||||
|
||||
// create new method pool object
|
||||
method = new Method(method.getPool(), clazz, new NameAndType(nat.getPool(), nat.getName(), sig));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import info.sigterm.deob.ClassFile;
|
||||
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.attributes.code.instruction.types.InvokeInstruction;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
import info.sigterm.deob.execution.InstructionContext;
|
||||
import info.sigterm.deob.execution.Stack;
|
||||
@@ -11,12 +12,13 @@ import info.sigterm.deob.execution.StackContext;
|
||||
import info.sigterm.deob.execution.Type;
|
||||
import info.sigterm.deob.pool.Method;
|
||||
import info.sigterm.deob.pool.NameAndType;
|
||||
import info.sigterm.deob.signature.Signature;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class InvokeVirtual extends Instruction
|
||||
public class InvokeVirtual extends Instruction implements InvokeInstruction
|
||||
{
|
||||
private Method method;
|
||||
|
||||
@@ -30,9 +32,9 @@ public class InvokeVirtual extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(method));
|
||||
}
|
||||
|
||||
@@ -79,5 +81,18 @@ public class InvokeVirtual extends Instruction
|
||||
|
||||
frame.addInstructionContext(ins);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeParameter(int idx)
|
||||
{
|
||||
info.sigterm.deob.pool.Class clazz = method.getClassEntry();
|
||||
NameAndType nat = method.getNameAndType();
|
||||
|
||||
// create new signature
|
||||
Signature sig = new Signature(nat.getDescriptor());
|
||||
sig.remove(idx);
|
||||
|
||||
// create new method pool object
|
||||
method = new Method(method.getPool(), clazz, new NameAndType(nat.getPool(), nat.getName(), sig));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,10 +27,22 @@ public class LDC extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void prime()
|
||||
{
|
||||
super.write(out, pc);
|
||||
out.writeByte(this.getPool().make(value));
|
||||
int index = this.getPool().make(value);
|
||||
if (index > 0xFF)
|
||||
{
|
||||
// new index might require changing this to an ldc_w
|
||||
this.replace(new LDC_W(this.getInstructions(), value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out);
|
||||
int index = this.getPool().make(value);
|
||||
out.writeByte(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,9 +27,9 @@ public class LDC2_W extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(value));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,18 @@ public class LDC_W extends Instruction
|
||||
length += 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public LDC_W(Instructions instructions, PoolEntry value)
|
||||
{
|
||||
super.write(out, pc);
|
||||
super(instructions, InstructionType.LDC_W, 0);
|
||||
|
||||
this.value = value;
|
||||
length += 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(value));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,13 @@ import java.io.IOException;
|
||||
public class LLoad extends Instruction implements LVTInstruction, WideInstruction
|
||||
{
|
||||
private int index;
|
||||
|
||||
public LLoad(Instructions instructions, int index)
|
||||
{
|
||||
super(instructions, InstructionType.LLOAD, 0);
|
||||
this.index = index;
|
||||
++length;
|
||||
}
|
||||
|
||||
public LLoad(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
@@ -40,9 +47,9 @@ public class LLoad extends Instruction implements LVTInstruction, WideInstructio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(index);
|
||||
}
|
||||
|
||||
@@ -76,9 +83,16 @@ public class LLoad extends Instruction implements LVTInstruction, WideInstructio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWide(DataOutputStream out, int pc) throws IOException
|
||||
public void writeWide(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
index = idx;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,12 @@ public class LLoad_0 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new LLoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -43,6 +43,12 @@ public class LLoad_1 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new LLoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -43,6 +43,12 @@ public class LLoad_2 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new LLoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -43,6 +43,12 @@ public class LLoad_3 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new LLoad(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -21,6 +21,13 @@ public class LStore extends Instruction implements LVTInstruction, WideInstructi
|
||||
{
|
||||
private int index;
|
||||
|
||||
public LStore(Instructions instructions, int index)
|
||||
{
|
||||
super(instructions, InstructionType.LSTORE, 0);
|
||||
this.index = index;
|
||||
++length;
|
||||
}
|
||||
|
||||
public LStore(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
@@ -40,9 +47,9 @@ public class LStore extends Instruction implements LVTInstruction, WideInstructi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(index);
|
||||
}
|
||||
|
||||
@@ -75,9 +82,16 @@ public class LStore extends Instruction implements LVTInstruction, WideInstructi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWide(DataOutputStream out, int pc) throws IOException
|
||||
public void writeWide(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
index = idx;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,12 @@ public class LStore_0 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new LStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -42,6 +42,12 @@ public class LStore_1 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new LStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -42,6 +42,12 @@ public class LStore_2 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new LStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -42,6 +42,12 @@ public class LStore_3 extends Instruction implements LVTInstruction
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
return new LStore(this.getInstructions(), idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
|
||||
@@ -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.attributes.code.instruction.types.JumpingInstruction;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
import info.sigterm.deob.execution.InstructionContext;
|
||||
import info.sigterm.deob.execution.Stack;
|
||||
@@ -11,9 +12,14 @@ import info.sigterm.deob.execution.StackContext;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LookupSwitch extends Instruction
|
||||
public class LookupSwitch extends Instruction implements JumpingInstruction
|
||||
{
|
||||
private List<Instruction> branchi = new ArrayList<>();
|
||||
private Instruction defi;
|
||||
|
||||
private int def;
|
||||
private int count;
|
||||
private int[] match;
|
||||
@@ -45,30 +51,49 @@ public class LookupSwitch extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void setPc(int pc)
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.setPc(pc);
|
||||
|
||||
int tableSkip = 4 - (pc + 1) % 4;
|
||||
if (tableSkip == 4) tableSkip = 0;
|
||||
|
||||
length = 1 + tableSkip + 8 + (count * 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve()
|
||||
{
|
||||
for (int i : branch)
|
||||
branchi.add(this.getInstructions().findInstruction(this.getPc() + i));
|
||||
defi = this.getInstructions().findInstruction(this.getPc() + def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out);
|
||||
|
||||
int tableSkip = 4 - (this.getPc() + 1) % 4;
|
||||
if (tableSkip == 4) tableSkip = 0;
|
||||
if (tableSkip > 0) out.write(new byte[tableSkip]);
|
||||
|
||||
out.writeInt(def);
|
||||
out.writeInt(defi.getPc() - this.getPc());
|
||||
|
||||
out.writeInt(count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
out.writeInt(match[i]);
|
||||
out.writeInt(branch[i]);
|
||||
out.writeInt(branchi.get(i).getPc() - this.getPc());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildJumpGraph()
|
||||
{
|
||||
for (int i : branch)
|
||||
for (Instruction i : branchi)
|
||||
this.addJump(i);
|
||||
this.addJump(def);
|
||||
this.addJump(defi);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,4 +121,15 @@ public class LookupSwitch extends Instruction
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(Instruction oldi, Instruction newi)
|
||||
{
|
||||
if (defi == oldi)
|
||||
defi = newi;
|
||||
|
||||
for (int i = 0; i < branchi.size(); ++i)
|
||||
if (branchi.get(i) == oldi)
|
||||
branchi.set(i, newi);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@ public class MultiANewArray extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(clazz));
|
||||
out.writeByte(dimensions);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ public class New extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(clazz));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ public class NewArray extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeByte(type);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ public class PutField extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(field));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ public class PutStatic extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(this.getPool().make(field));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ public class SiPush extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
out.writeShort(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.attributes.code.instruction.types.JumpingInstruction;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
import info.sigterm.deob.execution.InstructionContext;
|
||||
import info.sigterm.deob.execution.Stack;
|
||||
@@ -11,9 +12,14 @@ import info.sigterm.deob.execution.StackContext;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TableSwitch extends Instruction
|
||||
public class TableSwitch extends Instruction implements JumpingInstruction
|
||||
{
|
||||
private List<Instruction> branchi = new ArrayList<>();
|
||||
private Instruction defi;
|
||||
|
||||
private int def;
|
||||
private int low;
|
||||
private int high;
|
||||
@@ -42,29 +48,49 @@ public class TableSwitch extends Instruction
|
||||
length += tableSkip + 12 + (count * 4);
|
||||
}
|
||||
|
||||
// changing the pc changes the instruction length due to padding
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void setPc(int pc)
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.setPc(pc);
|
||||
|
||||
int tableSkip = 4 - (pc + 1) % 4;
|
||||
if (tableSkip == 4) tableSkip = 0;
|
||||
|
||||
length = 1 + tableSkip + 12 + (jumps.length * 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve()
|
||||
{
|
||||
for (int i : jumps)
|
||||
branchi.add(this.getInstructions().findInstruction(this.getPc() + i));
|
||||
defi = this.getInstructions().findInstruction(this.getPc() + def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out);
|
||||
|
||||
int tableSkip = 4 - (this.getPc() + 1) % 4;
|
||||
if (tableSkip == 4) tableSkip = 0;
|
||||
if (tableSkip > 0) out.write(new byte[tableSkip]);
|
||||
|
||||
out.writeInt(def);
|
||||
out.writeInt(defi.getPc() - this.getPc());
|
||||
out.writeInt(low);
|
||||
out.writeInt(high);
|
||||
|
||||
for (int i = 0; i < high - low + 1; ++i)
|
||||
out.writeInt(jumps[i]);
|
||||
for (Instruction i : branchi)
|
||||
out.writeInt(i.getPc() - this.getPc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildJumpGraph()
|
||||
{
|
||||
for (int i : jumps)
|
||||
for (Instruction i : branchi)
|
||||
this.addJump(i);
|
||||
this.addJump(def);
|
||||
this.addJump(defi);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,4 +118,15 @@ public class TableSwitch extends Instruction
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(Instruction oldi, Instruction newi)
|
||||
{
|
||||
if (defi == oldi)
|
||||
defi = newi;
|
||||
|
||||
for (int i = 0; i < branchi.size(); ++i)
|
||||
if (branchi.get(i) == oldi)
|
||||
branchi.set(i, newi);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.attributes.code.instruction.types.LVTInstruction;
|
||||
import info.sigterm.deob.attributes.code.instruction.types.WideInstruction;
|
||||
import info.sigterm.deob.execution.Frame;
|
||||
|
||||
@@ -11,7 +12,7 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
public class Wide extends Instruction
|
||||
public class Wide extends Instruction implements LVTInstruction
|
||||
{
|
||||
private Instruction ins;
|
||||
|
||||
@@ -27,7 +28,7 @@ public class Wide extends Instruction
|
||||
try
|
||||
{
|
||||
Constructor<? extends Instruction> con = op.getInstructionClass().getConstructor(Instructions.class, InstructionType.class, Instruction.class, int.class);
|
||||
ins = con.newInstance(instructions, type, this, pc);
|
||||
ins = con.newInstance(instructions, op, this, pc);
|
||||
length += ins.getLength();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -37,12 +38,12 @@ public class Wide extends Instruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
super.write(out, pc);
|
||||
super.write(out);
|
||||
|
||||
WideInstruction w = (WideInstruction) ins;
|
||||
w.writeWide(out, pc);
|
||||
w.writeWide(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,4 +52,28 @@ public class Wide extends Instruction
|
||||
ins.execute(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(Instruction oldi, Instruction newi)
|
||||
{
|
||||
assert oldi != ins;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVariableIndex()
|
||||
{
|
||||
return ((LVTInstruction) ins).getVariableIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction setVariableIndex(int idx)
|
||||
{
|
||||
ins = ((LVTInstruction) ins).setVariableIndex(idx);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean store()
|
||||
{
|
||||
return ((LVTInstruction) ins).store();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user