Make generic load/store instructions. Unused params was replacing ins which requires a reexecution, but it wasn't
This commit is contained in:
@@ -104,6 +104,9 @@ public abstract class Instruction
|
|||||||
int index = ins.indexOf(this);
|
int index = ins.indexOf(this);
|
||||||
ins.remove(this);
|
ins.remove(this);
|
||||||
ins.add(index, other);
|
ins.add(index, other);
|
||||||
|
|
||||||
|
assert other.getInstructions() == this.instructions;
|
||||||
|
this.instructions = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeStack()
|
public boolean removeStack()
|
||||||
|
|||||||
@@ -55,4 +55,10 @@ public class ALoad_0 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return new ALoad(this.getInstructions(), idx);
|
return new ALoad(this.getInstructions(), idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new ALoad(this.getInstructions(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,4 +55,10 @@ public class ALoad_1 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return new ALoad(this.getInstructions(), idx);
|
return new ALoad(this.getInstructions(), idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new ALoad(this.getInstructions(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,4 +55,10 @@ public class ALoad_2 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new ALoad(this.getInstructions(), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,4 +55,10 @@ public class ALoad_3 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new ALoad(this.getInstructions(), 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ public class AStore_0 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new AStore(this.getInstructions(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ public class AStore_1 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new AStore(this.getInstructions(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ public class AStore_2 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new AStore(this.getInstructions(), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ public class AStore_3 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new AStore(this.getInstructions(), 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class DLoad_0 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new DLoad(this.getInstructions(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class DLoad_1 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new DLoad(this.getInstructions(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class DLoad_2 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new DLoad(this.getInstructions(), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class DLoad_3 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new DLoad(this.getInstructions(), 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ public class DStore_0 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new DStore(this.getInstructions(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ public class DStore_1 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new DStore(this.getInstructions(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ public class DStore_2 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new DStore(this.getInstructions(), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ public class DStore_3 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new DStore(this.getInstructions(), 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class FLoad_0 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new FLoad(this.getInstructions(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class FLoad_1 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new FLoad(this.getInstructions(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class FLoad_2 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new FLoad(this.getInstructions(), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class FLoad_3 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new FLoad(this.getInstructions(), 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ public class FStore_0 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new FStore(this.getInstructions(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ public class FStore_1 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new FStore(this.getInstructions(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ public class FStore_2 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new FStore(this.getInstructions(), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ public class FStore_3 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new FStore(this.getInstructions(), 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class ILoad_0 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new ILoad(this.getInstructions(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class ILoad_1 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new ILoad(this.getInstructions(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class ILoad_2 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new ILoad(this.getInstructions(), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class ILoad_3 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new ILoad(this.getInstructions(), 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,4 +59,10 @@ public class IStore_0 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new IStore(this.getInstructions(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,4 +59,10 @@ public class IStore_1 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new IStore(this.getInstructions(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,4 +59,10 @@ public class IStore_2 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new IStore(this.getInstructions(), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,4 +54,10 @@ public class IStore_3 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new IStore(this.getInstructions(), 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class LLoad_0 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new LLoad(this.getInstructions(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class LLoad_1 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new LLoad(this.getInstructions(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class LLoad_2 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new LLoad(this.getInstructions(), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,10 @@ public class LLoad_3 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new LLoad(this.getInstructions(), 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,4 +54,10 @@ public class LStore_0 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new LStore(this.getInstructions(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,4 +54,10 @@ public class LStore_1 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new LStore(this.getInstructions(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,4 +54,10 @@ public class LStore_2 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new LStore(this.getInstructions(), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,4 +54,10 @@ public class LStore_3 extends Instruction implements LVTInstruction
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction makeGeneric()
|
||||||
|
{
|
||||||
|
return new LStore(this.getInstructions(), 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,10 +170,6 @@ public class UnusedParameters implements Deobfuscator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int numArgs = signature.size();
|
|
||||||
if (methods.size() > 1 || !methods.get(0).isStatic())
|
|
||||||
++numArgs;
|
|
||||||
|
|
||||||
for (Method method : methods)
|
for (Method method : methods)
|
||||||
if (method.getCode() != null)
|
if (method.getCode() != null)
|
||||||
// adjust lvt indexes to get rid of idx in the method
|
// adjust lvt indexes to get rid of idx in the method
|
||||||
@@ -186,15 +182,16 @@ public class UnusedParameters implements Deobfuscator
|
|||||||
int i = lins.getVariableIndex();
|
int i = lins.getVariableIndex();
|
||||||
assert i != lvtIndex; // current unused variable detection just looks for no accesses
|
assert i != lvtIndex; // current unused variable detection just looks for no accesses
|
||||||
|
|
||||||
//if (i >= numArgs)
|
|
||||||
// continue;
|
|
||||||
|
|
||||||
// reassign
|
// reassign
|
||||||
if (i > lvtIndex)
|
if (i > lvtIndex)
|
||||||
{
|
{
|
||||||
|
assert i > 0;
|
||||||
|
|
||||||
Instruction newIns = lins.setVariableIndex(--i);
|
Instruction newIns = lins.setVariableIndex(--i);
|
||||||
if (newIns != ins)
|
assert ins == newIns;
|
||||||
ins.replace(newIns);
|
// this doesn't work because we'd have to reexecute or the above Frames would be messing with these instructions
|
||||||
|
//if (newIns != ins)
|
||||||
|
// ins.replace(newIns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -256,8 +253,6 @@ public class UnusedParameters implements Deobfuscator
|
|||||||
removeParameter(methods, signature, execution, unusedParameter, lvtIndexes[unusedParameter]);
|
removeParameter(methods, signature, execution, unusedParameter, lvtIndexes[unusedParameter]);
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new int[] { count };
|
return new int[] { count };
|
||||||
@@ -279,7 +274,7 @@ public class UnusedParameters implements Deobfuscator
|
|||||||
i = checkParametersOnce(execution, group);
|
i = checkParametersOnce(execution, group);
|
||||||
|
|
||||||
count += i[0];
|
count += i[0];
|
||||||
break;
|
//break;
|
||||||
}
|
}
|
||||||
while (i[0] > 0);
|
while (i[0] > 0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user