Click here to Skip to main content
15,216,402 members
Rate this:
Please Sign up or sign in to vote.
See more:
How a key logger works. What is the logic behind this.
Can any body tell me logic of key logger?
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 3

Why?

OK, this is what it is: http://en.wikipedia.org/wiki/Key_logger[^].

You probably mean software key logger. According to Microsoft, it impossible to create with C#. It needs a Windows Hook to be registered. See http://msdn.microsoft.com/en-us/library/ms632589%28v=vs.85%29.aspx[^]. The problem is registration and using of a system-global hook. It must be implemented in an unmanaged DLL which you can use to communicate with your .NET software.

See also:
http://msdn.microsoft.com/en-us/library/ms644959(v=vs.85).aspx[^],
http://msdn.microsoft.com/en-us/library/ms644960(v=vs.85).aspx[^],
http://msdn.microsoft.com/en-us/library/ff468841(v=vs.85).aspx[^].

See the following CodeProject articles helping to implement Global System Hook in C# with the help of C++ unmanaged DLL:
Using Window Messages to Implement Global System Hooks in C#[^],
Global System Hooks in .NET[^],
Processing Global Mouse and Keyboard Hooks in C#[^].

—SA
   
v2
Comments
Abhinav S 21-Jul-11 4:46am
   
My 5. Lot of details. But I hope the OP does not misuse this information.
Sergey Alexandrovich Kryukov 21-Jul-11 10:26am
   
Yes, that a concern. Hope not.
Thank you, Abhinav.
--SA
Rate this:
Please Sign up or sign in to vote.

Solution 1

The logic is simple enoough. Every key typed on the keyboard is captured by a program.
This can be achieved using a keyboard hook.
   
Comments
   
And how would you do it in C#? P/Invoke of SetWindowsHookEx? According to Microsoft, it won't work if the global system hook is needed -- unfortunately; and it is needed for a key logger.
Please see my solution.
--SA
Abhinav S 21-Jul-11 4:45am
   
I left it for the OP as an exercise to find out.
Rate this:
Please Sign up or sign in to vote.

Solution 2

   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100