Split intValue/longValue.

This commit is contained in:
Adam
2015-11-20 21:21:43 -05:00
parent 26b3aa46a5
commit 792446c8fb
5 changed files with 55 additions and 71 deletions

View File

@@ -25,53 +25,53 @@ public class Deob
{
public static void main(String[] args) throws IOException
{
merge(); if(true) return;
//merge(); if(true) return;
long start = System.currentTimeMillis();
ClassGroup group = JarUtil.loadJar(new File(args[0]));
// run(group, new RenameUnique());
//
// // remove except RuntimeException
// run(group, new RuntimeExceptions());
//
// // remove unused methods
// run(group, new UnreachedCode());
// run(group, new UnusedMethods());
//
// // remove illegal state exceptions, frees up some parameters
// run(group, new IllegalStateExceptions());
//
// // remove constant logically dead parameters
// run(group, new ConstantParameter());
//
// // remove unhit blocks
// run(group, new UnreachedCode());
// run(group, new UnusedMethods());
//
// // remove unused parameters
// run(group, new UnusedParameters());
//
// // remove unused fields
// run(group, new UnusedFields());
//
// // remove unused methods, again?
// run(group, new UnusedMethods());
//
//// run(group, new MethodInliner());
//// run(group, new UnusedMethods()); // inliner might leave unused methods
//
//// // broken because rename was removed
//// //run(group, new MethodMover());
//
// run(group, new FieldInliner());
//
//// // XXX this is broken because when moving clinit around, some fields can depend on other fields
//// // (like multianewarray)
//// //new FieldMover().run(group);
//
// run(group, new UnusedClass());
run(group, new RenameUnique());
// remove except RuntimeException
run(group, new RuntimeExceptions());
// remove unused methods
run(group, new UnreachedCode());
run(group, new UnusedMethods());
// remove illegal state exceptions, frees up some parameters
run(group, new IllegalStateExceptions());
// remove constant logically dead parameters
run(group, new ConstantParameter());
// remove unhit blocks
run(group, new UnreachedCode());
run(group, new UnusedMethods());
// remove unused parameters
run(group, new UnusedParameters());
// remove unused fields
run(group, new UnusedFields());
// remove unused methods, again?
run(group, new UnusedMethods());
// run(group, new MethodInliner());
// run(group, new UnusedMethods()); // inliner might leave unused methods
// // broken because rename was removed
// //run(group, new MethodMover());
run(group, new FieldInliner());
// // XXX this is broken because when moving clinit around, some fields can depend on other fields
// // (like multianewarray)
// //new FieldMover().run(group);
run(group, new UnusedClass());
ModArith mod = new ModArith();
mod.run(group);
@@ -91,6 +91,8 @@ public class Deob
last = cur;
}
mod.annotateEncryption();
// eval constant fields (only set once to a constant in ctor) maybe just inline them
// make fields private

View File

@@ -128,7 +128,7 @@ public class Attributes
attributes.add(a);
}
public void addAnnotation(Type type, PoolEntry value)
public void addAnnotation(Type type, String etype, PoolEntry value)
{
Annotations an = (Annotations) findType(AttributeType.RUNTIMEVISIBLEANNOTATIONS);
if (an == null)
@@ -142,7 +142,7 @@ public class Attributes
an.addAnnotation(annotation);
Element element = new Element(annotation);
element.setType(new Type("value"));
element.setType(new Type(etype));
element.setValue(value);
annotation.addElement(element);
}

View File

@@ -80,15 +80,6 @@ public class RenameUnique implements Deobfuscator
this.generatFieldNames(mappings, group);
this.generateMethodNames(mappings, group);
try
{
mappings.save(new File("d:/rs/07/uniquemappings.json"));
}
catch (IOException ex)
{
Logger.getLogger(RenameUnique.class.getName()).log(Level.SEVERE, null, ex);
}
renamer = new Renamer(mappings);
renamer.run(group);
}

View File

@@ -88,7 +88,7 @@ public class Renamer implements Deobfuscator
field.setType(new Type("L" + name + ";", field.getType().getArrayDims()));
}
cf.getAttributes().addAnnotation(OBFUSCATED_NAME_TYPE, new UTF8(cf.getName()));
cf.getAttributes().addAnnotation(OBFUSCATED_NAME_TYPE, "value", new UTF8(cf.getName()));
cf.setName(name);
}
@@ -181,7 +181,7 @@ public class Renamer implements Deobfuscator
if (newName == null)
continue;
field.getAttributes().addAnnotation(OBFUSCATED_NAME_TYPE, new UTF8(field.getName()));
field.getAttributes().addAnnotation(OBFUSCATED_NAME_TYPE, "value", new UTF8(field.getName()));
field.setName(newName);
++fields;
}
@@ -199,7 +199,7 @@ public class Renamer implements Deobfuscator
for (Method m : virtualMethods)
{
m.getAttributes().addAnnotation(OBFUSCATED_NAME_TYPE, new UTF8(m.getName()));
m.getAttributes().addAnnotation(OBFUSCATED_NAME_TYPE, "value", new UTF8(m.getName()));
m.setName(newName);
}
methods += virtualMethods.size();

View File

@@ -43,6 +43,7 @@ public class ModArith implements Deobfuscator
private MultiValueMap<Field, Number> constantGetters = new MultiValueMap<>(),
constantSetters = new MultiValueMap<>();
private List<Pair> pairs = new ArrayList<>();
private Encryption encryption = new Encryption();
private List<InstructionContext> getInsInExpr(InstructionContext ctx, Set<Instruction> set)
{
@@ -651,8 +652,6 @@ public class ModArith implements Deobfuscator
execution.populateInitialMethods();
execution.run();
Encryption encryption = new Encryption();
findUses();
findUses2();
reduce2();
@@ -671,23 +670,12 @@ public class ModArith implements Deobfuscator
System.out.println("Changed " + ++i);
}
annotateEncryption(encryption);
try
{
encryption.save(new File("d:/rs/07/encryption.json"));
}
catch (IOException ex)
{
Logger.getLogger(ModArith.class.getName()).log(Level.SEVERE, null, ex);
}
return i;
}
private static final Type OBFUSCATED_GETTER = new Type("Lnet/runelite/mapping/ObfuscatedGetter;");
private void annotateEncryption(Encryption encryption)
public void annotateEncryption()
{
for (ClassFile cf : group.getClasses())
{
@@ -700,7 +688,10 @@ public class ModArith implements Deobfuscator
PoolEntry value = pair.getType() == Long.class ?
new net.runelite.deob.pool.Long((long) pair.getter) :
new net.runelite.deob.pool.Integer((int) pair.getter);
f.getAttributes().addAnnotation(OBFUSCATED_GETTER, value);
String ename = pair.getType() == Long.class ?
"longValue" :
"intValue";
f.getAttributes().addAnnotation(OBFUSCATED_GETTER, ename, value);
}
}
}