How to hook windows'socket functions using SetWindowsHookEx function
-
Please help me! I am writing a small program that I want to uses the Hook function for windows'socket functions like recv, send,... I have tried to uses the function SetWindowsHookEx: HHOOK SetWindowsHookEx( int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId ); But it seems to have too fews argument.It has only 4 arguments: one for the type of hook, one for the address of the function to be hooked, one for the instance that contain the function, one for the thread that the function is running in. I cannot find out where to put the address of the new function that I want to put into the hook chain. Please show me where to put the new function's address, how to uses the SetWindowsHookEx function and how its argument work. Thank you very much!
-
Please help me! I am writing a small program that I want to uses the Hook function for windows'socket functions like recv, send,... I have tried to uses the function SetWindowsHookEx: HHOOK SetWindowsHookEx( int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId ); But it seems to have too fews argument.It has only 4 arguments: one for the type of hook, one for the address of the function to be hooked, one for the instance that contain the function, one for the thread that the function is running in. I cannot find out where to put the address of the new function that I want to put into the hook chain. Please show me where to put the new function's address, how to uses the SetWindowsHookEx function and how its argument work. Thank you very much!
lpfn parameter is the HOOKPROC. you can pass the function handle there. But i think you are trying to do something like sniffing right? Search codeproject for "Sniffer" you will get plenty of tools with source code. SetWindowsHookEx allows us to HOOK these types
WH_CALLWNDPROC Thread or global
WH_CALLWNDPROCRET Thread or global
WH_CBT Thread or global
WH_DEBUG Thread or global
WH_FOREGROUNDIDLE Thread or global
WH_GETMESSAGE Thread or global
WH_JOURNALPLAYBACK Global only
WH_JOURNALRECORD Global only
WH_KEYBOARD Thread or global
WH_KEYBOARD_LL Global only
WH_MOUSE Thread or global
WH_MOUSE_LL Global only
WH_MSGFILTER Thread or global
WH_SHELL Thread or global
WH_SYSMSGFILTER Global onlyAFAIK it is not possible to hook socket using this API. SaRath.
_"It is your attitude, not your aptitude, that determines your altitude - Zig Ziglar."
-
Please help me! I am writing a small program that I want to uses the Hook function for windows'socket functions like recv, send,... I have tried to uses the function SetWindowsHookEx: HHOOK SetWindowsHookEx( int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId ); But it seems to have too fews argument.It has only 4 arguments: one for the type of hook, one for the address of the function to be hooked, one for the instance that contain the function, one for the thread that the function is running in. I cannot find out where to put the address of the new function that I want to put into the hook chain. Please show me where to put the new function's address, how to uses the SetWindowsHookEx function and how its argument work. Thank you very much!
vietth2004 wrote:
how to uses the SetWindowsHookEx function and how its argument work.
See API Hooking Revealed [^]and Hooking the Keyboard [^] maybe it is some helpful to you_**
**_
whitesky
-
Please help me! I am writing a small program that I want to uses the Hook function for windows'socket functions like recv, send,... I have tried to uses the function SetWindowsHookEx: HHOOK SetWindowsHookEx( int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId ); But it seems to have too fews argument.It has only 4 arguments: one for the type of hook, one for the address of the function to be hooked, one for the instance that contain the function, one for the thread that the function is running in. I cannot find out where to put the address of the new function that I want to put into the hook chain. Please show me where to put the new function's address, how to uses the SetWindowsHookEx function and how its argument work. Thank you very much!
You could look at the following http://www.codeproject.com/dll/apihijack.asp[^] which has a simple example showing how to hook API's.
-
You could look at the following http://www.codeproject.com/dll/apihijack.asp[^] which has a simple example showing how to hook API's.
Thank you very much!