diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/ArrayStore.java b/src/main/java/net/runelite/deob/attributes/code/instructions/ArrayStore.java index 83da0276b6..01147b4c4c 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/ArrayStore.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/ArrayStore.java @@ -4,6 +4,7 @@ import net.runelite.deob.Field; 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.ArrayLoad; import net.runelite.deob.attributes.code.instruction.types.ArrayStoreInstruction; import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction; import net.runelite.deob.deobfuscators.rename.MappingExecutorUtil; @@ -48,6 +49,28 @@ public abstract class ArrayStore extends Instruction implements ArrayStoreInstru otherField = ((ArrayStore) other.getInstruction()).getMyField(other); mapping.map(myField, otherField); + + // map value + + StackContext object1 = ctx.getPops().get(0), // value set to. + 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 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 f1a5fc1133..bfaff7fb63 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 @@ -131,6 +131,8 @@ public class PutField extends Instruction implements SetFieldInstruction mapping.map(f1, f2); } } + + // XXX also map value here? } @Override diff --git a/src/main/java/net/runelite/deob/deobfuscators/rename/MappingExecutorUtil.java b/src/main/java/net/runelite/deob/deobfuscators/rename/MappingExecutorUtil.java index 699ea1a77f..14d42fb757 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/rename/MappingExecutorUtil.java +++ b/src/main/java/net/runelite/deob/deobfuscators/rename/MappingExecutorUtil.java @@ -7,20 +7,17 @@ import java.util.stream.Collectors; import net.runelite.deob.ClassGroup; import net.runelite.deob.Method; import net.runelite.deob.attributes.code.Instruction; -import net.runelite.deob.attributes.code.instruction.types.ComparisonInstruction; +import net.runelite.deob.attributes.code.instruction.types.ArrayLoad; import net.runelite.deob.attributes.code.instruction.types.DupInstruction; import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction; import net.runelite.deob.attributes.code.instruction.types.LVTInstruction; import net.runelite.deob.attributes.code.instruction.types.MappableInstruction; import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction; -import net.runelite.deob.attributes.code.instruction.types.ReturnInstruction; import net.runelite.deob.attributes.code.instruction.types.SetFieldInstruction; -import net.runelite.deob.attributes.code.instructions.AALoad; import net.runelite.deob.attributes.code.instructions.InvokeStatic; import net.runelite.deob.execution.Execution; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; -import net.runelite.deob.execution.MethodContext; import net.runelite.deob.execution.ParallellMappingExecutor; import net.runelite.deob.execution.StackContext; import net.runelite.deob.execution.VariableContext; @@ -272,10 +269,10 @@ public class MappingExecutorUtil return resolve(s.getPushed(), s); } - if (ctx.getInstruction() instanceof AALoad) + if (ctx.getInstruction() instanceof ArrayLoad) { // might be multidimensional array - StackContext s = ctx.getPops().get(1); + StackContext s = ctx.getPops().get(1); // the array return resolve(s.getPushed(), s); } diff --git a/src/test/java/net/runelite/deob/deobfuscators/rename/AnnotationMapperTest.java b/src/test/java/net/runelite/deob/deobfuscators/rename/AnnotationMapperTest.java index 611073316a..9c7d585bfe 100644 --- a/src/test/java/net/runelite/deob/deobfuscators/rename/AnnotationMapperTest.java +++ b/src/test/java/net/runelite/deob/deobfuscators/rename/AnnotationMapperTest.java @@ -9,8 +9,8 @@ import org.junit.Test; public class AnnotationMapperTest { private static final String JAR1 = "C:\\Users\\Adam\\.m2\\repository\\net\\runelite\\rs\\rs-client\\1.0-SNAPSHOT\\rs-client-1.0-SNAPSHOT.jar", - JAR2 = "c:/rs/gamepack_v18_deobbed.jar", - OUT = "c:/rs/adamout.jar"; + JAR2 = "d:/rs/07/gamepack_v18_deobbed.jar", + OUT = "d:/rs/07/adamout.jar"; @Test public void testRun() throws IOException diff --git a/src/test/java/net/runelite/deob/deobfuscators/rename/MapStaticTest.java b/src/test/java/net/runelite/deob/deobfuscators/rename/MapStaticTest.java index 138d496fb2..fc9d9213e3 100644 --- a/src/test/java/net/runelite/deob/deobfuscators/rename/MapStaticTest.java +++ b/src/test/java/net/runelite/deob/deobfuscators/rename/MapStaticTest.java @@ -614,20 +614,22 @@ public class MapStaticTest @Test public void testPacket() throws IOException { + String JAR1 = "C:\\Users\\Adam\\.m2\\repository\\net\\runelite\\rs\\rs-client\\1.0-SNAPSHOT\\rs-client-1.0-SNAPSHOT.jar", + JAR2 = "d:/rs/07/gamepack_v18_deobbed.jar"; + ClassGroup group1 = JarUtil.loadJar(new File(JAR1)); ClassGroup group2 = JarUtil.loadJar(new File(JAR2)); - group1.findClass("client").findField("field446").packetHandler = true; - group2.findClass("client").findField("field324").packetHandler = true; + group1.findClass("client").findField("field333").packetHandler = true; + group2.findClass("client").findField("field488").packetHandler = true; - Method m1 = group1.findClass("client").findMethod("vmethod3096"); - Method m2 = group2.findClass("client").findMethod("vmethod2975"); + Method m1 = group1.findClass("client").findMethod("vmethod2968"); + Method m2 = group2.findClass("client").findMethod("vmethod3044"); ParallelExecutorMapping mappings = MappingExecutorUtil.map(m1, m2); - // var55 = class17.method214(); vs var107 = class25.field625[++class25.field624 - 1]; - PacketHandler h1 = mappings.findPacketHandler1(127); - PacketHandler h2 = mappings.findPacketHandler2(160); + PacketHandler h1 = mappings.findPacketHandler1(9); + PacketHandler h2 = mappings.findPacketHandler2(25); ParallelExecutorMapping mapping = MappingExecutorUtil.mapFrame(group1, group2, h1.getFirstInsOfHandler(), h2.getFirstInsOfHandler()); diff --git a/src/test/java/net/runelite/deob/deobfuscators/rename/MapperTest.java b/src/test/java/net/runelite/deob/deobfuscators/rename/MapperTest.java index 555f1090c1..0df3276f35 100644 --- a/src/test/java/net/runelite/deob/deobfuscators/rename/MapperTest.java +++ b/src/test/java/net/runelite/deob/deobfuscators/rename/MapperTest.java @@ -1,37 +1,37 @@ -package net.runelite.deob.deobfuscators.rename; - -import java.io.File; -import java.io.IOException; -import net.runelite.deob.ClassGroup; -import static net.runelite.deob.deobfuscators.rename.MapStaticTest.print; -import static net.runelite.deob.deobfuscators.rename.MapStaticTest.summary; -import net.runelite.deob.util.JarUtil; -import org.junit.Test; - -// Compares two deobfuscated versions of the client -public class MapperTest -{ - private static final String JAR1 = "C:\\Users\\Adam\\.m2\\repository\\net\\runelite\\rs\\rs-client\\1.0-SNAPSHOT\\rs-client-1.0-SNAPSHOT.jar",//"d:/rs/07/gamepack_v16_deobbed.jar", - JAR2 = MapperTest.class.getResource("/gamepack_v16_deobbed.jar").getFile(); -// private static final String JAR1 = MapStaticTest.class.getResource("/adamin1.jar").getFile(), -// JAR2 = MapStaticTest.class.getResource("/adamin2.jar").getFile(); - - @Test - public void testRun() throws IOException - { - ClassGroup group1 = JarUtil.loadJar(new File(JAR1)); - ClassGroup group2 = JarUtil.loadJar(new File(JAR2)); - - Mapper mapper = new Mapper(group1, group2); - mapper.run(); - ParallelExecutorMapping mapping = mapper.getMapping(); - - summary(mapping, group1); - - String sg1 = print(group1), - sg2 = print(group2); - - System.out.println("GROUP 1 " + sg1); - System.out.println("GROUP 2 " + sg2); - } -} +package net.runelite.deob.deobfuscators.rename; + +import java.io.File; +import java.io.IOException; +import net.runelite.deob.ClassGroup; +import static net.runelite.deob.deobfuscators.rename.MapStaticTest.print; +import static net.runelite.deob.deobfuscators.rename.MapStaticTest.summary; +import net.runelite.deob.util.JarUtil; +import org.junit.Test; + +// Compares two deobfuscated versions of the client +public class MapperTest +{ + private static final String JAR1 = "C:\\Users\\Adam\\.m2\\repository\\net\\runelite\\rs\\rs-client\\1.0-SNAPSHOT\\rs-client-1.0-SNAPSHOT.jar", + JAR2 = "c:/rs/gamepack_v18_deobbed.jar"; +// private static final String JAR1 = MapStaticTest.class.getResource("/adamin1.jar").getFile(), +// JAR2 = MapStaticTest.class.getResource("/adamin2.jar").getFile(); + + @Test + public void testRun() throws IOException + { + ClassGroup group1 = JarUtil.loadJar(new File(JAR1)); + ClassGroup group2 = JarUtil.loadJar(new File(JAR2)); + + Mapper mapper = new Mapper(group1, group2); + mapper.run(); + ParallelExecutorMapping mapping = mapper.getMapping(); + + summary(mapping, group1); + + String sg1 = print(group1), + sg2 = print(group2); + + System.out.println("GROUP 1 " + sg1); + System.out.println("GROUP 2 " + sg2); + } +}