Im making an application to manipulate send and recv, doing it with send was very easy but I can't figure how to fake or replace the recv.
What I'm trying to do is for example, if the program receives "Hello"
, filter it and make the program believe it received "Bye"
.
Here is the portion of the code where I try to filter the recv:
int WINAPI MyRecv(SOCKET s, char* buf, int len, int flags)
{
int i = 0;
int ret = pRecv(s, buf, len, flags);
while (i < ret && buf)
{
if (strncmp(buf, "Hello\0", 5) == 0)
{
strcpy(buf,"Bye\0");
}// End of if
int len = strlen(buf) +1;
buf += len;
i += len;
}//End of While
return ret;
}//End of Function
Actually this kind of works, but tries to do it with the next call after it receives "Hello"
and that isn't the intention, I want to replace the actual packet that contains "Hello"
and change it to "Bye"