mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
Фикс отсутствия краша Java при обнаружении модификации клиента
This commit is contained in:
parent
dab963a2eb
commit
fc6e191ddf
3 changed files with 16 additions and 3 deletions
|
@ -109,9 +109,8 @@ public static void start(Path path1) throws IOException {
|
|||
handle(path.resolve(NAME + "32.exe"), "wrapper32.exe"),
|
||||
handle(path.resolve(NAME + "64.exe"), "wrapper64.exe"));
|
||||
HashedDir guard = new HashedDir(path, null, true, false);
|
||||
try (DirWatcher dirWatcher = new DirWatcher(path, guard, null, false)) {
|
||||
CommonHelper.newThread("Guard Directory Watcher", true, dirWatcher).start();
|
||||
}
|
||||
DirWatcher dirWatcher = new DirWatcher(path, guard, null, false);
|
||||
CommonHelper.newThread("Guard Directory Watcher", true, dirWatcher).start();
|
||||
}
|
||||
|
||||
private static void transfer(byte[] orig, Path mustdiedll) throws IOException {
|
||||
|
|
9
libLauncher/src/main/java/cpw/mods/fml/SafeExitJVM.java
Normal file
9
libLauncher/src/main/java/cpw/mods/fml/SafeExitJVM.java
Normal file
|
@ -0,0 +1,9 @@
|
|||
package cpw.mods.fml;
|
||||
// FMLSecurityManager запрещает делать System.exit из классов
|
||||
// Не входящих в пакеты самого Forge
|
||||
public class SafeExitJVM {
|
||||
public static void exit(int code)
|
||||
{
|
||||
System.exit(code);
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@
|
|||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
|
||||
import cpw.mods.fml.SafeExitJVM;
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.hasher.HashedEntry.Type;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
@ -66,6 +67,7 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) th
|
|||
|
||||
private static void handleError(Throwable e) {
|
||||
LogHelper.error(e);
|
||||
SafeExitJVM.exit(-123);
|
||||
}
|
||||
|
||||
private static Deque<String> toPath(Iterable<Path> path) {
|
||||
|
@ -135,8 +137,10 @@ private void processKey(WatchKey key) throws IOException {
|
|||
}
|
||||
|
||||
private void processLoop() throws IOException, InterruptedException {
|
||||
LogHelper.info("WatchService start processing");
|
||||
while (!Thread.interrupted())
|
||||
processKey(service.take());
|
||||
LogHelper.info("WatchService closed");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -145,6 +149,7 @@ public void run() {
|
|||
try {
|
||||
processLoop();
|
||||
} catch (InterruptedException | ClosedWatchServiceException ignored) {
|
||||
LogHelper.info("WatchService closed 2");
|
||||
// Do nothing (closed etc)
|
||||
} catch (Throwable exc) {
|
||||
handleError(exc);
|
||||
|
|
Loading…
Reference in a new issue