mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Жёсткий краш вместо выхода. (#222)
* [FEATURE] Жёсткий краш вместо выхода. * [ANY] Обновлены модули. * [FIX] Пустой лог ошибок.
This commit is contained in:
parent
2bee616d1c
commit
4027ec3b91
4 changed files with 49 additions and 26 deletions
|
@ -1,5 +1,6 @@
|
||||||
package ru.gravit.launcher;
|
package ru.gravit.launcher;
|
||||||
|
|
||||||
|
import ru.gravit.utils.NativeJVMHalt;
|
||||||
import ru.gravit.utils.helper.LogHelper;
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -16,6 +17,9 @@
|
||||||
import org.objectweb.asm.tree.InsnNode;
|
import org.objectweb.asm.tree.InsnNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
import cpw.mods.fml.SafeExitJVMLegacy;
|
||||||
|
import net.minecraftforge.fml.SafeExitJVM;
|
||||||
|
|
||||||
import static org.objectweb.asm.Opcodes.*;
|
import static org.objectweb.asm.Opcodes.*;
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
|
@ -33,8 +37,12 @@ public boolean isAgentStarted() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void premain(String agentArgument, Instrumentation instrumentation) {
|
public static void premain(String agentArgument, Instrumentation instrumentation) {
|
||||||
System.out.println("Launcher Agent");
|
System.out.println("Launcher Agent");
|
||||||
inst = instrumentation;
|
inst = instrumentation;
|
||||||
|
SafeExitJVMLegacy.class.getName();
|
||||||
|
SafeExitJVM.class.getName();
|
||||||
|
NativeJVMHalt.class.getName();
|
||||||
|
NativeJVMHalt.initFunc();
|
||||||
isAgentStarted = true;
|
isAgentStarted = true;
|
||||||
boolean pb = true;
|
boolean pb = true;
|
||||||
boolean rt = true;
|
boolean rt = true;
|
||||||
|
@ -45,8 +53,12 @@ public static void premain(String agentArgument, Instrumentation instrumentation
|
||||||
if (trimmedArg.contains("r")) rt = false;
|
if (trimmedArg.contains("r")) rt = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*if (rt || pb)*/
|
try {
|
||||||
replaceClasses(pb, rt);
|
replaceClasses(pb, rt);
|
||||||
|
} catch (Error e) {
|
||||||
|
NativeJVMHalt.haltA(294);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isStarted() {
|
public static boolean isStarted() {
|
||||||
|
@ -60,25 +72,25 @@ private static void replaceClasses(boolean pb, boolean rt) {
|
||||||
try {
|
try {
|
||||||
defs.add(new java.lang.instrument.ClassDefinition(java.lang.Runtime.class, transformClass(java.lang.Runtime.class.getName(), getClassFile(java.lang.Runtime.class))));
|
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) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
throw new Error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pb) {
|
if(pb) {
|
||||||
try {
|
try {
|
||||||
defs.add(new java.lang.instrument.ClassDefinition(java.lang.ProcessBuilder.class, transformClass(java.lang.ProcessBuilder.class.getName(), getClassFile(java.lang.ProcessBuilder.class))));
|
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) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
throw new Error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
defs.add(new java.lang.instrument.ClassDefinition(java.awt.Robot.class, transformClass(java.awt.Robot.class.getName(), getClassFile(java.awt.Robot.class))));
|
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) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
throw new Error(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
inst.redefineClasses(defs.toArray(new java.lang.instrument.ClassDefinition[0]));
|
inst.redefineClasses(defs.toArray(new java.lang.instrument.ClassDefinition[0]));
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
throw new Error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package ru.gravit.launcher.hasher;
|
package ru.gravit.launcher.hasher;
|
||||||
|
|
||||||
import cpw.mods.fml.SafeExitJVMLegacy;
|
|
||||||
import net.minecraftforge.fml.SafeExitJVM;
|
|
||||||
import ru.gravit.launcher.LauncherAPI;
|
import ru.gravit.launcher.LauncherAPI;
|
||||||
import ru.gravit.launcher.hasher.HashedEntry.Type;
|
import ru.gravit.launcher.hasher.HashedEntry.Type;
|
||||||
import ru.gravit.utils.NativeJVMHalt;
|
import ru.gravit.utils.NativeJVMHalt;
|
||||||
|
@ -59,18 +57,7 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) th
|
||||||
|
|
||||||
private static void handleError(Throwable e) {
|
private static void handleError(Throwable e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
try {
|
NativeJVMHalt.haltA(-123);
|
||||||
SafeExitJVMLegacy.exit(-123);
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
SafeExitJVM.exit(-123);
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
|
|
||||||
}
|
|
||||||
NativeJVMHalt halt = new NativeJVMHalt(-123);
|
|
||||||
halt.halt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Deque<String> toPath(Iterable<Path> path) {
|
private static Deque<String> toPath(Iterable<Path> path) {
|
||||||
|
|
|
@ -1,15 +1,39 @@
|
||||||
package ru.gravit.utils;
|
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 final class NativeJVMHalt {
|
||||||
public NativeJVMHalt(int haltCode) {
|
public NativeJVMHalt(int haltCode) {
|
||||||
this.haltCode = haltCode;
|
this.haltCode = haltCode;
|
||||||
LogHelper.error("JVM exit code %d", haltCode);
|
System.out.println("JVM exit code " + haltCode);
|
||||||
halt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
||||||
Subproject commit 84be0a664b2c97dc45dbae75cfe97d7f3c45fe33
|
Subproject commit 2d7c696aebf750f29b0a185faea25a3262fa905e
|
Loading…
Reference in a new issue