To Stoicho... Re: Repost, Unanswered Hooking Problem...

  • Thread starter Thread starter TMP
  • Start date Start date
T

TMP

Thank you so much Stoitcho,but then I have another question.I was able to
implement a low level keyboard hook (globally of course) by using (almost)
the same code fragment.So I thought if it works for every top level window
on desktop globally it would work for a single procedure too.May be I'm
wrong.Could you inform me a little more on this subject or recommend some
references that will give me details?
Best regards
 
Hi TMP,
It really depends on what kind of hook you want to install. For example for
WH_MOUSE_LL hooks MSDN states:
"...However, the WH_MOUSE_LL hook is not injected into another process.
Instead, the context switches back to the process that installed the hook
and it is called in its original context. Then the context switches back to
the application that generated the event. "
Pay attention on "...However, the WH_MOUSE_LL hook is not injected into
another process..."
This global hook is possible with .NET. This puts some programers in
confusion because they have read the followin MS statement:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q318804#3

The reality is .NET doesn't forbid any hooks. Some of them, though, are
simply not possible. Sad but true.
Actually WH_KEYBOARD_LL and WH_MOUSE_LL are the only global hooks that can
be installed globaly.
 
Thank you so much, appearently I missed that part about LL hooks on MSDN.
Sigh, I'll switch to C++ or so it seems.
Stoitcho Goutsev (100) said:
Hi TMP,
It really depends on what kind of hook you want to install. For example for
WH_MOUSE_LL hooks MSDN states:
"...However, the WH_MOUSE_LL hook is not injected into another process.
Instead, the context switches back to the process that installed the hook
and it is called in its original context. Then the context switches back to
the application that generated the event. "
Pay attention on "...However, the WH_MOUSE_LL hook is not injected into
another process..."
This global hook is possible with .NET. This puts some programers in
confusion because they have read the followin MS statement:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q318804#3

The reality is .NET doesn't forbid any hooks. Some of them, though, are
simply not possible. Sad but true.
Actually WH_KEYBOARD_LL and WH_MOUSE_LL are the only global hooks that can
be installed globaly.


--
HTH
B\rgds
100 [C# MVP]

TMP said:
Thank you so much Stoitcho,but then I have another question.I was able to
implement a low level keyboard hook (globally of course) by using (almost)
the same code fragment.So I thought if it works for every top level window
on desktop globally it would work for a single procedure too.May be I'm
wrong.Could you inform me a little more on this subject or recommend some
references that will give me details?
Best regards
 
Hi TMP,
What you might wanna do is to write unmanaged (native) dll that holds your
hook procedure. Then you use that DLL and inject it as a hook into the other
processes. Then you have to establish some kind of interprocess
communication (if you need it of course)between the hooked process and the
managed one. There are options you have. The simplest one seems to be
windows messages.


--
B\rgds
HTH
100 [C# MVP]

TMP said:
Thank you so much, appearently I missed that part about LL hooks on MSDN.
Sigh, I'll switch to C++ or so it seems.
Stoitcho Goutsev (100) said:
Hi TMP,
It really depends on what kind of hook you want to install. For example for
WH_MOUSE_LL hooks MSDN states:
"...However, the WH_MOUSE_LL hook is not injected into another process.
Instead, the context switches back to the process that installed the hook
and it is called in its original context. Then the context switches back to
the application that generated the event. "
Pay attention on "...However, the WH_MOUSE_LL hook is not injected into
another process..."
This global hook is possible with .NET. This puts some programers in
confusion because they have read the followin MS statement:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q318804#3

The reality is .NET doesn't forbid any hooks. Some of them, though, are
simply not possible. Sad but true.
Actually WH_KEYBOARD_LL and WH_MOUSE_LL are the only global hooks that can
be installed globaly.


--
HTH
B\rgds
100 [C# MVP]

TMP said:
Thank you so much Stoitcho,but then I have another question.I was able to
implement a low level keyboard hook (globally of course) by using (almost)
the same code fragment.So I thought if it works for every top level window
on desktop globally it would work for a single procedure too.May be I'm
wrong.Could you inform me a little more on this subject or recommend some
references that will give me details?
Best regards
 
Back
Top