Click to See Complete Forum and Search --> : Replacing HTTP headers with LSP


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 ?

TatMan
October 19th, 2005, 04:23 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 ?
Hi Tomkey,
I just wonder had you got any resolution on your problem.
I am having the same problem.

MikeAThon
October 19th, 2005, 04:42 PM
I think he might have found his answer in the news://alt.winsock.programming newsgroup. It might have been a different person, but the questions and the timing of them are similar:

"LSP - changing outgoing data" at http://groups.google.com/group/alt.winsock.programming/browse_thread/thread/9682c7629569be66/

"Opera, IE and Mozilla as the clients for LSP" at http://groups.google.com/group/alt.winsock.programming/browse_thread/thread/6e9d6f015b30a2fe/

Mike