From d833b53646221b27d5ddc1a33ab33cb64356bcac Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 13 Feb 2016 19:00:18 -0500 Subject: [PATCH] map value of putfields --- .../code/instructions/PutField.java | 29 +++++++++++++++---- .../code/instructions/PutStatic.java | 22 ++++++++++++++ 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/PutField.java b/src/main/java/net/runelite/deob/attributes/code/instructions/PutField.java index 36e87d989d..049951bb5c 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/PutField.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/PutField.java @@ -17,8 +17,10 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.runelite.deob.Method; +import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction; import net.runelite.deob.attributes.code.instruction.types.MappableInstruction; import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction; +import net.runelite.deob.deobfuscators.rename.MappingExecutorUtil; import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping; public class PutField extends Instruction implements SetFieldInstruction @@ -97,11 +99,6 @@ public class PutField extends Instruction implements SetFieldInstruction if (myField != null) field = myField.getPoolField(); } - - private boolean isConstantAssignment(InstructionContext ctx) - { - return ctx.getPops().get(0).getPushed().getInstruction() instanceof PushConstantInstruction; - } @Override public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other) @@ -112,6 +109,28 @@ public class PutField extends Instruction implements SetFieldInstruction assert myField.getType().equals(otherField.getType()); mapping.map(myField, otherField); + + // map assignment + + StackContext object1 = ctx.getPops().get(1), + object2 = other.getPops().get(1); + + InstructionContext base1 = MappingExecutorUtil.resolve(object1.getPushed(), object1); + InstructionContext base2 = MappingExecutorUtil.resolve(object2.getPushed(), object2); + + if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction) + { + GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(), + gf2 = (GetFieldInstruction) base2.getInstruction(); + + net.runelite.deob.Field f1 = gf1.getMyField(), + f2 = gf2.getMyField(); + + if (f1 != null && f2 != null) + { + mapping.map(f1, f2); + } + } } @Override diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/PutStatic.java b/src/main/java/net/runelite/deob/attributes/code/instructions/PutStatic.java index 00d8ef5ce9..be3774f2b5 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/PutStatic.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/PutStatic.java @@ -17,7 +17,9 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.runelite.deob.Method; +import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction; import net.runelite.deob.attributes.code.instruction.types.MappableInstruction; +import net.runelite.deob.deobfuscators.rename.MappingExecutorUtil; import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping; public class PutStatic extends Instruction implements SetFieldInstruction @@ -105,6 +107,26 @@ public class PutStatic extends Instruction implements SetFieldInstruction assert myField.getType().equals(otherField.getType()); mapping.map(myField, otherField); + + StackContext object1 = ctx.getPops().get(0), + object2 = other.getPops().get(0); + + InstructionContext base1 = MappingExecutorUtil.resolve(object1.getPushed(), object1); + InstructionContext base2 = MappingExecutorUtil.resolve(object2.getPushed(), object2); + + if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction) + { + GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(), + gf2 = (GetFieldInstruction) base2.getInstruction(); + + net.runelite.deob.Field f1 = gf1.getMyField(), + f2 = gf2.getMyField(); + + if (f1 != null && f2 != null) + { + mapping.map(f1, f2); + } + } } @Override