mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-01 22:14:01 +03:00
Added wrap. Fixed NeverDecomp.
This commit is contained in:
parent
af16505bac
commit
bf73e15c3f
3 changed files with 16 additions and 57 deletions
|
@ -19,55 +19,6 @@ public class AntiDecomp {
|
|||
Throwable.class, Exception.class, Error.class, InternalError.class, RuntimeException.class, NullPointerException.class,
|
||||
AssertionError.class, NoClassDefFoundError.class, IOException.class, NoSuchFieldException.class, SecurityException.class, InvocationTargetException.class
|
||||
};
|
||||
private static class ObfClassVisitor extends ClassVisitor {
|
||||
private Random r = new SecureRandom();
|
||||
private ObfClassVisitor(ClassVisitor classVisitor) {
|
||||
super(Opcodes.ASM7, classVisitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
return new AdviceAdapter(Opcodes.ASM7, super.visitMethod(access, name, desc, signature, exceptions), access,
|
||||
name, desc) {
|
||||
|
||||
@Override
|
||||
public void onMethodEnter() {
|
||||
antiDecomp();
|
||||
}
|
||||
|
||||
public void antiDecomp() {
|
||||
Label lbl1 = super.newLabel(), lbl15 = super.newLabel(), lbl2 = super.newLabel(),
|
||||
lbl25 = super.newLabel();
|
||||
|
||||
// try-catch блок с lbl1 до lbl2 с переходом на lbl2 при java/lang/Exception
|
||||
this.visitException(lbl1, lbl2, lbl2);
|
||||
|
||||
// lbl1: iconst_0
|
||||
super.visitLabel(lbl1);
|
||||
super.visitInsn(ICONST_0);
|
||||
// lbl15: pop; goto lbl25
|
||||
super.visitLabel(lbl15);
|
||||
super.visitInsn(POP);
|
||||
this.jumpLabel(lbl25);
|
||||
// lbl2: pop; pop2
|
||||
super.visitLabel(lbl2);
|
||||
super.visitInsn(POP);
|
||||
super.visitInsn(POP2);
|
||||
// lbl25:
|
||||
super.visitLabel(lbl25);
|
||||
}
|
||||
|
||||
public void visitException(Label st, Label en, Label h) {
|
||||
super.visitTryCatchBlock(st, en, h, Type.getInternalName(exceptionsL[r.nextInt(exceptionsL.length-1)]));
|
||||
}
|
||||
|
||||
public void jumpLabel(Label to) {
|
||||
super.visitJumpInsn(GOTO, to);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static class AObfClassVisitor extends ClassVisitor {
|
||||
private Random r = new SecureRandom();
|
||||
private AObfClassVisitor(ClassVisitor classVisitor) {
|
||||
|
@ -134,11 +85,4 @@ public static byte[] antiDecomp(final byte[] input, ClassMetadataReader reader)
|
|||
cr.accept(new AObfClassVisitor(cw), ClassReader.SKIP_DEBUG | ClassReader.EXPAND_FRAMES);
|
||||
return cw.toByteArray();
|
||||
}
|
||||
|
||||
public static byte[] expAntiDecomp(byte[] input, ClassMetadataReader reader) {
|
||||
ClassReader cr = new ClassReader(input);
|
||||
ClassWriter cw = new SafeClassWriter(reader, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||
cr.accept(new ObfClassVisitor(cw), ClassReader.SKIP_DEBUG | ClassReader.EXPAND_FRAMES);
|
||||
return cw.toByteArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import ru.gravit.launcher.AutogenConfig;
|
||||
import ru.gravit.launcher.modules.TestClientModule;
|
||||
import ru.gravit.launchserver.asm.ClassMetadataReader;
|
||||
import ru.gravit.launchserver.binary.BuildContext;
|
||||
import ru.gravit.launchserver.binary.JAConfigurator;
|
||||
import ru.gravit.launchserver.binary.JARLauncherBinary;
|
||||
|
@ -28,6 +30,11 @@ public static interface Transformer {
|
|||
byte[] transform(byte[] input, String classname, JARLauncherBinary data);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public static interface ReaderTransformer {
|
||||
byte[] transform(byte[] input, String classname, ClassMetadataReader data);
|
||||
}
|
||||
|
||||
private boolean BUILDRUNTIME;
|
||||
private final Set<BuildHook> POST_HOOKS;
|
||||
private final Set<Runnable> POST_PROGUARDRUN_HOOKS;
|
||||
|
@ -161,4 +168,12 @@ public void registerPreHook(BuildHook hook) {
|
|||
public void setBuildRuntime(boolean runtime) {
|
||||
BUILDRUNTIME = runtime;
|
||||
}
|
||||
|
||||
public static Transformer wrap(BiFunction<byte[], ClassMetadataReader, byte[]> func) {
|
||||
return (code, name, binaryCls) -> func.apply(code, binaryCls.reader);
|
||||
}
|
||||
|
||||
public static Transformer wrap(ReaderTransformer func) {
|
||||
return (code, name, binaryCls) -> func.transform(code, name, binaryCls.reader);
|
||||
}
|
||||
}
|
||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
|||
Subproject commit b956ffe0479d6b7b8c28c6f16864e516f45b307d
|
||||
Subproject commit c4705248d6e6576294a9ff62edd4dd263b682533
|
Loading…
Reference in a new issue