fix mixins getting confused between methods

This commit is contained in:
Lucwousin
2019-08-11 06:34:03 +02:00
parent df0501f302
commit dbdb686843
35 changed files with 209 additions and 160 deletions

View File

@@ -45,6 +45,16 @@ public class InjectUtil
return obfuscatedField;
}
public static ClassFile toDeobClass(final ClassFile obCf, final ClassGroup deob) throws InjectionException
{
final ClassFile wowThatWasQuick = deob.findObfuscatedName(obCf.getName());
if (wowThatWasQuick == null)
{
throw new InjectionException("It wasn't obfscated enough, or a bit too much. Whatever it was it, wasn't in deob");
}
return wowThatWasQuick;
}
public static Type getFieldType(final Field f)
{
Type type = f.getType();
@@ -97,6 +107,21 @@ public class InjectUtil
return m;
}
/**
* Find a static method in ClassGroup group. Throws exception if not found.
*/
public static Method findStaticMethod(final ClassGroup group, final String name, Signature sig) throws InjectionException
{
Method m = group.findStaticMethod(name, sig);
if (m == null)
{
throw new InjectionException(String.format("Static method \"%s\" could not be found.", name));
}
return m;
}
public static Method findMethod(Inject inject, String name) throws InjectionException
{
return findMethod(inject, name, null);

View File

@@ -60,6 +60,8 @@ import net.runelite.asm.attributes.code.instructions.PutField;
import net.runelite.asm.signature.Signature;
import net.runelite.asm.visitors.ClassFileVisitor;
import net.runelite.deob.DeobAnnotations;
import static net.runelite.injector.InjectUtil.findStaticMethod;
import static net.runelite.injector.InjectUtil.toDeobClass;
import static net.runelite.injector.InjectUtil.toObClass;
import static net.runelite.injector.InjectUtil.toObField;
import org.objectweb.asm.ClassReader;
@@ -329,9 +331,17 @@ public class MixinInjector
}
String deobMethodName = (String) copyAnnotation.getElement().getValue();
Method deobMethod;
if (method.isStatic())
{
deobMethod = findStaticMethod(inject.getDeobfuscated(), deobMethodName, method.getDescriptor().rsApiToRsClient());
}
else
{
ClassFile deobCf = toDeobClass(cf, inject.getDeobfuscated());
deobMethod = deobCf.findMethod(deobMethodName, method.getDescriptor().rsApiToRsClient());
}
ClassFile deobCf = inject.toDeobClass(cf);
Method deobMethod = findDeobMethod(deobCf, deobMethodName, method.getDescriptor());
if (deobMethod == null)
{

View File

@@ -22,7 +22,7 @@ public class RenderDraw
private static final net.runelite.asm.pool.Method renderDraw = new net.runelite.asm.pool.Method(
new Class("net.runelite.client.callback.Hooks"),
"renderDraw",
new Signature("(Lnet/runelite/api/Renderable;IIIIIIIIJ)V")
new Signature("(Lnet/runelite/api/Entity;IIIIIIIIJ)V")
);
private final Inject inject;