我在获取 Microsoft 平台 SDK 提供的示例 LSP 中的 WSPSend 函数中的目标端口号时遇到问题。
这是我正在使用的代码。如下图,不输入if语句。我使用调试功能验证了这一点。
我正在尝试使用目标端口 80 识别此函数内的传出 HTTP 数据包。
int WSPAPI
WSPSend(
SOCKET s,
LPWSABUF lpBuffers,
DWORD dwBufferCount,
LPDWORD lpNumberOfBytesSent,
DWORD dwFlags,
LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
LPWSATHREADID lpThreadId,
LPINT lpErrno
)
{
INT ret = SOCKET_ERROR;
SOCK_INFO *SocketContext = NULL;
LPWSAOVERLAPPEDPLUS ProviderOverlapped = NULL;
*lpErrno = NO_ERROR;
//
// Find our provider socket corresponding to this one
//
SocketContext = FindAndRefSocketContext(s, lpErrno);
if ( NULL == SocketContext )
{
dbgprint( "WSPSend: FindAndRefSocketContext failed!" );
goto cleanup;
}
// My code starts here!!!
SOCKET app = SocketContext->LayeredSocket;
struct sockaddr FAR name;
int FAR namelen;
getpeername(app, &name, &namelen);
struct sockaddr_in sin;
sin =* (const struct sockaddr_in *) (&name);
if(sin.sin_port == htons(80))
{
// This code is not executed after sending HTTP packets!!
}
}
任何想法?