constant parameter: annotate methods with constant parameters are @obfuscatedsignature so we can find them later in inject. Remove deobbed 16 jar as it doesnt have up to date annotations anymore.

This commit is contained in:
Adam
2016-03-10 23:40:48 -05:00
parent 39c14267e5
commit 06c6c5d3b0
3 changed files with 37 additions and 7 deletions

View File

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

View File

@@ -26,6 +26,11 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import net.runelite.deob.attributes.Annotations;
import net.runelite.deob.attributes.Attributes;
import net.runelite.deob.attributes.annotation.Annotation;
import net.runelite.deob.attributes.annotation.Element;
import net.runelite.deob.signature.Type;
import org.apache.commons.collections4.map.MultiValueMap;
class ConstantMethodParameter
@@ -71,8 +76,6 @@ class ConstantMethodParameter
}
return true;
}
}
class MethodGroup
@@ -342,12 +345,14 @@ public class ConstantParameter implements Deobfuscator
Method method;
int lvtIndex;
int paramIndex;
Object value; // example value, used for @ObfuscatedSignature. Just one possible value.
public MethodLvtPair(Method method, int lvtIndex, int paramIndex)
public MethodLvtPair(Method method, int lvtIndex, int paramIndex, Object value)
{
this.method = method;
this.lvtIndex = lvtIndex;
this.paramIndex = paramIndex;
this.value = value;
}
@Override
@@ -396,7 +401,7 @@ public class ConstantParameter implements Deobfuscator
{
for (Method method : cmp.methods)
{
MethodLvtPair pair = new MethodLvtPair(method, cmp.lvtIndex, cmp.paramIndex);
MethodLvtPair pair = new MethodLvtPair(method, cmp.lvtIndex, cmp.paramIndex, cmp.value);
if (invalidDeadops.contains(pair))
continue;
@@ -440,8 +445,9 @@ public class ConstantParameter implements Deobfuscator
int count = 0;
for (MethodLvtPair mvp : deadops.keySet())
{
Method method = mvp.method;
List<LogicallyDeadOp> ops = deadops.get(mvp);
annotateObfuscatedSignature(mvp);
for (LogicallyDeadOp op : ops)
{
@@ -510,6 +516,27 @@ public class ConstantParameter implements Deobfuscator
return count;
}
private static final Type OBFUSCATED_SIGNATURE = new Type("Lnet/runelite/mapping/ObfuscatedSignature;");
private void annotateObfuscatedSignature(MethodLvtPair mvp)
{
Method m = mvp.method;
Object value = mvp.value;
Attributes attributes = m.getAttributes();
Annotations annotations = attributes.getAnnotations();
if (annotations != null && annotations.find(OBFUSCATED_SIGNATURE) != null)
return;
Annotation annotation = attributes.addAnnotation(OBFUSCATED_SIGNATURE, "signature", new net.runelite.deob.pool.UTF8(m.getDescriptor().toString()));
Element element = new Element(annotation);
element.setType(new Type("garbageValue"));
element.setValue(new net.runelite.deob.pool.UTF8(value.toString()));
annotation.addElement(element);
}
@Override
public void run(ClassGroup group)
{

View File

@@ -8,10 +8,11 @@ import static net.runelite.deob.deobfuscators.rename.MapStaticTest.summary;
import net.runelite.deob.util.JarUtil;
import org.junit.Test;
// Compares two deobfuscated versions of the client
public class MapperTest
{
private static final String JAR1 = "C:\\Users\\Adam\\.m2\\repository\\net\\runelite\\rs\\rs-client\\1.0-SNAPSHOT\\rs-client-1.0-SNAPSHOT.jar",//"d:/rs/07/gamepack_v16_deobbed.jar",
JAR2 = "d:/rs/07/gamepack_v17_deobbed.jar";
JAR2 = MapperTest.class.getResource("/gamepack_v16_deobbed.jar").getFile();
// private static final String JAR1 = MapStaticTest.class.getResource("/adamin1.jar").getFile(),
// JAR2 = MapStaticTest.class.getResource("/adamin2.jar").getFile();