From f74b5cd1d978853cf37f427c36fd432c0151eb11 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 21 Jan 2019 16:08:49 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=D1=8B=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B7=D0=BA=D0=B8=20=D1=81=D0=B2=D0=BE=D0=B5=D0=B9=20=D0=B4?= =?UTF-8?q?=D0=B6=D0=B0=D0=B2=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/gravit/launcher/LauncherEngine.java | 3 ++- .../java/ru/gravit/launcher/client/ClientLauncher.java | 2 +- .../ru/gravit/launcher/guard/LauncherWrapperGuard.java | 9 ++++++++- .../java/ru/gravit/launcher/gui/JSRuntimeProvider.java | 10 ++++++++-- 4 files changed, 19 insertions(+), 5 deletions(-) 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