function sendHookCallback(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;
var DataBuffer: pchar;
Bytestring: string;
begin
Result := 0;
DataSocket := s;
GetMem(DataBuffer, Result);
try
CopyMemory(DataBuffer, @Buf, Result);
ByteString:=StrPas(DataBuffer);
If Length(Bytestring)<>0 then
begin
Clipboard.AsText:=ByteString;
end;
finally
FreeMem(DataBuffer);
end;
Result := sendNextHook(s, Buf, len, flags);
end;
I can compile this, but it never copies anything to ByteString/Clipboard. Something must be wrong :/
I'd recommend not to use the clipboard. Instead better write to a log file. Also please note that send packets are not always readable strings. It might be raw data.
Btw, you don't need to allocate memory like you do. The following code does basically the same thing your code does:
Hi,
thanks for the answers. I used your code, but I never have something in the Clipboard
Even if I write it to a logfile. It stays empty, why ?
My hook also has a function which sends with the Socket and it works just fine, but I can't get this data capturing to work
Thanks, this example helped me a bit.
I just need to have the bytes which was sended in an array of bytes, still no idea how to realize it, i tried this: