[FIX] OW2 asm.

This commit is contained in:
Zaxar163 2019-04-07 11:20:40 +03:00
parent 8e87f55cff
commit b7673cf134
No known key found for this signature in database
GPG key ID: 1FE4F2E1F053831B
2 changed files with 5 additions and 5 deletions

View file

@ -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) {

View file

@ -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;