Lookup methods and return those in getMethods(). Lookup stuff in execution next to the classgraph building.

This commit is contained in:
Adam
2015-11-14 22:07:44 -05:00
parent 337e98fb95
commit 66084e1398
7 changed files with 69 additions and 62 deletions

View File

@@ -4,6 +4,7 @@ import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.runelite.deob.attributes.Code;
public class ClassGroup
{
@@ -52,4 +53,19 @@ public class ClassGroup
for (ClassFile c : classes)
c.buildClassGraph();
}
public void lookup()
{
for (ClassFile cf : this.getClasses())
for (Method m : cf.getMethods().getMethods())
{
Code code = m.getCode();
if (code == null)
continue;
code.getInstructions().lookup();
}
}
}

View File

@@ -20,6 +20,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.runelite.deob.execution.Execution;
@@ -55,16 +56,7 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
@Override
public List<net.runelite.deob.Method> getMethods()
{
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
if (otherClass == null)
return new ArrayList<>(); // not our class
// look up this method in this class and anything that inherits from it
List<net.runelite.deob.Method> list = new ArrayList<>();
findMethodFromClass(list, otherClass);
return list;
return myMethods != null ? myMethods : Arrays.asList();
}
private void findMethodFromClass(List<net.runelite.deob.Method> list, ClassFile clazz)
@@ -143,7 +135,16 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
@Override
public void lookup()
{
myMethods = this.getMethods();
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
if (otherClass == null)
return; // not our class
// look up this method in this class and anything that inherits from it
List<net.runelite.deob.Method> list = new ArrayList<>();
findMethodFromClass(list, otherClass);
myMethods = list;
}
@Override

View File

@@ -20,6 +20,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.runelite.deob.execution.Execution;
@@ -50,18 +51,7 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
@Override
public List<net.runelite.deob.Method> getMethods()
{
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
if (otherClass == null)
return new ArrayList<>(); // not our class
net.runelite.deob.Method other = otherClass.findMethod(method.getNameAndType());
assert other != null;
List<net.runelite.deob.Method> list = new ArrayList<>();
list.add(other);
return list;
return myMethods != null ? myMethods : Arrays.asList();
}
@Override
@@ -136,7 +126,18 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
@Override
public void lookup()
{
myMethods = this.getMethods();
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
if (otherClass == null)
return; // not our class
net.runelite.deob.Method other = otherClass.findMethod(method.getNameAndType());
assert other != null;
List<net.runelite.deob.Method> list = new ArrayList<>();
list.add(other);
myMethods = list;
}
@Override

View File

@@ -20,6 +20,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.runelite.deob.execution.Execution;
@@ -57,18 +58,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
@Override
public List<net.runelite.deob.Method> getMethods()
{
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
if (otherClass == null)
return new ArrayList<>(); // not our class
net.runelite.deob.Method other = otherClass.findMethodDeepStatic(method.getNameAndType());
assert other != null;
List<net.runelite.deob.Method> list = new ArrayList<>();
list.add(other);
return list;
return myMethods != null ? myMethods : Arrays.asList();
}
@Override
@@ -140,7 +130,18 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
@Override
public void lookup()
{
myMethods = this.getMethods();
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
if (otherClass == null)
return; // not our class
net.runelite.deob.Method other = otherClass.findMethodDeepStatic(method.getNameAndType());
assert other != null;
List<net.runelite.deob.Method> list = new ArrayList<>();
list.add(other);
myMethods = list;
}
@Override

View File

@@ -20,6 +20,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.runelite.deob.execution.Execution;
@@ -96,16 +97,7 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
@Override
public List<net.runelite.deob.Method> getMethods()
{
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
if (otherClass == null)
return new ArrayList<>(); // not our class
// look up this method in this class and anything that inherits from it
List<net.runelite.deob.Method> list = new ArrayList<>();
findMethodFromClass(list, otherClass);
return list;
return myMethods != null ? myMethods : Arrays.asList();
}
private void findMethodFromClass(List<net.runelite.deob.Method> list, ClassFile clazz)
@@ -141,7 +133,16 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
@Override
public void lookup()
{
myMethods = this.getMethods();
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
if (otherClass == null)
return; // not our class
// look up this method in this class and anything that inherits from it
List<net.runelite.deob.Method> list = new ArrayList<>();
findMethodFromClass(list, otherClass);
myMethods = list;
}
@Override

View File

@@ -255,19 +255,6 @@ public class RenameUnique implements Deobfuscator
return map;
}
private void lookup(ClassGroup group)
{
for (ClassFile cf : group.getClasses())
for (Method m : cf.getMethods().getMethods())
{
Code c = m.getCode();
if (c == null)
continue;
c.getInstructions().lookup();
}
}
private void regeneratePool(ClassGroup group)
{
for (ClassFile cf : group.getClasses())
@@ -285,7 +272,6 @@ public class RenameUnique implements Deobfuscator
public void run(ClassGroup group)
{
group.buildClassGraph();
lookup(group);
NameMappings mappings = this.generateClassNames(group);

View File

@@ -48,6 +48,7 @@ public class Execution
List<Method> methods = new ArrayList<>();
group.buildClassGraph(); // required when looking up methods
group.lookup(); // lookup methods
for (ClassFile cf : group.getClasses())
{