Import bugfixes. Need to @Import annotations etc since it can't pick up methods from the api atm
This commit is contained in:
@@ -61,11 +61,14 @@ public class Inject
|
|||||||
|
|
||||||
private Type toObType(Type t)
|
private Type toObType(Type t)
|
||||||
{
|
{
|
||||||
|
if (t.isPrimitive())
|
||||||
|
return t;
|
||||||
|
|
||||||
String className = t.getType();
|
String className = t.getType();
|
||||||
ClassFile cf = deobfuscated.findClass(className);
|
ClassFile cf = deobfuscated.findClass(className);
|
||||||
|
|
||||||
Annotations an = cf.getAttributes().getAnnotations();
|
Annotations an = cf.getAttributes().getAnnotations();
|
||||||
String obfuscatedName = an.find(OBFUSCATED_NAME).getElement().toString();
|
String obfuscatedName = an.find(OBFUSCATED_NAME).getElement().getString();
|
||||||
return new Type(obfuscatedName, t.getArrayDims());
|
return new Type(obfuscatedName, t.getArrayDims());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +86,11 @@ public class Inject
|
|||||||
for (ClassFile cf : deobfuscated.getClasses())
|
for (ClassFile cf : deobfuscated.getClasses())
|
||||||
{
|
{
|
||||||
Annotations an = cf.getAttributes().getAnnotations();
|
Annotations an = cf.getAttributes().getAnnotations();
|
||||||
String obfuscatedName = an.find(OBFUSCATED_NAME).getElement().toString();
|
|
||||||
|
String obfuscatedName = cf.getName();
|
||||||
|
Annotation obfuscatedNameAnnotation = an.find(OBFUSCATED_NAME);
|
||||||
|
if (obfuscatedNameAnnotation != null)
|
||||||
|
obfuscatedName = obfuscatedNameAnnotation.getElement().getString();
|
||||||
|
|
||||||
ClassFile other = vanilla.findClass(obfuscatedName);
|
ClassFile other = vanilla.findClass(obfuscatedName);
|
||||||
assert other != null;
|
assert other != null;
|
||||||
@@ -99,8 +106,8 @@ public class Inject
|
|||||||
if (an.find(EXPORT) == null)
|
if (an.find(EXPORT) == null)
|
||||||
continue; // not an exported field
|
continue; // not an exported field
|
||||||
|
|
||||||
String exportedName = an.find(EXPORT).getElement().toString();
|
String exportedName = an.find(EXPORT).getElement().getString();
|
||||||
obfuscatedName = an.find(OBFUSCATED_NAME).getElement().toString();
|
obfuscatedName = an.find(OBFUSCATED_NAME).getElement().getString();
|
||||||
|
|
||||||
Annotation getterAnnotation = an.find(OBFUSCATED_GETTER);
|
Annotation getterAnnotation = an.find(OBFUSCATED_GETTER);
|
||||||
Number getter = null;
|
Number getter = null;
|
||||||
@@ -131,8 +138,8 @@ public class Inject
|
|||||||
if (an.find(EXPORT) == null)
|
if (an.find(EXPORT) == null)
|
||||||
continue; // not an exported method
|
continue; // not an exported method
|
||||||
|
|
||||||
String exportedName = an.find(EXPORT).getElement().toString();
|
String exportedName = an.find(EXPORT).getElement().getString();
|
||||||
obfuscatedName = an.find(OBFUSCATED_NAME).getElement().toString();
|
obfuscatedName = an.find(OBFUSCATED_NAME).getElement().getString();
|
||||||
|
|
||||||
// XXX static methods don't have to be in the same class, so we should have @ObfuscatedClass or something
|
// XXX static methods don't have to be in the same class, so we should have @ObfuscatedClass or something
|
||||||
|
|
||||||
@@ -152,7 +159,7 @@ public class Inject
|
|||||||
if (a == null)
|
if (a == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
String ifaceName = a.getElement().toString();
|
String ifaceName = "net.runelite.rs.api." + a.getElement().getString();
|
||||||
Class clazz = new Class(ifaceName);
|
Class clazz = new Class(ifaceName);
|
||||||
|
|
||||||
Interfaces interfaces = other.getInterfaces();
|
Interfaces interfaces = other.getInterfaces();
|
||||||
@@ -164,7 +171,7 @@ public class Inject
|
|||||||
}
|
}
|
||||||
catch (ClassNotFoundException ex)
|
catch (ClassNotFoundException ex)
|
||||||
{
|
{
|
||||||
ex.addSuppressed(ex);
|
ex.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
30
src/test/java/net/runelite/deob/injection/InjectTest.java
Normal file
30
src/test/java/net/runelite/deob/injection/InjectTest.java
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package net.runelite.deob.injection;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import net.runelite.deob.ClassGroup;
|
||||||
|
import net.runelite.deob.runeloader.MappingImporter;
|
||||||
|
import net.runelite.deob.util.JarUtil;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class InjectTest
|
||||||
|
{
|
||||||
|
private static final File DEOBFUSCATED = new File("d:/rs/07/adamin.jar");
|
||||||
|
private static final File VANILLA = new File(MappingImporter.class.getResource("/gamepack_v16.jar").getFile());
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRun() throws IOException
|
||||||
|
{
|
||||||
|
ClassGroup deob = JarUtil.loadJar(DEOBFUSCATED),
|
||||||
|
vanilla = JarUtil.loadJar(VANILLA);
|
||||||
|
|
||||||
|
Inject instance = new Inject(deob, vanilla);
|
||||||
|
instance.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ public class MappingImporter
|
|||||||
{
|
{
|
||||||
private static final File IN = new File("d:/rs/07/adamin.jar");
|
private static final File IN = new File("d:/rs/07/adamin.jar");
|
||||||
private static final File OUT = new File("d:/rs/07/adamout.jar");
|
private static final File OUT = new File("d:/rs/07/adamout.jar");
|
||||||
private static final File RL_INJECTION = new File("C:\\Users\\Adam\\git\\jbytecode\\src\\test\\resources\\injection_v16.json");
|
private static final File RL_INJECTION = new File(MappingImporter.class.getResource("/injection_v16.json").getFile());
|
||||||
|
|
||||||
private static final Type OBFUSCATED_NAME = new Type("Lnet/runelite/mapping/ObfuscatedName;");
|
private static final Type OBFUSCATED_NAME = new Type("Lnet/runelite/mapping/ObfuscatedName;");
|
||||||
private static final Type EXPORT = new Type("Lnet/runelite/mapping/Export;");
|
private static final Type EXPORT = new Type("Lnet/runelite/mapping/Export;");
|
||||||
|
|||||||
Reference in New Issue
Block a user