public Int32 MyRecvFrom(IntPtr Socket, IntPtr buffer, Int32 length, SendDataFlags flags, ref SockAddr from, IntPtr fromlen) { // this.HookClient.Log("recvfrom"); return(0); // return recvfrom(Socket, buffer, length, flags, ref from, IntPtr.Zero); }
private Int32 MySendTo(IntPtr Socket, IntPtr buffer, Int32 length, SendDataFlags flags, ref SockAddr To, Int32 tomlen) { // this.HookClient.Log("sendto"); return(0); // return sendto(Socket, buffer, length, flags, ref To, tomlen); }
/* * This is the winsock hook which intercepts the "sendto" method. */ private int SendToHook(IntPtr Socket, IntPtr buff, int len, SendDataFlags flags, ref SockAddr To, int tomlen) { int returnCode = 0; try { returnCode = sendto(Socket, buff, len, flags, ref To, tomlen); if (returnCode == -1) { int errCode = Marshal.GetLastWin32Error(); if (errCode == (int)WSA_ERROR.WSAENOTSOCK) { // swallow the original eeror and spoof a good return code this.handler.OnErrorCaptured(this.applicationName, "sendto", this.processName, errCode); WSASetLastError(0); returnCode = 0; } } } catch (Exception exception) { this.handler.OnError(this.applicationName, this.processName, exception); } return(returnCode); }
public static extern Int32 sendto(IntPtr Socket, IntPtr buffer, Int32 length, SendDataFlags flags, ref SockAddr To, Int32 tomlen);
public static extern Int32 recvfrom(IntPtr Socket, IntPtr buffer, Int32 length, SendDataFlags flags, ref SockAddr from, IntPtr fromlen);
public static extern int sendto(IntPtr Socket, IntPtr buff, int len, SendDataFlags flags, ref SockAddr To, int tomlen);