Skip to main content

Java SPY++ (Interprocess code injection) : Need something to start with

Please note these forums are being decommissioned and use the new and improved forums at
4 replies [Last post]
Joined: 2011-12-07


I'm working on a kind of spy++ and I need to add java support. (any type of GUI)

I need to :

1- inject some code into a *JAVA* application at runtime (I already do this for native, .NET, WPF etc..)
2- Get the architecture of the user interface (the type of control with the parent-child hiercharchy)
3- Get all possible properties for a specific *JAVA* control. By example getting the text of a text button or the list of items of a listView


1- Is there any C++/C#/Java example of injecting java code into another java process ?
2- Is there any java equivalent for interprocess native window message with SendMessage (ex: LVM_GETITEMS to get listview items)
3- Is there any java equivalent for MS .Net Control.FromHandle() Is it possible to get an access to a control instance once i'm injected into the java process?
4- Can you point me to some interresting things to accomplish my particular tasks? (code injection and getting properties)

I just need something to start with.... I have not many chances to work more with java until now



Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-05-06

The Java Attach API allows you to attach to other Java processes running on the system and load agents.

An agent (see Java's Instrumentation API) can run arbitrary Java code within that process and even modify bytecode on-the-fly using ClassFileTransformers.

For (2) and (3), within your agent, use Window.getOwnerlessWindows() and/or Frame.getFrames() to get top level windows and frames for the Java application. Then drill down through the component hierarchy using the AWT APIs, accessing components as needed.

As for examples, here is one for the attach API.

Another example of creating an agent.

Joined: 2011-12-07

Prunge : I just want to tell you that your help was ***extremely useful*** We would NEVER have succeeded without your help. I really want to say thanks your for your help :)

Joined: 2011-12-07


I will take a look at this tomorrow, That sound like a good start :)


Joined: 2011-12-07

I'm using NetBeans

How i'm suppose to get access to (import) ??
I get the following error : package does not exist

I never really use java before for any complicate may sounds basic but i'm still trying to figure it how since many hours.. How can I get com.sun.*.* ?