Keyboard Hooks  
Author Message
TTris





PostPosted: Visual C++ Language, Keyboard Hooks Top

Hi, I'm creating a keylogger to test an antivirus program I am making, and from what I've heard, the best way to do this is with a Keyboard Hook. If somebody could not only post the code involved in creating a Keyboard Hook but possibly give some basic explanation of it. If anyone could do this for me I would greatly appreciate it because I've looked around this forum and the internet to figure out how to do this hook but I havent had any luck yet.

Visual C++1  
 
 
einaros





PostPosted: Visual C++ Language, Keyboard Hooks Top

http://www.codeproject.com/dll/keyboardhook.asp.

Note that this forum is meant for C++ language related issues only. Specific solutions and implementatoins (and especially potentially shady ones such as this), is better aimed for general discussion board such as the newsgroups at http://msdn.microsoft.com/newsgroups, the codeguru forums or any number of other sites. As for the shady part, don't expect anyone to do the dirty work for you -- even though you say it's for testing purposes only.



 
 
Simple Samples





PostPosted: Visual C++ Language, Keyboard Hooks Top

Most people familiar with system-wide hooks will be skeptical of your motivation. My guess is that in this case, there is ample justification for being suspicious.

It took me a couple of months to get a system-wide hook to work. I studied everything I could find, and I did spend time searching. There are more resources available now compared to when I was looking. There are now a couple or more samples that did not exist then.

I could post a sample myself, but I won't because the code is simple if the knowledge required for the sample exists. A system-wide hook is something that can cause problems, and anyone using sample code that does not adequately understand Windows can easily cause problems.

If you are developing a system-wide hook, then you need to understand DLLs. If you don't, then learn about them. Another critical concept to understand is Address Spaces; see my Processes and Address Spaces.

Actually, for a keyboard system-wide hook, it might not be necessary to create a DLL. You can look at documentation and such; I forget where I read it, but a keyboard system-wide hook might be different from other system-wide hooks in that it might not be necessary to have them in a DLL and if so then the concept of address spaces might not be relevant.

Additional questions, though, should be asked in an appropriate newsgroup or forum.