Lookup methods and return those in getMethods(). Lookup stuff in execution next to the classgraph building.
This commit is contained in:
@@ -4,6 +4,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.runelite.deob.attributes.Code;
|
||||||
|
|
||||||
public class ClassGroup
|
public class ClassGroup
|
||||||
{
|
{
|
||||||
@@ -52,4 +53,19 @@ public class ClassGroup
|
|||||||
for (ClassFile c : classes)
|
for (ClassFile c : classes)
|
||||||
c.buildClassGraph();
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.runelite.deob.execution.Execution;
|
import net.runelite.deob.execution.Execution;
|
||||||
|
|
||||||
@@ -55,16 +56,7 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
|
|||||||
@Override
|
@Override
|
||||||
public List<net.runelite.deob.Method> getMethods()
|
public List<net.runelite.deob.Method> getMethods()
|
||||||
{
|
{
|
||||||
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
|
return myMethods != null ? myMethods : Arrays.asList();
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findMethodFromClass(List<net.runelite.deob.Method> list, ClassFile clazz)
|
private void findMethodFromClass(List<net.runelite.deob.Method> list, ClassFile clazz)
|
||||||
@@ -143,7 +135,16 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
|
|||||||
@Override
|
@Override
|
||||||
public void lookup()
|
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
|
@Override
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.runelite.deob.execution.Execution;
|
import net.runelite.deob.execution.Execution;
|
||||||
|
|
||||||
@@ -50,18 +51,7 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
|
|||||||
@Override
|
@Override
|
||||||
public List<net.runelite.deob.Method> getMethods()
|
public List<net.runelite.deob.Method> getMethods()
|
||||||
{
|
{
|
||||||
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
|
return myMethods != null ? myMethods : Arrays.asList();
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -136,7 +126,18 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
|
|||||||
@Override
|
@Override
|
||||||
public void lookup()
|
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
|
@Override
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.runelite.deob.execution.Execution;
|
import net.runelite.deob.execution.Execution;
|
||||||
|
|
||||||
@@ -57,18 +58,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
|
|||||||
@Override
|
@Override
|
||||||
public List<net.runelite.deob.Method> getMethods()
|
public List<net.runelite.deob.Method> getMethods()
|
||||||
{
|
{
|
||||||
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
|
return myMethods != null ? myMethods : Arrays.asList();
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -140,7 +130,18 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
|
|||||||
@Override
|
@Override
|
||||||
public void lookup()
|
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
|
@Override
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.runelite.deob.execution.Execution;
|
import net.runelite.deob.execution.Execution;
|
||||||
|
|
||||||
@@ -96,16 +97,7 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
|
|||||||
@Override
|
@Override
|
||||||
public List<net.runelite.deob.Method> getMethods()
|
public List<net.runelite.deob.Method> getMethods()
|
||||||
{
|
{
|
||||||
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
|
return myMethods != null ? myMethods : Arrays.asList();
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findMethodFromClass(List<net.runelite.deob.Method> list, ClassFile clazz)
|
private void findMethodFromClass(List<net.runelite.deob.Method> list, ClassFile clazz)
|
||||||
@@ -141,7 +133,16 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
|
|||||||
@Override
|
@Override
|
||||||
public void lookup()
|
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
|
@Override
|
||||||
|
|||||||
@@ -255,19 +255,6 @@ public class RenameUnique implements Deobfuscator
|
|||||||
return map;
|
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)
|
private void regeneratePool(ClassGroup group)
|
||||||
{
|
{
|
||||||
for (ClassFile cf : group.getClasses())
|
for (ClassFile cf : group.getClasses())
|
||||||
@@ -285,7 +272,6 @@ public class RenameUnique implements Deobfuscator
|
|||||||
public void run(ClassGroup group)
|
public void run(ClassGroup group)
|
||||||
{
|
{
|
||||||
group.buildClassGraph();
|
group.buildClassGraph();
|
||||||
lookup(group);
|
|
||||||
|
|
||||||
NameMappings mappings = this.generateClassNames(group);
|
NameMappings mappings = this.generateClassNames(group);
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public class Execution
|
|||||||
List<Method> methods = new ArrayList<>();
|
List<Method> methods = new ArrayList<>();
|
||||||
|
|
||||||
group.buildClassGraph(); // required when looking up methods
|
group.buildClassGraph(); // required when looking up methods
|
||||||
|
group.lookup(); // lookup methods
|
||||||
|
|
||||||
for (ClassFile cf : group.getClasses())
|
for (ClassFile cf : group.getClasses())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user