diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index db5a797a..273cc5a2 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -62,9 +62,10 @@ public void start(String... args) throws Throwable { Launcher.modulesManager = new ClientModuleManager(this); LauncherConfig.getAutogenConfig().initModules(); Launcher.modulesManager.preInitModules(); - LauncherGuardManager.initGuard(false); if (runtimeProvider == null) runtimeProvider = new JSRuntimeProvider(); runtimeProvider.init(false); + runtimeProvider.preLoad(); + LauncherGuardManager.initGuard(false); Objects.requireNonNull(args, "args"); if (started.getAndSet(true)) throw new IllegalStateException("Launcher has been already started"); diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 932ddf80..fa950ead 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -469,7 +469,6 @@ public static void main(String... args) throws Throwable { LauncherConfig.getAutogenConfig().initModules(); //INIT initGson(); Launcher.modulesManager.preInitModules(); - LauncherGuardManager.initGuard(true); checkJVMBitsAndVersion(); JVMHelper.verifySystemProperties(ClientLauncher.class, true); EnvHelper.checkDangerousParams(); @@ -478,6 +477,7 @@ public static void main(String... args) throws Throwable { if (engine.runtimeProvider == null) engine.runtimeProvider = new JSRuntimeProvider(); engine.runtimeProvider.init(true); engine.runtimeProvider.preLoad(); + LauncherGuardManager.initGuard(true); // Read and delete params file LogHelper.debug("Reading ClientLauncher params"); Params params; diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java index 59d8f74c..a244196d 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java @@ -3,7 +3,10 @@ import ru.gravit.launcher.client.DirBridge; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.JVMHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.UnpackHelper; +import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; @@ -23,6 +26,10 @@ public Path getJavaBinPath() { @Override public void init(boolean clientInstance) { - + try { + UnpackHelper.unpack(IOHelper.getResourceURL(JVMHelper.JVM_BITS == 64 ? "wrapper64.exe" : "wrapper32.exe"),DirBridge.getGuardDir()); + } catch (IOException e) { + throw new SecurityException(e); + } } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java b/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java index a3109c43..bf8ec25f 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java +++ b/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java @@ -47,6 +47,7 @@ public class JSRuntimeProvider implements RuntimeProvider { private final ScriptEngine engine = CommonHelper.newScriptEngine(); + private boolean isPreLoaded = false; @LauncherAPI public static void addLauncherClassBindings(Map bindings) { @@ -145,6 +146,7 @@ private void setScriptBindings() { @Override public void run(String[] args) throws ScriptException, NoSuchMethodException, IOException { + preLoad(); loadScript(Launcher.INIT_SCRIPT_FILE); LogHelper.info("Invoking start() function"); Launcher.modulesManager.postInitModules(); @@ -154,8 +156,12 @@ public void run(String[] args) throws ScriptException, NoSuchMethodException, IO @Override public void preLoad() throws IOException, ScriptException { - loadScript(Launcher.API_SCRIPT_FILE); - loadScript(Launcher.CONFIG_SCRIPT_FILE); + if(!isPreLoaded) + { + loadScript(Launcher.API_SCRIPT_FILE); + loadScript(Launcher.CONFIG_SCRIPT_FILE); + isPreLoaded = true; + } } @Override