Revert to working state
This commit is contained in:
@@ -51,16 +51,13 @@ import javax.inject.Singleton;
|
|||||||
import java.applet.Applet;
|
import java.applet.Applet;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.security.cert.Certificate;
|
import java.security.cert.Certificate;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.CertificateFactory;
|
import java.security.cert.CertificateFactory;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.jar.*;
|
import java.util.jar.*;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -69,33 +66,27 @@ import static net.runelite.client.rs.ClientUpdateCheckMode.*;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ClientLoader
|
public class ClientLoader {
|
||||||
{
|
public static File hooksFile = new File(RuneLite.RUNELITE_DIR + "/hooks-" + RuneLiteAPI.getVersion() + "-.json");
|
||||||
public static File hooksFile = new File(RuneLite.RUNELITE_DIR+"/hooks-"+ RuneLiteAPI.getVersion() +"-.json");
|
private final ClientConfigLoader clientConfigLoader;
|
||||||
private final ClientConfigLoader clientConfigLoader;
|
private ClientUpdateCheckMode updateCheckMode;
|
||||||
private ClientUpdateCheckMode updateCheckMode;
|
private JarOutputStream target;
|
||||||
private JarOutputStream target;
|
|
||||||
private boolean scrapedHooks = false;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ClientLoader(
|
private ClientLoader(
|
||||||
@Named("updateCheckMode") final ClientUpdateCheckMode updateCheckMode,
|
@Named("updateCheckMode") final ClientUpdateCheckMode updateCheckMode,
|
||||||
final ClientConfigLoader clientConfigLoader)
|
final ClientConfigLoader clientConfigLoader) {
|
||||||
{
|
this.updateCheckMode = updateCheckMode;
|
||||||
this.updateCheckMode = updateCheckMode;
|
this.clientConfigLoader = clientConfigLoader;
|
||||||
this.clientConfigLoader = clientConfigLoader;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static Certificate[] getJagexCertificateChain() throws CertificateException
|
private static Certificate[] getJagexCertificateChain() throws CertificateException {
|
||||||
{
|
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
|
||||||
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
|
Collection<? extends Certificate> certificates = certificateFactory.generateCertificates(ClientLoader.class.getResourceAsStream("jagex.crt"));
|
||||||
Collection<? extends Certificate> certificates = certificateFactory.generateCertificates(ClientLoader.class.getResourceAsStream("jagex.crt"));
|
return certificates.toArray(new Certificate[certificates.size()]);
|
||||||
return certificates.toArray(new Certificate[certificates.size()]);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static String initVanillaInjected(String jarFile) {
|
public static String getClientInstance(String jarFile) {
|
||||||
List<String> protectedMethods = new ArrayList<>();
|
|
||||||
String clientInstance = "";
|
|
||||||
JarClassLoader jcl = new JarClassLoader();
|
JarClassLoader jcl = new JarClassLoader();
|
||||||
try {
|
try {
|
||||||
ClassPool classPool = new ClassPool(true);
|
ClassPool classPool = new ClassPool(true);
|
||||||
@@ -123,10 +114,8 @@ public class ClientLoader
|
|||||||
try {
|
try {
|
||||||
jcl2.add(new FileInputStream(ByteCodeUtils.injectedClientFile));
|
jcl2.add(new FileInputStream(ByteCodeUtils.injectedClientFile));
|
||||||
Field[] fields = classToLoad.getDeclaredFields();
|
Field[] fields = classToLoad.getDeclaredFields();
|
||||||
Method[] methods = classToLoad.getMethods();
|
|
||||||
for (Field f : fields) {
|
for (Field f : fields) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (f.getType().getName() == "client") {
|
if (f.getType().getName() == "client") {
|
||||||
ByteCodePatcher.hooks.clientInstance = classToLoad.getName() + "." + f.getName();
|
ByteCodePatcher.hooks.clientInstance = classToLoad.getName() + "." + f.getName();
|
||||||
System.out.println("[RuneLit] Found client instance at " + classToLoad.getName() + "." + f.getName());
|
System.out.println("[RuneLit] Found client instance at " + classToLoad.getName() + "." + f.getName());
|
||||||
@@ -136,11 +125,6 @@ public class ClientLoader
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Method m : methods) {
|
|
||||||
if (m.getName().contains("protect")) {
|
|
||||||
protectedMethods.add(classToLoad.getName()+":"+m.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -158,14 +142,7 @@ public class ClientLoader
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
String[] hooksProtectedMethods = new String[protectedMethods.size()];
|
return "";
|
||||||
int i = 0;
|
|
||||||
for (String s : protectedMethods) {
|
|
||||||
hooksProtectedMethods[i] = s;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ByteCodePatcher.hooks.protectedMethods = hooksProtectedMethods;
|
|
||||||
return clientInstance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Applet load() {
|
public Applet load() {
|
||||||
@@ -285,10 +262,10 @@ public class ClientLoader
|
|||||||
if (hooks.clientInstance.equals("") ||
|
if (hooks.clientInstance.equals("") ||
|
||||||
hooks.projectileClass.equals("") ||
|
hooks.projectileClass.equals("") ||
|
||||||
hooks.actorClass.equals("") ||
|
hooks.actorClass.equals("") ||
|
||||||
hooks.clientInstance.equals("") ||
|
hooks.mainClientInstance.equals("") ||
|
||||||
hooks.playerClass.equals("")) {
|
hooks.playerClass.equals("")) {
|
||||||
System.out.println("[RuneLit] Bad hooks, re-scraping.");
|
System.out.println("[RuneLit] Bad hooks, re-scraping.");
|
||||||
ByteCodePatcher.clientInstance = ByteCodeUtils.injectedClientFile.getPath();
|
ByteCodePatcher.clientInstance = getClientInstance(ByteCodeUtils.injectedClientFile.getPath());
|
||||||
ByteCodePatcher.findHooks(injectedClientFile.getPath());
|
ByteCodePatcher.findHooks(injectedClientFile.getPath());
|
||||||
} else {
|
} else {
|
||||||
ByteCodePatcher.clientInstance = hooks.clientInstance;
|
ByteCodePatcher.clientInstance = hooks.clientInstance;
|
||||||
@@ -298,7 +275,7 @@ public class ClientLoader
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
System.out.println("[RuneLit] Hooks file not found, scraping hooks.");
|
System.out.println("[RuneLit] Hooks file not found, scraping hooks.");
|
||||||
ByteCodePatcher.clientInstance = initVanillaInjected(ByteCodeUtils.injectedClientFile.getPath());
|
ByteCodePatcher.clientInstance = getClientInstance(ByteCodeUtils.injectedClientFile.getPath());
|
||||||
ByteCodePatcher.findHooks(injectedClientFile.getPath());
|
ByteCodePatcher.findHooks(injectedClientFile.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ import javassist.CtClass;
|
|||||||
import javassist.NotFoundException;
|
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.*;
|
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.getProjectileTransform;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import org.xeustechnologies.jcl.JarClassLoader;
|
import org.xeustechnologies.jcl.JarClassLoader;
|
||||||
|
|
||||||
@@ -40,10 +43,11 @@ 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 getProjectileClass = Class.forName(hooks.mainClientInstance, false, child);
|
||||||
|
transformGetProjectile(getProjectileClass);
|
||||||
Class playerClass = Class.forName(hooks.playerClass, false, child);
|
Class playerClass = Class.forName(hooks.playerClass, false, child);
|
||||||
transformPlayer(playerClass);
|
transformPlayer(playerClass);
|
||||||
Class clientClass = Class.forName(hooks.clientClass, false, child);
|
|
||||||
transformClient(clientClass);
|
|
||||||
ByteCodeUtils.updateHijackedJar();
|
ByteCodeUtils.updateHijackedJar();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -97,8 +101,8 @@ 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);
|
||||||
|
checkgetProjectiles(classToLoad);
|
||||||
checkPlayer(classToLoad);
|
checkPlayer(classToLoad);
|
||||||
checkClient(classToLoad);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -153,6 +157,28 @@ public class ByteCodePatcher {
|
|||||||
pt.modify(projectile);
|
pt.modify(projectile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void checkgetProjectiles(Class getprojectile) {
|
||||||
|
try {
|
||||||
|
Method method = getprojectile.getDeclaredMethod("getProjectiles");
|
||||||
|
if (method != null) {
|
||||||
|
hooks.mainClientInstance = getprojectile.getName();
|
||||||
|
System.out.println("[RuneLit] Transforming Projectile at class: " + getprojectile.getName());
|
||||||
|
getProjectileTransform gpt = new getProjectileTransform();
|
||||||
|
gpt.modify(getprojectile);
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
} catch (NoClassDefFoundError e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void transformGetProjectile(Class current) {
|
||||||
|
System.out.println("[RuneLit] Transforming getProjectile at class: " + current.getName());
|
||||||
|
getProjectileTransform gpt = new getProjectileTransform();
|
||||||
|
gpt.modify(current);
|
||||||
|
}
|
||||||
|
|
||||||
public static void checkPlayer(Class current) {
|
public static void checkPlayer(Class current) {
|
||||||
try {
|
try {
|
||||||
Method method = current.getDeclaredMethod("getSkullIcon");
|
Method method = current.getDeclaredMethod("getSkullIcon");
|
||||||
@@ -162,20 +188,6 @@ public class ByteCodePatcher {
|
|||||||
PlayerTransform pt = new PlayerTransform();
|
PlayerTransform pt = new PlayerTransform();
|
||||||
pt.modify(current);
|
pt.modify(current);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void checkClient(Class current) {
|
|
||||||
try {
|
|
||||||
Method method = current.getDeclaredMethod("getProjectiles");
|
|
||||||
if (method != null) {
|
|
||||||
hooks.clientInstance = current.getName();
|
|
||||||
System.out.println("[RuneLit] Transforming Projectile at class: " + current.getName());
|
|
||||||
ClientTransform ct = new ClientTransform();
|
|
||||||
ct.modify(current);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
} catch (NoClassDefFoundError e) {
|
} catch (NoClassDefFoundError e) {
|
||||||
@@ -183,12 +195,6 @@ public class ByteCodePatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void transformClient(Class client) {
|
|
||||||
System.out.println("[RuneLit] Transforming Client at class: " + client.getName());
|
|
||||||
ClientTransform ct = new ClientTransform();
|
|
||||||
ct.modify(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void transformPlayer(Class player) {
|
public static void transformPlayer(Class player) {
|
||||||
System.out.println("[RuneLit] Transforming Player at class: " + player.getName());
|
System.out.println("[RuneLit] Transforming Player at class: " + player.getName());
|
||||||
PlayerTransform pt = new PlayerTransform();
|
PlayerTransform pt = new PlayerTransform();
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
package net.runelite.client.rs.bytecode;
|
package net.runelite.client.rs.bytecode;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Hooks {
|
public class Hooks {
|
||||||
|
|
||||||
public String clientInstance = "";
|
public String clientInstance = "";
|
||||||
public String actorClass = "";
|
public String actorClass = "";
|
||||||
public String projectileClass = "";
|
public String projectileClass = "";
|
||||||
|
public String mainClientInstance = "";
|
||||||
public String playerClass = "";
|
public String playerClass = "";
|
||||||
public String clientClass = "client"; //Always named client
|
|
||||||
public String[] protectedMethods;
|
|
||||||
|
|
||||||
public Hooks() {
|
public Hooks() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package net.runelite.client.rs.bytecode.transformers;
|
package net.runelite.client.rs.bytecode.transformers;
|
||||||
|
|
||||||
import javassist.CtClass;
|
import javassist.CtClass;
|
||||||
@@ -61,4 +62,3 @@ public class PlayerTransform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,26 +3,27 @@ package net.runelite.client.rs.bytecode.transformers;
|
|||||||
import javassist.CtClass;
|
import javassist.CtClass;
|
||||||
import javassist.CtMethod;
|
import javassist.CtMethod;
|
||||||
import javassist.CtNewMethod;
|
import javassist.CtNewMethod;
|
||||||
import javassist.NotFoundException;
|
|
||||||
import javassist.bytecode.AnnotationsAttribute;
|
import javassist.bytecode.AnnotationsAttribute;
|
||||||
import javassist.bytecode.ClassFile;
|
import javassist.bytecode.ClassFile;
|
||||||
import javassist.bytecode.ConstPool;
|
import javassist.bytecode.ConstPool;
|
||||||
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
||||||
|
|
||||||
public class ClientTransform {
|
|
||||||
|
public class getProjectileTransform {
|
||||||
public CtClass ct = null;
|
public CtClass ct = null;
|
||||||
|
|
||||||
public void modify(Class client) {
|
public void modify(Class getprojectile) {
|
||||||
try {
|
try {
|
||||||
ct = ByteCodePatcher.classPool.get(client.getName());
|
ct = ByteCodePatcher.classPool.get(getprojectile.getName());
|
||||||
transformGetProjectiles();
|
|
||||||
|
transformGetProjectile();
|
||||||
ByteCodePatcher.modifiedClasses.add(ct);
|
ByteCodePatcher.modifiedClasses.add(ct);
|
||||||
} catch (NotFoundException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformGetProjectiles() {
|
public void transformGetProjectile() {
|
||||||
|
|
||||||
CtMethod getProjectiles;
|
CtMethod getProjectiles;
|
||||||
try {
|
try {
|
||||||
@@ -52,5 +53,4 @@ public class ClientTransform {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user