Access Transformer

This commit is contained in:
kirillsaint 2023-07-02 15:00:36 +06:00
parent d430104e06
commit 06ee455342
3 changed files with 91 additions and 0 deletions

BIN
libs/asm-5.0.3.jar Normal file

Binary file not shown.

View File

@ -0,0 +1,90 @@
package net.silentclient.client.mixin;
import net.minecraft.launchwrapper.IClassTransformer;
import net.silentclient.client.Client;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import java.lang.reflect.Modifier;
public class SilentClientTransformer implements IClassTransformer {
@Override
public byte[] transform(String name, String transformedName, byte[] bytes) {
if (bytes == null)
{
return null;
}
if(transformedName.equals("bfl$e")) {
Client.logger.info("Transforming class: " + transformedName);
ClassReader classreader = new ClassReader(bytes);
ClassWriter classwriter = new ClassWriter(1);
SilentClientTransformer.AccessTransformerVisitor visitor = new SilentClientTransformer.AccessTransformerVisitor(262144, classwriter);
classreader.accept(visitor, 0);
return classwriter.toByteArray();
}
if(transformedName.equals("bfl$r")) {
Client.logger.info("Transforming class: " + transformedName);
ClassReader classreader = new ClassReader(bytes);
ClassWriter classwriter = new ClassWriter(1);
SilentClientTransformer.AccessTransformerVisitor visitor = new SilentClientTransformer.AccessTransformerVisitor(262144, classwriter);
classreader.accept(visitor, 0);
return classwriter.toByteArray();
}
if(transformedName.equals("bnm$a")) {
Client.logger.info("Transforming class: " + transformedName);
ClassReader classreader = new ClassReader(bytes);
ClassWriter classwriter = new ClassWriter(1);
SilentClientTransformer.AccessTransformerVisitor visitor = new SilentClientTransformer.AccessTransformerVisitor(262144, classwriter);
classreader.accept(visitor, 0);
return classwriter.toByteArray();
}
if(transformedName.equals("ajd$a")) {
Client.logger.info("Transforming class: " + transformedName);
ClassReader classreader = new ClassReader(bytes);
ClassWriter classwriter = new ClassWriter(1);
SilentClientTransformer.AccessTransformerVisitor visitor = new SilentClientTransformer.AccessTransformerVisitor(262144, classwriter);
classreader.accept(visitor, 0);
return classwriter.toByteArray();
}
if(transformedName.equals("bha$a")) {
Client.logger.info("Transforming class: " + transformedName);
ClassReader classreader = new ClassReader(bytes);
ClassWriter classwriter = new ClassWriter(1);
SilentClientTransformer.AccessTransformerVisitor visitor = new SilentClientTransformer.AccessTransformerVisitor(262144, classwriter);
classreader.accept(visitor, 0);
return classwriter.toByteArray();
}
return bytes;
}
public class AccessTransformerVisitor extends ClassVisitor {
public AccessTransformerVisitor(int api, ClassVisitor cv) {
super(api, cv);
}
@Override
public void visitInnerClass(String name, String outerName, String innerName, int access) {
super.visitInnerClass(name, outerName, innerName, Modifier.PUBLIC);
}
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
super.visit(version, Modifier.PUBLIC, name, signature, superName, interfaces);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
return super.visitMethod(Modifier.PUBLIC, name, desc, signature, exceptions);
}
}
}

View File

@ -61,6 +61,7 @@ public class SilentClientTweaker implements ITweaker {
environment.setObfuscationContext("notch"); environment.setObfuscationContext("notch");
} }
environment.setSide(MixinEnvironment.Side.CLIENT); environment.setSide(MixinEnvironment.Side.CLIENT);
classLoader.registerTransformer("net.silentclient.client.mixin.SilentClientTransformer");
} }
@Override @Override