feat(debug): 添加调试窗口和类监控功能
- 新增 DebugWindow 类用于显示调试信息 - 在主程序中添加调试窗口的创建和显示逻辑 - 新增 ClassDebug 类提供类监控和调试功能 - 更新 build.gradle 添加 byte-buddy 依赖
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.axis.innovators.box;
|
||||
|
||||
import com.axis.innovators.box.decompilation.gui.ModernJarViewer;
|
||||
import com.axis.innovators.box.events.GlobalEventBus;
|
||||
import com.axis.innovators.box.events.OpenFileEvents;
|
||||
import com.axis.innovators.box.events.StartupEvent;
|
||||
@@ -8,10 +7,10 @@ import com.axis.innovators.box.gui.*;
|
||||
import com.axis.innovators.box.plugins.PluginDescriptor;
|
||||
import com.axis.innovators.box.plugins.PluginLoader;
|
||||
import com.axis.innovators.box.plugins.PluginPyLoader;
|
||||
import com.axis.innovators.box.register.LanguageManager;
|
||||
import com.axis.innovators.box.register.RegistrationSettingsItem;
|
||||
import com.axis.innovators.box.register.RegistrationTool;
|
||||
import com.axis.innovators.box.register.RegistrationTopic;
|
||||
import com.axis.innovators.box.register.LanguageManager;
|
||||
import com.axis.innovators.box.tools.*;
|
||||
import com.axis.innovators.box.util.PythonResult;
|
||||
import com.axis.innovators.box.util.Tray;
|
||||
@@ -27,19 +26,20 @@ import org.apache.logging.log4j.core.appender.RollingFileAppender;
|
||||
import org.apache.logging.log4j.core.config.Configuration;
|
||||
import org.api.dog.agent.VirtualMachine;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.tzd.lm.LM;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.*;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.lang.management.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
@@ -72,9 +72,20 @@ public class AxisInnovatorsBox {
|
||||
private final List<WindowsJDialog> windowsJDialogList = new ArrayList<>();
|
||||
private final StateManager stateManager = new StateManager();
|
||||
private UserTags userTags;
|
||||
private final boolean isDebug;
|
||||
private static DebugWindow debugWindow;
|
||||
|
||||
public AxisInnovatorsBox(String[] args) {
|
||||
public AxisInnovatorsBox(String[] args, boolean isDebug) {
|
||||
this.args = args;
|
||||
this.isDebug = isDebug;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取调试状态
|
||||
* @return 调试状态
|
||||
*/
|
||||
public boolean isDebugEnvironment(){
|
||||
return isDebug;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +93,7 @@ public class AxisInnovatorsBox {
|
||||
try {
|
||||
LibraryLoad.loadLibrary("FridaNative");
|
||||
LibraryLoad.loadLibrary("ThrowSafely");
|
||||
LibraryLoad.loadLibrary("DogAgent");
|
||||
LibraryLoad.loadLibrary("DogAgent");
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to load the 'FridaNative' library", e);
|
||||
}
|
||||
@@ -325,21 +336,8 @@ public class AxisInnovatorsBox {
|
||||
// 播放错误音效的方法
|
||||
private void playErrorSound() {
|
||||
try {
|
||||
// 使用系统默认的错误音效
|
||||
Toolkit.getDefaultToolkit().beep();
|
||||
|
||||
// 或者播放自定义音效
|
||||
/*
|
||||
File soundFile = new File("error_sound.wav");
|
||||
if (soundFile.exists()) {
|
||||
AudioInputStream audioIn = AudioSystem.getAudioInputStream(soundFile);
|
||||
Clip clip = AudioSystem.getClip();
|
||||
clip.open(audioIn);
|
||||
clip.start();
|
||||
}
|
||||
*/
|
||||
} catch (Exception ex) {
|
||||
// 忽略音效播放错误
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,10 +355,8 @@ public class AxisInnovatorsBox {
|
||||
|
||||
private void processAppender(ZipOutputStream zos, Set<String> addedFiles,
|
||||
Appender appender) throws IOException {
|
||||
if (appender instanceof FileAppender) {
|
||||
FileAppender fileAppender = (FileAppender) appender;
|
||||
if (appender instanceof FileAppender fileAppender) {
|
||||
String fileName = fileAppender.getFileName();
|
||||
|
||||
if (fileName != null && !addedFiles.contains(fileName)) {
|
||||
addFileToZip(zos, new File(fileName), "logs/");
|
||||
addedFiles.add(fileName);
|
||||
@@ -410,7 +406,9 @@ public class AxisInnovatorsBox {
|
||||
filePattern = filePattern.substring(lastSlash + 1);
|
||||
}
|
||||
int patternStart = filePattern.indexOf('%');
|
||||
if (patternStart == -1) patternStart = filePattern.indexOf('$');
|
||||
if (patternStart == -1) {
|
||||
patternStart = filePattern.indexOf('$');
|
||||
}
|
||||
|
||||
if (patternStart > 0) {
|
||||
baseName = filePattern.substring(0, patternStart);
|
||||
@@ -531,7 +529,9 @@ public class AxisInnovatorsBox {
|
||||
}
|
||||
|
||||
private String formatMemory(long bytes) {
|
||||
if (bytes < 1024) return bytes + " B";
|
||||
if (bytes < 1024) {
|
||||
return bytes + " B";
|
||||
}
|
||||
int exp = (int) (Math.log(bytes) / Math.log(1024));
|
||||
char unit = "KMGTPE".charAt(exp - 1);
|
||||
return String.format("%.1f %sB", bytes / Math.pow(1024, exp), unit);
|
||||
@@ -601,22 +601,10 @@ public class AxisInnovatorsBox {
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
// 添加目录到ZIP(递归)
|
||||
private void addDirectoryToZip(ZipOutputStream zos, File dir, String basePath) throws IOException {
|
||||
if (!dir.exists() || !dir.isDirectory()) return;
|
||||
|
||||
for (File file : dir.listFiles()) {
|
||||
String entryPath = basePath + "/" + file.getName();
|
||||
if (file.isDirectory()) {
|
||||
addDirectoryToZip(zos, file, entryPath);
|
||||
} else {
|
||||
addFileToZip(zos, file, entryPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addFileToZip(ZipOutputStream zos, File file, String entryPath) throws IOException {
|
||||
if (!file.exists()) return;
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String entryName = entryPath + file.getName();
|
||||
ZipEntry zipEntry = new ZipEntry(entryName);
|
||||
@@ -755,7 +743,7 @@ public class AxisInnovatorsBox {
|
||||
* @param windowsJDialog 窗口
|
||||
*/
|
||||
public boolean isWindowStartup(WindowsJDialog windowsJDialog) {
|
||||
return windowsJDialogList.contains(windowsJDialog);
|
||||
return !windowsJDialogList.contains(windowsJDialog);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -790,8 +778,34 @@ public class AxisInnovatorsBox {
|
||||
isWindow = true;
|
||||
}
|
||||
|
||||
public static void run(String[] args) {
|
||||
main = new AxisInnovatorsBox(args);
|
||||
private void createDebugWindow() {
|
||||
debugWindow = new DebugWindow();
|
||||
|
||||
// 关键配置:设置为独立窗口,不受模态对话框影响
|
||||
//debugWindow.setAlwaysOnTop(true);
|
||||
//debugWindow.setFocusableWindowState(true);
|
||||
//debugWindow.setFocusable(true);
|
||||
|
||||
// 当主窗口关闭时关闭调试窗口
|
||||
ex.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
debugWindow.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
ex.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
debugWindow.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
debugWindow.setVisible(true);
|
||||
}
|
||||
|
||||
public static void run(String[] args, boolean isDebug) {
|
||||
main = new AxisInnovatorsBox(args,isDebug);
|
||||
try {
|
||||
main.initLog4j2();
|
||||
main.setTopic();
|
||||
@@ -828,7 +842,15 @@ public class AxisInnovatorsBox {
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
try {
|
||||
main.ex = new MainWindow();
|
||||
main.ex = new MainWindow(){
|
||||
@Override
|
||||
public void setVisible(boolean b) {
|
||||
if (debugWindow != null) {
|
||||
debugWindow.setVisible(b);
|
||||
}
|
||||
super.setVisible(b);
|
||||
}
|
||||
};
|
||||
GlobalEventBus.EVENT_BUS.post(new StartupEvent(main));
|
||||
PluginPyLoader.getLoadedPlugins().forEach((pluginId, pyPluginDescriptor) -> {
|
||||
if (pyPluginDescriptor.getLastResult().getInterpreter() != null){
|
||||
@@ -843,8 +865,9 @@ public class AxisInnovatorsBox {
|
||||
main.runWindow();
|
||||
} catch (Exception e) {
|
||||
logger.error("There was a problem starting the main thread", e);
|
||||
if (main.ex != null)
|
||||
if (main.ex != null) {
|
||||
main.ex.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
}
|
||||
main.organizingCrashReports(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -860,8 +883,9 @@ public class AxisInnovatorsBox {
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to load plugins", e);
|
||||
if (main.ex != null)
|
||||
if (main.ex != null) {
|
||||
main.ex.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
}
|
||||
main.organizingCrashReports(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -870,8 +894,9 @@ public class AxisInnovatorsBox {
|
||||
main.thread.start();
|
||||
} catch (Exception e) {
|
||||
logger.error("In unexpected errors", e);
|
||||
if (main.ex != null)
|
||||
if (main.ex != null) {
|
||||
main.ex.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
}
|
||||
main.organizingCrashReports(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -894,6 +919,10 @@ public class AxisInnovatorsBox {
|
||||
ex.initUI();
|
||||
isWindow = true;
|
||||
ex.setVisible(true);
|
||||
|
||||
if (isDebug) {
|
||||
SwingUtilities.invokeLater(this::createDebugWindow);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.axis.innovators.box;
|
||||
|
||||
import com.axis.innovators.box.browser.MainApplication;
|
||||
import com.axis.innovators.box.browser.WindowRegistry;
|
||||
import com.axis.innovators.box.decompilation.gui.ModernJarViewer;
|
||||
import com.axis.innovators.box.register.LanguageManager;
|
||||
import com.axis.innovators.box.tools.ArgsParser;
|
||||
import com.axis.innovators.box.tools.FolderCleaner;
|
||||
import com.axis.innovators.box.tools.FolderCreator;
|
||||
import com.axis.innovators.box.register.LanguageManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
@@ -46,6 +45,20 @@ public class Main {
|
||||
LanguageManager.loadLanguage("system:zh_CN");
|
||||
}
|
||||
|
||||
// 检查是否包含调试控制台参数
|
||||
boolean debugWindowEnabled = false;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if ("-debugControlWindow-on".equals(args[i])) {
|
||||
debugWindowEnabled = true;
|
||||
// 移除此参数避免干扰后续处理
|
||||
String[] newArgs = new String[args.length - 1];
|
||||
System.arraycopy(args, 0, newArgs, 0, i);
|
||||
System.arraycopy(args, i + 1, newArgs, i, args.length - i - 1);
|
||||
args = newArgs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, String>> validFiles = ArgsParser.parseArgs(args);
|
||||
for (Map<String, String> fileInfo : validFiles) {
|
||||
String extension = fileInfo.get("extension");
|
||||
@@ -66,12 +79,12 @@ public class Main {
|
||||
|
||||
if (".html".equals(extension)) {
|
||||
MainApplication.popupHTMLWindow(path);
|
||||
releaseLock(); // 释放锁(窗口模式)
|
||||
releaseLock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AxisInnovatorsBox.run(args);
|
||||
AxisInnovatorsBox.run(args, debugWindowEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
1986
src/main/java/com/axis/innovators/box/gui/DebugWindow.java
Normal file
1986
src/main/java/com/axis/innovators/box/gui/DebugWindow.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,30 +1,27 @@
|
||||
package com.axis.innovators.box.gui;
|
||||
|
||||
import com.axis.innovators.box.AxisInnovatorsBox;
|
||||
import com.axis.innovators.box.decompilation.gui.ModernJarViewer;
|
||||
import com.axis.innovators.box.events.*;
|
||||
import com.axis.innovators.box.register.RegistrationSettingsItem;
|
||||
import com.axis.innovators.box.register.LanguageManager;
|
||||
import com.axis.innovators.box.register.RegistrationSettingsItem;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
import javax.swing.plaf.PanelUI;
|
||||
import javax.swing.plaf.basic.BasicScrollBarUI;
|
||||
import javax.swing.plaf.basic.BasicTabbedPaneUI;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ConvolveOp;
|
||||
import java.awt.image.Kernel;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 显示窗口(显示的主窗口)
|
||||
@@ -350,7 +347,7 @@ public class MainWindow extends JFrame {
|
||||
|
||||
private WindowsJDialog dialog;
|
||||
public void showSettings() {
|
||||
if (dialog == null || !AxisInnovatorsBox.getMain().isWindowStartup(dialog)) {
|
||||
if (dialog == null || AxisInnovatorsBox.getMain().isWindowStartup(dialog)) {
|
||||
dialog = new WindowsJDialog(this,
|
||||
LanguageManager.getLoadedLanguages().getText("mainWindow.settings.title"), true);
|
||||
}
|
||||
@@ -373,7 +370,7 @@ public class MainWindow extends JFrame {
|
||||
GlobalEventBus.EVENT_BUS.post(new SettingsLoadEvents(dialog, content));
|
||||
dialog.add(content);
|
||||
dialog.revalidate();
|
||||
if (!AxisInnovatorsBox.getMain().isWindowStartup(dialog)) {
|
||||
if (AxisInnovatorsBox.getMain().isWindowStartup(dialog)) {
|
||||
AxisInnovatorsBox.getMain().popupWindow(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
1578
src/main/java/com/axis/innovators/box/gui/MemoryAnalysisPanel.java
Normal file
1578
src/main/java/com/axis/innovators/box/gui/MemoryAnalysisPanel.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,10 @@ package com.axis.innovators.box.tools;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.api.dog.agent.VirtualMachine;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
/**
|
||||
* 在当前jar下创建文件夹
|
||||
@@ -85,6 +87,15 @@ public class FolderCreator {
|
||||
return folder;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String jvmName = ManagementFactory.getRuntimeMXBean().getName();
|
||||
String pid = jvmName.split("@")[0];
|
||||
System.load("C:\\Users\\Administrator\\MCreatorWorkspaces\\mineralluminescence\\DogAgent.dll");
|
||||
VirtualMachine vm = VirtualMachine.getVirtualMachine(Float.parseFloat(pid), true);
|
||||
//vm.getInstrumentation();
|
||||
vm.getInstrumentation();
|
||||
}
|
||||
|
||||
public static String getLibraryFolder() {
|
||||
String folder = createFolder(LIBRARY_NAME);
|
||||
if (folder == null) {
|
||||
|
||||
Reference in New Issue
Block a user