C++ hooking winsock

前端 未结 2 945
眼角桃花
眼角桃花 2021-02-03 15:10

I am trying to hook winsock send and recv in order to read all traffic of a process. I am injectin the following code as a dll inside the target process

#include         


        
2条回答
  •  你的背包
    2021-02-03 15:57

    Be sure to use the correct calling convention on your hooked functions. The default calling convention is usually __cdecl. However 'send', and 'recv' use __stdcall (#define WINAPI __stdcall)

    The main difference between the two are:

    When a function uses __cdecl the caller is responsible for stack cleanup. However when a function uses __stdcall the called function is responsible for stack cleanup.

    int WINAPI nSend(SOCKET s, const char *buf, int len,int flags);
    int WINAPI nRecv(SOCKET s, char* buf, int len, int flags)
    

    See here for more information.

提交回复
热议问题