[FIX] Использование GravitGuard вместе с своей Java

This commit is contained in:
Gravit 2019-09-18 02:12:55 +07:00
parent 06c33a47ad
commit 0e278b715b
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -23,7 +23,7 @@ public class LauncherGravitGuard implements LauncherGuardInterface {
@Override @Override
public String getName() { public String getName() {
return "wrapper"; return "gravitguard";
} }
@Override @Override
@ -31,7 +31,7 @@ public Path getJavaBinPath() {
if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) { if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) {
javaBinPath = ClientLauncher.getJavaBinPath(); javaBinPath = ClientLauncher.getJavaBinPath();
String projectName = Launcher.getConfig().projectname; String projectName = Launcher.getConfig().projectname;
String wrapperUnpackName = JVMHelper.JVM_BITS == 64 ? projectName.concat("64.exe") : projectName.concat("32.exe"); String wrapperUnpackName = ( javaBinPath == null ? JVMHelper.JVM_BITS : JVMHelper.OS_BITS ) == 64 ? projectName.concat("64.exe") : projectName.concat("32.exe");
return DirBridge.getGuardDir().resolve(wrapperUnpackName); return DirBridge.getGuardDir().resolve(wrapperUnpackName);
} else } else
return IOHelper.resolveJavaBin(Paths.get(System.getProperty("java.home"))); return IOHelper.resolveJavaBin(Paths.get(System.getProperty("java.home")));
@ -39,18 +39,22 @@ public Path getJavaBinPath() {
@Override @Override
public int getClientJVMBits() { public int getClientJVMBits() {
return JVMHelper.JVM_BITS; //При использовании GravitGuard без своей джавы
//Если при запуске лаунчера используется 32 бит джава, а ОС 64бит
//То в окне настроек будет отображаться >1.б доступной памяти
//Однако при выставлении >1.б JVM x32 работать откажеться
return JVMHelper.OS_BITS;
} }
@Override @Override
public void init(boolean clientInstance) { public void init(boolean clientInstance) {
try { try {
String wrapperName = JVMHelper.JVM_BITS == 64 ? "wrapper64.exe" : "wrapper32.exe";
String projectName = Launcher.getConfig().projectname; String projectName = Launcher.getConfig().projectname;
String wrapperUnpackName = JVMHelper.JVM_BITS == 64 ? projectName.concat("64.exe") : projectName.concat("32.exe"); UnpackHelper.unpack(Launcher.getResourceURL("wrapper32.exe", "guard"), DirBridge.getGuardDir().resolve(projectName.concat("64.exe")));
String antiInjectName = JVMHelper.JVM_BITS == 64 ? "AntiInject64.dll" : "AntiInject32.dll"; UnpackHelper.unpack(Launcher.getResourceURL("AntiInject64.dll", "guard"), DirBridge.getGuardDir().resolve("AntiInject64.dll"));
UnpackHelper.unpack(Launcher.getResourceURL(wrapperName, "guard"), DirBridge.getGuardDir().resolve(wrapperUnpackName));
UnpackHelper.unpack(Launcher.getResourceURL(antiInjectName, "guard"), DirBridge.getGuardDir().resolve(antiInjectName)); UnpackHelper.unpack(Launcher.getResourceURL("wrapper32.exe", "guard"), DirBridge.getGuardDir().resolve(projectName.concat("32.exe")));
UnpackHelper.unpack(Launcher.getResourceURL("AntiInject32.dll", "guard"), DirBridge.getGuardDir().resolve("AntiInject32.dll"));
} catch (IOException e) { } catch (IOException e) {
throw new SecurityException(e); throw new SecurityException(e);
} }