upstream drawAfterWidgets

This commit is contained in:
therealunull
2020-12-15 15:24:06 -05:00
parent 3ff221f6fd
commit da96331491
8 changed files with 56 additions and 11 deletions

View File

@@ -36,7 +36,7 @@ buildscript {
dependencies { dependencies {
classpath("org.ajoberstar.grgit:grgit-core:4.1.0") classpath("org.ajoberstar.grgit:grgit-core:4.1.0")
classpath("com.github.ben-manes:gradle-versions-plugin:0.36.0") classpath("com.github.ben-manes:gradle-versions-plugin:0.36.0")
classpath("com.openosrs:openosrs-injector:1.3.0") classpath("com.openosrs:openosrs-injector:1.0.1")
} }
} }

View File

@@ -57,6 +57,11 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
super(instructions, type); super(instructions, type);
} }
public InvokeInterface(Instructions instructions, Method method) {
super(instructions, InstructionType.INVOKEINTERFACE);
this.method = method;
}
@Override @Override
public String toString() public String toString()
{ {

View File

@@ -1,4 +1,4 @@
org.gradle.caching=true org.gradle.caching=false
org.gradle.warning.mode=all org.gradle.warning.mode=all
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.console=rich org.gradle.console=rich

View File

@@ -18,7 +18,7 @@ plugins {
val oprsver = "3.5.1" val oprsver = "3.5.1"
group = "com.openosrs" group = "com.openosrs"
version = "1.3.0" version = "1.0.1"
repositories { repositories {
mavenCentral() mavenCentral()
@@ -38,9 +38,7 @@ dependencies {
implementation("org.ow2.asm:asm-util:8.0.1") implementation("org.ow2.asm:asm-util:8.0.1")
implementation("org.jetbrains:annotations:19.0.0") implementation("org.jetbrains:annotations:19.0.0")
implementation("com.google.guava:guava:29.0-jre") implementation("com.google.guava:guava:29.0-jre")
implementation("com.openosrs:deobfuscator:${oprsver}") { implementation(project(":deobfuscator"))
isTransitive = false
}
testCompileOnly("com.openosrs:injection-annotations:1.0") testCompileOnly("com.openosrs:injection-annotations:1.0")
testImplementation("junit:junit:4.13") testImplementation("junit:junit:4.13")

View File

@@ -28,6 +28,7 @@ import net.runelite.asm.signature.Signature;
public abstract class InjectData public abstract class InjectData
{ {
public static final String HOOKS = "net/runelite/client/callback/Hooks"; public static final String HOOKS = "net/runelite/client/callback/Hooks";
public static final String CALLBACKS = "net/runelite/api/hooks/Callbacks";
@Getter @Getter
private final ClassGroup vanilla; private final ClassGroup vanilla;

View File

@@ -33,22 +33,25 @@ package com.openosrs.injector.injectors.raw;
import com.openosrs.injector.InjectException; import com.openosrs.injector.InjectException;
import com.openosrs.injector.InjectUtil; import com.openosrs.injector.InjectUtil;
import com.openosrs.injector.injection.InjectData; import com.openosrs.injector.injection.InjectData;
import static com.openosrs.injector.injection.InjectData.CALLBACKS;
import com.openosrs.injector.injectors.AbstractInjector; import com.openosrs.injector.injectors.AbstractInjector;
import java.util.HashSet; import java.util.HashSet;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Set; import java.util.Set;
import net.runelite.asm.ClassFile; import net.runelite.asm.ClassFile;
import net.runelite.asm.Field;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.attributes.code.Instruction; import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.Instructions; import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.Label; import net.runelite.asm.attributes.code.Label;
import net.runelite.asm.attributes.code.instruction.types.JumpingInstruction; import net.runelite.asm.attributes.code.instruction.types.JumpingInstruction;
import net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction; import net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction;
import net.runelite.asm.attributes.code.instructions.GetField;
import net.runelite.asm.attributes.code.instructions.GetStatic; import net.runelite.asm.attributes.code.instructions.GetStatic;
import net.runelite.asm.attributes.code.instructions.IMul; import net.runelite.asm.attributes.code.instructions.IMul;
import net.runelite.asm.attributes.code.instructions.InvokeInterface;
import net.runelite.asm.attributes.code.instructions.InvokeStatic; import net.runelite.asm.attributes.code.instructions.InvokeStatic;
import net.runelite.asm.signature.Signature; import net.runelite.asm.signature.Signature;
import static com.openosrs.injector.injection.InjectData.HOOKS;
public class DrawAfterWidgets extends AbstractInjector public class DrawAfterWidgets extends AbstractInjector
{ {
@@ -103,6 +106,8 @@ public class DrawAfterWidgets extends AbstractInjector
boolean injected = false; boolean injected = false;
Field client = getVanillaStaticFieldFromDeob("client");
Field callbacks = getObfuscatedField("callbacks");
Method noClip = InjectUtil.findMethod(inject, "Rasterizer2D_resetClip", "Rasterizer2D", null); // !!!!! Method noClip = InjectUtil.findMethod(inject, "Rasterizer2D_resetClip", "Rasterizer2D", null); // !!!!!
if (noClip == null) if (noClip == null)
@@ -235,16 +240,17 @@ public class DrawAfterWidgets extends AbstractInjector
for (Label l : labelsToInjectAfter) for (Label l : labelsToInjectAfter)
{ {
InvokeStatic invoke = new InvokeStatic(instructions, InvokeInterface invoke = new InvokeInterface(instructions,
new net.runelite.asm.pool.Method( new net.runelite.asm.pool.Method(
new net.runelite.asm.pool.Class(HOOKS), new net.runelite.asm.pool.Class(CALLBACKS),
"drawAfterWidgets", "drawAfterWidgets",
new Signature("()V") new Signature("()V")
) )
); );
instructions.addInstruction(instructions.getInstructions().indexOf(l) + 1, invoke); instructions.addInstruction(instructions.getInstructions().indexOf(l) + 1, invoke);
instructions.addInstruction(instructions.getInstructions().indexOf(l) + 1, new GetField(instructions, callbacks.getPoolField()));
instructions.addInstruction(instructions.getInstructions().indexOf(l) + 1, new GetStatic(instructions, client.getPoolField()));
log.debug("[DEBUG] injectDrawAfterWidgets injected a call after " + l); log.debug("[DEBUG] injectDrawAfterWidgets injected a call after " + l);
injected = true; injected = true;
@@ -257,4 +263,36 @@ public class DrawAfterWidgets extends AbstractInjector
throw new InjectException("injectDrawAfterWidgets failed to inject!"); throw new InjectException("injectDrawAfterWidgets failed to inject!");
} }
} }
public Field getVanillaStaticFieldFromDeob(String s)
{
for (ClassFile c : inject.getDeobfuscated())
{
for (Field f : c.getFields())
{
if (f.isStatic())
if (f.getName().equals(s))
{
return inject.toVanilla(f);
}
}
}
return null;
}
public Field getObfuscatedField(String s)
{
for (ClassFile c : inject.getVanilla())
{
for (Field f : c.getFields())
{
if (!f.isStatic())
if (f.getName().equals(s))
{
return f;
}
}
}
return null;
}
} }

View File

@@ -70,6 +70,8 @@ public interface Callbacks
*/ */
void drawAboveOverheads(); void drawAboveOverheads();
void drawAfterWidgets();
/** /**
* Client top-most draw method, rendering over top of most of game interfaces. * Client top-most draw method, rendering over top of most of game interfaces.
* *

View File

@@ -450,7 +450,8 @@ public class Hooks implements Callbacks
} }
} }
public static void drawAfterWidgets() @Override
public void drawAfterWidgets()
{ {
MainBufferProvider bufferProvider = (MainBufferProvider) client.getBufferProvider(); MainBufferProvider bufferProvider = (MainBufferProvider) client.getBufferProvider();
Graphics2D graphics2d = getGraphics(bufferProvider); Graphics2D graphics2d = getGraphics(bufferProvider);