Fix some of the dup stuff, works a little better?
This commit is contained in:
@@ -65,6 +65,7 @@ public class Dup extends Instruction implements DupInstruction
|
|||||||
// ctx = stack pushed by this instruction, return stack popped by this instruction
|
// ctx = stack pushed by this instruction, return stack popped by this instruction
|
||||||
InstructionContext ctx = sctx.getPushed();
|
InstructionContext ctx = sctx.getPushed();
|
||||||
assert ctx.getInstruction() == this;
|
assert ctx.getInstruction() == this;
|
||||||
|
assert ctx.getPushes().contains(sctx);
|
||||||
return ctx.getPops().get(0);
|
return ctx.getPops().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public class MultiplicationDeobfuscator implements Deobfuscator
|
|||||||
}
|
}
|
||||||
else if (i.getInstruction() instanceof DupInstruction)
|
else if (i.getInstruction() instanceof DupInstruction)
|
||||||
{
|
{
|
||||||
if(true) throw new IllegalStateException();
|
//if(true) throw new IllegalStateException();
|
||||||
DupInstruction dup = (DupInstruction) i.getInstruction();
|
DupInstruction dup = (DupInstruction) i.getInstruction();
|
||||||
|
|
||||||
//if (dup instanceof Dup || dup instanceof Dup_X1)
|
//if (dup instanceof Dup || dup instanceof Dup_X1)
|
||||||
@@ -144,7 +144,12 @@ public class MultiplicationDeobfuscator implements Deobfuscator
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
MultiplicationExpression other = parseExpression(orig.getPushed());
|
MultiplicationExpression other = parseExpression(orig.getPushed());
|
||||||
me.subexpressions.add(other);
|
// this expression is used elsewhere like 'pushConstant' so any changes
|
||||||
|
// done to it affect that, too. so multiply it by existing values?
|
||||||
|
me.instructions.addAll(other.instructions);
|
||||||
|
me.dupedInstructions.addAll(other.instructions);
|
||||||
|
me.subexpressions.addAll(other.subexpressions);
|
||||||
|
//me.subexpressions.add(other);
|
||||||
}
|
}
|
||||||
catch (IllegalStateException ex)
|
catch (IllegalStateException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import net.runelite.deob.execution.InstructionContext;
|
|||||||
|
|
||||||
public class MultiplicationExpression
|
public class MultiplicationExpression
|
||||||
{
|
{
|
||||||
List<InstructionContext> instructions = new ArrayList<>(); // push constant instructions that are being multiplied
|
List<InstructionContext> instructions = new ArrayList<>(), // push constant instructions that are being multiplied
|
||||||
|
dupedInstructions = new ArrayList<>();
|
||||||
List<MultiplicationExpression> subexpressions = new ArrayList<>(); // for distributing, each subexpr is * by this
|
List<MultiplicationExpression> subexpressions = new ArrayList<>(); // for distributing, each subexpr is * by this
|
||||||
InstructionContext dupmagic; // inverse of what is distributed to subexpressions gets set here
|
InstructionContext dupmagic; // inverse of what is distributed to subexpressions gets set here
|
||||||
static boolean replace;
|
static boolean replace;
|
||||||
@@ -27,23 +28,49 @@ public class MultiplicationExpression
|
|||||||
result *= value;
|
result *= value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assert (dupmagic != null) == !dupedInstructions.isEmpty();
|
||||||
|
if (dupmagic != null)
|
||||||
|
{
|
||||||
|
// mul dupmagic by result of dup ins?
|
||||||
|
|
||||||
|
PushConstantInstruction pci = (PushConstantInstruction) dupmagic.getInstruction();
|
||||||
|
int value = (int) pci.getConstant().getObject();
|
||||||
|
|
||||||
|
for (InstructionContext ic : dupedInstructions)
|
||||||
|
{
|
||||||
|
PushConstantInstruction pci2 = (PushConstantInstruction) ic.getInstruction();
|
||||||
|
int value2 = (int) pci2.getConstant().getObject();
|
||||||
|
|
||||||
|
value *= value2;
|
||||||
|
}
|
||||||
|
|
||||||
|
Instruction newIns = pci.setConstant(new net.runelite.deob.pool.Integer(value));
|
||||||
|
System.out.println("dupmagic");
|
||||||
|
assert newIns == (Instruction) pci;
|
||||||
|
}
|
||||||
|
|
||||||
// multiply subexpressions by result
|
// multiply subexpressions by result
|
||||||
if (!subexpressions.isEmpty())
|
if (!subexpressions.isEmpty())
|
||||||
{
|
{
|
||||||
for (MultiplicationExpression me : subexpressions)
|
for (MultiplicationExpression me : subexpressions)
|
||||||
{
|
{
|
||||||
|
// if (me.instructions.isEmpty() && this.dupmagic != null)
|
||||||
|
// {
|
||||||
|
// assert me.dupmagic == null;
|
||||||
|
// me.dupmagic = this.dupmagic;
|
||||||
|
// }
|
||||||
count += me.simplify(result);
|
count += me.simplify(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dupmagic != null)
|
// if (dupmagic != null)
|
||||||
{
|
// {
|
||||||
PushConstantInstruction pci = (PushConstantInstruction) dupmagic.getInstruction();
|
// PushConstantInstruction pci = (PushConstantInstruction) dupmagic.getInstruction();
|
||||||
int value = (int) pci.getConstant().getObject();
|
// int value = (int) pci.getConstant().getObject();
|
||||||
|
//
|
||||||
value *= DMath.modInverse(result);
|
// value *= DMath.modInverse(result);
|
||||||
|
//
|
||||||
pci.setConstant(new net.runelite.deob.pool.Integer(value));
|
// pci.setConstant(new net.runelite.deob.pool.Integer(value));
|
||||||
}
|
// }
|
||||||
|
|
||||||
result = 1; // constant has been distributed, outer numbers all go to 1
|
result = 1; // constant has been distributed, outer numbers all go to 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user