something is wrong somewhere but I don't see anything
This commit is contained in:
@@ -4,7 +4,7 @@ import net.runelite.deob.execution.StackContext;
|
||||
|
||||
public interface DupInstruction
|
||||
{
|
||||
public StackContext resolve(StackContext sctx);
|
||||
public StackContext getOriginal(StackContext sctx);
|
||||
|
||||
public StackContext getOtherBranch(StackContext sctx);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class Dup extends Instruction implements DupInstruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackContext resolve(StackContext sctx)
|
||||
public StackContext getOriginal(StackContext sctx)
|
||||
{
|
||||
// ctx = stack pushed by this instruction, return stack popped by this instruction
|
||||
InstructionContext ctx = sctx.getPushed();
|
||||
|
||||
@@ -73,7 +73,7 @@ public class Dup2 extends Instruction implements DupInstruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackContext resolve(StackContext ctx)
|
||||
public StackContext getOriginal(StackContext ctx)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class Dup2_X1 extends Instruction implements DupInstruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackContext resolve(StackContext ctx)
|
||||
public StackContext getOriginal(StackContext ctx)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class Dup2_X2 extends Instruction implements DupInstruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackContext resolve(StackContext ctx)
|
||||
public StackContext getOriginal(StackContext ctx)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Dup_X1 extends Instruction implements DupInstruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackContext resolve(StackContext sctx)
|
||||
public StackContext getOriginal(StackContext sctx)
|
||||
{
|
||||
// ctx = stack pushed by this instruction, return stack popped by this instruction
|
||||
InstructionContext ctx = sctx.getPushed();
|
||||
|
||||
@@ -71,14 +71,51 @@ public class Dup_X2 extends Instruction implements DupInstruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackContext resolve(StackContext ctx)
|
||||
public StackContext getOriginal(StackContext sctx)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
// 3 2 1 -> 1 3 2 1
|
||||
InstructionContext ctx = sctx.getPushed();
|
||||
assert ctx.getInstruction() == this;
|
||||
|
||||
assert ctx.getPushes().contains(sctx);
|
||||
int pushedIndex = ctx.getPushes().indexOf(sctx);
|
||||
int poppedIndex;
|
||||
|
||||
switch (pushedIndex)
|
||||
{
|
||||
case 0:
|
||||
case 3:
|
||||
poppedIndex = 0;
|
||||
break;
|
||||
case 1:
|
||||
poppedIndex = 2;
|
||||
break;
|
||||
case 2:
|
||||
poppedIndex = 1;
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
return ctx.getPops().get(poppedIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackContext getOtherBranch(StackContext sctx)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
// sctx = stack pushed by this instruction, return the other branch
|
||||
InstructionContext ctx = sctx.getPushed();
|
||||
assert ctx.getInstruction() == this;
|
||||
|
||||
assert ctx.getPushes().contains(sctx);
|
||||
int pushedIndex = ctx.getPushes().indexOf(sctx);
|
||||
|
||||
// 3 2 1 -> 1 3 2 1
|
||||
|
||||
if (pushedIndex == 0)
|
||||
return ctx.getPushes().get(3);
|
||||
else if (pushedIndex == 3)
|
||||
return ctx.getPushes().get(0);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,9 +120,10 @@ public class MultiplicationDeobfuscator implements Deobfuscator
|
||||
}
|
||||
else if (i.getInstruction() instanceof DupInstruction)
|
||||
{
|
||||
if(true) throw new IllegalStateException();
|
||||
DupInstruction dup = (DupInstruction) i.getInstruction();
|
||||
|
||||
if (dup instanceof Dup || dup instanceof Dup_X1)
|
||||
//if (dup instanceof Dup || dup instanceof Dup_X1)
|
||||
{
|
||||
|
||||
// find other branch of the dup instruction
|
||||
@@ -139,7 +140,7 @@ public class MultiplicationDeobfuscator implements Deobfuscator
|
||||
|
||||
me.dupmagic = pushConstant;
|
||||
|
||||
StackContext orig = dup.resolve(sctx); // original
|
||||
StackContext orig = dup.getOriginal(sctx); // original
|
||||
try
|
||||
{
|
||||
MultiplicationExpression other = parseExpression(orig.getPushed());
|
||||
@@ -152,7 +153,8 @@ public class MultiplicationDeobfuscator implements Deobfuscator
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("dup ins " + i);
|
||||
System.out.println("dup ins " + otherCtxI.getInstruction());
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user