Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Events with dll in java

Thread view: 
ZaRMaS@gmail.com - 26 Jun 2006 16:58 GMT
Hi all,

I want to develop a keylogger-like in java (not for hacking, my
programm which work in background has a hotkey to have interaction with
the selec program). Atfer many researches in the net, i must use a
native code and to load the dll with java. I don't understand how the
dll can talk with the java program :

*If dll receives a keyboard signal, how java program can have a signal
from the dll ?

Example : Dll developped in c++ receives all events from the keyboard.
How it can be transmitted to java program?
Chris Uppal - 26 Jun 2006 17:52 GMT
> *If dll receives a keyboard signal, how java program can have a signal
> from the dll ?

It's probably best to get the information out of the 'C' world of JNI and into
the Java world as quickly as possible.  So I'd define a static method on some
class which your DLL invokes on every keystroke.  That method (/not/ a native
method) would presumably convert the information into a more structured form (a
Keystroke object perhaps, and maybe there'd be some sort of Observer pattern),
but none of that matters to the C code.

To call a static method from C in JNI you will have to find the class using
FindClass() (it's a good idea to convert the object reference into a global
reference and cache it in your DLL -- don't forget to release it later).  Also
use GetStaticMethodID() to find the method you are going to call (you can cache
that too).  And to invoke the method, use one of the method invokation JNI
calls, such as CallStaticVoidMethod().

Your C code which monitors the the keyboard will presumably have to run in a
separate OS thread.  You can implement that simply by starting a Java thread
which calls a native method which "never returns".  Alternatively you could
create a new thread in C, and tell Java about that thread by calling
AttachThread().

   -- chris


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.