commit
8be6cfa8ae
|
@ -0,0 +1,51 @@
|
|||
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 PluginManagerCoreTransformer implements MyTransformer {
|
||||
|
||||
@Override
|
||||
public String getHookClassName() {
|
||||
return "com/intellij/ide/plugins/PluginManagerCore";
|
||||
}
|
||||
|
||||
@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 ("isPluginInstalled".equals(m.name)) {
|
||||
InsnList list = new InsnList();
|
||||
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/StackTraceRule", "check", "()Z", false));
|
||||
LabelNode labelNode = new LabelNode();
|
||||
list.add(new JumpInsnNode(IFEQ, labelNode));
|
||||
list.add(new InsnNode(ICONST_0));
|
||||
list.add(new InsnNode(IRETURN));
|
||||
list.add(labelNode);
|
||||
m.instructions.insert(list);
|
||||
} else if ("getPlugins".equals(m.name)) {
|
||||
InsnList list = new InsnList();
|
||||
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/StackTraceRule", "check", "()Z", false));
|
||||
LabelNode labelNode = new LabelNode();
|
||||
list.add(new JumpInsnNode(IFEQ, labelNode));
|
||||
list.add(new InsnNode(ICONST_0));
|
||||
list.add(new TypeInsnNode(ANEWARRAY, "java/lang/Object"));
|
||||
list.add(new InsnNode(ARETURN));
|
||||
list.add(labelNode);
|
||||
m.instructions.insert(list);
|
||||
}
|
||||
}
|
||||
ClassWriter writer = new SafeClassWriter(null, null, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||
node.accept(writer);
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import com.janetfilter.core.plugin.PluginEntry;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PrivacyPlugin implements PluginEntry {
|
||||
public class PrivacyPlugin implements PluginEntry {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PRIVACY";
|
||||
|
@ -19,6 +19,10 @@ public class PrivacyPlugin implements PluginEntry {
|
|||
|
||||
@Override
|
||||
public List<MyTransformer> getTransformers() {
|
||||
return Arrays.asList(new VMOptionsTransformer(),new PluginClassLoaderTransformer(),new LicensingFacadeTransformer());
|
||||
return Arrays.asList(
|
||||
new VMOptionsTransformer(),
|
||||
new PluginClassLoaderTransformer(),
|
||||
new LicensingFacadeTransformer(),
|
||||
new PluginManagerCoreTransformer());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue