mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
Compare commits
6 commits
8509cbb6b5
...
537623afaf
Author | SHA1 | Date | |
---|---|---|---|
|
537623afaf | ||
|
0cff6e247a | ||
|
b85075c559 | ||
|
3e654f4d79 | ||
|
46f1f7b69e | ||
|
981f2ac3dd |
12 changed files with 31 additions and 92 deletions
|
@ -7,10 +7,7 @@
|
|||
import pro.gravit.utils.helper.UnpackHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -40,7 +37,7 @@ public Path process(Path inputFile) throws IOException {
|
|||
if(Files.isDirectory(server.launcherLibrariesCompile)) {
|
||||
IOHelper.walk(server.launcherLibrariesCompile, new ListFileVisitor(server.launcherBinary.addonLibs), false);
|
||||
}
|
||||
try(Stream<Path> stream = Files.walk(server.launcherPack).filter((e) -> {
|
||||
try(Stream<Path> stream = Files.walk(server.launcherPack, FileVisitOption.FOLLOW_LINKS).filter((e) -> {
|
||||
try {
|
||||
return !Files.isDirectory(e) && !Files.isHidden(e);
|
||||
} catch (IOException ex) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
|
||||
String mainClassName = "pro.gravit.launcher.start.ClientLauncherWrapper"
|
||||
String mainAgentName = "pro.gravit.launcher.runtime.LauncherAgent"
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
|
@ -20,7 +19,6 @@
|
|||
jar {
|
||||
archiveClassifier.set('clean')
|
||||
manifest.attributes("Main-Class": mainClassName,
|
||||
"Premain-Class": mainAgentName,
|
||||
"Multi-Release": "true",
|
||||
"Automatic-Module-Name": "GravitLauncher")
|
||||
}
|
||||
|
|
|
@ -124,7 +124,6 @@ public static void main(String... args) throws Throwable {
|
|||
LogHelper.printLicense("Launcher");
|
||||
LauncherEngine.checkClass(LauncherEngineWrapper.class);
|
||||
LauncherEngine.checkClass(LauncherEngine.class);
|
||||
LauncherEngine.checkClass(LauncherAgent.class);
|
||||
LauncherEngine.checkClass(ClientLauncherEntryPoint.class);
|
||||
LauncherEngine.modulesManager = new RuntimeModuleManager();
|
||||
LauncherEngine.modulesManager.loadModule(new RuntimeLauncherCoreModule());
|
||||
|
|
|
@ -142,9 +142,7 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException {
|
|||
}
|
||||
//ADD CLASSPATH
|
||||
processArgs.add(JVMHelper.jvmProperty("java.library.path", this.params.nativesDir));
|
||||
if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.AGENT) {
|
||||
processArgs.add("-javaagent:".concat(IOHelper.getCodeSource(ClientLauncherEntryPoint.class).toAbsolutePath().toString()));
|
||||
} else if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.SYSTEM_ARGS) {
|
||||
if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.SYSTEM_ARGS) {
|
||||
Set<Path> ignorePath = new HashSet<>();
|
||||
var moduleConf = params.profile.getModuleConf();
|
||||
if(moduleConf != null) {
|
||||
|
@ -159,6 +157,24 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException {
|
|||
processArgs.add("--add-modules");
|
||||
processArgs.add(String.join(",", moduleConf.modules));
|
||||
}
|
||||
if(moduleConf.exports != null && !moduleConf.exports.isEmpty()) {
|
||||
for(var e : moduleConf.exports.entrySet()) {
|
||||
processArgs.add("--add-exports");
|
||||
processArgs.add(String.format("%s=%s", e.getKey(), e.getValue()));
|
||||
}
|
||||
}
|
||||
if(moduleConf.opens != null && !moduleConf.opens.isEmpty()) {
|
||||
for(var e : moduleConf.opens.entrySet()) {
|
||||
processArgs.add("--add-opens");
|
||||
processArgs.add(String.format("%s=%s", e.getKey(), e.getValue()));
|
||||
}
|
||||
}
|
||||
if(moduleConf.reads != null && !moduleConf.reads.isEmpty()) {
|
||||
for(var e : moduleConf.reads.entrySet()) {
|
||||
processArgs.add("--add-reads");
|
||||
processArgs.add(String.format("%s=%s", e.getKey(), e.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
systemClassPath.addAll(ClientLauncherEntryPoint.resolveClassPath(ignorePath, workDir, params.actions, params.profile)
|
||||
.map(Path::toString)
|
||||
|
|
|
@ -392,7 +392,7 @@ public List<CompatibilityFlags> getFlags() {
|
|||
}
|
||||
|
||||
public enum ClassLoaderConfig {
|
||||
AGENT, LAUNCHER, MODULE, SYSTEM_ARGS
|
||||
LAUNCHER, MODULE, SYSTEM_ARGS
|
||||
}
|
||||
|
||||
public enum CompatibilityFlags {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
apply plugin: 'org.openjfx.javafxplugin'
|
||||
|
||||
String mainClassName = "pro.gravit.launcher.ClientLauncherWrapper"
|
||||
String mainAgentName = "pro.gravit.launcher.LauncherAgent"
|
||||
String mainClassName = "pro.gravit.launcher.start.ClientLauncherWrapper"
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
|
@ -14,7 +13,6 @@
|
|||
jar {
|
||||
archiveClassifier.set('clean')
|
||||
manifest.attributes("Main-Class": mainClassName,
|
||||
"Premain-Class": mainAgentName,
|
||||
"Multi-Release": "true")
|
||||
}
|
||||
|
||||
|
|
|
@ -86,9 +86,7 @@ private static void realMain(String[] args) throws Throwable {
|
|||
modulesManager.invokeEvent(new PreConfigPhase());
|
||||
LogHelper.debug("Reading ClientLauncher params");
|
||||
ClientParams params = readParams(new InetSocketAddress("127.0.0.1", Launcher.getConfig().clientPort));
|
||||
if (params.profile.getClassLoaderConfig() != ClientProfile.ClassLoaderConfig.AGENT) {
|
||||
ClientLauncherMethods.verifyNoAgent();
|
||||
}
|
||||
if(params.timestamp > System.currentTimeMillis() || params.timestamp + 30*1000 < System.currentTimeMillis() ) {
|
||||
LogHelper.error("Timestamp failed. Exit");
|
||||
ClientLauncherMethods.exitLauncher(-662);
|
||||
|
@ -160,7 +158,7 @@ private static void realMain(String[] args) throws Throwable {
|
|||
System.load(Paths.get(params.nativesDir).resolve(ClientService.findLibrary(e)).toAbsolutePath().toString());
|
||||
}
|
||||
}
|
||||
if (classLoaderConfig == ClientProfile.ClassLoaderConfig.LAUNCHER) {
|
||||
if (classLoaderConfig == ClientProfile.ClassLoaderConfig.LAUNCHER || classLoaderConfig == ClientProfile.ClassLoaderConfig.MODULE) {
|
||||
if(JVMHelper.JVM_VERSION <= 11) {
|
||||
launch = new LegacyLaunch();
|
||||
} else {
|
||||
|
@ -170,20 +168,12 @@ private static void realMain(String[] args) throws Throwable {
|
|||
System.setProperty("java.class.path", classpath.stream().map(Path::toString).collect(Collectors.joining(File.pathSeparator)));
|
||||
modulesManager.invokeEvent(new ClientProcessClassLoaderEvent(launch, classLoaderControl, profile));
|
||||
ClientService.baseURLs = classLoaderControl.getURLs();
|
||||
} else if (classLoaderConfig == ClientProfile.ClassLoaderConfig.AGENT) {
|
||||
launch = new BasicLaunch(LauncherAgent.inst);
|
||||
classpathURLs.add(IOHelper.getCodeSource(ClientLauncherEntryPoint.class).toUri().toURL());
|
||||
classLoaderControl = launch.init(classpath, params.nativesDir, options);
|
||||
for (URL url : classpathURLs) {
|
||||
LauncherAgent.addJVMClassPath(Paths.get(url.toURI()));
|
||||
}
|
||||
ClientService.instrumentation = LauncherAgent.inst;
|
||||
modulesManager.invokeEvent(new ClientProcessClassLoaderEvent(launch, null, profile));
|
||||
ClientService.baseURLs = classpathURLs.toArray(new URL[0]);
|
||||
} else if (classLoaderConfig == ClientProfile.ClassLoaderConfig.SYSTEM_ARGS) {
|
||||
launch = new BasicLaunch();
|
||||
classLoaderControl = launch.init(classpath, params.nativesDir, options);
|
||||
ClientService.baseURLs = classpathURLs.toArray(new URL[0]);
|
||||
} else {
|
||||
throw new UnsupportedOperationException(String.format("Unknown classLoaderConfig %s", classLoaderConfig));
|
||||
}
|
||||
if(profile.hasFlag(ClientProfile.CompatibilityFlags.CLASS_CONTROL_API)) {
|
||||
ClientService.classLoaderControl = classLoaderControl;
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
package pro.gravit.launcher.client;
|
||||
|
||||
import pro.gravit.launcher.client.utils.NativeJVMHalt;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.nio.file.Path;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
|
||||
public final class LauncherAgent {
|
||||
public static Instrumentation inst;
|
||||
private static boolean isAgentStarted = false;
|
||||
|
||||
public static void addJVMClassPath(String path) throws IOException {
|
||||
LogHelper.debug("Launcher Agent addJVMClassPath");
|
||||
inst.appendToSystemClassLoaderSearch(new JarFile(new File(path)));
|
||||
}
|
||||
|
||||
public static void addJVMClassPath(Path path) throws IOException {
|
||||
LogHelper.debug("Launcher Agent addJVMClassPath");
|
||||
inst.appendToSystemClassLoaderSearch(new JarFile(path.toFile()));
|
||||
}
|
||||
|
||||
public static void premain(String agentArgument, Instrumentation instrumentation) {
|
||||
System.out.println("Launcher Agent");
|
||||
checkAgentStacktrace();
|
||||
inst = instrumentation;
|
||||
NativeJVMHalt.initFunc();
|
||||
isAgentStarted = true;
|
||||
}
|
||||
|
||||
public static void checkAgentStacktrace() {
|
||||
RuntimeException ex = new SecurityException("Error check agent stacktrace");
|
||||
boolean isFoundNative = false;
|
||||
boolean foundPreMain = false;
|
||||
for (StackTraceElement e : ex.getStackTrace()) {
|
||||
if (e.isNativeMethod()) {
|
||||
if (!isFoundNative) isFoundNative = true;
|
||||
else throw ex;
|
||||
}
|
||||
if (e.getMethodName().equals("premain")) {
|
||||
if (!foundPreMain) foundPreMain = true;
|
||||
else throw ex;
|
||||
}
|
||||
}
|
||||
if (!isFoundNative || !foundPreMain) throw ex;
|
||||
}
|
||||
|
||||
public static boolean isStarted() {
|
||||
return isAgentStarted;
|
||||
}
|
||||
|
||||
public boolean isAgentStarted() {
|
||||
return isAgentStarted;
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ public final class Version implements Comparable<Version> {
|
|||
public static final int MINOR = 6;
|
||||
public static final int PATCH = 6;
|
||||
public static final int BUILD = 1;
|
||||
public static final Version.Type RELEASE = Type.DEV;
|
||||
public static final Version.Type RELEASE = Type.STABLE;
|
||||
public final int major;
|
||||
public final int minor;
|
||||
public final int patch;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
id 'org.openjfx.javafxplugin' version '0.1.0' apply false
|
||||
}
|
||||
group = 'pro.gravit.launcher'
|
||||
version = '5.6.5'
|
||||
version = '5.6.6'
|
||||
|
||||
apply from: 'props.gradle'
|
||||
|
||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
|||
Subproject commit fd0bbc04d1bcc2af9b0c86569166f491c266693b
|
||||
Subproject commit 65f882bd90623aa1581ad24cfa4f52563ea95bc0
|
|
@ -1,7 +1,7 @@
|
|||
project.ext {
|
||||
verAsm = '9.7'
|
||||
verNetty = '4.1.111.Final'
|
||||
verOshiCore = '6.6.1'
|
||||
verOshiCore = '6.6.2'
|
||||
verJunit = '5.10.2'
|
||||
verJansi = '2.4.1'
|
||||
verJline = '3.26.1'
|
||||
|
|
Loading…
Reference in a new issue