easyhook Can I block specific data?

Oct 30, 2013 at 2:56 AM
I would like to filter the data that you specify
int recv_Hooked(IntPtr socketHandle, IntPtr buf, int count, int socketFlags)
        {
            int bufCount = SocketMethod.recv(socketHandle, buf, count, socketFlags);
            if (bufCount>= 12)
            {
                byte[] newBuffer = new byte[bufCount];
                Marshal.Copy(buf, newBuffer, 0, bufCount);
                string ascii = System.Text.ASCIIEncoding.ASCII.GetString(newBuffer);
       
                if(ascii.IndexOf("find data")!=-1)
                {
                     //block packet
                     return 0; //To receive even if this
                 }
            }
            return bufCount;
        }
Tell me please!
Thx
Oct 30, 2013 at 12:04 PM
from MSDN: recv function
If no incoming data is available at the socket, the recv call blocks and waits for data to arrive according to the blocking rules defined for WSARecv with the MSG_PARTIAL flag not set unless the socket is nonblocking. In this case, a value of SOCKET_ERROR is returned with the error code set to WSAEWOULDBLOCK. The select, WSAAsyncSelect, or WSAEventSelect functions can be used to determine when more data arrives.
I guess something like this would work if the socket is blocking:
int recv_Hooked(...) {
    while ( true == ShouldBlockPacket(() => recv_Original(...)) ) { };
    return bufCount;
}
Marked as answer by spazzarama on 2/6/2014 at 7:52 PM
Oct 30, 2013 at 4:09 PM
Thank you so much