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 051db9c1..96d48f07 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -5,6 +5,7 @@ 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; @@ -33,6 +34,9 @@ import proguard.ProGuard; public final class JARLauncherBinary extends LauncherBinary { + + public static final String[] guardFileList = {"Avanguard64.dll", "Avanguard32.dll", "wrapper64.exe", "wrapper32.exe"}; + private final class RuntimeDirVisitor extends SimpleFileVisitor { private final ZipOutputStream output; private final Map runtime; @@ -69,6 +73,7 @@ private static ZipEntry newEntry(String fileName) { @LauncherAPI public final Path runtimeDir; + public final Path guardDir; @LauncherAPI public final Path initScriptFile; @@ -81,6 +86,7 @@ public JARLauncherBinary(LaunchServer server) throws IOException { super(server, server.dir.resolve(server.config.binaryName + ".jar"), server.dir.resolve(server.config.binaryName + (server.config.sign.enabled ? "-sign.jar" : "-obf.jar"))); runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR); + guardDir = server.dir.resolve("guard"); initScriptFile = runtimeDir.resolve(Launcher.INIT_SCRIPT_FILE); obfJar = server.config.sign.enabled ? server.dir.resolve(server.config.binaryName + "-obf.jar") : syncBinaryFile; @@ -90,6 +96,7 @@ public JARLauncherBinary(LaunchServer server) throws IOException { @Override public void build() throws IOException { tryUnpackRuntime(); + tryUnpackGuard(); // Build launcher binary LogHelper.info("Building launcher binary file"); @@ -232,6 +239,13 @@ private void stdBuild() throws IOException { output.putNextEntry(e); jaConfigurator.compile(); output.write(jaConfigurator.getBytecode()); + for(String file : guardFileList) + { + Path path = guardDir.resolve(file); + ZipEntry en = newZipEntry(file); + output.putNextEntry(en); + IOHelper.transfer(path,output); + } server.buildHookManager.postHook(context); } catch (CannotCompileException | NotFoundException e) { LogHelper.error(e); @@ -257,4 +271,23 @@ public void tryUnpackRuntime() throws IOException { } } } + @LauncherAPI + public void tryUnpackGuard() throws IOException { + // Verify is runtime dir unpacked + if (IOHelper.isDir(guardDir)) + return; // Already unpacked + + // Unpack launcher runtime files + Files.createDirectory(guardDir); + LogHelper.info("Unpacking launcher native guard files"); + try (ZipInputStream input = IOHelper.newZipInput(IOHelper.getResourceURL("guard.zip"))) { + for (ZipEntry entry = input.getNextEntry(); entry != null; entry = input.getNextEntry()) { + if (entry.isDirectory()) + continue; // Skip dirs + + // Unpack runtime file + IOHelper.transfer(input, guardDir.resolve(IOHelper.toPath(entry.getName()))); + } + } + } } diff --git a/LaunchServer/src/main/resources/guard.zip b/LaunchServer/src/main/resources/guard.zip new file mode 100644 index 00000000..bc5332b1 Binary files /dev/null and b/LaunchServer/src/main/resources/guard.zip differ diff --git a/Launcher/src/main/resources/Avanguard32.dll b/Launcher/src/main/resources/Avanguard32.dll deleted file mode 100644 index 4b845d58..00000000 Binary files a/Launcher/src/main/resources/Avanguard32.dll and /dev/null differ diff --git a/Launcher/src/main/resources/Avanguard64.dll b/Launcher/src/main/resources/Avanguard64.dll deleted file mode 100644 index 1e612bd8..00000000 Binary files a/Launcher/src/main/resources/Avanguard64.dll and /dev/null differ diff --git a/Launcher/src/main/resources/full/Avanguard32.dll b/Launcher/src/main/resources/full/Avanguard32.dll deleted file mode 100644 index 6a7fa15a..00000000 Binary files a/Launcher/src/main/resources/full/Avanguard32.dll and /dev/null differ diff --git a/Launcher/src/main/resources/full/Avanguard64.dll b/Launcher/src/main/resources/full/Avanguard64.dll deleted file mode 100644 index 1e26afec..00000000 Binary files a/Launcher/src/main/resources/full/Avanguard64.dll and /dev/null differ diff --git a/Launcher/src/main/resources/wrapper32.exe b/Launcher/src/main/resources/wrapper32.exe deleted file mode 100644 index 4a5ce974..00000000 Binary files a/Launcher/src/main/resources/wrapper32.exe and /dev/null differ diff --git a/Launcher/src/main/resources/wrapper64.exe b/Launcher/src/main/resources/wrapper64.exe deleted file mode 100644 index cce1e484..00000000 Binary files a/Launcher/src/main/resources/wrapper64.exe and /dev/null differ