Making a global hook with this code:
Making segment .data shared and putting it to the DLL. But this doesn't work! What can be wrong?
.data hNextHook Dd 0 .code GetMsgProc Proc Code:DWORD, wParam:DWORD, lParam:DWORD invoke CallNextHookEx, hNextHook, Code, wParam, lParam ret GetMsgProc Endp invoke SetWindowsHookEx, WH_GETMESSAGE, ADDR GetMsgProc, 0, 0 mov hNextHook, eax
how are you setting the hook exactly? where is the dll entry point? you can't just dump code inside a dll.. look at iczelion's tutorials.
All made as it must be. DllMain works perfectly, functions are working, but the hook code is not called. I wrote a code which is in the function(inside a DLL)and which is called from my exe file to set hook. Here it is:
And that's all! I don't understand what can be wrong!!!
HookApps Proc invoke SetWindowsHookEx, WH_GETMESSAGE, ADDR GetMsgProc, 0, 0 mov hNextHook, eax ret HookApps Endp
I think you have to install global hook with this way:
.data dwHinst dword 0 dwHhook dword 0 .code DllMain proc hinst: dword, reason : dword, unused : dword .if reason == DLL_PROCESS_ATTACH push hinst ; <-- pop dwHinst ; <-- .elseif reason == DLL_PROCESS_DETACH invoke UnhookWindowsHookEx, dwHhook .endif mov eax, TRUE ret DllMain endp HookApps Proc invoke SetWindowsHookEx, WH_GETMESSAGE, ADDR GetMsgProc, dwHist, 0 ;look at the third parameter mov dwHhook, eax ret HookApps Endp
Thanx vkim, it worked ;)