From b7673cf13408dee3deb5ce1c1051c0837f457639 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Sun, 7 Apr 2019 11:20:40 +0300 Subject: [PATCH] [FIX] OW2 asm. --- Launcher/build.gradle | 2 +- .../src/main/java/ru/gravit/launcher/LauncherAgent.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Launcher/build.gradle b/Launcher/build.gradle index f15b639d..83d594fd 100644 --- a/Launcher/build.gradle +++ b/Launcher/build.gradle @@ -28,7 +28,7 @@ dependencies { pack project(':LauncherAPI') // Not error on obf. bundle 'com.github.oshi:oshi-core:3.13.0' - bundle 'org.ow2.asm:asm-tree:7.1' + compileOnly 'org.ow2.asm:asm-all:5.0.3' } task genRuntimeJS(type: Zip) { diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java index 3a589a16..14117c8e 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java @@ -43,7 +43,7 @@ public static void premain(String agentArgument, Instrumentation instrumentation if (trimmedArg.contains("r")) rt = false; } } - replaceClasses(pb, rt); + if (rt || pb) replaceClasses(pb, rt); } public static boolean isStarted() { @@ -54,7 +54,7 @@ public static boolean isStarted() { * @author https://github.com/Konloch/JVM-Sandbox * Replaces the Runtime class via instrumentation, transforms the class via ASM */ - public static void replaceClasses(boolean pb, boolean rt) { + private static void replaceClasses(boolean pb, boolean rt) { for(Class c : inst.getAllLoadedClasses()) { if(rt && c.getName().equals("java.lang.Runtime")) { try { @@ -84,7 +84,7 @@ public static void replaceClasses(boolean pb, boolean rt) { * @author https://github.com/Konloch/JVM-Sandbox * Use ASM to modify the byte array */ - public static byte[] transformClass(String className, byte[] classBytes) { + private static byte[] transformClass(String className, byte[] classBytes) { if (className.equals("java.lang.Runtime")) { ClassReader cr=new ClassReader(classBytes); ClassNode cn=new ClassNode(); @@ -146,7 +146,7 @@ public static byte[] transformClass(String className, byte[] classBytes) { * @return array, respending this class in bytecode. * @throws IOException */ - public static byte[] getClassFile(Class clazz) throws IOException { + private static byte[] getClassFile(Class clazz) throws IOException { InputStream is = clazz.getResourceAsStream( "/" + clazz.getName().replace('.', '/') + ".class"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int r = 0;