(Winsock hook) replace/filter packet bytes

11/17/2010 17:03 dream19#1
Hi guys

Please, can someone explain me or help me about my winsock hook?!

I need to change the first and second bytes of the packet I've received...
example:


I'm receiving the packet:

00 01 02 03 04 05 06 07 08 09

I need to change only the first and second byte to:

03 04 02 03 04 05 06 07 08 09

How can I do? :confused:
please help me
11/17/2010 19:18 SmackJew#2
Code:
*packet = 3;
*(packet+1) = 4;
11/17/2010 19:21 dream19#3
Quote:
Originally Posted by SmackJew View Post
Code:
*packet = 3;
*(packet+1) = 4;

Hi,
it's my code in delphi:


Code:
function recvCallBack(s: TSocket; Buf: Pointer; len, flags: Integer): Integer; stdcall;
var
 DataBuffer: pchar;
begin
   GetMem(DataBuffer, len);
   CopyMemory(DataBuffer, @Buf,  len);
   DataBuffer[0] := chr(3); //$03
   DataBuffer[1] := chr(4); //$04
   CopyMemory(@Buf, DataBuffer,  len);

  Result := recvNext(s, Buf, len, flags);
end;
But it's changing ALL bytes of the packet...

What's wrong?



PS: you can post the code in C / C++... then I convert to delphi...
11/18/2010 18:10 hallamasch#4
He already did post the code in C