Rest of rename unique. Untested but asm looks ok.
This commit is contained in:
@@ -162,6 +162,19 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
|
||||
{
|
||||
if (method.getClassEntry().getName().equals(cf.getName()))
|
||||
method = new InterfaceMethod(new Class(name), method.getNameAndType());
|
||||
|
||||
Signature signature = method.getNameAndType().getDescriptor();
|
||||
for (int i = 0; i < signature.size(); ++i)
|
||||
{
|
||||
info.sigterm.deob.signature.Type type = signature.getTypeOfArg(i);
|
||||
|
||||
if (type.getType().equals("L" + cf.getName() + ";"))
|
||||
signature.setTypeOfArg(i, new info.sigterm.deob.signature.Type("L" + name + ";", type.getArrayDims()));
|
||||
}
|
||||
|
||||
// rename return type
|
||||
if (signature.getReturnValue().getType().equals("L" + cf.getName() + ";"))
|
||||
signature.setTypeOfReturnValue(new info.sigterm.deob.signature.Type("L" + name + ";", signature.getReturnValue().getArrayDims()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -154,6 +154,19 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
|
||||
{
|
||||
if (method.getClassEntry().getName().equals(cf.getName()))
|
||||
method = new Method(new Class(name), method.getNameAndType());
|
||||
|
||||
Signature signature = method.getNameAndType().getDescriptor();
|
||||
for (int i = 0; i < signature.size(); ++i)
|
||||
{
|
||||
info.sigterm.deob.signature.Type type = signature.getTypeOfArg(i);
|
||||
|
||||
if (type.getType().equals("L" + cf.getName() + ";"))
|
||||
signature.setTypeOfArg(i, new info.sigterm.deob.signature.Type("L" + name + ";", type.getArrayDims()));
|
||||
}
|
||||
|
||||
// rename return type
|
||||
if (signature.getReturnValue().getType().equals("L" + cf.getName() + ";"))
|
||||
signature.setTypeOfReturnValue(new info.sigterm.deob.signature.Type("L" + name + ";", signature.getReturnValue().getArrayDims()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -151,6 +151,19 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
|
||||
{
|
||||
if (method.getClassEntry().getName().equals(cf.getName()))
|
||||
method = new Method(new Class(name), method.getNameAndType());
|
||||
|
||||
Signature signature = method.getNameAndType().getDescriptor();
|
||||
for (int i = 0; i < signature.size(); ++i)
|
||||
{
|
||||
info.sigterm.deob.signature.Type type = signature.getTypeOfArg(i);
|
||||
|
||||
if (type.getType().equals("L" + cf.getName() + ";"))
|
||||
signature.setTypeOfArg(i, new info.sigterm.deob.signature.Type("L" + name + ";", type.getArrayDims()));
|
||||
}
|
||||
|
||||
// rename return type
|
||||
if (signature.getReturnValue().getType().equals("L" + cf.getName() + ";"))
|
||||
signature.setTypeOfReturnValue(new info.sigterm.deob.signature.Type("L" + name + ";", signature.getReturnValue().getArrayDims()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -161,6 +161,19 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
|
||||
{
|
||||
if (method.getClassEntry().getName().equals(cf.getName()))
|
||||
method = new Method(new Class(name), method.getNameAndType());
|
||||
|
||||
Signature signature = method.getNameAndType().getDescriptor();
|
||||
for (int i = 0; i < signature.size(); ++i)
|
||||
{
|
||||
info.sigterm.deob.signature.Type type = signature.getTypeOfArg(i);
|
||||
|
||||
if (type.getType().equals("L" + cf.getName() + ";"))
|
||||
signature.setTypeOfArg(i, new info.sigterm.deob.signature.Type("L" + name + ";", type.getArrayDims()));
|
||||
}
|
||||
|
||||
// rename return type
|
||||
if (signature.getReturnValue().getType().equals("L" + cf.getName() + ";"))
|
||||
signature.setTypeOfReturnValue(new info.sigterm.deob.signature.Type("L" + name + ";", signature.getReturnValue().getArrayDims()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -141,7 +141,7 @@ public class RenameUnique implements Deobfuscator
|
||||
return list;
|
||||
}
|
||||
|
||||
private void renameMethod(ClassGroup group, Method m, String name)
|
||||
private void renameMethod(ClassGroup group, List<Method> methods, String name)
|
||||
{
|
||||
for (ClassFile c : group.getClasses())
|
||||
{
|
||||
@@ -151,12 +151,14 @@ public class RenameUnique implements Deobfuscator
|
||||
if (method.getCode() != null)
|
||||
{
|
||||
Instructions instructions = method.getCode().getInstructions();
|
||||
instructions.renameMethod(m, name);
|
||||
for (Method m : methods)
|
||||
instructions.renameMethod(m, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m.setName(name);
|
||||
for (Method m : methods)
|
||||
m.setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -196,11 +198,15 @@ public class RenameUnique implements Deobfuscator
|
||||
|
||||
List<Method> virtualMethods = getVirutalMethods(method);
|
||||
assert !virtualMethods.isEmpty();
|
||||
if (virtualMethods.size() != 1)
|
||||
continue; // do next
|
||||
|
||||
renameMethod(group, method, "method" + i++);
|
||||
++methods;
|
||||
String name;
|
||||
if (virtualMethods.size() == 1)
|
||||
name = "method" + i++;
|
||||
else
|
||||
name = "vmethod" + i++;
|
||||
|
||||
renameMethod(group, virtualMethods, name);
|
||||
methods += virtualMethods.size();
|
||||
}
|
||||
|
||||
System.out.println("Uniquely renamed " + classes + " classes, " + fields + " fields, and " + methods + " methods");
|
||||
|
||||
Reference in New Issue
Block a user