ByteCodePatcher
Adds PlayerTransform -Adds transformProtectedGetSkullIcon -Adds transformGetSkullIcon
This commit is contained in:
@@ -233,7 +233,8 @@ public class ClientLoader
|
|||||||
|
|
||||||
if (hooks.clientInstance.equals("")||
|
if (hooks.clientInstance.equals("")||
|
||||||
hooks.projectileClass.equals("") ||
|
hooks.projectileClass.equals("") ||
|
||||||
hooks.actorClass.equals("")) {
|
hooks.actorClass.equals("") ||
|
||||||
|
hooks.playerClass.equals("")) {
|
||||||
System.out.println("[RuneLit] Bad hooks, re-scraping.");
|
System.out.println("[RuneLit] Bad hooks, re-scraping.");
|
||||||
ByteCodePatcher.clientInstance = getClientInstance(ByteCodeUtils.injectedClientFile.getPath());
|
ByteCodePatcher.clientInstance = getClientInstance(ByteCodeUtils.injectedClientFile.getPath());
|
||||||
ByteCodePatcher.findHooks(injectedClientFile.getPath());
|
ByteCodePatcher.findHooks(injectedClientFile.getPath());
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import javassist.NotFoundException;
|
|||||||
import net.runelite.client.RuneLite;
|
import net.runelite.client.RuneLite;
|
||||||
import net.runelite.client.rs.ClientLoader;
|
import net.runelite.client.rs.ClientLoader;
|
||||||
import net.runelite.client.rs.bytecode.transformers.ActorTransform;
|
import net.runelite.client.rs.bytecode.transformers.ActorTransform;
|
||||||
|
import net.runelite.client.rs.bytecode.transformers.PlayerTransform;
|
||||||
import net.runelite.client.rs.bytecode.transformers.ProjectileTransform;
|
import net.runelite.client.rs.bytecode.transformers.ProjectileTransform;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import org.xeustechnologies.jcl.JarClassLoader;
|
import org.xeustechnologies.jcl.JarClassLoader;
|
||||||
@@ -50,6 +51,8 @@ public class ByteCodePatcher {
|
|||||||
transformActor(actorClass);
|
transformActor(actorClass);
|
||||||
Class projectileClass = Class.forName(hooks.projectileClass, false, child);
|
Class projectileClass = Class.forName(hooks.projectileClass, false, child);
|
||||||
transformProjectile(projectileClass);
|
transformProjectile(projectileClass);
|
||||||
|
Class playerClass = Class.forName(hooks.playerClass, false, child);
|
||||||
|
transformPlayer(playerClass);
|
||||||
ByteCodeUtils.updateHijackedJar();
|
ByteCodeUtils.updateHijackedJar();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -103,6 +106,7 @@ public class ByteCodePatcher {
|
|||||||
Class classToLoad = Class.forName(entry.getName().replace(".class", ""), false, child);
|
Class classToLoad = Class.forName(entry.getName().replace(".class", ""), false, child);
|
||||||
checkActor(classToLoad);
|
checkActor(classToLoad);
|
||||||
checkProjectile(classToLoad);
|
checkProjectile(classToLoad);
|
||||||
|
checkPlayer(classToLoad);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -129,10 +133,10 @@ public class ByteCodePatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void transformActor(Class current) {
|
public static void transformActor(Class actor) {
|
||||||
System.out.println("[RuneLit] Transforming Actor at class: "+current.getName());
|
System.out.println("[RuneLit] Transforming Actor at class: "+actor.getName());
|
||||||
ActorTransform at = new ActorTransform();
|
ActorTransform at = new ActorTransform();
|
||||||
at.modify(current);
|
at.modify(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkProjectile(Class current) {
|
public static void checkProjectile(Class current) {
|
||||||
@@ -151,10 +155,32 @@ public class ByteCodePatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void transformProjectile(Class current) {
|
public static void transformProjectile(Class projectile) {
|
||||||
System.out.println("[RuneLit] Transforming Projectile at class: "+current.getName());
|
System.out.println("[RuneLit] Transforming Projectile at class: "+projectile.getName());
|
||||||
ProjectileTransform pt = new ProjectileTransform();
|
ProjectileTransform pt = new ProjectileTransform();
|
||||||
pt.modify(current);
|
pt.modify(projectile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkPlayer(Class current) {
|
||||||
|
try {
|
||||||
|
Method method = current.getDeclaredMethod("getSkullIcon");
|
||||||
|
if (method!=null) {
|
||||||
|
hooks.playerClass = current.getName();
|
||||||
|
System.out.println("[RuneLit] Transforming Player at class: "+current.getName());
|
||||||
|
PlayerTransform pt = new PlayerTransform();
|
||||||
|
pt.modify(current);
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
} catch (NoClassDefFoundError e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void transformPlayer(Class player) {
|
||||||
|
System.out.println("[RuneLit] Transforming Player at class: "+player.getName());
|
||||||
|
PlayerTransform pt = new PlayerTransform();
|
||||||
|
pt.modify(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ public class Hooks {
|
|||||||
public String clientInstance = "";
|
public String clientInstance = "";
|
||||||
public String actorClass = "";
|
public String actorClass = "";
|
||||||
public String projectileClass = "";
|
public String projectileClass = "";
|
||||||
|
public String playerClass = "";
|
||||||
|
|
||||||
public Hooks() {
|
public Hooks() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package net.runelite.client.rs.bytecode.transformers;
|
||||||
|
|
||||||
|
import javassist.CtClass;
|
||||||
|
import javassist.CtMethod;
|
||||||
|
import javassist.CtNewMethod;
|
||||||
|
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
||||||
|
|
||||||
|
public class PlayerTransform {
|
||||||
|
public CtClass ct = null;
|
||||||
|
|
||||||
|
public void modify(Class player) {
|
||||||
|
try {
|
||||||
|
ct = ByteCodePatcher.classPool.get(player.getName());
|
||||||
|
transformProtectedGetSkullIcon();
|
||||||
|
transformGetSkullIcon();
|
||||||
|
ByteCodePatcher.modifiedClasses.add(ct);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void transformProtectedGetSkullIcon() {
|
||||||
|
CtMethod protectedGetSkullIcon;
|
||||||
|
try {
|
||||||
|
protectedGetSkullIcon = ct.getDeclaredMethod("1protect$getRsSkullIcon");
|
||||||
|
ct.removeMethod(protectedGetSkullIcon);
|
||||||
|
protectedGetSkullIcon.setName("getRsSkullIcon");
|
||||||
|
ct.addMethod(protectedGetSkullIcon);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void transformGetSkullIcon() {
|
||||||
|
CtMethod getSkullIcon;
|
||||||
|
try {
|
||||||
|
String SkullIcon = "net.runelite.api.SkullIcon";
|
||||||
|
getSkullIcon = ct.getDeclaredMethod("getSkullIcon");
|
||||||
|
ct.removeMethod(getSkullIcon);
|
||||||
|
getSkullIcon = CtNewMethod.make("public "+SkullIcon+" getSkullIcon() {" +
|
||||||
|
" switch (this.getRsSkullIcon()) {" +
|
||||||
|
" case 0: {" +
|
||||||
|
" return "+SkullIcon+".SKULL; }" +
|
||||||
|
" case 1: {" +
|
||||||
|
" return "+SkullIcon+".SKULL_FIGHT_PIT; }" +
|
||||||
|
" case 8: {" +
|
||||||
|
" return "+SkullIcon+".DEAD_MAN_FIVE; }" +
|
||||||
|
" case 9: {" +
|
||||||
|
" return "+SkullIcon+".DEAD_MAN_FOUR; }" +
|
||||||
|
" case 10: {" +
|
||||||
|
" return "+SkullIcon+".DEAD_MAN_THREE; }" +
|
||||||
|
" case 11: {" +
|
||||||
|
" return "+SkullIcon+".DEAD_MAN_TWO; }" +
|
||||||
|
" case 12: {" +
|
||||||
|
" return "+SkullIcon+".DEAD_MAN_ONE; } }" +
|
||||||
|
" return null; }",ct);
|
||||||
|
ct.addMethod(getSkullIcon);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user