mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FIX] Не позволяем лаунчеру разжираться слишком сильно
This commit is contained in:
parent
e002d1a7e9
commit
89c412cda1
3 changed files with 10 additions and 11 deletions
|
@ -18,6 +18,7 @@ public SafeClassWriter(ClassMetadataReader classMetadataReader, int flags) {
|
||||||
this.classMetadataReader = classMetadataReader;
|
this.classMetadataReader = classMetadataReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SafeClassWriter(ClassReader classReader, ClassMetadataReader classMetadataReader, int flags) {
|
public SafeClassWriter(ClassReader classReader, ClassMetadataReader classMetadataReader, int flags) {
|
||||||
super(classReader, flags);
|
super(classReader, flags);
|
||||||
this.classMetadataReader = classMetadataReader;
|
this.classMetadataReader = classMetadataReader;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
@ -69,16 +70,12 @@ public static void apply(Path inputFile, Path addFile, ZipOutputStream output, L
|
||||||
output.putNextEntry(IOHelper.newZipEntry(e));
|
output.putNextEntry(IOHelper.newZipEntry(e));
|
||||||
if (filename.endsWith(".class")) {
|
if (filename.endsWith(".class")) {
|
||||||
byte[] bytes;
|
byte[] bytes;
|
||||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) {
|
if(needFixes) {
|
||||||
IOHelper.transfer(input, outputStream);
|
bytes = classFix(input, reader, srv.config.launcher.stripLineNumbers);
|
||||||
bytes = outputStream.toByteArray();
|
output.write(bytes);
|
||||||
}
|
}
|
||||||
try {
|
else
|
||||||
if(needFixes) bytes = classFix(bytes, reader, srv.config.launcher.stripLineNumbers);
|
IOHelper.transfer(input, output);
|
||||||
} catch (Throwable t) {
|
|
||||||
LogHelper.error(t);
|
|
||||||
}
|
|
||||||
output.write(bytes);
|
|
||||||
} else
|
} else
|
||||||
IOHelper.transfer(input, output);
|
IOHelper.transfer(input, output);
|
||||||
e = input.getNextEntry();
|
e = input.getNextEntry();
|
||||||
|
@ -87,8 +84,8 @@ public static void apply(Path inputFile, Path addFile, ZipOutputStream output, L
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] classFix(byte[] bytes, ClassMetadataReader reader, boolean stripNumbers) {
|
private static byte[] classFix(InputStream input, ClassMetadataReader reader, boolean stripNumbers) throws IOException {
|
||||||
ClassReader cr = new ClassReader(bytes);
|
ClassReader cr = new ClassReader(input);
|
||||||
ClassNode cn = new ClassNode();
|
ClassNode cn = new ClassNode();
|
||||||
cr.accept(cn, stripNumbers ? (ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES) : ClassReader.SKIP_FRAMES);
|
cr.accept(cn, stripNumbers ? (ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES) : ClassReader.SKIP_FRAMES);
|
||||||
ClassWriter cw = new SafeClassWriter(reader, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
ClassWriter cw = new SafeClassWriter(reader, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
|
|
|
@ -81,6 +81,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
|
||||||
}
|
}
|
||||||
Collections.addAll(args, MAGIC_ARG);
|
Collections.addAll(args, MAGIC_ARG);
|
||||||
Collections.addAll(args, "-XX:+DisableAttachMechanism");
|
Collections.addAll(args, "-XX:+DisableAttachMechanism");
|
||||||
|
Collections.addAll(args, "-Xmx256M");
|
||||||
Collections.addAll(args, "-javaagent:".concat(pathLauncher));
|
Collections.addAll(args, "-javaagent:".concat(pathLauncher));
|
||||||
Collections.addAll(args, "-cp");
|
Collections.addAll(args, "-cp");
|
||||||
Collections.addAll(args, pathLauncher);
|
Collections.addAll(args, pathLauncher);
|
||||||
|
|
Loading…
Reference in a new issue