【发布时间】:2011-07-16 07:59:56
【问题描述】:
我正在从我的服务器 (C++) 中连接一些函数。我想挂钩某些功能,以便能够转储数据包,一些客户端发送(连接/断开包)。我已经连接了函数 recv/recvfrom 和 WSARecv/WSARecvFrom。只有 WSARecvFrom 函数被调用(多次),但仅在服务器启动时调用。我必须挂钩哪些功能来查找远程机器的连接/断开连接包?我注意到,在服务器上播放时,这 4 个接收函数永远不会被调用!为什么?
例子:
typedef int (WINAPI *def_recv)(SOCKET s, char* buf, int len, int flags);
def_recv Real_recv;
int WINAPI custom_recv(SOCKET s, char* buf, int len, int flags) {
Log("recv ...");
return Real_recv(s, buf, len, flags);
}
Real_recv = (def_recv)DetourFunction((PBYTE)(DWORD)GetProcAddress(GetModuleHandleA("ws2_32.dll"), "recv"),(PBYTE)&custom_recv);
【问题讨论】:
-
如果是你的服务器和你的代码,为什么还要使用Detours?您大概可以修改您的服务器代码以记录/发送您在真正的 API 调用返回后收到的数据。