fix: support android studio 2025.1.2
This commit is contained in:
parent
3e5cf0680d
commit
a3b68f7746
41
src/main/java/com/novitechie/CollectionsTransformer.java
Normal file
41
src/main/java/com/novitechie/CollectionsTransformer.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.novitechie;
|
||||
|
||||
import com.janetfilter.core.plugin.MyTransformer;
|
||||
import jdk.internal.org.objectweb.asm.ClassReader;
|
||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||
import jdk.internal.org.objectweb.asm.tree.*;
|
||||
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
/**
|
||||
* @author YeloChick
|
||||
*/
|
||||
public class CollectionsTransformer implements MyTransformer {
|
||||
|
||||
@Override
|
||||
public String getHookClassName() {
|
||||
return "java/util/Collections";
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(String className, byte[] classBytes, int order) throws Exception {
|
||||
ClassReader reader = new ClassReader(classBytes);
|
||||
ClassNode node = new ClassNode(ASM5);
|
||||
reader.accept(node, 0);
|
||||
for (MethodNode m : node.methods) {
|
||||
if ("shuffle".equals(m.name)) {
|
||||
InsnList list = new InsnList();
|
||||
LabelNode L0 = new LabelNode();
|
||||
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/StackTraceRule", "check", "()Z", false));
|
||||
list.add(new JumpInsnNode(IFEQ, L0));
|
||||
list.add(new VarInsnNode(ALOAD, 0));
|
||||
list.add(new InsnNode(ARETURN));
|
||||
list.add(L0);
|
||||
m.instructions.insert(list);
|
||||
}
|
||||
}
|
||||
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||
node.accept(writer);
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ public class PluginManagerCoreTransformer implements MyTransformer {
|
||||
LabelNode L3 = new LabelNode();
|
||||
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/StackTraceRule", "check", "()Z", false));
|
||||
list.add(new JumpInsnNode(IFEQ, L0));
|
||||
list.add(new MethodInsnNode(INVOKESTATIC, "com/intellij/ide/plugins/PluginManagerCore", "getPluginSet", "()Lcom/intellij/ide/plugins/PluginSet;", false));
|
||||
list.add(new FieldInsnNode(GETSTATIC, "com/intellij/ide/plugins/PluginManagerCore", "nullablePluginSet", "Lcom/intellij/ide/plugins/PluginSet;"));
|
||||
list.add(new FieldInsnNode(GETFIELD, "com/intellij/ide/plugins/PluginSet", "allPlugins", "Ljava/util/Set;"));
|
||||
list.add(new VarInsnNode(ASTORE, 0));
|
||||
list.add(new TypeInsnNode(NEW, "java/util/HashSet"));
|
||||
|
@ -35,6 +35,7 @@ public class PrivacyPlugin implements PluginEntry {
|
||||
@Override
|
||||
public List<MyTransformer> getTransformers() {
|
||||
return Arrays.asList(
|
||||
// new CollectionsTransformer(),
|
||||
new VMOptionsTransformer(),
|
||||
new PluginClassLoaderTransformer(),
|
||||
new LicensingFacadeTransformer(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user