Idr this. Some fields have different accessors (at least public) between versions and is messing with this.
This commit is contained in:
@@ -1,133 +0,0 @@
|
||||
//package net.runelite.deob.execution;
|
||||
//
|
||||
//import net.runelite.deob.ClassGroup;
|
||||
//import net.runelite.deob.ClassGroupFactory;
|
||||
//import net.runelite.deob.Method;
|
||||
//import net.runelite.deob.attributes.Code;
|
||||
//import net.runelite.deob.attributes.code.Instruction;
|
||||
//import net.runelite.deob.attributes.code.Instructions;
|
||||
//import net.runelite.deob.attributes.code.instructions.Goto;
|
||||
//import net.runelite.deob.attributes.code.instructions.IConst_0;
|
||||
//import net.runelite.deob.attributes.code.instructions.If0;
|
||||
//import net.runelite.deob.attributes.code.instructions.InvokeStatic;
|
||||
//import net.runelite.deob.attributes.code.instructions.NOP;
|
||||
//import net.runelite.deob.attributes.code.instructions.VReturn;
|
||||
//import net.runelite.deob.deobfuscators.rename.graph.Graph;
|
||||
//import org.junit.Assert;
|
||||
//import org.junit.Test;
|
||||
//
|
||||
//public class FrameTest
|
||||
//{
|
||||
// // invoke instruction,
|
||||
// // conditional jump out,
|
||||
// // both jump in,
|
||||
// // jump,
|
||||
// // invoke
|
||||
// // check that num edges = 4
|
||||
// @Test
|
||||
// public void testGraph()
|
||||
// {
|
||||
// ClassGroup group = ClassGroupFactory.generateGroup();
|
||||
// Code code = group.findClass("test").findMethod("func").getCode();
|
||||
// Instructions ins = code.getInstructions();
|
||||
//
|
||||
// code.setMaxStack(1);
|
||||
//
|
||||
// Method void1 = group.findClass("test").findMethod("void1"),
|
||||
// void2 = group.findClass("test").findMethod("void2"),
|
||||
// void3 = group.findClass("test").findMethod("void3"),
|
||||
// void4 = group.findClass("test").findMethod("void4");
|
||||
//
|
||||
// NOP label1 = new NOP(ins),
|
||||
// label2 = new NOP(ins),
|
||||
// label3 = new NOP(ins);
|
||||
//
|
||||
// Instruction body[] = {
|
||||
// new InvokeStatic(ins, void1.getPoolMethod()),
|
||||
//
|
||||
// new IConst_0(ins),
|
||||
// new If0(ins, label1),
|
||||
//
|
||||
// new InvokeStatic(ins, void2.getPoolMethod()),
|
||||
// new Goto(ins, label2),
|
||||
//
|
||||
// label1,
|
||||
// new InvokeStatic(ins, void3.getPoolMethod()),
|
||||
//
|
||||
// label2,
|
||||
// // do something dumb
|
||||
//
|
||||
// new Goto(ins, label3),
|
||||
// label3,
|
||||
//
|
||||
// new InvokeStatic(ins, void4.getPoolMethod()),
|
||||
//
|
||||
// new VReturn(ins)
|
||||
// };
|
||||
//
|
||||
// for (Instruction i : body)
|
||||
// ins.addInstruction(i);
|
||||
//
|
||||
// Execution e = new Execution(group);
|
||||
// e.setBuildGraph(true);
|
||||
// e.populateInitialMethods();
|
||||
// e.run();
|
||||
//
|
||||
// Graph graph = e.processedFrames.get(0).getMethodCtx().getGraph();
|
||||
// Assert.assertEquals(4, graph.size());
|
||||
// }
|
||||
//
|
||||
// // invoke instruction,
|
||||
// // conditional jump out,
|
||||
// // both jump in,
|
||||
// // invoke
|
||||
// // check that num edges = 4
|
||||
// @Test
|
||||
// public void testGraph2()
|
||||
// {
|
||||
// ClassGroup group = ClassGroupFactory.generateGroup();
|
||||
// Code code = group.findClass("test").findMethod("func").getCode();
|
||||
// Instructions ins = code.getInstructions();
|
||||
//
|
||||
// code.setMaxStack(1);
|
||||
//
|
||||
// Method void1 = group.findClass("test").findMethod("void1"),
|
||||
// void2 = group.findClass("test").findMethod("void2"),
|
||||
// void3 = group.findClass("test").findMethod("void3"),
|
||||
// void4 = group.findClass("test").findMethod("void4");
|
||||
//
|
||||
// NOP label1 = new NOP(ins),
|
||||
// label2 = new NOP(ins);
|
||||
//
|
||||
// Instruction body[] = {
|
||||
// new InvokeStatic(ins, void1.getPoolMethod()),
|
||||
//
|
||||
// new IConst_0(ins),
|
||||
// new If0(ins, label1),
|
||||
//
|
||||
// new InvokeStatic(ins, void2.getPoolMethod()),
|
||||
// new Goto(ins, label2),
|
||||
//
|
||||
// label1,
|
||||
// new InvokeStatic(ins, void3.getPoolMethod()),
|
||||
//
|
||||
// label2,
|
||||
// // do something dumb
|
||||
//
|
||||
// new InvokeStatic(ins, void4.getPoolMethod()),
|
||||
//
|
||||
// new VReturn(ins)
|
||||
// };
|
||||
//
|
||||
// for (Instruction i : body)
|
||||
// ins.addInstruction(i);
|
||||
//
|
||||
// Execution e = new Execution(group);
|
||||
// e.setBuildGraph(true);
|
||||
// e.populateInitialMethods();
|
||||
// e.run();
|
||||
//
|
||||
// Graph graph = e.processedFrames.get(0).getMethodCtx().getGraph();
|
||||
// Assert.assertEquals(4, graph.size());
|
||||
// }
|
||||
//}
|
||||
138
src/test/java/net/runelite/deob/execution/GraphTest.java
Normal file
138
src/test/java/net/runelite/deob/execution/GraphTest.java
Normal file
@@ -0,0 +1,138 @@
|
||||
package net.runelite.deob.execution;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import net.runelite.deob.ClassFile;
|
||||
import net.runelite.deob.ClassGroup;
|
||||
import net.runelite.deob.Method;
|
||||
import net.runelite.deob.deobfuscators.rename.InstructionList;
|
||||
import net.runelite.deob.deobfuscators.rename.Rename2;
|
||||
import net.runelite.deob.deobfuscators.rename.graph.Graph;
|
||||
import net.runelite.deob.deobfuscators.rename.graph.Vertex;
|
||||
import net.runelite.deob.util.NameMappings;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
class TestClass2
|
||||
{
|
||||
int array[];
|
||||
int count;
|
||||
|
||||
void method1()
|
||||
{
|
||||
array[++count - 1] = 1;
|
||||
array[++count - 1] = 2;
|
||||
}
|
||||
|
||||
void method2()
|
||||
{
|
||||
array[++count - 1] = 1;
|
||||
array[++count - 1] = 2;
|
||||
array[++count - 1] = 3;
|
||||
array[++count - 1] = 4;
|
||||
}
|
||||
}
|
||||
|
||||
public class GraphTest
|
||||
{
|
||||
private ClassGroup loadClassGroup(String name) throws IOException
|
||||
{
|
||||
ClassGroup group = new ClassGroup();
|
||||
|
||||
ClassFile cf = this.loadClass(name);
|
||||
group.addClass(cf);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
private ClassFile loadClass(String name) throws IOException
|
||||
{
|
||||
InputStream in = this.getClass().getClassLoader().getResourceAsStream("net/runelite/deob/execution/" + name + ".class");
|
||||
Assert.assertNotNull(in);
|
||||
|
||||
ClassGroup group = new ClassGroup();
|
||||
ClassFile cf = new ClassFile(group, new DataInputStream(in));
|
||||
group.addClass(cf);
|
||||
return cf;
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void test() throws IOException
|
||||
{
|
||||
ClassGroup group1 = this.loadClassGroup("TestClass"), group2 = this.loadClassGroup("TestClass");
|
||||
|
||||
Execution e = new Execution(group1);
|
||||
e.setBuildGraph(true);
|
||||
e.populateInitialMethods();
|
||||
e.run();
|
||||
|
||||
Execution e2 = new Execution(group2);
|
||||
e2.setBuildGraph(true);
|
||||
e2.populateInitialMethods();
|
||||
e2.run();
|
||||
|
||||
Graph graph = e.getGraph();
|
||||
Graph graph2 = e2.getGraph();
|
||||
|
||||
Assert.assertEquals(4, graph.getVerticies().size());
|
||||
|
||||
Method m = group1.getClasses().get(0).findMethod("init");
|
||||
Vertex v = graph.getVertexFor(m);
|
||||
|
||||
Assert.assertEquals(1, v.getEdges().size());
|
||||
|
||||
m = group1.getClasses().get(0).findMethod("method2");
|
||||
v = graph.getVertexFor(m);
|
||||
|
||||
Assert.assertEquals(1, v.getEdges().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() throws IOException
|
||||
{
|
||||
ClassGroup group1 = this.loadClassGroup("one/TestClass"), group2 = this.loadClassGroup("two/TestClass");
|
||||
Rename2 rename2 = new Rename2();
|
||||
NameMappings mappings = rename2.run(group1, group2); // 2->1
|
||||
|
||||
ClassFile cf1 = group1.getClasses().get(0),
|
||||
cf2 = group2.getClasses().get(0);
|
||||
|
||||
Method m2 = cf2.findMethod("init");
|
||||
Assert.assertTrue(mappings.get(m2.getPoolMethod()).equals("init"));
|
||||
|
||||
m2 = cf2.findMethod("method6");
|
||||
String to = mappings.get(m2.getPoolMethod());
|
||||
Assert.assertNotNull(to);
|
||||
Assert.assertTrue(to.equals("method2"));
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void testVertexEquals() throws IOException
|
||||
{
|
||||
ClassGroup group1 = this.loadClassGroup("one/TestClass"), group2 = this.loadClassGroup("two/TestClass");
|
||||
|
||||
ClassFile cf1 = group1.getClasses().get(0),
|
||||
cf2 = group2.getClasses().get(0);
|
||||
|
||||
Graph g1 = new Graph(), g2 = new Graph();
|
||||
|
||||
Vertex v1 = new Vertex(g1, cf2.findMethod("method6")),
|
||||
v2 = new Vertex(g2, cf1.findMethod("method2"));
|
||||
|
||||
Assert.assertTrue(v1.couldBeEqual(v2));
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void test3() throws IOException
|
||||
{
|
||||
ClassFile cf1 = this.loadClass("TestClass2"), cf2 = this.loadClass("TestClass2");
|
||||
|
||||
Method m1 = cf1.findMethod("method1"), m2 = cf2.findMethod("method2");
|
||||
|
||||
InstructionList il1 = new InstructionList(m1.getCode().getInstructions().getInstructions()),
|
||||
il2 = new InstructionList(m2.getCode().getInstructions().getInstructions());
|
||||
|
||||
Assert.assertFalse(il1.couldBeEqual(il2));
|
||||
}
|
||||
}
|
||||
30
src/test/java/net/runelite/deob/execution/one/TestClass.java
Normal file
30
src/test/java/net/runelite/deob/execution/one/TestClass.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package net.runelite.deob.execution.one;
|
||||
|
||||
public class TestClass
|
||||
{
|
||||
int i;
|
||||
|
||||
public void init()
|
||||
{
|
||||
method1(this);
|
||||
}
|
||||
|
||||
static void method1(TestClass tc)
|
||||
{
|
||||
tc.method2();
|
||||
}
|
||||
|
||||
void method2()
|
||||
{
|
||||
if (i > 42)
|
||||
{
|
||||
int i = 5 + 6;
|
||||
method3();
|
||||
}
|
||||
}
|
||||
|
||||
void method3()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
30
src/test/java/net/runelite/deob/execution/two/TestClass.java
Normal file
30
src/test/java/net/runelite/deob/execution/two/TestClass.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package net.runelite.deob.execution.two;
|
||||
|
||||
public class TestClass
|
||||
{
|
||||
int i;
|
||||
|
||||
public void init()
|
||||
{
|
||||
method5(this);
|
||||
}
|
||||
|
||||
static void method5(TestClass tc)
|
||||
{
|
||||
tc.method6();
|
||||
}
|
||||
|
||||
void method6()
|
||||
{
|
||||
if (i > 42)
|
||||
{
|
||||
int i = 5 + 6;
|
||||
method7();
|
||||
}
|
||||
}
|
||||
|
||||
void method7()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user