(Solved) Mousehook troubles (Win10)

Everything else that doesn't fall into one of the other PB categories.
User avatar
chi
Addict
Addict
Posts: 1034
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

(Solved) Mousehook troubles (Win10)

Post 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
Last edited by chi on Tue Sep 24, 2019 1:48 pm, edited 1 time in total.
Et cetera is my worst enemy
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: Mousehook troubles (Win10)

Post by Sicro »

The mouse hook procedure should be outsourced in a DLL. Is that the case with you?
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
User avatar
chi
Addict
Addict
Posts: 1034
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Mousehook troubles (Win10)

Post 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...
Et cetera is my worst enemy
fryquez
Enthusiast
Enthusiast
Posts: 367
Joined: Mon Dec 21, 2015 8:12 pm

Re: Mousehook troubles (Win10)

Post by fryquez »

Use ChangeWindowMessageFilter_() or ChangeWindowMessageFilterEx_() in your exe
and allow it to receive the message your dll sends.
User avatar
chi
Addict
Addict
Posts: 1034
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Mousehook troubles (Win10)

Post 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!
Et cetera is my worst enemy
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: (Solved) Mousehook troubles (Win10)

Post by Mistrel »

Cool. I've been using Win32 for years and never knew about this. Always learning something new. :)
Post Reply