LowLevelMouseHook-Example icon indicating copy to clipboard operation
LowLevelMouseHook-Example copied to clipboard

Hardware keypresses does not detectable by other programs

Open kfirfer opened this issue 4 years ago • 7 comments

Disclaimer: I have zero C# knowledge

While I running the program, he somehow remove the capability to recognize key pressed, even physical , with other programs

For example, after running the program, This python standard code doesn't works:

        if keyboard.is_pressed("del"):
            os._exit(1)

'is_pressed' function doesn't care if it came from the physical keyboard nor injected

kfirfer avatar Apr 10 '22 11:04 kfirfer

Yeah, there is a very big issue with the code (mine)

The code currently prevents any other program, which registered a Low level keyboard/mouse hook with SetWindowsHook prior to our program, to recieve any low level mouse/keyboard kernel events

To remedy this, the program not receiving any mouse/keyboard events, must remove their hooks, and then reinstate them (placing their hook procedure before our program in the hook chain)

tldr; the code in this repo should not be used as it is a bit misleading

TetteDev avatar Apr 10 '22 18:04 TetteDev

The reason this happens is this line; https://github.com/Sadulisten/LowLevelMouseHook-Example/blob/master/LLMHREmover/Program.cs#L175

Dont know what I thought when I wrote this, but dereferencing the parameter lParam and passing it back as a pointer to callnexthook makes no sense

TetteDev avatar Apr 10 '22 18:04 TetteDev

If it were to be done properly, it would simply pass the lParam, without doing any stupid stuff, right back into Callnexthook

TetteDev avatar Apr 10 '22 18:04 TetteDev

I have "updated" the code in the repo. Now there shouldn't be any of the previous stupidities mentioned before, code is untested though, so it might not work but in theory it should (hopefully)

Have a good day/night

TetteDev avatar Apr 10 '22 19:04 TetteDev

Thanks for the fast respond !

I succeeded to run your updated code, and the python code works now without a problem

But now its seems other programs can detect if it came from physical/other process

Tested with this repo detector example: https://github.com/errorc0de404/DetectMouseEvents

Wish I could contribute, I just monkey copy pasted =/

kfirfer avatar Apr 10 '22 19:04 kfirfer

Can you try doing these two things;

  1. Start the detector first, and then this program; and report if it works
  2. Start this program first, and then the detector; and report if it works

If neither of these works, then I am afraid this no longer is a viable method for removing llmhf/llkhf flags unfortunately

TetteDev avatar Apr 10 '22 19:04 TetteDev

Tried both situations, also as Administrator but he still detected

Thanks anyway !

kfirfer avatar Apr 10 '22 19:04 kfirfer