Introduction

This program can be used to find out how your computer is being used while you are away. After installing, this program stores all the keystrokes and uploads a text file containing these strokes to an FTP site daily.

There are 4 sections to this program as described below. One is the keyboard hook. Second is the text file FTP uploader. The third section deals with looking for a connection to the internet. The last one is the installation program. The four sections are discussed below.

I. The keyboard hook DLL.

The first section of the program is a keyboard hook DLL. There is nothing new in this DLL. The DLL stores all the keystrokes in a text file in the System Folder. This DLL is described in detail in the Keyboard hook DLL article in CodeProject.

II. Uploading a text file to a FTP site

This program simply uploads the text file in the system folder to a FTP site.

III. Looking for connection to the Internet

This program looks for a connection to the 'net. If the connection is found, it calls the program to upload the text file created in section II. This is the main program that executes every time the system starts up. This program installs the keyboard hook and checks the registry to find if a text file has been uploaded today. If not, it sets a timer that checks for a network connection.

IV. Installing the programs in your system

This program installs the 3 sections to your computer. The executables of sections I to III are stored as binary resources. After the first execution of this program, the 3 resource files are stored in the System folder as Servv22.dll, Serv22.exe and Servpost.exe.

I know the description is not as good as it could be, so please check the source files. These really help to show how this program works. I know that there are many faults in this program structure, so please excuse me, as I am still learning VC++.

I welcome your valuable comments about this article.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

About the Author

Comments and Discussions

I had exactly the same problem this weekend and it was killing me........

When the thread loses focus the handle of whatever method I use to send the keystrokes is set to 0......

After a while I realised that the handles were pseudohandles and were applicable ONLY to the process that created them. Therefore when a new window comes into focus to recieve keystrokes (and assuming it belongs to a new process), the handle that was stored in the shared section of the DLL becomes invalid.

I could not try to make proper handles each time focus changed using DuplicateHandle() as each process was not aware of each other.

In the end I created a Mailslot with CreateMailslot() in my main program....then I connected to the Mailslot with CreateFile() in the DllMain when it recieved a DLL_PROCESS_ATTACH message...I kept this handle global, but local to my process and now it works AOK...

As an added extra I transported the keystrokes across the network to a listening client.....now when I type a line, it comes up in TELNET on the listening computer.....

If you want to look go to www.robjford.com (mysite - shameless plug)and look under tutorials....the code and binaries are there...there are probably still a few bugs to fix...but it works ok

I can't say that I'm an expert on this subject either, but from what I gather, the dll is mapped to each process's memory. It's not actually unhooked, it would be like an entirely different dll monitoring the host program's ( the program the dll is attached to ) keystokes. I found a similar program elsewhere that uses the FindWindow() function to find the main program ( the one that installed the keyboard hook ) and then it uses this to CWnd::SendMessage() containing the actual keystroke. This seems to work pretty good. Hope this isn't too cryptic of an explanation.