开发者

HookProc param - null

I've made a mouse low level hook and it works fine except one problem: the procedure's param.

here's my code: http://pastebin.com/X2198UTb

My HookProc located in the middle of the code under my comment.

Is it a problem or it should be like that? if it should be like that - how can I know which window should get the right click? /// I added a condition to a开发者_运维知识库ctivate the event - right click.


Your code is quite confusing because of the fact that you declared the WH_MOUSE constant to have the value 14. WH_MOUSE actually has the value 7, and 14 is the value of WH_MOUSE_LL (and yes I know you wrote "low level" in your question).

But then you go on by using the WH_MOUSE related types. Specifically, the hook procedure of a WH_MOUSE_LL hook receives a MSLLHOOKSTRUCT structure, not the MOUSEHOOKSTRUCT you're using.

Also, as Hans and Tergiver has hinted, you should pass in the module handle of your own code, not User32.dll. Try using Marshal.GetHINSTANCE(typeof(globalMouse).Module).


This shouldn't even work at all. If you try the same thing (using LoadLibrary("User32") and a thread id of 0) in a pure native app, it will only work for a short while.

Use of a global hook requires a native (no C#) DLL. This is far more complicated than it might seem, especially if you want it to work on 64-bit Windows where you need both a 32- and 64-bit injection DLL as well as 32- and 64-bit injection processes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜