Now dumps protected fields / methods on rev update. makes it easier to look for things to transform :)
This commit is contained in:
zeruth
2019-04-21 23:18:42 -04:00
parent b0b11cf9c8
commit 77d9e18f01
2 changed files with 33 additions and 6 deletions

View File

@@ -45,13 +45,16 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
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.Attributes; import java.util.jar.Attributes;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
@@ -88,6 +91,7 @@ public class ClientLoader
private final ClientConfigLoader clientConfigLoader; private final ClientConfigLoader clientConfigLoader;
private ClientUpdateCheckMode updateCheckMode; private ClientUpdateCheckMode updateCheckMode;
private JarOutputStream target; private JarOutputStream target;
private static String[] preotectedStuffs;
@Inject @Inject
private ClientLoader( private ClientLoader(
@@ -236,7 +240,7 @@ public class ClientLoader
hooks.actorClass.equals("") || hooks.actorClass.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 = getClientInstance(ByteCodeUtils.injectedClientFile.getPath()); ByteCodePatcher.clientInstance = initHookScrape(ByteCodeUtils.injectedClientFile.getPath());
ByteCodePatcher.findHooks(injectedClientFile.getPath()); ByteCodePatcher.findHooks(injectedClientFile.getPath());
} else { } else {
ByteCodePatcher.clientInstance = hooks.clientInstance; ByteCodePatcher.clientInstance = hooks.clientInstance;
@@ -246,7 +250,8 @@ 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 = getClientInstance(ByteCodeUtils.injectedClientFile.getPath()); ByteCodePatcher.clientInstance = initHookScrape(ByteCodeUtils.injectedClientFile.getPath());
ByteCodePatcher.hooks.protectedStuff = preotectedStuffs;
ByteCodePatcher.findHooks(injectedClientFile.getPath()); ByteCodePatcher.findHooks(injectedClientFile.getPath());
} }
@@ -335,7 +340,9 @@ public class ClientLoader
return certificates.toArray(new Certificate[certificates.size()]); return certificates.toArray(new Certificate[certificates.size()]);
} }
public static String getClientInstance(String jarFile) { public static String initHookScrape(String jarFile) {
List protectedStuff = new ArrayList<String>();
String clientInstance = "";
JarClassLoader jcl = new JarClassLoader(); JarClassLoader jcl = new JarClassLoader();
try { try {
ClassPool classPool = new ClassPool(true); ClassPool classPool = new ClassPool(true);
@@ -363,17 +370,26 @@ 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.getDeclaredMethods();
for (Field f : fields) { for (Field f : fields) {
try { try {
if (f.getName().contains("$")) {
System.out.println(classToLoad.getName()+"."+f.getName());
protectedStuff.add(classToLoad.getName()+"."+f.getName());
}
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()); clientInstance = classToLoad.getName()+"."+f.getName();
return classToLoad.getName()+"."+f.getName();
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
for (Method m : methods) {
if (m.getName().contains("$")) {
protectedStuff.add(classToLoad.getName()+"."+m.getName());
}
}
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -391,6 +407,16 @@ public class ClientLoader
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return ""; int i = 0;
for (Object o : protectedStuff) {
i++;
}
preotectedStuffs = new String[i];
i = 0;
for (Object o : protectedStuff) {
preotectedStuffs[i] = (String) o;
i++;
}
return clientInstance;
} }
} }

View File

@@ -6,6 +6,7 @@ public class Hooks {
public String actorClass = ""; public String actorClass = "";
public String projectileClass = ""; public String projectileClass = "";
public String playerClass = ""; public String playerClass = "";
public String[] protectedStuff;
public Hooks() { public Hooks() {
} }