Tomek.Sergey
October 11th, 2005, 05:43 PM
Hi !
I need to replace some fields in the http header in all (http) traffic passing through my PC. I decided to do it via LSP.
The header I want to edit is in the WSPSend function of my LSP.
Here is the func declaration :
int WSPAPI WSPSend (
SOCKET s,
LPWSABUF lpBuffers,
DWORD dwBufferCount,
LPDWORD lpNumberOfBytesSent,
DWORD dwFlags,
LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
LPWSATHREADID lpThreadId,
LPINT lpErrno
)
The data I want to edit is in lpBuffers. The trick is that I don't know how many buffers (dwBufferCount) there can be and who is setting this value. In most cases it's set to 1. It means that we write lpBuffers[0].buf to get to the needed buffer.
When I try JUST to replace let's say the address in HOST field of the http header to the address with the same quantity of letters, then it's OK. Now, let I want to replace the address from 'www.yahoo.com' to 'www.microsoft.com', what should I do ? First I thought I have to free the old buffer (lpBuffers[0].buf) and set to new one, but when I do so, my IE crashes. So maybe I have to alloc new buffer and set its address to lpBuffers[1].buf and its length to lpBuffers[1].len ? Then who will free it ? Do I have to do that or the system ? If this is fault way to solve my task, then how can I do it all ?
I need to replace some fields in the http header in all (http) traffic passing through my PC. I decided to do it via LSP.
The header I want to edit is in the WSPSend function of my LSP.
Here is the func declaration :
int WSPAPI WSPSend (
SOCKET s,
LPWSABUF lpBuffers,
DWORD dwBufferCount,
LPDWORD lpNumberOfBytesSent,
DWORD dwFlags,
LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
LPWSATHREADID lpThreadId,
LPINT lpErrno
)
The data I want to edit is in lpBuffers. The trick is that I don't know how many buffers (dwBufferCount) there can be and who is setting this value. In most cases it's set to 1. It means that we write lpBuffers[0].buf to get to the needed buffer.
When I try JUST to replace let's say the address in HOST field of the http header to the address with the same quantity of letters, then it's OK. Now, let I want to replace the address from 'www.yahoo.com' to 'www.microsoft.com', what should I do ? First I thought I have to free the old buffer (lpBuffers[0].buf) and set to new one, but when I do so, my IE crashes. So maybe I have to alloc new buffer and set its address to lpBuffers[1].buf and its length to lpBuffers[1].len ? Then who will free it ? Do I have to do that or the system ? If this is fault way to solve my task, then how can I do it all ?