configMap;
+ private final Properties properties;
+
+ /**
+ * 构造函数
+ * @param statusName 状态文件名
+ */
+ public StateManager(String statusName) {
+ statusFile = FolderCreator.getConfigurationFolder() + statusName + ".properties";
+ configMap = new HashMap<>();
+ properties = new Properties();
+ loadConfiguration();
+ }
+
+ /**
+ * 默认构造函数
+ */
+ public StateManager() {
+ statusFile = FolderCreator.getConfigurationFolder() + "state_management.properties";
+ configMap = new HashMap<>();
+ properties = new Properties();
+ loadConfiguration();
+ }
+
+ /**
+ * 加载配置文件内容到Map中
+ * 如果文件不存在,则创建该文件
+ */
+ private void loadConfiguration() {
+ File configFile = new File(statusFile);
+
+ if (!configFile.exists()) {
+ try {
+ configFile.getParentFile().mkdirs();
+ configFile.createNewFile();
+ System.out.println("The configuration file does not exist, a new one has been created: " + statusFile);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return;
+ }
+ }
+
+ try (FileInputStream fis = new FileInputStream(configFile)) {
+ properties.load(fis);
+ for (String key : properties.stringPropertyNames()) {
+ configMap.put(key, properties.getProperty(key));
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 保存状态到Map和配置文件中
+ * @param key 键
+ * @param value 值
+ */
+ public void saveState(String key, String value) {
+ configMap.put(key, value);
+ properties.setProperty(key, value);
+ saveToFile();
+ }
+
+ public void saveState(String key, int value) {
+ saveState(key, String.valueOf(value));
+ }
+
+ public void saveState(String key, long value) {
+ saveState(key, String.valueOf(value));
+ }
+
+ public void saveState(String key, float value) {
+ saveState(key, String.valueOf(value));
+ }
+
+ public void saveState(String key, boolean value) {
+ saveState(key, String.valueOf(value));
+ }
+
+ public void saveState(String key, double value) {
+ saveState(key, String.valueOf(value));
+ }
+
+ public void saveState(String key, char value) {
+ saveState(key, String.valueOf(value));
+ }
+
+ public void saveState(String key, byte value) {
+ saveState(key, String.valueOf(value));
+ }
+
+ public void saveState(String key, short value) {
+ saveState(key, String.valueOf(value));
+ }
+
+ /**
+ * 将当前状态保存到配置文件中
+ */
+ private void saveToFile() {
+ try (FileOutputStream fos = new FileOutputStream(statusFile)) {
+ properties.store(fos, "Updated configuration");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 从Map中获取状态值
+ * @param key 键
+ * @return 值
+ */
+ public String getState(String key) {
+ return configMap.get(key);
+ }
+
+ public int getStateAsInt(String key) {
+ return Integer.parseInt(configMap.get(key));
+ }
+
+ public long getStateAsLong(String key) {
+ return Long.parseLong(configMap.get(key));
+ }
+
+ public float getStateAsFloat(String key) {
+ return Float.parseFloat(configMap.get(key));
+ }
+
+ public boolean getStateAsBoolean(String key) {
+ return Boolean.parseBoolean(configMap.get(key));
+ }
+
+ public double getStateAsDouble(String key) {
+ return Double.parseDouble(configMap.get(key));
+ }
+
+ public char getStateAsChar(String key) {
+ return configMap.get(key).charAt(0);
+ }
+
+ public byte getStateAsByte(String key) {
+ return Byte.parseByte(configMap.get(key));
+ }
+
+ public short getStateAsShort(String key) {
+ return Short.parseShort(configMap.get(key));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/tzd/frida/Main.java b/src/main/java/org/tzd/frida/Main.java
deleted file mode 100644
index 1c53626..0000000
--- a/src/main/java/org/tzd/frida/Main.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.tzd.frida;
-
-import org.tzd.frida.windows.CallbackMessage;
-import org.tzd.frida.windows.Frida;
-import org.tzd.frida.windows.FridaRunnable;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-/**
- * Main 类用于启动和执行 Frida 注入操作。
- *
- * 此类主要包含一个入口方法 main,用于加载必要的本地库并初始化 Frida 对象。
- * 它会通过调用 getProcessPid 方法获取指定进程的 PID,并将 JavaScript 代码注入到目标进程中。
- *
- * @author tzdwindows 7
- */
-public class Main {
-
- /**
- * 程序入口方法。
- *
- * 此方法加载本地 DLL 库并创建一个 Frida 实例。接着通过 run 和 execute 方法执行指定的任务。
- * 执行期间,会将回调函数添加到 Frida 实例中,接收并打印消息。
- *
- * @param args 命令行参数
- */
- public static void main(String[] args) {
- // 加载本地 DLL 文件
- System.load("C:\\Users\\Administrator\\source\\repos\\FridaNative\\x64\\Release\\FridaNative.dll");
-
- // 创建 Frida 实例并传入 JavaScript 代码及进程 PID
- Frida frida = new Frida("console.log('Hello, Frida!');", getProcessPid("java.exe"));
-
- // 执行 Frida 任务,注入代码并注册回调函数
- frida.run(new Runnable() {
- @Override
- public void run() {
- // 在此处添加要执行的代码
- }
- }).execute(new FridaRunnable() {
- @Override
- public void run(Frida frida) {
- // 注册回调消息,接收到消息时打印
- frida.addCallbackMessage(new CallbackMessage() {
- @Override
- public void onMessage(String message) {
- System.out.println(message); // 打印收到的消息
- }
- });
- }
- }).start(); // 启动线程
- }
-
- /**
- * 获取指定进程的 PID。
- *
- * 此方法通过运行 Windows 命令 tasklist 获取系统中所有正在运行的进程,并查找指定进程名。
- * 一旦找到匹配的进程,它将提取进程的 PID 并返回。
- *
- * @param processName 要查找的进程名称。
- * @return 目标进程的 PID,如果未找到则返回 -1。
- */
- public static long getProcessPid(String processName) {
- long pid = -1;
- try {
- ProcessBuilder builder = new ProcessBuilder("tasklist");
- builder.redirectErrorStream(true);
- Process process = builder.start();
- BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
- String line;
-
- while ((line = reader.readLine()) != null) {
- if (line.contains(processName)) {
- String[] parts = line.split("\\s+");
- pid = Long.parseLong(parts[1]);
- break;
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return pid;
- }
-}
diff --git a/src/main/java/org/tzd/lm/LM.java b/src/main/java/org/tzd/lm/LM.java
index ef21063..d41cfb2 100644
--- a/src/main/java/org/tzd/lm/LM.java
+++ b/src/main/java/org/tzd/lm/LM.java
@@ -80,7 +80,7 @@ public class LM {
public static long createContext(long modelHandle){
return createContext(modelHandle,
- 4096,
+ 100000,
0,
0,
0,
diff --git a/statestate_management.properties b/statestate_management.properties
new file mode 100644
index 0000000..e69de29