Home arrow static arrow Java Programming [Archive] - Attach to another process
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Attach to another process
1 Duke Stars available
This topic has 6 replies on 1 page.

Posts:9
Registered: 8/22/03
Attach to another process  
Jun 8, 2004 1:18 AM



 
I am wondering how to attach to another process.

scenarios:
1. There is a gui running. You would like your program to attach and execute methods in it. Like clicking buttons as an automated process in an intelligent manner.

2. There is a service running. You would like your program to attach and create a gui for it for the administrator and be able to change its settings.

How do you do this. If I make a new main and try to use the existing classes they will be initialized and launched again... How do you identify yourself as part of the running program, like a new thread maybe?

No network or socket programming should be involved.

Anyone knows?
 

Posts:269
Registered: 10/12/99
Re: Attach to another process  
Jun 8, 2004 4:16 PM (reply 1 of 6)



 
You mean like an add-on for an existing program for which you don't have the source code?

Monika.
 

Posts:801
Registered: 8/1/00
Re: Attach to another process  
Jun 8, 2004 10:46 PM (reply 2 of 6)



 
I did such trick in MS Windows. I wrote DLL (with JNI code), which was injected to another process (with CreateRemoteThread). In this DLL I attached to the running JVM, loaded (with a custom class loader) my classes packed in JAR. The code in this JAR enumerated all components in the java application. With this code and Java Accessibility SDK I simulated Key-Mouse actions (and not only this).
 

Posts:9
Registered: 8/22/03
Re: Attach to another process  
Jun 9, 2004 2:07 AM (reply 3 of 6)



 
yes monika. I mean that..
but even with source code, if you want the utility to be an add-in and not dependent of the original program..
 

Posts:9
Registered: 8/22/03
Re: Attach to another process  
Jun 9, 2004 2:09 AM (reply 4 of 6)



 
sounds real good, and complicated...

do you have examples?
 

Posts:4,689
Registered: 6/6/03
Re: Attach to another process  
Jun 9, 2004 3:53 AM (reply 5 of 6)



 
If you have control over the other process, you could make it listen on a port and execute the commands it receives on it. Thus yould could attach to the other process through simply sending it messages to that control port.
 

Posts:269
Registered: 10/12/99
Re: Attach to another process  
Jun 15, 2004 4:15 PM (reply 6 of 6)



 
@BIJ001, that sounds interesting, could you explain that in more detail or point to example source code?

Monika.
 
This topic has 6 replies on 1 page.