Make generic load/store instructions. Unused params was replacing ins which requires a reexecution, but it wasn't

This commit is contained in:
Adam
2015-10-19 15:23:01 -04:00
parent 98143941b3
commit 6c038e7fa6
42 changed files with 250 additions and 12 deletions

View File

@@ -104,6 +104,9 @@ public abstract class Instruction
int index = ins.indexOf(this);
ins.remove(this);
ins.add(index, other);
assert other.getInstructions() == this.instructions;
this.instructions = null;
}
public boolean removeStack()

View File

@@ -55,4 +55,10 @@ public class ALoad_0 extends Instruction implements LVTInstruction
{
return new ALoad(this.getInstructions(), idx);
}
@Override
public Instruction makeGeneric()
{
return new ALoad(this.getInstructions(), 0);
}
}

View File

@@ -55,4 +55,10 @@ public class ALoad_1 extends Instruction implements LVTInstruction
{
return new ALoad(this.getInstructions(), idx);
}
@Override
public Instruction makeGeneric()
{
return new ALoad(this.getInstructions(), 1);
}
}

View File

@@ -55,4 +55,10 @@ public class ALoad_2 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new ALoad(this.getInstructions(), 2);
}
}

View File

@@ -55,4 +55,10 @@ public class ALoad_3 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new ALoad(this.getInstructions(), 3);
}
}

View File

@@ -52,4 +52,10 @@ public class AStore_0 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new AStore(this.getInstructions(), 0);
}
}

View File

@@ -52,4 +52,10 @@ public class AStore_1 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new AStore(this.getInstructions(), 1);
}
}

View File

@@ -52,4 +52,10 @@ public class AStore_2 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new AStore(this.getInstructions(), 2);
}
}

View File

@@ -52,4 +52,10 @@ public class AStore_3 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new AStore(this.getInstructions(), 3);
}
}

View File

@@ -57,4 +57,10 @@ public class DLoad_0 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new DLoad(this.getInstructions(), 0);
}
}

View File

@@ -57,4 +57,10 @@ public class DLoad_1 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new DLoad(this.getInstructions(), 1);
}
}

View File

@@ -57,4 +57,10 @@ public class DLoad_2 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new DLoad(this.getInstructions(), 2);
}
}

View File

@@ -57,4 +57,10 @@ public class DLoad_3 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new DLoad(this.getInstructions(), 3);
}
}

View File

@@ -52,4 +52,10 @@ public class DStore_0 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new DStore(this.getInstructions(), 0);
}
}

View File

@@ -52,4 +52,10 @@ public class DStore_1 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new DStore(this.getInstructions(), 1);
}
}

View File

@@ -52,4 +52,10 @@ public class DStore_2 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new DStore(this.getInstructions(), 2);
}
}

View File

@@ -52,4 +52,10 @@ public class DStore_3 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new DStore(this.getInstructions(), 3);
}
}

View File

@@ -57,4 +57,10 @@ public class FLoad_0 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new FLoad(this.getInstructions(), 0);
}
}

View File

@@ -57,4 +57,10 @@ public class FLoad_1 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new FLoad(this.getInstructions(), 1);
}
}

View File

@@ -57,4 +57,10 @@ public class FLoad_2 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new FLoad(this.getInstructions(), 2);
}
}

View File

@@ -57,4 +57,10 @@ public class FLoad_3 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new FLoad(this.getInstructions(), 3);
}
}

View File

@@ -52,4 +52,10 @@ public class FStore_0 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new FStore(this.getInstructions(), 0);
}
}

View File

@@ -52,4 +52,10 @@ public class FStore_1 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new FStore(this.getInstructions(), 1);
}
}

View File

@@ -52,4 +52,10 @@ public class FStore_2 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new FStore(this.getInstructions(), 2);
}
}

View File

@@ -52,4 +52,10 @@ public class FStore_3 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new FStore(this.getInstructions(), 3);
}
}

View File

@@ -57,4 +57,10 @@ public class ILoad_0 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new ILoad(this.getInstructions(), 0);
}
}

View File

@@ -57,4 +57,10 @@ public class ILoad_1 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new ILoad(this.getInstructions(), 1);
}
}

View File

@@ -57,4 +57,10 @@ public class ILoad_2 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new ILoad(this.getInstructions(), 2);
}
}

View File

@@ -57,4 +57,10 @@ public class ILoad_3 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new ILoad(this.getInstructions(), 3);
}
}

View File

@@ -59,4 +59,10 @@ public class IStore_0 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new IStore(this.getInstructions(), 0);
}
}

View File

@@ -59,4 +59,10 @@ public class IStore_1 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new IStore(this.getInstructions(), 1);
}
}

View File

@@ -59,4 +59,10 @@ public class IStore_2 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new IStore(this.getInstructions(), 2);
}
}

View File

@@ -54,4 +54,10 @@ public class IStore_3 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new IStore(this.getInstructions(), 3);
}
}

View File

@@ -57,4 +57,10 @@ public class LLoad_0 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new LLoad(this.getInstructions(), 0);
}
}

View File

@@ -57,4 +57,10 @@ public class LLoad_1 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new LLoad(this.getInstructions(), 1);
}
}

View File

@@ -57,4 +57,10 @@ public class LLoad_2 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new LLoad(this.getInstructions(), 2);
}
}

View File

@@ -57,4 +57,10 @@ public class LLoad_3 extends Instruction implements LVTInstruction
{
return false;
}
@Override
public Instruction makeGeneric()
{
return new LLoad(this.getInstructions(), 3);
}
}

View File

@@ -54,4 +54,10 @@ public class LStore_0 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new LStore(this.getInstructions(), 0);
}
}

View File

@@ -54,4 +54,10 @@ public class LStore_1 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new LStore(this.getInstructions(), 1);
}
}

View File

@@ -54,4 +54,10 @@ public class LStore_2 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new LStore(this.getInstructions(), 2);
}
}

View File

@@ -54,4 +54,10 @@ public class LStore_3 extends Instruction implements LVTInstruction
{
return true;
}
@Override
public Instruction makeGeneric()
{
return new LStore(this.getInstructions(), 3);
}
}

View File

@@ -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)
if (method.getCode() != null)
// adjust lvt indexes to get rid of idx in the method
@@ -186,15 +182,16 @@ public class UnusedParameters implements Deobfuscator
int i = lins.getVariableIndex();
assert i != lvtIndex; // current unused variable detection just looks for no accesses
//if (i >= numArgs)
// continue;
// reassign
if (i > lvtIndex)
{
assert i > 0;
Instruction newIns = lins.setVariableIndex(--i);
if (newIns != ins)
ins.replace(newIns);
assert ins == 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]);
++count;
break;
}
}
return new int[] { count };
@@ -279,7 +274,7 @@ public class UnusedParameters implements Deobfuscator
i = checkParametersOnce(execution, group);
count += i[0];
break;
//break;
}
while (i[0] > 0);