Page 1 of 1

(Solved) Mousehook troubles (Win10)

Posted: Mon Sep 23, 2019 1:57 pm
by chi
I'm having troubles to port an old program of mine (based on this code) to Windows 10 (coming from Win7)

When I start nlh.exe as a non-elevated process, only non-elevated programs seems to react to the hook. Starting nlh.exe with admin-rights only works on elevated, but not on non-elevated programs. I've already tried uiAccess=true inside the manifest, test-signed my program (Jimmy Brush's reply) and installed the .cert on Win10, but I still get the "A referral was returned from the server."-Message. Is there anything else I have to do, to make it work on Win10? Is uiAccess=true the only way?

All suggestions are welcome ;) Thx


edit1: Seems like I made a mistake installing the certificate... uiAccess=true works now without the error message, but I still don't get a signal from non-elevated and elevated programs at the same time

Re: Mousehook troubles (Win10)

Posted: Mon Sep 23, 2019 10:05 pm
by Sicro
The mouse hook procedure should be outsourced in a DLL. Is that the case with you?

Re: Mousehook troubles (Win10)

Posted: Tue Sep 24, 2019 12:06 pm
by chi
Sicro wrote:The mouse hook procedure should be outsourced in a DLL. Is that the case with you?
Yes, the dll is separate, of course (code).

The mousehook currently works on Win7 without UAC for both non-elevated and elevated programs simultaneously. With UAC on, I need to launch the exe with admin rights to catch all elevated programs, but this wont catch any non-elevated programs. And launching it without admin rights just collects messages from non-elevated programs. Same behavior on Windows 10, except that it doesn't matter anymore if UAC is on or off...

Re: Mousehook troubles (Win10)

Posted: Tue Sep 24, 2019 12:16 pm
by fryquez
Use ChangeWindowMessageFilter_() or ChangeWindowMessageFilterEx_() in your exe
and allow it to receive the message your dll sends.

Re: Mousehook troubles (Win10)

Posted: Tue Sep 24, 2019 1:43 pm
by chi
You gotta love the PB community ;)

Thank you, fryquez! Exactly what I was looking for (but didn't know)...

Adding

Code: Select all

ChangeWindowMessageFilter_(#NLH_DLL_CONTROL, #MSGFLT_ADD)
to the program and running it with admin rights, catches now both elevated and non-elevated messages!

Re: (Solved) Mousehook troubles (Win10)

Posted: Sat Sep 28, 2019 8:57 am
by Mistrel
Cool. I've been using Win32 for years and never knew about this. Always learning something new. :)