class172.java: this.field2982 = ((1 * this.field2963 & -65536) + this.field2982 * 1) * -402105799; not working.

This commit is contained in:
Adam
2015-09-09 21:24:37 -04:00
parent 9404e1d9af
commit 2cfba32e28
3 changed files with 107 additions and 54 deletions

View File

@@ -31,6 +31,7 @@ public class IMul extends Instruction
ins.pop(one, two); ins.pop(one, two);
Encryption encryption = frame.getExecution().getEncryption(); Encryption encryption = frame.getExecution().getEncryption();
int encKey = 0;
if (encryption != null) if (encryption != null)
{ {
if (one.encryption != 0) if (one.encryption != 0)
@@ -52,9 +53,12 @@ public class IMul extends Instruction
// { // {
// System.out.println("decrr"); // System.out.println("decrr");
// } // }
encKey = one.encryption;
} }
else if (two.encryption != 0) else if (two.encryption != 0)
{ {
assert one.encryption == 0;
PushConstantInstruction pci = (PushConstantInstruction) one.getPushed().getInstruction(); PushConstantInstruction pci = (PushConstantInstruction) one.getPushed().getInstruction();
int other = (int) pci.getConstant().getObject(); int other = (int) pci.getConstant().getObject();
@@ -64,10 +68,12 @@ public class IMul extends Instruction
encryption.change(pci, o); encryption.change(pci, o);
} }
encKey = two.encryption;
} }
} }
StackContext ctx = new StackContext(ins, int.class); StackContext ctx = new StackContext(ins, int.class);
ctx.encryption = encKey;
stack.push(ctx); stack.push(ctx);
ins.push(ctx); ins.push(ctx);

View File

@@ -3,6 +3,8 @@ package net.runelite.deob.attributes.code.instructions;
import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.Instruction;
import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.InstructionType;
import net.runelite.deob.attributes.code.Instructions; import net.runelite.deob.attributes.code.Instructions;
import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction;
import net.runelite.deob.deobfuscators.arithmetic.Encryption;
import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.Frame;
import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.InstructionContext;
import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.Stack;
@@ -26,7 +28,52 @@ public class ISub extends Instruction
ins.pop(two, one); 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); StackContext ctx = new StackContext(ins, int.class);
ctx.encryption = encKey;
stack.push(ctx); stack.push(ctx);
ins.push(ctx); ins.push(ctx);

View File

@@ -210,60 +210,60 @@ public class ModArith implements Deobfuscator
// } // }
} }
private List<Field> getFieldsInExpression(InstructionContext ctx, List<Integer> constants) // private List<Field> getFieldsInExpression(InstructionContext ctx, List<Integer> constants)
{ // {
return check(ctx, new HashSet<InstructionContext>(), constants); // return check(ctx, new HashSet<InstructionContext>(), constants);
} // }
//
private List<Field> check(InstructionContext context, Set<InstructionContext> visited, List<Integer> constants) // private List<Field> check(InstructionContext context, Set<InstructionContext> visited, List<Integer> constants)
{ // {
List<Field> fields = new ArrayList<>(); // List<Field> fields = new ArrayList<>();
//
if (visited.contains(context)) // if (visited.contains(context))
return fields; // return fields;
//
visited.add(context); // visited.add(context);
//
if (context.getInstruction() instanceof InvokeInstruction) // if (context.getInstruction() instanceof InvokeInstruction)
{ // {
// field = func(field * constant), the output of the function isn't directly related to the result of field * constant // // field = func(field * constant), the output of the function isn't directly related to the result of field * constant
return fields; // return fields;
} // }
//
if (context.getInstruction() instanceof FieldInstruction) // if (context.getInstruction() instanceof FieldInstruction)
{ // {
FieldInstruction fi = (FieldInstruction) context.getInstruction(); // FieldInstruction fi = (FieldInstruction) context.getInstruction();
Field myf = fi.getMyField(); // Field myf = fi.getMyField();
if (myf != null) // if (myf != null)
fields.add(myf); // fields.add(myf);
} // }
//
if (context.getInstruction() instanceof PushConstantInstruction) // if (context.getInstruction() instanceof PushConstantInstruction)
{ // {
PushConstantInstruction pci = (PushConstantInstruction) context.getInstruction(); // PushConstantInstruction pci = (PushConstantInstruction) context.getInstruction();
int i = (int) pci.getConstant().getObject(); // int i = (int) pci.getConstant().getObject();
constants.add(i); // constants.add(i);
} // }
//
for (StackContext ctx : context.getPops()) // for (StackContext ctx : context.getPops())
{ // {
InstructionContext i = ctx.getPushed(); // InstructionContext i = ctx.getPushed();
//
fields.addAll(check(i, visited, constants)); // fields.addAll(check(i, visited, constants));
} // }
//
for (StackContext ctx : context.getPushes()) // for (StackContext ctx : context.getPushes())
{ // {
InstructionContext i = ctx.getPopped(); // InstructionContext i = ctx.getPopped();
//
if (i == null) // if (i == null)
continue; // continue;
//
fields.addAll(check(i, visited, constants)); // fields.addAll(check(i, visited, constants));
} // }
//
return fields; // return fields;
} // }
@Override @Override
public void run(ClassGroup group) public void run(ClassGroup group)