mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +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;
|
||||
}
|
||||
|
||||
|
||||
public SafeClassWriter(ClassReader classReader, ClassMetadataReader classMetadataReader, int flags) {
|
||||
super(classReader, flags);
|
||||
this.classMetadataReader = classMetadataReader;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
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));
|
||||
if (filename.endsWith(".class")) {
|
||||
byte[] bytes;
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) {
|
||||
IOHelper.transfer(input, outputStream);
|
||||
bytes = outputStream.toByteArray();
|
||||
if(needFixes) {
|
||||
bytes = classFix(input, reader, srv.config.launcher.stripLineNumbers);
|
||||
output.write(bytes);
|
||||
}
|
||||
try {
|
||||
if(needFixes) bytes = classFix(bytes, reader, srv.config.launcher.stripLineNumbers);
|
||||
} catch (Throwable t) {
|
||||
LogHelper.error(t);
|
||||
}
|
||||
output.write(bytes);
|
||||
else
|
||||
IOHelper.transfer(input, output);
|
||||
} else
|
||||
IOHelper.transfer(input, output);
|
||||
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) {
|
||||
ClassReader cr = new ClassReader(bytes);
|
||||
private static byte[] classFix(InputStream input, ClassMetadataReader reader, boolean stripNumbers) throws IOException {
|
||||
ClassReader cr = new ClassReader(input);
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, stripNumbers ? (ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES) : ClassReader.SKIP_FRAMES);
|
||||
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, "-XX:+DisableAttachMechanism");
|
||||
Collections.addAll(args, "-Xmx256M");
|
||||
Collections.addAll(args, "-javaagent:".concat(pathLauncher));
|
||||
Collections.addAll(args, "-cp");
|
||||
Collections.addAll(args, pathLauncher);
|
||||
|
|
Loading…
Reference in a new issue