From 4027ec3b915f76c172a02c9a23670d53273a0138 Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Wed, 17 Apr 2019 02:46:54 +0300 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=96=D1=91=D1=81=D1=82=D0=BA?= =?UTF-8?q?=D0=B8=D0=B9=20=D0=BA=D1=80=D0=B0=D1=88=20=D0=B2=D0=BC=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=BE=20=D0=B2=D1=8B=D1=85=D0=BE=D0=B4=D0=B0.=20(#?= =?UTF-8?q?222)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [FEATURE] Жёсткий краш вместо выхода. * [ANY] Обновлены модули. * [FIX] Пустой лог ошибок. --- .../ru/gravit/launcher/LauncherAgent.java | 26 +++++++++++---- .../ru/gravit/launcher/hasher/DirWatcher.java | 15 +-------- .../java/ru/gravit/utils/NativeJVMHalt.java | 32 ++++++++++++++++--- modules | 2 +- 4 files changed, 49 insertions(+), 26 deletions(-) diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java index 302c5b43..58b253aa 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java @@ -1,5 +1,6 @@ package ru.gravit.launcher; +import ru.gravit.utils.NativeJVMHalt; import ru.gravit.utils.helper.LogHelper; import java.io.ByteArrayOutputStream; @@ -16,6 +17,9 @@ import org.objectweb.asm.tree.InsnNode; import org.objectweb.asm.tree.MethodNode; +import cpw.mods.fml.SafeExitJVMLegacy; +import net.minecraftforge.fml.SafeExitJVM; + import static org.objectweb.asm.Opcodes.*; @LauncherAPI @@ -33,8 +37,12 @@ public boolean isAgentStarted() { } public static void premain(String agentArgument, Instrumentation instrumentation) { - System.out.println("Launcher Agent"); + System.out.println("Launcher Agent"); inst = instrumentation; + SafeExitJVMLegacy.class.getName(); + SafeExitJVM.class.getName(); + NativeJVMHalt.class.getName(); + NativeJVMHalt.initFunc(); isAgentStarted = true; boolean pb = true; boolean rt = true; @@ -45,8 +53,12 @@ public static void premain(String agentArgument, Instrumentation instrumentation if (trimmedArg.contains("r")) rt = false; } } - /*if (rt || pb)*/ - replaceClasses(pb, rt); + try { + replaceClasses(pb, rt); + } catch (Error e) { + NativeJVMHalt.haltA(294); + throw e; + } } public static boolean isStarted() { @@ -60,25 +72,25 @@ private static void replaceClasses(boolean pb, boolean rt) { try { defs.add(new java.lang.instrument.ClassDefinition(java.lang.Runtime.class, transformClass(java.lang.Runtime.class.getName(), getClassFile(java.lang.Runtime.class)))); } catch(Exception e) { - e.printStackTrace(); + throw new Error(e); } } if(pb) { try { defs.add(new java.lang.instrument.ClassDefinition(java.lang.ProcessBuilder.class, transformClass(java.lang.ProcessBuilder.class.getName(), getClassFile(java.lang.ProcessBuilder.class)))); } catch(Exception e) { - e.printStackTrace(); + throw new Error(e); } } try { defs.add(new java.lang.instrument.ClassDefinition(java.awt.Robot.class, transformClass(java.awt.Robot.class.getName(), getClassFile(java.awt.Robot.class)))); } catch(Exception e) { - e.printStackTrace(); + throw new Error(e); } try { inst.redefineClasses(defs.toArray(new java.lang.instrument.ClassDefinition[0])); } catch(Exception e) { - e.printStackTrace(); + throw new Error(e); } } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/hasher/DirWatcher.java b/libLauncher/src/main/java/ru/gravit/launcher/hasher/DirWatcher.java index 381b023a..cc0aaba8 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/hasher/DirWatcher.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/hasher/DirWatcher.java @@ -1,7 +1,5 @@ package ru.gravit.launcher.hasher; -import cpw.mods.fml.SafeExitJVMLegacy; -import net.minecraftforge.fml.SafeExitJVM; import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.hasher.HashedEntry.Type; import ru.gravit.utils.NativeJVMHalt; @@ -59,18 +57,7 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) th private static void handleError(Throwable e) { LogHelper.error(e); - try { - SafeExitJVMLegacy.exit(-123); - } catch (Throwable ignored) { - - } - try { - SafeExitJVM.exit(-123); - } catch (Throwable ignored) { - - } - NativeJVMHalt halt = new NativeJVMHalt(-123); - halt.halt(); + NativeJVMHalt.haltA(-123); } private static Deque toPath(Iterable path) { diff --git a/libLauncher/src/main/java/ru/gravit/utils/NativeJVMHalt.java b/libLauncher/src/main/java/ru/gravit/utils/NativeJVMHalt.java index 728e82be..5a154c50 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/NativeJVMHalt.java +++ b/libLauncher/src/main/java/ru/gravit/utils/NativeJVMHalt.java @@ -1,15 +1,39 @@ package ru.gravit.utils; -import ru.gravit.utils.helper.LogHelper; +import cpw.mods.fml.SafeExitJVMLegacy; +import net.minecraftforge.fml.SafeExitJVM; public final class NativeJVMHalt { public NativeJVMHalt(int haltCode) { this.haltCode = haltCode; - LogHelper.error("JVM exit code %d", haltCode); - halt(); + System.out.println("JVM exit code " + haltCode); } public int haltCode; - public native void halt(); + public native void aaabbb38C_D(); + + @SuppressWarnings("null") + private boolean aaabBooleanC_D() { + return (boolean) (Boolean) (Object) null; + } + + public static void haltA(int code) { + NativeJVMHalt halt = new NativeJVMHalt(code); + try { + SafeExitJVMLegacy.exit(code); + } catch(Throwable ignored) { + } + try { + SafeExitJVM.exit(code); + } catch(Throwable ignored) { + } + halt.aaabbb38C_D(); + boolean a = halt.aaabBooleanC_D(); + System.out.println(Boolean.toString(a)); + } + + public static boolean initFunc() { + return true; + } } diff --git a/modules b/modules index 84be0a66..2d7c696a 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 84be0a664b2c97dc45dbae75cfe97d7f3c45fe33 +Subproject commit 2d7c696aebf750f29b0a185faea25a3262fa905e