CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2006
    Posts
    1

    Windows Service & Keyboard hook

    Hi all

    I had created two programs, the first, a Windows Service and the other a Keyboard hook. Both programs runs very well. Now, I want to join both and to create one, that it works like a simple keylogger and start before logon screen appear in WinXP/2K. I have proven several possibilities but without any solution, for example, the Service start, and it call and install the hook procedure, this last is installed but never is called when a key is pressed, also when the service stop, the hook is uninstalled too, everything works well, but my callback procedure never is called.

    If this is not possible, please, say it to me because I am losing long time looking for a solution, in another case, if somebody could give to an aid to me very would be thanked for them.

    Thanks in advance!

  2. #2
    Join Date
    Jan 2004
    Location
    Denmark
    Posts
    64

    Re: Windows Service & Keyboard hook

    You can't install a keyboard hook before a user has logged on, obviously, because if you could, it would be way too easy to steal a users password.

    Why do you need a keyboard hook before a user is logged on?

  3. #3
    Join Date
    Jan 2005
    Location
    germany
    Posts
    160

    Re: Windows Service & Keyboard hook

    Well, its really hard for me to imagine, which non criminal intention you might have with your program.

    But to stay on a technical level: I guess your programm works perfectly OK. Because keyboard and mouse devices are connected to window stations and desktops. Both are not available for a service running before anybody has logged on. And I doubt, that you can get the window station of the logon process, cause window stations are secured objects.
    Find details on msdn:

    http://msdn.microsoft.com/library/de...w_stations.asp

  4. #4
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: Windows Service & Keyboard hook

    Are you setting mouse and keyboard hook ? Are you setting it system wide ?

    See the explaination in MSDN for SetWindowshookEx for last parameter dwThreadId,
    dwThreadId
    [in] Specifies the identifier of the thread with which the hook procedure is to be associated. If this parameter is zero, the hook procedure is associated with all existing threads running in the same desktop as the calling thread.
    which means that the hooks set from service will not have access to the interactive desktop without which it is not possible to get the callbacks.
    To resolve this issue you will have to make the service interactive, this can be set from Service control panel on LogOn tab-> Allow service to interact with desktop.
    Regards,
    Ramkrishna Pawar

  5. #5
    Join Date
    Jan 2004
    Location
    Denmark
    Posts
    64

    Re: Windows Service & Keyboard hook

    Quote Originally Posted by HoM
    Well, its really hard for me to imagine, which non criminal intention you might have with your program.

    I second that.

  6. #6
    Join Date
    Oct 2008
    Posts
    1

    Re: Windows Service & Keyboard hook

    If it is hard for you to imagine an application that is not criminal, this has nothing to do with the intentions of the OP. It tells me something about your creativity.

    How about simplifying the login procedure by providing a hardware solution without compromising external security? Or how about a software-based KVM-switch like the one I've been developing (which is what landed me here, since Synergy doesn't solve it, if it is possible at all). How about a service that provides visual feedback on key presses for accessibility?

    Instead, what you really meant to say was: "If I were developing something like this, it would probably be for criminal purposes." The Dutch have a saying to this effect: trust the innkeeper like he trusts his customers.

  7. #7
    Join Date
    Jan 2005
    Location
    germany
    Posts
    160

    Re: Windows Service & Keyboard hook

    I think you are wrong. If you were searching a solution for "accessibility in logon process" (or whatever) why didn't you ask for that?
    Without ever having done it myself: I am pretty sure, that replacing gina.dll will allow you to do, what you intended. It is the documented way to interfere the logon process.

    So maybe you are right: my creativity was restricted (by technical know how) :-) or in other words: asking your question in a more general way would have left a bit more space for creativity.

    regards
    HoM

  8. #8
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Windows Service & Keyboard hook

    Quote Originally Posted by Grismar
    How about simplifying the login procedure by providing a hardware solution without compromising external security? ...a software-based KVM-switch ...a service that provides visual feedback on key presses for accessibility...
    Does your guessing have something to do with the OP?
    Quote Originally Posted by Leun@m
    I want to join both and to create one, that it works like a simple keylogger and start before logon screen appear in WinXP/2K.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured