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:
@@ -128,7 +128,7 @@ public class Attributes
|
|||||||
attributes.add(a);
|
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);
|
Annotations an = (Annotations) findType(AttributeType.RUNTIMEVISIBLEANNOTATIONS);
|
||||||
if (an == null)
|
if (an == null)
|
||||||
@@ -145,6 +145,8 @@ public class Attributes
|
|||||||
element.setType(new Type(etype));
|
element.setType(new Type(etype));
|
||||||
element.setValue(value);
|
element.setValue(value);
|
||||||
annotation.addElement(element);
|
annotation.addElement(element);
|
||||||
|
|
||||||
|
return annotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Annotations getAnnotations()
|
public Annotations getAnnotations()
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
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;
|
import org.apache.commons.collections4.map.MultiValueMap;
|
||||||
|
|
||||||
class ConstantMethodParameter
|
class ConstantMethodParameter
|
||||||
@@ -71,8 +76,6 @@ class ConstantMethodParameter
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MethodGroup
|
class MethodGroup
|
||||||
@@ -342,12 +345,14 @@ public class ConstantParameter implements Deobfuscator
|
|||||||
Method method;
|
Method method;
|
||||||
int lvtIndex;
|
int lvtIndex;
|
||||||
int paramIndex;
|
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.method = method;
|
||||||
this.lvtIndex = lvtIndex;
|
this.lvtIndex = lvtIndex;
|
||||||
this.paramIndex = paramIndex;
|
this.paramIndex = paramIndex;
|
||||||
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -396,7 +401,7 @@ public class ConstantParameter implements Deobfuscator
|
|||||||
{
|
{
|
||||||
for (Method method : cmp.methods)
|
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))
|
if (invalidDeadops.contains(pair))
|
||||||
continue;
|
continue;
|
||||||
@@ -440,9 +445,10 @@ public class ConstantParameter implements Deobfuscator
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
for (MethodLvtPair mvp : deadops.keySet())
|
for (MethodLvtPair mvp : deadops.keySet())
|
||||||
{
|
{
|
||||||
Method method = mvp.method;
|
|
||||||
List<LogicallyDeadOp> ops = deadops.get(mvp);
|
List<LogicallyDeadOp> ops = deadops.get(mvp);
|
||||||
|
|
||||||
|
annotateObfuscatedSignature(mvp);
|
||||||
|
|
||||||
for (LogicallyDeadOp op : ops)
|
for (LogicallyDeadOp op : ops)
|
||||||
{
|
{
|
||||||
InstructionContext ctx = op.compCtx; // comparison
|
InstructionContext ctx = op.compCtx; // comparison
|
||||||
@@ -510,6 +516,27 @@ public class ConstantParameter implements Deobfuscator
|
|||||||
return count;
|
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
|
@Override
|
||||||
public void run(ClassGroup group)
|
public void run(ClassGroup group)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import static net.runelite.deob.deobfuscators.rename.MapStaticTest.summary;
|
|||||||
import net.runelite.deob.util.JarUtil;
|
import net.runelite.deob.util.JarUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
// Compares two deobfuscated versions of the client
|
||||||
public class MapperTest
|
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",
|
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(),
|
// private static final String JAR1 = MapStaticTest.class.getResource("/adamin1.jar").getFile(),
|
||||||
// JAR2 = MapStaticTest.class.getResource("/adamin2.jar").getFile();
|
// JAR2 = MapStaticTest.class.getResource("/adamin2.jar").getFile();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user