<small id='5Ret8'></small><noframes id='5Ret8'>

  • <tfoot id='5Ret8'></tfoot>
      <bdo id='5Ret8'></bdo><ul id='5Ret8'></ul>
    1. <legend id='5Ret8'><style id='5Ret8'><dir id='5Ret8'><q id='5Ret8'></q></dir></style></legend>

      1. <i id='5Ret8'><tr id='5Ret8'><dt id='5Ret8'><q id='5Ret8'><span id='5Ret8'><b id='5Ret8'><form id='5Ret8'><ins id='5Ret8'></ins><ul id='5Ret8'></ul><sub id='5Ret8'></sub></form><legend id='5Ret8'></legend><bdo id='5Ret8'><pre id='5Ret8'><center id='5Ret8'></center></pre></bdo></b><th id='5Ret8'></th></span></q></dt></tr></i><div id='5Ret8'><tfoot id='5Ret8'></tfoot><dl id='5Ret8'><fieldset id='5Ret8'></fieldset></dl></div>

        附加到已经运行的 JVM

        Attach to already running JVM(附加到已经运行的 JVM)
        • <legend id='zK5oO'><style id='zK5oO'><dir id='zK5oO'><q id='zK5oO'></q></dir></style></legend>

              • <bdo id='zK5oO'></bdo><ul id='zK5oO'></ul>
              • <small id='zK5oO'></small><noframes id='zK5oO'>

                <i id='zK5oO'><tr id='zK5oO'><dt id='zK5oO'><q id='zK5oO'><span id='zK5oO'><b id='zK5oO'><form id='zK5oO'><ins id='zK5oO'></ins><ul id='zK5oO'></ul><sub id='zK5oO'></sub></form><legend id='zK5oO'></legend><bdo id='zK5oO'><pre id='zK5oO'><center id='zK5oO'></center></pre></bdo></b><th id='zK5oO'></th></span></q></dt></tr></i><div id='zK5oO'><tfoot id='zK5oO'></tfoot><dl id='zK5oO'><fieldset id='zK5oO'></fieldset></dl></div>

                <tfoot id='zK5oO'></tfoot>
                    <tbody id='zK5oO'></tbody>
                  本文介绍了附加到已经运行的 JVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法附加到已经运行的 JVM?

                  Is there a way to attach to an already running JVM?

                  例如,在 JNI 中,您可以使用 JNI_CreateJavaVM 创建 VM 并运行 jar 并检查其所有类..

                  For example, in JNI you can use JNI_CreateJavaVM to create a VM and run a jar and inspect all its classes..

                  但是,如果 jar 已经在运行,我无法找到附加到其 JVM 并与其类进行通信或获取其 env 指针的方法..

                  However, if the jar is already running, I cannot find a way to attach to its JVM and communicate with its classes or get its env pointer..

                  另一个问题是,如果 jar 加载了我的本机库 (.dll) 并且我想在 .dll 中创建一个 JVM,我不能......我也不能在没有 jar 调用我的函数的情况下附加 jar 的当前 JVM..

                  Another problem is that if the jar loads my native library (.dll) and I want to create a JVM inside the .dll, I cannot.. Nor can I attach the jar's current JVM either without the jar calling my function..

                  Java 端的示例:

                  class Foo
                  {
                      static {loadLibrary("Foo")}
                  }
                  

                  在 C++ 方面:

                  void Foo()
                  {
                      //CreateJVM
                      //Attach to the current process..
                      //Call function from the jar that loaded me.
                  }
                  

                  如果 jar 不先调用 Foo,则无法做到这一点.

                  This cannot be done without the jar calling Foo first.

                  有什么想法吗?有没有办法获取当前的 JVM 或附加到它或外部的 jvm 实例?

                  Any ideas? Is there no way to get the current JVM or to attach to it or an external jvm instance?

                  推荐答案

                  可以.

                  1) 在托管 JVM 的进程中注入 DLL(例如,java.exejavaw.exe>iexplore.exe).一种常见的注入技术是使用 SetWindowsHookEx

                  1) Inject a DLL in the process hosting the JVM (eg, java.exe, or javaw.exe, or iexplore.exe). A common injection technique is to use SetWindowsHookEx

                  2)在DLL中,使用GetModuleHandle

                  3) 获取JNI_GetCreatedJavaVMs函数的地址,使用GetProcAddress

                  3) Get the address of the JNI_GetCreatedJavaVMs function, using GetProcAddress

                  4) 调用函数,如果成功,则使用 JavaVMAttachCurrentThread 函数指针将线程附加到找到的第一个 JVM> 结构.

                  4) Call the function and, if successfull, attach your thread to the first JVM found, using the AttachCurrentThread function pointer from the JavaVM struture.

                  5) 完成.

                  有用的链接:调用 API

                  这篇关于附加到已经运行的 JVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                    <legend id='bM1yH'><style id='bM1yH'><dir id='bM1yH'><q id='bM1yH'></q></dir></style></legend>
                        • <bdo id='bM1yH'></bdo><ul id='bM1yH'></ul>
                            <tfoot id='bM1yH'></tfoot>

                            <small id='bM1yH'></small><noframes id='bM1yH'>

                          • <i id='bM1yH'><tr id='bM1yH'><dt id='bM1yH'><q id='bM1yH'><span id='bM1yH'><b id='bM1yH'><form id='bM1yH'><ins id='bM1yH'></ins><ul id='bM1yH'></ul><sub id='bM1yH'></sub></form><legend id='bM1yH'></legend><bdo id='bM1yH'><pre id='bM1yH'><center id='bM1yH'></center></pre></bdo></b><th id='bM1yH'></th></span></q></dt></tr></i><div id='bM1yH'><tfoot id='bM1yH'></tfoot><dl id='bM1yH'><fieldset id='bM1yH'></fieldset></dl></div>
                              <tbody id='bM1yH'></tbody>