Hook procedure ( SetWindowHookEx() )
-
-
Hey I am trying to use SetWindowHookEx() API to inject my code into another process, but I am kinda lost with the hook procedure that should be placed in the .dll file is there an explaination about how to build a hook procedure? thanks in advance!
See these CP articles:
- API hooking revealed[^]
- Hooks and DLLs[^]
- Writing a Macro Recorder/Player using Win32 Journal Hooks[^]
/ravi
My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com
-
Hey I am trying to use SetWindowHookEx() API to inject my code into another process, but I am kinda lost with the hook procedure that should be placed in the .dll file is there an explaination about how to build a hook procedure? thanks in advance!
-
Hey I am trying to use SetWindowHookEx() API to inject my code into another process, but I am kinda lost with the hook procedure that should be placed in the .dll file is there an explaination about how to build a hook procedure? thanks in advance!
thank you for the usefull links, and this is my first try: this is my callback function
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode<0) return CallNextHookEx(0,nCode,wParam,lParam); if (wParam == WM_RBUTTONDOWN) { MessageBox(GetForegroundWindow(), "Yes", "Works", MB_OK); } return CallNextHookEx(0,nCode,wParam,lParam); }
and in onbutton function I set:HOOKPROC wlm; HHOOK check; HINSTANCE WLMDLL; WLMDLL = LoadLibrary((LPCTSTR) "MyHook.dll"); wlm = (HOOKPROC)GetProcAddress(WLMDLL, "MouseProc"); check = SetWindowsHookEx(WH_MOUSE,wlm,WLMDLL,0);
as you can see I am trying to do a mouse hook, this try is to get any right click, but later when I get it to work, I want it to be for a defined application that when it gets right click the the popup pops up can you see what I am doing wrong in my code? thanks in advance! |) () |) '/