feat(debug): 添加调试窗口和类监控功能
- 新增 DebugWindow 类用于显示调试信息 - 在主程序中添加调试窗口的创建和显示逻辑 - 新增 ClassDebug 类提供类监控和调试功能 - 更新 build.gradle 添加 byte-buddy 依赖
This commit is contained in:
@@ -56,6 +56,7 @@ dependencies {
|
||||
implementation 'org.ow2.asm:asm-analysis:9.7.1'
|
||||
implementation 'org.ow2.asm:asm-util:9.7.1'
|
||||
implementation 'org.ow2.asm:asm-tree:9.7.1'
|
||||
implementation 'net.bytebuddy:byte-buddy:1.17.6'
|
||||
|
||||
implementation 'org.jsoup:jsoup:1.17.2'
|
||||
|
||||
|
||||
BIN
src/main/Cpp/GetInstance/.vs/GetInstance/v17/.suo
Normal file
BIN
src/main/Cpp/GetInstance/.vs/GetInstance/v17/.suo
Normal file
Binary file not shown.
BIN
src/main/Cpp/GetInstance/.vs/GetInstance/v17/Browse.VC.db
Normal file
BIN
src/main/Cpp/GetInstance/.vs/GetInstance/v17/Browse.VC.db
Normal file
Binary file not shown.
BIN
src/main/Cpp/GetInstance/.vs/GetInstance/v17/Browse.VC.db-shm
Normal file
BIN
src/main/Cpp/GetInstance/.vs/GetInstance/v17/Browse.VC.db-shm
Normal file
Binary file not shown.
BIN
src/main/Cpp/GetInstance/.vs/GetInstance/v17/Browse.VC.opendb
Normal file
BIN
src/main/Cpp/GetInstance/.vs/GetInstance/v17/Browse.VC.opendb
Normal file
Binary file not shown.
@@ -0,0 +1,91 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\Administrator\\source\\repos\\GetInstance\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{3C9F4D1A-8483-4E0A-94FB-7E75617957A9}|GetInstance\\GetInstance.vcxproj|C:\\Users\\Administrator\\source\\repos\\GetInstance\\GetInstance\\org_tzd_debug_GetInstance.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{3C9F4D1A-8483-4E0A-94FB-7E75617957A9}|GetInstance\\GetInstance.vcxproj|solutionrelative:GetInstance\\org_tzd_debug_GetInstance.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{3C9F4D1A-8483-4E0A-94FB-7E75617957A9}|GetInstance\\GetInstance.vcxproj|C:\\Users\\Administrator\\source\\repos\\GetInstance\\GetInstance\\org_tzd_debug_GetInstance.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{3C9F4D1A-8483-4E0A-94FB-7E75617957A9}|GetInstance\\GetInstance.vcxproj|solutionrelative:GetInstance\\org_tzd_debug_GetInstance.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{3C9F4D1A-8483-4E0A-94FB-7E75617957A9}|GetInstance\\GetInstance.vcxproj|C:\\Users\\Administrator\\source\\repos\\GetInstance\\GetInstance\\dllmain.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{3C9F4D1A-8483-4E0A-94FB-7E75617957A9}|GetInstance\\GetInstance.vcxproj|solutionrelative:GetInstance\\dllmain.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 6,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{3ae79031-e1bc-11d0-8f78-00a0c9110057}"
|
||||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{1c64b9c2-e352-428e-a56d-0ace190b99a6}"
|
||||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
|
||||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:1:0:{e8b06f52-6d01-11d2-aa7d-00c04f990343}"
|
||||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{d3750d8a-574b-4fb3-b7e2-aa8af40e8231}"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "org_tzd_debug_GetInstance.h",
|
||||
"DocumentMoniker": "C:\\Users\\Administrator\\source\\repos\\GetInstance\\GetInstance\\org_tzd_debug_GetInstance.h",
|
||||
"RelativeDocumentMoniker": "GetInstance\\org_tzd_debug_GetInstance.h",
|
||||
"ToolTip": "C:\\Users\\Administrator\\source\\repos\\GetInstance\\GetInstance\\org_tzd_debug_GetInstance.h",
|
||||
"RelativeToolTip": "GetInstance\\org_tzd_debug_GetInstance.h",
|
||||
"ViewState": "AQIAAAEAAAAAAAAAAAAcwA4AAAAxAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
|
||||
"WhenOpened": "2025-06-26T12:47:16.975Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "org_tzd_debug_GetInstance.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\Administrator\\source\\repos\\GetInstance\\GetInstance\\org_tzd_debug_GetInstance.cpp",
|
||||
"RelativeDocumentMoniker": "GetInstance\\org_tzd_debug_GetInstance.cpp",
|
||||
"ToolTip": "C:\\Users\\Administrator\\source\\repos\\GetInstance\\GetInstance\\org_tzd_debug_GetInstance.cpp*",
|
||||
"RelativeToolTip": "GetInstance\\org_tzd_debug_GetInstance.cpp*",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAA0AAAALAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
|
||||
"WhenOpened": "2025-06-26T12:42:02.251Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "dllmain.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\Administrator\\source\\repos\\GetInstance\\GetInstance\\dllmain.cpp",
|
||||
"RelativeDocumentMoniker": "GetInstance\\dllmain.cpp",
|
||||
"ToolTip": "C:\\Users\\Administrator\\source\\repos\\GetInstance\\GetInstance\\dllmain.cpp",
|
||||
"RelativeToolTip": "GetInstance\\dllmain.cpp",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAADwvwAAAAAAAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
|
||||
"WhenOpened": "2025-06-26T12:39:18.259Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
162
src/main/Cpp/GetInstance/GetInstance/GetInstance.vcxproj
Normal file
162
src/main/Cpp/GetInstance/GetInstance/GetInstance.vcxproj
Normal file
@@ -0,0 +1,162 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{3c9f4d1a-8483-4e0a-94fb-7e75617957a9}</ProjectGuid>
|
||||
<RootNamespace>GetInstance</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>C:\Users\Administrator\.jdks\corretto-20.0.2.1\include\win32;C:\Users\Administrator\.jdks\corretto-20.0.2.1\include;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;GETINSTANCE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;GETINSTANCE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;GETINSTANCE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;GETINSTANCE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="org_tzd_debug_GetInstance.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="org_tzd_debug_GetInstance.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="org_tzd_debug_GetInstance.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="org_tzd_debug_GetInstance.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>false</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
19
src/main/Cpp/GetInstance/GetInstance/dllmain.cpp
Normal file
19
src/main/Cpp/GetInstance/GetInstance/dllmain.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
// dllmain.cpp : 定义 DLL 应用程序的入口点。
|
||||
#include "pch.h"
|
||||
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
5
src/main/Cpp/GetInstance/GetInstance/framework.h
Normal file
5
src/main/Cpp/GetInstance/GetInstance/framework.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
|
||||
// Windows 头文件
|
||||
#include <windows.h>
|
||||
@@ -0,0 +1,85 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include <jni.h>
|
||||
#include <jvmti.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// JVMTI<54>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊÿ<CEAA><C3BF>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD>ǩ
|
||||
static jvmtiIterationControl JNICALL
|
||||
objectInstanceCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) {
|
||||
*tag_ptr = 1; // Ϊ<><CEAA><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>ù̶<C3B9><CCB6><EFBFBD>ǩ1
|
||||
return JVMTI_ITERATION_CONTINUE;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jobjectArray JNICALL
|
||||
Java_org_tzd_debug_GetInstance_getInstance(JNIEnv* env, jclass clazz, jclass targetClazz) {
|
||||
// <20><>ȡJVM<56><4D><EFBFBD><EFBFBD>
|
||||
JavaVM* vm;
|
||||
env->GetJavaVM(&vm);
|
||||
|
||||
// <20><>ȡJVMTI<54><49><EFBFBD><EFBFBD>
|
||||
jvmtiEnv* jvmti = nullptr;
|
||||
jint result = vm->GetEnv((void**)&jvmti, JVMTI_VERSION_1_0);
|
||||
if (result != JNI_OK || jvmti == nullptr) {
|
||||
env->ThrowNew(env->FindClass("java/lang/IllegalStateException"),
|
||||
"Failed to get JVMTI environment");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD>ӱ<EFBFBD>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>
|
||||
jvmtiCapabilities capabilities = { 0 };
|
||||
capabilities.can_tag_objects = 1;
|
||||
jvmtiError error = jvmti->AddCapabilities(&capabilities);
|
||||
if (error != JVMTI_ERROR_NONE) {
|
||||
env->ThrowNew(env->FindClass("java/lang/UnsupportedOperationException"),
|
||||
"JVM doesn't support object tagging");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD>ǩ
|
||||
error = jvmti->IterateOverInstancesOfClass(
|
||||
targetClazz,
|
||||
JVMTI_HEAP_OBJECT_EITHER,
|
||||
objectInstanceCallback,
|
||||
nullptr
|
||||
);
|
||||
if (error != JVMTI_ERROR_NONE) {
|
||||
env->ThrowNew(env->FindClass("java/lang/RuntimeException"),
|
||||
"IterateOverInstancesOfClass failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ǩ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
||||
jlong tag = 1;
|
||||
jint count = 0;
|
||||
jobject* instances = nullptr;
|
||||
error = jvmti->GetObjectsWithTags(
|
||||
1,
|
||||
&tag,
|
||||
&count,
|
||||
&instances,
|
||||
nullptr
|
||||
);
|
||||
if (error != JVMTI_ERROR_NONE) {
|
||||
env->ThrowNew(env->FindClass("java/lang/RuntimeException"),
|
||||
"GetObjectsWithTags failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
jobjectArray resultArray = env->NewObjectArray(count, targetClazz, nullptr);
|
||||
if (resultArray == nullptr) {
|
||||
jvmti->Deallocate((unsigned char*)instances);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
for (int i = 0; i < count; i++) {
|
||||
env->SetObjectArrayElement(resultArray, i, instances[i]);
|
||||
}
|
||||
|
||||
// <20>ͷ<EFBFBD>JVMTI<54><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
jvmti->Deallocate((unsigned char*)instances);
|
||||
|
||||
return resultArray;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_tzd_debug_GetInstance */
|
||||
|
||||
#ifndef _Included_org_tzd_debug_GetInstance
|
||||
#define _Included_org_tzd_debug_GetInstance
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_tzd_debug_GetInstance
|
||||
* Method: getInstance
|
||||
* Signature: (Ljava/lang/Class;)[Ljava/lang/Object;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_tzd_debug_GetInstance_getInstance
|
||||
(JNIEnv *, jclass, jclass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
5
src/main/Cpp/GetInstance/GetInstance/pch.cpp
Normal file
5
src/main/Cpp/GetInstance/GetInstance/pch.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
// pch.cpp: 与预编译标头对应的源文件
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
// 当使用预编译的头时,需要使用此源文件,编译才能成功。
|
||||
13
src/main/Cpp/GetInstance/GetInstance/pch.h
Normal file
13
src/main/Cpp/GetInstance/GetInstance/pch.h
Normal file
@@ -0,0 +1,13 @@
|
||||
// pch.h: 这是预编译标头文件。
|
||||
// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
|
||||
// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
|
||||
// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
|
||||
// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
|
||||
|
||||
#ifndef PCH_H
|
||||
#define PCH_H
|
||||
|
||||
// 添加要在此处预编译的标头
|
||||
#include "framework.h"
|
||||
|
||||
#endif //PCH_H
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>C:\Users\Administrator\source\repos\GetInstance\x64\Release\GetInstance.dll</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
<SatelliteDlls />
|
||||
<NonRecipeFileRefs />
|
||||
</Project>
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
org_tzd_debug_GetInstance.cpp
|
||||
正在创建库 C:\Users\Administrator\source\repos\GetInstance\x64\Release\GetInstance.lib 和对象 C:\Users\Administrator\source\repos\GetInstance\x64\Release\GetInstance.exp
|
||||
正在生成代码
|
||||
Previous IPDB and IOBJ mismatch, fall back to full compilation.
|
||||
All 13 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
|
||||
已完成代码的生成
|
||||
GetInstance.vcxproj -> C:\Users\Administrator\source\repos\GetInstance\x64\Release\GetInstance.dll
|
||||
BIN
src/main/Cpp/GetInstance/GetInstance/x64/Release/GetInstance.pch
Normal file
BIN
src/main/Cpp/GetInstance/GetInstance/x64/Release/GetInstance.pch
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
C:\Users\Administrator\source\repos\GetInstance\GetInstance\dllmain.cpp;C:\Users\Administrator\source\repos\GetInstance\GetInstance\x64\Release\dllmain.obj
|
||||
C:\Users\Administrator\source\repos\GetInstance\GetInstance\org_tzd_debug_GetInstance.cpp;C:\Users\Administrator\source\repos\GetInstance\GetInstance\x64\Release\org_tzd_debug_GetInstance.obj
|
||||
C:\Users\Administrator\source\repos\GetInstance\GetInstance\pch.cpp;C:\Users\Administrator\source\repos\GetInstance\GetInstance\x64\Release\pch.obj
|
||||
@@ -0,0 +1,2 @@
|
||||
PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.40.33807:TargetPlatformVersion=10.0.20348.0:
|
||||
Release|x64|C:\Users\Administrator\source\repos\GetInstance\|
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
^C:\USERS\ADMINISTRATOR\SOURCE\REPOS\GETINSTANCE\GETINSTANCE\X64\RELEASE\DLLMAIN.OBJ|C:\USERS\ADMINISTRATOR\SOURCE\REPOS\GETINSTANCE\GETINSTANCE\X64\RELEASE\ORG_TZD_DEBUG_GETINSTANCE.OBJ|C:\USERS\ADMINISTRATOR\SOURCE\REPOS\GETINSTANCE\GETINSTANCE\X64\RELEASE\PCH.OBJ
|
||||
C:\Users\Administrator\source\repos\GetInstance\x64\Release\GetInstance.lib
|
||||
C:\Users\Administrator\source\repos\GetInstance\x64\Release\GetInstance.EXP
|
||||
C:\Users\Administrator\source\repos\GetInstance\GetInstance\x64\Release\GetInstance.IPDB
|
||||
C:\Users\Administrator\source\repos\GetInstance\GetInstance\x64\Release\GetInstance.iobj
|
||||
Binary file not shown.
BIN
src/main/Cpp/GetInstance/GetInstance/x64/Release/dllmain.obj
Normal file
BIN
src/main/Cpp/GetInstance/GetInstance/x64/Release/dllmain.obj
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/main/Cpp/GetInstance/GetInstance/x64/Release/pch.obj
Normal file
BIN
src/main/Cpp/GetInstance/GetInstance/x64/Release/pch.obj
Normal file
Binary file not shown.
BIN
src/main/Cpp/GetInstance/GetInstance/x64/Release/vc143.pdb
Normal file
BIN
src/main/Cpp/GetInstance/GetInstance/x64/Release/vc143.pdb
Normal file
Binary file not shown.
BIN
src/main/Cpp/GetInstance/x64/Release/GetInstance.dll
Normal file
BIN
src/main/Cpp/GetInstance/x64/Release/GetInstance.dll
Normal file
Binary file not shown.
BIN
src/main/Cpp/GetInstance/x64/Release/GetInstance.exp
Normal file
BIN
src/main/Cpp/GetInstance/x64/Release/GetInstance.exp
Normal file
Binary file not shown.
BIN
src/main/Cpp/GetInstance/x64/Release/GetInstance.lib
Normal file
BIN
src/main/Cpp/GetInstance/x64/Release/GetInstance.lib
Normal file
Binary file not shown.
BIN
src/main/Cpp/GetInstance/x64/Release/GetInstance.pdb
Normal file
BIN
src/main/Cpp/GetInstance/x64/Release/GetInstance.pdb
Normal file
Binary file not shown.
@@ -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) {
|
||||
|
||||
227
src/main/java/org/tzd/debug/ClassDebug.java
Normal file
227
src/main/java/org/tzd/debug/ClassDebug.java
Normal file
@@ -0,0 +1,227 @@
|
||||
package org.tzd.debug;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.api.dog.agent.VirtualMachine;
|
||||
import org.tzd.debug.util.GlobalObjects;
|
||||
|
||||
import javax.tools.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.instrument.ClassFileTransformer;
|
||||
import java.lang.instrument.IllegalClassFormatException;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 对类进行监控和debug操作
|
||||
* @author tzdwindows 7
|
||||
*/
|
||||
public class ClassDebug {
|
||||
private static final Logger logger = LogManager.getLogger(ClassDebug.class);
|
||||
private static Instrumentation instrumentation;
|
||||
|
||||
/**
|
||||
* 监控类加载
|
||||
* @param monitor 监控器
|
||||
*/
|
||||
public static void monitoringLoading(LoadingMonitor monitor) {
|
||||
if (instrumentation != null) {
|
||||
instrumentation.addTransformer(new ClassFileTransformer() {
|
||||
@Override
|
||||
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer)
|
||||
throws IllegalClassFormatException {
|
||||
monitor.load(loader, className, classBeingRedefined, protectionDomain, classfileBuffer);
|
||||
return classfileBuffer;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
logger.error("Instrumentation is null");
|
||||
try {
|
||||
VirtualMachine vm = VirtualMachine.getVirtualMachine(ProcessHandle.current().pid(), true);
|
||||
instrumentation = vm.getInstrumentation();
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to attach to VM: {}", e.getMessage());
|
||||
}
|
||||
monitoringLoading(monitor);
|
||||
}
|
||||
}
|
||||
|
||||
public static Instrumentation getInstrumentation() {
|
||||
if (instrumentation == null) {
|
||||
try {
|
||||
VirtualMachine vm = VirtualMachine.getVirtualMachine(ProcessHandle.current().pid(), true);
|
||||
instrumentation = vm.getInstrumentation();
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to attach to VM: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
return instrumentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行动态代码
|
||||
* @param code 要执行的代码
|
||||
* @return 执行结果(空字符串表示成功,否则为错误信息)
|
||||
*/
|
||||
public static String executeCode(String code) {
|
||||
GlobalObjects globalObjects = new GlobalObjects();
|
||||
globalObjects.instrumentation = instrumentation;
|
||||
|
||||
|
||||
// 1. 预处理代码:替换print/printf为System.out
|
||||
String processedCode = code.trim();
|
||||
if (processedCode.startsWith("print(") && processedCode.endsWith(");")) {
|
||||
processedCode = "System.out.println" + processedCode.substring("print".length());
|
||||
} else if (processedCode.startsWith("printf(") && processedCode.endsWith(");")) {
|
||||
processedCode = "System.out.printf" + processedCode.substring("printf".length());
|
||||
}
|
||||
|
||||
// 2. 构建完整类代码
|
||||
String className = "DynamicExecutedCode";
|
||||
String fullCode = "package dynamic;\n" + // 添加包声明避免冲突
|
||||
"import org.tzd.debug.util.GlobalObjects;import java.util.*;\n" +
|
||||
"public class " + className + " {\n" +
|
||||
" public static GlobalObjects global;\n" + // 静态字段接收全局对象
|
||||
" public static void run() {\n" +
|
||||
" try {\n" + // 添加try-catch捕获用户代码异常
|
||||
processedCode + "\n" +
|
||||
" } catch (Throwable t) {\n" +
|
||||
" throw new RuntimeException(t);\n" + // 包装异常以保持堆栈
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
Path tempDir = null;
|
||||
try {
|
||||
// 3. 创建临时目录和源文件
|
||||
tempDir = Files.createTempDirectory("dynamicCode");
|
||||
Path sourceDir = tempDir.resolve("dynamic");
|
||||
Files.createDirectories(sourceDir);
|
||||
Path sourceFile = sourceDir.resolve(className + ".java");
|
||||
Files.write(sourceFile, fullCode.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 4. 编译代码
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
if (compiler == null) {
|
||||
return "错误:找不到Java编译器。请使用JDK运行此程序。";
|
||||
}
|
||||
|
||||
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
|
||||
try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null)) {
|
||||
String[] compileOptions = {"-d", tempDir.toString(), "-cp", System.getProperty("java.class.path")};
|
||||
Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjects(sourceFile);
|
||||
|
||||
JavaCompiler.CompilationTask task = compiler.getTask(
|
||||
null, fileManager, diagnostics,
|
||||
Arrays.asList(compileOptions), null, compilationUnits
|
||||
);
|
||||
|
||||
boolean success = task.call();
|
||||
if (!success) {
|
||||
StringBuilder errorMsg = new StringBuilder("编译错误:\n");
|
||||
for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics.getDiagnostics()) {
|
||||
errorMsg.append(String.format(
|
||||
"Line %d: %s\n",
|
||||
diagnostic.getLineNumber(),
|
||||
diagnostic.getMessage(Locale.getDefault())
|
||||
));
|
||||
}
|
||||
return errorMsg.toString();
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 加载并执行
|
||||
URLClassLoader classLoader = new URLClassLoader(
|
||||
new URL[]{tempDir.toUri().toURL()},
|
||||
ClassDebug.class.getClassLoader()
|
||||
);
|
||||
Class<?> loadedClass = classLoader.loadClass("dynamic." + className);
|
||||
|
||||
// 注入全局对象
|
||||
Field globalField = loadedClass.getDeclaredField("global");
|
||||
globalField.set(null, globalObjects);
|
||||
|
||||
Method runMethod = loadedClass.getMethod("run");
|
||||
runMethod.invoke(null);
|
||||
return "";
|
||||
} catch (Throwable e) {
|
||||
// 6. 异常处理
|
||||
Throwable cause = e;
|
||||
while (cause.getCause() != null) {
|
||||
cause = cause.getCause();
|
||||
}
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
cause.printStackTrace(new PrintWriter(sw));
|
||||
return "运行时错误:" + cause.getMessage() + "\n堆栈跟踪:\n" + sw.toString();
|
||||
} finally {
|
||||
// 7. 清理资源
|
||||
if (tempDir != null) {
|
||||
try {
|
||||
Files.walk(tempDir)
|
||||
.sorted(Comparator.reverseOrder())
|
||||
.map(Path::toFile)
|
||||
.forEach(File::delete);
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
executeCode("JOptionPane.showMessageDialog(null, \"普通对话框\");");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已加载的类
|
||||
* @return 已加载的类
|
||||
*/
|
||||
public static Class<?>[] getLoadedClasses() {
|
||||
if (instrumentation == null){
|
||||
try {
|
||||
VirtualMachine vm = VirtualMachine.getVirtualMachine(ProcessHandle.current().pid(), true);
|
||||
instrumentation = vm.getInstrumentation();
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to attach to VM: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
return instrumentation.getAllLoadedClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类的方法与字段
|
||||
* @param clazz 类名
|
||||
* @return 类的方法与字段
|
||||
*/
|
||||
public static String getMethodAndField(String clazz) {
|
||||
try {
|
||||
Class<?> aClass = Class.forName(clazz);
|
||||
String methods = Arrays.stream(aClass.getDeclaredMethods())
|
||||
.map(Method::toString)
|
||||
.collect(Collectors.joining("\n"));
|
||||
String fields = Arrays.stream(aClass.getDeclaredFields())
|
||||
.map(Field::toString)
|
||||
.collect(Collectors.joining("\n"));
|
||||
return "方法:\n" + methods + "\n\n字段:\n" + fields;
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("Class not found: " + clazz, e);
|
||||
}
|
||||
}
|
||||
|
||||
public interface LoadingMonitor {
|
||||
void load(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer);
|
||||
}
|
||||
}
|
||||
18
src/main/java/org/tzd/debug/GetInstance.java
Normal file
18
src/main/java/org/tzd/debug/GetInstance.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package org.tzd.debug;
|
||||
|
||||
/**
|
||||
* @author tzdwindows 7
|
||||
*/
|
||||
public class GetInstance {
|
||||
|
||||
static {
|
||||
System.load("C:\\Users\\Administrator\\source\\repos\\GetInstance\\x64\\Release\\GetInstance.dll");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类的所有实例
|
||||
* @param clazz 类
|
||||
* @return 类的所有实例
|
||||
*/
|
||||
public static native Object[] getInstance(Class<?> clazz);
|
||||
}
|
||||
217
src/main/java/org/tzd/debug/MethodDebug.java
Normal file
217
src/main/java/org/tzd/debug/MethodDebug.java
Normal file
@@ -0,0 +1,217 @@
|
||||
package org.tzd.debug;
|
||||
|
||||
import net.bytebuddy.agent.builder.AgentBuilder;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.implementation.MethodDelegation;
|
||||
import net.bytebuddy.implementation.bind.annotation.AllArguments;
|
||||
import net.bytebuddy.implementation.bind.annotation.Origin;
|
||||
import net.bytebuddy.implementation.bind.annotation.RuntimeType;
|
||||
import net.bytebuddy.implementation.bind.annotation.SuperCall;
|
||||
import net.bytebuddy.implementation.bytecode.assign.Assigner;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.api.dog.agent.VirtualMachine;
|
||||
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class MethodDebug {
|
||||
private static final Logger logger = LogManager.getLogger(MethodDebug.class);
|
||||
private static Instrumentation instrumentation;
|
||||
private static final List<MethodMonitorCallback> callbacks = new CopyOnWriteArrayList<>();
|
||||
|
||||
static {
|
||||
try {
|
||||
VirtualMachine vm = VirtualMachine.getVirtualMachine(ProcessHandle.current().pid(), true);
|
||||
instrumentation = vm.getInstrumentation();
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to attach to VM: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
try {
|
||||
new AgentBuilder.Default()
|
||||
.with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
|
||||
// 只拦截你的应用代码,排除系统类
|
||||
.ignore(ElementMatchers.nameStartsWith("java.")
|
||||
.or(ElementMatchers.nameStartsWith("javax."))
|
||||
.or(ElementMatchers.nameStartsWith("sun."))
|
||||
.or(ElementMatchers.nameStartsWith("com.sun."))
|
||||
.or(ElementMatchers.nameStartsWith("jdk."))
|
||||
.or(ElementMatchers.nameStartsWith("org.tzd.debug.")))
|
||||
.or(ElementMatchers.nameStartsWith("com.axis.innovators.box.tools.RegisterTray"))
|
||||
.or(ElementMatchers.nameStartsWith("com.formdev.flatlaf."))
|
||||
.or(ElementMatchers.nameStartsWith("com.axis.innovators.box.gui."))
|
||||
.or(ElementMatchers.nameStartsWith("org.apache."))
|
||||
.or(ElementMatchers.nameStartsWith("jdk."))
|
||||
.or(ElementMatchers.nameStartsWith("org.fife."))
|
||||
.or(ElementMatchers.nameStartsWith("java.awt."))
|
||||
.or(ElementMatchers.nameStartsWith("javax.swing."))
|
||||
.type(ElementMatchers.any())
|
||||
.transform((builder, type, classLoader, module, pd) ->
|
||||
builder.method(ElementMatchers.any().
|
||||
and(ElementMatchers.not(ElementMatchers.isNative()))
|
||||
.and(ElementMatchers.not(ElementMatchers.isAbstract()))
|
||||
)
|
||||
.intercept(MethodDelegation.to(
|
||||
MethodInterceptor.class))
|
||||
).installOn(instrumentation);
|
||||
} catch (Exception e) {
|
||||
logger.error("Agent installation failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addCallback(MethodMonitorCallback callback) {
|
||||
callbacks.add(callback);
|
||||
}
|
||||
|
||||
public static void removeCallback(MethodMonitorCallback callback) {
|
||||
callbacks.remove(callback);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
logger.info("Starting MethodDebug main method");
|
||||
|
||||
// 先添加回调
|
||||
addCallback(new MethodMonitorCallback() {
|
||||
@Override
|
||||
public void onMethodEnter(String className, String methodName, Object[] args) {
|
||||
logger.info("ENTER: {}.{}", className, methodName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMethodExit(String className, String methodName, Object returnValue, Throwable exception, long durationNanos) {
|
||||
String status = exception != null ? "FAILED" : "SUCCESS";
|
||||
logger.info("EXIT: {}.{} - {} ({} ns)", className, methodName, status, durationNanos);
|
||||
}
|
||||
});
|
||||
|
||||
// 然后安装Agent
|
||||
load();
|
||||
|
||||
// 测试监控
|
||||
logger.info("Starting test loop...");
|
||||
while (true) {
|
||||
try {
|
||||
logger.info("Calling ds.ada()...");
|
||||
//ds.ada();
|
||||
Thread.sleep(1000); // 添加延迟避免过度占用CPU
|
||||
} catch (Exception e) {
|
||||
logger.error("Error in test loop", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface MethodMonitorCallback {
|
||||
void onMethodEnter(String className, String methodName, Object[] args);
|
||||
void onMethodExit(String className, String methodName, Object returnValue, Throwable exception, long durationNanos);
|
||||
}
|
||||
|
||||
public static class MethodInterceptor {
|
||||
@RuntimeType
|
||||
public static Object intercept(@Origin Method method,
|
||||
@SuperCall Callable<?> callable,
|
||||
@AllArguments Object[] args) throws Exception {
|
||||
String className = method.getDeclaringClass().getName();
|
||||
String methodName = method.getName();
|
||||
|
||||
// 通知进入
|
||||
for (MethodMonitorCallback callback : callbacks) {
|
||||
try {
|
||||
callback.onMethodEnter(className, methodName, args);
|
||||
} catch (Throwable t) {
|
||||
logger.error("Callback error in onMethodEnter", t);
|
||||
}
|
||||
}
|
||||
|
||||
long start = System.nanoTime();
|
||||
Object result = null;
|
||||
Throwable exception = null;
|
||||
|
||||
try {
|
||||
if (callable != null) {
|
||||
result = callable.call();
|
||||
}
|
||||
return result;
|
||||
} catch (Throwable t) {
|
||||
exception = t;
|
||||
throw t;
|
||||
} finally {
|
||||
long duration = System.nanoTime() - start;
|
||||
|
||||
// 通知退出
|
||||
for (MethodMonitorCallback callback : callbacks) {
|
||||
try {
|
||||
callback.onMethodExit(className, methodName, result, exception, duration);
|
||||
} catch (Throwable t) {
|
||||
logger.error("Callback error in onMethodExit", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MethodTimerAdvice {
|
||||
@Advice.OnMethodEnter
|
||||
static MethodContext enter(@Advice.Origin Method method,
|
||||
@Advice.AllArguments Object[] args) {
|
||||
System.out.println("MethodTimerAdvice.enter");
|
||||
if (callbacks.isEmpty()) return null;
|
||||
|
||||
MethodContext context = new MethodContext();
|
||||
context.startTime = System.nanoTime();
|
||||
context.className = method.getDeclaringClass().getName();
|
||||
context.methodName = method.getName();
|
||||
context.args = args;
|
||||
|
||||
// 通知所有回调
|
||||
for (MethodMonitorCallback callback : callbacks) {
|
||||
try {
|
||||
callback.onMethodEnter(context.className, context.methodName, args);
|
||||
} catch (Throwable t) {
|
||||
logger.error("Callback execution error in onMethodEnter", t);
|
||||
}
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
@Advice.OnMethodExit(onThrowable = Throwable.class)
|
||||
static void exit(@Advice.Enter MethodContext context,
|
||||
@Advice.Thrown Throwable exception,
|
||||
@Advice.Return(typing = Assigner.Typing.DYNAMIC, readOnly = false) Object returnValue) {
|
||||
System.out.println("MethodTimerAdvice.exit");
|
||||
if (context == null || callbacks.isEmpty()) return;
|
||||
|
||||
long duration = System.nanoTime() - context.startTime;
|
||||
|
||||
// 通知所有回调
|
||||
for (MethodMonitorCallback callback : callbacks) {
|
||||
try {
|
||||
callback.onMethodExit(
|
||||
context.className,
|
||||
context.methodName,
|
||||
returnValue,
|
||||
exception,
|
||||
duration
|
||||
);
|
||||
} catch (Throwable t) {
|
||||
logger.error("Callback execution error in onMethodExit", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 上下文对象,用于在方法进入和退出之间传递数据
|
||||
static class MethodContext {
|
||||
long startTime;
|
||||
String className;
|
||||
String methodName;
|
||||
Object[] args;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
src/main/java/org/tzd/debug/util/GlobalObjects.java
Normal file
18
src/main/java/org/tzd/debug/util/GlobalObjects.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package org.tzd.debug.util;
|
||||
|
||||
import com.axis.innovators.box.AxisInnovatorsBox;
|
||||
|
||||
import java.lang.instrument.Instrumentation;
|
||||
|
||||
/**
|
||||
* 调试控制台的全局对象
|
||||
* @author tzdwindows 7
|
||||
*/
|
||||
public class GlobalObjects {
|
||||
/**
|
||||
* Instrumentation对象
|
||||
*/
|
||||
public Instrumentation instrumentation;
|
||||
|
||||
public AxisInnovatorsBox axisInnovatorsBox = AxisInnovatorsBox.getMain();
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
package org.tzd.lm;
|
||||
|
||||
import java.io.*;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
@@ -9,9 +15,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* 使用AI接口获取回复
|
||||
* @author tzdwindows 7
|
||||
@@ -35,6 +38,7 @@ public class LMApi {
|
||||
public void setContent(String content) { this.content = content; }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 调用AI接口获取回复
|
||||
* @param messages 消息列表
|
||||
|
||||
Reference in New Issue
Block a user