Carry encryption over in iadd and dup x1, this needs to be handled a better way.

This commit is contained in:
Adam
2015-09-08 20:45:57 -04:00
parent 7e9233a5d5
commit 9404e1d9af
2 changed files with 51 additions and 0 deletions

View File

@@ -29,16 +29,19 @@ public class Dup_X1 extends Instruction
ins.pop(one, two);
StackContext ctx = new StackContext(ins, one.getType());
ctx.encryption = one.encryption;
stack.push(ctx);
ins.push(ctx);
ctx = new StackContext(ins, two.getType());
ctx.encryption = two.encryption;
stack.push(ctx);
ins.push(ctx);
ctx = new StackContext(ins, one.getType());
ctx.encryption = one.encryption;
stack.push(ctx);
ins.push(ctx);

View File

@@ -3,6 +3,9 @@ package net.runelite.deob.attributes.code.instructions;
import net.runelite.deob.attributes.code.Instruction;
import net.runelite.deob.attributes.code.InstructionType;
import net.runelite.deob.attributes.code.Instructions;
import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction;
import net.runelite.deob.deobfuscators.arithmetic.DMath;
import net.runelite.deob.deobfuscators.arithmetic.Encryption;
import net.runelite.deob.execution.Frame;
import net.runelite.deob.execution.InstructionContext;
import net.runelite.deob.execution.Stack;
@@ -26,7 +29,52 @@ public class IAdd extends Instruction
ins.pop(two, one);
Encryption encryption = frame.getExecution().getEncryption();
int encKey = 0;
if (encryption != null)
{
if (one.encryption != 0)
{
assert two.encryption == 0;
if (two.getPushed().getInstruction() instanceof PushConstantInstruction)
{
PushConstantInstruction pci = (PushConstantInstruction) two.getPushed().getInstruction();
int value = (int) pci.getConstant().getObject();
if (value != 0 && value != 1)
{
int o = value * one.encryption;
encryption.change(pci, o);
}
}
encKey = one.encryption;
}
else if (two.encryption != 0)
{
assert one.encryption == 0;
if (one.getPushed().getInstruction() instanceof PushConstantInstruction)
{
PushConstantInstruction pci = (PushConstantInstruction) one.getPushed().getInstruction();
int value = (int) pci.getConstant().getObject();
if (value != 0 && value != 1)
{
int o = value * two.encryption;
encryption.change(pci, o);
}
}
encKey = two.encryption;
}
}
StackContext ctx = new StackContext(ins, int.class);
ctx.encryption = encKey;
stack.push(ctx);
ins.push(ctx);