feat: smart input pro v2.3.8
This commit is contained in:
		
							
								
								
									
										2
									
								
								activation.conf.example
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								activation.conf.example
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
[SmartInputHookClass]
 | 
			
		||||
EQUAL,O00oOO0
 | 
			
		||||
							
								
								
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							@@ -63,7 +63,7 @@
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>com.ja-netfilter</groupId>
 | 
			
		||||
            <artifactId>ja-netfilter</artifactId>
 | 
			
		||||
            <version>2.0.1</version>
 | 
			
		||||
            <version>2.1.1</version>
 | 
			
		||||
            <scope>provided</scope>
 | 
			
		||||
        </dependency>
 | 
			
		||||
    </dependencies>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,27 @@
 | 
			
		||||
package com.yelochick;
 | 
			
		||||
 | 
			
		||||
import com.janetfilter.core.Environment;
 | 
			
		||||
import com.janetfilter.core.plugin.MyTransformer;
 | 
			
		||||
import com.janetfilter.core.plugin.PluginConfig;
 | 
			
		||||
import com.janetfilter.core.plugin.PluginEntry;
 | 
			
		||||
import com.yelochick.coolrequest.VipApiTransformer;
 | 
			
		||||
import com.yelochick.smartinput.OsLanguageManagerProxyTransformer;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class ActivationPlugin implements PluginEntry {
 | 
			
		||||
 | 
			
		||||
    private final List<MyTransformer> transformers = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void init(Environment environment, PluginConfig config) {
 | 
			
		||||
        transformers.add(new VipApiTransformer());
 | 
			
		||||
        transformers.add(new OsLanguageManagerProxyTransformer(config.getBySection("SmartInputHookClass")));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return "ACTIVATION";
 | 
			
		||||
@@ -21,9 +34,6 @@ public class ActivationPlugin implements PluginEntry {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<MyTransformer> getTransformers() {
 | 
			
		||||
        return Arrays.asList(
 | 
			
		||||
                new VipApiTransformer(),
 | 
			
		||||
                new OsLanguageManagerProxyTransformer()
 | 
			
		||||
        );
 | 
			
		||||
        return Collections.unmodifiableList(transformers);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,15 @@
 | 
			
		||||
package com.yelochick.smartinput;
 | 
			
		||||
 | 
			
		||||
import com.janetfilter.core.commons.DebugInfo;
 | 
			
		||||
import com.janetfilter.core.models.FilterRule;
 | 
			
		||||
import com.janetfilter.core.plugin.MyTransformer;
 | 
			
		||||
import com.yelochick.SafeClassWriter;
 | 
			
		||||
import jdk.internal.org.objectweb.asm.ClassReader;
 | 
			
		||||
import jdk.internal.org.objectweb.asm.ClassWriter;
 | 
			
		||||
import jdk.internal.org.objectweb.asm.tree.*;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static jdk.internal.org.objectweb.asm.Opcodes.*;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -14,13 +17,23 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
 | 
			
		||||
 */
 | 
			
		||||
public class OsLanguageManagerProxyTransformer implements MyTransformer {
 | 
			
		||||
 | 
			
		||||
    private final List<FilterRule> rules;
 | 
			
		||||
 | 
			
		||||
    public OsLanguageManagerProxyTransformer(List<FilterRule> rules) {
 | 
			
		||||
        this.rules = rules;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getHookClassName() {
 | 
			
		||||
        return "O00oOO0";
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public byte[] transform(String className, byte[] classBytes, int order) throws Exception {
 | 
			
		||||
        if (!classMatched(className)) {
 | 
			
		||||
            return classBytes;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ClassReader reader = new ClassReader(classBytes);
 | 
			
		||||
        ClassNode node = new ClassNode(ASM5);
 | 
			
		||||
        reader.accept(node, 0);
 | 
			
		||||
@@ -39,4 +52,14 @@ public class OsLanguageManagerProxyTransformer implements MyTransformer {
 | 
			
		||||
        node.accept(writer);
 | 
			
		||||
        return writer.toByteArray();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private boolean classMatched(String className) {
 | 
			
		||||
        for (FilterRule rule : rules) {
 | 
			
		||||
            if (rule.test(className)) {
 | 
			
		||||
                DebugInfo.output("Native wrapper: " + className + ", rule: " + rule);
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user