hi madshi
the code for the receive (recv) i tnink that i understand it fully i have even trying to change two data in the hook without any error occur.
i have tried even another method (overwriting but i don't know why it doesn't work).
i used this method to manage the buffer size.that's means when i change an data with an different string lenght it adjuste the size that why i tried the overwrite method.
i don't know what is bad in this code.
Code: Select all
function recvHookProc(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;
var
DataBuffer: pchar;
begin
result := recvNextHook(s, Buf, len, flags);
GetMem(DataBuffer, Result);
try
//get our copy of the data
CopyMemory(DataBuffer, @Buf, Result);
if result > 0 then begin
i1 := 0;
while true do begin
i1 := PosPchar('helo', @DataBuffer, 4, result, true, i1);
if i1 > 0 then
Move(pchar(string('cool'))^, (pchar(@Buf)+i1)^, result)
else
break;
end;
end;
//overwrite the original data with our new data
CopyMemory(@Buf, DataBuffer, Result);
finally
FreeMem(DataBuffer);
end;
end;
for the receive i think that all my code is fine because i have respected an logical structure.
but i still fails and i don't know what ?
i understand also that i must change data in send before calling the real api function.
but when i try to change it,an error occur inside my hook dll.
i have tested and looked many type of code that i have tried but it doesn't work.
if you can explain what's happen about my code and give me also some hint perhaps i think that i can solve it ? but i am not sure
thank you again
@+