feat: hook ClassLoader, Class, RuntimeMXBean, System, PluginManagerCore
This commit is contained in:
29
src/main/java/com/novitechie/rules/VMOptionsRule.java
Normal file
29
src/main/java/com/novitechie/rules/VMOptionsRule.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.novitechie.rules;
|
||||
|
||||
import com.janetfilter.core.commons.DebugInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* @author YeloChick
|
||||
*/
|
||||
public class VMOptionsRule {
|
||||
|
||||
public static Path hook() {
|
||||
String tmpdir = System.getProperty("java.io.tmpdir");
|
||||
File file = new File(tmpdir, "fake.vmoptions");
|
||||
if (file.exists()) {
|
||||
return file.toPath();
|
||||
}
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
fos.write("# This file is created by plugin-privacy".getBytes());
|
||||
return file.toPath();
|
||||
} catch (IOException e) {
|
||||
DebugInfo.output("create temp file error", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user