This commit is contained in:
parent
b534b92456
commit
34a9334eaf
3 changed files with 32 additions and 14 deletions
|
@ -1,7 +1,8 @@
|
||||||
package de.com.baseband.launcher;
|
package de.com.baseband.launcher;
|
||||||
|
|
||||||
import de.com.baseband.clientboot.ClientBoot;
|
import de.com.baseband.clientboot.ClientBoot;
|
||||||
import de.com.baseband.launcher.classloader.CustomClassLoader;
|
import de.com.baseband.launcher.classloader.GameClassLoader;
|
||||||
|
import de.com.baseband.launcher.classloader.SimpleClassLoader;
|
||||||
import de.com.baseband.launcher.security.SecurityImpl;
|
import de.com.baseband.launcher.security.SecurityImpl;
|
||||||
import de.com.baseband.launcher.security.impl.AntiInstrumentationImpl;
|
import de.com.baseband.launcher.security.impl.AntiInstrumentationImpl;
|
||||||
import de.com.baseband.launcher.security.impl.JVMArgImpl;
|
import de.com.baseband.launcher.security.impl.JVMArgImpl;
|
||||||
|
@ -70,12 +71,12 @@ public class Loader implements Util {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CustomClassLoader classLoader;
|
private static GameClassLoader classLoader;
|
||||||
|
|
||||||
public static void run() {
|
public static void run() {
|
||||||
AccessKiller.killReflectionFor(
|
AccessKiller.killReflectionFor(
|
||||||
CustomClassLoader.class,
|
GameClassLoader.class,
|
||||||
CustomClassLoader.CustomMixinServer.class);
|
GameClassLoader.CustomMixinServer.class);
|
||||||
AccessKiller.killFieldAccess(Loader.class);
|
AccessKiller.killFieldAccess(Loader.class);
|
||||||
AccessKiller.killMethodAccess(Loader.class);
|
AccessKiller.killMethodAccess(Loader.class);
|
||||||
|
|
||||||
|
@ -337,7 +338,7 @@ public class Loader implements Util {
|
||||||
}
|
}
|
||||||
LOGGER.info("BaseBand downloaded: {} chunks.", data.size());
|
LOGGER.info("BaseBand downloaded: {} chunks.", data.size());
|
||||||
LOGGER.info("Booting BaseBand {} @ {}", clientData.getString("build-name"), new String(data.get("commit")).trim());
|
LOGGER.info("Booting BaseBand {} @ {}", clientData.getString("build-name"), new String(data.get("commit")).trim());
|
||||||
classLoader = new CustomClassLoader(data);
|
classLoader = new GameClassLoader(data);
|
||||||
downloadUpdated.unlock();
|
downloadUpdated.unlock();
|
||||||
classLoader.inject();
|
classLoader.inject();
|
||||||
classLoader.informClient(clientData);
|
classLoader.informClient(clientData);
|
||||||
|
@ -365,7 +366,7 @@ public class Loader implements Util {
|
||||||
HashMap<String, byte[]> data = downloadFromSPL("https://download.baseband.com.de/download/client/" + options.getString("branch"));
|
HashMap<String, byte[]> data = downloadFromSPL("https://download.baseband.com.de/download/client/" + options.getString("branch"));
|
||||||
LOGGER.info("BaseBand downloaded: {} chunks.", data.size());
|
LOGGER.info("BaseBand downloaded: {} chunks.", data.size());
|
||||||
LOGGER.info("Booting BaseBand {} @ {}", options.getString("build-name"), new String(data.get("commit")).trim());
|
LOGGER.info("Booting BaseBand {} @ {}", options.getString("build-name"), new String(data.get("commit")).trim());
|
||||||
classLoader = new CustomClassLoader(data);
|
classLoader = new GameClassLoader(data);
|
||||||
classLoader.inject();
|
classLoader.inject();
|
||||||
classLoader.informClient(options);
|
classLoader.informClient(options);
|
||||||
}
|
}
|
||||||
|
@ -373,8 +374,7 @@ public class Loader implements Util {
|
||||||
|
|
||||||
private static void splUpdate() {
|
private static void splUpdate() {
|
||||||
LOGGER.info("BaseBand is downloading a significant update...");
|
LOGGER.info("BaseBand is downloading a significant update...");
|
||||||
CustomClassLoader loaderReloader = new CustomClassLoader(downloadFromSPL("https://download.baseband.com.de/download/loader"));
|
SimpleClassLoader loaderReloader = new SimpleClassLoader(downloadFromSPL("https://download.baseband.com.de/download/loader"));
|
||||||
loaderReloader.inject();
|
|
||||||
LOGGER.info("BaseBand has downloaded a significant update. Applying...");
|
LOGGER.info("BaseBand has downloaded a significant update. Applying...");
|
||||||
try {
|
try {
|
||||||
loaderReloader.loadClass(Tweaker.class.getName()).getMethod("load").invoke(null);
|
loaderReloader.loadClass(Tweaker.class.getName()).getMethod("load").invoke(null);
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import static de.com.baseband.launcher.Loader.exit;
|
import static de.com.baseband.launcher.Loader.exit;
|
||||||
|
|
||||||
public class CustomClassLoader extends ClassLoader implements Util {
|
public class GameClassLoader extends ClassLoader implements Util {
|
||||||
private final HashSet<String> names = new HashSet<>();
|
private final HashSet<String> names = new HashSet<>();
|
||||||
private final DataKeeper<Map<String, byte[]>> binaryKeeper;
|
private final DataKeeper<Map<String, byte[]>> binaryKeeper;
|
||||||
private final DataKeeper<PermissionManager> mixinPermissionManager;
|
private final DataKeeper<PermissionManager> mixinPermissionManager;
|
||||||
|
@ -34,17 +34,17 @@ public class CustomClassLoader extends ClassLoader implements Util {
|
||||||
try {
|
try {
|
||||||
Method m = Arrays.stream(Class.forName("java.lang.ClassLoader").getDeclaredClasses()).filter(x -> x.getSimpleName().equalsIgnoreCase("ParallelLoaders")).findFirst().get().getDeclaredMethod("register", Class.class);
|
Method m = Arrays.stream(Class.forName("java.lang.ClassLoader").getDeclaredClasses()).filter(x -> x.getSimpleName().equalsIgnoreCase("ParallelLoaders")).findFirst().get().getDeclaredMethod("register", Class.class);
|
||||||
m.setAccessible(true);
|
m.setAccessible(true);
|
||||||
m.invoke(null, CustomClassLoader.class);
|
m.invoke(null, GameClassLoader.class);
|
||||||
LOGGER.info("Patched ClassLoader.");
|
LOGGER.info("Patched ClassLoader.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("unable to patch ClassLoader", e);
|
throw new RuntimeException("unable to patch ClassLoader", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomClassLoader(Map<String, byte[]> data) {
|
public GameClassLoader(Map<String, byte[]> data) {
|
||||||
names.addAll(data.keySet());
|
names.addAll(data.keySet());
|
||||||
this.binaryKeeper = new DataKeeper<>(
|
this.binaryKeeper = new DataKeeper<>(
|
||||||
new PermissionOR(new ClassLoaderRestriction(this), new CallClassRestriction(CustomClassLoader.class, CustomMixinServer.class)),
|
new PermissionOR(new ClassLoaderRestriction(this), new CallClassRestriction(GameClassLoader.class, CustomMixinServer.class)),
|
||||||
StrictnessBuilder.create()
|
StrictnessBuilder.create()
|
||||||
.property("Restriction.ClassLoader.RestrictLambda", true)
|
.property("Restriction.ClassLoader.RestrictLambda", true)
|
||||||
.property("Restriction.ClassLoader.MaxDistance", 5)
|
.property("Restriction.ClassLoader.MaxDistance", 5)
|
||||||
|
@ -191,9 +191,9 @@ public class CustomClassLoader extends ClassLoader implements Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CustomMixinServer extends MixinServiceLaunchWrapper {
|
public static class CustomMixinServer extends MixinServiceLaunchWrapper {
|
||||||
private final CustomClassLoader parent;
|
private final GameClassLoader parent;
|
||||||
|
|
||||||
public CustomMixinServer(CustomClassLoader parent) {
|
public CustomMixinServer(GameClassLoader parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package de.com.baseband.launcher.classloader;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class SimpleClassLoader extends ClassLoader {
|
||||||
|
|
||||||
|
HashMap<String, byte[]> classes;
|
||||||
|
|
||||||
|
public SimpleClassLoader(HashMap<String, byte[]> classes) {
|
||||||
|
this.classes = classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<?> findClass(String name) {
|
||||||
|
byte[] b = classes.get(name.replace('.', '/') + ".class");
|
||||||
|
return defineClass(name.replace('/', '.'), b, 0, b.length);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue