Injecting a class into the JVM and interacting with existing classes
I want to inject my Java class into an existing Java application, on Windows.
I found an article describing a method using CreateRemoteThread
- java-code-injection-via-winapis
But it's not clear if the injected class can 'connect' with the existing classes and call them.
Does anybody know if this is possible? Are there functions in the JNI which can be used to search and get a reference to already running classe开发者_如何学运维s?
i'm sure there are other complicated ways to do what you want to do (e.g. using the java instrumentation apis). however, there is probably a much easier way.
- find the class which is the main class for the application
- decompile the class into java code.
- add a simple hook to invoke your custom code (or otherwise modify this class to suit your needs)
- recompile the modified class and replace the class file in the relevant jar
- run your modified application!
精彩评论