Rename unique non overriden methods

This commit is contained in:
Adam
2015-07-10 22:00:12 -04:00
parent 26458e7280
commit b03a0e3181
13 changed files with 148 additions and 17 deletions

View File

@@ -3,6 +3,7 @@ package info.sigterm.deob.attributes.code;
import info.sigterm.deob.ClassFile;
import info.sigterm.deob.ConstantPool;
import info.sigterm.deob.Field;
import info.sigterm.deob.Method;
import info.sigterm.deob.execution.Frame;
import java.io.DataOutputStream;
@@ -216,4 +217,8 @@ public abstract class Instruction
public void renameField(Field f, String name)
{
}
public void renameMethod(Method m, String name)
{
}
}

View File

@@ -2,6 +2,7 @@ package info.sigterm.deob.attributes.code;
import info.sigterm.deob.ClassFile;
import info.sigterm.deob.Field;
import info.sigterm.deob.Method;
import info.sigterm.deob.attributes.Code;
import info.sigterm.deob.attributes.code.instruction.types.JumpingInstruction;
@@ -209,4 +210,10 @@ public class Instructions
for (Instruction i : instructions)
i.renameField(f, name);
}
public void renameMethod(Method m, String name)
{
for (Instruction i : instructions)
i.renameMethod(m, name);
}
}

View File

@@ -62,7 +62,7 @@ public class GetStatic extends Instruction implements GetFieldInstruction
if (cf == null)
return;
info.sigterm.deob.Field f = cf.findField(nat);
info.sigterm.deob.Field f = cf.findFieldDeep(nat);
assert f != null;
f.addReference(this);

View File

@@ -64,7 +64,7 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
private void findMethodFromClass(List<info.sigterm.deob.Method> list, ClassFile clazz)
{
info.sigterm.deob.Method m = clazz.findMethod(method.getNameAndType());
info.sigterm.deob.Method m = clazz.findMethodDeep(method.getNameAndType());
if (m != null)
list.add(m);
@@ -163,4 +163,11 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
if (method.getClassEntry().getName().equals(cf.getName()))
method = new InterfaceMethod(new Class(name), method.getNameAndType());
}
@Override
public void renameMethod(info.sigterm.deob.Method m, String name)
{
if (method.getNameAndType().equals(m.getNameAndType()) && method.getClassEntry().getName().equals(m.getMethods().getClassFile().getName()))
method = new InterfaceMethod(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor()));
}
}

View File

@@ -51,7 +51,7 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
if (otherClass == null)
return new ArrayList<>(); // not our class
info.sigterm.deob.Method other = otherClass.findMethod(method.getNameAndType());
info.sigterm.deob.Method other = otherClass.findMethodDeep(method.getNameAndType());
List<info.sigterm.deob.Method> list = new ArrayList<>();
list.add(other);
@@ -155,4 +155,11 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
if (method.getClassEntry().getName().equals(cf.getName()))
method = new Method(new Class(name), method.getNameAndType());
}
@Override
public void renameMethod(info.sigterm.deob.Method m, String name)
{
if (method.getNameAndType().equals(m.getNameAndType()) && method.getClassEntry().getName().equals(m.getMethods().getClassFile().getName()))
method = new Method(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor()));
}
}

View File

@@ -51,7 +51,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
if (otherClass == null)
return new ArrayList<>(); // not our class
info.sigterm.deob.Method other = otherClass.findMethod(method.getNameAndType());
info.sigterm.deob.Method other = otherClass.findMethodDeep(method.getNameAndType());
List<info.sigterm.deob.Method> list = new ArrayList<>();
list.add(other);
@@ -152,4 +152,11 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
if (method.getClassEntry().getName().equals(cf.getName()))
method = new Method(new Class(name), method.getNameAndType());
}
@Override
public void renameMethod(info.sigterm.deob.Method m, String name)
{
if (method.getNameAndType().equals(m.getNameAndType()) && method.getClassEntry().getName().equals(m.getMethods().getClassFile().getName()))
method = new Method(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor()));
}
}

View File

@@ -99,7 +99,7 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
private void findMethodFromClass(List<info.sigterm.deob.Method> list, ClassFile clazz)
{
info.sigterm.deob.Method m = clazz.findMethod(method.getNameAndType());
info.sigterm.deob.Method m = clazz.findMethodDeep(method.getNameAndType());
if (m != null)
list.add(m);
@@ -162,4 +162,11 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
if (method.getClassEntry().getName().equals(cf.getName()))
method = new Method(new Class(name), method.getNameAndType());
}
@Override
public void renameMethod(info.sigterm.deob.Method m, String name)
{
if (method.getNameAndType().equals(m.getNameAndType()) && method.getClassEntry().getName().equals(m.getMethods().getClassFile().getName()))
method = new Method(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor()));
}
}