diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java index 213e4241..8d289edc 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -5,7 +5,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.InputStream; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.util.HashMap; @@ -20,7 +19,6 @@ import javassist.NotFoundException; import ru.gravit.launcher.AutogenConfig; import ru.gravit.launcher.Launcher; -import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; @@ -69,27 +67,27 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO private final class GuardDirVisitor extends SimpleFileVisitor { private final ZipOutputStream output; - private final Map runtime; + private final Map guard; - private GuardDirVisitor(ZipOutputStream output, Map runtime) { + private GuardDirVisitor(ZipOutputStream output, Map guard) { this.output = output; - this.runtime = runtime; + this.guard = guard; } @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { String dirName = IOHelper.toString(guardDir.relativize(dir)); - output.putNextEntry(newEntry(dirName + '/')); + output.putNextEntry(newGuardEntry(dirName + '/')); return super.preVisitDirectory(dir, attrs); } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { String fileName = IOHelper.toString(guardDir.relativize(file)); - runtime.put(fileName, SecurityHelper.digest(DigestAlgorithm.MD5, file)); + guard.put(fileName, SecurityHelper.digest(DigestAlgorithm.MD5, file)); // Create zip entry and transfer contents - output.putNextEntry(newEntry(fileName)); + output.putNextEntry(newGuardEntry(fileName)); IOHelper.transfer(file, output); // Return result @@ -100,6 +98,9 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO private static ZipEntry newEntry(String fileName) { return newZipEntry(Launcher.RUNTIME_DIR + IOHelper.CROSS_SEPARATOR + fileName); } + private static ZipEntry newGuardEntry(String fileName) { + return newZipEntry(Launcher.GUARD_DIR + IOHelper.CROSS_SEPARATOR + fileName); + } public final Path runtimeDir; @@ -246,13 +247,13 @@ private void stdBuild() throws IOException { output.putNextEntry(newZipEntry(ent.getKey().replace('.', '/').concat(".class"))); output.write(server.buildHookManager.classTransform(ent.getValue(), ent.getKey())); } - // map for runtime + // map for guard Map runtime = new HashMap<>(256); if (server.buildHookManager.buildRuntime()) { // Verify has init script file if (!IOHelper.isFile(initScriptFile)) throw new IOException(String.format("Missing init script file ('%s')", Launcher.INIT_SCRIPT_FILE)); - // Write launcher runtime dir + // Write launcher guard dir IOHelper.walk(runtimeDir, new RuntimeDirVisitor(output, runtime), false); IOHelper.walk(guardDir, new GuardDirVisitor(output, runtime), false); } @@ -281,11 +282,11 @@ private void stdBuild() throws IOException { public void tryUnpackRuntime() throws IOException { - // Verify is runtime dir unpacked + // Verify is guard dir unpacked if (IOHelper.isDir(runtimeDir)) return; // Already unpacked - // Unpack launcher runtime files + // Unpack launcher guard files Files.createDirectory(runtimeDir); LogHelper.info("Unpacking launcher runtime files"); try (ZipInputStream input = IOHelper.newZipInput(IOHelper.getResourceURL("runtime.zip"))) { @@ -293,18 +294,18 @@ public void tryUnpackRuntime() throws IOException { if (entry.isDirectory()) continue; // Skip dirs - // Unpack runtime file + // Unpack guard file IOHelper.transfer(input, runtimeDir.resolve(IOHelper.toPath(entry.getName()))); } } } public void tryUnpackGuard() throws IOException { - // Verify is runtime dir unpacked + // Verify is guard dir unpacked if (IOHelper.isDir(guardDir)) return; // Already unpacked - // Unpack launcher runtime files + // Unpack launcher guard files Files.createDirectory(guardDir); LogHelper.info("Unpacking launcher native guard files"); try (ZipInputStream input = IOHelper.newZipInput(IOHelper.getResourceURL("guard.zip"))) { @@ -312,7 +313,7 @@ public void tryUnpackGuard() throws IOException { if (entry.isDirectory()) continue; // Skip dirs - // Unpack runtime file + // Unpack guard file IOHelper.transfer(input, guardDir.resolve(IOHelper.toPath(entry.getName()))); } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java index fac29ef1..85fda4d2 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java @@ -29,6 +29,8 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString(); args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled()))); Collections.addAll(args, "-javaagent:".concat(pathLauncher)); + Collections.addAll(args, "-cp"); + Collections.addAll(args, pathLauncher); Collections.addAll(args, LauncherEngine.class.getName()); EnvHelper.addEnv(processBuilder); LogHelper.debug("Commandline: " + args); diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index 5d0ff57e..d1bd3e4a 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -151,7 +151,7 @@ public static void main(String... args) throws Throwable { JVMHelper.checkStackTrace(LauncherEngine.class); JVMHelper.verifySystemProperties(Launcher.class, true); EnvHelper.checkDangerousParams(); - if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set"); + //if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set"); LogHelper.printVersion("Launcher"); // Start Launcher Instant start = Instant.now(); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java b/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java index bbbed701..b503a285 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java @@ -52,6 +52,8 @@ static int readBuildNumber() { @LauncherAPI public static final String RUNTIME_DIR = "runtime"; @LauncherAPI + public static final String GUARD_DIR = "guard"; + @LauncherAPI public static final String CONFIG_FILE = "config.bin"; @LauncherAPI public static ClientProfile profile;