• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Windows hooks

Khanmots

Gawd
Joined
May 12, 2007
Messages
905
I'm attempting to setup a system whereby a hotkey can be used to enable/disable a set of hooks to block mouse input and most all keyboard input from reaching the system. (so that a tablet can be safely holstered)

However, I've determined that even if you have your global hook dll with it's HHOOK variables in a shared data segment that:
1) If application A enables them via the dll and then exits that they are then disabled at exit.
2) If application B loads the dll and sits there not exiting, then the same behavior is still seen when application A runs and exits.
3) If application B loads the dll and sets them and then sits there not exiting. Then application A can disable them, exit, and have the state change persist. However, it can't then reset and have the hook persist past exit.

So my question is, how do I go about having a temporary instance of an app enable persistent hooks? At this point I'm guessing I either need to figure out how to setup a service that loads the dll and waits for my temporary app to tell it to enable/disable or I need to have the dll loaded by a program I know will be running, and then setup an IPC method to tell it to enable/disable. Or is there a relatively simple way to tell windows to allow the hooks to persist past program exit?
 
I think I see what's going on. I'm setting the third parameter in SetWindowsHookEx(), i.e. HINSTANCE hMod, to HMODULE hModule as set in DllMain(). I'm guessing that this is what's causing the hook to remove itself when the setting app exits.

I'm not sure how to address this though.
 
I guess I could add an external SetHandle() function to my dll, have that function call GetModuleHandle(0); and store the result in a HMODULE variable in the dll's shared data segment, then make a call to SetHandle() in my persistent application. Then change my dll's external enable hook function to use that stored HMODULE value when setting the hooks.

Seems messy though :/

I should probably point out that I can't (or don't know how) to imbed the detection of the hotkey into the persistent application due to the fact that *all* these buttons show as scan-code 255 in windows. The vendor has an application though that allows you to set an application (or bat file... or whatever) to call upon button press. Hence my current split approach.
 
And... that didn't seem to work. Anyone have any suggestions where to go from here? Or am I going to need to find a more specialized forum?
 
Looks like my fallback of registering a windows message and using that to signal to my persistant app to make the calls into the dll to enable/disable the hooks will work as expected as I only have one module instance involved then. Still wish I knew why setting the handle to the module instance linked to the persistent app didn't though.
 
Back
Top