?
Solved

Can WH_DEBUG hook detect when a hook is uninstalled

Posted on 2004-03-31
5
Medium Priority
?
603 Views
Last Modified: 2013-12-03
I know that WH_DEBUG can detect when a hook is installed.  Does anybody know whether it can also detect when a hook is uninstalled?  If so, can you point me to a code sample which does such detection.  Thanks...
0
Comment
Question by:DanFromBoston
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 16

Expert Comment

by:nonubik
ID: 10730447
I don't think so. And I don't think it can detect when a hook is installed.
MSDN states :
"WH_DEBUG Hook
The system calls a WH_DEBUG hook procedure before calling hook procedures associated with any other hook in the system. You can use this hook to determine whether to allow the system to call hook procedures associated with other types of hooks."

So nothing about (un)installation of a hook.
0
 
LVL 16

Expert Comment

by:nonubik
ID: 10730465
http://msdn.microsoft.com/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Hooks/AboutHooks.asp?frame=true#wh_debughook
I think you were missleaded by what says the MSDN for DebugProc wParam parameter (which I'm positive it's a copy-paste of the table from SetWindowsHookEx.. :)
0
 
LVL 5

Accepted Solution

by:
drnick earned 450 total points
ID: 10830860
you can do the following:

install a normal global hook
which, of course, involves that your dll is loaded in every app
your dll then, in its initialization code, replaces the normal UnhookWindowsHookEx by a
routine of the same signature which calls the "real" unhookwindowshookex proc but
also places a notification record in a shared memory section of your dll.
this record will then be read periodically by a thread in your application.

the whole thing is a little bit complicated, but it would work, maybe.
0
 
LVL 1

Author Comment

by:DanFromBoston
ID: 10832542
That's an interesting idea.  Are you sure that when you install a global hook that it's loaded into every app on the system?  I thought it was just loaded in the context of the thread you specify.
0
 
LVL 16

Assisted Solution

by:nonubik
nonubik earned 300 total points
ID: 10832567
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Hooks/HookReference/HookFunctions/SetWindowsHookEx.asp

dwThreadId "If this parameter is zero, the hook procedure is associated with all existing threads running in the same desktop as the calling thread."
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question